Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/create-release-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ on:
- bare-jco
- jco-node-fs
- jco-transpile
- jco-cm-runtime
- jco-std
- js-component-bindgen
- preview2-shim
Expand Down Expand Up @@ -115,6 +116,12 @@ jobs:
export CURRENT_VERSION;
export IS_JS_PROJECT=true;
;;
jco-cm-runtime)
export PROJECT_DIR="$PWD/packages/$PROJECT";
CURRENT_VERSION="$(node -e "process.stdout.write(require(process.env.PROJECT_DIR + '/package.json').version)")";
export CURRENT_VERSION;
export IS_JS_PROJECT=true;
;;
jco-std)
export PROJECT_DIR="$PWD/packages/$PROJECT";
CURRENT_VERSION="$(node -e "process.stdout.write(require(process.env.PROJECT_DIR + '/package.json').version)")";
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/main-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@ jobs:
- name: Install node modules
run: pnpm install

- name: Build and test Component Model runtime
run: |
pnpm --filter '@bytecodealliance/jco-cm-runtime' run build
pnpm --filter '@bytecodealliance/jco-cm-runtime' run test

- name: Upload Component Model runtime build output
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: jco-cm-runtime-dist
path: packages/jco-cm-runtime/dist

- name: Build jco for test
working-directory: packages/jco
run: |
Expand Down Expand Up @@ -218,6 +229,11 @@ jobs:
with:
name: jco-build-ts
path: packages/jco/dist
- name: Restore Component Model runtime build output
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: jco-cm-runtime-dist
path: packages/jco-cm-runtime/dist

- name: Restore artifacts for JS tests
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
Expand Down Expand Up @@ -301,6 +317,11 @@ jobs:
with:
name: jco-build-ts
path: packages/jco/dist
- name: Restore Component Model runtime build output
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: jco-cm-runtime-dist
path: packages/jco-cm-runtime/dist

- name: Restore artifacts for JS tests
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ jobs:
- name: Install node modules
run: pnpm install

- name: Build and test Component Model runtime
run: |
pnpm --filter '@bytecodealliance/jco-cm-runtime' run build
pnpm --filter '@bytecodealliance/jco-cm-runtime' run test

- name: Upload Component Model runtime build output
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: jco-cm-runtime-dist
path: packages/jco-cm-runtime/dist

- name: Build jco for test
working-directory: packages/jco
run: |
Expand Down Expand Up @@ -187,6 +198,11 @@ jobs:
with:
name: jco-build-ts
path: packages/jco/dist
- name: Restore Component Model runtime build output
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: jco-cm-runtime-dist
path: packages/jco-cm-runtime/dist

- name: Restore preview2-shim build output
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
Expand Down Expand Up @@ -275,6 +291,11 @@ jobs:
with:
name: jco-transpile-vendor
path: packages/jco-transpile/vendor
- name: Restore Component Model runtime build output
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: jco-cm-runtime-dist
path: packages/jco-cm-runtime/dist

- name: Restore artifacts for JS tests
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
Expand Down Expand Up @@ -349,6 +370,11 @@ jobs:
with:
name: jco-build-ts
path: packages/jco/dist
- name: Restore Component Model runtime build output
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: jco-cm-runtime-dist
path: packages/jco-cm-runtime/dist

- name: Restore artifacts for JS tests
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
Expand Down Expand Up @@ -424,6 +450,11 @@ jobs:
with:
name: jco-build-ts
path: packages/jco/dist
- name: Restore Component Model runtime build output
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: jco-cm-runtime-dist
path: packages/jco-cm-runtime/dist

- name: Restore artifacts for JS tests
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
Expand Down Expand Up @@ -800,6 +831,11 @@ jobs:
with:
name: jco-build-ts
path: packages/jco/dist
- name: Restore Component Model runtime build output
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: jco-cm-runtime-dist
path: packages/jco-cm-runtime/dist

- name: Restore artifacts for JS tests
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
Expand Down Expand Up @@ -939,6 +975,11 @@ jobs:
with:
name: jco-build-ts
path: packages/jco/dist
- name: Restore Component Model runtime build output
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: jco-cm-runtime-dist
path: packages/jco-cm-runtime/dist

- name: Restore jco-transpile vendor
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ on:
- "jco-node-fs-v[0-9]+.[0-9]+.[0-9]+-*"
- "jco-transpile-v[0-9]+.[0-9]+.[0-9]+*"
- "jco-transpile-v[0-9]+.[0-9]+.[0-9]+-*"
- "jco-cm-runtime-v[0-9]+.[0-9]+.[0-9]+*"
- "jco-cm-runtime-v[0-9]+.[0-9]+.[0-9]+-*"
- "jco-std-v[0-9]+.[0-9]+.[0-9]+*"
- "jco-std-v[0-9]+.[0-9]+.[0-9]+-*"
- "preview2-shim-v[0-9]+.[0-9]+.[0-9]+*"
Expand All @@ -32,6 +34,8 @@ on:
- "prep-release-jco-node-fs-v[0-9]+.[0-9]+.[0-9]+-*"
- "prep-release-jco-transpile-v[0-9]+.[0-9]+.[0-9]+*"
- "prep-release-jco-transpile-v[0-9]+.[0-9]+.[0-9]+-*"
- "prep-release-jco-cm-runtime-v[0-9]+.[0-9]+.[0-9]+*"
- "prep-release-jco-cm-runtime-v[0-9]+.[0-9]+.[0-9]+-*"
- "prep-release-jco-std-v[0-9]+.[0-9]+.[0-9]+*"
- "prep-release-jco-std-v[0-9]+.[0-9]+.[0-9]+-*"
- "prep-release-preview2-shim-v[0-9]+.[0-9]+.[0-9]+*"
Expand All @@ -54,6 +58,7 @@ on:
- bare-jco
- jco-node-fs
- jco-transpile
- jco-cm-runtime
- jco-std
- js-component-bindgen
- preview2-shim
Expand Down Expand Up @@ -182,6 +187,15 @@ jobs:
export ARTIFACTS_GLOB="packages/jco-transpile/bytecodealliance-jco-transpile-*.tgz";
export ARTIFACT_NAME="bytecodealliance-jco-transpile-$NEXT_VERSION.tgz";
;;
jco-cm-runtime)
export PROJECT_DIR="$PWD/packages/$PROJECT";
export PROJECT_PACKAGE_NAME="@bytecodealliance/$PROJECT";
CURRENT_VERSION=$(node -e "process.stdout.write(require(process.env.PROJECT_DIR + '/package.json').version)");
export CURRENT_VERSION;
export IS_JS_PROJECT=true;
export ARTIFACTS_GLOB="packages/jco-cm-runtime/bytecodealliance-jco-cm-runtime-*.tgz";
export ARTIFACT_NAME="bytecodealliance-jco-cm-runtime-$NEXT_VERSION.tgz";
;;
jco-std)
export PROJECT_DIR="$PWD/packages/$PROJECT";
export PROJECT_PACKAGE_NAME="@bytecodealliance/$PROJECT";
Expand Down Expand Up @@ -560,6 +574,20 @@ jobs:
pnpm install --save "$PACKAGE_DIR"
pnpm run all

- name: Test built Component Model runtime NPM package
if: ${{ needs.meta.outputs.project == 'jco-cm-runtime' }}
shell: bash
env:
ARTIFACT_NAME: ${{ needs.meta.outputs.artifact-name }}
GH_WORKSPACE: ${{ github.workspace }}
run: |
export PACKAGE_PATH="$GH_WORKSPACE/gh-artifacts/$ARTIFACT_NAME"
mkdir -p /tmp/test-jco-cm-runtime
cd /tmp/test-jco-cm-runtime
echo '{"private":true,"type":"module"}' > package.json
pnpm install "$PACKAGE_PATH"
node --input-type=module -e "import { runtime, RUNTIME_ABI_VERSION } from '@bytecodealliance/jco-cm-runtime'; const instance = runtime.create({ requestedAbiVersion: RUNTIME_ABI_VERSION, strict: false, flagsAsBigInt: false, nodejsCompat: true, asyncDeterminism: 'random' }); const entry = instance.intrinsics.resource.tableGet([1 << 30, 0, 7, 42 | (1 << 30)], 1); if (entry.rep !== 42 || !entry.own) throw new Error('runtime smoke test failed');"

- name: Test built jco-node-fs NPM package
if: ${{ needs.meta.outputs.project == 'jco-node-fs' }}
env:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/tag-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ on:
- bare-jco
- jco-node-fs
- jco-transpile
- jco-cm-runtime
- jco-std
- js-component-bindgen
- preview2-shim
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/js-component-bindgen-component/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ impl bindings::Guest for JsComponentBindgenComponent {
.guest(options.guest.unwrap_or(false))
.maybe_async_mode(options.async_mode.map(Into::into))
.strict(options.strict.unwrap_or(false))
.maybe_runtime_module(options.runtime_module)
.flags_as_bigint(options.flags_as_bigint.unwrap_or(false))
.variants_inline_cases(options.variants_inline_cases.unwrap_or(false))
.use_namespace_objects(options.use_namespace_objects.unwrap_or(false))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ world js-component-bindgen {
/// Configure whether to generate code that includes strict type checks
strict: option<bool>,

/// ES module providing the Component Model runtime implementation.
runtime-module: option<string>,

/// Represent WIT flags as bigint values instead of objects of booleans.
flags-as-bigint: option<bool>,

Expand Down
3 changes: 3 additions & 0 deletions crates/js-component-bindgen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ wasmtime-environ = { workspace = true, features = ['component-model'] }
wit-bindgen-core = { workspace = true }
wit-component = { workspace = true }
wit-parser = { workspace = true }

[dev-dependencies]
wat = { workspace = true, features = [ "component-model" ] }
5 changes: 5 additions & 0 deletions crates/js-component-bindgen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
$ cargo add js-component-bindgen
```

Generated JavaScript that uses Component Model runtime intrinsics imports
`@bytecodealliance/jco-cm-runtime` by default. Applications using this crate
directly must make that package, or the module selected with
`TranspileOpts::runtime_module`, resolvable from the generated output.

# License

This project is licensed under the Apache 2.0 license with the LLVM exception.
Expand Down
4 changes: 3 additions & 1 deletion crates/js-component-bindgen/src/function_bindgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1928,6 +1928,8 @@ impl Bindgen for FunctionBindgen<'_> {
let get_component_state = self.intrinsic(Intrinsic::Component(
ComponentIntrinsic::GetOrCreateAsyncState,
));
let track_host_operation =
self.intrinsic(Intrinsic::Component(ComponentIntrinsic::TrackHostOperation));
let start_current_task_fn = self.intrinsic(Intrinsic::AsyncTask(
AsyncTaskIntrinsic::CreateNewCurrentTask,
));
Expand Down Expand Up @@ -2105,7 +2107,7 @@ impl Bindgen for FunctionBindgen<'_> {
r#"{call_prefix} {call_wrapper}({{
componentIdx: task.componentIdx(),
taskID: task.id(),
fn: () => {callee_fn_js}({callee_args_js}),
fn: () => {track_host_operation}(() => {callee_fn_js}({callee_args_js})),
}})
"#,
);
Expand Down
Loading
Loading