Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
974918b
docs: update README & AGENTS for ns-wasm-core and ns-wasm-kit-runtime
listepo Aug 6, 2026
1c4554f
feat: add @cross-code/ns-endive — Endive Java-based WASM runtime plugin
listepo Aug 6, 2026
fe39392
fix(ci): add new packages to build lists and change filters
listepo Aug 6, 2026
021b6d4
docs(AGENTS): scope Rust/UniFFI architecture to ns-wasm3 and ns-wamr
listepo Aug 6, 2026
7c23cc2
docs(README): fix plugin count — three WASM runtimes, ns-wry separate
listepo Aug 6, 2026
bb0ec60
fix(demo): run Endive only on Android, update success message
listepo Aug 6, 2026
afd69e6
fix(endive): pass log to runFixtureChecks, drop as any cast
listepo Aug 6, 2026
a79caa6
fix(endive): use Double.valueOf(), ArrayList for call args, raw getGl…
listepo Aug 6, 2026
435ddbc
fix(endive): normalizeAndroid globals through java.lang.Long, toJavaW…
listepo Aug 6, 2026
46af590
fix(demo): gate WasmKit to iOS only, Endive to Android only
listepo Aug 6, 2026
b7f1d66
feat: add @cross-code/ns-wasm-edge — WasmEdge runtime plugin
listepo Aug 6, 2026
0f98635
feat: add @cross-code/ns-wasm-chicory — Chicory pure-Java WASM runtime
listepo Aug 6, 2026
5ce773d
chore: sync lockfiles, tsconfig, spec updates across all packages
listepo Aug 7, 2026
00b3fc0
feat: add oxlint and oxfmt Nx inference plugins
listepo Aug 7, 2026
bd3d65f
feat: universal simulator xcframeworks, runtime-support suite gating
listepo Aug 7, 2026
89ffc08
chore: lockfile — add oxlint and oxfmt devDependencies
listepo Aug 7, 2026
e4adca1
chore: update oxlint to 1.77.0 and oxfmt to 0.62.0
listepo Aug 7, 2026
551b6c6
fix(ns-wasm-core): fix fromWire Infinity/NaN rejection and loadModule…
listepo Aug 7, 2026
37bb1f1
fix(ci): add ns-wasm-chicory and ns-wasm-edge to test app build list
listepo Aug 7, 2026
347432d
feat(ns-wasm-chicory): add Android native layer with Chicory Java run…
listepo Aug 7, 2026
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
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,21 +172,21 @@ jobs:
changed="$(git diff --name-only "$base...HEAD")" || run_all

echo "$changed"
if grep -qE '^(packages/ns-wasm3/|\.github/workflows/ci\.yml$)' <<<"$changed"; then
if grep -qE '^(packages/ns-wasm3/|packages/ns-wasm-core/|\.github/workflows/ci\.yml$)' <<<"$changed"; then
echo "wasm3=true" >> "$GITHUB_OUTPUT"
else
echo "wasm3=false" >> "$GITHUB_OUTPUT"
fi

if grep -qE '^(packages/ns-wamr/|\.github/workflows/ci\.yml$)' <<<"$changed"; then
if grep -qE '^(packages/ns-wamr/|packages/ns-wasm-core/|\.github/workflows/ci\.yml$)' <<<"$changed"; then
echo "wamr=true" >> "$GITHUB_OUTPUT"
else
echo "wamr=false" >> "$GITHUB_OUTPUT"
fi

# The app's suite runs the plugin end to end, so a plugin or fixture
# change is as relevant to it as a change to the app itself.
if grep -qE '^(apps/ns-wasm-test/|packages/ns-wasm3/|packages/ns-wamr/|packages/ns-wasm-fixture/|\.github/workflows/ci\.yml$)' <<<"$changed"; then
if grep -qE '^(apps/ns-wasm-test/|packages/ns-wasm3/|packages/ns-wamr/|packages/ns-wasm-kit-runtime/|packages/ns-endive/|packages/ns-wasm-chicory/|packages/ns-wasm-edge/|packages/ns-wasm-core/|packages/ns-wasm-fixture/|\.github/workflows/ci\.yml$)' <<<"$changed"; then
echo "app=true" >> "$GITHUB_OUTPUT"
else
echo "app=false" >> "$GITHUB_OUTPUT"
Expand Down Expand Up @@ -459,7 +459,7 @@ jobs:
# The app snapshots local file: dependencies when pnpm installs them, so
# every package whose entry point lives in dist/ must be built first.
- name: Build the app's local packages
run: pnpm exec nx run-many -t build -p ns-wasm3 ns-wamr vitest-ns vitest-ns-ui
run: pnpm exec nx run-many -t build -p ns-wasm-core ns-wasm3 ns-wamr ns-wasm-kit-runtime ns-endive ns-wasm-chicory ns-wasm-edge vitest-ns vitest-ns-ui

- name: Install the test app's dependencies
working-directory: apps/ns-wasm-test
Expand Down Expand Up @@ -497,7 +497,7 @@ jobs:
# Keep this before the app install: pnpm snapshots local file: packages,
# including their generated dist/ entry points, into app node_modules.
- name: Build the app's local packages
run: pnpm exec nx run-many -t build -p ns-wasm3 ns-wamr vitest-ns vitest-ns-ui
run: pnpm exec nx run-many -t build -p ns-wasm-core ns-wasm3 ns-wamr ns-wasm-kit-runtime ns-endive ns-wasm-chicory ns-wasm-edge vitest-ns vitest-ns-ui

- name: Install the test app's dependencies
working-directory: apps/ns-wasm-test
Expand Down
12 changes: 12 additions & 0 deletions .oxfmtrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"ignorePatterns": [
"**/node_modules/**",
"**/dist/**",
"**/.buck-out/**",
"**/target/**",
"**/.build/**",
"**/platforms/**",
"**/src/vendors/**",
"**/test-output/**"
]
}
31 changes: 31 additions & 0 deletions .oxlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"$schema": "https://raw.githubusercontent.com/oxc-project/oxc/main/crates/oxc_linter/src/schema.json",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail
test -f node_modules/oxlint/configuration_schema.json

Repository: listepo/cross-code

Length of output: 156


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- tracked configuration and manifests ---'
git ls-files | rg '(^|/)(\.oxlintrc\.json|package\.json|pnpm-lock\.yaml|yarn\.lock|package-lock\.json|bun\.lockb?|oxlint)' || true

printf '%s\n' '--- .oxlintrc.json ---'
cat -n .oxlintrc.json

printf '%s\n' '--- dependency declarations ---'
for f in package.json pnpm-lock.yaml yarn.lock package-lock.json bun.lock bun.lockb; do
  if test -f "$f"; then
    printf '\n--- %s ---\n' "$f"
    rg -n -C 3 'oxlint|configuration_schema|oxc-project/oxc' "$f" || true
  fi
done

printf '%s\n' '--- configured URL headers ---'
curl -L -sS -o /tmp/oxlint-schema.json -w 'HTTP %{http_code}\n' \
  'https://raw.githubusercontent.com/oxc-project/oxc/main/crates/oxc_linter/src/schema.json'
if test -s /tmp/oxlint-schema.json; then
  head -c 300 /tmp/oxlint-schema.json
  printf '\n'
fi

Repository: listepo/cross-code

Length of output: 2156


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- locked oxlint entries ---'
rg -n -i -C 5 'oxlint|configuration_schema|oxc_linter' pnpm-lock.yaml package.json

printf '%s\n' '--- npm package metadata ---'
curl -sS -L 'https://registry.npmjs.org/oxlint' |
  node -e '
    let data = "";
    process.stdin.on("data", c => data += c);
    process.stdin.on("end", () => {
      const p = JSON.parse(data);
      for (const version of ["0.15.0", p["dist-tags"]?.latest]) {
        if (p.versions?.[version]) {
          console.log(JSON.stringify({
            version,
            dist: p.versions[version].dist,
            files: p.versions[version].files
          }, null, 2));
        }
      }
    });
  '

printf '%s\n' '--- package tarball file list ---'
tmpdir="$(mktemp -d)"
trap 'rm -rf "$tmpdir"' EXIT
curl -sS -L 'https://registry.npmjs.org/oxlint/-/oxlint-0.15.0.tgz' -o "$tmpdir/oxlint.tgz"
tar -tzf "$tmpdir/oxlint.tgz" | rg -i 'schema|config|package.json'

Repository: listepo/cross-code

Length of output: 2486


Use the schema shipped with oxlint.

The current URL returns HTTP 404. oxlint@0.15.0 includes configuration_schema.json; set $schema to ./node_modules/oxlint/configuration_schema.json.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.oxlintrc.json at line 2, Update the $schema value in .oxlintrc.json to
reference the local ./node_modules/oxlint/configuration_schema.json file shipped
with oxlint, replacing the invalid remote URL.

"plugins": ["typescript", "import", "unicorn"],
"rules": {
"no-unused-vars": "error",
"no-console": "warn",
"typescript/no-non-null-assertion": "warn",
"import/no-default-export": "off"
},
"env": {
"node": true,
"es2022": true
},
"globals": {
"globalThis": "readonly",
"NSData": "readonly",
"NSMutableArray": "readonly"
},
"settings": {},
"ignorePatterns": [
"**/node_modules/**",
"**/dist/**",
"**/.buck-out/**",
"**/target/**",
"**/.build/**",
"**/platforms/**",
"**/src/vendors/**",
"**/test-output/**",
"**/*.d.ts"
]
}
33 changes: 25 additions & 8 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,23 @@

## NativeScript plugins in this repo

Three sibling plugins live under `packages/`, all sharing the same
architecture: Rust cargo workspace, UniFFI (uniffi-rs) Kotlin/Swift bindings,
and a TypeScript adapter. The two WASM plugins are mirror images of each
other (same class shapes, same wire protocol, same error mapping). Everything
the plugins share is documented in [Shared plugin architecture](#shared-plugin-architecture)
below; each package's AGENTS.md holds only engine-specific detail.

Several sibling plugins live under `packages/`, all sharing the same
TypeScript API (wire protocol, error mapping, and `WasmRuntime` / `WasmModule` /
`WasmFunction` class shapes). The Rust cargo workspace and UniFFI (uniffi-rs)
Kotlin/Swift bindings — together with the mirror-image native architecture
described in [Shared plugin architecture](#shared-plugin-architecture) — apply
to **ns-wasm3 and ns-wamr**. The newer runtimes (`ns-wasm-kit-runtime`, the
Swift-native WasmKit interpreter; `ns-endive`, the Java-native Endive
interpreter) share the same TypeScript adapter pattern, wire protocol, and
`@cross-code/ns-wasm-core` foundation, but have their own per-engine native
layers. Only engine-specific detail lives in each package's AGENTS.md.

- **`ns-wasm-core`** (`@cross-code/ns-wasm-core`) — shared foundation package
providing the wire protocol (`parseSignature`, `toWire`, `fromWire`,
`WasmError`), the native adapter interfaces (`NativeRuntimeAdapter`,
`NativeModuleAdapter`, `NativeFunctionAdapter`), and the generic
`WasmRuntime`/`WasmModule`/`WasmFunction` base classes that every WASM
runtime plugin extends.
- **`ns-wasm3`** (`@cross-code/ns-wasm3`) — mature plugin binding
the wasm3 interpreter (Swift Package on iOS, Kotlin + Rust JNI (cargo-ndk) on Android).
See `packages/ns-wasm3/AGENTS.md`.
Expand All @@ -53,6 +63,11 @@ below; each package's AGENTS.md holds only engine-specific detail.
builds enable only the interpreter (see [Key differences](#key-differences-wasm3-vs-wamr)).
WAMR-2.3.0 sources are vendored at `packages/ns-wamr/src/vendors/wamr/`.
See `packages/ns-wamr/AGENTS.md`.
- **`ns-wasm-kit-runtime`** (`@cross-code/ns-wasm-kit-runtime`) — plugin wrapping
the [WasmKit](https://github.com/swiftwasm/WasmKit) Swift interpreter.
iOS-only at this time (WasmKit is Swift-native and served through SwiftPM);
Android throws a clear unsupported error. Follows the same TypeScript
adapter pattern as the other two plugins.
- **`ns-wry`** (`@cross-code/ns-wry`) — general-purpose NativeScript plugin
scaffold built on Rust + UniFFI (uniffi-rs) with cargo-ndk Android pipeline.
See `packages/ns-wry/AGENTS.md` for the bare-metal architecture; extend the
Expand Down Expand Up @@ -80,7 +95,7 @@ until sources are present.

## Shared plugin architecture

Both plugins follow the same architecture: a platform-agnostic wire protocol
The WASM runtime plugins follow the same architecture: a platform-agnostic wire protocol
(`src/lib/wire.ts`), per-platform TypeScript adapter files, Swift `@objc`
classes on iOS, Kotlin + Rust JNI on Android, and Nx targets declared via
`package.json`. Substitute `<Engine>` = `Wasm3`-family
Expand Down Expand Up @@ -542,8 +557,10 @@ wasm-pack-generated `.d.ts`. See `packages/ns-wasm-fixture/README.md`.

| Path | Contents |
| --------------------------------------- | ----------------------------------------------------------------------- |
| `packages/ns-wasm-core/AGENTS.md` | (none — shared foundation; see Shared plugin architecture above) |
| `packages/ns-wasm3/AGENTS.md` | wasm3-specific: stack ABI, globals, fixtures, build/test |
| `packages/ns-wamr/AGENTS.md` | WAMR-specific: two-phase load, exec env, WASI, tiers, trampolines, shim |
| `packages/ns-wasm-kit-runtime/AGENTS.md` | WasmKit-specific: iOS-only Swift interpreter, Android unsupported stub |
| `packages/ns-wry/AGENTS.md` | wry scaffold: Rust + UniFFI architecture, platform stubs, extension guide |
| `apps/ns-wasm-test/AGENTS.md` | test app: layout, design decisions, running the suites, adding specs |
| `apps/ns-wry-app` | test app: WebView demo, build-plugin-and-run workflow |
Expand Down
58 changes: 49 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
# cross-code

An Nx monorepo for running WebAssembly on [NativeScript](https://nativescript.org) —
three sibling plugins built on Rust + UniFFI:
three WASM runtime plugins built on a shared TypeScript foundation (wire protocol,
adapter interfaces, base Runtime/Module/Function classes):

- [`wasm3`](https://github.com/wasm3/wasm3) — lightweight interpreter (v0.5.2)
- [WAMR](https://github.com/bytecodealliance/wasm-micro-runtime) — WebAssembly
Micro Runtime (2.3.0): interpreter, Fast JIT, LLVM JIT, AOT, WASI
- [`ns-wry`](packages/ns-wry) — Rust + [UniFFI](https://github.com/mozilla/uniffi-rs)
(uniffi-rs) auto-generated Kotlin/Swift bindings, cargo-ndk Android pipeline
- [WasmKit](https://github.com/swiftwasm/WasmKit) — Swift-based WebAssembly
runtime with WASI support, iOS-native through SwiftPM

Also in the monorepo: [`ns-wry`](packages/ns-wry) — a general-purpose NativeScript
plugin scaffold built on Rust + [UniFFI](https://github.com/mozilla/uniffi-rs)
(uniffi-rs) auto-generated Kotlin/Swift bindings and cargo-ndk Android pipeline.

> **Project status: Active development.** APIs and project layout may change without notice; expect breaking changes between releases.

## Packages

| Package | Description |
| ----------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| [`@cross-code/ns-wasm-core`](packages/ns-wasm-core) | Shared foundation — wire protocol, `WasmError`, adapter interfaces, base `WasmRuntime`/`WasmModule`/`WasmFunction` classes |
| [`@cross-code/ns-wasm3`](packages/ns-wasm3) | NativeScript plugin — Swift Package on iOS, Kotlin + Rust JNI (cargo-ndk) on Android (wasm3 interpreter) |
| [`@cross-code/ns-wamr`](packages/ns-wamr) | NativeScript plugin — Swift Package on iOS, Kotlin + Rust JNI (cargo-ndk) on Android (WAMR: interpreter, Fast JIT, LLVM JIT, AOT, WASI) |
| [`@cross-code/ns-wasm-kit-runtime`](packages/ns-wasm-kit-runtime) | NativeScript plugin — Swift Package on iOS (WasmKit interpreter); Android throws a clear unsupported error |
| [`@cross-code/ns-wasm-fixture`](packages/ns-wasm-fixture) | Rust/wasm-pack test fixtures (committed `.wasm` binaries) |
| [`@cross-code/vitest-ns`](packages/vitest-ns) | Vitest custom pool and NativeScript Worker runtime for on-device unit tests |
| [`@cross-code/vitest-ns-ui`](packages/vitest-ns-ui) | Optional NativeScript Core results page for device-side Vitest progress |
Expand All @@ -25,7 +32,10 @@ three sibling plugins built on Rust + UniFFI:
| [`ns-wasm-test`](apps/ns-wasm-test) | NativeScript test app — runs the plugins on a simulator/emulator from a demo page and through Vitest + `vitest-ns` |
| [`ns-wry-app`](apps/ns-wry-app) | NativeScript test app for @cross-code/ns-wry — WebView demo with google.com on iOS/Android |

Both plugins expose the same TypeScript API — see [WASM.md](WASM.md).
The WASM runtime plugins expose the same TypeScript API — see [WASM.md](WASM.md). All runtime
plugins (wasm3, WAMR, WasmKit) share the same foundation (`@cross-code/ns-wasm-core`)
which provides the wire protocol, error classes, adapter interfaces and generic
`WasmRuntime`/`WasmModule`/`WasmFunction` classes.
Each package README covers its own layout, development workflow and troubleshooting
(see [Per-package documentation](#per-package-documentation)).

Expand Down Expand Up @@ -141,24 +151,54 @@ curl -fsSL https://github.com/facebook/buck2/releases/latest/download/buck2-aarc

or `mise plugin install buck2 https://github.com/izaakschroeder/asdf-buck2`.

## WebAssembly plugins (wasm3 & WAMR)
## WebAssembly plugins (wasm3, WAMR & WasmKit)

Usage and API documentation for the two WebAssembly plugins — install,
Usage and API documentation for the WebAssembly plugins — install,
quick start, calling exports, linear memory, globals, host imports, value
marshalling, error messages, the complete API reference, and shared
troubleshooting — lives in **[WASM.md](WASM.md)**.

Both plugins expose the same TypeScript API; only the class names differ
All three plugins expose the same TypeScript API; only the class names differ
(`Wasm3Runtime` / `Wasm3Module` / `Wasm3Function` vs
`WamrRuntime` / `WamrModule` / `WamrFunction`).
`WamrRuntime` / `WamrModule` / `WamrFunction` vs
`WasmKitRuntime` / `WasmKitModule` / `WasmKitFunction`).
WasmKit is iOS-only (Swift-based runtime); Android throws a clear "not supported" error.

## Linting

### Kotlin (Android wrappers)

```bash
# Detekt (static analysis) + Ktlint (formatting) — hand-written sources only
pnpm exec nx run ns-wasm3:lint.android
pnpm exec nx run ns-wasm3:lint.android --configuration=format # auto-fix

# Config: detekt.yml + .editorconfig at the repo root (shared by both engines)
```

### Swift (iOS wrappers)

```bash
# SwiftLint — hand-written sources only
pnpm exec nx run ns-wasm3:lint.ios
pnpm exec nx run ns-wamr:lint.ios

# Periphery — unused-code detection (builds the SwiftPM package)
pnpm exec nx run ns-wasm3:periphery.ios
pnpm exec nx run ns-wamr:periphery.ios

# Config: .swiftlint.yml + .periphery.yml at the repo root (shared by all engines)
```

## Per-package documentation

| Package | Docs |
| --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| WebAssembly plugins (wasm3 & WAMR) | [WASM.md](WASM.md) — shared usage, API reference, marshalling, errors, troubleshooting |
| WebAssembly plugins (wasm3, WAMR & WasmKit) | [WASM.md](WASM.md) — shared usage, API reference, marshalling, errors, troubleshooting |
| `@cross-code/ns-wasm-core` | [AGENTS.md](AGENTS.md#shared-plugin-architecture) — wire protocol, WasmError, adapter interfaces, base classes |
| `@cross-code/ns-wasm3` | [README](packages/ns-wasm3/README.md) — platform details, package layout, developing, troubleshooting, license |
| `@cross-code/ns-wamr` | [README](packages/ns-wamr/README.md) — execution tiers, package layout, developing, troubleshooting, license |
| `@cross-code/ns-wasm-kit-runtime` | [README](packages/ns-wasm-kit-runtime/README.md) — WasmKit Swift interpreter, iOS-only adapter, developing, troubleshooting |
| `@cross-code/ns-wasm-fixture` | [README](packages/ns-wasm-fixture/README.md) — exported subpaths, rebuilding the `.wasm` fixtures |
| `@cross-code/vitest-ns` | [README](packages/vitest-ns/README.md) — custom pool, Worker registry, concurrency, and transport |
| `@cross-code/vitest-ns-ui` | [README](packages/vitest-ns-ui/README.md) — optional NativeScript results UI |
Expand Down
11 changes: 11 additions & 0 deletions apps/ns-wasm-test/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ app/
vitest-ns.worker.ts Worker registry
tests/wasm3/ wasm3 Vitest specs
tests/wamr/ WAMR Vitest specs
tests/wasmkit/ WasmKit specs (iOS-only engine)
tests/endive/ Endive specs (Android-only engine)
tests/chicory/ Chicory specs (Android-only engine)
tests/wasmedge/ WasmEdge specs
tests/runtime-support.ts per-engine platform matrix + suite gating
wasm/fixture-suite.ts shared correctness checks
wasm/wasm-assets.ts bundled fixture paths/byte reader
vitest.ios.config.mts iOS simulator host config
Expand All @@ -54,6 +59,12 @@ tsconfig.spec.json specs and test-only entries
thread-safe. A worker is long-lived and files assigned to it share module and
global state.
- Dispose every `Wasm3Runtime`/`WamrRuntime` in `afterEach` or `finally`.
- A suite for a single-platform or not-yet-native engine goes through
`describeRuntime()` in `tests/runtime-support.ts`, never a bare
`describe.skip`. The matrix there is the one place recording which engines
target which platforms and which still lack a native layer. wasm3 and WAMR
ship natives on both platforms and must keep calling `describe` directly, so
a runtime that fails to load still fails the run rather than skipping.
- `fixture-suite.ts` is the canonical shared marshalling specification. Add
cross-plugin checks there; keep plugin-specific error/tier cases in specs.
- The fixture suite must remain structurally typed and must not import either
Expand Down
41 changes: 39 additions & 2 deletions apps/ns-wasm-test/app/main-view-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { Observable } from '@nativescript/core';
import { WamrExecutionTier, WamrRuntime } from '@cross-code/ns-wamr';
import { Wasm3Runtime } from '@cross-code/ns-wasm3';
import { WasmKitRuntime } from '@cross-code/ns-wasm-kit-runtime';
import { EndiveRuntime } from '@cross-code/ns-endive';
import { WasmEdgeRuntime } from '@cross-code/ns-wasm-edge';
import { ChicoryRuntime } from '@cross-code/ns-wasm-chicory';

import {
createHostImports,
Expand Down Expand Up @@ -59,13 +62,23 @@ export class WasmDemoModel extends Observable {
}

onRun() {
const sections = [runWasm3(), runWamr(), runWasmKit()];
const sections = [runWasm3(), runWamr(), runWasmEdge()];
// WasmKit is Swift-native — only include it on iOS.
if ((globalThis as any).isIOS) {
sections.push(runWasmKit());
}
// Endive is Java-native — only include it on Android.
if ((globalThis as any).isAndroid) {
sections.push(runEndive());
// Chicory is also pure-Java, Android-only.
sections.push(runChicory());
}
const checks = sections.flatMap((s) => s.checks);
const summary = summarize(checks);

this.status =
summary.failed === 0
? `${summary.passed}/${summary.total} checks passed on both runtimes`
? `${summary.passed}/${summary.total} checks passed on all runtimes`
: `${summary.failed} of ${summary.total} checks FAILED`;
this.report = sections
.map((s) => [s.title, ...s.checks.map(formatCheck)].join('\n'))
Expand Down Expand Up @@ -148,6 +161,14 @@ function runWasm3(): Section {
);
}

function runWasmEdge(): Section {
return runSection(
'WasmEdge',
() => WasmEdgeRuntime.version(),
() => new WasmEdgeRuntime(),
);
}

function runWasmKit(): Section {
return runSection(
'WasmKit',
Expand All @@ -156,6 +177,22 @@ function runWasmKit(): Section {
);
}

function runEndive(): Section {
return runSection(
'Endive',
() => EndiveRuntime.version(),
() => new EndiveRuntime(),
);
}

function runChicory(): Section {
return runSection(
'Chicory',
() => ChicoryRuntime.version(),
() => new ChicoryRuntime(),
);
}

function runWamr(): Section {
return runSection(
`WAMR (${WamrExecutionTier[WamrExecutionTier.Interpreter]})`,
Expand Down
Loading
Loading