Skip to main content

Crate bynk_emit

Crate bynk_emit 

Source
Expand description

Bynk’s TypeScript emission, plus the per-unit build sequencing that drives it — the layer above bynk-project (discovery, the dependency graph), bynk-check (all semantic checking, R3.5), and (since the P7.12 crate carve) bynk-ir/bynk-lower (the typed IR and its &CheckedProgram → Ir lowering pass).

project owns compile_project/run_checks: the two-pass sequence over a project’s units — discover and parse (bynk-project), then resolve, type-check (bynk-check) and emit each unit with full visibility of what it uses/consumes. emitter lowers a checked program to TypeScript. Input: a project tree (or an in-memory overlay). Output: TypeScript files plus diagnostics — this crate originates none of its own (P5.5, design/tracks/semantics-in-the-checker.md §3.5, R10.1).

Extracted from bynkc as slice 4 of the crate-decomposition track over bynk-syntax + bynk-check. Behaviour is unchanged; bynkc depends on this crate and re-exports its modules so its public API (compile_project, ProjectOutput, …) and the binary are untouched.

Re-exports§

pub use emitter::wrangler::COMPATIBILITY_DATE;
pub use emitter::wrangler::DEFAULT_COMPATIBILITY_FLAGS;
pub use emitter::wrangler::WRANGLER_MIN;
pub use emitter::wrangler::compatibility_flags;

Modules§

emitter
TypeScript emission (spec §7, v0.1 §6, v0.2 §6).
project
Multi-file project compilation (v0.3 §3.2 and §3.3, v0.4 §3.5).
wire_format
State-migrations S4 (#2259): the call signature and the sweep route’s names, for bynk migrate sweep, which signs as the runtime verifies. #1969: the cross-context wire format, version 1, as a published surface.

Structs§

Compiled
A single-file compile that also returns the non-failing warnings produced on success — what a CLI prints (v0.89, ADR 0117). compile is the warning-discarding convenience over this.

Constants§

EDGE_FROM_PREFIX
I2 (#1971): the edge keys’ names, for the driver (bynk dev, bynk deploy), which sees the compiler only through this crate. I2 (#1971): the secret a callee holds for the edge from one caller, edge_key_from.
EDGE_TO_PREFIX
I2 (#1971): the edge keys’ names, for the driver (bynk dev, bynk deploy), which sees the compiler only through this crate. I2 (#1971): the secret a caller holds for the edge to one callee, edge_key_to.
LOCAL_CALL_KEY
I2 (#1971): the value of every edge key off the deployed path. bynk dev passes it for each edge a Worker is on (BYNK_CALL_TO_<callee>, BYNK_CALL_FROM_<caller>, named by bynk_check::wire_format), and the generated test harnesses put it in every participant’s env. Fixed rather than random so two bynk dev --context sessions run side by side still admit each other’s calls. It guards nothing, so it must never reach a deployed Worker: bynk deploy mints one key per edge, and none is ever written into a generated wrangler.toml.
NODE_MAJOR_FLOOR
Minimum supported Node.js major version for the node platform binding and for running Bynk’s emitted TypeScript.
TYPESCRIPT_MAJOR_FLOOR
#1672: the oldest TypeScript major the emitted output is verified against. CI type-checks every positive fixture under it (tsc_verify, with typescript@5 installed on every test leg).
TYPESCRIPT_MAJOR_TESTED
#1672: the newest TypeScript major the emitted output is verified against — the one users get from npm install -g typescript. CI type-checks every positive fixture under it too (a second tsc_verify pass on the Linux leg), the npx fallbacks provision it, and bynk doctor reports a tsc newer than it as untested.

Functions§

check_with_warnings
Check a single-file commons without building it: the same diagnostics as compile_with_warnings, minus the build-only ones, and no emission. Returns the non-failing warnings on success. The single-file half of bynk check / bynkc check (bynk_driver::run_check); a directory goes through the project pipeline in Mode::Check instead.
compile
Compile a single Bynk source string to a TypeScript string.
compile_with_warnings
The warning-preserving single-file compile behind compile. See Compiled.
edge_key_from
I2 (#1971): the edge keys’ names, for the driver (bynk dev, bynk deploy), which sees the compiler only through this crate. I2 (#1971): the secret the callee holds for calls from caller (BYNK_CALL_FROM_SHOP__ORDERS). The callee picks it by the request’s CALLER_HEADER, so an undeclared caller finds no key and is refused.
edge_key_to
I2 (#1971): the edge keys’ names, for the driver (bynk dev, bynk deploy), which sees the compiler only through this crate. I2 (#1971): the secret the caller holds for calls to callee (BYNK_CALL_TO_SHOP__PAYMENT). Same value as the callee’s edge_key_from for the same edge.