Skip to main content

Module data

Module data 

Source
Expand description

A surface’s data model: a JSON value addressed by JSON Pointers (RFC 6901), with the rules every A2UI SDK shares (the specification’s conformance suite, core/data_model.yaml):

  • Empty segments collapse, so //a///b//, /a/b/, and /a/b are one path; "" and / are the root. ~1 unescapes to / before ~0 to ~.
  • null reads as absent, and writing through it creates the containers.
  • A write creates missing containers: an array when the next segment is an index, else an object. Array indices are canonical (no leading zeros), at most MAX_ARRAY_INDEX; writing past the end pads with null.
  • Writing through a string, number, or boolean is an error, as is a non-numeric segment on an array.
  • __proto__, constructor, and prototype are refused as segments in every SDK, whatever its language, so models move between them unchanged.
  • A watcher is notified when the value at its own path changed: a write to an ancestor, the path, or a descendant that left it the same notifies no one.

Structs§

DataError
A data model operation the model or the user cannot do.
DataModel
A surface’s data model.
WatchId
An id for one watch, so the same path can be watched twice.

Constants§

MAX_ARRAY_INDEX
The largest array index a write may use.

Functions§

normalize
A path in its normal form: segments collapsed and re-escaped, / for the root.
pointer
The JSON Pointer for segments (/ for none).
resolve
Resolve path against a context path: an absolute path (starting with /) stands alone; a relative one, inside a template, extends the context; "" and . are the context itself.
segments
The segments of a JSON Pointer, unescaped, with empty segments dropped. Refuses the forbidden segments.