@bytecodealliance/jco 1.0.1 → 1.0.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 +2 -2
- package/lib/wasi_snapshot_preview1.command.wasm +0 -0
- package/lib/wasi_snapshot_preview1.reactor.wasm +0 -0
- package/obj/interfaces/wasi-filesystem-types.d.ts +4 -4
- package/obj/interfaces/wasi-io-streams.d.ts +5 -5
- package/obj/js-component-bindgen-component.component.wasm +0 -0
- package/obj/js-component-bindgen-component.core.wasm +0 -0
- package/obj/js-component-bindgen-component.core2.wasm +0 -0
- package/obj/js-component-bindgen-component.d.ts +14 -0
- package/obj/js-component-bindgen-component.js +1001 -735
- package/obj/wasm-tools.component.wasm +0 -0
- package/obj/wasm-tools.core.wasm +0 -0
- package/obj/wasm-tools.core2.wasm +0 -0
- package/obj/wasm-tools.js +1198 -918
- package/package.json +8 -8
- package/src/cmd/componentize.js +1 -1
- package/src/cmd/run.js +7 -3
- package/src/cmd/transpile.js +2 -0
- package/src/jco.js +4 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bytecodealliance/jco",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "JavaScript tooling for working with WebAssembly Components",
|
|
5
5
|
"author": "Guy Bedford",
|
|
6
6
|
"bin": {
|
|
@@ -18,13 +18,13 @@
|
|
|
18
18
|
},
|
|
19
19
|
"type": "module",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@bytecodealliance/preview2-shim": "0.
|
|
22
|
-
"binaryen": "^
|
|
23
|
-
"chalk-template": "^
|
|
24
|
-
"commander": "^
|
|
25
|
-
"mkdirp": "^
|
|
26
|
-
"ora": "^
|
|
27
|
-
"terser": "^5
|
|
21
|
+
"@bytecodealliance/preview2-shim": "0.16.0",
|
|
22
|
+
"binaryen": "^116.0.0",
|
|
23
|
+
"chalk-template": "^1",
|
|
24
|
+
"commander": "^12",
|
|
25
|
+
"mkdirp": "^3",
|
|
26
|
+
"ora": "^8",
|
|
27
|
+
"terser": "^5"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@bytecodealliance/componentize-js": "^0.7.0",
|
package/src/cmd/componentize.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { readFile, writeFile } from 'node:fs/promises';
|
|
2
2
|
import { resolve } from 'node:path';
|
|
3
3
|
import c from 'chalk-template';
|
|
4
|
-
import { isWindows } from '../common.js';
|
|
5
4
|
|
|
6
5
|
export async function componentize (jsSource, opts) {
|
|
7
6
|
let componentizeFn;
|
|
@@ -14,6 +13,7 @@ export async function componentize (jsSource, opts) {
|
|
|
14
13
|
}
|
|
15
14
|
const source = await readFile(jsSource, 'utf8');
|
|
16
15
|
const { component, imports } = await componentizeFn(source, {
|
|
16
|
+
sourceName: jsSource,
|
|
17
17
|
witPath: resolve(opts.wit),
|
|
18
18
|
worldName: opts.worldName,
|
|
19
19
|
enableStdout: opts.enableStdout,
|
package/src/cmd/run.js
CHANGED
|
@@ -2,7 +2,7 @@ import { getTmpDir } from '../common.js';
|
|
|
2
2
|
import { transpile } from './transpile.js';
|
|
3
3
|
import { rm, stat, mkdir, writeFile, symlink } from 'node:fs/promises';
|
|
4
4
|
import { basename, resolve, extname } from 'node:path';
|
|
5
|
-
import {
|
|
5
|
+
import { spawn } from 'node:child_process';
|
|
6
6
|
import process from 'node:process';
|
|
7
7
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
8
8
|
import c from 'chalk-template';
|
|
@@ -75,7 +75,8 @@ async function runComponent (componentPath, args, opts, executor) {
|
|
|
75
75
|
wasiShim: true,
|
|
76
76
|
outDir,
|
|
77
77
|
tracing: opts.jcoTrace,
|
|
78
|
-
map: opts.jcoMap
|
|
78
|
+
map: opts.jcoMap,
|
|
79
|
+
importBindings: opts.jcoImportBindings,
|
|
79
80
|
});
|
|
80
81
|
}
|
|
81
82
|
catch (e) {
|
|
@@ -112,6 +113,7 @@ async function runComponent (componentPath, args, opts, executor) {
|
|
|
112
113
|
const runPath = resolve(outDir, '_run.js');
|
|
113
114
|
await writeFile(runPath, `
|
|
114
115
|
${jcoImport ? `import ${JSON.stringify(pathToFileURL(jcoImport))}` : ''}
|
|
116
|
+
import process from 'node:process';
|
|
115
117
|
try {
|
|
116
118
|
process.argv[1] = "${name}";
|
|
117
119
|
} catch {}
|
|
@@ -119,8 +121,10 @@ async function runComponent (componentPath, args, opts, executor) {
|
|
|
119
121
|
${executor}
|
|
120
122
|
`);
|
|
121
123
|
|
|
124
|
+
const nodePath = process.env.JCO_RUN_PATH || process.argv[0];
|
|
125
|
+
|
|
122
126
|
process.exitCode = await new Promise((resolve, reject) => {
|
|
123
|
-
const cp =
|
|
127
|
+
const cp = spawn(nodePath, [...process.env.JCO_RUN_ARGS ? process.env.JCO_RUN_ARGS.split(' ') : [], runPath, ...args], { stdio: 'inherit' });
|
|
124
128
|
|
|
125
129
|
cp.on('error', reject);
|
|
126
130
|
cp.on('exit', resolve);
|
package/src/cmd/transpile.js
CHANGED
|
@@ -80,6 +80,7 @@ async function wasm2Js (source) {
|
|
|
80
80
|
* @param {{
|
|
81
81
|
* name: string,
|
|
82
82
|
* instantiation?: 'async' | 'sync',
|
|
83
|
+
* importBindings?: 'js' | 'optimized', 'hybrid', 'direct-optimized',
|
|
83
84
|
* map?: Record<string, string>,
|
|
84
85
|
* validLiftingOptimization?: bool,
|
|
85
86
|
* tracing?: bool,
|
|
@@ -133,6 +134,7 @@ export async function transpileComponent (component, opts = {}) {
|
|
|
133
134
|
name: opts.name ?? 'component',
|
|
134
135
|
map: Object.entries(opts.map ?? {}),
|
|
135
136
|
instantiation,
|
|
137
|
+
importBindings: opts.importBindings ? { tag: opts.importBindings } : null,
|
|
136
138
|
validLiftingOptimization: opts.validLiftingOptimization ?? false,
|
|
137
139
|
tracing: opts.tracing ?? false,
|
|
138
140
|
noNodejsCompat: opts.nodejsCompat === false,
|
package/src/jco.js
CHANGED
|
@@ -11,7 +11,7 @@ program
|
|
|
11
11
|
.name('jco')
|
|
12
12
|
.description(c`{bold jco - WebAssembly JS Component Tools}\n JS Component Transpilation Bindgen & Wasm Tools for JS`)
|
|
13
13
|
.usage('<command> [options]')
|
|
14
|
-
.version('1.0.
|
|
14
|
+
.version('1.0.3');
|
|
15
15
|
|
|
16
16
|
function myParseInt(value) {
|
|
17
17
|
return parseInt(value, 10);
|
|
@@ -38,6 +38,7 @@ program.command('transpile')
|
|
|
38
38
|
.option('-O, --optimize', 'optimize the component first')
|
|
39
39
|
.option('--no-typescript', 'do not output TypeScript .d.ts types')
|
|
40
40
|
.option('--valid-lifting-optimization', 'optimize component binary validations assuming all lifted values are valid')
|
|
41
|
+
.addOption(new Option('--import-bindings [mode]', 'bindings mode for imports').choices(['js', 'optimized', 'hybrid', 'direct-optimized']).preset('js'))
|
|
41
42
|
.option('--tracing', 'emit `tracing` calls on function entry/exit')
|
|
42
43
|
.option('-b, --base64-cutoff <bytes>', 'set the byte size under which core Wasm binaries will be inlined as base64', myParseInt)
|
|
43
44
|
.option('--tla-compat', 'enables compatibility for JS environments without top-level await support via an async $init promise export')
|
|
@@ -64,6 +65,7 @@ program.command('run')
|
|
|
64
65
|
.option('--jco-trace', 'Enable call tracing')
|
|
65
66
|
.option('--jco-import <module>', 'Custom module to import before the run executes to support custom environment setup')
|
|
66
67
|
.option('--jco-map <mappings...>', 'specifier=./output custom mappings for the component imports')
|
|
68
|
+
.addOption(new Option('--jco-import-bindings [mode]', 'bindings mode for imports').choices(['js', 'optimized', 'hybrid', 'direct-optimized']).preset('js'))
|
|
67
69
|
.argument('[args...]', 'Any CLI arguments for the component')
|
|
68
70
|
.action(asyncAction(async function run (cmd, args, opts, command) {
|
|
69
71
|
// specially only allow help option in first position
|
|
@@ -86,6 +88,7 @@ program.command('serve')
|
|
|
86
88
|
.option('--jco-dir <dir>', 'Instead of using a temporary dir, set the output directory for the transpiled code')
|
|
87
89
|
.option('--jco-trace', 'Enable call tracing')
|
|
88
90
|
.option('--jco-import <module>', 'Custom module to import before the server executes to support custom environment setup')
|
|
91
|
+
.addOption(new Option('--jco-import-bindings [mode]', 'bindings mode for imports').choices(['js', 'optimized', 'hybrid', 'direct-optimized']).preset('js'))
|
|
89
92
|
.option('--jco-map <mappings...>', 'specifier=./output custom mappings for the component imports')
|
|
90
93
|
.argument('[args...]', 'Any CLI arguments for the component')
|
|
91
94
|
.action(asyncAction(async function serve (cmd, args, opts, command) {
|