-
Notifications
You must be signed in to change notification settings - Fork 32
/
types.d.ts
80 lines (78 loc) · 2.09 KB
/
types.d.ts
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
interface ComponentizeOptions {
/**
* Source name for debugging
*/
sourceName?: string,
/**
* Path to custom ComponentizeJS engine build to use
*/
engine?: string,
/**
* Path to custom weval cache to use
*/
aotCache?: string,
/**
* Enable AoT using weval
*/
enableAot?: boolean,
/**
* Use a pre-existing path to the `weval` binary, if present
*/
wevalBin?: string,
/**
* Path to custom Preview2 Adapter
*/
preview2Adapter?: string,
/**
* Path to WIT file or folder
*/
witPath?: string,
/**
* Target world name for componentization
*/
worldName?: 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')[],
/**
* Enable WASI features in the base engine
* (no experimental subsystems currently supported)
*/
enableFeatures?: [],
/**
* Pass environment variables to the spawned Wizer or Weval 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>,
}
/**
* @param source JavaScript module to componentize
* @param opts Componentize options
*/
export function componentize(source: string, opts: ComponentizeOptions): Promise<ComponentizeOutput>
/**
*
* @param source 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]][]
}