Expand description
Browser storage — the AREAS a page can keep text in, and the one place every tier decides what an area IS.
A page that says it persists something must actually persist it. Before this, the only
storage anywhere was a map inside the running program: a ## Store … persisted as "key"
compiled to WebAssembly kept its state in the module’s own memory, which dies with the page.
The sentence said “persisted” and a reload started from the initializers.
★ TEXT IN, TEXT OUT, AND NOTHING IS SPECIAL. A stored value is an opaque string: the browser
API is already length-delimited, so there is no separator to escape and no byte that means
anything. A quote, a newline, a NUL and a ☃ are ordinary content. This is the same reason
the patch stream length-prefixes its text rather than delimiting it — a format with no
delimiter has no escaping bug class.
★ A MISSING KEY IS None, NEVER "". An empty string is a value a page legitimately stores
(an empty draft is exactly what a cleared form field holds), and a reader that cannot tell
“nothing is saved” from “an empty string is saved” will overwrite one with the other.
Structs§
- Storage
State - Every area, saved. What
takereturns andrestoreputs back.
Constants§
- LOCAL
- Survives closing the tab — what
persisted as "key"means. - SESSION
- Survives a RELOAD and ends with the tab — what
preserved across reloadsmeans. - SHARED
- The topics every page on them shares — what
## Store … shared on "topic"keeps its fields in, keyed<topic>.<field>. A write is a frame the other pages on the topic receive (take_shared_writes); the page that receives one merges it (__lgx_shared), the host never does. Survives a reload and closing the tab: it lives with the topic, not the page.
Functions§
- check_
area - Check an area name, or say what the areas are.
- end_
session - CLOSING THE TAB — the session area ends; the local and shared areas survive.
- get
- keys
- Every key an area holds, in sorted order — for a test or a dev panel that wants to see what a page has left on a visitor’s machine.
- remove
- Removing a key that was never there is not an error: a page clearing state it may or may not have written must not have to ask first.
- reset
- A FRESH BROWSER PROFILE — every area empty.
- restore
- Put back a storage profile a matching
takereturned. - set
- take
- Take the current storage, leaving a fresh (empty) profile in its place —
reset, but the profile it replaces comes back to the caller instead of being dropped. A nested run (a candidate page tier compared against the reference) takes the caller’s storage before writing its own, andrestores it when it is done, so the caller’s own storage survives the comparison instead of leaking into — or out of — the candidate’s run. - take_
shared_ writes - Every write to
SHAREDsince the last look,(topic, key, frame), in order — taken, so the host hands each to the other pages on its topic once, as a relay delivers a published frame. The topic is the key’s part before its first..