@bytecodealliance/jco 1.24.0 → 1.24.2
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/package.json +4 -7
- package/src/api.js +9 -61
- package/src/cmd/componentize.js +2 -7
- package/src/cmd/opt.js +5 -7
- package/src/cmd/run.js +2 -2
- package/src/cmd/transpile.js +36 -604
- package/src/cmd/types.js +17 -8
- package/src/cmd/wasm-tools.js +17 -24
- package/src/jco.js +3 -3
- package/types/api.d.ts +1 -31
- package/types/api.d.ts.map +1 -1
- package/types/cmd/componentize.d.ts.map +1 -1
- package/types/cmd/opt.d.ts.map +1 -1
- package/types/cmd/transpile.d.ts +25 -15
- package/types/cmd/transpile.d.ts.map +1 -1
- package/types/cmd/types.d.ts.map +1 -1
- package/types/cmd/wasm-tools.d.ts.map +1 -1
- package/obj/interfaces/local-wasm-tools-tools.d.ts +0 -79
- package/obj/interfaces/wasi-cli-environment.d.ts +0 -2
- package/obj/interfaces/wasi-cli-exit.d.ts +0 -3
- package/obj/interfaces/wasi-cli-stderr.d.ts +0 -3
- package/obj/interfaces/wasi-cli-stdin.d.ts +0 -3
- package/obj/interfaces/wasi-cli-stdout.d.ts +0 -3
- package/obj/interfaces/wasi-cli-terminal-input.d.ts +0 -8
- package/obj/interfaces/wasi-cli-terminal-output.d.ts +0 -8
- package/obj/interfaces/wasi-cli-terminal-stderr.d.ts +0 -3
- package/obj/interfaces/wasi-cli-terminal-stdin.d.ts +0 -3
- package/obj/interfaces/wasi-cli-terminal-stdout.d.ts +0 -3
- package/obj/interfaces/wasi-clocks-wall-clock.d.ts +0 -5
- package/obj/interfaces/wasi-filesystem-preopens.d.ts +0 -3
- package/obj/interfaces/wasi-filesystem-types.d.ts +0 -165
- package/obj/interfaces/wasi-io-error.d.ts +0 -8
- package/obj/interfaces/wasi-io-streams.d.ts +0 -30
- package/obj/interfaces/wasi-random-random.d.ts +0 -2
- 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 +0 -120
- package/obj/js-component-bindgen-component.js +0 -13637
- package/obj/wasm-tools.core.wasm +0 -0
- package/obj/wasm-tools.core2.wasm +0 -0
- package/obj/wasm-tools.d.ts +0 -20
- package/obj/wasm-tools.js +0 -14389
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bytecodealliance/jco",
|
|
3
|
-
"version": "1.24.
|
|
3
|
+
"version": "1.24.2",
|
|
4
4
|
"description": "JavaScript tooling for working with WebAssembly Components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Component",
|
|
@@ -32,11 +32,7 @@
|
|
|
32
32
|
"files": [
|
|
33
33
|
"lib",
|
|
34
34
|
"src",
|
|
35
|
-
"types"
|
|
36
|
-
"obj/*.core*.wasm",
|
|
37
|
-
"obj/*.js",
|
|
38
|
-
"obj/*.ts",
|
|
39
|
-
"obj/interfaces"
|
|
35
|
+
"types"
|
|
40
36
|
],
|
|
41
37
|
"type": "module",
|
|
42
38
|
"main": "src/jco.js",
|
|
@@ -62,9 +58,10 @@
|
|
|
62
58
|
"dependencies": {
|
|
63
59
|
"@bytecodealliance/componentize-js": "^0.21.0",
|
|
64
60
|
"@bytecodealliance/componentize-js-0-19-3": "npm:@bytecodealliance/componentize-js@^0.19.3",
|
|
61
|
+
"@bytecodealliance/jco-transpile": "^0.3.3",
|
|
65
62
|
"@bytecodealliance/preview2-shim": "^0.17.9",
|
|
66
63
|
"@bytecodealliance/preview3-shim": "^0.1.2",
|
|
67
|
-
"binaryen": "^
|
|
64
|
+
"binaryen": "^130.0.0",
|
|
68
65
|
"commander": "^14",
|
|
69
66
|
"mkdirp": "^3",
|
|
70
67
|
"ora": "^8",
|
package/src/api.js
CHANGED
|
@@ -1,68 +1,16 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
export { optimizeComponent as opt } from "./cmd/opt.js";
|
|
3
3
|
export { transpileComponent as transpile, typesComponent as types } from "./cmd/transpile.js";
|
|
4
|
-
import { $init, tools } from "../obj/wasm-tools.js";
|
|
5
|
-
const {
|
|
6
|
-
print: printFn,
|
|
7
|
-
parse: parseFn,
|
|
8
|
-
componentWit: componentWitFn,
|
|
9
|
-
componentNew: componentNewFn,
|
|
10
|
-
componentEmbed: componentEmbedFn,
|
|
11
|
-
metadataAdd: metadataAddFn,
|
|
12
|
-
metadataShow: metadataShowFn,
|
|
13
|
-
} = tools;
|
|
14
4
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
*/
|
|
25
|
-
export async function parse(wat) {
|
|
26
|
-
await $init;
|
|
27
|
-
return parseFn(wat);
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* @param {Uint8Array} binary
|
|
31
|
-
*/
|
|
32
|
-
export async function componentWit(binary) {
|
|
33
|
-
await $init;
|
|
34
|
-
return componentWitFn(binary);
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* @param {Uint8Array} binary
|
|
38
|
-
* @param {Array<[string, Uint8Array]>} [adapters]
|
|
39
|
-
*/
|
|
40
|
-
export async function componentNew(binary, adapters) {
|
|
41
|
-
await $init;
|
|
42
|
-
return componentNewFn(binary, adapters);
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* @param {tools.EmbedOpts} embedOpts
|
|
46
|
-
*/
|
|
47
|
-
export async function componentEmbed(embedOpts) {
|
|
48
|
-
await $init;
|
|
49
|
-
return componentEmbedFn(embedOpts);
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* @param {Uint8Array} binary
|
|
53
|
-
* @param {tools.ProducersFields} metadata
|
|
54
|
-
*/
|
|
55
|
-
export async function metadataAdd(binary, metadata) {
|
|
56
|
-
await $init;
|
|
57
|
-
return metadataAddFn(binary, metadata);
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* @param {Uint8Array} binary
|
|
61
|
-
*/
|
|
62
|
-
export async function metadataShow(binary) {
|
|
63
|
-
await $init;
|
|
64
|
-
return metadataShowFn(binary);
|
|
65
|
-
}
|
|
5
|
+
export {
|
|
6
|
+
print,
|
|
7
|
+
parse,
|
|
8
|
+
componentWit,
|
|
9
|
+
componentNew,
|
|
10
|
+
componentEmbed,
|
|
11
|
+
metadataAdd,
|
|
12
|
+
metadataShow,
|
|
13
|
+
} from "@bytecodealliance/jco-transpile/wasm-tools";
|
|
66
14
|
|
|
67
15
|
export function preview1AdapterCommandPath() {
|
|
68
16
|
return new URL("../lib/wasi_snapshot_preview1.command.wasm", import.meta.url);
|
package/src/cmd/componentize.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { stat, readFile, writeFile } from "node:fs/promises";
|
|
2
2
|
import { resolve, basename } from "node:path";
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import { componentWitMetadataForWorld } from "@bytecodealliance/jco-transpile";
|
|
5
5
|
|
|
6
6
|
import { styleText, isWindows } from "../common.js";
|
|
7
7
|
|
|
@@ -19,13 +19,8 @@ const DEBUG_FEATURES = ["stdio"];
|
|
|
19
19
|
* @returns bool
|
|
20
20
|
*/
|
|
21
21
|
async function usesOlderWasiHTTP(witPath, worldName) {
|
|
22
|
-
await wasmToolsComponent.$init;
|
|
23
|
-
|
|
24
22
|
witPath = (isWindows ? "//?/" : "") + resolve(witPath);
|
|
25
|
-
const worldMetadata =
|
|
26
|
-
{ tag: "path", val: witPath },
|
|
27
|
-
worldName ?? null,
|
|
28
|
-
);
|
|
23
|
+
const worldMetadata = await componentWitMetadataForWorld({ tag: "path", val: witPath }, worldName ?? null);
|
|
29
24
|
|
|
30
25
|
// Check if the an old `wasi:http/incoming-handler` version is exported
|
|
31
26
|
const exportsOldIncomingHandler = worldMetadata.exports.some((iface) => {
|
package/src/cmd/opt.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
+
import { fileURLToPath } from "node:url";
|
|
1
2
|
import { writeFile } from "node:fs/promises";
|
|
2
3
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { metadataShow, print } from "@bytecodealliance/jco-transpile/wasm-tools";
|
|
5
|
+
|
|
6
6
|
import { readFile, sizeStr, fixedDigitDisplay, table, spawnIOTmp, setShowSpinner, getShowSpinner } from "../common.js";
|
|
7
7
|
import ora from "#ora";
|
|
8
8
|
|
|
9
9
|
import { styleText } from "../common.js";
|
|
10
10
|
|
|
11
11
|
export async function opt(componentPath, opts, program) {
|
|
12
|
-
await $init;
|
|
13
12
|
const varIdx = program.parent.rawArgs.indexOf("--");
|
|
14
13
|
if (varIdx !== -1) {
|
|
15
14
|
opts.optArgs = program.parent.rawArgs.slice(varIdx + 1);
|
|
@@ -81,11 +80,10 @@ function byteLengthLEB128(val) {
|
|
|
81
80
|
* @returns {Promise<{ component: Uint8Array, compressionInfo: { beforeBytes: number, afterBytes: number }[] >}
|
|
82
81
|
*/
|
|
83
82
|
export async function optimizeComponent(componentBytes, opts) {
|
|
84
|
-
await $init;
|
|
85
83
|
const showSpinner = getShowSpinner();
|
|
86
84
|
let spinner;
|
|
87
85
|
try {
|
|
88
|
-
let componentMetadata = metadataShow(componentBytes);
|
|
86
|
+
let componentMetadata = await metadataShow(componentBytes);
|
|
89
87
|
componentMetadata.forEach((metadata, index) => {
|
|
90
88
|
// add index to the metadata object
|
|
91
89
|
metadata.index = index;
|
|
@@ -211,7 +209,7 @@ export async function optimizeComponent(componentBytes, opts) {
|
|
|
211
209
|
// verify it still parses ok
|
|
212
210
|
if (!opts?.noVerify) {
|
|
213
211
|
try {
|
|
214
|
-
print(outComponentBytes);
|
|
212
|
+
await print(outComponentBytes);
|
|
215
213
|
} catch (e) {
|
|
216
214
|
throw new Error(`Internal error performing optimization.\n${e.message}`);
|
|
217
215
|
}
|
package/src/cmd/run.js
CHANGED
|
@@ -5,7 +5,7 @@ import process from "node:process";
|
|
|
5
5
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
6
6
|
|
|
7
7
|
import { getTmpDir, styleText } from "../common.js";
|
|
8
|
-
import {
|
|
8
|
+
import { transpileCmd } from "./transpile.js";
|
|
9
9
|
|
|
10
10
|
const DEFAULT_SERVE_HOST = "localhost";
|
|
11
11
|
|
|
@@ -85,7 +85,7 @@ async function runComponent(componentPath, args, opts, executor) {
|
|
|
85
85
|
|
|
86
86
|
try {
|
|
87
87
|
try {
|
|
88
|
-
await
|
|
88
|
+
await transpileCmd(componentPath, {
|
|
89
89
|
name,
|
|
90
90
|
quiet: true,
|
|
91
91
|
noTypescript: true,
|