foldkit-ssr 0.9.0 → 0.11.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 (52) hide show
  1. package/README.md +402 -36
  2. package/dist/{client-F16QT0sc.d.ts → client-qmdYY-Eb.d.ts} +15 -5
  3. package/dist/client-qmdYY-Eb.d.ts.map +1 -0
  4. package/dist/client.d.ts +5 -5
  5. package/dist/client.js +126 -54
  6. package/dist/client.js.map +1 -1
  7. package/dist/context.d.ts +1 -1
  8. package/dist/context.js +12 -0
  9. package/dist/context.js.map +1 -1
  10. package/dist/diagnostics.d.ts +2 -2
  11. package/dist/diagnostics.js +8 -1
  12. package/dist/diagnostics.js.map +1 -1
  13. package/dist/index.d.ts +127 -25
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +317 -59
  16. package/dist/index.js.map +1 -1
  17. package/dist/keep.d.ts +36 -0
  18. package/dist/keep.d.ts.map +1 -0
  19. package/dist/keep.js +109 -0
  20. package/dist/keep.js.map +1 -0
  21. package/dist/{listen-zNd0IIAT.d.ts → listen-DaUPRKVR.d.ts} +4 -2
  22. package/dist/listen-DaUPRKVR.d.ts.map +1 -0
  23. package/dist/listen.d.ts +2 -2
  24. package/dist/listen.js +31 -23
  25. package/dist/listen.js.map +1 -1
  26. package/dist/pageCache-DO0pOgnc.d.ts +80 -0
  27. package/dist/pageCache-DO0pOgnc.d.ts.map +1 -0
  28. package/dist/pageCache.d.ts +2 -0
  29. package/dist/pageCache.js +112 -0
  30. package/dist/pageCache.js.map +1 -0
  31. package/dist/{requestContext-D9nsbGSJ.d.ts → requestContext-DmwmQeci.d.ts} +12 -2
  32. package/dist/requestContext-DmwmQeci.d.ts.map +1 -0
  33. package/dist/requestContext.d.ts +2 -2
  34. package/dist/requestContext.js +30 -13
  35. package/dist/requestContext.js.map +1 -1
  36. package/dist/{resumable-BWItJsxF.d.ts → resumable-BPN_qQHU.d.ts} +33 -12
  37. package/dist/resumable-BPN_qQHU.d.ts.map +1 -0
  38. package/dist/resumable.d.ts +2 -2
  39. package/dist/resumable.js +51 -8
  40. package/dist/resumable.js.map +1 -1
  41. package/dist/{shared-v1u-OEQI.d.ts → shared-CJN-m58Z.d.ts} +37 -10
  42. package/dist/shared-CJN-m58Z.d.ts.map +1 -0
  43. package/dist/shared.d.ts +2 -2
  44. package/dist/shared.js +31 -7
  45. package/dist/shared.js.map +1 -1
  46. package/dist/vite.d.ts +1 -1
  47. package/package.json +9 -9
  48. package/dist/client-F16QT0sc.d.ts.map +0 -1
  49. package/dist/listen-zNd0IIAT.d.ts.map +0 -1
  50. package/dist/requestContext-D9nsbGSJ.d.ts.map +0 -1
  51. package/dist/resumable-BWItJsxF.d.ts.map +0 -1
  52. package/dist/shared-v1u-OEQI.d.ts.map +0 -1
@@ -11,18 +11,32 @@ import { Option } from "effect";
11
11
  * with its own copy of this module, so the map lives on `globalThis` under a
12
12
  * registered symbol, and a context is known by its name.
13
13
  */
14
- const KEY = Symbol.for("foldkit-ssr/request-context");
15
- const valuesOf = () => {
16
- const global = globalThis;
17
- const held = global[KEY];
18
- if (held === void 0) {
19
- const made = /* @__PURE__ */ new WeakMap();
20
- global[KEY] = made;
21
- return made;
22
- }
23
- if (!(held instanceof WeakMap)) throw new Error(`foldkit-ssr: globalThis holds something else under ${String(KEY)}`);
24
- return held;
14
+ /**
15
+ * The map on `globalThis` under `name`'s registered symbol, made the first
16
+ * time it is asked for: every bundle's copy of this module finds the same one.
17
+ */
18
+ const globalMap = (name) => {
19
+ const key = Symbol.for(name);
20
+ return () => {
21
+ const global = globalThis;
22
+ const held = global[key];
23
+ if (held === void 0) {
24
+ const made = /* @__PURE__ */ new WeakMap();
25
+ global[key] = made;
26
+ return made;
27
+ }
28
+ if (!(held instanceof WeakMap)) throw new Error(`foldkit-ssr: globalThis holds something else under ${String(key)}`);
29
+ return held;
30
+ };
25
31
  };
32
+ const valuesOf = globalMap("foldkit-ssr/request-context");
33
+ /**
34
+ * The request a render that may be kept reads in place of the host's, to the
35
+ * host's, with what to record when the render reads a context of it. On
36
+ * `globalThis`, as the values are, since the Worker's copy of this module
37
+ * may be asked about a request the page bundle's `SSR.entry` made.
38
+ */
39
+ const watchedOf = globalMap("foldkit-ssr/watched-requests");
26
40
  /**
27
41
  * A request context named `name`. The host and the page each import it from
28
42
  * one module, so both agree on `C`; two bundles of that module find each
@@ -38,11 +52,14 @@ const requestContext = (name) => ({
38
52
  values.set(request, held);
39
53
  return request;
40
54
  },
41
- of: (request) => {
55
+ of: (given) => {
56
+ const watched = watchedOf().get(given);
57
+ watched?.readContext();
58
+ const request = watched?.original ?? given;
42
59
  const held = valuesOf().get(request);
43
60
  return held !== void 0 && held.has(name) ? Option.some(held.get(name)) : Option.none();
44
61
  }
45
62
  });
46
- export { requestContext };
63
+ export { requestContext, watchedOf };
47
64
 
48
65
  //# sourceMappingURL=requestContext.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"requestContext.js","names":[],"sources":["../src/requestContext.ts"],"sourcesContent":["/**\n * A value the host hands `renderPage` with the request. Foldkit's\n * `handleRequest` calls `renderPage(request)` and nothing more, so what the\n * host holds (a Worker's bindings, a reader built from them) rides the\n * request itself: kept in a `WeakMap` keyed by it, which holds nothing past\n * the request's life and never shares one request's value with another.\n *\n * The Worker and the page bundle Vite built are separate module graphs, each\n * with its own copy of this module, so the map lives on `globalThis` under a\n * registered symbol, and a context is known by its name.\n */\nimport { Option } from 'effect'\n\nconst KEY = Symbol.for('foldkit-ssr/request-context')\n\ntype Values = WeakMap<Request, Map<string, unknown>>\n\nconst valuesOf = (): Values => {\n const global = globalThis as { [KEY]?: unknown }\n const held = global[KEY]\n if (held === undefined) {\n const made: Values = new WeakMap()\n global[KEY] = made\n return made\n }\n if (!(held instanceof WeakMap))\n throw new Error(`foldkit-ssr: globalThis holds something else under ${String(KEY)}`)\n return held as Values\n}\n\n/** A value of type `C` the host attaches to a request, for its `renderPage` to read. */\nexport interface RequestContext<C> {\n readonly name: string\n /** Keeps `value` for `request` and returns the request. A second value under this name throws. */\n readonly attach: (request: Request, value: C) => Request\n /**\n * The value the host attached to `request`; none when it attached nothing,\n * as Vite's dev server, which builds its own `Request`, or a host that\n * passed on a copy (`new Request(request)`).\n */\n readonly of: (request: Request) => Option.Option<C>\n}\n\n/**\n * A request context named `name`. The host and the page each import it from\n * one module, so both agree on `C`; two bundles of that module find each\n * other's values by the name.\n */\nexport const requestContext = <C>(name: string): RequestContext<C> => ({\n name,\n attach: (request, value) => {\n const values = valuesOf()\n const held = values.get(request) ?? new Map<string, unknown>()\n if (held.has(name))\n throw new Error(`foldkit-ssr: the request already carries a \"${name}\" context`)\n held.set(name, value)\n values.set(request, held)\n return request\n },\n of: request => {\n const held = valuesOf().get(request)\n return held !== undefined && held.has(name) ? Option.some(held.get(name) as C) : Option.none()\n },\n})\n"],"mappings":";;;;;;;;;;;;;AAaA,MAAM,MAAM,OAAO,IAAI,6BAA6B;AAIpD,MAAM,iBAAyB;CAC7B,MAAM,SAAS;CACf,MAAM,OAAO,OAAO;CACpB,IAAI,SAAS,KAAA,GAAW;EACtB,MAAM,uBAAe,IAAI,QAAQ;EACjC,OAAO,OAAO;EACd,OAAO;CACT;CACA,IAAI,EAAE,gBAAgB,UACpB,MAAM,IAAI,MAAM,sDAAsD,OAAO,GAAG,GAAG;CACrF,OAAO;AACT;;;;;;AAoBA,MAAa,kBAAqB,UAAqC;CACrE;CACA,SAAS,SAAS,UAAU;EAC1B,MAAM,SAAS,SAAS;EACxB,MAAM,OAAO,OAAO,IAAI,OAAO,qBAAK,IAAI,IAAqB;EAC7D,IAAI,KAAK,IAAI,IAAI,GACf,MAAM,IAAI,MAAM,+CAA+C,KAAK,UAAU;EAChF,KAAK,IAAI,MAAM,KAAK;EACpB,OAAO,IAAI,SAAS,IAAI;EACxB,OAAO;CACT;CACA,KAAI,YAAW;EACb,MAAM,OAAO,SAAS,CAAC,CAAC,IAAI,OAAO;EACnC,OAAO,SAAS,KAAA,KAAa,KAAK,IAAI,IAAI,IAAI,OAAO,KAAK,KAAK,IAAI,IAAI,CAAM,IAAI,OAAO,KAAK;CAC/F;AACF"}
1
+ {"version":3,"file":"requestContext.js","names":[],"sources":["../src/requestContext.ts"],"sourcesContent":["/**\n * A value the host hands `renderPage` with the request. Foldkit's\n * `handleRequest` calls `renderPage(request)` and nothing more, so what the\n * host holds (a Worker's bindings, a reader built from them) rides the\n * request itself: kept in a `WeakMap` keyed by it, which holds nothing past\n * the request's life and never shares one request's value with another.\n *\n * The Worker and the page bundle Vite built are separate module graphs, each\n * with its own copy of this module, so the map lives on `globalThis` under a\n * registered symbol, and a context is known by its name.\n */\nimport { Option } from 'effect'\n\n/**\n * The map on `globalThis` under `name`'s registered symbol, made the first\n * time it is asked for: every bundle's copy of this module finds the same one.\n */\nconst globalMap = <V>(name: string) => {\n const key = Symbol.for(name)\n return (): WeakMap<Request, V> => {\n const global = globalThis as { [key]?: unknown }\n const held = global[key]\n if (held === undefined) {\n const made = new WeakMap<Request, V>()\n global[key] = made\n return made\n }\n if (!(held instanceof WeakMap))\n throw new Error(`foldkit-ssr: globalThis holds something else under ${String(key)}`)\n return held as WeakMap<Request, V>\n }\n}\n\nconst valuesOf = globalMap<Map<string, unknown>>('foldkit-ssr/request-context')\n\n/**\n * The request a render that may be kept reads in place of the host's, to the\n * host's, with what to record when the render reads a context of it. On\n * `globalThis`, as the values are, since the Worker's copy of this module\n * may be asked about a request the page bundle's `SSR.entry` made.\n */\nexport const watchedOf = globalMap<{\n readonly original: Request\n readonly readContext: () => void\n}>('foldkit-ssr/watched-requests')\n\n/** A value of type `C` the host attaches to a request, for its `renderPage` to read. */\nexport interface RequestContext<C> {\n readonly name: string\n /** Keeps `value` for `request` and returns the request. A second value under this name throws. */\n readonly attach: (request: Request, value: C) => Request\n /**\n * The value the host attached to `request`; none when it attached nothing,\n * as Vite's dev server, which builds its own `Request`, or a host that\n * passed on a copy (`new Request(request)`).\n */\n readonly of: (request: Request) => Option.Option<C>\n}\n\n/**\n * A request context named `name`. The host and the page each import it from\n * one module, so both agree on `C`; two bundles of that module find each\n * other's values by the name.\n */\nexport const requestContext = <C>(name: string): RequestContext<C> => ({\n name,\n attach: (request, value) => {\n const values = valuesOf()\n const held = values.get(request) ?? new Map<string, unknown>()\n if (held.has(name))\n throw new Error(`foldkit-ssr: the request already carries a \"${name}\" context`)\n held.set(name, value)\n values.set(request, held)\n return request\n },\n of: given => {\n const watched = watchedOf().get(given)\n // A context may say who is asking, which a kept page must not depend on.\n watched?.readContext()\n const request = watched?.original ?? given\n const held = valuesOf().get(request)\n return held !== undefined && held.has(name) ? Option.some(held.get(name) as C) : Option.none()\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,MAAM,aAAgB,SAAiB;CACrC,MAAM,MAAM,OAAO,IAAI,IAAI;CAC3B,aAAkC;EAChC,MAAM,SAAS;EACf,MAAM,OAAO,OAAO;EACpB,IAAI,SAAS,KAAA,GAAW;GACtB,MAAM,uBAAO,IAAI,QAAoB;GACrC,OAAO,OAAO;GACd,OAAO;EACT;EACA,IAAI,EAAE,gBAAgB,UACpB,MAAM,IAAI,MAAM,sDAAsD,OAAO,GAAG,GAAG;EACrF,OAAO;CACT;AACF;AAEA,MAAM,WAAW,UAAgC,6BAA6B;;;;;;;AAQ9E,MAAa,YAAY,UAGtB,8BAA8B;;;;;;AAoBjC,MAAa,kBAAqB,UAAqC;CACrE;CACA,SAAS,SAAS,UAAU;EAC1B,MAAM,SAAS,SAAS;EACxB,MAAM,OAAO,OAAO,IAAI,OAAO,qBAAK,IAAI,IAAqB;EAC7D,IAAI,KAAK,IAAI,IAAI,GACf,MAAM,IAAI,MAAM,+CAA+C,KAAK,UAAU;EAChF,KAAK,IAAI,MAAM,KAAK;EACpB,OAAO,IAAI,SAAS,IAAI;EACxB,OAAO;CACT;CACA,KAAI,UAAS;EACX,MAAM,UAAU,UAAU,CAAC,CAAC,IAAI,KAAK;EAErC,SAAS,YAAY;EACrB,MAAM,UAAU,SAAS,YAAY;EACrC,MAAM,OAAO,SAAS,CAAC,CAAC,IAAI,OAAO;EACnC,OAAO,SAAS,KAAA,KAAa,KAAK,IAAI,IAAI,IAAI,OAAO,KAAK,KAAK,IAAI,IAAI,CAAM,IAAI,OAAO,KAAK;CAC/F;AACF"}
@@ -14,6 +14,13 @@ declare const UNNAMED_HANDLER = "*";
14
14
  declare const FALLBACK_FIELD = "foldkit-plus-message";
15
15
  /** The posted field that says how many placement wrappers the form's fields sit under. */
16
16
  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
+ /** The value of a `KeepTyped` marker no resumable element took, while the server renders. */
23
+ declare const UNPLACED_KEEP = "?";
17
24
  /** The attribute on a placement's root naming its slot, while the server renders. */
18
25
  declare const SLOT_ATTRIBUTE = "data-foldkit-plus-slot";
19
26
  declare const invalid: unique symbol;
@@ -37,15 +44,22 @@ type Rest<M, Fixed> = Omit<Made<M>, '_tag' | keyof Fixed>;
37
44
  type ProducesMessage<M, Message> = [Made<M>] extends [Message] ? unknown : Invalid<"the member is not one of this view's Messages">;
38
45
  type TextHoleCheck<M, Fixed> = [keyof Rest<M, Fixed>] extends [never] ? Invalid<'the member has no field left for the event to fill'> : true extends IsUnion<keyof Rest<M, Fixed>> ? Invalid<'the member leaves more than one field for the event to fill: fix the others'> : Rest<M, Fixed>[keyof Rest<M, Fixed>] extends string ? string extends Rest<M, Fixed>[keyof Rest<M, Fixed>] ? unknown : Invalid<'the field the event fills must be a string'> : Invalid<'the field the event fills must be a string'>;
39
46
  type KeyHoleCheck<M, Fixed> = [keyof Rest<M, Fixed>] extends ['key' | 'modifiers'] ? ['key' | 'modifiers'] extends [keyof Rest<M, Fixed>] ? unknown : Invalid<'the member must leave exactly key and modifiers for the event to fill'> : Invalid<'the member must leave exactly key and modifiers for the event to fill'>;
47
+ /**
48
+ * Foldkit's attribute of one tag, as its own builder returns it, so an
49
+ * element that refuses some attributes (a `textarea`, `InnerHTML`) takes it.
50
+ */
51
+ type Tagged<Message, Tag extends string> = Extract<Attribute<Message>, {
52
+ readonly _tag: Tag;
53
+ }>;
40
54
  /** `OnInput` and `OnChange`: a closure, or a member whose one string field the event fills. */
41
- interface TextHole<Message> {
42
- (toMessage: (value: string) => Message): Attribute<Message>;
43
- <M extends AnyMemberSchema, const Fixed extends Fixable<M> = {}>(member: M & ProducesMessage<M, Message> & TextHoleCheck<M, Fixed>, fixed?: Fixed): Attribute<Message>;
55
+ interface TextHole<Message, Tag extends string> {
56
+ (toMessage: (value: string) => Message): Tagged<Message, Tag>;
57
+ <M extends AnyMemberSchema, const Fixed extends Fixable<M> = {}>(member: M & ProducesMessage<M, Message> & TextHoleCheck<M, Fixed>, fixed?: Fixed): Tagged<Message, Tag>;
44
58
  }
45
59
  /** `OnKeyDown` and `OnKeyUp`: a closure, or a member whose `key` and `modifiers` the event fills. */
46
- interface KeyHole<Message> {
47
- (toMessage: (key: string, modifiers: KeyboardModifiers) => Message): Attribute<Message>;
48
- <M extends AnyMemberSchema, const Fixed extends Fixable<M> = {}>(member: M & ProducesMessage<M, Message> & KeyHoleCheck<M, Fixed>, fixed?: Fixed): Attribute<Message>;
60
+ interface KeyHole<Message, Tag extends string> {
61
+ (toMessage: (key: string, modifiers: KeyboardModifiers) => Message): Tagged<Message, Tag>;
62
+ <M extends AnyMemberSchema, const Fixed extends Fixable<M> = {}>(member: M & ProducesMessage<M, Message> & KeyHoleCheck<M, Fixed>, fixed?: Fixed): Tagged<Message, Tag>;
49
63
  }
50
64
  /**
51
65
  * A builder a view is given: Foldkit's `HtmlBuilder`, or a Surface renderer's,
@@ -66,10 +80,17 @@ type MessageOf<Builder> = Builder extends {
66
80
  * so a placement's view accepts it as the parent's builder.
67
81
  */
68
82
  type ResumableBuilder<Message> = Omit<HtmlBuilder<Message>, 'OnInput' | 'OnChange' | 'OnKeyDown' | 'OnKeyUp'> & {
69
- readonly OnInput: TextHole<Message>;
70
- readonly OnChange: TextHole<Message>;
71
- readonly OnKeyDown: KeyHole<Message>;
72
- readonly OnKeyUp: KeyHole<Message>;
83
+ readonly OnInput: TextHole<Message, 'OnInput'>;
84
+ readonly OnChange: TextHole<Message, 'OnChange'>;
85
+ readonly OnKeyDown: KeyHole<Message, 'OnKeyDown'>;
86
+ readonly OnKeyUp: KeyHole<Message, 'OnKeyUp'>;
87
+ /**
88
+ * Keeps what is typed into this field before the runtime starts: the
89
+ * browser replays it as the field's `OnInput` Message (else its
90
+ * `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`.
92
+ */
93
+ readonly KeepTyped: () => Tagged<Message, 'Attribute'>;
73
94
  };
74
95
  /**
75
96
  * The resumable builder for a view's `h`. Use it in place of `h`; it has the
@@ -82,5 +103,5 @@ declare const builder: <Builder extends AnyBuilder>(h: Builder) => ResumableBuil
82
103
  * `SurfaceView.define`, or an application's own view.
83
104
  */
84
105
  declare const view: <Model, Builder extends AnyBuilder, Out>(render: (model: Model, rh: ResumableBuilder<MessageOf<Builder>>) => Out) => (model: Model, h: Builder) => Out;
85
- export { FALLBACK_FIELD as a, MessageOf as c, TextHole as d, UNNAMED_HANDLER as f, FALLBACK_DEPTH_FIELD as i, ResumableBuilder as l, view as m, BINDING_ATTRIBUTE as n, Invalid as o, builder as p, EVENT_OF as r, KeyHole as s, AnyBuilder as t, SLOT_ATTRIBUTE as u };
86
- //# sourceMappingURL=resumable-BWItJsxF.d.ts.map
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
+ //# sourceM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,UAAU,eAAe,YAAY,MAAM;IAElD;;;;;;;;KAUQ,iBAAiB,WAAW,KACtC,YAAY;WAGH,SAAS,SAAS;WAClB,UAAU,SAAS;WACnB,WAAW,QAAQ;WACnB,SAAS,QAAQ;;;;;;;WAOjB,iBAAiB,OAAO;;;;;;cA4DtB,UAAW,gBAAgB,YAAU,GAC7C,YACF,iBAAiB,UAAU;;;;;;cAsQjB,OACV,OAAO,gBAAgB,YAAY,KAAG,SAC5B,OAAO,OAAO,IAAI,iBAAiB,UAAU,cAAc,SAAG,OAEjE,OAAK,GAAK,YAAU"}
@@ -1,2 +1,2 @@
1
- import { a as FALLBACK_FIELD, c as MessageOf, d as TextHole, f as UNNAMED_HANDLER, i as FALLBACK_DEPTH_FIELD, l as ResumableBuilder, m as view, n as BINDING_ATTRIBUTE, o as Invalid, p as builder, r as EVENT_OF, s as KeyHole, t as AnyBuilder, u as SLOT_ATTRIBUTE } from "./resumable-BWItJsxF.js";
2
- export { AnyBuilder, BINDING_ATTRIBUTE, EVENT_OF, FALLBACK_DEPTH_FIELD, FALLBACK_FIELD, Invalid, KeyHole, MessageOf, ResumableBuilder, SLOT_ATTRIBUTE, TextHole, UNNAMED_HANDLER, builder, view };
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";
2
+ 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
@@ -124,6 +124,27 @@ const UNNAMED_HANDLER = "*";
124
124
  const FALLBACK_FIELD = "foldkit-plus-message";
125
125
  /** The posted field that says how many placement wrappers the form's fields sit under. */
126
126
  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
+ /** The value of a `KeepTyped` marker no resumable element took, while the server renders. */
133
+ const UNPLACED_KEEP = "?";
134
+ /**
135
+ * The `input` types whose value is not something typed, so `KeepTyped` has
136
+ * nothing to keep on them.
137
+ */
138
+ const UNTYPED_INPUTS = /* @__PURE__ */ new Set([
139
+ "checkbox",
140
+ "radio",
141
+ "file",
142
+ "hidden",
143
+ "button",
144
+ "submit",
145
+ "reset",
146
+ "image"
147
+ ]);
127
148
  /** The attribute on a placement's root naming its slot, while the server renders. */
128
149
  const SLOT_ATTRIBUTE = "data-foldkit-plus-slot";
129
150
  const isMember = (value) => typeof value === "function" && typeof value.fields === "object";
@@ -146,6 +167,8 @@ const NO_MODIFIERS = {
146
167
  const holes = /* @__PURE__ */ new WeakMap();
147
168
  const isAttribute = (item) => "_tag" in item;
148
169
  const builders = /* @__PURE__ */ new WeakMap();
170
+ /** Each attribute `KeepTyped` made: a request to the element it is given, never written as it is. */
171
+ const keeps = /* @__PURE__ */ new WeakSet();
149
172
  /** A hole form's placeholder Message, or `undefined` when its field's checks refuse one. */
150
173
  const placeholder = (make) => {
151
174
  try {
@@ -164,12 +187,15 @@ const builder = (h) => {
164
187
  const source = h;
165
188
  const attribute = source.Attribute;
166
189
  /** The attributes with a marker for each binding, while the server renders. */
167
- const mark = (tag, attributes) => {
190
+ const mark = (tag, given) => {
191
+ const kept = given.some((item) => keeps.has(item));
192
+ const attributes = kept ? given.filter((item) => !keeps.has(item)) : given;
168
193
  const now = current();
169
194
  if (now?.mode !== "collect" && now?.mode !== "replay") return attributes;
170
195
  const id = attributes.find((item) => isAttribute(item) && item._tag === "Id");
171
196
  const element = id === void 0 ? tag : `${tag}#${id.value}`;
172
197
  const tokens = /* @__PURE__ */ new Map();
198
+ const typed = /* @__PURE__ */ new Map();
173
199
  for (const item of attributes) {
174
200
  if (!isAttribute(item)) continue;
175
201
  const event = item._tag === "OnCustomEvent" ? item.name : EVENT_OF[item._tag];
@@ -204,20 +230,31 @@ const builder = (h) => {
204
230
  });
205
231
  list.push("*");
206
232
  } else {
233
+ if (binding.hole !== void 0 && !typed.has(binding.attribute)) typed.set(binding.attribute, now.bindings.length);
207
234
  list.push(String(now.bindings.length));
208
235
  now.bindings.push(binding);
209
236
  }
210
237
  }
211
- if (tokens.size === 0) return attributes;
212
238
  const markers = [...tokens].map(([event, list]) => attribute(`${BINDING_ATTRIBUTE}${event}`, list.join(" ")));
213
- return [...attributes, ...markers];
239
+ 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`);
244
+ } 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`);
246
+ } else markers.push(attribute(KEEP_ATTRIBUTE, String(ordinal)));
247
+ }
248
+ return markers.length === 0 ? attributes : [...attributes, ...markers];
214
249
  };
215
250
  /**
216
251
  * A form whose `OnSubmit` names a Message, while the server renders for a
217
252
  * plan with a fallback, also posts that Message: `method="post"` to its own
218
253
  * URL, and a hidden input carrying the Message encoded. Posted fields named
219
254
  * as the Message's own fields override them, so a typed title reaches
220
- * `update` as it would through the page.
255
+ * `update` as it would through the page. A form given its own `Method` is
256
+ * the view's, left as drawn: a search is a GET of the address the URL
257
+ * mirror reads, and posts no Message.
221
258
  */
222
259
  const fallback = (tag, attributes, children) => {
223
260
  const now = current();
@@ -226,7 +263,8 @@ const builder = (h) => {
226
263
  children
227
264
  };
228
265
  const submit = attributes.find((item) => isAttribute(item) && item._tag === "OnSubmit");
229
- if (submit === void 0 || !Array.isArray(children)) return {
266
+ const method = attributes.some((item) => isAttribute(item) && item._tag === "Method");
267
+ if (submit === void 0 || method || !Array.isArray(children)) return {
230
268
  attributes,
231
269
  children
232
270
  };
@@ -294,8 +332,8 @@ const builder = (h) => {
294
332
  };
295
333
  /**
296
334
  * `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.
335
+ * server renders: a boundary a tool can find, which the browser takes off
336
+ * as the page boots, with the markers.
299
337
  */
300
338
  const submodel = (config) => {
301
339
  const original = source.submodel;
@@ -344,6 +382,11 @@ const builder = (h) => {
344
382
  return element(mark(name, posted.attributes), posted.children, ...rest.slice(1));
345
383
  };
346
384
  } else wrapped[name] = value;
385
+ wrapped.KeepTyped = () => {
386
+ const made = attribute(KEEP_ATTRIBUTE, current()?.mode === "collect" ? "?" : "");
387
+ keeps.add(made);
388
+ return made;
389
+ };
347
390
  builders.set(h, wrapped);
348
391
  return wrapped;
349
392
  };
@@ -353,6 +396,6 @@ const builder = (h) => {
353
396
  * `SurfaceView.define`, or an application's own view.
354
397
  */
355
398
  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 };
399
+ export { BINDING_ATTRIBUTE, EVENT_OF, FALLBACK_DEPTH_FIELD, FALLBACK_FIELD, KEEP_ATTRIBUTE, SLOT_ATTRIBUTE, UNNAMED_HANDLER, UNPLACED_KEEP, builder, view };
357
400
 
358
401
  //# sourceMappingURL=resumable.js.map
@@ -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/** 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,WA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EAAE;GAChD,OAAO,MAAM,GAAG,CAAC,CAAC,KAAK,KAAK,KAAK,OAAO,UAAU,GAAG,OAAO,UAAU,GAAG,KAAK,MAAM,CAAC,CAAC;EACxF;CACJ,OAAO,IAAI,SAAS,KAAK,IAAI,KAAK,OAAO,UAAU,YAAY;EAC7D,MAAM,UAAU;EAIhB,QAAQ,SAAS,YAAiC,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,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 { 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,aAAa;CACb,aAAa;CACb,YAAY;CACZ,QAAQ;CACR,aAAa;CACb,cAAc;CACd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E;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,4 +1,4 @@
1
- import { n as DecodedBinding } from "./listen-zNd0IIAT.js";
1
+ import { n as DecodedBinding } from "./listen-DaUPRKVR.js";
2
2
  import { Cause, Effect, Layer, Option, Result, Schema, Stream } from "effect";
3
3
  import { ActiveSurface, Diagnostic, Metadata, ModelPlace, ReportDiagnostic, SurfaceSource, WritableProjection } from "foldkit-surface";
4
4
  import { Html, HtmlBuilder } from "foldkit/html";
@@ -36,8 +36,18 @@ interface HandlerUnnamed extends Diagnostic {
36
36
  readonly element: string;
37
37
  readonly event: string;
38
38
  }
39
+ /**
40
+ * A kept page drawn otherwise for the request it served (`SSR.entry`'s
41
+ * `cache.check`): the render read something of the request, or anything
42
+ * else that differs between requests, that the cache could not see. The
43
+ * request was given the page drawn again.
44
+ */
45
+ interface CachedPageDiffers extends Diagnostic {
46
+ readonly _tag: 'CachedPageDiffers';
47
+ readonly url: string;
48
+ }
39
49
  /** Every diagnostic SSR reports. */
40
- type SsrDiagnostic = PageContained | StaticRegionMissing | BundleUnloaded | PageFailed | HandlerUnnamed;
50
+ type SsrDiagnostic = PageContained | StaticRegionMissing | BundleUnloaded | PageFailed | HandlerUnnamed | CachedPageDiffers;
41
51
  declare const pageContained: (reason: PageContained['reason'], detail: string) => PageContained;
42
52
  declare const noBuildId: PageContained;
43
53
  /** The page's stamped build id, if it has one, is not the client's `client`. */
@@ -48,6 +58,7 @@ declare const pageFailed: (url: string, cause: Cause.Cause<unknown>) => PageFail
48
58
  declare const handlerUnnamed: (plan: string, element: string, event: string) => HandlerUnnamed;
49
59
  /** `effect` reporting to `report` when one is given, else to the reporter in its context. */
50
60
  declare const reportingTo: (report: ReportDiagnostic | undefined) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
61
+ declare const cachedPageDiffers: (url: string) => CachedPageDiffers;
51
62
  type Region = ReadonlyArray<Html | string>;
52
63
  /** An element whose handler for `event` is a function, which the page cannot describe. */
53
64
  interface UnnamedHandler {
@@ -93,6 +104,8 @@ type RenderContext = {
93
104
  }>;
94
105
  /** Each element and event marked `*`: a handler the page cannot name. */
95
106
  readonly unnamed: Array<UnnamedHandler>;
107
+ /** Why each `KeepTyped` field met cannot be replayed, one line each. */
108
+ readonly unkeepable: Array<string>;
96
109
  } | {
97
110
  readonly mode: 'replay';
98
111
  readonly regions: ReadonlyMap<string, Region>;
@@ -128,6 +141,12 @@ declare const FOLDKIT_APP_ATTRIBUTE = "data-foldkit-app";
128
141
  declare const RESUME_ATTRIBUTE = "data-foldkit-plus-resume";
129
142
  /** The envelope format this package writes and reads. */
130
143
  declare const PROTOCOL = 1;
144
+ /**
145
+ * The comment a render's `styles` follow in the stamped root. Hydration
146
+ * removes children the view does not draw, so `SSR.hydrate` moves what
147
+ * follows it into the head before adopting the page.
148
+ */
149
+ declare const STYLES_MARKER = "foldkit-plus-styles";
131
150
  /**
132
151
  * JSON for a script element: `<` is escaped so `</script>` in the data ends
133
152
  * nothing. U+2028 and U+2029 are escaped too: they are fine in JSON and break a
@@ -135,10 +154,11 @@ declare const PROTOCOL = 1;
135
154
  */
136
155
  declare const serializeJsonScript: (value: unknown) => string;
137
156
  /**
138
- * The envelope JSON as the stamped root carries it: `serializeJsonScript`
139
- * already escaped `<` and the line separators, and an attribute must escape
140
- * `&` and `"` besides, so no string in the Model can break out of the value.
141
- * `getAttribute` resolves the entities back, which is exactly the JSON.
157
+ * The envelope JSON as the stamped root carries it, in single quotes so the
158
+ * JSON's own double quotes need no escape. `&` and `'` are escaped, so no
159
+ * string in the Model can break out of the value; `getAttribute` resolves the
160
+ * entities back to exactly the JSON. `serializeJsonScript` has already escaped
161
+ * `<` and the line separators.
142
162
  */
143
163
  declare const attributeOf: (json: string) => string;
144
164
  /**
@@ -331,6 +351,13 @@ declare const modelFrom: <Model, Fields extends Schema.Struct.Fields>(plan: Resu
331
351
  declare const resume: <Model, Fields extends Schema.Struct.Fields>(plan: ResumePlan<Model, Fields>, page: ParentNode, options?: {
332
352
  readonly route?: string | undefined;
333
353
  }) => Result.Result<Model, ResumeRefused>;
354
+ /**
355
+ * The Message telling the application the URL it is at, when the page was
356
+ * recorded for its path alone and the browser is at a query: `init` never ran
357
+ * here, so the application would otherwise never learn the query. None for
358
+ * an application without routing, or a page at no query.
359
+ */
360
+ declare const arrival: <Model, Message>(config: ResumableConfig<Model, Message>, page: ParentNode, href: string) => Option.Option<Message>;
334
361
  /** The tag a Message value carries, for naming it. */
335
362
  declare const tagOf: (message: unknown) => string;
336
363
  /**
@@ -403,7 +430,7 @@ interface Loadable {
403
430
  /** The config whose `init` returns this start, whatever arguments it is given. */
404
431
  declare const startingFrom: <Model>(config: ResumableConfig<Model>, start: {
405
432
  readonly model: Model;
406
- readonly commands?: ReadonlyArray<unknown>;
433
+ readonly commands?: ReadonlyArray<unknown> | undefined;
407
434
  }) => {
408
435
  ports?: Readonly<{
409
436
  inbound?: Readonly<Record<string, import("foldkit/port").Inbound<any, any>>>;
@@ -449,7 +476,7 @@ declare const startingFrom: <Model>(config: ResumableConfig<Model>, start: {
449
476
  lazy?: ReadonlyArray<Loadable> | undefined;
450
477
  init: () => {
451
478
  readonly model: Model;
452
- readonly commands?: ReadonlyArray<unknown>;
479
+ readonly commands?: ReadonlyArray<unknown> | undefined;
453
480
  };
454
481
  };
455
482
  /** A route as the envelope records it: the path and the query. */
@@ -471,5 +498,5 @@ declare const bindingsAndEvents: <Model, Fields extends Schema.Struct.Fields>(pl
471
498
  readonly bindings: ReadonlyArray<DecodedBinding>;
472
499
  readonly events: ReadonlyArray<string> | undefined;
473
500
  }, ResumeRefused>;
474
- export { reportingTo as $, serving as A, within as B, pathKey as C, resume as D, refuse as E, Region as F, SsrDiagnostic as G, HandlerUnnamed as H, RenderContext as I, handlerUnnamed as J, StaticRegionMissing as K, UnnamedHandler as L, staticRegion as M, tagOf as N, routeOf as O, Binding as P, pageFailed as Q, current as R, modelFrom as S, projectionsOf as T, PageContained as U, BundleUnloaded as V, PageFailed as W, otherBuild as X, noBuildId as Y, pageContained as Z, bindings as _, PROTOCOL as a, metaEntry as b, ResumableConfig as c, ResumeRefused as d, staticRegionMissing as et, RouteMatch as f, attributeOf as g, allowedTags as h, Meta as i, startingFrom as j, serializeJsonScript as k, ResumePart as l, Start as m, Loadable as n, PlanSurface as o, STATIC_ATTRIBUTE as p, bundleUnloaded as q, META_ATTRIBUTE as r, RESUME_ATTRIBUTE as s, FOLDKIT_APP_ATTRIBUTE as t, ResumePlan as u, bindingsAndEvents as v, plan as w, metaMarkup as x, codecOf as y, withContext as z };
475
- //# sourceMappingURL=shared-v1u-OEQI.d.ts.map
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared-CJN-m58Z.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,0BAA0B;WAChC;WACA;;;KAIC,gBACR,gBACA,sBACA,iBACA,aACA,iBACA;cAES,gBAAa,QAAY,yBAAuB,mBAAmB;cAQnE,WAAW;;cAMX,aAAU,QAAY,OAAO,gBAAc,mBAAmB;cAS9D,sBAAmB,mBAAqB;cAQxC,iBAAc,mBAAqB;cAQnC,aAAU,aAAe,OAAS,MAAM,mBAAiB;cASzD,iBAAc,cAAgB,iBAAiB,kBAAkB;;cAWjE,cAAW,QACb,kCACR,GAAG,GAAG,GAAC,QAAU,OAAO,OAAO,GAAG,GAAG,OAAK,OAAO,OAAO,GAAG,GAAG;cAGpD,oBAAiB,gBAAkB;KCnHpC,SAAS,cAAc;;UAGlB;WACN;WACA;;;;;;;;;UAUM;;WAEN;WACA;WACA;WACA;WACA,OAAO;;WAEP;WACA;;KAGC;WAEG;WACA,SAAS,YAAY;WACrB,YAAY;WACZ,UAAU,MAAM;;WAEhB,YAAY;;EAErB,OAAO;;EAEP;;EAEA;;WAES,UAAU;aACR;aACA;aACA;;;WAGF,SAAS,MAAM;;WAEf,YAAY;;WAGZ;WACA,SAAS,oBAAoB;WAC7B,UAAU,MAAM;WAChB,YAAY;EAC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AE5B,YAAY,MAAM;;;;;;WAMlB,OAAO,cAAc;;;UAIf;WACN;WACA,YAAY;WACZ;;;cAcE,eAAgB,OAAK,QACxB,gBAAgB,QAAM;WACZ,OAAO;WAAgB,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAnCnB,OAAA,OAAA,OAAA;EACb,WAAA;EAEK,gBAAA,SAAS;EACN,mBAAA,SAAS;EAEhB,YAAA,MAAM;EAMX,OAAA,cAAc;;aAuBL,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,2 @@
1
- import { A as serving, C as pathKey, D as resume, E as refuse, M as staticRegion, N as tagOf, O as routeOf, S as modelFrom, T as projectionsOf, _ as bindings, a as PROTOCOL, b as metaEntry, c as ResumableConfig, d as ResumeRefused, f as RouteMatch, g as attributeOf, h as allowedTags, i as Meta, j as startingFrom, k as serializeJsonScript, l as ResumePart, m as Start, 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 bindingsAndEvents, w as plan, x as metaMarkup, y as codecOf } from "./shared-v1u-OEQI.js";
2
- export { FOLDKIT_APP_ATTRIBUTE, Loadable, META_ATTRIBUTE, Meta, PROTOCOL, PlanSurface, RESUME_ATTRIBUTE, ResumableConfig, ResumePart, ResumePlan, ResumeRefused, RouteMatch, STATIC_ATTRIBUTE, Start, allowedTags, attributeOf, bindings, bindingsAndEvents, codecOf, metaEntry, metaMarkup, modelFrom, pathKey, plan, projectionsOf, refuse, resume, routeOf, serializeJsonScript, serving, startingFrom, staticRegion, tagOf };
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 };