@bytecodealliance/jco 0.9.3 → 0.9.5

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 CHANGED
@@ -103,6 +103,10 @@ Options include:
103
103
  * `--instantiation`: Instead of a direct ES module, export an `instantiate` function which can take the imports as an argument instead of implicit imports.
104
104
  * `--valid-lifting-optimization`: Internal validations are removed assuming that core Wasm binaries are valid components, providing a minor output size saving.
105
105
 
106
+ #### Bindgen Crate
107
+
108
+ To directly call into the transpilation in Rust, the bindgen used in jco is also available on crates.io as [js-component-bindgen](https://crates.io/crates/js-component-bindgen).
109
+
106
110
  ### Componentize
107
111
 
108
112
  To componentize a JS file run:
@@ -1,3 +1,3 @@
1
- export namespace ImportsEnvironment {
1
+ export namespace Environment {
2
2
  export function getEnvironment(): [string, string][];
3
3
  }
@@ -1,4 +1,4 @@
1
- export namespace ImportsExit {
1
+ export namespace Exit {
2
2
  export function exit(status: Result<void, void>): void;
3
3
  }
4
4
  export type Result<T, E> = { tag: 'ok', val: T } | { tag: 'err', val: E };
@@ -1,4 +1,4 @@
1
- export namespace ImportsFilesystem {
1
+ export namespace Filesystem {
2
2
  export function readViaStream(this: Descriptor, offset: Filesize): InputStream;
3
3
  export function writeViaStream(this: Descriptor, offset: Filesize): OutputStream;
4
4
  export function appendViaStream(this: Descriptor): OutputStream;
@@ -10,7 +10,7 @@ export namespace ImportsFilesystem {
10
10
  }
11
11
  export type Descriptor = number;
12
12
  export type Filesize = bigint;
13
- import type { InputStream } from '../imports/streams';
13
+ import type { InputStream } from '../interfaces/wasi-io-streams';
14
14
  export { InputStream };
15
15
  /**
16
16
  * # Variants
@@ -90,7 +90,7 @@ export { InputStream };
90
90
  * ## `"cross-device"`
91
91
  */
92
92
  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 '../imports/streams';
93
+ import type { OutputStream } from '../interfaces/wasi-io-streams';
94
94
  export { OutputStream };
95
95
  /**
96
96
  * # Variants
@@ -115,7 +115,7 @@ export type DescriptorType = 'unknown' | 'block-device' | 'character-device' | '
115
115
  export type Device = bigint;
116
116
  export type Inode = bigint;
117
117
  export type LinkCount = bigint;
118
- import type { Datetime } from '../imports/wall-clock';
118
+ import type { Datetime } from '../interfaces/wasi-clocks-wall-clock';
119
119
  export { Datetime };
120
120
  export interface DescriptorStat {
121
121
  device: Device,
@@ -0,0 +1,5 @@
1
+ export namespace Preopens {
2
+ export function getDirectories(): [Descriptor, string][];
3
+ }
4
+ import type { Descriptor } from '../interfaces/wasi-filesystem-filesystem';
5
+ export { Descriptor };
@@ -1,3 +1,3 @@
1
- export namespace ImportsRandom {
1
+ export namespace Random {
2
2
  export function getRandomBytes(len: bigint): Uint8Array | ArrayBuffer;
3
3
  }
@@ -0,0 +1,5 @@
1
+ export namespace Stderr {
2
+ export function getStderr(): OutputStream;
3
+ }
4
+ import type { OutputStream } from '../interfaces/wasi-io-streams';
5
+ export { OutputStream };
@@ -0,0 +1,5 @@
1
+ export namespace Stdin {
2
+ export function getStdin(): InputStream;
3
+ }
4
+ import type { InputStream } from '../interfaces/wasi-io-streams';
5
+ export { InputStream };
@@ -0,0 +1,5 @@
1
+ export namespace Stdout {
2
+ export function getStdout(): OutputStream;
3
+ }
4
+ import type { OutputStream } from '../interfaces/wasi-io-streams';
5
+ export { OutputStream };
@@ -1,4 +1,4 @@
1
- export namespace ImportsStreams {
1
+ export namespace Streams {
2
2
  export function read(this: InputStream, len: bigint): [Uint8Array | ArrayBuffer, boolean];
3
3
  export function blockingRead(this: InputStream, len: bigint): [Uint8Array | ArrayBuffer, boolean];
4
4
  export function dropInputStream(this: InputStream): void;
@@ -1,4 +1,4 @@
1
- export namespace ImportsWallClock {
1
+ export namespace WallClock {
2
2
  }
3
3
  export interface Datetime {
4
4
  seconds: bigint,
@@ -44,16 +44,16 @@ export interface Transpiled {
44
44
  imports: string[],
45
45
  exports: [string, ExportType][],
46
46
  }
47
- import { ImportsEnvironment } from './imports/environment';
48
- import { ImportsExit } from './imports/exit';
49
- import { ImportsPreopens } from './imports/preopens';
50
- import { ImportsStderr } from './imports/stderr';
51
- import { ImportsStdin } from './imports/stdin';
52
- import { ImportsStdout } from './imports/stdout';
53
- import { ImportsWallClock } from './imports/wall-clock';
54
- import { ImportsFilesystem } from './imports/filesystem';
55
- import { ImportsStreams } from './imports/streams';
56
- import { ImportsRandom } from './imports/random';
47
+ import { Environment } from './interfaces/environment';
48
+ import { Exit } from './interfaces/exit';
49
+ import { Preopens } from './interfaces/preopens';
50
+ import { Stderr } from './interfaces/stderr';
51
+ import { Stdin } from './interfaces/stdin';
52
+ import { Stdout } from './interfaces/stdout';
53
+ import { WallClock } from './interfaces/wall-clock';
54
+ import { Filesystem } from './interfaces/filesystem';
55
+ import { Streams } from './interfaces/streams';
56
+ import { Random } from './interfaces/random';
57
57
  export function generate(component: Uint8Array | ArrayBuffer, options: GenerateOptions): Transpiled;
58
58
  export function generateTypes(name: string, options: TypeGenerationOptions): Files;
59
59
 
Binary file
@@ -32,16 +32,16 @@ export interface EmbedOpts {
32
32
  world?: string,
33
33
  metadata?: ProducersFields,
34
34
  }
35
- import { ImportsEnvironment } from './imports/environment';
36
- import { ImportsExit } from './imports/exit';
37
- import { ImportsPreopens } from './imports/preopens';
38
- import { ImportsStderr } from './imports/stderr';
39
- import { ImportsStdin } from './imports/stdin';
40
- import { ImportsStdout } from './imports/stdout';
41
- import { ImportsWallClock } from './imports/wall-clock';
42
- import { ImportsFilesystem } from './imports/filesystem';
43
- import { ImportsStreams } from './imports/streams';
44
- import { ImportsRandom } from './imports/random';
35
+ import { Environment } from './interfaces/environment';
36
+ import { Exit } from './interfaces/exit';
37
+ import { Preopens } from './interfaces/preopens';
38
+ import { Stderr } from './interfaces/stderr';
39
+ import { Stdin } from './interfaces/stdin';
40
+ import { Stdout } from './interfaces/stdout';
41
+ import { WallClock } from './interfaces/wall-clock';
42
+ import { Filesystem } from './interfaces/filesystem';
43
+ import { Streams } from './interfaces/streams';
44
+ import { Random } from './interfaces/random';
45
45
  export function parse(wat: string): Uint8Array;
46
46
  export function print(binary: Uint8Array | ArrayBuffer): string;
47
47
  export function componentNew(binary: Uint8Array | ArrayBuffer, adapters: [string, Uint8Array | ArrayBuffer][] | null): Uint8Array;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytecodealliance/jco",
3
- "version": "0.9.3",
3
+ "version": "0.9.5",
4
4
  "description": "JavaScript tooling for working with WebAssembly Components",
5
5
  "author": "Guy Bedford",
6
6
  "bin": {
@@ -79,7 +79,7 @@ async function wasm2Js (source) {
79
79
  */
80
80
  export async function transpileComponent (component, opts = {}) {
81
81
  await $init;
82
- if (opts.noWasiShim) opts.wasiShim = false;
82
+ if (opts.noWasiShim || opts.instantiation) opts.wasiShim = false;
83
83
 
84
84
  let spinner;
85
85
  const showSpinner = getShowSpinner();
package/src/jco.js CHANGED
@@ -10,7 +10,7 @@ program
10
10
  .name('jco')
11
11
  .description(c`{bold jco - WebAssembly JS Component Tools}\n JS Component Transpilation Bindgen & Wasm Tools for JS`)
12
12
  .usage('<command> [options]')
13
- .version('0.9.3');
13
+ .version('0.9.4');
14
14
 
15
15
  function myParseInt(value) {
16
16
  return parseInt(value, 10);
@@ -1,3 +0,0 @@
1
- export namespace ExportsTest {
2
- export function hello(): string;
3
- }
@@ -1,5 +0,0 @@
1
- export namespace ImportsPreopens {
2
- export function getDirectories(): [Descriptor, string][];
3
- }
4
- import type { Descriptor } from '../imports/filesystem';
5
- export { Descriptor };
@@ -1,5 +0,0 @@
1
- export namespace ImportsStderr {
2
- export function getStderr(): OutputStream;
3
- }
4
- import type { OutputStream } from '../imports/streams';
5
- export { OutputStream };
@@ -1,5 +0,0 @@
1
- export namespace ImportsStdin {
2
- export function getStdin(): InputStream;
3
- }
4
- import type { InputStream } from '../imports/streams';
5
- export { InputStream };
@@ -1,5 +0,0 @@
1
- export namespace ImportsStdout {
2
- export function getStdout(): OutputStream;
3
- }
4
- import type { OutputStream } from '../imports/streams';
5
- export { OutputStream };