forked from bytecodealliance/ComponentizeJS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.d.ts
63 lines (61 loc) · 1.55 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
interface ComponentizeOptions {
/**
* Source name for debugging
*/
sourceName?: string,
/**
* Path to custom ComponentizeJS engine build to use
*/
engine?: 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()
*
*/
disableFeatures?: ('stdio' | 'random' | 'clocks')[],
/**
* Enable WASI features in the base engine
*
* - http: fetch() API
*
*/
enableFeatures?: ('http')[],
}
/**
* @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]][]
}