Semantics and limits
What TRON preserves, what it does not, and where it should not be used.
- Same value semantics as JSON.
toJSON()is honoured, so aDatearrives as its ISO string, not aDate(exactly likeresponse.json()).MapandSetserialize as{}andBigIntthrows, as withJSON.stringify; dev mode logs a warning when a route returns them. - Not for
loador form actions. SvelteKit serializes those with devalue, which preserves Dates, Maps and Sets. This package targetsroute()endpoints, LLM-facing output and service-to-service payloads. - Payloads under about 1 KB stay JSON unless
minBytes: 0orforce: trueis set. They are still decoded transparently. - Content type is
application/tron. A TRON body may carry a declaration preamble that is not valid JSON, so never label itapplication/json. - Schema mode uses
new Functionfor the row constructor where the runtime allows it. In CSP-restricted browsers the fallback scanner takes over, and on Cloudflare Workers, which forbidnew Function, versions from 0.0.2 use a closure-based row constructor instead. - Numeric enum values are rejected in
enums: they would be ambiguous with dictionary indices and decode asundefined. Enum values must be strings or booleans. decodeColumnarneedsencodeColumnaroutput. The defaultencode()emitstabledeclarations that the WASM columnar scanner does not accept; it returnsundefinedfor them.