You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The component iself can be executed in any component runtime, see the [example](EXAMPLE.md) for an end to end workflow in Wasmtime.
102
102
103
+
### Async Support
104
+
105
+
To support asynchronous operations, all functions may optionally be written as sync or async functions, even though they will always be turned into sync component functions.
106
+
107
+
For example, to use `fetch` which requires async calls, we can write the same example component using an async function:
ComponentizeJS will automatically resolve promises returned by functions to syncify their return values, running the event loop within the JS component to resolution.
117
+
118
+
This asynchrony is only supported for exported functions - imported functions can only be synchronous pending component-model-level async support.
119
+
103
120
### CLI
104
121
105
122
ComponentizeJS can be used as a CLI from `jco`:
@@ -125,13 +142,13 @@ The default set of features includes:
125
142
*`'stdio'`: Output to stderr and stdout for errors and console logging, depends on `wasi:cli` and `wasi:io`.
126
143
*`'random'`: Support for cryptographic random, depends on `wasi:random`. **When disabled, random numbers will still be generated but will not be random and instead fully deterministic.**
127
144
*`'clocks'`: Support for clocks and duration polls, depends on `wasi:clocks` and `wasi:io`. **When disabled, using any timer functions like setTimeout or setInterval will panic.**
145
+
*`'http'`: Support for outbound HTTP via the `fetch` global in JS.
128
146
129
-
Setting `disableFeatures: ['random', 'stdio', 'clocks']` will disable all features creating a minimal "pure component", that does not depend on any WASI APIs at all and just the target world.
147
+
Setting `disableFeatures: ['random', 'stdio', 'clocks', 'http']` will disable all features creating a minimal "pure component", that does not depend on any WASI APIs at all and just the target world.
130
148
131
149
Note that pure components **will not report errors and will instead trap**, so that this should only be enabled after very careful testing.
132
150
133
-
Note that features explicitly imported by the target world cannot be disabled - if you target a component to a world
134
-
that imports `wasi:clocks`, then `disableFeatures: ['clocks']` will not be supported.
151
+
Note that features explicitly imported by the target world cannot be disabled - if you target a component to a world that imports `wasi:clocks`, then `disableFeatures: ['clocks']` will not be supported.
0 commit comments