codegen library

The surface valence codegen emits calls to. Not for app code.

Everything here is the marshalling half of the bridge: strict decoders, reply and event script builders, and the message cap. It lives in the package so a fix ships once; the generated bridge.g.dart is the only thing that should import it.

App code wants package:valence/valence.dart instead, which is also where BridgeError lives: a generated file imports both, and the two surfaces deliberately do not overlap.

Functions

bridgeReplyScript(String reply) → String
Wraps a reply from the generated bridgeDispatch in the script the host passes to runJavaScript.
decodeBool(Object? v, String f) → bool
Decodes a JSON boolean, or throws E_PARAMS. Used by generated code.
decodeInt(Object? v, String f) → int
Decodes a JSON integer, or throws E_PARAMS. Used by generated code.
decodeKeys(Map<String, Object?> m, Set<String> allowed, String f) → void
Rejects any field the schema does not declare. Used by generated code.
decodeListOf<T>(Object? v, String f, T each(Object? e, String p)) → List<T>
Decodes a JSON list, naming the failing index. Used by generated code.
decodeNum(Object? v, String f) → num
Decodes a JSON number, or throws E_PARAMS. Used by generated code.
decodeObject(Object? v, String f) → Map<String, Object?>
Decodes a JSON object, or throws E_PARAMS. Used by generated code.
decodeString(Object? v, String f) → String
Decodes a JSON string, or throws E_PARAMS. Used by generated code.
eventScript(String name, Object? payload) → String
Builds the script that delivers one event to the page. Used by generated code.
replyError(Object? id, String code, String message) → String
Encodes a failed reply. Used by generated code.
replyOk(Object? id, Object? v) → String
Encodes a successful reply, replacing an over-cap one with E_TOO_LARGE. Used by generated code.