@bytecodealliance/jco 0.12.3 → 0.13.1
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/lib/wasi_snapshot_preview1.command.wasm +0 -0
- package/lib/wasi_snapshot_preview1.reactor.wasm +0 -0
- package/obj/interfaces/wasi-cli-stderr.d.ts +1 -1
- package/obj/interfaces/wasi-cli-stdin.d.ts +1 -1
- package/obj/interfaces/wasi-cli-stdout.d.ts +1 -1
- package/obj/interfaces/wasi-cli-terminal-input.d.ts +4 -2
- package/obj/interfaces/wasi-cli-terminal-output.d.ts +4 -2
- package/obj/interfaces/wasi-cli-terminal-stderr.d.ts +1 -1
- package/obj/interfaces/wasi-cli-terminal-stdin.d.ts +1 -1
- package/obj/interfaces/wasi-cli-terminal-stdout.d.ts +1 -1
- package/obj/interfaces/wasi-filesystem-preopens.d.ts +1 -1
- package/obj/interfaces/wasi-filesystem-types.d.ts +24 -17
- package/obj/interfaces/wasi-io-streams.d.ts +26 -26
- package/obj/interfaces/wasi-sockets-tcp.d.ts +4 -0
- 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 +1 -0
- package/obj/js-component-bindgen-component.js +992 -682
- 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.d.ts +1 -0
- package/obj/wasm-tools.js +992 -682
- package/package.json +4 -4
- package/src/cmd/run.js +21 -27
- package/src/jco.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bytecodealliance/jco",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.1",
|
|
4
4
|
"description": "JavaScript tooling for working with WebAssembly Components",
|
|
5
5
|
"author": "Guy Bedford",
|
|
6
6
|
"bin": {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"type": "module",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@bytecodealliance/preview2-shim": "0.0.
|
|
21
|
+
"@bytecodealliance/preview2-shim": "0.0.20",
|
|
22
22
|
"binaryen": "^111.0.0",
|
|
23
23
|
"chalk-template": "^0.4.0",
|
|
24
24
|
"commander": "^9.4.1",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"terser": "^5.16.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@bytecodealliance/componentize-js": "^0.
|
|
30
|
+
"@bytecodealliance/componentize-js": "^0.4.0",
|
|
31
31
|
"@types/node": "^18.11.17",
|
|
32
32
|
"@typescript-eslint/eslint-plugin": "^5.41.0",
|
|
33
33
|
"@typescript-eslint/parser": "^5.41.0",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"homepage": "https://github.com/bytecodealliance/jco#readme",
|
|
53
53
|
"scripts": {
|
|
54
54
|
"build": "cargo xtask build workspace",
|
|
55
|
-
"build:types:preview2-shim": "cargo xtask
|
|
55
|
+
"build:types:preview2-shim": "cargo xtask generate wasi-types",
|
|
56
56
|
"lint": "eslint -c eslintrc.cjs lib/**/*.js packages/*/lib/**/*.js",
|
|
57
57
|
"test": "mocha -u tdd test/test.js --timeout 120000"
|
|
58
58
|
},
|
package/src/cmd/run.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { getTmpDir } from '../common.js';
|
|
2
2
|
import { transpile } from './transpile.js';
|
|
3
|
-
import { rm, stat, mkdir, writeFile, symlink
|
|
3
|
+
import { rm, stat, mkdir, writeFile, symlink } from 'node:fs/promises';
|
|
4
4
|
import { basename, resolve, extname } from 'node:path';
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
5
|
+
import { fork } from 'node:child_process';
|
|
6
|
+
import process from 'node:process';
|
|
7
7
|
import { fileURLToPath } from 'node:url';
|
|
8
8
|
import c from 'chalk-template';
|
|
9
9
|
|
|
10
10
|
export async function run (componentPath, args) {
|
|
11
|
+
// Ensure that `args` is an array
|
|
12
|
+
args = [...args];
|
|
13
|
+
|
|
11
14
|
const name = basename(componentPath.slice(0, -extname(componentPath).length || Infinity));
|
|
12
15
|
const outDir = await getTmpDir();
|
|
13
|
-
let cp;
|
|
14
16
|
try {
|
|
15
17
|
try {
|
|
16
18
|
await transpile(componentPath, {
|
|
@@ -22,11 +24,9 @@ export async function run (componentPath, args) {
|
|
|
22
24
|
});
|
|
23
25
|
}
|
|
24
26
|
catch (e) {
|
|
25
|
-
|
|
26
|
-
throw e;
|
|
27
|
+
throw new Error('Unable to transpile command for execution', { cause: e });
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
await mkdir(resolve(outDir, 'node_modules', '@bytecodealliance'), { recursive: true });
|
|
30
30
|
await writeFile(resolve(outDir, 'package.json'), JSON.stringify({ type: 'module' }));
|
|
31
31
|
|
|
32
32
|
let preview2ShimPath = fileURLToPath(new URL('../../node_modules/@bytecodealliance/preview2-shim', import.meta.url));
|
|
@@ -38,14 +38,15 @@ export async function run (componentPath, args) {
|
|
|
38
38
|
}
|
|
39
39
|
catch {}
|
|
40
40
|
let len = preview2ShimPath.length;
|
|
41
|
-
preview2ShimPath = resolve(preview2ShimPath, '
|
|
41
|
+
preview2ShimPath = resolve(preview2ShimPath, '..', '..', '..', 'node_modules', '@bytecodealliance', 'preview2-shim');
|
|
42
42
|
if (preview2ShimPath.length === len) {
|
|
43
|
-
|
|
44
|
-
return;
|
|
43
|
+
throw c`Unable to locate the {bold @bytecodealliance/preview2-shim} package, make sure it is installed.`;
|
|
45
44
|
}
|
|
46
45
|
}
|
|
47
46
|
|
|
48
|
-
|
|
47
|
+
const modulesDir = resolve(outDir, 'node_modules', '@bytecodealliance');
|
|
48
|
+
await mkdir(modulesDir, { recursive: true });
|
|
49
|
+
await symlink(preview2ShimPath, resolve(modulesDir, 'preview2-shim'), 'dir');
|
|
49
50
|
|
|
50
51
|
const runPath = resolve(outDir, '_run.js');
|
|
51
52
|
await writeFile(runPath, `
|
|
@@ -71,24 +72,17 @@ export async function run (componentPath, args) {
|
|
|
71
72
|
throw e;
|
|
72
73
|
}
|
|
73
74
|
`);
|
|
74
|
-
await chmod(runPath, 0o777);
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
process.exitCode = await new Promise((resolve, reject) => {
|
|
77
|
+
const cp = fork(runPath, args, { stdio: 'inherit' });
|
|
78
|
+
|
|
79
|
+
cp.on('error', reject);
|
|
80
|
+
cp.on('exit', resolve);
|
|
81
|
+
});
|
|
77
82
|
}
|
|
78
83
|
finally {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
} catch {}
|
|
83
|
-
}
|
|
84
|
+
try {
|
|
85
|
+
await rm(outDir, { recursive: true });
|
|
86
|
+
} catch {}
|
|
84
87
|
}
|
|
85
|
-
|
|
86
|
-
const exitCode = await new Promise((resolve, reject) => {
|
|
87
|
-
cp.on('error', reject);
|
|
88
|
-
cp.on('exit', resolve);
|
|
89
|
-
});
|
|
90
|
-
try {
|
|
91
|
-
await rm(outDir, { recursive: true });
|
|
92
|
-
} catch {}
|
|
93
|
-
exit(exitCode);
|
|
94
88
|
}
|
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('0.
|
|
14
|
+
.version('0.13.1');
|
|
15
15
|
|
|
16
16
|
function myParseInt(value) {
|
|
17
17
|
return parseInt(value, 10);
|