diff --git a/CHANGELOG.md b/CHANGELOG.md index 8fad84e5..d268c48e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## v0.31.0 + +- [#137](https://github.com/justjake/quickjs-emscripten/pull/137) + - Add `quickjs-for-quickjs`, a package that can run inside quickjs, so you can put quickjs inside your quickjs. + - **Possibly breaking**: Fix a build system bug that made commonjs or esm variants include both types, thus being larger than they needed to be. After upgrading a variant to this release, you should verify that it can be imported/required as expected. You may need to add additional variants if you were using an "esm" variant from both cjs and esm. + ## v0.30.0 - [#200](https://github.com/justjake/quickjs-emscripten/pull/200) Inspect and iterate handles, equality, changes to result types, changes to debug logging. diff --git a/README.md b/README.md index de4c113d..67dc356b 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ compiled to WebAssembly. - Create and manipulate values inside the QuickJS runtime ([more][values]). - Expose host functions to the QuickJS runtime ([more][functions]). - Execute synchronous code that uses asynchronous functions, with [asyncify][asyncify]. +- Supports browsers, NodeJS, Deno, Bun, Cloudflare Workers, QuickJS (via [quickjs-for-quickjs][]). [Github] | [NPM] | [API Documentation][api] | [Variants][core] | [Examples][tests] @@ -43,6 +44,7 @@ main() [values]: #interfacing-with-the-interpreter [asyncify]: #asyncify [functions]: #exposing-apis +[quickjs-for-quickjs]: https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-for-quickjs - [quickjs-emscripten](#quickjs-emscripten) - [Usage](#usage) diff --git a/c/interface.c b/c/interface.c index 48cedffd..39eb0c6b 100644 --- a/c/interface.c +++ b/c/interface.c @@ -728,6 +728,8 @@ MaybeAsync(JSBorrowedChar *) QTS_Dump(JSContext *ctx, JSValueConst *obj) { copy_prop_if_needed(ctx, enumerable_props, *obj, "name"); copy_prop_if_needed(ctx, enumerable_props, *obj, "message"); copy_prop_if_needed(ctx, enumerable_props, *obj, "stack"); + copy_prop_if_needed(ctx, enumerable_props, *obj, "fileName"); + copy_prop_if_needed(ctx, enumerable_props, *obj, "lineNumber"); // Serialize again. JSValue enumerable_json = JS_JSONStringify(ctx, enumerable_props, JS_UNDEFINED, JS_UNDEFINED); diff --git a/doc/@jitl/quickjs-asmjs-mjs-release-sync/README.md b/doc/@jitl/quickjs-asmjs-mjs-release-sync/README.md new file mode 100644 index 00000000..d87401a9 --- /dev/null +++ b/doc/@jitl/quickjs-asmjs-mjs-release-sync/README.md @@ -0,0 +1,89 @@ +[quickjs-emscripten](../../packages.md) • **@jitl/quickjs-asmjs-mjs-release-sync** • [Readme](README.md) \| [Exports](exports.md) + +*** + +# @jitl/quickjs-asmjs-mjs-release-sync + +Compiled to pure Javascript, no WebAssembly required. + +This generated package is part of [quickjs-emscripten](https://github.com/justjake/quickjs-emscripten). +It contains a variant of the quickjs WASM library, and can be used with quickjs-emscripten-core. + +```typescript +import variant from "@jitl/quickjs-asmjs-mjs-release-sync" +import { newQuickJSWASMModuleFromVariant } from "quickjs-emscripten-core" +const QuickJS = await newQuickJSWASMModuleFromVariant(variant) +``` + +This variant was built with the following settings: + +## Contents + +- [Library: quickjs](README.md#library-quickjs) +- [Release mode: release](README.md#release-mode-release) +- [Exports: import](README.md#exports-import) +- [Extra async magic? No](README.md#extra-async-magic-no) +- [Single-file, or separate .wasm file? asmjs](README.md#single-file-or-separate-wasm-file-asmjs) +- [More details](README.md#more-details) + +## 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. + +## Release mode: release + +Optimized for performance; use when building/deploying your application. + +## Exports: import + +Exports the following in package.json for the package entrypoint: + +- Exports a NodeJS-compatible ESModule. Cannot be imported synchronously from a NodeJS CommonJS module. + +## Extra async magic? No + +The default, normal build. Note that both variants support regular async functions. + +## Single-file, or separate .wasm file? 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. + +## More details + +Full variant JSON description: + +```json +{ + "library": "quickjs", + "releaseMode": "release", + "syncMode": "sync", + "description": "Compiled to pure Javascript, no WebAssembly required.", + "emscriptenInclusion": "asmjs", + "exports": { + "import": { + "emscriptenEnvironment": ["web", "worker", "node"] + } + } +} +``` + +Variant-specific Emscripten build flags: + +```json +[ + "-Oz", + "-flto", + "--closure 1", + "-s FILESYSTEM=0", + "--pre-js $(TEMPLATES)/pre-extension.js", + "--pre-js $(TEMPLATES)/pre-wasmMemory.js", + "-s WASM=0", + "-s SINGLE_FILE=1" +] +``` + +*** + +Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/doc/@jitl/quickjs-asmjs-mjs-release-sync/exports.md b/doc/@jitl/quickjs-asmjs-mjs-release-sync/exports.md new file mode 100644 index 00000000..e215c9c1 --- /dev/null +++ b/doc/@jitl/quickjs-asmjs-mjs-release-sync/exports.md @@ -0,0 +1,40 @@ +[quickjs-emscripten](../../packages.md) • **@jitl/quickjs-asmjs-mjs-release-sync** • [Readme](README.md) \| [Exports](exports.md) + +*** + +[quickjs-emscripten](../../packages.md) / @jitl/quickjs-asmjs-mjs-release-sync + +# @jitl/quickjs-asmjs-mjs-release-sync + +## Contents + +- [Variables](exports.md#variables) + - [default](exports.md#default) + - [@jitl/quickjs-asmjs-mjs-release-sync](exports.md#jitlquickjs-asmjs-mjs-release-sync) + +## Variables + +### default + +> **`const`** **default**: [`QuickJSSyncVariant`](../../quickjs-emscripten/interfaces/QuickJSSyncVariant.md) + +### @jitl/quickjs-asmjs-mjs-release-sync + +[Docs](https://github.com/justjake/quickjs-emscripten/blob/main/doc/@jitl/quickjs-asmjs-mjs-release-sync/README.md) | +Compiled to pure Javascript, no WebAssembly required. + +| Variable | Setting | Description | +| -- | -- | -- | +| 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. | +| releaseMode | release | Optimized for performance; use when building/deploying your application. | +| syncMode | sync | The default, normal build. Note that both variants support regular async functions. | +| 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. | +| exports | import | Has these package.json export conditions | + +#### Source + +[index.ts:19](https://github.com/justjake/quickjs-emscripten/blob/main/packages/variant-quickjs-asmjs-mjs-release-sync/src/index.ts#L19) + +*** + +Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/doc/README.md b/doc/README.md index 95a382a3..02aca07c 100644 --- a/doc/README.md +++ b/doc/README.md @@ -11,6 +11,7 @@ compiled to WebAssembly. - Create and manipulate values inside the QuickJS runtime ([more][values]). - Expose host functions to the QuickJS runtime ([more][functions]). - Execute synchronous code that uses asynchronous functions, with [asyncify][asyncify]. +- Supports browsers, NodeJS, Deno, Bun, Cloudflare Workers, QuickJS (via [quickjs-for-quickjs][]). [Github] | [NPM] | [API Documentation][api] | [Variants][core] | [Examples][tests] @@ -47,6 +48,7 @@ main() [values]: #interfacing-with-the-interpreter [asyncify]: #asyncify [functions]: #exposing-apis +[quickjs-for-quickjs]: https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-for-quickjs - [quickjs-emscripten](#quickjs-emscripten) - [Usage](#usage) diff --git a/doc/packages.md b/doc/packages.md index b22125ad..69e42148 100644 --- a/doc/packages.md +++ b/doc/packages.md @@ -29,6 +29,7 @@ - [@jitl/quickjs-singlefile-browser-debug-asyncify](@jitl/quickjs-singlefile-browser-debug-asyncify/README.md) - [@jitl/quickjs-singlefile-browser-release-sync](@jitl/quickjs-singlefile-browser-release-sync/README.md) - [@jitl/quickjs-singlefile-browser-release-asyncify](@jitl/quickjs-singlefile-browser-release-asyncify/README.md) +- [@jitl/quickjs-asmjs-mjs-release-sync](@jitl/quickjs-asmjs-mjs-release-sync/README.md) *** diff --git a/doc/quickjs-emscripten-core/README.md b/doc/quickjs-emscripten-core/README.md index c9946214..ba1cb0c9 100644 --- a/doc/quickjs-emscripten-core/README.md +++ b/doc/quickjs-emscripten-core/README.md @@ -48,6 +48,7 @@ const QuickJS = await newQuickJSWASMModuleFromVariant(releaseVariant) - [@jitl/quickjs-singlefile-browser-debug-asyncify](README.md#jitlquickjs-singlefile-browser-debug-asyncify) - [@jitl/quickjs-singlefile-browser-release-sync](README.md#jitlquickjs-singlefile-browser-release-sync) - [@jitl/quickjs-singlefile-browser-release-asyncify](README.md#jitlquickjs-singlefile-browser-release-asyncify) + - [@jitl/quickjs-asmjs-mjs-release-sync](README.md#jitlquickjs-asmjs-mjs-release-sync) ## What's a variant? @@ -357,6 +358,19 @@ Variant with the WASM data embedded into a browser ESModule. | 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. | | exports | browser | Has these package.json export conditions | +### @jitl/quickjs-asmjs-mjs-release-sync + +[Docs](https://github.com/justjake/quickjs-emscripten/blob/main/doc/@jitl/quickjs-asmjs-mjs-release-sync/README.md) | +Compiled to pure Javascript, no WebAssembly required. + +| Variable | Setting | Description | +| ------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| 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. | +| releaseMode | release | Optimized for performance; use when building/deploying your application. | +| syncMode | sync | The default, normal build. Note that both variants support regular async functions. | +| 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. | +| exports | import | Has these package.json export conditions | + *** Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/doc/quickjs-emscripten-core/classes/DisposableFail.md b/doc/quickjs-emscripten-core/classes/DisposableFail.md index 3a615c2c..b1cef224 100644 --- a/doc/quickjs-emscripten-core/classes/DisposableFail.md +++ b/doc/quickjs-emscripten-core/classes/DisposableFail.md @@ -55,7 +55,7 @@ #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:426](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L426) +[packages/quickjs-emscripten-core/src/lifetime.ts:451](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L451) ## Properties @@ -65,7 +65,7 @@ #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:427](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L427) +[packages/quickjs-emscripten-core/src/lifetime.ts:452](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L452) ## Accessors @@ -79,7 +79,7 @@ #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:433](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L433) +[packages/quickjs-emscripten-core/src/lifetime.ts:458](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L458) ## Methods @@ -117,7 +117,7 @@ Just calls the standard .dispose() method of this class. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:437](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L437) +[packages/quickjs-emscripten-core/src/lifetime.ts:462](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L462) *** @@ -131,7 +131,7 @@ Just calls the standard .dispose() method of this class. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:443](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L443) +[packages/quickjs-emscripten-core/src/lifetime.ts:468](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L468) *** @@ -153,7 +153,7 @@ Just calls the standard .dispose() method of this class. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:448](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L448) +[packages/quickjs-emscripten-core/src/lifetime.ts:473](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L473) *** @@ -183,7 +183,7 @@ Just calls the standard .dispose() method of this class. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:384](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L384) +[packages/quickjs-emscripten-core/src/lifetime.ts:409](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L409) *** @@ -211,7 +211,7 @@ Just calls the standard .dispose() method of this class. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:391](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L391) +[packages/quickjs-emscripten-core/src/lifetime.ts:416](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L416) *** @@ -239,7 +239,7 @@ Just calls the standard .dispose() method of this class. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:380](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L380) +[packages/quickjs-emscripten-core/src/lifetime.ts:405](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L405) *** diff --git a/doc/quickjs-emscripten-core/classes/DisposableSuccess.md b/doc/quickjs-emscripten-core/classes/DisposableSuccess.md index ff6d43a1..70b6aaeb 100644 --- a/doc/quickjs-emscripten-core/classes/DisposableSuccess.md +++ b/doc/quickjs-emscripten-core/classes/DisposableSuccess.md @@ -54,7 +54,7 @@ #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:402](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L402) +[packages/quickjs-emscripten-core/src/lifetime.ts:427](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L427) ## Properties @@ -64,7 +64,7 @@ #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:400](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L400) +[packages/quickjs-emscripten-core/src/lifetime.ts:425](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L425) *** @@ -74,7 +74,7 @@ #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:402](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L402) +[packages/quickjs-emscripten-core/src/lifetime.ts:427](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L427) ## Accessors @@ -88,7 +88,7 @@ #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:406](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L406) +[packages/quickjs-emscripten-core/src/lifetime.ts:431](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L431) ## Methods @@ -126,7 +126,7 @@ Just calls the standard .dispose() method of this class. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:410](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L410) +[packages/quickjs-emscripten-core/src/lifetime.ts:435](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L435) *** @@ -140,7 +140,7 @@ Just calls the standard .dispose() method of this class. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:416](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L416) +[packages/quickjs-emscripten-core/src/lifetime.ts:441](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L441) *** @@ -162,7 +162,7 @@ Just calls the standard .dispose() method of this class. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:420](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L420) +[packages/quickjs-emscripten-core/src/lifetime.ts:445](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L445) *** @@ -192,7 +192,7 @@ Just calls the standard .dispose() method of this class. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:384](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L384) +[packages/quickjs-emscripten-core/src/lifetime.ts:409](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L409) *** @@ -220,7 +220,7 @@ Just calls the standard .dispose() method of this class. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:391](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L391) +[packages/quickjs-emscripten-core/src/lifetime.ts:416](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L416) *** @@ -248,7 +248,7 @@ Just calls the standard .dispose() method of this class. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:380](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L380) +[packages/quickjs-emscripten-core/src/lifetime.ts:405](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L405) *** diff --git a/doc/quickjs-emscripten-core/classes/Lifetime.md b/doc/quickjs-emscripten-core/classes/Lifetime.md index e7143477..c88e8f5a 100644 --- a/doc/quickjs-emscripten-core/classes/Lifetime.md +++ b/doc/quickjs-emscripten-core/classes/Lifetime.md @@ -35,6 +35,8 @@ Typically, quickjs-emscripten uses Lifetimes to protect C memory pointers. - [consume()](Lifetime.md#consume) - [dispose()](Lifetime.md#dispose) - [dup()](Lifetime.md#dup) + - [map()](Lifetime.md#map) + - [tap()](Lifetime.md#tap) ## Extends @@ -324,7 +326,7 @@ Dispose of [value](Lifetime.md#value-1) and perform cleanup. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:149](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L149) +[packages/quickjs-emscripten-core/src/lifetime.ts:174](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L174) *** @@ -344,4 +346,95 @@ Create a new handle pointing to the same [value](Lifetime.md#value-1). *** +### map() + +#### map(map) + +> **map**\<`O`\>(`map`): `O` + +Call `map` with this lifetime, returning the result. +Does not dispose the lifetime. + +##### Type parameters + +• **O** + +##### Parameters + +• **map**: (`lifetime`) => `O` + +##### Returns + +`O` + +the result of `map(this)`. + +##### Source + +[packages/quickjs-emscripten-core/src/lifetime.ts:151](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L151) + +#### map(map) + +> **map**\<`O`\>(`map`): `O` + +##### Type parameters + +• **O** + +##### Parameters + +• **map**: (`lifetime`) => `O` + +##### Returns + +`O` + +##### Source + +[packages/quickjs-emscripten-core/src/lifetime.ts:152](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L152) + +*** + +### tap() + +#### tap(fn) + +> **tap**(`fn`): [`Lifetime`](Lifetime.md)\<`T`, `TCopy`, `Owner`\> + +Call `fn` with this lifetime, then return `this`. Does not dispose the +lifetime. Useful for imperative operations within an expression, like when +you're building up objects, or to add logging in the middle of a call chain. + +##### Parameters + +• **fn**: (`lifetime`) => `void` + +##### Returns + +[`Lifetime`](Lifetime.md)\<`T`, `TCopy`, `Owner`\> + +this + +##### Source + +[packages/quickjs-emscripten-core/src/lifetime.ts:164](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L164) + +#### tap(fn) + +> **tap**(`fn`): [`QuickJSHandle`](../exports.md#quickjshandle) + +##### Parameters + +• **fn**: (`lifetime`) => `void` + +##### Returns + +[`QuickJSHandle`](../exports.md#quickjshandle) + +##### Source + +[packages/quickjs-emscripten-core/src/lifetime.ts:165](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L165) + +*** + Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/doc/quickjs-emscripten-core/classes/QuickJSAsyncContext.md b/doc/quickjs-emscripten-core/classes/QuickJSAsyncContext.md index 345518a8..754d4bc9 100644 --- a/doc/quickjs-emscripten-core/classes/QuickJSAsyncContext.md +++ b/doc/quickjs-emscripten-core/classes/QuickJSAsyncContext.md @@ -389,7 +389,7 @@ socket.on("data", chunk => { #### Source -[packages/quickjs-emscripten-core/src/context.ts:1422](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L1422) +[packages/quickjs-emscripten-core/src/context.ts:1431](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L1431) *** @@ -505,7 +505,7 @@ socket.write(dataLifetime?.value) #### Source -[packages/quickjs-emscripten-core/src/context.ts:1405](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L1405) +[packages/quickjs-emscripten-core/src/context.ts:1414](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L1414) *** @@ -643,7 +643,7 @@ See [EvalFlags](../exports.md#evalflags) for number semantics #### Source -[packages/quickjs-emscripten-core/src/context.ts:1431](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L1431) +[packages/quickjs-emscripten-core/src/context.ts:1440](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L1440) *** @@ -1611,7 +1611,7 @@ properties. #### Source -[packages/quickjs-emscripten-core/src/context.ts:1427](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L1427) +[packages/quickjs-emscripten-core/src/context.ts:1436](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L1436) *** diff --git a/doc/quickjs-emscripten-core/classes/QuickJSContext.md b/doc/quickjs-emscripten-core/classes/QuickJSContext.md index 65647992..bf3f1ad7 100644 --- a/doc/quickjs-emscripten-core/classes/QuickJSContext.md +++ b/doc/quickjs-emscripten-core/classes/QuickJSContext.md @@ -409,7 +409,7 @@ socket.on("data", chunk => { #### Source -[packages/quickjs-emscripten-core/src/context.ts:1422](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L1422) +[packages/quickjs-emscripten-core/src/context.ts:1431](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L1431) *** @@ -521,7 +521,7 @@ socket.write(dataLifetime?.value) #### Source -[packages/quickjs-emscripten-core/src/context.ts:1405](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L1405) +[packages/quickjs-emscripten-core/src/context.ts:1414](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L1414) *** @@ -625,7 +625,7 @@ interrupted, the error will have name `InternalError` and message #### Source -[packages/quickjs-emscripten-core/src/context.ts:1431](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L1431) +[packages/quickjs-emscripten-core/src/context.ts:1440](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L1440) *** @@ -1469,7 +1469,7 @@ properties. #### Source -[packages/quickjs-emscripten-core/src/context.ts:1427](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L1427) +[packages/quickjs-emscripten-core/src/context.ts:1436](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L1436) *** diff --git a/doc/quickjs-emscripten-core/classes/Scope.md b/doc/quickjs-emscripten-core/classes/Scope.md index 682fafd8..34f5312a 100644 --- a/doc/quickjs-emscripten-core/classes/Scope.md +++ b/doc/quickjs-emscripten-core/classes/Scope.md @@ -63,7 +63,7 @@ false after the object has been [dispose](Scope.md#dispose-1)d #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:308](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L308) +[packages/quickjs-emscripten-core/src/lifetime.ts:333](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L333) ## Methods @@ -111,7 +111,7 @@ Dispose of the underlying resources used by this object. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:312](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L312) +[packages/quickjs-emscripten-core/src/lifetime.ts:337](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L337) *** @@ -135,7 +135,7 @@ Track `lifetime` so that it is disposed when this scope is disposed. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:303](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L303) +[packages/quickjs-emscripten-core/src/lifetime.ts:328](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L328) *** @@ -165,7 +165,7 @@ Do not use with async functions. Instead, use [withScopeAsync](Scope.md#withscop #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:248](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L248) +[packages/quickjs-emscripten-core/src/lifetime.ts:273](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L273) *** @@ -192,7 +192,7 @@ block returns. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:285](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L285) +[packages/quickjs-emscripten-core/src/lifetime.ts:310](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L310) *** @@ -220,7 +220,7 @@ block returns. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:261](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L261) +[packages/quickjs-emscripten-core/src/lifetime.ts:286](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L286) *** diff --git a/doc/quickjs-emscripten-core/classes/StaticLifetime.md b/doc/quickjs-emscripten-core/classes/StaticLifetime.md index 6b93e251..97d17214 100644 --- a/doc/quickjs-emscripten-core/classes/StaticLifetime.md +++ b/doc/quickjs-emscripten-core/classes/StaticLifetime.md @@ -31,6 +31,8 @@ A Lifetime that lives forever. Used for constants. - [consume()](StaticLifetime.md#consume) - [dispose()](StaticLifetime.md#dispose) - [dup()](StaticLifetime.md#dup) + - [map()](StaticLifetime.md#map) + - [tap()](StaticLifetime.md#tap) ## Extends @@ -64,7 +66,7 @@ A Lifetime that lives forever. Used for constants. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:173](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L173) +[packages/quickjs-emscripten-core/src/lifetime.ts:198](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L198) ## Properties @@ -196,7 +198,7 @@ false after the object has been [dispose](StaticLifetime.md#dispose-1)d #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:178](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L178) +[packages/quickjs-emscripten-core/src/lifetime.ts:203](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L203) *** @@ -327,7 +329,7 @@ Dispose of [value](StaticLifetime.md#value-1) and perform cleanup. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:188](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L188) +[packages/quickjs-emscripten-core/src/lifetime.ts:213](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L213) *** @@ -347,7 +349,114 @@ Create a new handle pointing to the same [value](StaticLifetime.md#value-1). #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:183](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L183) +[packages/quickjs-emscripten-core/src/lifetime.ts:208](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L208) + +*** + +### map() + +#### map(map) + +> **map**\<`O`\>(`map`): `O` + +Call `map` with this lifetime, returning the result. +Does not dispose the lifetime. + +##### Type parameters + +• **O** + +##### Parameters + +• **map**: (`lifetime`) => `O` + +##### Returns + +`O` + +the result of `map(this)`. + +##### Inherited from + +[`quickjs-emscripten-core.Lifetime.map`](Lifetime.md#map) + +##### Source + +[packages/quickjs-emscripten-core/src/lifetime.ts:151](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L151) + +#### map(map) + +> **map**\<`O`\>(`map`): `O` + +##### Type parameters + +• **O** + +##### Parameters + +• **map**: (`lifetime`) => `O` + +##### Returns + +`O` + +##### Inherited from + +[`quickjs-emscripten-core.Lifetime.map`](Lifetime.md#map) + +##### Source + +[packages/quickjs-emscripten-core/src/lifetime.ts:152](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L152) + +*** + +### tap() + +#### tap(fn) + +> **tap**(`fn`): [`StaticLifetime`](StaticLifetime.md)\<`T`, `Owner`\> + +Call `fn` with this lifetime, then return `this`. Does not dispose the +lifetime. Useful for imperative operations within an expression, like when +you're building up objects, or to add logging in the middle of a call chain. + +##### Parameters + +• **fn**: (`lifetime`) => `void` + +##### Returns + +[`StaticLifetime`](StaticLifetime.md)\<`T`, `Owner`\> + +this + +##### Inherited from + +[`quickjs-emscripten-core.Lifetime.tap`](Lifetime.md#tap) + +##### Source + +[packages/quickjs-emscripten-core/src/lifetime.ts:164](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L164) + +#### tap(fn) + +> **tap**(`fn`): [`QuickJSHandle`](../exports.md#quickjshandle) + +##### Parameters + +• **fn**: (`lifetime`) => `void` + +##### Returns + +[`QuickJSHandle`](../exports.md#quickjshandle) + +##### Inherited from + +[`quickjs-emscripten-core.Lifetime.tap`](Lifetime.md#tap) + +##### Source + +[packages/quickjs-emscripten-core/src/lifetime.ts:165](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L165) *** diff --git a/doc/quickjs-emscripten-core/classes/WeakLifetime.md b/doc/quickjs-emscripten-core/classes/WeakLifetime.md index c3e9d495..089cf48f 100644 --- a/doc/quickjs-emscripten-core/classes/WeakLifetime.md +++ b/doc/quickjs-emscripten-core/classes/WeakLifetime.md @@ -35,6 +35,8 @@ Used for function arguments. - [consume()](WeakLifetime.md#consume) - [dispose()](WeakLifetime.md#dispose) - [dup()](WeakLifetime.md#dup) + - [map()](WeakLifetime.md#map) + - [tap()](WeakLifetime.md#tap) ## Extends @@ -74,7 +76,7 @@ Used for function arguments. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:199](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L199) +[packages/quickjs-emscripten-core/src/lifetime.ts:224](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L224) ## Properties @@ -337,7 +339,7 @@ Dispose of [value](WeakLifetime.md#value-1) and perform cleanup. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:209](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L209) +[packages/quickjs-emscripten-core/src/lifetime.ts:234](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L234) *** @@ -361,4 +363,111 @@ Create a new handle pointing to the same [value](WeakLifetime.md#value-1). *** +### map() + +#### map(map) + +> **map**\<`O`\>(`map`): `O` + +Call `map` with this lifetime, returning the result. +Does not dispose the lifetime. + +##### Type parameters + +• **O** + +##### Parameters + +• **map**: (`lifetime`) => `O` + +##### Returns + +`O` + +the result of `map(this)`. + +##### Inherited from + +[`quickjs-emscripten-core.Lifetime.map`](Lifetime.md#map) + +##### Source + +[packages/quickjs-emscripten-core/src/lifetime.ts:151](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L151) + +#### map(map) + +> **map**\<`O`\>(`map`): `O` + +##### Type parameters + +• **O** + +##### Parameters + +• **map**: (`lifetime`) => `O` + +##### Returns + +`O` + +##### Inherited from + +[`quickjs-emscripten-core.Lifetime.map`](Lifetime.md#map) + +##### Source + +[packages/quickjs-emscripten-core/src/lifetime.ts:152](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L152) + +*** + +### tap() + +#### tap(fn) + +> **tap**(`fn`): [`WeakLifetime`](WeakLifetime.md)\<`T`, `TCopy`, `Owner`\> + +Call `fn` with this lifetime, then return `this`. Does not dispose the +lifetime. Useful for imperative operations within an expression, like when +you're building up objects, or to add logging in the middle of a call chain. + +##### Parameters + +• **fn**: (`lifetime`) => `void` + +##### Returns + +[`WeakLifetime`](WeakLifetime.md)\<`T`, `TCopy`, `Owner`\> + +this + +##### Inherited from + +[`quickjs-emscripten-core.Lifetime.tap`](Lifetime.md#tap) + +##### Source + +[packages/quickjs-emscripten-core/src/lifetime.ts:164](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L164) + +#### tap(fn) + +> **tap**(`fn`): [`QuickJSHandle`](../exports.md#quickjshandle) + +##### Parameters + +• **fn**: (`lifetime`) => `void` + +##### Returns + +[`QuickJSHandle`](../exports.md#quickjshandle) + +##### Inherited from + +[`quickjs-emscripten-core.Lifetime.tap`](Lifetime.md#tap) + +##### Source + +[packages/quickjs-emscripten-core/src/lifetime.ts:165](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L165) + +*** + Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/doc/quickjs-emscripten-core/exports.md b/doc/quickjs-emscripten-core/exports.md index c0da3274..51df2323 100644 --- a/doc/quickjs-emscripten-core/exports.md +++ b/doc/quickjs-emscripten-core/exports.md @@ -179,7 +179,7 @@ An `Array` that also implements [Disposable](interfaces/Disposable.md): #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:329](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L329) +[packages/quickjs-emscripten-core/src/lifetime.ts:354](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L354) *** @@ -195,7 +195,7 @@ An `Array` that also implements [Disposable](interfaces/Disposable.md): #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:453](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L453) +[packages/quickjs-emscripten-core/src/lifetime.ts:478](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L478) *** @@ -237,7 +237,7 @@ by the runtime. ### InterruptHandler -> **InterruptHandler**: (`runtime`) => `boolean` \| `undefined` +> **InterruptHandler**: (`runtime`) => `boolean` \| `undefined` \| `void` Callback called regularly while the VM executes code. Determines if a VM's execution should be interrupted. @@ -248,7 +248,7 @@ Determines if a VM's execution should be interrupted. #### Returns -`boolean` \| `undefined` +`boolean` \| `undefined` \| `void` `true` to interrupt JS execution inside the VM. @@ -905,7 +905,7 @@ The default [Intrinsics](exports.md#intrinsics) language features enabled in a Q #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:453](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L453) +[packages/quickjs-emscripten-core/src/lifetime.ts:478](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L478) *** @@ -1198,7 +1198,7 @@ Create an array that also implements [Disposable](interfaces/Disposable.md). #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:334](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L334) +[packages/quickjs-emscripten-core/src/lifetime.ts:359](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L359) *** diff --git a/doc/quickjs-emscripten-core/namespaces/errors/classes/QuickJSAsyncifyError.md b/doc/quickjs-emscripten-core/namespaces/errors/classes/QuickJSAsyncifyError.md index f8b54767..f54e832f 100644 --- a/doc/quickjs-emscripten-core/namespaces/errors/classes/QuickJSAsyncifyError.md +++ b/doc/quickjs-emscripten-core/namespaces/errors/classes/QuickJSAsyncifyError.md @@ -52,7 +52,7 @@ node\_modules/typescript/lib/lib.es5.d.ts:1081 #### Source -[packages/quickjs-emscripten-core/src/errors.ts:29](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L29) +[packages/quickjs-emscripten-core/src/errors.ts:33](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L33) *** diff --git a/doc/quickjs-emscripten-core/namespaces/errors/classes/QuickJSAsyncifySuspended.md b/doc/quickjs-emscripten-core/namespaces/errors/classes/QuickJSAsyncifySuspended.md index c2dcd778..05168843 100644 --- a/doc/quickjs-emscripten-core/namespaces/errors/classes/QuickJSAsyncifySuspended.md +++ b/doc/quickjs-emscripten-core/namespaces/errors/classes/QuickJSAsyncifySuspended.md @@ -52,7 +52,7 @@ node\_modules/typescript/lib/lib.es5.d.ts:1081 #### Source -[packages/quickjs-emscripten-core/src/errors.ts:33](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L33) +[packages/quickjs-emscripten-core/src/errors.ts:37](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L37) *** diff --git a/doc/quickjs-emscripten-core/namespaces/errors/classes/QuickJSEmptyGetOwnPropertyNames.md b/doc/quickjs-emscripten-core/namespaces/errors/classes/QuickJSEmptyGetOwnPropertyNames.md index 3a6e4a62..38907f4d 100644 --- a/doc/quickjs-emscripten-core/namespaces/errors/classes/QuickJSEmptyGetOwnPropertyNames.md +++ b/doc/quickjs-emscripten-core/namespaces/errors/classes/QuickJSEmptyGetOwnPropertyNames.md @@ -52,7 +52,7 @@ node\_modules/typescript/lib/lib.es5.d.ts:1081 #### Source -[packages/quickjs-emscripten-core/src/errors.ts:53](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L53) +[packages/quickjs-emscripten-core/src/errors.ts:57](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L57) *** diff --git a/doc/quickjs-emscripten-core/namespaces/errors/classes/QuickJSEmscriptenModuleError.md b/doc/quickjs-emscripten-core/namespaces/errors/classes/QuickJSEmscriptenModuleError.md index 0d707d15..6de3198c 100644 --- a/doc/quickjs-emscripten-core/namespaces/errors/classes/QuickJSEmscriptenModuleError.md +++ b/doc/quickjs-emscripten-core/namespaces/errors/classes/QuickJSEmscriptenModuleError.md @@ -52,7 +52,7 @@ node\_modules/typescript/lib/lib.es5.d.ts:1081 #### Source -[packages/quickjs-emscripten-core/src/errors.ts:41](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L41) +[packages/quickjs-emscripten-core/src/errors.ts:45](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L45) *** diff --git a/doc/quickjs-emscripten-core/namespaces/errors/classes/QuickJSMemoryLeakDetected.md b/doc/quickjs-emscripten-core/namespaces/errors/classes/QuickJSMemoryLeakDetected.md index 1c04616d..85c5385a 100644 --- a/doc/quickjs-emscripten-core/namespaces/errors/classes/QuickJSMemoryLeakDetected.md +++ b/doc/quickjs-emscripten-core/namespaces/errors/classes/QuickJSMemoryLeakDetected.md @@ -52,7 +52,7 @@ node\_modules/typescript/lib/lib.es5.d.ts:1081 #### Source -[packages/quickjs-emscripten-core/src/errors.ts:37](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L37) +[packages/quickjs-emscripten-core/src/errors.ts:41](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L41) *** diff --git a/doc/quickjs-emscripten-core/namespaces/errors/classes/QuickJSNotImplemented.md b/doc/quickjs-emscripten-core/namespaces/errors/classes/QuickJSNotImplemented.md index 5584d60a..ab28b86a 100644 --- a/doc/quickjs-emscripten-core/namespaces/errors/classes/QuickJSNotImplemented.md +++ b/doc/quickjs-emscripten-core/namespaces/errors/classes/QuickJSNotImplemented.md @@ -52,7 +52,7 @@ node\_modules/typescript/lib/lib.es5.d.ts:1081 #### Source -[packages/quickjs-emscripten-core/src/errors.ts:25](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L25) +[packages/quickjs-emscripten-core/src/errors.ts:29](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L29) *** diff --git a/doc/quickjs-emscripten-core/namespaces/errors/classes/QuickJSPromisePending.md b/doc/quickjs-emscripten-core/namespaces/errors/classes/QuickJSPromisePending.md index 507d45e6..48153e06 100644 --- a/doc/quickjs-emscripten-core/namespaces/errors/classes/QuickJSPromisePending.md +++ b/doc/quickjs-emscripten-core/namespaces/errors/classes/QuickJSPromisePending.md @@ -52,7 +52,7 @@ node\_modules/typescript/lib/lib.es5.d.ts:1081 #### Source -[packages/quickjs-emscripten-core/src/errors.ts:49](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L49) +[packages/quickjs-emscripten-core/src/errors.ts:53](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L53) *** diff --git a/doc/quickjs-emscripten-core/namespaces/errors/classes/QuickJSUnknownIntrinsic.md b/doc/quickjs-emscripten-core/namespaces/errors/classes/QuickJSUnknownIntrinsic.md index 92d051fc..6cd58c47 100644 --- a/doc/quickjs-emscripten-core/namespaces/errors/classes/QuickJSUnknownIntrinsic.md +++ b/doc/quickjs-emscripten-core/namespaces/errors/classes/QuickJSUnknownIntrinsic.md @@ -73,7 +73,7 @@ node\_modules/typescript/lib/lib.es5.d.ts:1081 #### Source -[packages/quickjs-emscripten-core/src/errors.ts:45](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L45) +[packages/quickjs-emscripten-core/src/errors.ts:49](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L49) *** diff --git a/doc/quickjs-emscripten-core/namespaces/errors/classes/QuickJSUseAfterFree.md b/doc/quickjs-emscripten-core/namespaces/errors/classes/QuickJSUseAfterFree.md index aada20cf..5b9a0df9 100644 --- a/doc/quickjs-emscripten-core/namespaces/errors/classes/QuickJSUseAfterFree.md +++ b/doc/quickjs-emscripten-core/namespaces/errors/classes/QuickJSUseAfterFree.md @@ -52,7 +52,7 @@ node\_modules/typescript/lib/lib.es5.d.ts:1081 #### Source -[packages/quickjs-emscripten-core/src/errors.ts:21](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L21) +[packages/quickjs-emscripten-core/src/errors.ts:25](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L25) *** diff --git a/doc/quickjs-emscripten-core/namespaces/errors/classes/QuickJSWrongOwner.md b/doc/quickjs-emscripten-core/namespaces/errors/classes/QuickJSWrongOwner.md index 42411823..17405113 100644 --- a/doc/quickjs-emscripten-core/namespaces/errors/classes/QuickJSWrongOwner.md +++ b/doc/quickjs-emscripten-core/namespaces/errors/classes/QuickJSWrongOwner.md @@ -52,7 +52,7 @@ node\_modules/typescript/lib/lib.es5.d.ts:1081 #### Source -[packages/quickjs-emscripten-core/src/errors.ts:17](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L17) +[packages/quickjs-emscripten-core/src/errors.ts:21](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L21) *** diff --git a/doc/quickjs-emscripten/README.md b/doc/quickjs-emscripten/README.md index 025b8e45..56d90b3d 100644 --- a/doc/quickjs-emscripten/README.md +++ b/doc/quickjs-emscripten/README.md @@ -11,6 +11,7 @@ compiled to WebAssembly. - Create and manipulate values inside the QuickJS runtime ([more][values]). - Expose host functions to the QuickJS runtime ([more][functions]). - Execute synchronous code that uses asynchronous functions, with [asyncify][asyncify]. +- Supports browsers, NodeJS, Deno, Bun, Cloudflare Workers, QuickJS (via [quickjs-for-quickjs][]). [Github] | [NPM] | [API Documentation][api] | [Variants][core] | [Examples][tests] @@ -47,6 +48,7 @@ main() [values]: #interfacing-with-the-interpreter [asyncify]: #asyncify [functions]: #exposing-apis +[quickjs-for-quickjs]: https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-for-quickjs - [quickjs-emscripten](#quickjs-emscripten) - [Usage](#usage) diff --git a/doc/quickjs-emscripten/classes/DisposableFail.md b/doc/quickjs-emscripten/classes/DisposableFail.md index e10ede00..af081e63 100644 --- a/doc/quickjs-emscripten/classes/DisposableFail.md +++ b/doc/quickjs-emscripten/classes/DisposableFail.md @@ -55,7 +55,7 @@ #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:426](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L426) +[packages/quickjs-emscripten-core/src/lifetime.ts:451](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L451) ## Properties @@ -65,7 +65,7 @@ #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:427](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L427) +[packages/quickjs-emscripten-core/src/lifetime.ts:452](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L452) ## Accessors @@ -79,7 +79,7 @@ #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:433](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L433) +[packages/quickjs-emscripten-core/src/lifetime.ts:458](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L458) ## Methods @@ -117,7 +117,7 @@ Just calls the standard .dispose() method of this class. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:437](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L437) +[packages/quickjs-emscripten-core/src/lifetime.ts:462](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L462) *** @@ -131,7 +131,7 @@ Just calls the standard .dispose() method of this class. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:443](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L443) +[packages/quickjs-emscripten-core/src/lifetime.ts:468](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L468) *** @@ -153,7 +153,7 @@ Just calls the standard .dispose() method of this class. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:448](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L448) +[packages/quickjs-emscripten-core/src/lifetime.ts:473](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L473) *** @@ -183,7 +183,7 @@ Just calls the standard .dispose() method of this class. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:384](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L384) +[packages/quickjs-emscripten-core/src/lifetime.ts:409](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L409) *** @@ -211,7 +211,7 @@ Just calls the standard .dispose() method of this class. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:391](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L391) +[packages/quickjs-emscripten-core/src/lifetime.ts:416](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L416) *** @@ -239,7 +239,7 @@ Just calls the standard .dispose() method of this class. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:380](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L380) +[packages/quickjs-emscripten-core/src/lifetime.ts:405](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L405) *** diff --git a/doc/quickjs-emscripten/classes/DisposableSuccess.md b/doc/quickjs-emscripten/classes/DisposableSuccess.md index fad44ca8..c4dce084 100644 --- a/doc/quickjs-emscripten/classes/DisposableSuccess.md +++ b/doc/quickjs-emscripten/classes/DisposableSuccess.md @@ -54,7 +54,7 @@ #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:402](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L402) +[packages/quickjs-emscripten-core/src/lifetime.ts:427](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L427) ## Properties @@ -64,7 +64,7 @@ #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:400](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L400) +[packages/quickjs-emscripten-core/src/lifetime.ts:425](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L425) *** @@ -74,7 +74,7 @@ #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:402](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L402) +[packages/quickjs-emscripten-core/src/lifetime.ts:427](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L427) ## Accessors @@ -88,7 +88,7 @@ #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:406](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L406) +[packages/quickjs-emscripten-core/src/lifetime.ts:431](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L431) ## Methods @@ -126,7 +126,7 @@ Just calls the standard .dispose() method of this class. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:410](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L410) +[packages/quickjs-emscripten-core/src/lifetime.ts:435](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L435) *** @@ -140,7 +140,7 @@ Just calls the standard .dispose() method of this class. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:416](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L416) +[packages/quickjs-emscripten-core/src/lifetime.ts:441](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L441) *** @@ -162,7 +162,7 @@ Just calls the standard .dispose() method of this class. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:420](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L420) +[packages/quickjs-emscripten-core/src/lifetime.ts:445](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L445) *** @@ -192,7 +192,7 @@ Just calls the standard .dispose() method of this class. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:384](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L384) +[packages/quickjs-emscripten-core/src/lifetime.ts:409](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L409) *** @@ -220,7 +220,7 @@ Just calls the standard .dispose() method of this class. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:391](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L391) +[packages/quickjs-emscripten-core/src/lifetime.ts:416](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L416) *** @@ -248,7 +248,7 @@ Just calls the standard .dispose() method of this class. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:380](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L380) +[packages/quickjs-emscripten-core/src/lifetime.ts:405](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L405) *** diff --git a/doc/quickjs-emscripten/classes/Lifetime.md b/doc/quickjs-emscripten/classes/Lifetime.md index 3fbcd4b1..62ec48a9 100644 --- a/doc/quickjs-emscripten/classes/Lifetime.md +++ b/doc/quickjs-emscripten/classes/Lifetime.md @@ -35,6 +35,8 @@ Typically, quickjs-emscripten uses Lifetimes to protect C memory pointers. - [consume()](Lifetime.md#consume) - [dispose()](Lifetime.md#dispose) - [dup()](Lifetime.md#dup) + - [map()](Lifetime.md#map) + - [tap()](Lifetime.md#tap) ## Extends @@ -324,7 +326,7 @@ Dispose of [value](Lifetime.md#value-1) and perform cleanup. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:149](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L149) +[packages/quickjs-emscripten-core/src/lifetime.ts:174](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L174) *** @@ -344,4 +346,95 @@ Create a new handle pointing to the same [value](Lifetime.md#value-1). *** +### map() + +#### map(map) + +> **map**\<`O`\>(`map`): `O` + +Call `map` with this lifetime, returning the result. +Does not dispose the lifetime. + +##### Type parameters + +• **O** + +##### Parameters + +• **map**: (`lifetime`) => `O` + +##### Returns + +`O` + +the result of `map(this)`. + +##### Source + +[packages/quickjs-emscripten-core/src/lifetime.ts:151](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L151) + +#### map(map) + +> **map**\<`O`\>(`map`): `O` + +##### Type parameters + +• **O** + +##### Parameters + +• **map**: (`lifetime`) => `O` + +##### Returns + +`O` + +##### Source + +[packages/quickjs-emscripten-core/src/lifetime.ts:152](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L152) + +*** + +### tap() + +#### tap(fn) + +> **tap**(`fn`): [`Lifetime`](Lifetime.md)\<`T`, `TCopy`, `Owner`\> + +Call `fn` with this lifetime, then return `this`. Does not dispose the +lifetime. Useful for imperative operations within an expression, like when +you're building up objects, or to add logging in the middle of a call chain. + +##### Parameters + +• **fn**: (`lifetime`) => `void` + +##### Returns + +[`Lifetime`](Lifetime.md)\<`T`, `TCopy`, `Owner`\> + +this + +##### Source + +[packages/quickjs-emscripten-core/src/lifetime.ts:164](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L164) + +#### tap(fn) + +> **tap**(`fn`): [`QuickJSHandle`](../exports.md#quickjshandle) + +##### Parameters + +• **fn**: (`lifetime`) => `void` + +##### Returns + +[`QuickJSHandle`](../exports.md#quickjshandle) + +##### Source + +[packages/quickjs-emscripten-core/src/lifetime.ts:165](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L165) + +*** + Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/doc/quickjs-emscripten/classes/QuickJSAsyncContext.md b/doc/quickjs-emscripten/classes/QuickJSAsyncContext.md index f312c8cf..d5fdcc5b 100644 --- a/doc/quickjs-emscripten/classes/QuickJSAsyncContext.md +++ b/doc/quickjs-emscripten/classes/QuickJSAsyncContext.md @@ -389,7 +389,7 @@ socket.on("data", chunk => { #### Source -[packages/quickjs-emscripten-core/src/context.ts:1422](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L1422) +[packages/quickjs-emscripten-core/src/context.ts:1431](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L1431) *** @@ -505,7 +505,7 @@ socket.write(dataLifetime?.value) #### Source -[packages/quickjs-emscripten-core/src/context.ts:1405](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L1405) +[packages/quickjs-emscripten-core/src/context.ts:1414](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L1414) *** @@ -643,7 +643,7 @@ See [EvalFlags](../exports.md#evalflags) for number semantics #### Source -[packages/quickjs-emscripten-core/src/context.ts:1431](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L1431) +[packages/quickjs-emscripten-core/src/context.ts:1440](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L1440) *** @@ -1611,7 +1611,7 @@ properties. #### Source -[packages/quickjs-emscripten-core/src/context.ts:1427](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L1427) +[packages/quickjs-emscripten-core/src/context.ts:1436](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L1436) *** diff --git a/doc/quickjs-emscripten/classes/QuickJSContext.md b/doc/quickjs-emscripten/classes/QuickJSContext.md index 11d282b2..00d400b9 100644 --- a/doc/quickjs-emscripten/classes/QuickJSContext.md +++ b/doc/quickjs-emscripten/classes/QuickJSContext.md @@ -409,7 +409,7 @@ socket.on("data", chunk => { #### Source -[packages/quickjs-emscripten-core/src/context.ts:1422](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L1422) +[packages/quickjs-emscripten-core/src/context.ts:1431](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L1431) *** @@ -521,7 +521,7 @@ socket.write(dataLifetime?.value) #### Source -[packages/quickjs-emscripten-core/src/context.ts:1405](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L1405) +[packages/quickjs-emscripten-core/src/context.ts:1414](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L1414) *** @@ -625,7 +625,7 @@ interrupted, the error will have name `InternalError` and message #### Source -[packages/quickjs-emscripten-core/src/context.ts:1431](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L1431) +[packages/quickjs-emscripten-core/src/context.ts:1440](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L1440) *** @@ -1469,7 +1469,7 @@ properties. #### Source -[packages/quickjs-emscripten-core/src/context.ts:1427](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L1427) +[packages/quickjs-emscripten-core/src/context.ts:1436](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/context.ts#L1436) *** diff --git a/doc/quickjs-emscripten/classes/Scope.md b/doc/quickjs-emscripten/classes/Scope.md index 038058ef..b231f37f 100644 --- a/doc/quickjs-emscripten/classes/Scope.md +++ b/doc/quickjs-emscripten/classes/Scope.md @@ -63,7 +63,7 @@ false after the object has been [dispose](Scope.md#dispose-1)d #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:308](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L308) +[packages/quickjs-emscripten-core/src/lifetime.ts:333](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L333) ## Methods @@ -111,7 +111,7 @@ Dispose of the underlying resources used by this object. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:312](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L312) +[packages/quickjs-emscripten-core/src/lifetime.ts:337](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L337) *** @@ -135,7 +135,7 @@ Track `lifetime` so that it is disposed when this scope is disposed. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:303](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L303) +[packages/quickjs-emscripten-core/src/lifetime.ts:328](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L328) *** @@ -165,7 +165,7 @@ Do not use with async functions. Instead, use [withScopeAsync](Scope.md#withscop #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:248](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L248) +[packages/quickjs-emscripten-core/src/lifetime.ts:273](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L273) *** @@ -192,7 +192,7 @@ block returns. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:285](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L285) +[packages/quickjs-emscripten-core/src/lifetime.ts:310](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L310) *** @@ -220,7 +220,7 @@ block returns. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:261](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L261) +[packages/quickjs-emscripten-core/src/lifetime.ts:286](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L286) *** diff --git a/doc/quickjs-emscripten/classes/StaticLifetime.md b/doc/quickjs-emscripten/classes/StaticLifetime.md index 43563372..d8ce4a69 100644 --- a/doc/quickjs-emscripten/classes/StaticLifetime.md +++ b/doc/quickjs-emscripten/classes/StaticLifetime.md @@ -31,6 +31,8 @@ A Lifetime that lives forever. Used for constants. - [consume()](StaticLifetime.md#consume) - [dispose()](StaticLifetime.md#dispose) - [dup()](StaticLifetime.md#dup) + - [map()](StaticLifetime.md#map) + - [tap()](StaticLifetime.md#tap) ## Extends @@ -64,7 +66,7 @@ A Lifetime that lives forever. Used for constants. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:173](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L173) +[packages/quickjs-emscripten-core/src/lifetime.ts:198](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L198) ## Properties @@ -196,7 +198,7 @@ false after the object has been [dispose](StaticLifetime.md#dispose-1)d #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:178](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L178) +[packages/quickjs-emscripten-core/src/lifetime.ts:203](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L203) *** @@ -327,7 +329,7 @@ Dispose of [value](StaticLifetime.md#value-1) and perform cleanup. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:188](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L188) +[packages/quickjs-emscripten-core/src/lifetime.ts:213](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L213) *** @@ -347,7 +349,114 @@ Create a new handle pointing to the same [value](StaticLifetime.md#value-1). #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:183](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L183) +[packages/quickjs-emscripten-core/src/lifetime.ts:208](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L208) + +*** + +### map() + +#### map(map) + +> **map**\<`O`\>(`map`): `O` + +Call `map` with this lifetime, returning the result. +Does not dispose the lifetime. + +##### Type parameters + +• **O** + +##### Parameters + +• **map**: (`lifetime`) => `O` + +##### Returns + +`O` + +the result of `map(this)`. + +##### Inherited from + +[`quickjs-emscripten.Lifetime.map`](Lifetime.md#map) + +##### Source + +[packages/quickjs-emscripten-core/src/lifetime.ts:151](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L151) + +#### map(map) + +> **map**\<`O`\>(`map`): `O` + +##### Type parameters + +• **O** + +##### Parameters + +• **map**: (`lifetime`) => `O` + +##### Returns + +`O` + +##### Inherited from + +[`quickjs-emscripten.Lifetime.map`](Lifetime.md#map) + +##### Source + +[packages/quickjs-emscripten-core/src/lifetime.ts:152](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L152) + +*** + +### tap() + +#### tap(fn) + +> **tap**(`fn`): [`StaticLifetime`](StaticLifetime.md)\<`T`, `Owner`\> + +Call `fn` with this lifetime, then return `this`. Does not dispose the +lifetime. Useful for imperative operations within an expression, like when +you're building up objects, or to add logging in the middle of a call chain. + +##### Parameters + +• **fn**: (`lifetime`) => `void` + +##### Returns + +[`StaticLifetime`](StaticLifetime.md)\<`T`, `Owner`\> + +this + +##### Inherited from + +[`quickjs-emscripten.Lifetime.tap`](Lifetime.md#tap) + +##### Source + +[packages/quickjs-emscripten-core/src/lifetime.ts:164](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L164) + +#### tap(fn) + +> **tap**(`fn`): [`QuickJSHandle`](../exports.md#quickjshandle) + +##### Parameters + +• **fn**: (`lifetime`) => `void` + +##### Returns + +[`QuickJSHandle`](../exports.md#quickjshandle) + +##### Inherited from + +[`quickjs-emscripten.Lifetime.tap`](Lifetime.md#tap) + +##### Source + +[packages/quickjs-emscripten-core/src/lifetime.ts:165](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L165) *** diff --git a/doc/quickjs-emscripten/classes/WeakLifetime.md b/doc/quickjs-emscripten/classes/WeakLifetime.md index 41173dc4..eedbf4cd 100644 --- a/doc/quickjs-emscripten/classes/WeakLifetime.md +++ b/doc/quickjs-emscripten/classes/WeakLifetime.md @@ -35,6 +35,8 @@ Used for function arguments. - [consume()](WeakLifetime.md#consume) - [dispose()](WeakLifetime.md#dispose) - [dup()](WeakLifetime.md#dup) + - [map()](WeakLifetime.md#map) + - [tap()](WeakLifetime.md#tap) ## Extends @@ -74,7 +76,7 @@ Used for function arguments. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:199](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L199) +[packages/quickjs-emscripten-core/src/lifetime.ts:224](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L224) ## Properties @@ -337,7 +339,7 @@ Dispose of [value](WeakLifetime.md#value-1) and perform cleanup. #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:209](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L209) +[packages/quickjs-emscripten-core/src/lifetime.ts:234](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L234) *** @@ -361,4 +363,111 @@ Create a new handle pointing to the same [value](WeakLifetime.md#value-1). *** +### map() + +#### map(map) + +> **map**\<`O`\>(`map`): `O` + +Call `map` with this lifetime, returning the result. +Does not dispose the lifetime. + +##### Type parameters + +• **O** + +##### Parameters + +• **map**: (`lifetime`) => `O` + +##### Returns + +`O` + +the result of `map(this)`. + +##### Inherited from + +[`quickjs-emscripten.Lifetime.map`](Lifetime.md#map) + +##### Source + +[packages/quickjs-emscripten-core/src/lifetime.ts:151](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L151) + +#### map(map) + +> **map**\<`O`\>(`map`): `O` + +##### Type parameters + +• **O** + +##### Parameters + +• **map**: (`lifetime`) => `O` + +##### Returns + +`O` + +##### Inherited from + +[`quickjs-emscripten.Lifetime.map`](Lifetime.md#map) + +##### Source + +[packages/quickjs-emscripten-core/src/lifetime.ts:152](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L152) + +*** + +### tap() + +#### tap(fn) + +> **tap**(`fn`): [`WeakLifetime`](WeakLifetime.md)\<`T`, `TCopy`, `Owner`\> + +Call `fn` with this lifetime, then return `this`. Does not dispose the +lifetime. Useful for imperative operations within an expression, like when +you're building up objects, or to add logging in the middle of a call chain. + +##### Parameters + +• **fn**: (`lifetime`) => `void` + +##### Returns + +[`WeakLifetime`](WeakLifetime.md)\<`T`, `TCopy`, `Owner`\> + +this + +##### Inherited from + +[`quickjs-emscripten.Lifetime.tap`](Lifetime.md#tap) + +##### Source + +[packages/quickjs-emscripten-core/src/lifetime.ts:164](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L164) + +#### tap(fn) + +> **tap**(`fn`): [`QuickJSHandle`](../exports.md#quickjshandle) + +##### Parameters + +• **fn**: (`lifetime`) => `void` + +##### Returns + +[`QuickJSHandle`](../exports.md#quickjshandle) + +##### Inherited from + +[`quickjs-emscripten.Lifetime.tap`](Lifetime.md#tap) + +##### Source + +[packages/quickjs-emscripten-core/src/lifetime.ts:165](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L165) + +*** + Generated using [typedoc-plugin-markdown](https://www.npmjs.com/package/typedoc-plugin-markdown) and [TypeDoc](https://typedoc.org/) diff --git a/doc/quickjs-emscripten/exports.md b/doc/quickjs-emscripten/exports.md index 88fbae13..fc574efb 100644 --- a/doc/quickjs-emscripten/exports.md +++ b/doc/quickjs-emscripten/exports.md @@ -193,7 +193,7 @@ An `Array` that also implements [Disposable](interfaces/Disposable.md): #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:329](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L329) +[packages/quickjs-emscripten-core/src/lifetime.ts:354](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L354) *** @@ -209,7 +209,7 @@ An `Array` that also implements [Disposable](interfaces/Disposable.md): #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:453](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L453) +[packages/quickjs-emscripten-core/src/lifetime.ts:478](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L478) *** @@ -251,7 +251,7 @@ by the runtime. ### InterruptHandler -> **InterruptHandler**: (`runtime`) => `boolean` \| `undefined` +> **InterruptHandler**: (`runtime`) => `boolean` \| `undefined` \| `void` Callback called regularly while the VM executes code. Determines if a VM's execution should be interrupted. @@ -262,7 +262,7 @@ Determines if a VM's execution should be interrupted. #### Returns -`boolean` \| `undefined` +`boolean` \| `undefined` \| `void` `true` to interrupt JS execution inside the VM. @@ -965,7 +965,7 @@ The default [Intrinsics](exports.md#intrinsics) language features enabled in a Q #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:453](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L453) +[packages/quickjs-emscripten-core/src/lifetime.ts:478](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L478) *** @@ -1304,7 +1304,7 @@ Create an array that also implements [Disposable](interfaces/Disposable.md). #### Source -[packages/quickjs-emscripten-core/src/lifetime.ts:334](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L334) +[packages/quickjs-emscripten-core/src/lifetime.ts:359](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/lifetime.ts#L359) *** diff --git a/doc/quickjs-emscripten/namespaces/errors/classes/QuickJSAsyncifyError.md b/doc/quickjs-emscripten/namespaces/errors/classes/QuickJSAsyncifyError.md index 16145711..7645b7f0 100644 --- a/doc/quickjs-emscripten/namespaces/errors/classes/QuickJSAsyncifyError.md +++ b/doc/quickjs-emscripten/namespaces/errors/classes/QuickJSAsyncifyError.md @@ -52,7 +52,7 @@ node\_modules/typescript/lib/lib.es5.d.ts:1081 #### Source -[packages/quickjs-emscripten-core/src/errors.ts:29](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L29) +[packages/quickjs-emscripten-core/src/errors.ts:33](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L33) *** diff --git a/doc/quickjs-emscripten/namespaces/errors/classes/QuickJSAsyncifySuspended.md b/doc/quickjs-emscripten/namespaces/errors/classes/QuickJSAsyncifySuspended.md index fb19558d..1eb66f9a 100644 --- a/doc/quickjs-emscripten/namespaces/errors/classes/QuickJSAsyncifySuspended.md +++ b/doc/quickjs-emscripten/namespaces/errors/classes/QuickJSAsyncifySuspended.md @@ -52,7 +52,7 @@ node\_modules/typescript/lib/lib.es5.d.ts:1081 #### Source -[packages/quickjs-emscripten-core/src/errors.ts:33](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L33) +[packages/quickjs-emscripten-core/src/errors.ts:37](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L37) *** diff --git a/doc/quickjs-emscripten/namespaces/errors/classes/QuickJSEmptyGetOwnPropertyNames.md b/doc/quickjs-emscripten/namespaces/errors/classes/QuickJSEmptyGetOwnPropertyNames.md index a1d39aba..1f7a442c 100644 --- a/doc/quickjs-emscripten/namespaces/errors/classes/QuickJSEmptyGetOwnPropertyNames.md +++ b/doc/quickjs-emscripten/namespaces/errors/classes/QuickJSEmptyGetOwnPropertyNames.md @@ -52,7 +52,7 @@ node\_modules/typescript/lib/lib.es5.d.ts:1081 #### Source -[packages/quickjs-emscripten-core/src/errors.ts:53](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L53) +[packages/quickjs-emscripten-core/src/errors.ts:57](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L57) *** diff --git a/doc/quickjs-emscripten/namespaces/errors/classes/QuickJSEmscriptenModuleError.md b/doc/quickjs-emscripten/namespaces/errors/classes/QuickJSEmscriptenModuleError.md index 4b72410f..92f4ea54 100644 --- a/doc/quickjs-emscripten/namespaces/errors/classes/QuickJSEmscriptenModuleError.md +++ b/doc/quickjs-emscripten/namespaces/errors/classes/QuickJSEmscriptenModuleError.md @@ -52,7 +52,7 @@ node\_modules/typescript/lib/lib.es5.d.ts:1081 #### Source -[packages/quickjs-emscripten-core/src/errors.ts:41](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L41) +[packages/quickjs-emscripten-core/src/errors.ts:45](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L45) *** diff --git a/doc/quickjs-emscripten/namespaces/errors/classes/QuickJSMemoryLeakDetected.md b/doc/quickjs-emscripten/namespaces/errors/classes/QuickJSMemoryLeakDetected.md index 37f52310..631e1e49 100644 --- a/doc/quickjs-emscripten/namespaces/errors/classes/QuickJSMemoryLeakDetected.md +++ b/doc/quickjs-emscripten/namespaces/errors/classes/QuickJSMemoryLeakDetected.md @@ -52,7 +52,7 @@ node\_modules/typescript/lib/lib.es5.d.ts:1081 #### Source -[packages/quickjs-emscripten-core/src/errors.ts:37](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L37) +[packages/quickjs-emscripten-core/src/errors.ts:41](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L41) *** diff --git a/doc/quickjs-emscripten/namespaces/errors/classes/QuickJSNotImplemented.md b/doc/quickjs-emscripten/namespaces/errors/classes/QuickJSNotImplemented.md index 6e079b5c..f450c81b 100644 --- a/doc/quickjs-emscripten/namespaces/errors/classes/QuickJSNotImplemented.md +++ b/doc/quickjs-emscripten/namespaces/errors/classes/QuickJSNotImplemented.md @@ -52,7 +52,7 @@ node\_modules/typescript/lib/lib.es5.d.ts:1081 #### Source -[packages/quickjs-emscripten-core/src/errors.ts:25](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L25) +[packages/quickjs-emscripten-core/src/errors.ts:29](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L29) *** diff --git a/doc/quickjs-emscripten/namespaces/errors/classes/QuickJSPromisePending.md b/doc/quickjs-emscripten/namespaces/errors/classes/QuickJSPromisePending.md index dac6d304..b23993ed 100644 --- a/doc/quickjs-emscripten/namespaces/errors/classes/QuickJSPromisePending.md +++ b/doc/quickjs-emscripten/namespaces/errors/classes/QuickJSPromisePending.md @@ -52,7 +52,7 @@ node\_modules/typescript/lib/lib.es5.d.ts:1081 #### Source -[packages/quickjs-emscripten-core/src/errors.ts:49](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L49) +[packages/quickjs-emscripten-core/src/errors.ts:53](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L53) *** diff --git a/doc/quickjs-emscripten/namespaces/errors/classes/QuickJSUnknownIntrinsic.md b/doc/quickjs-emscripten/namespaces/errors/classes/QuickJSUnknownIntrinsic.md index d1f7d950..42959ad2 100644 --- a/doc/quickjs-emscripten/namespaces/errors/classes/QuickJSUnknownIntrinsic.md +++ b/doc/quickjs-emscripten/namespaces/errors/classes/QuickJSUnknownIntrinsic.md @@ -73,7 +73,7 @@ node\_modules/typescript/lib/lib.es5.d.ts:1081 #### Source -[packages/quickjs-emscripten-core/src/errors.ts:45](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L45) +[packages/quickjs-emscripten-core/src/errors.ts:49](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L49) *** diff --git a/doc/quickjs-emscripten/namespaces/errors/classes/QuickJSUseAfterFree.md b/doc/quickjs-emscripten/namespaces/errors/classes/QuickJSUseAfterFree.md index e896dbc1..cf73087c 100644 --- a/doc/quickjs-emscripten/namespaces/errors/classes/QuickJSUseAfterFree.md +++ b/doc/quickjs-emscripten/namespaces/errors/classes/QuickJSUseAfterFree.md @@ -52,7 +52,7 @@ node\_modules/typescript/lib/lib.es5.d.ts:1081 #### Source -[packages/quickjs-emscripten-core/src/errors.ts:21](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L21) +[packages/quickjs-emscripten-core/src/errors.ts:25](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L25) *** diff --git a/doc/quickjs-emscripten/namespaces/errors/classes/QuickJSWrongOwner.md b/doc/quickjs-emscripten/namespaces/errors/classes/QuickJSWrongOwner.md index 6e35723f..acc3b09e 100644 --- a/doc/quickjs-emscripten/namespaces/errors/classes/QuickJSWrongOwner.md +++ b/doc/quickjs-emscripten/namespaces/errors/classes/QuickJSWrongOwner.md @@ -52,7 +52,7 @@ node\_modules/typescript/lib/lib.es5.d.ts:1081 #### Source -[packages/quickjs-emscripten-core/src/errors.ts:17](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L17) +[packages/quickjs-emscripten-core/src/errors.ts:21](https://github.com/justjake/quickjs-emscripten/blob/main/packages/quickjs-emscripten-core/src/errors.ts#L21) *** diff --git a/examples/bun-typescript/.gitignore b/examples/bun-typescript/.gitignore new file mode 100644 index 00000000..6736aa1e --- /dev/null +++ b/examples/bun-typescript/.gitignore @@ -0,0 +1,2 @@ +node_modules +index.js diff --git a/examples/bun-typescript/.npmrc b/examples/bun-typescript/.npmrc new file mode 100644 index 00000000..09b35cdd --- /dev/null +++ b/examples/bun-typescript/.npmrc @@ -0,0 +1,2 @@ +audit=false +fund=false diff --git a/examples/bun-typescript/bun.lockb b/examples/bun-typescript/bun.lockb new file mode 100755 index 00000000..2c03ba51 Binary files /dev/null and b/examples/bun-typescript/bun.lockb differ diff --git a/examples/bun-typescript/index.ts b/examples/bun-typescript/index.ts new file mode 100644 index 00000000..3105895c --- /dev/null +++ b/examples/bun-typescript/index.ts @@ -0,0 +1,10 @@ +import { getQuickJS } from "quickjs-emscripten" +async function main() { + const QuickJS = await getQuickJS() + console.log(QuickJS.evalCode('"QuickJS.evalCode successful"')) + + const vm = QuickJS.newContext() + const memoryUsage = vm.runtime.dumpMemoryUsage() + console.log("Empty VM memory usage:", memoryUsage) +} +main() diff --git a/examples/bun-typescript/package-lock.json b/examples/bun-typescript/package-lock.json new file mode 100644 index 00000000..f32ea7e2 --- /dev/null +++ b/examples/bun-typescript/package-lock.json @@ -0,0 +1,96 @@ +{ + "name": "quickjs-emscripten-smoketest", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "quickjs-emscripten-smoketest", + "version": "1.0.0", + "license": "MIT", + "dependencies": { + "@jitl/quickjs-ffi-types": "file:../../build/tar/@jitl-quickjs-ffi-types.tgz", + "@jitl/quickjs-wasmfile-debug-asyncify": "file:../../build/tar/@jitl-quickjs-wasmfile-debug-asyncify.tgz", + "@jitl/quickjs-wasmfile-debug-sync": "file:../../build/tar/@jitl-quickjs-wasmfile-debug-sync.tgz", + "@jitl/quickjs-wasmfile-release-asyncify": "file:../../build/tar/@jitl-quickjs-wasmfile-release-asyncify.tgz", + "@jitl/quickjs-wasmfile-release-sync": "file:../../build/tar/@jitl-quickjs-wasmfile-release-sync.tgz", + "quickjs-emscripten": "file:../../build/tar/quickjs-emscripten.tgz", + "quickjs-emscripten-core": "file:../../build/tar/quickjs-emscripten-core.tgz", + "typescript": "5" + } + }, + "node_modules/@jitl/quickjs-ffi-types": { + "version": "0.26.0", + "resolved": "file:../../build/tar/@jitl-quickjs-ffi-types.tgz", + "integrity": "sha512-49pRXLrdnhglSm5tzBcoa8Q0H5Gscm9IgzQKLeBWYJnDzLoWw4SLZspRTxfxB168uUmwszWy0uBCG6QZYvDTxw==" + }, + "node_modules/@jitl/quickjs-wasmfile-debug-asyncify": { + "version": "0.26.0", + "resolved": "file:../../build/tar/@jitl-quickjs-wasmfile-debug-asyncify.tgz", + "integrity": "sha512-uApydMFA2re/zR2ITUjpua7AD9wJgoPayyldxAh7c0Y0eh+Q1ttJL54HzfEU6Jh4kEver28YpqaEcj9/4d96bw==", + "dependencies": { + "@jitl/quickjs-ffi-types": "0.26.0" + } + }, + "node_modules/@jitl/quickjs-wasmfile-debug-sync": { + "version": "0.26.0", + "resolved": "file:../../build/tar/@jitl-quickjs-wasmfile-debug-sync.tgz", + "integrity": "sha512-M5BeymxjnFunAWHwfgj3uEv0LvWdzjHugOuieygVMoi+fQ020o4rlCcjbttqZZiFgII8HWV4jbBm4vwsbgbCaw==", + "dependencies": { + "@jitl/quickjs-ffi-types": "0.26.0" + } + }, + "node_modules/@jitl/quickjs-wasmfile-release-asyncify": { + "version": "0.26.0", + "resolved": "file:../../build/tar/@jitl-quickjs-wasmfile-release-asyncify.tgz", + "integrity": "sha512-TLgIZAv292dW2I6PoM2yKPR5t+XqKDZS/Sezy8pi8rsZamDscjt9AM8f2QA+YNpyUPU4zTcaUX3Ccp5bj8d20w==", + "dependencies": { + "@jitl/quickjs-ffi-types": "0.26.0" + } + }, + "node_modules/@jitl/quickjs-wasmfile-release-sync": { + "version": "0.26.0", + "resolved": "file:../../build/tar/@jitl-quickjs-wasmfile-release-sync.tgz", + "integrity": "sha512-6VLyG89jAcIv/Y868yVaZD1K/uqguH2eHHL5DCXiYHSR6Q614LeRRtAVXygRu8MtOWKZ0O6Uong/KzJ+1hLEHg==", + "dependencies": { + "@jitl/quickjs-ffi-types": "0.26.0" + } + }, + "node_modules/quickjs-emscripten": { + "version": "0.26.0", + "resolved": "file:../../build/tar/quickjs-emscripten.tgz", + "integrity": "sha512-0xv4U8lyWDzXbXZUxoNIGATlI7+j57LmeYZRsQDym3yLDJDnG3o9AVNorQniGRw+CmeuMSufNLtfwPw9U/r3QA==", + "license": "MIT", + "dependencies": { + "@jitl/quickjs-wasmfile-debug-asyncify": "0.26.0", + "@jitl/quickjs-wasmfile-debug-sync": "0.26.0", + "@jitl/quickjs-wasmfile-release-asyncify": "0.26.0", + "@jitl/quickjs-wasmfile-release-sync": "0.26.0", + "quickjs-emscripten-core": "0.26.0" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/quickjs-emscripten-core": { + "version": "0.26.0", + "resolved": "file:../../build/tar/quickjs-emscripten-core.tgz", + "integrity": "sha512-RFglP182/9sTYirChNUsQOIbH70goOMe4rVr0G4aJykIk0m9ogglUvhXP7iANOeA9CFCKB93ORp6DJ5KJctbKg==", + "license": "MIT", + "dependencies": { + "@jitl/quickjs-ffi-types": "0.26.0" + } + }, + "node_modules/typescript": { + "version": "5.3.3", + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + } + } +} diff --git a/examples/bun-typescript/package.json b/examples/bun-typescript/package.json new file mode 100644 index 00000000..80f0be6a --- /dev/null +++ b/examples/bun-typescript/package.json @@ -0,0 +1,18 @@ +{ + "name": "quickjs-emscripten-smoketest", + "version": "1.0.0", + "type": "commonjs", + "main": "index.js", + "license": "MIT", + "dependencies": { + "@jitl/quickjs-ffi-types": "file:../../build/tar/@jitl-quickjs-ffi-types.tgz", + "@jitl/quickjs-wasmfile-debug-asyncify": "file:../../build/tar/@jitl-quickjs-wasmfile-debug-asyncify.tgz", + "@jitl/quickjs-wasmfile-debug-sync": "file:../../build/tar/@jitl-quickjs-wasmfile-debug-sync.tgz", + "@jitl/quickjs-wasmfile-release-asyncify": "file:../../build/tar/@jitl-quickjs-wasmfile-release-asyncify.tgz", + "@jitl/quickjs-wasmfile-release-sync": "file:../../build/tar/@jitl-quickjs-wasmfile-release-sync.tgz", + "quickjs-emscripten": "file:../../build/tar/quickjs-emscripten.tgz", + "quickjs-emscripten-core": "file:../../build/tar/quickjs-emscripten-core.tgz", + "typescript": "5" + }, + "workspaces": [] +} diff --git a/examples/bun-typescript/tsconfig.json b/examples/bun-typescript/tsconfig.json new file mode 100644 index 00000000..8b4876fc --- /dev/null +++ b/examples/bun-typescript/tsconfig.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "target": "ES6", + "lib": ["ES2015", "DOM"], + "module": "Node16", + "strict": true + }, + "include": ["*.ts"], + "exclude": ["../../node_modules/**/*"] +} diff --git a/package.json b/package.json index 12398479..c19bb460 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "quickjs-emscripten-repo", "private": true, - "version": "0.30.0", + "version": "0.31.0", "sideEffects": false, "license": "MIT", "type": "commonjs", @@ -44,7 +44,7 @@ "all:publish:stable": "yarn run check:packages && yarn for-each-publishable-package npm publish --access public", "all:publish:next": "yarn run check:packages && yarn for-each-publishable-package npm publish --access public --tag next", "all:version": "./scripts/set-version.ts", - "for-each-package-cmd": "yarn workspaces foreach --from 'packages/*' -Rpti", + "for-each-package-cmd": "yarn workspaces foreach --from 'packages/*' --topological-dev -Rpti", "for-each-publishable-package": "yarn for-each-package-cmd --exclude 'packages/internal-*'", "for-each-package": "yarn for-each-package-cmd run" }, diff --git a/packages/internal-tsconfig/package.json b/packages/internal-tsconfig/package.json index 5cce5b26..7e3aede5 100644 --- a/packages/internal-tsconfig/package.json +++ b/packages/internal-tsconfig/package.json @@ -1,7 +1,7 @@ { "name": "@jitl/tsconfig", "private": true, - "version": "0.30.0", + "version": "0.31.0", "scripts": { "build": "yarn build:tsc && echo built $npm_package_json && ls -l", "build:tsc": "npx tsc --project tsconfig.tsup.json", diff --git a/packages/internal-tsconfig/tsconfig.json b/packages/internal-tsconfig/tsconfig.json index 6bc2677d..6b65072f 100644 --- a/packages/internal-tsconfig/tsconfig.json +++ b/packages/internal-tsconfig/tsconfig.json @@ -35,7 +35,7 @@ "noEmitOnError": true, // "importHelpers": true, /* Import emit helpers from 'tslib'. */ // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ - // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ + "isolatedModules": true /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */, // "emitDeclarationOnly": true, /* Strict Type-Checking Options */ diff --git a/packages/internal-tsconfig/tsup.base.config.ts b/packages/internal-tsconfig/tsup.base.config.ts index ea915700..7ded78f6 100644 --- a/packages/internal-tsconfig/tsup.base.config.ts +++ b/packages/internal-tsconfig/tsup.base.config.ts @@ -1,13 +1,14 @@ import type { Options } from "tsup" import { defineConfig } from "tsup" -const baseConfig = defineConfig((options) => ({ +const baseConfig = defineConfig((_options) => ({ entry: ["src/index.ts"], - minify: !options.watch, sourcemap: true, dts: true, clean: true, format: ["cjs", "esm"], + minifySyntax: true, + minifyWhitespace: true, })) as (options: Options) => Options export function extendConfig(options: Options = {}) { diff --git a/packages/quickjs-emscripten-core/README.md b/packages/quickjs-emscripten-core/README.md index 2c99c9b9..8bd5dd5c 100644 --- a/packages/quickjs-emscripten-core/README.md +++ b/packages/quickjs-emscripten-core/README.md @@ -326,3 +326,16 @@ Variant with the WASM data embedded into a browser ESModule. | syncMode | asyncify | Build run through the ASYNCIFY WebAssembly transform. This imposes substantial size (2x the size of sync) and speed penalties (40% the speed of sync). In return, allows synchronous calls from the QuickJS WASM runtime to async functions on the host. The extra magic makes this variant slower than sync variants. Note that both variants support regular async functions. Only adopt ASYNCIFY if you need to! The [QuickJSAsyncRuntime](https://github.com/justjake/quickjs-emscripten/blob/main/doc/quickjs-emscripten/classes/QuickJSAsyncRuntime.md) and [QuickJSAsyncContext](https://github.com/justjake/quickjs-emscripten/blob/main/doc/quickjs-emscripten/classes/QuickJSAsyncContext.md) classes expose the ASYNCIFY-specific APIs. | | 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. | | exports | browser | Has these package.json export conditions | + +### @jitl/quickjs-asmjs-mjs-release-sync + +[Docs](https://github.com/justjake/quickjs-emscripten/blob/main/doc/@jitl/quickjs-asmjs-mjs-release-sync/README.md) | +Compiled to pure Javascript, no WebAssembly required. + +| Variable | Setting | Description | +| ------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| 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. | +| releaseMode | release | Optimized for performance; use when building/deploying your application. | +| syncMode | sync | The default, normal build. Note that both variants support regular async functions. | +| 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. | +| exports | import | Has these package.json export conditions | diff --git a/packages/quickjs-emscripten-core/package.json b/packages/quickjs-emscripten-core/package.json index 88a5539a..71989561 100644 --- a/packages/quickjs-emscripten-core/package.json +++ b/packages/quickjs-emscripten-core/package.json @@ -1,6 +1,6 @@ { "name": "quickjs-emscripten-core", - "version": "0.30.0", + "version": "0.31.0", "sideEffects": false, "license": "MIT", "type": "commonjs", diff --git a/packages/quickjs-emscripten-core/src/context.ts b/packages/quickjs-emscripten-core/src/context.ts index da43fbbd..d2a19bdb 100644 --- a/packages/quickjs-emscripten-core/src/context.ts +++ b/packages/quickjs-emscripten-core/src/context.ts @@ -1281,28 +1281,37 @@ export class QuickJSContext const cause = result.error.consume((error) => this.dump(error)) if (cause && typeof cause === "object" && typeof cause.message === "string") { - const { message, name, stack } = cause - const exception = new QuickJSUnwrapError("") - const hostStack = exception.stack + const { message, name, stack, ...rest } = cause + const exception = new QuickJSUnwrapError(cause, context) if (typeof name === "string") { exception.name = cause.name } + exception.message = message + const hostStack = exception.stack if (typeof stack === "string") { exception.stack = `${name}: ${message}\n${cause.stack}Host: ${hostStack}` } - Object.assign(exception, { cause, context, message }) + Object.assign(exception, rest) throw exception } - throw new QuickJSUnwrapError(cause, context) + throw new QuickJSUnwrapError(cause) } return result.value } + /** @private */ + [Symbol.for("nodejs.util.inspect.custom")]() { + if (!this.alive) { + return `${this.constructor.name} { disposed }` + } + return `${this.constructor.name} { ctx: ${this.ctx.value} rt: ${this.rt.value} }` + } + /** @private */ protected fnNextId = -32768 // min value of signed 16bit int used by Quickjs /** @private */ diff --git a/packages/quickjs-emscripten-core/src/errors.ts b/packages/quickjs-emscripten-core/src/errors.ts index a2711f6f..af491e54 100644 --- a/packages/quickjs-emscripten-core/src/errors.ts +++ b/packages/quickjs-emscripten-core/src/errors.ts @@ -9,7 +9,11 @@ export class QuickJSUnwrapError extends Error { public cause: unknown, public context?: QuickJSContext, ) { - super(String(cause)) + const message = + typeof cause === "object" && cause && "message" in cause + ? String(cause.message) + : String(cause) + super(message) } } diff --git a/packages/quickjs-emscripten-core/src/index.ts b/packages/quickjs-emscripten-core/src/index.ts index 8583c07a..4f62a7b7 100644 --- a/packages/quickjs-emscripten-core/src/index.ts +++ b/packages/quickjs-emscripten-core/src/index.ts @@ -3,12 +3,14 @@ export * from "@jitl/quickjs-ffi-types" // Sync classes export { QuickJSWASMModule } from "./module" export { QuickJSContext } from "./context" -export { QuickJSRuntime, InterruptHandler, ExecutePendingJobsResult } from "./runtime" +export { QuickJSRuntime } from "./runtime" +export type { InterruptHandler, ExecutePendingJobsResult } from "./runtime" // Async classes export { QuickJSAsyncWASMModule } from "./module-asyncify" export { QuickJSAsyncRuntime } from "./runtime-asyncify" -export { QuickJSAsyncContext, AsyncFunctionImplementation } from "./context-asyncify" +export { QuickJSAsyncContext } from "./context-asyncify" +export type { AsyncFunctionImplementation } from "./context-asyncify" // Build variants export * from "./from-variant" @@ -45,5 +47,5 @@ export type { } from "./types" export { DefaultIntrinsics } from "./types" export type { ModuleEvalOptions } from "./module" -export { QuickJSPropertyKey } from "./context" +export type { QuickJSPropertyKey } from "./context" export { debugLog, setDebugMode } from "./debug" diff --git a/packages/quickjs-emscripten-core/src/lifetime.ts b/packages/quickjs-emscripten-core/src/lifetime.ts index 1442e2af..5b97e43b 100644 --- a/packages/quickjs-emscripten-core/src/lifetime.ts +++ b/packages/quickjs-emscripten-core/src/lifetime.ts @@ -143,6 +143,31 @@ export class Lifetime return result } + /** + * Call `map` with this lifetime, returning the result. + * Does not dispose the lifetime. + * @return the result of `map(this)`. + */ + map(map: (lifetime: this) => O): O + map(map: (lifetime: QuickJSHandle) => O): O + map(map: (lifetime: any) => O): O { + this.assertAlive() + return map(this) + } + + /** + * Call `fn` with this lifetime, then return `this`. Does not dispose the + * lifetime. Useful for imperative operations within an expression, like when + * you're building up objects, or to add logging in the middle of a call chain. + * @returns this + */ + tap(fn: (lifetime: this) => void): this + tap(fn: (lifetime: QuickJSHandle) => void): QuickJSHandle + tap(fn: (lifetime: any) => void): any { + fn(this) + return this + } + /** * Dispose of {@link value} and perform cleanup. */ diff --git a/packages/quickjs-emscripten-core/src/runtime.ts b/packages/quickjs-emscripten-core/src/runtime.ts index adf77513..fd98b406 100644 --- a/packages/quickjs-emscripten-core/src/runtime.ts +++ b/packages/quickjs-emscripten-core/src/runtime.ts @@ -24,7 +24,7 @@ import { intrinsicsToFlags } from "./types" * @returns `true` to interrupt JS execution inside the VM. * @returns `false` or `undefined` to continue JS execution inside the VM. */ -export type InterruptHandler = (runtime: QuickJSRuntime) => boolean | undefined +export type InterruptHandler = (runtime: QuickJSRuntime) => boolean | undefined | void /** * Used as an optional for the results of executing pendingJobs. @@ -366,6 +366,14 @@ export class QuickJSRuntime extends UsingDisposable implements Disposable { } } + /** @private */ + [Symbol.for("nodejs.util.inspect.custom")]() { + if (!this.alive) { + return `${this.constructor.name} { disposed }` + } + return `${this.constructor.name} { rt: ${this.rt.value} }` + } + private getSystemContext() { if (!this.context) { // We own this context and should dispose of it. diff --git a/packages/quickjs-emscripten/package.json b/packages/quickjs-emscripten/package.json index 70b84bdf..e0c73676 100644 --- a/packages/quickjs-emscripten/package.json +++ b/packages/quickjs-emscripten/package.json @@ -1,6 +1,6 @@ { "name": "quickjs-emscripten", - "version": "0.30.0", + "version": "0.31.0", "sideEffects": false, "license": "MIT", "type": "commonjs", @@ -33,7 +33,7 @@ "clean": "git clean -fx dist .output", "tsc": "npx tsc -p . --noEmit", "test:vi": "VITEST=1 npx vitest run", - "test:node": "npx tsc -p tsconfig.build.json && ./makeTestPackageJson.ts && node -r source-map-support/register --test ./.output/*node-test*.*js", + "test:node": "npx tsc -p tsconfig.build.json && ./makeTestPackageJson.ts && node --experimental-import-meta-resolve -r source-map-support/register --test ./.output/*node-test*.*js", "test": "npm run test:vi && npm run test:node" }, "types": "./dist/index.d.ts", diff --git a/packages/quickjs-emscripten/src/quickjs-in-quickjs-node-test.mts b/packages/quickjs-emscripten/src/quickjs-in-quickjs-node-test.mts new file mode 100644 index 00000000..022e781e --- /dev/null +++ b/packages/quickjs-emscripten/src/quickjs-in-quickjs-node-test.mts @@ -0,0 +1,162 @@ +import fs from "node:fs" +import util from "node:util" +import module from "node:module" +import { test } from "node:test" +import path from "node:path" +import assert from "node:assert" +import { getQuickJS } from "./index.js" +import type { JSModuleLoader, JSModuleNormalizer, QuickJSHandle, QuickJSContext } from "./index.js" + +const DEBUG = false + +const ttyLog = (...args: unknown[]) => { + if (DEBUG) { + const fd = fs.openSync("/dev/tty", "w") + fs.writeSync(fd, util.format(...args) + "\n") + fs.closeSync(fd) + } +} + +const QuickJS = await getQuickJS() + +function addConsoleGlobal(context: QuickJSContext, logOfLogs: any[]) { + const consoleHandle = context.newObject() + const log = context.newFunction("log", (...args: QuickJSHandle[]) => { + const logged = args.map((arg) => context.dump(arg)) + logOfLogs.push(logged) + ttyLog(...logged) + }) + context.setProp(consoleHandle, "log", log) + context.setProp(consoleHandle, "error", log) + context.setProp(context.global, "console", consoleHandle) + log.dispose() + consoleHandle.dispose() +} + +function* pathAncestors(filepath: string) { + yield filepath + while (filepath !== "/") { + filepath = path.dirname(filepath) + yield filepath + } +} + +class QuickJSNodeModuleLoader { + static convertPath(filepath: string, mountPoints: Map) { + filepath = path.normalize(filepath) + for (const dirname of pathAncestors(filepath)) { + const mappedDirname = mountPoints.get(dirname) + if (!mappedDirname) { + continue + } + return mappedDirname + filepath.slice(dirname.length) + } + return undefined + } + + require = module.createRequire(import.meta.url) + hostToGuest = new Map() + guestToHost = new Map() + + mount(args: { hostPath: string; guestPath: string }) { + const guestPath = path.normalize(args.guestPath) + if (!path.isAbsolute(guestPath)) { + throw new Error("guestPath must be absolute") + } + + const hostPath = fs.realpathSync(args.hostPath) + this.hostToGuest.set(hostPath, guestPath) + this.guestToHost.set(guestPath, hostPath) + + ttyLog("mount", { hostPath, guestPath }) + } + + mountImport(args: { hostImport: string; guestImport: string; direct?: true }) { + const hostFile = this.require.resolve(args.hostImport).replace(".js", ".mjs") + this.mount({ + hostPath: args.direct ? hostFile : path.dirname(hostFile), + guestPath: "/node_modules/" + args.guestImport, + }) + } + + toGuestPath(hostPath: string) { + return QuickJSNodeModuleLoader.convertPath(hostPath, this.hostToGuest) + } + + toHostPath(guestPath: string) { + return QuickJSNodeModuleLoader.convertPath(guestPath, this.guestToHost) + } + + jsModuleNormalizer: JSModuleNormalizer = (baseModuleName, requestedName, _context) => { + if (path.isAbsolute(requestedName)) { + ttyLog("absolute", requestedName) + return path.normalize(requestedName) + } + + if (requestedName.startsWith(".")) { + const resolved = path.resolve(path.dirname(baseModuleName), requestedName) + ttyLog("relative", { resolved, baseModuleName, requestedName }) + return path.normalize(resolved) + } + + const resolved = path.resolve("/node_modules/", requestedName) + ttyLog("node_modules", { resolved, baseModuleName, requestedName }) + return path.normalize(resolved) + } + + jsModuleLoader: JSModuleLoader = (moduleName, _context) => { + try { + const hostPath = this.toHostPath(moduleName) + if (hostPath) { + return fs.readFileSync(hostPath, "utf8") + } + throw new Error("Not found") + } catch (error) { + ttyLog("QuickJSNodeModuleLoader.loader error:", { moduleName, error }) + return { + error: Error(`Not found: ${moduleName}`), + } + } + } +} + +test("quickjs-for-quickjs", () => { + const moduleLoader = new QuickJSNodeModuleLoader() + moduleLoader.mountImport({ + hostImport: "quickjs-emscripten-core", + guestImport: "quickjs-emscripten-core", + }) + moduleLoader.mountImport({ + hostImport: "@jitl/quickjs-asmjs-mjs-release-sync", + guestImport: "@jitl/quickjs-asmjs-mjs-release-sync", + }) + moduleLoader.mountImport({ + hostImport: "@jitl/quickjs-ffi-types", + guestImport: "@jitl/quickjs-ffi-types", + direct: true, + }) + + const runtime = QuickJS.newRuntime() + runtime.setModuleLoader(moduleLoader.jsModuleLoader, moduleLoader.jsModuleNormalizer) + + const context = runtime.newContext() + const logs: any[] = [] + addConsoleGlobal(context, logs) + + ttyLog("hi") + + const result = context.evalCode( + ` +import { newQuickJSWASMModuleFromVariant } from 'quickjs-emscripten-core/index.mjs' +import variant from '@jitl/quickjs-asmjs-mjs-release-sync/index.mjs' +globalThis.done = newQuickJSWASMModuleFromVariant(variant).then(QuickJS => { + const result = QuickJS.evalCode('1+2') + console.log('inner result', result) +}) +`, + "/script.mjs", + ) + context.unwrapResult(result).dispose() + runtime.executePendingJobs() + assert.deepEqual(logs, [["inner result", 3]]) +}) diff --git a/packages/quickjs-ffi-types/package.json b/packages/quickjs-ffi-types/package.json index 3cb5804c..760fb441 100644 --- a/packages/quickjs-ffi-types/package.json +++ b/packages/quickjs-ffi-types/package.json @@ -1,6 +1,6 @@ { "name": "@jitl/quickjs-ffi-types", - "version": "0.30.0", + "version": "0.31.0", "license": "MIT", "repository": { "type": "git", diff --git a/packages/quickjs-for-quickjs/LICENSE b/packages/quickjs-for-quickjs/LICENSE new file mode 100644 index 00000000..22f51c71 --- /dev/null +++ b/packages/quickjs-for-quickjs/LICENSE @@ -0,0 +1,21 @@ +The MIT License + +quickjs-emscripten copyright (c) 2019-2024 Jake Teton-Landis + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/quickjs-for-quickjs/README.md b/packages/quickjs-for-quickjs/README.md new file mode 100644 index 00000000..6e8cc1ea --- /dev/null +++ b/packages/quickjs-for-quickjs/README.md @@ -0,0 +1,70 @@ +# quickjs-for-quickjs + +![yo dawg i herd u like quickjs so i put quickjs in ur quickjs so u can eval while u eval](./yodawg.jpg) + +This package is a build of [quickjs-emscripten](https://github.com/justjake/quickjs-emscripten) that can run inside QuickJS or any other JavaScript runtime without WebAssembly support. The QuickJS C library is compiled to Asm.js, and then bundled together with the quickjs-emscripten JavaScript wrapper into a single standalone file with no external dependencies. + +`quickjs-for-quickjs` has been tested in the following configurations: + +- ✅ NodeJS -> quickjs-for-quickjs +- ✅ NodeJS -> quickjs-emscripten RELEASE_SYNC -> quickjs-for-quickjs +- ❌ NodeJS -> quickjs-emscripten RELEASE_SYNC -> quickjs-for-quickjs -> quickjs-for-quickjs (This hits stack overflow in QuickJS. It could work with a larger stack size for the outer QuickJS instance) + +## Why? + +For fun! + +This could have practical applications, like if you're a user writing a plugin for a 3rd-party system using quickjs-emscripten for scripting, and you as a plugin author also want your plugin to have its own plugin ecosystem. + +## Usage + +For a more detailed example, see [the "example" directory][example] in the repo. + +[example]: https://github.com/justjake/quickjs-emscripte/tree/main/packages/quickjs-for-quickjs/example + +```javascript +// nodejs-host.mjs +import fs from "node:fs/promises" +import module from "node:module" +import { getQuickJS, setUpContext } from "quickjs-for-quickjs" + +// get quickjs source code +const require = module.createRequire(import.meta.url) +const quickjsSource = await fs.readFile(require.resolve("quickjs-for-quickjs"), "utf8") + +// create the host QuickJS context +const QuickJS = await getQuickJS() +const context = QuickJS.createContext() + +// inject console.log, which is required for quickjs-for-quickjs to work +setUpContext(context) + +// allow the host QuickJS to import quickjs-for-quickjs module +context.runtime.setModuleLoader((name) => { + if (name === "quickjs-for-quickjs") { + return quickjsSource + } + throw new Error(`Module not found: ${name}`) +}) + +const quickjsHost = ` +// import and create inner QuickJS guest context +import { getQuickJS } from "quickjs-for-quickjs" +const context = await getQuickJS().then(mod => mod.createContext()) + +// eval some code in the inner context +const innerResult = context.evalCode('1 + 2', "quickjs-guest.mjs").unwrap() + +// export the result +export const result = innerResult.consume(context.dump) +` + +// eval the quickjs host +const handle = context.evalCode(quickjsHost, "quickjs-host.mjs").unwrap() + +// get the result +context.runtime.executePendingJob() +const result = context.unwrapResult(context.getPromiseState(handle)) + +console.log(result.consume(context.dump)) +``` diff --git a/packages/quickjs-for-quickjs/example/node-host.mjs b/packages/quickjs-for-quickjs/example/node-host.mjs new file mode 100644 index 00000000..5ea39a1f --- /dev/null +++ b/packages/quickjs-for-quickjs/example/node-host.mjs @@ -0,0 +1,51 @@ +import fs from "node:fs/promises" +import module from "node:module" +import { getQuickJS, setUpContext } from "quickjs-for-quickjs" +const require = module.createRequire(import.meta.url) + +console.log("hello") + +const quickjsSource = await fs.readFile(require.resolve("quickjs-for-quickjs"), "utf8") +const exportQuickjsSource = `export default ${JSON.stringify(quickjsSource)}` + +const exampleQuickjsHostSource = await fs.readFile(require.resolve("./quickjs-host.mjs"), "utf8") +const exportExampleQuickjsHostSource = `export default ${JSON.stringify(exampleQuickjsHostSource)}` + +const QuickJS = await getQuickJS() +const context = setUpContext(QuickJS.newContext()) +context.runtime.setModuleLoader((name) => { + console.log(`0: import ${name}`) + if (name === "quickjs-for-quickjs") { + return quickjsSource + } + if (name === "quickjs-for-quickjs-source") { + return exportQuickjsSource + } + if (name === "example-quickjs-host-source") { + return exportExampleQuickjsHostSource + } + return { error: new Error("not found") } +}) + +let nestingLimit = 2 +context.setProp( + context.global, + "done", + context.newFunction("done", () => context.newNumber(--nestingLimit <= 0 ? 1 : 0)), +) +const handle = context + .evalCode(exampleQuickjsHostSource, "quickjs-host.mjs", { + type: "module", + }) + .unwrap() + +const promise = context.resolvePromise(handle) +context.runtime.executePendingJobs() + +const result = (await promise).unwrap() + +console.log({ + result: context.dump(context.getProp(result, "result")), +}) + +console.log("result:", context.dump(context.getProp(await promise, "result"))) diff --git a/packages/quickjs-for-quickjs/example/quickjs-host.mjs b/packages/quickjs-for-quickjs/example/quickjs-host.mjs new file mode 100644 index 00000000..a82df11f --- /dev/null +++ b/packages/quickjs-for-quickjs/example/quickjs-host.mjs @@ -0,0 +1,49 @@ +import { getQuickJS, setUpContext } from "quickjs-for-quickjs" +import quickjsSource from "quickjs-for-quickjs-source" +import exampleQuickjsHostSource from "example-quickjs-host-source" + +console.log(`${console.depth}: started`) +const QuickJS = await getQuickJS() + +const exportQuickjsSource = `export default ${JSON.stringify(quickjsSource)}` +const exportExampleQuickjsHostSource = `export default ${JSON.stringify(exampleQuickjsHostSource)}` + +console.log(`${console.depth}: imported`) + +const context = setUpContext(QuickJS.newContext()) +context.runtime.setModuleLoader((name) => { + console.log(`${console.depth}: import ${name}`) + if (name === "quickjs-for-quickjs") { + return quickjsSource + } + if (name === "quickjs-for-quickjs-source") { + return exportQuickjsSource + } + if (name === "example-quickjs-host-source") { + return exportExampleQuickjsHostSource + } + return { error: new Error("not found") } +}) +context.setProp( + context.global, + "done", + context.newFunction("random", () => context.newNumber(done())), +) + +console.log(`${console.depth}: evaluating`) + +const codeToEval = done() + ? `export const result = ['hello', 'world', console.depth].join(' ')` + : exampleQuickjsHostSource +const promise = context.resolvePromise(context.evalCode(codeToEval).unwrap()) + +console.log(`${console.depth}: executing pending jobs`) +context.runtime.executePendingJobs() + +console.log("awaiting") +const promised = (await promise).unwrap() +console.log(`${console.depth}:`, { promised, type: context.typeof(promised) }) + +export const result = "hello " + context.dump(context.getProp(promised, "result")) + +console.log(`${console.depth}: done`) diff --git a/packages/quickjs-for-quickjs/package.json b/packages/quickjs-for-quickjs/package.json new file mode 100644 index 00000000..d86e032e --- /dev/null +++ b/packages/quickjs-for-quickjs/package.json @@ -0,0 +1,40 @@ +{ + "name": "quickjs-for-quickjs", + "version": "0.31.0", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/justjake/quickjs-emscripten" + }, + "author": { + "name": "Jake Teton-Landis", + "url": "https://jake.tl" + }, + "scripts": { + "check": "npx tsc --project . --noEmit", + "build": "npx tsup", + "clean": "git clean -fx dist" + }, + "files": [ + "LICENSE", + "yodawg.jpg", + "example/**/*", + "dist/**/*" + ], + "types": "dist/index.d.mts", + "main": "dist/index.mjs", + "module": "dist/index.mjs", + "exports": { + "./package.json": "./package.json", + ".": { + "types": "./dist/index.d.mts", + "import": "./dist/index.mjs", + "default": "./dist/index.mjs" + } + }, + "devDependencies": { + "@jitl/quickjs-asmjs-mjs-release-sync": "workspace:*", + "@jitl/tsconfig": "workspace:*", + "quickjs-emscripten-core": "workspace:*" + } +} diff --git a/packages/quickjs-for-quickjs/src/index.mts b/packages/quickjs-for-quickjs/src/index.mts new file mode 100644 index 00000000..6a7d3a09 --- /dev/null +++ b/packages/quickjs-for-quickjs/src/index.mts @@ -0,0 +1,52 @@ +import type { QuickJSWASMModule, QuickJSContext } from "quickjs-emscripten-core" +import { newQuickJSWASMModuleFromVariant } from "quickjs-emscripten-core" +import RELEASE_SYNC from "@jitl/quickjs-asmjs-mjs-release-sync" + +let promise: Promise | undefined + +export function getQuickJS(): Promise { + return (promise ??= newQuickJSWASMModule()) +} + +export function newQuickJSWASMModule(): Promise { + // TODO: why are the types mad? + return newQuickJSWASMModuleFromVariant(RELEASE_SYNC as any) +} + +export function setUpContext( + context: QuickJSContext, + options: { + log?: (...args: unknown[]) => void + } = {}, +) { + const { log } = options + const depth: number = (console as any)["depth"] ?? 0 + using consoleHandle = context.newObject() + using logHandle = context.newFunction("console.log", (...args) => { + const message = args.map(context.dump) + if (log) { + log(...message) + } else { + console.log(...message) + } + }) + using depthHandle = context.newNumber(1 + depth) + + context.setProp(consoleHandle, "log", logHandle) + context.setProp(consoleHandle, "error", logHandle) + context.setProp(consoleHandle, "depth", depthHandle) + + context.setProp(context.global, "console", consoleHandle) + + context.runtime.setMaxStackSize(0) + context.runtime.setMemoryLimit(0) + let interruptCount = 0 + context.runtime.setInterruptHandler(() => { + console.log(`${depth}: ...eval... (${++interruptCount})`) + return undefined + }) + + return context +} + +export { RELEASE_SYNC } diff --git a/packages/quickjs-for-quickjs/tsconfig.json b/packages/quickjs-for-quickjs/tsconfig.json new file mode 100644 index 00000000..3dd81964 --- /dev/null +++ b/packages/quickjs-for-quickjs/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "@jitl/tsconfig/tsconfig.json", + "include": ["src/**/*"], + "compilerOptions": { + "rootDir": "src" + } +} diff --git a/packages/quickjs-for-quickjs/tsup.config.ts b/packages/quickjs-for-quickjs/tsup.config.ts new file mode 100644 index 00000000..cf490f78 --- /dev/null +++ b/packages/quickjs-for-quickjs/tsup.config.ts @@ -0,0 +1,10 @@ +import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" + +export default extendConfig({ + entry: ["src/index.mts"], + format: ["esm"], + external: [], + clean: true, + splitting: false, + sourcemap: false, +}) diff --git a/packages/quickjs-for-quickjs/yodawg.jpg b/packages/quickjs-for-quickjs/yodawg.jpg new file mode 100644 index 00000000..81e68c25 Binary files /dev/null and b/packages/quickjs-for-quickjs/yodawg.jpg differ diff --git a/packages/variant-quickjs-asmjs-mjs-release-sync/LICENSE b/packages/variant-quickjs-asmjs-mjs-release-sync/LICENSE new file mode 100644 index 00000000..92facdd2 --- /dev/null +++ b/packages/variant-quickjs-asmjs-mjs-release-sync/LICENSE @@ -0,0 +1,47 @@ +quickjs-emscripten: +The MIT License + +quickjs-emscripten copyright (c) 2019-2024 Jake Teton-Landis + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + +quickjs: +QuickJS Javascript Engine + +Copyright (c) 2017-2021 Fabrice Bellard +Copyright (c) 2017-2021 Charlie Gordon + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/packages/variant-quickjs-asmjs-mjs-release-sync/Makefile b/packages/variant-quickjs-asmjs-mjs-release-sync/Makefile new file mode 100644 index 00000000..8b0076b0 --- /dev/null +++ b/packages/variant-quickjs-asmjs-mjs-release-sync/Makefile @@ -0,0 +1,172 @@ +# Tools +EMSDK_VERSION=3.1.65 +EMSDK_DOCKER_IMAGE=emscripten/emsdk:3.1.65 +EMCC_SRC=../../scripts/emcc.sh +EMCC=EMSDK_VERSION=$(EMSDK_VERSION) EMSDK_DOCKER_IMAGE=$(EMSDK_DOCKER_IMAGE) EMSDK_PROJECT_ROOT=$(REPO_ROOT) EMSDK_DOCKER_CACHE=$(REPO_ROOT)/emsdk-cache/$(EMSDK_VERSION) $(EMCC_SRC) +GENERATE_TS=$(GENERATE_TS_ENV) ../../scripts/generate.ts +THIS_DIR := $(dir $(abspath $(firstword $(MAKEFILE_LIST)))) +REPO_ROOT := $(abspath $(THIS_DIR)/../..) + +QUICKJS_LIB=quickjs + +# Paths +QUICKJS_ROOT=../../vendor/$(QUICKJS_LIB) +WRAPPER_ROOT=../../c +TEMPLATES=../../templates +# Intermediate build files +BUILD_ROOT=build +BUILD_WRAPPER=$(BUILD_ROOT)/wrapper +BUILD_QUICKJS=$(BUILD_ROOT)/quickjs +# Distributed to users +DIST=dist + +# QuickJS +QUICKJS_OBJS=quickjs.o libregexp.o libunicode.o cutils.o quickjs-libc.o libbf.o +ifeq ($(QUICKJS_LIB),quickjs-ng) + QUICKJS_DEFINES:=-D_GNU_SOURCE + CFLAGS_WASM+=-DQTS_USE_QUICKJS_NG +else + QUICKJS_CONFIG_VERSION=$(shell cat $(QUICKJS_ROOT)/VERSION) + QUICKJS_DEFINES:=-D_GNU_SOURCE -DCONFIG_VERSION=\"$(QUICKJS_CONFIG_VERSION)\" -DCONFIG_STACK_CHECK -DCONFIG_BIGNUM + CFLAGS_WASM+=-DCONFIG_BIGNUM +endif +VARIANT_QUICKJS_OBJS=$(patsubst %.o, $(BUILD_QUICKJS)/%.o, $(QUICKJS_OBJS)) + +# quickjs-emscripten +WRAPPER_DEFINES+=-Wcast-function-type # Likewise, warns about some quickjs casts we don't control. +EMCC_EXPORTED_FUNCS+=-s EXPORTED_FUNCTIONS=@$(BUILD_WRAPPER)/symbols.json +EMCC_EXPORTED_FUNCS_ASYNCIFY+=-s EXPORTED_FUNCTIONS=@$(BUILD_WRAPPER)/symbols.asyncify.json + +# Emscripten options +CFLAGS_WASM+=-s EXPORTED_RUNTIME_METHODS=@../../exportedRuntimeMethods.json +CFLAGS_WASM+=-s MODULARIZE=1 +CFLAGS_WASM+=-s IMPORTED_MEMORY=1 # Allow passing WASM memory to Emscripten +CFLAGS_WASM+=-s EXPORT_NAME=QuickJSRaw +CFLAGS_WASM+=-s INVOKE_RUN=0 +CFLAGS_WASM+=-s ALLOW_MEMORY_GROWTH=1 +CFLAGS_WASM+=-s ALLOW_TABLE_GROWTH=1 +CFLAGS_WASM+=-s STACK_SIZE=5MB +# CFLAGS_WASM+=-s MINIMAL_RUNTIME=1 # Appears to break MODULARIZE +CFLAGS_WASM+=-s SUPPORT_ERRNO=0 + +# Emscripten options - like STRICT +# https://github.com/emscripten-core/emscripten/blob/fa339b76424ca9fbe5cf15faea0295d2ac8d58cc/src/settings.js#L1095-L1109 +# CFLAGS_WASM+=-s STRICT_JS=1 # Doesn't work with MODULARIZE +CFLAGS_WASM+=-s IGNORE_MISSING_MAIN=0 --no-entry +CFLAGS_WASM+=-s AUTO_JS_LIBRARIES=0 +CFLAGS_WASM+=-s -lccall.js +CFLAGS_WASM+=-s AUTO_NATIVE_LIBRARIES=0 +CFLAGS_WASM+=-s AUTO_ARCHIVE_INDEXES=0 +CFLAGS_WASM+=-s DEFAULT_TO_CXX=0 +CFLAGS_WASM+=-s ALLOW_UNIMPLEMENTED_SYSCALLS=0 + +# Emscripten options - NodeJS +CFLAGS_WASM+=-s MIN_NODE_VERSION=160000 +CFLAGS_WASM+=-s NODEJS_CATCH_EXIT=0 + +CFLAGS_MJS+=-s EXPORT_ES6=1 +CFLAGS_BROWSER+=-s EXPORT_ES6=1 + +# VARIANT +SYNC=SYNC +CFLAGS_WASM_BROWSER=$(CFLAGS_WASM) + +# Emscripten options - variant & target specific +CFLAGS_WASM+=-Oz +CFLAGS_WASM+=-flto +CFLAGS_WASM+=--closure 1 +CFLAGS_WASM+=-s FILESYSTEM=0 +CFLAGS_WASM+=--pre-js $(TEMPLATES)/pre-extension.js +CFLAGS_WASM+=--pre-js $(TEMPLATES)/pre-wasmMemory.js +CFLAGS_WASM+=-s WASM=0 +CFLAGS_WASM+=-s SINGLE_FILE=1 + +CFLAGS_MJS+=-s ENVIRONMENT=web,worker,node + + + +# GENERATE_TS options - variant specific + + + +ifdef DEBUG_MAKE + MKDIRP=@echo "\n=====[["" target: $@, deps: $<, variant: $(VARIANT) ""]]=====" ; mkdir -p $(dir $@) +else + MKDIRP=@mkdir -p $(dir $@) + CFLAGS+=-Wunused-command-line-argument=0 +endif + +############################################################################### +# High-level +all: EXPORTS + +clean: + git clean -fx $(DIST) $(BUILD_ROOT) + +############################################################################### +# Emscripten output targets +EXPORTS: MJS +CJS: $(DIST)/emscripten-module.cjs $(DIST)/emscripten-module.d.ts +MJS: $(DIST)/emscripten-module.mjs $(DIST)/emscripten-module.d.ts +BROWSER: $(DIST)/emscripten-module.browser.mjs $(DIST)/emscripten-module.browser.d.ts +CLOUDFLARE: $(DIST)/emscripten-module.cloudflare.cjs $(DIST)/emscripten-module.cloudflare.d.ts + +$(DIST)/emscripten-module.mjs: CFLAGS_WASM+=$(CFLAGS_ESM) +$(DIST)/emscripten-module.mjs: $(BUILD_WRAPPER)/interface.o $(VARIANT_QUICKJS_OBJS) $(WASM_SYMBOLS) | $(EMCC_SRC) + $(MKDIRP) + $(EMCC) $(CFLAGS_WASM) $(WRAPPER_DEFINES) $(EMCC_EXPORTED_FUNCS) -o $@ $< $(VARIANT_QUICKJS_OBJS) + +$(DIST)/emscripten-module.cjs: CFLAGS_WASM+=$(CFLAGS_CJS) +$(DIST)/emscripten-module.cjs: $(BUILD_WRAPPER)/interface.o $(VARIANT_QUICKJS_OBJS) $(WASM_SYMBOLS) | $(EMCC_SRC) + $(MKDIRP) + $(EMCC) $(CFLAGS_WASM) $(WRAPPER_DEFINES) $(EMCC_EXPORTED_FUNCS) -o $@ $< $(VARIANT_QUICKJS_OBJS) + +$(DIST)/emscripten-module.d.ts: $(TEMPLATES)/emscripten-module.$(SYNC).d.ts + $(MKDIRP) + echo '// Generated from $<' > $@ + cat $< >> $@ + +$(DIST)/emscripten-module%.d.ts: $(TEMPLATES)/emscripten-module.$(SYNC).d.ts + $(MKDIRP) + echo '// Generated from $<' > $@ + cat $< >> $@ + +# Browser target needs intermediate build to avoid two copies of .wasm +$(DIST)/emscripten-module.%.mjs: $(BUILD_WRAPPER)/%/emscripten-module.js + $(MKDIRP) + if [ -e $(basename $<).wasm ] ; then cp -v $(basename $<).wasm* $(dir $@); fi + cp $< $@ + +$(DIST)/emscripten-module.%.cjs: $(BUILD_WRAPPER)/%/emscripten-module.js + $(MKDIRP) + if [ -e $(basename $<).wasm ] ; then cp -v $(basename $<).wasm* $(dir $@); fi + cp $< $@ + +$(BUILD_WRAPPER)/browser/emscripten-module.js: CFLAGS_WASM+=$(CFLAGS_BROWSER) +$(BUILD_WRAPPER)/cloudflare/emscripten-module.js: CFLAGS_WASM+=$(CFLAGS_CLOUDFLARE) +$(BUILD_WRAPPER)/%/emscripten-module.js: $(BUILD_WRAPPER)/interface.o $(VARIANT_QUICKJS_OBJS) $(WASM_SYMBOLS) | $(EMCC_SRC) + $(MKDIRP) + $(EMCC) $(CFLAGS_WASM) $(WRAPPER_DEFINES) $(EMCC_EXPORTED_FUNCS) -o $@ $< $(VARIANT_QUICKJS_OBJS) + +############################################################################### +# Emscripten intermediate files +WASM_SYMBOLS=$(BUILD_WRAPPER)/symbols.json $(BUILD_WRAPPER)/asyncify-remove.json $(BUILD_WRAPPER)/asyncify-imports.json +$(BUILD_WRAPPER)/%.o: $(WRAPPER_ROOT)/%.c $(WASM_SYMBOLS) | $(EMCC_SRC) + $(MKDIRP) + $(EMCC) $(CFLAGS_WASM) $(WRAPPER_DEFINES) -c -o $@ $< + +$(BUILD_QUICKJS)/%.o: $(QUICKJS_ROOT)/%.c $(WASM_SYMBOLS) | $(EMCC_SRC) + $(MKDIRP) + $(EMCC) $(CFLAGS_WASM) $(QUICKJS_DEFINES) -c -o $@ $< + +$(BUILD_WRAPPER)/symbols.json: + $(MKDIRP) + $(GENERATE_TS) symbols $@ + +$(BUILD_WRAPPER)/asyncify-remove.json: + $(MKDIRP) + $(GENERATE_TS) sync-symbols $@ + +$(BUILD_WRAPPER)/asyncify-imports.json: + $(MKDIRP) + $(GENERATE_TS) async-callback-symbols $@ diff --git a/packages/variant-quickjs-asmjs-mjs-release-sync/README.md b/packages/variant-quickjs-asmjs-mjs-release-sync/README.md new file mode 100644 index 00000000..8d648b7f --- /dev/null +++ b/packages/variant-quickjs-asmjs-mjs-release-sync/README.md @@ -0,0 +1,72 @@ +# @jitl/quickjs-asmjs-mjs-release-sync + +Compiled to pure Javascript, no WebAssembly required. + +This generated package is part of [quickjs-emscripten](https://github.com/justjake/quickjs-emscripten). +It contains a variant of the quickjs WASM library, and can be used with quickjs-emscripten-core. + +```typescript +import variant from "@jitl/quickjs-asmjs-mjs-release-sync" +import { newQuickJSWASMModuleFromVariant } from "quickjs-emscripten-core" +const QuickJS = await newQuickJSWASMModuleFromVariant(variant) +``` + +This variant was built with the following settings: + +## 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. + +## Release mode: release + +Optimized for performance; use when building/deploying your application. + +## Exports: import + +Exports the following in package.json for the package entrypoint: + +- Exports a NodeJS-compatible ESModule. Cannot be imported synchronously from a NodeJS CommonJS module. + +## Extra async magic? No + +The default, normal build. Note that both variants support regular async functions. + +## Single-file, or separate .wasm file? 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. + +## More details + +Full variant JSON description: + +```json +{ + "library": "quickjs", + "releaseMode": "release", + "syncMode": "sync", + "description": "Compiled to pure Javascript, no WebAssembly required.", + "emscriptenInclusion": "asmjs", + "exports": { + "import": { + "emscriptenEnvironment": ["web", "worker", "node"] + } + } +} +``` + +Variant-specific Emscripten build flags: + +```json +[ + "-Oz", + "-flto", + "--closure 1", + "-s FILESYSTEM=0", + "--pre-js $(TEMPLATES)/pre-extension.js", + "--pre-js $(TEMPLATES)/pre-wasmMemory.js", + "-s WASM=0", + "-s SINGLE_FILE=1" +] +``` diff --git a/packages/variant-quickjs-asmjs-mjs-release-sync/package.json b/packages/variant-quickjs-asmjs-mjs-release-sync/package.json new file mode 100644 index 00000000..6b09f208 --- /dev/null +++ b/packages/variant-quickjs-asmjs-mjs-release-sync/package.json @@ -0,0 +1,48 @@ +{ + "name": "@jitl/quickjs-asmjs-mjs-release-sync", + "license": "MIT", + "version": "0.31.0", + "description": "Variant of quickjs library: Compiled to pure Javascript, no WebAssembly required.", + "sideEffects": false, + "repository": { + "type": "git", + "url": "https://github.com/justjake/quickjs-emscripten" + }, + "author": { + "name": "Jake Teton-Landis", + "url": "https://jake.tl" + }, + "scripts": { + "build": "yarn build:c && yarn build:ts", + "build:c": "make -j2", + "build:ts": "npx tsup", + "check:types": "npx tsc --project . --noEmit", + "clean": "make clean", + "prepare": "yarn clean && yarn build" + }, + "files": [ + "LICENSE", + "README.md", + "dist/**/*", + "!dist/*.tsbuildinfo" + ], + "types": "./dist/index.d.mts", + "main": "./dist/index.mjs", + "module": "./dist/index.mjs", + "exports": { + ".": { + "types": "./dist/index.d.mts", + "import": "./dist/index.mjs", + "default": "./dist/index.mjs" + }, + "./package.json": "./package.json", + "./emscripten-module": { + "types": "./dist/emscripten-module.d.ts", + "import": "./dist/emscripten-module.mjs", + "default": "./dist/emscripten-module.mjs" + } + }, + "dependencies": { + "@jitl/quickjs-ffi-types": "workspace:*" + } +} diff --git a/packages/variant-quickjs-asmjs-mjs-release-sync/src/ffi.ts b/packages/variant-quickjs-asmjs-mjs-release-sync/src/ffi.ts new file mode 100644 index 00000000..419f408d --- /dev/null +++ b/packages/variant-quickjs-asmjs-mjs-release-sync/src/ffi.ts @@ -0,0 +1,419 @@ +// This file generated by "generate.ts ffi" in the root of the repo. +import { + QuickJSEmscriptenModule, + JSRuntimePointer, + JSContextPointer, + JSContextPointerPointer, + JSModuleDefPointer, + JSValuePointer, + JSValueConstPointer, + JSValuePointerPointer, + JSValuePointerPointerPointer, + JSValueConstPointerPointer, + QTS_C_To_HostCallbackFuncPointer, + QTS_C_To_HostInterruptFuncPointer, + QTS_C_To_HostLoadModuleFuncPointer, + BorrowedHeapCharPointer, + OwnedHeapCharPointer, + JSBorrowedCharPointer, + JSVoidPointer, + UInt32Pointer, + EvalFlags, + IntrinsicsFlags, + EvalDetectModule, + GetOwnPropertyNamesFlags, + IsEqualOp, + JSPromiseStateEnum, +} from "@jitl/quickjs-ffi-types" + +/** + * Low-level FFI bindings to QuickJS's Emscripten module. + * See instead {@link QuickJSContext}, the public Javascript interface exposed by this + * library. + * + * @unstable The FFI interface is considered private and may change. + */ +export class QuickJSFFI { + constructor(private module: QuickJSEmscriptenModule) {} + /** Set at compile time. */ + readonly DEBUG = false + + QTS_Throw: ( + ctx: JSContextPointer, + error: JSValuePointer | JSValueConstPointer, + ) => JSValuePointer = this.module.cwrap("QTS_Throw", "number", ["number", "number"]) + + QTS_NewError: (ctx: JSContextPointer) => JSValuePointer = this.module.cwrap( + "QTS_NewError", + "number", + ["number"], + ) + + QTS_RuntimeSetMemoryLimit: (rt: JSRuntimePointer, limit: number) => void = this.module.cwrap( + "QTS_RuntimeSetMemoryLimit", + null, + ["number", "number"], + ) + + QTS_RuntimeComputeMemoryUsage: (rt: JSRuntimePointer, ctx: JSContextPointer) => JSValuePointer = + this.module.cwrap("QTS_RuntimeComputeMemoryUsage", "number", ["number", "number"]) + + QTS_RuntimeDumpMemoryUsage: (rt: JSRuntimePointer) => OwnedHeapCharPointer = this.module.cwrap( + "QTS_RuntimeDumpMemoryUsage", + "number", + ["number"], + ) + + QTS_RecoverableLeakCheck: () => number = this.module.cwrap( + "QTS_RecoverableLeakCheck", + "number", + [], + ) + + QTS_BuildIsSanitizeLeak: () => number = this.module.cwrap("QTS_BuildIsSanitizeLeak", "number", []) + + QTS_RuntimeSetMaxStackSize: (rt: JSRuntimePointer, stack_size: number) => void = + this.module.cwrap("QTS_RuntimeSetMaxStackSize", null, ["number", "number"]) + + QTS_GetUndefined: () => JSValueConstPointer = this.module.cwrap("QTS_GetUndefined", "number", []) + + QTS_GetNull: () => JSValueConstPointer = this.module.cwrap("QTS_GetNull", "number", []) + + QTS_GetFalse: () => JSValueConstPointer = this.module.cwrap("QTS_GetFalse", "number", []) + + QTS_GetTrue: () => JSValueConstPointer = this.module.cwrap("QTS_GetTrue", "number", []) + + QTS_NewRuntime: () => JSRuntimePointer = this.module.cwrap("QTS_NewRuntime", "number", []) + + QTS_FreeRuntime: (rt: JSRuntimePointer) => void = this.module.cwrap("QTS_FreeRuntime", null, [ + "number", + ]) + + QTS_NewContext: (rt: JSRuntimePointer, intrinsics: IntrinsicsFlags) => JSContextPointer = + this.module.cwrap("QTS_NewContext", "number", ["number", "number"]) + + QTS_FreeContext: (ctx: JSContextPointer) => void = this.module.cwrap("QTS_FreeContext", null, [ + "number", + ]) + + QTS_FreeValuePointer: (ctx: JSContextPointer, value: JSValuePointer) => void = this.module.cwrap( + "QTS_FreeValuePointer", + null, + ["number", "number"], + ) + + QTS_FreeValuePointerRuntime: (rt: JSRuntimePointer, value: JSValuePointer) => void = + this.module.cwrap("QTS_FreeValuePointerRuntime", null, ["number", "number"]) + + QTS_FreeVoidPointer: (ctx: JSContextPointer, ptr: JSVoidPointer) => void = this.module.cwrap( + "QTS_FreeVoidPointer", + null, + ["number", "number"], + ) + + QTS_FreeCString: (ctx: JSContextPointer, str: JSBorrowedCharPointer) => void = this.module.cwrap( + "QTS_FreeCString", + null, + ["number", "number"], + ) + + QTS_DupValuePointer: ( + ctx: JSContextPointer, + val: JSValuePointer | JSValueConstPointer, + ) => JSValuePointer = this.module.cwrap("QTS_DupValuePointer", "number", ["number", "number"]) + + QTS_NewObject: (ctx: JSContextPointer) => JSValuePointer = this.module.cwrap( + "QTS_NewObject", + "number", + ["number"], + ) + + QTS_NewObjectProto: ( + ctx: JSContextPointer, + proto: JSValuePointer | JSValueConstPointer, + ) => JSValuePointer = this.module.cwrap("QTS_NewObjectProto", "number", ["number", "number"]) + + QTS_NewArray: (ctx: JSContextPointer) => JSValuePointer = this.module.cwrap( + "QTS_NewArray", + "number", + ["number"], + ) + + QTS_NewArrayBuffer: ( + ctx: JSContextPointer, + buffer: JSVoidPointer, + length: number, + ) => JSValuePointer = this.module.cwrap("QTS_NewArrayBuffer", "number", [ + "number", + "number", + "number", + ]) + + QTS_NewFloat64: (ctx: JSContextPointer, num: number) => JSValuePointer = this.module.cwrap( + "QTS_NewFloat64", + "number", + ["number", "number"], + ) + + QTS_GetFloat64: (ctx: JSContextPointer, value: JSValuePointer | JSValueConstPointer) => number = + this.module.cwrap("QTS_GetFloat64", "number", ["number", "number"]) + + QTS_NewString: (ctx: JSContextPointer, string: BorrowedHeapCharPointer) => JSValuePointer = + this.module.cwrap("QTS_NewString", "number", ["number", "number"]) + + QTS_GetString: ( + ctx: JSContextPointer, + value: JSValuePointer | JSValueConstPointer, + ) => JSBorrowedCharPointer = this.module.cwrap("QTS_GetString", "number", ["number", "number"]) + + QTS_GetArrayBuffer: ( + ctx: JSContextPointer, + data: JSValuePointer | JSValueConstPointer, + ) => JSVoidPointer = this.module.cwrap("QTS_GetArrayBuffer", "number", ["number", "number"]) + + QTS_GetArrayBufferLength: ( + ctx: JSContextPointer, + data: JSValuePointer | JSValueConstPointer, + ) => number = this.module.cwrap("QTS_GetArrayBufferLength", "number", ["number", "number"]) + + QTS_NewSymbol: ( + ctx: JSContextPointer, + description: BorrowedHeapCharPointer, + isGlobal: number, + ) => JSValuePointer = this.module.cwrap("QTS_NewSymbol", "number", ["number", "number", "number"]) + + QTS_GetSymbolDescriptionOrKey: ( + ctx: JSContextPointer, + value: JSValuePointer | JSValueConstPointer, + ) => JSBorrowedCharPointer = this.module.cwrap("QTS_GetSymbolDescriptionOrKey", "number", [ + "number", + "number", + ]) + + QTS_IsGlobalSymbol: ( + ctx: JSContextPointer, + value: JSValuePointer | JSValueConstPointer, + ) => number = this.module.cwrap("QTS_IsGlobalSymbol", "number", ["number", "number"]) + + QTS_IsJobPending: (rt: JSRuntimePointer) => number = this.module.cwrap( + "QTS_IsJobPending", + "number", + ["number"], + ) + + QTS_ExecutePendingJob: ( + rt: JSRuntimePointer, + maxJobsToExecute: number, + lastJobContext: JSContextPointerPointer, + ) => JSValuePointer = this.module.cwrap("QTS_ExecutePendingJob", "number", [ + "number", + "number", + "number", + ]) + + QTS_GetProp: ( + ctx: JSContextPointer, + this_val: JSValuePointer | JSValueConstPointer, + prop_name: JSValuePointer | JSValueConstPointer, + ) => JSValuePointer = this.module.cwrap("QTS_GetProp", "number", ["number", "number", "number"]) + + QTS_GetPropNumber: ( + ctx: JSContextPointer, + this_val: JSValuePointer | JSValueConstPointer, + prop_name: number, + ) => JSValuePointer = this.module.cwrap("QTS_GetPropNumber", "number", [ + "number", + "number", + "number", + ]) + + QTS_SetProp: ( + ctx: JSContextPointer, + this_val: JSValuePointer | JSValueConstPointer, + prop_name: JSValuePointer | JSValueConstPointer, + prop_value: JSValuePointer | JSValueConstPointer, + ) => void = this.module.cwrap("QTS_SetProp", null, ["number", "number", "number", "number"]) + + QTS_DefineProp: ( + ctx: JSContextPointer, + this_val: JSValuePointer | JSValueConstPointer, + prop_name: JSValuePointer | JSValueConstPointer, + prop_value: JSValuePointer | JSValueConstPointer, + get: JSValuePointer | JSValueConstPointer, + set: JSValuePointer | JSValueConstPointer, + configurable: boolean, + enumerable: boolean, + has_value: boolean, + ) => void = this.module.cwrap("QTS_DefineProp", null, [ + "number", + "number", + "number", + "number", + "number", + "number", + "boolean", + "boolean", + "boolean", + ]) + + QTS_GetOwnPropertyNames: ( + ctx: JSContextPointer, + out_ptrs: JSValuePointerPointerPointer, + out_len: UInt32Pointer, + obj: JSValuePointer | JSValueConstPointer, + flags: number, + ) => JSValuePointer = this.module.cwrap("QTS_GetOwnPropertyNames", "number", [ + "number", + "number", + "number", + "number", + "number", + ]) + + QTS_Call: ( + ctx: JSContextPointer, + func_obj: JSValuePointer | JSValueConstPointer, + this_obj: JSValuePointer | JSValueConstPointer, + argc: number, + argv_ptrs: JSValueConstPointerPointer, + ) => JSValuePointer = this.module.cwrap("QTS_Call", "number", [ + "number", + "number", + "number", + "number", + "number", + ]) + + QTS_ResolveException: (ctx: JSContextPointer, maybe_exception: JSValuePointer) => JSValuePointer = + this.module.cwrap("QTS_ResolveException", "number", ["number", "number"]) + + QTS_Dump: ( + ctx: JSContextPointer, + obj: JSValuePointer | JSValueConstPointer, + ) => JSBorrowedCharPointer = this.module.cwrap("QTS_Dump", "number", ["number", "number"]) + + QTS_Eval: ( + ctx: JSContextPointer, + js_code: BorrowedHeapCharPointer, + js_code_length: number, + filename: string, + detectModule: EvalDetectModule, + evalFlags: EvalFlags, + ) => JSValuePointer = this.module.cwrap("QTS_Eval", "number", [ + "number", + "number", + "number", + "string", + "number", + "number", + ]) + + QTS_GetModuleNamespace: ( + ctx: JSContextPointer, + module_func_obj: JSValuePointer | JSValueConstPointer, + ) => JSValuePointer = this.module.cwrap("QTS_GetModuleNamespace", "number", ["number", "number"]) + + QTS_Typeof: ( + ctx: JSContextPointer, + value: JSValuePointer | JSValueConstPointer, + ) => OwnedHeapCharPointer = this.module.cwrap("QTS_Typeof", "number", ["number", "number"]) + + QTS_GetLength: ( + ctx: JSContextPointer, + out_len: UInt32Pointer, + value: JSValuePointer | JSValueConstPointer, + ) => number = this.module.cwrap("QTS_GetLength", "number", ["number", "number", "number"]) + + QTS_IsEqual: ( + ctx: JSContextPointer, + a: JSValuePointer | JSValueConstPointer, + b: JSValuePointer | JSValueConstPointer, + op: IsEqualOp, + ) => number = this.module.cwrap("QTS_IsEqual", "number", ["number", "number", "number", "number"]) + + QTS_GetGlobalObject: (ctx: JSContextPointer) => JSValuePointer = this.module.cwrap( + "QTS_GetGlobalObject", + "number", + ["number"], + ) + + QTS_NewPromiseCapability: ( + ctx: JSContextPointer, + resolve_funcs_out: JSValuePointerPointer, + ) => JSValuePointer = this.module.cwrap("QTS_NewPromiseCapability", "number", [ + "number", + "number", + ]) + + QTS_PromiseState: ( + ctx: JSContextPointer, + promise: JSValuePointer | JSValueConstPointer, + ) => JSPromiseStateEnum = this.module.cwrap("QTS_PromiseState", "number", ["number", "number"]) + + QTS_PromiseResult: ( + ctx: JSContextPointer, + promise: JSValuePointer | JSValueConstPointer, + ) => JSValuePointer = this.module.cwrap("QTS_PromiseResult", "number", ["number", "number"]) + + QTS_TestStringArg: (string: string) => void = this.module.cwrap("QTS_TestStringArg", null, [ + "string", + ]) + + QTS_GetDebugLogEnabled: (rt: JSRuntimePointer) => number = this.module.cwrap( + "QTS_GetDebugLogEnabled", + "number", + ["number"], + ) + + QTS_SetDebugLogEnabled: (rt: JSRuntimePointer, is_enabled: number) => void = this.module.cwrap( + "QTS_SetDebugLogEnabled", + null, + ["number", "number"], + ) + + QTS_BuildIsDebug: () => number = this.module.cwrap("QTS_BuildIsDebug", "number", []) + + QTS_BuildIsAsyncify: () => number = this.module.cwrap("QTS_BuildIsAsyncify", "number", []) + + QTS_NewFunction: (ctx: JSContextPointer, func_id: number, name: string) => JSValuePointer = + this.module.cwrap("QTS_NewFunction", "number", ["number", "number", "string"]) + + QTS_ArgvGetJSValueConstPointer: ( + argv: JSValuePointer | JSValueConstPointer, + index: number, + ) => JSValueConstPointer = this.module.cwrap("QTS_ArgvGetJSValueConstPointer", "number", [ + "number", + "number", + ]) + + QTS_RuntimeEnableInterruptHandler: (rt: JSRuntimePointer) => void = this.module.cwrap( + "QTS_RuntimeEnableInterruptHandler", + null, + ["number"], + ) + + QTS_RuntimeDisableInterruptHandler: (rt: JSRuntimePointer) => void = this.module.cwrap( + "QTS_RuntimeDisableInterruptHandler", + null, + ["number"], + ) + + QTS_RuntimeEnableModuleLoader: (rt: JSRuntimePointer, use_custom_normalize: number) => void = + this.module.cwrap("QTS_RuntimeEnableModuleLoader", null, ["number", "number"]) + + QTS_RuntimeDisableModuleLoader: (rt: JSRuntimePointer) => void = this.module.cwrap( + "QTS_RuntimeDisableModuleLoader", + null, + ["number"], + ) + + QTS_bjson_encode: ( + ctx: JSContextPointer, + val: JSValuePointer | JSValueConstPointer, + ) => JSValuePointer = this.module.cwrap("QTS_bjson_encode", "number", ["number", "number"]) + + QTS_bjson_decode: ( + ctx: JSContextPointer, + data: JSValuePointer | JSValueConstPointer, + ) => JSValuePointer = this.module.cwrap("QTS_bjson_decode", "number", ["number", "number"]) +} diff --git a/packages/variant-quickjs-asmjs-mjs-release-sync/src/index.ts b/packages/variant-quickjs-asmjs-mjs-release-sync/src/index.ts new file mode 100644 index 00000000..0eaa9f15 --- /dev/null +++ b/packages/variant-quickjs-asmjs-mjs-release-sync/src/index.ts @@ -0,0 +1,24 @@ +import type { QuickJSSyncVariant } from "@jitl/quickjs-ffi-types" +import moduleLoader from "@jitl/quickjs-asmjs-mjs-release-sync/emscripten-module" +import { QuickJSFFI } from "./ffi.js" +/** + * ### @jitl/quickjs-asmjs-mjs-release-sync + * + * [Docs](https://github.com/justjake/quickjs-emscripten/blob/main/doc/@jitl/quickjs-asmjs-mjs-release-sync/README.md) | + * Compiled to pure Javascript, no WebAssembly required. + * + * | Variable | Setting | Description | + * | -- | -- | -- | + * | 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. | + * | releaseMode | release | Optimized for performance; use when building/deploying your application. | + * | syncMode | sync | The default, normal build. Note that both variants support regular async functions. | + * | 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. | + * | exports | import | Has these package.json export conditions | + * + */ +const variant: QuickJSSyncVariant = { + type: "sync", + importFFI: () => Promise.resolve(QuickJSFFI), + importModuleLoader: () => Promise.resolve(moduleLoader), +} as const +export default variant diff --git a/packages/variant-quickjs-asmjs-mjs-release-sync/tsconfig.json b/packages/variant-quickjs-asmjs-mjs-release-sync/tsconfig.json new file mode 100644 index 00000000..3a077e27 --- /dev/null +++ b/packages/variant-quickjs-asmjs-mjs-release-sync/tsconfig.json @@ -0,0 +1 @@ +{ "extends": "@jitl/tsconfig/tsconfig.json", "include": ["src/*"], "exclude": ["node_modules"] } diff --git a/packages/variant-quickjs-asmjs-mjs-release-sync/tsup.config.ts b/packages/variant-quickjs-asmjs-mjs-release-sync/tsup.config.ts new file mode 100644 index 00000000..b99f85b0 --- /dev/null +++ b/packages/variant-quickjs-asmjs-mjs-release-sync/tsup.config.ts @@ -0,0 +1,7 @@ +import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" +export default extendConfig({ + entry: ["src/index.ts"], + external: [], + format: ["esm"], + clean: false, +}) diff --git a/packages/variant-quickjs-asmjs-mjs-release-sync/typedoc.json b/packages/variant-quickjs-asmjs-mjs-release-sync/typedoc.json new file mode 100644 index 00000000..e0f02210 --- /dev/null +++ b/packages/variant-quickjs-asmjs-mjs-release-sync/typedoc.json @@ -0,0 +1 @@ +{ "extends": "../../typedoc.base.js", "entryPoints": ["./src/index.ts"], "mergeReadme": true } diff --git a/packages/variant-quickjs-ng-wasmfile-debug-asyncify/Makefile b/packages/variant-quickjs-ng-wasmfile-debug-asyncify/Makefile index 16fa99c8..8c2b2a38 100644 --- a/packages/variant-quickjs-ng-wasmfile-debug-asyncify/Makefile +++ b/packages/variant-quickjs-ng-wasmfile-debug-asyncify/Makefile @@ -1,6 +1,6 @@ # Tools -EMSDK_VERSION=3.1.64 -EMSDK_DOCKER_IMAGE=emscripten/emsdk:3.1.64 +EMSDK_VERSION=3.1.65 +EMSDK_DOCKER_IMAGE=emscripten/emsdk:3.1.65 EMCC_SRC=../../scripts/emcc.sh EMCC=EMSDK_VERSION=$(EMSDK_VERSION) EMSDK_DOCKER_IMAGE=$(EMSDK_DOCKER_IMAGE) EMSDK_PROJECT_ROOT=$(REPO_ROOT) EMSDK_DOCKER_CACHE=$(REPO_ROOT)/emsdk-cache/$(EMSDK_VERSION) $(EMCC_SRC) GENERATE_TS=$(GENERATE_TS_ENV) ../../scripts/generate.ts @@ -38,7 +38,6 @@ EMCC_EXPORTED_FUNCS+=-s EXPORTED_FUNCTIONS=@$(BUILD_WRAPPER)/symbols.json EMCC_EXPORTED_FUNCS_ASYNCIFY+=-s EXPORTED_FUNCTIONS=@$(BUILD_WRAPPER)/symbols.asyncify.json # Emscripten options -CFLAGS_WASM+=-s WASM=1 CFLAGS_WASM+=-s EXPORTED_RUNTIME_METHODS=@../../exportedRuntimeMethods.json CFLAGS_WASM+=-s MODULARIZE=1 CFLAGS_WASM+=-s IMPORTED_MEMORY=1 # Allow passing WASM memory to Emscripten diff --git a/packages/variant-quickjs-ng-wasmfile-debug-asyncify/package.json b/packages/variant-quickjs-ng-wasmfile-debug-asyncify/package.json index 3bae4dd1..bfe2a4f4 100644 --- a/packages/variant-quickjs-ng-wasmfile-debug-asyncify/package.json +++ b/packages/variant-quickjs-ng-wasmfile-debug-asyncify/package.json @@ -1,7 +1,7 @@ { "name": "@jitl/quickjs-ng-wasmfile-debug-asyncify", "license": "MIT", - "version": "0.30.0", + "version": "0.31.0", "description": "Variant of quickjs library: Variant with separate .WASM file. Supports browser ESM, NodeJS ESM, and NodeJS CommonJS.", "sideEffects": false, "repository": { diff --git a/packages/variant-quickjs-ng-wasmfile-debug-asyncify/tsup.config.ts b/packages/variant-quickjs-ng-wasmfile-debug-asyncify/tsup.config.ts index 30451ad2..d2ab789b 100644 --- a/packages/variant-quickjs-ng-wasmfile-debug-asyncify/tsup.config.ts +++ b/packages/variant-quickjs-ng-wasmfile-debug-asyncify/tsup.config.ts @@ -1,8 +1,7 @@ import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" - export default extendConfig({ entry: ["src/index.ts", "src/ffi.ts"], external: ["@jitl/quickjs-ng-wasmfile-debug-asyncify/emscripten-module"], - formats: ["esm", "cjs"], + format: ["esm", "cjs"], clean: false, }) diff --git a/packages/variant-quickjs-ng-wasmfile-debug-sync/Makefile b/packages/variant-quickjs-ng-wasmfile-debug-sync/Makefile index ef572faa..8eab16ee 100644 --- a/packages/variant-quickjs-ng-wasmfile-debug-sync/Makefile +++ b/packages/variant-quickjs-ng-wasmfile-debug-sync/Makefile @@ -1,6 +1,6 @@ # Tools -EMSDK_VERSION=3.1.64 -EMSDK_DOCKER_IMAGE=emscripten/emsdk:3.1.64 +EMSDK_VERSION=3.1.65 +EMSDK_DOCKER_IMAGE=emscripten/emsdk:3.1.65 EMCC_SRC=../../scripts/emcc.sh EMCC=EMSDK_VERSION=$(EMSDK_VERSION) EMSDK_DOCKER_IMAGE=$(EMSDK_DOCKER_IMAGE) EMSDK_PROJECT_ROOT=$(REPO_ROOT) EMSDK_DOCKER_CACHE=$(REPO_ROOT)/emsdk-cache/$(EMSDK_VERSION) $(EMCC_SRC) GENERATE_TS=$(GENERATE_TS_ENV) ../../scripts/generate.ts @@ -38,7 +38,6 @@ EMCC_EXPORTED_FUNCS+=-s EXPORTED_FUNCTIONS=@$(BUILD_WRAPPER)/symbols.json EMCC_EXPORTED_FUNCS_ASYNCIFY+=-s EXPORTED_FUNCTIONS=@$(BUILD_WRAPPER)/symbols.asyncify.json # Emscripten options -CFLAGS_WASM+=-s WASM=1 CFLAGS_WASM+=-s EXPORTED_RUNTIME_METHODS=@../../exportedRuntimeMethods.json CFLAGS_WASM+=-s MODULARIZE=1 CFLAGS_WASM+=-s IMPORTED_MEMORY=1 # Allow passing WASM memory to Emscripten diff --git a/packages/variant-quickjs-ng-wasmfile-debug-sync/package.json b/packages/variant-quickjs-ng-wasmfile-debug-sync/package.json index 5679565d..0fd01f15 100644 --- a/packages/variant-quickjs-ng-wasmfile-debug-sync/package.json +++ b/packages/variant-quickjs-ng-wasmfile-debug-sync/package.json @@ -1,7 +1,7 @@ { "name": "@jitl/quickjs-ng-wasmfile-debug-sync", "license": "MIT", - "version": "0.30.0", + "version": "0.31.0", "description": "Variant of quickjs library: Variant with separate .WASM file. Supports browser ESM, NodeJS ESM, and NodeJS CommonJS.", "sideEffects": false, "repository": { diff --git a/packages/variant-quickjs-ng-wasmfile-debug-sync/tsup.config.ts b/packages/variant-quickjs-ng-wasmfile-debug-sync/tsup.config.ts index 11d9a581..da548d8b 100644 --- a/packages/variant-quickjs-ng-wasmfile-debug-sync/tsup.config.ts +++ b/packages/variant-quickjs-ng-wasmfile-debug-sync/tsup.config.ts @@ -1,8 +1,7 @@ import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" - export default extendConfig({ entry: ["src/index.ts", "src/ffi.ts"], external: ["@jitl/quickjs-ng-wasmfile-debug-sync/emscripten-module"], - formats: ["esm", "cjs"], + format: ["esm", "cjs"], clean: false, }) diff --git a/packages/variant-quickjs-ng-wasmfile-release-asyncify/Makefile b/packages/variant-quickjs-ng-wasmfile-release-asyncify/Makefile index fa97b618..66dc3f74 100644 --- a/packages/variant-quickjs-ng-wasmfile-release-asyncify/Makefile +++ b/packages/variant-quickjs-ng-wasmfile-release-asyncify/Makefile @@ -1,6 +1,6 @@ # Tools -EMSDK_VERSION=3.1.64 -EMSDK_DOCKER_IMAGE=emscripten/emsdk:3.1.64 +EMSDK_VERSION=3.1.65 +EMSDK_DOCKER_IMAGE=emscripten/emsdk:3.1.65 EMCC_SRC=../../scripts/emcc.sh EMCC=EMSDK_VERSION=$(EMSDK_VERSION) EMSDK_DOCKER_IMAGE=$(EMSDK_DOCKER_IMAGE) EMSDK_PROJECT_ROOT=$(REPO_ROOT) EMSDK_DOCKER_CACHE=$(REPO_ROOT)/emsdk-cache/$(EMSDK_VERSION) $(EMCC_SRC) GENERATE_TS=$(GENERATE_TS_ENV) ../../scripts/generate.ts @@ -38,7 +38,6 @@ EMCC_EXPORTED_FUNCS+=-s EXPORTED_FUNCTIONS=@$(BUILD_WRAPPER)/symbols.json EMCC_EXPORTED_FUNCS_ASYNCIFY+=-s EXPORTED_FUNCTIONS=@$(BUILD_WRAPPER)/symbols.asyncify.json # Emscripten options -CFLAGS_WASM+=-s WASM=1 CFLAGS_WASM+=-s EXPORTED_RUNTIME_METHODS=@../../exportedRuntimeMethods.json CFLAGS_WASM+=-s MODULARIZE=1 CFLAGS_WASM+=-s IMPORTED_MEMORY=1 # Allow passing WASM memory to Emscripten diff --git a/packages/variant-quickjs-ng-wasmfile-release-asyncify/package.json b/packages/variant-quickjs-ng-wasmfile-release-asyncify/package.json index 90964565..0378d772 100644 --- a/packages/variant-quickjs-ng-wasmfile-release-asyncify/package.json +++ b/packages/variant-quickjs-ng-wasmfile-release-asyncify/package.json @@ -1,7 +1,7 @@ { "name": "@jitl/quickjs-ng-wasmfile-release-asyncify", "license": "MIT", - "version": "0.30.0", + "version": "0.31.0", "description": "Variant of quickjs library: Variant with separate .WASM file. Supports browser ESM, NodeJS ESM, and NodeJS CommonJS.", "sideEffects": false, "repository": { diff --git a/packages/variant-quickjs-ng-wasmfile-release-asyncify/tsup.config.ts b/packages/variant-quickjs-ng-wasmfile-release-asyncify/tsup.config.ts index 998c3ddb..c762d2ff 100644 --- a/packages/variant-quickjs-ng-wasmfile-release-asyncify/tsup.config.ts +++ b/packages/variant-quickjs-ng-wasmfile-release-asyncify/tsup.config.ts @@ -1,8 +1,7 @@ import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" - export default extendConfig({ entry: ["src/index.ts", "src/ffi.ts"], external: ["@jitl/quickjs-ng-wasmfile-release-asyncify/emscripten-module"], - formats: ["esm", "cjs"], + format: ["esm", "cjs"], clean: false, }) diff --git a/packages/variant-quickjs-ng-wasmfile-release-sync/Makefile b/packages/variant-quickjs-ng-wasmfile-release-sync/Makefile index 6f37e049..ce4a8ce7 100644 --- a/packages/variant-quickjs-ng-wasmfile-release-sync/Makefile +++ b/packages/variant-quickjs-ng-wasmfile-release-sync/Makefile @@ -1,6 +1,6 @@ # Tools -EMSDK_VERSION=3.1.64 -EMSDK_DOCKER_IMAGE=emscripten/emsdk:3.1.64 +EMSDK_VERSION=3.1.65 +EMSDK_DOCKER_IMAGE=emscripten/emsdk:3.1.65 EMCC_SRC=../../scripts/emcc.sh EMCC=EMSDK_VERSION=$(EMSDK_VERSION) EMSDK_DOCKER_IMAGE=$(EMSDK_DOCKER_IMAGE) EMSDK_PROJECT_ROOT=$(REPO_ROOT) EMSDK_DOCKER_CACHE=$(REPO_ROOT)/emsdk-cache/$(EMSDK_VERSION) $(EMCC_SRC) GENERATE_TS=$(GENERATE_TS_ENV) ../../scripts/generate.ts @@ -38,7 +38,6 @@ EMCC_EXPORTED_FUNCS+=-s EXPORTED_FUNCTIONS=@$(BUILD_WRAPPER)/symbols.json EMCC_EXPORTED_FUNCS_ASYNCIFY+=-s EXPORTED_FUNCTIONS=@$(BUILD_WRAPPER)/symbols.asyncify.json # Emscripten options -CFLAGS_WASM+=-s WASM=1 CFLAGS_WASM+=-s EXPORTED_RUNTIME_METHODS=@../../exportedRuntimeMethods.json CFLAGS_WASM+=-s MODULARIZE=1 CFLAGS_WASM+=-s IMPORTED_MEMORY=1 # Allow passing WASM memory to Emscripten diff --git a/packages/variant-quickjs-ng-wasmfile-release-sync/package.json b/packages/variant-quickjs-ng-wasmfile-release-sync/package.json index 4ea60895..8c6052f0 100644 --- a/packages/variant-quickjs-ng-wasmfile-release-sync/package.json +++ b/packages/variant-quickjs-ng-wasmfile-release-sync/package.json @@ -1,7 +1,7 @@ { "name": "@jitl/quickjs-ng-wasmfile-release-sync", "license": "MIT", - "version": "0.30.0", + "version": "0.31.0", "description": "Variant of quickjs library: Variant with separate .WASM file. Supports browser ESM, NodeJS ESM, and NodeJS CommonJS.", "sideEffects": false, "repository": { diff --git a/packages/variant-quickjs-ng-wasmfile-release-sync/tsup.config.ts b/packages/variant-quickjs-ng-wasmfile-release-sync/tsup.config.ts index 6636095e..ec030821 100644 --- a/packages/variant-quickjs-ng-wasmfile-release-sync/tsup.config.ts +++ b/packages/variant-quickjs-ng-wasmfile-release-sync/tsup.config.ts @@ -1,8 +1,7 @@ import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" - export default extendConfig({ entry: ["src/index.ts", "src/ffi.ts"], external: ["@jitl/quickjs-ng-wasmfile-release-sync/emscripten-module"], - formats: ["esm", "cjs"], + format: ["esm", "cjs"], clean: false, }) diff --git a/packages/variant-quickjs-singlefile-browser-debug-asyncify/Makefile b/packages/variant-quickjs-singlefile-browser-debug-asyncify/Makefile index 97ac9d0e..84953e75 100644 --- a/packages/variant-quickjs-singlefile-browser-debug-asyncify/Makefile +++ b/packages/variant-quickjs-singlefile-browser-debug-asyncify/Makefile @@ -1,6 +1,6 @@ # Tools -EMSDK_VERSION=3.1.64 -EMSDK_DOCKER_IMAGE=emscripten/emsdk:3.1.64 +EMSDK_VERSION=3.1.65 +EMSDK_DOCKER_IMAGE=emscripten/emsdk:3.1.65 EMCC_SRC=../../scripts/emcc.sh EMCC=EMSDK_VERSION=$(EMSDK_VERSION) EMSDK_DOCKER_IMAGE=$(EMSDK_DOCKER_IMAGE) EMSDK_PROJECT_ROOT=$(REPO_ROOT) EMSDK_DOCKER_CACHE=$(REPO_ROOT)/emsdk-cache/$(EMSDK_VERSION) $(EMCC_SRC) GENERATE_TS=$(GENERATE_TS_ENV) ../../scripts/generate.ts @@ -38,7 +38,6 @@ EMCC_EXPORTED_FUNCS+=-s EXPORTED_FUNCTIONS=@$(BUILD_WRAPPER)/symbols.json EMCC_EXPORTED_FUNCS_ASYNCIFY+=-s EXPORTED_FUNCTIONS=@$(BUILD_WRAPPER)/symbols.asyncify.json # Emscripten options -CFLAGS_WASM+=-s WASM=1 CFLAGS_WASM+=-s EXPORTED_RUNTIME_METHODS=@../../exportedRuntimeMethods.json CFLAGS_WASM+=-s MODULARIZE=1 CFLAGS_WASM+=-s IMPORTED_MEMORY=1 # Allow passing WASM memory to Emscripten diff --git a/packages/variant-quickjs-singlefile-browser-debug-asyncify/package.json b/packages/variant-quickjs-singlefile-browser-debug-asyncify/package.json index 7132e03c..b1c8b4b0 100644 --- a/packages/variant-quickjs-singlefile-browser-debug-asyncify/package.json +++ b/packages/variant-quickjs-singlefile-browser-debug-asyncify/package.json @@ -1,7 +1,7 @@ { "name": "@jitl/quickjs-singlefile-browser-debug-asyncify", "license": "MIT", - "version": "0.30.0", + "version": "0.31.0", "description": "Variant of quickjs library: Variant with the WASM data embedded into a browser ESModule.", "sideEffects": false, "repository": { @@ -38,14 +38,15 @@ }, "./package.json": "./package.json", "./ffi": { - "types": "./dist/ffi.d.ts", + "types": "./dist/ffi.d.mts", "import": "./dist/ffi.mjs", "default": "./dist/ffi.mjs" }, "./emscripten-module": { "types": "./dist/emscripten-module.browser.d.ts", "browser": "./dist/emscripten-module.browser.mjs", - "import": "./dist/emscripten-module.browser.mjs" + "import": "./dist/emscripten-module.browser.mjs", + "default": "./dist/emscripten-module.browser.mjs" } }, "dependencies": { diff --git a/packages/variant-quickjs-singlefile-browser-debug-asyncify/tsup.config.ts b/packages/variant-quickjs-singlefile-browser-debug-asyncify/tsup.config.ts index 3501a3d1..fbd0f507 100644 --- a/packages/variant-quickjs-singlefile-browser-debug-asyncify/tsup.config.ts +++ b/packages/variant-quickjs-singlefile-browser-debug-asyncify/tsup.config.ts @@ -1,8 +1,7 @@ import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" - export default extendConfig({ entry: ["src/index.ts", "src/ffi.ts"], - external: ["@jitl/quickjs-singlefile-browser-debug-asyncify/emscripten-module"], - formats: ["esm"], + external: [], + format: ["esm"], clean: false, }) diff --git a/packages/variant-quickjs-singlefile-browser-debug-sync/Makefile b/packages/variant-quickjs-singlefile-browser-debug-sync/Makefile index 20313d1e..199a275a 100644 --- a/packages/variant-quickjs-singlefile-browser-debug-sync/Makefile +++ b/packages/variant-quickjs-singlefile-browser-debug-sync/Makefile @@ -1,6 +1,6 @@ # Tools -EMSDK_VERSION=3.1.64 -EMSDK_DOCKER_IMAGE=emscripten/emsdk:3.1.64 +EMSDK_VERSION=3.1.65 +EMSDK_DOCKER_IMAGE=emscripten/emsdk:3.1.65 EMCC_SRC=../../scripts/emcc.sh EMCC=EMSDK_VERSION=$(EMSDK_VERSION) EMSDK_DOCKER_IMAGE=$(EMSDK_DOCKER_IMAGE) EMSDK_PROJECT_ROOT=$(REPO_ROOT) EMSDK_DOCKER_CACHE=$(REPO_ROOT)/emsdk-cache/$(EMSDK_VERSION) $(EMCC_SRC) GENERATE_TS=$(GENERATE_TS_ENV) ../../scripts/generate.ts @@ -38,7 +38,6 @@ EMCC_EXPORTED_FUNCS+=-s EXPORTED_FUNCTIONS=@$(BUILD_WRAPPER)/symbols.json EMCC_EXPORTED_FUNCS_ASYNCIFY+=-s EXPORTED_FUNCTIONS=@$(BUILD_WRAPPER)/symbols.asyncify.json # Emscripten options -CFLAGS_WASM+=-s WASM=1 CFLAGS_WASM+=-s EXPORTED_RUNTIME_METHODS=@../../exportedRuntimeMethods.json CFLAGS_WASM+=-s MODULARIZE=1 CFLAGS_WASM+=-s IMPORTED_MEMORY=1 # Allow passing WASM memory to Emscripten diff --git a/packages/variant-quickjs-singlefile-browser-debug-sync/package.json b/packages/variant-quickjs-singlefile-browser-debug-sync/package.json index 8b10ac76..d1a257a6 100644 --- a/packages/variant-quickjs-singlefile-browser-debug-sync/package.json +++ b/packages/variant-quickjs-singlefile-browser-debug-sync/package.json @@ -1,7 +1,7 @@ { "name": "@jitl/quickjs-singlefile-browser-debug-sync", "license": "MIT", - "version": "0.30.0", + "version": "0.31.0", "description": "Variant of quickjs library: Variant with the WASM data embedded into a browser ESModule.", "sideEffects": false, "repository": { @@ -38,14 +38,15 @@ }, "./package.json": "./package.json", "./ffi": { - "types": "./dist/ffi.d.ts", + "types": "./dist/ffi.d.mts", "import": "./dist/ffi.mjs", "default": "./dist/ffi.mjs" }, "./emscripten-module": { "types": "./dist/emscripten-module.browser.d.ts", "browser": "./dist/emscripten-module.browser.mjs", - "import": "./dist/emscripten-module.browser.mjs" + "import": "./dist/emscripten-module.browser.mjs", + "default": "./dist/emscripten-module.browser.mjs" } }, "dependencies": { diff --git a/packages/variant-quickjs-singlefile-browser-debug-sync/tsup.config.ts b/packages/variant-quickjs-singlefile-browser-debug-sync/tsup.config.ts index 4b7e31f3..fbd0f507 100644 --- a/packages/variant-quickjs-singlefile-browser-debug-sync/tsup.config.ts +++ b/packages/variant-quickjs-singlefile-browser-debug-sync/tsup.config.ts @@ -1,8 +1,7 @@ import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" - export default extendConfig({ entry: ["src/index.ts", "src/ffi.ts"], - external: ["@jitl/quickjs-singlefile-browser-debug-sync/emscripten-module"], - formats: ["esm"], + external: [], + format: ["esm"], clean: false, }) diff --git a/packages/variant-quickjs-singlefile-browser-release-asyncify/Makefile b/packages/variant-quickjs-singlefile-browser-release-asyncify/Makefile index 61068155..fbb8c343 100644 --- a/packages/variant-quickjs-singlefile-browser-release-asyncify/Makefile +++ b/packages/variant-quickjs-singlefile-browser-release-asyncify/Makefile @@ -1,6 +1,6 @@ # Tools -EMSDK_VERSION=3.1.64 -EMSDK_DOCKER_IMAGE=emscripten/emsdk:3.1.64 +EMSDK_VERSION=3.1.65 +EMSDK_DOCKER_IMAGE=emscripten/emsdk:3.1.65 EMCC_SRC=../../scripts/emcc.sh EMCC=EMSDK_VERSION=$(EMSDK_VERSION) EMSDK_DOCKER_IMAGE=$(EMSDK_DOCKER_IMAGE) EMSDK_PROJECT_ROOT=$(REPO_ROOT) EMSDK_DOCKER_CACHE=$(REPO_ROOT)/emsdk-cache/$(EMSDK_VERSION) $(EMCC_SRC) GENERATE_TS=$(GENERATE_TS_ENV) ../../scripts/generate.ts @@ -38,7 +38,6 @@ EMCC_EXPORTED_FUNCS+=-s EXPORTED_FUNCTIONS=@$(BUILD_WRAPPER)/symbols.json EMCC_EXPORTED_FUNCS_ASYNCIFY+=-s EXPORTED_FUNCTIONS=@$(BUILD_WRAPPER)/symbols.asyncify.json # Emscripten options -CFLAGS_WASM+=-s WASM=1 CFLAGS_WASM+=-s EXPORTED_RUNTIME_METHODS=@../../exportedRuntimeMethods.json CFLAGS_WASM+=-s MODULARIZE=1 CFLAGS_WASM+=-s IMPORTED_MEMORY=1 # Allow passing WASM memory to Emscripten diff --git a/packages/variant-quickjs-singlefile-browser-release-asyncify/package.json b/packages/variant-quickjs-singlefile-browser-release-asyncify/package.json index 909b3359..d85ff42f 100644 --- a/packages/variant-quickjs-singlefile-browser-release-asyncify/package.json +++ b/packages/variant-quickjs-singlefile-browser-release-asyncify/package.json @@ -1,7 +1,7 @@ { "name": "@jitl/quickjs-singlefile-browser-release-asyncify", "license": "MIT", - "version": "0.30.0", + "version": "0.31.0", "description": "Variant of quickjs library: Variant with the WASM data embedded into a browser ESModule.", "sideEffects": false, "repository": { @@ -38,14 +38,15 @@ }, "./package.json": "./package.json", "./ffi": { - "types": "./dist/ffi.d.ts", + "types": "./dist/ffi.d.mts", "import": "./dist/ffi.mjs", "default": "./dist/ffi.mjs" }, "./emscripten-module": { "types": "./dist/emscripten-module.browser.d.ts", "browser": "./dist/emscripten-module.browser.mjs", - "import": "./dist/emscripten-module.browser.mjs" + "import": "./dist/emscripten-module.browser.mjs", + "default": "./dist/emscripten-module.browser.mjs" } }, "dependencies": { diff --git a/packages/variant-quickjs-singlefile-browser-release-asyncify/tsup.config.ts b/packages/variant-quickjs-singlefile-browser-release-asyncify/tsup.config.ts index 1aee367f..fbd0f507 100644 --- a/packages/variant-quickjs-singlefile-browser-release-asyncify/tsup.config.ts +++ b/packages/variant-quickjs-singlefile-browser-release-asyncify/tsup.config.ts @@ -1,8 +1,7 @@ import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" - export default extendConfig({ entry: ["src/index.ts", "src/ffi.ts"], - external: ["@jitl/quickjs-singlefile-browser-release-asyncify/emscripten-module"], - formats: ["esm"], + external: [], + format: ["esm"], clean: false, }) diff --git a/packages/variant-quickjs-singlefile-browser-release-sync/Makefile b/packages/variant-quickjs-singlefile-browser-release-sync/Makefile index 66f97d57..1b881b01 100644 --- a/packages/variant-quickjs-singlefile-browser-release-sync/Makefile +++ b/packages/variant-quickjs-singlefile-browser-release-sync/Makefile @@ -1,6 +1,6 @@ # Tools -EMSDK_VERSION=3.1.64 -EMSDK_DOCKER_IMAGE=emscripten/emsdk:3.1.64 +EMSDK_VERSION=3.1.65 +EMSDK_DOCKER_IMAGE=emscripten/emsdk:3.1.65 EMCC_SRC=../../scripts/emcc.sh EMCC=EMSDK_VERSION=$(EMSDK_VERSION) EMSDK_DOCKER_IMAGE=$(EMSDK_DOCKER_IMAGE) EMSDK_PROJECT_ROOT=$(REPO_ROOT) EMSDK_DOCKER_CACHE=$(REPO_ROOT)/emsdk-cache/$(EMSDK_VERSION) $(EMCC_SRC) GENERATE_TS=$(GENERATE_TS_ENV) ../../scripts/generate.ts @@ -38,7 +38,6 @@ EMCC_EXPORTED_FUNCS+=-s EXPORTED_FUNCTIONS=@$(BUILD_WRAPPER)/symbols.json EMCC_EXPORTED_FUNCS_ASYNCIFY+=-s EXPORTED_FUNCTIONS=@$(BUILD_WRAPPER)/symbols.asyncify.json # Emscripten options -CFLAGS_WASM+=-s WASM=1 CFLAGS_WASM+=-s EXPORTED_RUNTIME_METHODS=@../../exportedRuntimeMethods.json CFLAGS_WASM+=-s MODULARIZE=1 CFLAGS_WASM+=-s IMPORTED_MEMORY=1 # Allow passing WASM memory to Emscripten diff --git a/packages/variant-quickjs-singlefile-browser-release-sync/package.json b/packages/variant-quickjs-singlefile-browser-release-sync/package.json index 945b0bd4..1f307870 100644 --- a/packages/variant-quickjs-singlefile-browser-release-sync/package.json +++ b/packages/variant-quickjs-singlefile-browser-release-sync/package.json @@ -1,7 +1,7 @@ { "name": "@jitl/quickjs-singlefile-browser-release-sync", "license": "MIT", - "version": "0.30.0", + "version": "0.31.0", "description": "Variant of quickjs library: Variant with the WASM data embedded into a browser ESModule.", "sideEffects": false, "repository": { @@ -38,14 +38,15 @@ }, "./package.json": "./package.json", "./ffi": { - "types": "./dist/ffi.d.ts", + "types": "./dist/ffi.d.mts", "import": "./dist/ffi.mjs", "default": "./dist/ffi.mjs" }, "./emscripten-module": { "types": "./dist/emscripten-module.browser.d.ts", "browser": "./dist/emscripten-module.browser.mjs", - "import": "./dist/emscripten-module.browser.mjs" + "import": "./dist/emscripten-module.browser.mjs", + "default": "./dist/emscripten-module.browser.mjs" } }, "dependencies": { diff --git a/packages/variant-quickjs-singlefile-browser-release-sync/tsup.config.ts b/packages/variant-quickjs-singlefile-browser-release-sync/tsup.config.ts index 604b63ee..fbd0f507 100644 --- a/packages/variant-quickjs-singlefile-browser-release-sync/tsup.config.ts +++ b/packages/variant-quickjs-singlefile-browser-release-sync/tsup.config.ts @@ -1,8 +1,7 @@ import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" - export default extendConfig({ entry: ["src/index.ts", "src/ffi.ts"], - external: ["@jitl/quickjs-singlefile-browser-release-sync/emscripten-module"], - formats: ["esm"], + external: [], + format: ["esm"], clean: false, }) diff --git a/packages/variant-quickjs-singlefile-cjs-debug-asyncify/Makefile b/packages/variant-quickjs-singlefile-cjs-debug-asyncify/Makefile index 4fd5522f..e9f520c1 100644 --- a/packages/variant-quickjs-singlefile-cjs-debug-asyncify/Makefile +++ b/packages/variant-quickjs-singlefile-cjs-debug-asyncify/Makefile @@ -1,6 +1,6 @@ # Tools -EMSDK_VERSION=3.1.64 -EMSDK_DOCKER_IMAGE=emscripten/emsdk:3.1.64 +EMSDK_VERSION=3.1.65 +EMSDK_DOCKER_IMAGE=emscripten/emsdk:3.1.65 EMCC_SRC=../../scripts/emcc.sh EMCC=EMSDK_VERSION=$(EMSDK_VERSION) EMSDK_DOCKER_IMAGE=$(EMSDK_DOCKER_IMAGE) EMSDK_PROJECT_ROOT=$(REPO_ROOT) EMSDK_DOCKER_CACHE=$(REPO_ROOT)/emsdk-cache/$(EMSDK_VERSION) $(EMCC_SRC) GENERATE_TS=$(GENERATE_TS_ENV) ../../scripts/generate.ts @@ -38,7 +38,6 @@ EMCC_EXPORTED_FUNCS+=-s EXPORTED_FUNCTIONS=@$(BUILD_WRAPPER)/symbols.json EMCC_EXPORTED_FUNCS_ASYNCIFY+=-s EXPORTED_FUNCTIONS=@$(BUILD_WRAPPER)/symbols.asyncify.json # Emscripten options -CFLAGS_WASM+=-s WASM=1 CFLAGS_WASM+=-s EXPORTED_RUNTIME_METHODS=@../../exportedRuntimeMethods.json CFLAGS_WASM+=-s MODULARIZE=1 CFLAGS_WASM+=-s IMPORTED_MEMORY=1 # Allow passing WASM memory to Emscripten diff --git a/packages/variant-quickjs-singlefile-cjs-debug-asyncify/package.json b/packages/variant-quickjs-singlefile-cjs-debug-asyncify/package.json index d7eac754..08566d6d 100644 --- a/packages/variant-quickjs-singlefile-cjs-debug-asyncify/package.json +++ b/packages/variant-quickjs-singlefile-cjs-debug-asyncify/package.json @@ -1,7 +1,7 @@ { "name": "@jitl/quickjs-singlefile-cjs-debug-asyncify", "license": "MIT", - "version": "0.30.0", + "version": "0.31.0", "description": "Variant of quickjs library: Variant with the WASM data embedded into a universal (Node and Browser compatible) CommonJS module.", "sideEffects": false, "repository": { diff --git a/packages/variant-quickjs-singlefile-cjs-debug-asyncify/tsup.config.ts b/packages/variant-quickjs-singlefile-cjs-debug-asyncify/tsup.config.ts index 1ae4be23..1e0a2f62 100644 --- a/packages/variant-quickjs-singlefile-cjs-debug-asyncify/tsup.config.ts +++ b/packages/variant-quickjs-singlefile-cjs-debug-asyncify/tsup.config.ts @@ -1,8 +1,7 @@ import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" - export default extendConfig({ entry: ["src/index.ts", "src/ffi.ts"], - external: ["@jitl/quickjs-singlefile-cjs-debug-asyncify/emscripten-module"], - formats: ["cjs"], + external: [], + format: ["cjs"], clean: false, }) diff --git a/packages/variant-quickjs-singlefile-cjs-debug-sync/Makefile b/packages/variant-quickjs-singlefile-cjs-debug-sync/Makefile index 2d3fd16e..1f65e61b 100644 --- a/packages/variant-quickjs-singlefile-cjs-debug-sync/Makefile +++ b/packages/variant-quickjs-singlefile-cjs-debug-sync/Makefile @@ -1,6 +1,6 @@ # Tools -EMSDK_VERSION=3.1.64 -EMSDK_DOCKER_IMAGE=emscripten/emsdk:3.1.64 +EMSDK_VERSION=3.1.65 +EMSDK_DOCKER_IMAGE=emscripten/emsdk:3.1.65 EMCC_SRC=../../scripts/emcc.sh EMCC=EMSDK_VERSION=$(EMSDK_VERSION) EMSDK_DOCKER_IMAGE=$(EMSDK_DOCKER_IMAGE) EMSDK_PROJECT_ROOT=$(REPO_ROOT) EMSDK_DOCKER_CACHE=$(REPO_ROOT)/emsdk-cache/$(EMSDK_VERSION) $(EMCC_SRC) GENERATE_TS=$(GENERATE_TS_ENV) ../../scripts/generate.ts @@ -38,7 +38,6 @@ EMCC_EXPORTED_FUNCS+=-s EXPORTED_FUNCTIONS=@$(BUILD_WRAPPER)/symbols.json EMCC_EXPORTED_FUNCS_ASYNCIFY+=-s EXPORTED_FUNCTIONS=@$(BUILD_WRAPPER)/symbols.asyncify.json # Emscripten options -CFLAGS_WASM+=-s WASM=1 CFLAGS_WASM+=-s EXPORTED_RUNTIME_METHODS=@../../exportedRuntimeMethods.json CFLAGS_WASM+=-s MODULARIZE=1 CFLAGS_WASM+=-s IMPORTED_MEMORY=1 # Allow passing WASM memory to Emscripten diff --git a/packages/variant-quickjs-singlefile-cjs-debug-sync/package.json b/packages/variant-quickjs-singlefile-cjs-debug-sync/package.json index 8e70b579..76e50399 100644 --- a/packages/variant-quickjs-singlefile-cjs-debug-sync/package.json +++ b/packages/variant-quickjs-singlefile-cjs-debug-sync/package.json @@ -1,7 +1,7 @@ { "name": "@jitl/quickjs-singlefile-cjs-debug-sync", "license": "MIT", - "version": "0.30.0", + "version": "0.31.0", "description": "Variant of quickjs library: Variant with the WASM data embedded into a universal (Node and Browser compatible) CommonJS module.", "sideEffects": false, "repository": { diff --git a/packages/variant-quickjs-singlefile-cjs-debug-sync/tsup.config.ts b/packages/variant-quickjs-singlefile-cjs-debug-sync/tsup.config.ts index 557d0270..1e0a2f62 100644 --- a/packages/variant-quickjs-singlefile-cjs-debug-sync/tsup.config.ts +++ b/packages/variant-quickjs-singlefile-cjs-debug-sync/tsup.config.ts @@ -1,8 +1,7 @@ import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" - export default extendConfig({ entry: ["src/index.ts", "src/ffi.ts"], - external: ["@jitl/quickjs-singlefile-cjs-debug-sync/emscripten-module"], - formats: ["cjs"], + external: [], + format: ["cjs"], clean: false, }) diff --git a/packages/variant-quickjs-singlefile-cjs-release-asyncify/Makefile b/packages/variant-quickjs-singlefile-cjs-release-asyncify/Makefile index b2c3f5e4..a9566b72 100644 --- a/packages/variant-quickjs-singlefile-cjs-release-asyncify/Makefile +++ b/packages/variant-quickjs-singlefile-cjs-release-asyncify/Makefile @@ -1,6 +1,6 @@ # Tools -EMSDK_VERSION=3.1.64 -EMSDK_DOCKER_IMAGE=emscripten/emsdk:3.1.64 +EMSDK_VERSION=3.1.65 +EMSDK_DOCKER_IMAGE=emscripten/emsdk:3.1.65 EMCC_SRC=../../scripts/emcc.sh EMCC=EMSDK_VERSION=$(EMSDK_VERSION) EMSDK_DOCKER_IMAGE=$(EMSDK_DOCKER_IMAGE) EMSDK_PROJECT_ROOT=$(REPO_ROOT) EMSDK_DOCKER_CACHE=$(REPO_ROOT)/emsdk-cache/$(EMSDK_VERSION) $(EMCC_SRC) GENERATE_TS=$(GENERATE_TS_ENV) ../../scripts/generate.ts @@ -38,7 +38,6 @@ EMCC_EXPORTED_FUNCS+=-s EXPORTED_FUNCTIONS=@$(BUILD_WRAPPER)/symbols.json EMCC_EXPORTED_FUNCS_ASYNCIFY+=-s EXPORTED_FUNCTIONS=@$(BUILD_WRAPPER)/symbols.asyncify.json # Emscripten options -CFLAGS_WASM+=-s WASM=1 CFLAGS_WASM+=-s EXPORTED_RUNTIME_METHODS=@../../exportedRuntimeMethods.json CFLAGS_WASM+=-s MODULARIZE=1 CFLAGS_WASM+=-s IMPORTED_MEMORY=1 # Allow passing WASM memory to Emscripten diff --git a/packages/variant-quickjs-singlefile-cjs-release-asyncify/package.json b/packages/variant-quickjs-singlefile-cjs-release-asyncify/package.json index 3f37cece..59d3211f 100644 --- a/packages/variant-quickjs-singlefile-cjs-release-asyncify/package.json +++ b/packages/variant-quickjs-singlefile-cjs-release-asyncify/package.json @@ -1,7 +1,7 @@ { "name": "@jitl/quickjs-singlefile-cjs-release-asyncify", "license": "MIT", - "version": "0.30.0", + "version": "0.31.0", "description": "Variant of quickjs library: Variant with the WASM data embedded into a universal (Node and Browser compatible) CommonJS module.", "sideEffects": false, "repository": { diff --git a/packages/variant-quickjs-singlefile-cjs-release-asyncify/tsup.config.ts b/packages/variant-quickjs-singlefile-cjs-release-asyncify/tsup.config.ts index ecb57989..1e0a2f62 100644 --- a/packages/variant-quickjs-singlefile-cjs-release-asyncify/tsup.config.ts +++ b/packages/variant-quickjs-singlefile-cjs-release-asyncify/tsup.config.ts @@ -1,8 +1,7 @@ import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" - export default extendConfig({ entry: ["src/index.ts", "src/ffi.ts"], - external: ["@jitl/quickjs-singlefile-cjs-release-asyncify/emscripten-module"], - formats: ["cjs"], + external: [], + format: ["cjs"], clean: false, }) diff --git a/packages/variant-quickjs-singlefile-cjs-release-sync/Makefile b/packages/variant-quickjs-singlefile-cjs-release-sync/Makefile index c29d2205..29392d85 100644 --- a/packages/variant-quickjs-singlefile-cjs-release-sync/Makefile +++ b/packages/variant-quickjs-singlefile-cjs-release-sync/Makefile @@ -1,6 +1,6 @@ # Tools -EMSDK_VERSION=3.1.64 -EMSDK_DOCKER_IMAGE=emscripten/emsdk:3.1.64 +EMSDK_VERSION=3.1.65 +EMSDK_DOCKER_IMAGE=emscripten/emsdk:3.1.65 EMCC_SRC=../../scripts/emcc.sh EMCC=EMSDK_VERSION=$(EMSDK_VERSION) EMSDK_DOCKER_IMAGE=$(EMSDK_DOCKER_IMAGE) EMSDK_PROJECT_ROOT=$(REPO_ROOT) EMSDK_DOCKER_CACHE=$(REPO_ROOT)/emsdk-cache/$(EMSDK_VERSION) $(EMCC_SRC) GENERATE_TS=$(GENERATE_TS_ENV) ../../scripts/generate.ts @@ -38,7 +38,6 @@ EMCC_EXPORTED_FUNCS+=-s EXPORTED_FUNCTIONS=@$(BUILD_WRAPPER)/symbols.json EMCC_EXPORTED_FUNCS_ASYNCIFY+=-s EXPORTED_FUNCTIONS=@$(BUILD_WRAPPER)/symbols.asyncify.json # Emscripten options -CFLAGS_WASM+=-s WASM=1 CFLAGS_WASM+=-s EXPORTED_RUNTIME_METHODS=@../../exportedRuntimeMethods.json CFLAGS_WASM+=-s MODULARIZE=1 CFLAGS_WASM+=-s IMPORTED_MEMORY=1 # Allow passing WASM memory to Emscripten diff --git a/packages/variant-quickjs-singlefile-cjs-release-sync/package.json b/packages/variant-quickjs-singlefile-cjs-release-sync/package.json index 7b93a7b5..4a16a753 100644 --- a/packages/variant-quickjs-singlefile-cjs-release-sync/package.json +++ b/packages/variant-quickjs-singlefile-cjs-release-sync/package.json @@ -1,7 +1,7 @@ { "name": "@jitl/quickjs-singlefile-cjs-release-sync", "license": "MIT", - "version": "0.30.0", + "version": "0.31.0", "description": "Variant of quickjs library: Variant with the WASM data embedded into a universal (Node and Browser compatible) CommonJS module.", "sideEffects": false, "repository": { diff --git a/packages/variant-quickjs-singlefile-cjs-release-sync/tsup.config.ts b/packages/variant-quickjs-singlefile-cjs-release-sync/tsup.config.ts index c6a76e67..1e0a2f62 100644 --- a/packages/variant-quickjs-singlefile-cjs-release-sync/tsup.config.ts +++ b/packages/variant-quickjs-singlefile-cjs-release-sync/tsup.config.ts @@ -1,8 +1,7 @@ import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" - export default extendConfig({ entry: ["src/index.ts", "src/ffi.ts"], - external: ["@jitl/quickjs-singlefile-cjs-release-sync/emscripten-module"], - formats: ["cjs"], + external: [], + format: ["cjs"], clean: false, }) diff --git a/packages/variant-quickjs-singlefile-mjs-debug-asyncify/Makefile b/packages/variant-quickjs-singlefile-mjs-debug-asyncify/Makefile index 3137c992..9c0abf44 100644 --- a/packages/variant-quickjs-singlefile-mjs-debug-asyncify/Makefile +++ b/packages/variant-quickjs-singlefile-mjs-debug-asyncify/Makefile @@ -1,6 +1,6 @@ # Tools -EMSDK_VERSION=3.1.64 -EMSDK_DOCKER_IMAGE=emscripten/emsdk:3.1.64 +EMSDK_VERSION=3.1.65 +EMSDK_DOCKER_IMAGE=emscripten/emsdk:3.1.65 EMCC_SRC=../../scripts/emcc.sh EMCC=EMSDK_VERSION=$(EMSDK_VERSION) EMSDK_DOCKER_IMAGE=$(EMSDK_DOCKER_IMAGE) EMSDK_PROJECT_ROOT=$(REPO_ROOT) EMSDK_DOCKER_CACHE=$(REPO_ROOT)/emsdk-cache/$(EMSDK_VERSION) $(EMCC_SRC) GENERATE_TS=$(GENERATE_TS_ENV) ../../scripts/generate.ts @@ -38,7 +38,6 @@ EMCC_EXPORTED_FUNCS+=-s EXPORTED_FUNCTIONS=@$(BUILD_WRAPPER)/symbols.json EMCC_EXPORTED_FUNCS_ASYNCIFY+=-s EXPORTED_FUNCTIONS=@$(BUILD_WRAPPER)/symbols.asyncify.json # Emscripten options -CFLAGS_WASM+=-s WASM=1 CFLAGS_WASM+=-s EXPORTED_RUNTIME_METHODS=@../../exportedRuntimeMethods.json CFLAGS_WASM+=-s MODULARIZE=1 CFLAGS_WASM+=-s IMPORTED_MEMORY=1 # Allow passing WASM memory to Emscripten diff --git a/packages/variant-quickjs-singlefile-mjs-debug-asyncify/package.json b/packages/variant-quickjs-singlefile-mjs-debug-asyncify/package.json index dd71b0c5..9b8b0ab1 100644 --- a/packages/variant-quickjs-singlefile-mjs-debug-asyncify/package.json +++ b/packages/variant-quickjs-singlefile-mjs-debug-asyncify/package.json @@ -1,7 +1,7 @@ { "name": "@jitl/quickjs-singlefile-mjs-debug-asyncify", "license": "MIT", - "version": "0.30.0", + "version": "0.31.0", "description": "Variant of quickjs library: Variant with the WASM data embedded into a NodeJS ESModule.", "sideEffects": false, "repository": { @@ -37,13 +37,14 @@ }, "./package.json": "./package.json", "./ffi": { - "types": "./dist/ffi.d.ts", + "types": "./dist/ffi.d.mts", "import": "./dist/ffi.mjs", "default": "./dist/ffi.mjs" }, "./emscripten-module": { "types": "./dist/emscripten-module.d.ts", - "import": "./dist/emscripten-module.mjs" + "import": "./dist/emscripten-module.mjs", + "default": "./dist/emscripten-module.mjs" } }, "dependencies": { diff --git a/packages/variant-quickjs-singlefile-mjs-debug-asyncify/tsup.config.ts b/packages/variant-quickjs-singlefile-mjs-debug-asyncify/tsup.config.ts index 6a96f502..fbd0f507 100644 --- a/packages/variant-quickjs-singlefile-mjs-debug-asyncify/tsup.config.ts +++ b/packages/variant-quickjs-singlefile-mjs-debug-asyncify/tsup.config.ts @@ -1,8 +1,7 @@ import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" - export default extendConfig({ entry: ["src/index.ts", "src/ffi.ts"], - external: ["@jitl/quickjs-singlefile-mjs-debug-asyncify/emscripten-module"], - formats: ["esm"], + external: [], + format: ["esm"], clean: false, }) diff --git a/packages/variant-quickjs-singlefile-mjs-debug-sync/Makefile b/packages/variant-quickjs-singlefile-mjs-debug-sync/Makefile index f3fb14a2..855979a5 100644 --- a/packages/variant-quickjs-singlefile-mjs-debug-sync/Makefile +++ b/packages/variant-quickjs-singlefile-mjs-debug-sync/Makefile @@ -1,6 +1,6 @@ # Tools -EMSDK_VERSION=3.1.64 -EMSDK_DOCKER_IMAGE=emscripten/emsdk:3.1.64 +EMSDK_VERSION=3.1.65 +EMSDK_DOCKER_IMAGE=emscripten/emsdk:3.1.65 EMCC_SRC=../../scripts/emcc.sh EMCC=EMSDK_VERSION=$(EMSDK_VERSION) EMSDK_DOCKER_IMAGE=$(EMSDK_DOCKER_IMAGE) EMSDK_PROJECT_ROOT=$(REPO_ROOT) EMSDK_DOCKER_CACHE=$(REPO_ROOT)/emsdk-cache/$(EMSDK_VERSION) $(EMCC_SRC) GENERATE_TS=$(GENERATE_TS_ENV) ../../scripts/generate.ts @@ -38,7 +38,6 @@ EMCC_EXPORTED_FUNCS+=-s EXPORTED_FUNCTIONS=@$(BUILD_WRAPPER)/symbols.json EMCC_EXPORTED_FUNCS_ASYNCIFY+=-s EXPORTED_FUNCTIONS=@$(BUILD_WRAPPER)/symbols.asyncify.json # Emscripten options -CFLAGS_WASM+=-s WASM=1 CFLAGS_WASM+=-s EXPORTED_RUNTIME_METHODS=@../../exportedRuntimeMethods.json CFLAGS_WASM+=-s MODULARIZE=1 CFLAGS_WASM+=-s IMPORTED_MEMORY=1 # Allow passing WASM memory to Emscripten diff --git a/packages/variant-quickjs-singlefile-mjs-debug-sync/package.json b/packages/variant-quickjs-singlefile-mjs-debug-sync/package.json index 4cf9837c..3fd03693 100644 --- a/packages/variant-quickjs-singlefile-mjs-debug-sync/package.json +++ b/packages/variant-quickjs-singlefile-mjs-debug-sync/package.json @@ -1,7 +1,7 @@ { "name": "@jitl/quickjs-singlefile-mjs-debug-sync", "license": "MIT", - "version": "0.30.0", + "version": "0.31.0", "description": "Variant of quickjs library: Variant with the WASM data embedded into a NodeJS ESModule.", "sideEffects": false, "repository": { @@ -37,13 +37,14 @@ }, "./package.json": "./package.json", "./ffi": { - "types": "./dist/ffi.d.ts", + "types": "./dist/ffi.d.mts", "import": "./dist/ffi.mjs", "default": "./dist/ffi.mjs" }, "./emscripten-module": { "types": "./dist/emscripten-module.d.ts", - "import": "./dist/emscripten-module.mjs" + "import": "./dist/emscripten-module.mjs", + "default": "./dist/emscripten-module.mjs" } }, "dependencies": { diff --git a/packages/variant-quickjs-singlefile-mjs-debug-sync/tsup.config.ts b/packages/variant-quickjs-singlefile-mjs-debug-sync/tsup.config.ts index 6a6d5598..fbd0f507 100644 --- a/packages/variant-quickjs-singlefile-mjs-debug-sync/tsup.config.ts +++ b/packages/variant-quickjs-singlefile-mjs-debug-sync/tsup.config.ts @@ -1,8 +1,7 @@ import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" - export default extendConfig({ entry: ["src/index.ts", "src/ffi.ts"], - external: ["@jitl/quickjs-singlefile-mjs-debug-sync/emscripten-module"], - formats: ["esm"], + external: [], + format: ["esm"], clean: false, }) diff --git a/packages/variant-quickjs-singlefile-mjs-release-asyncify/Makefile b/packages/variant-quickjs-singlefile-mjs-release-asyncify/Makefile index 7e6179a2..4e1b8a1a 100644 --- a/packages/variant-quickjs-singlefile-mjs-release-asyncify/Makefile +++ b/packages/variant-quickjs-singlefile-mjs-release-asyncify/Makefile @@ -1,6 +1,6 @@ # Tools -EMSDK_VERSION=3.1.64 -EMSDK_DOCKER_IMAGE=emscripten/emsdk:3.1.64 +EMSDK_VERSION=3.1.65 +EMSDK_DOCKER_IMAGE=emscripten/emsdk:3.1.65 EMCC_SRC=../../scripts/emcc.sh EMCC=EMSDK_VERSION=$(EMSDK_VERSION) EMSDK_DOCKER_IMAGE=$(EMSDK_DOCKER_IMAGE) EMSDK_PROJECT_ROOT=$(REPO_ROOT) EMSDK_DOCKER_CACHE=$(REPO_ROOT)/emsdk-cache/$(EMSDK_VERSION) $(EMCC_SRC) GENERATE_TS=$(GENERATE_TS_ENV) ../../scripts/generate.ts @@ -38,7 +38,6 @@ EMCC_EXPORTED_FUNCS+=-s EXPORTED_FUNCTIONS=@$(BUILD_WRAPPER)/symbols.json EMCC_EXPORTED_FUNCS_ASYNCIFY+=-s EXPORTED_FUNCTIONS=@$(BUILD_WRAPPER)/symbols.asyncify.json # Emscripten options -CFLAGS_WASM+=-s WASM=1 CFLAGS_WASM+=-s EXPORTED_RUNTIME_METHODS=@../../exportedRuntimeMethods.json CFLAGS_WASM+=-s MODULARIZE=1 CFLAGS_WASM+=-s IMPORTED_MEMORY=1 # Allow passing WASM memory to Emscripten diff --git a/packages/variant-quickjs-singlefile-mjs-release-asyncify/package.json b/packages/variant-quickjs-singlefile-mjs-release-asyncify/package.json index 4b4a1056..76c1bbe2 100644 --- a/packages/variant-quickjs-singlefile-mjs-release-asyncify/package.json +++ b/packages/variant-quickjs-singlefile-mjs-release-asyncify/package.json @@ -1,7 +1,7 @@ { "name": "@jitl/quickjs-singlefile-mjs-release-asyncify", "license": "MIT", - "version": "0.30.0", + "version": "0.31.0", "description": "Variant of quickjs library: Variant with the WASM data embedded into a NodeJS ESModule.", "sideEffects": false, "repository": { @@ -37,13 +37,14 @@ }, "./package.json": "./package.json", "./ffi": { - "types": "./dist/ffi.d.ts", + "types": "./dist/ffi.d.mts", "import": "./dist/ffi.mjs", "default": "./dist/ffi.mjs" }, "./emscripten-module": { "types": "./dist/emscripten-module.d.ts", - "import": "./dist/emscripten-module.mjs" + "import": "./dist/emscripten-module.mjs", + "default": "./dist/emscripten-module.mjs" } }, "dependencies": { diff --git a/packages/variant-quickjs-singlefile-mjs-release-asyncify/tsup.config.ts b/packages/variant-quickjs-singlefile-mjs-release-asyncify/tsup.config.ts index 7645627d..fbd0f507 100644 --- a/packages/variant-quickjs-singlefile-mjs-release-asyncify/tsup.config.ts +++ b/packages/variant-quickjs-singlefile-mjs-release-asyncify/tsup.config.ts @@ -1,8 +1,7 @@ import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" - export default extendConfig({ entry: ["src/index.ts", "src/ffi.ts"], - external: ["@jitl/quickjs-singlefile-mjs-release-asyncify/emscripten-module"], - formats: ["esm"], + external: [], + format: ["esm"], clean: false, }) diff --git a/packages/variant-quickjs-singlefile-mjs-release-sync/Makefile b/packages/variant-quickjs-singlefile-mjs-release-sync/Makefile index a7548983..dac0b9c3 100644 --- a/packages/variant-quickjs-singlefile-mjs-release-sync/Makefile +++ b/packages/variant-quickjs-singlefile-mjs-release-sync/Makefile @@ -1,6 +1,6 @@ # Tools -EMSDK_VERSION=3.1.64 -EMSDK_DOCKER_IMAGE=emscripten/emsdk:3.1.64 +EMSDK_VERSION=3.1.65 +EMSDK_DOCKER_IMAGE=emscripten/emsdk:3.1.65 EMCC_SRC=../../scripts/emcc.sh EMCC=EMSDK_VERSION=$(EMSDK_VERSION) EMSDK_DOCKER_IMAGE=$(EMSDK_DOCKER_IMAGE) EMSDK_PROJECT_ROOT=$(REPO_ROOT) EMSDK_DOCKER_CACHE=$(REPO_ROOT)/emsdk-cache/$(EMSDK_VERSION) $(EMCC_SRC) GENERATE_TS=$(GENERATE_TS_ENV) ../../scripts/generate.ts @@ -38,7 +38,6 @@ EMCC_EXPORTED_FUNCS+=-s EXPORTED_FUNCTIONS=@$(BUILD_WRAPPER)/symbols.json EMCC_EXPORTED_FUNCS_ASYNCIFY+=-s EXPORTED_FUNCTIONS=@$(BUILD_WRAPPER)/symbols.asyncify.json # Emscripten options -CFLAGS_WASM+=-s WASM=1 CFLAGS_WASM+=-s EXPORTED_RUNTIME_METHODS=@../../exportedRuntimeMethods.json CFLAGS_WASM+=-s MODULARIZE=1 CFLAGS_WASM+=-s IMPORTED_MEMORY=1 # Allow passing WASM memory to Emscripten diff --git a/packages/variant-quickjs-singlefile-mjs-release-sync/package.json b/packages/variant-quickjs-singlefile-mjs-release-sync/package.json index 98b56bdc..1f327fc6 100644 --- a/packages/variant-quickjs-singlefile-mjs-release-sync/package.json +++ b/packages/variant-quickjs-singlefile-mjs-release-sync/package.json @@ -1,7 +1,7 @@ { "name": "@jitl/quickjs-singlefile-mjs-release-sync", "license": "MIT", - "version": "0.30.0", + "version": "0.31.0", "description": "Variant of quickjs library: Variant with the WASM data embedded into a NodeJS ESModule.", "sideEffects": false, "repository": { @@ -37,13 +37,14 @@ }, "./package.json": "./package.json", "./ffi": { - "types": "./dist/ffi.d.ts", + "types": "./dist/ffi.d.mts", "import": "./dist/ffi.mjs", "default": "./dist/ffi.mjs" }, "./emscripten-module": { "types": "./dist/emscripten-module.d.ts", - "import": "./dist/emscripten-module.mjs" + "import": "./dist/emscripten-module.mjs", + "default": "./dist/emscripten-module.mjs" } }, "dependencies": { diff --git a/packages/variant-quickjs-singlefile-mjs-release-sync/tsup.config.ts b/packages/variant-quickjs-singlefile-mjs-release-sync/tsup.config.ts index 5de3be3b..fbd0f507 100644 --- a/packages/variant-quickjs-singlefile-mjs-release-sync/tsup.config.ts +++ b/packages/variant-quickjs-singlefile-mjs-release-sync/tsup.config.ts @@ -1,8 +1,7 @@ import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" - export default extendConfig({ entry: ["src/index.ts", "src/ffi.ts"], - external: ["@jitl/quickjs-singlefile-mjs-release-sync/emscripten-module"], - formats: ["esm"], + external: [], + format: ["esm"], clean: false, }) diff --git a/packages/variant-quickjs-wasmfile-debug-asyncify/Makefile b/packages/variant-quickjs-wasmfile-debug-asyncify/Makefile index 64ce94bb..f0f6d634 100644 --- a/packages/variant-quickjs-wasmfile-debug-asyncify/Makefile +++ b/packages/variant-quickjs-wasmfile-debug-asyncify/Makefile @@ -1,6 +1,6 @@ # Tools -EMSDK_VERSION=3.1.64 -EMSDK_DOCKER_IMAGE=emscripten/emsdk:3.1.64 +EMSDK_VERSION=3.1.65 +EMSDK_DOCKER_IMAGE=emscripten/emsdk:3.1.65 EMCC_SRC=../../scripts/emcc.sh EMCC=EMSDK_VERSION=$(EMSDK_VERSION) EMSDK_DOCKER_IMAGE=$(EMSDK_DOCKER_IMAGE) EMSDK_PROJECT_ROOT=$(REPO_ROOT) EMSDK_DOCKER_CACHE=$(REPO_ROOT)/emsdk-cache/$(EMSDK_VERSION) $(EMCC_SRC) GENERATE_TS=$(GENERATE_TS_ENV) ../../scripts/generate.ts @@ -38,7 +38,6 @@ EMCC_EXPORTED_FUNCS+=-s EXPORTED_FUNCTIONS=@$(BUILD_WRAPPER)/symbols.json EMCC_EXPORTED_FUNCS_ASYNCIFY+=-s EXPORTED_FUNCTIONS=@$(BUILD_WRAPPER)/symbols.asyncify.json # Emscripten options -CFLAGS_WASM+=-s WASM=1 CFLAGS_WASM+=-s EXPORTED_RUNTIME_METHODS=@../../exportedRuntimeMethods.json CFLAGS_WASM+=-s MODULARIZE=1 CFLAGS_WASM+=-s IMPORTED_MEMORY=1 # Allow passing WASM memory to Emscripten diff --git a/packages/variant-quickjs-wasmfile-debug-asyncify/package.json b/packages/variant-quickjs-wasmfile-debug-asyncify/package.json index 9f180418..640f63a2 100644 --- a/packages/variant-quickjs-wasmfile-debug-asyncify/package.json +++ b/packages/variant-quickjs-wasmfile-debug-asyncify/package.json @@ -1,7 +1,7 @@ { "name": "@jitl/quickjs-wasmfile-debug-asyncify", "license": "MIT", - "version": "0.30.0", + "version": "0.31.0", "description": "Variant of quickjs library: Variant with separate .WASM file. Supports browser ESM, NodeJS ESM, and NodeJS CommonJS.", "sideEffects": false, "repository": { diff --git a/packages/variant-quickjs-wasmfile-debug-asyncify/tsup.config.ts b/packages/variant-quickjs-wasmfile-debug-asyncify/tsup.config.ts index 20b4be35..be8403fb 100644 --- a/packages/variant-quickjs-wasmfile-debug-asyncify/tsup.config.ts +++ b/packages/variant-quickjs-wasmfile-debug-asyncify/tsup.config.ts @@ -1,8 +1,7 @@ import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" - export default extendConfig({ entry: ["src/index.ts", "src/ffi.ts"], external: ["@jitl/quickjs-wasmfile-debug-asyncify/emscripten-module"], - formats: ["esm", "cjs"], + format: ["esm", "cjs"], clean: false, }) diff --git a/packages/variant-quickjs-wasmfile-debug-sync/Makefile b/packages/variant-quickjs-wasmfile-debug-sync/Makefile index 1e379e0b..10075fa1 100644 --- a/packages/variant-quickjs-wasmfile-debug-sync/Makefile +++ b/packages/variant-quickjs-wasmfile-debug-sync/Makefile @@ -1,6 +1,6 @@ # Tools -EMSDK_VERSION=3.1.64 -EMSDK_DOCKER_IMAGE=emscripten/emsdk:3.1.64 +EMSDK_VERSION=3.1.65 +EMSDK_DOCKER_IMAGE=emscripten/emsdk:3.1.65 EMCC_SRC=../../scripts/emcc.sh EMCC=EMSDK_VERSION=$(EMSDK_VERSION) EMSDK_DOCKER_IMAGE=$(EMSDK_DOCKER_IMAGE) EMSDK_PROJECT_ROOT=$(REPO_ROOT) EMSDK_DOCKER_CACHE=$(REPO_ROOT)/emsdk-cache/$(EMSDK_VERSION) $(EMCC_SRC) GENERATE_TS=$(GENERATE_TS_ENV) ../../scripts/generate.ts @@ -38,7 +38,6 @@ EMCC_EXPORTED_FUNCS+=-s EXPORTED_FUNCTIONS=@$(BUILD_WRAPPER)/symbols.json EMCC_EXPORTED_FUNCS_ASYNCIFY+=-s EXPORTED_FUNCTIONS=@$(BUILD_WRAPPER)/symbols.asyncify.json # Emscripten options -CFLAGS_WASM+=-s WASM=1 CFLAGS_WASM+=-s EXPORTED_RUNTIME_METHODS=@../../exportedRuntimeMethods.json CFLAGS_WASM+=-s MODULARIZE=1 CFLAGS_WASM+=-s IMPORTED_MEMORY=1 # Allow passing WASM memory to Emscripten diff --git a/packages/variant-quickjs-wasmfile-debug-sync/package.json b/packages/variant-quickjs-wasmfile-debug-sync/package.json index d14559f1..aef52149 100644 --- a/packages/variant-quickjs-wasmfile-debug-sync/package.json +++ b/packages/variant-quickjs-wasmfile-debug-sync/package.json @@ -1,7 +1,7 @@ { "name": "@jitl/quickjs-wasmfile-debug-sync", "license": "MIT", - "version": "0.30.0", + "version": "0.31.0", "description": "Variant of quickjs library: Variant with separate .WASM file. Supports browser ESM, NodeJS ESM, and NodeJS CommonJS.", "sideEffects": false, "repository": { diff --git a/packages/variant-quickjs-wasmfile-debug-sync/tsup.config.ts b/packages/variant-quickjs-wasmfile-debug-sync/tsup.config.ts index 308bc138..89164775 100644 --- a/packages/variant-quickjs-wasmfile-debug-sync/tsup.config.ts +++ b/packages/variant-quickjs-wasmfile-debug-sync/tsup.config.ts @@ -1,8 +1,7 @@ import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" - export default extendConfig({ entry: ["src/index.ts", "src/ffi.ts"], external: ["@jitl/quickjs-wasmfile-debug-sync/emscripten-module"], - formats: ["esm", "cjs"], + format: ["esm", "cjs"], clean: false, }) diff --git a/packages/variant-quickjs-wasmfile-release-asyncify/Makefile b/packages/variant-quickjs-wasmfile-release-asyncify/Makefile index 809201bb..467cbe41 100644 --- a/packages/variant-quickjs-wasmfile-release-asyncify/Makefile +++ b/packages/variant-quickjs-wasmfile-release-asyncify/Makefile @@ -1,6 +1,6 @@ # Tools -EMSDK_VERSION=3.1.64 -EMSDK_DOCKER_IMAGE=emscripten/emsdk:3.1.64 +EMSDK_VERSION=3.1.65 +EMSDK_DOCKER_IMAGE=emscripten/emsdk:3.1.65 EMCC_SRC=../../scripts/emcc.sh EMCC=EMSDK_VERSION=$(EMSDK_VERSION) EMSDK_DOCKER_IMAGE=$(EMSDK_DOCKER_IMAGE) EMSDK_PROJECT_ROOT=$(REPO_ROOT) EMSDK_DOCKER_CACHE=$(REPO_ROOT)/emsdk-cache/$(EMSDK_VERSION) $(EMCC_SRC) GENERATE_TS=$(GENERATE_TS_ENV) ../../scripts/generate.ts @@ -38,7 +38,6 @@ EMCC_EXPORTED_FUNCS+=-s EXPORTED_FUNCTIONS=@$(BUILD_WRAPPER)/symbols.json EMCC_EXPORTED_FUNCS_ASYNCIFY+=-s EXPORTED_FUNCTIONS=@$(BUILD_WRAPPER)/symbols.asyncify.json # Emscripten options -CFLAGS_WASM+=-s WASM=1 CFLAGS_WASM+=-s EXPORTED_RUNTIME_METHODS=@../../exportedRuntimeMethods.json CFLAGS_WASM+=-s MODULARIZE=1 CFLAGS_WASM+=-s IMPORTED_MEMORY=1 # Allow passing WASM memory to Emscripten diff --git a/packages/variant-quickjs-wasmfile-release-asyncify/package.json b/packages/variant-quickjs-wasmfile-release-asyncify/package.json index 6f063e66..984722a1 100644 --- a/packages/variant-quickjs-wasmfile-release-asyncify/package.json +++ b/packages/variant-quickjs-wasmfile-release-asyncify/package.json @@ -1,7 +1,7 @@ { "name": "@jitl/quickjs-wasmfile-release-asyncify", "license": "MIT", - "version": "0.30.0", + "version": "0.31.0", "description": "Variant of quickjs library: Variant with separate .WASM file. Supports browser ESM, NodeJS ESM, and NodeJS CommonJS.", "sideEffects": false, "repository": { diff --git a/packages/variant-quickjs-wasmfile-release-asyncify/tsup.config.ts b/packages/variant-quickjs-wasmfile-release-asyncify/tsup.config.ts index 336b998c..b2b3fed9 100644 --- a/packages/variant-quickjs-wasmfile-release-asyncify/tsup.config.ts +++ b/packages/variant-quickjs-wasmfile-release-asyncify/tsup.config.ts @@ -1,8 +1,7 @@ import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" - export default extendConfig({ entry: ["src/index.ts", "src/ffi.ts"], external: ["@jitl/quickjs-wasmfile-release-asyncify/emscripten-module"], - formats: ["esm", "cjs"], + format: ["esm", "cjs"], clean: false, }) diff --git a/packages/variant-quickjs-wasmfile-release-sync/Makefile b/packages/variant-quickjs-wasmfile-release-sync/Makefile index 750e7b6c..8b19b6aa 100644 --- a/packages/variant-quickjs-wasmfile-release-sync/Makefile +++ b/packages/variant-quickjs-wasmfile-release-sync/Makefile @@ -1,6 +1,6 @@ # Tools -EMSDK_VERSION=3.1.64 -EMSDK_DOCKER_IMAGE=emscripten/emsdk:3.1.64 +EMSDK_VERSION=3.1.65 +EMSDK_DOCKER_IMAGE=emscripten/emsdk:3.1.65 EMCC_SRC=../../scripts/emcc.sh EMCC=EMSDK_VERSION=$(EMSDK_VERSION) EMSDK_DOCKER_IMAGE=$(EMSDK_DOCKER_IMAGE) EMSDK_PROJECT_ROOT=$(REPO_ROOT) EMSDK_DOCKER_CACHE=$(REPO_ROOT)/emsdk-cache/$(EMSDK_VERSION) $(EMCC_SRC) GENERATE_TS=$(GENERATE_TS_ENV) ../../scripts/generate.ts @@ -38,7 +38,6 @@ EMCC_EXPORTED_FUNCS+=-s EXPORTED_FUNCTIONS=@$(BUILD_WRAPPER)/symbols.json EMCC_EXPORTED_FUNCS_ASYNCIFY+=-s EXPORTED_FUNCTIONS=@$(BUILD_WRAPPER)/symbols.asyncify.json # Emscripten options -CFLAGS_WASM+=-s WASM=1 CFLAGS_WASM+=-s EXPORTED_RUNTIME_METHODS=@../../exportedRuntimeMethods.json CFLAGS_WASM+=-s MODULARIZE=1 CFLAGS_WASM+=-s IMPORTED_MEMORY=1 # Allow passing WASM memory to Emscripten diff --git a/packages/variant-quickjs-wasmfile-release-sync/package.json b/packages/variant-quickjs-wasmfile-release-sync/package.json index d0773477..402f798b 100644 --- a/packages/variant-quickjs-wasmfile-release-sync/package.json +++ b/packages/variant-quickjs-wasmfile-release-sync/package.json @@ -1,7 +1,7 @@ { "name": "@jitl/quickjs-wasmfile-release-sync", "license": "MIT", - "version": "0.30.0", + "version": "0.31.0", "description": "Variant of quickjs library: Variant with separate .WASM file. Supports browser ESM, NodeJS ESM, and NodeJS CommonJS.", "sideEffects": false, "repository": { diff --git a/packages/variant-quickjs-wasmfile-release-sync/tsup.config.ts b/packages/variant-quickjs-wasmfile-release-sync/tsup.config.ts index 09592773..c6b1441d 100644 --- a/packages/variant-quickjs-wasmfile-release-sync/tsup.config.ts +++ b/packages/variant-quickjs-wasmfile-release-sync/tsup.config.ts @@ -1,8 +1,7 @@ import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" - export default extendConfig({ entry: ["src/index.ts", "src/ffi.ts"], external: ["@jitl/quickjs-wasmfile-release-sync/emscripten-module"], - formats: ["esm", "cjs"], + format: ["esm", "cjs"], clean: false, }) diff --git a/scripts/prepareVariants.ts b/scripts/prepareVariants.ts index 7c683b4d..f29040b1 100755 --- a/scripts/prepareVariants.ts +++ b/scripts/prepareVariants.ts @@ -34,6 +34,7 @@ enum CLibrary { enum EmscriptenInclusion { SingleFile = "singlefile", Separate = "wasm", + AsmJs = "asmjs", } // https://github.com/emscripten-core/emscripten/blob/7bed0e2477000603c26766897e1f455c08bc3358/src/settings.js#L647 @@ -124,6 +125,22 @@ const targets = { browser: SEPARATE_FILE_INCLUSION.browser, }, }), + "asmjs-mjs": makeTarget({ + description: `Compiled to pure Javascript, no WebAssembly required.`, + emscriptenInclusion: EmscriptenInclusion.AsmJs, + releaseMode: ReleaseMode.Release, + syncMode: SyncMode.Sync, + library: CLibrary.QuickJS, + exports: { + import: { + emscriptenEnvironment: [ + EmscriptenEnvironment.web, + EmscriptenEnvironment.worker, + EmscriptenEnvironment.node, + ], + }, + }, + }), } type TargetSpec = Partial & @@ -205,6 +222,7 @@ const ReleaseModeFlags = { const EmscriptenInclusionFlags = { [EmscriptenInclusion.Separate]: [], [EmscriptenInclusion.SingleFile]: [`-s SINGLE_FILE=1`], + [EmscriptenInclusion.AsmJs]: [`-s WASM=0`, `-s SINGLE_FILE=1`], } function getCflags(targetName: string, variant: BuildVariant) { @@ -283,7 +301,6 @@ interface FinalVariant { dir: string packageJson: PackageJson variant: BuildVariant - indexJs: string } async function main() { @@ -348,6 +365,32 @@ async function main() { main: js ? "./dist/index.js" : "./dist/index.mjs", module: mjs ? "./dist/index.mjs" : undefined, } + const ffiExports = { + types: js ? "./dist/ffi.d.ts" : "./dist/ffi.d.mts", + import: mjs ? "./dist/ffi.mjs" : "./dist/ffi.js", + require: js ? "./dist/ffi.js" : undefined, + default: js ? "./dist/ffi.js" : "./dist/ffi.mjs", + } + const emscriptenExports = { + types: variant.exports.browser + ? "./dist/emscripten-module.browser.d.ts" + : "./dist/emscripten-module.d.ts", + iife: variant.exports.require ? "./dist/emscripten-module.cjs" : undefined, + workerd: variant.exports.workerd ? "./dist/emscripten-module.cloudflare.cjs" : undefined, + browser: variant.exports.browser ? "./dist/emscripten-module.browser.mjs" : undefined, + import: variant.exports.import + ? "./dist/emscripten-module.mjs" + : variant.exports.browser + ? "./dist/emscripten-module.browser.mjs" + : "./dist/emscripten-module.cjs", + require: variant.exports.require ? "./dist/emscripten-module.cjs" : undefined, + default: variant.exports.require ? "./dist/emscripten-module.cjs" : undefined, + } + emscriptenExports.default = + emscriptenExports.default ?? + emscriptenExports.require ?? + emscriptenExports.import ?? + emscriptenExports.browser const packageJson: PackageJson = { name: `@jitl/${basename}`, @@ -384,33 +427,13 @@ async function main() { default: indexExports.main, }, "./package.json": "./package.json", - "./ffi": { - types: "./dist/ffi.d.ts", - import: mjs ? "./dist/ffi.mjs" : "./dist/ffi.js", - require: js ? "./dist/ffi.js" : undefined, - default: js ? "./dist/ffi.js" : "./dist/ffi.mjs", - }, + "./ffi": + variant.emscriptenInclusion !== EmscriptenInclusion.AsmJs ? ffiExports : undefined, "./wasm": variant.emscriptenInclusion === EmscriptenInclusion.Separate ? "./dist/emscripten-module.wasm" : undefined, - "./emscripten-module": { - types: variant.exports.browser - ? "./dist/emscripten-module.browser.d.ts" - : "./dist/emscripten-module.d.ts", - iife: variant.exports.require ? "./dist/emscripten-module.cjs" : undefined, - workerd: variant.exports.workerd - ? "./dist/emscripten-module.cloudflare.cjs" - : undefined, - browser: variant.exports.browser ? "./dist/emscripten-module.browser.mjs" : undefined, - import: variant.exports.import - ? "./dist/emscripten-module.mjs" - : variant.exports.browser - ? "./dist/emscripten-module.browser.mjs" - : "./dist/emscripten-module.cjs", - require: variant.exports.require ? "./dist/emscripten-module.cjs" : undefined, - default: variant.exports.require ? "./dist/emscripten-module.cjs" : undefined, - }, + "./emscripten-module": emscriptenExports, }, dependencies: { "@jitl/quickjs-ffi-types": "workspace:*", @@ -434,14 +457,19 @@ async function main() { targetName, dir: path.relative(repoRoot, dir), packageJson, - indexJs: path.relative(repoRoot, path.join(dist, "index.js")), variant, } if (finalVariant.dir in variantsJson) { throw new Error(`Duplicate variant dir ${finalVariant.dir}`) } - variantsJson[finalVariant.dir] = finalVariant + variantsJson[finalVariant.dir] = { + ...finalVariant, + packageJson: { + ...finalVariant.packageJson, + version: "(omitted)", + }, + } await writePretty(path.join(dir, "package.json"), JSON.stringify(packageJson)) await writePretty(path.join(dir, "LICENSE"), renderLicense(targetName, variant)) @@ -470,6 +498,7 @@ async function main() { const describeInclusion = { [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.`, [EmscriptenInclusion.Separate]: `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.`, + [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.`, } const describeMode = { @@ -728,6 +757,24 @@ function renderIndexTs( [SyncMode.Asyncify]: "QuickJSAsyncVariant", }[variant.syncMode] + if (variant.emscriptenInclusion === EmscriptenInclusion.AsmJs) { + // Eager loading please! + return ` +import type { ${variantTypeName} } from '@jitl/quickjs-ffi-types' +import moduleLoader from '${packageJson.name}/emscripten-module' +import { ${className} } from './ffi.js' +/** +${docComment} + */ +const variant: ${variantTypeName} = { + type: '${modeName}', + importFFI: () => Promise.resolve(${className}), + importModuleLoader: () => Promise.resolve(moduleLoader), +} as const +export default variant +` + } + return ` import type { ${variantTypeName} } from '@jitl/quickjs-ffi-types' @@ -769,16 +816,26 @@ function getTsupExtensions(variant: BuildVariant) { function renderTsupConfig(variant: BuildVariant, packageJson: PackageJson): string { const { js, mjs } = getTsupExtensions(variant) + const external: string[] = [] + const needsExternal = + [variant.exports.browser, variant.exports.import, variant.exports.require].filter(Boolean) + .length > 1 + if (needsExternal) { + external.push(`${packageJson.name}/emscripten-module`) + } + + const entry = ["src/index.ts"] + if (variant.emscriptenInclusion !== EmscriptenInclusion.AsmJs) { + entry.push("src/ffi.ts") + } + const formats = [mjs && "esm", js && "cjs"].filter(Boolean) return ` import { extendConfig } from "@jitl/tsconfig/tsup.base.config.js" - export default extendConfig({ - entry: ["src/index.ts", "src/ffi.ts"], - external: [ - "${packageJson.name}/emscripten-module", - ], - formats: ${JSON.stringify(formats)}, + entry: ${JSON.stringify(entry)}, + external: ${JSON.stringify(external)}, + format: ${JSON.stringify(formats)}, clean: false, }) ` diff --git a/templates/Variant.mk b/templates/Variant.mk index 2bfcf7e2..fd4711d3 100644 --- a/templates/Variant.mk +++ b/templates/Variant.mk @@ -1,6 +1,6 @@ # Tools -EMSDK_VERSION=3.1.64 -EMSDK_DOCKER_IMAGE=emscripten/emsdk:3.1.64 +EMSDK_VERSION=3.1.65 +EMSDK_DOCKER_IMAGE=emscripten/emsdk:3.1.65 EMCC_SRC=../../scripts/emcc.sh EMCC=EMSDK_VERSION=$(EMSDK_VERSION) EMSDK_DOCKER_IMAGE=$(EMSDK_DOCKER_IMAGE) EMSDK_PROJECT_ROOT=$(REPO_ROOT) EMSDK_DOCKER_CACHE=$(REPO_ROOT)/emsdk-cache/$(EMSDK_VERSION) $(EMCC_SRC) GENERATE_TS=$(GENERATE_TS_ENV) ../../scripts/generate.ts @@ -38,7 +38,6 @@ EMCC_EXPORTED_FUNCS+=-s EXPORTED_FUNCTIONS=@$(BUILD_WRAPPER)/symbols.json EMCC_EXPORTED_FUNCS_ASYNCIFY+=-s EXPORTED_FUNCTIONS=@$(BUILD_WRAPPER)/symbols.asyncify.json # Emscripten options -CFLAGS_WASM+=-s WASM=1 CFLAGS_WASM+=-s EXPORTED_RUNTIME_METHODS=@../../exportedRuntimeMethods.json CFLAGS_WASM+=-s MODULARIZE=1 CFLAGS_WASM+=-s IMPORTED_MEMORY=1 # Allow passing WASM memory to Emscripten diff --git a/variants.json b/variants.json index 6264c434..853cf8f0 100644 --- a/variants.json +++ b/variants.json @@ -6,7 +6,7 @@ "packageJson": { "name": "@jitl/quickjs-wasmfile-debug-sync", "license": "MIT", - "version": "0.30.0", + "version": "(omitted)", "description": "Variant of quickjs library: Variant with separate .WASM file. Supports browser ESM, NodeJS ESM, and NodeJS CommonJS.", "sideEffects": false, "repository": { "type": "git", "url": "https://github.com/justjake/quickjs-emscripten" }, @@ -51,7 +51,6 @@ }, "dependencies": { "@jitl/quickjs-ffi-types": "workspace:*" } }, - "indexJs": "packages/variant-quickjs-wasmfile-debug-sync/dist/index.js", "variant": { "library": "quickjs", "releaseMode": "debug", @@ -73,7 +72,7 @@ "packageJson": { "name": "@jitl/quickjs-wasmfile-debug-asyncify", "license": "MIT", - "version": "0.30.0", + "version": "(omitted)", "description": "Variant of quickjs library: Variant with separate .WASM file. Supports browser ESM, NodeJS ESM, and NodeJS CommonJS.", "sideEffects": false, "repository": { "type": "git", "url": "https://github.com/justjake/quickjs-emscripten" }, @@ -118,7 +117,6 @@ }, "dependencies": { "@jitl/quickjs-ffi-types": "workspace:*" } }, - "indexJs": "packages/variant-quickjs-wasmfile-debug-asyncify/dist/index.js", "variant": { "library": "quickjs", "releaseMode": "debug", @@ -140,7 +138,7 @@ "packageJson": { "name": "@jitl/quickjs-wasmfile-release-sync", "license": "MIT", - "version": "0.30.0", + "version": "(omitted)", "description": "Variant of quickjs library: Variant with separate .WASM file. Supports browser ESM, NodeJS ESM, and NodeJS CommonJS.", "sideEffects": false, "repository": { "type": "git", "url": "https://github.com/justjake/quickjs-emscripten" }, @@ -185,7 +183,6 @@ }, "dependencies": { "@jitl/quickjs-ffi-types": "workspace:*" } }, - "indexJs": "packages/variant-quickjs-wasmfile-release-sync/dist/index.js", "variant": { "library": "quickjs", "releaseMode": "release", @@ -207,7 +204,7 @@ "packageJson": { "name": "@jitl/quickjs-wasmfile-release-asyncify", "license": "MIT", - "version": "0.30.0", + "version": "(omitted)", "description": "Variant of quickjs library: Variant with separate .WASM file. Supports browser ESM, NodeJS ESM, and NodeJS CommonJS.", "sideEffects": false, "repository": { "type": "git", "url": "https://github.com/justjake/quickjs-emscripten" }, @@ -252,7 +249,6 @@ }, "dependencies": { "@jitl/quickjs-ffi-types": "workspace:*" } }, - "indexJs": "packages/variant-quickjs-wasmfile-release-asyncify/dist/index.js", "variant": { "library": "quickjs", "releaseMode": "release", @@ -274,7 +270,7 @@ "packageJson": { "name": "@jitl/quickjs-ng-wasmfile-debug-sync", "license": "MIT", - "version": "0.30.0", + "version": "(omitted)", "description": "Variant of quickjs library: Variant with separate .WASM file. Supports browser ESM, NodeJS ESM, and NodeJS CommonJS.", "sideEffects": false, "repository": { "type": "git", "url": "https://github.com/justjake/quickjs-emscripten" }, @@ -319,7 +315,6 @@ }, "dependencies": { "@jitl/quickjs-ffi-types": "workspace:*" } }, - "indexJs": "packages/variant-quickjs-ng-wasmfile-debug-sync/dist/index.js", "variant": { "library": "quickjs-ng", "releaseMode": "debug", @@ -341,7 +336,7 @@ "packageJson": { "name": "@jitl/quickjs-ng-wasmfile-debug-asyncify", "license": "MIT", - "version": "0.30.0", + "version": "(omitted)", "description": "Variant of quickjs library: Variant with separate .WASM file. Supports browser ESM, NodeJS ESM, and NodeJS CommonJS.", "sideEffects": false, "repository": { "type": "git", "url": "https://github.com/justjake/quickjs-emscripten" }, @@ -386,7 +381,6 @@ }, "dependencies": { "@jitl/quickjs-ffi-types": "workspace:*" } }, - "indexJs": "packages/variant-quickjs-ng-wasmfile-debug-asyncify/dist/index.js", "variant": { "library": "quickjs-ng", "releaseMode": "debug", @@ -408,7 +402,7 @@ "packageJson": { "name": "@jitl/quickjs-ng-wasmfile-release-sync", "license": "MIT", - "version": "0.30.0", + "version": "(omitted)", "description": "Variant of quickjs library: Variant with separate .WASM file. Supports browser ESM, NodeJS ESM, and NodeJS CommonJS.", "sideEffects": false, "repository": { "type": "git", "url": "https://github.com/justjake/quickjs-emscripten" }, @@ -453,7 +447,6 @@ }, "dependencies": { "@jitl/quickjs-ffi-types": "workspace:*" } }, - "indexJs": "packages/variant-quickjs-ng-wasmfile-release-sync/dist/index.js", "variant": { "library": "quickjs-ng", "releaseMode": "release", @@ -475,7 +468,7 @@ "packageJson": { "name": "@jitl/quickjs-ng-wasmfile-release-asyncify", "license": "MIT", - "version": "0.30.0", + "version": "(omitted)", "description": "Variant of quickjs library: Variant with separate .WASM file. Supports browser ESM, NodeJS ESM, and NodeJS CommonJS.", "sideEffects": false, "repository": { "type": "git", "url": "https://github.com/justjake/quickjs-emscripten" }, @@ -520,7 +513,6 @@ }, "dependencies": { "@jitl/quickjs-ffi-types": "workspace:*" } }, - "indexJs": "packages/variant-quickjs-ng-wasmfile-release-asyncify/dist/index.js", "variant": { "library": "quickjs-ng", "releaseMode": "release", @@ -542,7 +534,7 @@ "packageJson": { "name": "@jitl/quickjs-singlefile-cjs-debug-sync", "license": "MIT", - "version": "0.30.0", + "version": "(omitted)", "description": "Variant of quickjs library: Variant with the WASM data embedded into a universal (Node and Browser compatible) CommonJS module.", "sideEffects": false, "repository": { "type": "git", "url": "https://github.com/justjake/quickjs-emscripten" }, @@ -582,7 +574,6 @@ }, "dependencies": { "@jitl/quickjs-ffi-types": "workspace:*" } }, - "indexJs": "packages/variant-quickjs-singlefile-cjs-debug-sync/dist/index.js", "variant": { "library": "quickjs", "releaseMode": "debug", @@ -599,7 +590,7 @@ "packageJson": { "name": "@jitl/quickjs-singlefile-cjs-debug-asyncify", "license": "MIT", - "version": "0.30.0", + "version": "(omitted)", "description": "Variant of quickjs library: Variant with the WASM data embedded into a universal (Node and Browser compatible) CommonJS module.", "sideEffects": false, "repository": { "type": "git", "url": "https://github.com/justjake/quickjs-emscripten" }, @@ -639,7 +630,6 @@ }, "dependencies": { "@jitl/quickjs-ffi-types": "workspace:*" } }, - "indexJs": "packages/variant-quickjs-singlefile-cjs-debug-asyncify/dist/index.js", "variant": { "library": "quickjs", "releaseMode": "debug", @@ -656,7 +646,7 @@ "packageJson": { "name": "@jitl/quickjs-singlefile-cjs-release-sync", "license": "MIT", - "version": "0.30.0", + "version": "(omitted)", "description": "Variant of quickjs library: Variant with the WASM data embedded into a universal (Node and Browser compatible) CommonJS module.", "sideEffects": false, "repository": { "type": "git", "url": "https://github.com/justjake/quickjs-emscripten" }, @@ -696,7 +686,6 @@ }, "dependencies": { "@jitl/quickjs-ffi-types": "workspace:*" } }, - "indexJs": "packages/variant-quickjs-singlefile-cjs-release-sync/dist/index.js", "variant": { "library": "quickjs", "releaseMode": "release", @@ -713,7 +702,7 @@ "packageJson": { "name": "@jitl/quickjs-singlefile-cjs-release-asyncify", "license": "MIT", - "version": "0.30.0", + "version": "(omitted)", "description": "Variant of quickjs library: Variant with the WASM data embedded into a universal (Node and Browser compatible) CommonJS module.", "sideEffects": false, "repository": { "type": "git", "url": "https://github.com/justjake/quickjs-emscripten" }, @@ -753,7 +742,6 @@ }, "dependencies": { "@jitl/quickjs-ffi-types": "workspace:*" } }, - "indexJs": "packages/variant-quickjs-singlefile-cjs-release-asyncify/dist/index.js", "variant": { "library": "quickjs", "releaseMode": "release", @@ -770,7 +758,7 @@ "packageJson": { "name": "@jitl/quickjs-singlefile-mjs-debug-sync", "license": "MIT", - "version": "0.30.0", + "version": "(omitted)", "description": "Variant of quickjs library: Variant with the WASM data embedded into a NodeJS ESModule.", "sideEffects": false, "repository": { "type": "git", "url": "https://github.com/justjake/quickjs-emscripten" }, @@ -795,18 +783,18 @@ }, "./package.json": "./package.json", "./ffi": { - "types": "./dist/ffi.d.ts", + "types": "./dist/ffi.d.mts", "import": "./dist/ffi.mjs", "default": "./dist/ffi.mjs" }, "./emscripten-module": { "types": "./dist/emscripten-module.d.ts", - "import": "./dist/emscripten-module.mjs" + "import": "./dist/emscripten-module.mjs", + "default": "./dist/emscripten-module.mjs" } }, "dependencies": { "@jitl/quickjs-ffi-types": "workspace:*" } }, - "indexJs": "packages/variant-quickjs-singlefile-mjs-debug-sync/dist/index.js", "variant": { "library": "quickjs", "releaseMode": "debug", @@ -823,7 +811,7 @@ "packageJson": { "name": "@jitl/quickjs-singlefile-mjs-debug-asyncify", "license": "MIT", - "version": "0.30.0", + "version": "(omitted)", "description": "Variant of quickjs library: Variant with the WASM data embedded into a NodeJS ESModule.", "sideEffects": false, "repository": { "type": "git", "url": "https://github.com/justjake/quickjs-emscripten" }, @@ -848,18 +836,18 @@ }, "./package.json": "./package.json", "./ffi": { - "types": "./dist/ffi.d.ts", + "types": "./dist/ffi.d.mts", "import": "./dist/ffi.mjs", "default": "./dist/ffi.mjs" }, "./emscripten-module": { "types": "./dist/emscripten-module.d.ts", - "import": "./dist/emscripten-module.mjs" + "import": "./dist/emscripten-module.mjs", + "default": "./dist/emscripten-module.mjs" } }, "dependencies": { "@jitl/quickjs-ffi-types": "workspace:*" } }, - "indexJs": "packages/variant-quickjs-singlefile-mjs-debug-asyncify/dist/index.js", "variant": { "library": "quickjs", "releaseMode": "debug", @@ -876,7 +864,7 @@ "packageJson": { "name": "@jitl/quickjs-singlefile-mjs-release-sync", "license": "MIT", - "version": "0.30.0", + "version": "(omitted)", "description": "Variant of quickjs library: Variant with the WASM data embedded into a NodeJS ESModule.", "sideEffects": false, "repository": { "type": "git", "url": "https://github.com/justjake/quickjs-emscripten" }, @@ -901,18 +889,18 @@ }, "./package.json": "./package.json", "./ffi": { - "types": "./dist/ffi.d.ts", + "types": "./dist/ffi.d.mts", "import": "./dist/ffi.mjs", "default": "./dist/ffi.mjs" }, "./emscripten-module": { "types": "./dist/emscripten-module.d.ts", - "import": "./dist/emscripten-module.mjs" + "import": "./dist/emscripten-module.mjs", + "default": "./dist/emscripten-module.mjs" } }, "dependencies": { "@jitl/quickjs-ffi-types": "workspace:*" } }, - "indexJs": "packages/variant-quickjs-singlefile-mjs-release-sync/dist/index.js", "variant": { "library": "quickjs", "releaseMode": "release", @@ -929,7 +917,7 @@ "packageJson": { "name": "@jitl/quickjs-singlefile-mjs-release-asyncify", "license": "MIT", - "version": "0.30.0", + "version": "(omitted)", "description": "Variant of quickjs library: Variant with the WASM data embedded into a NodeJS ESModule.", "sideEffects": false, "repository": { "type": "git", "url": "https://github.com/justjake/quickjs-emscripten" }, @@ -954,18 +942,18 @@ }, "./package.json": "./package.json", "./ffi": { - "types": "./dist/ffi.d.ts", + "types": "./dist/ffi.d.mts", "import": "./dist/ffi.mjs", "default": "./dist/ffi.mjs" }, "./emscripten-module": { "types": "./dist/emscripten-module.d.ts", - "import": "./dist/emscripten-module.mjs" + "import": "./dist/emscripten-module.mjs", + "default": "./dist/emscripten-module.mjs" } }, "dependencies": { "@jitl/quickjs-ffi-types": "workspace:*" } }, - "indexJs": "packages/variant-quickjs-singlefile-mjs-release-asyncify/dist/index.js", "variant": { "library": "quickjs", "releaseMode": "release", @@ -982,7 +970,7 @@ "packageJson": { "name": "@jitl/quickjs-singlefile-browser-debug-sync", "license": "MIT", - "version": "0.30.0", + "version": "(omitted)", "description": "Variant of quickjs library: Variant with the WASM data embedded into a browser ESModule.", "sideEffects": false, "repository": { "type": "git", "url": "https://github.com/justjake/quickjs-emscripten" }, @@ -1008,19 +996,19 @@ }, "./package.json": "./package.json", "./ffi": { - "types": "./dist/ffi.d.ts", + "types": "./dist/ffi.d.mts", "import": "./dist/ffi.mjs", "default": "./dist/ffi.mjs" }, "./emscripten-module": { "types": "./dist/emscripten-module.browser.d.ts", "browser": "./dist/emscripten-module.browser.mjs", - "import": "./dist/emscripten-module.browser.mjs" + "import": "./dist/emscripten-module.browser.mjs", + "default": "./dist/emscripten-module.browser.mjs" } }, "dependencies": { "@jitl/quickjs-ffi-types": "workspace:*" } }, - "indexJs": "packages/variant-quickjs-singlefile-browser-debug-sync/dist/index.js", "variant": { "library": "quickjs", "releaseMode": "debug", @@ -1037,7 +1025,7 @@ "packageJson": { "name": "@jitl/quickjs-singlefile-browser-debug-asyncify", "license": "MIT", - "version": "0.30.0", + "version": "(omitted)", "description": "Variant of quickjs library: Variant with the WASM data embedded into a browser ESModule.", "sideEffects": false, "repository": { "type": "git", "url": "https://github.com/justjake/quickjs-emscripten" }, @@ -1063,19 +1051,19 @@ }, "./package.json": "./package.json", "./ffi": { - "types": "./dist/ffi.d.ts", + "types": "./dist/ffi.d.mts", "import": "./dist/ffi.mjs", "default": "./dist/ffi.mjs" }, "./emscripten-module": { "types": "./dist/emscripten-module.browser.d.ts", "browser": "./dist/emscripten-module.browser.mjs", - "import": "./dist/emscripten-module.browser.mjs" + "import": "./dist/emscripten-module.browser.mjs", + "default": "./dist/emscripten-module.browser.mjs" } }, "dependencies": { "@jitl/quickjs-ffi-types": "workspace:*" } }, - "indexJs": "packages/variant-quickjs-singlefile-browser-debug-asyncify/dist/index.js", "variant": { "library": "quickjs", "releaseMode": "debug", @@ -1092,7 +1080,7 @@ "packageJson": { "name": "@jitl/quickjs-singlefile-browser-release-sync", "license": "MIT", - "version": "0.30.0", + "version": "(omitted)", "description": "Variant of quickjs library: Variant with the WASM data embedded into a browser ESModule.", "sideEffects": false, "repository": { "type": "git", "url": "https://github.com/justjake/quickjs-emscripten" }, @@ -1118,19 +1106,19 @@ }, "./package.json": "./package.json", "./ffi": { - "types": "./dist/ffi.d.ts", + "types": "./dist/ffi.d.mts", "import": "./dist/ffi.mjs", "default": "./dist/ffi.mjs" }, "./emscripten-module": { "types": "./dist/emscripten-module.browser.d.ts", "browser": "./dist/emscripten-module.browser.mjs", - "import": "./dist/emscripten-module.browser.mjs" + "import": "./dist/emscripten-module.browser.mjs", + "default": "./dist/emscripten-module.browser.mjs" } }, "dependencies": { "@jitl/quickjs-ffi-types": "workspace:*" } }, - "indexJs": "packages/variant-quickjs-singlefile-browser-release-sync/dist/index.js", "variant": { "library": "quickjs", "releaseMode": "release", @@ -1147,7 +1135,7 @@ "packageJson": { "name": "@jitl/quickjs-singlefile-browser-release-asyncify", "license": "MIT", - "version": "0.30.0", + "version": "(omitted)", "description": "Variant of quickjs library: Variant with the WASM data embedded into a browser ESModule.", "sideEffects": false, "repository": { "type": "git", "url": "https://github.com/justjake/quickjs-emscripten" }, @@ -1173,19 +1161,19 @@ }, "./package.json": "./package.json", "./ffi": { - "types": "./dist/ffi.d.ts", + "types": "./dist/ffi.d.mts", "import": "./dist/ffi.mjs", "default": "./dist/ffi.mjs" }, "./emscripten-module": { "types": "./dist/emscripten-module.browser.d.ts", "browser": "./dist/emscripten-module.browser.mjs", - "import": "./dist/emscripten-module.browser.mjs" + "import": "./dist/emscripten-module.browser.mjs", + "default": "./dist/emscripten-module.browser.mjs" } }, "dependencies": { "@jitl/quickjs-ffi-types": "workspace:*" } }, - "indexJs": "packages/variant-quickjs-singlefile-browser-release-asyncify/dist/index.js", "variant": { "library": "quickjs", "releaseMode": "release", @@ -1194,5 +1182,53 @@ "emscriptenInclusion": "singlefile", "exports": { "browser": { "emscriptenEnvironment": ["web", "worker"] } } } + }, + "packages/variant-quickjs-asmjs-mjs-release-sync": { + "basename": "quickjs-asmjs-mjs-release-sync", + "targetName": "asmjs-mjs", + "dir": "packages/variant-quickjs-asmjs-mjs-release-sync", + "packageJson": { + "name": "@jitl/quickjs-asmjs-mjs-release-sync", + "license": "MIT", + "version": "(omitted)", + "description": "Variant of quickjs library: Compiled to pure Javascript, no WebAssembly required.", + "sideEffects": false, + "repository": { "type": "git", "url": "https://github.com/justjake/quickjs-emscripten" }, + "author": { "name": "Jake Teton-Landis", "url": "https://jake.tl" }, + "scripts": { + "build": "yarn build:c && yarn build:ts", + "build:c": "make -j2", + "build:ts": "npx tsup", + "check:types": "npx tsc --project . --noEmit", + "clean": "make clean", + "prepare": "yarn clean && yarn build" + }, + "files": ["LICENSE", "README.md", "dist/**/*", "!dist/*.tsbuildinfo"], + "types": "./dist/index.d.mts", + "main": "./dist/index.mjs", + "module": "./dist/index.mjs", + "exports": { + ".": { + "types": "./dist/index.d.mts", + "import": "./dist/index.mjs", + "default": "./dist/index.mjs" + }, + "./package.json": "./package.json", + "./emscripten-module": { + "types": "./dist/emscripten-module.d.ts", + "import": "./dist/emscripten-module.mjs", + "default": "./dist/emscripten-module.mjs" + } + }, + "dependencies": { "@jitl/quickjs-ffi-types": "workspace:*" } + }, + "variant": { + "library": "quickjs", + "releaseMode": "release", + "syncMode": "sync", + "description": "Compiled to pure Javascript, no WebAssembly required.", + "emscriptenInclusion": "asmjs", + "exports": { "import": { "emscriptenEnvironment": ["web", "worker", "node"] } } + } } } diff --git a/yarn.lock b/yarn.lock index 36155294..11477327 100644 --- a/yarn.lock +++ b/yarn.lock @@ -613,6 +613,14 @@ __metadata: languageName: node linkType: hard +"@jitl/quickjs-asmjs-mjs-release-sync@workspace:*, @jitl/quickjs-asmjs-mjs-release-sync@workspace:packages/variant-quickjs-asmjs-mjs-release-sync": + version: 0.0.0-use.local + resolution: "@jitl/quickjs-asmjs-mjs-release-sync@workspace:packages/variant-quickjs-asmjs-mjs-release-sync" + dependencies: + "@jitl/quickjs-ffi-types": "workspace:*" + languageName: unknown + linkType: soft + "@jitl/quickjs-ffi-types@workspace:*, @jitl/quickjs-ffi-types@workspace:packages/quickjs-ffi-types": version: 0.0.0-use.local resolution: "@jitl/quickjs-ffi-types@workspace:packages/quickjs-ffi-types" @@ -5565,6 +5573,16 @@ __metadata: languageName: unknown linkType: soft +"quickjs-for-quickjs@workspace:packages/quickjs-for-quickjs": + version: 0.0.0-use.local + resolution: "quickjs-for-quickjs@workspace:packages/quickjs-for-quickjs" + dependencies: + "@jitl/quickjs-asmjs-mjs-release-sync": "workspace:*" + "@jitl/tsconfig": "workspace:*" + quickjs-emscripten-core: "workspace:*" + languageName: unknown + linkType: soft + "range-parser@npm:~1.2.1": version: 1.2.1 resolution: "range-parser@npm:1.2.1"