├── .clang-format ├── .eslintignore ├── .eslintrc.cjs ├── .gitattributes ├── .github └── workflows │ └── main.yml ├── .gitignore ├── .npmignore ├── .prettierignore ├── .prettierrc ├── .vscode ├── c_cpp_properties.json └── settings.json ├── .yarn └── releases │ └── yarn-4.0.2.cjs ├── .yarnrc.yml ├── CHANGELOG.md ├── LICENSE ├── README.md ├── c ├── interface.c ├── sanitize_test.c └── test.c ├── doc ├── .nojekyll ├── @jitl │ ├── quickjs-asmjs-mjs-release-sync │ │ ├── README.md │ │ └── exports.md │ ├── quickjs-ffi-types │ │ ├── README.md │ │ ├── exports.md │ │ └── interfaces │ │ │ ├── EmscriptenModule.md │ │ │ ├── EmscriptenModuleLoader.md │ │ │ ├── EmscriptenModuleLoaderOptions.md │ │ │ ├── QuickJSAsyncEmscriptenModule.md │ │ │ ├── QuickJSAsyncFFI.md │ │ │ ├── QuickJSAsyncVariant.md │ │ │ ├── QuickJSEmscriptenModule.md │ │ │ ├── QuickJSFFI.md │ │ │ ├── QuickJSSyncVariant.md │ │ │ └── SourceMapData.md │ ├── quickjs-ng-wasmfile-debug-asyncify │ │ ├── README.md │ │ └── exports.md │ ├── quickjs-ng-wasmfile-debug-sync │ │ ├── README.md │ │ └── exports.md │ ├── quickjs-ng-wasmfile-release-asyncify │ │ ├── README.md │ │ └── exports.md │ ├── quickjs-ng-wasmfile-release-sync │ │ ├── README.md │ │ └── exports.md │ ├── quickjs-singlefile-browser-debug-asyncify │ │ ├── README.md │ │ └── exports.md │ ├── quickjs-singlefile-browser-debug-sync │ │ ├── README.md │ │ └── exports.md │ ├── quickjs-singlefile-browser-release-asyncify │ │ ├── README.md │ │ └── exports.md │ ├── quickjs-singlefile-browser-release-sync │ │ ├── README.md │ │ └── exports.md │ ├── quickjs-singlefile-cjs-debug-asyncify │ │ ├── README.md │ │ └── exports.md │ ├── quickjs-singlefile-cjs-debug-sync │ │ ├── README.md │ │ └── exports.md │ ├── quickjs-singlefile-cjs-release-asyncify │ │ ├── README.md │ │ └── exports.md │ ├── quickjs-singlefile-cjs-release-sync │ │ ├── README.md │ │ └── exports.md │ ├── quickjs-singlefile-mjs-debug-asyncify │ │ ├── README.md │ │ └── exports.md │ ├── quickjs-singlefile-mjs-debug-sync │ │ ├── README.md │ │ └── exports.md │ ├── quickjs-singlefile-mjs-release-asyncify │ │ ├── README.md │ │ └── exports.md │ ├── quickjs-singlefile-mjs-release-sync │ │ ├── README.md │ │ └── exports.md │ ├── quickjs-wasmfile-debug-asyncify │ │ ├── README.md │ │ └── exports.md │ ├── quickjs-wasmfile-debug-sync │ │ ├── README.md │ │ └── exports.md │ ├── quickjs-wasmfile-release-asyncify │ │ ├── README.md │ │ └── exports.md │ └── quickjs-wasmfile-release-sync │ │ ├── README.md │ │ └── exports.md ├── README.md ├── packages.md ├── quickjs-emscripten-core │ ├── README.md │ ├── classes │ │ ├── DisposableFail.md │ │ ├── DisposableSuccess.md │ │ ├── Lifetime.md │ │ ├── QuickJSAsyncContext.md │ │ ├── QuickJSAsyncRuntime.md │ │ ├── QuickJSAsyncWASMModule.md │ │ ├── QuickJSContext.md │ │ ├── QuickJSDeferredPromise.md │ │ ├── QuickJSRuntime.md │ │ ├── QuickJSWASMModule.md │ │ ├── Scope.md │ │ ├── StaticLifetime.md │ │ ├── TestQuickJSWASMModule.md │ │ ├── UsingDisposable.md │ │ └── WeakLifetime.md │ ├── exports.md │ ├── interfaces │ │ ├── AsyncRuntimeOptions.md │ │ ├── ContextEvalOptions.md │ │ ├── ContextOptions.md │ │ ├── CustomizeVariantOptions.md │ │ ├── Disposable.md │ │ ├── EmscriptenModule.md │ │ ├── EmscriptenModuleLoader.md │ │ ├── EmscriptenModuleLoaderOptions.md │ │ ├── JSModuleLoader.md │ │ ├── JSModuleLoaderAsync.md │ │ ├── JSModuleNormalizer.md │ │ ├── JSModuleNormalizerAsync.md │ │ ├── JSPromiseStateFulfilled.md │ │ ├── JSPromiseStatePending.md │ │ ├── JSPromiseStateRejected.md │ │ ├── LowLevelJavascriptVm.md │ │ ├── ModuleEvalOptions.md │ │ ├── QuickJSAsyncEmscriptenModule.md │ │ ├── QuickJSAsyncFFI.md │ │ ├── QuickJSAsyncVariant.md │ │ ├── QuickJSEmscriptenModule.md │ │ ├── QuickJSFFI.md │ │ ├── QuickJSSyncVariant.md │ │ ├── RuntimeOptions.md │ │ ├── RuntimeOptionsBase.md │ │ ├── SourceMapData.md │ │ └── VmPropertyDescriptor.md │ └── namespaces │ │ └── errors │ │ ├── README.md │ │ └── classes │ │ ├── QuickJSAsyncifyError.md │ │ ├── QuickJSAsyncifySuspended.md │ │ ├── QuickJSEmptyGetOwnPropertyNames.md │ │ ├── QuickJSEmscriptenModuleError.md │ │ ├── QuickJSMemoryLeakDetected.md │ │ ├── QuickJSNotImplemented.md │ │ ├── QuickJSPromisePending.md │ │ ├── QuickJSUnknownIntrinsic.md │ │ ├── QuickJSUnwrapError.md │ │ ├── QuickJSUseAfterFree.md │ │ └── QuickJSWrongOwner.md └── quickjs-emscripten │ ├── README.md │ ├── classes │ ├── DisposableFail.md │ ├── DisposableSuccess.md │ ├── Lifetime.md │ ├── QuickJSAsyncContext.md │ ├── QuickJSAsyncRuntime.md │ ├── QuickJSAsyncWASMModule.md │ ├── QuickJSContext.md │ ├── QuickJSDeferredPromise.md │ ├── QuickJSRuntime.md │ ├── QuickJSWASMModule.md │ ├── Scope.md │ ├── StaticLifetime.md │ ├── TestQuickJSWASMModule.md │ ├── UsingDisposable.md │ └── WeakLifetime.md │ ├── exports.md │ ├── interfaces │ ├── AsyncRuntimeOptions.md │ ├── ContextEvalOptions.md │ ├── ContextOptions.md │ ├── CustomizeVariantOptions.md │ ├── Disposable.md │ ├── EmscriptenModule.md │ ├── EmscriptenModuleLoader.md │ ├── EmscriptenModuleLoaderOptions.md │ ├── JSModuleLoader.md │ ├── JSModuleLoaderAsync.md │ ├── JSModuleNormalizer.md │ ├── JSModuleNormalizerAsync.md │ ├── JSPromiseStateFulfilled.md │ ├── JSPromiseStatePending.md │ ├── JSPromiseStateRejected.md │ ├── LowLevelJavascriptVm.md │ ├── ModuleEvalOptions.md │ ├── QuickJSAsyncEmscriptenModule.md │ ├── QuickJSAsyncFFI.md │ ├── QuickJSAsyncVariant.md │ ├── QuickJSEmscriptenModule.md │ ├── QuickJSFFI.md │ ├── QuickJSSyncVariant.md │ ├── RuntimeOptions.md │ ├── RuntimeOptionsBase.md │ ├── SourceMapData.md │ └── VmPropertyDescriptor.md │ └── namespaces │ └── errors │ ├── README.md │ └── classes │ ├── QuickJSAsyncifyError.md │ ├── QuickJSAsyncifySuspended.md │ ├── QuickJSEmptyGetOwnPropertyNames.md │ ├── QuickJSEmscriptenModuleError.md │ ├── QuickJSMemoryLeakDetected.md │ ├── QuickJSNotImplemented.md │ ├── QuickJSPromisePending.md │ ├── QuickJSUnknownIntrinsic.md │ ├── QuickJSUnwrapError.md │ ├── QuickJSUseAfterFree.md │ └── QuickJSWrongOwner.md ├── examples ├── bun-typescript │ ├── .gitignore │ ├── .npmrc │ ├── bun.lockb │ ├── index.ts │ ├── package-lock.json │ ├── package.json │ └── tsconfig.json ├── cloudflare-workers │ ├── .editorconfig │ ├── .gitignore │ ├── .prettierrc │ ├── README.md │ ├── copy-wasm-file-into-src.sh │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── DEBUG_SYNC.wasm.map │ │ ├── cloudflare.d.ts │ │ └── index.mts │ ├── tsconfig.json │ └── wrangler.toml ├── create-react-app │ ├── .gitignore │ ├── .npmrc │ ├── README.md │ ├── package-lock.json │ ├── package.json │ ├── public │ │ ├── favicon.ico │ │ ├── index.html │ │ ├── logo192.png │ │ ├── logo512.png │ │ ├── manifest.json │ │ └── robots.txt │ ├── src │ │ ├── App.css │ │ ├── App.test.tsx │ │ ├── App.tsx │ │ ├── index.css │ │ ├── index.tsx │ │ ├── react-app-env.d.ts │ │ ├── serviceWorker.ts │ │ └── setupTests.ts │ └── tsconfig.json ├── deno │ ├── .gitignore │ ├── README.md │ ├── main.ts │ ├── package-lock.json │ └── package.json ├── esmodule.html ├── iife-global.html ├── imports │ ├── cdn.esm.sh │ │ └── v69 │ │ │ ├── react-dom@17.0.2 │ │ │ └── es2015 │ │ │ │ └── server.js │ │ │ └── react@17.0.2 │ │ │ └── es2015 │ │ │ └── react.js │ ├── data.json │ └── esm.sh │ │ ├── react-dom@17 │ │ └── server │ │ └── react@17 ├── node-minimal │ ├── main.mjs │ ├── package-lock.json │ ├── package.json │ └── quickjs.mjs ├── node-typescript │ ├── .gitignore │ ├── .npmrc │ ├── index.ts │ ├── package-lock.json │ ├── package.json │ └── tsconfig.json └── vite-vue │ ├── .gitignore │ ├── .npmrc │ ├── .vscode │ └── extensions.json │ ├── README.md │ ├── index.html │ ├── package-lock.json │ ├── package.json │ ├── public │ └── vite.svg │ ├── src │ ├── App.vue │ ├── assets │ │ └── vue.svg │ ├── components │ │ └── HelloWorld.vue │ ├── main.js │ ├── quickjs.ts │ └── style.css │ └── vite.config.js ├── exportedRuntimeMethods.json ├── package.json ├── packages ├── internal-tsconfig │ ├── .gitignore │ ├── package.json │ ├── tsconfig.json │ ├── tsconfig.tsup.json │ ├── tsup.base.config.ts │ └── vite.base.config.mts ├── quickjs-emscripten-core │ ├── .gitignore │ ├── LICENSE │ ├── README.md │ ├── README.template.md │ ├── package.json │ ├── src │ │ ├── QuickJSIterator.ts │ │ ├── asyncify-helpers.test.ts │ │ ├── asyncify-helpers.ts │ │ ├── context-asyncify.ts │ │ ├── context.ts │ │ ├── debug.ts │ │ ├── deferred-promise.ts │ │ ├── errors.ts │ │ ├── from-variant.ts │ │ ├── index.ts │ │ ├── interrupt-helpers.ts │ │ ├── lifetime.test.ts │ │ ├── lifetime.ts │ │ ├── memory.ts │ │ ├── module-asyncify.ts │ │ ├── module-test.ts │ │ ├── module.ts │ │ ├── runtime-asyncify.ts │ │ ├── runtime.ts │ │ ├── types.ts │ │ └── vm-interface.ts │ ├── tsconfig.build.json │ ├── tsconfig.json │ ├── tsup.config.ts │ ├── typedoc.js │ └── vite.config.mts ├── quickjs-emscripten │ ├── .gitignore │ ├── LICENSE │ ├── makeTestPackageJson.ts │ ├── node.package.json │ ├── package.json │ ├── src │ │ ├── index.ts │ │ ├── leak.test.ts │ │ ├── mod.ts │ │ ├── package.test.ts │ │ ├── quickjs-in-quickjs-node-test.mts │ │ ├── quickjs.test.ts │ │ ├── readme.test.ts │ │ ├── variant-node-test-cjs.cts │ │ ├── variant-node-test-mjs.mts │ │ ├── variant-test-suite.ts │ │ ├── variant-vi-cjs.test.cts │ │ ├── variant-vi-mjs.test.mts │ │ ├── variants.iife.ts │ │ └── variants.ts │ ├── test │ │ └── json-generator-dot-com-1024-rows.json │ ├── tsconfig.build.json │ ├── tsconfig.iife.json │ ├── tsconfig.json │ ├── tsup.config.ts │ ├── typedoc.js │ └── vite.config.mts ├── quickjs-ffi-types │ ├── .gitignore │ ├── LICENSE │ ├── README.md │ ├── package.json │ ├── src │ │ ├── emscripten-types.ts │ │ ├── ffi-async.ts │ │ ├── ffi-types.ts │ │ ├── ffi.ts │ │ ├── index.ts │ │ └── variant-types.ts │ ├── tsconfig.json │ ├── tsup.config.ts │ └── typedoc.js ├── quickjs-for-quickjs │ ├── LICENSE │ ├── README.md │ ├── example │ │ ├── node-host.mjs │ │ └── quickjs-host.mjs │ ├── package.json │ ├── src │ │ └── index.mts │ ├── tsconfig.json │ ├── tsup.config.ts │ └── yodawg.jpg ├── variant-quickjs-asmjs-mjs-release-sync │ ├── LICENSE │ ├── Makefile │ ├── README.md │ ├── package.json │ ├── src │ │ ├── ffi.ts │ │ └── index.ts │ ├── tsconfig.json │ ├── tsup.config.ts │ └── typedoc.json ├── variant-quickjs-ng-wasmfile-debug-asyncify │ ├── LICENSE │ ├── Makefile │ ├── README.md │ ├── package.json │ ├── src │ │ ├── ffi.ts │ │ └── index.ts │ ├── tsconfig.json │ ├── tsup.config.ts │ └── typedoc.json ├── variant-quickjs-ng-wasmfile-debug-sync │ ├── LICENSE │ ├── Makefile │ ├── README.md │ ├── package.json │ ├── src │ │ ├── ffi.ts │ │ └── index.ts │ ├── tsconfig.json │ ├── tsup.config.ts │ └── typedoc.json ├── variant-quickjs-ng-wasmfile-release-asyncify │ ├── LICENSE │ ├── Makefile │ ├── README.md │ ├── package.json │ ├── src │ │ ├── ffi.ts │ │ └── index.ts │ ├── tsconfig.json │ ├── tsup.config.ts │ └── typedoc.json ├── variant-quickjs-ng-wasmfile-release-sync │ ├── LICENSE │ ├── Makefile │ ├── README.md │ ├── package.json │ ├── src │ │ ├── ffi.ts │ │ └── index.ts │ ├── tsconfig.json │ ├── tsup.config.ts │ └── typedoc.json ├── variant-quickjs-singlefile-browser-debug-asyncify │ ├── LICENSE │ ├── Makefile │ ├── README.md │ ├── package.json │ ├── src │ │ ├── ffi.ts │ │ └── index.ts │ ├── tsconfig.json │ ├── tsup.config.ts │ └── typedoc.json ├── variant-quickjs-singlefile-browser-debug-sync │ ├── LICENSE │ ├── Makefile │ ├── README.md │ ├── package.json │ ├── src │ │ ├── ffi.ts │ │ └── index.ts │ ├── tsconfig.json │ ├── tsup.config.ts │ └── typedoc.json ├── variant-quickjs-singlefile-browser-release-asyncify │ ├── LICENSE │ ├── Makefile │ ├── README.md │ ├── package.json │ ├── src │ │ ├── ffi.ts │ │ └── index.ts │ ├── tsconfig.json │ ├── tsup.config.ts │ └── typedoc.json ├── variant-quickjs-singlefile-browser-release-sync │ ├── LICENSE │ ├── Makefile │ ├── README.md │ ├── package.json │ ├── src │ │ ├── ffi.ts │ │ └── index.ts │ ├── tsconfig.json │ ├── tsup.config.ts │ └── typedoc.json ├── variant-quickjs-singlefile-cjs-debug-asyncify │ ├── LICENSE │ ├── Makefile │ ├── README.md │ ├── package.json │ ├── src │ │ ├── ffi.ts │ │ └── index.ts │ ├── tsconfig.json │ ├── tsup.config.ts │ └── typedoc.json ├── variant-quickjs-singlefile-cjs-debug-sync │ ├── LICENSE │ ├── Makefile │ ├── README.md │ ├── package.json │ ├── src │ │ ├── ffi.ts │ │ └── index.ts │ ├── tsconfig.json │ ├── tsup.config.ts │ └── typedoc.json ├── variant-quickjs-singlefile-cjs-release-asyncify │ ├── LICENSE │ ├── Makefile │ ├── README.md │ ├── package.json │ ├── src │ │ ├── ffi.ts │ │ └── index.ts │ ├── tsconfig.json │ ├── tsup.config.ts │ └── typedoc.json ├── variant-quickjs-singlefile-cjs-release-sync │ ├── LICENSE │ ├── Makefile │ ├── README.md │ ├── package.json │ ├── src │ │ ├── ffi.ts │ │ └── index.ts │ ├── tsconfig.json │ ├── tsup.config.ts │ └── typedoc.json ├── variant-quickjs-singlefile-mjs-debug-asyncify │ ├── LICENSE │ ├── Makefile │ ├── README.md │ ├── package.json │ ├── src │ │ ├── ffi.ts │ │ └── index.ts │ ├── tsconfig.json │ ├── tsup.config.ts │ └── typedoc.json ├── variant-quickjs-singlefile-mjs-debug-sync │ ├── LICENSE │ ├── Makefile │ ├── README.md │ ├── package.json │ ├── src │ │ ├── ffi.ts │ │ └── index.ts │ ├── tsconfig.json │ ├── tsup.config.ts │ └── typedoc.json ├── variant-quickjs-singlefile-mjs-release-asyncify │ ├── LICENSE │ ├── Makefile │ ├── README.md │ ├── package.json │ ├── src │ │ ├── ffi.ts │ │ └── index.ts │ ├── tsconfig.json │ ├── tsup.config.ts │ └── typedoc.json ├── variant-quickjs-singlefile-mjs-release-sync │ ├── LICENSE │ ├── Makefile │ ├── README.md │ ├── package.json │ ├── src │ │ ├── ffi.ts │ │ └── index.ts │ ├── tsconfig.json │ ├── tsup.config.ts │ └── typedoc.json ├── variant-quickjs-wasmfile-debug-asyncify │ ├── LICENSE │ ├── Makefile │ ├── README.md │ ├── package.json │ ├── src │ │ ├── ffi.ts │ │ └── index.ts │ ├── tsconfig.json │ ├── tsup.config.ts │ └── typedoc.json ├── variant-quickjs-wasmfile-debug-sync │ ├── LICENSE │ ├── Makefile │ ├── README.md │ ├── package.json │ ├── src │ │ ├── ffi.ts │ │ └── index.ts │ ├── tsconfig.json │ ├── tsup.config.ts │ └── typedoc.json ├── variant-quickjs-wasmfile-release-asyncify │ ├── LICENSE │ ├── Makefile │ ├── README.md │ ├── package.json │ ├── src │ │ ├── ffi.ts │ │ └── index.ts │ ├── tsconfig.json │ ├── tsup.config.ts │ └── typedoc.json └── variant-quickjs-wasmfile-release-sync │ ├── LICENSE │ ├── Makefile │ ├── README.md │ ├── package.json │ ├── src │ ├── ffi.ts │ └── index.ts │ ├── tsconfig.json │ ├── tsup.config.ts │ └── typedoc.json ├── scripts ├── check-packages-built.ts ├── downloadEcmaScriptModules.ts ├── emcc.sh ├── generate.ts ├── helpers.ts ├── prepareVariants.ts ├── set-version.ts ├── smoketest-create-react-app.ts ├── smoketest-deno.ts ├── smoketest-node-minimal.ts ├── smoketest-node.ts └── smoketest-vite.ts ├── templates ├── Variant.mk ├── emscripten-module.ASYNCIFY.d.ts ├── emscripten-module.SYNC.d.ts ├── pre-extension.js ├── pre-sourceMapJson.js ├── pre-wasmMemory.js └── pre-wasmOffsetConverter.js ├── tsconfig.json ├── typedoc.base.js ├── typedoc.js ├── variants.json ├── vendor ├── quickjs-ng │ ├── .github │ │ └── workflows │ │ │ ├── ci.yml │ │ │ └── release.yml │ ├── .gitignore │ ├── .gitmodules │ ├── CMakeLists.txt │ ├── LICENSE │ ├── Makefile │ ├── README.md │ ├── cutils.c │ ├── cutils.h │ ├── dirent_compat.h │ ├── doc │ │ └── quickjs.texi │ ├── examples │ │ ├── fib.c │ │ ├── fib_module.js │ │ ├── hello.js │ │ ├── hello_module.js │ │ ├── pi_bigint.js │ │ ├── point.c │ │ ├── test_fib.js │ │ └── test_point.js │ ├── getopt_compat.h │ ├── libbf.c │ ├── libbf.h │ ├── libregexp-opcode.h │ ├── libregexp.c │ ├── libregexp.h │ ├── libunicode-table.h │ ├── libunicode.c │ ├── libunicode.h │ ├── list.h │ ├── qjs.c │ ├── qjsc.c │ ├── quickjs-atom.h │ ├── quickjs-c-atomics.h │ ├── quickjs-libc.c │ ├── quickjs-libc.h │ ├── quickjs-opcode.h │ ├── quickjs.c │ ├── quickjs.h │ ├── repl.js │ ├── run-test262.c │ ├── test262.conf │ ├── test262_errors.txt │ ├── tests │ │ ├── bjson.c │ │ ├── function_source.js │ │ ├── microbench.js │ │ ├── test262.patch │ │ ├── test_bigint.js │ │ ├── test_bjson.js │ │ ├── test_builtin.js │ │ ├── test_closure.js │ │ ├── test_language.js │ │ ├── test_loop.js │ │ ├── test_queue_microtask.js │ │ ├── test_std.js │ │ ├── test_worker.js │ │ └── test_worker_module.js │ ├── unicode_download.sh │ ├── unicode_gen.c │ ├── unicode_gen_def.h │ ├── v8-tweak.js │ ├── v8.js │ ├── v8.sh │ └── v8.txt ├── quickjs-patches │ └── 0166-webkit-wasm.patch └── quickjs │ ├── .github │ └── workflows │ │ └── ci.yml │ ├── .gitignore │ ├── Changelog │ ├── LICENSE │ ├── Makefile │ ├── TODO │ ├── VERSION │ ├── compat │ └── test-closefrom.c │ ├── cutils.c │ ├── cutils.h │ ├── doc │ ├── jsbignum.texi │ └── quickjs.texi │ ├── examples │ ├── fib.c │ ├── fib_module.js │ ├── hello.js │ ├── hello_module.js │ ├── pi_bigdecimal.js │ ├── pi_bigfloat.js │ ├── pi_bigint.js │ ├── point.c │ ├── test_fib.js │ └── test_point.js │ ├── fuzz │ ├── README │ ├── fuzz.dict │ ├── fuzz_common.c │ ├── fuzz_common.h │ ├── fuzz_compile.c │ ├── fuzz_eval.c │ ├── fuzz_regexp.c │ └── generate_dict.js │ ├── libbf.c │ ├── libbf.h │ ├── libregexp-opcode.h │ ├── libregexp.c │ ├── libregexp.h │ ├── libunicode-table.h │ ├── libunicode.c │ ├── libunicode.h │ ├── list.h │ ├── qjs.c │ ├── qjsc.c │ ├── qjscalc.js │ ├── quickjs-atom.h │ ├── quickjs-libc.c │ ├── quickjs-libc.h │ ├── quickjs-opcode.h │ ├── quickjs.c │ ├── quickjs.h │ ├── readme.txt │ ├── release.sh │ ├── repl.js │ ├── run-test262.c │ ├── test262.conf │ ├── test262_errors.txt │ ├── test262o.conf │ ├── test262o_errors.txt │ ├── tests │ ├── bjson.c │ ├── microbench.js │ ├── test262.patch │ ├── test_bigfloat.js │ ├── test_bignum.js │ ├── test_bjson.js │ ├── test_builtin.js │ ├── test_closure.js │ ├── test_language.js │ ├── test_loop.js │ ├── test_op_overloading.js │ ├── test_qjscalc.js │ ├── test_std.js │ ├── test_worker.js │ └── test_worker_module.js │ ├── unicode_download.sh │ ├── unicode_gen.c │ └── unicode_gen_def.h ├── yarn.lock └── yodawg.jpg /.clang-format: -------------------------------------------------------------------------------- 1 | BasedOnStyle: Google 2 | ColumnLimit: 0 3 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | ts/generated 2 | quickjs 3 | .yarn 4 | doc 5 | json-generator-dot-com-1024-rows.json 6 | dist 7 | examples/imports 8 | examples/create-react-app 9 | examples/node-typescript/*.js 10 | build 11 | emsdk-cache 12 | .output 13 | packages/internal-tsconfig/*.d.*ts 14 | packages/internal-tsconfig/*.*js 15 | packages/variant-*/src/ffi.ts 16 | packages/quickjs-ffi-types/src/ffi*.ts 17 | typedoc.js 18 | typedoc.base.js 19 | vendor 20 | -------------------------------------------------------------------------------- /.eslintrc.cjs: -------------------------------------------------------------------------------- 1 | /* eslint-env node */ 2 | /* @type import("eslint").ESLintConfig */ 3 | module.exports = { 4 | plugins: ["@typescript-eslint", "import"], 5 | extends: [ 6 | "eslint:recommended", 7 | "plugin:@typescript-eslint/recommended", 8 | "plugin:import/typescript", 9 | ], 10 | parser: "@typescript-eslint/parser", 11 | root: true, 12 | rules: { 13 | // Disables 14 | "@typescript-eslint/no-explicit-any": "off", 15 | "no-extra-semi": "off", // covered by prettier 16 | 17 | // Enables 18 | "@typescript-eslint/consistent-type-imports": "error", 19 | "import/order": "error", 20 | "import/no-duplicates": "error", 21 | "import/no-cycle": "error", 22 | "@typescript-eslint/no-unused-vars": [ 23 | "error", 24 | { 25 | varsIgnorePattern: "^_", 26 | argsIgnorePattern: "^_", 27 | destructuredArrayIgnorePattern: "^_", 28 | }, 29 | ], 30 | }, 31 | settings: { 32 | // 'import/resolver': { 33 | // typescript: true, 34 | // node: true, 35 | // } 36 | }, 37 | } 38 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Don't diff generated .emscripten-module files 2 | *.emscripten-module.js -diff 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | yarn-error.log 3 | npm-error.log 4 | 5 | *.tsbuildinfo 6 | .vscode/*.log 7 | 8 | /build 9 | /dist 10 | /emsdk-cache 11 | 12 | /packages/quickjs-emscripten/README.md 13 | 14 | /packages/*/build 15 | /packages/*/dist 16 | 17 | # QuickJS build stuff 18 | /quickjs/test_fib.c 19 | /quickjs/examples/test_fib 20 | /quickjs/.obj/ 21 | /quickjs/examples/hello 22 | /quickjs/examples/hello_module 23 | /quickjs/hello.c 24 | /quickjs/libquickjs.a 25 | /quickjs/libquickjs.lto.a 26 | /quickjs/qjs 27 | /quickjs/qjsc 28 | /quickjs/qjscalc 29 | /quickjs/qjscalc.c 30 | /quickjs/repl.c 31 | /quickjs/run-test262 32 | 33 | .yarn/cache 34 | .yarn/install-state.gz 35 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | *.tsbuildinfo 2 | *.test.js 3 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | ts/generated 2 | quickjs 3 | .yarn 4 | .* 5 | doc 6 | json-generator-dot-com-1024-rows.json 7 | dist 8 | examples/imports 9 | examples/node-typescript/*.js 10 | build 11 | emsdk-cache 12 | .output 13 | packages/internal-tsconfig/*.d.*ts 14 | packages/internal-tsconfig/*.*js 15 | vendor -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "tabWidth": 2, 3 | "useTabs": false, 4 | "printWidth": 100, 5 | "singleQuote": false, 6 | "semi": false 7 | } 8 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "cSpell.words": ["Asyncified", "ASYNCIFY", "chonkers", "JSFFI", "JSWASM", "runtimes"], 3 | "files.associations": { 4 | "cutils.h": "c", 5 | "quickjs.h": "c", 6 | "quickjs-libc.h": "c", 7 | "stdio.h": "c", 8 | "lsan_interface.h": "c", 9 | "math.h": "c", 10 | "stdbool.h": "c", 11 | "emscripten.h": "c", 12 | "quickjs-atom.h": "c" 13 | }, 14 | "files.exclude": { 15 | ".yarn/releases/*": true 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /.yarnrc.yml: -------------------------------------------------------------------------------- 1 | compressionLevel: mixed 2 | 3 | enableGlobalCache: false 4 | 5 | nodeLinker: node-modules 6 | 7 | yarnPath: .yarn/releases/yarn-4.0.2.cjs 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | quickjs-emscripten copyright (c) 2019-2024 Jake Teton-Landis 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /c/sanitize_test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main() { 6 | malloc(5000); 7 | __lsan_do_recoverable_leak_check(); 8 | } -------------------------------------------------------------------------------- /c/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "interface.h" 4 | 5 | /*void eval_and_log(char* code) {*/ 6 | /*char* result = QTS_EvalToJSON(code);*/ 7 | /*fputs("-->\n", stdout);*/ 8 | /*fputs(result, stdout);*/ 9 | /*fputs("<--\n", stdout);*/ 10 | /*}*/ 11 | 12 | int main() { 13 | /*eval_and_log(*/ 14 | /*"\"hello \" + \"world!\""*/ 15 | /*);*/ 16 | /*eval_and_log(*/ 17 | /*"\"hello \" + \"worl"*/ 18 | /*);*/ 19 | 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /doc/.nojekyll: -------------------------------------------------------------------------------- 1 | TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false. -------------------------------------------------------------------------------- /doc/@jitl/quickjs-ffi-types/README.md: -------------------------------------------------------------------------------- 1 | [quickjs-emscripten](../../packages.md) • **@jitl/quickjs-ffi-types** • [Readme](README.md) \| [Exports](exports.md) 2 | 3 | *** 4 | 5 | # @jitl/quickjs-ffi-types 6 | 7 | This is an internal package, part of [quickjs-emscripten](https://github.com/justjake/quickjs-emscripten). 8 | 9 | See the main package for documentation. 10 | 11 | *** 12 | 13 | Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) 14 | -------------------------------------------------------------------------------- /doc/@jitl/quickjs-ffi-types/interfaces/EmscriptenModuleLoader.md: -------------------------------------------------------------------------------- 1 | [quickjs-emscripten](../../../packages.md) • **@jitl/quickjs-ffi-types** • [Readme](../README.md) \| [Exports](../exports.md) 2 | 3 | *** 4 | 5 | [quickjs-emscripten](../../../packages.md) / [@jitl/quickjs-ffi-types](../exports.md) / EmscriptenModuleLoader 6 | 7 | # Interface: EmscriptenModuleLoader()\ 8 | 9 | ## Type parameters 10 | 11 | • **T** extends [`EmscriptenModule`](EmscriptenModule.md) 12 | 13 | > **EmscriptenModuleLoader**(`options`?): `Promise`\<`T`\> 14 | 15 | ## Parameters 16 | 17 | • **options?**: [`EmscriptenModuleLoaderOptions`](EmscriptenModuleLoaderOptions.md) 18 | 19 | ## Returns 20 | 21 | `Promise`\<`T`\> 22 | 23 | ## Source 24 | 25 | [packages/quickjs-ffi-types/src/emscripten-types.ts:249](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-ffi-types/src/emscripten-types.ts#L249) 26 | 27 | *** 28 | 29 | Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) 30 | -------------------------------------------------------------------------------- /doc/@jitl/quickjs-ffi-types/interfaces/SourceMapData.md: -------------------------------------------------------------------------------- 1 | [quickjs-emscripten](../../../packages.md) • **@jitl/quickjs-ffi-types** • [Readme](../README.md) \| [Exports](../exports.md) 2 | 3 | *** 4 | 5 | [quickjs-emscripten](../../../packages.md) / [@jitl/quickjs-ffi-types](../exports.md) / SourceMapData 6 | 7 | # Interface: SourceMapData 8 | 9 | ## Contents 10 | 11 | - [Properties](SourceMapData.md#properties) 12 | - [mappings](SourceMapData.md#mappings) 13 | - [names](SourceMapData.md#names) 14 | - [sources](SourceMapData.md#sources) 15 | - [version](SourceMapData.md#version) 16 | 17 | ## Properties 18 | 19 | ### mappings 20 | 21 | > **mappings**: `string` 22 | 23 | #### Source 24 | 25 | [packages/quickjs-ffi-types/src/emscripten-types.ts:58](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-ffi-types/src/emscripten-types.ts#L58) 26 | 27 | *** 28 | 29 | ### names 30 | 31 | > **names**: `string`[] 32 | 33 | #### Source 34 | 35 | [packages/quickjs-ffi-types/src/emscripten-types.ts:57](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-ffi-types/src/emscripten-types.ts#L57) 36 | 37 | *** 38 | 39 | ### sources 40 | 41 | > **sources**: `string`[] 42 | 43 | #### Source 44 | 45 | [packages/quickjs-ffi-types/src/emscripten-types.ts:56](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-ffi-types/src/emscripten-types.ts#L56) 46 | 47 | *** 48 | 49 | ### version 50 | 51 | > **version**: `number` 52 | 53 | #### Source 54 | 55 | [packages/quickjs-ffi-types/src/emscripten-types.ts:55](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-ffi-types/src/emscripten-types.ts#L55) 56 | 57 | *** 58 | 59 | Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) 60 | -------------------------------------------------------------------------------- /doc/quickjs-emscripten-core/interfaces/ContextOptions.md: -------------------------------------------------------------------------------- 1 | [quickjs-emscripten](../../packages.md) • **quickjs-emscripten-core** • [Readme](../README.md) \| [Exports](../exports.md) 2 | 3 | *** 4 | 5 | [quickjs-emscripten](../../packages.md) / [quickjs-emscripten-core](../exports.md) / ContextOptions 6 | 7 | # Interface: ContextOptions 8 | 9 | Options for creating a [QuickJSContext](../classes/QuickJSContext.md) or [QuickJSAsyncContext](../classes/QuickJSAsyncContext.md) 10 | Pass to [QuickJSRuntime#newContext](../classes/QuickJSRuntime.md#newcontext). 11 | 12 | ## Contents 13 | 14 | - [Properties](ContextOptions.md#properties) 15 | - [intrinsics?](ContextOptions.md#intrinsics) 16 | 17 | ## Properties 18 | 19 | ### intrinsics? 20 | 21 | > **intrinsics**?: [`Intrinsics`](../exports.md#intrinsics) 22 | 23 | What built-in objects and language features to enable? 24 | If unset, the default intrinsics will be used. 25 | To omit all intrinsics, pass an empty array. 26 | 27 | To remove a specific intrinsic, but retain the other defaults, 28 | override it from [DefaultIntrinsics](../exports.md#defaultintrinsics) 29 | ```ts 30 | const contextWithoutDateOrEval = runtime.newContext({ 31 | intrinsics: { 32 | ...DefaultIntrinsics, 33 | Date: false, 34 | } 35 | }) 36 | ``` 37 | 38 | #### Source 39 | 40 | [packages/quickjs-emscripten-core/src/types.ts:229](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/types.ts#L229) 41 | 42 | *** 43 | 44 | Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) 45 | -------------------------------------------------------------------------------- /doc/quickjs-emscripten-core/interfaces/EmscriptenModuleLoader.md: -------------------------------------------------------------------------------- 1 | [quickjs-emscripten](../../packages.md) • **quickjs-emscripten-core** • [Readme](../README.md) \| [Exports](../exports.md) 2 | 3 | *** 4 | 5 | [quickjs-emscripten](../../packages.md) / [quickjs-emscripten-core](../exports.md) / EmscriptenModuleLoader 6 | 7 | # Interface: EmscriptenModuleLoader()\ 8 | 9 | ## Type parameters 10 | 11 | • **T** extends [`EmscriptenModule`](EmscriptenModule.md) 12 | 13 | > **EmscriptenModuleLoader**(`options`?): `Promise`\<`T`\> 14 | 15 | ## Parameters 16 | 17 | • **options?**: [`EmscriptenModuleLoaderOptions`](EmscriptenModuleLoaderOptions.md) 18 | 19 | ## Returns 20 | 21 | `Promise`\<`T`\> 22 | 23 | ## Source 24 | 25 | [packages/quickjs-ffi-types/src/emscripten-types.ts:249](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-ffi-types/src/emscripten-types.ts#L249) 26 | 27 | *** 28 | 29 | Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) 30 | -------------------------------------------------------------------------------- /doc/quickjs-emscripten-core/interfaces/JSModuleLoader.md: -------------------------------------------------------------------------------- 1 | [quickjs-emscripten](../../packages.md) • **quickjs-emscripten-core** • [Readme](../README.md) \| [Exports](../exports.md) 2 | 3 | *** 4 | 5 | [quickjs-emscripten](../../packages.md) / [quickjs-emscripten-core](../exports.md) / JSModuleLoader 6 | 7 | # Interface: JSModuleLoader() 8 | 9 | > **JSModuleLoader**(`moduleName`, `context`): [`JSModuleLoadResult`](../exports.md#jsmoduleloadresult) 10 | 11 | Load module (sync) 12 | 13 | ## Parameters 14 | 15 | • **moduleName**: `string` 16 | 17 | • **context**: [`QuickJSContext`](../classes/QuickJSContext.md) 18 | 19 | ## Returns 20 | 21 | [`JSModuleLoadResult`](../exports.md#jsmoduleloadresult) 22 | 23 | ## Source 24 | 25 | [packages/quickjs-emscripten-core/src/types.ts:83](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/types.ts#L83) 26 | 27 | *** 28 | 29 | Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) 30 | -------------------------------------------------------------------------------- /doc/quickjs-emscripten-core/interfaces/JSModuleLoaderAsync.md: -------------------------------------------------------------------------------- 1 | [quickjs-emscripten](../../packages.md) • **quickjs-emscripten-core** • [Readme](../README.md) \| [Exports](../exports.md) 2 | 3 | *** 4 | 5 | [quickjs-emscripten](../../packages.md) / [quickjs-emscripten-core](../exports.md) / JSModuleLoaderAsync 6 | 7 | # Interface: JSModuleLoaderAsync() 8 | 9 | > **JSModuleLoaderAsync**(`moduleName`, `context`): [`JSModuleLoadResult`](../exports.md#jsmoduleloadresult) \| `Promise`\<[`JSModuleLoadResult`](../exports.md#jsmoduleloadresult)\> 10 | 11 | Load module (async) 12 | 13 | ## Parameters 14 | 15 | • **moduleName**: `string` 16 | 17 | • **context**: [`QuickJSAsyncContext`](../classes/QuickJSAsyncContext.md) 18 | 19 | ## Returns 20 | 21 | [`JSModuleLoadResult`](../exports.md#jsmoduleloadresult) \| `Promise`\<[`JSModuleLoadResult`](../exports.md#jsmoduleloadresult)\> 22 | 23 | ## Source 24 | 25 | [packages/quickjs-emscripten-core/src/types.ts:76](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/types.ts#L76) 26 | 27 | *** 28 | 29 | Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) 30 | -------------------------------------------------------------------------------- /doc/quickjs-emscripten-core/interfaces/JSModuleNormalizerAsync.md: -------------------------------------------------------------------------------- 1 | [quickjs-emscripten](../../packages.md) • **quickjs-emscripten-core** • [Readme](../README.md) \| [Exports](../exports.md) 2 | 3 | *** 4 | 5 | [quickjs-emscripten](../../packages.md) / [quickjs-emscripten-core](../exports.md) / JSModuleNormalizerAsync 6 | 7 | # Interface: JSModuleNormalizerAsync() 8 | 9 | ## Extended By 10 | 11 | - [`JSModuleNormalizer`](JSModuleNormalizer.md) 12 | 13 | > **JSModuleNormalizerAsync**(`baseModuleName`, `requestedName`, `vm`): [`JSModuleNormalizeResult`](../exports.md#jsmodulenormalizeresult) \| `Promise`\<[`JSModuleNormalizeResult`](../exports.md#jsmodulenormalizeresult)\> 14 | 15 | ## Parameters 16 | 17 | • **baseModuleName**: `string` 18 | 19 | • **requestedName**: `string` 20 | 21 | • **vm**: [`QuickJSAsyncContext`](../classes/QuickJSAsyncContext.md) 22 | 23 | ## Returns 24 | 25 | [`JSModuleNormalizeResult`](../exports.md#jsmodulenormalizeresult) \| `Promise`\<[`JSModuleNormalizeResult`](../exports.md#jsmodulenormalizeresult)\> 26 | 27 | ## Source 28 | 29 | [packages/quickjs-emscripten-core/src/types.ts:93](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/types.ts#L93) 30 | 31 | *** 32 | 33 | Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) 34 | -------------------------------------------------------------------------------- /doc/quickjs-emscripten-core/interfaces/JSPromiseStatePending.md: -------------------------------------------------------------------------------- 1 | [quickjs-emscripten](../../packages.md) • **quickjs-emscripten-core** • [Readme](../README.md) \| [Exports](../exports.md) 2 | 3 | *** 4 | 5 | [quickjs-emscripten](../../packages.md) / [quickjs-emscripten-core](../exports.md) / JSPromiseStatePending 6 | 7 | # Interface: JSPromiseStatePending 8 | 9 | Pending promise state. 10 | See [JSPromiseState](../exports.md#jspromisestate). 11 | 12 | ## Contents 13 | 14 | - [Properties](JSPromiseStatePending.md#properties) 15 | - [type](JSPromiseStatePending.md#type) 16 | - [Accessors](JSPromiseStatePending.md#accessors) 17 | - [error](JSPromiseStatePending.md#error) 18 | 19 | ## Properties 20 | 21 | ### type 22 | 23 | > **type**: `"pending"` 24 | 25 | #### Source 26 | 27 | [packages/quickjs-emscripten-core/src/deferred-promise.ts:21](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/deferred-promise.ts#L21) 28 | 29 | ## Accessors 30 | 31 | ### error 32 | 33 | > **`get`** **error**(): `Error` 34 | 35 | The error property here allows unwrapping a JSPromiseState with [QuickJSContext#unwrapResult](../classes/QuickJSContext.md#unwrapresult). 36 | Unwrapping a pending promise will throw a QuickJSPromisePending error. 37 | 38 | #### Returns 39 | 40 | `Error` 41 | 42 | #### Source 43 | 44 | [packages/quickjs-emscripten-core/src/deferred-promise.ts:26](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/deferred-promise.ts#L26) 45 | 46 | *** 47 | 48 | Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) 49 | -------------------------------------------------------------------------------- /doc/quickjs-emscripten-core/interfaces/JSPromiseStateRejected.md: -------------------------------------------------------------------------------- 1 | [quickjs-emscripten](../../packages.md) • **quickjs-emscripten-core** • [Readme](../README.md) \| [Exports](../exports.md) 2 | 3 | *** 4 | 5 | [quickjs-emscripten](../../packages.md) / [quickjs-emscripten-core](../exports.md) / JSPromiseStateRejected 6 | 7 | # Interface: JSPromiseStateRejected 8 | 9 | Rejected promise state. 10 | See [JSPromiseState](../exports.md#jspromisestate). 11 | 12 | ## Contents 13 | 14 | - [Properties](JSPromiseStateRejected.md#properties) 15 | - [error](JSPromiseStateRejected.md#error) 16 | - [type](JSPromiseStateRejected.md#type) 17 | 18 | ## Properties 19 | 20 | ### error 21 | 22 | > **error**: [`QuickJSHandle`](../exports.md#quickjshandle) 23 | 24 | #### Source 25 | 26 | [packages/quickjs-emscripten-core/src/deferred-promise.ts:47](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/deferred-promise.ts#L47) 27 | 28 | *** 29 | 30 | ### type 31 | 32 | > **type**: `"rejected"` 33 | 34 | #### Source 35 | 36 | [packages/quickjs-emscripten-core/src/deferred-promise.ts:46](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/deferred-promise.ts#L46) 37 | 38 | *** 39 | 40 | Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) 41 | -------------------------------------------------------------------------------- /doc/quickjs-emscripten-core/interfaces/SourceMapData.md: -------------------------------------------------------------------------------- 1 | [quickjs-emscripten](../../packages.md) • **quickjs-emscripten-core** • [Readme](../README.md) \| [Exports](../exports.md) 2 | 3 | *** 4 | 5 | [quickjs-emscripten](../../packages.md) / [quickjs-emscripten-core](../exports.md) / SourceMapData 6 | 7 | # Interface: SourceMapData 8 | 9 | ## Contents 10 | 11 | - [Properties](SourceMapData.md#properties) 12 | - [mappings](SourceMapData.md#mappings) 13 | - [names](SourceMapData.md#names) 14 | - [sources](SourceMapData.md#sources) 15 | - [version](SourceMapData.md#version) 16 | 17 | ## Properties 18 | 19 | ### mappings 20 | 21 | > **mappings**: `string` 22 | 23 | #### Source 24 | 25 | [packages/quickjs-ffi-types/src/emscripten-types.ts:58](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-ffi-types/src/emscripten-types.ts#L58) 26 | 27 | *** 28 | 29 | ### names 30 | 31 | > **names**: `string`[] 32 | 33 | #### Source 34 | 35 | [packages/quickjs-ffi-types/src/emscripten-types.ts:57](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-ffi-types/src/emscripten-types.ts#L57) 36 | 37 | *** 38 | 39 | ### sources 40 | 41 | > **sources**: `string`[] 42 | 43 | #### Source 44 | 45 | [packages/quickjs-ffi-types/src/emscripten-types.ts:56](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-ffi-types/src/emscripten-types.ts#L56) 46 | 47 | *** 48 | 49 | ### version 50 | 51 | > **version**: `number` 52 | 53 | #### Source 54 | 55 | [packages/quickjs-ffi-types/src/emscripten-types.ts:55](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-ffi-types/src/emscripten-types.ts#L55) 56 | 57 | *** 58 | 59 | Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) 60 | -------------------------------------------------------------------------------- /doc/quickjs-emscripten-core/namespaces/errors/README.md: -------------------------------------------------------------------------------- 1 | [quickjs-emscripten](../../../packages.md) • **quickjs-emscripten-core** • [Readme](../../README.md) \| [Exports](../../exports.md) 2 | 3 | *** 4 | 5 | [quickjs-emscripten](../../../packages.md) / [quickjs-emscripten-core](../../exports.md) / errors 6 | 7 | # Namespace: errors 8 | 9 | Collects the informative errors this library may throw. 10 | 11 | ## Index 12 | 13 | ### Classes 14 | 15 | - [QuickJSAsyncifyError](classes/QuickJSAsyncifyError.md) 16 | - [QuickJSAsyncifySuspended](classes/QuickJSAsyncifySuspended.md) 17 | - [QuickJSEmptyGetOwnPropertyNames](classes/QuickJSEmptyGetOwnPropertyNames.md) 18 | - [QuickJSEmscriptenModuleError](classes/QuickJSEmscriptenModuleError.md) 19 | - [QuickJSMemoryLeakDetected](classes/QuickJSMemoryLeakDetected.md) 20 | - [QuickJSNotImplemented](classes/QuickJSNotImplemented.md) 21 | - [QuickJSPromisePending](classes/QuickJSPromisePending.md) 22 | - [QuickJSUnknownIntrinsic](classes/QuickJSUnknownIntrinsic.md) 23 | - [QuickJSUnwrapError](classes/QuickJSUnwrapError.md) 24 | - [QuickJSUseAfterFree](classes/QuickJSUseAfterFree.md) 25 | - [QuickJSWrongOwner](classes/QuickJSWrongOwner.md) 26 | 27 | *** 28 | 29 | Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) 30 | -------------------------------------------------------------------------------- /doc/quickjs-emscripten-core/namespaces/errors/classes/QuickJSAsyncifyError.md: -------------------------------------------------------------------------------- 1 | [quickjs-emscripten](../../../../packages.md) • **quickjs-emscripten-core** • [Readme](../../../README.md) \| [Exports](../../../exports.md) 2 | 3 | *** 4 | 5 | [quickjs-emscripten](../../../../packages.md) / [quickjs-emscripten-core](../../../exports.md) / [errors](../README.md) / QuickJSAsyncifyError 6 | 7 | # Class: QuickJSAsyncifyError 8 | 9 | ## Contents 10 | 11 | - [Extends](QuickJSAsyncifyError.md#extends) 12 | - [Constructors](QuickJSAsyncifyError.md#constructors) 13 | - [new QuickJSAsyncifyError(message)](QuickJSAsyncifyError.md#new-quickjsasyncifyerrormessage) 14 | - [Properties](QuickJSAsyncifyError.md#properties) 15 | - [name](QuickJSAsyncifyError.md#name) 16 | 17 | ## Extends 18 | 19 | - `Error` 20 | 21 | ## Constructors 22 | 23 | ### new QuickJSAsyncifyError(message) 24 | 25 | > **new QuickJSAsyncifyError**(`message`?): [`QuickJSAsyncifyError`](QuickJSAsyncifyError.md) 26 | 27 | #### Parameters 28 | 29 | • **message?**: `string` 30 | 31 | #### Returns 32 | 33 | [`QuickJSAsyncifyError`](QuickJSAsyncifyError.md) 34 | 35 | #### Inherited from 36 | 37 | `Error.constructor` 38 | 39 | #### Source 40 | 41 | node\_modules/typescript/lib/lib.es5.d.ts:1081 42 | 43 | ## Properties 44 | 45 | ### name 46 | 47 | > **name**: `string` = `"QuickJSAsyncifyError"` 48 | 49 | #### Overrides 50 | 51 | `Error.name` 52 | 53 | #### Source 54 | 55 | [packages/quickjs-emscripten-core/src/errors.ts:33](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L33) 56 | 57 | *** 58 | 59 | Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) 60 | -------------------------------------------------------------------------------- /doc/quickjs-emscripten-core/namespaces/errors/classes/QuickJSAsyncifySuspended.md: -------------------------------------------------------------------------------- 1 | [quickjs-emscripten](../../../../packages.md) • **quickjs-emscripten-core** • [Readme](../../../README.md) \| [Exports](../../../exports.md) 2 | 3 | *** 4 | 5 | [quickjs-emscripten](../../../../packages.md) / [quickjs-emscripten-core](../../../exports.md) / [errors](../README.md) / QuickJSAsyncifySuspended 6 | 7 | # Class: QuickJSAsyncifySuspended 8 | 9 | ## Contents 10 | 11 | - [Extends](QuickJSAsyncifySuspended.md#extends) 12 | - [Constructors](QuickJSAsyncifySuspended.md#constructors) 13 | - [new QuickJSAsyncifySuspended(message)](QuickJSAsyncifySuspended.md#new-quickjsasyncifysuspendedmessage) 14 | - [Properties](QuickJSAsyncifySuspended.md#properties) 15 | - [name](QuickJSAsyncifySuspended.md#name) 16 | 17 | ## Extends 18 | 19 | - `Error` 20 | 21 | ## Constructors 22 | 23 | ### new QuickJSAsyncifySuspended(message) 24 | 25 | > **new QuickJSAsyncifySuspended**(`message`?): [`QuickJSAsyncifySuspended`](QuickJSAsyncifySuspended.md) 26 | 27 | #### Parameters 28 | 29 | • **message?**: `string` 30 | 31 | #### Returns 32 | 33 | [`QuickJSAsyncifySuspended`](QuickJSAsyncifySuspended.md) 34 | 35 | #### Inherited from 36 | 37 | `Error.constructor` 38 | 39 | #### Source 40 | 41 | node\_modules/typescript/lib/lib.es5.d.ts:1081 42 | 43 | ## Properties 44 | 45 | ### name 46 | 47 | > **name**: `string` = `"QuickJSAsyncifySuspended"` 48 | 49 | #### Overrides 50 | 51 | `Error.name` 52 | 53 | #### Source 54 | 55 | [packages/quickjs-emscripten-core/src/errors.ts:37](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L37) 56 | 57 | *** 58 | 59 | Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) 60 | -------------------------------------------------------------------------------- /doc/quickjs-emscripten-core/namespaces/errors/classes/QuickJSMemoryLeakDetected.md: -------------------------------------------------------------------------------- 1 | [quickjs-emscripten](../../../../packages.md) • **quickjs-emscripten-core** • [Readme](../../../README.md) \| [Exports](../../../exports.md) 2 | 3 | *** 4 | 5 | [quickjs-emscripten](../../../../packages.md) / [quickjs-emscripten-core](../../../exports.md) / [errors](../README.md) / QuickJSMemoryLeakDetected 6 | 7 | # Class: QuickJSMemoryLeakDetected 8 | 9 | ## Contents 10 | 11 | - [Extends](QuickJSMemoryLeakDetected.md#extends) 12 | - [Constructors](QuickJSMemoryLeakDetected.md#constructors) 13 | - [new QuickJSMemoryLeakDetected(message)](QuickJSMemoryLeakDetected.md#new-quickjsmemoryleakdetectedmessage) 14 | - [Properties](QuickJSMemoryLeakDetected.md#properties) 15 | - [name](QuickJSMemoryLeakDetected.md#name) 16 | 17 | ## Extends 18 | 19 | - `Error` 20 | 21 | ## Constructors 22 | 23 | ### new QuickJSMemoryLeakDetected(message) 24 | 25 | > **new QuickJSMemoryLeakDetected**(`message`?): [`QuickJSMemoryLeakDetected`](QuickJSMemoryLeakDetected.md) 26 | 27 | #### Parameters 28 | 29 | • **message?**: `string` 30 | 31 | #### Returns 32 | 33 | [`QuickJSMemoryLeakDetected`](QuickJSMemoryLeakDetected.md) 34 | 35 | #### Inherited from 36 | 37 | `Error.constructor` 38 | 39 | #### Source 40 | 41 | node\_modules/typescript/lib/lib.es5.d.ts:1081 42 | 43 | ## Properties 44 | 45 | ### name 46 | 47 | > **name**: `string` = `"QuickJSMemoryLeakDetected"` 48 | 49 | #### Overrides 50 | 51 | `Error.name` 52 | 53 | #### Source 54 | 55 | [packages/quickjs-emscripten-core/src/errors.ts:41](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L41) 56 | 57 | *** 58 | 59 | Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) 60 | -------------------------------------------------------------------------------- /doc/quickjs-emscripten-core/namespaces/errors/classes/QuickJSNotImplemented.md: -------------------------------------------------------------------------------- 1 | [quickjs-emscripten](../../../../packages.md) • **quickjs-emscripten-core** • [Readme](../../../README.md) \| [Exports](../../../exports.md) 2 | 3 | *** 4 | 5 | [quickjs-emscripten](../../../../packages.md) / [quickjs-emscripten-core](../../../exports.md) / [errors](../README.md) / QuickJSNotImplemented 6 | 7 | # Class: QuickJSNotImplemented 8 | 9 | ## Contents 10 | 11 | - [Extends](QuickJSNotImplemented.md#extends) 12 | - [Constructors](QuickJSNotImplemented.md#constructors) 13 | - [new QuickJSNotImplemented(message)](QuickJSNotImplemented.md#new-quickjsnotimplementedmessage) 14 | - [Properties](QuickJSNotImplemented.md#properties) 15 | - [name](QuickJSNotImplemented.md#name) 16 | 17 | ## Extends 18 | 19 | - `Error` 20 | 21 | ## Constructors 22 | 23 | ### new QuickJSNotImplemented(message) 24 | 25 | > **new QuickJSNotImplemented**(`message`?): [`QuickJSNotImplemented`](QuickJSNotImplemented.md) 26 | 27 | #### Parameters 28 | 29 | • **message?**: `string` 30 | 31 | #### Returns 32 | 33 | [`QuickJSNotImplemented`](QuickJSNotImplemented.md) 34 | 35 | #### Inherited from 36 | 37 | `Error.constructor` 38 | 39 | #### Source 40 | 41 | node\_modules/typescript/lib/lib.es5.d.ts:1081 42 | 43 | ## Properties 44 | 45 | ### name 46 | 47 | > **name**: `string` = `"QuickJSNotImplemented"` 48 | 49 | #### Overrides 50 | 51 | `Error.name` 52 | 53 | #### Source 54 | 55 | [packages/quickjs-emscripten-core/src/errors.ts:29](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L29) 56 | 57 | *** 58 | 59 | Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) 60 | -------------------------------------------------------------------------------- /doc/quickjs-emscripten-core/namespaces/errors/classes/QuickJSPromisePending.md: -------------------------------------------------------------------------------- 1 | [quickjs-emscripten](../../../../packages.md) • **quickjs-emscripten-core** • [Readme](../../../README.md) \| [Exports](../../../exports.md) 2 | 3 | *** 4 | 5 | [quickjs-emscripten](../../../../packages.md) / [quickjs-emscripten-core](../../../exports.md) / [errors](../README.md) / QuickJSPromisePending 6 | 7 | # Class: QuickJSPromisePending 8 | 9 | ## Contents 10 | 11 | - [Extends](QuickJSPromisePending.md#extends) 12 | - [Constructors](QuickJSPromisePending.md#constructors) 13 | - [new QuickJSPromisePending(message)](QuickJSPromisePending.md#new-quickjspromisependingmessage) 14 | - [Properties](QuickJSPromisePending.md#properties) 15 | - [name](QuickJSPromisePending.md#name) 16 | 17 | ## Extends 18 | 19 | - `Error` 20 | 21 | ## Constructors 22 | 23 | ### new QuickJSPromisePending(message) 24 | 25 | > **new QuickJSPromisePending**(`message`?): [`QuickJSPromisePending`](QuickJSPromisePending.md) 26 | 27 | #### Parameters 28 | 29 | • **message?**: `string` 30 | 31 | #### Returns 32 | 33 | [`QuickJSPromisePending`](QuickJSPromisePending.md) 34 | 35 | #### Inherited from 36 | 37 | `Error.constructor` 38 | 39 | #### Source 40 | 41 | node\_modules/typescript/lib/lib.es5.d.ts:1081 42 | 43 | ## Properties 44 | 45 | ### name 46 | 47 | > **name**: `string` = `"QuickJSPromisePending"` 48 | 49 | #### Overrides 50 | 51 | `Error.name` 52 | 53 | #### Source 54 | 55 | [packages/quickjs-emscripten-core/src/errors.ts:53](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L53) 56 | 57 | *** 58 | 59 | Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) 60 | -------------------------------------------------------------------------------- /doc/quickjs-emscripten-core/namespaces/errors/classes/QuickJSUseAfterFree.md: -------------------------------------------------------------------------------- 1 | [quickjs-emscripten](../../../../packages.md) • **quickjs-emscripten-core** • [Readme](../../../README.md) \| [Exports](../../../exports.md) 2 | 3 | *** 4 | 5 | [quickjs-emscripten](../../../../packages.md) / [quickjs-emscripten-core](../../../exports.md) / [errors](../README.md) / QuickJSUseAfterFree 6 | 7 | # Class: QuickJSUseAfterFree 8 | 9 | ## Contents 10 | 11 | - [Extends](QuickJSUseAfterFree.md#extends) 12 | - [Constructors](QuickJSUseAfterFree.md#constructors) 13 | - [new QuickJSUseAfterFree(message)](QuickJSUseAfterFree.md#new-quickjsuseafterfreemessage) 14 | - [Properties](QuickJSUseAfterFree.md#properties) 15 | - [name](QuickJSUseAfterFree.md#name) 16 | 17 | ## Extends 18 | 19 | - `Error` 20 | 21 | ## Constructors 22 | 23 | ### new QuickJSUseAfterFree(message) 24 | 25 | > **new QuickJSUseAfterFree**(`message`?): [`QuickJSUseAfterFree`](QuickJSUseAfterFree.md) 26 | 27 | #### Parameters 28 | 29 | • **message?**: `string` 30 | 31 | #### Returns 32 | 33 | [`QuickJSUseAfterFree`](QuickJSUseAfterFree.md) 34 | 35 | #### Inherited from 36 | 37 | `Error.constructor` 38 | 39 | #### Source 40 | 41 | node\_modules/typescript/lib/lib.es5.d.ts:1081 42 | 43 | ## Properties 44 | 45 | ### name 46 | 47 | > **name**: `string` = `"QuickJSUseAfterFree"` 48 | 49 | #### Overrides 50 | 51 | `Error.name` 52 | 53 | #### Source 54 | 55 | [packages/quickjs-emscripten-core/src/errors.ts:25](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L25) 56 | 57 | *** 58 | 59 | Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) 60 | -------------------------------------------------------------------------------- /doc/quickjs-emscripten-core/namespaces/errors/classes/QuickJSWrongOwner.md: -------------------------------------------------------------------------------- 1 | [quickjs-emscripten](../../../../packages.md) • **quickjs-emscripten-core** • [Readme](../../../README.md) \| [Exports](../../../exports.md) 2 | 3 | *** 4 | 5 | [quickjs-emscripten](../../../../packages.md) / [quickjs-emscripten-core](../../../exports.md) / [errors](../README.md) / QuickJSWrongOwner 6 | 7 | # Class: QuickJSWrongOwner 8 | 9 | ## Contents 10 | 11 | - [Extends](QuickJSWrongOwner.md#extends) 12 | - [Constructors](QuickJSWrongOwner.md#constructors) 13 | - [new QuickJSWrongOwner(message)](QuickJSWrongOwner.md#new-quickjswrongownermessage) 14 | - [Properties](QuickJSWrongOwner.md#properties) 15 | - [name](QuickJSWrongOwner.md#name) 16 | 17 | ## Extends 18 | 19 | - `Error` 20 | 21 | ## Constructors 22 | 23 | ### new QuickJSWrongOwner(message) 24 | 25 | > **new QuickJSWrongOwner**(`message`?): [`QuickJSWrongOwner`](QuickJSWrongOwner.md) 26 | 27 | #### Parameters 28 | 29 | • **message?**: `string` 30 | 31 | #### Returns 32 | 33 | [`QuickJSWrongOwner`](QuickJSWrongOwner.md) 34 | 35 | #### Inherited from 36 | 37 | `Error.constructor` 38 | 39 | #### Source 40 | 41 | node\_modules/typescript/lib/lib.es5.d.ts:1081 42 | 43 | ## Properties 44 | 45 | ### name 46 | 47 | > **name**: `string` = `"QuickJSWrongOwner"` 48 | 49 | #### Overrides 50 | 51 | `Error.name` 52 | 53 | #### Source 54 | 55 | [packages/quickjs-emscripten-core/src/errors.ts:21](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L21) 56 | 57 | *** 58 | 59 | Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) 60 | -------------------------------------------------------------------------------- /doc/quickjs-emscripten/interfaces/ContextOptions.md: -------------------------------------------------------------------------------- 1 | [quickjs-emscripten](../../packages.md) • **quickjs-emscripten** • [Readme](../README.md) \| [Exports](../exports.md) 2 | 3 | *** 4 | 5 | [quickjs-emscripten](../../packages.md) / [quickjs-emscripten](../exports.md) / ContextOptions 6 | 7 | # Interface: ContextOptions 8 | 9 | Options for creating a [QuickJSContext](../classes/QuickJSContext.md) or [QuickJSAsyncContext](../classes/QuickJSAsyncContext.md) 10 | Pass to [QuickJSRuntime#newContext](../classes/QuickJSRuntime.md#newcontext). 11 | 12 | ## Contents 13 | 14 | - [Properties](ContextOptions.md#properties) 15 | - [intrinsics?](ContextOptions.md#intrinsics) 16 | 17 | ## Properties 18 | 19 | ### intrinsics? 20 | 21 | > **intrinsics**?: [`Intrinsics`](../exports.md#intrinsics) 22 | 23 | What built-in objects and language features to enable? 24 | If unset, the default intrinsics will be used. 25 | To omit all intrinsics, pass an empty array. 26 | 27 | To remove a specific intrinsic, but retain the other defaults, 28 | override it from [DefaultIntrinsics](../exports.md#defaultintrinsics) 29 | ```ts 30 | const contextWithoutDateOrEval = runtime.newContext({ 31 | intrinsics: { 32 | ...DefaultIntrinsics, 33 | Date: false, 34 | } 35 | }) 36 | ``` 37 | 38 | #### Source 39 | 40 | [packages/quickjs-emscripten-core/src/types.ts:229](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/types.ts#L229) 41 | 42 | *** 43 | 44 | Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) 45 | -------------------------------------------------------------------------------- /doc/quickjs-emscripten/interfaces/EmscriptenModuleLoader.md: -------------------------------------------------------------------------------- 1 | [quickjs-emscripten](../../packages.md) • **quickjs-emscripten** • [Readme](../README.md) \| [Exports](../exports.md) 2 | 3 | *** 4 | 5 | [quickjs-emscripten](../../packages.md) / [quickjs-emscripten](../exports.md) / EmscriptenModuleLoader 6 | 7 | # Interface: EmscriptenModuleLoader()\ 8 | 9 | ## Type parameters 10 | 11 | • **T** extends [`EmscriptenModule`](EmscriptenModule.md) 12 | 13 | > **EmscriptenModuleLoader**(`options`?): `Promise`\<`T`\> 14 | 15 | ## Parameters 16 | 17 | • **options?**: [`EmscriptenModuleLoaderOptions`](EmscriptenModuleLoaderOptions.md) 18 | 19 | ## Returns 20 | 21 | `Promise`\<`T`\> 22 | 23 | ## Source 24 | 25 | packages/quickjs-ffi-types/dist/index.d.ts:334 26 | 27 | *** 28 | 29 | Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) 30 | -------------------------------------------------------------------------------- /doc/quickjs-emscripten/interfaces/JSModuleLoader.md: -------------------------------------------------------------------------------- 1 | [quickjs-emscripten](../../packages.md) • **quickjs-emscripten** • [Readme](../README.md) \| [Exports](../exports.md) 2 | 3 | *** 4 | 5 | [quickjs-emscripten](../../packages.md) / [quickjs-emscripten](../exports.md) / JSModuleLoader 6 | 7 | # Interface: JSModuleLoader() 8 | 9 | > **JSModuleLoader**(`moduleName`, `context`): [`JSModuleLoadResult`](../exports.md#jsmoduleloadresult) 10 | 11 | Load module (sync) 12 | 13 | ## Parameters 14 | 15 | • **moduleName**: `string` 16 | 17 | • **context**: [`QuickJSContext`](../classes/QuickJSContext.md) 18 | 19 | ## Returns 20 | 21 | [`JSModuleLoadResult`](../exports.md#jsmoduleloadresult) 22 | 23 | ## Source 24 | 25 | [packages/quickjs-emscripten-core/src/types.ts:83](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/types.ts#L83) 26 | 27 | *** 28 | 29 | Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) 30 | -------------------------------------------------------------------------------- /doc/quickjs-emscripten/interfaces/JSModuleLoaderAsync.md: -------------------------------------------------------------------------------- 1 | [quickjs-emscripten](../../packages.md) • **quickjs-emscripten** • [Readme](../README.md) \| [Exports](../exports.md) 2 | 3 | *** 4 | 5 | [quickjs-emscripten](../../packages.md) / [quickjs-emscripten](../exports.md) / JSModuleLoaderAsync 6 | 7 | # Interface: JSModuleLoaderAsync() 8 | 9 | > **JSModuleLoaderAsync**(`moduleName`, `context`): [`JSModuleLoadResult`](../exports.md#jsmoduleloadresult) \| `Promise`\<[`JSModuleLoadResult`](../exports.md#jsmoduleloadresult)\> 10 | 11 | Load module (async) 12 | 13 | ## Parameters 14 | 15 | • **moduleName**: `string` 16 | 17 | • **context**: [`QuickJSAsyncContext`](../classes/QuickJSAsyncContext.md) 18 | 19 | ## Returns 20 | 21 | [`JSModuleLoadResult`](../exports.md#jsmoduleloadresult) \| `Promise`\<[`JSModuleLoadResult`](../exports.md#jsmoduleloadresult)\> 22 | 23 | ## Source 24 | 25 | [packages/quickjs-emscripten-core/src/types.ts:76](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/types.ts#L76) 26 | 27 | *** 28 | 29 | Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) 30 | -------------------------------------------------------------------------------- /doc/quickjs-emscripten/interfaces/JSModuleNormalizerAsync.md: -------------------------------------------------------------------------------- 1 | [quickjs-emscripten](../../packages.md) • **quickjs-emscripten** • [Readme](../README.md) \| [Exports](../exports.md) 2 | 3 | *** 4 | 5 | [quickjs-emscripten](../../packages.md) / [quickjs-emscripten](../exports.md) / JSModuleNormalizerAsync 6 | 7 | # Interface: JSModuleNormalizerAsync() 8 | 9 | ## Extended By 10 | 11 | - [`JSModuleNormalizer`](JSModuleNormalizer.md) 12 | 13 | > **JSModuleNormalizerAsync**(`baseModuleName`, `requestedName`, `vm`): [`JSModuleNormalizeResult`](../exports.md#jsmodulenormalizeresult) \| `Promise`\<[`JSModuleNormalizeResult`](../exports.md#jsmodulenormalizeresult)\> 14 | 15 | ## Parameters 16 | 17 | • **baseModuleName**: `string` 18 | 19 | • **requestedName**: `string` 20 | 21 | • **vm**: [`QuickJSAsyncContext`](../classes/QuickJSAsyncContext.md) 22 | 23 | ## Returns 24 | 25 | [`JSModuleNormalizeResult`](../exports.md#jsmodulenormalizeresult) \| `Promise`\<[`JSModuleNormalizeResult`](../exports.md#jsmodulenormalizeresult)\> 26 | 27 | ## Source 28 | 29 | [packages/quickjs-emscripten-core/src/types.ts:93](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/types.ts#L93) 30 | 31 | *** 32 | 33 | Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) 34 | -------------------------------------------------------------------------------- /doc/quickjs-emscripten/interfaces/JSPromiseStatePending.md: -------------------------------------------------------------------------------- 1 | [quickjs-emscripten](../../packages.md) • **quickjs-emscripten** • [Readme](../README.md) \| [Exports](../exports.md) 2 | 3 | *** 4 | 5 | [quickjs-emscripten](../../packages.md) / [quickjs-emscripten](../exports.md) / JSPromiseStatePending 6 | 7 | # Interface: JSPromiseStatePending 8 | 9 | Pending promise state. 10 | See [JSPromiseState](../exports.md#jspromisestate). 11 | 12 | ## Contents 13 | 14 | - [Properties](JSPromiseStatePending.md#properties) 15 | - [type](JSPromiseStatePending.md#type) 16 | - [Accessors](JSPromiseStatePending.md#accessors) 17 | - [error](JSPromiseStatePending.md#error) 18 | 19 | ## Properties 20 | 21 | ### type 22 | 23 | > **type**: `"pending"` 24 | 25 | #### Source 26 | 27 | [packages/quickjs-emscripten-core/src/deferred-promise.ts:21](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/deferred-promise.ts#L21) 28 | 29 | ## Accessors 30 | 31 | ### error 32 | 33 | > **`get`** **error**(): `Error` 34 | 35 | The error property here allows unwrapping a JSPromiseState with [QuickJSContext#unwrapResult](../classes/QuickJSContext.md#unwrapresult). 36 | Unwrapping a pending promise will throw a QuickJSPromisePending error. 37 | 38 | #### Returns 39 | 40 | `Error` 41 | 42 | #### Source 43 | 44 | [packages/quickjs-emscripten-core/src/deferred-promise.ts:26](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/deferred-promise.ts#L26) 45 | 46 | *** 47 | 48 | Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) 49 | -------------------------------------------------------------------------------- /doc/quickjs-emscripten/interfaces/JSPromiseStateRejected.md: -------------------------------------------------------------------------------- 1 | [quickjs-emscripten](../../packages.md) • **quickjs-emscripten** • [Readme](../README.md) \| [Exports](../exports.md) 2 | 3 | *** 4 | 5 | [quickjs-emscripten](../../packages.md) / [quickjs-emscripten](../exports.md) / JSPromiseStateRejected 6 | 7 | # Interface: JSPromiseStateRejected 8 | 9 | Rejected promise state. 10 | See [JSPromiseState](../exports.md#jspromisestate). 11 | 12 | ## Contents 13 | 14 | - [Properties](JSPromiseStateRejected.md#properties) 15 | - [error](JSPromiseStateRejected.md#error) 16 | - [type](JSPromiseStateRejected.md#type) 17 | 18 | ## Properties 19 | 20 | ### error 21 | 22 | > **error**: [`QuickJSHandle`](../exports.md#quickjshandle) 23 | 24 | #### Source 25 | 26 | [packages/quickjs-emscripten-core/src/deferred-promise.ts:47](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/deferred-promise.ts#L47) 27 | 28 | *** 29 | 30 | ### type 31 | 32 | > **type**: `"rejected"` 33 | 34 | #### Source 35 | 36 | [packages/quickjs-emscripten-core/src/deferred-promise.ts:46](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/deferred-promise.ts#L46) 37 | 38 | *** 39 | 40 | Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) 41 | -------------------------------------------------------------------------------- /doc/quickjs-emscripten/interfaces/SourceMapData.md: -------------------------------------------------------------------------------- 1 | [quickjs-emscripten](../../packages.md) • **quickjs-emscripten** • [Readme](../README.md) \| [Exports](../exports.md) 2 | 3 | *** 4 | 5 | [quickjs-emscripten](../../packages.md) / [quickjs-emscripten](../exports.md) / SourceMapData 6 | 7 | # Interface: SourceMapData 8 | 9 | ## Contents 10 | 11 | - [Properties](SourceMapData.md#properties) 12 | - [mappings](SourceMapData.md#mappings) 13 | - [names](SourceMapData.md#names) 14 | - [sources](SourceMapData.md#sources) 15 | - [version](SourceMapData.md#version) 16 | 17 | ## Properties 18 | 19 | ### mappings 20 | 21 | > **mappings**: `string` 22 | 23 | #### Source 24 | 25 | packages/quickjs-ffi-types/dist/index.d.ts:205 26 | 27 | *** 28 | 29 | ### names 30 | 31 | > **names**: `string`[] 32 | 33 | #### Source 34 | 35 | packages/quickjs-ffi-types/dist/index.d.ts:204 36 | 37 | *** 38 | 39 | ### sources 40 | 41 | > **sources**: `string`[] 42 | 43 | #### Source 44 | 45 | packages/quickjs-ffi-types/dist/index.d.ts:203 46 | 47 | *** 48 | 49 | ### version 50 | 51 | > **version**: `number` 52 | 53 | #### Source 54 | 55 | packages/quickjs-ffi-types/dist/index.d.ts:202 56 | 57 | *** 58 | 59 | Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) 60 | -------------------------------------------------------------------------------- /doc/quickjs-emscripten/namespaces/errors/README.md: -------------------------------------------------------------------------------- 1 | [quickjs-emscripten](../../../packages.md) • **quickjs-emscripten** • [Readme](../../README.md) \| [Exports](../../exports.md) 2 | 3 | *** 4 | 5 | [quickjs-emscripten](../../../packages.md) / [quickjs-emscripten](../../exports.md) / errors 6 | 7 | # Namespace: errors 8 | 9 | Collects the informative errors this library may throw. 10 | 11 | ## Index 12 | 13 | ### Classes 14 | 15 | - [QuickJSAsyncifyError](classes/QuickJSAsyncifyError.md) 16 | - [QuickJSAsyncifySuspended](classes/QuickJSAsyncifySuspended.md) 17 | - [QuickJSEmptyGetOwnPropertyNames](classes/QuickJSEmptyGetOwnPropertyNames.md) 18 | - [QuickJSEmscriptenModuleError](classes/QuickJSEmscriptenModuleError.md) 19 | - [QuickJSMemoryLeakDetected](classes/QuickJSMemoryLeakDetected.md) 20 | - [QuickJSNotImplemented](classes/QuickJSNotImplemented.md) 21 | - [QuickJSPromisePending](classes/QuickJSPromisePending.md) 22 | - [QuickJSUnknownIntrinsic](classes/QuickJSUnknownIntrinsic.md) 23 | - [QuickJSUnwrapError](classes/QuickJSUnwrapError.md) 24 | - [QuickJSUseAfterFree](classes/QuickJSUseAfterFree.md) 25 | - [QuickJSWrongOwner](classes/QuickJSWrongOwner.md) 26 | 27 | *** 28 | 29 | Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) 30 | -------------------------------------------------------------------------------- /doc/quickjs-emscripten/namespaces/errors/classes/QuickJSAsyncifyError.md: -------------------------------------------------------------------------------- 1 | [quickjs-emscripten](../../../../packages.md) • **quickjs-emscripten** • [Readme](../../../README.md) \| [Exports](../../../exports.md) 2 | 3 | *** 4 | 5 | [quickjs-emscripten](../../../../packages.md) / [quickjs-emscripten](../../../exports.md) / [errors](../README.md) / QuickJSAsyncifyError 6 | 7 | # Class: QuickJSAsyncifyError 8 | 9 | ## Contents 10 | 11 | - [Extends](QuickJSAsyncifyError.md#extends) 12 | - [Constructors](QuickJSAsyncifyError.md#constructors) 13 | - [new QuickJSAsyncifyError(message)](QuickJSAsyncifyError.md#new-quickjsasyncifyerrormessage) 14 | - [Properties](QuickJSAsyncifyError.md#properties) 15 | - [name](QuickJSAsyncifyError.md#name) 16 | 17 | ## Extends 18 | 19 | - `Error` 20 | 21 | ## Constructors 22 | 23 | ### new QuickJSAsyncifyError(message) 24 | 25 | > **new QuickJSAsyncifyError**(`message`?): [`QuickJSAsyncifyError`](QuickJSAsyncifyError.md) 26 | 27 | #### Parameters 28 | 29 | • **message?**: `string` 30 | 31 | #### Returns 32 | 33 | [`QuickJSAsyncifyError`](QuickJSAsyncifyError.md) 34 | 35 | #### Inherited from 36 | 37 | `Error.constructor` 38 | 39 | #### Source 40 | 41 | node\_modules/typescript/lib/lib.es5.d.ts:1081 42 | 43 | ## Properties 44 | 45 | ### name 46 | 47 | > **name**: `string` = `"QuickJSAsyncifyError"` 48 | 49 | #### Overrides 50 | 51 | `Error.name` 52 | 53 | #### Source 54 | 55 | [packages/quickjs-emscripten-core/src/errors.ts:33](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L33) 56 | 57 | *** 58 | 59 | Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) 60 | -------------------------------------------------------------------------------- /doc/quickjs-emscripten/namespaces/errors/classes/QuickJSAsyncifySuspended.md: -------------------------------------------------------------------------------- 1 | [quickjs-emscripten](../../../../packages.md) • **quickjs-emscripten** • [Readme](../../../README.md) \| [Exports](../../../exports.md) 2 | 3 | *** 4 | 5 | [quickjs-emscripten](../../../../packages.md) / [quickjs-emscripten](../../../exports.md) / [errors](../README.md) / QuickJSAsyncifySuspended 6 | 7 | # Class: QuickJSAsyncifySuspended 8 | 9 | ## Contents 10 | 11 | - [Extends](QuickJSAsyncifySuspended.md#extends) 12 | - [Constructors](QuickJSAsyncifySuspended.md#constructors) 13 | - [new QuickJSAsyncifySuspended(message)](QuickJSAsyncifySuspended.md#new-quickjsasyncifysuspendedmessage) 14 | - [Properties](QuickJSAsyncifySuspended.md#properties) 15 | - [name](QuickJSAsyncifySuspended.md#name) 16 | 17 | ## Extends 18 | 19 | - `Error` 20 | 21 | ## Constructors 22 | 23 | ### new QuickJSAsyncifySuspended(message) 24 | 25 | > **new QuickJSAsyncifySuspended**(`message`?): [`QuickJSAsyncifySuspended`](QuickJSAsyncifySuspended.md) 26 | 27 | #### Parameters 28 | 29 | • **message?**: `string` 30 | 31 | #### Returns 32 | 33 | [`QuickJSAsyncifySuspended`](QuickJSAsyncifySuspended.md) 34 | 35 | #### Inherited from 36 | 37 | `Error.constructor` 38 | 39 | #### Source 40 | 41 | node\_modules/typescript/lib/lib.es5.d.ts:1081 42 | 43 | ## Properties 44 | 45 | ### name 46 | 47 | > **name**: `string` = `"QuickJSAsyncifySuspended"` 48 | 49 | #### Overrides 50 | 51 | `Error.name` 52 | 53 | #### Source 54 | 55 | [packages/quickjs-emscripten-core/src/errors.ts:37](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L37) 56 | 57 | *** 58 | 59 | Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) 60 | -------------------------------------------------------------------------------- /doc/quickjs-emscripten/namespaces/errors/classes/QuickJSMemoryLeakDetected.md: -------------------------------------------------------------------------------- 1 | [quickjs-emscripten](../../../../packages.md) • **quickjs-emscripten** • [Readme](../../../README.md) \| [Exports](../../../exports.md) 2 | 3 | *** 4 | 5 | [quickjs-emscripten](../../../../packages.md) / [quickjs-emscripten](../../../exports.md) / [errors](../README.md) / QuickJSMemoryLeakDetected 6 | 7 | # Class: QuickJSMemoryLeakDetected 8 | 9 | ## Contents 10 | 11 | - [Extends](QuickJSMemoryLeakDetected.md#extends) 12 | - [Constructors](QuickJSMemoryLeakDetected.md#constructors) 13 | - [new QuickJSMemoryLeakDetected(message)](QuickJSMemoryLeakDetected.md#new-quickjsmemoryleakdetectedmessage) 14 | - [Properties](QuickJSMemoryLeakDetected.md#properties) 15 | - [name](QuickJSMemoryLeakDetected.md#name) 16 | 17 | ## Extends 18 | 19 | - `Error` 20 | 21 | ## Constructors 22 | 23 | ### new QuickJSMemoryLeakDetected(message) 24 | 25 | > **new QuickJSMemoryLeakDetected**(`message`?): [`QuickJSMemoryLeakDetected`](QuickJSMemoryLeakDetected.md) 26 | 27 | #### Parameters 28 | 29 | • **message?**: `string` 30 | 31 | #### Returns 32 | 33 | [`QuickJSMemoryLeakDetected`](QuickJSMemoryLeakDetected.md) 34 | 35 | #### Inherited from 36 | 37 | `Error.constructor` 38 | 39 | #### Source 40 | 41 | node\_modules/typescript/lib/lib.es5.d.ts:1081 42 | 43 | ## Properties 44 | 45 | ### name 46 | 47 | > **name**: `string` = `"QuickJSMemoryLeakDetected"` 48 | 49 | #### Overrides 50 | 51 | `Error.name` 52 | 53 | #### Source 54 | 55 | [packages/quickjs-emscripten-core/src/errors.ts:41](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L41) 56 | 57 | *** 58 | 59 | Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) 60 | -------------------------------------------------------------------------------- /doc/quickjs-emscripten/namespaces/errors/classes/QuickJSNotImplemented.md: -------------------------------------------------------------------------------- 1 | [quickjs-emscripten](../../../../packages.md) • **quickjs-emscripten** • [Readme](../../../README.md) \| [Exports](../../../exports.md) 2 | 3 | *** 4 | 5 | [quickjs-emscripten](../../../../packages.md) / [quickjs-emscripten](../../../exports.md) / [errors](../README.md) / QuickJSNotImplemented 6 | 7 | # Class: QuickJSNotImplemented 8 | 9 | ## Contents 10 | 11 | - [Extends](QuickJSNotImplemented.md#extends) 12 | - [Constructors](QuickJSNotImplemented.md#constructors) 13 | - [new QuickJSNotImplemented(message)](QuickJSNotImplemented.md#new-quickjsnotimplementedmessage) 14 | - [Properties](QuickJSNotImplemented.md#properties) 15 | - [name](QuickJSNotImplemented.md#name) 16 | 17 | ## Extends 18 | 19 | - `Error` 20 | 21 | ## Constructors 22 | 23 | ### new QuickJSNotImplemented(message) 24 | 25 | > **new QuickJSNotImplemented**(`message`?): [`QuickJSNotImplemented`](QuickJSNotImplemented.md) 26 | 27 | #### Parameters 28 | 29 | • **message?**: `string` 30 | 31 | #### Returns 32 | 33 | [`QuickJSNotImplemented`](QuickJSNotImplemented.md) 34 | 35 | #### Inherited from 36 | 37 | `Error.constructor` 38 | 39 | #### Source 40 | 41 | node\_modules/typescript/lib/lib.es5.d.ts:1081 42 | 43 | ## Properties 44 | 45 | ### name 46 | 47 | > **name**: `string` = `"QuickJSNotImplemented"` 48 | 49 | #### Overrides 50 | 51 | `Error.name` 52 | 53 | #### Source 54 | 55 | [packages/quickjs-emscripten-core/src/errors.ts:29](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L29) 56 | 57 | *** 58 | 59 | Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) 60 | -------------------------------------------------------------------------------- /doc/quickjs-emscripten/namespaces/errors/classes/QuickJSPromisePending.md: -------------------------------------------------------------------------------- 1 | [quickjs-emscripten](../../../../packages.md) • **quickjs-emscripten** • [Readme](../../../README.md) \| [Exports](../../../exports.md) 2 | 3 | *** 4 | 5 | [quickjs-emscripten](../../../../packages.md) / [quickjs-emscripten](../../../exports.md) / [errors](../README.md) / QuickJSPromisePending 6 | 7 | # Class: QuickJSPromisePending 8 | 9 | ## Contents 10 | 11 | - [Extends](QuickJSPromisePending.md#extends) 12 | - [Constructors](QuickJSPromisePending.md#constructors) 13 | - [new QuickJSPromisePending(message)](QuickJSPromisePending.md#new-quickjspromisependingmessage) 14 | - [Properties](QuickJSPromisePending.md#properties) 15 | - [name](QuickJSPromisePending.md#name) 16 | 17 | ## Extends 18 | 19 | - `Error` 20 | 21 | ## Constructors 22 | 23 | ### new QuickJSPromisePending(message) 24 | 25 | > **new QuickJSPromisePending**(`message`?): [`QuickJSPromisePending`](QuickJSPromisePending.md) 26 | 27 | #### Parameters 28 | 29 | • **message?**: `string` 30 | 31 | #### Returns 32 | 33 | [`QuickJSPromisePending`](QuickJSPromisePending.md) 34 | 35 | #### Inherited from 36 | 37 | `Error.constructor` 38 | 39 | #### Source 40 | 41 | node\_modules/typescript/lib/lib.es5.d.ts:1081 42 | 43 | ## Properties 44 | 45 | ### name 46 | 47 | > **name**: `string` = `"QuickJSPromisePending"` 48 | 49 | #### Overrides 50 | 51 | `Error.name` 52 | 53 | #### Source 54 | 55 | [packages/quickjs-emscripten-core/src/errors.ts:53](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L53) 56 | 57 | *** 58 | 59 | Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) 60 | -------------------------------------------------------------------------------- /doc/quickjs-emscripten/namespaces/errors/classes/QuickJSUseAfterFree.md: -------------------------------------------------------------------------------- 1 | [quickjs-emscripten](../../../../packages.md) • **quickjs-emscripten** • [Readme](../../../README.md) \| [Exports](../../../exports.md) 2 | 3 | *** 4 | 5 | [quickjs-emscripten](../../../../packages.md) / [quickjs-emscripten](../../../exports.md) / [errors](../README.md) / QuickJSUseAfterFree 6 | 7 | # Class: QuickJSUseAfterFree 8 | 9 | ## Contents 10 | 11 | - [Extends](QuickJSUseAfterFree.md#extends) 12 | - [Constructors](QuickJSUseAfterFree.md#constructors) 13 | - [new QuickJSUseAfterFree(message)](QuickJSUseAfterFree.md#new-quickjsuseafterfreemessage) 14 | - [Properties](QuickJSUseAfterFree.md#properties) 15 | - [name](QuickJSUseAfterFree.md#name) 16 | 17 | ## Extends 18 | 19 | - `Error` 20 | 21 | ## Constructors 22 | 23 | ### new QuickJSUseAfterFree(message) 24 | 25 | > **new QuickJSUseAfterFree**(`message`?): [`QuickJSUseAfterFree`](QuickJSUseAfterFree.md) 26 | 27 | #### Parameters 28 | 29 | • **message?**: `string` 30 | 31 | #### Returns 32 | 33 | [`QuickJSUseAfterFree`](QuickJSUseAfterFree.md) 34 | 35 | #### Inherited from 36 | 37 | `Error.constructor` 38 | 39 | #### Source 40 | 41 | node\_modules/typescript/lib/lib.es5.d.ts:1081 42 | 43 | ## Properties 44 | 45 | ### name 46 | 47 | > **name**: `string` = `"QuickJSUseAfterFree"` 48 | 49 | #### Overrides 50 | 51 | `Error.name` 52 | 53 | #### Source 54 | 55 | [packages/quickjs-emscripten-core/src/errors.ts:25](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L25) 56 | 57 | *** 58 | 59 | Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) 60 | -------------------------------------------------------------------------------- /doc/quickjs-emscripten/namespaces/errors/classes/QuickJSWrongOwner.md: -------------------------------------------------------------------------------- 1 | [quickjs-emscripten](../../../../packages.md) • **quickjs-emscripten** • [Readme](../../../README.md) \| [Exports](../../../exports.md) 2 | 3 | *** 4 | 5 | [quickjs-emscripten](../../../../packages.md) / [quickjs-emscripten](../../../exports.md) / [errors](../README.md) / QuickJSWrongOwner 6 | 7 | # Class: QuickJSWrongOwner 8 | 9 | ## Contents 10 | 11 | - [Extends](QuickJSWrongOwner.md#extends) 12 | - [Constructors](QuickJSWrongOwner.md#constructors) 13 | - [new QuickJSWrongOwner(message)](QuickJSWrongOwner.md#new-quickjswrongownermessage) 14 | - [Properties](QuickJSWrongOwner.md#properties) 15 | - [name](QuickJSWrongOwner.md#name) 16 | 17 | ## Extends 18 | 19 | - `Error` 20 | 21 | ## Constructors 22 | 23 | ### new QuickJSWrongOwner(message) 24 | 25 | > **new QuickJSWrongOwner**(`message`?): [`QuickJSWrongOwner`](QuickJSWrongOwner.md) 26 | 27 | #### Parameters 28 | 29 | • **message?**: `string` 30 | 31 | #### Returns 32 | 33 | [`QuickJSWrongOwner`](QuickJSWrongOwner.md) 34 | 35 | #### Inherited from 36 | 37 | `Error.constructor` 38 | 39 | #### Source 40 | 41 | node\_modules/typescript/lib/lib.es5.d.ts:1081 42 | 43 | ## Properties 44 | 45 | ### name 46 | 47 | > **name**: `string` = `"QuickJSWrongOwner"` 48 | 49 | #### Overrides 50 | 51 | `Error.name` 52 | 53 | #### Source 54 | 55 | [packages/quickjs-emscripten-core/src/errors.ts:21](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L21) 56 | 57 | *** 58 | 59 | Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) 60 | -------------------------------------------------------------------------------- /examples/bun-typescript/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | index.js 3 | -------------------------------------------------------------------------------- /examples/bun-typescript/.npmrc: -------------------------------------------------------------------------------- 1 | audit=false 2 | fund=false 3 | -------------------------------------------------------------------------------- /examples/bun-typescript/bun.lockb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjake/quickjs-emscripten/aa48b619983f02c5691d989c0771a3421178ce4b/examples/bun-typescript/bun.lockb -------------------------------------------------------------------------------- /examples/bun-typescript/index.ts: -------------------------------------------------------------------------------- 1 | import { getQuickJS } from "quickjs-emscripten" 2 | async function main() { 3 | const QuickJS = await getQuickJS() 4 | console.log(QuickJS.evalCode('"QuickJS.evalCode successful"')) 5 | 6 | const vm = QuickJS.newContext() 7 | const memoryUsage = vm.runtime.dumpMemoryUsage() 8 | console.log("Empty VM memory usage:", memoryUsage) 9 | } 10 | main() 11 | -------------------------------------------------------------------------------- /examples/bun-typescript/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "quickjs-emscripten-smoketest", 3 | "version": "1.0.0", 4 | "type": "commonjs", 5 | "main": "index.js", 6 | "license": "MIT", 7 | "dependencies": { 8 | "@jitl/quickjs-ffi-types": "file:../../build/tar/@jitl-quickjs-ffi-types.tgz", 9 | "@jitl/quickjs-wasmfile-debug-asyncify": "file:../../build/tar/@jitl-quickjs-wasmfile-debug-asyncify.tgz", 10 | "@jitl/quickjs-wasmfile-debug-sync": "file:../../build/tar/@jitl-quickjs-wasmfile-debug-sync.tgz", 11 | "@jitl/quickjs-wasmfile-release-asyncify": "file:../../build/tar/@jitl-quickjs-wasmfile-release-asyncify.tgz", 12 | "@jitl/quickjs-wasmfile-release-sync": "file:../../build/tar/@jitl-quickjs-wasmfile-release-sync.tgz", 13 | "quickjs-emscripten": "file:../../build/tar/quickjs-emscripten.tgz", 14 | "quickjs-emscripten-core": "file:../../build/tar/quickjs-emscripten-core.tgz", 15 | "typescript": "5" 16 | }, 17 | "workspaces": [] 18 | } 19 | -------------------------------------------------------------------------------- /examples/bun-typescript/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES6", 4 | "lib": ["ES2015", "DOM"], 5 | "module": "Node16", 6 | "strict": true 7 | }, 8 | "include": ["*.ts"], 9 | "exclude": ["../../node_modules/**/*"] 10 | } 11 | -------------------------------------------------------------------------------- /examples/cloudflare-workers/.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = tab 6 | tab_width = 2 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.yml] 13 | indent_style = space 14 | -------------------------------------------------------------------------------- /examples/cloudflare-workers/.gitignore: -------------------------------------------------------------------------------- 1 | src/*.wasm 2 | src/*.wasm.* 3 | node_modules 4 | .wrangler 5 | -------------------------------------------------------------------------------- /examples/cloudflare-workers/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 140, 3 | "singleQuote": true, 4 | "semi": true, 5 | "useTabs": true 6 | } 7 | -------------------------------------------------------------------------------- /examples/cloudflare-workers/README.md: -------------------------------------------------------------------------------- 1 | # quickjs-emscripten + cloudflare workers 2 | 3 | Cloudflare Workers need some extra setup steps because of the unusual environment and limitations with the bundling defaults, because Cloudflare refuses to let us read these files and compile them from bytes. 4 | 5 | 1. We need to copy the WASM files for the QuickJS variants in use into the `src` directory, so we can import them directly. The script [copy-wasm-file-into-src.sh](./copy-wasm-file-into-src.sh) does this. You should copy it to your project, and run it whenever you update `quickjs-emscripten` to a new version. It will copy the WASM and SourceMap files from `node_modules` into the src directory every time you run it. 6 | - This creates the files `src/DEBUG_SYNC.wasm` and `src/DEBUG_SYNC.wasm.map.txt`. Add them to your .gitignore. 7 | 2. We need to override the normal loading behavior to use the special imported WebAssembly.Module. See [src/index.mts](./src/index.mts). Copy and paste the code in index.mts into your project, or do something similar: 8 | - import the quickjs-emscripten WASM files directly, like `import wasmModule from './DEBUG_SYNC.wasm'`. 9 | - import the quickjs-emscripten SourceMap.txt files directly as well, like `import wasmSourceMapData from './DEBUG_SYNC.wasm.map.txt'`. 10 | - create a new variant using those files: `const cloudflareVariant = newVariant(DEBUG_SYNC, { wasmModule, wasmSourceMapData })`. 11 | - Instead of using `await getQuickJS()`, use `newQuickJSWASMModule(cloudflareVariant)`. 12 | -------------------------------------------------------------------------------- /examples/cloudflare-workers/copy-wasm-file-into-src.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # quickjs-emscripten exposes an export for the .wasm file, but Cloudflare refuses to accept it. 4 | # Cloudflare's build system only allows importing .wasm files using a relative path. 5 | # Github issue: https://github.com/cloudflare/workers-sdk/issues/1672 6 | # 7 | # Instead the easy way out is to just copy the .wasm files we need into the build directory. 8 | # Once there, we can import them and use them to make a new quickjs variant. 9 | # 10 | 11 | set -eo pipefail 12 | 13 | VARIANTS=( 14 | DEBUG_SYNC 15 | RELEASE_SYNC 16 | ) 17 | 18 | for VARIANT in "${VARIANTS[@]}"; do 19 | kebab="$(echo "$VARIANT" | tr '[:upper:]' '[:lower:]' | tr '_' '-')" 20 | WASM_FILE="$(node -p 'require.resolve("@jitl/quickjs-wasmfile-'$kebab'/wasm")')" 21 | cp -v "$WASM_FILE" src/$VARIANT.wasm 22 | if [[ -f "$WASM_FILE.map" ]]; then 23 | cp -v "$WASM_FILE.map" src/$VARIANT.wasm.map.txt 24 | fi 25 | done 26 | -------------------------------------------------------------------------------- /examples/cloudflare-workers/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "raspy-glade-9e89", 3 | "version": "0.0.0", 4 | "private": true, 5 | "scripts": { 6 | "deploy": "./copy-wasm-file-into-src.sh && wrangler deploy", 7 | "dev": "./copy-wasm-file-into-src.sh && wrangler dev", 8 | "start": "wrangler dev" 9 | }, 10 | "devDependencies": { 11 | "@cloudflare/workers-types": "^4.20231218.0", 12 | "typescript": "^5.0.4", 13 | "wrangler": "^3.0.0" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /examples/cloudflare-workers/src/cloudflare.d.ts: -------------------------------------------------------------------------------- 1 | declare module '*.wasm' { 2 | export default WebAssembly.Module; 3 | } 4 | 5 | declare module '*.txt' { 6 | export default string; 7 | } 8 | -------------------------------------------------------------------------------- /examples/cloudflare-workers/src/index.mts: -------------------------------------------------------------------------------- 1 | /** 2 | * Welcome to Cloudflare Workers! This is your first worker. 3 | * 4 | * - Run `npm run dev` in your terminal to start a development server 5 | * - Open a browser tab at http://localhost:8787/ to see your worker in action 6 | * - Run `npm run deploy` to publish your worker 7 | * 8 | * Learn more at https://developers.cloudflare.com/workers/ 9 | */ 10 | 11 | import type { QuickJSWASMModule } from 'quickjs-emscripten'; 12 | import { newQuickJSWASMModule, DEBUG_SYNC as baseVariant, newVariant } from 'quickjs-emscripten'; 13 | import cloudflareWasmModule from './DEBUG_SYNC.wasm'; 14 | import cloudflareWasmModuleSourceMap from './DEBUG_SYNC.wasm.map.txt'; 15 | 16 | /** 17 | * We need to make a new variant that directly passes the imported WebAssembly.Module 18 | * to Emscripten. Normally we'd load the wasm file as bytes from a URL, but 19 | * that's forbidden in Cloudflare workers. 20 | */ 21 | const cloudflareVariant = newVariant(baseVariant, { 22 | wasmModule: cloudflareWasmModule, 23 | wasmSourceMapData: cloudflareWasmModuleSourceMap, 24 | }); 25 | 26 | export interface Env { 27 | // Example binding to KV. Learn more at https://developers.cloudflare.com/workers/runtime-apis/kv/ 28 | // MY_KV_NAMESPACE: KVNamespace; 29 | } 30 | 31 | let QuickJS: QuickJSWASMModule | undefined; 32 | 33 | export default { 34 | async fetch(_request: Request, _env: Env, _ctx: ExecutionContext): Promise { 35 | QuickJS ??= await newQuickJSWASMModule(cloudflareVariant); 36 | const url = new URL(_request.url); 37 | const code = url.searchParams.get('code') ?? '"Set ?code= to a JS expression to eval"'; 38 | const result = QuickJS.evalCode(code); 39 | return new Response(JSON.stringify({ code, result })); 40 | }, 41 | }; 42 | -------------------------------------------------------------------------------- /examples/cloudflare-workers/wrangler.toml: -------------------------------------------------------------------------------- 1 | name = "cloudflare-workers-example" 2 | main = "src/index.mts" 3 | compatibility_date = "2023-12-18" 4 | 5 | -------------------------------------------------------------------------------- /examples/create-react-app/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /examples/create-react-app/.npmrc: -------------------------------------------------------------------------------- 1 | audit=false 2 | fund=false 3 | -------------------------------------------------------------------------------- /examples/create-react-app/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "website", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@jitl/quickjs-ffi-types": "file:../../build/tar/@jitl-quickjs-ffi-types.tgz", 7 | "@jitl/quickjs-wasmfile-debug-asyncify": "file:../../build/tar/@jitl-quickjs-wasmfile-debug-asyncify.tgz", 8 | "@jitl/quickjs-wasmfile-debug-sync": "file:../../build/tar/@jitl-quickjs-wasmfile-debug-sync.tgz", 9 | "@jitl/quickjs-wasmfile-release-asyncify": "file:../../build/tar/@jitl-quickjs-wasmfile-release-asyncify.tgz", 10 | "@jitl/quickjs-wasmfile-release-sync": "file:../../build/tar/@jitl-quickjs-wasmfile-release-sync.tgz", 11 | "@testing-library/jest-dom": "^4.2.4", 12 | "@testing-library/react": "^9.3.2", 13 | "@testing-library/user-event": "^7.1.2", 14 | "@types/jest": "^24.0.0", 15 | "@types/node": "^16.0.0", 16 | "@types/react": "^16.9.0", 17 | "@types/react-dom": "^16.9.0", 18 | "quickjs-emscripten": "file:../../build/tar/quickjs-emscripten.tgz", 19 | "quickjs-emscripten-core": "file:../../build/tar/quickjs-emscripten-core.tgz", 20 | "react": "^16.13.1", 21 | "react-dom": "^16.13.1", 22 | "react-scripts": "^5.0", 23 | "typescript": "4.5" 24 | }, 25 | "scripts": { 26 | "start": "react-scripts start", 27 | "build": "react-scripts build", 28 | "test": "react-scripts test", 29 | "eject": "react-scripts eject" 30 | }, 31 | "eslintConfig": { 32 | "extends": "react-app" 33 | }, 34 | "browserslist": { 35 | "production": [ 36 | ">0.2%", 37 | "not dead", 38 | "not op_mini all" 39 | ], 40 | "development": [ 41 | "last 1 chrome version", 42 | "last 1 firefox version", 43 | "last 1 safari version" 44 | ] 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /examples/create-react-app/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjake/quickjs-emscripten/aa48b619983f02c5691d989c0771a3421178ce4b/examples/create-react-app/public/favicon.ico -------------------------------------------------------------------------------- /examples/create-react-app/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjake/quickjs-emscripten/aa48b619983f02c5691d989c0771a3421178ce4b/examples/create-react-app/public/logo192.png -------------------------------------------------------------------------------- /examples/create-react-app/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjake/quickjs-emscripten/aa48b619983f02c5691d989c0771a3421178ce4b/examples/create-react-app/public/logo512.png -------------------------------------------------------------------------------- /examples/create-react-app/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /examples/create-react-app/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /examples/create-react-app/src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | max-width: 756px; 3 | margin: 1em auto; 4 | padding: 1em; 5 | } 6 | 7 | textarea, 8 | input, 9 | pre { 10 | border: 1px solid #aaa; 11 | border-radius: 2px; 12 | padding: 0.75em; 13 | min-width: 100%; 14 | min-height: 5em; 15 | margin-top: 1em; 16 | box-shadow: 0px 0.25em 1.5em rgba(0, 0, 0, 0.07); 17 | } 18 | -------------------------------------------------------------------------------- /examples/create-react-app/src/App.test.tsx: -------------------------------------------------------------------------------- 1 | import React from "react" 2 | import { render } from "@testing-library/react" 3 | import App from "./App" 4 | 5 | test("renders something", () => { 6 | const { getByText } = render() 7 | const linkElement = getByText(/QuickJS/) 8 | expect(linkElement).toBeInTheDocument() 9 | }) 10 | -------------------------------------------------------------------------------- /examples/create-react-app/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", 4 | "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif; 5 | -webkit-font-smoothing: antialiased; 6 | -moz-osx-font-smoothing: grayscale; 7 | } 8 | -------------------------------------------------------------------------------- /examples/create-react-app/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from "react" 2 | import ReactDOM from "react-dom" 3 | import "./index.css" 4 | import App from "./App" 5 | import * as serviceWorker from "./serviceWorker" 6 | 7 | ReactDOM.render( 8 | 9 | 10 | , 11 | document.getElementById("root"), 12 | ) 13 | 14 | // If you want your app to work offline and load faster, you can change 15 | // unregister() to register() below. Note this comes with some pitfalls. 16 | // Learn more about service workers: https://bit.ly/CRA-PWA 17 | serviceWorker.unregister() 18 | -------------------------------------------------------------------------------- /examples/create-react-app/src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /examples/create-react-app/src/setupTests.ts: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import "@testing-library/jest-dom/extend-expect" 6 | -------------------------------------------------------------------------------- /examples/create-react-app/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": ["dom", "dom.iterable", "esnext"], 5 | "allowJs": true, 6 | "skipLibCheck": true, 7 | "esModuleInterop": true, 8 | "allowSyntheticDefaultImports": true, 9 | "strict": true, 10 | "forceConsistentCasingInFileNames": true, 11 | "module": "esnext", 12 | "moduleResolution": "node", 13 | "resolveJsonModule": true, 14 | "isolatedModules": true, 15 | "noEmit": true, 16 | "jsx": "react-jsx", 17 | "noFallthroughCasesInSwitch": true 18 | }, 19 | "include": ["src"] 20 | } 21 | -------------------------------------------------------------------------------- /examples/deno/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /examples/deno/README.md: -------------------------------------------------------------------------------- 1 | # deno + quickjs-emscripten 2 | 3 | Deno's support for NPM specifiers makes it easy to use quickjs-emscripten these days. 4 | 5 | Just add an `import { ...} from 'npm:quickjs-emscripten@0.25.0'` (or any other semver range), it works just fine. 6 | -------------------------------------------------------------------------------- /examples/deno/main.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S deno run --allow-read --unstable-byonm 2 | import { getQuickJS } from "npm:quickjs-emscripten" 3 | const QuickJS = await getQuickJS() 4 | console.log(QuickJS.evalCode("1+1")) 5 | -------------------------------------------------------------------------------- /examples/deno/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "@jitl/quickjs-ffi-types": "file:../../build/tar/@jitl-quickjs-ffi-types.tgz", 4 | "@jitl/quickjs-wasmfile-debug-asyncify": "file:../../build/tar/@jitl-quickjs-wasmfile-debug-asyncify.tgz", 5 | "@jitl/quickjs-wasmfile-debug-sync": "file:../../build/tar/@jitl-quickjs-wasmfile-debug-sync.tgz", 6 | "@jitl/quickjs-wasmfile-release-asyncify": "file:../../build/tar/@jitl-quickjs-wasmfile-release-asyncify.tgz", 7 | "@jitl/quickjs-wasmfile-release-sync": "file:../../build/tar/@jitl-quickjs-wasmfile-release-sync.tgz", 8 | "quickjs-emscripten": "file:../../build/tar/quickjs-emscripten.tgz", 9 | "quickjs-emscripten-core": "file:../../build/tar/quickjs-emscripten-core.tgz" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /examples/esmodule.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ES Module with esm.sh 7 | 8 | 9 | Open your console 10 | 11 | 12 | 13 | 18 | 19 | -------------------------------------------------------------------------------- /examples/iife-global.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | IIFE Global example 7 | 8 | 9 | Open your console 10 | 11 | 12 | 16 | 17 | 22 | 23 | -------------------------------------------------------------------------------- /examples/imports/data.json: -------------------------------------------------------------------------------- 1 | ["very", "useful", "data"] 2 | -------------------------------------------------------------------------------- /examples/imports/esm.sh/react-dom@17/server: -------------------------------------------------------------------------------- 1 | /* esm.sh - react-dom@17.0.2/server */ 2 | export * from "../../cdn.esm.sh/v69/react-dom@17.0.2/es2015/server.js"; 3 | export { default } from "../../cdn.esm.sh/v69/react-dom@17.0.2/es2015/server.js"; 4 | -------------------------------------------------------------------------------- /examples/imports/esm.sh/react@17: -------------------------------------------------------------------------------- 1 | /* esm.sh - react@17.0.2 */ 2 | export * from "../cdn.esm.sh/v69/react@17.0.2/es2015/react.js"; 3 | export { default } from "../cdn.esm.sh/v69/react@17.0.2/es2015/react.js"; 4 | -------------------------------------------------------------------------------- /examples/node-minimal/main.mjs: -------------------------------------------------------------------------------- 1 | import { QuickJS } from "./quickjs.mjs" 2 | console.log(QuickJS.evalCode("1 + 1")) 3 | -------------------------------------------------------------------------------- /examples/node-minimal/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "quickjs-emscripten-minimal-smoketest", 3 | "version": "1.0.0", 4 | "lockfileVersion": 3, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "quickjs-emscripten-minimal-smoketest", 9 | "version": "1.0.0", 10 | "license": "MIT", 11 | "dependencies": { 12 | "@jitl/quickjs-ffi-types": "file:../../build/tar/@jitl-quickjs-ffi-types.tgz", 13 | "@jitl/quickjs-wasmfile-release-sync": "file:../../build/tar/@jitl-quickjs-wasmfile-release-sync.tgz", 14 | "quickjs-emscripten-core": "file:../../build/tar/quickjs-emscripten-core.tgz" 15 | } 16 | }, 17 | "node_modules/@jitl/quickjs-ffi-types": { 18 | "version": "0.27.0", 19 | "resolved": "file:../../build/tar/@jitl-quickjs-ffi-types.tgz", 20 | "integrity": "sha512-MWO0SgqjdisTkhm4h/dT2roTXqNdoJvi6THgizPP1tpzOxEmhI9qbQX7C26MDZFoj4rG/9Scqnt82ZWmB/GY3g==" 21 | }, 22 | "node_modules/@jitl/quickjs-wasmfile-release-sync": { 23 | "version": "0.27.0", 24 | "resolved": "file:../../build/tar/@jitl-quickjs-wasmfile-release-sync.tgz", 25 | "integrity": "sha512-8YxCA85he2ZXE83W2r7sHGgNr/A6bA58xhwltpv94EvD060UbQJz6WzKeFrHj+nwyTDsQ/eJNUT1wflneiUFHw==", 26 | "dependencies": { 27 | "@jitl/quickjs-ffi-types": "0.27.0" 28 | } 29 | }, 30 | "node_modules/quickjs-emscripten-core": { 31 | "version": "0.27.0", 32 | "resolved": "file:../../build/tar/quickjs-emscripten-core.tgz", 33 | "integrity": "sha512-rjxkeWBcwAVav8vR0o+ome+LDI8+v5pY93PZpBXS+1vf5Z8mN0mOR7t2YHDDxhc5b/albeF9FpDZDytoXh0RJQ==", 34 | "license": "MIT", 35 | "dependencies": { 36 | "@jitl/quickjs-ffi-types": "0.27.0" 37 | } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /examples/node-minimal/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "quickjs-emscripten-minimal-smoketest", 3 | "version": "1.0.0", 4 | "type": "commonjs", 5 | "main": "main.mjs", 6 | "license": "MIT", 7 | "private": true, 8 | "scripts": { 9 | "start": "node ./main.mjs" 10 | }, 11 | "dependencies": { 12 | "@jitl/quickjs-ffi-types": "file:../../build/tar/@jitl-quickjs-ffi-types.tgz", 13 | "@jitl/quickjs-wasmfile-release-sync": "file:../../build/tar/@jitl-quickjs-wasmfile-release-sync.tgz", 14 | "quickjs-emscripten-core": "file:../../build/tar/quickjs-emscripten-core.tgz" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /examples/node-minimal/quickjs.mjs: -------------------------------------------------------------------------------- 1 | import { newQuickJSWASMModuleFromVariant } from "quickjs-emscripten-core" 2 | import RELEASE_SYNC from "@jitl/quickjs-wasmfile-release-sync" 3 | 4 | /** 5 | * Export the QuickJSWASMModule instance as a singleton. 6 | */ 7 | export const QuickJS = await newQuickJSWASMModuleFromVariant(RELEASE_SYNC) 8 | -------------------------------------------------------------------------------- /examples/node-typescript/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | index.js 3 | -------------------------------------------------------------------------------- /examples/node-typescript/.npmrc: -------------------------------------------------------------------------------- 1 | audit=false 2 | fund=false 3 | -------------------------------------------------------------------------------- /examples/node-typescript/index.ts: -------------------------------------------------------------------------------- 1 | import { getQuickJS } from "quickjs-emscripten" 2 | async function main() { 3 | const QuickJS = await getQuickJS() 4 | console.log(QuickJS.evalCode('"QuickJS.evalCode successful"')) 5 | 6 | const vm = QuickJS.newContext() 7 | const memoryUsage = vm.runtime.dumpMemoryUsage() 8 | console.log("Empty VM memory usage:", memoryUsage) 9 | } 10 | main() 11 | -------------------------------------------------------------------------------- /examples/node-typescript/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "quickjs-emscripten-smoketest", 3 | "version": "1.0.0", 4 | "type": "commonjs", 5 | "main": "index.js", 6 | "license": "MIT", 7 | "dependencies": { 8 | "@jitl/quickjs-ffi-types": "file:../../build/tar/@jitl-quickjs-ffi-types.tgz", 9 | "@jitl/quickjs-wasmfile-debug-asyncify": "file:../../build/tar/@jitl-quickjs-wasmfile-debug-asyncify.tgz", 10 | "@jitl/quickjs-wasmfile-debug-sync": "file:../../build/tar/@jitl-quickjs-wasmfile-debug-sync.tgz", 11 | "@jitl/quickjs-wasmfile-release-asyncify": "file:../../build/tar/@jitl-quickjs-wasmfile-release-asyncify.tgz", 12 | "@jitl/quickjs-wasmfile-release-sync": "file:../../build/tar/@jitl-quickjs-wasmfile-release-sync.tgz", 13 | "quickjs-emscripten": "file:../../build/tar/quickjs-emscripten.tgz", 14 | "quickjs-emscripten-core": "file:../../build/tar/quickjs-emscripten-core.tgz", 15 | "typescript": "5" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /examples/node-typescript/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES6", 4 | "lib": ["ES2015", "DOM"], 5 | "module": "Node16", 6 | "strict": true 7 | }, 8 | "include": ["*.ts"], 9 | "exclude": ["../../node_modules/**/*"] 10 | } 11 | -------------------------------------------------------------------------------- /examples/vite-vue/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | -------------------------------------------------------------------------------- /examples/vite-vue/.npmrc: -------------------------------------------------------------------------------- 1 | audit=false 2 | fund=false 3 | -------------------------------------------------------------------------------- /examples/vite-vue/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": ["Vue.volar", "Vue.vscode-typescript-vue-plugin"] 3 | } 4 | -------------------------------------------------------------------------------- /examples/vite-vue/README.md: -------------------------------------------------------------------------------- 1 | # Vue 3 + Vite 2 | 3 | This template should help get you started developing with Vue 3 in Vite. The template uses Vue 3 ` 12 | 13 | 14 | -------------------------------------------------------------------------------- /examples/vite-vue/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vite-vue", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "scripts": { 7 | "dev": "vite", 8 | "build": "vite build", 9 | "preview": "vite preview" 10 | }, 11 | "dependencies": { 12 | "@jitl/quickjs-ffi-types": "file:../../build/tar/@jitl-quickjs-ffi-types.tgz", 13 | "@jitl/quickjs-wasmfile-debug-asyncify": "file:../../build/tar/@jitl-quickjs-wasmfile-debug-asyncify.tgz", 14 | "@jitl/quickjs-wasmfile-debug-sync": "file:../../build/tar/@jitl-quickjs-wasmfile-debug-sync.tgz", 15 | "@jitl/quickjs-wasmfile-release-asyncify": "file:../../build/tar/@jitl-quickjs-wasmfile-release-asyncify.tgz", 16 | "@jitl/quickjs-wasmfile-release-sync": "file:../../build/tar/@jitl-quickjs-wasmfile-release-sync.tgz", 17 | "quickjs-emscripten": "file:../../build/tar/quickjs-emscripten.tgz", 18 | "quickjs-emscripten-core": "file:../../build/tar/quickjs-emscripten-core.tgz", 19 | "vue": "^3.3.11" 20 | }, 21 | "devDependencies": { 22 | "@vitejs/plugin-vue": "^4.5.2", 23 | "vite": "^5.0.13" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /examples/vite-vue/public/vite.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/vite-vue/src/App.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 8 | 9 | 23 | -------------------------------------------------------------------------------- /examples/vite-vue/src/assets/vue.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/vite-vue/src/components/HelloWorld.vue: -------------------------------------------------------------------------------- 1 | 25 | 26 | 35 | 36 | 46 | -------------------------------------------------------------------------------- /examples/vite-vue/src/main.js: -------------------------------------------------------------------------------- 1 | import { createApp } from "vue" 2 | import "./style.css" 3 | import App from "./App.vue" 4 | 5 | createApp(App).mount("#app") 6 | -------------------------------------------------------------------------------- /examples/vite-vue/src/quickjs.ts: -------------------------------------------------------------------------------- 1 | import { newQuickJSWASMModuleFromVariant, newVariant, RELEASE_SYNC } from "quickjs-emscripten" 2 | // eslint-disable-next-line @typescript-eslint/ban-ts-comment 3 | // @ts-expect-error - ?url returns a URL resolving to the given asset. 4 | import wasmLocation from "@jitl/quickjs-wasmfile-release-sync/wasm?url" 5 | 6 | const variant = newVariant(RELEASE_SYNC, { 7 | wasmLocation, 8 | }) 9 | 10 | export async function load() { 11 | return await newQuickJSWASMModuleFromVariant(variant) 12 | } 13 | -------------------------------------------------------------------------------- /examples/vite-vue/src/style.css: -------------------------------------------------------------------------------- 1 | :root { 2 | font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; 3 | line-height: 1.5; 4 | font-weight: 400; 5 | 6 | color-scheme: light dark; 7 | color: rgba(255, 255, 255, 0.87); 8 | background-color: #242424; 9 | 10 | font-synthesis: none; 11 | text-rendering: optimizeLegibility; 12 | -webkit-font-smoothing: antialiased; 13 | -moz-osx-font-smoothing: grayscale; 14 | } 15 | 16 | a { 17 | font-weight: 500; 18 | color: #646cff; 19 | text-decoration: inherit; 20 | } 21 | a:hover { 22 | color: #535bf2; 23 | } 24 | 25 | body { 26 | margin: 0; 27 | display: flex; 28 | place-items: center; 29 | min-width: 320px; 30 | min-height: 100vh; 31 | } 32 | 33 | h1 { 34 | font-size: 3.2em; 35 | line-height: 1.1; 36 | } 37 | 38 | button { 39 | border-radius: 8px; 40 | border: 1px solid transparent; 41 | padding: 0.6em 1.2em; 42 | font-size: 1em; 43 | font-weight: 500; 44 | font-family: inherit; 45 | background-color: #1a1a1a; 46 | cursor: pointer; 47 | transition: border-color 0.25s; 48 | } 49 | button:hover { 50 | border-color: #646cff; 51 | } 52 | button:focus, 53 | button:focus-visible { 54 | outline: 4px auto -webkit-focus-ring-color; 55 | } 56 | 57 | .card { 58 | padding: 2em; 59 | } 60 | 61 | #app { 62 | max-width: 1280px; 63 | margin: 0 auto; 64 | padding: 2rem; 65 | text-align: center; 66 | } 67 | 68 | @media (prefers-color-scheme: light) { 69 | :root { 70 | color: #213547; 71 | background-color: #ffffff; 72 | } 73 | a:hover { 74 | color: #747bff; 75 | } 76 | button { 77 | background-color: #f9f9f9; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /examples/vite-vue/vite.config.js: -------------------------------------------------------------------------------- 1 | import { defineConfig } from "vite" 2 | import vue from "@vitejs/plugin-vue" 3 | 4 | // https://vitejs.dev/config/ 5 | export default defineConfig({ 6 | plugins: [vue()], 7 | }) 8 | -------------------------------------------------------------------------------- /exportedRuntimeMethods.json: -------------------------------------------------------------------------------- 1 | ["cwrap", "stringToUTF8", "lengthBytesUTF8", "UTF8ToString", "___lsan_do_recoverable_leak_check"] 2 | -------------------------------------------------------------------------------- /packages/internal-tsconfig/.gitignore: -------------------------------------------------------------------------------- 1 | *.*js 2 | *.d.*ts 3 | *.map 4 | -------------------------------------------------------------------------------- /packages/internal-tsconfig/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@jitl/tsconfig", 3 | "private": true, 4 | "version": "0.31.0", 5 | "scripts": { 6 | "build": "yarn build:tsc && echo built $npm_package_json && ls -l", 7 | "build:tsc": "npx tsc --project tsconfig.tsup.json", 8 | "clean": "git clean -fx ." 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/internal-tsconfig/tsconfig.tsup.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/tsconfig", 3 | "extends": "./tsconfig.json", 4 | "include": ["*.*ts"] 5 | } 6 | -------------------------------------------------------------------------------- /packages/internal-tsconfig/tsup.base.config.ts: -------------------------------------------------------------------------------- 1 | import type { Options } from "tsup" 2 | import { defineConfig } from "tsup" 3 | 4 | const baseConfig = defineConfig((_options) => ({ 5 | entry: ["src/index.ts"], 6 | sourcemap: true, 7 | dts: true, 8 | clean: true, 9 | format: ["cjs", "esm"], 10 | minifySyntax: true, 11 | minifyWhitespace: true, 12 | })) as (options: Options) => Options 13 | 14 | export function extendConfig(options: Options = {}) { 15 | return defineConfig((config) => { 16 | const base = baseConfig(config) 17 | return { 18 | ...base, 19 | ...options, 20 | } 21 | }) as (options: Options) => Options 22 | } 23 | -------------------------------------------------------------------------------- /packages/internal-tsconfig/vite.base.config.mts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from "vitest/config" 2 | import tsconfigPaths from "vite-tsconfig-paths" 3 | 4 | export default defineConfig({ 5 | // Incantation needed for vite to not barf on "using" statement 6 | esbuild: { 7 | target: "es2020", 8 | }, 9 | plugins: [tsconfigPaths()], 10 | test: { 11 | onStackTrace(_error, _frame) { 12 | return true 13 | }, 14 | }, 15 | }) 16 | -------------------------------------------------------------------------------- /packages/quickjs-emscripten-core/.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | -------------------------------------------------------------------------------- /packages/quickjs-emscripten-core/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | quickjs-emscripten copyright (c) 2019-2024 Jake Teton-Landis 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/quickjs-emscripten-core/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "quickjs-emscripten-core", 3 | "version": "0.31.0", 4 | "sideEffects": false, 5 | "license": "MIT", 6 | "type": "commonjs", 7 | "keywords": [ 8 | "eval", 9 | "quickjs", 10 | "vm", 11 | "interpreter", 12 | "runtime", 13 | "safe", 14 | "emscripten", 15 | "wasm" 16 | ], 17 | "author": { 18 | "name": "Jake Teton-Landis", 19 | "url": "https://jake.tl" 20 | }, 21 | "repository": { 22 | "type": "git", 23 | "url": "https://github.com/justjake/quickjs-emscripten" 24 | }, 25 | "files": [ 26 | "LICENSE", 27 | "dist/**/*", 28 | "!dist/*.test.js", 29 | "!dist/*.tsbuildinfo" 30 | ], 31 | "types": "./dist/index.d.ts", 32 | "main": "./dist/index.js", 33 | "module": "./dist/index.mjs", 34 | "exports": { 35 | ".": { 36 | "types": "./dist/index.d.ts", 37 | "import": "./dist/index.mjs", 38 | "require": "./dist/index.js" 39 | } 40 | }, 41 | "scripts": { 42 | "tsc": "npx tsc -p . --noEmit", 43 | "test": "npx vitest run", 44 | "build": "npx tsup" 45 | }, 46 | "dependencies": { 47 | "@jitl/quickjs-ffi-types": "workspace:*" 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /packages/quickjs-emscripten-core/src/asyncify-helpers.test.ts: -------------------------------------------------------------------------------- 1 | import assert from "assert" 2 | import { describe, it } from "vitest" 3 | import { maybeAsyncFn } from "./asyncify-helpers" 4 | 5 | describe("maybeAsync", () => { 6 | const addPromises = maybeAsyncFn( 7 | undefined, 8 | function* (awaited, a: number | Promise, b: number | Promise) { 9 | return (yield* awaited(a)) + (yield* awaited(b)) 10 | }, 11 | ) 12 | 13 | it("has sync output for sync inputs", () => { 14 | const sum2 = addPromises(5, 6) 15 | assert.strictEqual(sum2, 11) 16 | }) 17 | 18 | it("has async output for async inputs", async () => { 19 | const result = addPromises(Promise.resolve(1), 2) 20 | assert(result instanceof Promise, "is promise") 21 | const sum = await result 22 | assert.strictEqual(sum, 3, "sums correctly") 23 | }) 24 | 25 | it("throws any sync errors", () => { 26 | // eslint-disable-next-line require-yield 27 | const fn = maybeAsyncFn(undefined, function* () { 28 | throw new Error("sync error") 29 | }) 30 | 31 | assert.throws(() => fn(), /sync error/) 32 | }) 33 | 34 | it("it throws async errors", () => { 35 | const fn = maybeAsyncFn(undefined, function* (awaited) { 36 | yield* awaited(new Promise((resolve) => setTimeout(resolve, 50))) 37 | throw new Error("async error") 38 | }) 39 | 40 | assert.rejects(() => fn(), /async error/) 41 | }) 42 | }) 43 | -------------------------------------------------------------------------------- /packages/quickjs-emscripten-core/src/debug.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @private 3 | * Mutable variable. Use {@link setDebugMode} to enable. 4 | */ 5 | export let QTS_DEBUG = false 6 | 7 | /** 8 | * Enable (or disable) debug logging and object creation tracking globally. 9 | * This setting is inherited by newly created QuickJSRuntime instances. 10 | * To get debug logging in the WebAssembly module, you need to use a debug build variant. 11 | * See [the quickjs-emscripten-core README](https://github.com/justjake/quickjs-emscripten/tree/main/doc/quickjs-emscripten-core) for more about build variants. 12 | */ 13 | export function setDebugMode(enabled: boolean = true) { 14 | QTS_DEBUG = enabled 15 | } 16 | 17 | /** Get the global debug mode */ 18 | export function isDebugMode() { 19 | return QTS_DEBUG 20 | } 21 | 22 | /** 23 | * @private 24 | */ 25 | export function debugLog(...args: any[]) { 26 | if (QTS_DEBUG) { 27 | console.log("quickjs-emscripten:", ...args) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /packages/quickjs-emscripten-core/src/errors.ts: -------------------------------------------------------------------------------- 1 | import type { QuickJSContext } from "./context" 2 | 3 | /** 4 | * Error thrown if {@link QuickJSContext#unwrapResult} unwraps an error value that isn't an object. 5 | */ 6 | export class QuickJSUnwrapError extends Error { 7 | name = "QuickJSUnwrapError" 8 | constructor( 9 | public cause: unknown, 10 | public context?: QuickJSContext, 11 | ) { 12 | const message = 13 | typeof cause === "object" && cause && "message" in cause 14 | ? String(cause.message) 15 | : String(cause) 16 | super(message) 17 | } 18 | } 19 | 20 | export class QuickJSWrongOwner extends Error { 21 | name = "QuickJSWrongOwner" 22 | } 23 | 24 | export class QuickJSUseAfterFree extends Error { 25 | name = "QuickJSUseAfterFree" 26 | } 27 | 28 | export class QuickJSNotImplemented extends Error { 29 | name = "QuickJSNotImplemented" 30 | } 31 | 32 | export class QuickJSAsyncifyError extends Error { 33 | name = "QuickJSAsyncifyError" 34 | } 35 | 36 | export class QuickJSAsyncifySuspended extends Error { 37 | name = "QuickJSAsyncifySuspended" 38 | } 39 | 40 | export class QuickJSMemoryLeakDetected extends Error { 41 | name = "QuickJSMemoryLeakDetected" 42 | } 43 | 44 | export class QuickJSEmscriptenModuleError extends Error { 45 | name = "QuickJSEmscriptenModuleError" 46 | } 47 | 48 | export class QuickJSUnknownIntrinsic extends TypeError { 49 | name = "QuickJSUnknownIntrinsic" 50 | } 51 | 52 | export class QuickJSPromisePending extends Error { 53 | name = "QuickJSPromisePending" 54 | } 55 | 56 | export class QuickJSEmptyGetOwnPropertyNames extends Error { 57 | name = "QuickJSEmptyGetOwnPropertyNames" 58 | } 59 | -------------------------------------------------------------------------------- /packages/quickjs-emscripten-core/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from "@jitl/quickjs-ffi-types" 2 | 3 | // Sync classes 4 | export { QuickJSWASMModule } from "./module" 5 | export { QuickJSContext } from "./context" 6 | export { QuickJSRuntime } from "./runtime" 7 | export type { InterruptHandler, ExecutePendingJobsResult } from "./runtime" 8 | 9 | // Async classes 10 | export { QuickJSAsyncWASMModule } from "./module-asyncify" 11 | export { QuickJSAsyncRuntime } from "./runtime-asyncify" 12 | export { QuickJSAsyncContext } from "./context-asyncify" 13 | export type { AsyncFunctionImplementation } from "./context-asyncify" 14 | 15 | // Build variants 16 | export * from "./from-variant" 17 | 18 | // Export helpers 19 | export * from "./vm-interface" 20 | export * from "./lifetime" 21 | export * from "./interrupt-helpers" 22 | /** Collects the informative errors this library may throw. */ 23 | export * as errors from "./errors" 24 | export * from "./deferred-promise" 25 | export * from "./module-test" 26 | export type { 27 | StaticJSValue, 28 | JSValueConst, 29 | JSValue, 30 | QuickJSHandle, 31 | ContextOptions, 32 | ContextEvalOptions, 33 | RuntimeOptions, 34 | AsyncRuntimeOptions, 35 | RuntimeOptionsBase, 36 | JSModuleLoader, 37 | JSModuleLoadResult, 38 | JSModuleLoaderAsync, 39 | JSModuleLoadSuccess, 40 | JSModuleLoadFailure, 41 | JSModuleNormalizer, 42 | JSModuleNormalizerAsync, 43 | JSModuleNormalizeResult, 44 | JSModuleNormalizeFailure, 45 | JSModuleNormalizeSuccess, 46 | Intrinsics, 47 | } from "./types" 48 | export { DefaultIntrinsics } from "./types" 49 | export type { ModuleEvalOptions } from "./module" 50 | export type { QuickJSPropertyKey } from "./context" 51 | export { debugLog, setDebugMode } from "./debug" 52 | -------------------------------------------------------------------------------- /packages/quickjs-emscripten-core/src/interrupt-helpers.ts: -------------------------------------------------------------------------------- 1 | import type { InterruptHandler } from "./runtime" 2 | 3 | /** 4 | * Returns an interrupt handler that interrupts Javascript execution after a deadline time. 5 | * 6 | * @param deadline - Interrupt execution if it's still running after this time. 7 | * Number values are compared against `Date.now()` 8 | */ 9 | export function shouldInterruptAfterDeadline(deadline: Date | number): InterruptHandler { 10 | const deadlineAsNumber = typeof deadline === "number" ? deadline : deadline.getTime() 11 | 12 | return function () { 13 | return Date.now() > deadlineAsNumber 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /packages/quickjs-emscripten-core/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@jitl/tsconfig/tsconfig.json", 3 | "include": ["src/**/*"], 4 | "compilerOptions": { 5 | "rootDir": "src", 6 | "outDir": "dist", 7 | "paths": {} 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/quickjs-emscripten-core/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@jitl/tsconfig/tsconfig.json", 3 | "include": ["src/**/*"], 4 | "compilerOptions": { 5 | "paths": { 6 | "@jitl/quickjs-ffi-types": ["../quickjs-ffi-types/src"], 7 | "@jitl/quickjs-ffi-types/*": ["../quickjs-ffi-types/src/*"] 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/quickjs-emscripten-core/tsup.config.ts: -------------------------------------------------------------------------------- 1 | import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" 2 | 3 | export default extendConfig({ 4 | tsconfig: "./tsconfig.build.json", 5 | }) 6 | -------------------------------------------------------------------------------- /packages/quickjs-emscripten-core/typedoc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: "../../typedoc.base.js", 3 | entryPoints: ["./src/index.ts"], 4 | } 5 | -------------------------------------------------------------------------------- /packages/quickjs-emscripten-core/vite.config.mts: -------------------------------------------------------------------------------- 1 | import config from "@jitl/tsconfig/vite.base.config.mjs" 2 | export default config 3 | -------------------------------------------------------------------------------- /packages/quickjs-emscripten/.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | .output 3 | -------------------------------------------------------------------------------- /packages/quickjs-emscripten/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | quickjs-emscripten copyright (c) 2019-2024 Jake Teton-Landis 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/quickjs-emscripten/makeTestPackageJson.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S npx tsx 2 | import fs from "node:fs" 3 | import pkg from "./package.json" 4 | import update from "./node.package.json" 5 | const newPkg = { ...pkg, ...update } 6 | fs.writeFileSync(".output/package.json", JSON.stringify(newPkg, null, 2)) 7 | -------------------------------------------------------------------------------- /packages/quickjs-emscripten/node.package.json: -------------------------------------------------------------------------------- 1 | { 2 | "imports": { 3 | "#variants": "./variants.js" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /packages/quickjs-emscripten/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from "quickjs-emscripten-core" 2 | export * from "#variants" 3 | export * from "./mod.js" 4 | -------------------------------------------------------------------------------- /packages/quickjs-emscripten/src/package.test.ts: -------------------------------------------------------------------------------- 1 | import { assert, test } from "vitest" 2 | import packageJson from "../package.json" 3 | 4 | test("all export subpaths start with ./", () => { 5 | for (const [name, mappings] of Object.entries(packageJson.exports)) { 6 | if (typeof mappings === "string") { 7 | assert.isTrue( 8 | mappings.startsWith("./"), 9 | `package.json export "${name}" points to ${mappings}, but it doesn't start with ./`, 10 | ) 11 | continue 12 | } 13 | 14 | for (const [condition, subpath] of Object.entries(mappings)) { 15 | assert.isTrue( 16 | subpath.startsWith("./"), 17 | `package.json export "${name}" condition ${condition} subpath ${subpath} does not start with ./`, 18 | ) 19 | } 20 | } 21 | }) 22 | -------------------------------------------------------------------------------- /packages/quickjs-emscripten/src/variant-node-test-cjs.cts: -------------------------------------------------------------------------------- 1 | import { describe, it } from "node:test" 2 | import { packageSpecifiers, testSuite } from "./variant-test-suite" 3 | import * as quickjsEmscripten from "." 4 | 5 | const VARIANT_LOADERS: Record Promise> = {} 6 | for (const [name, conditions] of Object.entries(packageSpecifiers)) { 7 | if (conditions.import) { 8 | VARIANT_LOADERS[`import(${name})`] = () => import(name) 9 | } 10 | if (conditions.require) { 11 | // eslint-disable-next-line @typescript-eslint/no-var-requires 12 | VARIANT_LOADERS[`require(${name})`] = () => Promise.resolve(require(name)) 13 | } 14 | } 15 | 16 | describe("node:test load variants from CommonJS", () => { 17 | testSuite({ describe, it }, VARIANT_LOADERS, quickjsEmscripten) 18 | }) 19 | -------------------------------------------------------------------------------- /packages/quickjs-emscripten/src/variant-node-test-mjs.mts: -------------------------------------------------------------------------------- 1 | import { describe, it } from "node:test" 2 | import { createRequire } from "node:module" 3 | 4 | import { packageSpecifiers, testSuite } from "./variant-test-suite.js" 5 | import * as quickjsEmscripten from "./index.js" 6 | 7 | const require = createRequire(import.meta.url) 8 | 9 | const VARIANT_LOADERS: Record Promise> = {} 10 | for (const [name, conditions] of Object.entries(packageSpecifiers)) { 11 | if (conditions.import) { 12 | VARIANT_LOADERS[`import(${name})`] = () => import(name) 13 | } 14 | if (conditions.require) { 15 | VARIANT_LOADERS[`require(${name})`] = () => Promise.resolve(require(name)) 16 | } 17 | } 18 | 19 | describe("node:test load variants from ESModule", () => { 20 | testSuite({ describe, it }, VARIANT_LOADERS, quickjsEmscripten) 21 | }) 22 | -------------------------------------------------------------------------------- /packages/quickjs-emscripten/src/variant-vi-cjs.test.cts: -------------------------------------------------------------------------------- 1 | import { describe, it } from "vitest" 2 | import { testSuite } from "./variant-test-suite" 3 | import * as quickjsEmscripten from "." 4 | 5 | describe("variants (vi cjs)", () => { 6 | testSuite({ describe, it }, {}, quickjsEmscripten) 7 | }) 8 | -------------------------------------------------------------------------------- /packages/quickjs-emscripten/src/variant-vi-mjs.test.mts: -------------------------------------------------------------------------------- 1 | import { describe, it } from "vitest" 2 | import { testSuite } from "./variant-test-suite.js" 3 | import * as quickjsEmscripten from "./index.js" 4 | 5 | describe("variants (vi mjs)", () => { 6 | testSuite({ describe, it }, {}, quickjsEmscripten) 7 | }) 8 | -------------------------------------------------------------------------------- /packages/quickjs-emscripten/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": ".output", 5 | "rootDir": "src", 6 | "paths": { 7 | "#variants": ["./src/variants.ts", "./src/variants.js"] 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/quickjs-emscripten/tsconfig.iife.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "paths": { 5 | "#variants": ["./src/variants.iife.ts", "./src/variants.iife.js"] 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/quickjs-emscripten/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@jitl/tsconfig/tsconfig.json", 3 | "include": ["src/*.*ts"], 4 | "compilerOptions": { 5 | "paths": { 6 | "#variants": ["./src/variants.ts", "./src/variants.js"], 7 | "quickjs-emscripten-core": ["../quickjs-emscripten-core/src"], 8 | "quickjs-emscripten-core/*": ["../quickjs-emscripten-core/src/*"] 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /packages/quickjs-emscripten/tsup.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig, type Options } from "tsup" 2 | import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" 3 | 4 | const browsers: Extract> = [ 5 | "deno1", 6 | "safari14", 7 | "chrome80", 8 | "firefox72", 9 | "ios16", 10 | ] 11 | 12 | const configs = [ 13 | extendConfig({ 14 | entry: ["src/index.ts", "src/variants.ts"], 15 | tsconfig: "./tsconfig.build.json", 16 | format: "esm", 17 | target: ["node16", ...browsers], 18 | }), 19 | extendConfig({ 20 | entry: ["src/index.ts", "src/variants.ts"], 21 | tsconfig: "./tsconfig.build.json", 22 | format: "cjs", 23 | }), 24 | extendConfig({ 25 | entry: ["src/index.ts"], 26 | format: "iife", 27 | globalName: "QJS", 28 | target: [...browsers], 29 | tsconfig: "./tsconfig.iife.json", 30 | sourcemap: false, 31 | dts: false, 32 | esbuildOptions(options, _context) { 33 | options.conditions ??= [] 34 | options.conditions.push("iife") 35 | }, 36 | }), 37 | ] 38 | 39 | export default defineConfig((options) => configs.map((cfg) => cfg(options))) 40 | -------------------------------------------------------------------------------- /packages/quickjs-emscripten/typedoc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: "../../typedoc.base.js", 3 | entryPoints: ["./src/index.ts"], 4 | } 5 | -------------------------------------------------------------------------------- /packages/quickjs-emscripten/vite.config.mts: -------------------------------------------------------------------------------- 1 | import config from "@jitl/tsconfig/vite.base.config.mjs" 2 | export default config 3 | -------------------------------------------------------------------------------- /packages/quickjs-ffi-types/.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | -------------------------------------------------------------------------------- /packages/quickjs-ffi-types/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | quickjs-emscripten copyright (c) 2019-2024 Jake Teton-Landis 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/quickjs-ffi-types/README.md: -------------------------------------------------------------------------------- 1 | # @jitl/quickjs-ffi-types 2 | 3 | This is an internal package, part of [quickjs-emscripten](https://github.com/justjake/quickjs-emscripten). 4 | 5 | See the main package for documentation. 6 | -------------------------------------------------------------------------------- /packages/quickjs-ffi-types/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@jitl/quickjs-ffi-types", 3 | "version": "0.31.0", 4 | "license": "MIT", 5 | "repository": { 6 | "type": "git", 7 | "url": "https://github.com/justjake/quickjs-emscripten" 8 | }, 9 | "author": { 10 | "name": "Jake Teton-Landis", 11 | "url": "https://jake.tl" 12 | }, 13 | "scripts": { 14 | "check": "npx tsc --project . --noEmit", 15 | "build": "npx tsup", 16 | "clean": "git clean -fx dist" 17 | }, 18 | "files": [ 19 | "LICENSE", 20 | "dist/**/*" 21 | ], 22 | "types": "dist/index.d.ts", 23 | "main": "dist/index.js", 24 | "module": "dist/index.mjs", 25 | "exports": { 26 | "./package.json": "./package.json", 27 | ".": { 28 | "types": "./dist/index.d.ts", 29 | "import": "./dist/index.mjs", 30 | "require": "./dist/index.js" 31 | } 32 | }, 33 | "devDependencies": { 34 | "@jitl/tsconfig": "workspace:*" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /packages/quickjs-ffi-types/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./emscripten-types" 2 | export * from "./ffi-types" 3 | // eslint-disable-next-line import/no-cycle 4 | export * from "./ffi" 5 | // eslint-disable-next-line import/no-cycle 6 | export * from "./ffi-async" 7 | export * from "./variant-types" 8 | -------------------------------------------------------------------------------- /packages/quickjs-ffi-types/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@jitl/tsconfig/tsconfig.json", 3 | "include": ["src/**/*"], 4 | "compilerOptions": { 5 | "rootDir": "src" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/quickjs-ffi-types/tsup.config.ts: -------------------------------------------------------------------------------- 1 | import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" 2 | 3 | export default extendConfig() 4 | -------------------------------------------------------------------------------- /packages/quickjs-ffi-types/typedoc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: "../../typedoc.base.js", 3 | mergeReadme: true, 4 | entryPoints: ["./src/index.ts"], 5 | } 6 | -------------------------------------------------------------------------------- /packages/quickjs-for-quickjs/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | quickjs-emscripten copyright (c) 2019-2024 Jake Teton-Landis 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/quickjs-for-quickjs/example/node-host.mjs: -------------------------------------------------------------------------------- 1 | import fs from "node:fs/promises" 2 | import module from "node:module" 3 | import { getQuickJS, setUpContext } from "quickjs-for-quickjs" 4 | const require = module.createRequire(import.meta.url) 5 | 6 | console.log("hello") 7 | 8 | const quickjsSource = await fs.readFile(require.resolve("quickjs-for-quickjs"), "utf8") 9 | const exportQuickjsSource = `export default ${JSON.stringify(quickjsSource)}` 10 | 11 | const exampleQuickjsHostSource = await fs.readFile(require.resolve("./quickjs-host.mjs"), "utf8") 12 | const exportExampleQuickjsHostSource = `export default ${JSON.stringify(exampleQuickjsHostSource)}` 13 | 14 | const QuickJS = await getQuickJS() 15 | const context = setUpContext(QuickJS.newContext()) 16 | context.runtime.setModuleLoader((name) => { 17 | console.log(`0: import ${name}`) 18 | if (name === "quickjs-for-quickjs") { 19 | return quickjsSource 20 | } 21 | if (name === "quickjs-for-quickjs-source") { 22 | return exportQuickjsSource 23 | } 24 | if (name === "example-quickjs-host-source") { 25 | return exportExampleQuickjsHostSource 26 | } 27 | return { error: new Error("not found") } 28 | }) 29 | 30 | let nestingLimit = 2 31 | context.setProp( 32 | context.global, 33 | "done", 34 | context.newFunction("done", () => context.newNumber(--nestingLimit <= 0 ? 1 : 0)), 35 | ) 36 | const handle = context 37 | .evalCode(exampleQuickjsHostSource, "quickjs-host.mjs", { 38 | type: "module", 39 | }) 40 | .unwrap() 41 | 42 | const promise = context.resolvePromise(handle) 43 | context.runtime.executePendingJobs() 44 | 45 | const result = (await promise).unwrap() 46 | 47 | console.log({ 48 | result: context.dump(context.getProp(result, "result")), 49 | }) 50 | 51 | console.log("result:", context.dump(context.getProp(await promise, "result"))) 52 | -------------------------------------------------------------------------------- /packages/quickjs-for-quickjs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "quickjs-for-quickjs", 3 | "version": "0.31.0", 4 | "license": "MIT", 5 | "repository": { 6 | "type": "git", 7 | "url": "https://github.com/justjake/quickjs-emscripten" 8 | }, 9 | "author": { 10 | "name": "Jake Teton-Landis", 11 | "url": "https://jake.tl" 12 | }, 13 | "scripts": { 14 | "check": "npx tsc --project . --noEmit", 15 | "build": "npx tsup", 16 | "clean": "git clean -fx dist" 17 | }, 18 | "files": [ 19 | "LICENSE", 20 | "yodawg.jpg", 21 | "example/**/*", 22 | "dist/**/*" 23 | ], 24 | "types": "dist/index.d.mts", 25 | "main": "dist/index.mjs", 26 | "module": "dist/index.mjs", 27 | "exports": { 28 | "./package.json": "./package.json", 29 | ".": { 30 | "types": "./dist/index.d.mts", 31 | "import": "./dist/index.mjs", 32 | "default": "./dist/index.mjs" 33 | } 34 | }, 35 | "devDependencies": { 36 | "@jitl/quickjs-asmjs-mjs-release-sync": "workspace:*", 37 | "@jitl/tsconfig": "workspace:*", 38 | "quickjs-emscripten-core": "workspace:*" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /packages/quickjs-for-quickjs/src/index.mts: -------------------------------------------------------------------------------- 1 | import type { QuickJSWASMModule, QuickJSContext } from "quickjs-emscripten-core" 2 | import { newQuickJSWASMModuleFromVariant } from "quickjs-emscripten-core" 3 | import RELEASE_SYNC from "@jitl/quickjs-asmjs-mjs-release-sync" 4 | 5 | let promise: Promise | undefined 6 | 7 | export function getQuickJS(): Promise { 8 | return (promise ??= newQuickJSWASMModule()) 9 | } 10 | 11 | export function newQuickJSWASMModule(): Promise { 12 | // TODO: why are the types mad? 13 | return newQuickJSWASMModuleFromVariant(RELEASE_SYNC as any) 14 | } 15 | 16 | export function setUpContext( 17 | context: QuickJSContext, 18 | options: { 19 | log?: (...args: unknown[]) => void 20 | } = {}, 21 | ) { 22 | const { log } = options 23 | const depth: number = (console as any)["depth"] ?? 0 24 | using consoleHandle = context.newObject() 25 | using logHandle = context.newFunction("console.log", (...args) => { 26 | const message = args.map(context.dump) 27 | if (log) { 28 | log(...message) 29 | } else { 30 | console.log(...message) 31 | } 32 | }) 33 | using depthHandle = context.newNumber(1 + depth) 34 | 35 | context.setProp(consoleHandle, "log", logHandle) 36 | context.setProp(consoleHandle, "error", logHandle) 37 | context.setProp(consoleHandle, "depth", depthHandle) 38 | 39 | context.setProp(context.global, "console", consoleHandle) 40 | 41 | context.runtime.setMaxStackSize(0) 42 | context.runtime.setMemoryLimit(0) 43 | let interruptCount = 0 44 | context.runtime.setInterruptHandler(() => { 45 | console.log(`${depth}: ...eval... (${++interruptCount})`) 46 | return undefined 47 | }) 48 | 49 | return context 50 | } 51 | 52 | export { RELEASE_SYNC } 53 | -------------------------------------------------------------------------------- /packages/quickjs-for-quickjs/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@jitl/tsconfig/tsconfig.json", 3 | "include": ["src/**/*"], 4 | "compilerOptions": { 5 | "rootDir": "src" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/quickjs-for-quickjs/tsup.config.ts: -------------------------------------------------------------------------------- 1 | import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" 2 | 3 | export default extendConfig({ 4 | entry: ["src/index.mts"], 5 | format: ["esm"], 6 | external: [], 7 | clean: true, 8 | splitting: false, 9 | sourcemap: false, 10 | }) 11 | -------------------------------------------------------------------------------- /packages/quickjs-for-quickjs/yodawg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjake/quickjs-emscripten/aa48b619983f02c5691d989c0771a3421178ce4b/packages/quickjs-for-quickjs/yodawg.jpg -------------------------------------------------------------------------------- /packages/variant-quickjs-asmjs-mjs-release-sync/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@jitl/quickjs-asmjs-mjs-release-sync", 3 | "license": "MIT", 4 | "version": "0.31.0", 5 | "description": "Variant of quickjs library: Compiled to pure Javascript, no WebAssembly required.", 6 | "sideEffects": false, 7 | "repository": { 8 | "type": "git", 9 | "url": "https://github.com/justjake/quickjs-emscripten" 10 | }, 11 | "author": { 12 | "name": "Jake Teton-Landis", 13 | "url": "https://jake.tl" 14 | }, 15 | "scripts": { 16 | "build": "yarn build:c && yarn build:ts", 17 | "build:c": "make -j2", 18 | "build:ts": "npx tsup", 19 | "check:types": "npx tsc --project . --noEmit", 20 | "clean": "make clean", 21 | "prepare": "yarn clean && yarn build" 22 | }, 23 | "files": [ 24 | "LICENSE", 25 | "README.md", 26 | "dist/**/*", 27 | "!dist/*.tsbuildinfo" 28 | ], 29 | "types": "./dist/index.d.mts", 30 | "main": "./dist/index.mjs", 31 | "module": "./dist/index.mjs", 32 | "exports": { 33 | ".": { 34 | "types": "./dist/index.d.mts", 35 | "import": "./dist/index.mjs", 36 | "default": "./dist/index.mjs" 37 | }, 38 | "./package.json": "./package.json", 39 | "./emscripten-module": { 40 | "types": "./dist/emscripten-module.d.ts", 41 | "import": "./dist/emscripten-module.mjs", 42 | "default": "./dist/emscripten-module.mjs" 43 | } 44 | }, 45 | "dependencies": { 46 | "@jitl/quickjs-ffi-types": "workspace:*" 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /packages/variant-quickjs-asmjs-mjs-release-sync/src/index.ts: -------------------------------------------------------------------------------- 1 | import type { QuickJSSyncVariant } from "@jitl/quickjs-ffi-types" 2 | import moduleLoader from "@jitl/quickjs-asmjs-mjs-release-sync/emscripten-module" 3 | import { QuickJSFFI } from "./ffi.js" 4 | /** 5 | * ### @jitl/quickjs-asmjs-mjs-release-sync 6 | * 7 | * [Docs](https://github.com/justjake/quickjs-emscripten/blob/main/doc/@jitl/quickjs-asmjs-mjs-release-sync/README.md) | 8 | * Compiled to pure Javascript, no WebAssembly required. 9 | * 10 | * | Variable | Setting | Description | 11 | * | -- | -- | -- | 12 | * | library | quickjs | The original [bellard/quickjs](https://github.com/bellard/quickjs) library. Version [2024-02-14+36911f0d](https://github.com/bellard/quickjs/commit/36911f0d3ab1a4c190a4d5cbe7c2db225a455389) vendored to quickjs-emscripten on 2024-06-15. | 13 | * | releaseMode | release | Optimized for performance; use when building/deploying your application. | 14 | * | syncMode | sync | The default, normal build. Note that both variants support regular async functions. | 15 | * | emscriptenInclusion | asmjs | The C library code is compiled to Javascript, no WebAssembly used. Sometimes called "asmjs". This is the slowest possible option, and is intended for constrained environments that do not support WebAssembly, like quickjs-for-quickjs. | 16 | * | exports | import | Has these package.json export conditions | 17 | * 18 | */ 19 | const variant: QuickJSSyncVariant = { 20 | type: "sync", 21 | importFFI: () => Promise.resolve(QuickJSFFI), 22 | importModuleLoader: () => Promise.resolve(moduleLoader), 23 | } as const 24 | export default variant 25 | -------------------------------------------------------------------------------- /packages/variant-quickjs-asmjs-mjs-release-sync/tsconfig.json: -------------------------------------------------------------------------------- 1 | { "extends": "@jitl/tsconfig/tsconfig.json", "include": ["src/*"], "exclude": ["node_modules"] } 2 | -------------------------------------------------------------------------------- /packages/variant-quickjs-asmjs-mjs-release-sync/tsup.config.ts: -------------------------------------------------------------------------------- 1 | import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" 2 | export default extendConfig({ 3 | entry: ["src/index.ts"], 4 | external: [], 5 | format: ["esm"], 6 | clean: false, 7 | }) 8 | -------------------------------------------------------------------------------- /packages/variant-quickjs-asmjs-mjs-release-sync/typedoc.json: -------------------------------------------------------------------------------- 1 | { "extends": "../../typedoc.base.js", "entryPoints": ["./src/index.ts"], "mergeReadme": true } 2 | -------------------------------------------------------------------------------- /packages/variant-quickjs-ng-wasmfile-debug-asyncify/tsconfig.json: -------------------------------------------------------------------------------- 1 | { "extends": "@jitl/tsconfig/tsconfig.json", "include": ["src/*"], "exclude": ["node_modules"] } 2 | -------------------------------------------------------------------------------- /packages/variant-quickjs-ng-wasmfile-debug-asyncify/tsup.config.ts: -------------------------------------------------------------------------------- 1 | import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" 2 | export default extendConfig({ 3 | entry: ["src/index.ts", "src/ffi.ts"], 4 | external: ["@jitl/quickjs-ng-wasmfile-debug-asyncify/emscripten-module"], 5 | format: ["esm", "cjs"], 6 | clean: false, 7 | }) 8 | -------------------------------------------------------------------------------- /packages/variant-quickjs-ng-wasmfile-debug-asyncify/typedoc.json: -------------------------------------------------------------------------------- 1 | { "extends": "../../typedoc.base.js", "entryPoints": ["./src/index.ts"], "mergeReadme": true } 2 | -------------------------------------------------------------------------------- /packages/variant-quickjs-ng-wasmfile-debug-sync/tsconfig.json: -------------------------------------------------------------------------------- 1 | { "extends": "@jitl/tsconfig/tsconfig.json", "include": ["src/*"], "exclude": ["node_modules"] } 2 | -------------------------------------------------------------------------------- /packages/variant-quickjs-ng-wasmfile-debug-sync/tsup.config.ts: -------------------------------------------------------------------------------- 1 | import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" 2 | export default extendConfig({ 3 | entry: ["src/index.ts", "src/ffi.ts"], 4 | external: ["@jitl/quickjs-ng-wasmfile-debug-sync/emscripten-module"], 5 | format: ["esm", "cjs"], 6 | clean: false, 7 | }) 8 | -------------------------------------------------------------------------------- /packages/variant-quickjs-ng-wasmfile-debug-sync/typedoc.json: -------------------------------------------------------------------------------- 1 | { "extends": "../../typedoc.base.js", "entryPoints": ["./src/index.ts"], "mergeReadme": true } 2 | -------------------------------------------------------------------------------- /packages/variant-quickjs-ng-wasmfile-release-asyncify/tsconfig.json: -------------------------------------------------------------------------------- 1 | { "extends": "@jitl/tsconfig/tsconfig.json", "include": ["src/*"], "exclude": ["node_modules"] } 2 | -------------------------------------------------------------------------------- /packages/variant-quickjs-ng-wasmfile-release-asyncify/tsup.config.ts: -------------------------------------------------------------------------------- 1 | import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" 2 | export default extendConfig({ 3 | entry: ["src/index.ts", "src/ffi.ts"], 4 | external: ["@jitl/quickjs-ng-wasmfile-release-asyncify/emscripten-module"], 5 | format: ["esm", "cjs"], 6 | clean: false, 7 | }) 8 | -------------------------------------------------------------------------------- /packages/variant-quickjs-ng-wasmfile-release-asyncify/typedoc.json: -------------------------------------------------------------------------------- 1 | { "extends": "../../typedoc.base.js", "entryPoints": ["./src/index.ts"], "mergeReadme": true } 2 | -------------------------------------------------------------------------------- /packages/variant-quickjs-ng-wasmfile-release-sync/src/index.ts: -------------------------------------------------------------------------------- 1 | import type { QuickJSSyncVariant } from "@jitl/quickjs-ffi-types" 2 | 3 | /** 4 | * ### @jitl/quickjs-ng-wasmfile-release-sync 5 | * 6 | * [Docs](https://github.com/justjake/quickjs-emscripten/blob/main/doc/@jitl/quickjs-ng-wasmfile-release-sync/README.md) | 7 | * Variant with separate .WASM file. Supports browser ESM, NodeJS ESM, and NodeJS CommonJS. 8 | * 9 | * | Variable | Setting | Description | 10 | * | -- | -- | -- | 11 | * | library | quickjs-ng | [quickjs-ng](https://github.com/quickjs-ng/quickjs) is a fork of quickjs that tends to add features more quickly. Version [git+7ded62c5](https://github.com/quickjs-ng/quickjs/commit/7ded62c536fca860b8106c39fb75f2df8fe27180) vendored to quickjs-emscripten on 2024-02-12. | 12 | * | releaseMode | release | Optimized for performance; use when building/deploying your application. | 13 | * | syncMode | sync | The default, normal build. Note that both variants support regular async functions. | 14 | * | emscriptenInclusion | wasm | Has a separate .wasm file. May offer better caching in your browser, and reduces the size of your JS bundle. If you have issues, try a 'singlefile' variant. | 15 | * | exports | require import browser workerd | Has these package.json export conditions | 16 | * 17 | */ 18 | const variant: QuickJSSyncVariant = { 19 | type: "sync", 20 | importFFI: () => import("./ffi.js").then((mod) => mod.QuickJSFFI), 21 | importModuleLoader: () => 22 | import("@jitl/quickjs-ng-wasmfile-release-sync/emscripten-module").then((mod) => mod.default), 23 | } as const 24 | 25 | export default variant 26 | -------------------------------------------------------------------------------- /packages/variant-quickjs-ng-wasmfile-release-sync/tsconfig.json: -------------------------------------------------------------------------------- 1 | { "extends": "@jitl/tsconfig/tsconfig.json", "include": ["src/*"], "exclude": ["node_modules"] } 2 | -------------------------------------------------------------------------------- /packages/variant-quickjs-ng-wasmfile-release-sync/tsup.config.ts: -------------------------------------------------------------------------------- 1 | import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" 2 | export default extendConfig({ 3 | entry: ["src/index.ts", "src/ffi.ts"], 4 | external: ["@jitl/quickjs-ng-wasmfile-release-sync/emscripten-module"], 5 | format: ["esm", "cjs"], 6 | clean: false, 7 | }) 8 | -------------------------------------------------------------------------------- /packages/variant-quickjs-ng-wasmfile-release-sync/typedoc.json: -------------------------------------------------------------------------------- 1 | { "extends": "../../typedoc.base.js", "entryPoints": ["./src/index.ts"], "mergeReadme": true } 2 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-browser-debug-asyncify/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@jitl/quickjs-singlefile-browser-debug-asyncify", 3 | "license": "MIT", 4 | "version": "0.31.0", 5 | "description": "Variant of quickjs library: Variant with the WASM data embedded into a browser ESModule.", 6 | "sideEffects": false, 7 | "repository": { 8 | "type": "git", 9 | "url": "https://github.com/justjake/quickjs-emscripten" 10 | }, 11 | "author": { 12 | "name": "Jake Teton-Landis", 13 | "url": "https://jake.tl" 14 | }, 15 | "scripts": { 16 | "build": "yarn build:c && yarn build:ts", 17 | "build:c": "make -j2", 18 | "build:ts": "npx tsup", 19 | "check:types": "npx tsc --project . --noEmit", 20 | "clean": "make clean", 21 | "prepare": "yarn clean && yarn build" 22 | }, 23 | "files": [ 24 | "LICENSE", 25 | "README.md", 26 | "dist/**/*", 27 | "!dist/*.tsbuildinfo" 28 | ], 29 | "types": "./dist/index.d.mts", 30 | "main": "./dist/index.mjs", 31 | "module": "./dist/index.mjs", 32 | "browser": "./dist/index.mjs", 33 | "exports": { 34 | ".": { 35 | "types": "./dist/index.d.mts", 36 | "import": "./dist/index.mjs", 37 | "default": "./dist/index.mjs" 38 | }, 39 | "./package.json": "./package.json", 40 | "./ffi": { 41 | "types": "./dist/ffi.d.mts", 42 | "import": "./dist/ffi.mjs", 43 | "default": "./dist/ffi.mjs" 44 | }, 45 | "./emscripten-module": { 46 | "types": "./dist/emscripten-module.browser.d.ts", 47 | "browser": "./dist/emscripten-module.browser.mjs", 48 | "import": "./dist/emscripten-module.browser.mjs", 49 | "default": "./dist/emscripten-module.browser.mjs" 50 | } 51 | }, 52 | "dependencies": { 53 | "@jitl/quickjs-ffi-types": "workspace:*" 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-browser-debug-asyncify/tsconfig.json: -------------------------------------------------------------------------------- 1 | { "extends": "@jitl/tsconfig/tsconfig.json", "include": ["src/*"], "exclude": ["node_modules"] } 2 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-browser-debug-asyncify/tsup.config.ts: -------------------------------------------------------------------------------- 1 | import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" 2 | export default extendConfig({ 3 | entry: ["src/index.ts", "src/ffi.ts"], 4 | external: [], 5 | format: ["esm"], 6 | clean: false, 7 | }) 8 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-browser-debug-asyncify/typedoc.json: -------------------------------------------------------------------------------- 1 | { "extends": "../../typedoc.base.js", "entryPoints": ["./src/index.ts"], "mergeReadme": true } 2 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-browser-debug-sync/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@jitl/quickjs-singlefile-browser-debug-sync", 3 | "license": "MIT", 4 | "version": "0.31.0", 5 | "description": "Variant of quickjs library: Variant with the WASM data embedded into a browser ESModule.", 6 | "sideEffects": false, 7 | "repository": { 8 | "type": "git", 9 | "url": "https://github.com/justjake/quickjs-emscripten" 10 | }, 11 | "author": { 12 | "name": "Jake Teton-Landis", 13 | "url": "https://jake.tl" 14 | }, 15 | "scripts": { 16 | "build": "yarn build:c && yarn build:ts", 17 | "build:c": "make -j2", 18 | "build:ts": "npx tsup", 19 | "check:types": "npx tsc --project . --noEmit", 20 | "clean": "make clean", 21 | "prepare": "yarn clean && yarn build" 22 | }, 23 | "files": [ 24 | "LICENSE", 25 | "README.md", 26 | "dist/**/*", 27 | "!dist/*.tsbuildinfo" 28 | ], 29 | "types": "./dist/index.d.mts", 30 | "main": "./dist/index.mjs", 31 | "module": "./dist/index.mjs", 32 | "browser": "./dist/index.mjs", 33 | "exports": { 34 | ".": { 35 | "types": "./dist/index.d.mts", 36 | "import": "./dist/index.mjs", 37 | "default": "./dist/index.mjs" 38 | }, 39 | "./package.json": "./package.json", 40 | "./ffi": { 41 | "types": "./dist/ffi.d.mts", 42 | "import": "./dist/ffi.mjs", 43 | "default": "./dist/ffi.mjs" 44 | }, 45 | "./emscripten-module": { 46 | "types": "./dist/emscripten-module.browser.d.ts", 47 | "browser": "./dist/emscripten-module.browser.mjs", 48 | "import": "./dist/emscripten-module.browser.mjs", 49 | "default": "./dist/emscripten-module.browser.mjs" 50 | } 51 | }, 52 | "dependencies": { 53 | "@jitl/quickjs-ffi-types": "workspace:*" 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-browser-debug-sync/src/index.ts: -------------------------------------------------------------------------------- 1 | import type { QuickJSSyncVariant } from "@jitl/quickjs-ffi-types" 2 | 3 | /** 4 | * ### @jitl/quickjs-singlefile-browser-debug-sync 5 | * 6 | * [Docs](https://github.com/justjake/quickjs-emscripten/blob/main/doc/@jitl/quickjs-singlefile-browser-debug-sync/README.md) | 7 | * Variant with the WASM data embedded into a browser ESModule. 8 | * 9 | * | Variable | Setting | Description | 10 | * | -- | -- | -- | 11 | * | library | quickjs | The original [bellard/quickjs](https://github.com/bellard/quickjs) library. Version [2024-02-14+36911f0d](https://github.com/bellard/quickjs/commit/36911f0d3ab1a4c190a4d5cbe7c2db225a455389) vendored to quickjs-emscripten on 2024-06-15. | 12 | * | releaseMode | debug | Enables assertions and memory sanitizers. Try to run your tests against debug variants, in addition to your preferred production variant, to catch more bugs. | 13 | * | syncMode | sync | The default, normal build. Note that both variants support regular async functions. | 14 | * | emscriptenInclusion | singlefile | The WASM runtime is included directly in the JS file. Use if you run into issues with missing .wasm files when building or deploying your app. | 15 | * | exports | browser | Has these package.json export conditions | 16 | * 17 | */ 18 | const variant: QuickJSSyncVariant = { 19 | type: "sync", 20 | importFFI: () => import("./ffi.js").then((mod) => mod.QuickJSFFI), 21 | importModuleLoader: () => 22 | import("@jitl/quickjs-singlefile-browser-debug-sync/emscripten-module").then( 23 | (mod) => mod.default, 24 | ), 25 | } as const 26 | 27 | export default variant 28 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-browser-debug-sync/tsconfig.json: -------------------------------------------------------------------------------- 1 | { "extends": "@jitl/tsconfig/tsconfig.json", "include": ["src/*"], "exclude": ["node_modules"] } 2 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-browser-debug-sync/tsup.config.ts: -------------------------------------------------------------------------------- 1 | import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" 2 | export default extendConfig({ 3 | entry: ["src/index.ts", "src/ffi.ts"], 4 | external: [], 5 | format: ["esm"], 6 | clean: false, 7 | }) 8 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-browser-debug-sync/typedoc.json: -------------------------------------------------------------------------------- 1 | { "extends": "../../typedoc.base.js", "entryPoints": ["./src/index.ts"], "mergeReadme": true } 2 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-browser-release-asyncify/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@jitl/quickjs-singlefile-browser-release-asyncify", 3 | "license": "MIT", 4 | "version": "0.31.0", 5 | "description": "Variant of quickjs library: Variant with the WASM data embedded into a browser ESModule.", 6 | "sideEffects": false, 7 | "repository": { 8 | "type": "git", 9 | "url": "https://github.com/justjake/quickjs-emscripten" 10 | }, 11 | "author": { 12 | "name": "Jake Teton-Landis", 13 | "url": "https://jake.tl" 14 | }, 15 | "scripts": { 16 | "build": "yarn build:c && yarn build:ts", 17 | "build:c": "make -j2", 18 | "build:ts": "npx tsup", 19 | "check:types": "npx tsc --project . --noEmit", 20 | "clean": "make clean", 21 | "prepare": "yarn clean && yarn build" 22 | }, 23 | "files": [ 24 | "LICENSE", 25 | "README.md", 26 | "dist/**/*", 27 | "!dist/*.tsbuildinfo" 28 | ], 29 | "types": "./dist/index.d.mts", 30 | "main": "./dist/index.mjs", 31 | "module": "./dist/index.mjs", 32 | "browser": "./dist/index.mjs", 33 | "exports": { 34 | ".": { 35 | "types": "./dist/index.d.mts", 36 | "import": "./dist/index.mjs", 37 | "default": "./dist/index.mjs" 38 | }, 39 | "./package.json": "./package.json", 40 | "./ffi": { 41 | "types": "./dist/ffi.d.mts", 42 | "import": "./dist/ffi.mjs", 43 | "default": "./dist/ffi.mjs" 44 | }, 45 | "./emscripten-module": { 46 | "types": "./dist/emscripten-module.browser.d.ts", 47 | "browser": "./dist/emscripten-module.browser.mjs", 48 | "import": "./dist/emscripten-module.browser.mjs", 49 | "default": "./dist/emscripten-module.browser.mjs" 50 | } 51 | }, 52 | "dependencies": { 53 | "@jitl/quickjs-ffi-types": "workspace:*" 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-browser-release-asyncify/tsconfig.json: -------------------------------------------------------------------------------- 1 | { "extends": "@jitl/tsconfig/tsconfig.json", "include": ["src/*"], "exclude": ["node_modules"] } 2 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-browser-release-asyncify/tsup.config.ts: -------------------------------------------------------------------------------- 1 | import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" 2 | export default extendConfig({ 3 | entry: ["src/index.ts", "src/ffi.ts"], 4 | external: [], 5 | format: ["esm"], 6 | clean: false, 7 | }) 8 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-browser-release-asyncify/typedoc.json: -------------------------------------------------------------------------------- 1 | { "extends": "../../typedoc.base.js", "entryPoints": ["./src/index.ts"], "mergeReadme": true } 2 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-browser-release-sync/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@jitl/quickjs-singlefile-browser-release-sync", 3 | "license": "MIT", 4 | "version": "0.31.0", 5 | "description": "Variant of quickjs library: Variant with the WASM data embedded into a browser ESModule.", 6 | "sideEffects": false, 7 | "repository": { 8 | "type": "git", 9 | "url": "https://github.com/justjake/quickjs-emscripten" 10 | }, 11 | "author": { 12 | "name": "Jake Teton-Landis", 13 | "url": "https://jake.tl" 14 | }, 15 | "scripts": { 16 | "build": "yarn build:c && yarn build:ts", 17 | "build:c": "make -j2", 18 | "build:ts": "npx tsup", 19 | "check:types": "npx tsc --project . --noEmit", 20 | "clean": "make clean", 21 | "prepare": "yarn clean && yarn build" 22 | }, 23 | "files": [ 24 | "LICENSE", 25 | "README.md", 26 | "dist/**/*", 27 | "!dist/*.tsbuildinfo" 28 | ], 29 | "types": "./dist/index.d.mts", 30 | "main": "./dist/index.mjs", 31 | "module": "./dist/index.mjs", 32 | "browser": "./dist/index.mjs", 33 | "exports": { 34 | ".": { 35 | "types": "./dist/index.d.mts", 36 | "import": "./dist/index.mjs", 37 | "default": "./dist/index.mjs" 38 | }, 39 | "./package.json": "./package.json", 40 | "./ffi": { 41 | "types": "./dist/ffi.d.mts", 42 | "import": "./dist/ffi.mjs", 43 | "default": "./dist/ffi.mjs" 44 | }, 45 | "./emscripten-module": { 46 | "types": "./dist/emscripten-module.browser.d.ts", 47 | "browser": "./dist/emscripten-module.browser.mjs", 48 | "import": "./dist/emscripten-module.browser.mjs", 49 | "default": "./dist/emscripten-module.browser.mjs" 50 | } 51 | }, 52 | "dependencies": { 53 | "@jitl/quickjs-ffi-types": "workspace:*" 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-browser-release-sync/src/index.ts: -------------------------------------------------------------------------------- 1 | import type { QuickJSSyncVariant } from "@jitl/quickjs-ffi-types" 2 | 3 | /** 4 | * ### @jitl/quickjs-singlefile-browser-release-sync 5 | * 6 | * [Docs](https://github.com/justjake/quickjs-emscripten/blob/main/doc/@jitl/quickjs-singlefile-browser-release-sync/README.md) | 7 | * Variant with the WASM data embedded into a browser ESModule. 8 | * 9 | * | Variable | Setting | Description | 10 | * | -- | -- | -- | 11 | * | library | quickjs | The original [bellard/quickjs](https://github.com/bellard/quickjs) library. Version [2024-02-14+36911f0d](https://github.com/bellard/quickjs/commit/36911f0d3ab1a4c190a4d5cbe7c2db225a455389) vendored to quickjs-emscripten on 2024-06-15. | 12 | * | releaseMode | release | Optimized for performance; use when building/deploying your application. | 13 | * | syncMode | sync | The default, normal build. Note that both variants support regular async functions. | 14 | * | emscriptenInclusion | singlefile | The WASM runtime is included directly in the JS file. Use if you run into issues with missing .wasm files when building or deploying your app. | 15 | * | exports | browser | Has these package.json export conditions | 16 | * 17 | */ 18 | const variant: QuickJSSyncVariant = { 19 | type: "sync", 20 | importFFI: () => import("./ffi.js").then((mod) => mod.QuickJSFFI), 21 | importModuleLoader: () => 22 | import("@jitl/quickjs-singlefile-browser-release-sync/emscripten-module").then( 23 | (mod) => mod.default, 24 | ), 25 | } as const 26 | 27 | export default variant 28 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-browser-release-sync/tsconfig.json: -------------------------------------------------------------------------------- 1 | { "extends": "@jitl/tsconfig/tsconfig.json", "include": ["src/*"], "exclude": ["node_modules"] } 2 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-browser-release-sync/tsup.config.ts: -------------------------------------------------------------------------------- 1 | import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" 2 | export default extendConfig({ 3 | entry: ["src/index.ts", "src/ffi.ts"], 4 | external: [], 5 | format: ["esm"], 6 | clean: false, 7 | }) 8 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-browser-release-sync/typedoc.json: -------------------------------------------------------------------------------- 1 | { "extends": "../../typedoc.base.js", "entryPoints": ["./src/index.ts"], "mergeReadme": true } 2 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-cjs-debug-asyncify/tsconfig.json: -------------------------------------------------------------------------------- 1 | { "extends": "@jitl/tsconfig/tsconfig.json", "include": ["src/*"], "exclude": ["node_modules"] } 2 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-cjs-debug-asyncify/tsup.config.ts: -------------------------------------------------------------------------------- 1 | import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" 2 | export default extendConfig({ 3 | entry: ["src/index.ts", "src/ffi.ts"], 4 | external: [], 5 | format: ["cjs"], 6 | clean: false, 7 | }) 8 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-cjs-debug-asyncify/typedoc.json: -------------------------------------------------------------------------------- 1 | { "extends": "../../typedoc.base.js", "entryPoints": ["./src/index.ts"], "mergeReadme": true } 2 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-cjs-debug-sync/src/index.ts: -------------------------------------------------------------------------------- 1 | import type { QuickJSSyncVariant } from "@jitl/quickjs-ffi-types" 2 | 3 | /** 4 | * ### @jitl/quickjs-singlefile-cjs-debug-sync 5 | * 6 | * [Docs](https://github.com/justjake/quickjs-emscripten/blob/main/doc/@jitl/quickjs-singlefile-cjs-debug-sync/README.md) | 7 | * Variant with the WASM data embedded into a universal (Node and Browser compatible) CommonJS module. 8 | * 9 | * | Variable | Setting | Description | 10 | * | -- | -- | -- | 11 | * | library | quickjs | The original [bellard/quickjs](https://github.com/bellard/quickjs) library. Version [2024-02-14+36911f0d](https://github.com/bellard/quickjs/commit/36911f0d3ab1a4c190a4d5cbe7c2db225a455389) vendored to quickjs-emscripten on 2024-06-15. | 12 | * | releaseMode | debug | Enables assertions and memory sanitizers. Try to run your tests against debug variants, in addition to your preferred production variant, to catch more bugs. | 13 | * | syncMode | sync | The default, normal build. Note that both variants support regular async functions. | 14 | * | emscriptenInclusion | singlefile | The WASM runtime is included directly in the JS file. Use if you run into issues with missing .wasm files when building or deploying your app. | 15 | * | exports | require | Has these package.json export conditions | 16 | * 17 | */ 18 | const variant: QuickJSSyncVariant = { 19 | type: "sync", 20 | importFFI: () => import("./ffi.js").then((mod) => mod.QuickJSFFI), 21 | importModuleLoader: () => 22 | import("@jitl/quickjs-singlefile-cjs-debug-sync/emscripten-module").then((mod) => mod.default), 23 | } as const 24 | 25 | export default variant 26 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-cjs-debug-sync/tsconfig.json: -------------------------------------------------------------------------------- 1 | { "extends": "@jitl/tsconfig/tsconfig.json", "include": ["src/*"], "exclude": ["node_modules"] } 2 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-cjs-debug-sync/tsup.config.ts: -------------------------------------------------------------------------------- 1 | import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" 2 | export default extendConfig({ 3 | entry: ["src/index.ts", "src/ffi.ts"], 4 | external: [], 5 | format: ["cjs"], 6 | clean: false, 7 | }) 8 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-cjs-debug-sync/typedoc.json: -------------------------------------------------------------------------------- 1 | { "extends": "../../typedoc.base.js", "entryPoints": ["./src/index.ts"], "mergeReadme": true } 2 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-cjs-release-asyncify/tsconfig.json: -------------------------------------------------------------------------------- 1 | { "extends": "@jitl/tsconfig/tsconfig.json", "include": ["src/*"], "exclude": ["node_modules"] } 2 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-cjs-release-asyncify/tsup.config.ts: -------------------------------------------------------------------------------- 1 | import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" 2 | export default extendConfig({ 3 | entry: ["src/index.ts", "src/ffi.ts"], 4 | external: [], 5 | format: ["cjs"], 6 | clean: false, 7 | }) 8 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-cjs-release-asyncify/typedoc.json: -------------------------------------------------------------------------------- 1 | { "extends": "../../typedoc.base.js", "entryPoints": ["./src/index.ts"], "mergeReadme": true } 2 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-cjs-release-sync/src/index.ts: -------------------------------------------------------------------------------- 1 | import type { QuickJSSyncVariant } from "@jitl/quickjs-ffi-types" 2 | 3 | /** 4 | * ### @jitl/quickjs-singlefile-cjs-release-sync 5 | * 6 | * [Docs](https://github.com/justjake/quickjs-emscripten/blob/main/doc/@jitl/quickjs-singlefile-cjs-release-sync/README.md) | 7 | * Variant with the WASM data embedded into a universal (Node and Browser compatible) CommonJS module. 8 | * 9 | * | Variable | Setting | Description | 10 | * | -- | -- | -- | 11 | * | library | quickjs | The original [bellard/quickjs](https://github.com/bellard/quickjs) library. Version [2024-02-14+36911f0d](https://github.com/bellard/quickjs/commit/36911f0d3ab1a4c190a4d5cbe7c2db225a455389) vendored to quickjs-emscripten on 2024-06-15. | 12 | * | releaseMode | release | Optimized for performance; use when building/deploying your application. | 13 | * | syncMode | sync | The default, normal build. Note that both variants support regular async functions. | 14 | * | emscriptenInclusion | singlefile | The WASM runtime is included directly in the JS file. Use if you run into issues with missing .wasm files when building or deploying your app. | 15 | * | exports | require | Has these package.json export conditions | 16 | * 17 | */ 18 | const variant: QuickJSSyncVariant = { 19 | type: "sync", 20 | importFFI: () => import("./ffi.js").then((mod) => mod.QuickJSFFI), 21 | importModuleLoader: () => 22 | import("@jitl/quickjs-singlefile-cjs-release-sync/emscripten-module").then( 23 | (mod) => mod.default, 24 | ), 25 | } as const 26 | 27 | export default variant 28 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-cjs-release-sync/tsconfig.json: -------------------------------------------------------------------------------- 1 | { "extends": "@jitl/tsconfig/tsconfig.json", "include": ["src/*"], "exclude": ["node_modules"] } 2 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-cjs-release-sync/tsup.config.ts: -------------------------------------------------------------------------------- 1 | import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" 2 | export default extendConfig({ 3 | entry: ["src/index.ts", "src/ffi.ts"], 4 | external: [], 5 | format: ["cjs"], 6 | clean: false, 7 | }) 8 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-cjs-release-sync/typedoc.json: -------------------------------------------------------------------------------- 1 | { "extends": "../../typedoc.base.js", "entryPoints": ["./src/index.ts"], "mergeReadme": true } 2 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-mjs-debug-asyncify/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@jitl/quickjs-singlefile-mjs-debug-asyncify", 3 | "license": "MIT", 4 | "version": "0.31.0", 5 | "description": "Variant of quickjs library: Variant with the WASM data embedded into a NodeJS ESModule.", 6 | "sideEffects": false, 7 | "repository": { 8 | "type": "git", 9 | "url": "https://github.com/justjake/quickjs-emscripten" 10 | }, 11 | "author": { 12 | "name": "Jake Teton-Landis", 13 | "url": "https://jake.tl" 14 | }, 15 | "scripts": { 16 | "build": "yarn build:c && yarn build:ts", 17 | "build:c": "make -j2", 18 | "build:ts": "npx tsup", 19 | "check:types": "npx tsc --project . --noEmit", 20 | "clean": "make clean", 21 | "prepare": "yarn clean && yarn build" 22 | }, 23 | "files": [ 24 | "LICENSE", 25 | "README.md", 26 | "dist/**/*", 27 | "!dist/*.tsbuildinfo" 28 | ], 29 | "types": "./dist/index.d.mts", 30 | "main": "./dist/index.mjs", 31 | "module": "./dist/index.mjs", 32 | "exports": { 33 | ".": { 34 | "types": "./dist/index.d.mts", 35 | "import": "./dist/index.mjs", 36 | "default": "./dist/index.mjs" 37 | }, 38 | "./package.json": "./package.json", 39 | "./ffi": { 40 | "types": "./dist/ffi.d.mts", 41 | "import": "./dist/ffi.mjs", 42 | "default": "./dist/ffi.mjs" 43 | }, 44 | "./emscripten-module": { 45 | "types": "./dist/emscripten-module.d.ts", 46 | "import": "./dist/emscripten-module.mjs", 47 | "default": "./dist/emscripten-module.mjs" 48 | } 49 | }, 50 | "dependencies": { 51 | "@jitl/quickjs-ffi-types": "workspace:*" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-mjs-debug-asyncify/tsconfig.json: -------------------------------------------------------------------------------- 1 | { "extends": "@jitl/tsconfig/tsconfig.json", "include": ["src/*"], "exclude": ["node_modules"] } 2 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-mjs-debug-asyncify/tsup.config.ts: -------------------------------------------------------------------------------- 1 | import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" 2 | export default extendConfig({ 3 | entry: ["src/index.ts", "src/ffi.ts"], 4 | external: [], 5 | format: ["esm"], 6 | clean: false, 7 | }) 8 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-mjs-debug-asyncify/typedoc.json: -------------------------------------------------------------------------------- 1 | { "extends": "../../typedoc.base.js", "entryPoints": ["./src/index.ts"], "mergeReadme": true } 2 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-mjs-debug-sync/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@jitl/quickjs-singlefile-mjs-debug-sync", 3 | "license": "MIT", 4 | "version": "0.31.0", 5 | "description": "Variant of quickjs library: Variant with the WASM data embedded into a NodeJS ESModule.", 6 | "sideEffects": false, 7 | "repository": { 8 | "type": "git", 9 | "url": "https://github.com/justjake/quickjs-emscripten" 10 | }, 11 | "author": { 12 | "name": "Jake Teton-Landis", 13 | "url": "https://jake.tl" 14 | }, 15 | "scripts": { 16 | "build": "yarn build:c && yarn build:ts", 17 | "build:c": "make -j2", 18 | "build:ts": "npx tsup", 19 | "check:types": "npx tsc --project . --noEmit", 20 | "clean": "make clean", 21 | "prepare": "yarn clean && yarn build" 22 | }, 23 | "files": [ 24 | "LICENSE", 25 | "README.md", 26 | "dist/**/*", 27 | "!dist/*.tsbuildinfo" 28 | ], 29 | "types": "./dist/index.d.mts", 30 | "main": "./dist/index.mjs", 31 | "module": "./dist/index.mjs", 32 | "exports": { 33 | ".": { 34 | "types": "./dist/index.d.mts", 35 | "import": "./dist/index.mjs", 36 | "default": "./dist/index.mjs" 37 | }, 38 | "./package.json": "./package.json", 39 | "./ffi": { 40 | "types": "./dist/ffi.d.mts", 41 | "import": "./dist/ffi.mjs", 42 | "default": "./dist/ffi.mjs" 43 | }, 44 | "./emscripten-module": { 45 | "types": "./dist/emscripten-module.d.ts", 46 | "import": "./dist/emscripten-module.mjs", 47 | "default": "./dist/emscripten-module.mjs" 48 | } 49 | }, 50 | "dependencies": { 51 | "@jitl/quickjs-ffi-types": "workspace:*" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-mjs-debug-sync/src/index.ts: -------------------------------------------------------------------------------- 1 | import type { QuickJSSyncVariant } from "@jitl/quickjs-ffi-types" 2 | 3 | /** 4 | * ### @jitl/quickjs-singlefile-mjs-debug-sync 5 | * 6 | * [Docs](https://github.com/justjake/quickjs-emscripten/blob/main/doc/@jitl/quickjs-singlefile-mjs-debug-sync/README.md) | 7 | * Variant with the WASM data embedded into a NodeJS ESModule. 8 | * 9 | * | Variable | Setting | Description | 10 | * | -- | -- | -- | 11 | * | library | quickjs | The original [bellard/quickjs](https://github.com/bellard/quickjs) library. Version [2024-02-14+36911f0d](https://github.com/bellard/quickjs/commit/36911f0d3ab1a4c190a4d5cbe7c2db225a455389) vendored to quickjs-emscripten on 2024-06-15. | 12 | * | releaseMode | debug | Enables assertions and memory sanitizers. Try to run your tests against debug variants, in addition to your preferred production variant, to catch more bugs. | 13 | * | syncMode | sync | The default, normal build. Note that both variants support regular async functions. | 14 | * | emscriptenInclusion | singlefile | The WASM runtime is included directly in the JS file. Use if you run into issues with missing .wasm files when building or deploying your app. | 15 | * | exports | import | Has these package.json export conditions | 16 | * 17 | */ 18 | const variant: QuickJSSyncVariant = { 19 | type: "sync", 20 | importFFI: () => import("./ffi.js").then((mod) => mod.QuickJSFFI), 21 | importModuleLoader: () => 22 | import("@jitl/quickjs-singlefile-mjs-debug-sync/emscripten-module").then((mod) => mod.default), 23 | } as const 24 | 25 | export default variant 26 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-mjs-debug-sync/tsconfig.json: -------------------------------------------------------------------------------- 1 | { "extends": "@jitl/tsconfig/tsconfig.json", "include": ["src/*"], "exclude": ["node_modules"] } 2 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-mjs-debug-sync/tsup.config.ts: -------------------------------------------------------------------------------- 1 | import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" 2 | export default extendConfig({ 3 | entry: ["src/index.ts", "src/ffi.ts"], 4 | external: [], 5 | format: ["esm"], 6 | clean: false, 7 | }) 8 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-mjs-debug-sync/typedoc.json: -------------------------------------------------------------------------------- 1 | { "extends": "../../typedoc.base.js", "entryPoints": ["./src/index.ts"], "mergeReadme": true } 2 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-mjs-release-asyncify/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@jitl/quickjs-singlefile-mjs-release-asyncify", 3 | "license": "MIT", 4 | "version": "0.31.0", 5 | "description": "Variant of quickjs library: Variant with the WASM data embedded into a NodeJS ESModule.", 6 | "sideEffects": false, 7 | "repository": { 8 | "type": "git", 9 | "url": "https://github.com/justjake/quickjs-emscripten" 10 | }, 11 | "author": { 12 | "name": "Jake Teton-Landis", 13 | "url": "https://jake.tl" 14 | }, 15 | "scripts": { 16 | "build": "yarn build:c && yarn build:ts", 17 | "build:c": "make -j2", 18 | "build:ts": "npx tsup", 19 | "check:types": "npx tsc --project . --noEmit", 20 | "clean": "make clean", 21 | "prepare": "yarn clean && yarn build" 22 | }, 23 | "files": [ 24 | "LICENSE", 25 | "README.md", 26 | "dist/**/*", 27 | "!dist/*.tsbuildinfo" 28 | ], 29 | "types": "./dist/index.d.mts", 30 | "main": "./dist/index.mjs", 31 | "module": "./dist/index.mjs", 32 | "exports": { 33 | ".": { 34 | "types": "./dist/index.d.mts", 35 | "import": "./dist/index.mjs", 36 | "default": "./dist/index.mjs" 37 | }, 38 | "./package.json": "./package.json", 39 | "./ffi": { 40 | "types": "./dist/ffi.d.mts", 41 | "import": "./dist/ffi.mjs", 42 | "default": "./dist/ffi.mjs" 43 | }, 44 | "./emscripten-module": { 45 | "types": "./dist/emscripten-module.d.ts", 46 | "import": "./dist/emscripten-module.mjs", 47 | "default": "./dist/emscripten-module.mjs" 48 | } 49 | }, 50 | "dependencies": { 51 | "@jitl/quickjs-ffi-types": "workspace:*" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-mjs-release-asyncify/tsconfig.json: -------------------------------------------------------------------------------- 1 | { "extends": "@jitl/tsconfig/tsconfig.json", "include": ["src/*"], "exclude": ["node_modules"] } 2 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-mjs-release-asyncify/tsup.config.ts: -------------------------------------------------------------------------------- 1 | import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" 2 | export default extendConfig({ 3 | entry: ["src/index.ts", "src/ffi.ts"], 4 | external: [], 5 | format: ["esm"], 6 | clean: false, 7 | }) 8 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-mjs-release-asyncify/typedoc.json: -------------------------------------------------------------------------------- 1 | { "extends": "../../typedoc.base.js", "entryPoints": ["./src/index.ts"], "mergeReadme": true } 2 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-mjs-release-sync/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@jitl/quickjs-singlefile-mjs-release-sync", 3 | "license": "MIT", 4 | "version": "0.31.0", 5 | "description": "Variant of quickjs library: Variant with the WASM data embedded into a NodeJS ESModule.", 6 | "sideEffects": false, 7 | "repository": { 8 | "type": "git", 9 | "url": "https://github.com/justjake/quickjs-emscripten" 10 | }, 11 | "author": { 12 | "name": "Jake Teton-Landis", 13 | "url": "https://jake.tl" 14 | }, 15 | "scripts": { 16 | "build": "yarn build:c && yarn build:ts", 17 | "build:c": "make -j2", 18 | "build:ts": "npx tsup", 19 | "check:types": "npx tsc --project . --noEmit", 20 | "clean": "make clean", 21 | "prepare": "yarn clean && yarn build" 22 | }, 23 | "files": [ 24 | "LICENSE", 25 | "README.md", 26 | "dist/**/*", 27 | "!dist/*.tsbuildinfo" 28 | ], 29 | "types": "./dist/index.d.mts", 30 | "main": "./dist/index.mjs", 31 | "module": "./dist/index.mjs", 32 | "exports": { 33 | ".": { 34 | "types": "./dist/index.d.mts", 35 | "import": "./dist/index.mjs", 36 | "default": "./dist/index.mjs" 37 | }, 38 | "./package.json": "./package.json", 39 | "./ffi": { 40 | "types": "./dist/ffi.d.mts", 41 | "import": "./dist/ffi.mjs", 42 | "default": "./dist/ffi.mjs" 43 | }, 44 | "./emscripten-module": { 45 | "types": "./dist/emscripten-module.d.ts", 46 | "import": "./dist/emscripten-module.mjs", 47 | "default": "./dist/emscripten-module.mjs" 48 | } 49 | }, 50 | "dependencies": { 51 | "@jitl/quickjs-ffi-types": "workspace:*" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-mjs-release-sync/src/index.ts: -------------------------------------------------------------------------------- 1 | import type { QuickJSSyncVariant } from "@jitl/quickjs-ffi-types" 2 | 3 | /** 4 | * ### @jitl/quickjs-singlefile-mjs-release-sync 5 | * 6 | * [Docs](https://github.com/justjake/quickjs-emscripten/blob/main/doc/@jitl/quickjs-singlefile-mjs-release-sync/README.md) | 7 | * Variant with the WASM data embedded into a NodeJS ESModule. 8 | * 9 | * | Variable | Setting | Description | 10 | * | -- | -- | -- | 11 | * | library | quickjs | The original [bellard/quickjs](https://github.com/bellard/quickjs) library. Version [2024-02-14+36911f0d](https://github.com/bellard/quickjs/commit/36911f0d3ab1a4c190a4d5cbe7c2db225a455389) vendored to quickjs-emscripten on 2024-06-15. | 12 | * | releaseMode | release | Optimized for performance; use when building/deploying your application. | 13 | * | syncMode | sync | The default, normal build. Note that both variants support regular async functions. | 14 | * | emscriptenInclusion | singlefile | The WASM runtime is included directly in the JS file. Use if you run into issues with missing .wasm files when building or deploying your app. | 15 | * | exports | import | Has these package.json export conditions | 16 | * 17 | */ 18 | const variant: QuickJSSyncVariant = { 19 | type: "sync", 20 | importFFI: () => import("./ffi.js").then((mod) => mod.QuickJSFFI), 21 | importModuleLoader: () => 22 | import("@jitl/quickjs-singlefile-mjs-release-sync/emscripten-module").then( 23 | (mod) => mod.default, 24 | ), 25 | } as const 26 | 27 | export default variant 28 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-mjs-release-sync/tsconfig.json: -------------------------------------------------------------------------------- 1 | { "extends": "@jitl/tsconfig/tsconfig.json", "include": ["src/*"], "exclude": ["node_modules"] } 2 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-mjs-release-sync/tsup.config.ts: -------------------------------------------------------------------------------- 1 | import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" 2 | export default extendConfig({ 3 | entry: ["src/index.ts", "src/ffi.ts"], 4 | external: [], 5 | format: ["esm"], 6 | clean: false, 7 | }) 8 | -------------------------------------------------------------------------------- /packages/variant-quickjs-singlefile-mjs-release-sync/typedoc.json: -------------------------------------------------------------------------------- 1 | { "extends": "../../typedoc.base.js", "entryPoints": ["./src/index.ts"], "mergeReadme": true } 2 | -------------------------------------------------------------------------------- /packages/variant-quickjs-wasmfile-debug-asyncify/tsconfig.json: -------------------------------------------------------------------------------- 1 | { "extends": "@jitl/tsconfig/tsconfig.json", "include": ["src/*"], "exclude": ["node_modules"] } 2 | -------------------------------------------------------------------------------- /packages/variant-quickjs-wasmfile-debug-asyncify/tsup.config.ts: -------------------------------------------------------------------------------- 1 | import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" 2 | export default extendConfig({ 3 | entry: ["src/index.ts", "src/ffi.ts"], 4 | external: ["@jitl/quickjs-wasmfile-debug-asyncify/emscripten-module"], 5 | format: ["esm", "cjs"], 6 | clean: false, 7 | }) 8 | -------------------------------------------------------------------------------- /packages/variant-quickjs-wasmfile-debug-asyncify/typedoc.json: -------------------------------------------------------------------------------- 1 | { "extends": "../../typedoc.base.js", "entryPoints": ["./src/index.ts"], "mergeReadme": true } 2 | -------------------------------------------------------------------------------- /packages/variant-quickjs-wasmfile-debug-sync/src/index.ts: -------------------------------------------------------------------------------- 1 | import type { QuickJSSyncVariant } from "@jitl/quickjs-ffi-types" 2 | 3 | /** 4 | * ### @jitl/quickjs-wasmfile-debug-sync 5 | * 6 | * [Docs](https://github.com/justjake/quickjs-emscripten/blob/main/doc/@jitl/quickjs-wasmfile-debug-sync/README.md) | 7 | * Variant with separate .WASM file. Supports browser ESM, NodeJS ESM, and NodeJS CommonJS. 8 | * 9 | * | Variable | Setting | Description | 10 | * | -- | -- | -- | 11 | * | library | quickjs | The original [bellard/quickjs](https://github.com/bellard/quickjs) library. Version [2024-02-14+36911f0d](https://github.com/bellard/quickjs/commit/36911f0d3ab1a4c190a4d5cbe7c2db225a455389) vendored to quickjs-emscripten on 2024-06-15. | 12 | * | releaseMode | debug | Enables assertions and memory sanitizers. Try to run your tests against debug variants, in addition to your preferred production variant, to catch more bugs. | 13 | * | syncMode | sync | The default, normal build. Note that both variants support regular async functions. | 14 | * | emscriptenInclusion | wasm | Has a separate .wasm file. May offer better caching in your browser, and reduces the size of your JS bundle. If you have issues, try a 'singlefile' variant. | 15 | * | exports | require import browser workerd | Has these package.json export conditions | 16 | * 17 | */ 18 | const variant: QuickJSSyncVariant = { 19 | type: "sync", 20 | importFFI: () => import("./ffi.js").then((mod) => mod.QuickJSFFI), 21 | importModuleLoader: () => 22 | import("@jitl/quickjs-wasmfile-debug-sync/emscripten-module").then((mod) => mod.default), 23 | } as const 24 | 25 | export default variant 26 | -------------------------------------------------------------------------------- /packages/variant-quickjs-wasmfile-debug-sync/tsconfig.json: -------------------------------------------------------------------------------- 1 | { "extends": "@jitl/tsconfig/tsconfig.json", "include": ["src/*"], "exclude": ["node_modules"] } 2 | -------------------------------------------------------------------------------- /packages/variant-quickjs-wasmfile-debug-sync/tsup.config.ts: -------------------------------------------------------------------------------- 1 | import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" 2 | export default extendConfig({ 3 | entry: ["src/index.ts", "src/ffi.ts"], 4 | external: ["@jitl/quickjs-wasmfile-debug-sync/emscripten-module"], 5 | format: ["esm", "cjs"], 6 | clean: false, 7 | }) 8 | -------------------------------------------------------------------------------- /packages/variant-quickjs-wasmfile-debug-sync/typedoc.json: -------------------------------------------------------------------------------- 1 | { "extends": "../../typedoc.base.js", "entryPoints": ["./src/index.ts"], "mergeReadme": true } 2 | -------------------------------------------------------------------------------- /packages/variant-quickjs-wasmfile-release-asyncify/tsconfig.json: -------------------------------------------------------------------------------- 1 | { "extends": "@jitl/tsconfig/tsconfig.json", "include": ["src/*"], "exclude": ["node_modules"] } 2 | -------------------------------------------------------------------------------- /packages/variant-quickjs-wasmfile-release-asyncify/tsup.config.ts: -------------------------------------------------------------------------------- 1 | import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" 2 | export default extendConfig({ 3 | entry: ["src/index.ts", "src/ffi.ts"], 4 | external: ["@jitl/quickjs-wasmfile-release-asyncify/emscripten-module"], 5 | format: ["esm", "cjs"], 6 | clean: false, 7 | }) 8 | -------------------------------------------------------------------------------- /packages/variant-quickjs-wasmfile-release-asyncify/typedoc.json: -------------------------------------------------------------------------------- 1 | { "extends": "../../typedoc.base.js", "entryPoints": ["./src/index.ts"], "mergeReadme": true } 2 | -------------------------------------------------------------------------------- /packages/variant-quickjs-wasmfile-release-sync/src/index.ts: -------------------------------------------------------------------------------- 1 | import type { QuickJSSyncVariant } from "@jitl/quickjs-ffi-types" 2 | 3 | /** 4 | * ### @jitl/quickjs-wasmfile-release-sync 5 | * 6 | * [Docs](https://github.com/justjake/quickjs-emscripten/blob/main/doc/@jitl/quickjs-wasmfile-release-sync/README.md) | 7 | * Variant with separate .WASM file. Supports browser ESM, NodeJS ESM, and NodeJS CommonJS. 8 | * 9 | * | Variable | Setting | Description | 10 | * | -- | -- | -- | 11 | * | library | quickjs | The original [bellard/quickjs](https://github.com/bellard/quickjs) library. Version [2024-02-14+36911f0d](https://github.com/bellard/quickjs/commit/36911f0d3ab1a4c190a4d5cbe7c2db225a455389) vendored to quickjs-emscripten on 2024-06-15. | 12 | * | releaseMode | release | Optimized for performance; use when building/deploying your application. | 13 | * | syncMode | sync | The default, normal build. Note that both variants support regular async functions. | 14 | * | emscriptenInclusion | wasm | Has a separate .wasm file. May offer better caching in your browser, and reduces the size of your JS bundle. If you have issues, try a 'singlefile' variant. | 15 | * | exports | require import browser workerd | Has these package.json export conditions | 16 | * 17 | */ 18 | const variant: QuickJSSyncVariant = { 19 | type: "sync", 20 | importFFI: () => import("./ffi.js").then((mod) => mod.QuickJSFFI), 21 | importModuleLoader: () => 22 | import("@jitl/quickjs-wasmfile-release-sync/emscripten-module").then((mod) => mod.default), 23 | } as const 24 | 25 | export default variant 26 | -------------------------------------------------------------------------------- /packages/variant-quickjs-wasmfile-release-sync/tsconfig.json: -------------------------------------------------------------------------------- 1 | { "extends": "@jitl/tsconfig/tsconfig.json", "include": ["src/*"], "exclude": ["node_modules"] } 2 | -------------------------------------------------------------------------------- /packages/variant-quickjs-wasmfile-release-sync/tsup.config.ts: -------------------------------------------------------------------------------- 1 | import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" 2 | export default extendConfig({ 3 | entry: ["src/index.ts", "src/ffi.ts"], 4 | external: ["@jitl/quickjs-wasmfile-release-sync/emscripten-module"], 5 | format: ["esm", "cjs"], 6 | clean: false, 7 | }) 8 | -------------------------------------------------------------------------------- /packages/variant-quickjs-wasmfile-release-sync/typedoc.json: -------------------------------------------------------------------------------- 1 | { "extends": "../../typedoc.base.js", "entryPoints": ["./src/index.ts"], "mergeReadme": true } 2 | -------------------------------------------------------------------------------- /scripts/emcc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Use system emcc if installed, otherwise use Docker. 3 | set -eo pipefail 4 | 5 | if [[ -z "$EMSDK_USE_DOCKER" ]] && command -v emcc >/dev/null; then 6 | if emcc --version | grep "$EMSDK_VERSION" >/dev/null; then 7 | exec emcc "$@" 8 | fi 9 | fi 10 | 11 | if [[ -z "$EMSDK_PROJECT_ROOT" ]]; then 12 | echo "EMSDK_PROJECT_ROOT must be set to a path" 13 | exit 1 14 | fi 15 | 16 | DOCKER_ARGV=( 17 | run --rm 18 | -v "$EMSDK_PROJECT_ROOT:$EMSDK_PROJECT_ROOT" 19 | -v "$(pwd):$(pwd)" 20 | -u "$(id -u):$(id -g)" 21 | -w "$(pwd)" 22 | ) 23 | 24 | if [[ -n "$EMSDK_DOCKER_CACHE" ]]; then 25 | # There are some files that are not pre-build in the Docker image, 26 | # and take a while to be automatically generated by emsdk. 27 | # We cache these on the host inside EMSDK_DOCKER_CACHE. 28 | EMSDK_DOCKER_CACHE_PATHS=( 29 | sysroot/lib/wasm32-emscripten/lto 30 | sysroot/lib/wasm32-emscripten/thinlto 31 | sysroot/lib/wasm32-emscripten/pic 32 | symbol_lists 33 | ) 34 | for dir in "${EMSDK_DOCKER_CACHE_PATHS[@]}"; do 35 | host="$EMSDK_DOCKER_CACHE/$dir" 36 | guest="/emsdk/upstream/emscripten/cache/$dir" 37 | 38 | mkdir -p "$host" 39 | DOCKER_ARGV+=( 40 | -v "$host:$guest" 41 | ) 42 | done 43 | fi 44 | 45 | DOCKER_ARGV+=( 46 | "${EMSDK_DOCKER_IMAGE}" emcc "$@" 47 | ) 48 | 49 | set -x 50 | exec docker "${DOCKER_ARGV[@]}" 51 | -------------------------------------------------------------------------------- /scripts/set-version.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S npx tsx 2 | import type { PackageJson } from "./helpers.js" 3 | import { getYarnWorkspaces, readJson, writePretty } from "./helpers.js" 4 | 5 | async function main() { 6 | const NEXT_VERSION = process.argv[2] 7 | if (!NEXT_VERSION) { 8 | throw new Error(`Usage: ${process.argv[0]} `) 9 | } 10 | 11 | const set: Record = {} 12 | for (const workspace of getYarnWorkspaces()) { 13 | const packageJson: PackageJson = readJson(workspace.location + "/package.json") 14 | if (packageJson.version === NEXT_VERSION) { 15 | set[packageJson.name] = `unchanged (${NEXT_VERSION})` 16 | continue 17 | } 18 | 19 | set[packageJson.name] = `${packageJson.version} -> ${NEXT_VERSION}` 20 | packageJson.version = NEXT_VERSION 21 | // get rid of annoying Yarn thingy 22 | ;(packageJson as any).stableVersion = undefined 23 | await writePretty(workspace.location + "/package.json", JSON.stringify(packageJson, null, 2)) 24 | } 25 | console.log(set) 26 | } 27 | 28 | main().catch((e) => { 29 | console.error(e) 30 | process.exit(1) 31 | }) 32 | -------------------------------------------------------------------------------- /scripts/smoketest-create-react-app.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S npx tsx 2 | import * as sh from "./helpers" 3 | 4 | const target = sh.resolve(__dirname, "../examples/create-react-app") 5 | sh.installDependencyGraphFromTar(target, "quickjs-emscripten") 6 | sh.exec(`cd ${target} && npm run build`) 7 | -------------------------------------------------------------------------------- /scripts/smoketest-deno.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S npx tsx 2 | import * as sh from "./helpers" 3 | 4 | const target = sh.resolve(__dirname, "../examples/deno") 5 | sh.installDependencyGraphFromTar(target, "quickjs-emscripten", { 6 | fromRegistry: true, 7 | install: "npm install", 8 | remove: "npm remove", 9 | }) 10 | sh.exec(`cd ${target} && ./main.ts`) 11 | -------------------------------------------------------------------------------- /scripts/smoketest-node-minimal.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S npx tsx 2 | import * as sh from "./helpers" 3 | 4 | const target = sh.resolve(__dirname, "../examples/node-minimal") 5 | sh.installDependencyGraphFromTar(target, [ 6 | "quickjs-emscripten-core", 7 | "@jitl/quickjs-wasmfile-release-sync", 8 | ]) 9 | sh.exec(`cd ${target} && node main.mjs`) 10 | -------------------------------------------------------------------------------- /scripts/smoketest-node.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S npx tsx 2 | import * as sh from "./helpers" 3 | 4 | const target = sh.resolve(__dirname, "../examples/node-typescript") 5 | sh.installDependencyGraphFromTar(target, "quickjs-emscripten") 6 | sh.exec(`cd ${target} && npx tsc --project .`) 7 | sh.exec(`cd ${target} && node index.js`) 8 | -------------------------------------------------------------------------------- /scripts/smoketest-vite.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S npx tsx 2 | import * as sh from "./helpers" 3 | 4 | const target = sh.resolve(__dirname, "../examples/vite-vue") 5 | sh.installDependencyGraphFromTar(target, "quickjs-emscripten") 6 | sh.exec(`cd ${target} && npm run build`) 7 | -------------------------------------------------------------------------------- /templates/emscripten-module.ASYNCIFY.d.ts: -------------------------------------------------------------------------------- 1 | import type { EmscriptenModuleLoader, QuickJSAsyncEmscriptenModule } from "@jitl/quickjs-ffi-types" 2 | /** 3 | * Emscripten module built from [`quickjs/quickjs.h`](../quickjs/quickjs.h) and 4 | * our FFI support functions [c/interface.c](../c/interface.c), compiled with -s 5 | * ASYNCIFY=1. 6 | * 7 | * Because this version is built with ASYNCIFY, the C code can call asynchronous 8 | * Javascript functions as though they were synchronous. 9 | * 10 | * Note that emscripten modules returned by a `MODULARIZE=1` emscripten build 11 | * (like this one) load asynchronously. 12 | */ 13 | declare const ModuleLoader: EmscriptenModuleLoader 14 | export default ModuleLoader 15 | -------------------------------------------------------------------------------- /templates/emscripten-module.SYNC.d.ts: -------------------------------------------------------------------------------- 1 | import type { EmscriptenModuleLoader, QuickJSEmscriptenModule } from "@jitl/quickjs-ffi-types" 2 | /** 3 | * Emscripten module built from the unmodified [`quickjs/quickjs.h`](../quickjs/quickjs.h) 4 | * and our FFI support functions [c/interface.c](../c/interface.c). 5 | * 6 | * Note that emscripten modules returned by a `MODULARIZE=1` emscripten build 7 | * (like this one) load asynchronously. 8 | */ 9 | declare const ModuleLoader: EmscriptenModuleLoader 10 | export default ModuleLoader 11 | -------------------------------------------------------------------------------- /templates/pre-extension.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-undef */ 2 | // quickjs-emscripten code injected into emscripten-module.js 3 | // We use this to expose and patch up issues with Emscripten's source map handling... 4 | function quickjsEmscriptenInit(debugLog) { 5 | const log = debugLog || function () {} 6 | // Everything goes in a function so we can defer running until other variables 7 | // are initialized in case they change. 8 | const extension = { log } 9 | for (const init of quickjsEmscriptenInit.inits) { 10 | init(extension) 11 | } 12 | Module["quickJSEmscriptenExtensions"] = extension 13 | return extension 14 | } 15 | quickjsEmscriptenInit.inits = [] 16 | Module["quickjsEmscriptenInit"] = quickjsEmscriptenInit 17 | -------------------------------------------------------------------------------- /templates/pre-sourceMapJson.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-undef */ 2 | quickjsEmscriptenInit.inits.push((extension) => { 3 | if (typeof receiveSourceMapJSON !== "undefined") { 4 | extension["receiveSourceMapJSON"] = (data) => { 5 | if (typeof wasmSourceMap === "undefined") { 6 | extension.log("receiveSourceMapJSON: received", data) 7 | return receiveSourceMapJSON(data) 8 | } else { 9 | extension.log("receiveSourceMapJSON: already have data:", wasmSourceMap, "ignoring", data) 10 | } 11 | } 12 | } 13 | }) 14 | -------------------------------------------------------------------------------- /templates/pre-wasmMemory.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-undef */ 2 | quickjsEmscriptenInit.inits.push((extension) => { 3 | extension["getWasmMemory"] = function () { 4 | return wasmMemory 5 | } 6 | }) 7 | -------------------------------------------------------------------------------- /templates/pre-wasmOffsetConverter.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-undef */ 2 | quickjsEmscriptenInit.inits.push((extension) => { 3 | if (typeof WasmOffsetConverter !== "undefined") { 4 | extension["WasmOffsetConverter"] = WasmOffsetConverter 5 | // Expose function to receive WasmOffsetConverter, set to wasmOffsetConverter local variable 6 | // if it exists 7 | try { 8 | // Check if wasmOffsetConverter variable exists. If it isn't defined, this 9 | // will throw and we'll skip the rest of the branch. 10 | extension["existingWasmOffsetConverter"] = wasmOffsetConverter 11 | extension["receiveWasmOffsetConverter"] = function (wasmBinary, wasmModule) { 12 | if (!wasmOffsetConverter) { 13 | extension.log("wasmOffsetConverter set") 14 | wasmOffsetConverter = new WasmOffsetConverter(wasmBinary, wasmModule) 15 | } else { 16 | extension.log("wasmOffsetConverter already set, ignored") 17 | } 18 | } 19 | } catch (error) { 20 | // Nothing. 21 | extension["receiveWasmOffsetConverter"] = function () { 22 | extension.log("wasmOffsetConverter variable not defined, this is a no-op") 23 | } 24 | } 25 | } 26 | }) 27 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@jitl/tsconfig/tsconfig.json", 3 | "compilerOptions": { 4 | "noEmit": true 5 | }, 6 | "include": ["scripts/**/*", "packages/*/*"] 7 | } 8 | -------------------------------------------------------------------------------- /typedoc.base.js: -------------------------------------------------------------------------------- 1 | const NO_THANKS = ["**/node_modules/**", "./quickjs/**"] 2 | 3 | module.exports = { 4 | // link to main instead of the current git SHA 5 | // which is borked with our strategy of deploying the docs 6 | // in the repo. 7 | gitRevision: "main", 8 | excludePrivate: true, 9 | excludeExternals: true, 10 | categorizeByGroup: true, 11 | plugin: ["typedoc-plugin-markdown"], 12 | exclude: NO_THANKS, 13 | externalPattern: NO_THANKS[0], 14 | // excludeReferences: true, 15 | 16 | // Experimental 17 | // https://github.com/tgreyuk/typedoc-plugin-markdown/blob/next/packages/typedoc-plugin-markdown/docs/plugin-options.md 18 | // useCodeBlocks: true, 19 | // outputFileStrategy: "modules" 20 | // mergeReadme: true, 21 | entryFileName: "README.md", 22 | membersWithOwnFile: ["Class", "Interface"], 23 | } 24 | -------------------------------------------------------------------------------- /typedoc.js: -------------------------------------------------------------------------------- 1 | const variants = require("./variants.json") 2 | 3 | const ROOT_PACKAGES = ["quickjs-emscripten", "quickjs-emscripten-core", "quickjs-ffi-types"].map( 4 | (path) => `./packages/${path}`, 5 | ) 6 | 7 | const VARIANT_PACKAGES = Object.values(variants).map((variant) => variant.dir) 8 | 9 | module.exports = { 10 | extends: "./typedoc.base.js", 11 | name: "quickjs-emscripten", 12 | entryPoints: [...ROOT_PACKAGES, ...VARIANT_PACKAGES], 13 | entryPointStrategy: "packages", 14 | out: "./doc", 15 | } 16 | -------------------------------------------------------------------------------- /vendor/quickjs-ng/.gitignore: -------------------------------------------------------------------------------- 1 | *.a 2 | *.orig 3 | *.so 4 | .obj/ 5 | build/ 6 | unicode/ 7 | test262_*.txt 8 | .idea 9 | cmake-* -------------------------------------------------------------------------------- /vendor/quickjs-ng/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "test262"] 2 | path = test262 3 | url = https://github.com/tc39/test262 4 | shallow = true 5 | -------------------------------------------------------------------------------- /vendor/quickjs-ng/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017-2021 Fabrice Bellard 4 | Copyright (c) 2017-2021 Charlie Gordon 5 | Copyright (c) 2023 Ben Noordhuis 6 | Copyright (c) 2023 Saúl Ibarra Corretgé 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in 16 | all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | THE SOFTWARE. 25 | -------------------------------------------------------------------------------- /vendor/quickjs-ng/README.md: -------------------------------------------------------------------------------- 1 | # ⚡️ QuickJS - A mighty JavaScript engine 2 | 3 | Friendly [QuickJS](https://bellard.org/quickjs) fork focused on reigniting the project. 4 | 5 | 🚧 Work in progress. 6 | -------------------------------------------------------------------------------- /vendor/quickjs-ng/examples/fib_module.js: -------------------------------------------------------------------------------- 1 | /* fib module */ 2 | export function fib(n) 3 | { 4 | if (n <= 0) 5 | return 0; 6 | else if (n == 1) 7 | return 1; 8 | else 9 | return fib(n - 1) + fib(n - 2); 10 | } 11 | -------------------------------------------------------------------------------- /vendor/quickjs-ng/examples/hello.js: -------------------------------------------------------------------------------- 1 | console.log("Hello World"); 2 | -------------------------------------------------------------------------------- /vendor/quickjs-ng/examples/hello_module.js: -------------------------------------------------------------------------------- 1 | /* example of JS module */ 2 | 3 | import { fib } from "./fib_module.js"; 4 | 5 | console.log("Hello World"); 6 | console.log("fib(10)=", fib(10)); 7 | -------------------------------------------------------------------------------- /vendor/quickjs-ng/examples/test_fib.js: -------------------------------------------------------------------------------- 1 | /* example of JS module importing a C module */ 2 | 3 | import { fib } from "./fib.so"; 4 | 5 | console.log("Hello World"); 6 | console.log("fib(10)=", fib(10)); 7 | -------------------------------------------------------------------------------- /vendor/quickjs-ng/examples/test_point.js: -------------------------------------------------------------------------------- 1 | /* example of JS module importing a C module */ 2 | import { Point } from "./point.so"; 3 | 4 | function assert(b, str) 5 | { 6 | if (b) { 7 | return; 8 | } else { 9 | throw Error("assertion failed: " + str); 10 | } 11 | } 12 | 13 | class ColorPoint extends Point { 14 | constructor(x, y, color) { 15 | super(x, y); 16 | this.color = color; 17 | } 18 | get_color() { 19 | return this.color; 20 | } 21 | }; 22 | 23 | function main() 24 | { 25 | var pt, pt2; 26 | 27 | pt = new Point(2, 3); 28 | assert(pt.x === 2); 29 | assert(pt.y === 3); 30 | pt.x = 4; 31 | assert(pt.x === 4); 32 | assert(pt.norm() == 5); 33 | 34 | pt2 = new ColorPoint(2, 3, 0xffffff); 35 | assert(pt2.x === 2); 36 | assert(pt2.color === 0xffffff); 37 | assert(pt2.get_color() === 0xffffff); 38 | } 39 | 40 | main(); 41 | -------------------------------------------------------------------------------- /vendor/quickjs-ng/tests/function_source.js: -------------------------------------------------------------------------------- 1 | "use strict" 2 | const expect = "function f() { return 42 }" 3 | function f() { return 42 } 4 | 5 | { 6 | const actual = f.toString() 7 | if (actual !== expect) throw Error(actual) 8 | } 9 | 10 | { 11 | const f = eval(expect + "f") 12 | const actual = f.toString() 13 | if (actual !== expect) throw Error(actual) 14 | } 15 | -------------------------------------------------------------------------------- /vendor/quickjs-ng/tests/test_worker_module.js: -------------------------------------------------------------------------------- 1 | /* Worker code for test_worker.js */ 2 | import * as std from "std"; 3 | import * as os from "os"; 4 | 5 | var parent = os.Worker.parent; 6 | 7 | function handle_msg(e) { 8 | var ev = e.data; 9 | // print("child_recv", JSON.stringify(ev)); 10 | switch(ev.type) { 11 | case "abort": 12 | parent.postMessage({ type: "done" }); 13 | break; 14 | case "sab": 15 | /* modify the SharedArrayBuffer */ 16 | ev.buf[2] = 10; 17 | parent.postMessage({ type: "sab_done", buf: ev.buf }); 18 | break; 19 | } 20 | } 21 | 22 | function worker_main() { 23 | var i; 24 | 25 | parent.onmessage = handle_msg; 26 | for(i = 0; i < 10; i++) { 27 | parent.postMessage({ type: "num", num: i }); 28 | } 29 | } 30 | 31 | worker_main(); 32 | -------------------------------------------------------------------------------- /vendor/quickjs-ng/unicode_download.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | url="ftp://ftp.unicode.org/Public/14.0.0/ucd" 5 | emoji_url="${url}/emoji/emoji-data.txt" 6 | 7 | files="CaseFolding.txt DerivedNormalizationProps.txt PropList.txt \ 8 | SpecialCasing.txt CompositionExclusions.txt ScriptExtensions.txt \ 9 | UnicodeData.txt DerivedCoreProperties.txt NormalizationTest.txt Scripts.txt \ 10 | PropertyValueAliases.txt" 11 | 12 | mkdir -p unicode 13 | 14 | for f in $files; do 15 | g="${url}/${f}" 16 | wget $g -O unicode/$f 17 | done 18 | 19 | wget $emoji_url -O unicode/emoji-data.txt 20 | -------------------------------------------------------------------------------- /vendor/quickjs-ng/v8-tweak.js: -------------------------------------------------------------------------------- 1 | ;(function() { 2 | "use strict" 3 | const print = globalThis.print 4 | globalThis.print = function() {} // print nothing, v8 tests are chatty 5 | let count = 0 // rate limit to avoid excessive logs 6 | globalThis.failWithMessage = function(message) { 7 | if (count > 99) return 8 | if (++count > 99) return print("") 9 | print(String(message).slice(0, 128)) 10 | } 11 | })() 12 | -------------------------------------------------------------------------------- /vendor/quickjs-ng/v8.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | : ${QJS:=build/qjs} 4 | "$QJS" v8.js $* 2>&1 | tee v8.txt$$ 5 | diff -uw v8.txt v8.txt$$ || exit 1 6 | rm v8.txt$$ 7 | -------------------------------------------------------------------------------- /vendor/quickjs-patches/0166-webkit-wasm.patch: -------------------------------------------------------------------------------- 1 | diff --git a/vendor/quickjs/quickjs.c b/vendor/quickjs/quickjs.c 2 | index f000ff74..fa7742a2 100644 3 | --- a/vendor/quickjs/quickjs.c 4 | +++ b/vendor/quickjs/quickjs.c 5 | @@ -32053,6 +32053,7 @@ static void push_short_int(DynBuf *bc_out, int val) 6 | dbuf_putc(bc_out, OP_push_0 + val); 7 | return; 8 | } 9 | +#if !defined(__EMSCRIPTEN__) // Workaround for WebKit WASM https://github.com/justjake/quickjs-emscripten/issues/166 10 | if (val == (int8_t)val) { 11 | dbuf_putc(bc_out, OP_push_i8); 12 | dbuf_putc(bc_out, val); 13 | @@ -32063,6 +32064,7 @@ static void push_short_int(DynBuf *bc_out, int val) 14 | dbuf_put_u16(bc_out, val); 15 | return; 16 | } 17 | +#endif // !defined(__EMSCRIPTEN__) 18 | #endif 19 | dbuf_putc(bc_out, OP_push_i32); 20 | dbuf_put_u32(bc_out, val); 21 | -------------------------------------------------------------------------------- /vendor/quickjs/.gitignore: -------------------------------------------------------------------------------- 1 | *.a 2 | .obj/ 3 | tests/bjson.so 4 | examples/test_fib 5 | test_fib.c 6 | examples/*.so 7 | examples/hello 8 | examples/hello_module 9 | hello.c 10 | microbench*.txt 11 | qjs 12 | qjsc 13 | qjscalc 14 | qjscalc.c 15 | repl.c 16 | run-test262 17 | test262 18 | test262_*.txt 19 | test262o 20 | test262o_*.txt 21 | unicode 22 | unicode_gen 23 | run_octane 24 | run_sunspider_like 25 | -------------------------------------------------------------------------------- /vendor/quickjs/LICENSE: -------------------------------------------------------------------------------- 1 | QuickJS Javascript Engine 2 | 3 | Copyright (c) 2017-2021 Fabrice Bellard 4 | Copyright (c) 2017-2021 Charlie Gordon 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /vendor/quickjs/VERSION: -------------------------------------------------------------------------------- 1 | 2024-02-14 2 | -------------------------------------------------------------------------------- /vendor/quickjs/compat/test-closefrom.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(void) { 4 | closefrom(3); 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /vendor/quickjs/examples/fib_module.js: -------------------------------------------------------------------------------- 1 | /* fib module */ 2 | export function fib(n) 3 | { 4 | if (n <= 0) 5 | return 0; 6 | else if (n == 1) 7 | return 1; 8 | else 9 | return fib(n - 1) + fib(n - 2); 10 | } 11 | -------------------------------------------------------------------------------- /vendor/quickjs/examples/hello.js: -------------------------------------------------------------------------------- 1 | console.log("Hello World"); 2 | -------------------------------------------------------------------------------- /vendor/quickjs/examples/hello_module.js: -------------------------------------------------------------------------------- 1 | /* example of JS module */ 2 | 3 | import { fib } from "./fib_module.js"; 4 | 5 | console.log("Hello World"); 6 | console.log("fib(10)=", fib(10)); 7 | -------------------------------------------------------------------------------- /vendor/quickjs/examples/test_fib.js: -------------------------------------------------------------------------------- 1 | /* example of JS module importing a C module */ 2 | 3 | import { fib } from "./fib.so"; 4 | 5 | console.log("Hello World"); 6 | console.log("fib(10)=", fib(10)); 7 | -------------------------------------------------------------------------------- /vendor/quickjs/examples/test_point.js: -------------------------------------------------------------------------------- 1 | /* example of JS module importing a C module */ 2 | import { Point } from "./point.so"; 3 | 4 | function assert(b, str) 5 | { 6 | if (b) { 7 | return; 8 | } else { 9 | throw Error("assertion failed: " + str); 10 | } 11 | } 12 | 13 | class ColorPoint extends Point { 14 | constructor(x, y, color) { 15 | super(x, y); 16 | this.color = color; 17 | } 18 | get_color() { 19 | return this.color; 20 | } 21 | }; 22 | 23 | function main() 24 | { 25 | var pt, pt2; 26 | 27 | pt = new Point(2, 3); 28 | assert(pt.x === 2); 29 | assert(pt.y === 3); 30 | pt.x = 4; 31 | assert(pt.x === 4); 32 | assert(pt.norm() == 5); 33 | 34 | pt2 = new ColorPoint(2, 3, 0xffffff); 35 | assert(pt2.x === 2); 36 | assert(pt2.color === 0xffffff); 37 | assert(pt2.get_color() === 0xffffff); 38 | } 39 | 40 | main(); 41 | -------------------------------------------------------------------------------- /vendor/quickjs/fuzz/README: -------------------------------------------------------------------------------- 1 | libFuzzer support for QuickJS 2 | ============================= 3 | 4 | Build QuickJS with libFuzzer support as follows: 5 | 6 | CONFIG_CLANG=y make libfuzzer 7 | 8 | This can be extended with sanitizer support to improve efficacy: 9 | 10 | CONFIG_CLANG=y CONFIG_ASAN=y make libfuzzer 11 | 12 | 13 | Currently, there are three fuzzing targets defined: fuzz_eval, fuzz_compile and fuzz_regexp. 14 | The above build command will produce an executable binary for each of them, which can be 15 | simply executed as: 16 | 17 | ./fuzz_eval 18 | 19 | or with an initial corpus: 20 | 21 | ./fuzz_compile corpus_dir/ 22 | 23 | or with a predefined dictionary to improve its efficacy: 24 | 25 | ./fuzz_eval -dict fuzz/fuzz.dict 26 | 27 | or with arbitrary CLI arguments provided by libFuzzer (https://llvm.org/docs/LibFuzzer.html). 28 | -------------------------------------------------------------------------------- /vendor/quickjs/fuzz/fuzz_common.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 Google Inc. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | */ 15 | 16 | #include "quickjs.h" 17 | #include "quickjs-libc.h" 18 | 19 | static int nbinterrupts = 0; 20 | 21 | void reset_nbinterrupts(); 22 | void test_one_input_init(JSRuntime *rt, JSContext *ctx); 23 | -------------------------------------------------------------------------------- /vendor/quickjs/fuzz/fuzz_eval.c: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 Google Inc. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | */ 15 | 16 | #include "quickjs.h" 17 | #include "quickjs-libc.h" 18 | #include "fuzz/fuzz_common.h" 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { 25 | if (size == 0) 26 | return 0; 27 | 28 | JSRuntime *rt = JS_NewRuntime(); 29 | JSContext *ctx = JS_NewContext(rt); 30 | test_one_input_init(rt, ctx); 31 | 32 | uint8_t *null_terminated_data = malloc(size + 1); 33 | memcpy(null_terminated_data, data, size); 34 | null_terminated_data[size] = 0; 35 | 36 | reset_nbinterrupts(); 37 | //the final 0 does not count (as in strlen) 38 | JSValue val = JS_Eval(ctx, (const char *)null_terminated_data, size, "", JS_EVAL_TYPE_GLOBAL); 39 | free(null_terminated_data); 40 | //TODO targets with JS_ParseJSON, JS_ReadObject 41 | if (!JS_IsException(val)) { 42 | js_std_loop(ctx); 43 | JS_FreeValue(ctx, val); 44 | } 45 | js_std_free_handlers(rt); 46 | JS_FreeContext(ctx); 47 | JS_FreeRuntime(rt); 48 | return 0; 49 | } 50 | -------------------------------------------------------------------------------- /vendor/quickjs/fuzz/generate_dict.js: -------------------------------------------------------------------------------- 1 | // Function to recursively iterate through built-in names. 2 | function collectBuiltinNames(obj, visited = new Set(), result = new Set()) { 3 | // Check if the object has already been visited to avoid infinite recursion. 4 | if (visited.has(obj)) 5 | return; 6 | 7 | // Add the current object to the set of visited objects 8 | visited.add(obj); 9 | // Get the property names of the current object 10 | const properties = Object.getOwnPropertyNames(obj); 11 | // Iterate through each property 12 | for (var i=0; i < properties.length; i++) { 13 | var property = properties[i]; 14 | if (property != "collectBuiltinNames" && typeof property != "number") 15 | result.add(property); 16 | // Check if the property is an object and if so, recursively iterate through its properties. 17 | if (typeof obj[property] === 'object' && obj[property] !== null) 18 | collectBuiltinNames(obj[property], visited, result); 19 | } 20 | return result; 21 | } 22 | 23 | // Start the recursive iteration with the global object. 24 | console.log(Array.from(collectBuiltinNames(this)).join('\n')); 25 | -------------------------------------------------------------------------------- /vendor/quickjs/readme.txt: -------------------------------------------------------------------------------- 1 | The main documentation is in doc/quickjs.pdf or doc/quickjs.html. 2 | -------------------------------------------------------------------------------- /vendor/quickjs/test262_errors.txt: -------------------------------------------------------------------------------- 1 | test262/test/annexB/language/eval-code/direct/script-decl-lex-collision-in-sloppy-mode.js:13: Test262Error: Expected a SyntaxError to be thrown but no exception was thrown at all 2 | test262/test/language/expressions/assignment/target-member-computed-reference-null.js:32: Test262Error: Expected a DummyError but got a TypeError 3 | test262/test/language/expressions/assignment/target-member-computed-reference-null.js:32: strict mode: Test262Error: Expected a DummyError but got a TypeError 4 | test262/test/language/expressions/assignment/target-member-computed-reference-undefined.js:32: Test262Error: Expected a DummyError but got a TypeError 5 | test262/test/language/expressions/assignment/target-member-computed-reference-undefined.js:32: strict mode: Test262Error: Expected a DummyError but got a TypeError 6 | test262/test/language/expressions/in/private-field-invalid-assignment-target.js:23: unexpected error type: Test262: This statement should not be evaluated. 7 | test262/test/language/expressions/in/private-field-invalid-assignment-target.js:23: strict mode: unexpected error type: Test262: This statement should not be evaluated. 8 | test262/test/language/global-code/script-decl-lex-var-declared-via-eval-sloppy.js:13: Test262Error: variable Expected a SyntaxError to be thrown but no exception was thrown at all 9 | -------------------------------------------------------------------------------- /vendor/quickjs/test262o_errors.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjake/quickjs-emscripten/aa48b619983f02c5691d989c0771a3421178ce4b/vendor/quickjs/test262o_errors.txt -------------------------------------------------------------------------------- /vendor/quickjs/tests/test_worker_module.js: -------------------------------------------------------------------------------- 1 | /* Worker code for test_worker.js */ 2 | import * as std from "std"; 3 | import * as os from "os"; 4 | 5 | var parent = os.Worker.parent; 6 | 7 | function handle_msg(e) { 8 | var ev = e.data; 9 | // print("child_recv", JSON.stringify(ev)); 10 | switch(ev.type) { 11 | case "abort": 12 | parent.postMessage({ type: "done" }); 13 | parent.onMessage = null; /* terminate the worker */ 14 | break; 15 | case "sab": 16 | /* modify the SharedArrayBuffer */ 17 | ev.buf[2] = 10; 18 | parent.postMessage({ type: "sab_done", buf: ev.buf }); 19 | break; 20 | } 21 | } 22 | 23 | function worker_main() { 24 | var i; 25 | 26 | parent.onmessage = handle_msg; 27 | for(i = 0; i < 10; i++) { 28 | parent.postMessage({ type: "num", num: i }); 29 | } 30 | } 31 | 32 | worker_main(); 33 | -------------------------------------------------------------------------------- /vendor/quickjs/unicode_download.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | url="ftp://ftp.unicode.org/Public/15.0.0/ucd" 5 | emoji_url="${url}/emoji/emoji-data.txt" 6 | 7 | files="CaseFolding.txt DerivedNormalizationProps.txt PropList.txt \ 8 | SpecialCasing.txt CompositionExclusions.txt ScriptExtensions.txt \ 9 | UnicodeData.txt DerivedCoreProperties.txt NormalizationTest.txt Scripts.txt \ 10 | PropertyValueAliases.txt" 11 | 12 | mkdir -p unicode 13 | 14 | for f in $files; do 15 | g="${url}/${f}" 16 | wget $g -O unicode/$f 17 | done 18 | 19 | wget $emoji_url -O unicode/emoji-data.txt 20 | -------------------------------------------------------------------------------- /yodawg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justjake/quickjs-emscripten/aa48b619983f02c5691d989c0771a3421178ce4b/yodawg.jpg --------------------------------------------------------------------------------