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.
CompleteResult
The editor’s completion list at a cursor position (#808).
CompletionCandidate
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 as EmittedFile/Diagnostic).
Diagnostic
A diagnostic flattened for the JS side, with a 1-indexed line/column.
EmittedFile
One emitted JavaScript module of the compiled program.
HoverResult
The inferred type at a cursor position in a single in-memory source, or None if 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, 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.
complete
Completion at a byte offset into 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, so files: None throughout).
complete_to_json
Complete to a JSON string — { items: [{ label, kind, detail, insert_text }] }.
hover
Hover for a byte offset into source, for the given platform.
hover_to_json
Hover to a JSON string — { ty: string | null }.