@bytecodealliance/jco 0.14.2 → 1.0.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/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 +12 -4
- 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.js +23 -23
- 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 +1163 -243
- package/package.json +4 -4
- package/src/api.d.ts +7 -7
- package/src/api.d.ts.map +1 -1
- package/src/cmd/run.d.ts +1 -0
- package/src/cmd/run.d.ts.map +1 -1
- package/src/cmd/transpile.d.ts.map +1 -1
- package/src/cmd/transpile.js +19 -4
- package/src/cmd/wasm-tools.d.ts.map +1 -1
- package/src/cmd/wasm-tools.js +0 -1
- package/src/jco.js +3 -2
- package/obj/interfaces/wasi-sockets-tcp.d.ts +0 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bytecodealliance/jco",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
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.
|
|
21
|
+
"@bytecodealliance/preview2-shim": "0.15.1",
|
|
22
22
|
"binaryen": "^111.0.0",
|
|
23
23
|
"chalk-template": "^0.4.0",
|
|
24
24
|
"commander": "^9.4.1",
|
|
@@ -27,14 +27,14 @@
|
|
|
27
27
|
"terser": "^5.16.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@bytecodealliance/componentize-js": "^0.
|
|
30
|
+
"@bytecodealliance/componentize-js": "^0.6.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",
|
|
34
34
|
"eslint": "^8.30.0",
|
|
35
35
|
"mocha": "^10.2.0",
|
|
36
36
|
"terser": "^5.16.1",
|
|
37
|
-
"typescript": "^
|
|
37
|
+
"typescript": "^5.3.3"
|
|
38
38
|
},
|
|
39
39
|
"repository": {
|
|
40
40
|
"type": "git",
|
package/src/api.d.ts
CHANGED
|
@@ -2,39 +2,39 @@
|
|
|
2
2
|
* @param {Parameters<import('../obj/wasm-tools.js').print>[0]} binary
|
|
3
3
|
* @return {Promise<ReturnType<import('../obj/wasm-tools.js').print>>}
|
|
4
4
|
*/
|
|
5
|
-
export function print(binary:
|
|
5
|
+
export function print(binary: any): Promise<ReturnType<import('../obj/wasm-tools.js').print>>;
|
|
6
6
|
/**
|
|
7
7
|
* @param {Parameters<import('../obj/wasm-tools.js').parse>[0]} wat
|
|
8
8
|
* @return {Promise<ReturnType<import('../obj/wasm-tools.js').parse>>}
|
|
9
9
|
*/
|
|
10
|
-
export function parse(wat:
|
|
10
|
+
export function parse(wat: any): Promise<ReturnType<import('../obj/wasm-tools.js').parse>>;
|
|
11
11
|
/**
|
|
12
12
|
* @param {Parameters<import('../obj/wasm-tools.js').componentWit>[0]} binary
|
|
13
13
|
* @return {Promise<ReturnType<import('../obj/wasm-tools.js').componentWit>>}
|
|
14
14
|
*/
|
|
15
|
-
export function componentWit(binary:
|
|
15
|
+
export function componentWit(binary: any): Promise<ReturnType<import('../obj/wasm-tools.js').componentWit>>;
|
|
16
16
|
/**
|
|
17
17
|
* @param {Parameters<import('../obj/wasm-tools.js').componentNew>[0]} binary
|
|
18
18
|
* @param {Parameters<import('../obj/wasm-tools.js').componentNew>[1]} adapters
|
|
19
19
|
* @return {Promise<ReturnType<import('../obj/wasm-tools.js').componentNew>>}
|
|
20
20
|
*/
|
|
21
|
-
export function componentNew(binary:
|
|
21
|
+
export function componentNew(binary: any, adapters: any): Promise<ReturnType<import('../obj/wasm-tools.js').componentNew>>;
|
|
22
22
|
/**
|
|
23
23
|
* @param {Parameters<import('../obj/wasm-tools.js').componentEmbed>[0]} embedOpts
|
|
24
24
|
* @return {Promise<ReturnType<import('../obj/wasm-tools.js').componentEmbed>>}
|
|
25
25
|
*/
|
|
26
|
-
export function componentEmbed(embedOpts:
|
|
26
|
+
export function componentEmbed(embedOpts: any): Promise<ReturnType<import('../obj/wasm-tools.js').componentEmbed>>;
|
|
27
27
|
/**
|
|
28
28
|
* @param {Parameters<import('../obj/wasm-tools.js').metadataAdd>[0]} binary
|
|
29
29
|
* @param {Parameters<import('../obj/wasm-tools.js').metadataAdd>[1]} metadata
|
|
30
30
|
* @return {Promise<ReturnType<import('../obj/wasm-tools.js').metadataAdd>>}
|
|
31
31
|
*/
|
|
32
|
-
export function metadataAdd(binary:
|
|
32
|
+
export function metadataAdd(binary: any, metadata: any): Promise<ReturnType<import('../obj/wasm-tools.js').metadataAdd>>;
|
|
33
33
|
/**
|
|
34
34
|
* @param {Parameters<import('../obj/wasm-tools.js').metadataShow>[0]} binary
|
|
35
35
|
* @return {Promise<ReturnType<import('../obj/wasm-tools.js').metadataShow>>}
|
|
36
36
|
*/
|
|
37
|
-
export function metadataShow(binary:
|
|
37
|
+
export function metadataShow(binary: any): Promise<ReturnType<import('../obj/wasm-tools.js').metadataShow>>;
|
|
38
38
|
export function preview1AdapterCommandPath(): URL;
|
|
39
39
|
export function preview1AdapterReactorPath(): URL;
|
|
40
40
|
export { optimizeComponent as opt } from "./cmd/opt.js";
|
package/src/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["api.js"],"names":[],"mappings":"AAKA;;;GAGG;AACH,
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["api.js"],"names":[],"mappings":"AAKA;;;GAGG;AACH,oCAFY,QAAQ,WAAW,OAAO,sBAAsB,EAAE,KAAK,CAAC,CAAC,CAKpE;AACD;;;GAGG;AACH,iCAFY,QAAQ,WAAW,OAAO,sBAAsB,EAAE,KAAK,CAAC,CAAC,CAKpE;AACD;;;GAGG;AACH,2CAFY,QAAQ,WAAW,OAAO,sBAAsB,EAAE,YAAY,CAAC,CAAC,CAK3E;AACD;;;;GAIG;AACH,0DAFY,QAAQ,WAAW,OAAO,sBAAsB,EAAE,YAAY,CAAC,CAAC,CAK3E;AACD;;;GAGG;AACH,gDAFY,QAAQ,WAAW,OAAO,sBAAsB,EAAE,cAAc,CAAC,CAAC,CAK7E;AACD;;;;GAIG;AACH,yDAFY,QAAQ,WAAW,OAAO,sBAAsB,EAAE,WAAW,CAAC,CAAC,CAK1E;AACD;;;GAGG;AACH,2CAFY,QAAQ,WAAW,OAAO,sBAAsB,EAAE,YAAY,CAAC,CAAC,CAK3E;AACD,kDAEC;AACD,kDAEC"}
|
package/src/cmd/run.d.ts
CHANGED
package/src/cmd/run.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["run.js"],"names":[],"mappings":"AASA,
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["run.js"],"names":[],"mappings":"AASA,6EAmBC;AAED,+EA2BC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transpile.d.ts","sourceRoot":"","sources":["transpile.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"transpile.d.ts","sourceRoot":"","sources":["transpile.js"],"names":[],"mappings":"AAgBA,sFAqCC;AAuBD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,8CAlBW,UAAU;UAEV,MAAM;oBACI,OAAO,GAAG,MAAM;UAC1B,OAAO,MAAM,EAAE,MAAM,CAAC;;;;;;;;;;cAUlB,MAAM,EAAE;;;;;aAEoD,MAAM,EAAE;aAAW,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC,EAAE;GAiShI"}
|
package/src/cmd/transpile.js
CHANGED
|
@@ -1,19 +1,34 @@
|
|
|
1
1
|
import { $init, generate } from '../../obj/js-component-bindgen-component.js';
|
|
2
|
-
import { writeFile } from 'fs/promises';
|
|
3
|
-
import { mkdir } from 'fs/promises';
|
|
4
|
-
import { dirname, extname, basename } from 'path';
|
|
2
|
+
import { writeFile } from 'node:fs/promises';
|
|
3
|
+
import { mkdir } from 'node:fs/promises';
|
|
4
|
+
import { dirname, extname, basename, resolve } from 'node:path';
|
|
5
5
|
import c from 'chalk-template';
|
|
6
6
|
import { readFile, sizeStr, table, spawnIOTmp, setShowSpinner, getShowSpinner } from '../common.js';
|
|
7
7
|
import { optimizeComponent } from './opt.js';
|
|
8
8
|
import { minify } from 'terser';
|
|
9
9
|
import { fileURLToPath } from 'url';
|
|
10
|
+
import { $init as wasmToolsInit, tools } from "../../obj/wasm-tools.js";
|
|
11
|
+
const { componentEmbed, componentNew } = tools;
|
|
10
12
|
import ora from '#ora';
|
|
13
|
+
import { platform } from 'node:process';
|
|
14
|
+
|
|
15
|
+
const isWindows = platform === 'win32';
|
|
11
16
|
|
|
12
17
|
export async function transpile (componentPath, opts, program) {
|
|
13
18
|
const varIdx = program?.parent.rawArgs.indexOf('--');
|
|
14
19
|
if (varIdx !== undefined && varIdx !== -1)
|
|
15
20
|
opts.optArgs = program.parent.rawArgs.slice(varIdx + 1);
|
|
16
|
-
|
|
21
|
+
|
|
22
|
+
let component;
|
|
23
|
+
if (!opts.stub) {
|
|
24
|
+
component = await readFile(componentPath);
|
|
25
|
+
} else {
|
|
26
|
+
await wasmToolsInit;
|
|
27
|
+
component = componentNew(componentEmbed({
|
|
28
|
+
dummy: true,
|
|
29
|
+
witPath: (isWindows ? '//?/' : '') + resolve(componentPath)
|
|
30
|
+
}), []);
|
|
31
|
+
}
|
|
17
32
|
|
|
18
33
|
if (!opts.quiet)
|
|
19
34
|
setShowSpinner(true);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wasm-tools.d.ts","sourceRoot":"","sources":["wasm-tools.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wasm-tools.d.ts","sourceRoot":"","sources":["wasm-tools.js"],"names":[],"mappings":"AAOA,2DAKC;AAED,2DASC;AAED,kEASC;AAED,kEAsBC;AAED,oEAaC;AAED,iEAUC;AAED,kEAiCC"}
|
package/src/cmd/wasm-tools.js
CHANGED
|
@@ -4,7 +4,6 @@ import { $init, tools } from "../../obj/wasm-tools.js";
|
|
|
4
4
|
const { print: printFn, parse: parseFn, componentWit: componentWitFn, componentNew: componentNewFn, componentEmbed: componentEmbedFn, metadataAdd: metadataAddFn, metadataShow: metadataShowFn } = tools;
|
|
5
5
|
import { resolve, basename, extname } from 'node:path';
|
|
6
6
|
import c from 'chalk-template';
|
|
7
|
-
import { platform } from 'node:process';
|
|
8
7
|
|
|
9
8
|
export async function parse(file, opts) {
|
|
10
9
|
await $init;
|
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('1.0.0');
|
|
15
15
|
|
|
16
16
|
function myParseInt(value) {
|
|
17
17
|
return parseInt(value, 10);
|
|
@@ -19,7 +19,7 @@ function myParseInt(value) {
|
|
|
19
19
|
|
|
20
20
|
program.command('componentize')
|
|
21
21
|
.description('Create a component from a JavaScript module')
|
|
22
|
-
.usage('<js-source> -o <component-path>')
|
|
22
|
+
.usage('<js-source> --wit wit-world.wit -o <component-path>')
|
|
23
23
|
.argument('<js-source>', 'JS source file to build')
|
|
24
24
|
.requiredOption('-w, --wit <path>', 'WIT path to build with')
|
|
25
25
|
.option('-n, --world-name <name>', 'WIT world to build')
|
|
@@ -44,6 +44,7 @@ program.command('transpile')
|
|
|
44
44
|
.option('--no-nodejs-compat', 'disables compatibility in Node.js without a fetch global')
|
|
45
45
|
.option('-M, --map <mappings...>', 'specifier=./output custom mappings for the component imports')
|
|
46
46
|
.option('--no-wasi-shim', 'disable automatic rewriting of WASI imports to use @bytecodealliance/preview2-shim')
|
|
47
|
+
.option('--stub', 'generate a stub implementation from a WIT file directly')
|
|
47
48
|
.option('--js', 'output JS instead of core WebAssembly')
|
|
48
49
|
.addOption(new Option('-I, --instantiation [mode]', 'output for custom module instantiation').choices(['async', 'sync']).preset('async'))
|
|
49
50
|
.option('-q, --quiet', 'disable logging')
|