@brink-lang/web
v0.16.0
Published
The brink ink-language compiler, IDE session, and story runtime for the web (WebAssembly): compile .ink source, drive stories, and power editor tooling from JavaScript/TypeScript.
Maintainers
Readme
@brink-lang/web
The brink ink-language compiler, IDE session, and story runtime, compiled to WebAssembly with ergonomic TypeScript wrappers.
compile(source)— compile.inksource to a runnable story binaryStoryRunnerHandle— drive a compiled story (continue, choices, variables, save/load, external functions, engine→ink calls)EditorSessionHandle— incremental multi-file IDE session (diagnostics, completions, hover, rename, semantic tokens, outline, story graph, …)
All boundary types (CompileResult, Line, Choice, HostManifest, …)
ship with the package — no extra @types install.
Install
npm install @brink-lang/webUsage
Initialize the wasm module once, then use anything:
import { initWasm, compile, StoryRunnerHandle } from "@brink-lang/web";
await initWasm();
const result = compile(`Hello, world!\n-> END\n`);
if (!result.ok) throw new Error(result.error);
const story = new StoryRunnerHandle(new Uint8Array(result.story_bytes!));
for (;;) {
const line = story.continueSingle();
if (line.type === "text") { console.log(line.text); continue; }
if (line.type === "choices") { story.choose(0); continue; }
break; // done | end
}Bundlers (Vite, Rollup, webpack 5)
The package locates its .wasm binary with
new URL("brink_web_bg.wasm", import.meta.url), which modern bundlers
resolve and emit as an asset automatically — no plugin needed.
With Vite, exclude the package from dependency pre-bundling so the relative wasm URL survives the dev server's optimizer:
// vite.config.ts
export default defineConfig({
optimizeDeps: { exclude: ["@brink-lang/web"] },
});(Production vite build works either way; the exclude is for vite dev.)
No bundler / custom hosting
Pass the binary's location (URL, path string, or precompiled
WebAssembly.Module) to initWasm:
await initWasm(new URL("/assets/brink_web_bg.wasm", location.origin));Related
@brink-lang/studio— the embeddable brink studio IDE (mountStudio), built on this package.
License
MIT
