@bytecodealliance/componentize-js
Advanced tools
Comparing version 0.10.5 to 0.11.0
{ | ||
"name": "@bytecodealliance/componentize-js", | ||
"version": "0.10.5", | ||
"version": "0.11.0", | ||
"homepage": "https://github.com/bytecodealliance/componentize-js#readme", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -103,2 +103,19 @@ <div align="center"> | ||
### Async Support | ||
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. | ||
For example, to use `fetch` which requires async calls, we can write the same example component using an async function: | ||
```js | ||
export async function sayHello (name) { | ||
const text = await (await fetch(`http://localhost:8080/${name}`)).text(); | ||
console.log(text); | ||
} | ||
``` | ||
ComponentizeJS will automatically resolve promises returned by functions to syncify their return values, running the event loop within the JS component to resolution. | ||
This asynchrony is only supported for exported functions - imported functions can only be synchronous pending component-model-level async support. | ||
### CLI | ||
@@ -129,9 +146,9 @@ | ||
* `'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.** | ||
* `'http'`: Support for outbound HTTP via the `fetch` global in JS. | ||
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. | ||
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. | ||
Note that pure components **will not report errors and will instead trap**, so that this should only be enabled after very careful testing. | ||
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. | ||
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. | ||
@@ -152,4 +169,3 @@ ## Using StarlingMonkey's `fetch-event` | ||
preview2Adapter?: string, | ||
disableFeatures?: ('stdio' | 'random' | 'clocks')[], | ||
enableFeatures?: ('http')[], | ||
disableFeatures?: ('stdio' | 'random' | 'clocks' | 'http')[], | ||
}): { | ||
@@ -156,0 +172,0 @@ component: Uint8Array, |
@@ -69,3 +69,2 @@ import wizer from '@bytecodealliance/wizer'; | ||
// we never disable a feature that is already in the target world usage | ||
@@ -82,3 +81,3 @@ const features = []; | ||
} | ||
if (enableFeatures.includes('http')) { | ||
if (!disableFeatures.includes('http')) { | ||
features.push('http'); | ||
@@ -99,3 +98,2 @@ } | ||
if (DEBUG_BINDINGS) { | ||
@@ -102,0 +100,0 @@ console.log('--- JS Source ---'); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
180702926
27
205
3