@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/dev.cjs CHANGED
@@ -1,40 +1,81 @@
1
1
  'use strict';
2
2
 
3
3
  var solidJs = require('solid-js');
4
- var signals = require('@solidjs/signals');
5
4
 
6
- const Properties = /*#__PURE__*/new Set([
7
- "value", "checked", "selected", "muted"]);
5
+ const DOMWithState = {
6
+ INPUT: {
7
+ value: 1,
8
+ defaultValue: 2,
9
+ checked: 1,
10
+ defaultChecked: 2
11
+ },
12
+ SELECT: {
13
+ value: 1
14
+ },
15
+ OPTION: {
16
+ value: 1,
17
+ selected: 1,
18
+ defaultSelected: 2
19
+ },
20
+ TEXTAREA: {
21
+ value: 1,
22
+ defaultValue: 2
23
+ },
24
+ VIDEO: {
25
+ muted: 1,
26
+ defaultMuted: 2
27
+ },
28
+ AUDIO: {
29
+ muted: 1,
30
+ defaultMuted: 2
31
+ }
32
+ };
8
33
  const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
34
+ const $$SLOT = /*#__PURE__*/Symbol("slot");
35
+ const $$HOST = /*#__PURE__*/Symbol("host");
9
36
  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"]);
10
37
  const SVGElements = /*#__PURE__*/new Set([
11
38
  "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",
12
39
  "set", "stop",
13
40
  "svg", "switch", "symbol", "text", "textPath",
14
41
  "tref", "tspan", "use", "view", "vkern"]);
15
- const SVGNamespace = {
42
+ 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"]);
43
+ const Namespaces = {
44
+ svg: "http://www.w3.org/2000/svg",
45
+ mathml: "http://www.w3.org/1998/Math/MathML",
16
46
  xlink: "http://www.w3.org/1999/xlink",
17
47
  xml: "http://www.w3.org/XML/1998/namespace"
18
48
  };
19
- 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",
20
- "webview",
21
- "isindex", "listing", "multicol", "nextid", "noindex", "search"]);
49
+ const VoidElements = /*#__PURE__*/new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]);
50
+ const RawTextElements = /*#__PURE__*/new Set(["style", "script", "noscript", "template", "textarea", "title"]);
51
+ 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(","));
22
52
 
23
- const effect = (fn, effectFn, initial) => solidJs.createRenderEffect(fn, effectFn, initial, {
24
- transparent: true
25
- });
26
- const memo = (fn, transparent) => transparent ? fn.$r ? fn : signals.createMemo(() => fn(), undefined, {
27
- transparent: true
28
- }) : solidJs.createMemo(() => fn());
53
+ const transparentOptions = {
54
+ transparent: true,
55
+ sync: true
56
+ };
57
+ const syncOptions = {
58
+ sync: true
59
+ };
60
+ const effect = (fn, effectFn, options) => solidJs.createRenderEffect(fn, effectFn, options ? {
61
+ sync: true,
62
+ ...options,
63
+ transparent: !options.scope
64
+ } : transparentOptions);
65
+ const memo = fn => solidJs.createMemo(() => fn(), syncOptions);
29
66
 
30
- function reconcileArrays(parentNode, a, b) {
67
+ function reconcileArrays(parentNode, a, b, marker) {
31
68
  let bLength = b.length,
32
69
  aEnd = a.length,
33
70
  bEnd = bLength,
34
71
  aStart = 0,
35
72
  bStart = 0,
36
- after = a[aEnd - 1].nextSibling,
37
- map = null;
73
+ tail = a[aEnd - 1],
74
+ tailTag = tail[$$SLOT],
75
+ after = tail.parentNode === parentNode && (!tailTag || tailTag === marker) ? tail.nextSibling : marker || null,
76
+ map = null,
77
+ anchor,
78
+ anchorTag;
38
79
  while (aStart < aEnd || bStart < bEnd) {
39
80
  if (a[aStart] === b[bStart]) {
40
81
  aStart++;
@@ -46,18 +87,43 @@ function reconcileArrays(parentNode, a, b) {
46
87
  bEnd--;
47
88
  }
48
89
  if (aEnd === aStart) {
49
- const node = bEnd < bLength ? bStart ? b[bStart - 1].nextSibling : b[bEnd - bStart] : after;
50
- while (bStart < bEnd) parentNode.insertBefore(b[bStart++], node);
90
+ let node;
91
+ if (bEnd < bLength) {
92
+ if (bStart) {
93
+ const prev = b[bStart - 1];
94
+ const prevTag = prev[$$SLOT];
95
+ node = prev.parentNode === parentNode && (!prevTag || prevTag === marker) ? prev.nextSibling : after;
96
+ } else node = b[bEnd - bStart];
97
+ } else node = after;
98
+ while (bStart < bEnd) {
99
+ const n = b[bStart++];
100
+ parentNode.insertBefore(n, node);
101
+ if (marker) n[$$SLOT] = marker;
102
+ }
51
103
  } else if (bEnd === bStart) {
52
104
  while (aStart < aEnd) {
53
- if (!map || !map.has(a[aStart])) a[aStart].remove();
54
- aStart++;
105
+ const n = a[aStart++];
106
+ if (!map || !map.has(n)) {
107
+ const tag = n[$$SLOT];
108
+ if (n.parentNode === parentNode && (!tag || tag === marker)) n.remove();
109
+ }
110
+ }
111
+ } else if ((anchor = a[aStart]) === b[bEnd - 1] && b[bStart] === a[aEnd - 1] && anchor.parentNode === parentNode && (!(anchorTag = anchor[$$SLOT]) || anchorTag === marker)) {
112
+ if (marker) {
113
+ do {
114
+ const n = a[--aEnd];
115
+ parentNode.insertBefore(n, anchor);
116
+ n[$$SLOT] = marker;
117
+ bStart++;
118
+ if (aStart >= aEnd - 1 || bStart >= bEnd) break;
119
+ } while (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]);
120
+ } else {
121
+ do {
122
+ parentNode.insertBefore(a[--aEnd], anchor);
123
+ bStart++;
124
+ if (aStart >= aEnd - 1 || bStart >= bEnd) break;
125
+ } while (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]);
55
126
  }
56
- } else if (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]) {
57
- const node = a[--aEnd].nextSibling;
58
- parentNode.insertBefore(b[bStart++], a[aStart++].nextSibling);
59
- parentNode.insertBefore(b[--bEnd], node);
60
- a[aEnd] = b[bEnd];
61
127
  } else {
62
128
  if (!map) {
63
129
  map = new Map();
@@ -75,80 +141,279 @@ function reconcileArrays(parentNode, a, b) {
75
141
  sequence++;
76
142
  }
77
143
  if (sequence > index - bStart) {
78
- const node = a[aStart];
79
- while (bStart < index) parentNode.insertBefore(b[bStart++], node);
80
- } else parentNode.replaceChild(b[bStart++], a[aStart++]);
144
+ const head = a[aStart];
145
+ const headTag = head[$$SLOT];
146
+ const node = head.parentNode === parentNode && (!headTag || headTag === marker) ? head : after;
147
+ while (bStart < index) {
148
+ const n = b[bStart++];
149
+ parentNode.insertBefore(n, node);
150
+ if (marker) n[$$SLOT] = marker;
151
+ }
152
+ } else {
153
+ const oldNode = a[aStart++];
154
+ const newNode = b[bStart++];
155
+ const oldTag = oldNode[$$SLOT];
156
+ if (oldNode.parentNode === parentNode && (!oldTag || oldTag === marker)) {
157
+ parentNode.replaceChild(newNode, oldNode);
158
+ } else {
159
+ parentNode.insertBefore(newNode, after);
160
+ }
161
+ if (marker) newNode[$$SLOT] = marker;
162
+ }
81
163
  } else aStart++;
82
- } else a[aStart++].remove();
164
+ } else {
165
+ const n = a[aStart++];
166
+ const nTag = n[$$SLOT];
167
+ if (n.parentNode === parentNode && (!nTag || nTag === marker)) n.remove();
168
+ }
169
+ }
170
+ }
171
+ }
172
+
173
+ const HEAD_ELIGIBLE_TAGS = new Set(["title", "meta", "link", "style", "script", "base"]);
174
+ const HEAD_ATTR_NAME = /^[a-zA-Z_][a-zA-Z0-9_:.-]*$/;
175
+ const RESOURCE_LINK_RELS = new Set(["preload", "modulepreload", "prefetch", "preconnect", "dns-prefetch", "stylesheet"]);
176
+ const RESOURCE_QUALIFIERS = ["as", "crossorigin", "type", "media", "imagesrcset", "imagesizes"];
177
+ function evalHeadValue(v) {
178
+ return typeof v === "function" ? v() : v;
179
+ }
180
+ function evalHeadProps(props, presets) {
181
+ const out = {};
182
+ for (const name in props) out[name] = presets && name in presets ? presets[name] : evalHeadValue(props[name]);
183
+ return out;
184
+ }
185
+ function classifyHeadTag(desc) {
186
+ const tag = desc.tag;
187
+ if (tag === "link") {
188
+ const rel = evalHeadValue(desc.props && desc.props.rel);
189
+ return {
190
+ resource: RESOURCE_LINK_RELS.has(rel),
191
+ rel
192
+ };
193
+ }
194
+ if (tag === "style") return {
195
+ resource: !!(desc.props && "href" in desc.props)
196
+ };
197
+ if (tag === "script") return {
198
+ resource: !!(desc.props && "src" in desc.props)
199
+ };
200
+ return {
201
+ resource: false
202
+ };
203
+ }
204
+ function resourceIdentity(tag, props) {
205
+ let id = "res:" + tag + ":" + (props.rel || "") + ":" + (props.href || props.src || "");
206
+ for (let i = 0; i < RESOURCE_QUALIFIERS.length; i++) {
207
+ const q = RESOURCE_QUALIFIERS[i];
208
+ if (props[q] != null) id += ":" + q + "=" + props[q];
209
+ }
210
+ return id;
211
+ }
212
+ function replaceableIdentity(tag, props, key, unique) {
213
+ if (tag === "title") return "title";
214
+ if (tag === "base") return "base";
215
+ if (tag === "meta" && props.charset != null) return "charset";
216
+ if (key != null) return tag + ":key:" + key;
217
+ if (tag === "meta") {
218
+ for (const ns of ["name", "property", "http-equiv"]) if (props[ns] != null) return "meta:" + ns + ":" + props[ns] + (props.media != null ? ":media=" + props.media : "");
219
+ return unique;
220
+ }
221
+ if (tag === "link") {
222
+ const rel = props.rel || "";
223
+ if (rel === "icon" || rel === "apple-touch-icon") return "link:" + rel + (props.sizes != null ? ":sizes=" + props.sizes : "") + (props.type != null ? ":type=" + props.type : "");
224
+ return "link:" + rel + ":" + (props.href || "");
225
+ }
226
+ return unique;
227
+ }
228
+ function resolveHead(groups) {
229
+ const winners = new Map();
230
+ const sorted = groups.slice().sort((a, b) => a.seq - b.seq);
231
+ for (let i = 0; i < sorted.length; i++) {
232
+ const group = sorted[i];
233
+ const byIdentity = new Map();
234
+ for (let j = 0; j < group.tags.length; j++) {
235
+ const t = group.tags[j];
236
+ let list = byIdentity.get(t.identity);
237
+ if (!list) byIdentity.set(t.identity, list = []);
238
+ list.push(t);
239
+ }
240
+ for (const [identity, tags] of byIdentity) {
241
+ if (identity === "title") {
242
+ if (tags.length > 1) console.warn("Multiple <title> tags in one head group; the last one wins.");
243
+ winners.set(identity, {
244
+ seq: group.seq,
245
+ tags: [tags[tags.length - 1]]
246
+ });
247
+ } else {
248
+ winners.set(identity, {
249
+ seq: group.seq,
250
+ tags
251
+ });
252
+ }
83
253
  }
84
254
  }
255
+ return winners;
85
256
  }
86
257
 
87
- const $$EVENTS = "_$DX_DELEGATE";
258
+ const $$EVENT_OWNER = "_$DX_EVENT_OWNER";
259
+ const INNER_OWNED = {};
260
+ const delegatedEvents = new Set();
261
+ const delegatedContainers = new Map();
88
262
  function render$1(code, element, init, options = {}) {
89
263
  if (!element) {
90
264
  throw new Error("The `element` passed to `render(..., element)` doesn't exist. Make sure `element` exists in the document.");
91
265
  }
92
266
  let disposer;
93
- solidJs.createRoot(dispose => {
94
- disposer = dispose;
95
- element === document ? solidJs.flatten(code) : insert(element, code(), element.firstChild ? null : undefined, init);
96
- }, {
97
- id: options.renderId
98
- });
267
+ registerDelegatedRoot(element);
268
+ try {
269
+ solidJs.createRoot(dispose => {
270
+ disposer = dispose;
271
+ if (element === document) {
272
+ const tree = code();
273
+ effect(() => solidJs.flatten(tree), () => {});
274
+ } else {
275
+ const tree = code();
276
+ insert(element, () => tree, element.firstChild ? null : undefined, init, options.insertOptions);
277
+ }
278
+ }, {
279
+ id: options.renderId
280
+ });
281
+ } catch (err) {
282
+ if (disposer) disposer();
283
+ unregisterDelegatedRoot(element);
284
+ throw err;
285
+ }
99
286
  return () => {
100
287
  disposer();
288
+ unregisterDelegatedRoot(element);
101
289
  element.textContent = "";
102
290
  };
103
291
  }
104
- function template(html, isImportNode, isSVG, isMathML) {
292
+ function create(html, bypassGuard, flag) {
293
+ if (isHydrating() && !bypassGuard) throw new Error("Failed attempt to create new DOM elements during hydration. Check that the libraries you are using support hydration.");
294
+ const t = document.createElement("template");
295
+ t.innerHTML = html;
296
+ return flag === 2 ? t.content.firstChild.firstChild : t.content.firstChild;
297
+ }
298
+ function template(html, flag) {
105
299
  let node;
106
- const create = bypassGuard => {
107
- if (isHydrating() && !bypassGuard) throw new Error("Failed attempt to create new DOM elements during hydration. Check that the libraries you are using support hydration.");
108
- const t = isMathML ? document.createElementNS("http://www.w3.org/1998/Math/MathML", "template") : document.createElement("template");
109
- t.innerHTML = html;
110
- return isSVG ? t.content.firstChild.firstChild : isMathML ? t.firstChild : t.content.firstChild;
111
- };
112
- const fn = isImportNode ? bypassGuard => solidJs.untrack(() => document.importNode(node || (node = create(bypassGuard)), true)) : bypassGuard => (node || (node = create(bypassGuard))).cloneNode(true);
113
- fn._html = html;
300
+ const fn = flag === 1 ? bypassGuard => document.importNode(node || (node = create(html, bypassGuard, flag)), true) : bypassGuard => (node || (node = create(html, bypassGuard, flag))).cloneNode(true);
301
+ fn._html = flag === 2 ? html.replace(/^<[^>]+>/, "") : html;
114
302
  return fn;
115
303
  }
116
- function delegateEvents(eventNames, document = window.document) {
117
- const e = document[$$EVENTS] || (document[$$EVENTS] = new Set());
304
+ function delegateEvents(eventNames) {
118
305
  for (let i = 0, l = eventNames.length; i < l; i++) {
119
306
  const name = eventNames[i];
120
- if (!e.has(name)) {
121
- e.add(name);
122
- document.addEventListener(name, eventHandler);
307
+ if (!delegatedEvents.has(name)) {
308
+ delegatedEvents.add(name);
309
+ delegatedContainers.forEach((state, container) => attachDelegatedEvent(name, container, state));
123
310
  }
124
311
  }
125
312
  }
126
- function clearDelegatedEvents(document = window.document) {
127
- if (document[$$EVENTS]) {
128
- for (let name of document[$$EVENTS].keys()) document.removeEventListener(name, eventHandler);
129
- delete document[$$EVENTS];
313
+ function registerDelegatedRoot(root) {
314
+ const state = registerDelegatedContainer(root, root);
315
+ if (state) state.roots = (state.roots || 0) + 1;
316
+ }
317
+ function unregisterDelegatedRoot(root) {
318
+ const state = delegatedContainers.get(root);
319
+ if (state) state.roots > 1 ? state.roots-- : delete state.roots;
320
+ unregisterDelegatedContainer(root, root);
321
+ }
322
+ function registerDelegatedContainer(container, owner = container) {
323
+ if (!container || !owner) return;
324
+ let state = delegatedContainers.get(container);
325
+ if (!state) delegatedContainers.set(container, state = {
326
+ owners: new Map(),
327
+ handlers: new Map()
328
+ });
329
+ state.owners.set(owner, (state.owners.get(owner) || 0) + 1);
330
+ delegatedEvents.forEach(name => attachDelegatedEvent(name, container, state));
331
+ return state;
332
+ }
333
+ function unregisterDelegatedContainer(container, owner = container) {
334
+ const state = delegatedContainers.get(container);
335
+ if (!state) return;
336
+ const count = state.owners.get(owner);
337
+ if (count > 1) state.owners.set(owner, count - 1);else state.owners.delete(owner);
338
+ if (state.owners.size) return;
339
+ state.handlers.forEach((handler, name) => container.removeEventListener(name, handler));
340
+ delegatedContainers.delete(container);
341
+ }
342
+ function attachDelegatedEvent(name, container, state) {
343
+ if (state.handlers.has(name)) return;
344
+ const handler = e => eventHandler(e, container, state);
345
+ state.handlers.set(name, handler);
346
+ container.addEventListener(name, handler);
347
+ }
348
+ function getDelegatedRoot(node) {
349
+ while (node) {
350
+ if (delegatedContainers.get(node)?.roots) return node;
351
+ node = node._$host || node.parentNode || node.host;
352
+ }
353
+ }
354
+ function findOwner(target, state) {
355
+ let node = target;
356
+ let distance = 0;
357
+ while (node) {
358
+ if (state.owners.has(node)) return {
359
+ owner: node,
360
+ distance
361
+ };
362
+ distance++;
363
+ node = node._$host || node.parentNode || node.host;
130
364
  }
131
365
  }
132
366
  function setProperty(node, name, value) {
133
367
  if (isHydrating(node)) return;
134
368
  node[name] = value;
135
369
  }
370
+ let claimHandlers = null;
371
+ const CLAIM_SEAM = Symbol.for("dom-expressions.element-claims");
372
+ function registerElementClaim(handler) {
373
+ (claimHandlers || (claimHandlers = globalThis[CLAIM_SEAM] = [])).push(handler);
374
+ return () => {
375
+ const index = claimHandlers.indexOf(handler);
376
+ index > -1 && claimHandlers.splice(index, 1);
377
+ };
378
+ }
379
+ const CLAIMED_ELEMENTS = "a[href], form[action]";
380
+ function claimElementTree(root) {
381
+ const handlers = globalThis[CLAIM_SEAM];
382
+ if (handlers === undefined || handlers.length === 0) return root;
383
+ const isElement = root.nodeType === 1;
384
+ if (!isElement && root.nodeType !== 11) return root;
385
+ if (isElement && root.matches(CLAIMED_ELEMENTS)) {
386
+ for (let i = 0; i < handlers.length; i++) handlers[i](root);
387
+ }
388
+ const found = root.querySelectorAll(CLAIMED_ELEMENTS);
389
+ for (let i = 0; i < found.length; i++) {
390
+ for (let j = 0; j < handlers.length; j++) handlers[j](found[i]);
391
+ }
392
+ return root;
393
+ }
394
+ function claimElement(node) {
395
+ if (claimHandlers !== null) {
396
+ for (let i = 0; i < claimHandlers.length; i++) claimHandlers[i](node);
397
+ }
398
+ return node;
399
+ }
136
400
  function setAttribute(node, name, value) {
137
401
  if (isHydrating(node)) return;
138
402
  if (value == null || value === false) node.removeAttribute(name);else node.setAttribute(name, value === true ? "" : value);
403
+ if (claimHandlers !== null && (name === "href" || name === "action")) claimElement(node);
139
404
  }
140
405
  function setAttributeNS(node, namespace, name, value) {
141
406
  if (isHydrating(node)) return;
142
- if (value == null) node.removeAttributeNS(namespace, name);else node.setAttributeNS(namespace, name, value);
407
+ if (value == null || value === false) node.removeAttributeNS(namespace, name.indexOf(":") > -1 ? name.split(":").pop() : name);else node.setAttributeNS(namespace, name, value === true ? "" : value);
143
408
  }
144
- function className(node, value, isSVG, prev) {
409
+ function className(node, value, prev) {
145
410
  if (isHydrating(node)) return;
146
411
  if (value == null || value === false) {
147
412
  prev && node.removeAttribute("class");
148
413
  return;
149
414
  }
150
415
  if (typeof value === "string") {
151
- value !== prev && (isSVG ? node.setAttribute("class", value) : node.className = value);
416
+ value !== prev && node.setAttribute("class", value);
152
417
  return;
153
418
  }
154
419
  if (typeof prev === "string") {
@@ -162,16 +427,16 @@ function className(node, value, isSVG, prev) {
162
427
  for (i = 0, len = prevKeys.length; i < len; i++) {
163
428
  const key = prevKeys[i];
164
429
  if (!key || key === "undefined" || value[key]) continue;
165
- toggleClassKey(node, key, false);
430
+ node.classList.remove(key);
166
431
  }
167
432
  for (i = 0, len = classKeys.length; i < len; i++) {
168
433
  const key = classKeys[i],
169
434
  classValue = !!value[key];
170
435
  if (!key || key === "undefined" || prev[key] === classValue || !classValue) continue;
171
- toggleClassKey(node, key, true);
436
+ node.classList.add(key);
172
437
  }
173
438
  }
174
- function addEventListener(node, name, handler, delegate) {
439
+ function addEvent(node, name, handler, delegate) {
175
440
  if (delegate) {
176
441
  if (Array.isArray(handler)) {
177
442
  node[`$$${name}`] = handler[0];
@@ -184,33 +449,48 @@ function addEventListener(node, name, handler, delegate) {
184
449
  }
185
450
  function style(node, value, prev) {
186
451
  if (!value) {
187
- if (prev) setAttribute(node, "style");
452
+ if (prev || node._$styles) {
453
+ setAttribute(node, "style");
454
+ node._$styles = undefined;
455
+ }
188
456
  return;
189
457
  }
190
458
  const nodeStyle = node.style;
191
- if (typeof value === "string") return nodeStyle.cssText = value;
192
- typeof prev === "string" && (nodeStyle.cssText = prev = undefined);
193
- prev || (prev = {});
194
- value || (value = {});
459
+ if (typeof value === "string") {
460
+ node._$styles = undefined;
461
+ return nodeStyle.cssText = value;
462
+ }
463
+ if (typeof prev === "string") {
464
+ nodeStyle.cssText = "";
465
+ prev = undefined;
466
+ }
467
+ let applied = node._$styles;
468
+ if (!applied) {
469
+ applied = node._$styles = prev ? {
470
+ ...prev
471
+ } : {};
472
+ }
195
473
  let v, s;
474
+ for (s in applied) {
475
+ if (value[s] == null) {
476
+ nodeStyle.removeProperty(s);
477
+ delete applied[s];
478
+ }
479
+ }
196
480
  for (s in value) {
197
481
  v = value[s];
198
- if (v !== prev[s]) nodeStyle.setProperty(s, v);
199
- delete prev[s];
482
+ if (v != null && v !== applied[s]) {
483
+ nodeStyle.setProperty(s, v);
484
+ applied[s] = v;
485
+ }
200
486
  }
201
- for (s in prev) value[s] == null && nodeStyle.removeProperty(s);
202
487
  }
203
488
  function setStyleProperty(node, name, value) {
204
489
  value != null ? node.style.setProperty(name, value) : node.style.removeProperty(name);
205
490
  }
206
- function spread(node, props = {}, isSVG, skipChildren) {
491
+ function spread(node, props = {}, skipChildren) {
207
492
  const prevProps = {};
208
- if (!skipChildren) {
209
- effect(() => normalize(props.children, prevProps.children), value => {
210
- insertExpression(node, value, prevProps.children);
211
- prevProps.children = value;
212
- });
213
- }
493
+ if (!skipChildren) insert(node, () => props.children);
214
494
  effect(() => {
215
495
  const r = props.ref;
216
496
  (typeof r === "function" || Array.isArray(r)) && ref(() => r, node);
@@ -222,7 +502,7 @@ function spread(node, props = {}, isSVG, skipChildren) {
222
502
  newProps[prop] = props[prop];
223
503
  }
224
504
  return newProps;
225
- }, props => assign(node, props, isSVG, true, prevProps, true));
505
+ }, props => assign(node, props, true, prevProps, true));
226
506
  return prevProps;
227
507
  }
228
508
  function dynamicProperty(props, key) {
@@ -242,49 +522,468 @@ function ref(fn, element) {
242
522
  const resolved = solidJs.untrack(fn);
243
523
  solidJs.runWithOwner(null, () => applyRef(resolved, element));
244
524
  }
245
- function insert(parent, accessor, marker, initial) {
246
- const multi = marker !== undefined;
247
- if (multi && !initial) initial = [];
248
- if (isHydrating(parent)) {
249
- if (!multi && initial === undefined && parent) initial = [...parent.childNodes];
250
- if (Array.isArray(initial)) {
251
- let j = 0;
252
- for (let i = 0; i < initial.length; i++) {
253
- if (initial[i].nodeType === 8 && initial[i].nodeValue === "!$") initial[i].remove();else initial[j++] = initial[i];
525
+ function scope(fn) {
526
+ fn.$s = true;
527
+ return fn;
528
+ }
529
+ const SCOPE_OPTIONS = {
530
+ scope: true
531
+ };
532
+ let hydrationRt = null;
533
+ function installHydrationRuntime() {
534
+ hydrationRt = {
535
+ claimInitial(parent, multi, initial) {
536
+ if (isHydrating(parent)) {
537
+ if (!multi && initial === undefined && parent) initial = [...parent.childNodes];
538
+ if (Array.isArray(initial)) stripTextSeparators(initial);
254
539
  }
255
- initial.length = j;
540
+ return initial;
541
+ },
542
+ reclaimRegion(current, parent, marker) {
543
+ if (!solidJs.sharedConfig.hydrating || !current || !parent.isConnected) return current;
544
+ const first = Array.isArray(current) ? current[0] : current;
545
+ if (!first || !first.nodeType || first.isConnected) return current;
546
+ let nodes;
547
+ if (marker) {
548
+ nodes = [];
549
+ let node = marker.previousSibling,
550
+ depth = 0;
551
+ while (node) {
552
+ if (node.nodeType === 8) {
553
+ const v = node.nodeValue;
554
+ if (v === "/") depth++;else if (v === "$") {
555
+ if (depth === 0) break;
556
+ depth--;
557
+ }
558
+ }
559
+ nodes.unshift(node);
560
+ node = node.previousSibling;
561
+ }
562
+ } else nodes = [...parent.childNodes];
563
+ return stripTextSeparators(nodes);
564
+ },
565
+ dedupEvent(e) {
566
+ return !!(solidJs.sharedConfig.registry && solidJs.sharedConfig.events && solidJs.sharedConfig.events.find(([el, ev]) => ev === e));
256
567
  }
568
+ };
569
+ }
570
+ function stripTextSeparators(nodes) {
571
+ let j = 0;
572
+ for (let i = 0; i < nodes.length; i++) {
573
+ const node = nodes[i],
574
+ t = node.nodeType;
575
+ if (t === 8) {
576
+ const v = node.nodeValue;
577
+ if (v === "!$") {
578
+ node.remove();
579
+ continue;
580
+ }
581
+ if (v.startsWith("pl-")) continue;
582
+ } else if (t === 1 && node.localName === "template" && node.id.startsWith("pl-")) continue;
583
+ nodes[j++] = node;
257
584
  }
585
+ nodes.length = j;
586
+ return nodes;
587
+ }
588
+ function insert(parent, accessor, marker, initial, options) {
589
+ const multi = marker !== undefined;
590
+ const host = options && options.host;
591
+ if (multi && !initial) initial = [];
592
+ if (hydrationRt !== null) initial = hydrationRt.claimInitial(parent, multi, initial);
258
593
  if (typeof accessor !== "function") {
259
594
  accessor = normalize(accessor, initial, multi, true);
260
- if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker);
595
+ if (typeof accessor !== "function") {
596
+ insertExpression(parent, accessor, initial, marker);
597
+ host && tagHost(accessor, host);
598
+ return;
599
+ }
261
600
  }
262
- accessor = memo(accessor, true);
263
- if (multi && initial.length === 0 && !isHydrating(parent)) {
601
+ if (multi && initial.length === 0) {
264
602
  const placeholder = document.createTextNode("");
265
603
  parent.insertBefore(placeholder, marker);
266
604
  initial = [placeholder];
267
605
  }
268
- effect(prev => normalize(accessor, prev, multi), (value, current) => insertExpression(parent, value, current, marker), initial);
606
+ let current = initial;
607
+ effect(prev => {
608
+ if (hydrationRt !== null) current = hydrationRt.reclaimRegion(current, parent, marker);
609
+ const value = normalize(accessor(), current, multi, true);
610
+ if (typeof value !== "function") return value;
611
+ effect(() => (hydrationRt !== null && (current = hydrationRt.reclaimRegion(current, parent, marker)), normalize(value, current, multi)), inner => {
612
+ insertExpression(parent, inner, current, marker);
613
+ current = inner;
614
+ host && tagHost(current, host);
615
+ }, prev !== undefined && !(options && options.schedule) ? {
616
+ ...options,
617
+ schedule: true
618
+ } : options);
619
+ return INNER_OWNED;
620
+ }, value => {
621
+ if (value === INNER_OWNED) return;
622
+ insertExpression(parent, value, current, marker);
623
+ current = value;
624
+ host && tagHost(current, host);
625
+ },
626
+ accessor.$s ? options ? {
627
+ ...options,
628
+ scope: true
629
+ } : SCOPE_OPTIONS : options);
269
630
  }
270
- function assign(node, props, isSVG, skipChildren, prevProps = {}, skipRef = false) {
631
+ function assign(node, props, skipChildren, prevProps = {}, skipRef = false) {
632
+ const nodeName = node.nodeName;
271
633
  props || (props = {});
272
634
  for (const prop in prevProps) {
273
635
  if (!(prop in props)) {
274
636
  if (prop === "children") continue;
275
- prevProps[prop] = assignProp(node, prop, null, prevProps[prop], isSVG, skipRef);
637
+ prevProps[prop] = assignProp(node, prop, null, prevProps[prop], skipRef, nodeName);
276
638
  }
277
639
  }
278
640
  for (const prop in props) {
279
641
  if (prop === "children") {
280
- if (!skipChildren) insertExpression(node, props.children);
642
+ if (!skipChildren) insertExpression(node, normalize(props.children, undefined, false));
643
+ continue;
644
+ }
645
+ prevProps[prop] = assignProp(node, prop, props[prop], prevProps[prop], skipRef, nodeName);
646
+ }
647
+ }
648
+ const ASSET_REMOVAL_GRACE = 100;
649
+ const assetRegistry = new Map();
650
+ function assetEntryKey(descriptor) {
651
+ if (descriptor.policy === "exclusive") return "x|" + descriptor.key;
652
+ return descriptor.type === "inline-style" ? "i|" + descriptor.id : descriptor.type + "|" + descriptor.href;
653
+ }
654
+ function findAssetElement(selector, attr, value) {
655
+ const nodes = document.querySelectorAll(selector);
656
+ for (let i = 0; i < nodes.length; i++) {
657
+ if (nodes[i].getAttribute(attr) === value) return nodes[i];
658
+ }
659
+ return null;
660
+ }
661
+ function mountAssetElement(descriptor) {
662
+ let el;
663
+ if (descriptor.type === "inline-style") {
664
+ el = findAssetElement("style[data-asset]", "data-asset", descriptor.id);
665
+ if (!el) {
666
+ el = document.createElement("style");
667
+ el.setAttribute("data-asset", descriptor.id);
668
+ el.textContent = descriptor.content || "";
669
+ }
670
+ } else {
671
+ const rel = descriptor.type === "module" ? "modulepreload" : "stylesheet";
672
+ el = findAssetElement(`link[rel="${rel}"]`, "href", descriptor.href);
673
+ if (!el) {
674
+ el = document.createElement("link");
675
+ el.rel = rel;
676
+ el.href = descriptor.href;
677
+ }
678
+ }
679
+ if (descriptor.attrs) {
680
+ for (const name in descriptor.attrs) el.setAttribute(name, descriptor.attrs[name]);
681
+ }
682
+ if (!el.isConnected) document.head.appendChild(el);
683
+ return el;
684
+ }
685
+ function acquireAsset(descriptor) {
686
+ const key = assetEntryKey(descriptor);
687
+ let entry = assetRegistry.get(key);
688
+ if (descriptor.policy === "exclusive") {
689
+ if (!entry) {
690
+ entry = {
691
+ original: descriptor.get(),
692
+ set: descriptor.set,
693
+ writers: []
694
+ };
695
+ assetRegistry.set(key, entry);
696
+ }
697
+ const writer = {
698
+ value: descriptor.value
699
+ };
700
+ entry.writers.push(writer);
701
+ entry.set(writer.value);
702
+ let released = false;
703
+ return () => {
704
+ if (released) return;
705
+ released = true;
706
+ const index = entry.writers.indexOf(writer);
707
+ const wasTop = index === entry.writers.length - 1;
708
+ entry.writers.splice(index, 1);
709
+ if (!wasTop) return;
710
+ if (entry.writers.length) {
711
+ entry.set(entry.writers[entry.writers.length - 1].value);
712
+ } else {
713
+ entry.set(entry.original);
714
+ assetRegistry.delete(key);
715
+ }
716
+ };
717
+ }
718
+ if (!entry) {
719
+ entry = {
720
+ count: 0,
721
+ element: null,
722
+ timer: null
723
+ };
724
+ assetRegistry.set(key, entry);
725
+ }
726
+ if (entry.timer) {
727
+ clearTimeout(entry.timer);
728
+ entry.timer = null;
729
+ }
730
+ entry.count++;
731
+ if (!entry.element || !entry.element.isConnected) entry.element = mountAssetElement(descriptor);
732
+ let released = false;
733
+ return () => {
734
+ if (released) return;
735
+ released = true;
736
+ if (--entry.count > 0) return;
737
+ entry.timer = setTimeout(() => {
738
+ assetRegistry.delete(key);
739
+ entry.element && entry.element.remove();
740
+ }, ASSET_REMOVAL_GRACE);
741
+ };
742
+ }
743
+ let headRegistrations = null;
744
+ let headSeq = 0;
745
+ let headUid = 0;
746
+ let headOwned = null;
747
+ let headApplied = null;
748
+ let headFallbackTitle = null;
749
+ let headScheduled = false;
750
+ const headMountedResources = new Set();
751
+ function initHeadRegistry() {
752
+ if (headRegistrations) return;
753
+ headRegistrations = [];
754
+ headOwned = new Map();
755
+ headApplied = new Map();
756
+ const t = document.querySelector("title");
757
+ headFallbackTitle = t && !t.hasAttribute("data-dh") ? t.textContent : null;
758
+ if (globalThis._$HY) globalThis._$HY.h = applyServerHeadOps;
759
+ }
760
+ function applyServerHeadOps(ops) {
761
+ for (let i = 0; i < ops.length; i++) {
762
+ const op = ops[i];
763
+ const identity = op[0] === "t" ? "title" : op[1];
764
+ if (headOwned.has(identity)) continue;
765
+ if (op[0] === "t") setHeadTitle(op[1]);else if (op[0] === "r") {
766
+ const els = headMarkedElements(identity);
767
+ for (let j = 0; j < els.length; j++) els[j].remove();
768
+ } else {
769
+ const el = document.createElement(op[2]);
770
+ for (const name in op[3]) el.setAttribute(name, op[3][name]);
771
+ if (op[4] != null) el.textContent = op[4];
772
+ el.setAttribute("data-dh", identity);
773
+ document.head.appendChild(el);
774
+ }
775
+ }
776
+ }
777
+ function headMarkedElements(identity) {
778
+ const nodes = document.head.querySelectorAll("[data-dh]");
779
+ const out = [];
780
+ for (let i = 0; i < nodes.length; i++) {
781
+ if (nodes[i].getAttribute("data-dh") === identity) out.push(nodes[i]);
782
+ }
783
+ return out;
784
+ }
785
+ function setHeadTitle(text) {
786
+ let el = document.querySelector("title");
787
+ if (!el) {
788
+ el = document.createElement("title");
789
+ document.head.appendChild(el);
790
+ }
791
+ el.textContent = text;
792
+ el.setAttribute("data-dh", "title");
793
+ return el;
794
+ }
795
+ function scheduleHeadApply() {
796
+ if (headScheduled) return;
797
+ headScheduled = true;
798
+ queueMicrotask(flushHeadRegistry);
799
+ }
800
+ function flushHeadRegistry() {
801
+ if (solidJs.sharedConfig.hydrating) {
802
+ setTimeout(flushHeadRegistry, 0);
803
+ return;
804
+ }
805
+ headScheduled = false;
806
+ const winners = resolveHead(headRegistrations);
807
+ for (const [identity, els] of headOwned) {
808
+ if (winners.has(identity)) continue;
809
+ headOwned.delete(identity);
810
+ headApplied.delete(identity);
811
+ if (identity === "title") {
812
+ if (headFallbackTitle != null) setHeadTitle(headFallbackTitle).removeAttribute("data-dh");
813
+ } else {
814
+ for (let i = 0; i < els.length; i++) els[i].remove();
815
+ }
816
+ }
817
+ for (const [identity, winner] of winners) {
818
+ let sig = "";
819
+ for (let i = 0; i < winner.tags.length; i++) sig += winner.tags[i].tag + JSON.stringify(winner.tags[i].props) + "|";
820
+ if (headApplied.get(identity) === sig) continue;
821
+ headApplied.set(identity, sig);
822
+ if (identity === "base" || identity === "charset") {
823
+ console.warn(`useHead: <${winner.tags[0].tag}> (${identity}) is shell-only and ignored on the client`);
824
+ continue;
825
+ }
826
+ if (identity === "title") {
827
+ const children = winner.tags[0].props.children;
828
+ setHeadTitle(children == null ? "" : String(children));
829
+ headOwned.set(identity, []);
830
+ continue;
831
+ }
832
+ const existing = headMarkedElements(identity);
833
+ const els = [];
834
+ for (let i = 0; i < winner.tags.length; i++) {
835
+ els.push(renderHeadElement(winner.tags[i], identity, existing));
836
+ }
837
+ for (let i = 0; i < existing.length; i++) {
838
+ if (els.indexOf(existing[i]) === -1) existing[i].remove();
839
+ }
840
+ headOwned.set(identity, els);
841
+ }
842
+ }
843
+ function createHeadElement(tag, props) {
844
+ const el = document.createElement(tag);
845
+ for (const name in props) {
846
+ if (name === "children" || name === "ref" || name.slice(0, 2) === "on") continue;
847
+ if (!HEAD_ATTR_NAME.test(name)) {
848
+ console.warn(`useHead: ignoring invalid attribute name "${name}"`);
281
849
  continue;
282
850
  }
283
- const value = props[prop];
284
- prevProps[prop] = assignProp(node, prop, value, prevProps[prop], isSVG, skipRef);
851
+ const v = props[name];
852
+ if (v == null || v === false) continue;
853
+ el.setAttribute(name, v === true ? "" : String(v));
854
+ }
855
+ if (props.children != null) el.textContent = String(props.children);
856
+ return el;
857
+ }
858
+ function renderHeadElement(t, identity, existing) {
859
+ for (let i = 0; i < existing.length; i++) {
860
+ if (headElementMatches(existing[i], t)) return existing.splice(i, 1)[0];
861
+ }
862
+ const el = createHeadElement(t.tag, t.props);
863
+ el.setAttribute("data-dh", identity);
864
+ document.head.appendChild(el);
865
+ return el;
866
+ }
867
+ function headElementMatches(el, t) {
868
+ if (el.tagName.toLowerCase() !== t.tag) return false;
869
+ for (const name in t.props) {
870
+ if (name === "children" || name === "ref" || name.slice(0, 2) === "on") continue;
871
+ if (!HEAD_ATTR_NAME.test(name)) continue;
872
+ const v = t.props[name];
873
+ if (v == null || v === false) {
874
+ if (el.hasAttribute(name)) return false;
875
+ } else if (el.getAttribute(name) !== (v === true ? "" : String(v))) return false;
876
+ }
877
+ const children = t.props.children;
878
+ return (children == null ? "" : String(children)) === el.textContent;
879
+ }
880
+ function acquireHeadResource(tag, props) {
881
+ if (tag === "link" && (props.rel === "stylesheet" || props.rel === "modulepreload")) {
882
+ const descriptor = {
883
+ type: props.rel === "stylesheet" ? "style" : "module",
884
+ href: props.href
885
+ };
886
+ let attrs = null;
887
+ for (const name in props) {
888
+ if (name === "rel" || name === "href") continue;
889
+ if (!HEAD_ATTR_NAME.test(name)) continue;
890
+ const v = props[name];
891
+ if (v == null || v === false) continue;
892
+ (attrs || (attrs = {}))[name] = v === true ? "" : String(v);
893
+ }
894
+ if (attrs) descriptor.attrs = attrs;
895
+ return acquireAsset(descriptor);
896
+ }
897
+ const identity = resourceIdentity(tag, props);
898
+ if (headMountedResources.has(identity)) return noopFn;
899
+ headMountedResources.add(identity);
900
+ const url = props.href || props.src;
901
+ let el = null;
902
+ if (url != null) {
903
+ 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);
285
904
  }
905
+ if (!el) document.head.appendChild(createHeadElement(tag, props));
906
+ return noopFn;
907
+ }
908
+ function noopFn() {}
909
+ function useHead(tags) {
910
+ initHeadRegistry();
911
+ const reg = {
912
+ seq: -1,
913
+ tags: null
914
+ };
915
+ const uid = ++headUid;
916
+ effect(() => {
917
+ let list = typeof tags === "function" ? tags() : tags;
918
+ if (!Array.isArray(list)) list = [list];
919
+ const replaceable = [];
920
+ const resources = [];
921
+ for (let i = 0; i < list.length; i++) {
922
+ const desc = list[i];
923
+ if (!desc || !HEAD_ELIGIBLE_TAGS.has(desc.tag)) {
924
+ console.warn(`useHead: ignoring non-head tag`, desc);
925
+ continue;
926
+ }
927
+ const cls = classifyHeadTag(desc);
928
+ const props = evalHeadProps(desc.props || {}, cls.rel !== undefined ? {
929
+ rel: cls.rel
930
+ } : undefined);
931
+ if (cls.resource) {
932
+ resources.push({
933
+ tag: desc.tag,
934
+ props
935
+ });
936
+ } else {
937
+ const key = evalHeadValue(desc.key);
938
+ replaceable.push({
939
+ tag: desc.tag,
940
+ props,
941
+ identity: replaceableIdentity(desc.tag, props, key, "u:c" + uid + ":" + i)
942
+ });
943
+ }
944
+ }
945
+ return {
946
+ replaceable,
947
+ resources
948
+ };
949
+ }, evaluated => {
950
+ const releases = [];
951
+ for (let i = 0; i < evaluated.resources.length; i++) {
952
+ releases.push(acquireHeadResource(evaluated.resources[i].tag, evaluated.resources[i].props));
953
+ }
954
+ reg.tags = evaluated.replaceable;
955
+ if (reg.seq < 0) reg.seq = ++headSeq;
956
+ if (headRegistrations.indexOf(reg) === -1) headRegistrations.push(reg);
957
+ scheduleHeadApply();
958
+ return () => {
959
+ const idx = headRegistrations.indexOf(reg);
960
+ if (idx > -1) headRegistrations.splice(idx, 1);
961
+ for (let i = 0; i < releases.length; i++) releases[i]();
962
+ scheduleHeadApply();
963
+ };
964
+ });
965
+ }
966
+ function loadModuleAssets(mapping) {
967
+ const hy = globalThis._$HY;
968
+ if (!hy) return;
969
+ const pending = [];
970
+ for (const key in mapping) {
971
+ if (hy.modules[key]) continue;
972
+ const entryUrl = mapping[key];
973
+ if (!hy.loading[key]) {
974
+ hy.loading[key] = import(entryUrl).then(mod => {
975
+ hy.modules[key] = mod;
976
+ }, err => {
977
+ delete hy.loading[key];
978
+ throw err;
979
+ });
980
+ }
981
+ pending.push(hy.loading[key]);
982
+ }
983
+ return pending.length ? Promise.all(pending).then(() => {}) : undefined;
286
984
  }
287
985
  function hydrate$1(code, element, options = {}) {
986
+ installHydrationRuntime();
288
987
  if (globalThis._$HY.done) return render$1(code, element, [...element.childNodes], options);
289
988
  options.renderId ||= "";
290
989
  if (!globalThis._$HY.modules) globalThis._$HY.modules = {};
@@ -294,6 +993,7 @@ function hydrate$1(code, element, options = {}) {
294
993
  solidJs.sharedConfig.load = id => globalThis._$HY.r[id];
295
994
  solidJs.sharedConfig.has = id => id in globalThis._$HY.r;
296
995
  solidJs.sharedConfig.gather = root => gatherHydratable(element, root);
996
+ solidJs.sharedConfig.loadModuleAssets = loadModuleAssets;
297
997
  solidJs.sharedConfig.cleanupFragment = id => {
298
998
  const tpl = document.getElementById("pl-" + id);
299
999
  if (tpl) {
@@ -311,15 +1011,45 @@ function hydrate$1(code, element, options = {}) {
311
1011
  }
312
1012
  };
313
1013
  solidJs.sharedConfig.registry = new Map();
1014
+ if (!solidJs.sharedConfig.boundaryScopes) solidJs.sharedConfig.boundaryScopes = new Map();
1015
+ solidJs.sharedConfig.captureBoundaryScope = id => {
1016
+ if (solidJs.sharedConfig.registry) solidJs.sharedConfig.boundaryScopes.set(id, {
1017
+ registry: solidJs.sharedConfig.registry,
1018
+ gather: solidJs.sharedConfig.gather
1019
+ });
1020
+ };
314
1021
  solidJs.sharedConfig.hydrating = true;
315
1022
  {
316
1023
  solidJs.sharedConfig.verifyHydration = () => {
317
1024
  if (solidJs.sharedConfig.registry && solidJs.sharedConfig.registry.size) {
318
- const orphaned = [...solidJs.sharedConfig.registry.values()];
1025
+ const orphaned = [...solidJs.sharedConfig.registry.values()].filter(node => node.isConnected);
1026
+ solidJs.sharedConfig.registry.clear();
1027
+ if (!orphaned.length) return;
319
1028
  console.warn(`Hydration completed with ${orphaned.length} unclaimed server-rendered node(s):\n` + orphaned.map(node => ` ${node.outerHTML.slice(0, 100)}`).join("\n"));
320
1029
  }
321
1030
  };
322
1031
  }
1032
+ const rootMapping = globalThis._$HY.r && globalThis._$HY.r["_assets"];
1033
+ if (rootMapping && typeof rootMapping === "object") {
1034
+ const p = loadModuleAssets(rootMapping);
1035
+ if (p) {
1036
+ gatherHydratable(element, options.renderId);
1037
+ let disposer;
1038
+ p.then(() => {
1039
+ try {
1040
+ disposer = render$1(code, element, [...element.childNodes], options);
1041
+ } finally {
1042
+ solidJs.sharedConfig.hydrating = false;
1043
+ }
1044
+ }, err => {
1045
+ console.error("Hydration module preload failed, falling back to client render:", err);
1046
+ solidJs.sharedConfig.hydrating = false;
1047
+ solidJs.sharedConfig.registry = undefined;
1048
+ disposer = render$1(code, element, [...element.childNodes], options);
1049
+ });
1050
+ return () => disposer && disposer();
1051
+ }
1052
+ }
323
1053
  try {
324
1054
  gatherHydratable(element, options.renderId);
325
1055
  return render$1(code, element, [...element.childNodes], options);
@@ -381,20 +1111,21 @@ function getFirstChild(node, expectedTag) {
381
1111
  function getNextSibling(node, expectedTag) {
382
1112
  const sibling = node.nextSibling;
383
1113
  if (isHydrating() && expectedTag && sibling?.localName !== expectedTag) {
384
- const parent = node.parentElement;
1114
+ const parent = node.parentNode;
385
1115
  const isMissing = !sibling || sibling.nodeType !== 1;
386
1116
  console.warn("Hydration structure mismatch: expected <" + expectedTag + "> after", node, "in", parent, "\n " + describeSiblings(parent, sibling, expectedTag, isMissing));
387
1117
  }
388
1118
  return sibling;
389
1119
  }
390
1120
  function describeSiblings(parent, mismatchChild, expectedTag, isMissing) {
1121
+ if (!parent) return `<${expectedTag} \u2190 parent unavailable>`;
391
1122
  const children = [];
392
1123
  let child = parent.firstChild;
393
1124
  while (child) {
394
1125
  if (child.nodeType === 1) children.push(child);
395
1126
  child = child.nextSibling;
396
1127
  }
397
- const pTag = parent.localName;
1128
+ const pTag = parent.localName || "#fragment";
398
1129
  if (isMissing) {
399
1130
  const tags = children.map(c => `<${c.localName}>`).join("");
400
1131
  return `<${pTag}>${tags}<${expectedTag} \u2190 missing></${pTag}>`;
@@ -426,7 +1157,32 @@ function runHydrationEvents() {
426
1157
  const [el, e] = events[0];
427
1158
  if (!completed.has(el)) return;
428
1159
  events.shift();
429
- eventHandler(e);
1160
+ let matchContainer, matchState, matchDistance, matches;
1161
+ for (const [container, state] of delegatedContainers) {
1162
+ if (!state.handlers.has(e.type)) continue;
1163
+ const entry = findOwner(e.target, state);
1164
+ if (!entry) continue;
1165
+ if (matchContainer) {
1166
+ if (!matches) matches = [{
1167
+ container: matchContainer,
1168
+ state: matchState,
1169
+ distance: matchDistance
1170
+ }];
1171
+ matches.push({
1172
+ container,
1173
+ state,
1174
+ distance: entry.distance
1175
+ });
1176
+ } else {
1177
+ matchContainer = container;
1178
+ matchState = state;
1179
+ matchDistance = entry.distance;
1180
+ }
1181
+ }
1182
+ if (matches) {
1183
+ matches.sort((a, b) => a.distance - b.distance);
1184
+ for (let i = 0; i < matches.length; i++) eventHandler(e, matches[i].container, matches[i].state);
1185
+ } else if (matchContainer) eventHandler(e, matchContainer, matchState);
430
1186
  }
431
1187
  if (solidJs.sharedConfig.done) {
432
1188
  solidJs.sharedConfig.events = _$HY.events = null;
@@ -437,16 +1193,31 @@ function runHydrationEvents() {
437
1193
  }
438
1194
  }
439
1195
  function isHydrating(node) {
440
- return solidJs.sharedConfig.hydrating && (!node || node.isConnected);
441
- }
442
- function toggleClassKey(node, key, value) {
443
- const classNames = key.trim().split(/\s+/);
444
- for (let i = 0, nameLen = classNames.length; i < nameLen; i++) node.classList.toggle(classNames[i], value);
1196
+ if (!solidJs.sharedConfig.hydrating) return false;
1197
+ if (!node || node.isConnected) return true;
1198
+ const roots = solidJs.sharedConfig.claimRoots;
1199
+ if (roots) {
1200
+ for (let i = 0; i < roots.length; i++) {
1201
+ if (roots[i].contains(node)) return true;
1202
+ }
1203
+ }
1204
+ return false;
445
1205
  }
446
1206
  function classListToObject(classList) {
447
1207
  if (Array.isArray(classList)) {
448
1208
  const result = {};
449
1209
  flattenClassList(classList, result);
1210
+ classList = result;
1211
+ }
1212
+ if (classList && typeof classList === "object") {
1213
+ const result = {},
1214
+ keys = Object.keys(classList);
1215
+ for (let i = 0, len = keys.length; i < len; i++) {
1216
+ const key = keys[i];
1217
+ if (!classList[key]) continue;
1218
+ const classNames = key.trim().split(/\s+/);
1219
+ for (let j = 0, nameLen = classNames.length; j < nameLen; j++) classNames[j] && (result[classNames[j]] = true);
1220
+ }
450
1221
  return result;
451
1222
  }
452
1223
  return classList;
@@ -457,18 +1228,16 @@ function flattenClassList(list, result) {
457
1228
  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;
458
1229
  }
459
1230
  }
460
- function assignProp(node, prop, value, prev, isSVG, skipRef) {
461
- let forceProp;
1231
+ function assignProp(node, prop, value, prev, skipRef, nodeName) {
462
1232
  if (prop === "style") return style(node, value, prev), value;
463
- if (prop === "class") return className(node, value, isSVG, prev), value;
464
- if (value === prev) return prev;
1233
+ if (prop === "class") return className(node, value, prev), value;
1234
+ if (value === prev && DOMWithState[nodeName]?.[prop] !== 1) return prev;
465
1235
  if (prop === "ref") {
466
1236
  if (!skipRef && value) ref(() => value, node);
467
- } else if (prop.slice(0, 3) === "on:") {
468
- const e = prop.slice(3);
469
- prev && node.removeEventListener(e, prev, typeof prev !== "function" && prev);
470
- value && node.addEventListener(e, value, typeof value !== "function" && value);
471
- } else if (prop.slice(0, 2) === "on") {
1237
+ return value;
1238
+ }
1239
+ const hasNamespace = prop.indexOf(":") > -1;
1240
+ if (!hasNamespace && prop.slice(0, 2) === "on") {
472
1241
  const name = prop.slice(2).toLowerCase();
473
1242
  const delegate = DelegatedEvents.has(name);
474
1243
  if (!delegate && prev) {
@@ -476,26 +1245,34 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
476
1245
  node.removeEventListener(name, h);
477
1246
  }
478
1247
  if (delegate || value) {
479
- addEventListener(node, name, value, delegate);
1248
+ addEvent(node, name, value, delegate);
480
1249
  delegate && delegateEvents([name]);
481
1250
  }
482
- } else if ((forceProp = prop.slice(0, 5) === "prop:") || ChildProperties.has(prop) || !isSVG && Properties.has(prop)) {
483
- if (forceProp) prop = prop.slice(5);else if (isHydrating(node)) return value;
484
- if (prop === "value" && node.nodeName === "SELECT") queueMicrotask(() => node.value = value) || (node.value = value);else node[prop] = value;
1251
+ } else if (hasNamespace && prop.slice(0, 5) === "prop:" || ChildProperties.has(prop) || DOMWithState[nodeName]?.[prop]) {
1252
+ if (hasNamespace) prop = prop.slice(5);else if (isHydrating(node)) return value;
1253
+ if (prop === "value" && nodeName === "SELECT") queueMicrotask(() => node.value = value) || (node.value = value);else if ((prop === "value" || prop === "defaultValue") && (nodeName === "INPUT" || nodeName === "TEXTAREA"))
1254
+ node[prop] = value ?? "";else node[prop] = value;
485
1255
  } else {
486
- const ns = isSVG && prop.indexOf(":") > -1 && SVGNamespace[prop.split(":")[0]];
1256
+ const ns = hasNamespace && Namespaces[prop.split(":")[0]];
487
1257
  if (ns) setAttributeNS(node, ns, prop, value);else setAttribute(node, prop, value);
488
1258
  }
489
1259
  return value;
490
1260
  }
491
- function eventHandler(e) {
492
- if (solidJs.sharedConfig.registry && solidJs.sharedConfig.events) {
493
- if (solidJs.sharedConfig.events.find(([el, ev]) => ev === e)) return;
1261
+ function eventHandler(e, container, state) {
1262
+ if (hydrationRt !== null && hydrationRt.dedupEvent(e)) return;
1263
+ const prev = e[$$EVENT_OWNER];
1264
+ let resumeNode;
1265
+ if (prev) {
1266
+ if (prev === true || prev === container || !container.contains(prev)) return;
1267
+ resumeNode = prev;
494
1268
  }
495
- let node = e.target;
1269
+ const owner = state && (state.owners.size === 1 && state.owners.has(container) ? container : findOwner(e.target, state)?.owner);
1270
+ if (state && !owner) return;
1271
+ e[$$EVENT_OWNER] = owner || true;
1272
+ let node = resumeNode || e.target;
496
1273
  const key = `$$${e.type}`;
497
1274
  const oriTarget = e.target;
498
- const oriCurrentTarget = e.currentTarget;
1275
+ const boundary = owner || container || e.currentTarget;
499
1276
  const retarget = value => Object.defineProperty(e, "target", {
500
1277
  configurable: true,
501
1278
  value
@@ -511,35 +1288,43 @@ function eventHandler(e) {
511
1288
  return true;
512
1289
  };
513
1290
  const walkUpTree = () => {
514
- while (handleNode() && (node = node._$host || node.parentNode || node.host));
1291
+ while (handleNode()) {
1292
+ if (node === boundary || node.parentNode === boundary) break;
1293
+ node = node._$host || node.parentNode || node.host;
1294
+ }
515
1295
  };
516
1296
  Object.defineProperty(e, "currentTarget", {
517
1297
  configurable: true,
518
1298
  get() {
519
- return node || document;
1299
+ return node || boundary || document;
520
1300
  }
521
1301
  });
522
- if (e.composedPath) {
1302
+ if (resumeNode) {
1303
+ if (resumeNode === e.target) node = resumeNode._$host || resumeNode.parentNode || resumeNode.host;
1304
+ if (node && node !== boundary) walkUpTree();
1305
+ } else if (e.composedPath) {
523
1306
  const path = e.composedPath();
524
- retarget(path[0]);
525
- for (let i = 0; i < path.length - 2; i++) {
526
- node = path[i];
527
- if (!handleNode()) break;
528
- if (node._$host) {
529
- node = node._$host;
530
- walkUpTree();
531
- break;
532
- }
533
- if (node.parentNode === oriCurrentTarget) {
534
- break;
1307
+ if (path.length) {
1308
+ retarget(path[0]);
1309
+ for (let i = 0; i < path.length; i++) {
1310
+ node = path[i];
1311
+ if (!handleNode()) break;
1312
+ if (node._$host) {
1313
+ node = node._$host;
1314
+ walkUpTree();
1315
+ break;
1316
+ }
1317
+ if (node === boundary || node.parentNode === boundary) {
1318
+ break;
1319
+ }
535
1320
  }
536
- }
1321
+ } else walkUpTree();
537
1322
  }
538
1323
  else walkUpTree();
539
1324
  retarget(oriTarget);
540
1325
  }
541
1326
  function insertExpression(parent, value, current, marker) {
542
- if (isHydrating(parent)) return;
1327
+ if (hydrationRt !== null && isHydrating(parent)) return;
543
1328
  if (value === current) return;
544
1329
  const t = typeof value,
545
1330
  multi = marker !== undefined;
@@ -547,15 +1332,25 @@ function insertExpression(parent, value, current, marker) {
547
1332
  const tc = typeof current;
548
1333
  if (tc === "string" || tc === "number") {
549
1334
  parent.firstChild.data = value;
550
- } else parent.textContent = value;
1335
+ } else {
1336
+ if (ownsAllChildren(parent, current)) parent.textContent = value;else {
1337
+ removeOwnedChildren(parent, current);
1338
+ parent.insertBefore(document.createTextNode(value), parent.firstChild);
1339
+ }
1340
+ }
551
1341
  } else if (value === undefined) {
552
1342
  cleanChildren(parent, current, marker);
553
1343
  } else if (value.nodeType) {
554
1344
  if (Array.isArray(current)) {
555
1345
  cleanChildren(parent, current, multi ? marker : null, value);
556
- } else if (current === undefined || !parent.firstChild) {
1346
+ } else if (current && current.nodeType) {
1347
+ current.parentNode === parent ? parent.replaceChild(value, current) : parent.appendChild(value);
1348
+ } else if (current && parent.firstChild) {
1349
+ parent.replaceChild(value, parent.firstChild);
1350
+ } else {
557
1351
  parent.appendChild(value);
558
- } else parent.replaceChild(value, parent.firstChild);
1352
+ }
1353
+ if (marker) value[$$SLOT] = marker;
559
1354
  } else if (Array.isArray(value)) {
560
1355
  const currentArray = current && Array.isArray(current);
561
1356
  if (value.length === 0) {
@@ -563,9 +1358,9 @@ function insertExpression(parent, value, current, marker) {
563
1358
  } else if (currentArray) {
564
1359
  if (current.length === 0) {
565
1360
  appendNodes(parent, value, marker);
566
- } else reconcileArrays(parent, current, value);
1361
+ } else reconcileArrays(parent, current, value, marker);
567
1362
  } else {
568
- current && cleanChildren(parent);
1363
+ current && cleanChildren(parent, current);
569
1364
  appendNodes(parent, value);
570
1365
  }
571
1366
  } else console.warn(`Unrecognized value. Skipped inserting`, value);
@@ -587,21 +1382,64 @@ function normalize(value, current, multi, doNotUnwrap) {
587
1382
  }
588
1383
  return value;
589
1384
  }
1385
+ function tagHost(value, host) {
1386
+ if (Array.isArray(value)) {
1387
+ for (let i = 0, len = value.length; i < len; i++) tagHost(value[i], host);
1388
+ } else if (value && value.nodeType && value[$$HOST] !== host) {
1389
+ value[$$HOST] = host;
1390
+ Object.defineProperty(value, "_$host", {
1391
+ get: host,
1392
+ configurable: true
1393
+ });
1394
+ }
1395
+ }
590
1396
  function appendNodes(parent, array, marker = null) {
591
- for (let i = 0, len = array.length; i < len; i++) parent.insertBefore(array[i], marker);
1397
+ for (let i = 0, len = array.length; i < len; i++) {
1398
+ const n = array[i];
1399
+ parent.insertBefore(n, marker);
1400
+ if (marker) n[$$SLOT] = marker;
1401
+ }
1402
+ }
1403
+ function ownsAllChildren(parent, current) {
1404
+ if (current == null) return true;
1405
+ if (Array.isArray(current)) {
1406
+ return current.length ? parent.firstChild === current[0] && parent.lastChild === current[current.length - 1] : parent.firstChild === null;
1407
+ }
1408
+ if (current === "") return parent.firstChild === null;
1409
+ if (current.nodeType) return parent.firstChild === current && parent.lastChild === current;
1410
+ const first = parent.firstChild;
1411
+ return first !== null && first.nodeType === 3 && parent.lastChild === first;
1412
+ }
1413
+ function removeOwnedChildren(parent, current) {
1414
+ if (Array.isArray(current)) {
1415
+ for (let i = 0; i < current.length; i++) {
1416
+ const el = current[i];
1417
+ if (el.parentNode === parent) el.remove();
1418
+ }
1419
+ } else if (current.nodeType) {
1420
+ if (current.parentNode === parent) current.remove();
1421
+ } else {
1422
+ const first = parent.firstChild;
1423
+ if (first && first.nodeType === 3) first.remove();
1424
+ }
592
1425
  }
593
1426
  function cleanChildren(parent, current, marker, replacement) {
594
- if (marker === undefined) return parent.textContent = "";
1427
+ if (marker === undefined) {
1428
+ if (ownsAllChildren(parent, current)) return parent.textContent = "";
1429
+ return removeOwnedChildren(parent, current);
1430
+ }
595
1431
  if (current.length) {
596
1432
  let inserted = false;
597
1433
  for (let i = current.length - 1; i >= 0; i--) {
598
1434
  const el = current[i];
599
1435
  if (replacement !== el) {
600
- const isParent = el.parentNode === parent;
601
- if (replacement && !inserted && !i) isParent ? parent.replaceChild(replacement, el) : parent.insertBefore(replacement, marker);else isParent && el.remove();
1436
+ const tag = el[$$SLOT];
1437
+ const owns = el.parentNode === parent && (!tag || tag === marker);
1438
+ if (replacement && !inserted && !i) owns ? parent.replaceChild(replacement, el) : parent.insertBefore(replacement, marker);else if (owns) el.remove();
602
1439
  } else inserted = true;
603
1440
  }
604
1441
  } else if (replacement) parent.insertBefore(replacement, marker);
1442
+ if (replacement && marker) replacement[$$SLOT] = marker;
605
1443
  }
606
1444
  function gatherHydratable(element, root) {
607
1445
  const templates = element.querySelectorAll(`*[_hk]`);
@@ -639,83 +1477,234 @@ function ssrHydrationKey() {}
639
1477
  function resolveSSRNode(node) {}
640
1478
  function escape(html) {}
641
1479
 
642
- function render(...args) {
643
- solidJs.enforceLoadingBoundary(true);
644
- const result = render$1(...args);
645
- solidJs.enforceLoadingBoundary(false);
646
- return result;
1480
+ const ENVELOPE = Symbol.for("solid.ResponseEnvelope");
1481
+ class ResponseEnvelope {
1482
+ constructor(response, value) {
1483
+ this.response = response;
1484
+ this.value = value;
1485
+ }
1486
+ }
1487
+ ResponseEnvelope.prototype[ENVELOPE] = true;
1488
+ function isResponseEnvelope(value) {
1489
+ return !!(value && typeof value === "object" && value[ENVELOPE]);
1490
+ }
1491
+ const HREF = Symbol.for("solid.Href");
1492
+ function isHref(value) {
1493
+ return !!(value && (typeof value === "object" || typeof value === "function") && value[HREF]);
1494
+ }
1495
+ const REVALIDATE_HEADER = "X-Revalidate";
1496
+ function initWithRevalidate(init) {
1497
+ const {
1498
+ revalidate,
1499
+ ...responseInit
1500
+ } = init;
1501
+ const headers = new Headers(responseInit.headers);
1502
+ revalidate !== undefined && headers.set(REVALIDATE_HEADER, revalidate.toString());
1503
+ return {
1504
+ responseInit,
1505
+ headers
1506
+ };
1507
+ }
1508
+ function redirect(url, init = 302) {
1509
+ if (typeof url !== "string" && !isHref(url)) {
1510
+ throw new TypeError("redirect() expects a string URL or an Href-branded value (Symbol.for('solid.Href')).");
1511
+ }
1512
+ const {
1513
+ responseInit,
1514
+ headers
1515
+ } = initWithRevalidate(typeof init === "number" ? {
1516
+ status: init
1517
+ } : init);
1518
+ if (responseInit.status === undefined) {
1519
+ responseInit.status = 302;
1520
+ }
1521
+ headers.set("Location", String(url));
1522
+ return new Response(null, {
1523
+ ...responseInit,
1524
+ headers
1525
+ });
1526
+ }
1527
+ function reload(init = {}) {
1528
+ const {
1529
+ responseInit,
1530
+ headers
1531
+ } = initWithRevalidate(init);
1532
+ return new Response(null, {
1533
+ ...responseInit,
1534
+ headers
1535
+ });
1536
+ }
1537
+ function respond(value, init = {}) {
1538
+ const {
1539
+ responseInit,
1540
+ headers
1541
+ } = initWithRevalidate(init);
1542
+ headers.set("Content-Type", "application/json");
1543
+ return new ResponseEnvelope(new Response(JSON.stringify(value), {
1544
+ ...responseInit,
1545
+ headers
1546
+ }), value);
647
1547
  }
1548
+
1549
+ const mergeProps = solidJs.merge;
648
1550
  const isServer = false;
649
1551
  const isDev = true;
650
- const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
651
- function createElement(tagName, isSVG = false, is = undefined) {
652
- return isSVG ? document.createElementNS(SVG_NAMESPACE, tagName) : document.createElement(tagName, {
653
- is
654
- });
1552
+ function render(code, element, init, options = {}) {
1553
+ solidJs.enforceLoadingBoundary(true);
1554
+ try {
1555
+ const dispose = render$1(code, element, init, {
1556
+ ...options,
1557
+ insertOptions: {
1558
+ schedule: true
1559
+ }
1560
+ });
1561
+ solidJs.flush();
1562
+ return dispose;
1563
+ } finally {
1564
+ solidJs.enforceLoadingBoundary(false);
1565
+ }
655
1566
  }
656
1567
  const hydrate = (...args) => {
657
1568
  solidJs.enableHydration();
658
1569
  return hydrate$1(...args);
659
1570
  };
660
1571
  function Portal(props) {
1572
+ return solidJs.runWithOwner(solidJs.createOwner(), () => portalImpl(props));
1573
+ }
1574
+ function portalImpl(props) {
661
1575
  const treeMarker = document.createTextNode(""),
662
1576
  startMarker = document.createTextNode(""),
663
1577
  endMarker = document.createTextNode(""),
664
- mount = () => createElementProxy(props.mount || document.body, treeMarker);
665
- let content = solidJs.createMemo(() => [startMarker, props.children]);
666
- solidJs.createRenderEffect(() => [mount(), content()], ([m, c]) => {
1578
+ mount = () => props.mount || document.body,
1579
+ content = solidJs.createMemo(() => [startMarker, props.children], {
1580
+ ssrSource: "client"
1581
+ });
1582
+ solidJs.createRenderEffect(
1583
+ () => [mount(), content(), solidJs.getOwner()], ([, c, owner]) => {
1584
+ const m = solidJs.untrack(mount);
667
1585
  m.appendChild(endMarker);
668
- insert(m, c, endMarker);
1586
+ const dispose = solidJs.runWithOwner(owner, () => solidJs.createRoot(d => {
1587
+ insert(m, c, endMarker, undefined, {
1588
+ host: () => treeMarker.parentNode
1589
+ });
1590
+ return d;
1591
+ }));
669
1592
  return () => {
1593
+ dispose();
670
1594
  let c = startMarker;
671
- while (c && c !== endMarker) {
1595
+ while (c) {
672
1596
  const n = c.nextSibling;
673
1597
  m.removeChild(c);
1598
+ if (c === endMarker) break;
674
1599
  c = n;
675
1600
  }
676
1601
  };
1602
+ },
1603
+ {
1604
+ schedule: true,
1605
+ ssrSource: "client"
1606
+ });
1607
+ solidJs.createEffect(mount, () => {
1608
+ const m = solidJs.untrack(mount);
1609
+ const ownerRoot = getDelegatedRoot(treeMarker);
1610
+ if (!ownerRoot || ownerRoot.contains(m)) return;
1611
+ registerDelegatedContainer(m, ownerRoot);
1612
+ return () => unregisterDelegatedContainer(m, ownerRoot);
1613
+ }, {
1614
+ ssrSource: "client"
1615
+ });
1616
+ if (solidJs.sharedConfig.hydrating) return solidJs.createMemo(() => treeMarker, {
1617
+ ssrSource: "client"
677
1618
  });
678
1619
  return treeMarker;
679
1620
  }
680
- function createElementProxy(el, marker) {
681
- return new Proxy(el, {
682
- get(target, prop) {
683
- if (prop === "appendChild" || prop === "insertBefore") {
684
- return (...args) => {
685
- Object.defineProperty(args[0], "_$host", {
686
- get: () => marker.parentNode,
687
- configurable: true
688
- });
689
- target[prop](...args);
690
- };
691
- }
692
- const value = Reflect.get(target, prop);
693
- return typeof value === "function" ? value.bind(target) : value;
694
- }
695
- });
1621
+ const COMPONENT_BINDING = Symbol.for("dom-expressions.component-binding");
1622
+ function bindingOf(value) {
1623
+ return value !== null && (typeof value === "function" || typeof value === "object") && value[COMPONENT_BINDING] || undefined;
696
1624
  }
697
- function createDynamic(component, props) {
698
- const cached = solidJs.createMemo(component);
699
- return solidJs.createMemo(() => {
700
- const component = cached();
701
- switch (typeof component) {
702
- case "function":
703
- Object.assign(component, {
704
- [solidJs.$DEVCOMP]: true
705
- });
706
- return solidJs.untrack(() => component(props));
707
- case "string":
708
- const isSvg = SVGElements.has(component);
709
- const el = solidJs.sharedConfig.hydrating ? getNextElement() : createElement(component, isSvg, solidJs.untrack(() => props.is));
710
- spread(el, props, isSvg);
711
- return el;
1625
+ function dynamic(source) {
1626
+ let latest = 0;
1627
+ const sites = new Set();
1628
+ const resolveBinding = (next, prev) => {
1629
+ const binding = bindingOf(next);
1630
+ if (!binding) return next;
1631
+ const prevBinding = bindingOf(prev);
1632
+ if (prevBinding && prevBinding.component === binding.component) {
1633
+ for (const deliver of sites) deliver(binding.address);
1634
+ return prev;
712
1635
  }
1636
+ return next;
1637
+ };
1638
+ const cached = solidJs.createMemo(prev => {
1639
+ const next = source();
1640
+ if (!next || typeof next.then !== "function") return resolveBinding(next, prev);
1641
+ const token = ++latest;
1642
+ return {
1643
+ then: (onFulfilled, onRejected) => next.then(resolved => onFulfilled(token === latest ? resolveBinding(resolved, prev) : resolved), onRejected)
1644
+ };
1645
+ }, {
1646
+ lazy: true
713
1647
  });
1648
+ return props => {
1649
+ return solidJs.createMemo(() => {
1650
+ const component = cached();
1651
+ switch (typeof component) {
1652
+ case "function":
1653
+ {
1654
+ Object.assign(component, {
1655
+ [solidJs.$DEVCOMP]: true
1656
+ });
1657
+ const binding = bindingOf(component);
1658
+ if (binding) {
1659
+ const [address, setAddress] = solidJs.createSignal(binding.address);
1660
+ sites.add(setAddress);
1661
+ solidJs.onCleanup(() => sites.delete(setAddress));
1662
+ return solidJs.untrack(() => binding.component(props, address));
1663
+ }
1664
+ return solidJs.untrack(() => component(props));
1665
+ }
1666
+ case "string":
1667
+ const el = solidJs.sharedConfig.hydrating ? getNextElement() : createElement(component, solidJs.untrack(() => props.is));
1668
+ spread(el, props);
1669
+ return el;
1670
+ }
1671
+ });
1672
+ };
714
1673
  }
715
1674
  function Dynamic(props) {
716
- const others = solidJs.omit(props, "component");
717
- return createDynamic(() => props.component, others);
1675
+ const Comp = dynamic(() => props.component);
1676
+ return solidJs.createComponent(Comp, solidJs.omit(props, "component"));
1677
+ }
1678
+ function createElement(tagName, is = undefined) {
1679
+ return SVGElements.has(tagName) ? document.createElementNS(Namespaces.svg, tagName) : MathMLElements.has(tagName) ? document.createElementNS(Namespaces.mathml, tagName) : document.createElement(tagName, {
1680
+ is
1681
+ });
1682
+ }
1683
+ function loadClientOnly(fn, setComp) {
1684
+ fn().then(m => setComp(() => m.default));
718
1685
  }
1686
+ function clientOnly(fn, options = {},
1687
+ _moduleUrl) {
1688
+ const [comp, setComp] = solidJs.createSignal();
1689
+ let started = !options.lazy;
1690
+ started && loadClientOnly(fn, setComp);
1691
+ return props => {
1692
+ let Comp;
1693
+ let m;
1694
+ const rest = solidJs.omit(props, "fallback");
1695
+ if (!started) {
1696
+ started = true;
1697
+ loadClientOnly(fn, setComp);
1698
+ }
1699
+ if ((Comp = solidJs.untrack(comp)) && !solidJs.sharedConfig.hydrating) return Comp(rest);
1700
+ const [mounted, setMounted] = solidJs.createSignal(!solidJs.sharedConfig.hydrating);
1701
+ const gate = solidJs.createMemo(() => (Comp = comp(), m = mounted(), solidJs.untrack(() => Comp && m ? Comp(rest) : props.fallback)));
1702
+ solidJs.sharedConfig.onHydrationEnd(() => setMounted(true));
1703
+ return gate;
1704
+ };
1705
+ }
1706
+ function httpStatus(_code, _text) {}
1707
+ function httpHeader(_name, _value, _options) {}
719
1708
 
720
1709
  Object.defineProperty(exports, "Errored", {
721
1710
  enumerable: true,
@@ -741,6 +1730,14 @@ Object.defineProperty(exports, "NoHydration", {
741
1730
  enumerable: true,
742
1731
  get: function () { return solidJs.NoHydration; }
743
1732
  });
1733
+ Object.defineProperty(exports, "Repeat", {
1734
+ enumerable: true,
1735
+ get: function () { return solidJs.Repeat; }
1736
+ });
1737
+ Object.defineProperty(exports, "Reveal", {
1738
+ enumerable: true,
1739
+ get: function () { return solidJs.Reveal; }
1740
+ });
744
1741
  Object.defineProperty(exports, "Show", {
745
1742
  enumerable: true,
746
1743
  get: function () { return solidJs.Show; }
@@ -757,10 +1754,6 @@ Object.defineProperty(exports, "getOwner", {
757
1754
  enumerable: true,
758
1755
  get: function () { return solidJs.getOwner; }
759
1756
  });
760
- Object.defineProperty(exports, "mergeProps", {
761
- enumerable: true,
762
- get: function () { return solidJs.merge; }
763
- });
764
1757
  Object.defineProperty(exports, "untrack", {
765
1758
  enumerable: true,
766
1759
  get: function () { return solidJs.untrack; }
@@ -768,26 +1761,36 @@ Object.defineProperty(exports, "untrack", {
768
1761
  exports.Assets = voidFn;
769
1762
  exports.ChildProperties = ChildProperties;
770
1763
  exports.DOMElements = DOMElements;
1764
+ exports.DOMWithState = DOMWithState;
771
1765
  exports.DelegatedEvents = DelegatedEvents;
772
1766
  exports.Dynamic = Dynamic;
1767
+ exports.HREF = HREF;
773
1768
  exports.HydrationScript = voidFn;
1769
+ exports.MathMLElements = MathMLElements;
1770
+ exports.Namespaces = Namespaces;
774
1771
  exports.Portal = Portal;
775
- exports.Properties = Properties;
1772
+ exports.REVALIDATE_HEADER = REVALIDATE_HEADER;
1773
+ exports.RawTextElements = RawTextElements;
776
1774
  exports.RequestContext = RequestContext;
1775
+ exports.ResponseEnvelope = ResponseEnvelope;
777
1776
  exports.SVGElements = SVGElements;
778
- exports.SVGNamespace = SVGNamespace;
779
- exports.addEventListener = addEventListener;
1777
+ exports.VoidElements = VoidElements;
1778
+ exports.acquireAsset = acquireAsset;
1779
+ exports.addEvent = addEvent;
780
1780
  exports.applyRef = applyRef;
781
1781
  exports.assign = assign;
1782
+ exports.claimElement = claimElement;
1783
+ exports.claimElementTree = claimElementTree;
782
1784
  exports.className = className;
783
- exports.clearDelegatedEvents = clearDelegatedEvents;
784
- exports.createDynamic = createDynamic;
1785
+ exports.clientOnly = clientOnly;
785
1786
  exports.delegateEvents = delegateEvents;
1787
+ exports.dynamic = dynamic;
786
1788
  exports.dynamicProperty = dynamicProperty;
787
1789
  exports.effect = effect;
788
1790
  exports.escape = escape;
789
1791
  exports.generateHydrationScript = voidFn;
790
1792
  exports.getAssets = voidFn;
1793
+ exports.getDelegatedRoot = getDelegatedRoot;
791
1794
  exports.getFirstChild = getFirstChild;
792
1795
  exports.getHydrationKey = getHydrationKey;
793
1796
  exports.getNextElement = getNextElement;
@@ -795,18 +1798,31 @@ exports.getNextMarker = getNextMarker;
795
1798
  exports.getNextMatch = getNextMatch;
796
1799
  exports.getNextSibling = getNextSibling;
797
1800
  exports.getRequestEvent = voidFn;
1801
+ exports.httpHeader = httpHeader;
1802
+ exports.httpStatus = httpStatus;
798
1803
  exports.hydrate = hydrate;
799
1804
  exports.insert = insert;
1805
+ exports.installHydrationRuntime = installHydrationRuntime;
800
1806
  exports.isDev = isDev;
1807
+ exports.isHref = isHref;
1808
+ exports.isResponseEnvelope = isResponseEnvelope;
801
1809
  exports.isServer = isServer;
802
1810
  exports.memo = memo;
1811
+ exports.mergeProps = mergeProps;
1812
+ exports.redirect = redirect;
803
1813
  exports.ref = ref;
1814
+ exports.registerDelegatedContainer = registerDelegatedContainer;
1815
+ exports.registerDelegatedRoot = registerDelegatedRoot;
1816
+ exports.registerElementClaim = registerElementClaim;
1817
+ exports.reload = reload;
804
1818
  exports.render = render;
805
1819
  exports.renderToStream = renderToStream;
806
1820
  exports.renderToString = renderToString;
807
1821
  exports.renderToStringAsync = renderToStringAsync;
808
1822
  exports.resolveSSRNode = resolveSSRNode;
1823
+ exports.respond = respond;
809
1824
  exports.runHydrationEvents = runHydrationEvents;
1825
+ exports.scope = scope;
810
1826
  exports.setAttribute = setAttribute;
811
1827
  exports.setAttributeNS = setAttributeNS;
812
1828
  exports.setProperty = setProperty;
@@ -820,4 +1836,7 @@ exports.ssrHydrationKey = ssrHydrationKey;
820
1836
  exports.ssrStyle = ssrStyle;
821
1837
  exports.style = style;
822
1838
  exports.template = template;
1839
+ exports.unregisterDelegatedContainer = unregisterDelegatedContainer;
1840
+ exports.unregisterDelegatedRoot = unregisterDelegatedRoot;
823
1841
  exports.useAssets = voidFn;
1842
+ exports.useHead = useHead;