Skip to main content

Module typescript

Module typescript 

Source
Expand description

TypeScript target: emit the ergonomic type declarations a programmer writes against, plus the self-describing schema-bytes the peer parses at startup.

The emitted module depends only on @bearcove/phon-schema (the data plane): the type declarations, a registry built from the schema-bytes, and the per-root schemaId constants. Encode/decode wrappers (which need the engine) belong to the RPC layer that imports this, not here.

The type shapes match what decodeTyped produces (r[codegen.emits]): struct -> interface; enum -> { tag, … } discriminated union; small ints -> number, 64/128-bit -> bigint; option -> T | null; map -> Map; char, datetime, uuid, qname -> string.

Functions§

render
Render a whole Module to a single TypeScript source file.
render_registry
Render JUST a named phon Registry for module’s schemas (no type declarations, no schemaId). The generated source carries one canonical SchemaBundleEnvelope constant and admits it through the language runtime. Used by RPC codegen, which supplies its own channel-aware declarations.
schema_bundle_bytes
Encode the complete schema closure carried by a generated module.