@@ -4,88 +4,108 @@ interface ComponentizeOptions {
44 *
55 * This file must be a valid JavaScript module, and can import other modules using relative paths.
66 */
7- sourcePath : string ,
7+ sourcePath : string ;
88 /**
9- * Use a debug build
10- * Note that the debug build only includes the names section only for size optimization, and not DWARF
11- * debugging sections, due to a lack of support in Node.js for these debugging workflows currently.
9+ * Path to WIT file or folder
1210 */
13- debugBuild ?: boolean ,
11+ witPath ?: string ;
12+ /**
13+ * Target world name for componentization
14+ */
15+ worldName ?: string ;
1416 /**
1517 * Path to custom ComponentizeJS engine build to use
1618 */
17- engine ?: string ,
19+ engine ?: string ;
1820 /**
1921 * Path to custom weval cache to use
2022 */
21- aotCache ?: string ,
23+ aotCache ?: string ;
2224 /**
2325 * Enable AoT using weval
2426 */
25- enableAot ?: boolean ,
27+ enableAot ?: boolean ;
2628 /**
2729 * Use a pre-existing path to the `weval` binary, if present
2830 */
29- wevalBin ?: string ,
31+ wevalBin ?: string ;
3032 /**
3133 * Use a pre-existing path to the `wizer` binary, if present
3234 */
33- wizerBin ?: string ,
35+ wizerBin ?: string ;
3436 /**
3537 * Path to custom Preview2 Adapter
3638 */
37- preview2Adapter ?: string ,
38- /**
39- * Path to WIT file or folder
40- */
41- witPath ?: string ,
42- /**
43- * Target world name for componentization
44- */
45- worldName ?: string ,
39+ preview2Adapter ?: string ;
4640 /**
4741 * Disable WASI features in the base engine
4842 * Disabling all features results in a pure component with no WASI dependence
49- *
43+ *
5044 * - stdio: console.log(), console.error and errors are provided to stderr
5145 * - random: Math.random() and crypto.randomBytes()
5246 * - clocks: Date.now(), performance.now()
5347 * - http: fetch() support
54- *
48+ *
5549 */
56- disableFeatures ?: ( 'stdio' | 'random' | 'clocks' | 'http' ) [ ] ,
50+ disableFeatures ?: ( 'stdio' | 'random' | 'clocks' | 'http' | 'fetch-event' ) [ ] ;
5751 /**
5852 * Enable WASI features in the base engine
5953 * (no experimental subsystems currently supported)
6054 */
61- enableFeatures ?: [ ] ,
55+ enableFeatures ?: [ ] ;
6256 /**
6357 * Pass environment variables to the spawned Wizer or Weval Process
6458 * If set to true, all host environment variables are passed
6559 * To pass only a subset, provide an object with the desired variables
6660 */
67- env ?: boolean | Record < string , string > ,
61+ env ?: boolean | Record < string , string > ;
6862 /**
6963 * Runtime arguments to provide to the StarlingMonkey engine initialization
7064 * (see https://github.com/bytecodealliance/StarlingMonkey/blob/main/include/config-parser.h)
7165 */
72- runtimeArgs ?: string ,
66+ runtimeArgs ?: string ;
67+ /**
68+ * Use a debug build
69+ * Note that the debug build only includes the names section only for size optimization, and not DWARF
70+ * debugging sections, due to a lack of support in Node.js for these debugging workflows currently.
71+ */
72+ debugBuild ?: boolean ;
73+ /**
74+ * Debug options
75+ */
76+ debug ?: {
77+ /** Whether to enable bindings-specific debugging */
78+ bindings ?: boolean ;
79+ /** Path to debug bindings to use */
80+ bindingsDir ?: string ;
81+ /** Whether to enable binary-specific debugging */
82+ binary ?: boolean ;
83+ /** Path to the binary that was output */
84+ binaryPath ?: string ;
85+ /** Whether to enable wizer logging */
86+ wizerLogging : false ;
87+ } ;
7388}
7489
7590/**
7691 * Componentize a JavaScript module to a WebAssembly component
7792 *
7893 * @param opts Componentize options
7994 */
80- export function componentize ( opts : ComponentizeOptions ) : Promise < ComponentizeOutput >
95+ export function componentize (
96+ opts : ComponentizeOptions ,
97+ ) : Promise < ComponentizeOutput > ;
8198
8299/**
83100 * @deprecated Use `componentize(opts)` instead
84101 *
85102 * @param source Source code of JavaScript module to componentize
86103 * @param opts Componentize options
87104 */
88- export function componentize ( source : string , opts : ComponentizeOptions ) : Promise < ComponentizeOutput >
105+ export function componentize (
106+ source : string ,
107+ opts : ComponentizeOptions ,
108+ ) : Promise < ComponentizeOutput > ;
89109
90110/**
91111 * @deprecated Use `componentize(opts)` instead
@@ -94,20 +114,37 @@ export function componentize(source: string, opts: ComponentizeOptions): Promise
94114 * @param witWorld Inline WIT string to componentize to
95115 * @param opts Componentize options
96116 */
97- export function componentize ( source : string , witWorld : string , opts ?: ComponentizeOptions ) : Promise < ComponentizeOutput >
117+ export function componentize (
118+ source : string ,
119+ witWorld : string ,
120+ opts ?: ComponentizeOptions ,
121+ ) : Promise < ComponentizeOutput > ;
98122
99123interface ComponentizeOutput {
100124 /**
101125 * Component binary
102126 */
103- component : Uint8Array ,
127+ component : Uint8Array ;
104128 /**
105129 * Used guest imports in JavaScript (excluding those from StarlingMonkey engine)
106130 */
107- imports : [ [ string , string ] ] [ ]
131+ imports : [ [ string , string ] ] [ ] ;
132+ /**
133+ * Debugging output (only present if enabled)
134+ */
135+ debug ?: {
136+ /** Whether bindings debugging was enabled */
137+ bindings ?: boolean ;
138+ /** Work directory used during processing */
139+ workDir ?: string ;
140+ /** Whether binary debugging was enabled */
141+ binary ?: boolean ;
142+ /** Path to the produced binary */
143+ binaryPath ?: string ;
144+ } ;
108145}
109146
110147/**
111148 * ComponentizeJS version string
112149 */
113- export const version : string
150+ export const version : string ;
0 commit comments