celox-napi
Rust adapter API and N-API/WASI handles for Celox. This crate is useful to frontend authors that ship their own native addon and want to expose a frontend-specific constructor without serializing a Celox artifact as JSON.
The frontend addon accepts its own artifact type, lowers it with
celox-frontend-sdk, and returns the standard handle:
use FrontendArtifact;
use NativeSimulatorHandle;
use Result;
use napi;
The frontend's TypeScript package can expose the API its users expect:
import { Simulator, type FrontendSimulatorHandle } from "@celox-sim/celox";
import { fromMyArtifact as nativeFromMyArtifact } from "./native.js";
export function fromMyArtifact<P>(artifact: MyArtifact): Simulator<P> {
const handle: FrontendSimulatorHandle = nativeFromMyArtifact(artifact);
return Simulator.fromFrontendHandle<P>(handle);
}
MyArtifact remains the frontend's public model. Its conversion happens inside
Rust, directly into FrontendArtifact; the frontend artifact is not transported
as JSON.
See examples/my-frontend-napi in the Celox repository for a buildable addon.