@tybys/wasm-util 0.4.0 → 0.5.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/README.md +2 -2
- package/dist/wasm-util.d.ts +25 -8
- package/dist/wasm-util.esm-bundler.js +1042 -476
- package/dist/wasm-util.esm.js +1042 -476
- package/dist/wasm-util.esm.min.js +1 -1
- package/dist/wasm-util.js +1043 -475
- package/dist/wasm-util.min.js +1 -1
- package/lib/cjs/asyncify.js +22 -31
- package/lib/cjs/load.js +33 -32
- package/lib/cjs/memory.js +1 -0
- package/lib/cjs/wasi/fd.js +57 -15
- package/lib/cjs/wasi/index.js +92 -60
- package/lib/cjs/wasi/preview1.js +684 -209
- package/lib/cjs/wasi/rights.js +1 -0
- package/lib/cjs/wasi/types.js +61 -30
- package/lib/mjs/asyncify.mjs +22 -31
- package/lib/mjs/load.mjs +30 -31
- package/lib/mjs/memory.mjs +1 -1
- package/lib/mjs/wasi/fd.mjs +53 -13
- package/lib/mjs/wasi/index.mjs +93 -61
- package/lib/mjs/wasi/preview1.mjs +685 -210
- package/lib/mjs/wasi/rights.mjs +2 -2
- package/lib/mjs/wasi/types.mjs +61 -30
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@ const fs = createFsFromVolume(Volume.from({
|
|
|
25
25
|
'/home/wasi': null
|
|
26
26
|
}))
|
|
27
27
|
|
|
28
|
-
const wasi =
|
|
28
|
+
const wasi = WASI.createSync({
|
|
29
29
|
args: ['chrome', 'file.wasm'],
|
|
30
30
|
env: {
|
|
31
31
|
NODE_ENV: 'development',
|
|
@@ -34,7 +34,7 @@ const wasi = new WASI({
|
|
|
34
34
|
preopens: {
|
|
35
35
|
'/': '/'
|
|
36
36
|
},
|
|
37
|
-
|
|
37
|
+
fs,
|
|
38
38
|
|
|
39
39
|
// redirect stdout / stderr
|
|
40
40
|
|
package/dist/wasm-util.d.ts
CHANGED
|
@@ -31,6 +31,12 @@ export declare type AsyncifyExports<T, U> = T extends Record<string, any> ? {
|
|
|
31
31
|
[P in keyof T]: T[P] extends Callable ? U extends Array<Exclude<keyof T, AsyncifyExportName>> ? P extends U[number] ? AsyncifyExportFunction<T[P]> : T[P] : AsyncifyExportFunction<T[P]> : T[P];
|
|
32
32
|
} : T;
|
|
33
33
|
|
|
34
|
+
/** @public */
|
|
35
|
+
export declare function asyncifyLoad(asyncify: AsyncifyOptions, urlOrBuffer: string | URL | BufferSource, imports?: WebAssembly.Imports): Promise<WebAssembly.WebAssemblyInstantiatedSource>;
|
|
36
|
+
|
|
37
|
+
/** @public */
|
|
38
|
+
export declare function asyncifyLoadSync(asyncify: AsyncifyOptions, buffer: BufferSource, imports?: WebAssembly.Imports): WebAssembly.WebAssemblyInstantiatedSource;
|
|
39
|
+
|
|
34
40
|
/** @public */
|
|
35
41
|
export declare interface AsyncifyOptions {
|
|
36
42
|
wasm64?: boolean;
|
|
@@ -41,6 +47,14 @@ export declare interface AsyncifyOptions {
|
|
|
41
47
|
wrapExports?: string[];
|
|
42
48
|
}
|
|
43
49
|
|
|
50
|
+
/** @public */
|
|
51
|
+
export declare interface AsyncWASIOptions extends WASIOptions {
|
|
52
|
+
fs: {
|
|
53
|
+
promises: IFsPromises;
|
|
54
|
+
};
|
|
55
|
+
asyncify?: Asyncify;
|
|
56
|
+
}
|
|
57
|
+
|
|
44
58
|
/** @public */
|
|
45
59
|
export declare interface BaseEncodingOptions {
|
|
46
60
|
encoding?: BufferEncoding_2;
|
|
@@ -249,10 +263,10 @@ declare const kSetMemory: unique symbol;
|
|
|
249
263
|
declare const kStarted: unique symbol;
|
|
250
264
|
|
|
251
265
|
/** @public */
|
|
252
|
-
export declare function load(urlOrBuffer: string | URL | BufferSource, imports?: WebAssembly.Imports
|
|
266
|
+
export declare function load(urlOrBuffer: string | URL | BufferSource, imports?: WebAssembly.Imports): Promise<WebAssembly.WebAssemblyInstantiatedSource>;
|
|
253
267
|
|
|
254
268
|
/** @public */
|
|
255
|
-
export declare function loadSync(buffer: BufferSource, imports?: WebAssembly.Imports
|
|
269
|
+
export declare function loadSync(buffer: BufferSource, imports?: WebAssembly.Imports): WebAssembly.WebAssemblyInstantiatedSource;
|
|
256
270
|
|
|
257
271
|
/** @public */
|
|
258
272
|
export declare interface MakeDirectoryOptions {
|
|
@@ -342,6 +356,11 @@ export declare interface StatsBase<T> {
|
|
|
342
356
|
birthtime: Date;
|
|
343
357
|
}
|
|
344
358
|
|
|
359
|
+
/** @public */
|
|
360
|
+
export declare interface SyncWASIOptions extends WASIOptions {
|
|
361
|
+
fs?: IFs;
|
|
362
|
+
}
|
|
363
|
+
|
|
345
364
|
/** @public */
|
|
346
365
|
export declare class WASI {
|
|
347
366
|
private [kSetMemory];
|
|
@@ -349,7 +368,9 @@ export declare class WASI {
|
|
|
349
368
|
private [kExitCode];
|
|
350
369
|
private [kInstance];
|
|
351
370
|
readonly wasiImport: Record<string, any>;
|
|
352
|
-
|
|
371
|
+
static createSync(options?: SyncWASIOptions): WASI;
|
|
372
|
+
static createAsync(options?: AsyncWASIOptions): Promise<WASI>;
|
|
373
|
+
private constructor();
|
|
353
374
|
start(instance: WebAssembly.Instance): number | undefined | Promise<number> | Promise<undefined>;
|
|
354
375
|
initialize(instance: WebAssembly.Instance): void | Promise<void>;
|
|
355
376
|
}
|
|
@@ -365,10 +386,6 @@ export declare interface WASIOptions {
|
|
|
365
386
|
returnOnExit?: boolean | undefined;
|
|
366
387
|
print?: (str: string) => void;
|
|
367
388
|
printErr?: (str: string) => void;
|
|
368
|
-
filesystem?: {
|
|
369
|
-
type: 'memfs';
|
|
370
|
-
fs: IFs;
|
|
371
|
-
};
|
|
372
389
|
}
|
|
373
390
|
|
|
374
391
|
/** @public */
|
|
@@ -381,7 +398,7 @@ export declare const WebAssemblyMemory: {
|
|
|
381
398
|
export declare function wrapAsyncExport<T extends Function = any>(f: Function): T;
|
|
382
399
|
|
|
383
400
|
/** @public */
|
|
384
|
-
export declare function wrapAsyncImport(f:
|
|
401
|
+
export declare function wrapAsyncImport<T extends (...args: any[]) => any>(f: T, parameterType: WebAssembly.ValueType[], returnType: WebAssembly.ValueType[]): (...args: [object, ...Parameters<T>]) => ReturnType<T>;
|
|
385
402
|
|
|
386
403
|
/** @public */
|
|
387
404
|
export declare function wrapExports<T extends WebAssembly.Exports>(exports: T): PromisifyExports<T, void>;
|