@solidjs/web 2.0.0-beta.3 → 2.0.0-beta.31

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 (73) hide show
  1. package/README.md +27 -4
  2. package/dist/dev.cjs +1224 -205
  3. package/dist/dev.js +1188 -199
  4. package/dist/server.cjs +1429 -234
  5. package/dist/server.js +1391 -231
  6. package/dist/web.cjs +1207 -195
  7. package/dist/web.js +1171 -189
  8. package/frames/dist/client.cjs +1694 -0
  9. package/frames/dist/client.dev.cjs +1707 -0
  10. package/frames/dist/client.dev.js +1695 -0
  11. package/frames/dist/client.js +1682 -0
  12. package/frames/dist/server.cjs +2520 -0
  13. package/frames/dist/server.js +2508 -0
  14. package/frames/package.json +30 -0
  15. package/package.json +285 -37
  16. package/serialization/dist/serialization.cjs +169 -0
  17. package/serialization/dist/serialization.js +159 -0
  18. package/serialization/package.json +20 -0
  19. package/serialization/types/index.d.ts +157 -0
  20. package/serialization/types-cjs/index.d.cts +157 -0
  21. package/serialization/types-cjs/package.json +3 -0
  22. package/server-functions/dist/client.cjs +613 -0
  23. package/server-functions/dist/client.js +585 -0
  24. package/server-functions/dist/server.cjs +904 -0
  25. package/server-functions/dist/server.js +875 -0
  26. package/server-functions/package.json +30 -0
  27. package/storage/package.json +8 -3
  28. package/storage/types/index.d.ts +26 -0
  29. package/storage/types-cjs/index.d.cts +28 -0
  30. package/storage/types-cjs/package.json +3 -0
  31. package/types/client.d.ts +127 -21
  32. package/types/core.d.ts +4 -3
  33. package/types/frames/client.d.ts +22 -0
  34. package/types/frames/frame-client.d.ts +282 -0
  35. package/types/frames/frame-sink.d.ts +171 -0
  36. package/types/frames/frame-transport.d.ts +190 -0
  37. package/types/frames/serializer.d.ts +157 -0
  38. package/types/frames/server.d.ts +30 -0
  39. package/types/index.d.ts +211 -26
  40. package/types/jsx-properties.d.ts +93 -0
  41. package/types/jsx.d.ts +4150 -1
  42. package/types/response.d.ts +129 -0
  43. package/types/serializer.d.ts +157 -0
  44. package/types/server-functions/client.d.ts +200 -0
  45. package/types/server-functions/flash.d.ts +38 -0
  46. package/types/server-functions/server.d.ts +490 -0
  47. package/types/server-functions/shared.d.ts +445 -0
  48. package/types/server-mock.d.ts +93 -0
  49. package/types/server.d.ts +223 -28
  50. package/types-cjs/client.d.cts +194 -0
  51. package/types-cjs/core.d.cts +4 -0
  52. package/types-cjs/frames/client.d.cts +22 -0
  53. package/types-cjs/frames/frame-client.d.cts +282 -0
  54. package/types-cjs/frames/frame-sink.d.cts +171 -0
  55. package/types-cjs/frames/frame-transport.d.cts +190 -0
  56. package/types-cjs/frames/serializer.d.cts +157 -0
  57. package/types-cjs/frames/server.d.cts +30 -0
  58. package/types-cjs/index.d.cts +231 -0
  59. package/types-cjs/jsx-properties.d.cts +93 -0
  60. package/types-cjs/jsx.d.cts +4150 -0
  61. package/types-cjs/package.json +3 -0
  62. package/types-cjs/response.d.cts +129 -0
  63. package/types-cjs/serializer.d.cts +157 -0
  64. package/types-cjs/server-functions/client.d.cts +200 -0
  65. package/types-cjs/server-functions/flash.d.cts +38 -0
  66. package/types-cjs/server-functions/server.d.cts +490 -0
  67. package/types-cjs/server-functions/shared.d.cts +445 -0
  68. package/types-cjs/server-mock.d.cts +165 -0
  69. package/types-cjs/server.d.cts +351 -0
  70. package/storage/types/src/client.d.ts +0 -1
  71. package/storage/types/src/index.d.ts +0 -46
  72. package/storage/types/src/server-mock.d.ts +0 -72
  73. package/storage/types/storage/src/index.d.ts +0 -2
package/dist/web.js CHANGED
@@ -1,39 +1,80 @@
1
- import { createRenderEffect, createMemo as createMemo$1, sharedConfig, untrack, runWithOwner, flatten, createRoot, omit, enableHydration } from 'solid-js';
2
- export { Errored, For, Hydration, Loading, Match, NoHydration, Show, Switch, createComponent, getOwner, merge as mergeProps, untrack } from 'solid-js';
3
- import { createMemo } from '@solidjs/signals';
1
+ import { createRenderEffect, createMemo, sharedConfig, untrack, runWithOwner, flatten, createRoot, merge, createComponent, omit, createOwner, createSignal, onCleanup, enableHydration, flush, getOwner, createEffect } from 'solid-js';
2
+ export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, getOwner, untrack } from 'solid-js';
4
3
 
5
- const Properties = /*#__PURE__*/new Set([
6
- "value", "checked", "selected", "muted"]);
4
+ const DOMWithState = {
5
+ INPUT: {
6
+ value: 1,
7
+ defaultValue: 2,
8
+ checked: 1,
9
+ defaultChecked: 2
10
+ },
11
+ SELECT: {
12
+ value: 1
13
+ },
14
+ OPTION: {
15
+ value: 1,
16
+ selected: 1,
17
+ defaultSelected: 2
18
+ },
19
+ TEXTAREA: {
20
+ value: 1,
21
+ defaultValue: 2
22
+ },
23
+ VIDEO: {
24
+ muted: 1,
25
+ defaultMuted: 2
26
+ },
27
+ AUDIO: {
28
+ muted: 1,
29
+ defaultMuted: 2
30
+ }
31
+ };
7
32
  const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
33
+ const $$SLOT = /*#__PURE__*/Symbol("slot");
34
+ const $$HOST = /*#__PURE__*/Symbol("host");
8
35
  const DelegatedEvents = /*#__PURE__*/new Set(["beforeinput", "click", "dblclick", "contextmenu", "focusin", "focusout", "input", "keydown", "keyup", "mousedown", "mousemove", "mouseout", "mouseover", "mouseup", "pointerdown", "pointermove", "pointerout", "pointerover", "pointerup", "touchend", "touchmove", "touchstart"]);
9
36
  const SVGElements = /*#__PURE__*/new Set([
10
37
  "altGlyph", "altGlyphDef", "altGlyphItem", "animate", "animateColor", "animateMotion", "animateTransform", "circle", "clipPath", "color-profile", "cursor", "defs", "desc", "ellipse", "feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence", "filter", "font", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignObject", "g", "glyph", "glyphRef", "hkern", "image", "line", "linearGradient", "marker", "mask", "metadata", "missing-glyph", "mpath", "path", "pattern", "polygon", "polyline", "radialGradient", "rect",
11
38
  "set", "stop",
12
39
  "svg", "switch", "symbol", "text", "textPath",
13
40
  "tref", "tspan", "use", "view", "vkern"]);
14
- const SVGNamespace = {
41
+ const MathMLElements = /*#__PURE__*/new Set(["annotation", "annotation-xml", "maction", "math", "menclose", "merror", "mfenced", "mfrac", "mi", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mprescripts", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msubsup", "msup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "semantics"]);
42
+ const Namespaces = {
43
+ svg: "http://www.w3.org/2000/svg",
44
+ mathml: "http://www.w3.org/1998/Math/MathML",
15
45
  xlink: "http://www.w3.org/1999/xlink",
16
46
  xml: "http://www.w3.org/XML/1998/namespace"
17
47
  };
18
- const DOMElements = /*#__PURE__*/new Set(["html", "base", "head", "link", "meta", "style", "title", "body", "address", "article", "aside", "footer", "header", "main", "nav", "section", "body", "blockquote", "dd", "div", "dl", "dt", "figcaption", "figure", "hr", "li", "ol", "p", "pre", "ul", "a", "abbr", "b", "bdi", "bdo", "br", "cite", "code", "data", "dfn", "em", "i", "kbd", "mark", "q", "rp", "rt", "ruby", "s", "samp", "small", "span", "strong", "sub", "sup", "time", "u", "var", "wbr", "area", "audio", "img", "map", "track", "video", "embed", "iframe", "object", "param", "picture", "portal", "source", "svg", "math", "canvas", "noscript", "script", "del", "ins", "caption", "col", "colgroup", "table", "tbody", "td", "tfoot", "th", "thead", "tr", "button", "datalist", "fieldset", "form", "input", "label", "legend", "meter", "optgroup", "option", "output", "progress", "select", "textarea", "details", "dialog", "menu", "summary", "details", "slot", "template", "acronym", "applet", "basefont", "bgsound", "big", "blink", "center", "content", "dir", "font", "frame", "frameset", "hgroup", "image", "keygen", "marquee", "menuitem", "nobr", "noembed", "noframes", "plaintext", "rb", "rtc", "shadow", "spacer", "strike", "tt", "xmp", "a", "abbr", "acronym", "address", "applet", "area", "article", "aside", "audio", "b", "base", "basefont", "bdi", "bdo", "bgsound", "big", "blink", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "content", "data", "datalist", "dd", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "em", "embed", "fieldset", "figcaption", "figure", "font", "footer", "form", "frame", "frameset", "head", "header", "hgroup", "hr", "html", "i", "iframe", "image", "img", "input", "ins", "kbd", "keygen", "label", "legend", "li", "link", "main", "map", "mark", "marquee", "menu", "menuitem", "meta", "meter", "nav", "nobr", "noembed", "noframes", "noscript", "object", "ol", "optgroup", "option", "output", "p", "param", "picture", "plaintext", "portal", "pre", "progress", "q", "rb", "rp", "rt", "rtc", "ruby", "s", "samp", "script", "section", "select", "shadow", "slot", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "title", "tr", "track", "tt", "u", "ul", "var", "video", "wbr", "xmp", "input", "h1", "h2", "h3", "h4", "h5", "h6",
19
- "webview",
20
- "isindex", "listing", "multicol", "nextid", "noindex", "search"]);
48
+ const VoidElements = /*#__PURE__*/new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]);
49
+ const RawTextElements = /*#__PURE__*/new Set(["style", "script", "noscript", "template", "textarea", "title"]);
50
+ const DOMElements = /*#__PURE__*/new Set(/*#__PURE__*/"a,abbr,acronym,address,applet,area,article,aside,audio,b,base,basefont,bdi,bdo,bgsound,big,blink,blockquote,body,br,button,canvas,caption,center,cite,code,col,colgroup,content,data,datalist,dd,del,details,dfn,dialog,dir,div,dl,dt,em,embed,fieldset,figcaption,figure,font,footer,form,frame,frameset,h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,i,iframe,image,img,input,ins,isindex,kbd,keygen,label,legend,li,link,listing,main,map,mark,marquee,math,menu,menuitem,meta,meter,multicol,nav,nextid,nobr,noembed,noframes,noindex,noscript,object,ol,optgroup,option,output,p,param,picture,plaintext,portal,pre,progress,q,rb,rp,rt,rtc,ruby,s,samp,script,search,section,select,shadow,slot,small,source,spacer,span,strike,strong,style,sub,summary,sup,svg,table,tbody,td,template,textarea,tfoot,th,thead,time,title,tr,track,tt,u,ul,var,video,wbr,webview,xmp".split(","));
21
51
 
22
- const effect = (fn, effectFn, initial) => createRenderEffect(fn, effectFn, initial, {
23
- transparent: true
24
- });
25
- const memo = (fn, transparent) => transparent ? fn.$r ? fn : createMemo(() => fn(), undefined, {
26
- transparent: true
27
- }) : createMemo$1(() => fn());
52
+ const transparentOptions = {
53
+ transparent: true,
54
+ sync: true
55
+ };
56
+ const syncOptions = {
57
+ sync: true
58
+ };
59
+ const effect = (fn, effectFn, options) => createRenderEffect(fn, effectFn, options ? {
60
+ sync: true,
61
+ ...options,
62
+ transparent: !options.scope
63
+ } : transparentOptions);
64
+ const memo = fn => createMemo(() => fn(), syncOptions);
28
65
 
29
- function reconcileArrays(parentNode, a, b) {
66
+ function reconcileArrays(parentNode, a, b, marker) {
30
67
  let bLength = b.length,
31
68
  aEnd = a.length,
32
69
  bEnd = bLength,
33
70
  aStart = 0,
34
71
  bStart = 0,
35
- after = a[aEnd - 1].nextSibling,
36
- map = null;
72
+ tail = a[aEnd - 1],
73
+ tailTag = tail[$$SLOT],
74
+ after = tail.parentNode === parentNode && (!tailTag || tailTag === marker) ? tail.nextSibling : marker || null,
75
+ map = null,
76
+ anchor,
77
+ anchorTag;
37
78
  while (aStart < aEnd || bStart < bEnd) {
38
79
  if (a[aStart] === b[bStart]) {
39
80
  aStart++;
@@ -45,18 +86,43 @@ function reconcileArrays(parentNode, a, b) {
45
86
  bEnd--;
46
87
  }
47
88
  if (aEnd === aStart) {
48
- const node = bEnd < bLength ? bStart ? b[bStart - 1].nextSibling : b[bEnd - bStart] : after;
49
- while (bStart < bEnd) parentNode.insertBefore(b[bStart++], node);
89
+ let node;
90
+ if (bEnd < bLength) {
91
+ if (bStart) {
92
+ const prev = b[bStart - 1];
93
+ const prevTag = prev[$$SLOT];
94
+ node = prev.parentNode === parentNode && (!prevTag || prevTag === marker) ? prev.nextSibling : after;
95
+ } else node = b[bEnd - bStart];
96
+ } else node = after;
97
+ while (bStart < bEnd) {
98
+ const n = b[bStart++];
99
+ parentNode.insertBefore(n, node);
100
+ if (marker) n[$$SLOT] = marker;
101
+ }
50
102
  } else if (bEnd === bStart) {
51
103
  while (aStart < aEnd) {
52
- if (!map || !map.has(a[aStart])) a[aStart].remove();
53
- aStart++;
104
+ const n = a[aStart++];
105
+ if (!map || !map.has(n)) {
106
+ const tag = n[$$SLOT];
107
+ if (n.parentNode === parentNode && (!tag || tag === marker)) n.remove();
108
+ }
109
+ }
110
+ } else if ((anchor = a[aStart]) === b[bEnd - 1] && b[bStart] === a[aEnd - 1] && anchor.parentNode === parentNode && (!(anchorTag = anchor[$$SLOT]) || anchorTag === marker)) {
111
+ if (marker) {
112
+ do {
113
+ const n = a[--aEnd];
114
+ parentNode.insertBefore(n, anchor);
115
+ n[$$SLOT] = marker;
116
+ bStart++;
117
+ if (aStart >= aEnd - 1 || bStart >= bEnd) break;
118
+ } while (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]);
119
+ } else {
120
+ do {
121
+ parentNode.insertBefore(a[--aEnd], anchor);
122
+ bStart++;
123
+ if (aStart >= aEnd - 1 || bStart >= bEnd) break;
124
+ } while (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]);
54
125
  }
55
- } else if (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]) {
56
- const node = a[--aEnd].nextSibling;
57
- parentNode.insertBefore(b[bStart++], a[aStart++].nextSibling);
58
- parentNode.insertBefore(b[--bEnd], node);
59
- a[aEnd] = b[bEnd];
60
126
  } else {
61
127
  if (!map) {
62
128
  map = new Map();
@@ -74,75 +140,273 @@ function reconcileArrays(parentNode, a, b) {
74
140
  sequence++;
75
141
  }
76
142
  if (sequence > index - bStart) {
77
- const node = a[aStart];
78
- while (bStart < index) parentNode.insertBefore(b[bStart++], node);
79
- } else parentNode.replaceChild(b[bStart++], a[aStart++]);
143
+ const head = a[aStart];
144
+ const headTag = head[$$SLOT];
145
+ const node = head.parentNode === parentNode && (!headTag || headTag === marker) ? head : after;
146
+ while (bStart < index) {
147
+ const n = b[bStart++];
148
+ parentNode.insertBefore(n, node);
149
+ if (marker) n[$$SLOT] = marker;
150
+ }
151
+ } else {
152
+ const oldNode = a[aStart++];
153
+ const newNode = b[bStart++];
154
+ const oldTag = oldNode[$$SLOT];
155
+ if (oldNode.parentNode === parentNode && (!oldTag || oldTag === marker)) {
156
+ parentNode.replaceChild(newNode, oldNode);
157
+ } else {
158
+ parentNode.insertBefore(newNode, after);
159
+ }
160
+ if (marker) newNode[$$SLOT] = marker;
161
+ }
80
162
  } else aStart++;
81
- } else a[aStart++].remove();
163
+ } else {
164
+ const n = a[aStart++];
165
+ const nTag = n[$$SLOT];
166
+ if (n.parentNode === parentNode && (!nTag || nTag === marker)) n.remove();
167
+ }
168
+ }
169
+ }
170
+ }
171
+
172
+ const HEAD_ELIGIBLE_TAGS = new Set(["title", "meta", "link", "style", "script", "base"]);
173
+ const HEAD_ATTR_NAME = /^[a-zA-Z_][a-zA-Z0-9_:.-]*$/;
174
+ const RESOURCE_LINK_RELS = new Set(["preload", "modulepreload", "prefetch", "preconnect", "dns-prefetch", "stylesheet"]);
175
+ const RESOURCE_QUALIFIERS = ["as", "crossorigin", "type", "media", "imagesrcset", "imagesizes"];
176
+ function evalHeadValue(v) {
177
+ return typeof v === "function" ? v() : v;
178
+ }
179
+ function evalHeadProps(props, presets) {
180
+ const out = {};
181
+ for (const name in props) out[name] = presets && name in presets ? presets[name] : evalHeadValue(props[name]);
182
+ return out;
183
+ }
184
+ function classifyHeadTag(desc) {
185
+ const tag = desc.tag;
186
+ if (tag === "link") {
187
+ const rel = evalHeadValue(desc.props && desc.props.rel);
188
+ return {
189
+ resource: RESOURCE_LINK_RELS.has(rel),
190
+ rel
191
+ };
192
+ }
193
+ if (tag === "style") return {
194
+ resource: !!(desc.props && "href" in desc.props)
195
+ };
196
+ if (tag === "script") return {
197
+ resource: !!(desc.props && "src" in desc.props)
198
+ };
199
+ return {
200
+ resource: false
201
+ };
202
+ }
203
+ function resourceIdentity(tag, props) {
204
+ let id = "res:" + tag + ":" + (props.rel || "") + ":" + (props.href || props.src || "");
205
+ for (let i = 0; i < RESOURCE_QUALIFIERS.length; i++) {
206
+ const q = RESOURCE_QUALIFIERS[i];
207
+ if (props[q] != null) id += ":" + q + "=" + props[q];
208
+ }
209
+ return id;
210
+ }
211
+ function replaceableIdentity(tag, props, key, unique) {
212
+ if (tag === "title") return "title";
213
+ if (tag === "base") return "base";
214
+ if (tag === "meta" && props.charset != null) return "charset";
215
+ if (key != null) return tag + ":key:" + key;
216
+ if (tag === "meta") {
217
+ for (const ns of ["name", "property", "http-equiv"]) if (props[ns] != null) return "meta:" + ns + ":" + props[ns] + (props.media != null ? ":media=" + props.media : "");
218
+ return unique;
219
+ }
220
+ if (tag === "link") {
221
+ const rel = props.rel || "";
222
+ if (rel === "icon" || rel === "apple-touch-icon") return "link:" + rel + (props.sizes != null ? ":sizes=" + props.sizes : "") + (props.type != null ? ":type=" + props.type : "");
223
+ return "link:" + rel + ":" + (props.href || "");
224
+ }
225
+ return unique;
226
+ }
227
+ function resolveHead(groups) {
228
+ const winners = new Map();
229
+ const sorted = groups.slice().sort((a, b) => a.seq - b.seq);
230
+ for (let i = 0; i < sorted.length; i++) {
231
+ const group = sorted[i];
232
+ const byIdentity = new Map();
233
+ for (let j = 0; j < group.tags.length; j++) {
234
+ const t = group.tags[j];
235
+ let list = byIdentity.get(t.identity);
236
+ if (!list) byIdentity.set(t.identity, list = []);
237
+ list.push(t);
238
+ }
239
+ for (const [identity, tags] of byIdentity) {
240
+ if (identity === "title") {
241
+ winners.set(identity, {
242
+ seq: group.seq,
243
+ tags: [tags[tags.length - 1]]
244
+ });
245
+ } else {
246
+ winners.set(identity, {
247
+ seq: group.seq,
248
+ tags
249
+ });
250
+ }
82
251
  }
83
252
  }
253
+ return winners;
84
254
  }
85
255
 
86
- const $$EVENTS = "_$DX_DELEGATE";
256
+ const $$EVENT_OWNER = "_$DX_EVENT_OWNER";
257
+ const INNER_OWNED = {};
258
+ const delegatedEvents = new Set();
259
+ const delegatedContainers = new Map();
87
260
  function render$1(code, element, init, options = {}) {
88
261
  let disposer;
89
- createRoot(dispose => {
90
- disposer = dispose;
91
- element === document ? flatten(code) : insert(element, code(), element.firstChild ? null : undefined, init);
92
- }, {
93
- id: options.renderId
94
- });
262
+ registerDelegatedRoot(element);
263
+ try {
264
+ createRoot(dispose => {
265
+ disposer = dispose;
266
+ if (element === document) {
267
+ const tree = code();
268
+ effect(() => flatten(tree), () => {});
269
+ } else {
270
+ const tree = code();
271
+ insert(element, () => tree, element.firstChild ? null : undefined, init, options.insertOptions);
272
+ }
273
+ }, {
274
+ id: options.renderId
275
+ });
276
+ } catch (err) {
277
+ if (disposer) disposer();
278
+ unregisterDelegatedRoot(element);
279
+ throw err;
280
+ }
95
281
  return () => {
96
282
  disposer();
283
+ unregisterDelegatedRoot(element);
97
284
  element.textContent = "";
98
285
  };
99
286
  }
100
- function template(html, isImportNode, isSVG, isMathML) {
287
+ function create(html, bypassGuard, flag) {
288
+ const t = document.createElement("template");
289
+ t.innerHTML = html;
290
+ return flag === 2 ? t.content.firstChild.firstChild : t.content.firstChild;
291
+ }
292
+ function template(html, flag) {
101
293
  let node;
102
- const create = bypassGuard => {
103
- const t = isMathML ? document.createElementNS("http://www.w3.org/1998/Math/MathML", "template") : document.createElement("template");
104
- t.innerHTML = html;
105
- return isSVG ? t.content.firstChild.firstChild : isMathML ? t.firstChild : t.content.firstChild;
106
- };
107
- const fn = isImportNode ? bypassGuard => untrack(() => document.importNode(node || (node = create()), true)) : bypassGuard => (node || (node = create())).cloneNode(true);
294
+ const fn = flag === 1 ? bypassGuard => document.importNode(node || (node = create(html, bypassGuard, flag)), true) : bypassGuard => (node || (node = create(html, bypassGuard, flag))).cloneNode(true);
108
295
  return fn;
109
296
  }
110
- function delegateEvents(eventNames, document = window.document) {
111
- const e = document[$$EVENTS] || (document[$$EVENTS] = new Set());
297
+ function delegateEvents(eventNames) {
112
298
  for (let i = 0, l = eventNames.length; i < l; i++) {
113
299
  const name = eventNames[i];
114
- if (!e.has(name)) {
115
- e.add(name);
116
- document.addEventListener(name, eventHandler);
300
+ if (!delegatedEvents.has(name)) {
301
+ delegatedEvents.add(name);
302
+ delegatedContainers.forEach((state, container) => attachDelegatedEvent(name, container, state));
117
303
  }
118
304
  }
119
305
  }
120
- function clearDelegatedEvents(document = window.document) {
121
- if (document[$$EVENTS]) {
122
- for (let name of document[$$EVENTS].keys()) document.removeEventListener(name, eventHandler);
123
- delete document[$$EVENTS];
306
+ function registerDelegatedRoot(root) {
307
+ const state = registerDelegatedContainer(root, root);
308
+ if (state) state.roots = (state.roots || 0) + 1;
309
+ }
310
+ function unregisterDelegatedRoot(root) {
311
+ const state = delegatedContainers.get(root);
312
+ if (state) state.roots > 1 ? state.roots-- : delete state.roots;
313
+ unregisterDelegatedContainer(root, root);
314
+ }
315
+ function registerDelegatedContainer(container, owner = container) {
316
+ if (!container || !owner) return;
317
+ let state = delegatedContainers.get(container);
318
+ if (!state) delegatedContainers.set(container, state = {
319
+ owners: new Map(),
320
+ handlers: new Map()
321
+ });
322
+ state.owners.set(owner, (state.owners.get(owner) || 0) + 1);
323
+ delegatedEvents.forEach(name => attachDelegatedEvent(name, container, state));
324
+ return state;
325
+ }
326
+ function unregisterDelegatedContainer(container, owner = container) {
327
+ const state = delegatedContainers.get(container);
328
+ if (!state) return;
329
+ const count = state.owners.get(owner);
330
+ if (count > 1) state.owners.set(owner, count - 1);else state.owners.delete(owner);
331
+ if (state.owners.size) return;
332
+ state.handlers.forEach((handler, name) => container.removeEventListener(name, handler));
333
+ delegatedContainers.delete(container);
334
+ }
335
+ function attachDelegatedEvent(name, container, state) {
336
+ if (state.handlers.has(name)) return;
337
+ const handler = e => eventHandler(e, container, state);
338
+ state.handlers.set(name, handler);
339
+ container.addEventListener(name, handler);
340
+ }
341
+ function getDelegatedRoot(node) {
342
+ while (node) {
343
+ if (delegatedContainers.get(node)?.roots) return node;
344
+ node = node._$host || node.parentNode || node.host;
345
+ }
346
+ }
347
+ function findOwner(target, state) {
348
+ let node = target;
349
+ let distance = 0;
350
+ while (node) {
351
+ if (state.owners.has(node)) return {
352
+ owner: node,
353
+ distance
354
+ };
355
+ distance++;
356
+ node = node._$host || node.parentNode || node.host;
124
357
  }
125
358
  }
126
359
  function setProperty(node, name, value) {
127
360
  if (isHydrating(node)) return;
128
361
  node[name] = value;
129
362
  }
363
+ let claimHandlers = null;
364
+ const CLAIM_SEAM = Symbol.for("dom-expressions.element-claims");
365
+ function registerElementClaim(handler) {
366
+ (claimHandlers || (claimHandlers = globalThis[CLAIM_SEAM] = [])).push(handler);
367
+ return () => {
368
+ const index = claimHandlers.indexOf(handler);
369
+ index > -1 && claimHandlers.splice(index, 1);
370
+ };
371
+ }
372
+ const CLAIMED_ELEMENTS = "a[href], form[action]";
373
+ function claimElementTree(root) {
374
+ const handlers = globalThis[CLAIM_SEAM];
375
+ if (handlers === undefined || handlers.length === 0) return root;
376
+ const isElement = root.nodeType === 1;
377
+ if (!isElement && root.nodeType !== 11) return root;
378
+ if (isElement && root.matches(CLAIMED_ELEMENTS)) {
379
+ for (let i = 0; i < handlers.length; i++) handlers[i](root);
380
+ }
381
+ const found = root.querySelectorAll(CLAIMED_ELEMENTS);
382
+ for (let i = 0; i < found.length; i++) {
383
+ for (let j = 0; j < handlers.length; j++) handlers[j](found[i]);
384
+ }
385
+ return root;
386
+ }
387
+ function claimElement(node) {
388
+ if (claimHandlers !== null) {
389
+ for (let i = 0; i < claimHandlers.length; i++) claimHandlers[i](node);
390
+ }
391
+ return node;
392
+ }
130
393
  function setAttribute(node, name, value) {
131
394
  if (isHydrating(node)) return;
132
395
  if (value == null || value === false) node.removeAttribute(name);else node.setAttribute(name, value === true ? "" : value);
396
+ if (claimHandlers !== null && (name === "href" || name === "action")) claimElement(node);
133
397
  }
134
398
  function setAttributeNS(node, namespace, name, value) {
135
399
  if (isHydrating(node)) return;
136
- if (value == null) node.removeAttributeNS(namespace, name);else node.setAttributeNS(namespace, name, value);
400
+ if (value == null || value === false) node.removeAttributeNS(namespace, name.indexOf(":") > -1 ? name.split(":").pop() : name);else node.setAttributeNS(namespace, name, value === true ? "" : value);
137
401
  }
138
- function className(node, value, isSVG, prev) {
402
+ function className(node, value, prev) {
139
403
  if (isHydrating(node)) return;
140
404
  if (value == null || value === false) {
141
405
  prev && node.removeAttribute("class");
142
406
  return;
143
407
  }
144
408
  if (typeof value === "string") {
145
- value !== prev && (isSVG ? node.setAttribute("class", value) : node.className = value);
409
+ value !== prev && node.setAttribute("class", value);
146
410
  return;
147
411
  }
148
412
  if (typeof prev === "string") {
@@ -156,16 +420,16 @@ function className(node, value, isSVG, prev) {
156
420
  for (i = 0, len = prevKeys.length; i < len; i++) {
157
421
  const key = prevKeys[i];
158
422
  if (!key || key === "undefined" || value[key]) continue;
159
- toggleClassKey(node, key, false);
423
+ node.classList.remove(key);
160
424
  }
161
425
  for (i = 0, len = classKeys.length; i < len; i++) {
162
426
  const key = classKeys[i],
163
427
  classValue = !!value[key];
164
428
  if (!key || key === "undefined" || prev[key] === classValue || !classValue) continue;
165
- toggleClassKey(node, key, true);
429
+ node.classList.add(key);
166
430
  }
167
431
  }
168
- function addEventListener(node, name, handler, delegate) {
432
+ function addEvent(node, name, handler, delegate) {
169
433
  if (delegate) {
170
434
  if (Array.isArray(handler)) {
171
435
  node[`$$${name}`] = handler[0];
@@ -178,33 +442,48 @@ function addEventListener(node, name, handler, delegate) {
178
442
  }
179
443
  function style(node, value, prev) {
180
444
  if (!value) {
181
- if (prev) setAttribute(node, "style");
445
+ if (prev || node._$styles) {
446
+ setAttribute(node, "style");
447
+ node._$styles = undefined;
448
+ }
182
449
  return;
183
450
  }
184
451
  const nodeStyle = node.style;
185
- if (typeof value === "string") return nodeStyle.cssText = value;
186
- typeof prev === "string" && (nodeStyle.cssText = prev = undefined);
187
- prev || (prev = {});
188
- value || (value = {});
452
+ if (typeof value === "string") {
453
+ node._$styles = undefined;
454
+ return nodeStyle.cssText = value;
455
+ }
456
+ if (typeof prev === "string") {
457
+ nodeStyle.cssText = "";
458
+ prev = undefined;
459
+ }
460
+ let applied = node._$styles;
461
+ if (!applied) {
462
+ applied = node._$styles = prev ? {
463
+ ...prev
464
+ } : {};
465
+ }
189
466
  let v, s;
467
+ for (s in applied) {
468
+ if (value[s] == null) {
469
+ nodeStyle.removeProperty(s);
470
+ delete applied[s];
471
+ }
472
+ }
190
473
  for (s in value) {
191
474
  v = value[s];
192
- if (v !== prev[s]) nodeStyle.setProperty(s, v);
193
- delete prev[s];
475
+ if (v != null && v !== applied[s]) {
476
+ nodeStyle.setProperty(s, v);
477
+ applied[s] = v;
478
+ }
194
479
  }
195
- for (s in prev) value[s] == null && nodeStyle.removeProperty(s);
196
480
  }
197
481
  function setStyleProperty(node, name, value) {
198
482
  value != null ? node.style.setProperty(name, value) : node.style.removeProperty(name);
199
483
  }
200
- function spread(node, props = {}, isSVG, skipChildren) {
484
+ function spread(node, props = {}, skipChildren) {
201
485
  const prevProps = {};
202
- if (!skipChildren) {
203
- effect(() => normalize(props.children, prevProps.children), value => {
204
- insertExpression(node, value, prevProps.children);
205
- prevProps.children = value;
206
- });
207
- }
486
+ if (!skipChildren) insert(node, () => props.children);
208
487
  effect(() => {
209
488
  const r = props.ref;
210
489
  (typeof r === "function" || Array.isArray(r)) && ref(() => r, node);
@@ -216,7 +495,7 @@ function spread(node, props = {}, isSVG, skipChildren) {
216
495
  newProps[prop] = props[prop];
217
496
  }
218
497
  return newProps;
219
- }, props => assign(node, props, isSVG, true, prevProps, true));
498
+ }, props => assign(node, props, true, prevProps, true));
220
499
  return prevProps;
221
500
  }
222
501
  function dynamicProperty(props, key) {
@@ -236,49 +515,465 @@ function ref(fn, element) {
236
515
  const resolved = untrack(fn);
237
516
  runWithOwner(null, () => applyRef(resolved, element));
238
517
  }
239
- function insert(parent, accessor, marker, initial) {
240
- const multi = marker !== undefined;
241
- if (multi && !initial) initial = [];
242
- if (isHydrating(parent)) {
243
- if (!multi && initial === undefined && parent) initial = [...parent.childNodes];
244
- if (Array.isArray(initial)) {
245
- let j = 0;
246
- for (let i = 0; i < initial.length; i++) {
247
- if (initial[i].nodeType === 8 && initial[i].nodeValue === "!$") initial[i].remove();else initial[j++] = initial[i];
518
+ function scope(fn) {
519
+ fn.$s = true;
520
+ return fn;
521
+ }
522
+ const SCOPE_OPTIONS = {
523
+ scope: true
524
+ };
525
+ let hydrationRt = null;
526
+ function installHydrationRuntime() {
527
+ hydrationRt = {
528
+ claimInitial(parent, multi, initial) {
529
+ if (isHydrating(parent)) {
530
+ if (!multi && initial === undefined && parent) initial = [...parent.childNodes];
531
+ if (Array.isArray(initial)) stripTextSeparators(initial);
248
532
  }
249
- initial.length = j;
533
+ return initial;
534
+ },
535
+ reclaimRegion(current, parent, marker) {
536
+ if (!sharedConfig.hydrating || !current || !parent.isConnected) return current;
537
+ const first = Array.isArray(current) ? current[0] : current;
538
+ if (!first || !first.nodeType || first.isConnected) return current;
539
+ let nodes;
540
+ if (marker) {
541
+ nodes = [];
542
+ let node = marker.previousSibling,
543
+ depth = 0;
544
+ while (node) {
545
+ if (node.nodeType === 8) {
546
+ const v = node.nodeValue;
547
+ if (v === "/") depth++;else if (v === "$") {
548
+ if (depth === 0) break;
549
+ depth--;
550
+ }
551
+ }
552
+ nodes.unshift(node);
553
+ node = node.previousSibling;
554
+ }
555
+ } else nodes = [...parent.childNodes];
556
+ return stripTextSeparators(nodes);
557
+ },
558
+ dedupEvent(e) {
559
+ return !!(sharedConfig.registry && sharedConfig.events && sharedConfig.events.find(([el, ev]) => ev === e));
250
560
  }
561
+ };
562
+ }
563
+ function stripTextSeparators(nodes) {
564
+ let j = 0;
565
+ for (let i = 0; i < nodes.length; i++) {
566
+ const node = nodes[i],
567
+ t = node.nodeType;
568
+ if (t === 8) {
569
+ const v = node.nodeValue;
570
+ if (v === "!$") {
571
+ node.remove();
572
+ continue;
573
+ }
574
+ if (v.startsWith("pl-")) continue;
575
+ } else if (t === 1 && node.localName === "template" && node.id.startsWith("pl-")) continue;
576
+ nodes[j++] = node;
251
577
  }
578
+ nodes.length = j;
579
+ return nodes;
580
+ }
581
+ function insert(parent, accessor, marker, initial, options) {
582
+ const multi = marker !== undefined;
583
+ const host = options && options.host;
584
+ if (multi && !initial) initial = [];
585
+ if (hydrationRt !== null) initial = hydrationRt.claimInitial(parent, multi, initial);
252
586
  if (typeof accessor !== "function") {
253
587
  accessor = normalize(accessor, initial, multi, true);
254
- if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker);
588
+ if (typeof accessor !== "function") {
589
+ insertExpression(parent, accessor, initial, marker);
590
+ host && tagHost(accessor, host);
591
+ return;
592
+ }
255
593
  }
256
- accessor = memo(accessor, true);
257
- if (multi && initial.length === 0 && !isHydrating(parent)) {
594
+ if (multi && initial.length === 0) {
258
595
  const placeholder = document.createTextNode("");
259
596
  parent.insertBefore(placeholder, marker);
260
597
  initial = [placeholder];
261
598
  }
262
- effect(prev => normalize(accessor, prev, multi), (value, current) => insertExpression(parent, value, current, marker), initial);
599
+ let current = initial;
600
+ effect(prev => {
601
+ if (hydrationRt !== null) current = hydrationRt.reclaimRegion(current, parent, marker);
602
+ const value = normalize(accessor(), current, multi, true);
603
+ if (typeof value !== "function") return value;
604
+ effect(() => (hydrationRt !== null && (current = hydrationRt.reclaimRegion(current, parent, marker)), normalize(value, current, multi)), inner => {
605
+ insertExpression(parent, inner, current, marker);
606
+ current = inner;
607
+ host && tagHost(current, host);
608
+ }, prev !== undefined && !(options && options.schedule) ? {
609
+ ...options,
610
+ schedule: true
611
+ } : options);
612
+ return INNER_OWNED;
613
+ }, value => {
614
+ if (value === INNER_OWNED) return;
615
+ insertExpression(parent, value, current, marker);
616
+ current = value;
617
+ host && tagHost(current, host);
618
+ },
619
+ accessor.$s ? options ? {
620
+ ...options,
621
+ scope: true
622
+ } : SCOPE_OPTIONS : options);
263
623
  }
264
- function assign(node, props, isSVG, skipChildren, prevProps = {}, skipRef = false) {
624
+ function assign(node, props, skipChildren, prevProps = {}, skipRef = false) {
625
+ const nodeName = node.nodeName;
265
626
  props || (props = {});
266
627
  for (const prop in prevProps) {
267
628
  if (!(prop in props)) {
268
629
  if (prop === "children") continue;
269
- prevProps[prop] = assignProp(node, prop, null, prevProps[prop], isSVG, skipRef);
630
+ prevProps[prop] = assignProp(node, prop, null, prevProps[prop], skipRef, nodeName);
270
631
  }
271
632
  }
272
633
  for (const prop in props) {
273
634
  if (prop === "children") {
274
- if (!skipChildren) insertExpression(node, props.children);
635
+ if (!skipChildren) insertExpression(node, normalize(props.children, undefined, false));
275
636
  continue;
276
637
  }
277
- const value = props[prop];
278
- prevProps[prop] = assignProp(node, prop, value, prevProps[prop], isSVG, skipRef);
638
+ prevProps[prop] = assignProp(node, prop, props[prop], prevProps[prop], skipRef, nodeName);
279
639
  }
280
640
  }
641
+ const ASSET_REMOVAL_GRACE = 100;
642
+ const assetRegistry = new Map();
643
+ function assetEntryKey(descriptor) {
644
+ if (descriptor.policy === "exclusive") return "x|" + descriptor.key;
645
+ return descriptor.type === "inline-style" ? "i|" + descriptor.id : descriptor.type + "|" + descriptor.href;
646
+ }
647
+ function findAssetElement(selector, attr, value) {
648
+ const nodes = document.querySelectorAll(selector);
649
+ for (let i = 0; i < nodes.length; i++) {
650
+ if (nodes[i].getAttribute(attr) === value) return nodes[i];
651
+ }
652
+ return null;
653
+ }
654
+ function mountAssetElement(descriptor) {
655
+ let el;
656
+ if (descriptor.type === "inline-style") {
657
+ el = findAssetElement("style[data-asset]", "data-asset", descriptor.id);
658
+ if (!el) {
659
+ el = document.createElement("style");
660
+ el.setAttribute("data-asset", descriptor.id);
661
+ el.textContent = descriptor.content || "";
662
+ }
663
+ } else {
664
+ const rel = descriptor.type === "module" ? "modulepreload" : "stylesheet";
665
+ el = findAssetElement(`link[rel="${rel}"]`, "href", descriptor.href);
666
+ if (!el) {
667
+ el = document.createElement("link");
668
+ el.rel = rel;
669
+ el.href = descriptor.href;
670
+ }
671
+ }
672
+ if (descriptor.attrs) {
673
+ for (const name in descriptor.attrs) el.setAttribute(name, descriptor.attrs[name]);
674
+ }
675
+ if (!el.isConnected) document.head.appendChild(el);
676
+ return el;
677
+ }
678
+ function acquireAsset(descriptor) {
679
+ const key = assetEntryKey(descriptor);
680
+ let entry = assetRegistry.get(key);
681
+ if (descriptor.policy === "exclusive") {
682
+ if (!entry) {
683
+ entry = {
684
+ original: descriptor.get(),
685
+ set: descriptor.set,
686
+ writers: []
687
+ };
688
+ assetRegistry.set(key, entry);
689
+ }
690
+ const writer = {
691
+ value: descriptor.value
692
+ };
693
+ entry.writers.push(writer);
694
+ entry.set(writer.value);
695
+ let released = false;
696
+ return () => {
697
+ if (released) return;
698
+ released = true;
699
+ const index = entry.writers.indexOf(writer);
700
+ const wasTop = index === entry.writers.length - 1;
701
+ entry.writers.splice(index, 1);
702
+ if (!wasTop) return;
703
+ if (entry.writers.length) {
704
+ entry.set(entry.writers[entry.writers.length - 1].value);
705
+ } else {
706
+ entry.set(entry.original);
707
+ assetRegistry.delete(key);
708
+ }
709
+ };
710
+ }
711
+ if (!entry) {
712
+ entry = {
713
+ count: 0,
714
+ element: null,
715
+ timer: null
716
+ };
717
+ assetRegistry.set(key, entry);
718
+ }
719
+ if (entry.timer) {
720
+ clearTimeout(entry.timer);
721
+ entry.timer = null;
722
+ }
723
+ entry.count++;
724
+ if (!entry.element || !entry.element.isConnected) entry.element = mountAssetElement(descriptor);
725
+ let released = false;
726
+ return () => {
727
+ if (released) return;
728
+ released = true;
729
+ if (--entry.count > 0) return;
730
+ entry.timer = setTimeout(() => {
731
+ assetRegistry.delete(key);
732
+ entry.element && entry.element.remove();
733
+ }, ASSET_REMOVAL_GRACE);
734
+ };
735
+ }
736
+ let headRegistrations = null;
737
+ let headSeq = 0;
738
+ let headUid = 0;
739
+ let headOwned = null;
740
+ let headApplied = null;
741
+ let headFallbackTitle = null;
742
+ let headScheduled = false;
743
+ const headMountedResources = new Set();
744
+ function initHeadRegistry() {
745
+ if (headRegistrations) return;
746
+ headRegistrations = [];
747
+ headOwned = new Map();
748
+ headApplied = new Map();
749
+ const t = document.querySelector("title");
750
+ headFallbackTitle = t && !t.hasAttribute("data-dh") ? t.textContent : null;
751
+ if (globalThis._$HY) globalThis._$HY.h = applyServerHeadOps;
752
+ }
753
+ function applyServerHeadOps(ops) {
754
+ for (let i = 0; i < ops.length; i++) {
755
+ const op = ops[i];
756
+ const identity = op[0] === "t" ? "title" : op[1];
757
+ if (headOwned.has(identity)) continue;
758
+ if (op[0] === "t") setHeadTitle(op[1]);else if (op[0] === "r") {
759
+ const els = headMarkedElements(identity);
760
+ for (let j = 0; j < els.length; j++) els[j].remove();
761
+ } else {
762
+ const el = document.createElement(op[2]);
763
+ for (const name in op[3]) el.setAttribute(name, op[3][name]);
764
+ if (op[4] != null) el.textContent = op[4];
765
+ el.setAttribute("data-dh", identity);
766
+ document.head.appendChild(el);
767
+ }
768
+ }
769
+ }
770
+ function headMarkedElements(identity) {
771
+ const nodes = document.head.querySelectorAll("[data-dh]");
772
+ const out = [];
773
+ for (let i = 0; i < nodes.length; i++) {
774
+ if (nodes[i].getAttribute("data-dh") === identity) out.push(nodes[i]);
775
+ }
776
+ return out;
777
+ }
778
+ function setHeadTitle(text) {
779
+ let el = document.querySelector("title");
780
+ if (!el) {
781
+ el = document.createElement("title");
782
+ document.head.appendChild(el);
783
+ }
784
+ el.textContent = text;
785
+ el.setAttribute("data-dh", "title");
786
+ return el;
787
+ }
788
+ function scheduleHeadApply() {
789
+ if (headScheduled) return;
790
+ headScheduled = true;
791
+ queueMicrotask(flushHeadRegistry);
792
+ }
793
+ function flushHeadRegistry() {
794
+ if (sharedConfig.hydrating) {
795
+ setTimeout(flushHeadRegistry, 0);
796
+ return;
797
+ }
798
+ headScheduled = false;
799
+ const winners = resolveHead(headRegistrations);
800
+ for (const [identity, els] of headOwned) {
801
+ if (winners.has(identity)) continue;
802
+ headOwned.delete(identity);
803
+ headApplied.delete(identity);
804
+ if (identity === "title") {
805
+ if (headFallbackTitle != null) setHeadTitle(headFallbackTitle).removeAttribute("data-dh");
806
+ } else {
807
+ for (let i = 0; i < els.length; i++) els[i].remove();
808
+ }
809
+ }
810
+ for (const [identity, winner] of winners) {
811
+ let sig = "";
812
+ for (let i = 0; i < winner.tags.length; i++) sig += winner.tags[i].tag + JSON.stringify(winner.tags[i].props) + "|";
813
+ if (headApplied.get(identity) === sig) continue;
814
+ headApplied.set(identity, sig);
815
+ if (identity === "base" || identity === "charset") {
816
+ continue;
817
+ }
818
+ if (identity === "title") {
819
+ const children = winner.tags[0].props.children;
820
+ setHeadTitle(children == null ? "" : String(children));
821
+ headOwned.set(identity, []);
822
+ continue;
823
+ }
824
+ const existing = headMarkedElements(identity);
825
+ const els = [];
826
+ for (let i = 0; i < winner.tags.length; i++) {
827
+ els.push(renderHeadElement(winner.tags[i], identity, existing));
828
+ }
829
+ for (let i = 0; i < existing.length; i++) {
830
+ if (els.indexOf(existing[i]) === -1) existing[i].remove();
831
+ }
832
+ headOwned.set(identity, els);
833
+ }
834
+ }
835
+ function createHeadElement(tag, props) {
836
+ const el = document.createElement(tag);
837
+ for (const name in props) {
838
+ if (name === "children" || name === "ref" || name.slice(0, 2) === "on") continue;
839
+ if (!HEAD_ATTR_NAME.test(name)) {
840
+ continue;
841
+ }
842
+ const v = props[name];
843
+ if (v == null || v === false) continue;
844
+ el.setAttribute(name, v === true ? "" : String(v));
845
+ }
846
+ if (props.children != null) el.textContent = String(props.children);
847
+ return el;
848
+ }
849
+ function renderHeadElement(t, identity, existing) {
850
+ for (let i = 0; i < existing.length; i++) {
851
+ if (headElementMatches(existing[i], t)) return existing.splice(i, 1)[0];
852
+ }
853
+ const el = createHeadElement(t.tag, t.props);
854
+ el.setAttribute("data-dh", identity);
855
+ document.head.appendChild(el);
856
+ return el;
857
+ }
858
+ function headElementMatches(el, t) {
859
+ if (el.tagName.toLowerCase() !== t.tag) return false;
860
+ for (const name in t.props) {
861
+ if (name === "children" || name === "ref" || name.slice(0, 2) === "on") continue;
862
+ if (!HEAD_ATTR_NAME.test(name)) continue;
863
+ const v = t.props[name];
864
+ if (v == null || v === false) {
865
+ if (el.hasAttribute(name)) return false;
866
+ } else if (el.getAttribute(name) !== (v === true ? "" : String(v))) return false;
867
+ }
868
+ const children = t.props.children;
869
+ return (children == null ? "" : String(children)) === el.textContent;
870
+ }
871
+ function acquireHeadResource(tag, props) {
872
+ if (tag === "link" && (props.rel === "stylesheet" || props.rel === "modulepreload")) {
873
+ const descriptor = {
874
+ type: props.rel === "stylesheet" ? "style" : "module",
875
+ href: props.href
876
+ };
877
+ let attrs = null;
878
+ for (const name in props) {
879
+ if (name === "rel" || name === "href") continue;
880
+ if (!HEAD_ATTR_NAME.test(name)) continue;
881
+ const v = props[name];
882
+ if (v == null || v === false) continue;
883
+ (attrs || (attrs = {}))[name] = v === true ? "" : String(v);
884
+ }
885
+ if (attrs) descriptor.attrs = attrs;
886
+ return acquireAsset(descriptor);
887
+ }
888
+ const identity = resourceIdentity(tag, props);
889
+ if (headMountedResources.has(identity)) return noopFn;
890
+ headMountedResources.add(identity);
891
+ const url = props.href || props.src;
892
+ let el = null;
893
+ if (url != null) {
894
+ if (tag === "link") el = findAssetElement(`link[rel="${props.rel}"]`, "href", url);else if (tag === "script") el = findAssetElement("script[src]", "src", url);else el = findAssetElement("style[href]", "href", url);
895
+ }
896
+ if (!el) document.head.appendChild(createHeadElement(tag, props));
897
+ return noopFn;
898
+ }
899
+ function noopFn() {}
900
+ function useHead(tags) {
901
+ initHeadRegistry();
902
+ const reg = {
903
+ seq: -1,
904
+ tags: null
905
+ };
906
+ const uid = ++headUid;
907
+ effect(() => {
908
+ let list = typeof tags === "function" ? tags() : tags;
909
+ if (!Array.isArray(list)) list = [list];
910
+ const replaceable = [];
911
+ const resources = [];
912
+ for (let i = 0; i < list.length; i++) {
913
+ const desc = list[i];
914
+ if (!desc || !HEAD_ELIGIBLE_TAGS.has(desc.tag)) {
915
+ continue;
916
+ }
917
+ const cls = classifyHeadTag(desc);
918
+ const props = evalHeadProps(desc.props || {}, cls.rel !== undefined ? {
919
+ rel: cls.rel
920
+ } : undefined);
921
+ if (cls.resource) {
922
+ resources.push({
923
+ tag: desc.tag,
924
+ props
925
+ });
926
+ } else {
927
+ const key = evalHeadValue(desc.key);
928
+ replaceable.push({
929
+ tag: desc.tag,
930
+ props,
931
+ identity: replaceableIdentity(desc.tag, props, key, "u:c" + uid + ":" + i)
932
+ });
933
+ }
934
+ }
935
+ return {
936
+ replaceable,
937
+ resources
938
+ };
939
+ }, evaluated => {
940
+ const releases = [];
941
+ for (let i = 0; i < evaluated.resources.length; i++) {
942
+ releases.push(acquireHeadResource(evaluated.resources[i].tag, evaluated.resources[i].props));
943
+ }
944
+ reg.tags = evaluated.replaceable;
945
+ if (reg.seq < 0) reg.seq = ++headSeq;
946
+ if (headRegistrations.indexOf(reg) === -1) headRegistrations.push(reg);
947
+ scheduleHeadApply();
948
+ return () => {
949
+ const idx = headRegistrations.indexOf(reg);
950
+ if (idx > -1) headRegistrations.splice(idx, 1);
951
+ for (let i = 0; i < releases.length; i++) releases[i]();
952
+ scheduleHeadApply();
953
+ };
954
+ });
955
+ }
956
+ function loadModuleAssets(mapping) {
957
+ const hy = globalThis._$HY;
958
+ if (!hy) return;
959
+ const pending = [];
960
+ for (const key in mapping) {
961
+ if (hy.modules[key]) continue;
962
+ const entryUrl = mapping[key];
963
+ if (!hy.loading[key]) {
964
+ hy.loading[key] = import(entryUrl).then(mod => {
965
+ hy.modules[key] = mod;
966
+ }, err => {
967
+ delete hy.loading[key];
968
+ throw err;
969
+ });
970
+ }
971
+ pending.push(hy.loading[key]);
972
+ }
973
+ return pending.length ? Promise.all(pending).then(() => {}) : undefined;
974
+ }
281
975
  function hydrate$1(code, element, options = {}) {
976
+ installHydrationRuntime();
282
977
  if (globalThis._$HY.done) return render$1(code, element, [...element.childNodes], options);
283
978
  options.renderId ||= "";
284
979
  if (!globalThis._$HY.modules) globalThis._$HY.modules = {};
@@ -288,6 +983,7 @@ function hydrate$1(code, element, options = {}) {
288
983
  sharedConfig.load = id => globalThis._$HY.r[id];
289
984
  sharedConfig.has = id => id in globalThis._$HY.r;
290
985
  sharedConfig.gather = root => gatherHydratable(element, root);
986
+ sharedConfig.loadModuleAssets = loadModuleAssets;
291
987
  sharedConfig.cleanupFragment = id => {
292
988
  const tpl = document.getElementById("pl-" + id);
293
989
  if (tpl) {
@@ -305,7 +1001,35 @@ function hydrate$1(code, element, options = {}) {
305
1001
  }
306
1002
  };
307
1003
  sharedConfig.registry = new Map();
1004
+ if (!sharedConfig.boundaryScopes) sharedConfig.boundaryScopes = new Map();
1005
+ sharedConfig.captureBoundaryScope = id => {
1006
+ if (sharedConfig.registry) sharedConfig.boundaryScopes.set(id, {
1007
+ registry: sharedConfig.registry,
1008
+ gather: sharedConfig.gather
1009
+ });
1010
+ };
308
1011
  sharedConfig.hydrating = true;
1012
+ const rootMapping = globalThis._$HY.r && globalThis._$HY.r["_assets"];
1013
+ if (rootMapping && typeof rootMapping === "object") {
1014
+ const p = loadModuleAssets(rootMapping);
1015
+ if (p) {
1016
+ gatherHydratable(element, options.renderId);
1017
+ let disposer;
1018
+ p.then(() => {
1019
+ try {
1020
+ disposer = render$1(code, element, [...element.childNodes], options);
1021
+ } finally {
1022
+ sharedConfig.hydrating = false;
1023
+ }
1024
+ }, err => {
1025
+ console.error("Hydration module preload failed, falling back to client render:", err);
1026
+ sharedConfig.hydrating = false;
1027
+ sharedConfig.registry = undefined;
1028
+ disposer = render$1(code, element, [...element.childNodes], options);
1029
+ });
1030
+ return () => disposer && disposer();
1031
+ }
1032
+ }
309
1033
  try {
310
1034
  gatherHydratable(element, options.renderId);
311
1035
  return render$1(code, element, [...element.childNodes], options);
@@ -371,7 +1095,32 @@ function runHydrationEvents() {
371
1095
  const [el, e] = events[0];
372
1096
  if (!completed.has(el)) return;
373
1097
  events.shift();
374
- eventHandler(e);
1098
+ let matchContainer, matchState, matchDistance, matches;
1099
+ for (const [container, state] of delegatedContainers) {
1100
+ if (!state.handlers.has(e.type)) continue;
1101
+ const entry = findOwner(e.target, state);
1102
+ if (!entry) continue;
1103
+ if (matchContainer) {
1104
+ if (!matches) matches = [{
1105
+ container: matchContainer,
1106
+ state: matchState,
1107
+ distance: matchDistance
1108
+ }];
1109
+ matches.push({
1110
+ container,
1111
+ state,
1112
+ distance: entry.distance
1113
+ });
1114
+ } else {
1115
+ matchContainer = container;
1116
+ matchState = state;
1117
+ matchDistance = entry.distance;
1118
+ }
1119
+ }
1120
+ if (matches) {
1121
+ matches.sort((a, b) => a.distance - b.distance);
1122
+ for (let i = 0; i < matches.length; i++) eventHandler(e, matches[i].container, matches[i].state);
1123
+ } else if (matchContainer) eventHandler(e, matchContainer, matchState);
375
1124
  }
376
1125
  if (sharedConfig.done) {
377
1126
  sharedConfig.events = _$HY.events = null;
@@ -382,16 +1131,31 @@ function runHydrationEvents() {
382
1131
  }
383
1132
  }
384
1133
  function isHydrating(node) {
385
- return sharedConfig.hydrating && (!node || node.isConnected);
386
- }
387
- function toggleClassKey(node, key, value) {
388
- const classNames = key.trim().split(/\s+/);
389
- for (let i = 0, nameLen = classNames.length; i < nameLen; i++) node.classList.toggle(classNames[i], value);
1134
+ if (!sharedConfig.hydrating) return false;
1135
+ if (!node || node.isConnected) return true;
1136
+ const roots = sharedConfig.claimRoots;
1137
+ if (roots) {
1138
+ for (let i = 0; i < roots.length; i++) {
1139
+ if (roots[i].contains(node)) return true;
1140
+ }
1141
+ }
1142
+ return false;
390
1143
  }
391
1144
  function classListToObject(classList) {
392
1145
  if (Array.isArray(classList)) {
393
1146
  const result = {};
394
1147
  flattenClassList(classList, result);
1148
+ classList = result;
1149
+ }
1150
+ if (classList && typeof classList === "object") {
1151
+ const result = {},
1152
+ keys = Object.keys(classList);
1153
+ for (let i = 0, len = keys.length; i < len; i++) {
1154
+ const key = keys[i];
1155
+ if (!classList[key]) continue;
1156
+ const classNames = key.trim().split(/\s+/);
1157
+ for (let j = 0, nameLen = classNames.length; j < nameLen; j++) classNames[j] && (result[classNames[j]] = true);
1158
+ }
395
1159
  return result;
396
1160
  }
397
1161
  return classList;
@@ -402,18 +1166,16 @@ function flattenClassList(list, result) {
402
1166
  if (Array.isArray(item)) flattenClassList(item, result);else if (typeof item === "object" && item != null) Object.assign(result, item);else if (item || item === 0) result[item] = true;
403
1167
  }
404
1168
  }
405
- function assignProp(node, prop, value, prev, isSVG, skipRef) {
406
- let forceProp;
1169
+ function assignProp(node, prop, value, prev, skipRef, nodeName) {
407
1170
  if (prop === "style") return style(node, value, prev), value;
408
- if (prop === "class") return className(node, value, isSVG, prev), value;
409
- if (value === prev) return prev;
1171
+ if (prop === "class") return className(node, value, prev), value;
1172
+ if (value === prev && DOMWithState[nodeName]?.[prop] !== 1) return prev;
410
1173
  if (prop === "ref") {
411
1174
  if (!skipRef && value) ref(() => value, node);
412
- } else if (prop.slice(0, 3) === "on:") {
413
- const e = prop.slice(3);
414
- prev && node.removeEventListener(e, prev, typeof prev !== "function" && prev);
415
- value && node.addEventListener(e, value, typeof value !== "function" && value);
416
- } else if (prop.slice(0, 2) === "on") {
1175
+ return value;
1176
+ }
1177
+ const hasNamespace = prop.indexOf(":") > -1;
1178
+ if (!hasNamespace && prop.slice(0, 2) === "on") {
417
1179
  const name = prop.slice(2).toLowerCase();
418
1180
  const delegate = DelegatedEvents.has(name);
419
1181
  if (!delegate && prev) {
@@ -421,26 +1183,34 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
421
1183
  node.removeEventListener(name, h);
422
1184
  }
423
1185
  if (delegate || value) {
424
- addEventListener(node, name, value, delegate);
1186
+ addEvent(node, name, value, delegate);
425
1187
  delegate && delegateEvents([name]);
426
1188
  }
427
- } else if ((forceProp = prop.slice(0, 5) === "prop:") || ChildProperties.has(prop) || !isSVG && Properties.has(prop)) {
428
- if (forceProp) prop = prop.slice(5);else if (isHydrating(node)) return value;
429
- if (prop === "value" && node.nodeName === "SELECT") queueMicrotask(() => node.value = value) || (node.value = value);else node[prop] = value;
1189
+ } else if (hasNamespace && prop.slice(0, 5) === "prop:" || ChildProperties.has(prop) || DOMWithState[nodeName]?.[prop]) {
1190
+ if (hasNamespace) prop = prop.slice(5);else if (isHydrating(node)) return value;
1191
+ if (prop === "value" && nodeName === "SELECT") queueMicrotask(() => node.value = value) || (node.value = value);else if ((prop === "value" || prop === "defaultValue") && (nodeName === "INPUT" || nodeName === "TEXTAREA"))
1192
+ node[prop] = value ?? "";else node[prop] = value;
430
1193
  } else {
431
- const ns = isSVG && prop.indexOf(":") > -1 && SVGNamespace[prop.split(":")[0]];
1194
+ const ns = hasNamespace && Namespaces[prop.split(":")[0]];
432
1195
  if (ns) setAttributeNS(node, ns, prop, value);else setAttribute(node, prop, value);
433
1196
  }
434
1197
  return value;
435
1198
  }
436
- function eventHandler(e) {
437
- if (sharedConfig.registry && sharedConfig.events) {
438
- if (sharedConfig.events.find(([el, ev]) => ev === e)) return;
1199
+ function eventHandler(e, container, state) {
1200
+ if (hydrationRt !== null && hydrationRt.dedupEvent(e)) return;
1201
+ const prev = e[$$EVENT_OWNER];
1202
+ let resumeNode;
1203
+ if (prev) {
1204
+ if (prev === true || prev === container || !container.contains(prev)) return;
1205
+ resumeNode = prev;
439
1206
  }
440
- let node = e.target;
1207
+ const owner = state && (state.owners.size === 1 && state.owners.has(container) ? container : findOwner(e.target, state)?.owner);
1208
+ if (state && !owner) return;
1209
+ e[$$EVENT_OWNER] = owner || true;
1210
+ let node = resumeNode || e.target;
441
1211
  const key = `$$${e.type}`;
442
1212
  const oriTarget = e.target;
443
- const oriCurrentTarget = e.currentTarget;
1213
+ const boundary = owner || container || e.currentTarget;
444
1214
  const retarget = value => Object.defineProperty(e, "target", {
445
1215
  configurable: true,
446
1216
  value
@@ -456,35 +1226,43 @@ function eventHandler(e) {
456
1226
  return true;
457
1227
  };
458
1228
  const walkUpTree = () => {
459
- while (handleNode() && (node = node._$host || node.parentNode || node.host));
1229
+ while (handleNode()) {
1230
+ if (node === boundary || node.parentNode === boundary) break;
1231
+ node = node._$host || node.parentNode || node.host;
1232
+ }
460
1233
  };
461
1234
  Object.defineProperty(e, "currentTarget", {
462
1235
  configurable: true,
463
1236
  get() {
464
- return node || document;
1237
+ return node || boundary || document;
465
1238
  }
466
1239
  });
467
- if (e.composedPath) {
1240
+ if (resumeNode) {
1241
+ if (resumeNode === e.target) node = resumeNode._$host || resumeNode.parentNode || resumeNode.host;
1242
+ if (node && node !== boundary) walkUpTree();
1243
+ } else if (e.composedPath) {
468
1244
  const path = e.composedPath();
469
- retarget(path[0]);
470
- for (let i = 0; i < path.length - 2; i++) {
471
- node = path[i];
472
- if (!handleNode()) break;
473
- if (node._$host) {
474
- node = node._$host;
475
- walkUpTree();
476
- break;
477
- }
478
- if (node.parentNode === oriCurrentTarget) {
479
- break;
1245
+ if (path.length) {
1246
+ retarget(path[0]);
1247
+ for (let i = 0; i < path.length; i++) {
1248
+ node = path[i];
1249
+ if (!handleNode()) break;
1250
+ if (node._$host) {
1251
+ node = node._$host;
1252
+ walkUpTree();
1253
+ break;
1254
+ }
1255
+ if (node === boundary || node.parentNode === boundary) {
1256
+ break;
1257
+ }
480
1258
  }
481
- }
1259
+ } else walkUpTree();
482
1260
  }
483
1261
  else walkUpTree();
484
1262
  retarget(oriTarget);
485
1263
  }
486
1264
  function insertExpression(parent, value, current, marker) {
487
- if (isHydrating(parent)) return;
1265
+ if (hydrationRt !== null && isHydrating(parent)) return;
488
1266
  if (value === current) return;
489
1267
  const t = typeof value,
490
1268
  multi = marker !== undefined;
@@ -492,15 +1270,25 @@ function insertExpression(parent, value, current, marker) {
492
1270
  const tc = typeof current;
493
1271
  if (tc === "string" || tc === "number") {
494
1272
  parent.firstChild.data = value;
495
- } else parent.textContent = value;
1273
+ } else {
1274
+ if (ownsAllChildren(parent, current)) parent.textContent = value;else {
1275
+ removeOwnedChildren(parent, current);
1276
+ parent.insertBefore(document.createTextNode(value), parent.firstChild);
1277
+ }
1278
+ }
496
1279
  } else if (value === undefined) {
497
1280
  cleanChildren(parent, current, marker);
498
1281
  } else if (value.nodeType) {
499
1282
  if (Array.isArray(current)) {
500
1283
  cleanChildren(parent, current, multi ? marker : null, value);
501
- } else if (current === undefined || !parent.firstChild) {
1284
+ } else if (current && current.nodeType) {
1285
+ current.parentNode === parent ? parent.replaceChild(value, current) : parent.appendChild(value);
1286
+ } else if (current && parent.firstChild) {
1287
+ parent.replaceChild(value, parent.firstChild);
1288
+ } else {
502
1289
  parent.appendChild(value);
503
- } else parent.replaceChild(value, parent.firstChild);
1290
+ }
1291
+ if (marker) value[$$SLOT] = marker;
504
1292
  } else if (Array.isArray(value)) {
505
1293
  const currentArray = current && Array.isArray(current);
506
1294
  if (value.length === 0) {
@@ -508,9 +1296,9 @@ function insertExpression(parent, value, current, marker) {
508
1296
  } else if (currentArray) {
509
1297
  if (current.length === 0) {
510
1298
  appendNodes(parent, value, marker);
511
- } else reconcileArrays(parent, current, value);
1299
+ } else reconcileArrays(parent, current, value, marker);
512
1300
  } else {
513
- current && cleanChildren(parent);
1301
+ current && cleanChildren(parent, current);
514
1302
  appendNodes(parent, value);
515
1303
  }
516
1304
  } else ;
@@ -532,21 +1320,64 @@ function normalize(value, current, multi, doNotUnwrap) {
532
1320
  }
533
1321
  return value;
534
1322
  }
1323
+ function tagHost(value, host) {
1324
+ if (Array.isArray(value)) {
1325
+ for (let i = 0, len = value.length; i < len; i++) tagHost(value[i], host);
1326
+ } else if (value && value.nodeType && value[$$HOST] !== host) {
1327
+ value[$$HOST] = host;
1328
+ Object.defineProperty(value, "_$host", {
1329
+ get: host,
1330
+ configurable: true
1331
+ });
1332
+ }
1333
+ }
535
1334
  function appendNodes(parent, array, marker = null) {
536
- for (let i = 0, len = array.length; i < len; i++) parent.insertBefore(array[i], marker);
1335
+ for (let i = 0, len = array.length; i < len; i++) {
1336
+ const n = array[i];
1337
+ parent.insertBefore(n, marker);
1338
+ if (marker) n[$$SLOT] = marker;
1339
+ }
1340
+ }
1341
+ function ownsAllChildren(parent, current) {
1342
+ if (current == null) return true;
1343
+ if (Array.isArray(current)) {
1344
+ return current.length ? parent.firstChild === current[0] && parent.lastChild === current[current.length - 1] : parent.firstChild === null;
1345
+ }
1346
+ if (current === "") return parent.firstChild === null;
1347
+ if (current.nodeType) return parent.firstChild === current && parent.lastChild === current;
1348
+ const first = parent.firstChild;
1349
+ return first !== null && first.nodeType === 3 && parent.lastChild === first;
1350
+ }
1351
+ function removeOwnedChildren(parent, current) {
1352
+ if (Array.isArray(current)) {
1353
+ for (let i = 0; i < current.length; i++) {
1354
+ const el = current[i];
1355
+ if (el.parentNode === parent) el.remove();
1356
+ }
1357
+ } else if (current.nodeType) {
1358
+ if (current.parentNode === parent) current.remove();
1359
+ } else {
1360
+ const first = parent.firstChild;
1361
+ if (first && first.nodeType === 3) first.remove();
1362
+ }
537
1363
  }
538
1364
  function cleanChildren(parent, current, marker, replacement) {
539
- if (marker === undefined) return parent.textContent = "";
1365
+ if (marker === undefined) {
1366
+ if (ownsAllChildren(parent, current)) return parent.textContent = "";
1367
+ return removeOwnedChildren(parent, current);
1368
+ }
540
1369
  if (current.length) {
541
1370
  let inserted = false;
542
1371
  for (let i = current.length - 1; i >= 0; i--) {
543
1372
  const el = current[i];
544
1373
  if (replacement !== el) {
545
- const isParent = el.parentNode === parent;
546
- if (replacement && !inserted && !i) isParent ? parent.replaceChild(replacement, el) : parent.insertBefore(replacement, marker);else isParent && el.remove();
1374
+ const tag = el[$$SLOT];
1375
+ const owns = el.parentNode === parent && (!tag || tag === marker);
1376
+ if (replacement && !inserted && !i) owns ? parent.replaceChild(replacement, el) : parent.insertBefore(replacement, marker);else if (owns) el.remove();
547
1377
  } else inserted = true;
548
1378
  }
549
1379
  } else if (replacement) parent.insertBefore(replacement, marker);
1380
+ if (replacement && marker) replacement[$$SLOT] = marker;
550
1381
  }
551
1382
  function gatherHydratable(element, root) {
552
1383
  const templates = element.querySelectorAll(`*[_hk]`);
@@ -584,77 +1415,228 @@ function ssrHydrationKey() {}
584
1415
  function resolveSSRNode(node) {}
585
1416
  function escape(html) {}
586
1417
 
587
- function render(...args) {
588
- const result = render$1(...args);
589
- return result;
1418
+ const ENVELOPE = Symbol.for("solid.ResponseEnvelope");
1419
+ class ResponseEnvelope {
1420
+ constructor(response, value) {
1421
+ this.response = response;
1422
+ this.value = value;
1423
+ }
1424
+ }
1425
+ ResponseEnvelope.prototype[ENVELOPE] = true;
1426
+ function isResponseEnvelope(value) {
1427
+ return !!(value && typeof value === "object" && value[ENVELOPE]);
590
1428
  }
1429
+ const HREF = Symbol.for("solid.Href");
1430
+ function isHref(value) {
1431
+ return !!(value && (typeof value === "object" || typeof value === "function") && value[HREF]);
1432
+ }
1433
+ const REVALIDATE_HEADER = "X-Revalidate";
1434
+ function initWithRevalidate(init) {
1435
+ const {
1436
+ revalidate,
1437
+ ...responseInit
1438
+ } = init;
1439
+ const headers = new Headers(responseInit.headers);
1440
+ revalidate !== undefined && headers.set(REVALIDATE_HEADER, revalidate.toString());
1441
+ return {
1442
+ responseInit,
1443
+ headers
1444
+ };
1445
+ }
1446
+ function redirect(url, init = 302) {
1447
+ if (typeof url !== "string" && !isHref(url)) {
1448
+ throw new TypeError("redirect() expects a string URL or an Href-branded value (Symbol.for('solid.Href')).");
1449
+ }
1450
+ const {
1451
+ responseInit,
1452
+ headers
1453
+ } = initWithRevalidate(typeof init === "number" ? {
1454
+ status: init
1455
+ } : init);
1456
+ if (responseInit.status === undefined) {
1457
+ responseInit.status = 302;
1458
+ }
1459
+ headers.set("Location", String(url));
1460
+ return new Response(null, {
1461
+ ...responseInit,
1462
+ headers
1463
+ });
1464
+ }
1465
+ function reload(init = {}) {
1466
+ const {
1467
+ responseInit,
1468
+ headers
1469
+ } = initWithRevalidate(init);
1470
+ return new Response(null, {
1471
+ ...responseInit,
1472
+ headers
1473
+ });
1474
+ }
1475
+ function respond(value, init = {}) {
1476
+ const {
1477
+ responseInit,
1478
+ headers
1479
+ } = initWithRevalidate(init);
1480
+ headers.set("Content-Type", "application/json");
1481
+ return new ResponseEnvelope(new Response(JSON.stringify(value), {
1482
+ ...responseInit,
1483
+ headers
1484
+ }), value);
1485
+ }
1486
+
1487
+ const mergeProps = merge;
591
1488
  const isServer = false;
592
1489
  const isDev = false;
593
- const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
594
- function createElement(tagName, isSVG = false, is = undefined) {
595
- return isSVG ? document.createElementNS(SVG_NAMESPACE, tagName) : document.createElement(tagName, {
596
- is
597
- });
1490
+ function render(code, element, init, options = {}) {
1491
+ try {
1492
+ const dispose = render$1(code, element, init, {
1493
+ ...options,
1494
+ insertOptions: {
1495
+ schedule: true
1496
+ }
1497
+ });
1498
+ flush();
1499
+ return dispose;
1500
+ } finally {
1501
+ }
598
1502
  }
599
1503
  const hydrate = (...args) => {
600
1504
  enableHydration();
601
1505
  return hydrate$1(...args);
602
1506
  };
603
1507
  function Portal(props) {
1508
+ return runWithOwner(createOwner(), () => portalImpl(props));
1509
+ }
1510
+ function portalImpl(props) {
604
1511
  const treeMarker = document.createTextNode(""),
605
1512
  startMarker = document.createTextNode(""),
606
1513
  endMarker = document.createTextNode(""),
607
- mount = () => createElementProxy(props.mount || document.body, treeMarker);
608
- let content = createMemo$1(() => [startMarker, props.children]);
609
- createRenderEffect(() => [mount(), content()], ([m, c]) => {
1514
+ mount = () => props.mount || document.body,
1515
+ content = createMemo(() => [startMarker, props.children], {
1516
+ ssrSource: "client"
1517
+ });
1518
+ createRenderEffect(
1519
+ () => [mount(), content(), getOwner()], ([, c, owner]) => {
1520
+ const m = untrack(mount);
610
1521
  m.appendChild(endMarker);
611
- insert(m, c, endMarker);
1522
+ const dispose = runWithOwner(owner, () => createRoot(d => {
1523
+ insert(m, c, endMarker, undefined, {
1524
+ host: () => treeMarker.parentNode
1525
+ });
1526
+ return d;
1527
+ }));
612
1528
  return () => {
1529
+ dispose();
613
1530
  let c = startMarker;
614
- while (c && c !== endMarker) {
1531
+ while (c) {
615
1532
  const n = c.nextSibling;
616
1533
  m.removeChild(c);
1534
+ if (c === endMarker) break;
617
1535
  c = n;
618
1536
  }
619
1537
  };
1538
+ },
1539
+ {
1540
+ schedule: true,
1541
+ ssrSource: "client"
1542
+ });
1543
+ createEffect(mount, () => {
1544
+ const m = untrack(mount);
1545
+ const ownerRoot = getDelegatedRoot(treeMarker);
1546
+ if (!ownerRoot || ownerRoot.contains(m)) return;
1547
+ registerDelegatedContainer(m, ownerRoot);
1548
+ return () => unregisterDelegatedContainer(m, ownerRoot);
1549
+ }, {
1550
+ ssrSource: "client"
1551
+ });
1552
+ if (sharedConfig.hydrating) return createMemo(() => treeMarker, {
1553
+ ssrSource: "client"
620
1554
  });
621
1555
  return treeMarker;
622
1556
  }
623
- function createElementProxy(el, marker) {
624
- return new Proxy(el, {
625
- get(target, prop) {
626
- if (prop === "appendChild" || prop === "insertBefore") {
627
- return (...args) => {
628
- Object.defineProperty(args[0], "_$host", {
629
- get: () => marker.parentNode,
630
- configurable: true
631
- });
632
- target[prop](...args);
633
- };
634
- }
635
- const value = Reflect.get(target, prop);
636
- return typeof value === "function" ? value.bind(target) : value;
637
- }
638
- });
1557
+ const COMPONENT_BINDING = Symbol.for("dom-expressions.component-binding");
1558
+ function bindingOf(value) {
1559
+ return value !== null && (typeof value === "function" || typeof value === "object") && value[COMPONENT_BINDING] || undefined;
639
1560
  }
640
- function createDynamic(component, props) {
641
- const cached = createMemo$1(component);
642
- return createMemo$1(() => {
643
- const component = cached();
644
- switch (typeof component) {
645
- case "function":
646
- return untrack(() => component(props));
647
- case "string":
648
- const isSvg = SVGElements.has(component);
649
- const el = sharedConfig.hydrating ? getNextElement() : createElement(component, isSvg, untrack(() => props.is));
650
- spread(el, props, isSvg);
651
- return el;
1561
+ function dynamic(source) {
1562
+ let latest = 0;
1563
+ const sites = new Set();
1564
+ const resolveBinding = (next, prev) => {
1565
+ const binding = bindingOf(next);
1566
+ if (!binding) return next;
1567
+ const prevBinding = bindingOf(prev);
1568
+ if (prevBinding && prevBinding.component === binding.component) {
1569
+ for (const deliver of sites) deliver(binding.address);
1570
+ return prev;
652
1571
  }
1572
+ return next;
1573
+ };
1574
+ const cached = createMemo(prev => {
1575
+ const next = source();
1576
+ if (!next || typeof next.then !== "function") return resolveBinding(next, prev);
1577
+ const token = ++latest;
1578
+ return {
1579
+ then: (onFulfilled, onRejected) => next.then(resolved => onFulfilled(token === latest ? resolveBinding(resolved, prev) : resolved), onRejected)
1580
+ };
1581
+ }, {
1582
+ lazy: true
653
1583
  });
1584
+ return props => {
1585
+ return createMemo(() => {
1586
+ const component = cached();
1587
+ switch (typeof component) {
1588
+ case "function":
1589
+ {
1590
+ const binding = bindingOf(component);
1591
+ if (binding) {
1592
+ const [address, setAddress] = createSignal(binding.address);
1593
+ sites.add(setAddress);
1594
+ onCleanup(() => sites.delete(setAddress));
1595
+ return untrack(() => binding.component(props, address));
1596
+ }
1597
+ return untrack(() => component(props));
1598
+ }
1599
+ case "string":
1600
+ const el = sharedConfig.hydrating ? getNextElement() : createElement(component, untrack(() => props.is));
1601
+ spread(el, props);
1602
+ return el;
1603
+ }
1604
+ });
1605
+ };
654
1606
  }
655
1607
  function Dynamic(props) {
656
- const others = omit(props, "component");
657
- return createDynamic(() => props.component, others);
1608
+ const Comp = dynamic(() => props.component);
1609
+ return createComponent(Comp, omit(props, "component"));
1610
+ }
1611
+ function createElement(tagName, is = undefined) {
1612
+ return SVGElements.has(tagName) ? document.createElementNS(Namespaces.svg, tagName) : MathMLElements.has(tagName) ? document.createElementNS(Namespaces.mathml, tagName) : document.createElement(tagName, {
1613
+ is
1614
+ });
1615
+ }
1616
+ function loadClientOnly(fn, setComp) {
1617
+ fn().then(m => setComp(() => m.default));
1618
+ }
1619
+ function clientOnly(fn, options = {},
1620
+ _moduleUrl) {
1621
+ const [comp, setComp] = createSignal();
1622
+ let started = !options.lazy;
1623
+ started && loadClientOnly(fn, setComp);
1624
+ return props => {
1625
+ let Comp;
1626
+ let m;
1627
+ const rest = omit(props, "fallback");
1628
+ if (!started) {
1629
+ started = true;
1630
+ loadClientOnly(fn, setComp);
1631
+ }
1632
+ if ((Comp = untrack(comp)) && !sharedConfig.hydrating) return Comp(rest);
1633
+ const [mounted, setMounted] = createSignal(!sharedConfig.hydrating);
1634
+ const gate = createMemo(() => (Comp = comp(), m = mounted(), untrack(() => Comp && m ? Comp(rest) : props.fallback)));
1635
+ sharedConfig.onHydrationEnd(() => setMounted(true));
1636
+ return gate;
1637
+ };
658
1638
  }
1639
+ function httpStatus(_code, _text) {}
1640
+ function httpHeader(_name, _value, _options) {}
659
1641
 
660
- export { voidFn as Assets, ChildProperties, DOMElements, DelegatedEvents, Dynamic, voidFn as HydrationScript, Portal, Properties, RequestContext, SVGElements, SVGNamespace, addEventListener, applyRef, assign, className, clearDelegatedEvents, createDynamic, delegateEvents, dynamicProperty, effect, escape, voidFn as generateHydrationScript, voidFn as getAssets, getFirstChild, getHydrationKey, getNextElement, getNextMarker, getNextMatch, getNextSibling, voidFn as getRequestEvent, hydrate, insert, isDev, isServer, memo, ref, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, setProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrStyle, style, template, voidFn as useAssets };
1642
+ export { voidFn as Assets, ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, HREF, voidFn as HydrationScript, MathMLElements, Namespaces, Portal, REVALIDATE_HEADER, RawTextElements, RequestContext, ResponseEnvelope, SVGElements, VoidElements, acquireAsset, addEvent, applyRef, assign, claimElement, claimElementTree, className, clientOnly, delegateEvents, dynamic, dynamicProperty, effect, escape, voidFn as generateHydrationScript, voidFn as getAssets, getDelegatedRoot, getFirstChild, getHydrationKey, getNextElement, getNextMarker, getNextMatch, getNextSibling, voidFn as getRequestEvent, httpHeader, httpStatus, hydrate, insert, installHydrationRuntime, isDev, isHref, isResponseEnvelope, isServer, memo, mergeProps, redirect, ref, registerDelegatedContainer, registerDelegatedRoot, registerElementClaim, reload, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, respond, runHydrationEvents, scope, setAttribute, setAttributeNS, setProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrStyle, style, template, unregisterDelegatedContainer, unregisterDelegatedRoot, voidFn as useAssets, useHead };