@bytecodealliance/jco 0.5.1 → 0.5.3
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/README.md +1 -1
- package/api.d.ts +3 -0
- package/api.mjs +20 -4
- package/cli.mjs +24 -17
- package/js-component-bindgen-component.core.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -70,7 +70,7 @@ Commands:
|
|
|
70
70
|
To componentize a JS file run:
|
|
71
71
|
|
|
72
72
|
```
|
|
73
|
-
jco componentize app.js --
|
|
73
|
+
jco componentize app.js --wit world.wit -o component.wasm
|
|
74
74
|
```
|
|
75
75
|
|
|
76
76
|
Creates a component from a JS module implementing a WIT world definition, via a Spidermonkey engine embedding.
|
package/api.d.ts
CHANGED
|
@@ -31,6 +31,9 @@ export interface TranspileOpts {
|
|
|
31
31
|
/// if using optimize, custom optimization options
|
|
32
32
|
/// (defaults to best optimization, but this is very slow)
|
|
33
33
|
optArgs?: string[],
|
|
34
|
+
/// rewrite WASI imports to the @bytecodealliance/preview2-shim
|
|
35
|
+
/// defaults to false
|
|
36
|
+
wasiShim?: boolean
|
|
34
37
|
}
|
|
35
38
|
|
|
36
39
|
/**
|
package/api.mjs
CHANGED
|
@@ -40118,8 +40118,8 @@ const exports = {
|
|
|
40118
40118
|
|
|
40119
40119
|
const $init = (async() => {
|
|
40120
40120
|
const module0 = fetchCompile(__nccwpck_require__.ab + "js-component-bindgen-component.core.wasm");
|
|
40121
|
-
const module1 = base64Compile('AGFzbQEAAAABBgFgAn9/
|
|
40122
|
-
const module2 = base64Compile('AGFzbQEAAAABBgFgAn9/
|
|
40121
|
+
const module1 = base64Compile('AGFzbQEAAAABBgFgAn9/AAMCAQAEBQFwAQEBBxACATAAAAgkaW1wb3J0cwEACg0BCwAgACABQQARAAALAC0JcHJvZHVjZXJzAQxwcm9jZXNzZWQtYnkBDXdpdC1jb21wb25lbnQFMC43LjQANQRuYW1lABMSd2l0LWNvbXBvbmVudDpzaGltARkBABZpbmRpcmVjdC1jb25zb2xlLWVycm9y');
|
|
40122
|
+
const module2 = base64Compile('AGFzbQEAAAABBgFgAn9/AAIVAgABMAAAAAgkaW1wb3J0cwFwAQEBCQcBAEEACwEAAC0JcHJvZHVjZXJzAQxwcm9jZXNzZWQtYnkBDXdpdC1jb21wb25lbnQFMC43LjQAHARuYW1lABUUd2l0LWNvbXBvbmVudDpmaXh1cHM=');
|
|
40123
40123
|
Promise.all([module0, module1, module2]).catch(() => {});
|
|
40124
40124
|
({ exports: exports0 } = await instantiateCore(await module1));
|
|
40125
40125
|
({ exports: exports1 } = await instantiateCore(await module0, {
|
|
@@ -40805,8 +40805,8 @@ const exports = {
|
|
|
40805
40805
|
|
|
40806
40806
|
const $init = (async() => {
|
|
40807
40807
|
const module0 = fetchCompile(__nccwpck_require__.ab + "wasm-tools.core.wasm");
|
|
40808
|
-
const module1 = base64Compile('AGFzbQEAAAABBgFgAn9/
|
|
40809
|
-
const module2 = base64Compile('AGFzbQEAAAABBgFgAn9/
|
|
40808
|
+
const module1 = base64Compile('AGFzbQEAAAABBgFgAn9/AAMCAQAEBQFwAQEBBxACATAAAAgkaW1wb3J0cwEACg0BCwAgACABQQARAAALAC0JcHJvZHVjZXJzAQxwcm9jZXNzZWQtYnkBDXdpdC1jb21wb25lbnQFMC43LjQANQRuYW1lABMSd2l0LWNvbXBvbmVudDpzaGltARkBABZpbmRpcmVjdC1jb25zb2xlLWVycm9y');
|
|
40809
|
+
const module2 = base64Compile('AGFzbQEAAAABBgFgAn9/AAIVAgABMAAAAAgkaW1wb3J0cwFwAQEBCQcBAEEACwEAAC0JcHJvZHVjZXJzAQxwcm9jZXNzZWQtYnkBDXdpdC1jb21wb25lbnQFMC43LjQAHARuYW1lABUUd2l0LWNvbXBvbmVudDpmaXh1cHM=');
|
|
40810
40810
|
Promise.all([module0, module1, module2]).catch(() => {});
|
|
40811
40811
|
({ exports: exports0 } = await instantiateCore(await module1));
|
|
40812
40812
|
({ exports: exports1 } = await instantiateCore(await module0, {
|
|
@@ -41153,6 +41153,22 @@ async function transpileComponent (component, opts = {}) {
|
|
|
41153
41153
|
({ component } = await (0,_opt_js__WEBPACK_IMPORTED_MODULE_5__/* .optimizeComponent */ .j)(component, opts));
|
|
41154
41154
|
}
|
|
41155
41155
|
|
|
41156
|
+
if (opts.wasiShim) {
|
|
41157
|
+
opts.map = Object.assign({
|
|
41158
|
+
'environment-preopens': '@bytecodealliance/preview2-shim/environment-preopens',
|
|
41159
|
+
'instance-wall-clock': '@bytecodealliance/preview2-shim/instance-wall-clock',
|
|
41160
|
+
'instance-monotonic-clock': '@bytecodealliance/preview2-shim/instance-monotonic-clock',
|
|
41161
|
+
'streams': '@bytecodealliance/preview2-shim/streams',
|
|
41162
|
+
'monotonic-clock': '@bytecodealliance/preview2-shim/monotonic-clock',
|
|
41163
|
+
'filesystem': '@bytecodealliance/preview2-shim/filesystem',
|
|
41164
|
+
'wall-clock': '@bytecodealliance/preview2-shim/wall-clock',
|
|
41165
|
+
'environment': '@bytecodealliance/preview2-shim/environment',
|
|
41166
|
+
'random': '@bytecodealliance/preview2-shim/random',
|
|
41167
|
+
'exit': '@bytecodealliance/preview2-shim/exit',
|
|
41168
|
+
'stderr': '@bytecodealliance/preview2-shim/stderr'
|
|
41169
|
+
}, opts.map || {});
|
|
41170
|
+
}
|
|
41171
|
+
|
|
41156
41172
|
let { files, imports, exports } = generate(component, {
|
|
41157
41173
|
name: opts.name ?? 'component',
|
|
41158
41174
|
map: Object.entries(opts.map ?? {}),
|
package/cli.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import * as __WEBPACK_EXTERNAL_MODULE__bytecodealliance_componentize_js_a7e85369__ from "@bytecodealliance/componentize-js";
|
|
3
2
|
import { createRequire as __WEBPACK_EXTERNAL_createRequire } from "module";
|
|
4
3
|
/******/ var __webpack_modules__ = ({
|
|
5
4
|
|
|
@@ -6550,15 +6549,6 @@ function bisearch(ucs) {
|
|
|
6550
6549
|
}
|
|
6551
6550
|
|
|
6552
6551
|
|
|
6553
|
-
/***/ }),
|
|
6554
|
-
|
|
6555
|
-
/***/ 9291:
|
|
6556
|
-
/***/ ((module) => {
|
|
6557
|
-
|
|
6558
|
-
var x = y => { var x = {}; __nccwpck_require__.d(x, y); return x; }
|
|
6559
|
-
var y = x => () => x
|
|
6560
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE__bytecodealliance_componentize_js_a7e85369__;
|
|
6561
|
-
|
|
6562
6552
|
/***/ }),
|
|
6563
6553
|
|
|
6564
6554
|
/***/ 9491:
|
|
@@ -43526,8 +43516,8 @@ const exports = {
|
|
|
43526
43516
|
|
|
43527
43517
|
const $init = (async() => {
|
|
43528
43518
|
const module0 = fetchCompile(__nccwpck_require__.ab + "js-component-bindgen-component.core.wasm");
|
|
43529
|
-
const module1 = base64Compile('AGFzbQEAAAABBgFgAn9/
|
|
43530
|
-
const module2 = base64Compile('AGFzbQEAAAABBgFgAn9/
|
|
43519
|
+
const module1 = base64Compile('AGFzbQEAAAABBgFgAn9/AAMCAQAEBQFwAQEBBxACATAAAAgkaW1wb3J0cwEACg0BCwAgACABQQARAAALAC0JcHJvZHVjZXJzAQxwcm9jZXNzZWQtYnkBDXdpdC1jb21wb25lbnQFMC43LjQANQRuYW1lABMSd2l0LWNvbXBvbmVudDpzaGltARkBABZpbmRpcmVjdC1jb25zb2xlLWVycm9y');
|
|
43520
|
+
const module2 = base64Compile('AGFzbQEAAAABBgFgAn9/AAIVAgABMAAAAAgkaW1wb3J0cwFwAQEBCQcBAEEACwEAAC0JcHJvZHVjZXJzAQxwcm9jZXNzZWQtYnkBDXdpdC1jb21wb25lbnQFMC43LjQAHARuYW1lABUUd2l0LWNvbXBvbmVudDpmaXh1cHM=');
|
|
43531
43521
|
Promise.all([module0, module1, module2]).catch(() => {});
|
|
43532
43522
|
({ exports: exports0 } = await instantiateCore(await module1));
|
|
43533
43523
|
({ exports: exports1 } = await instantiateCore(await module0, {
|
|
@@ -44213,8 +44203,8 @@ const exports = {
|
|
|
44213
44203
|
|
|
44214
44204
|
const $init = (async() => {
|
|
44215
44205
|
const module0 = fetchCompile(__nccwpck_require__.ab + "wasm-tools.core.wasm");
|
|
44216
|
-
const module1 = base64Compile('AGFzbQEAAAABBgFgAn9/
|
|
44217
|
-
const module2 = base64Compile('AGFzbQEAAAABBgFgAn9/
|
|
44206
|
+
const module1 = base64Compile('AGFzbQEAAAABBgFgAn9/AAMCAQAEBQFwAQEBBxACATAAAAgkaW1wb3J0cwEACg0BCwAgACABQQARAAALAC0JcHJvZHVjZXJzAQxwcm9jZXNzZWQtYnkBDXdpdC1jb21wb25lbnQFMC43LjQANQRuYW1lABMSd2l0LWNvbXBvbmVudDpzaGltARkBABZpbmRpcmVjdC1jb25zb2xlLWVycm9y');
|
|
44207
|
+
const module2 = base64Compile('AGFzbQEAAAABBgFgAn9/AAIVAgABMAAAAAgkaW1wb3J0cwFwAQEBCQcBAEEACwEAAC0JcHJvZHVjZXJzAQxwcm9jZXNzZWQtYnkBDXdpdC1jb21wb25lbnQFMC43LjQAHARuYW1lABUUd2l0LWNvbXBvbmVudDpmaXh1cHM=');
|
|
44218
44208
|
Promise.all([module0, module1, module2]).catch(() => {});
|
|
44219
44209
|
({ exports: exports0 } = await instantiateCore(await module1));
|
|
44220
44210
|
({ exports: exports1 } = await instantiateCore(await module0, {
|
|
@@ -44255,7 +44245,7 @@ __webpack_async_result__();
|
|
|
44255
44245
|
async function componentize (jsSource, opts) {
|
|
44256
44246
|
let componentizeFn;
|
|
44257
44247
|
try {
|
|
44258
|
-
({ componentize: componentizeFn } = await
|
|
44248
|
+
({ componentize: componentizeFn } = await eval('import("@bytecodealliance/componentize-js")'));
|
|
44259
44249
|
} catch (e) {
|
|
44260
44250
|
throw new Error(`componentize-js must first be installed separately via "npm install @bytecodealliance/componentize-js".`);
|
|
44261
44251
|
}
|
|
@@ -44551,6 +44541,22 @@ async function transpileComponent (component, opts = {}) {
|
|
|
44551
44541
|
({ component } = await (0,_opt_js__WEBPACK_IMPORTED_MODULE_5__/* .optimizeComponent */ .j)(component, opts));
|
|
44552
44542
|
}
|
|
44553
44543
|
|
|
44544
|
+
if (opts.wasiShim) {
|
|
44545
|
+
opts.map = Object.assign({
|
|
44546
|
+
'environment-preopens': '@bytecodealliance/preview2-shim/environment-preopens',
|
|
44547
|
+
'instance-wall-clock': '@bytecodealliance/preview2-shim/instance-wall-clock',
|
|
44548
|
+
'instance-monotonic-clock': '@bytecodealliance/preview2-shim/instance-monotonic-clock',
|
|
44549
|
+
'streams': '@bytecodealliance/preview2-shim/streams',
|
|
44550
|
+
'monotonic-clock': '@bytecodealliance/preview2-shim/monotonic-clock',
|
|
44551
|
+
'filesystem': '@bytecodealliance/preview2-shim/filesystem',
|
|
44552
|
+
'wall-clock': '@bytecodealliance/preview2-shim/wall-clock',
|
|
44553
|
+
'environment': '@bytecodealliance/preview2-shim/environment',
|
|
44554
|
+
'random': '@bytecodealliance/preview2-shim/random',
|
|
44555
|
+
'exit': '@bytecodealliance/preview2-shim/exit',
|
|
44556
|
+
'stderr': '@bytecodealliance/preview2-shim/stderr'
|
|
44557
|
+
}, opts.map || {});
|
|
44558
|
+
}
|
|
44559
|
+
|
|
44554
44560
|
let { files, imports, exports } = generate(component, {
|
|
44555
44561
|
name: opts.name ?? 'component',
|
|
44556
44562
|
map: Object.entries(opts.map ?? {}),
|
|
@@ -45131,7 +45137,7 @@ var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_cmd
|
|
|
45131
45137
|
commander__WEBPACK_IMPORTED_MODULE_0__/* .program.name */ .Nx.name('jco')
|
|
45132
45138
|
.description(chalk_template__WEBPACK_IMPORTED_MODULE_5__/* ["default"] */ .Z`{bold jco - WebAssembly JS Component Tools}\n JS Component Transpilation Bindgen & Wasm Tools for JS`)
|
|
45133
45139
|
.usage('<command> [options]')
|
|
45134
|
-
.version('0.5.
|
|
45140
|
+
.version('0.5.3');
|
|
45135
45141
|
|
|
45136
45142
|
function myParseInt(value) {
|
|
45137
45143
|
return parseInt(value, 10);
|
|
@@ -45159,6 +45165,7 @@ commander__WEBPACK_IMPORTED_MODULE_0__/* .program.command */ .Nx.command('transp
|
|
|
45159
45165
|
.option('--tla-compat', 'enables compatibility for JS environments without top-level await support via an async $init promise export')
|
|
45160
45166
|
.option('--no-nodejs-compat', 'disables compatibility in Node.js without a fetch global')
|
|
45161
45167
|
.option('-M, --map <mappings...>', 'specifier=./output custom mappings for the component imports')
|
|
45168
|
+
.option('-w, --wasi-shim', 'automatically rewrite WASI imports to use @bytecodealliance/preview2-shim')
|
|
45162
45169
|
.option('--js', 'output JS instead of core WebAssembly')
|
|
45163
45170
|
.option('-I, --instantiation', 'output for custom module instantiation')
|
|
45164
45171
|
.option('-q, --quiet', 'disable logging')
|
|
@@ -45235,7 +45242,7 @@ function asyncAction (cmd) {
|
|
|
45235
45242
|
await cmd.apply(null, args);
|
|
45236
45243
|
}
|
|
45237
45244
|
catch (e) {
|
|
45238
|
-
process.stdout.write(`(
|
|
45245
|
+
process.stdout.write(`(jco ${cmd.name}) `);
|
|
45239
45246
|
if (typeof e === 'string') {
|
|
45240
45247
|
console.error(chalk_template__WEBPACK_IMPORTED_MODULE_5__/* ["default"] */ .Z`{red.bold Error}: ${e}\n`);
|
|
45241
45248
|
} else {
|
|
Binary file
|