@bytecodealliance/jco 0.10.3 → 0.11.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 +15 -2
- package/lib/wasi_snapshot_preview1.command.wasm +0 -0
- package/lib/wasi_snapshot_preview1.reactor.wasm +0 -0
- package/obj/exports/local-wasm-tools-tools.d.ts +43 -0
- package/obj/{interfaces/environment.d.ts → exports/wasi-cli-environment.d.ts} +1 -1
- package/obj/{interfaces/exit.d.ts → exports/wasi-cli-exit.d.ts} +1 -1
- package/obj/exports/wasi-cli-stderr.d.ts +5 -0
- package/obj/exports/wasi-cli-stdin.d.ts +5 -0
- package/obj/exports/wasi-cli-stdout.d.ts +5 -0
- package/obj/exports/wasi-cli-terminal-input.d.ts +4 -0
- package/obj/exports/wasi-cli-terminal-output.d.ts +4 -0
- package/obj/exports/wasi-cli-terminal-stderr.d.ts +5 -0
- package/obj/exports/wasi-cli-terminal-stdin.d.ts +5 -0
- package/obj/exports/wasi-cli-terminal-stdout.d.ts +5 -0
- package/obj/exports/wasi-filesystem-preopens.d.ts +5 -0
- package/obj/{interfaces/filesystem.d.ts → exports/wasi-filesystem-types.d.ts} +17 -16
- package/obj/exports/wasi-io-streams.d.ts +18 -0
- package/obj/imports/{wasi-cli-base-environment.d.ts → wasi-cli-environment.d.ts} +1 -1
- package/obj/{interfaces/wasi-cli-base-exit.d.ts → imports/wasi-cli-exit.d.ts} +1 -1
- package/obj/imports/{wasi-cli-base-stderr.d.ts → wasi-cli-stderr.d.ts} +1 -1
- package/obj/imports/{wasi-cli-base-stdin.d.ts → wasi-cli-stdin.d.ts} +1 -1
- package/obj/imports/{wasi-cli-base-stdout.d.ts → wasi-cli-stdout.d.ts} +1 -1
- package/obj/imports/wasi-cli-terminal-input.d.ts +4 -0
- package/obj/imports/wasi-cli-terminal-output.d.ts +4 -0
- package/obj/imports/wasi-cli-terminal-stderr.d.ts +5 -0
- package/obj/imports/wasi-cli-terminal-stdin.d.ts +5 -0
- package/obj/imports/wasi-cli-terminal-stdout.d.ts +5 -0
- package/obj/imports/wasi-filesystem-preopens.d.ts +5 -0
- package/obj/imports/{wasi-filesystem-filesystem.d.ts → wasi-filesystem-types.d.ts} +14 -13
- package/obj/imports/wasi-io-streams.d.ts +6 -9
- 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 +12 -7
- package/obj/js-component-bindgen-component.js +365 -117
- 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 +14 -48
- package/obj/wasm-tools.js +386 -127
- package/package.json +7 -4
- package/src/api.js +2 -1
- package/src/browser.js +3 -0
- package/src/cmd/opt.js +2 -1
- package/src/cmd/run.js +103 -0
- package/src/cmd/transpile.js +4 -3
- package/src/cmd/wasm-tools.js +10 -3
- package/src/jco.js +11 -1
- package/obj/imports/wasi-cli-base-exit.d.ts +0 -4
- package/obj/imports/wasi-cli-base-preopens.d.ts +0 -5
- package/obj/interfaces/preopens.d.ts +0 -5
- package/obj/interfaces/random.d.ts +0 -3
- package/obj/interfaces/stderr.d.ts +0 -5
- package/obj/interfaces/stdin.d.ts +0 -5
- package/obj/interfaces/stdout.d.ts +0 -5
- package/obj/interfaces/streams.d.ts +0 -21
- package/obj/interfaces/wall-clock.d.ts +0 -6
- package/obj/interfaces/wasi-cli-base-environment.d.ts +0 -3
- package/obj/interfaces/wasi-cli-base-preopens.d.ts +0 -5
- package/obj/interfaces/wasi-cli-base-stderr.d.ts +0 -5
- package/obj/interfaces/wasi-cli-base-stdin.d.ts +0 -5
- package/obj/interfaces/wasi-cli-base-stdout.d.ts +0 -5
- package/obj/interfaces/wasi-filesystem-filesystem.d.ts +0 -152
- package/obj/interfaces/wasi-io-streams.d.ts +0 -21
- /package/obj/{interfaces → exports}/wasi-clocks-wall-clock.d.ts +0 -0
- /package/obj/{interfaces → exports}/wasi-random-random.d.ts +0 -0
package/README.md
CHANGED
|
@@ -54,6 +54,7 @@ Options:
|
|
|
54
54
|
Commands:
|
|
55
55
|
componentize [options] <js-source> Create a component from a JavaScript module
|
|
56
56
|
transpile [options] <component-path> Transpile a WebAssembly Component to JS + core Wasm for JavaScript execution
|
|
57
|
+
run <command> [args...] Run a WebAssembly Command component
|
|
57
58
|
opt [options] <component-file> optimizes a Wasm component, including running wasm-opt Binaryen optimizations
|
|
58
59
|
wit [options] <component-path> extract the WIT from a WebAssembly Component [wasm-tools component wit]
|
|
59
60
|
print [options] <input> print the WebAssembly WAT text for a binary file [wasm-tools print]
|
|
@@ -98,7 +99,7 @@ Options include:
|
|
|
98
99
|
* `--js`: Converts core Wasm files to JavaScript for environments that don't even support core Wasm.
|
|
99
100
|
* `--base64-cutoff=<number>`: Sets the maximum number of bytes for inlining Wasm files into the JS using base64 encoding. Set to zero to disable base64 inlining entirely.
|
|
100
101
|
* `--no-wasi-shim`: Disable the WASI shim mapping to `@bytecodealliance/preview2-shim`.
|
|
101
|
-
* `--map`: Provide custom mappings for world imports. Supports both wildcard mappings (`*` similarly as in the package.json "exports" field) as well as `#` mappings for targetting exported interfaces. For example, the WASI mappings are internally defined with mappings like `--map wasi:filesystem/*=@bytecodealliance/preview2-shim/filesystem#*` to map `import as * filesystem from 'wasi:filesystem/
|
|
102
|
+
* `--map`: Provide custom mappings for world imports. Supports both wildcard mappings (`*` similarly as in the package.json "exports" field) as well as `#` mappings for targetting exported interfaces. For example, the WASI mappings are internally defined with mappings like `--map wasi:filesystem/*=@bytecodealliance/preview2-shim/filesystem#*` to map `import as * filesystem from 'wasi:filesystem/types'` to `import { types } from '@bytecodealliance/preview2-shim/filesystem`.
|
|
102
103
|
* `--no-nodejs-compat`: Disables Node.js compat in the output to load core Wasm with FS methods.
|
|
103
104
|
* `--instantiation`: Instead of a direct ES module, export an `instantiate` function which can take the imports as an argument instead of implicit imports.
|
|
104
105
|
* `--valid-lifting-optimization`: Internal validations are removed assuming that core Wasm binaries are valid components, providing a minor output size saving.
|
|
@@ -123,6 +124,18 @@ See [ComponentizeJS](https://github.com/bytecodealliance/componentize-js) for mo
|
|
|
123
124
|
|
|
124
125
|
> Additional engines may be supported in future via an `--engine` field or otherwise.
|
|
125
126
|
|
|
127
|
+
### Run
|
|
128
|
+
|
|
129
|
+
For Wasm components that implement the WASI Command world, a `jco run` utility is provided to run these applications in Node.js:
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
jco run cowasy.component.wasm hello
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Using the preview2-shim WASI implementation, full access to the underlying system primitives is provided, including filesystem and environment variable permissions.
|
|
136
|
+
|
|
137
|
+
> Since [preview2-shim](packages/preview2-shim) is an experimental work-in-progress implementation, there will likely be bugs.
|
|
138
|
+
|
|
126
139
|
## API
|
|
127
140
|
|
|
128
141
|
#### `transpile(component: Uint8Array, opts?): Promise<{ files: Record<string, Uint8Array> }>`
|
|
@@ -178,4 +191,4 @@ See [LICENSE](LICENSE) for more details.
|
|
|
178
191
|
|
|
179
192
|
Unless you explicitly state otherwise, any contribution intentionally submitted
|
|
180
193
|
for inclusion in this project by you, as defined in the Apache-2.0 license,
|
|
181
|
-
shall be licensed as above, without any additional terms or conditions.
|
|
194
|
+
shall be licensed as above, without any additional terms or conditions.
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export namespace LocalWasmToolsTools {
|
|
2
|
+
export function parse(wat: string): Uint8Array;
|
|
3
|
+
export function print(binary: Uint8Array | ArrayBuffer): string;
|
|
4
|
+
export function componentNew(binary: Uint8Array | ArrayBuffer, adapters: [string, Uint8Array | ArrayBuffer][] | null): Uint8Array;
|
|
5
|
+
export function componentWit(binary: Uint8Array | ArrayBuffer): string;
|
|
6
|
+
export function componentEmbed(embedOpts: EmbedOpts): Uint8Array;
|
|
7
|
+
export function metadataShow(binary: Uint8Array | ArrayBuffer): ModuleMetadata[];
|
|
8
|
+
export function metadataAdd(binary: Uint8Array | ArrayBuffer, metadata: ProducersFields): Uint8Array;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* # Variants
|
|
12
|
+
*
|
|
13
|
+
* ## `"utf8"`
|
|
14
|
+
*
|
|
15
|
+
* ## `"utf16"`
|
|
16
|
+
*
|
|
17
|
+
* ## `"compact-utf16"`
|
|
18
|
+
*/
|
|
19
|
+
export type StringEncoding = 'utf8' | 'utf16' | 'compact-utf16';
|
|
20
|
+
export type ProducersFields = [string, [string, string][]][];
|
|
21
|
+
export interface EmbedOpts {
|
|
22
|
+
binary?: Uint8Array,
|
|
23
|
+
witSource?: string,
|
|
24
|
+
witPath?: string,
|
|
25
|
+
stringEncoding?: StringEncoding,
|
|
26
|
+
dummy?: boolean,
|
|
27
|
+
world?: string,
|
|
28
|
+
metadata?: ProducersFields,
|
|
29
|
+
}
|
|
30
|
+
export type ModuleMetaType = ModuleMetaTypeModule | ModuleMetaTypeComponent;
|
|
31
|
+
export interface ModuleMetaTypeModule {
|
|
32
|
+
tag: 'module',
|
|
33
|
+
}
|
|
34
|
+
export interface ModuleMetaTypeComponent {
|
|
35
|
+
tag: 'component',
|
|
36
|
+
val: number,
|
|
37
|
+
}
|
|
38
|
+
export interface ModuleMetadata {
|
|
39
|
+
name?: string,
|
|
40
|
+
metaType: ModuleMetaType,
|
|
41
|
+
range: [number, number],
|
|
42
|
+
producers: ProducersFields,
|
|
43
|
+
}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
export namespace
|
|
2
|
-
export function readViaStream(
|
|
3
|
-
export function writeViaStream(
|
|
4
|
-
export function appendViaStream(
|
|
5
|
-
export function getType(
|
|
6
|
-
export function stat(
|
|
7
|
-
export function openAt(
|
|
8
|
-
export function dropDescriptor(
|
|
9
|
-
export function dropDirectoryEntryStream(
|
|
1
|
+
export namespace WasiFilesystemTypes {
|
|
2
|
+
export function readViaStream(this_: Descriptor, offset: Filesize): InputStream;
|
|
3
|
+
export function writeViaStream(this_: Descriptor, offset: Filesize): OutputStream;
|
|
4
|
+
export function appendViaStream(this_: Descriptor): OutputStream;
|
|
5
|
+
export function getType(this_: Descriptor): DescriptorType;
|
|
6
|
+
export function stat(this_: Descriptor): DescriptorStat;
|
|
7
|
+
export function openAt(this_: Descriptor, pathFlags: PathFlags, path: string, openFlags: OpenFlags, flags: DescriptorFlags, modes: Modes): Descriptor;
|
|
8
|
+
export function dropDescriptor(this_: Descriptor): void;
|
|
9
|
+
export function dropDirectoryEntryStream(this_: DirectoryEntryStream): void;
|
|
10
|
+
export function metadataHash(this_: Descriptor): MetadataHashValue;
|
|
10
11
|
}
|
|
11
12
|
export type Descriptor = number;
|
|
12
13
|
export type Filesize = bigint;
|
|
13
|
-
import type { InputStream } from '../
|
|
14
|
+
import type { InputStream } from '../exports/wasi-io-streams';
|
|
14
15
|
export { InputStream };
|
|
15
16
|
/**
|
|
16
17
|
* # Variants
|
|
@@ -90,7 +91,7 @@ export { InputStream };
|
|
|
90
91
|
* ## `"cross-device"`
|
|
91
92
|
*/
|
|
92
93
|
export type ErrorCode = 'access' | 'would-block' | 'already' | 'bad-descriptor' | 'busy' | 'deadlock' | 'quota' | 'exist' | 'file-too-large' | 'illegal-byte-sequence' | 'in-progress' | 'interrupted' | 'invalid' | 'io' | 'is-directory' | 'loop' | 'too-many-links' | 'message-size' | 'name-too-long' | 'no-device' | 'no-entry' | 'no-lock' | 'insufficient-memory' | 'insufficient-space' | 'not-directory' | 'not-empty' | 'not-recoverable' | 'unsupported' | 'no-tty' | 'no-such-device' | 'overflow' | 'not-permitted' | 'pipe' | 'read-only' | 'invalid-seek' | 'text-file-busy' | 'cross-device';
|
|
93
|
-
import type { OutputStream } from '../
|
|
94
|
+
import type { OutputStream } from '../exports/wasi-io-streams';
|
|
94
95
|
export { OutputStream };
|
|
95
96
|
/**
|
|
96
97
|
* # Variants
|
|
@@ -112,14 +113,10 @@ export { OutputStream };
|
|
|
112
113
|
* ## `"socket"`
|
|
113
114
|
*/
|
|
114
115
|
export type DescriptorType = 'unknown' | 'block-device' | 'character-device' | 'directory' | 'fifo' | 'symbolic-link' | 'regular-file' | 'socket';
|
|
115
|
-
export type Device = bigint;
|
|
116
|
-
export type Inode = bigint;
|
|
117
116
|
export type LinkCount = bigint;
|
|
118
|
-
import type { Datetime } from '../
|
|
117
|
+
import type { Datetime } from '../exports/wasi-clocks-wall-clock';
|
|
119
118
|
export { Datetime };
|
|
120
119
|
export interface DescriptorStat {
|
|
121
|
-
device: Device,
|
|
122
|
-
inode: Inode,
|
|
123
120
|
type: DescriptorType,
|
|
124
121
|
linkCount: LinkCount,
|
|
125
122
|
size: Filesize,
|
|
@@ -150,3 +147,7 @@ export interface Modes {
|
|
|
150
147
|
executable?: boolean,
|
|
151
148
|
}
|
|
152
149
|
export type DirectoryEntryStream = number;
|
|
150
|
+
export interface MetadataHashValue {
|
|
151
|
+
lower: bigint,
|
|
152
|
+
upper: bigint,
|
|
153
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export namespace WasiIoStreams {
|
|
2
|
+
export function read(this_: InputStream, len: bigint): [Uint8Array, StreamStatus];
|
|
3
|
+
export function blockingRead(this_: InputStream, len: bigint): [Uint8Array, StreamStatus];
|
|
4
|
+
export function dropInputStream(this_: InputStream): void;
|
|
5
|
+
export function write(this_: OutputStream, buf: Uint8Array | ArrayBuffer): [bigint, StreamStatus];
|
|
6
|
+
export function blockingWrite(this_: OutputStream, buf: Uint8Array | ArrayBuffer): [bigint, StreamStatus];
|
|
7
|
+
export function dropOutputStream(this_: OutputStream): void;
|
|
8
|
+
}
|
|
9
|
+
export type InputStream = number;
|
|
10
|
+
/**
|
|
11
|
+
* # Variants
|
|
12
|
+
*
|
|
13
|
+
* ## `"open"`
|
|
14
|
+
*
|
|
15
|
+
* ## `"ended"`
|
|
16
|
+
*/
|
|
17
|
+
export type StreamStatus = 'open' | 'ended';
|
|
18
|
+
export type OutputStream = number;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
export namespace
|
|
2
|
-
export function readViaStream(
|
|
3
|
-
export function writeViaStream(
|
|
4
|
-
export function appendViaStream(
|
|
5
|
-
export function getType(
|
|
6
|
-
export function stat(
|
|
7
|
-
export function openAt(
|
|
8
|
-
export function dropDescriptor(
|
|
9
|
-
export function dropDirectoryEntryStream(
|
|
1
|
+
export namespace WasiFilesystemTypes {
|
|
2
|
+
export function readViaStream(this_: Descriptor, offset: Filesize): InputStream;
|
|
3
|
+
export function writeViaStream(this_: Descriptor, offset: Filesize): OutputStream;
|
|
4
|
+
export function appendViaStream(this_: Descriptor): OutputStream;
|
|
5
|
+
export function getType(this_: Descriptor): DescriptorType;
|
|
6
|
+
export function stat(this_: Descriptor): DescriptorStat;
|
|
7
|
+
export function openAt(this_: Descriptor, pathFlags: PathFlags, path: string, openFlags: OpenFlags, flags: DescriptorFlags, modes: Modes): Descriptor;
|
|
8
|
+
export function dropDescriptor(this_: Descriptor): void;
|
|
9
|
+
export function dropDirectoryEntryStream(this_: DirectoryEntryStream): void;
|
|
10
|
+
export function metadataHash(this_: Descriptor): MetadataHashValue;
|
|
10
11
|
}
|
|
11
12
|
export type Descriptor = number;
|
|
12
13
|
export type Filesize = bigint;
|
|
@@ -112,14 +113,10 @@ export { OutputStream };
|
|
|
112
113
|
* ## `"socket"`
|
|
113
114
|
*/
|
|
114
115
|
export type DescriptorType = 'unknown' | 'block-device' | 'character-device' | 'directory' | 'fifo' | 'symbolic-link' | 'regular-file' | 'socket';
|
|
115
|
-
export type Device = bigint;
|
|
116
|
-
export type Inode = bigint;
|
|
117
116
|
export type LinkCount = bigint;
|
|
118
117
|
import type { Datetime } from '../imports/wasi-clocks-wall-clock';
|
|
119
118
|
export { Datetime };
|
|
120
119
|
export interface DescriptorStat {
|
|
121
|
-
device: Device,
|
|
122
|
-
inode: Inode,
|
|
123
120
|
type: DescriptorType,
|
|
124
121
|
linkCount: LinkCount,
|
|
125
122
|
size: Filesize,
|
|
@@ -150,3 +147,7 @@ export interface Modes {
|
|
|
150
147
|
executable?: boolean,
|
|
151
148
|
}
|
|
152
149
|
export type DirectoryEntryStream = number;
|
|
150
|
+
export interface MetadataHashValue {
|
|
151
|
+
lower: bigint,
|
|
152
|
+
upper: bigint,
|
|
153
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export namespace WasiIoStreams {
|
|
2
|
-
export function read(
|
|
3
|
-
export function blockingRead(
|
|
4
|
-
export function dropInputStream(
|
|
5
|
-
export function write(
|
|
6
|
-
export function blockingWrite(
|
|
7
|
-
export function dropOutputStream(
|
|
2
|
+
export function read(this_: InputStream, len: bigint): [Uint8Array | ArrayBuffer, StreamStatus];
|
|
3
|
+
export function blockingRead(this_: InputStream, len: bigint): [Uint8Array | ArrayBuffer, StreamStatus];
|
|
4
|
+
export function dropInputStream(this_: InputStream): void;
|
|
5
|
+
export function write(this_: OutputStream, buf: Uint8Array): [bigint, StreamStatus];
|
|
6
|
+
export function blockingWrite(this_: OutputStream, buf: Uint8Array): [bigint, StreamStatus];
|
|
7
|
+
export function dropOutputStream(this_: OutputStream): void;
|
|
8
8
|
}
|
|
9
9
|
export type InputStream = number;
|
|
10
10
|
/**
|
|
@@ -15,7 +15,4 @@ export type InputStream = number;
|
|
|
15
15
|
* ## `"ended"`
|
|
16
16
|
*/
|
|
17
17
|
export type StreamStatus = 'open' | 'ended';
|
|
18
|
-
export interface StreamError {
|
|
19
|
-
dummy: number,
|
|
20
|
-
}
|
|
21
18
|
export type OutputStream = number;
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -44,14 +44,19 @@ export interface Transpiled {
|
|
|
44
44
|
imports: string[],
|
|
45
45
|
exports: [string, ExportType][],
|
|
46
46
|
}
|
|
47
|
-
import {
|
|
48
|
-
import {
|
|
49
|
-
import {
|
|
50
|
-
import {
|
|
51
|
-
import {
|
|
52
|
-
import {
|
|
47
|
+
import { WasiCliEnvironment } from './imports/wasi-cli-environment';
|
|
48
|
+
import { WasiCliExit } from './imports/wasi-cli-exit';
|
|
49
|
+
import { WasiCliStderr } from './imports/wasi-cli-stderr';
|
|
50
|
+
import { WasiCliStdin } from './imports/wasi-cli-stdin';
|
|
51
|
+
import { WasiCliStdout } from './imports/wasi-cli-stdout';
|
|
52
|
+
import { WasiCliTerminalInput } from './imports/wasi-cli-terminal-input';
|
|
53
|
+
import { WasiCliTerminalOutput } from './imports/wasi-cli-terminal-output';
|
|
54
|
+
import { WasiCliTerminalStderr } from './imports/wasi-cli-terminal-stderr';
|
|
55
|
+
import { WasiCliTerminalStdin } from './imports/wasi-cli-terminal-stdin';
|
|
56
|
+
import { WasiCliTerminalStdout } from './imports/wasi-cli-terminal-stdout';
|
|
53
57
|
import { WasiClocksWallClock } from './imports/wasi-clocks-wall-clock';
|
|
54
|
-
import {
|
|
58
|
+
import { WasiFilesystemPreopens } from './imports/wasi-filesystem-preopens';
|
|
59
|
+
import { WasiFilesystemTypes } from './imports/wasi-filesystem-types';
|
|
55
60
|
import { WasiIoStreams } from './imports/wasi-io-streams';
|
|
56
61
|
import { WasiRandomRandom } from './imports/wasi-random-random';
|
|
57
62
|
export function generate(component: Uint8Array | ArrayBuffer, options: GenerateOptions): Transpiled;
|