foldkit-ssr 0.11.0 → 0.13.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 (63) hide show
  1. package/README.md +656 -83
  2. package/dist/{client-qmdYY-Eb.d.ts → client-cumvT9XN.d.ts} +10 -7
  3. package/dist/client-cumvT9XN.d.ts.map +1 -0
  4. package/dist/client.d.ts +6 -5
  5. package/dist/client.js +64 -16
  6. package/dist/client.js.map +1 -1
  7. package/dist/context.d.ts +1 -1
  8. package/dist/context.js.map +1 -1
  9. package/dist/diagnostics.d.ts +2 -2
  10. package/dist/diagnostics.js +7 -1
  11. package/dist/diagnostics.js.map +1 -1
  12. package/dist/handoff.d.ts +23 -0
  13. package/dist/handoff.d.ts.map +1 -0
  14. package/dist/handoff.js +15 -0
  15. package/dist/handoff.js.map +1 -0
  16. package/dist/index.d.ts +66 -26
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +282 -56
  19. package/dist/index.js.map +1 -1
  20. package/dist/keep.d.ts +3 -1
  21. package/dist/keep.d.ts.map +1 -1
  22. package/dist/keep.js +21 -6
  23. package/dist/keep.js.map +1 -1
  24. package/dist/{listen-DaUPRKVR.d.ts → listen-7HzKBhqU.d.ts} +11 -2
  25. package/dist/{listen-DaUPRKVR.d.ts.map → listen-7HzKBhqU.d.ts.map} +1 -1
  26. package/dist/listen.d.ts +2 -2
  27. package/dist/listen.js +17 -7
  28. package/dist/listen.js.map +1 -1
  29. package/dist/loader.d.ts +13 -0
  30. package/dist/loader.d.ts.map +1 -0
  31. package/dist/loader.js +156 -0
  32. package/dist/loader.js.map +1 -0
  33. package/dist/marks-CX15BwOw.d.ts +39 -0
  34. package/dist/marks-CX15BwOw.d.ts.map +1 -0
  35. package/dist/marks.d.ts +2 -0
  36. package/dist/marks.js +41 -0
  37. package/dist/marks.js.map +1 -0
  38. package/dist/{resumable-BPN_qQHU.d.ts → resumable-BV9_OKxr.d.ts} +7 -10
  39. package/dist/resumable-BV9_OKxr.d.ts.map +1 -0
  40. package/dist/resumable.d.ts +2 -1
  41. package/dist/resumable.js +16 -19
  42. package/dist/resumable.js.map +1 -1
  43. package/dist/runtimeChunk.d.ts +13 -0
  44. package/dist/runtimeChunk.d.ts.map +1 -0
  45. package/dist/runtimeChunk.js +36 -0
  46. package/dist/runtimeChunk.js.map +1 -0
  47. package/dist/runtimeUrl.d.ts +10 -0
  48. package/dist/runtimeUrl.d.ts.map +1 -0
  49. package/dist/runtimeUrl.js +13 -0
  50. package/dist/runtimeUrl.js.map +1 -0
  51. package/dist/{shared-CJN-m58Z.d.ts → shared-BuCOwm57.d.ts} +62 -20
  52. package/dist/shared-BuCOwm57.d.ts.map +1 -0
  53. package/dist/shared.d.ts +3 -2
  54. package/dist/shared.js +36 -13
  55. package/dist/shared.js.map +1 -1
  56. package/dist/vite.d.ts +19 -5
  57. package/dist/vite.d.ts.map +1 -1
  58. package/dist/vite.js +9 -2
  59. package/dist/vite.js.map +1 -1
  60. package/package.json +13 -8
  61. package/dist/client-qmdYY-Eb.d.ts.map +0 -1
  62. package/dist/resumable-BPN_qQHU.d.ts.map +0 -1
  63. package/dist/shared-CJN-m58Z.d.ts.map +0 -1
@@ -1,7 +1,5 @@
1
1
  import { Schema } from "effect";
2
2
  import { Attribute, HtmlBuilder, KeyboardModifiers } from "foldkit/html";
3
- /** The attribute prefix of an element's binding marker. */
4
- declare const BINDING_ATTRIBUTE = "data-foldkit-plus-on-";
5
3
  /**
6
4
  * The DOM event each of Foldkit's event attributes listens to, read from
7
5
  * Foldkit's own attribute table (0.163). `OnCustomEvent` names its event in
@@ -14,11 +12,6 @@ declare const UNNAMED_HANDLER = "*";
14
12
  declare const FALLBACK_FIELD = "foldkit-plus-message";
15
13
  /** The posted field that says how many placement wrappers the form's fields sit under. */
16
14
  declare const FALLBACK_DEPTH_FIELD = "foldkit-plus-depth";
17
- /**
18
- * The attribute on a field whose typing before boot is kept (`KeepTyped`),
19
- * naming the binding whose Message replays it.
20
- */
21
- declare const KEEP_ATTRIBUTE = "data-foldkit-plus-keep";
22
15
  /** The value of a `KeepTyped` marker no resumable element took, while the server renders. */
23
16
  declare const UNPLACED_KEEP = "?";
24
17
  /** The attribute on a placement's root naming its slot, while the server renders. */
@@ -88,7 +81,11 @@ type ResumableBuilder<Message> = Omit<HtmlBuilder<Message>, 'OnInput' | 'OnChang
88
81
  * Keeps what is typed into this field before the runtime starts: the
89
82
  * browser replays it as the field's `OnInput` Message (else its
90
83
  * `OnChange`), given in the hole form, and keeps the caret. The field must
91
- * be an `input` that takes text, a `textarea` or a `select`.
84
+ * be an `input` that takes text, a `textarea` or a `select`; or a
85
+ * checkbox or radio, whose ticking replays its `OnChange` (else `OnInput`,
86
+ * else `OnClick`) Message, in either form. On a plan whose `start` is not
87
+ * `'now'`, a field with such a binding and no `KeepTyped` is refused
88
+ * (`UnkeptField`).
92
89
  */
93
90
  readonly KeepTyped: () => Tagged<Message, 'Attribute'>;
94
91
  };
@@ -103,5 +100,5 @@ declare const builder: <Builder extends AnyBuilder>(h: Builder) => ResumableBuil
103
100
  * `SurfaceView.define`, or an application's own view.
104
101
  */
105
102
  declare const view: <Model, Builder extends AnyBuilder, Out>(render: (model: Model, rh: ResumableBuilder<MessageOf<Builder>>) => Out) => (model: Model, h: Builder) => Out;
106
- export { FALLBACK_FIELD as a, KeyHole as c, SLOT_ATTRIBUTE as d, TextHole as f, view as g, builder as h, FALLBACK_DEPTH_FIELD as i, MessageOf as l, UNPLACED_KEEP as m, BINDING_ATTRIBUTE as n, Invalid as o, UNNAMED_HANDLER as p, EVENT_OF as r, KEEP_ATTRIBUTE as s, AnyBuilder as t, ResumableBuilder as u };
107
- //# sourceMappingURL=resumable-BPN_qQHU.d.ts.map
103
+ export { Invalid as a, ResumableBuilder as c, UNNAMED_HANDLER as d, UNPLACED_KEEP as f, FALLBACK_FIELD as i, SLOT_ATTRIBUTE as l, view as m, EVENT_OF as n, KeyHole as o, builder as p, FALLBACK_DEPTH_FIEL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AAM;;;KAIlC,UAAU,WAAW;WACtB,UAAU,eAAe,YAAY,MAAM;IAElD;;;;;;;;KAUQ,iBAAiB,WAAW,KACtC,YAAY;WAGH,SAAS,SAAS;WAClB,UAAU,SAAS;WACnB,WAAW,QAAQ;WACnB,SAAS,QAAQ;;;;;;;;;;;WAWjB,iBAAiB,OAAO;;;;;;cAkEtB,UAAW,gBAAgB,YAAU,GAC7C,YACF,iBAAiB,UAAU;;;;;;cAqRjB,OACV,OAAO,gBAAgB,YAAY,KAAG,SAC5B,OAAO,OAAO,IAAI,iBAAiB,UAAU,cAAc,SAAG,OAEjE,OAAK,GAAK,YAAU"}
@@ -1,2 +1,3 @@
1
- import { a as FALLBACK_FIELD, c as KeyHole, d as SLOT_ATTRIBUTE, f as TextHole, g as view, h as builder, i as FALLBACK_DEPTH_FIELD, l as MessageOf, m as UNPLACED_KEEP, n as BINDING_ATTRIBUTE, o as Invalid, p as UNNAMED_HANDLER, r as EVENT_OF, s as KEEP_ATTRIBUTE, t as AnyBuilder, u as ResumableBuilder } from "./resumable-BPN_qQHU.js";
1
+ import { r as KEEP_ATTRIBUTE, t as BINDING_ATTRIBUTE } from "./marks-CX15BwOw.js";
2
+ import { a as Invalid, c as ResumableBuilder, d as UNNAMED_HANDLER, f as UNPLACED_KEEP, i as FALLBACK_FIELD, l as SLOT_ATTRIBUTE, m as view, n as EVENT_OF, o as KeyHole, p as builder, r as FALLBACK_DEPTH_FIELD, s as MessageOf, t as AnyBuilder, u as TextHole } from "./resumable-BV9_OKxr.js";
2
3
  export { AnyBuilder, BINDING_ATTRIBUTE, EVENT_OF, FALLBACK_DEPTH_FIELD, FALLBACK_FIELD, Invalid, KEEP_ATTRIBUTE, KeyHole, MessageOf, ResumableBuilder, SLOT_ATTRIBUTE, TextHole, UNNAMED_HANDLER, UNPLACED_KEEP, builder, view };
package/dist/resumable.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { current } from "./context.js";
2
- import { Schema, SchemaAST } from "effect";
2
+ import { BINDING_ATTRIBUTE, KEEP_ATTRIBUTE } from "./marks.js";
3
+ import { Match, Schema, SchemaAST } from "effect";
3
4
  // src/resumable.ts
4
5
  /**
5
6
  * The resumable builder: the application's `h`, whose event attributes say, in
@@ -16,8 +17,6 @@ import { Schema, SchemaAST } from "effect";
16
17
  * In the browser the builder marks nothing: it is the application's `h`, with
17
18
  * the hole forms turned into the closures Foldkit expects.
18
19
  */
19
- /** The attribute prefix of an element's binding marker. */
20
- const BINDING_ATTRIBUTE = "data-foldkit-plus-on-";
21
20
  /**
22
21
  * The DOM event each of Foldkit's event attributes listens to, read from
23
22
  * Foldkit's own attribute table (0.163). `OnCustomEvent` names its event in
@@ -124,20 +123,13 @@ const UNNAMED_HANDLER = "*";
124
123
  const FALLBACK_FIELD = "foldkit-plus-message";
125
124
  /** The posted field that says how many placement wrappers the form's fields sit under. */
126
125
  const FALLBACK_DEPTH_FIELD = "foldkit-plus-depth";
127
- /**
128
- * The attribute on a field whose typing before boot is kept (`KeepTyped`),
129
- * naming the binding whose Message replays it.
130
- */
131
- const KEEP_ATTRIBUTE = "data-foldkit-plus-keep";
132
126
  /** The value of a `KeepTyped` marker no resumable element took, while the server renders. */
133
127
  const UNPLACED_KEEP = "?";
134
128
  /**
135
- * The `input` types whose value is not something typed, so `KeepTyped` has
136
- * nothing to keep on them.
129
+ * The `input` types that hold nothing a person types or ticks, so
130
+ * `KeepTyped` has nothing to keep on them.
137
131
  */
138
132
  const UNTYPED_INPUTS = /* @__PURE__ */ new Set([
139
- "checkbox",
140
- "radio",
141
133
  "file",
142
134
  "hidden",
143
135
  "button",
@@ -166,6 +158,7 @@ const NO_MODIFIERS = {
166
158
  /** Each hole-form attribute, with its Message filled by a placeholder and the fields the event fills. */
167
159
  const holes = /* @__PURE__ */ new WeakMap();
168
160
  const isAttribute = (item) => "_tag" in item;
161
+ const eventOf = Match.type().pipe(Match.tag("OnCustomEvent", (custom) => custom.name), Match.orElse((other) => EVENT_OF[other._tag]));
169
162
  const builders = /* @__PURE__ */ new WeakMap();
170
163
  /** Each attribute `KeepTyped` made: a request to the element it is given, never written as it is. */
171
164
  const keeps = /* @__PURE__ */ new WeakSet();
@@ -196,9 +189,10 @@ const builder = (h) => {
196
189
  const element = id === void 0 ? tag : `${tag}#${id.value}`;
197
190
  const tokens = /* @__PURE__ */ new Map();
198
191
  const typed = /* @__PURE__ */ new Map();
192
+ const named = /* @__PURE__ */ new Map();
199
193
  for (const item of attributes) {
200
194
  if (!isAttribute(item)) continue;
201
- const event = item._tag === "OnCustomEvent" ? item.name : EVENT_OF[item._tag];
195
+ const event = eventOf(item);
202
196
  if (event === void 0) continue;
203
197
  if (now.mode === "collect" && now.region !== void 0) now.inStatic.push({
204
198
  region: now.region,
@@ -231,20 +225,23 @@ const builder = (h) => {
231
225
  list.push("*");
232
226
  } else {
233
227
  if (binding.hole !== void 0 && !typed.has(binding.attribute)) typed.set(binding.attribute, now.bindings.length);
228
+ if (!named.has(binding.attribute)) named.set(binding.attribute, now.bindings.length);
234
229
  list.push(String(now.bindings.length));
235
230
  now.bindings.push(binding);
236
231
  }
237
232
  }
238
233
  const markers = [...tokens].map(([event, list]) => attribute(`${BINDING_ATTRIBUTE}${event}`, list.join(" ")));
234
+ const type = attributes.find((item) => isAttribute(item) && item._tag === "Type")?.value.toLowerCase();
235
+ const checkable = tag === "input" && (type === "checkbox" || type === "radio");
236
+ const field = tag === "textarea" || tag === "select" || tag === "input" && (type === void 0 || !UNTYPED_INPUTS.has(type));
237
+ const ordinal = checkable ? named.get("OnChange") ?? named.get("OnInput") ?? named.get("OnClick") : typed.get("OnInput") ?? typed.get("OnChange");
239
238
  if (kept) {
240
- const ordinal = typed.get("OnInput") ?? typed.get("OnChange");
241
- const type = attributes.find((item) => isAttribute(item) && item._tag === "Type")?.value;
242
- if (!(tag === "textarea" || tag === "select" || tag === "input" && (type === void 0 || !UNTYPED_INPUTS.has(type.toLowerCase())))) {
243
- if (now.mode === "collect") now.unkeepable.push(`KeepTyped on ${type === void 0 ? element : `${element} of type ${type}`}, which holds no typed value: keep an input that takes text, a textarea or a select`);
239
+ if (!field) {
240
+ if (now.mode === "collect") now.unkeepable.push(`KeepTyped on ${type === void 0 ? element : `${element} of type ${type}`}, which holds nothing typed or ticked: keep an input that takes text, a checkbox, a radio, a textarea or a select`);
244
241
  } else if (ordinal === void 0) {
245
- if (now.mode === "collect") now.unkeepable.push(`KeepTyped on ${element}, which has no OnInput or OnChange given a Message member, so nothing names the Message its typing replays as`);
242
+ if (now.mode === "collect") now.unkeepable.push(`KeepTyped on ${element}, which has no ${checkable ? "OnChange, OnInput or OnClick naming a Message" : "OnInput or OnChange given a Message member"}, so nothing names the Message its typing replays as`);
246
243
  } else markers.push(attribute(KEEP_ATTRIBUTE, String(ordinal)));
247
- }
244
+ } else if (field && ordinal !== void 0 && now.mode === "collect") now.unkept.push(element);
248
245
  return markers.length === 0 ? attributes : [...attributes, ...markers];
249
246
  };
250
247
  /**
@@ -1 +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/**\n * The attribute on a field whose typing before boot is kept (`KeepTyped`),\n * naming the binding whose Message replays it.\n */\nexport const KEEP_ATTRIBUTE = 'data-foldkit-plus-keep'\n\n/** The value of a `KeepTyped` marker no resumable element took, while the server renders. */\nexport const UNPLACED_KEEP = '?'\n\n/**\n * The `input` types whose value is not something typed, so `KeepTyped` has\n * nothing to keep on them.\n */\nconst UNTYPED_INPUTS: ReadonlySet<string> = new Set([\n 'checkbox',\n 'radio',\n 'file',\n 'hidden',\n 'button',\n 'submit',\n 'reset',\n 'image',\n])\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/**\n * Foldkit's attribute of one tag, as its own builder returns it, so an\n * element that refuses some attributes (a `textarea`, `InnerHTML`) takes it.\n */\ntype Tagged<Message, Tag extends string> = Extract<Attribute<Message>, { readonly _tag: Tag }>\n\n/** `OnInput` and `OnChange`: a closure, or a member whose one string field the event fills. */\nexport interface TextHole<Message, Tag extends string> {\n (toMessage: (value: string) => Message): Tagged<Message, Tag>\n <M extends AnyMemberSchema, const Fixed extends Fixable<M> = {}>(\n member: M & ProducesMessage<M, Message> & TextHoleCheck<M, Fixed>,\n fixed?: Fixed,\n ): Tagged<Message, Tag>\n}\n\n/** `OnKeyDown` and `OnKeyUp`: a closure, or a member whose `key` and `modifiers` the event fills. */\nexport interface KeyHole<Message, Tag extends string> {\n (toMessage: (key: string, modifiers: KeyboardModifiers) => Message): Tagged<Message, Tag>\n <M extends AnyMemberSchema, const Fixed extends Fixable<M> = {}>(\n member: M & ProducesMessage<M, Message> & KeyHoleCheck<M, Fixed>,\n fixed?: Fixed,\n ): Tagged<Message, Tag>\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, 'OnInput'>\n readonly OnChange: TextHole<Message, 'OnChange'>\n readonly OnKeyDown: KeyHole<Message, 'OnKeyDown'>\n readonly OnKeyUp: KeyHole<Message, 'OnKeyUp'>\n /**\n * Keeps what is typed into this field before the runtime starts: the\n * browser replays it as the field's `OnInput` Message (else its\n * `OnChange`), given in the hole form, and keeps the caret. The field must\n * be an `input` that takes text, a `textarea` or a `select`.\n */\n readonly KeepTyped: () => Tagged<Message, 'Attribute'>\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/** Each attribute `KeepTyped` made: a request to the element it is given, never written as it is. */\nconst keeps = new WeakSet<object>()\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, given: ReadonlyArray<Item>): ReadonlyArray<unknown> => {\n const kept = given.some(item => keeps.has(item))\n const attributes = kept ? given.filter(item => !keeps.has(item)) : given\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 // The ordinal of the element's hole-form `OnInput` and `OnChange`, which `KeepTyped` replays.\n const typed = new Map<string, number>()\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 if (binding.hole !== undefined && !typed.has(binding.attribute)) {\n typed.set(binding.attribute, now.bindings.length)\n }\n list.push(String(now.bindings.length))\n now.bindings.push(binding)\n }\n }\n const markers = [...tokens].map(([event, list]) =>\n attribute(`${BINDING_ATTRIBUTE}${event}`, list.join(' ')),\n )\n if (kept) {\n const ordinal = typed.get('OnInput') ?? typed.get('OnChange')\n const type = attributes.find(\n (item): item is Extract<Attribute<unknown>, { readonly _tag: 'Type' }> =>\n isAttribute(item) && item._tag === 'Type',\n )?.value\n const field =\n tag === 'textarea' ||\n tag === 'select' ||\n (tag === 'input' && (type === undefined || !UNTYPED_INPUTS.has(type.toLowerCase())))\n if (!field) {\n if (now.mode === 'collect') {\n now.unkeepable.push(\n `KeepTyped on ${type === undefined ? element : `${element} of type ${type}`}, which holds no typed value: keep an input that takes text, a textarea or a select`,\n )\n }\n } else if (ordinal === undefined) {\n if (now.mode === 'collect') {\n now.unkeepable.push(\n `KeepTyped on ${element}, which has no OnInput or OnChange given a Message member, so nothing names the Message its typing replays as`,\n )\n }\n } else markers.push(attribute(KEEP_ATTRIBUTE, String(ordinal)))\n }\n return markers.length === 0 ? attributes : [...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. A form given its own `Method` is\n * the view's, left as drawn: a search is a GET of the address the URL\n * mirror reads, and posts no Message.\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 const method = attributes.some(item => isAttribute(item) && item._tag === 'Method')\n if (submit === undefined || method || !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 takes off\n * as the page boots, with 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 wrapped.KeepTyped = () => {\n // Written so during the server's first render: an element this builder\n // builds takes it out, so one left in the markup is on an element `h`\n // built, which nothing marks, and is refused there, naming the element.\n const made = attribute(KEEP_ATTRIBUTE, current()?.mode === 'collect' ? UNPLACED_KEEP : '')\n keeps.add(made as object)\n return made\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,aA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iC,GAAG,SAAyB;GAC5E,MAAM,SAAS,SAAS,MAAM,YAAY,KAAK,EAAE;GACjD,OAAO,QAAQ,KAAK,MAAM,OAAO,UAAU,GAAG,OAAO,UAAU,GAAG,KAAK,MAAM,CAAC,CAAC;EACjF;CACF,OAAO,QAAQ,QAAQ;CAEzB,QAAQ,kBAAkB;EAIxB,MAAM,OAAO,UAAU,gBAAgB,QAAQ,CAAC,EAAE,SAAS,YAAA,MAA4B,EAAE;EACzF,MAAM,IAAI,IAAc;EACxB,OAAO;CACT;CACA,SAAS,IAAI,GAAG,OAAO;CACvB,OAAO;AACT;;;;;;AAOA,MAAa,QAET,YAED,OAAc,MACb,OAAO,OAAO,QAAQ,CAAC,CAAC"}
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 { Match, Schema, SchemaAST } from 'effect'\nimport type { Attribute, ChildAttribute, HtmlBuilder, KeyboardModifiers } from 'foldkit/html'\nimport { current, type Binding } from './context.js'\nimport { BINDING_ATTRIBUTE, KEEP_ATTRIBUTE } from './marks.js'\n\nexport { BINDING_ATTRIBUTE, KEEP_ATTRIBUTE } from './marks.js'\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 value of a `KeepTyped` marker no resumable element took, while the server renders. */\nexport const UNPLACED_KEEP = '?'\n\n/**\n * The `input` types that hold nothing a person types or ticks, so\n * `KeepTyped` has nothing to keep on them.\n */\nconst UNTYPED_INPUTS: ReadonlySet<string> = new Set([\n 'file',\n 'hidden',\n 'button',\n 'submit',\n 'reset',\n 'image',\n])\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/**\n * Foldkit's attribute of one tag, as its own builder returns it, so an\n * element that refuses some attributes (a `textarea`, `InnerHTML`) takes it.\n */\ntype Tagged<Message, Tag extends string> = Extract<Attribute<Message>, { readonly _tag: Tag }>\n\n/** `OnInput` and `OnChange`: a closure, or a member whose one string field the event fills. */\nexport interface TextHole<Message, Tag extends string> {\n (toMessage: (value: string) => Message): Tagged<Message, Tag>\n <M extends AnyMemberSchema, const Fixed extends Fixable<M> = {}>(\n member: M & ProducesMessage<M, Message> & TextHoleCheck<M, Fixed>,\n fixed?: Fixed,\n ): Tagged<Message, Tag>\n}\n\n/** `OnKeyDown` and `OnKeyUp`: a closure, or a member whose `key` and `modifiers` the event fills. */\nexport interface KeyHole<Message, Tag extends string> {\n (toMessage: (key: string, modifiers: KeyboardModifiers) => Message): Tagged<Message, Tag>\n <M extends AnyMemberSchema, const Fixed extends Fixable<M> = {}>(\n member: M & ProducesMessage<M, Message> & KeyHoleCheck<M, Fixed>,\n fixed?: Fixed,\n ): Tagged<Message, Tag>\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, 'OnInput'>\n readonly OnChange: TextHole<Message, 'OnChange'>\n readonly OnKeyDown: KeyHole<Message, 'OnKeyDown'>\n readonly OnKeyUp: KeyHole<Message, 'OnKeyUp'>\n /**\n * Keeps what is typed into this field before the runtime starts: the\n * browser replays it as the field's `OnInput` Message (else its\n * `OnChange`), given in the hole form, and keeps the caret. The field must\n * be an `input` that takes text, a `textarea` or a `select`; or a\n * checkbox or radio, whose ticking replays its `OnChange` (else `OnInput`,\n * else `OnClick`) Message, in either form. On a plan whose `start` is not\n * `'now'`, a field with such a binding and no `KeepTyped` is refused\n * (`UnkeptField`).\n */\n readonly KeepTyped: () => Tagged<Message, 'Attribute'>\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\n// Built once: a matcher made in `mark` would be rebuilt for every attribute of every element.\nconst eventOf = Match.type<Attribute<unknown>>().pipe(\n Match.tag('OnCustomEvent', custom => custom.name),\n Match.orElse((other): string | undefined => EVENT_OF[other._tag]),\n)\n\nconst builders = new WeakMap<object, unknown>()\n\n/** Each attribute `KeepTyped` made: a request to the element it is given, never written as it is. */\nconst keeps = new WeakSet<object>()\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, given: ReadonlyArray<Item>): ReadonlyArray<unknown> => {\n const kept = given.some(item => keeps.has(item))\n const attributes = kept ? given.filter(item => !keeps.has(item)) : given\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 // The ordinal of the element's hole-form `OnInput` and `OnChange`, which\n // `KeepTyped` replays for a typed value, and of each attribute's first\n // binding: a checkbox or radio replays its `OnChange`, `OnInput` or\n // `OnClick` in either form, since what it holds is `checked`, which no\n // hole carries.\n const typed = new Map<string, number>()\n const named = new Map<string, number>()\n for (const item of attributes) {\n if (!isAttribute(item)) continue\n const event = eventOf(item)\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 if (binding.hole !== undefined && !typed.has(binding.attribute)) {\n typed.set(binding.attribute, now.bindings.length)\n }\n if (!named.has(binding.attribute)) named.set(binding.attribute, now.bindings.length)\n list.push(String(now.bindings.length))\n now.bindings.push(binding)\n }\n }\n const markers = [...tokens].map(([event, list]) =>\n attribute(`${BINDING_ATTRIBUTE}${event}`, list.join(' ')),\n )\n const type = attributes\n .find(\n (item): item is Extract<Attribute<unknown>, { readonly _tag: 'Type' }> =>\n isAttribute(item) && item._tag === 'Type',\n )\n ?.value.toLowerCase()\n const checkable = tag === 'input' && (type === 'checkbox' || type === 'radio')\n const field =\n tag === 'textarea' ||\n tag === 'select' ||\n (tag === 'input' && (type === undefined || !UNTYPED_INPUTS.has(type)))\n const ordinal = checkable\n ? (named.get('OnChange') ?? named.get('OnInput') ?? named.get('OnClick'))\n : (typed.get('OnInput') ?? typed.get('OnChange'))\n if (kept) {\n if (!field) {\n if (now.mode === 'collect') {\n now.unkeepable.push(\n `KeepTyped on ${type === undefined ? element : `${element} of type ${type}`}, which holds nothing typed or ticked: keep an input that takes text, a checkbox, a radio, a textarea or a select`,\n )\n }\n } else if (ordinal === undefined) {\n if (now.mode === 'collect') {\n now.unkeepable.push(\n `KeepTyped on ${element}, which has no ${checkable ? 'OnChange, OnInput or OnClick naming a Message' : 'OnInput or OnChange given a Message member'}, so nothing names the Message its typing replays as`,\n )\n }\n } else markers.push(attribute(KEEP_ATTRIBUTE, String(ordinal)))\n } else if (field && ordinal !== undefined && now.mode === 'collect') {\n // Refused by the server for a plan that does not start now: what is\n // typed before such a page boots would be lost at its first render.\n now.unkept.push(element)\n }\n return markers.length === 0 ? attributes : [...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. A form given its own `Method` is\n * the view's, left as drawn: a search is a GET of the address the URL\n * mirror reads, and posts no Message.\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 const method = attributes.some(item => isAttribute(item) && item._tag === 'Method')\n if (submit === undefined || method || !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 takes off\n * as the page boots, with 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 wrapped.KeepTyped = () => {\n // Written so during the server's first render: an element this builder\n // builds takes it out, so one left in the markup is on an element `h`\n // built, which nothing marks, and is refused there, naming the element.\n const made = attribute(KEEP_ATTRIBUTE, current()?.mode === 'collect' ? UNPLACED_KEEP : '')\n keeps.add(made as object)\n return made\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":";;;;;;;;;;;;;;;;;;;;;;;;AA2BA,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,WA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;;AAOA,MAAa,QAET,YAED,OAAc,MACb,OAAO,OAAO,QAAQ,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { Plugin } from "vite";
2
+ /**
3
+ * Emits `entry`, the module the loader's `runtime` imports, as a chunk of
4
+ * the client build, and writes that chunk's address into the loader. The
5
+ * chunk is the one the dynamic import loads: the bundler gives one module
6
+ * one chunk. A development server and a server build leave the loader
7
+ * without an address, and it fetches the chunk as it runs it.
8
+ */
9
+ export declare const runtimeChunk: (options: {
10
+ /** The runtime's module, root-relative (`/src/client/entry.ts`), as the loader imports it. */
11
+ readonly entry: string;
12
+ }) => Plugin;
13
+ //# sourceMappingURL=runtimeChunk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtimeChunk.d.ts","names":[],"sources":["../src/runtimeChunk.ts"],"mappings":";;;;;;;;qBAkBa,eAAY;;WAEd;MACP"}
@@ -0,0 +1,36 @@
1
+ // src/runtimeChunk.ts
2
+ /** `runtimeUrl`'s placeholder, as `runtimeUrl.ts` gives it, in either quote. */
3
+ const PLACEHOLDER = /(\bruntimeUrl(?:\s*:\s*string)?\s*=\s*)(['"])foldkit-ssr:runtime-url\2/;
4
+ /**
5
+ * Emits `entry`, the module the loader's `runtime` imports, as a chunk of
6
+ * the client build, and writes that chunk's address into the loader. The
7
+ * chunk is the one the dynamic import loads: the bundler gives one module
8
+ * one chunk. A development server and a server build leave the loader
9
+ * without an address, and it fetches the chunk as it runs it.
10
+ */
11
+ const runtimeChunk = (options) => {
12
+ let reference;
13
+ return {
14
+ name: "foldkit-ssr:runtime-chunk",
15
+ apply: "build",
16
+ applyToEnvironment: (environment) => environment.name === "client",
17
+ async buildStart() {
18
+ const resolved = await this.resolve(options.entry);
19
+ if (resolved === null) throw new Error(`foldkit-ssr: runtimeChunk cannot resolve its entry ${options.entry}`);
20
+ reference = this.emitFile({
21
+ type: "chunk",
22
+ id: resolved.id
23
+ });
24
+ },
25
+ transform(code) {
26
+ if (reference === void 0 || !PLACEHOLDER.test(code)) return null;
27
+ return {
28
+ code: code.replace(PLACEHOLDER, `$1import.meta.ROLLUP_FILE_URL_${reference}`),
29
+ map: null
30
+ };
31
+ }
32
+ };
33
+ };
34
+ export { runtimeChunk };
35
+
36
+ //# sourceMappingURL=runtimeChunk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtimeChunk.js","names":[],"sources":["../src/runtimeChunk.ts"],"sourcesContent":["/**\n * `runtimeChunk`, from `foldkit-ssr/vite`: tells `foldkit-ssr/loader` where a\n * client build put the runtime's chunk, so the loader can fetch it without\n * running it. Kept apart from the static site's plugin, which imports the\n * server renderer, so a config can import this one by path.\n */\nimport type { Plugin } from 'vite'\n\n/** `runtimeUrl`'s placeholder, as `runtimeUrl.ts` gives it, in either quote. */\nconst PLACEHOLDER = /(\\bruntimeUrl(?:\\s*:\\s*string)?\\s*=\\s*)(['\"])foldkit-ssr:runtime-url\\2/\n\n/**\n * Emits `entry`, the module the loader's `runtime` imports, as a chunk of\n * the client build, and writes that chunk's address into the loader. The\n * chunk is the one the dynamic import loads: the bundler gives one module\n * one chunk. A development server and a server build leave the loader\n * without an address, and it fetches the chunk as it runs it.\n */\nexport const runtimeChunk = (options: {\n /** The runtime's module, root-relative (`/src/client/entry.ts`), as the loader imports it. */\n readonly entry: string\n}): Plugin => {\n let reference: string | undefined\n return {\n name: 'foldkit-ssr:runtime-chunk',\n apply: 'build',\n applyToEnvironment: environment => environment.name === 'client',\n async buildStart() {\n const resolved = await this.resolve(options.entry)\n if (resolved === null) {\n throw new Error(`foldkit-ssr: runtimeChunk cannot resolve its entry ${options.entry}`)\n }\n reference = this.emitFile({ type: 'chunk', id: resolved.id })\n },\n transform(code) {\n if (reference === undefined || !PLACEHOLDER.test(code)) return null\n return {\n code: code.replace(PLACEHOLDER, `$1import.meta.ROLLUP_FILE_URL_${reference}`),\n map: null,\n }\n },\n }\n}\n"],"mappings":";;AASA,MAAM,cAAc;;;;;;;;AASpB,MAAa,gBAAgB,YAGf;CACZ,IAAI;CACJ,OAAO;EACL,MAAM;EACN,OAAO;EACP,qBAAoB,gBAAe,YAAY,SAAS;EACxD,MAAM,aAAa;GACjB,MAAM,WAAW,MAAM,KAAK,QAAQ,QAAQ,KAAK;GACjD,IAAI,aAAa,MACf,MAAM,IAAI,MAAM,sDAAsD,QAAQ,OAAO;GAEvF,YAAY,KAAK,SAAS;IAAE,MAAM;IAAS,IAAI,SAAS;GAAG,CAAC;EAC9D;EACA,UAAU,MAAM;GACd,IAAI,cAAc,KAAA,KAAa,CAAC,YAAY,KAAK,IAAI,GAAG,OAAO;GAC/D,OAAO;IACL,MAAM,KAAK,QAAQ,aAAa,iCAAiC,WAAW;IAC5E,KAAK;GACP;EACF;CACF;AACF"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * The runtime chunk's built address, for `foldkit-ssr/loader` to fetch
3
+ * without running it. `runtimeChunk` from `foldkit-ssr/vite` replaces the
4
+ * string `runtimeUrl` is given in a client build with the address the
5
+ * bundler gives the chunk; anywhere else it stays `UNBUILT`, and the loader
6
+ * fetches nothing early. Imports nothing, as the loader must not.
7
+ */
8
+ export declare const UNBUILT = "foldkit-ssr:runtime-url";
9
+ export declare const runtimeUrl: string;
10
+ //# sourceMappingURL=runtimeUrl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtimeUrl.d.ts","names":[],"sources":["../src/runtimeUrl.ts"],"mappings":";;;;;;;qBAOa;qBAEA"}
@@ -0,0 +1,13 @@
1
+ // src/runtimeUrl.ts
2
+ /**
3
+ * The runtime chunk's built address, for `foldkit-ssr/loader` to fetch
4
+ * without running it. `runtimeChunk` from `foldkit-ssr/vite` replaces the
5
+ * string `runtimeUrl` is given in a client build with the address the
6
+ * bundler gives the chunk; anywhere else it stays `UNBUILT`, and the loader
7
+ * fetches nothing early. Imports nothing, as the loader must not.
8
+ */
9
+ const UNBUILT = "foldkit-ssr:runtime-url";
10
+ const runtimeUrl = "foldkit-ssr:runtime-url";
11
+ export { UNBUILT, runtimeUrl };
12
+
13
+ //# sourceMappingURL=runtimeUrl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtimeUrl.js","names":[],"sources":["../src/runtimeUrl.ts"],"sourcesContent":["/**\n * The runtime chunk's built address, for `foldkit-ssr/loader` to fetch\n * without running it. `runtimeChunk` from `foldkit-ssr/vite` replaces the\n * string `runtimeUrl` is given in a client build with the address the\n * bundler gives the chunk; anywhere else it stays `UNBUILT`, and the loader\n * fetches nothing early. Imports nothing, as the loader must not.\n */\nexport const UNBUILT = 'foldkit-ssr:runtime-url'\n\nexport const runtimeUrl: string = 'foldkit-ssr:runtime-url'\n"],"mappings":";;;;;;;;AAOA,MAAa,UAAU;AAEvB,MAAa,aAAqB"}
@@ -1,7 +1,7 @@
1
- import { n as DecodedBinding } from "./listen-DaUPRKVR.js";
1
+ import { n as DecodedBinding } from "./listen-7HzKBhqU.js";
2
2
  import { Cause, Effect, Layer, Option, Result, Schema, Stream } from "effect";
3
- import { ActiveSurface, Diagnostic, Metadata, ModelPlace, ReportDiagnostic, SurfaceSource, WritableProjection } from "foldkit-surface";
4
- import { Html, HtmlBuilder } from "foldkit/html";
3
+ import { ActiveSurface, Diagnostic, Metadata, ModelPlace, ModelRef, ReportDiagnostic, SurfaceSource, WritableProjection } from "foldkit-surface";
4
+ import { Attribute, ChildAttribute, Html, HtmlBuilder } from "foldkit/html";
5
5
  import { Runtime } from "foldkit";
6
6
  import { Ports } from "foldkit/port";
7
7
  /** A served page the browser contained instead of resuming: it stays in view, inert, and no runtime starts. */
@@ -46,8 +46,18 @@ interface CachedPageDiffers extends Diagnostic {
46
46
  readonly _tag: 'CachedPageDiffers';
47
47
  readonly url: string;
48
48
  }
49
+ /**
50
+ * A served page whose head markup (a plan's `meta`) was still in its body:
51
+ * the host's document renderer is not wrapped in `SSR.headed`, so link
52
+ * previews and crawlers, which read the served head, never saw it.
53
+ * `SSR.hydrate` removed it; the head gets it once the page runs.
54
+ */
55
+ interface HeadNotMoved extends Diagnostic {
56
+ readonly _tag: 'HeadNotMoved';
57
+ }
49
58
  /** Every diagnostic SSR reports. */
50
- type SsrDiagnostic = PageContained | StaticRegionMissing | BundleUnloaded | PageFailed | HandlerUnnamed | CachedPageDiffers;
59
+ type SsrDiagnostic = PageContained | StaticRegionMissing | BundleUnloaded | PageFailed | HandlerUnnamed | CachedPageDiffers | HeadNotMoved;
60
+ declare const headNotMoved: HeadNotMoved;
51
61
  declare const pageContained: (reason: PageContained['reason'], detail: string) => PageContained;
52
62
  declare const noBuildId: PageContained;
53
63
  /** The page's stamped build id, if it has one, is not the client's `client`. */
@@ -106,6 +116,8 @@ type RenderContext = {
106
116
  readonly unnamed: Array<UnnamedHandler>;
107
117
  /** Why each `KeepTyped` field met cannot be replayed, one line each. */
108
118
  readonly unkeepable: Array<string>;
119
+ /** Each field with a binding that names its typing and no `KeepTyped`. */
120
+ readonly unkept: Array<string>;
109
121
  } | {
110
122
  readonly mode: 'replay';
111
123
  readonly regions: ReadonlyMap<string, Region>;
@@ -127,18 +139,6 @@ declare const within: <A>(next: RenderContext, run: () => A) => A;
127
139
  declare const withContext: <Config extends {
128
140
  readonly view: (model: any, h: any) => unknown;
129
141
  }>(config: Config, next: RenderContext) => Config;
130
- /**
131
- * The attribute Foldkit's server stamps on an application's root, as
132
- * `foldkit/experimental/server` exports it. Written out here so a page can
133
- * find its root without that module; a test pins the two together.
134
- */
135
- declare const FOLDKIT_APP_ATTRIBUTE = "data-foldkit-app";
136
- /**
137
- * The attribute on the stamped root that carries a page's resume envelope.
138
- * Foldkit pairs its own handoff the same way: the build id rides on the root
139
- * beside the app stamp, and the client reads it before adopting anything.
140
- */
141
- declare const RESUME_ATTRIBUTE = "data-foldkit-plus-resume";
142
142
  /** The envelope format this package writes and reads. */
143
143
  declare const PROTOCOL = 1;
144
144
  /**
@@ -147,6 +147,14 @@ declare const PROTOCOL = 1;
147
147
  * follows it into the head before adopting the page.
148
148
  */
149
149
  declare const STYLES_MARKER = "foldkit-plus-styles";
150
+ /**
151
+ * The comments a dynamically served page's head markup (a plan's `meta`)
152
+ * sits between in the stamped root, until the host's `SSR.headed` moves it
153
+ * before `</head>`. Left in the body, `SSR.hydrate` removes it and reports
154
+ * `HeadNotMoved`.
155
+ */
156
+ declare const HEAD_MARKER = "foldkit-plus-head";
157
+ declare const HEAD_END_MARKER = "/foldkit-plus-head";
150
158
  /**
151
159
  * JSON for a script element: `<` is escaped so `</script>` in the data ends
152
160
  * nothing. U+2028 and U+2029 are escaped too: they are fine in JSON and break a
@@ -210,6 +218,15 @@ type PlanSurface<Model> = ActiveSurface<Model> | SurfaceSource<Model>;
210
218
  declare const projectionsOf: <Model>(source: PlanSurface<Model>, model: Model) => ReadonlyArray<{
211
219
  readonly metadata: Metadata;
212
220
  }>;
221
+ /**
222
+ * A Model path the browser can read again for itself, such as one a URL or
223
+ * cookie mirror owns, and how to copy the server's value for the coverage
224
+ * check. The envelope leaves the path out.
225
+ */
226
+ interface RestoredPlace<Model> {
227
+ readonly path: ReadonlyArray<string>;
228
+ readonly copy: (target: Model, source: Model) => Model;
229
+ }
213
230
  /**
214
231
  * Which part of the Model the browser owns, and what it starts from.
215
232
  *
@@ -225,6 +242,13 @@ interface ResumePlan<Model, Fields extends Schema.Struct.Fields, Commands = unkn
225
242
  readonly boot?: ((model: Model) => Commands) | undefined;
226
243
  /** Model paths allowed to start from the baseline, as each place's focus gives them. */
227
244
  readonly local: ReadonlyArray<ReadonlyArray<string>>;
245
+ /**
246
+ * Model paths the browser reads again before the first render, such as the
247
+ * fields a URL or cookie mirror owns. The envelope leaves them out.
248
+ */
249
+ readonly restored: ReadonlyArray<RestoredPlace<Model>>;
250
+ /** The browser's own values for `restored`, read before the first render; never run on the server. */
251
+ readonly restore?: ((model: Model) => Model) | undefined;
228
252
  /** The Surfaces the browser may activate, which the plan must cover. */
229
253
  readonly surfaces: ReadonlyArray<PlanSurface<Model>>;
230
254
  /** State another package owns, each captured and restored by that package. */
@@ -315,6 +339,8 @@ declare const plan: <Model, Fields extends Schema.Struct.Fields, Commands = unkn
315
339
  readonly baseline?: Model | undefined;
316
340
  readonly boot?: ((model: Model) => Commands) | undefined;
317
341
  readonly local?: ReadonlyArray<ModelPlace<NoInfer<Model>>> | undefined;
342
+ readonly restored?: ReadonlyArray<ModelRef<NoInfer<Model>, any>> | undefined;
343
+ readonly restore?: ((model: Model) => Model) | undefined;
318
344
  readonly surfaces?: ReadonlyArray<PlanSurface<Model>> | undefined;
319
345
  readonly parts?: ReadonlyArray<ResumePart<Model>> | undefined;
320
346
  readonly start?: Start | undefined;
@@ -378,6 +404,15 @@ declare const STATIC_ATTRIBUTE = "data-foldkit-plus-static";
378
404
  * belongs in a Surface, not here.
379
405
  */
380
406
  declare const staticRegion: (id: string, render: (ih: HtmlBuilder<never>) => Region) => Html;
407
+ /**
408
+ * A bundle of attributes, such as a Slot's, typed as binding no Message, for a
409
+ * static region's `ih` or any builder. A Slot's attributes are typed with the
410
+ * page's Message whatever its Mixins add, so the type cannot tell a Style from
411
+ * a handler; this checks when it is called instead, and throws on any handler
412
+ * (an `On…` attribute) or a Submodel's attribute, neither of which a static
413
+ * region could run.
414
+ */
415
+ declare const unbound: <Message>(attributes: ReadonlyArray<Attribute<Message> | ChildAttribute>) => ReadonlyArray<Attribute<never>>;
381
416
  /**
382
417
  * Whether the view call in progress is the server rendering a page, rather than the browser: true
383
418
  * through both of `render`'s passes, false while the browser resumes and outside any render. For a
@@ -418,9 +453,16 @@ interface ResumableConfig<Model, Message = any> extends ApplicationOptions<Model
418
453
  * Bundles whose bodies load on demand (`Bundle.lazy`). The server loads
419
454
  * them before it renders; the browser loads them before it boots, answering
420
455
  * from the markers meanwhile, so a page never shows a bundle's placeholder.
456
+ * A function is asked with the Model the page is drawn from (the server's
457
+ * after `prepare`, the browser's as resumed), so only what that page draws
458
+ * loads: `model => Routing.codeFor(model.route)` (`Site.routing`).
421
459
  */
422
- readonly lazy?: ReadonlyArray<Loadable> | undefined;
460
+ readonly lazy?: ReadonlyArray<Loadable> | ((model: Model) => ReadonlyArray<Loadable>) | undefined;
423
461
  }
462
+ /** The lazy bundles a page drawn from `model` needs loaded. */
463
+ declare const lazyFor: <Model>(config: {
464
+ readonly lazy?: ResumableConfig<Model>['lazy'];
465
+ }, model: Model) => ReadonlyArray<Loadable>;
424
466
  /** What `SSR` needs of a lazy bundle: `Bundle.lazy` gives it. */
425
467
  interface Loadable {
426
468
  readonly name: string;
@@ -473,7 +515,7 @@ declare const startingFrom: <Model>(config: ResumableConfig<Model>, start: {
473
515
  subscriptions?: Readonly<Record<string, unknown>> | undefined;
474
516
  managedResources?: Readonly<Record<string, unknown>> | undefined;
475
517
  resources?: Layer.Layer<never, never, never> | undefined;
476
- lazy?: ReadonlyArray<Loadable> | undefined;
518
+ lazy?: readonly Loadable[] | ((model: Model) => ReadonlyArray<Loadable>) | undefined;
477
519
  init: () => {
478
520
  readonly model: Model;
479
521
  readonly commands?: ReadonlyArray<unknown> | undefined;
@@ -498,5 +540,5 @@ declare const bindingsAndEvents: <Model, Fields extends Schema.Struct.Fields>(pl
498
540
  readonly bindings: ReadonlyArray<DecodedBinding>;
499
541
  readonly events: ReadonlyArray<string> | undefined;
500
542
  }, ResumeRefused>;
501
- export { noBuildId as $, routeOf as A, current as B, metaMarkup as C, projectionsOf as D, plan as E, tagOf as F, HandlerUnnamed as G, within as H, Binding as I, SsrDiagnostic as J, PageContained as K, Region as L, serving as M, startingFrom as N, refuse as O, staticRegion as P, handlerUnnamed as Q, RenderContext as R, metaEntry as S, pathKey as T, BundleUnloaded as U, withContext as V, CachedPageDiffers as W, bundleUnloaded as X, StaticRegionMissing as Y, cachedPageDiffers as Z, arrival as _, PROTOCOL as a, bindingsAndEvents as b, ResumableConfig as c, ResumeRefused as d, otherBuild as et, RouteMatch as f, allowedTags as g, Start as h, Meta as i, staticRegionMissing as it, serializeJsonScript as j, resume as k, ResumePart as l, STYLES_MARKER as m, Loadable as n, pageFailed as nt, PlanSurface as o, STATIC_ATTRIBUTE as p, PageFailed as q, META_ATTRIBUTE as r, reportingTo as rt, RESUME_ATTRIBUTE as s, FOLDKIT_APP_ATTRIBUTE as t, pageContained as tt, ResumePlan as u, attributeOf as v, modelFrom as w, codecOf as x, bindings as y, UnnamedHandler as z };
502
- //# sourceMappingURL=shared-CJN-m58Z.d.ts.map
543
+ export { StaticRegionMissing as $, refuse as A, Region as B, lazyFor as C, pathKey as D, modelFrom as E, startingFrom as F, within as G, UnnamedHandler as H, staticRegion as I, HandlerUnnamed as J, BundleUnloaded as K, tagOf as L, routeOf as M, serializeJsonScript as N, plan as O, serving as P, SsrDiagnostic as Q, unbound as R, codecOf as S, metaMarkup as T, current as U, RenderContext as V, withContext as W, PageContained as X, HeadNotMoved as Y, PageFailed as Z, allowedTags as _, Meta as a, otherBuild as at, bindings as b, RestoredPlace as c, reportingTo as ct, ResumePlan as d, bundleUnloaded as et, ResumeRefused as f, Start as g, STYLES_MARKER as h, META_ATTRIBUTE as i, noBuildId as it, resume as j, projectionsOf as k, ResumableConfig as l, staticRegionMissing as lt, STATIC_ATTRIBUTE as m, HEAD_MARKER as n, handlerUnnamed as nt, PROTOCOL as o, pageContained as ot, RouteMatch as p, CachedPageDiffers as q, Loadable as r, headNotMoved as rt, PlanSurface as s, pageFailed as st, HEAD_END_MARKER as t, cachedPageDiffers as tt, ResumePart as u, arrival as v, metaEntry as w, bindingsAndEvents as x, attributeOf as y, Binding as z };
544
+ //# sourceMappingURL=shared-BuCOwm57.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared-BuCOwm57.d.ts","names":[],"sources":["../src/diagnostics.ts","../src/context.ts","../src/shared.ts"],"mappings":";;;;;;;UAaiB,sBAAsB;WAC5B;;;;;WAKA,qCAAqC;;;UAI/B,4BAA4B;WAClC;WACA;;;UAIM,uBAAuB;WAC7B;WACA;;;UAIM,mBAAmB;WACzB;WACA;WACA,OAAO,MAAM;;;UAIP,uBAAuB;WAC7B;WACA;WACA;WACA;;;;;;;;UASM,0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AAM;WACZ,OAAO;WAAgB,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA7CnB,OAAA,OAAA,OAAA;EACb,WAAA;EAEK,gBAAA,SAAS;EACN,mBAAA,SAAS;EAEhB,YAAA,MAAM;EASkC,gBAAA,eAAA,OAAA,UAAA,cAAc;;aA8BlD,OAAA;aAA2B,WAAA;;;;cAIzC,UAAO;;;;;;;;;cAaP,WAAY,OAAO,eAAe,OAAO,OAAO,QAAM,MAC3D,WAAW,OAAO,SAAO,MACzB,YAAU,MACV,SAAO,OACN,UACN,OAAO,OAAO,cAAc,iBAAiB;;;;;cASnC,oBAAqB,OAAO,eAAe,OAAO,OAAO,QAAM,MACpE,WAAW,OAAO,SAAO,MACzB,YAAU,MACV,SAAO,OACN,UACN,OAAO;WAEG,UAAU,cAAc;WACxB,QAAQ;GAEnB"}
package/dist/shared.d.ts CHANGED
@@ -1,2 +1,3 @@
1
- import { A as routeOf, C as metaMarkup, D as projectionsOf, E as plan, F as tagOf, M as serving, N as startingFrom, O as refuse, P as staticRegion, S as metaEntry, T as pathKey, _ as arrival, a as PROTOCOL, b as bindingsAndEvents, c as ResumableConfig, d as ResumeRefused, f as RouteMatch, g as allowedTags, h as Start, i as Meta, j as serializeJsonScript, k as resume, l as ResumePart, m as STYLES_MARKER, n as Loadable, o as PlanSurface, p as STATIC_ATTRIBUTE, r as META_ATTRIBUTE, s as RESUME_ATTRIBUTE, t as FOLDKIT_APP_ATTRIBUTE, u as ResumePlan, v as attributeOf, w as modelFrom, x as codecOf, y as bindings } from "./shared-CJN-m58Z.js";
2
- export { FOLDKIT_APP_ATTRIBUTE, Loadable, META_ATTRIBUTE, Meta, PROTOCOL, PlanSurface, RESUME_ATTRIBUTE, ResumableConfig, ResumePart, ResumePlan, ResumeRefused, RouteMatch, STATIC_ATTRIBUTE, STYLES_MARKER, Start, allowedTags, arrival, attributeOf, bindings, bindingsAndEvents, codecOf, metaEntry, metaMarkup, modelFrom, pathKey, plan, projectionsOf, refuse, resume, routeOf, serializeJsonScript, serving, startingFrom, staticRegion, tagOf };
1
+ import { i as RESUME_ATTRIBUTE, n as FOLDKIT_APP_ATTRIBUTE } from "./marks-CX15BwOw.js";
2
+ import { A as refuse, C as lazyFor, D as pathKey, E as modelFrom, F as startingFrom, I as staticRegion, L as tagOf, M as routeOf, N as serializeJsonScript, O as plan, P as serving, R as unbound, S as codecOf, T as metaMarkup, _ as allowedTags, a as Meta, b as bindings, c as RestoredPlace, d as ResumePlan, f as ResumeRefused, g as Start, h as STYLES_MARKER, i as META_ATTRIBUTE, j as resume, k as projectionsOf, l as ResumableConfig, m as STATIC_ATTRIBUTE, n as HEAD_MARKER, o as PROTOCOL, p as RouteMatch, r as Loadable, s as PlanSurface, t as HEAD_END_MARKER, u as ResumePart, v as arrival, w as metaEntry, x as bindingsAndEvents, y as attributeOf } from "./shared-BuCOwm57.js";
3
+ export { FOLDKIT_APP_ATTRIBUTE, HEAD_END_MARKER, HEAD_MARKER, Loadable, META_ATTRIBUTE, Meta, PROTOCOL, PlanSurface, RESUME_ATTRIBUTE, RestoredPlace, ResumableConfig, ResumePart, ResumePlan, ResumeRefused, RouteMatch, STATIC_ATTRIBUTE, STYLES_MARKER, Start, allowedTags, arrival, attributeOf, bindings, bindingsAndEvents, codecOf, lazyFor, metaEntry, metaMarkup, modelFrom, pathKey, plan, projectionsOf, refuse, resume, routeOf, serializeJsonScript, serving, startingFrom, staticRegion, tagOf, unbound };