-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathtypes.d.ts
More file actions
138 lines (133 loc) · 3.71 KB
/
types.d.ts
File metadata and controls
138 lines (133 loc) · 3.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
interface ComponentizeOptions {
/**
* The path to the file to componentize.
*
* This file must be a valid JavaScript module, and can import other modules using relative paths.
*/
sourcePath: string;
/**
* Path to WIT file or folder
*/
witPath?: string;
/**
* Target world name for componentization
*/
worldName?: string;
/**
* Path to custom ComponentizeJS engine build to use
*/
engine?: string;
/**
* Use a pre-existing path to the `wizer` binary, if present
*/
wizerBin?: string;
/**
* Path to custom Preview2 Adapter
*/
preview2Adapter?: string;
/**
* Disable WASI features in the base engine
* Disabling all features results in a pure component with no WASI dependence
*
* - stdio: console.log(), console.error and errors are provided to stderr
* - random: Math.random() and crypto.randomBytes()
* - clocks: Date.now(), performance.now()
* - http: fetch() support
*
*/
disableFeatures?: ('stdio' | 'random' | 'clocks' | 'http' | 'fetch-event')[];
/**
* Enable WASI features in the base engine
* (no experimental subsystems currently supported)
*/
enableFeatures?: [];
/**
* Pass environment variables to the spawned Wizer Process
* If set to true, all host environment variables are passed
* To pass only a subset, provide an object with the desired variables
*/
env?: boolean | Record<string, string>;
/**
* Runtime arguments to provide to the StarlingMonkey engine initialization
* (see https://github.com/bytecodealliance/StarlingMonkey/blob/main/include/config-parser.h)
*/
runtimeArgs?: string;
/**
* Use a debug build
* Note that the debug build only includes the names section only for size optimization, and not DWARF
* debugging sections, due to a lack of support in Node.js for these debugging workflows currently.
*/
debugBuild?: boolean;
/**
* Debug options
*/
debug?: {
/** Whether to enable bindings-specific debugging */
bindings?: boolean;
/** Path to debug bindings to use */
bindingsDir?: string;
/** Whether to enable binary-specific debugging */
binary?: boolean;
/** Path to the binary that was output */
binaryPath?: string;
/** Whether to enable wizer logging */
wizerLogging: false;
};
}
/**
* Componentize a JavaScript module to a WebAssembly component
*
* @param opts Componentize options
*/
export function componentize(
opts: ComponentizeOptions,
): Promise<ComponentizeOutput>;
/**
* @deprecated Use `componentize(opts)` instead
*
* @param source Source code of JavaScript module to componentize
* @param opts Componentize options
*/
export function componentize(
source: string,
opts: ComponentizeOptions,
): Promise<ComponentizeOutput>;
/**
* @deprecated Use `componentize(opts)` instead
*
* @param source Source code of JavaScript module to componentize
* @param witWorld Inline WIT string to componentize to
* @param opts Componentize options
*/
export function componentize(
source: string,
witWorld: string,
opts?: ComponentizeOptions,
): Promise<ComponentizeOutput>;
interface ComponentizeOutput {
/**
* Component binary
*/
component: Uint8Array;
/**
* Used guest imports in JavaScript (excluding those from StarlingMonkey engine)
*/
imports: [[string, string]][];
/**
* Debugging output (only present if enabled)
*/
debug?: {
/** Whether bindings debugging was enabled */
bindings?: boolean;
/** Work directory used during processing */
workDir?: string;
/** Whether binary debugging was enabled */
binary?: boolean;
/** Path to the produced binary */
binaryPath?: string;
};
}
/**
* ComponentizeJS version string
*/
export const version: string;