@bytecodealliance/jco 0.6.1 → 0.8.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 CHANGED
@@ -70,7 +70,7 @@ Commands:
70
70
  To componentize a JS file run:
71
71
 
72
72
  ```
73
- jco componentize app.js --wit world.wit -o component.wasm
73
+ jco componentize app.js --wit wit -n world-name -o component.wasm
74
74
  ```
75
75
 
76
76
  Creates a component from a JS module implementing a WIT world definition, via a Spidermonkey engine embedding.
package/api.d.ts CHANGED
@@ -31,11 +31,29 @@ export interface TranspileOpts {
31
31
  /// if using optimize, custom optimization options
32
32
  /// (defaults to best optimization, but this is very slow)
33
33
  optArgs?: string[],
34
- /// rewrite WASI imports to the @bytecodealliance/preview2-shim
35
- /// defaults to false
34
+ /// rewrites WASI imports to the @bytecodealliance/preview2-shim
35
+ /// defaults to true
36
36
  wasiShim?: boolean
37
37
  }
38
38
 
39
+ export interface EmbedOpts {
40
+ /// Component binary to embed
41
+ binary?: Uint8Array,
42
+ /// Pass an inline WIT source
43
+ witSource?: string,
44
+ /// Pass the file system path to WIT file
45
+ /// Either a path or a source must be passed not both
46
+ witPath?: string,
47
+ /// String encoding for the component functions
48
+ stringEncoding?: 'utf8' | 'utf16',
49
+ /// Generate a dummy component
50
+ dummy: option<bool>,
51
+ /// World name to embed
52
+ world?: string,
53
+ /// Metadata to embed
54
+ metadata?: Metadata
55
+ }
56
+
39
57
  /**
40
58
  * Transpile a Component into a JS-executable package
41
59
  */
@@ -65,12 +83,7 @@ type Metadata = [string, [string, string][]][];
65
83
  /**
66
84
  * Embed a world into a Wasm core binary
67
85
  */
68
- export function componentEmbed(binary: Uint8Array | ArrayBuffer | null, wit: string, opts: {
69
- stringEncoding?: 'utf8' | 'utf16' | 'compact-utf16',
70
- dummy?: boolean,
71
- world?: string,
72
- metadata?: Metadata
73
- }): Uint8Array;
86
+ export function componentEmbed(opts: EmbedOpts): Uint8Array;
74
87
 
75
88
  /**
76
89
  * Extract the producer metadata for a Wasm component or core module