Skip to content

Commit 5a78736

Browse files
authored
add types, readme fix, submodule update (#98)
1 parent fa61954 commit 5a78736

File tree

5 files changed

+55
-7
lines changed

5 files changed

+55
-7
lines changed

Diff for: .gitmodules

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[submodule "StarlingMonkey"]
22
path = StarlingMonkey
3-
url = [email protected]:guybedford/StarlingMonkey
3+
url = [email protected]:fermyon/StarlingMonkey

Diff for: README.md

+1-5
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,7 @@ const { component } = await componentize(`
8686
world hello {
8787
export hello: func(name: string) -> string;
8888
}
89-
`, {
90-
// recommended to get error debugging
91-
// disable to get a "pure component" without WASI imports
92-
enableStdout: true
93-
});
89+
`);
9490

9591
await writeFile('test.component.wasm', component);
9692
```

Diff for: package.json

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"@bytecodealliance/wizer": "^3.0.1",
1414
"es-module-lexer": "^1.4.1"
1515
},
16+
"types": "types.d.ts",
1617
"scripts": {
1718
"build": "make release",
1819
"build:debug": "make debug",

Diff for: types.d.ts

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
interface ComponentizeOptions {
2+
/**
3+
* Source name for debugging
4+
*/
5+
sourceName?: string,
6+
/**
7+
* Path to custom ComponentizeJS engine build to use
8+
*/
9+
engine?: string,
10+
/**
11+
* Path to custom Preview2 Adapter
12+
*/
13+
preview2Adapter?: string,
14+
/**
15+
* Path to WIT file or folder
16+
*/
17+
witPath?: string,
18+
/**
19+
* Target world name for componentization
20+
*/
21+
worldName?: string,
22+
/**
23+
* Disable WASI features in the base engine
24+
* Disabling all features results in a pure component with no WASI dependence
25+
*/
26+
disableFeatures?: ('stdio' | 'random' | 'clocks')[],
27+
}
28+
29+
/**
30+
* @param source JavaScript module to componentize
31+
* @param opts Componentize options
32+
*/
33+
export function componentize(source: string, opts: ComponentizeOptions): Promise<ComponentizeOutput>
34+
/**
35+
*
36+
* @param source JavaScript module to componentize
37+
* @param witWorld Inline WIT string to componentize to
38+
* @param opts Componentize options
39+
*/
40+
export function componentize(source: string, witWorld: string, opts?: ComponentizeOptions): Promise<ComponentizeOutput>
41+
42+
interface ComponentizeOutput {
43+
/**
44+
* Component binary
45+
*/
46+
component: Uint8Array,
47+
/**
48+
* Available component world imports to the componentized JavaScript (whether used or not)
49+
*/
50+
imports: [[string, string]][]
51+
}

0 commit comments

Comments
 (0)