API Overview

This is an overview of the different APIs for communicating between JavaScript and Rust.

The Zaplib package on npm has two entrypoints:

  1. zaplib_runtime.development.js: the main runtime, to be used on the browser's main thread.
  2. zaplib_worker_runtime.development.js: the Web Worker runtime, for use in your workers.

In production, similarly use: zaplib_runtime.production.js and zaplib_worker_runtime.production.js.

Note: Zaplib performs some global setup upon import, notably modifying TypedArray implementations. We advise importing Zaplib first before other dependencies, so that all of your application code uses these modified values.

Here is an overview of all the JS APIs, and their support with the WebAssembly runtime and the experimental Zapium runtime. Missing features are annotated with their ticket id.

APIBrowser main threadBrowser Web WorkerZapium main threadZapium Web Worker
zaplib.initializen/an/a
zaplib.initializeWorkern/an/a#69
zaplib.isInitialized#69
zaplib.registerCallJsCallbacks#70#69 #70
zaplib.unregisterCallJsCallbacks#70#69 #70
zaplib.callRustSync#69
zaplib.callRustAsync#69
zaplib.createReadOnlyBuffer#69
zaplib.createMutableBuffer#69
zaplib.newWorkerPort#69#69
zaplib.serializeZapArrayForPostMessage#69#69
zaplib.deserializeZapArrayFromPostMessage#69#69
zaplib.jsRuntime#69#69
zaplib.isZapBuffer