API Reference
TypeDoc-generated reference for @browser-ports/v8-wasm, V8 C++ mirror bindings, GuestRealm membrane, and compatibility subpaths
@browser-ports/v8-wasm exposes V8's C++ public API directly to TypeScript over V8-wasm, alongside high-level realm isolation primitives (GuestRealm, Membrane), Chrome DevTools Protocol (InspectorBridge), and four drop-in compatibility subpaths.
The generated TypeScript binding surface covers 230 V8 C++ classes, 93 enums, 1,033 bound methods, and 1,142 Wasm exports (76.2% of the upstream V8 public header surface), documented directly from upstream V8 C++ headers via TypeDoc.
Package Entry Points
| Import Path | Reference | Exports | Purpose |
|---|---|---|---|
@browser-ports/v8-wasm | Core Runtime & Realms | 19 classes, 33 functions, 9 interfaces, v8 namespace | Initialization, platforms, isolates, RAII scopes, GuestRealm, Membrane, InspectorBridge |
@browser-ports/v8-wasm (V8 Mirror) | Primitives & Values · Objects & Buffers · Scripts & Wasm · Isolates & Platform · Templates · Inspector & Profiler · Enums | 230 classes, 93 enums, 1,033 methods | Full generated V8 C++ public API mirror |
@browser-ports/v8-wasm/shadowrealm-polyfill | ShadowRealm | 3 exports | TC39 ShadowRealm backed by a real V8-wasm Isolate and Context |
@browser-ports/v8-wasm/ses | SES / Hardened JS | 5 exports | Compartment, harden, and lockdown with disjoint V8 realms |
@browser-ports/v8-wasm/jsc | JavaScriptCore C-API | 41 exports | Drop-in JSC C-API (JSGlobalContext*, JSEvaluateScript, JSValue*, JSObject*) |
@browser-ports/v8-wasm/realm-sandbox | Realm Sandbox | 4 exports | Page-level guest <script> and eval sandbox |
V8 C++ Mirror Reference Groups
| Section | Classes / Enums | Bound Methods | Upstream V8 Headers |
|---|---|---|---|
| V8 Primitives, Values & Exceptions | 38 classes | 246 | v8-data.h, v8-value.h, v8-primitive.h, v8-primitive-object.h, v8-date.h, v8-regexp.h, v8-external.h, v8-exception.h, v8-message.h |
| V8 Objects, Containers & Buffers | 38 classes | 238 | v8-object.h, v8-function.h, v8-container.h, v8-promise.h, v8-proxy.h, v8-json.h, v8-array-buffer.h, v8-typed-array.h, v8-value-serializer.h |
| V8 Scripts, Modules & Wasm | 30 classes | 82 | v8-script.h, v8-wasm.h, v8-extension.h, v8-source-location.h |
| V8 Isolates, Contexts & Platform | 44 classes | 191 | v8-initialization.h, v8-isolate.h, v8-context.h, v8-microtask-queue.h, v8-platform.h, v8-snapshot.h |
| V8 Templates & Callbacks | 13 classes | 34 | v8-template.h, v8-callbacks.h |
| V8 Inspector, Profiler & Metrics | 71 classes | 242 | v8-inspector.h, v8-debug.h, v8-profiler.h, v8-metrics.h, v8-statistics.h |
| V8 Enumerations | 93 enums | — | All public V8 and v8_inspector enums |
Initialization & Lifecycle Quickstart
Call initV8 once with the modularized Emscripten factory (or a pre-instantiated V8WasmExports object) before initializing V8, creating platforms, or allocating isolates and realms.
import {
initV8,
v8,
createSingleThreadedDefaultPlatform,
deletePlatform,
createIsolate,
createContext,
IsolateScope,
HandleScope,
ContextScope,
TryCatch,
stringFromUtf8Checked,
stringToUtf8,
getTryCatchException,
notifyIsolateShutdown,
} from '@browser-ports/v8-wasm';
import createV8Module from './v8_wasm_api.mjs';
await initV8({
module: createV8Module,
emscriptenOptions: { locateFile: (path: string) => `/wasm/${path}` },
});
const platform = createSingleThreadedDefaultPlatform();
v8.V8.initializePlatform(platform);
v8.V8.initialize();
using managed = createIsolate();
const { isolate } = managed;
using isoScope = new IsolateScope(isolate);
HandleScope.run(isolate, () => {
const ctx = createContext(isolate);
using ctxScope = new ContextScope(ctx);
using tc = new TryCatch(isolate);
const src = stringFromUtf8Checked(isolate, '20 + 22');
const script = v8.Script.compile(ctx, src).toLocalChecked();
const res = script.run(ctx);
if (res.isEmpty() && tc.hasCaught()) {
throw new Error(stringToUtf8(isolate, getTryCatchException(tc).toString(ctx).toLocalChecked()));
}
console.log(res.toLocalChecked().numberValue(ctx).fromJust()); // 42
});
notifyIsolateShutdown(platform, isolate);
deletePlatform(platform);The v8 Namespace
To prevent collisions with JavaScript built-in globals, generated classes whose names collide with JS globals are exported at top level with a V8 prefix (V8Object, V8String, V8Function, V8Array, V8Number, V8Boolean, V8Symbol, V8BigInt, V8Date, V8RegExp, V8Map, V8Set, V8Promise, V8Proxy, V8ArrayBuffer, V8SharedArrayBuffer, V8DataView, V8JSON) and exposed under their exact upstream C++ names on the v8 namespace object (v8.Object, v8.String, v8.Function, v8.Script, v8.Isolate, etc.).