Skip to main content

Crate bynk_wasm

Crate bynk_wasm 

Source
Expand description

The Bynk compiler as a wasm module for the in-browser REPL/playground (the in-browser track, slice 3 — ADR 0139).

One entry — bynk_compile (wasm) / compile (native) — takes an in-memory Bynk source and returns a runnable JavaScript module graph plus diagnostics, with no filesystem and no tsc:

source ─▶ bynk_emit::compile_in_memory (Bundle / Browser)  ─▶ ProjectOutput (TS)
       ─▶ bynk_strip::strip_project_to_js                   ─▶ ProjectOutput (JS)
       ─▶ { files: [{ path, contents }], diagnostics }

The pipeline reuses the on-disk path wholesale (first-party injection, the per-platform binding, the strip-only emitter), so the returned graph is the complete set the browser links: the user module, runtime.js, the bynk-browser.js binding, and compose.js. The crate compiles to wasm32 (the cdylib); the same logic is exercised natively (the rlib) by the slice-3 tests, with the browser harness deferred to the REPL shell (slice 4).

Structs§

AnalyzeResult
The diagnostics of a single in-memory source — non-bailing analysis, no emission (the editor’s live, on-type diagnostics — slice 5d).
CompileResult
The outcome of compiling one in-memory source.
Diagnostic
A diagnostic flattened for the JS side, with a 1-indexed line/column.
EmittedFile
One emitted JavaScript module of the compiled program.

Functions§

analyze
Analyse a source for diagnostics only (no compile/emit), for the given platform.
analyze_to_json
Analyse to a JSON string — { diagnostics: [{ from, to, line, col, severity, category, message }] }.
compile
Compile a single in-memory Bynk source to a JavaScript module graph for the given platform (the playground passes [Platform::Browser]). Pure: no filesystem, no tsc. The in-process Bundle subset only; programs that reach Workers/Cloudflare-only shapes are reported as diagnostics (slice-2 platform lock), never silently mis-compiled.
compile_to_json
Compile to a JSON string — the wasm boundary representation of CompileResult.