@componentor/quickjs-wasmfile-debug-asyncify 0.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,47 @@
1
+ quickjs-emscripten:
2
+ The MIT License
3
+
4
+ quickjs-emscripten copyright (c) 2019-2024 Jake Teton-Landis
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
23
+
24
+
25
+ quickjs:
26
+ QuickJS Javascript Engine
27
+
28
+ Copyright (c) 2017-2021 Fabrice Bellard
29
+ Copyright (c) 2017-2021 Charlie Gordon
30
+
31
+ Permission is hereby granted, free of charge, to any person obtaining a copy
32
+ of this software and associated documentation files (the "Software"), to deal
33
+ in the Software without restriction, including without limitation the rights
34
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
35
+ copies of the Software, and to permit persons to whom the Software is
36
+ furnished to do so, subject to the following conditions:
37
+
38
+ The above copyright notice and this permission notice shall be included in
39
+ all copies or substantial portions of the Software.
40
+
41
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
42
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
43
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
44
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
45
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
46
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
47
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,93 @@
1
+ # @componentor/quickjs-wasmfile-debug-asyncify
2
+
3
+ Variant with separate .WASM file. Supports browser ESM, NodeJS ESM, and NodeJS CommonJS.
4
+
5
+ This generated package is part of [quickjs-emscripten](https://github.com/componentor/quickjs-emscripten).
6
+ It contains a variant of the quickjs WASM library, and can be used with @componentor/quickjs-emscripten-core.
7
+
8
+ ```typescript
9
+ import variant from "@componentor/quickjs-wasmfile-debug-asyncify"
10
+ import { newQuickJSAsyncWASMModuleFromVariant } from "@componentor/quickjs-emscripten-core"
11
+ const QuickJS = await newQuickJSAsyncWASMModuleFromVariant(variant)
12
+ ```
13
+
14
+ This variant was built with the following settings:
15
+
16
+ ## Library: quickjs
17
+
18
+ The original [bellard/quickjs](https://github.com/bellard/quickjs) library.
19
+
20
+ Version [2024-02-14+36911f0d](https://github.com/bellard/quickjs/commit/36911f0d3ab1a4c190a4d5cbe7c2db225a455389) vendored to quickjs-emscripten on 2024-06-15.
21
+
22
+ ## Release mode: debug
23
+
24
+ Enables assertions and memory sanitizers. Try to run your tests against debug variants, in addition to your preferred production variant, to catch more bugs.
25
+
26
+ ## Exports: require import browser workerd
27
+
28
+ Exports the following in package.json for the package entrypoint:
29
+
30
+ - Exports a NodeJS-compatible CommonJS module, which is faster to load and run compared to an ESModule.
31
+ - Exports a NodeJS-compatible ESModule. Cannot be imported synchronously from a NodeJS CommonJS module.
32
+ - Exports a browser-compatible ESModule, designed to work in browsers and browser-like environments.
33
+ - Targets Cloudflare Workers.
34
+
35
+ ## Extra async magic? Yes
36
+
37
+ 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/componentor/quickjs-emscripten/blob/main/doc/quickjs-emscripten/classes/QuickJSAsyncRuntime.md) and [QuickJSAsyncContext](https://github.com/componentor/quickjs-emscripten/blob/main/doc/quickjs-emscripten/classes/QuickJSAsyncContext.md) classes expose the ASYNCIFY-specific APIs.
38
+
39
+ ## Single-file, or separate .wasm file? wasm
40
+
41
+ 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.
42
+
43
+ ## More details
44
+
45
+ Full variant JSON description:
46
+
47
+ ```json
48
+ {
49
+ "library": "quickjs",
50
+ "releaseMode": "debug",
51
+ "syncMode": "asyncify",
52
+ "description": "Variant with separate .WASM file. Supports browser ESM, NodeJS ESM, and NodeJS CommonJS.",
53
+ "emscriptenInclusion": "wasm",
54
+ "exports": {
55
+ "require": {
56
+ "emscriptenEnvironment": ["node"]
57
+ },
58
+ "import": {
59
+ "emscriptenEnvironment": ["node"]
60
+ },
61
+ "browser": {
62
+ "emscriptenEnvironment": ["web", "worker"]
63
+ },
64
+ "workerd": {
65
+ "emscriptenEnvironment": ["web"]
66
+ }
67
+ }
68
+ }
69
+ ```
70
+
71
+ Variant-specific Emscripten build flags:
72
+
73
+ ```json
74
+ [
75
+ "-s ASYNCIFY=1",
76
+ "-DQTS_ASYNCIFY=1",
77
+ "-DQTS_ASYNCIFY_DEFAULT_STACK_SIZE=81920",
78
+ "-s ASYNCIFY_STACK_SIZE=81920",
79
+ "-s ASYNCIFY_REMOVE=@$(BUILD_WRAPPER)/asyncify-remove.json",
80
+ "-s ASYNCIFY_IMPORTS=@$(BUILD_WRAPPER)/asyncify-imports.json",
81
+ "-lasync.js",
82
+ "-O0",
83
+ "-DQTS_DEBUG_MODE",
84
+ "-DDUMP_LEAKS=1",
85
+ "-gsource-map",
86
+ "-s ASSERTIONS=1",
87
+ "--pre-js $(TEMPLATES)/pre-extension.js",
88
+ "--pre-js $(TEMPLATES)/pre-sourceMapJson.js",
89
+ "--pre-js $(TEMPLATES)/pre-wasmOffsetConverter.js",
90
+ "--pre-js $(TEMPLATES)/pre-wasmMemory.js",
91
+ "-O3"
92
+ ]
93
+ ```
@@ -0,0 +1,18 @@
1
+ // Generated from ../../templates/emscripten-module.ASYNCIFY.d.ts
2
+ import type {
3
+ EmscriptenModuleLoader,
4
+ QuickJSAsyncEmscriptenModule,
5
+ } from "@componentor/quickjs-ffi-types"
6
+ /**
7
+ * Emscripten module built from [`quickjs/quickjs.h`](../quickjs/quickjs.h) and
8
+ * our FFI support functions [c/interface.c](../c/interface.c), compiled with -s
9
+ * ASYNCIFY=1.
10
+ *
11
+ * Because this version is built with ASYNCIFY, the C code can call asynchronous
12
+ * Javascript functions as though they were synchronous.
13
+ *
14
+ * Note that emscripten modules returned by a `MODULARIZE=1` emscripten build
15
+ * (like this one) load asynchronously.
16
+ */
17
+ declare const ModuleLoader: EmscriptenModuleLoader<QuickJSAsyncEmscriptenModule>
18
+ export default ModuleLoader