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§
- Analyze
Result - The diagnostics of a single in-memory source — non-bailing analysis, no emission (the editor’s live, on-type diagnostics — slice 5d).
- Compile
Result - The outcome of compiling one in-memory source.
- Complete
Result - The editor’s completion list at a cursor position (#808).
- Completion
Candidate - One completion candidate, serialised for the JS side — a shadow of
bynk_ide::completion::Completion/CompletionKind(that crate stays serde-free; this is the wire DTO, same pattern asEmittedFile/Diagnostic). - Diagnostic
- A diagnostic flattened for the JS side, with a 1-indexed line/column.
- Emitted
File - One emitted JavaScript module of the compiled program.
- Hover
Result - The inferred type at a cursor position in a single in-memory source, or
Noneif the expression at that position never typed at all — per ADR 0094, a well-typed function still contributes types even when a different function in the same file has an error, so this isn’t blanked by every mid-edit error, only by one at the position itself (or upstream of it, an unresolved name). The editor’s hover tooltip (#397).
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, notsc. The in-processBundlesubset 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. - complete
- Completion at a byte
offsetinto an in-memory Bynk source, for the given platform (capability methods, types, keywords, in-scope locals, and value-receiver members — #808, the other half of #397 hover shipped). Single buffer, single call — no project files, no multi-doc overlay/caching (the wasm boundary has none of those, sofiles: Nonethroughout). - complete_
to_ json - Complete to a JSON string —
{ items: [{ label, kind, detail, insert_text }] }. - hover
- Hover for a byte
offsetintosource, for the given platform. - hover_
to_ json - Hover to a JSON string —
{ ty: string | null }.