Skip to content

createBrowserCapabilities

createBrowserCapabilities(baseUrl?): PlatformCapabilities

Defined in: packages/runtime/src/platform/browser-caps.ts:67

Build PlatformCapabilities for the browser host.

string

Base URL for resolving relative loadAsset paths. Defaults to globalThis.location.href when available, otherwise empty (which means only absolute URLs work).

PlatformCapabilities

A PlatformCapabilities bound to the current browser window / worker globals.

Wires capabilities to the browser’s built-ins — fetch for both loadAsset (binary body via arrayBuffer()) and fetch, Blob + URL.createObjectURL for ESM evaluation (dynamic import(blobUrl)), and WebAssembly.compile for WASM. The module avoids requiring the DOM lib in tsconfig by casting through a structural BrowserGlobals shape, which keeps this file importable from a Node test runner without complaining about missing window.

importEsm rewrites import.meta.url to "" — in a blob-URL context the real value is the blob URL itself, which is meaningless to Emscripten glue. In the browser ENVIRONMENT_IS_NODE is false so createRequire never runs, so an empty string is safe.

Consumed by browserRuntime; prefer that factory for boot flows.

import { createBrowserCapabilities, createRuntime } from '@fishnet/runtime'
const runtime = createRuntime(createBrowserCapabilities())