@steerprotocol/app-loader
v3.0.6
Published
App Loader for Steer Protocol
Readme
Steer Protocol App Loader
Load and execute Steer wasm bundles in Node.js and browser environments.
Node 18+ is required.
Install
npm install @steerprotocol/app-loaderRuntime Support
- Root import
@steerprotocol/app-loader- Node: resolves to the Node entrypoint
- Browser bundlers: resolves to the browser entrypoint through the
browserexport condition
- Explicit browser import:
@steerprotocol/app-loader/browser - Explicit Node import:
@steerprotocol/app-loader/node
Usage
Node
Use the root import for typical Node usage.
import { loadWasm } from '@steerprotocol/app-loader';
import type { WasmModule } from '@steerprotocol/app-loader';
const bundle: WasmModule = await loadWasm('/absolute/path/to/bundle.wasm');
bundle.initialize('{"example":true}');Node supports:
- filesystem paths
ArrayBuffer- remote URLs
Node runtime note:
- native
fetchis required - Node 18+ is the supported baseline
If you want an explicit Node-only import:
import { loadWasm } from '@steerprotocol/app-loader/node';
import type { WasmModule } from '@steerprotocol/app-loader/node';
const bundle: WasmModule = await loadWasm('/absolute/path/to/bundle.wasm');Browser
The browser entry supports ArrayBuffer and remote URL loading.
import { loadWasm } from '@steerprotocol/app-loader';
import type { WasmModule } from '@steerprotocol/app-loader';
const response = await fetch('/bundle.wasm');
const bundle: WasmModule = await loadWasm(await response.arrayBuffer());
bundle.initialize('{"example":true}');If you want to pin the browser-specific entrypoint:
import { loadWasm } from '@steerprotocol/app-loader/browser';
import type { WasmModule } from '@steerprotocol/app-loader/browser';
const response = await fetch('/bundle.wasm');
const bundle: WasmModule = await loadWasm(await response.arrayBuffer());Browser ccxt
In browsers, ccxt is expected on globalThis.ccxt.
If you load ccxt from a CDN or hosted bundle, make sure it is available before executing wasm that depends on it.
<script src="https://unpkg.com/[email protected]/dist/ccxt.browser.min.js"></script>The hosted browser build is covered by the default test suite with a live network smoke test against the same unpkg URL.
Node ccxt
In Node, ccxt is loaded from the installed module automatically.
API
Main exports:
loadWasm(input, imports?)loadWasmSync(input, imports?)WasmModule(type-only export)CandleRawTradeData
WasmModule is a type-only export. Strict TypeScript consumers, including projects using
moduleResolution: "NodeNext", module: "NodeNext", and verbatimModuleSyntax: true, must import it with
import type:
import { loadWasm } from '@steerprotocol/app-loader';
import type { WasmModule } from '@steerprotocol/app-loader';The same rule applies to @steerprotocol/app-loader/node and @steerprotocol/app-loader/browser.
The non-type-only form is not the supported pattern for strict TS consumers:
import { WasmModule, loadWasm } from '@steerprotocol/app-loader';The returned wasm wrapper exposes the module surface when available, including:
initialize(config)execute(...args)config()transform()reset()
Development
Build
npm run buildUnit And Integration Tests
npm testAn env-gated live repro for the deprecated Sushi Polygon v2 connector is enabled when
STEER_SUBGRAPH_STUDIO_KEY is set (or STEER_SUBGRAPH_GATEWAY_KEY for local debugging). This connector is kept as historical evidence of a
known-broken path and is not part of the supported execution contract.
Packed Consumer Checks
These checks validate the packed artifact in consumer fixtures for:
- Node ESM
- Node CJS
- Strict TypeScript NodeNext consumers
- Vite browser bundler builds
- Next.js browser bundler builds
npm run test:consumersThis command builds the package, packs it, installs the tarball into fixture apps, validates the packed export artifacts, and runs each fixture check.
Migration Notes
Version 2 changes the package runtime contract.
- Browser consumers should rely on the root import only when their bundler honors the
browserexport condition. - Browser
ccxtintegration now expects the hosted browser build onglobalThis.ccxt. - Node consumers should use the root import or
@steerprotocol/app-loader/node. - Browser consumers can use
@steerprotocol/app-loader/browserto pin the browser-safe entrypoint explicitly.
