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 @@ -116,6 +117,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 @@ -215,6 +226,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 @@ -279,6 +295,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 @@ -353,6 +374,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 @@ -430,6 +456,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 @@ -820,6 +851,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 @@ -977,6 +1013,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 @@ -86,6 +86,7 @@ impl bindings::Guest for JsComponentBindgenComponent {
.perf_strings_skip_copy_utf16_validation
.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 @@ -105,6 +105,8 @@ world js-component-bindgen {
/// Skip validating utf16 strings that are copied between components which
/// both use utf16 (they are validated by default)
perf-strings-skip-copy-utf16-validation: 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" ] }
7 changes: 7 additions & 0 deletions crates/js-component-bindgen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@
$ cargo add js-component-bindgen
```

Generated JavaScript includes its runtime intrinsics inline by default. To
select an external runtime provider, set `TranspileOpts::runtime_module` to
`@bytecodealliance/jco-cm-runtime` or another module specifier. Make the selected
module resolvable from the generated output; it must export a `runtime` provider.
Currently, external providers implement `resource.tableGet`, while the remaining
intrinsics are generated inline.

# License

This project is licensed under the Apache 2.0 license with the LLVM exception.
Expand Down
Loading
Loading