Skip to content

Commit 88cd33b

Browse files
committed
feat: add binary type support for host functions
Adds Uint8Array/Buffer support for host function arguments and returns. Architecture: - New hyperlight-js-common crate: shared wire-format constants, binary sidecar encode/decode, FnReturn enum, DecodeError type - Guest extracts Uint8Array from QuickJS VM into binary sidecar - Host dispatches via register() (typed serde) or register_js() (JS bridge) - NAPI layer creates native Node.js Buffers via C API (no base64) - Tagged return format (0x00=JSON, 0x01=binary) for return path Key changes: - Single CallHostJsFunction entry point (removed legacy JSON-only path) - Native Buffer marshalling in NAPI (JsArg/JsReturn types) - Depth limits on all recursive JSON tree traversals (MAX_JSON_DEPTH=64) - Trailing data rejection in sidecar decoder - Typed register() rejects binary args with clear error message - Comprehensive test coverage (Rust unit + integration + JS vitest) - Updated README with Binary Data section and wire protocol docs - Updated CI publish order for new common crate Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com>
1 parent c6eb181 commit 88cd33b

20 files changed

Lines changed: 1610 additions & 160 deletions

File tree

.github/workflows/CreateRelease.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ jobs:
5656
5757
- name: Publish hyperlight-js
5858
run: |
59+
cargo publish -p hyperlight-js-common
5960
cargo publish -p hyperlight-js-runtime
6061
cargo publish -p hyperlight-js
6162
env:

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[workspace]
22
resolver = "2"
3-
members = ["src/hyperlight-js", "src/js-host-api", "src/hyperlight-js-runtime"]
3+
members = ["src/hyperlight-js", "src/js-host-api", "src/hyperlight-js-runtime", "src/hyperlight-js-common"]
44

55
[workspace.package]
66
version = "0.1.1"
@@ -16,6 +16,7 @@ hyperlight-guest-bin = { git = "https://github.com/hyperlight-dev/hyperlight", r
1616
hyperlight-guest = { git = "https://github.com/hyperlight-dev/hyperlight", rev = "620339aa95d508e8cbd1d38b4374f09090aade7b" }
1717
hyperlight-host = { git = "https://github.com/hyperlight-dev/hyperlight", rev = "620339aa95d508e8cbd1d38b4374f09090aade7b", default-features = false, features = ["executable_heap", "init-paging"] }
1818
hyperlight-js = { version = "0.1.1", path = "src/hyperlight-js" }
19+
hyperlight-js-common = { version = "0.1.1", path = "src/hyperlight-js-common" }
1920
hyperlight-js-runtime = { version = "0.1.1", path = "src/hyperlight-js-runtime" }
2021

2122
[profile.dev]

docs/release.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ When this job is done, a new [GitHub release](https://github.com/hyperlight-dev/
5151

5252
This release contains the benchmark results and the source code for the release along with automatically generated release notes.
5353

54-
In addition the hyperlight-js crates will be published to crates.io. You can verify this by going to the [hyperlight-js page on crates.io](https://crates.io/crates/hyperlight-js) and checking that the new version is listed.
54+
In addition the hyperlight-js crates will be published to crates.io in dependency order (`hyperlight-js-common``hyperlight-js-runtime``hyperlight-js`). You can verify this by going to the [hyperlight-js page on crates.io](https://crates.io/crates/hyperlight-js) and checking that the new version is listed.
5555

5656
## Patching a release
5757

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[package]
2+
name = "hyperlight-js-common"
3+
version.workspace = true
4+
edition.workspace = true
5+
rust-version.workspace = true
6+
license.workspace = true
7+
repository.workspace = true
8+
readme.workspace = true
9+
description = """
10+
Shared constants and binary framing utilities for hyperlight-js.
11+
12+
This crate is `no_std`-compatible (with `alloc`) so it can be used by both
13+
the host-side `hyperlight-js` crate and the guest-side `hyperlight-js-runtime`
14+
crate (which compiles for `x86_64-hyperlight-none`).
15+
"""
16+
17+
[dependencies]
18+
# no_std + alloc only — no std, no serde, no anyhow

0 commit comments

Comments
 (0)