SSR / foldkit-ssr
Lower-level API
SSR.render and SSR.hydrate are built from pieces usable on their own:
SSR.envelope(plan, model, { route? })returns the envelope for a Model, as JSON, andSSR.resume(plan, document, { route? })reads it back as aResult.SSR.rendercarries it on the stamped root, beside Foldkit's own stamps; the JSON escapes<as Foldkit escapes its Flags, and U+2028 and U+2029, and the attribute escapes&and"besides, so no string in the Model can break out of the value. Hydration drops the attribute on its first patch, so the browser reads it before it boots.SSR.inspect(plan, model): the plan's coverage as data.Resume.bindings(plan, document, root, model)decodes and checks a page's bindings, andResume.listen(root, { bindings, onAnswer, events? })answers events from the markers, one{ event, messages, unnamed? }per event.eventsis the envelope's list of every event the markers name; without itlistenreads every element's attributes to find them.SSR.hydrateuses both, passing the list; they are there for a custom boot.- Attribute names, for tools and tests:
RESUME_ATTRIBUTE(the envelope on the stamped root),STATIC_ATTRIBUTE,BINDING_ATTRIBUTE(a prefix, followed by the event),SLOT_ATTRIBUTE(a placement's root while the server renders) andFALLBACK_FIELD(the posted Message).