brumate 0.3.0 → 0.4.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 (122) hide show
  1. package/README.md +2 -2
  2. package/check.d.ts +49 -0
  3. package/dist/{boot-C25Sa6vq.d.ts → boot-DLlRmD9z.d.ts} +8 -10
  4. package/dist/cli.js +275 -15
  5. package/dist/cli.js.map +1 -1
  6. package/dist/client-BvDsC6Qr.js +3463 -0
  7. package/dist/client-BvDsC6Qr.js.map +1 -0
  8. package/dist/{client-D0CqSxoO.d.ts → client-DBwL2wKQ.d.ts} +390 -181
  9. package/dist/{client-routes-JTbGtukf.js → client-routes-BtGpYCef.js} +60 -30
  10. package/dist/client-routes-BtGpYCef.js.map +1 -0
  11. package/dist/{cookies-BzllthiF.js → cookies-Cnbf4w-S.js} +14 -7
  12. package/dist/cookies-Cnbf4w-S.js.map +1 -0
  13. package/dist/{defer-BbD7JQhj.js → defer-CKWZLv2K.js} +4 -4
  14. package/dist/defer-CKWZLv2K.js.map +1 -0
  15. package/dist/{devtools-CQgD7NPB.js → devtools-4uTPwR_v.js} +56 -82
  16. package/dist/devtools-4uTPwR_v.js.map +1 -0
  17. package/dist/{devtools-panel-BVB-W5q4.js → devtools-panel-Be9pxYgv.js} +397 -333
  18. package/dist/devtools-panel-Be9pxYgv.js.map +1 -0
  19. package/dist/{events-CSs7OwIC.js → events-LgLdp1R7.js} +34 -5
  20. package/dist/events-LgLdp1R7.js.map +1 -0
  21. package/dist/features-CHY5Ekku.js +30 -0
  22. package/dist/features-CHY5Ekku.js.map +1 -0
  23. package/dist/files-WW4RlajL.js +506 -0
  24. package/dist/files-WW4RlajL.js.map +1 -0
  25. package/dist/{forms-Cl21hkHt.d.ts → forms-j1xPAR14.d.ts} +3 -3
  26. package/dist/{forms-Bg-CwGqX.js → forms-nXK7-Lv_.js} +78 -44
  27. package/dist/forms-nXK7-Lv_.js.map +1 -0
  28. package/dist/highlight.js +31 -22
  29. package/dist/highlight.js.map +1 -1
  30. package/dist/{html-mNTKzaDD.js → html-BtKRyi7g.js} +86 -22
  31. package/dist/html-BtKRyi7g.js.map +1 -0
  32. package/dist/{html-Bq1rFxX_.d.ts → html-Bw9Qwu6F.d.ts} +20 -5
  33. package/dist/index.d.ts +96 -10
  34. package/dist/index.js +639 -104
  35. package/dist/index.js.map +1 -1
  36. package/dist/{inspect-BHpOw1LF.js → inspect-Y6y4uNZp.js} +3751 -676
  37. package/dist/inspect-Y6y4uNZp.js.map +1 -0
  38. package/dist/{loader-Dos_3NP0.js → loader-BjKGJzLN.js} +20 -14
  39. package/dist/loader-BjKGJzLN.js.map +1 -0
  40. package/dist/logo-DQ_OYhBi.js +10 -0
  41. package/dist/logo-DQ_OYhBi.js.map +1 -0
  42. package/dist/{navigate-O78d_zGN.js → navigate-CfOr-TRF.js} +94 -31
  43. package/dist/navigate-CfOr-TRF.js.map +1 -0
  44. package/dist/nesting-DA5vJw9X.js +265 -0
  45. package/dist/nesting-DA5vJw9X.js.map +1 -0
  46. package/dist/{produce-Doc91GkX.js → produce-B7X9ori9.js} +137 -9
  47. package/dist/produce-B7X9ori9.js.map +1 -0
  48. package/dist/{produce-D0V0ICkz.d.ts → produce-DIgHBVwL.d.ts} +39 -5
  49. package/dist/{rpc-ygMRPmN4.js → rpc-Q-XkLwFh.js} +11 -6
  50. package/dist/rpc-Q-XkLwFh.js.map +1 -0
  51. package/dist/runtime/batch.js +9 -7
  52. package/dist/runtime/batch.js.map +1 -1
  53. package/dist/runtime/client.d.ts +4 -4
  54. package/dist/runtime/client.js +4 -4
  55. package/dist/runtime/devtools.d.ts +11 -29
  56. package/dist/runtime/devtools.js +3 -1
  57. package/dist/runtime/env.js +14 -2
  58. package/dist/runtime/env.js.map +1 -1
  59. package/dist/runtime/events.d.ts +23 -1
  60. package/dist/runtime/events.js +1 -1
  61. package/dist/runtime/forms.d.ts +2 -2
  62. package/dist/runtime/forms.js +1 -1
  63. package/dist/runtime/hot.d.ts +1 -1
  64. package/dist/runtime/hot.js +5 -2
  65. package/dist/runtime/hot.js.map +1 -1
  66. package/dist/runtime/html.d.ts +2 -2
  67. package/dist/runtime/html.js +1 -1
  68. package/dist/runtime/loader.d.ts +2 -2
  69. package/dist/runtime/loader.js +2 -2
  70. package/dist/runtime/routes.js +4 -1
  71. package/dist/runtime/routes.js.map +1 -1
  72. package/dist/runtime/server.d.ts +5 -5
  73. package/dist/runtime/server.js +5 -5
  74. package/dist/runtime/signals.d.ts +38 -1
  75. package/dist/runtime/signals.js +33 -1
  76. package/dist/runtime/signals.js.map +1 -1
  77. package/dist/runtime/static-loader.d.ts +2 -2
  78. package/dist/runtime/static-loader.js +1 -1
  79. package/dist/runtime/testing.d.ts +18 -3
  80. package/dist/runtime/testing.js +150 -33
  81. package/dist/runtime/testing.js.map +1 -1
  82. package/dist/{server-DuFYRXrd.d.ts → server-BvPIg9pT.d.ts} +84 -22
  83. package/dist/{server-CxVDYE_V.js → server-DjyOVJtJ.js} +598 -164
  84. package/dist/server-DjyOVJtJ.js.map +1 -0
  85. package/dist/{static-loader-Drpr0AzI.d.ts → static-loader-BGgdp_Y5.d.ts} +2 -2
  86. package/dist/{static-loader-nZssh66R.js → static-loader-BZR17hSw.js} +78 -99
  87. package/dist/static-loader-BZR17hSw.js.map +1 -0
  88. package/dist/{stream-DCYZO4IF.js → stream-BP5AVmg5.js} +102 -16
  89. package/dist/stream-BP5AVmg5.js.map +1 -0
  90. package/dist/vite.d.ts +13 -20
  91. package/dist/vite.js +1890 -548
  92. package/dist/vite.js.map +1 -1
  93. package/elements.d.ts +951 -0
  94. package/forms/forms.brm.ts +3 -3
  95. package/package.json +12 -3
  96. package/skills/brumate/SKILL.md +58 -0
  97. package/skills/brumate/references/errors.md +2078 -0
  98. package/skills/brumate/references/events.md +117 -0
  99. package/skills/brumate/references/signals.md +61 -0
  100. package/skills/brumate/references/state.md +235 -0
  101. package/skills/brumate/references/syntax.md +250 -0
  102. package/types.d.ts +4 -4
  103. package/dist/client-BD6XT-s5.js +0 -1968
  104. package/dist/client-BD6XT-s5.js.map +0 -1
  105. package/dist/client-routes-JTbGtukf.js.map +0 -1
  106. package/dist/cookies-BzllthiF.js.map +0 -1
  107. package/dist/defer-BbD7JQhj.js.map +0 -1
  108. package/dist/devtools-CQgD7NPB.js.map +0 -1
  109. package/dist/devtools-panel-BVB-W5q4.js.map +0 -1
  110. package/dist/events-CSs7OwIC.js.map +0 -1
  111. package/dist/files-BXSSrQgc.js +0 -205
  112. package/dist/files-BXSSrQgc.js.map +0 -1
  113. package/dist/forms-Bg-CwGqX.js.map +0 -1
  114. package/dist/html-mNTKzaDD.js.map +0 -1
  115. package/dist/inspect-BHpOw1LF.js.map +0 -1
  116. package/dist/loader-Dos_3NP0.js.map +0 -1
  117. package/dist/navigate-O78d_zGN.js.map +0 -1
  118. package/dist/produce-Doc91GkX.js.map +0 -1
  119. package/dist/rpc-ygMRPmN4.js.map +0 -1
  120. package/dist/server-CxVDYE_V.js.map +0 -1
  121. package/dist/static-loader-nZssh66R.js.map +0 -1
  122. package/dist/stream-DCYZO4IF.js.map +0 -1
@@ -0,0 +1,265 @@
1
+ //#region src/nesting.ts
2
+ /**
3
+ * Elements whose start tag closes an open `<p>`, from the "in body" insertion mode of the HTML
4
+ * spec. `table` is left out, since only a document in quirks mode keeps the `<p>` open.
5
+ */
6
+ const CLOSES_P = /* @__PURE__ */ new Set([
7
+ "address",
8
+ "article",
9
+ "aside",
10
+ "blockquote",
11
+ "center",
12
+ "details",
13
+ "dialog",
14
+ "dir",
15
+ "div",
16
+ "dl",
17
+ "dd",
18
+ "dt",
19
+ "fieldset",
20
+ "figcaption",
21
+ "figure",
22
+ "footer",
23
+ "form",
24
+ "h1",
25
+ "h2",
26
+ "h3",
27
+ "h4",
28
+ "h5",
29
+ "h6",
30
+ "header",
31
+ "hgroup",
32
+ "hr",
33
+ "li",
34
+ "listing",
35
+ "main",
36
+ "menu",
37
+ "nav",
38
+ "ol",
39
+ "p",
40
+ "pre",
41
+ "search",
42
+ "section",
43
+ "summary",
44
+ "ul",
45
+ "xmp"
46
+ ]);
47
+ /** Elements that end the "button scope": a `<p>` above one of them stays open. */
48
+ const BUTTON_SCOPE = /* @__PURE__ */ new Set([
49
+ "applet",
50
+ "button",
51
+ "caption",
52
+ "html",
53
+ "marquee",
54
+ "object",
55
+ "table",
56
+ "td",
57
+ "template",
58
+ "th"
59
+ ]);
60
+ /** Elements that end the list of open `<a>` elements. */
61
+ const LINK_MARKERS = /* @__PURE__ */ new Set([
62
+ "applet",
63
+ "caption",
64
+ "marquee",
65
+ "object",
66
+ "template",
67
+ "td",
68
+ "th"
69
+ ]);
70
+ const HEADINGS = /* @__PURE__ */ new Set([
71
+ "h1",
72
+ "h2",
73
+ "h3",
74
+ "h4",
75
+ "h5",
76
+ "h6"
77
+ ]);
78
+ /** What a table, its sections and its rows hold. Anything else moves out of the table. */
79
+ const TABLE_CHILDREN = {
80
+ table: /* @__PURE__ */ new Set([
81
+ "caption",
82
+ "col",
83
+ "colgroup",
84
+ "form",
85
+ "input",
86
+ "script",
87
+ "style",
88
+ "tbody",
89
+ "td",
90
+ "template",
91
+ "tfoot",
92
+ "th",
93
+ "thead",
94
+ "tr"
95
+ ]),
96
+ tbody: /* @__PURE__ */ new Set([
97
+ "form",
98
+ "input",
99
+ "script",
100
+ "style",
101
+ "td",
102
+ "template",
103
+ "th",
104
+ "tr"
105
+ ]),
106
+ thead: /* @__PURE__ */ new Set([
107
+ "form",
108
+ "input",
109
+ "script",
110
+ "style",
111
+ "td",
112
+ "template",
113
+ "th",
114
+ "tr"
115
+ ]),
116
+ tfoot: /* @__PURE__ */ new Set([
117
+ "form",
118
+ "input",
119
+ "script",
120
+ "style",
121
+ "td",
122
+ "template",
123
+ "th",
124
+ "tr"
125
+ ]),
126
+ tr: /* @__PURE__ */ new Set([
127
+ "form",
128
+ "input",
129
+ "script",
130
+ "style",
131
+ "td",
132
+ "template",
133
+ "th"
134
+ ])
135
+ };
136
+ /** True when a `<p>` is open in button scope in `open`, the tags above an element. */
137
+ function paragraphOpen(open) {
138
+ for (let index = open.length - 1; index >= 0; index--) {
139
+ if (open[index] === "p") return true;
140
+ if (BUTTON_SCOPE.has(open[index])) return false;
141
+ }
142
+ return false;
143
+ }
144
+ /**
145
+ * The tag in `open`, the tags above an element with the nearest last, that the HTML parser closes
146
+ * or moves the element out of, or undefined. The rules come from the HTML spec and are the ones
147
+ * that hold in every document. The parser keeps a document in standard mode, so the same
148
+ * markup parses the same way everywhere.
149
+ */
150
+ function nestingProblem(open, tag) {
151
+ if (open.includes("svg") || open.includes("math")) return;
152
+ const parent = open[open.length - 1];
153
+ if (CLOSES_P.has(tag) && paragraphOpen(open)) return "p";
154
+ if (parent !== void 0) {
155
+ if (HEADINGS.has(parent) && HEADINGS.has(tag)) return parent;
156
+ if (parent === "li" && tag === "li") return parent;
157
+ if ((parent === "dd" || parent === "dt") && (tag === "dd" || tag === "dt")) return parent;
158
+ const allowed = TABLE_CHILDREN[parent];
159
+ if (allowed && !allowed.has(tag)) return parent;
160
+ }
161
+ if (tag === "a") for (let index = open.length - 1; index >= 0; index--) {
162
+ if (open[index] === "a") return "a";
163
+ if (LINK_MARKERS.has(open[index])) break;
164
+ }
165
+ if (tag === "form") for (let index = open.length - 1; index >= 0; index--) {
166
+ if (open[index] === "form") return "form";
167
+ if (open[index] === "template") break;
168
+ }
169
+ if (tag === "button") for (let index = open.length - 1; index >= 0; index--) {
170
+ if (open[index] === "button") return "button";
171
+ if (BUTTON_SCOPE.has(open[index])) break;
172
+ }
173
+ }
174
+ /** The message of BRM185. */
175
+ function nestingMessage(tag, parent) {
176
+ return `<${tag}> cannot be inside <${parent}>: the HTML parser closes or moves it before the page runs. Move it out of the <${parent}>, or use a <span> or as="span"`;
177
+ }
178
+ /** Walks the markup of a file, with the tags that are open above each node. */
179
+ function walk(file, onElement, onComponent) {
180
+ function body(content, open) {
181
+ if (!content) return;
182
+ for (const template of content.templates) body(template.body, []);
183
+ nodes(content.children, open);
184
+ }
185
+ function nodes(list, open) {
186
+ for (const node of list) visit(node, open);
187
+ }
188
+ function visit(node, open) {
189
+ switch (node.kind) {
190
+ case "element": {
191
+ const tag = node.tag.toLowerCase();
192
+ onElement(tag, open, node);
193
+ open.push(tag);
194
+ nodes(node.children, open);
195
+ open.pop();
196
+ return;
197
+ }
198
+ case "component":
199
+ onComponent(node, open);
200
+ nodes(node.children, []);
201
+ return;
202
+ case "dynamic":
203
+ nodes(node.children, []);
204
+ return;
205
+ case "fragment":
206
+ nodes(node.children, open);
207
+ return;
208
+ case "if":
209
+ for (const branch of node.branches) body(branch.body, open);
210
+ body(node.fallback, open);
211
+ return;
212
+ case "switch":
213
+ for (const branch of node.cases) body(branch.body, open);
214
+ body(node.fallback, open);
215
+ return;
216
+ case "for":
217
+ case "repeat":
218
+ case "loading":
219
+ case "client":
220
+ case "defer":
221
+ case "try":
222
+ body(node.body, open);
223
+ body(node.fallback, open);
224
+ return;
225
+ case "key":
226
+ body(node.body, open);
227
+ return;
228
+ case "portal":
229
+ case "head":
230
+ case "offscreen":
231
+ body(node.body, []);
232
+ return;
233
+ default: return;
234
+ }
235
+ }
236
+ for (const template of file.templates) body(template.body, []);
237
+ nodes(file.children, []);
238
+ }
239
+ /** Reports each element that the HTML parser closes or moves, as BRM185. */
240
+ function checkNesting(file, report) {
241
+ walk(file, (tag, open, node) => {
242
+ const parent = nestingProblem(open, tag);
243
+ if (parent !== void 0) report(nestingMessage(tag, parent), node);
244
+ }, () => {});
245
+ }
246
+ /** The components that sit inside a `<p>`, which the server checks in development. */
247
+ function paragraphComponents(file) {
248
+ const found = /* @__PURE__ */ new Set();
249
+ walk(file, () => {}, (node, open) => {
250
+ if (!open.includes("svg") && !open.includes("math") && paragraphOpen(open)) found.add(node);
251
+ });
252
+ return found;
253
+ }
254
+ /** The tag that the HTML starts with, skipping comments, or undefined. */
255
+ function firstTag(html) {
256
+ return /^(?:\s|<!--[^>]*?-->)*<([a-z][a-z0-9-]*)/i.exec(html)?.[1]?.toLowerCase();
257
+ }
258
+ /** True when a start tag of `tag` closes an open `<p>`. */
259
+ function closesParagraph(tag) {
260
+ return CLOSES_P.has(tag);
261
+ }
262
+ //#endregion
263
+ export { paragraphComponents as i, closesParagraph as n, firstTag as r, checkNesting as t };
264
+
265
+ //# sourceMappingURL=nesting-DA5vJw9X.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nesting-DA5vJw9X.js","names":[],"sources":["../src/nesting.ts"],"sourcesContent":["import type { Body, ComponentNode, Markup, Range, SFCFile } from './ast.ts';\n\n/**\n * Elements whose start tag closes an open `<p>`, from the \"in body\" insertion mode of the HTML\n * spec. `table` is left out, since only a document in quirks mode keeps the `<p>` open.\n */\nconst CLOSES_P = new Set([\n 'address',\n 'article',\n 'aside',\n 'blockquote',\n 'center',\n 'details',\n 'dialog',\n 'dir',\n 'div',\n 'dl',\n 'dd',\n 'dt',\n 'fieldset',\n 'figcaption',\n 'figure',\n 'footer',\n 'form',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'header',\n 'hgroup',\n 'hr',\n 'li',\n 'listing',\n 'main',\n 'menu',\n 'nav',\n 'ol',\n 'p',\n 'pre',\n 'search',\n 'section',\n 'summary',\n 'ul',\n 'xmp',\n]);\n\n/** Elements that end the \"button scope\": a `<p>` above one of them stays open. */\nconst BUTTON_SCOPE = new Set([\n 'applet',\n 'button',\n 'caption',\n 'html',\n 'marquee',\n 'object',\n 'table',\n 'td',\n 'template',\n 'th',\n]);\n\n/** Elements that end the list of open `<a>` elements. */\nconst LINK_MARKERS = new Set(['applet', 'caption', 'marquee', 'object', 'template', 'td', 'th']);\n\nconst HEADINGS = new Set(['h1', 'h2', 'h3', 'h4', 'h5', 'h6']);\n\n/** What a table, its sections and its rows hold. Anything else moves out of the table. */\nconst TABLE_CHILDREN: Record<string, ReadonlySet<string>> = {\n table: new Set([\n 'caption',\n 'col',\n 'colgroup',\n 'form',\n 'input',\n 'script',\n 'style',\n 'tbody',\n 'td',\n 'template',\n 'tfoot',\n 'th',\n 'thead',\n 'tr',\n ]),\n tbody: new Set(['form', 'input', 'script', 'style', 'td', 'template', 'th', 'tr']),\n thead: new Set(['form', 'input', 'script', 'style', 'td', 'template', 'th', 'tr']),\n tfoot: new Set(['form', 'input', 'script', 'style', 'td', 'template', 'th', 'tr']),\n tr: new Set(['form', 'input', 'script', 'style', 'td', 'template', 'th']),\n};\n\n/** True when a `<p>` is open in button scope in `open`, the tags above an element. */\nfunction paragraphOpen(open: readonly string[]): boolean {\n for (let index = open.length - 1; index >= 0; index--) {\n if (open[index] === 'p') {\n return true;\n }\n if (BUTTON_SCOPE.has(open[index]!)) {\n return false;\n }\n }\n return false;\n}\n\n/**\n * The tag in `open`, the tags above an element with the nearest last, that the HTML parser closes\n * or moves the element out of, or undefined. The rules come from the HTML spec and are the ones\n * that hold in every document. The parser keeps a document in standard mode, so the same\n * markup parses the same way everywhere.\n */\nexport function nestingProblem(open: readonly string[], tag: string): string | undefined {\n // Inside `<svg>` and `<math>` the parser follows other rules.\n if (open.includes('svg') || open.includes('math')) {\n return undefined;\n }\n const parent = open[open.length - 1];\n if (CLOSES_P.has(tag) && paragraphOpen(open)) {\n return 'p';\n }\n if (parent !== undefined) {\n // `<h1><h2>` closes the first heading. `<li><li>` and `<dd><dt>` close the item.\n if (HEADINGS.has(parent) && HEADINGS.has(tag)) {\n return parent;\n }\n if (parent === 'li' && tag === 'li') {\n return parent;\n }\n if ((parent === 'dd' || parent === 'dt') && (tag === 'dd' || tag === 'dt')) {\n return parent;\n }\n const allowed = TABLE_CHILDREN[parent];\n if (allowed && !allowed.has(tag)) {\n return parent;\n }\n }\n // `<a>` inside `<a>` splits the link. `<form>` inside `<form>` is dropped. `<button>` inside\n // `<button>` closes the first.\n if (tag === 'a') {\n for (let index = open.length - 1; index >= 0; index--) {\n if (open[index] === 'a') {\n return 'a';\n }\n if (LINK_MARKERS.has(open[index]!)) {\n break;\n }\n }\n }\n if (tag === 'form') {\n for (let index = open.length - 1; index >= 0; index--) {\n if (open[index] === 'form') {\n return 'form';\n }\n if (open[index] === 'template') {\n break;\n }\n }\n }\n if (tag === 'button') {\n for (let index = open.length - 1; index >= 0; index--) {\n if (open[index] === 'button') {\n return 'button';\n }\n if (BUTTON_SCOPE.has(open[index]!)) {\n break;\n }\n }\n }\n return undefined;\n}\n\n/** The message of BRM185. */\nexport function nestingMessage(tag: string, parent: string): string {\n return `<${tag}> cannot be inside <${parent}>: the HTML parser closes or moves it before the page runs. Move it out of the <${parent}>, or use a <span> or as=\"span\"`;\n}\n\n/** Walks the markup of a file, with the tags that are open above each node. */\nfunction walk(\n file: SFCFile,\n onElement: (tag: string, open: string[], node: Range) => void,\n onComponent: (node: ComponentNode, open: string[]) => void,\n): void {\n function body(content: Body | undefined, open: string[]): void {\n if (!content) {\n return;\n }\n for (const template of content.templates) {\n body(template.body, []);\n }\n nodes(content.children, open);\n }\n\n function nodes(list: Markup[], open: string[]): void {\n for (const node of list) {\n visit(node, open);\n }\n }\n\n function visit(node: Markup, open: string[]): void {\n switch (node.kind) {\n case 'element': {\n const tag = node.tag.toLowerCase();\n onElement(tag, open, node);\n open.push(tag);\n nodes(node.children, open);\n open.pop();\n return;\n }\n case 'component':\n onComponent(node, open);\n // Children render where the component puts them.\n nodes(node.children, []);\n return;\n case 'dynamic':\n // The tag is not known.\n nodes(node.children, []);\n return;\n case 'fragment':\n nodes(node.children, open);\n return;\n case 'if':\n for (const branch of node.branches) {\n body(branch.body, open);\n }\n body(node.fallback, open);\n return;\n case 'switch':\n for (const branch of node.cases) {\n body(branch.body, open);\n }\n body(node.fallback, open);\n return;\n case 'for':\n case 'repeat':\n case 'loading':\n case 'client':\n case 'defer':\n case 'try':\n body(node.body, open);\n body(node.fallback, open);\n return;\n case 'key':\n body(node.body, open);\n return;\n case 'portal':\n case 'head':\n case 'offscreen':\n // These render somewhere else, or in an element that is not known.\n body(node.body, []);\n return;\n default:\n return;\n }\n }\n\n for (const template of file.templates) {\n body(template.body, []);\n }\n nodes(file.children, []);\n}\n\n/** Reports each element that the HTML parser closes or moves, as BRM185. */\nexport function checkNesting(file: SFCFile, report: (message: string, at: Range) => void): void {\n walk(\n file,\n (tag, open, node) => {\n const parent = nestingProblem(open, tag);\n if (parent !== undefined) {\n report(nestingMessage(tag, parent), node);\n }\n },\n () => {},\n );\n}\n\n/** The components that sit inside a `<p>`, which the server checks in development. */\nexport function paragraphComponents(file: SFCFile): Set<ComponentNode> {\n const found = new Set<ComponentNode>();\n walk(\n file,\n () => {},\n (node, open) => {\n if (!open.includes('svg') && !open.includes('math') && paragraphOpen(open)) {\n found.add(node);\n }\n },\n );\n return found;\n}\n\n/** The tag that the HTML starts with, skipping comments, or undefined. */\nexport function firstTag(html: string): string | undefined {\n return /^(?:\\s|<!--[^>]*?-->)*<([a-z][a-z0-9-]*)/i.exec(html)?.[1]?.toLowerCase();\n}\n\n/** True when a start tag of `tag` closes an open `<p>`. */\nexport function closesParagraph(tag: string): boolean {\n return CLOSES_P.has(tag);\n}\n"],"mappings":";;;;;AAMA,MAAM,2BAAW,IAAI,IAAI;CACvB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;AAGD,MAAM,+BAAe,IAAI,IAAI;CAC3B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;AAGD,MAAM,+BAAe,IAAI,IAAI;CAAC;CAAU;CAAW;CAAW;CAAU;CAAY;CAAM;AAAI,CAAC;AAE/F,MAAM,2BAAW,IAAI,IAAI;CAAC;CAAM;CAAM;CAAM;CAAM;CAAM;AAAI,CAAC;;AAG7D,MAAM,iBAAsD;CAC1D,uBAAO,IAAI,IAAI;EACb;EACA;EACA;EACA;EACA;EACA;EAC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,KAAK,MAAM,UAAU,KAAK,OACxB,KAAK,OAAO,MAAM,IAAI;IAExB,KAAK,KAAK,UAAU,IAAI;IACxB;GACF,KAAK;GACL,KAAK;GACL,KAAK;GACL,KAAK;GACL,KAAK;GACL,KAAK;IACH,KAAK,KAAK,MAAM,IAAI;IACpB,KAAK,KAAK,UAAU,IAAI;IACxB;GACF,KAAK;IACH,KAAK,KAAK,MAAM,IAAI;IACpB;GACF,KAAK;GACL,KAAK;GACL,KAAK;IAEH,KAAK,KAAK,MAAM,CAAC,CAAC;IAClB;GACF,SACE;EACJ;CACF;CAEA,KAAK,MAAM,YAAY,KAAK,WAC1B,KAAK,SAAS,MAAM,CAAC,CAAC;CAExB,MAAM,KAAK,UAAU,CAAC,CAAC;AACzB;;AAGA,SAAgB,aAAa,MAAe,QAAoD;CAC9F,KACE,OACC,KAAK,MAAM,SAAS;EACnB,MAAM,SAAS,eAAe,MAAM,GAAG;EACvC,IAAI,WAAW,KAAA,GACb,OAAO,eAAe,KAAK,MAAM,GAAG,IAAI;CAE5C,SACM,CAAC,CACT;AACF;;AAGA,SAAgB,oBAAoB,MAAmC;CACrE,MAAM,wBAAQ,IAAI,IAAmB;CACrC,KACE,YACM,CAAC,IACN,MAAM,SAAS;EACd,IAAI,CAAC,KAAK,SAAS,KAAK,KAAK,CAAC,KAAK,SAAS,MAAM,KAAK,cAAc,IAAI,GACvE,MAAM,IAAI,IAAI;CAElB,CACF;CACA,OAAO;AACT;;AAGA,SAAgB,SAAS,MAAkC;CACzD,OAAO,4CAA4C,KAAK,IAAI,CAAC,GAAG,EAAE,EAAE,YAAY;AAClF;;AAGA,SAAgB,gBAAgB,KAAsB;CACpD,OAAO,SAAS,IAAI,GAAG;AACzB"}
@@ -1,4 +1,5 @@
1
- import { g as raw } from "./html-mNTKzaDD.js";
1
+ import { b as raw, t as Internal, y as ownValue } from "./html-BtKRyi7g.js";
2
+ import { i as HAS_CHILDREN, n as HAS_BINDINGS } from "./features-CHY5Ekku.js";
2
3
  //#region src/runtime/shared.ts
3
4
  /** The plugins of values of the app, by tag, which the entry `src/serial.ts` exports. */
4
5
  const valuePlugins = /* @__PURE__ */ new Map();
@@ -51,6 +52,26 @@ var ElementReference = class {
51
52
  }
52
53
  };
53
54
  /** A client function: an export of a client module, and the scope it reads. */
55
+ /** The key of the reference of children on the server, which the page state sends. */
56
+ const CHILDREN_REF = Symbol.for("brumate.children");
57
+ /**
58
+ * The children of a component in the page state: the export that renders them in the browser,
59
+ * such as `Page_1a2b#n0`, and the scope that they were written in. Each insert renders them
60
+ * again, with new scopes, as the body of a block does.
61
+ */
62
+ var ChildrenReference = class {
63
+ ref;
64
+ scope;
65
+ /** The scope and the anchor of the insert where the server rendered them, if it did. */
66
+ at;
67
+ anchor;
68
+ constructor(ref, scope, at, anchor) {
69
+ this.ref = ref;
70
+ this.scope = scope;
71
+ this.at = at;
72
+ this.anchor = anchor;
73
+ }
74
+ };
54
75
  var FunctionReference = class {
55
76
  /** `<component id>#<export name>`. */
56
77
  ref;
@@ -66,6 +87,36 @@ var FunctionReference = class {
66
87
  this.modifiers = modifiers;
67
88
  }
68
89
  };
90
+ /** The handlers that a merged handler calls, in order. A symbol of the registry. */
91
+ const PARTS = Symbol.for("brumate.parts");
92
+ /**
93
+ * One handler that calls each of `handlers` in order, with the same arguments. A prop holds one
94
+ * handler per event, and the browser takes one `b-on` entry for each part. Merged handlers in
95
+ * `handlers` give their parts, so the list stays flat.
96
+ */
97
+ function mergeHandlers(handlers) {
98
+ const parts = [];
99
+ for (const handler of handlers) parts.push(...handler[PARTS] ?? [handler]);
100
+ return Object.assign((...args) => {
101
+ for (const part of parts) part(...args);
102
+ }, { [PARTS]: parts });
103
+ }
104
+ /**
105
+ * Adds a handler prop, such as `onClick`, for each entry of the scoped `b-on` of a dynamic tag
106
+ * that names a component. `make` makes the handler of a reference. A handler of the same event in
107
+ * `props`, such as a rest prop passed on, is merged with it and runs first.
108
+ */
109
+ function addEntryHandlers(props, entries, scope, make) {
110
+ for (const entry of ownValue("b-on", entries)?.split(" ") ?? []) {
111
+ const [event, target] = entry.split("=");
112
+ const [name, ...modifiers] = event.split(":");
113
+ const [ref, at] = target.split("@");
114
+ const handler = make(new FunctionReference(ref, /^\d+$/.test(at ?? "") ? Number(at) : at ?? scope, void 0, modifiers.length > 0 ? modifiers : void 0));
115
+ const key = `on${name[0].toUpperCase()}${name.slice(1)}`;
116
+ const before = props[key];
117
+ props[key] = typeof before === "function" ? mergeHandlers([before, handler]) : handler;
118
+ }
119
+ }
69
120
  const BINDING = Symbol.for("brumate.binding");
70
121
  const SLOT = Symbol.for("brumate.slot");
71
122
  /** A slot of a scope, which a write of a bound prop goes to. */
@@ -110,12 +161,19 @@ Binding.prototype[BINDING] = true;
110
161
  * The props that a component destructures, with the values of their
111
162
  * bindings. `names` are the props that it destructures by name: the others,
112
163
  * which a rest prop holds, keep their bindings, so a spread passes them on.
113
- * Without `names`, every binding gives its value.
164
+ * Without `names`, every binding gives its value. `omit` are props that a rest
165
+ * leaves out, because another `$props()` call of the component names them.
114
166
  */
115
- function unbind(props, names) {
167
+ function unbind(props, names, omit, sink) {
116
168
  let result;
169
+ if (omit) {
170
+ result = { ...props };
171
+ for (const key of omit) delete result[key];
172
+ props = result;
173
+ }
117
174
  for (const key of names ?? Object.keys(props)) {
118
175
  const value = props[key];
176
+ if (sink && value instanceof Promise) (sink.props ??= []).push(value);
119
177
  if (isBinding(value)) {
120
178
  result ??= { ...props };
121
179
  result[key] = value.value;
@@ -124,6 +182,37 @@ function unbind(props, names) {
124
182
  return result ?? props;
125
183
  }
126
184
  /**
185
+ * What the slot of a memo holds while its compute throws or its promise rejects, and a memo that
186
+ * failed on the server holds from the page state. Each read of the slot throws the error.
187
+ */
188
+ var MemoError = class {
189
+ error;
190
+ constructor(error) {
191
+ this.error = error;
192
+ }
193
+ };
194
+ /**
195
+ * A promise that a parent passed as a prop. It stays a promise in the child, so `await` and
196
+ * `then` work on it. The page state holds it in this wrapper, so the browser knows the slot is
197
+ * a prop and does not replace the promise with its value, as it does for a memo that streams.
198
+ */
199
+ var PropPromise = class {
200
+ promise;
201
+ constructor(promise) {
202
+ this.promise = promise;
203
+ this[PROP_WRAPPER] = true;
204
+ }
205
+ };
206
+ const PROP_WRAPPER = Symbol.for("brumate.propWrapper");
207
+ /** True for the wrapper that holds a promise prop in the page state. */
208
+ function isPropWrapper(value) {
209
+ return typeof value === "object" && value !== null && PROP_WRAPPER in value;
210
+ }
211
+ /** The value of a feature that the build turned off, which no page state of it holds. */
212
+ function unused() {
213
+ throw new Error("The page state holds a value of a feature that no component of the build uses");
214
+ }
215
+ /**
127
216
  * Makes the values of brumate's plugins. A state record calls them as `$b`,
128
217
  * with one letter each, and the plugins read nodes of server function calls
129
218
  * with them too, so both give the same values.
@@ -131,10 +220,15 @@ function unbind(props, names) {
131
220
  const stateValues = {
132
221
  e: (scope, anchor) => new ElementReference(scope, anchor),
133
222
  f: (ref, scope, args, modifiers) => new FunctionReference(ref, scope, args, modifiers),
223
+ m: (parts) => Object.assign(parts, { [PARTS]: parts }),
224
+ i: (value) => new Internal(value),
134
225
  r: raw,
226
+ n: HAS_CHILDREN ? (ref, scope, at, anchor) => new ChildrenReference(ref, scope, at, anchor) : unused,
135
227
  c: (id) => Object.assign(() => "", { brumateId: id }),
136
228
  l: (scope, slot) => new SlotReference(scope, slot),
137
- b: (value, scope, slot, set) => new Binding(value, new SlotReference(scope, slot), set),
229
+ b: HAS_BINDINGS ? (value, scope, slot, set) => new Binding(value, new SlotReference(scope, slot), set) : unused,
230
+ q: (promise) => new PropPromise(promise),
231
+ x: (error) => new MemoError(error),
138
232
  u: (tag, data) => {
139
233
  const plugin = valuePlugins.get(tag);
140
234
  if (!plugin) throw new Error(`No plugin reads the value "${tag}". Export it in the plugins of the serial entry, src/serial.ts`);
@@ -145,6 +239,40 @@ const stateValues = {
145
239
  function isAsyncIterable(value) {
146
240
  return value !== null && typeof value === "object" && typeof value[Symbol.asyncIterator] === "function";
147
241
  }
242
+ /**
243
+ * A table of the fields of a state record and the reference classes that hold
244
+ * a scope ID, which each keep it in `scope`. Code that moves the IDs reads it.
245
+ * A new field of `ScopeState` fails to compile until it is in `fields`, and
246
+ * `holders` are the classes that keep references in their own fields, such as
247
+ * `Binding`, whose `ref` and `set` hold IDs. `scope-ids.test.ts` parses this
248
+ * file and fails for any class in it, of any shape, that is not in
249
+ * `references` or `holders` or in the test's list of classes without IDs.
250
+ * It checks class names only, so a person decides which list a new class
251
+ * belongs in.
252
+ */
253
+ const SCOPE_IDS = {
254
+ fields: {
255
+ k: "none",
256
+ p: "id",
257
+ m: "none",
258
+ i: "value",
259
+ o: "id",
260
+ t: "id",
261
+ f: "id",
262
+ v: "map",
263
+ x: "none",
264
+ s: "values",
265
+ c: "ids",
266
+ b: "map"
267
+ },
268
+ references: [
269
+ ElementReference,
270
+ FunctionReference,
271
+ ChildrenReference,
272
+ SlotReference
273
+ ],
274
+ holders: [Binding]
275
+ };
148
276
  //#endregion
149
277
  //#region src/runtime/produce.ts
150
278
  const DRAFT = Symbol("brumate.draft");
@@ -166,7 +294,7 @@ function prepare(state) {
166
294
  }
167
295
  return state.copy;
168
296
  }
169
- function stateOf(value) {
297
+ function getDraftState(value) {
170
298
  return typeof value === "object" && value !== null ? value[DRAFT] : void 0;
171
299
  }
172
300
  function createDraft(base, parent) {
@@ -238,7 +366,7 @@ function finalize(state) {
238
366
  const copy = state.copy;
239
367
  for (const [key, child] of state.children) if (copy[key] === child.base) copy[key] = finalize(child);
240
368
  for (const key of Reflect.ownKeys(copy)) {
241
- const draft = stateOf(copy[key]);
369
+ const draft = getDraftState(copy[key]);
242
370
  if (draft) copy[key] = finalize(draft);
243
371
  }
244
372
  return copy;
@@ -261,7 +389,7 @@ function produce(base, recipe) {
261
389
  }
262
390
  /** Replaces the drafts in a value that a recipe returns, such as the result of `draft.filter(…)`. */
263
391
  function resolve(value, seen) {
264
- const draft = stateOf(value);
392
+ const draft = getDraftState(value);
265
393
  if (draft) return finalize(draft);
266
394
  if (!isDraftable(value) || seen.has(value)) return value;
267
395
  seen.add(value);
@@ -269,6 +397,6 @@ function resolve(value, seen) {
269
397
  return value;
270
398
  }
271
399
  //#endregion
272
- export { SlotReference as a, isSlotReference as c, parseId as d, stateValues as f, FunctionReference as i, onSerialOptions as l, useSerialEntry as m, Binding as n, isAsyncIterable as o, unbind as p, ElementReference as r, isBinding as s, produce as t, onValuePlugin as u };
400
+ export { useSerialEntry as C, unbind as S, mergeHandlers as _, ElementReference as a, parseId as b, PARTS as c, SlotReference as d, addEntryHandlers as f, isSlotReference as g, isPropWrapper as h, ChildrenReference as i, PropPromise as l, isBinding as m, Binding as n, FunctionReference as o, isAsyncIterable as p, CHILDREN_REF as r, MemoError as s, produce as t, SCOPE_IDS as u, onSerialOptions as v, stateValues as x, onValuePlugin as y };
273
401
 
274
- //# sourceMappingURL=produce-Doc91GkX.js.map
402
+ //# sourceMappingURL=produce-B7X9ori9.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"produce-B7X9ori9.js","names":[],"sources":["../src/runtime/shared.ts","../src/runtime/produce.ts"],"sourcesContent":["// Values and types that the server and the browser share. It does not import\n// seroval, so the core, which reads the page state without it, stays small.\n// The plugins that write and read these values are in `serial.ts`.\n\nimport { HAS_BINDINGS, HAS_CHILDREN } from './features.ts';\nimport { Internal, ownValue, raw } from './html.ts';\nimport type { Raw } from './html.ts';\nimport type { SerialEntry, ValuePlugin } from './values.ts';\n\n/** The plugins of values of the app, by tag, which the entry `src/serial.ts` exports. */\nconst valuePlugins = new Map<string, ValuePlugin>();\nconst pluginListeners: ((plugin: ValuePlugin) => void)[] = [];\n/** The options of the entry, which the serializer reads when it loads. */\nlet entryOptions: Omit<SerialEntry, 'plugins'> = {};\nconst optionListeners: ((options: Omit<SerialEntry, 'plugins'>) => void)[] = [];\n\n/**\n * Takes the exports of the serial entry: its plugins and the options that it\n * changes. The server and the loader call it before the first value is\n * written or read.\n */\nexport function useSerialEntry(entry: SerialEntry): void {\n const { plugins = [], ...options } = entry;\n if (options.disabledFeatures !== undefined || options.depthLimit !== undefined) {\n entryOptions = options;\n for (const listener of optionListeners) {\n listener(options);\n }\n }\n registerValues(plugins);\n}\n\n/** Calls `listener` with the options of the entry, now and when they change. */\nexport function onSerialOptions(listener: (options: Omit<SerialEntry, 'plugins'>) => void): void {\n optionListeners.push(listener);\n listener(entryOptions);\n}\n\n/** Adds plugins of values of the app. */\nfunction registerValues(plugins: readonly ValuePlugin[]): void {\n for (const plugin of plugins) {\n if (valuePlugins.get(plugin.tag) === plugin) {\n continue;\n }\n valuePlugins.set(plugin.tag, plugin);\n for (const listener of pluginListeners) {\n listener(plugin);\n }\n }\n}\n\n/** Calls `listener` for each plugin of the app, those added so far and those added later. */\nexport function onValuePlugin(listener: (plugin: ValuePlugin) => void): void {\n pluginListeners.push(listener);\n for (const plugin of valuePlugins.values()) {\n listener(plugin);\n }\n}\n\n/**\n * The ID of a scope or of a `#loading` boundary. The rest of the page numbers\n * its scopes from the base of the render, such as `3`. A `#loading` body\n * numbers its own from 0 after the ID of its boundary and a dot, such as\n * `5.0` and `5.1`, so its IDs do not depend on when its data arrives.\n */\nexport type ScopeId = number | string;\n\n/** Reads a scope or boundary ID from markup. */\nexport function parseId(text: string): ScopeId {\n return /^-?\\d+$/.test(text) ? Number(text) : text;\n}\n\n/** Adds a number to an ID. An ID inside a boundary moves with its boundary. */\nexport function shiftId(id: ScopeId, by: number): ScopeId {\n if (typeof id === 'number') {\n return id + by;\n }\n const dot = id.indexOf('.');\n return `${Number(id.slice(0, dot)) + by}${id.slice(dot)}`;\n}\n\n/** An element that the server rendered. The client finds it by its anchor. */\nexport class ElementReference {\n readonly scope: ScopeId;\n readonly anchor: number;\n\n constructor(scope: ScopeId, anchor: number) {\n this.scope = scope;\n this.anchor = anchor;\n }\n}\n\n/** A client function: an export of a client module, and the scope it reads. */\n/** The key of the reference of children on the server, which the page state sends. */\nexport const CHILDREN_REF: unique symbol = Symbol.for('brumate.children') as never;\n\n/**\n * The children of a component in the page state: the export that renders them in the browser,\n * such as `Page_1a2b#n0`, and the scope that they were written in. Each insert renders them\n * again, with new scopes, as the body of a block does.\n */\nexport class ChildrenReference {\n readonly ref: string;\n readonly scope: ScopeId;\n /** The scope and the anchor of the insert where the server rendered them, if it did. */\n at: ScopeId | undefined;\n anchor: number | undefined;\n\n constructor(ref: string, scope: ScopeId, at?: ScopeId, anchor?: number) {\n this.ref = ref;\n this.scope = scope;\n this.at = at;\n this.anchor = anchor;\n }\n}\n\nexport class FunctionReference {\n /** `<component id>#<export name>`. */\n readonly ref: string;\n readonly scope: ScopeId;\n /** The arguments of a handler that `$handler` made, which come before the event. */\n readonly args: unknown[] | undefined;\n /** The modifiers of the wrappers of a handler, such as `prevent`, for the `b-on` of a spread. */\n readonly modifiers: string[] | undefined;\n\n constructor(ref: string, scope: ScopeId, args?: unknown[] | null, modifiers?: string[]) {\n this.ref = ref;\n this.scope = scope;\n this.args = args ?? undefined;\n this.modifiers = modifiers;\n }\n}\n\n/** The handlers that a merged handler calls, in order. A symbol of the registry. */\nexport const PARTS: unique symbol = Symbol.for('brumate.parts');\n\n// oxlint-disable-next-line typescript/no-explicit-any -- Handlers take any event.\ntype Handler = (...args: any[]) => unknown;\n\n/**\n * One handler that calls each of `handlers` in order, with the same arguments. A prop holds one\n * handler per event, and the browser takes one `b-on` entry for each part. Merged handlers in\n * `handlers` give their parts, so the list stays flat.\n */\nexport function mergeHandlers(handlers: Handler[]): Handler {\n const parts: Handler[] = [];\n for (const handler of handlers) {\n parts.push(...((handler as { [PARTS]?: Handler[] })[PARTS] ?? [handler]));\n }\n return Object.assign(\n (...args: unknown[]): void => {\n for (const part of parts) {\n part(...args);\n }\n },\n { [PARTS]: parts },\n );\n}\n\n/**\n * Adds a handler prop, such as `onClick`, for each entry of the scoped `b-on` of a dynamic tag\n * that names a component. `make` makes the handler of a reference. A handler of the same event in\n * `props`, such as a rest prop passed on, is merged with it and runs first.\n */\nexport function addEntryHandlers(\n props: Record<string, unknown>,\n entries: unknown,\n scope: ScopeId | undefined,\n make: (reference: FunctionReference) => Handler,\n): void {\n for (const entry of (ownValue('b-on', entries) as string | undefined)?.split(' ') ?? []) {\n const [event, target] = entry.split('=') as [string, string];\n const [name, ...modifiers] = event.split(':') as [string, ...string[]];\n const [ref, at] = target.split('@') as [string, string?];\n const handler = make(\n new FunctionReference(\n ref,\n /^\\d+$/.test(at ?? '') ? Number(at) : (at ?? scope!),\n undefined,\n modifiers.length > 0 ? modifiers : undefined,\n ),\n );\n const key = `on${name[0]!.toUpperCase()}${name.slice(1)}`;\n const before = props[key];\n props[key] =\n typeof before === 'function' ? mergeHandlers([before as Handler, handler]) : handler;\n }\n}\n\n// Brands of bindings and slot references, under keys of the registry, so two copies of the\n// runtime, such as a component's and the render context's, know each other's.\nconst BINDING = Symbol.for('brumate.binding');\nconst SLOT = Symbol.for('brumate.slot');\n\n/** A slot of a scope, which a write of a bound prop goes to. */\nexport class SlotReference {\n readonly scope: ScopeId;\n readonly slot: number;\n\n constructor(scope: ScopeId, slot: number) {\n this.scope = scope;\n this.slot = slot;\n }\n}\n\n(SlotReference.prototype as unknown as Record<symbol, boolean>)[SLOT] = true;\n\n/** True for a slot reference of any copy of the runtime. */\nexport function isSlotReference(value: unknown): value is SlotReference {\n return typeof value === 'object' && value !== null && SLOT in value;\n}\n\n/** True for a binding of any copy of the runtime. */\nexport function isBinding(value: unknown): value is Binding {\n return typeof value === 'object' && value !== null && BINDING in value;\n}\n\n/**\n * What `$bind(name)` passes a child: the value of the name, and its slot,\n * which the child's writes of the prop go to.\n */\nexport class Binding<T = unknown> {\n readonly value: T;\n readonly ref: SlotReference;\n /** The function of `$bind(name, fn)`, which a write calls in place of writing the slot. */\n readonly set: unknown;\n\n constructor(value: T, ref: SlotReference, set?: unknown) {\n this.value = value;\n this.ref = ref;\n this.set = set;\n }\n\n /** What a write of the bound prop goes to: the setter, or else the slot. */\n get target(): unknown {\n return this.set ?? this.ref;\n }\n}\n\n(Binding.prototype as unknown as Record<symbol, boolean>)[BINDING] = true;\n\n/**\n * The props that a component destructures, with the values of their\n * bindings. `names` are the props that it destructures by name: the others,\n * which a rest prop holds, keep their bindings, so a spread passes them on.\n * Without `names`, every binding gives its value. `omit` are props that a rest\n * leaves out, because another `$props()` call of the component names them.\n */\nexport function unbind(\n props: Record<string, unknown>,\n names?: readonly string[],\n omit?: readonly string[],\n sink?: PropSink,\n): Record<string, unknown> {\n let result: Record<string, unknown> | undefined;\n // The props that another `$props()` call of the component names, which a rest leaves out.\n if (omit) {\n result = { ...props };\n for (const key of omit) {\n delete result[key];\n }\n props = result;\n }\n for (const key of names ?? Object.keys(props)) {\n const value = props[key];\n if (sink && value instanceof Promise) {\n (sink.props ??= []).push(value);\n }\n if (isBinding(value)) {\n result ??= { ...props };\n result[key] = value.value;\n }\n }\n return result ?? props;\n}\n\n/**\n * What the slot of a memo holds while its compute throws or its promise rejects, and a memo that\n * failed on the server holds from the page state. Each read of the slot throws the error.\n */\nexport class MemoError {\n readonly error: unknown;\n\n constructor(error: unknown) {\n this.error = error;\n }\n}\n\n/**\n * A promise that a parent passed as a prop. It stays a promise in the child, so `await` and\n * `then` work on it. The page state holds it in this wrapper, so the browser knows the slot is\n * a prop and does not replace the promise with its value, as it does for a memo that streams.\n */\nexport class PropPromise {\n readonly promise: Promise<unknown>;\n\n constructor(promise: Promise<unknown>) {\n this.promise = promise;\n (this as Record<symbol, unknown>)[PROP_WRAPPER] = true;\n }\n}\n\n// Symbol.for, so copies of the runtime agree on the marks.\nconst PROP_WRAPPER = Symbol.for('brumate.propWrapper');\n\n/** A scope that collects the promise props that its component receives. */\nexport interface PropSink {\n props?: Promise<unknown>[] | undefined;\n}\n\n/** True for the wrapper that holds a promise prop in the page state. */\nexport function isPropWrapper(value: unknown): value is PropPromise {\n return typeof value === 'object' && value !== null && PROP_WRAPPER in value;\n}\n\n/** A component, which the compiler marks with its ID. */\nexport type ComponentValue = ((...args: never[]) => unknown) & { brumateId: string };\n\n/** The value of a feature that the build turned off, which no page state of it holds. */\nfunction unused(): never {\n throw new Error('The page state holds a value of a feature that no component of the build uses');\n}\n\n/**\n * Makes the values of brumate's plugins. A state record calls them as `$b`,\n * with one letter each, and the plugins read nodes of server function calls\n * with them too, so both give the same values.\n */\nexport const stateValues: {\n /** An element that the server rendered, by its scope and anchor. */\n e: (scope: ScopeId, anchor: number) => ElementReference;\n /** A client function, by its reference and scope. */\n f: (\n ref: string,\n scope: ScopeId,\n args?: unknown[] | null,\n modifiers?: string[],\n ) => FunctionReference;\n /** The parts of a merged handler, which `callable` makes one handler of. */\n m: (parts: FunctionReference[]) => FunctionReference[];\n /** A value of an attribute that brumate writes, such as the scope attribute of a style. */\n i: (value: unknown) => Internal;\n /** HTML that the client may insert again. */\n r: (html: string) => Raw;\n /** Children, by the export that renders them and their scope. */\n n: (ref: string, scope: ScopeId, at?: ScopeId, anchor?: number) => ChildrenReference;\n /**\n * A component, such as the value of a dynamic tag. The client gets a\n * function with the same ID that renders nothing. The client code that\n * changes the value uses the component's render module instead.\n */\n c: (id: string) => ComponentValue;\n /** A slot of a scope, which a bound prop writes. */\n l: (scope: ScopeId, slot: number) => SlotReference;\n /** A binding that a rest prop holds, with its value and its slot. */\n b: (value: unknown, scope: ScopeId, slot: number, set?: unknown) => Binding;\n /** A promise prop. See `PropPromise`. */\n q: (promise: Promise<unknown>) => PropPromise;\n /** The error of a memo that failed on the server. See `MemoError`. */\n x: (error: unknown) => MemoError;\n /** A value of the app, which a plugin of the entry makes from its data. */\n u: (tag: string, data: unknown) => unknown;\n} = {\n e: (scope, anchor) => new ElementReference(scope, anchor),\n f: (ref, scope, args, modifiers) => new FunctionReference(ref, scope, args, modifiers),\n m: (parts) => Object.assign(parts, { [PARTS]: parts }),\n i: (value) => new Internal(value),\n r: raw,\n n: HAS_CHILDREN\n ? (ref, scope, at, anchor) => new ChildrenReference(ref, scope, at, anchor)\n : unused,\n c: (id) => Object.assign(() => '', { brumateId: id }),\n l: (scope, slot) => new SlotReference(scope, slot),\n b: HAS_BINDINGS\n ? (value, scope, slot, set) => new Binding(value, new SlotReference(scope, slot), set)\n : unused,\n q: (promise) => new PropPromise(promise),\n x: (error) => new MemoError(error),\n u: (tag, data) => {\n const plugin = valuePlugins.get(tag);\n if (!plugin) {\n throw new Error(\n `No plugin reads the value \"${tag}\". Export it in the plugins of the serial entry, src/serial.ts`,\n );\n }\n return plugin.fromData(data);\n },\n};\n\n/** True for a value that `for await` reads, such as the result of an async generator. */\nexport function isAsyncIterable(value: unknown): value is AsyncIterable<unknown> {\n return (\n value !== null &&\n typeof value === 'object' &&\n typeof (value as AsyncIterable<unknown>)[Symbol.asyncIterator] === 'function'\n );\n}\n\n/** The state of one scope in the page. */\nexport interface ScopeState {\n /** The scope's ID in the compiled component. */\n k?: number;\n /** The ID of the scope that contains this one. Component root scopes have none. */\n p?: ScopeId;\n /** The component ID of a component's root scope. */\n m?: string;\n /** The item of a list item scope. */\n i?: unknown;\n /** The scope that rendered a component's root scope, for finding contexts. */\n o?: ScopeId;\n /**\n * For a scope of children that a component inserted, the scope where they\n * are, which contexts are found from in place of `p` and `o`.\n */\n t?: ScopeId;\n /** For a component that passes its children on, the scope where they are finally inserted. */\n f?: ScopeId;\n /** The values that the scope provides, by context key. */\n v?: Record<string, unknown>;\n /** The slots that hold the contexts that the scope reads, by context key. */\n x?: Record<string, number>;\n /** Slot values, in the order of the scope's layout. */\n s?: unknown[];\n /** The scope IDs of child components, by anchor index. */\n c?: Record<number, ScopeId>;\n /**\n * What the bound props of a component write, by the slot of the prop: a\n * slot of a parent, or the function of `$bind(name, fn)`.\n */\n b?: Record<number, unknown>;\n}\n\n/** The state of a page, by scope ID. */\nexport type PageState = Record<ScopeId, ScopeState>;\n\n/**\n * The flags of a group of scope records in `PackedState`:\n * - `ITEM_SLOT`: the item of each scope is its first slot.\n * - `ITEM`: each scope has its item after its slots.\n * - `CHILDREN`: each scope has its child components after that.\n * - `OWNER`: the scopes are component root scopes. `base` is the distance from the scope that\n * rendered each one, `o`, to the scope, and the first gap is from 0. Otherwise `base` is the\n * parent, `p`, of every scope.\n * - `MODULE`: the group has the component ID of its scopes after its header.\n * - `SOURCE`: the scopes are the items of a list whose list is a slot of an enclosing scope.\n * The header then has that scope's ID and the slot's index, and the items are not written:\n * the item of the scope at position `n` in the group is the value at `n` of the list, or of\n * `Array.from` of a Set. With `ITEM_SLOT`, each scope writes its slots after the first.\n * - `PREFIX`: the scopes are inside a `#loading` body. The header ends with the prefix of\n * their IDs, such as `5.`, and the gaps count the numbers after it.\n */\nexport const ITEM_SLOT = 1;\nexport const ITEM = 2;\nexport const CHILDREN = 4;\nexport const OWNER = 8;\nexport const MODULE = 16;\nexport const SOURCE = 32;\nexport const PREFIX = 64;\n\n/**\n * The page state as the server writes it. Records of scopes that share their\n * kind, their parent or owner, and their shape are in one group of `g`,\n * such as the items of a list, instead of one object each. A group is a flat\n * array: `[kind, base, flags, slotCount, module?, source?, sourceSlot?, prefix?, ...scopes]`, and each scope\n * is its ID as the gap from the one before it (the first from `base`), its\n * slots, and then its item and its child components, as `flags` says.\n */\nexport type PackedState = PageState & { g?: unknown[][] };\n\n/**\n * How a field of a state record holds scope IDs:\n * - `none`: no ID.\n * - `id`: the value is an ID.\n * - `ids`: an object whose values are IDs.\n * - `value`: a value that may hold references, such as an item.\n * - `values`: an array of such values.\n * - `map`: an object whose values are such values.\n */\nexport type FieldKind = 'none' | 'id' | 'ids' | 'value' | 'values' | 'map';\n\n/**\n * A table of the fields of a state record and the reference classes that hold\n * a scope ID, which each keep it in `scope`. Code that moves the IDs reads it.\n * A new field of `ScopeState` fails to compile until it is in `fields`, and\n * `holders` are the classes that keep references in their own fields, such as\n * `Binding`, whose `ref` and `set` hold IDs. `scope-ids.test.ts` parses this\n * file and fails for any class in it, of any shape, that is not in\n * `references` or `holders` or in the test's list of classes without IDs.\n * It checks class names only, so a person decides which list a new class\n * belongs in.\n */\nexport const SCOPE_IDS: {\n fields: Record<keyof ScopeState, FieldKind>;\n references: readonly (abstract new (...args: never[]) => { scope: ScopeId })[];\n holders: readonly (abstract new (...args: never[]) => object)[];\n} = {\n fields: {\n k: 'none',\n p: 'id',\n m: 'none',\n i: 'value',\n o: 'id',\n t: 'id',\n f: 'id',\n v: 'map',\n x: 'none',\n s: 'values',\n c: 'ids',\n b: 'map',\n },\n references: [ElementReference, FunctionReference, ChildrenReference, SlotReference],\n holders: [Binding],\n};\n","const DRAFT = Symbol('brumate.draft');\n\ninterface DraftState {\n base: Record<PropertyKey, unknown>;\n /** A shallow copy, made on the first change. */\n copy: Record<PropertyKey, unknown> | undefined;\n parent: DraftState | undefined;\n /** Drafts of the objects inside, by key. */\n children: Map<PropertyKey, DraftState & { proxy: object }>;\n modified: boolean;\n}\n\n/** Plain objects and arrays can be drafted. Other values, such as `Map`, are used as they are. */\nfunction isDraftable(value: unknown): value is Record<PropertyKey, unknown> {\n if (typeof value !== 'object' || value === null) {\n return false;\n }\n if (Array.isArray(value)) {\n return true;\n }\n const prototype = Object.getPrototypeOf(value);\n return prototype === Object.prototype || prototype === null;\n}\n\nfunction latest(state: DraftState): Record<PropertyKey, unknown> {\n return state.copy ?? state.base;\n}\n\n/** Copies an object and its parents on the first change. */\nfunction prepare(state: DraftState): Record<PropertyKey, unknown> {\n for (\n let current: DraftState | undefined = state;\n current && !current.modified;\n current = current.parent\n ) {\n current.modified = true;\n current.copy = (\n Array.isArray(current.base) ? [...current.base] : { ...current.base }\n ) as Record<PropertyKey, unknown>;\n }\n return state.copy!;\n}\n\nfunction getDraftState(value: unknown): DraftState | undefined {\n return typeof value === 'object' && value !== null\n ? ((value as Record<PropertyKey, unknown>)[DRAFT] as DraftState | undefined)\n : undefined;\n}\n\nfunction createDraft(\n base: Record<PropertyKey, unknown>,\n parent: DraftState | undefined,\n): DraftState & { proxy: object } {\n const state = {\n base,\n copy: undefined,\n parent,\n children: new Map(),\n modified: false,\n } as DraftState & {\n proxy: object;\n };\n // An empty target, so the draft can report the keys of the copy.\n const target = Array.isArray(base) ? [] : Object.create(Object.getPrototypeOf(base));\n state.proxy = new Proxy(target, {\n get(_, key) {\n if (key === DRAFT) {\n return state;\n }\n const source = latest(state);\n const value = source[key];\n if (!Object.hasOwn(source, key) || !isDraftable(value) || value !== state.base[key]) {\n return value;\n }\n let child = state.children.get(key);\n if (!child) {\n child = createDraft(value, state);\n state.children.set(key, child);\n }\n return child.proxy;\n },\n set(_, key, value) {\n const source = latest(state);\n if (Object.is(source[key], value) && Object.hasOwn(source, key)) {\n return true;\n }\n prepare(state)[key] = value;\n state.children.delete(key);\n return true;\n },\n deleteProperty(_, key) {\n if (Object.hasOwn(latest(state), key)) {\n delete prepare(state)[key];\n state.children.delete(key);\n }\n return true;\n },\n has(_, key) {\n return key in latest(state);\n },\n ownKeys() {\n return Reflect.ownKeys(latest(state));\n },\n getOwnPropertyDescriptor(_, key) {\n const descriptor = Reflect.getOwnPropertyDescriptor(latest(state), key);\n if (descriptor && key !== 'length') {\n descriptor.configurable = true;\n descriptor.writable = true;\n }\n return descriptor;\n },\n defineProperty(_, key, descriptor) {\n prepare(state);\n return Reflect.defineProperty(state.copy!, key, descriptor);\n },\n });\n return state;\n}\n\n/** Returns the final value of a draft: the base if nothing changed, or a new object that shares what did not. */\nfunction finalize(state: DraftState): unknown {\n if (!state.modified) {\n // A child can change without its parent being copied yet.\n for (const child of state.children.values()) {\n if (child.modified) {\n prepare(state);\n break;\n }\n }\n if (!state.modified) {\n return state.base;\n }\n }\n const copy = state.copy!;\n for (const [key, child] of state.children) {\n if (copy[key] === child.base) {\n copy[key] = finalize(child);\n }\n }\n // Drafts can also be assigned to other keys, such as when an array is reordered.\n for (const key of Reflect.ownKeys(copy)) {\n const draft = getDraftState(copy[key]);\n if (draft) {\n copy[key] = finalize(draft);\n }\n }\n return copy;\n}\n\n/**\n * Returns a changed copy of a value. The recipe changes a draft as if it\n * were the value. Objects that it does not change keep their identity, and\n * if it changes nothing, the value itself is returned. A recipe can also\n * return a new value. Only plain objects and arrays are drafted.\n */\nexport function produce<T>(base: T, recipe: (draft: T) => T | void): T {\n if (!isDraftable(base)) {\n const result = recipe(base);\n return result === undefined ? base : result;\n }\n const state = createDraft(base, undefined);\n const result = recipe(state.proxy as T);\n if (result !== undefined && result !== state.proxy) {\n return resolve(result, new Set()) as T;\n }\n return finalize(state) as T;\n}\n\n/** Replaces the drafts in a value that a recipe returns, such as the result of `draft.filter(…)`. */\nfunction resolve(value: unknown, seen: Set<unknown>): unknown {\n const draft = getDraftState(value);\n if (draft) {\n return finalize(draft);\n }\n if (!isDraftable(value) || seen.has(value)) {\n return value;\n }\n seen.add(value);\n for (const key of Reflect.ownKeys(value)) {\n value[key] = resolve(value[key], seen);\n }\n return value;\n}\n"],"mappings":";;;;AAUA,MAAM,+BAAe,IAAI,IAAyB;AAClD,MAAM,kBAAqD,CAAC;;AAE5D,IAAI,eAA6C,CAAC;AAClD,MAAM,kBAAuE,CAAC;;;;;;AAO9E,SAAgB,eAAe,OAA0B;CACvD,MAAM,EAAE,UAAU,CAAC,GAAG,GAAG,YAAY;CACrC,IAAI,QAAQ,qBAAqB,KAAA,KAAa,QAAQ,eAAe,KAAA,GAAW;EAC9E,eAAe;EACf,KAAK,MAAM,YAAY,iBACrB,SAAS,OAAO;CAEpB;CACA,eAAe,OAAO;AACxB;;AAGA,SAAgB,gBAAgB,UAAiE;CAC/F,gBAAgB,KAAK,QAAQ;CAC7B,SAAS,YAAY;AACvB;;AAGA,SAAS,eAAe,SAAuC;CAC7D,KAAK,MAAM,UAAU,SAAS;EAC5B,IAAI,aAAa,IAAI,OAAO,GAAG,MAAM,QACnC;EAEF,aAAa,IAAI,OAAO,KAAK,MAAM;EACnC,KAAK,MAAM,YAAY,iBACrB,SAAS,MAAM;CAEnB;AACF;;AAGA,SAAgB,cAAc,UAA+C;CAC3E,gBAAgB,KAAK,QAAQ;CAC7B,KAAK,MAAM,UAAU,aAAa,OAAO,GACvC,SAAS,MAAM;AAEnB;;AAWA,SAAgB,QAAQ,MAAuB;CAC7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}
22
- /** A client function: an export of a client module, and the scope it reads. */
23
22
  declare class FunctionReference {
24
23
  /** `<component id>#<export name>`. */
25
24
  readonly ref: string;
@@ -53,9 +52,14 @@ declare class Binding<T = unknown> {
53
52
  * The props that a component destructures, with the values of their
54
53
  * bindings. `names` are the props that it destructures by name: the others,
55
54
  * which a rest prop holds, keep their bindings, so a spread passes them on.
56
- * Without `names`, every binding gives its value.
55
+ * Without `names`, every binding gives its value. `omit` are props that a rest
56
+ * leaves out, because another `$props()` call of the component names them.
57
57
  */
58
- declare function unbind(props: Record<string, unknown>, names?: readonly string[]): Record<string, unknown>;
58
+ declare function unbind(props: Record<string, unknown>, names?: readonly string[], omit?: readonly string[], sink?: PropSink): Record<string, unknown>;
59
+ /** A scope that collects the promise props that its component receives. */
60
+ interface PropSink {
61
+ props?: Promise<unknown>[] | undefined;
62
+ }
59
63
  /** The state of one scope in the page. */
60
64
  interface ScopeState {
61
65
  /** The scope's ID in the compiled component. */
@@ -73,6 +77,8 @@ interface ScopeState {
73
77
  * are, which contexts are found from in place of `p` and `o`.
74
78
  */
75
79
  t?: ScopeId;
80
+ /** For a component that passes its children on, the scope where they are finally inserted. */
81
+ f?: ScopeId;
76
82
  /** The values that the scope provides, by context key. */
77
83
  v?: Record<string, unknown>;
78
84
  /** The slots that hold the contexts that the scope reads, by context key. */
@@ -100,6 +106,34 @@ type PageState = Record<ScopeId, ScopeState>;
100
106
  type PackedState = PageState & {
101
107
  g?: unknown[][];
102
108
  };
109
+ /**
110
+ * How a field of a state record holds scope IDs:
111
+ * - `none`: no ID.
112
+ * - `id`: the value is an ID.
113
+ * - `ids`: an object whose values are IDs.
114
+ * - `value`: a value that may hold references, such as an item.
115
+ * - `values`: an array of such values.
116
+ * - `map`: an object whose values are such values.
117
+ */
118
+ type FieldKind = "none" | "id" | "ids" | "value" | "values" | "map";
119
+ /**
120
+ * A table of the fields of a state record and the reference classes that hold
121
+ * a scope ID, which each keep it in `scope`. Code that moves the IDs reads it.
122
+ * A new field of `ScopeState` fails to compile until it is in `fields`, and
123
+ * `holders` are the classes that keep references in their own fields, such as
124
+ * `Binding`, whose `ref` and `set` hold IDs. `scope-ids.test.ts` parses this
125
+ * file and fails for any class in it, of any shape, that is not in
126
+ * `references` or `holders` or in the test's list of classes without IDs.
127
+ * It checks class names only, so a person decides which list a new class
128
+ * belongs in.
129
+ */
130
+ declare const SCOPE_IDS: {
131
+ fields: Record<keyof ScopeState, FieldKind>;
132
+ references: readonly (abstract new (...args: never[]) => {
133
+ scope: ScopeId;
134
+ })[];
135
+ holders: readonly (abstract new (...args: never[]) => object)[];
136
+ };
103
137
  //#endregion
104
138
  //#region src/runtime/produce.d.ts
105
139
  /**
@@ -110,5 +144,5 @@ type PackedState = PageState & {
110
144
  */
111
145
  declare function produce<T>(base: T, recipe: (draft: T) => T | void): T;
112
146
  //#endregion
113
- export { PackedState as a, ScopeState as c, FunctionReference as i, unbind as l, Binding as n, PageState as o, ElementReference as r, ScopeId as s, produce as t, useSerialEntry as u };
114
- //# sourceMappingURL=produce-D0V0ICkz.d.ts.map
147
+ export { PackedState as a, SCOPE_IDS as c, unbind as d, useSerialEntry as f, FunctionReference as i, ScopeId as l, Binding as n, PageState as o, ElementReference as r, PropSink as s, produce as t, ScopeState as u };
148
+ //# sourceMappingURL=produce-DIgHBVwL.d.ts.map