Expand description
Per-declaration emission — the functions emit_project drives to render each top-level Bynk
declaration into TypeScript. Split out of emitter.rs (ADR 0060), then into one file per
declaration kind (back-half paydown 2.1, #4086). This file only declares those files and
re-exports them, so every emitter::emit::X and emitter::X path still resolves; each child
imports what it uses explicitly. The one glob import below is not for this file: moved function
bodies spell parent paths through it, such as super::tco::plan, super::commons_alias,
super::serialisation::… and super::ty_to_type_ref.
types: type, refined, record and sum declarations and their checks;functions: attached methods, free functions, constants and contract guards;suite: the declarations a test suite makes, whichtestgencalls;handlers: handler method names and labels, and the handler-body items services, agents and free functions share;messages:messagesbundles and ICU placeholders;capability: capabilities, derived capabilities and providers;service: services, contexts, themakesurface and the actor-sum types;websocket: the Durable Object methods andfetchupgrade branch of afrom websocketservice;agent:emit_agent, the agent class’s constructor, its state record and its zero entries;agent_store: an agent’s store layout, lazy-read specs, and key and wire codecs;agent_state: theloadStateandcommitStatefunctions, hydration and the persistence guards;agent_migrate: themigrate from Nstep functions and their dispatcher;agent_dispatch: an agent’s handler methods, Workersfetchdispatch and factory;agent_history: the history-property driver.
Functions§
- any_
service_ binds_ caller - v0.54 (#655): whether any of
servicesdeclares anon call … by c: Callerhandler, whose emitteddepscarries the calling context’s qualified name as itsCallerIdidentity (ADR 0092). This is the single predicate both bundle caller-identity seams consult —emit_make_surface(which adds the__callerparameter) and the compose root (which passes the name) — so the two can never disagree on which providers thread a caller.caller_binder_forself-guardsHandlerKind::Call, so no kind filter is needed or wanted here. - collect_
handler_ labels - Slice 3 (semantic-debugging track, ADR 0105): the debug-metadata sidecar’s
{ fn → label }map — each emitted handler function paired with its Bynk operation label, so the debugger can name a stack frameGET "/"rather thanhttp_GET. bynk_ts::TsExpr by re-walking the unit’s handlers with the same naming functions the emitter uses (so the keys match the emitted function names); serialised as a JSON object (manual, like the source map — no serde). ReturnsNonewhen the unit declares no handlers. - context_
pascal - The PascalCase name a context uses for its generated
Depsinterface:shortener.links→ShortenerLinks. - cron_
handler_ method_ name - Synthesise a TypeScript-safe method name for an
on cronhandler (v0.10a):cron_<service>_<index>, whereindexis the handler’s position among the service’s cron handlers in declaration order. The same key is computed at each emission site (thehandlersmethod, thecomposesurface wrapper, and thescheduleddispatcher) by walking handlers in the same order, so it is collision-free and stable without encoding the schedule expression. - emit_
suite_ decls - #3066: a suite’s own
typeandconstdeclarations, as TypeScript for the body of one test runner: the types (an interface and its companion object, or a union), their JSON codecs (soselect[T],Json.encode/decodeand the boundary paths find__serialise_T/__deserialise_Tin scope), and the constants (cached-function declarations, like a unit’s). They are declared local to the runner, so another suite declaring the same name cannot collide and nothing here reaches the deployable.typedis the suite’s view with the suite’s types and constants already merged in;qualqualifies a target type a suite type’s codec mentions, as the module-level codecs do. - emit_
suite_ fn - #2834: a suite-local helper
fn—emit_free_fnwithout theexport, since it is declared inside a test runner and called from its body. - emit_
suite_ late_ codecs - #3111: the codecs a runner’s body reached for beyond the always-present
ones (
emit_suite_decls): a suite type under another generic (Result, a user generic, nested containers) at aJsonboundary.reachedis what the runner’s lowering noted; only roots that name a suite type are served here (the module-level closure serves the rest). Returns the function declarations, withexportdropped, to be spliced ahead of the body; empty when the body reached nothing new. - http_
handler_ method_ name_ ir - Synthesise a TypeScript-safe method name for an
on http METHOD pathhandler. The result is used both as the key on the service object and as the identifier the Worker fetch handler invokes. Path parameter segments (:name) becomeParam_nameto remain distinct from literal segments. (v0.9 §5.3) - queue_
handler_ method_ name - Method name for an
on queuehandler (v0.10b):queue_<service>_<index>, by the handler’s position among the service’s queue handlers. Computed identically at thehandlersmethod, thecomposesurface wrapper, and thequeuedispatcher (queue names are unique context-wide, but the index keeps the key identifier-safe without sanitising the name). - test_
scaffold_ ns - #1759: the identifier a generated test module imports a unit as
(
import * as __ns_greet from …). A test module destructures a unit’s values out of this namespace (const { greet } = __ns_greet;), so the namespace can’t takequalified_to_ns’s bare name: a contextgreetdeclaringfn greetwould shadow its own import and readgreetin its temporal dead zone. The reserved__ns_prefix can’t be a user identifier. Every test-module namespace reference goes through this, intests_emitand in lowering that runsin_test_scaffold().