@bytecodealliance/jco 1.25.1 → 1.26.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/README.md +27 -4
- package/dist/api.d.ts +6 -0
- package/dist/api.d.ts.map +1 -0
- package/{src → dist}/api.js +2 -12
- package/dist/api.js.map +1 -0
- package/dist/browser.d.ts +5 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +12 -0
- package/dist/browser.js.map +1 -0
- package/dist/bundle.d.ts +42 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +124 -0
- package/dist/bundle.js.map +1 -0
- package/dist/cmd/componentize.d.ts +34 -0
- package/dist/cmd/componentize.d.ts.map +1 -0
- package/dist/cmd/componentize.js +243 -0
- package/dist/cmd/componentize.js.map +1 -0
- package/{types → dist}/cmd/opt.d.ts +17 -12
- package/dist/cmd/opt.d.ts.map +1 -0
- package/{src → dist}/cmd/opt.js +53 -87
- package/dist/cmd/opt.js.map +1 -0
- package/dist/cmd/run.d.ts +3 -0
- package/dist/cmd/run.d.ts.map +1 -0
- package/{src → dist}/cmd/run.js +24 -54
- package/dist/cmd/run.js.map +1 -0
- package/dist/cmd/transpile.d.ts +48 -0
- package/dist/cmd/transpile.d.ts.map +1 -0
- package/{src → dist}/cmd/transpile.js +1 -36
- package/dist/cmd/transpile.js.map +1 -0
- package/{types → dist}/cmd/types.d.ts +21 -22
- package/dist/cmd/types.d.ts.map +1 -0
- package/{src → dist}/cmd/types.js +27 -51
- package/dist/cmd/types.js.map +1 -0
- package/dist/cmd/wasm-tools.d.ts +8 -0
- package/dist/cmd/wasm-tools.d.ts.map +1 -0
- package/{src → dist}/cmd/wasm-tools.js +28 -42
- package/dist/cmd/wasm-tools.js.map +1 -0
- package/{types → dist}/common.d.ts +27 -25
- package/dist/common.d.ts.map +1 -0
- package/{src → dist}/common.js +19 -44
- package/dist/common.js.map +1 -0
- package/{types → dist}/jco.d.ts.map +1 -1
- package/{src → dist}/jco.js +74 -149
- package/dist/jco.js.map +1 -0
- package/dist/ora-shim.d.ts +9 -0
- package/dist/ora-shim.d.ts.map +1 -0
- package/dist/ora-shim.js +10 -0
- package/dist/ora-shim.js.map +1 -0
- package/package.json +22 -22
- package/src/browser.js +0 -18
- package/src/cmd/componentize.js +0 -170
- package/src/ora-shim.js +0 -9
- package/types/api.d.ts +0 -6
- package/types/api.d.ts.map +0 -1
- package/types/browser.d.ts +0 -4
- package/types/browser.d.ts.map +0 -1
- package/types/cmd/componentize.d.ts +0 -2
- package/types/cmd/componentize.d.ts.map +0 -1
- package/types/cmd/opt.d.ts.map +0 -1
- package/types/cmd/run.d.ts +0 -3
- package/types/cmd/run.d.ts.map +0 -1
- package/types/cmd/transpile.d.ts +0 -72
- package/types/cmd/transpile.d.ts.map +0 -1
- package/types/cmd/types.d.ts.map +0 -1
- package/types/cmd/wasm-tools.d.ts +0 -8
- package/types/cmd/wasm-tools.d.ts.map +0 -1
- package/types/common.d.ts.map +0 -1
- package/types/ora-shim.d.ts +0 -8
- package/types/ora-shim.d.ts.map +0 -1
- /package/{types → dist}/jco.d.ts +0 -0
|
@@ -1,5 +1,23 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
1
|
+
export interface TypesOptions {
|
|
2
|
+
name?: string;
|
|
3
|
+
worldName?: string;
|
|
4
|
+
instantiation?: "async" | "sync";
|
|
5
|
+
tlaCompat?: boolean;
|
|
6
|
+
asyncMode?: string;
|
|
7
|
+
asyncImports?: string[];
|
|
8
|
+
asyncExports?: string[];
|
|
9
|
+
outDir?: string;
|
|
10
|
+
allFeatures?: boolean;
|
|
11
|
+
feature?: string[] | "all";
|
|
12
|
+
features?: string[] | "all";
|
|
13
|
+
asyncWasiImports?: string[];
|
|
14
|
+
asyncWasiExports?: string[];
|
|
15
|
+
guest?: boolean;
|
|
16
|
+
quiet?: boolean;
|
|
17
|
+
strict?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare function types(witPath: string | undefined, opts: TypesOptions): Promise<void>;
|
|
20
|
+
export declare function guestTypes(witPath: string | undefined, opts: TypesOptions): Promise<void>;
|
|
3
21
|
/**
|
|
4
22
|
* @param {string} witPath
|
|
5
23
|
* @param {{
|
|
@@ -22,24 +40,5 @@ export function guestTypes(witPath: any, opts: any): Promise<void>;
|
|
|
22
40
|
* }} opts
|
|
23
41
|
* @returns {Promise<{ [filename: string]: Uint8Array }>}
|
|
24
42
|
*/
|
|
25
|
-
export function typesComponent(witPath: string, opts:
|
|
26
|
-
name?: string;
|
|
27
|
-
worldName?: string;
|
|
28
|
-
instantiation?: "async" | "sync";
|
|
29
|
-
tlaCompat?: bool;
|
|
30
|
-
asyncMode?: string;
|
|
31
|
-
asyncImports?: string[];
|
|
32
|
-
asyncExports?: string[];
|
|
33
|
-
outDir?: string;
|
|
34
|
-
allFeatures?: bool;
|
|
35
|
-
feature?: string[] | "all";
|
|
36
|
-
features?: string[] | "all";
|
|
37
|
-
asyncWasiImports?: string[];
|
|
38
|
-
asyncWasiExports?: string[];
|
|
39
|
-
asyncExports?: string[];
|
|
40
|
-
asyncImports?: string[];
|
|
41
|
-
guest?: bool;
|
|
42
|
-
}): Promise<{
|
|
43
|
-
[filename: string]: Uint8Array;
|
|
44
|
-
}>;
|
|
43
|
+
export declare function typesComponent(witPath: string, opts: TypesOptions): Promise<Record<string, Uint8Array>>;
|
|
45
44
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/cmd/types.ts"],"names":[],"mappings":"AAuBA,MAAM,WAAW,YAAY;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACjC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;IAC5B,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,wBAAsB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,YAAY,iBAe1E;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,YAAY,iBAc/E;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CA4F7G"}
|
|
@@ -1,56 +1,33 @@
|
|
|
1
1
|
import { stat, mkdir } from "node:fs/promises";
|
|
2
2
|
import { extname, basename, resolve } from "node:path";
|
|
3
|
-
|
|
4
3
|
import { generateGuestTypes, generateHostTypes } from "@bytecodealliance/jco-transpile";
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
writeFiles,
|
|
8
|
-
resolveDefaultWITPath,
|
|
9
|
-
styleText,
|
|
10
|
-
ASYNC_WASI_IMPORTS,
|
|
11
|
-
ASYNC_WASI_EXPORTS,
|
|
12
|
-
DEFAULT_ASYNC_MODE,
|
|
13
|
-
} from "../common.js";
|
|
14
|
-
|
|
4
|
+
import { writeFiles, resolveDefaultWITPath, styleText, ASYNC_WASI_IMPORTS, ASYNC_WASI_EXPORTS, DEFAULT_ASYNC_MODE, } from "../common.js";
|
|
15
5
|
/** Default relative path for guest type declaration generation */
|
|
16
6
|
const DEFAULT_GUEST_TYPES_OUTPUT_DIR_PATH = "./types/generated/wit/guest";
|
|
17
|
-
|
|
18
7
|
/** Default relative path for host type declaration generation */
|
|
19
8
|
const DEFAULT_HOST_TYPES_OUTPUT_DIR_PATH = "./types/generated/wit/host";
|
|
20
|
-
|
|
21
9
|
export async function types(witPath, opts) {
|
|
22
10
|
witPath = await resolveDefaultWITPath(witPath);
|
|
23
|
-
|
|
24
11
|
// Use the default output directory if one was not provided
|
|
25
12
|
if (!opts.outDir) {
|
|
26
13
|
await mkdir(DEFAULT_HOST_TYPES_OUTPUT_DIR_PATH, { recursive: true });
|
|
27
14
|
opts.outDir = resolve(DEFAULT_HOST_TYPES_OUTPUT_DIR_PATH);
|
|
28
|
-
console.error(
|
|
29
|
-
`no output directory specified for host type declarations, using [${DEFAULT_HOST_TYPES_OUTPUT_DIR_PATH}]`,
|
|
30
|
-
);
|
|
15
|
+
console.error(`no output directory specified for host type declarations, using [${DEFAULT_HOST_TYPES_OUTPUT_DIR_PATH}]`);
|
|
31
16
|
}
|
|
32
|
-
|
|
33
17
|
const files = await typesComponent(witPath, opts);
|
|
34
|
-
|
|
35
18
|
await writeFiles(files, opts.quiet ? false : "Generated Type Files");
|
|
36
19
|
}
|
|
37
|
-
|
|
38
20
|
export async function guestTypes(witPath, opts) {
|
|
39
21
|
witPath = await resolveDefaultWITPath(witPath);
|
|
40
|
-
|
|
41
22
|
// Use the default output directory if one was not provided
|
|
42
23
|
if (!opts.outDir) {
|
|
43
24
|
await mkdir(DEFAULT_GUEST_TYPES_OUTPUT_DIR_PATH, { recursive: true });
|
|
44
25
|
opts.outDir = resolve(DEFAULT_GUEST_TYPES_OUTPUT_DIR_PATH);
|
|
45
|
-
console.error(
|
|
46
|
-
`no output directory specified for guest type declarations, using [${DEFAULT_GUEST_TYPES_OUTPUT_DIR_PATH}]`,
|
|
47
|
-
);
|
|
26
|
+
console.error(`no output directory specified for guest type declarations, using [${DEFAULT_GUEST_TYPES_OUTPUT_DIR_PATH}]`);
|
|
48
27
|
}
|
|
49
|
-
|
|
50
28
|
const files = await typesComponent(witPath, { ...opts, guest: true });
|
|
51
29
|
await writeFiles(files, opts.quiet ? false : "Generated Guest Typescript Definition Files (.d.ts)");
|
|
52
30
|
}
|
|
53
|
-
|
|
54
31
|
/**
|
|
55
32
|
* @param {string} witPath
|
|
56
33
|
* @param {{
|
|
@@ -74,38 +51,37 @@ export async function guestTypes(witPath, opts) {
|
|
|
74
51
|
* @returns {Promise<{ [filename: string]: Uint8Array }>}
|
|
75
52
|
*/
|
|
76
53
|
export async function typesComponent(witPath, opts) {
|
|
77
|
-
const name =
|
|
78
|
-
opts.name ||
|
|
54
|
+
const name = opts.name ||
|
|
79
55
|
(opts.worldName
|
|
80
56
|
? opts.worldName.split(":").pop().split("/").pop()
|
|
81
57
|
: basename(witPath.slice(0, -extname(witPath).length || Infinity)));
|
|
82
|
-
|
|
83
58
|
let instantiation;
|
|
84
59
|
if (opts.instantiation) {
|
|
85
60
|
if (typeof opts.instantiation === "string") {
|
|
86
61
|
instantiation = { tag: opts.instantiation };
|
|
87
|
-
}
|
|
62
|
+
}
|
|
63
|
+
else if (typeof opts.instantiation === "object") {
|
|
88
64
|
instantiation = opts.instantiation;
|
|
89
|
-
}
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
90
67
|
throw new Error("invalid instantiation configuration value");
|
|
91
68
|
}
|
|
92
69
|
}
|
|
93
|
-
|
|
94
70
|
let outDir = (opts.outDir ?? "").replace(/\\/g, "/");
|
|
95
71
|
if (!outDir.endsWith("/") && outDir !== "") {
|
|
96
72
|
outDir += "/";
|
|
97
73
|
}
|
|
98
|
-
|
|
99
74
|
// Bulid list of enabled features
|
|
100
|
-
let features =
|
|
75
|
+
let features = undefined;
|
|
101
76
|
if (opts.allFeatures) {
|
|
102
77
|
features = { tag: "all" };
|
|
103
|
-
}
|
|
78
|
+
}
|
|
79
|
+
else if (Array.isArray(opts.feature)) {
|
|
104
80
|
features = { tag: "list", val: opts.feature };
|
|
105
|
-
}
|
|
81
|
+
}
|
|
82
|
+
else if (Array.isArray(opts.features)) {
|
|
106
83
|
features = { tag: "list", val: opts.features };
|
|
107
84
|
}
|
|
108
|
-
|
|
109
85
|
// Build list of async imports/exports
|
|
110
86
|
let asyncImports = new Set([...(opts.asyncImports ?? [])]);
|
|
111
87
|
if (opts.asyncWasiImports) {
|
|
@@ -115,7 +91,6 @@ export async function typesComponent(witPath, opts) {
|
|
|
115
91
|
if (opts.asyncWasiExports) {
|
|
116
92
|
ASYNC_WASI_EXPORTS.forEach((v) => asyncExports.add(v));
|
|
117
93
|
}
|
|
118
|
-
|
|
119
94
|
// For simple type generation, we choose the "async mode" for the user
|
|
120
95
|
// even though it is not relevant here (JSPI may not be used, as types may
|
|
121
96
|
// be used to generate a guest that is never transpiled).
|
|
@@ -129,12 +104,13 @@ export async function typesComponent(witPath, opts) {
|
|
|
129
104
|
exports: [...asyncExports],
|
|
130
105
|
},
|
|
131
106
|
};
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
|
|
107
|
+
}
|
|
108
|
+
else if (asyncMode === "sync") {
|
|
109
|
+
asyncModeObj = undefined;
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
135
112
|
throw new Error(`invalid/unrecognized async mode [${asyncMode}]`);
|
|
136
113
|
}
|
|
137
|
-
|
|
138
114
|
// Run the type generation
|
|
139
115
|
let types;
|
|
140
116
|
const absWitPath = resolve(witPath);
|
|
@@ -152,20 +128,20 @@ export async function typesComponent(witPath, opts) {
|
|
|
152
128
|
asyncMode: asyncModeObj,
|
|
153
129
|
});
|
|
154
130
|
types = Object.entries(generated).map(([name, bytes]) => [`${outDir}${name}`, bytes]);
|
|
155
|
-
}
|
|
156
|
-
|
|
131
|
+
}
|
|
132
|
+
catch (err) {
|
|
133
|
+
const error = err;
|
|
134
|
+
if (error.toString().includes("does not match previous package name")) {
|
|
157
135
|
const hint = await printWITLayoutHint(absWitPath);
|
|
158
|
-
if (
|
|
159
|
-
|
|
136
|
+
if (error.message) {
|
|
137
|
+
error.message += `\n${hint}`;
|
|
160
138
|
}
|
|
161
|
-
throw
|
|
139
|
+
throw error;
|
|
162
140
|
}
|
|
163
|
-
throw
|
|
141
|
+
throw error;
|
|
164
142
|
}
|
|
165
|
-
|
|
166
143
|
return Object.fromEntries(types);
|
|
167
144
|
}
|
|
168
|
-
|
|
169
145
|
/**
|
|
170
146
|
* Print a hint about WIT folder layout
|
|
171
147
|
*
|
|
@@ -186,8 +162,8 @@ async function printWITLayoutHint(witPath) {
|
|
|
186
162
|
output += `${warningPrefix} - All package dependencies should be in "wit/deps" (i.e. "some:dep" in "wit/deps/some-dep.wit"\n`;
|
|
187
163
|
return output;
|
|
188
164
|
}
|
|
189
|
-
|
|
190
165
|
// see: https://github.com/vitest-dev/vitest/issues/6953#issuecomment-2505310022
|
|
191
166
|
if (typeof __vite_ssr_import_meta__ !== "undefined") {
|
|
192
167
|
__vite_ssr_import_meta__.resolve = (path) => "file://" + globalCreateRequire(import.meta.url).resolve(path);
|
|
193
168
|
}
|
|
169
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/cmd/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEvD,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAExF,OAAO,EACH,UAAU,EACV,qBAAqB,EACrB,SAAS,EACT,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,GACrB,MAAM,cAAc,CAAC;AAKtB,kEAAkE;A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AG,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,GAAG,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAChH,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function parse(file: string, opts: any): Promise<void>;
|
|
2
|
+
export declare function print(file: string, opts: any): Promise<void>;
|
|
3
|
+
export declare function componentWit(file: string, opts: any): Promise<void>;
|
|
4
|
+
export declare function componentNew(file: string | undefined, opts: any): Promise<void>;
|
|
5
|
+
export declare function componentEmbed(file: string | undefined, opts: any): Promise<void>;
|
|
6
|
+
export declare function metadataAdd(file: string, opts: any): Promise<void>;
|
|
7
|
+
export declare function metadataShow(file: string, opts: any): Promise<void>;
|
|
8
|
+
//# sourceMappingURL=wasm-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wasm-tools.d.ts","sourceRoot":"","sources":["../../src/cmd/wasm-tools.ts"],"names":[],"mappings":"AAeA,wBAAsB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,iBAIlD;AAED,wBAAsB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,iBAQlD;AAED,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,iBAQzD;AAED,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,GAAG,iBAwCrE;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,GAAG,iBAavE;AAED,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,iBASxD;AAED,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,iBAmCzD"}
|
|
@@ -1,44 +1,32 @@
|
|
|
1
1
|
import { resolve, basename, extname } from "node:path";
|
|
2
2
|
import { writeFile } from "node:fs/promises";
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
print as printFn,
|
|
6
|
-
parse as parseFn,
|
|
7
|
-
componentWit as componentWitFn,
|
|
8
|
-
componentNew as componentNewFn,
|
|
9
|
-
componentEmbed as componentEmbedFn,
|
|
10
|
-
metadataAdd as metadataAddFn,
|
|
11
|
-
metadataShow as metadataShowFn,
|
|
12
|
-
} from "@bytecodealliance/jco-transpile/wasm-tools";
|
|
13
|
-
|
|
3
|
+
import { print as printFn, parse as parseFn, componentWit as componentWitFn, componentNew as componentNewFn, componentEmbed as componentEmbedFn, metadataAdd as metadataAddFn, metadataShow as metadataShowFn, } from "@bytecodealliance/jco-transpile/wasm-tools";
|
|
14
4
|
import { readFile, isWindows, styleText } from "../common.js";
|
|
15
|
-
|
|
16
5
|
export async function parse(file, opts) {
|
|
17
6
|
const source = (await readFile(file)).toString();
|
|
18
7
|
const output = await parseFn(source);
|
|
19
8
|
await writeFile(opts.output, output);
|
|
20
9
|
}
|
|
21
|
-
|
|
22
10
|
export async function print(file, opts) {
|
|
23
11
|
const source = await readFile(file);
|
|
24
12
|
const output = await printFn(source);
|
|
25
13
|
if (opts.output) {
|
|
26
14
|
await writeFile(opts.output, output);
|
|
27
|
-
}
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
28
17
|
console.log(output);
|
|
29
18
|
}
|
|
30
19
|
}
|
|
31
|
-
|
|
32
20
|
export async function componentWit(file, opts) {
|
|
33
21
|
const source = await readFile(file);
|
|
34
|
-
const output = await componentWitFn(source
|
|
22
|
+
const output = await componentWitFn(source);
|
|
35
23
|
if (opts.output) {
|
|
36
24
|
await writeFile(opts.output, output);
|
|
37
|
-
}
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
38
27
|
console.log(output);
|
|
39
28
|
}
|
|
40
29
|
}
|
|
41
|
-
|
|
42
30
|
export async function componentNew(file, opts) {
|
|
43
31
|
const source = file ? await readFile(file) : null;
|
|
44
32
|
let adapters = [];
|
|
@@ -49,37 +37,35 @@ export async function componentNew(file, opts) {
|
|
|
49
37
|
adapters = [
|
|
50
38
|
[
|
|
51
39
|
"wasi_snapshot_preview1",
|
|
52
|
-
|
|
40
|
+
await readFile(new URL("../../lib/wasi_snapshot_preview1.reactor.wasm", import.meta.url)),
|
|
53
41
|
],
|
|
54
42
|
];
|
|
55
|
-
}
|
|
43
|
+
}
|
|
44
|
+
else if (opts.wasiCommand) {
|
|
56
45
|
adapters = [
|
|
57
46
|
[
|
|
58
47
|
"wasi_snapshot_preview1",
|
|
59
|
-
|
|
48
|
+
await readFile(new URL("../../lib/wasi_snapshot_preview1.command.wasm", import.meta.url)),
|
|
60
49
|
],
|
|
61
50
|
];
|
|
62
51
|
}
|
|
63
52
|
if (opts.adapt) {
|
|
64
|
-
adapters = adapters.concat(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
),
|
|
77
|
-
);
|
|
53
|
+
adapters = adapters.concat(await Promise.all(opts.adapt.map(async (adapt) => {
|
|
54
|
+
let adapter;
|
|
55
|
+
if (adapt.includes("=")) {
|
|
56
|
+
adapter = adapt.split("=", 2);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
adapter = [basename(adapt).slice(0, -extname(adapt).length), adapt];
|
|
60
|
+
}
|
|
61
|
+
const adapterPath = adapter[1];
|
|
62
|
+
adapter[1] = await readFile(adapterPath);
|
|
63
|
+
return adapter;
|
|
64
|
+
})));
|
|
78
65
|
}
|
|
79
66
|
const output = await componentNewFn(source, adapters);
|
|
80
67
|
await writeFile(opts.output, output);
|
|
81
68
|
}
|
|
82
|
-
|
|
83
69
|
export async function componentEmbed(file, opts) {
|
|
84
70
|
if (opts.metadata) {
|
|
85
71
|
opts.metadata = opts.metadata.map((meta) => {
|
|
@@ -94,7 +80,6 @@ export async function componentEmbed(file, opts) {
|
|
|
94
80
|
const output = await componentEmbedFn(opts);
|
|
95
81
|
await writeFile(opts.output, output);
|
|
96
82
|
}
|
|
97
|
-
|
|
98
83
|
export async function metadataAdd(file, opts) {
|
|
99
84
|
const metadata = opts.metadata.map((meta) => {
|
|
100
85
|
const [field, data = ""] = meta.split("=");
|
|
@@ -105,15 +90,14 @@ export async function metadataAdd(file, opts) {
|
|
|
105
90
|
const output = await metadataAddFn(source, metadata);
|
|
106
91
|
await writeFile(opts.output, output);
|
|
107
92
|
}
|
|
108
|
-
|
|
109
93
|
export async function metadataShow(file, opts) {
|
|
110
94
|
const source = await readFile(file);
|
|
111
|
-
let output = "",
|
|
112
|
-
stack = [1];
|
|
95
|
+
let output = "", stack = [1];
|
|
113
96
|
const meta = await metadataShowFn(source);
|
|
114
97
|
if (opts.json) {
|
|
115
98
|
console.log(JSON.stringify(meta, null, 2));
|
|
116
|
-
}
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
117
101
|
for (const { name, metaType, producers } of meta) {
|
|
118
102
|
output += " ".repeat(stack.length - 1);
|
|
119
103
|
const indent = " ".repeat(stack.length);
|
|
@@ -122,7 +106,8 @@ export async function metadataShow(file, opts) {
|
|
|
122
106
|
if (metaType.val > 0) {
|
|
123
107
|
stack.push(metaType.val);
|
|
124
108
|
}
|
|
125
|
-
}
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
126
111
|
output += `${styleText("bold", `[module${name ? " " + name : ""}]`)}\n`;
|
|
127
112
|
}
|
|
128
113
|
if (producers.length === 0) {
|
|
@@ -142,3 +127,4 @@ export async function metadataShow(file, opts) {
|
|
|
142
127
|
process.stdout.write(output);
|
|
143
128
|
}
|
|
144
129
|
}
|
|
130
|
+
//# sourceMappingURL=wasm-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wasm-tools.js","sourceRoot":"","sources":["../../src/cmd/wasm-tools.ts"],"names":[],"m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AE,OAAO,CAAC,IAAI,KAAK,EAAE,CAAC;oBAClC,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC,IAAI,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC;gBACrH,CAAC;YACL,CAAC;YACD,MAAM,IAAI,IAAI,CAAC;YACf,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;gBAChC,KAAK,CAAC,GAAG,EAAE,CAAC;YAChB,CAAC;YACD,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC;QAC9B,CAAC;QACD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;AACL,CAAC"}
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
1
|
+
import * as nodeUtils from "node:util";
|
|
2
|
+
export declare const isWindows: boolean;
|
|
3
|
+
export declare const ASYNC_WASI_IMPORTS: string[];
|
|
4
|
+
export declare const ASYNC_WASI_EXPORTS: string[];
|
|
5
|
+
export declare const DEFAULT_ASYNC_MODE = "sync";
|
|
6
|
+
/** Path of WIT files by default when one is not specified */
|
|
7
|
+
export declare const DEFAULT_WIT_PATH = "./wit";
|
|
8
|
+
export declare function setShowSpinner(val: boolean): void;
|
|
9
|
+
export declare function getShowSpinner(): boolean;
|
|
10
|
+
export declare function sizeStr(num: number): string;
|
|
11
|
+
export declare function fixedDigitDisplay(num: number, maxChars: number): string;
|
|
5
12
|
/**
|
|
6
13
|
* Generate tabular output
|
|
7
14
|
*
|
|
@@ -9,7 +16,7 @@ export function fixedDigitDisplay(num: any, maxChars: any): string;
|
|
|
9
16
|
* @param {string[]} align - alignment of columns
|
|
10
17
|
* @returns string
|
|
11
18
|
*/
|
|
12
|
-
export function table(rows: string[][], align?: string
|
|
19
|
+
export declare function table(rows: string[][], align?: Array<string | undefined>): string;
|
|
13
20
|
/**
|
|
14
21
|
* Securely creates a temporary directory and returns its path.
|
|
15
22
|
*
|
|
@@ -17,7 +24,17 @@ export function table(rows: string[][], align?: string[]): string;
|
|
|
17
24
|
*
|
|
18
25
|
* @returns {Promise<string>} A `Promise` that resovles to a created temporary directory path
|
|
19
26
|
*/
|
|
20
|
-
export function getTmpDir(): Promise<string>;
|
|
27
|
+
export declare function getTmpDir(): Promise<string>;
|
|
28
|
+
/**
|
|
29
|
+
* Read a given file, throwing a formatted error if one occurs
|
|
30
|
+
*
|
|
31
|
+
* @param {string} filePath - path to teh file to read
|
|
32
|
+
* @param {encoding} encoding - file encoding
|
|
33
|
+
* @returns {Promise<Buffer>} A promise that resolves to the contents of the file
|
|
34
|
+
*/
|
|
35
|
+
declare function readFileCli(filePath: string | URL): Promise<Buffer>;
|
|
36
|
+
declare function readFileCli(filePath: string | URL, encoding: BufferEncoding): Promise<string>;
|
|
37
|
+
export { readFileCli as readFile };
|
|
21
38
|
/**
|
|
22
39
|
* Spawn a command that processes a given wasm binary bytes with some
|
|
23
40
|
* command.
|
|
@@ -34,7 +51,7 @@ export function getTmpDir(): Promise<string>;
|
|
|
34
51
|
* @param {string[]} args - arguments to pass to the command (after the input file and before the output file)
|
|
35
52
|
* @returns {Promise<Buffer<ArrayBufferLike>>} A `Promise` that resolves when the command has exited
|
|
36
53
|
*/
|
|
37
|
-
export function spawnIOTmp(cmd: string, inputWasmBytes:
|
|
54
|
+
export declare function spawnIOTmp(cmd: string, inputWasmBytes: Uint8Array, args: string[]): Promise<Buffer>;
|
|
38
55
|
/**
|
|
39
56
|
* Given an object that has file names as keys and file contents as values,
|
|
40
57
|
* write out the files to a their locations.
|
|
@@ -46,14 +63,14 @@ export function spawnIOTmp(cmd: string, inputWasmBytes: Buffer<ArrayBufferLike>,
|
|
|
46
63
|
* @returns {Promise<void>>} A `Promise` that resolves when the fiels are all written
|
|
47
64
|
*
|
|
48
65
|
*/
|
|
49
|
-
export function writeFiles(files: Record<string, string>, summaryTitle:
|
|
66
|
+
export declare function writeFiles(files: Record<string, string | Uint8Array>, summaryTitle: string | false): Promise<void>;
|
|
50
67
|
/**
|
|
51
68
|
* Resolve the deafult WIT path, given a possibly
|
|
52
69
|
*
|
|
53
70
|
* @param {string | undefined} [witPath]
|
|
54
71
|
* @returns {Promise<string>}
|
|
55
72
|
*/
|
|
56
|
-
export function resolveDefaultWITPath(witPath?: string
|
|
73
|
+
export declare function resolveDefaultWITPath(witPath?: string): Promise<string>;
|
|
57
74
|
/**
|
|
58
75
|
* Partial polyfill for 'node:util' `styleText()`
|
|
59
76
|
*
|
|
@@ -61,20 +78,5 @@ export function resolveDefaultWITPath(witPath?: string | undefined): Promise<str
|
|
|
61
78
|
* @param {string} text - text that should be styled
|
|
62
79
|
* @returns {string} The styled string
|
|
63
80
|
*/
|
|
64
|
-
export function styleText(styles:
|
|
65
|
-
export const isWindows: boolean;
|
|
66
|
-
export const ASYNC_WASI_IMPORTS: string[];
|
|
67
|
-
export const ASYNC_WASI_EXPORTS: string[];
|
|
68
|
-
export const DEFAULT_ASYNC_MODE: "sync";
|
|
69
|
-
/** Path of WIT files by default when one is not specified */
|
|
70
|
-
export const DEFAULT_WIT_PATH: "./wit";
|
|
71
|
-
export { readFileCli as readFile };
|
|
72
|
-
/**
|
|
73
|
-
* Read a given file, throwing a formatted error if one occurs
|
|
74
|
-
*
|
|
75
|
-
* @param {string} filePath - path to teh file to read
|
|
76
|
-
* @param {encoding} encoding - file encoding
|
|
77
|
-
* @returns {Promise<Buffer>} A promise that resolves to the contents of the file
|
|
78
|
-
*/
|
|
79
|
-
declare function readFileCli(filePath: string, encoding: any): Promise<Buffer>;
|
|
81
|
+
export declare function styleText(styles: Parameters<typeof nodeUtils.styleText>[0], text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