foldkit-ssr 0.8.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +203 -69
  2. package/dist/client-F16QT0sc.d.ts +75 -0
  3. package/dist/client-F16QT0sc.d.ts.map +1 -0
  4. package/dist/client.d.ts +5 -0
  5. package/dist/client.js +271 -0
  6. package/dist/client.js.map +1 -0
  7. package/dist/context.d.ts +2 -0
  8. package/dist/context.js +21 -0
  9. package/dist/context.js.map +1 -0
  10. package/dist/diagnostics.d.ts +2 -0
  11. package/dist/diagnostics.js +59 -0
  12. package/dist/diagnostics.js.map +1 -0
  13. package/dist/{index.d.mts → index.d.ts} +18 -7
  14. package/dist/index.d.ts.map +1 -0
  15. package/dist/{index.mjs → index.js} +79 -60
  16. package/dist/index.js.map +1 -0
  17. package/dist/listen-zNd0IIAT.d.ts +69 -0
  18. package/dist/listen-zNd0IIAT.d.ts.map +1 -0
  19. package/dist/listen.d.ts +2 -0
  20. package/dist/listen.js +179 -0
  21. package/dist/listen.js.map +1 -0
  22. package/dist/requestContext-D9nsbGSJ.d.ts +21 -0
  23. package/dist/requestContext-D9nsbGSJ.d.ts.map +1 -0
  24. package/dist/requestContext.d.ts +2 -0
  25. package/dist/requestContext.js +48 -0
  26. package/dist/requestContext.js.map +1 -0
  27. package/dist/resumable-BWItJsxF.d.ts +86 -0
  28. package/dist/resumable-BWItJsxF.d.ts.map +1 -0
  29. package/dist/resumable.d.ts +2 -0
  30. package/dist/resumable.js +358 -0
  31. package/dist/resumable.js.map +1 -0
  32. package/dist/{client-DkwAniQQ.d.mts → shared-v1u-OEQI.d.ts} +218 -194
  33. package/dist/shared-v1u-OEQI.d.ts.map +1 -0
  34. package/dist/shared.d.ts +2 -0
  35. package/dist/shared.js +324 -0
  36. package/dist/shared.js.map +1 -0
  37. package/dist/{vite.d.mts → vite.d.ts} +3 -5
  38. package/dist/vite.d.ts.map +1 -0
  39. package/dist/{vite.mjs → vite.js} +3 -4
  40. package/dist/vite.js.map +1 -0
  41. package/package.json +17 -17
  42. package/dist/client-DVG9_3rL.mjs +0 -1113
  43. package/dist/client-DVG9_3rL.mjs.map +0 -1
  44. package/dist/client-DkwAniQQ.d.mts.map +0 -1
  45. package/dist/client.d.mts +0 -2
  46. package/dist/client.mjs +0 -1
  47. package/dist/index.d.mts.map +0 -1
  48. package/dist/index.mjs.map +0 -1
  49. package/dist/vite.d.mts.map +0 -1
  50. package/dist/vite.mjs.map +0 -1
@@ -0,0 +1,358 @@
1
+ import { current } from "./context.js";
2
+ import { Schema, SchemaAST } from "effect";
3
+ // src/resumable.ts
4
+ /**
5
+ * The resumable builder: the application's `h`, whose event attributes say, in
6
+ * the server's markup, which Message each element causes.
7
+ *
8
+ * A Foldkit handler is a Message value (`h.OnClick(Message.Liked({ id }))`), so
9
+ * for most events that is already data. The events that carry a value
10
+ * (`OnInput`, `OnChange`, `OnKeyDown`, `OnKeyUp`) take a closure only to put
11
+ * the value into a Message field; this builder also takes the Message's own
12
+ * constructor there, a Message with a hole, and fills the hole the same way.
13
+ *
14
+ * During the server's renders each binding gets an ordinal, recorded in render
15
+ * order, and its element a `data-foldkit-plus-on-<event>` attribute naming it.
16
+ * In the browser the builder marks nothing: it is the application's `h`, with
17
+ * the hole forms turned into the closures Foldkit expects.
18
+ */
19
+ /** The attribute prefix of an element's binding marker. */
20
+ const BINDING_ATTRIBUTE = "data-foldkit-plus-on-";
21
+ /**
22
+ * The DOM event each of Foldkit's event attributes listens to, read from
23
+ * Foldkit's own attribute table (0.163). `OnCustomEvent` names its event in
24
+ * its payload, and `OnMount` and `OnUnmount` listen to none.
25
+ */
26
+ const EVENT_OF = {
27
+ OnClick: "click",
28
+ OnDoubleClick: "dblclick",
29
+ OnMouseDown: "mousedown",
30
+ OnMouseUp: "mouseup",
31
+ OnMouseEnter: "mouseenter",
32
+ OnMouseLeave: "mouseleave",
33
+ OnMouseOver: "mouseover",
34
+ OnMouseOut: "mouseout",
35
+ OnMouseMove: "mousemove",
36
+ OnPointerMove: "pointermove",
37
+ OnPointerLeave: "pointerleave",
38
+ OnPointerDown: "pointerdown",
39
+ OnPointerUp: "pointerup",
40
+ OnKeyDown: "keydown",
41
+ OnKeyDownPreventDefault: "keydown",
42
+ OnKeyDownSelf: "keydown",
43
+ OnKeyDownSelfPreventDefault: "keydown",
44
+ OnKeyDownFocus: "keydown",
45
+ OnKeyUp: "keyup",
46
+ OnKeyUpPreventDefault: "keyup",
47
+ OnKeyPress: "keypress",
48
+ OnFocus: "focus",
49
+ OnBlur: "blur",
50
+ OnFocusEnter: "focusin",
51
+ OnFocusLeave: "focusout",
52
+ OnInput: "input",
53
+ OnChange: "change",
54
+ OnBeforeInput: "beforeinput",
55
+ OnBeforeInputPreventDefault: "beforeinput",
56
+ OnFileChange: "change",
57
+ OnSubmit: "submit",
58
+ OnReset: "reset",
59
+ OnScroll: "scroll",
60
+ OnWheel: "wheel",
61
+ OnCopy: "copy",
62
+ OnCut: "cut",
63
+ OnPaste: "paste",
64
+ OnPastePreventDefault: "paste",
65
+ OnCopyText: "copy",
66
+ OnCutText: "cut",
67
+ OnCancel: "cancel",
68
+ OnCancelPreventDefault: "cancel",
69
+ OnToggle: "toggle",
70
+ OnContextMenu: "contextmenu",
71
+ OnDragStart: "dragstart",
72
+ OnDrag: "drag",
73
+ OnDragEnd: "dragend",
74
+ OnDragEnter: "dragenter",
75
+ OnDragLeave: "dragleave",
76
+ OnDragOver: "dragover",
77
+ OnDrop: "drop",
78
+ OnDropFiles: "drop",
79
+ OnTouchStart: "touchstart",
80
+ OnTouchEnd: "touchend",
81
+ OnTouchMove: "touchmove",
82
+ OnTouchCancel: "touchcancel",
83
+ OnAnimationStart: "animationstart",
84
+ OnAnimationEnd: "animationend",
85
+ OnAnimationIteration: "animationiteration",
86
+ OnTransitionEnd: "transitionend",
87
+ OnLoad: "load",
88
+ OnError: "error",
89
+ OnPlay: "play",
90
+ OnPause: "pause",
91
+ OnEnded: "ended",
92
+ OnTimeUpdate: "timeupdate",
93
+ OnVolumeChange: "volumechange",
94
+ OnSelect: "select"
95
+ };
96
+ /**
97
+ * The attributes whose binding the page can describe: a Message value, or one
98
+ * of the hole forms this builder records. Any other handler still runs on the
99
+ * live page, so its event is marked `*`: the page does something there it
100
+ * cannot name, and a dispatcher that ran only the named bindings would do less.
101
+ */
102
+ const MARKABLE = /* @__PURE__ */ new Set([
103
+ "OnClick",
104
+ "OnDoubleClick",
105
+ "OnMouseDown",
106
+ "OnMouseUp",
107
+ "OnMouseEnter",
108
+ "OnMouseLeave",
109
+ "OnMouseOver",
110
+ "OnMouseOut",
111
+ "OnMouseMove",
112
+ "OnFocus",
113
+ "OnBlur",
114
+ "OnSubmit",
115
+ "OnReset",
116
+ "OnInput",
117
+ "OnChange",
118
+ "OnKeyDown",
119
+ "OnKeyUp"
120
+ ]);
121
+ /** The token in a marker for a handler the page cannot describe. */
122
+ const UNNAMED_HANDLER = "*";
123
+ /** The posted field that carries a form's encoded Message, for the server fallback. */
124
+ const FALLBACK_FIELD = "foldkit-plus-message";
125
+ /** The posted field that says how many placement wrappers the form's fields sit under. */
126
+ const FALLBACK_DEPTH_FIELD = "foldkit-plus-depth";
127
+ /** The attribute on a placement's root naming its slot, while the server renders. */
128
+ const SLOT_ATTRIBUTE = "data-foldkit-plus-slot";
129
+ const isMember = (value) => typeof value === "function" && typeof value.fields === "object";
130
+ const tagOf = (member) => {
131
+ const tag = member.fields._tag;
132
+ return Schema.isSchema(tag) && SchemaAST.isLiteral(tag.ast) && typeof tag.ast.literal === "string" ? tag.ast.literal : "the member";
133
+ };
134
+ /**
135
+ * The fields a member leaves for the event to fill, given what is fixed. Only
136
+ * `fixed`'s own keys fix a field: `in` finds `constructor` on every object.
137
+ */
138
+ const holeOf = (member, fixed) => Object.keys(member.fields).filter((field) => field !== "_tag" && !Object.hasOwn(fixed, field));
139
+ const NO_MODIFIERS = {
140
+ shiftKey: false,
141
+ ctrlKey: false,
142
+ altKey: false,
143
+ metaKey: false
144
+ };
145
+ /** Each hole-form attribute, with its Message filled by a placeholder and the fields the event fills. */
146
+ const holes = /* @__PURE__ */ new WeakMap();
147
+ const isAttribute = (item) => "_tag" in item;
148
+ const builders = /* @__PURE__ */ new WeakMap();
149
+ /** A hole form's placeholder Message, or `undefined` when its field's checks refuse one. */
150
+ const placeholder = (make) => {
151
+ try {
152
+ return make();
153
+ } catch {
154
+ return;
155
+ }
156
+ };
157
+ /**
158
+ * The resumable builder for a view's `h`. Use it in place of `h`; it has the
159
+ * same elements and attributes, and the hole forms of the four value events.
160
+ */
161
+ const builder = (h) => {
162
+ const cached = builders.get(h);
163
+ if (cached !== void 0) return cached;
164
+ const source = h;
165
+ const attribute = source.Attribute;
166
+ /** The attributes with a marker for each binding, while the server renders. */
167
+ const mark = (tag, attributes) => {
168
+ const now = current();
169
+ if (now?.mode !== "collect" && now?.mode !== "replay") return attributes;
170
+ const id = attributes.find((item) => isAttribute(item) && item._tag === "Id");
171
+ const element = id === void 0 ? tag : `${tag}#${id.value}`;
172
+ const tokens = /* @__PURE__ */ new Map();
173
+ for (const item of attributes) {
174
+ if (!isAttribute(item)) continue;
175
+ const event = item._tag === "OnCustomEvent" ? item.name : EVENT_OF[item._tag];
176
+ if (event === void 0) continue;
177
+ if (now.mode === "collect" && now.region !== void 0) now.inStatic.push({
178
+ region: now.region,
179
+ element,
180
+ event
181
+ });
182
+ const recorded = holes.get(item);
183
+ const nested = now.depth === 0 ? {} : { depth: now.depth };
184
+ const binding = !MARKABLE.has(item._tag) ? void 0 : "message" in item ? {
185
+ attribute: item._tag,
186
+ event,
187
+ element,
188
+ message: now.wrap(item.message),
189
+ ..."options" in item && item.options !== void 0 ? { options: item.options } : {}
190
+ } : recorded === void 0 ? void 0 : {
191
+ attribute: item._tag,
192
+ event,
193
+ element,
194
+ message: now.wrap(recorded.template),
195
+ hole: recorded.hole,
196
+ ...nested
197
+ };
198
+ const list = tokens.get(event) ?? [];
199
+ tokens.set(event, list);
200
+ if (binding === void 0) {
201
+ if (now.mode === "collect" && !list.includes("*")) now.unnamed.push({
202
+ element,
203
+ event
204
+ });
205
+ list.push("*");
206
+ } else {
207
+ list.push(String(now.bindings.length));
208
+ now.bindings.push(binding);
209
+ }
210
+ }
211
+ if (tokens.size === 0) return attributes;
212
+ const markers = [...tokens].map(([event, list]) => attribute(`${BINDING_ATTRIBUTE}${event}`, list.join(" ")));
213
+ return [...attributes, ...markers];
214
+ };
215
+ /**
216
+ * A form whose `OnSubmit` names a Message, while the server renders for a
217
+ * plan with a fallback, also posts that Message: `method="post"` to its own
218
+ * URL, and a hidden input carrying the Message encoded. Posted fields named
219
+ * as the Message's own fields override them, so a typed title reaches
220
+ * `update` as it would through the page.
221
+ */
222
+ const fallback = (tag, attributes, children) => {
223
+ const now = current();
224
+ if (tag !== "form" || now?.mode === void 0 || now.mode === "resume" || now.fallback === void 0) return {
225
+ attributes,
226
+ children
227
+ };
228
+ const submit = attributes.find((item) => isAttribute(item) && item._tag === "OnSubmit");
229
+ if (submit === void 0 || !Array.isArray(children)) return {
230
+ attributes,
231
+ children
232
+ };
233
+ const encoded = now.fallback(now.wrap(submit.message));
234
+ if (encoded === void 0) return {
235
+ attributes,
236
+ children
237
+ };
238
+ const make = (name) => source[name];
239
+ const input = source.input;
240
+ const hidden = (name, value) => input([
241
+ make("Type")("hidden"),
242
+ make("Name")(name),
243
+ make("Value")(value)
244
+ ]);
245
+ return {
246
+ attributes: [...attributes, make("Method")("post")],
247
+ children: [
248
+ ...children,
249
+ hidden(FALLBACK_FIELD, encoded),
250
+ ...now.depth === 0 ? [] : [hidden(FALLBACK_DEPTH_FIELD, String(now.depth))]
251
+ ]
252
+ };
253
+ };
254
+ const textHole = (name) => (given, fixed = {}) => {
255
+ const make = source[name];
256
+ if (!isMember(given)) return make(given);
257
+ const hole = holeOf(given, fixed);
258
+ if (hole.length !== 1) throw new Error(`Resume.builder: ${name}(${tagOf(given)}) leaves ${hole.length === 0 ? "no field" : hole.join(", ")} for the event to fill; it must leave one string field`);
259
+ const [field] = hole;
260
+ const made = make((value) => given({
261
+ ...fixed,
262
+ [field]: value
263
+ }));
264
+ const template = placeholder(() => given({
265
+ ...fixed,
266
+ [field]: ""
267
+ }));
268
+ if (template !== void 0) holes.set(made, {
269
+ template,
270
+ hole
271
+ });
272
+ return made;
273
+ };
274
+ const keyHole = (name) => (given, fixed = {}) => {
275
+ const make = source[name];
276
+ if (!isMember(given)) return make(given);
277
+ const hole = holeOf(given, fixed);
278
+ if (hole.length !== 2 || !hole.includes("key") || !hole.includes("modifiers")) throw new Error(`Resume.builder: ${name}(${tagOf(given)}) leaves ${hole.join(", ") || "no field"} for the event to fill; it must leave exactly key and modifiers`);
279
+ const made = make((key, modifiers) => given({
280
+ ...fixed,
281
+ key,
282
+ modifiers
283
+ }));
284
+ const template = placeholder(() => given({
285
+ ...fixed,
286
+ key: "",
287
+ modifiers: NO_MODIFIERS
288
+ }));
289
+ if (template !== void 0) holes.set(made, {
290
+ template,
291
+ hole
292
+ });
293
+ return made;
294
+ };
295
+ /**
296
+ * `h.submodel` with the child's root stamped with its slot, while the
297
+ * server renders: a boundary a tool can find, which the browser's first
298
+ * patch removes as it removes the markers.
299
+ */
300
+ const submodel = (config) => {
301
+ const original = source.submodel;
302
+ const now = current();
303
+ if (now?.mode !== "collect" && now?.mode !== "replay") return original(config);
304
+ const view = config.view;
305
+ const stamped = (...args) => {
306
+ const outer = {
307
+ wrap: now.wrap,
308
+ depth: now.depth
309
+ };
310
+ now.wrap = (message) => outer.wrap(config.toParentMessage(message));
311
+ now.depth = outer.depth + 1;
312
+ let out;
313
+ try {
314
+ out = view(...args);
315
+ } finally {
316
+ now.wrap = outer.wrap;
317
+ now.depth = outer.depth;
318
+ }
319
+ if (out !== null && typeof out === "object" && out.data !== void 0) out.data.attrs = {
320
+ ...out.data.attrs,
321
+ [SLOT_ATTRIBUTE]: config.slotId
322
+ };
323
+ return out;
324
+ };
325
+ return original({
326
+ ...config,
327
+ view: Object.assign(stamped, view)
328
+ });
329
+ };
330
+ const wrapped = {};
331
+ for (const [name, value] of Object.entries(source)) if (name === "submodel") wrapped[name] = submodel;
332
+ else if (name === "OnInput" || name === "OnChange") wrapped[name] = textHole(name);
333
+ else if (name === "OnKeyDown" || name === "OnKeyUp") wrapped[name] = keyHole(name);
334
+ else if (name === "keyed") {
335
+ const keyed = value;
336
+ wrapped[name] = (tag) => (key, attributes = [], ...rest) => {
337
+ const posted = fallback(tag, attributes, rest[0]);
338
+ return keyed(tag)(key, mark(tag, posted.attributes), posted.children, ...rest.slice(1));
339
+ };
340
+ } else if (/^[a-z]/.test(name) && typeof value === "function") {
341
+ const element = value;
342
+ wrapped[name] = (attributes, ...rest) => {
343
+ const posted = fallback(name, attributes, rest[0]);
344
+ return element(mark(name, posted.attributes), posted.children, ...rest.slice(1));
345
+ };
346
+ } else wrapped[name] = value;
347
+ builders.set(h, wrapped);
348
+ return wrapped;
349
+ };
350
+ /**
351
+ * A view or renderer written against the resumable builder, as one that takes
352
+ * the builder it is given: `Surface.rootView(Page, params, Resume.view(render))`,
353
+ * `SurfaceView.define`, or an application's own view.
354
+ */
355
+ const view = (render) => (model, h) => render(model, builder(h));
356
+ export { BINDING_ATTRIBUTE, EVENT_OF, FALLBACK_DEPTH_FIELD, FALLBACK_FIELD, SLOT_ATTRIBUTE, UNNAMED_HANDLER, builder, view };
357
+
358
+ //# sourceMappingURL=resumable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resumable.js","names":[],"sources":["../src/resumable.ts"],"sourcesContent":["/**\n * The resumable builder: the application's `h`, whose event attributes say, in\n * the server's markup, which Message each element causes.\n *\n * A Foldkit handler is a Message value (`h.OnClick(Message.Liked({ id }))`), so\n * for most events that is already data. The events that carry a value\n * (`OnInput`, `OnChange`, `OnKeyDown`, `OnKeyUp`) take a closure only to put\n * the value into a Message field; this builder also takes the Message's own\n * constructor there, a Message with a hole, and fills the hole the same way.\n *\n * During the server's renders each binding gets an ordinal, recorded in render\n * order, and its element a `data-foldkit-plus-on-<event>` attribute naming it.\n * In the browser the builder marks nothing: it is the application's `h`, with\n * the hole forms turned into the closures Foldkit expects.\n */\nimport { Schema, SchemaAST } from 'effect'\nimport type { Attribute, ChildAttribute, HtmlBuilder, KeyboardModifiers } from 'foldkit/html'\nimport { current, type Binding } from './context.js'\n\n/** The attribute prefix of an element's binding marker. */\nexport const BINDING_ATTRIBUTE = 'data-foldkit-plus-on-'\n\n/**\n * The DOM event each of Foldkit's event attributes listens to, read from\n * Foldkit's own attribute table (0.163). `OnCustomEvent` names its event in\n * its payload, and `OnMount` and `OnUnmount` listen to none.\n */\nexport const EVENT_OF: Readonly<Record<string, string>> = {\n OnClick: 'click',\n OnDoubleClick: 'dblclick',\n OnMouseDown: 'mousedown',\n OnMouseUp: 'mouseup',\n OnMouseEnter: 'mouseenter',\n OnMouseLeave: 'mouseleave',\n OnMouseOver: 'mouseover',\n OnMouseOut: 'mouseout',\n OnMouseMove: 'mousemove',\n OnPointerMove: 'pointermove',\n OnPointerLeave: 'pointerleave',\n OnPointerDown: 'pointerdown',\n OnPointerUp: 'pointerup',\n OnKeyDown: 'keydown',\n OnKeyDownPreventDefault: 'keydown',\n OnKeyDownSelf: 'keydown',\n OnKeyDownSelfPreventDefault: 'keydown',\n OnKeyDownFocus: 'keydown',\n OnKeyUp: 'keyup',\n OnKeyUpPreventDefault: 'keyup',\n OnKeyPress: 'keypress',\n OnFocus: 'focus',\n OnBlur: 'blur',\n OnFocusEnter: 'focusin',\n OnFocusLeave: 'focusout',\n OnInput: 'input',\n OnChange: 'change',\n OnBeforeInput: 'beforeinput',\n OnBeforeInputPreventDefault: 'beforeinput',\n OnFileChange: 'change',\n OnSubmit: 'submit',\n OnReset: 'reset',\n OnScroll: 'scroll',\n OnWheel: 'wheel',\n OnCopy: 'copy',\n OnCut: 'cut',\n OnPaste: 'paste',\n OnPastePreventDefault: 'paste',\n OnCopyText: 'copy',\n OnCutText: 'cut',\n OnCancel: 'cancel',\n OnCancelPreventDefault: 'cancel',\n OnToggle: 'toggle',\n OnContextMenu: 'contextmenu',\n OnDragStart: 'dragstart',\n OnDrag: 'drag',\n OnDragEnd: 'dragend',\n OnDragEnter: 'dragenter',\n OnDragLeave: 'dragleave',\n OnDragOver: 'dragover',\n OnDrop: 'drop',\n OnDropFiles: 'drop',\n OnTouchStart: 'touchstart',\n OnTouchEnd: 'touchend',\n OnTouchMove: 'touchmove',\n OnTouchCancel: 'touchcancel',\n OnAnimationStart: 'animationstart',\n OnAnimationEnd: 'animationend',\n OnAnimationIteration: 'animationiteration',\n OnTransitionEnd: 'transitionend',\n OnLoad: 'load',\n OnError: 'error',\n OnPlay: 'play',\n OnPause: 'pause',\n OnEnded: 'ended',\n OnTimeUpdate: 'timeupdate',\n OnVolumeChange: 'volumechange',\n OnSelect: 'select',\n}\n\n/**\n * The attributes whose binding the page can describe: a Message value, or one\n * of the hole forms this builder records. Any other handler still runs on the\n * live page, so its event is marked `*`: the page does something there it\n * cannot name, and a dispatcher that ran only the named bindings would do less.\n */\nconst MARKABLE: ReadonlySet<string> = new Set([\n 'OnClick',\n 'OnDoubleClick',\n 'OnMouseDown',\n 'OnMouseUp',\n 'OnMouseEnter',\n 'OnMouseLeave',\n 'OnMouseOver',\n 'OnMouseOut',\n 'OnMouseMove',\n 'OnFocus',\n 'OnBlur',\n 'OnSubmit',\n 'OnReset',\n 'OnInput',\n 'OnChange',\n 'OnKeyDown',\n 'OnKeyUp',\n])\n\n/** The token in a marker for a handler the page cannot describe. */\nexport const UNNAMED_HANDLER = '*'\n\n/** The posted field that carries a form's encoded Message, for the server fallback. */\nexport const FALLBACK_FIELD = 'foldkit-plus-message'\n\n/** The posted field that says how many placement wrappers the form's fields sit under. */\nexport const FALLBACK_DEPTH_FIELD = 'foldkit-plus-depth'\n\n/** The attribute on a placement's root naming its slot, while the server renders. */\nexport const SLOT_ATTRIBUTE = 'data-foldkit-plus-slot'\n\ndeclare const invalid: unique symbol\n\n/** A compile-time failure that names its cause. */\nexport interface Invalid<Message extends string> {\n readonly [invalid]: Message\n}\n\ntype IsUnion<T, U = T> = T extends unknown ? ([U] extends [T] ? false : true) : never\n\n/** A Message constructor from `defineMessageUnion`: a tagged Schema that can be called. */\ntype AnyMemberSchema = Schema.Top & { readonly fields: Schema.Struct.Fields }\n\n/** The Message a member makes. */\ntype Made<M> = M extends { readonly Type: infer T } ? T : never\n\n/** The fields a member's event may be given fixed: all but `_tag`. */\ntype Fixable<M> = Partial<Omit<Made<M>, '_tag'>>\n\n/** The fields of a member the event fills: those neither `_tag` nor fixed. */\ntype Rest<M, Fixed> = Omit<Made<M>, '_tag' | keyof Fixed>\n\ntype ProducesMessage<M, Message> = [Made<M>] extends [Message]\n ? unknown\n : Invalid<\"the member is not one of this view's Messages\">\n\ntype TextHoleCheck<M, Fixed> = [keyof Rest<M, Fixed>] extends [never]\n ? Invalid<'the member has no field left for the event to fill'>\n : true extends IsUnion<keyof Rest<M, Fixed>>\n ? Invalid<'the member leaves more than one field for the event to fill: fix the others'>\n : Rest<M, Fixed>[keyof Rest<M, Fixed>] extends string\n ? string extends Rest<M, Fixed>[keyof Rest<M, Fixed>]\n ? unknown\n : Invalid<'the field the event fills must be a string'>\n : Invalid<'the field the event fills must be a string'>\n\ntype KeyHoleCheck<M, Fixed> = [keyof Rest<M, Fixed>] extends ['key' | 'modifiers']\n ? ['key' | 'modifiers'] extends [keyof Rest<M, Fixed>]\n ? unknown\n : Invalid<'the member must leave exactly key and modifiers for the event to fill'>\n : Invalid<'the member must leave exactly key and modifiers for the event to fill'>\n\n/** `OnInput` and `OnChange`: a closure, or a member whose one string field the event fills. */\nexport interface TextHole<Message> {\n (toMessage: (value: string) => Message): Attribute<Message>\n <M extends AnyMemberSchema, const Fixed extends Fixable<M> = {}>(\n member: M & ProducesMessage<M, Message> & TextHoleCheck<M, Fixed>,\n fixed?: Fixed,\n ): Attribute<Message>\n}\n\n/** `OnKeyDown` and `OnKeyUp`: a closure, or a member whose `key` and `modifiers` the event fills. */\nexport interface KeyHole<Message> {\n (toMessage: (key: string, modifiers: KeyboardModifiers) => Message): Attribute<Message>\n <M extends AnyMemberSchema, const Fixed extends Fixable<M> = {}>(\n member: M & ProducesMessage<M, Message> & KeyHoleCheck<M, Fixed>,\n fixed?: Fixed,\n ): Attribute<Message>\n}\n\n/**\n * A builder a view is given: Foldkit's `HtmlBuilder`, or a Surface renderer's,\n * which leaves out Foldkit's phantom key. Its Message is what `OnClick` takes.\n */\nexport type AnyBuilder = {\n readonly OnClick: (message: never, ...rest: ReadonlyArray<never>) => unknown\n}\n\n/** The Message a builder's handlers make. */\nexport type MessageOf<Builder> = Builder extends {\n readonly OnClick: (message: infer Message, ...rest: ReadonlyArray<never>) => unknown\n}\n ? Message\n : never\n\n/**\n * The resumable builder for a view whose Messages are `Message`: its elements\n * and attributes, and the hole forms of the four value events. One shape\n * whether it wraps a view's `HtmlBuilder` or a Surface renderer's builder, so a\n * helper typed with it takes either. It keeps Foldkit's phantom Message key,\n * so a placement's view accepts it as the parent's builder.\n */\nexport type ResumableBuilder<Message> = Omit<\n HtmlBuilder<Message>,\n 'OnInput' | 'OnChange' | 'OnKeyDown' | 'OnKeyUp'\n> & {\n readonly OnInput: TextHole<Message>\n readonly OnChange: TextHole<Message>\n readonly OnKeyDown: KeyHole<Message>\n readonly OnKeyUp: KeyHole<Message>\n}\n\ntype AnyMember = ((value: Record<string, unknown>) => unknown) & {\n readonly fields: Readonly<Record<string, unknown>>\n}\n\nconst isMember = (value: unknown): value is AnyMember =>\n typeof value === 'function' && typeof (value as { fields?: unknown }).fields === 'object'\n\nconst tagOf = (member: AnyMember): string => {\n const tag = member.fields._tag\n return Schema.isSchema(tag) && SchemaAST.isLiteral(tag.ast) && typeof tag.ast.literal === 'string'\n ? tag.ast.literal\n : 'the member'\n}\n\n/**\n * The fields a member leaves for the event to fill, given what is fixed. Only\n * `fixed`'s own keys fix a field: `in` finds `constructor` on every object.\n */\nconst holeOf = (member: AnyMember, fixed: object): ReadonlyArray<string> =>\n Object.keys(member.fields).filter(field => field !== '_tag' && !Object.hasOwn(fixed, field))\n\nconst NO_MODIFIERS: KeyboardModifiers = {\n shiftKey: false,\n ctrlKey: false,\n altKey: false,\n metaKey: false,\n}\n\n/** Each hole-form attribute, with its Message filled by a placeholder and the fields the event fills. */\nconst holes = new WeakMap<\n object,\n { readonly template: unknown; readonly hole: ReadonlyArray<string> }\n>()\n\n/** What an element is given: Foldkit's attributes, and a Submodel's wrapped ones, which carry no tag. */\ntype Item = Attribute<unknown> | ChildAttribute\n\nconst isAttribute = (item: Item): item is Attribute<unknown> => '_tag' in item\n\nconst builders = new WeakMap<object, unknown>()\n\n/** A hole form's placeholder Message, or `undefined` when its field's checks refuse one. */\nconst placeholder = (make: () => unknown): unknown => {\n try {\n return make()\n } catch {\n return undefined\n }\n}\n\n/**\n * The resumable builder for a view's `h`. Use it in place of `h`; it has the\n * same elements and attributes, and the hole forms of the four value events.\n */\nexport const builder = <Builder extends AnyBuilder>(\n h: Builder,\n): ResumableBuilder<MessageOf<Builder>> => {\n const cached = builders.get(h)\n if (cached !== undefined) return cached as ResumableBuilder<MessageOf<Builder>>\n const source = h as unknown as Record<string, unknown>\n const attribute = source.Attribute as (name: string, value: string) => unknown\n\n /** The attributes with a marker for each binding, while the server renders. */\n const mark = (tag: string, attributes: ReadonlyArray<Item>): ReadonlyArray<unknown> => {\n const now = current()\n if (now?.mode !== 'collect' && now?.mode !== 'replay') return attributes\n const id = attributes.find(\n (item): item is Extract<Attribute<unknown>, { readonly _tag: 'Id' }> =>\n isAttribute(item) && item._tag === 'Id',\n )\n const element = id === undefined ? tag : `${tag}#${id.value}`\n // Foldkit chains every handler of an event, in the order the attributes\n // come, so a marker lists every binding of its event in that order.\n const tokens = new Map<string, Array<string>>()\n for (const item of attributes) {\n if (!isAttribute(item)) continue\n const event = item._tag === 'OnCustomEvent' ? item.name : EVENT_OF[item._tag]\n if (event === undefined) continue\n // Recorded for the refusal; the render does not survive it.\n if (now.mode === 'collect' && now.region !== undefined) {\n now.inStatic.push({ region: now.region, element, event })\n }\n const recorded = holes.get(item)\n const nested = now.depth === 0 ? {} : { depth: now.depth }\n const binding: Binding | undefined = !MARKABLE.has(item._tag)\n ? undefined\n : 'message' in item\n ? {\n attribute: item._tag,\n event,\n element,\n message: now.wrap(item.message),\n ...('options' in item && item.options !== undefined ? { options: item.options } : {}),\n }\n : recorded === undefined\n ? undefined\n : {\n attribute: item._tag,\n event,\n element,\n message: now.wrap(recorded.template),\n hole: recorded.hole,\n ...nested,\n }\n const list = tokens.get(event) ?? []\n tokens.set(event, list)\n if (binding === undefined) {\n // One entry per element and event, however many handlers it chains.\n if (now.mode === 'collect' && !list.includes(UNNAMED_HANDLER)) {\n now.unnamed.push({ element, event })\n }\n list.push(UNNAMED_HANDLER)\n } else {\n list.push(String(now.bindings.length))\n now.bindings.push(binding)\n }\n }\n if (tokens.size === 0) return attributes\n const markers = [...tokens].map(([event, list]) =>\n attribute(`${BINDING_ATTRIBUTE}${event}`, list.join(' ')),\n )\n return [...attributes, ...markers]\n }\n\n /**\n * A form whose `OnSubmit` names a Message, while the server renders for a\n * plan with a fallback, also posts that Message: `method=\"post\"` to its own\n * URL, and a hidden input carrying the Message encoded. Posted fields named\n * as the Message's own fields override them, so a typed title reaches\n * `update` as it would through the page.\n */\n const fallback = (\n tag: string,\n attributes: ReadonlyArray<Item>,\n children: unknown,\n ): { readonly attributes: ReadonlyArray<Item>; readonly children: unknown } => {\n const now = current()\n if (\n tag !== 'form' ||\n now?.mode === undefined ||\n now.mode === 'resume' ||\n now.fallback === undefined\n ) {\n return { attributes, children }\n }\n const submit = attributes.find(\n (item): item is Extract<Attribute<unknown>, { readonly _tag: 'OnSubmit' }> =>\n isAttribute(item) && item._tag === 'OnSubmit',\n )\n if (submit === undefined || !Array.isArray(children)) return { attributes, children }\n const encoded = now.fallback(now.wrap(submit.message))\n if (encoded === undefined) return { attributes, children }\n const make = (name: string) => source[name] as (value: string) => Attribute<unknown>\n const input = source.input as (attributes: ReadonlyArray<unknown>) => unknown\n const hidden = (name: string, value: string) =>\n input([make('Type')('hidden'), make('Name')(name), make('Value')(value)])\n return {\n attributes: [...attributes, make('Method')('post')],\n children: [\n ...children,\n hidden(FALLBACK_FIELD, encoded),\n ...(now.depth === 0 ? [] : [hidden(FALLBACK_DEPTH_FIELD, String(now.depth))]),\n ],\n }\n }\n\n const textHole =\n (name: string) =>\n (given: unknown, fixed: Record<string, unknown> = {}): unknown => {\n const make = source[name] as (toMessage: (value: string) => unknown) => object\n if (!isMember(given)) return make(given as (value: string) => unknown)\n const hole = holeOf(given, fixed)\n if (hole.length !== 1) {\n throw new Error(\n `Resume.builder: ${name}(${tagOf(given)}) leaves ${hole.length === 0 ? 'no field' : hole.join(', ')} for the event to fill; it must leave one string field`,\n )\n }\n const [field] = hole as [string]\n const made = make(value => given({ ...fixed, [field]: value }))\n const template = placeholder(() => given({ ...fixed, [field]: '' }))\n // A field whose checks refuse the empty placeholder cannot be written\n // into the page as data; left unrecorded, the handler is marked as one\n // the page cannot name, and the live page answers it.\n if (template !== undefined) holes.set(made, { template, hole })\n return made\n }\n\n const keyHole =\n (name: string) =>\n (given: unknown, fixed: Record<string, unknown> = {}): unknown => {\n const make = source[name] as (\n toMessage: (key: string, modifiers: KeyboardModifiers) => unknown,\n ) => object\n if (!isMember(given)) {\n return make(given as (key: string, modifiers: KeyboardModifiers) => unknown)\n }\n const hole = holeOf(given, fixed)\n if (hole.length !== 2 || !hole.includes('key') || !hole.includes('modifiers')) {\n throw new Error(\n `Resume.builder: ${name}(${tagOf(given)}) leaves ${hole.join(', ') || 'no field'} for the event to fill; it must leave exactly key and modifiers`,\n )\n }\n const made = make((key, modifiers) => given({ ...fixed, key, modifiers }))\n const template = placeholder(() => given({ ...fixed, key: '', modifiers: NO_MODIFIERS }))\n if (template !== undefined) holes.set(made, { template, hole })\n return made\n }\n\n /**\n * `h.submodel` with the child's root stamped with its slot, while the\n * server renders: a boundary a tool can find, which the browser's first\n * patch removes as it removes the markers.\n */\n const submodel = (config: {\n readonly slotId: string\n readonly view: unknown\n readonly toParentMessage: (message: unknown) => unknown\n }): unknown => {\n const original = source.submodel as (config: unknown) => unknown\n const now = current()\n if (now?.mode !== 'collect' && now?.mode !== 'replay') return original(config)\n const view = config.view as (...args: ReadonlyArray<unknown>) => unknown\n const stamped = (...args: ReadonlyArray<unknown>) => {\n // A binding inside dispatches the parent's Message, as Foldkit's own\n // handlers do, so it is recorded lifted through this placement.\n const outer = { wrap: now.wrap, depth: now.depth }\n now.wrap = message => outer.wrap(config.toParentMessage(message))\n now.depth = outer.depth + 1\n let out: { data?: { attrs?: Record<string, unknown> } } | null\n try {\n out = view(...args) as typeof out\n } finally {\n now.wrap = outer.wrap\n now.depth = outer.depth\n }\n if (out !== null && typeof out === 'object' && out.data !== undefined) {\n out.data.attrs = { ...out.data.attrs, [SLOT_ATTRIBUTE]: config.slotId }\n }\n return out\n }\n // The view carries Foldkit's Submodel brand as an own property; keep it.\n return original({ ...config, view: Object.assign(stamped, view) })\n }\n\n const wrapped: Record<string, unknown> = {}\n for (const [name, value] of Object.entries(source)) {\n if (name === 'submodel') wrapped[name] = submodel\n else if (name === 'OnInput' || name === 'OnChange') wrapped[name] = textHole(name)\n else if (name === 'OnKeyDown' || name === 'OnKeyUp') wrapped[name] = keyHole(name)\n else if (name === 'keyed') {\n const keyed = value as (tag: string) => (key: PropertyKey, ...rest: Array<unknown>) => unknown\n wrapped[name] =\n (tag: string) =>\n (key: PropertyKey, attributes: ReadonlyArray<Item> = [], ...rest: Array<unknown>) => {\n const posted = fallback(tag, attributes, rest[0])\n return keyed(tag)(key, mark(tag, posted.attributes), posted.children, ...rest.slice(1))\n }\n } else if (/^[a-z]/.test(name) && typeof value === 'function') {\n const element = value as (\n attributes: ReadonlyArray<unknown>,\n ...rest: Array<unknown>\n ) => unknown\n wrapped[name] = (attributes: ReadonlyArray<Item>, ...rest: Array<unknown>) => {\n const posted = fallback(name, attributes, rest[0])\n return element(mark(name, posted.attributes), posted.children, ...rest.slice(1))\n }\n } else wrapped[name] = value\n }\n builders.set(h, wrapped)\n return wrapped as unknown as ResumableBuilder<MessageOf<Builder>>\n}\n\n/**\n * A view or renderer written against the resumable builder, as one that takes\n * the builder it is given: `Surface.rootView(Page, params, Resume.view(render))`,\n * `SurfaceView.define`, or an application's own view.\n */\nexport const view =\n <Model, Builder extends AnyBuilder, Out>(\n render: (model: Model, rh: ResumableBuilder<MessageOf<Builder>>) => Out,\n ) =>\n (model: Model, h: Builder): Out =>\n render(model, builder(h))\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAoBA,MAAa,oBAAoB;;;;;;AAOjC,MAAa,WAA6C;CACxD,SAAS;CACT,eAAe;CACf,aAAa;CACb,WAAW;CACX,cAAc;CACd,cAAc;CACd,aAAa;CACb,YAAY;CACZ,aAAa;CACb,eAAe;CACf,gBAAgB;CAChB,eAAe;CACf,aAAa;CACb,WAAW;CACX,yBAAyB;CACzB,eAAe;CACf,6BAA6B;CAC7B,gBAAgB;CAChB,SAAS;CACT,uBAAuB;CACvB,YAAY;CACZ,SAAS;CACT,QAAQ;CACR,cAAc;CACd,cAAc;CACd,SAAS;CACT,UAAU;CACV,eAAe;CACf,6BAA6B;CAC7B,cAAc;CACd,UAAU;CACV,SAAS;CACT,UAAU;CACV,SAAS;CACT,QAAQ;CACR,OAAO;CACP,SAAS;CACT,uBAAuB;CACvB,YAAY;CACZ,WAAW;CACX,UAAU;CACV,wBAAwB;CACxB,UAAU;CACV,eAAe;CACf,aAAa;CACb,QAAQ;CACR,WAAW;CACX,aAAa;CACb,aAAa;CACb,YAAY;CACZ,QAAQ;CACR,aAAa;CACb,cAAc;CACd,YAAY;CACZ,aAAa;CACb,eAAe;CACf,kBAAkB;CAClB,gBAAgB;CAChB,sBAAsB;CACtB,iBAAiB;CACjB,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,SAAS;CACT,SAAS;CACT,cAAc;CACd,gBAAgB;CAChB,UA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