@solidjs/web 2.0.0-beta.2 → 2.0.0-beta.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +27 -4
  2. package/dist/dev.cjs +790 -223
  3. package/dist/dev.js +764 -217
  4. package/dist/server.cjs +742 -186
  5. package/dist/server.js +714 -183
  6. package/dist/web.cjs +779 -196
  7. package/dist/web.js +753 -190
  8. package/package.json +193 -38
  9. package/serialization/dist/serialization.cjs +83 -0
  10. package/serialization/dist/serialization.js +75 -0
  11. package/serialization/package.json +20 -0
  12. package/serialization/types/index.d.ts +139 -0
  13. package/serialization/types-cjs/index.d.cts +139 -0
  14. package/serialization/types-cjs/package.json +3 -0
  15. package/server-functions/dist/client.cjs +448 -0
  16. package/server-functions/dist/client.js +435 -0
  17. package/server-functions/dist/server.cjs +632 -0
  18. package/server-functions/dist/server.js +615 -0
  19. package/server-functions/package.json +30 -0
  20. package/storage/package.json +8 -3
  21. package/storage/types/index.d.ts +26 -0
  22. package/storage/types-cjs/index.d.cts +28 -0
  23. package/storage/types-cjs/package.json +3 -0
  24. package/types/client.d.ts +64 -21
  25. package/types/core.d.ts +3 -3
  26. package/types/index.d.ts +156 -24
  27. package/types/jsx-properties.d.ts +93 -0
  28. package/types/jsx.d.ts +4135 -1
  29. package/types/response.d.ts +93 -0
  30. package/types/serializer.d.ts +139 -0
  31. package/types/server-functions/client.d.ts +137 -0
  32. package/types/server-functions/server.d.ts +307 -0
  33. package/types/server-functions/shared.d.ts +342 -0
  34. package/types/server-mock.d.ts +89 -0
  35. package/types/server.d.ts +123 -28
  36. package/types-cjs/client.d.cts +131 -0
  37. package/types-cjs/core.d.cts +3 -0
  38. package/types-cjs/index.d.cts +178 -0
  39. package/types-cjs/jsx-properties.d.cts +93 -0
  40. package/types-cjs/jsx.d.cts +4135 -0
  41. package/types-cjs/package.json +3 -0
  42. package/types-cjs/response.d.cts +93 -0
  43. package/types-cjs/serializer.d.cts +139 -0
  44. package/types-cjs/server-functions/client.d.cts +137 -0
  45. package/types-cjs/server-functions/server.d.cts +307 -0
  46. package/types-cjs/server-functions/shared.d.cts +342 -0
  47. package/types-cjs/server-mock.d.cts +161 -0
  48. package/types-cjs/server.d.cts +251 -0
  49. package/storage/types/src/client.d.ts +0 -1
  50. package/storage/types/src/index.d.ts +0 -46
  51. package/storage/types/src/server-mock.d.ts +0 -72
  52. 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,58 +141,141 @@ 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
+ }
83
169
  }
84
170
  }
85
171
  }
86
172
 
87
- const $$EVENTS = "_$DX_DELEGATE";
173
+ const $$EVENT_OWNER = "_$DX_EVENT_OWNER";
174
+ const INNER_OWNED = {};
175
+ const delegatedEvents = new Set();
176
+ const delegatedContainers = new Map();
88
177
  function render$1(code, element, init, options = {}) {
89
178
  if (!element) {
90
179
  throw new Error("The `element` passed to `render(..., element)` doesn't exist. Make sure `element` exists in the document.");
91
180
  }
92
181
  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
- });
182
+ registerDelegatedRoot(element);
183
+ try {
184
+ solidJs.createRoot(dispose => {
185
+ disposer = dispose;
186
+ if (element === document) {
187
+ const tree = code();
188
+ effect(() => solidJs.flatten(tree), () => {});
189
+ } else {
190
+ const tree = code();
191
+ insert(element, () => tree, element.firstChild ? null : undefined, init, options.insertOptions);
192
+ }
193
+ }, {
194
+ id: options.renderId
195
+ });
196
+ } catch (err) {
197
+ if (disposer) disposer();
198
+ unregisterDelegatedRoot(element);
199
+ throw err;
200
+ }
99
201
  return () => {
100
202
  disposer();
203
+ unregisterDelegatedRoot(element);
101
204
  element.textContent = "";
102
205
  };
103
206
  }
104
- function template(html, isImportNode, isSVG, isMathML) {
207
+ function create(html, bypassGuard, flag) {
208
+ if (isHydrating() && !bypassGuard) throw new Error("Failed attempt to create new DOM elements during hydration. Check that the libraries you are using support hydration.");
209
+ const t = document.createElement("template");
210
+ t.innerHTML = html;
211
+ return flag === 2 ? t.content.firstChild.firstChild : t.content.firstChild;
212
+ }
213
+ function template(html, flag) {
105
214
  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;
215
+ const fn = flag === 1 ? bypassGuard => document.importNode(node || (node = create(html, bypassGuard, flag)), true) : bypassGuard => (node || (node = create(html, bypassGuard, flag))).cloneNode(true);
216
+ fn._html = flag === 2 ? html.replace(/^<[^>]+>/, "") : html;
114
217
  return fn;
115
218
  }
116
- function delegateEvents(eventNames, document = window.document) {
117
- const e = document[$$EVENTS] || (document[$$EVENTS] = new Set());
219
+ function delegateEvents(eventNames) {
118
220
  for (let i = 0, l = eventNames.length; i < l; i++) {
119
221
  const name = eventNames[i];
120
- if (!e.has(name)) {
121
- e.add(name);
122
- document.addEventListener(name, eventHandler);
222
+ if (!delegatedEvents.has(name)) {
223
+ delegatedEvents.add(name);
224
+ delegatedContainers.forEach((state, container) => attachDelegatedEvent(name, container, state));
123
225
  }
124
226
  }
125
227
  }
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];
228
+ function registerDelegatedRoot(root) {
229
+ const state = registerDelegatedContainer(root, root);
230
+ if (state) state.roots = (state.roots || 0) + 1;
231
+ }
232
+ function unregisterDelegatedRoot(root) {
233
+ const state = delegatedContainers.get(root);
234
+ if (state) state.roots > 1 ? state.roots-- : delete state.roots;
235
+ unregisterDelegatedContainer(root, root);
236
+ }
237
+ function registerDelegatedContainer(container, owner = container) {
238
+ if (!container || !owner) return;
239
+ let state = delegatedContainers.get(container);
240
+ if (!state) delegatedContainers.set(container, state = {
241
+ owners: new Map(),
242
+ handlers: new Map()
243
+ });
244
+ state.owners.set(owner, (state.owners.get(owner) || 0) + 1);
245
+ delegatedEvents.forEach(name => attachDelegatedEvent(name, container, state));
246
+ return state;
247
+ }
248
+ function unregisterDelegatedContainer(container, owner = container) {
249
+ const state = delegatedContainers.get(container);
250
+ if (!state) return;
251
+ const count = state.owners.get(owner);
252
+ if (count > 1) state.owners.set(owner, count - 1);else state.owners.delete(owner);
253
+ if (state.owners.size) return;
254
+ state.handlers.forEach((handler, name) => container.removeEventListener(name, handler));
255
+ delegatedContainers.delete(container);
256
+ }
257
+ function attachDelegatedEvent(name, container, state) {
258
+ if (state.handlers.has(name)) return;
259
+ const handler = e => eventHandler(e, container, state);
260
+ state.handlers.set(name, handler);
261
+ container.addEventListener(name, handler);
262
+ }
263
+ function getDelegatedRoot(node) {
264
+ while (node) {
265
+ if (delegatedContainers.get(node)?.roots) return node;
266
+ node = node._$host || node.parentNode || node.host;
267
+ }
268
+ }
269
+ function findOwner(target, state) {
270
+ let node = target;
271
+ let distance = 0;
272
+ while (node) {
273
+ if (state.owners.has(node)) return {
274
+ owner: node,
275
+ distance
276
+ };
277
+ distance++;
278
+ node = node._$host || node.parentNode || node.host;
130
279
  }
131
280
  }
132
281
  function setProperty(node, name, value) {
@@ -139,16 +288,16 @@ function setAttribute(node, name, value) {
139
288
  }
140
289
  function setAttributeNS(node, namespace, name, value) {
141
290
  if (isHydrating(node)) return;
142
- if (value == null) node.removeAttributeNS(namespace, name);else node.setAttributeNS(namespace, name, value);
291
+ if (value == null || value === false) node.removeAttributeNS(namespace, name.indexOf(":") > -1 ? name.split(":").pop() : name);else node.setAttributeNS(namespace, name, value === true ? "" : value);
143
292
  }
144
- function className(node, value, isSVG, prev) {
293
+ function className(node, value, prev) {
145
294
  if (isHydrating(node)) return;
146
295
  if (value == null || value === false) {
147
296
  prev && node.removeAttribute("class");
148
297
  return;
149
298
  }
150
299
  if (typeof value === "string") {
151
- value !== prev && (isSVG ? node.setAttribute("class", value) : node.className = value);
300
+ value !== prev && node.setAttribute("class", value);
152
301
  return;
153
302
  }
154
303
  if (typeof prev === "string") {
@@ -162,16 +311,16 @@ function className(node, value, isSVG, prev) {
162
311
  for (i = 0, len = prevKeys.length; i < len; i++) {
163
312
  const key = prevKeys[i];
164
313
  if (!key || key === "undefined" || value[key]) continue;
165
- toggleClassKey(node, key, false);
314
+ node.classList.remove(key);
166
315
  }
167
316
  for (i = 0, len = classKeys.length; i < len; i++) {
168
317
  const key = classKeys[i],
169
318
  classValue = !!value[key];
170
319
  if (!key || key === "undefined" || prev[key] === classValue || !classValue) continue;
171
- toggleClassKey(node, key, true);
320
+ node.classList.add(key);
172
321
  }
173
322
  }
174
- function addEventListener(node, name, handler, delegate) {
323
+ function addEvent(node, name, handler, delegate) {
175
324
  if (delegate) {
176
325
  if (Array.isArray(handler)) {
177
326
  node[`$$${name}`] = handler[0];
@@ -184,33 +333,48 @@ function addEventListener(node, name, handler, delegate) {
184
333
  }
185
334
  function style(node, value, prev) {
186
335
  if (!value) {
187
- if (prev) setAttribute(node, "style");
336
+ if (prev || node._$styles) {
337
+ setAttribute(node, "style");
338
+ node._$styles = undefined;
339
+ }
188
340
  return;
189
341
  }
190
342
  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 = {});
343
+ if (typeof value === "string") {
344
+ node._$styles = undefined;
345
+ return nodeStyle.cssText = value;
346
+ }
347
+ if (typeof prev === "string") {
348
+ nodeStyle.cssText = "";
349
+ prev = undefined;
350
+ }
351
+ let applied = node._$styles;
352
+ if (!applied) {
353
+ applied = node._$styles = prev ? {
354
+ ...prev
355
+ } : {};
356
+ }
195
357
  let v, s;
358
+ for (s in applied) {
359
+ if (value[s] == null) {
360
+ nodeStyle.removeProperty(s);
361
+ delete applied[s];
362
+ }
363
+ }
196
364
  for (s in value) {
197
365
  v = value[s];
198
- if (v !== prev[s]) nodeStyle.setProperty(s, v);
199
- delete prev[s];
366
+ if (v != null && v !== applied[s]) {
367
+ nodeStyle.setProperty(s, v);
368
+ applied[s] = v;
369
+ }
200
370
  }
201
- for (s in prev) value[s] == null && nodeStyle.removeProperty(s);
202
371
  }
203
372
  function setStyleProperty(node, name, value) {
204
373
  value != null ? node.style.setProperty(name, value) : node.style.removeProperty(name);
205
374
  }
206
- function spread(node, props = {}, isSVG, skipChildren) {
375
+ function spread(node, props = {}, skipChildren) {
207
376
  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
- }
377
+ if (!skipChildren) insert(node, () => props.children);
214
378
  effect(() => {
215
379
  const r = props.ref;
216
380
  (typeof r === "function" || Array.isArray(r)) && ref(() => r, node);
@@ -222,7 +386,7 @@ function spread(node, props = {}, isSVG, skipChildren) {
222
386
  newProps[prop] = props[prop];
223
387
  }
224
388
  return newProps;
225
- }, props => assign(node, props, isSVG, true, prevProps, true));
389
+ }, props => assign(node, props, true, prevProps, true));
226
390
  return prevProps;
227
391
  }
228
392
  function dynamicProperty(props, key) {
@@ -242,49 +406,235 @@ function ref(fn, element) {
242
406
  const resolved = solidJs.untrack(fn);
243
407
  solidJs.runWithOwner(null, () => applyRef(resolved, element));
244
408
  }
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];
409
+ function scope(fn) {
410
+ fn.$s = true;
411
+ return fn;
412
+ }
413
+ const SCOPE_OPTIONS = {
414
+ scope: true
415
+ };
416
+ let hydrationRt = null;
417
+ function installHydrationRuntime() {
418
+ hydrationRt = {
419
+ claimInitial(parent, multi, initial) {
420
+ if (isHydrating(parent)) {
421
+ if (!multi && initial === undefined && parent) initial = [...parent.childNodes];
422
+ if (Array.isArray(initial)) stripTextSeparators(initial);
254
423
  }
255
- initial.length = j;
424
+ return initial;
425
+ },
426
+ reclaimRegion(current, parent, marker) {
427
+ if (!solidJs.sharedConfig.hydrating || !current || !parent.isConnected) return current;
428
+ const first = Array.isArray(current) ? current[0] : current;
429
+ if (!first || !first.nodeType || first.isConnected) return current;
430
+ let nodes;
431
+ if (marker) {
432
+ nodes = [];
433
+ let node = marker.previousSibling,
434
+ depth = 0;
435
+ while (node) {
436
+ if (node.nodeType === 8) {
437
+ const v = node.nodeValue;
438
+ if (v === "/") depth++;else if (v === "$") {
439
+ if (depth === 0) break;
440
+ depth--;
441
+ }
442
+ }
443
+ nodes.unshift(node);
444
+ node = node.previousSibling;
445
+ }
446
+ } else nodes = [...parent.childNodes];
447
+ return stripTextSeparators(nodes);
448
+ },
449
+ dedupEvent(e) {
450
+ return !!(solidJs.sharedConfig.registry && solidJs.sharedConfig.events && solidJs.sharedConfig.events.find(([el, ev]) => ev === e));
256
451
  }
452
+ };
453
+ }
454
+ function stripTextSeparators(nodes) {
455
+ let j = 0;
456
+ for (let i = 0; i < nodes.length; i++) {
457
+ if (nodes[i].nodeType === 8 && nodes[i].nodeValue === "!$") nodes[i].remove();else nodes[j++] = nodes[i];
257
458
  }
459
+ nodes.length = j;
460
+ return nodes;
461
+ }
462
+ function insert(parent, accessor, marker, initial, options) {
463
+ const multi = marker !== undefined;
464
+ const host = options && options.host;
465
+ if (multi && !initial) initial = [];
466
+ if (hydrationRt !== null) initial = hydrationRt.claimInitial(parent, multi, initial);
258
467
  if (typeof accessor !== "function") {
259
468
  accessor = normalize(accessor, initial, multi, true);
260
- if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker);
469
+ if (typeof accessor !== "function") {
470
+ insertExpression(parent, accessor, initial, marker);
471
+ host && tagHost(accessor, host);
472
+ return;
473
+ }
261
474
  }
262
- accessor = memo(accessor, true);
263
- if (multi && initial.length === 0 && !isHydrating(parent)) {
475
+ if (multi && initial.length === 0) {
264
476
  const placeholder = document.createTextNode("");
265
477
  parent.insertBefore(placeholder, marker);
266
478
  initial = [placeholder];
267
479
  }
268
- effect(prev => normalize(accessor, prev, multi), (value, current) => insertExpression(parent, value, current, marker), initial);
480
+ let current = initial;
481
+ effect(prev => {
482
+ if (hydrationRt !== null) current = hydrationRt.reclaimRegion(current, parent, marker);
483
+ const value = normalize(accessor(), current, multi, true);
484
+ if (typeof value !== "function") return value;
485
+ effect(() => (hydrationRt !== null && (current = hydrationRt.reclaimRegion(current, parent, marker)), normalize(value, current, multi)), inner => {
486
+ insertExpression(parent, inner, current, marker);
487
+ current = inner;
488
+ host && tagHost(current, host);
489
+ }, prev !== undefined && !(options && options.schedule) ? {
490
+ ...options,
491
+ schedule: true
492
+ } : options);
493
+ return INNER_OWNED;
494
+ }, value => {
495
+ if (value === INNER_OWNED) return;
496
+ insertExpression(parent, value, current, marker);
497
+ current = value;
498
+ host && tagHost(current, host);
499
+ },
500
+ accessor.$s ? options ? {
501
+ ...options,
502
+ scope: true
503
+ } : SCOPE_OPTIONS : options);
269
504
  }
270
- function assign(node, props, isSVG, skipChildren, prevProps = {}, skipRef = false) {
505
+ function assign(node, props, skipChildren, prevProps = {}, skipRef = false) {
506
+ const nodeName = node.nodeName;
271
507
  props || (props = {});
272
508
  for (const prop in prevProps) {
273
509
  if (!(prop in props)) {
274
510
  if (prop === "children") continue;
275
- prevProps[prop] = assignProp(node, prop, null, prevProps[prop], isSVG, skipRef);
511
+ prevProps[prop] = assignProp(node, prop, null, prevProps[prop], skipRef, nodeName);
276
512
  }
277
513
  }
278
514
  for (const prop in props) {
279
515
  if (prop === "children") {
280
- if (!skipChildren) insertExpression(node, props.children);
516
+ if (!skipChildren) insertExpression(node, normalize(props.children, undefined, false));
281
517
  continue;
282
518
  }
283
- const value = props[prop];
284
- prevProps[prop] = assignProp(node, prop, value, prevProps[prop], isSVG, skipRef);
519
+ prevProps[prop] = assignProp(node, prop, props[prop], prevProps[prop], skipRef, nodeName);
520
+ }
521
+ }
522
+ const ASSET_REMOVAL_GRACE = 100;
523
+ const assetRegistry = new Map();
524
+ function assetEntryKey(descriptor) {
525
+ if (descriptor.policy === "exclusive") return "x|" + descriptor.key;
526
+ return descriptor.type === "inline-style" ? "i|" + descriptor.id : descriptor.type + "|" + descriptor.href;
527
+ }
528
+ function findAssetElement(selector, attr, value) {
529
+ const nodes = document.querySelectorAll(selector);
530
+ for (let i = 0; i < nodes.length; i++) {
531
+ if (nodes[i].getAttribute(attr) === value) return nodes[i];
285
532
  }
533
+ return null;
534
+ }
535
+ function mountAssetElement(descriptor) {
536
+ let el;
537
+ if (descriptor.type === "inline-style") {
538
+ el = findAssetElement("style[data-asset]", "data-asset", descriptor.id);
539
+ if (!el) {
540
+ el = document.createElement("style");
541
+ el.setAttribute("data-asset", descriptor.id);
542
+ el.textContent = descriptor.content || "";
543
+ }
544
+ } else {
545
+ const rel = descriptor.type === "module" ? "modulepreload" : "stylesheet";
546
+ el = findAssetElement(`link[rel="${rel}"]`, "href", descriptor.href);
547
+ if (!el) {
548
+ el = document.createElement("link");
549
+ el.rel = rel;
550
+ el.href = descriptor.href;
551
+ }
552
+ }
553
+ if (descriptor.attrs) {
554
+ for (const name in descriptor.attrs) el.setAttribute(name, descriptor.attrs[name]);
555
+ }
556
+ if (!el.isConnected) document.head.appendChild(el);
557
+ return el;
558
+ }
559
+ function acquireAsset(descriptor) {
560
+ const key = assetEntryKey(descriptor);
561
+ let entry = assetRegistry.get(key);
562
+ if (descriptor.policy === "exclusive") {
563
+ if (!entry) {
564
+ entry = {
565
+ original: descriptor.get(),
566
+ set: descriptor.set,
567
+ writers: []
568
+ };
569
+ assetRegistry.set(key, entry);
570
+ }
571
+ const writer = {
572
+ value: descriptor.value
573
+ };
574
+ entry.writers.push(writer);
575
+ entry.set(writer.value);
576
+ let released = false;
577
+ return () => {
578
+ if (released) return;
579
+ released = true;
580
+ const index = entry.writers.indexOf(writer);
581
+ const wasTop = index === entry.writers.length - 1;
582
+ entry.writers.splice(index, 1);
583
+ if (!wasTop) return;
584
+ if (entry.writers.length) {
585
+ entry.set(entry.writers[entry.writers.length - 1].value);
586
+ } else {
587
+ entry.set(entry.original);
588
+ assetRegistry.delete(key);
589
+ }
590
+ };
591
+ }
592
+ if (!entry) {
593
+ entry = {
594
+ count: 0,
595
+ element: null,
596
+ timer: null
597
+ };
598
+ assetRegistry.set(key, entry);
599
+ }
600
+ if (entry.timer) {
601
+ clearTimeout(entry.timer);
602
+ entry.timer = null;
603
+ }
604
+ entry.count++;
605
+ if (!entry.element || !entry.element.isConnected) entry.element = mountAssetElement(descriptor);
606
+ let released = false;
607
+ return () => {
608
+ if (released) return;
609
+ released = true;
610
+ if (--entry.count > 0) return;
611
+ entry.timer = setTimeout(() => {
612
+ assetRegistry.delete(key);
613
+ entry.element && entry.element.remove();
614
+ }, ASSET_REMOVAL_GRACE);
615
+ };
616
+ }
617
+ function loadModuleAssets(mapping) {
618
+ const hy = globalThis._$HY;
619
+ if (!hy) return;
620
+ const pending = [];
621
+ for (const key in mapping) {
622
+ if (hy.modules[key]) continue;
623
+ const entryUrl = mapping[key];
624
+ if (!hy.loading[key]) {
625
+ hy.loading[key] = import(entryUrl).then(mod => {
626
+ hy.modules[key] = mod;
627
+ }, err => {
628
+ delete hy.loading[key];
629
+ throw err;
630
+ });
631
+ }
632
+ pending.push(hy.loading[key]);
633
+ }
634
+ return pending.length ? Promise.all(pending).then(() => {}) : undefined;
286
635
  }
287
636
  function hydrate$1(code, element, options = {}) {
637
+ installHydrationRuntime();
288
638
  if (globalThis._$HY.done) return render$1(code, element, [...element.childNodes], options);
289
639
  options.renderId ||= "";
290
640
  if (!globalThis._$HY.modules) globalThis._$HY.modules = {};
@@ -294,6 +644,7 @@ function hydrate$1(code, element, options = {}) {
294
644
  solidJs.sharedConfig.load = id => globalThis._$HY.r[id];
295
645
  solidJs.sharedConfig.has = id => id in globalThis._$HY.r;
296
646
  solidJs.sharedConfig.gather = root => gatherHydratable(element, root);
647
+ solidJs.sharedConfig.loadModuleAssets = loadModuleAssets;
297
648
  solidJs.sharedConfig.cleanupFragment = id => {
298
649
  const tpl = document.getElementById("pl-" + id);
299
650
  if (tpl) {
@@ -311,15 +662,45 @@ function hydrate$1(code, element, options = {}) {
311
662
  }
312
663
  };
313
664
  solidJs.sharedConfig.registry = new Map();
665
+ if (!solidJs.sharedConfig.boundaryScopes) solidJs.sharedConfig.boundaryScopes = new Map();
666
+ solidJs.sharedConfig.captureBoundaryScope = id => {
667
+ if (solidJs.sharedConfig.registry) solidJs.sharedConfig.boundaryScopes.set(id, {
668
+ registry: solidJs.sharedConfig.registry,
669
+ gather: solidJs.sharedConfig.gather
670
+ });
671
+ };
314
672
  solidJs.sharedConfig.hydrating = true;
315
673
  {
316
674
  solidJs.sharedConfig.verifyHydration = () => {
317
675
  if (solidJs.sharedConfig.registry && solidJs.sharedConfig.registry.size) {
318
- const orphaned = [...solidJs.sharedConfig.registry.values()];
676
+ const orphaned = [...solidJs.sharedConfig.registry.values()].filter(node => node.isConnected);
677
+ solidJs.sharedConfig.registry.clear();
678
+ if (!orphaned.length) return;
319
679
  console.warn(`Hydration completed with ${orphaned.length} unclaimed server-rendered node(s):\n` + orphaned.map(node => ` ${node.outerHTML.slice(0, 100)}`).join("\n"));
320
680
  }
321
681
  };
322
682
  }
683
+ const rootMapping = globalThis._$HY.r && globalThis._$HY.r["_assets"];
684
+ if (rootMapping && typeof rootMapping === "object") {
685
+ const p = loadModuleAssets(rootMapping);
686
+ if (p) {
687
+ gatherHydratable(element, options.renderId);
688
+ let disposer;
689
+ p.then(() => {
690
+ try {
691
+ disposer = render$1(code, element, [...element.childNodes], options);
692
+ } finally {
693
+ solidJs.sharedConfig.hydrating = false;
694
+ }
695
+ }, err => {
696
+ console.error("Hydration module preload failed, falling back to client render:", err);
697
+ solidJs.sharedConfig.hydrating = false;
698
+ solidJs.sharedConfig.registry = undefined;
699
+ disposer = render$1(code, element, [...element.childNodes], options);
700
+ });
701
+ return () => disposer && disposer();
702
+ }
703
+ }
323
704
  try {
324
705
  gatherHydratable(element, options.renderId);
325
706
  return render$1(code, element, [...element.childNodes], options);
@@ -381,20 +762,21 @@ function getFirstChild(node, expectedTag) {
381
762
  function getNextSibling(node, expectedTag) {
382
763
  const sibling = node.nextSibling;
383
764
  if (isHydrating() && expectedTag && sibling?.localName !== expectedTag) {
384
- const parent = node.parentElement;
765
+ const parent = node.parentNode;
385
766
  const isMissing = !sibling || sibling.nodeType !== 1;
386
767
  console.warn("Hydration structure mismatch: expected <" + expectedTag + "> after", node, "in", parent, "\n " + describeSiblings(parent, sibling, expectedTag, isMissing));
387
768
  }
388
769
  return sibling;
389
770
  }
390
771
  function describeSiblings(parent, mismatchChild, expectedTag, isMissing) {
772
+ if (!parent) return `<${expectedTag} \u2190 parent unavailable>`;
391
773
  const children = [];
392
774
  let child = parent.firstChild;
393
775
  while (child) {
394
776
  if (child.nodeType === 1) children.push(child);
395
777
  child = child.nextSibling;
396
778
  }
397
- const pTag = parent.localName;
779
+ const pTag = parent.localName || "#fragment";
398
780
  if (isMissing) {
399
781
  const tags = children.map(c => `<${c.localName}>`).join("");
400
782
  return `<${pTag}>${tags}<${expectedTag} \u2190 missing></${pTag}>`;
@@ -426,7 +808,32 @@ function runHydrationEvents() {
426
808
  const [el, e] = events[0];
427
809
  if (!completed.has(el)) return;
428
810
  events.shift();
429
- eventHandler(e);
811
+ let matchContainer, matchState, matchDistance, matches;
812
+ for (const [container, state] of delegatedContainers) {
813
+ if (!state.handlers.has(e.type)) continue;
814
+ const entry = findOwner(e.target, state);
815
+ if (!entry) continue;
816
+ if (matchContainer) {
817
+ if (!matches) matches = [{
818
+ container: matchContainer,
819
+ state: matchState,
820
+ distance: matchDistance
821
+ }];
822
+ matches.push({
823
+ container,
824
+ state,
825
+ distance: entry.distance
826
+ });
827
+ } else {
828
+ matchContainer = container;
829
+ matchState = state;
830
+ matchDistance = entry.distance;
831
+ }
832
+ }
833
+ if (matches) {
834
+ matches.sort((a, b) => a.distance - b.distance);
835
+ for (let i = 0; i < matches.length; i++) eventHandler(e, matches[i].container, matches[i].state);
836
+ } else if (matchContainer) eventHandler(e, matchContainer, matchState);
430
837
  }
431
838
  if (solidJs.sharedConfig.done) {
432
839
  solidJs.sharedConfig.events = _$HY.events = null;
@@ -439,14 +846,21 @@ function runHydrationEvents() {
439
846
  function isHydrating(node) {
440
847
  return solidJs.sharedConfig.hydrating && (!node || node.isConnected);
441
848
  }
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);
445
- }
446
849
  function classListToObject(classList) {
447
850
  if (Array.isArray(classList)) {
448
851
  const result = {};
449
852
  flattenClassList(classList, result);
853
+ classList = result;
854
+ }
855
+ if (classList && typeof classList === "object") {
856
+ const result = {},
857
+ keys = Object.keys(classList);
858
+ for (let i = 0, len = keys.length; i < len; i++) {
859
+ const key = keys[i];
860
+ if (!classList[key]) continue;
861
+ const classNames = key.trim().split(/\s+/);
862
+ for (let j = 0, nameLen = classNames.length; j < nameLen; j++) classNames[j] && (result[classNames[j]] = true);
863
+ }
450
864
  return result;
451
865
  }
452
866
  return classList;
@@ -457,18 +871,16 @@ function flattenClassList(list, result) {
457
871
  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
872
  }
459
873
  }
460
- function assignProp(node, prop, value, prev, isSVG, skipRef) {
461
- let forceProp;
874
+ function assignProp(node, prop, value, prev, skipRef, nodeName) {
462
875
  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;
876
+ if (prop === "class") return className(node, value, prev), value;
877
+ if (value === prev && DOMWithState[nodeName]?.[prop] !== 1) return prev;
465
878
  if (prop === "ref") {
466
879
  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") {
880
+ return value;
881
+ }
882
+ const hasNamespace = prop.indexOf(":") > -1;
883
+ if (!hasNamespace && prop.slice(0, 2) === "on") {
472
884
  const name = prop.slice(2).toLowerCase();
473
885
  const delegate = DelegatedEvents.has(name);
474
886
  if (!delegate && prev) {
@@ -476,26 +888,33 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
476
888
  node.removeEventListener(name, h);
477
889
  }
478
890
  if (delegate || value) {
479
- addEventListener(node, name, value, delegate);
891
+ addEvent(node, name, value, delegate);
480
892
  delegate && delegateEvents([name]);
481
893
  }
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;
894
+ } else if (hasNamespace && prop.slice(0, 5) === "prop:" || ChildProperties.has(prop) || DOMWithState[nodeName]?.[prop]) {
895
+ if (hasNamespace) prop = prop.slice(5);else if (isHydrating(node)) return value;
896
+ if (prop === "value" && nodeName === "SELECT") queueMicrotask(() => node.value = value) || (node.value = value);else node[prop] = value;
485
897
  } else {
486
- const ns = isSVG && prop.indexOf(":") > -1 && SVGNamespace[prop.split(":")[0]];
898
+ const ns = hasNamespace && Namespaces[prop.split(":")[0]];
487
899
  if (ns) setAttributeNS(node, ns, prop, value);else setAttribute(node, prop, value);
488
900
  }
489
901
  return value;
490
902
  }
491
- function eventHandler(e) {
492
- if (solidJs.sharedConfig.registry && solidJs.sharedConfig.events) {
493
- if (solidJs.sharedConfig.events.find(([el, ev]) => ev === e)) return;
903
+ function eventHandler(e, container, state) {
904
+ if (hydrationRt !== null && hydrationRt.dedupEvent(e)) return;
905
+ const prev = e[$$EVENT_OWNER];
906
+ let resumeNode;
907
+ if (prev) {
908
+ if (prev === true || prev === container || !container.contains(prev)) return;
909
+ resumeNode = prev;
494
910
  }
495
- let node = e.target;
911
+ const owner = state && (state.owners.size === 1 && state.owners.has(container) ? container : findOwner(e.target, state)?.owner);
912
+ if (state && !owner) return;
913
+ e[$$EVENT_OWNER] = owner || true;
914
+ let node = resumeNode || e.target;
496
915
  const key = `$$${e.type}`;
497
916
  const oriTarget = e.target;
498
- const oriCurrentTarget = e.currentTarget;
917
+ const boundary = owner || container || e.currentTarget;
499
918
  const retarget = value => Object.defineProperty(e, "target", {
500
919
  configurable: true,
501
920
  value
@@ -511,35 +930,43 @@ function eventHandler(e) {
511
930
  return true;
512
931
  };
513
932
  const walkUpTree = () => {
514
- while (handleNode() && (node = node._$host || node.parentNode || node.host));
933
+ while (handleNode()) {
934
+ if (node === boundary || node.parentNode === boundary) break;
935
+ node = node._$host || node.parentNode || node.host;
936
+ }
515
937
  };
516
938
  Object.defineProperty(e, "currentTarget", {
517
939
  configurable: true,
518
940
  get() {
519
- return node || document;
941
+ return node || boundary || document;
520
942
  }
521
943
  });
522
- if (e.composedPath) {
944
+ if (resumeNode) {
945
+ if (resumeNode === e.target) node = resumeNode._$host || resumeNode.parentNode || resumeNode.host;
946
+ if (node && node !== boundary) walkUpTree();
947
+ } else if (e.composedPath) {
523
948
  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;
949
+ if (path.length) {
950
+ retarget(path[0]);
951
+ for (let i = 0; i < path.length; i++) {
952
+ node = path[i];
953
+ if (!handleNode()) break;
954
+ if (node._$host) {
955
+ node = node._$host;
956
+ walkUpTree();
957
+ break;
958
+ }
959
+ if (node === boundary || node.parentNode === boundary) {
960
+ break;
961
+ }
535
962
  }
536
- }
963
+ } else walkUpTree();
537
964
  }
538
965
  else walkUpTree();
539
966
  retarget(oriTarget);
540
967
  }
541
968
  function insertExpression(parent, value, current, marker) {
542
- if (isHydrating(parent)) return;
969
+ if (hydrationRt !== null && isHydrating(parent)) return;
543
970
  if (value === current) return;
544
971
  const t = typeof value,
545
972
  multi = marker !== undefined;
@@ -547,15 +974,25 @@ function insertExpression(parent, value, current, marker) {
547
974
  const tc = typeof current;
548
975
  if (tc === "string" || tc === "number") {
549
976
  parent.firstChild.data = value;
550
- } else parent.textContent = value;
977
+ } else {
978
+ if (ownsAllChildren(parent, current)) parent.textContent = value;else {
979
+ removeOwnedChildren(parent, current);
980
+ parent.insertBefore(document.createTextNode(value), parent.firstChild);
981
+ }
982
+ }
551
983
  } else if (value === undefined) {
552
984
  cleanChildren(parent, current, marker);
553
985
  } else if (value.nodeType) {
554
986
  if (Array.isArray(current)) {
555
987
  cleanChildren(parent, current, multi ? marker : null, value);
556
- } else if (current === undefined || !parent.firstChild) {
988
+ } else if (current && current.nodeType) {
989
+ current.parentNode === parent ? parent.replaceChild(value, current) : parent.appendChild(value);
990
+ } else if (current && parent.firstChild) {
991
+ parent.replaceChild(value, parent.firstChild);
992
+ } else {
557
993
  parent.appendChild(value);
558
- } else parent.replaceChild(value, parent.firstChild);
994
+ }
995
+ if (marker) value[$$SLOT] = marker;
559
996
  } else if (Array.isArray(value)) {
560
997
  const currentArray = current && Array.isArray(current);
561
998
  if (value.length === 0) {
@@ -563,9 +1000,9 @@ function insertExpression(parent, value, current, marker) {
563
1000
  } else if (currentArray) {
564
1001
  if (current.length === 0) {
565
1002
  appendNodes(parent, value, marker);
566
- } else reconcileArrays(parent, current, value);
1003
+ } else reconcileArrays(parent, current, value, marker);
567
1004
  } else {
568
- current && cleanChildren(parent);
1005
+ current && cleanChildren(parent, current);
569
1006
  appendNodes(parent, value);
570
1007
  }
571
1008
  } else console.warn(`Unrecognized value. Skipped inserting`, value);
@@ -587,21 +1024,64 @@ function normalize(value, current, multi, doNotUnwrap) {
587
1024
  }
588
1025
  return value;
589
1026
  }
1027
+ function tagHost(value, host) {
1028
+ if (Array.isArray(value)) {
1029
+ for (let i = 0, len = value.length; i < len; i++) tagHost(value[i], host);
1030
+ } else if (value && value.nodeType && value[$$HOST] !== host) {
1031
+ value[$$HOST] = host;
1032
+ Object.defineProperty(value, "_$host", {
1033
+ get: host,
1034
+ configurable: true
1035
+ });
1036
+ }
1037
+ }
590
1038
  function appendNodes(parent, array, marker = null) {
591
- for (let i = 0, len = array.length; i < len; i++) parent.insertBefore(array[i], marker);
1039
+ for (let i = 0, len = array.length; i < len; i++) {
1040
+ const n = array[i];
1041
+ parent.insertBefore(n, marker);
1042
+ if (marker) n[$$SLOT] = marker;
1043
+ }
1044
+ }
1045
+ function ownsAllChildren(parent, current) {
1046
+ if (current == null) return true;
1047
+ if (Array.isArray(current)) {
1048
+ return current.length ? parent.firstChild === current[0] && parent.lastChild === current[current.length - 1] : parent.firstChild === null;
1049
+ }
1050
+ if (current === "") return parent.firstChild === null;
1051
+ if (current.nodeType) return parent.firstChild === current && parent.lastChild === current;
1052
+ const first = parent.firstChild;
1053
+ return first !== null && first.nodeType === 3 && parent.lastChild === first;
1054
+ }
1055
+ function removeOwnedChildren(parent, current) {
1056
+ if (Array.isArray(current)) {
1057
+ for (let i = 0; i < current.length; i++) {
1058
+ const el = current[i];
1059
+ if (el.parentNode === parent) el.remove();
1060
+ }
1061
+ } else if (current.nodeType) {
1062
+ if (current.parentNode === parent) current.remove();
1063
+ } else {
1064
+ const first = parent.firstChild;
1065
+ if (first && first.nodeType === 3) first.remove();
1066
+ }
592
1067
  }
593
1068
  function cleanChildren(parent, current, marker, replacement) {
594
- if (marker === undefined) return parent.textContent = "";
1069
+ if (marker === undefined) {
1070
+ if (ownsAllChildren(parent, current)) return parent.textContent = "";
1071
+ return removeOwnedChildren(parent, current);
1072
+ }
595
1073
  if (current.length) {
596
1074
  let inserted = false;
597
1075
  for (let i = current.length - 1; i >= 0; i--) {
598
1076
  const el = current[i];
599
1077
  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();
1078
+ const tag = el[$$SLOT];
1079
+ const owns = el.parentNode === parent && (!tag || tag === marker);
1080
+ if (replacement && !inserted && !i) owns ? parent.replaceChild(replacement, el) : parent.insertBefore(replacement, marker);else if (owns) el.remove();
602
1081
  } else inserted = true;
603
1082
  }
604
1083
  } else if (replacement) parent.insertBefore(replacement, marker);
1084
+ if (replacement && marker) replacement[$$SLOT] = marker;
605
1085
  }
606
1086
  function gatherHydratable(element, root) {
607
1087
  const templates = element.querySelectorAll(`*[_hk]`);
@@ -639,101 +1119,168 @@ function ssrHydrationKey() {}
639
1119
  function resolveSSRNode(node) {}
640
1120
  function escape(html) {}
641
1121
 
642
- function render(...args) {
643
- let unhandledAsync = false;
644
- {
645
- solidJs.setOnUnhandledAsync(() => {
646
- unhandledAsync = true;
647
- });
1122
+ const ENVELOPE = Symbol.for("solid.ResponseEnvelope");
1123
+ class ResponseEnvelope {
1124
+ constructor(response, value) {
1125
+ this.response = response;
1126
+ this.value = value;
648
1127
  }
649
- const result = render$1(...args);
650
- {
651
- solidJs.setOnUnhandledAsync(null);
652
- if (unhandledAsync) {
653
- const message = "Async content was used in JSX without a <Loading> boundary. " + "Wrap async content in <Loading> to show a fallback while loading.";
654
- result();
655
- const container = args[1];
656
- container.textContent = "";
657
- const msg = document.createElement("pre");
658
- msg.style.cssText = "color:#e53e3e;background:#fff5f5;border:2px solid #e53e3e;" + "border-radius:4px;padding:16px;margin:16px;font-family:monospace;" + "white-space:pre-wrap;word-break:break-word;";
659
- msg.textContent = message;
660
- container.appendChild(msg);
661
- console.error(message);
662
- return () => {};
663
- }
664
- }
665
- return result;
666
1128
  }
1129
+ ResponseEnvelope.prototype[ENVELOPE] = true;
1130
+ function isResponseEnvelope(value) {
1131
+ return !!(value && typeof value === "object" && value[ENVELOPE]);
1132
+ }
1133
+ function initWithRevalidate(init) {
1134
+ const {
1135
+ revalidate,
1136
+ ...responseInit
1137
+ } = init;
1138
+ const headers = new Headers(responseInit.headers);
1139
+ revalidate !== undefined && headers.set("X-Revalidate", revalidate.toString());
1140
+ return {
1141
+ responseInit,
1142
+ headers
1143
+ };
1144
+ }
1145
+ function redirect(url, init = 302) {
1146
+ const {
1147
+ responseInit,
1148
+ headers
1149
+ } = initWithRevalidate(typeof init === "number" ? {
1150
+ status: init
1151
+ } : init);
1152
+ if (responseInit.status === undefined) {
1153
+ responseInit.status = 302;
1154
+ }
1155
+ headers.set("Location", url);
1156
+ return new Response(null, {
1157
+ ...responseInit,
1158
+ headers
1159
+ });
1160
+ }
1161
+ function reload(init = {}) {
1162
+ const {
1163
+ responseInit,
1164
+ headers
1165
+ } = initWithRevalidate(init);
1166
+ return new Response(null, {
1167
+ ...responseInit,
1168
+ headers
1169
+ });
1170
+ }
1171
+ function respond(value, init = {}) {
1172
+ const {
1173
+ responseInit,
1174
+ headers
1175
+ } = initWithRevalidate(init);
1176
+ headers.set("Content-Type", "application/json");
1177
+ return new ResponseEnvelope(new Response(JSON.stringify(value), {
1178
+ ...responseInit,
1179
+ headers
1180
+ }), value);
1181
+ }
1182
+
1183
+ const mergeProps = solidJs.merge;
667
1184
  const isServer = false;
668
1185
  const isDev = true;
669
- const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
670
- function createElement(tagName, isSVG = false, is = undefined) {
671
- return isSVG ? document.createElementNS(SVG_NAMESPACE, tagName) : document.createElement(tagName, {
672
- is
673
- });
1186
+ function render(code, element, init, options = {}) {
1187
+ solidJs.enforceLoadingBoundary(true);
1188
+ try {
1189
+ const dispose = render$1(code, element, init, {
1190
+ ...options,
1191
+ insertOptions: {
1192
+ schedule: true
1193
+ }
1194
+ });
1195
+ solidJs.flush();
1196
+ return dispose;
1197
+ } finally {
1198
+ solidJs.enforceLoadingBoundary(false);
1199
+ }
674
1200
  }
675
1201
  const hydrate = (...args) => {
676
1202
  solidJs.enableHydration();
677
1203
  return hydrate$1(...args);
678
1204
  };
679
1205
  function Portal(props) {
1206
+ return solidJs.runWithOwner(solidJs.createOwner(), () => portalImpl(props));
1207
+ }
1208
+ function portalImpl(props) {
680
1209
  const treeMarker = document.createTextNode(""),
681
1210
  startMarker = document.createTextNode(""),
682
1211
  endMarker = document.createTextNode(""),
683
- mount = () => createElementProxy(props.mount || document.body, treeMarker);
684
- let content = solidJs.createMemo(() => [startMarker, props.children]);
685
- solidJs.createRenderEffect(() => [mount(), content()], ([m, c]) => {
1212
+ mount = () => props.mount || document.body,
1213
+ content = solidJs.createMemo(() => [startMarker, props.children], {
1214
+ ssrSource: "client"
1215
+ });
1216
+ solidJs.createRenderEffect(
1217
+ () => [mount(), content(), solidJs.getOwner()], ([, c, owner]) => {
1218
+ const m = solidJs.untrack(mount);
686
1219
  m.appendChild(endMarker);
687
- insert(m, c, endMarker);
1220
+ const dispose = solidJs.runWithOwner(owner, () => solidJs.createRoot(d => {
1221
+ insert(m, c, endMarker, undefined, {
1222
+ host: () => treeMarker.parentNode
1223
+ });
1224
+ return d;
1225
+ }));
688
1226
  return () => {
1227
+ dispose();
689
1228
  let c = startMarker;
690
- while (c && c !== endMarker) {
1229
+ while (c) {
691
1230
  const n = c.nextSibling;
692
1231
  m.removeChild(c);
1232
+ if (c === endMarker) break;
693
1233
  c = n;
694
1234
  }
695
1235
  };
1236
+ },
1237
+ {
1238
+ schedule: true,
1239
+ ssrSource: "client"
1240
+ });
1241
+ solidJs.createEffect(mount, () => {
1242
+ const m = solidJs.untrack(mount);
1243
+ const ownerRoot = getDelegatedRoot(treeMarker);
1244
+ if (!ownerRoot || ownerRoot.contains(m)) return;
1245
+ registerDelegatedContainer(m, ownerRoot);
1246
+ return () => unregisterDelegatedContainer(m, ownerRoot);
1247
+ }, {
1248
+ ssrSource: "client"
1249
+ });
1250
+ if (solidJs.sharedConfig.hydrating) return solidJs.createMemo(() => treeMarker, {
1251
+ ssrSource: "client"
696
1252
  });
697
1253
  return treeMarker;
698
1254
  }
699
- function createElementProxy(el, marker) {
700
- return new Proxy(el, {
701
- get(target, prop) {
702
- if (prop === "appendChild" || prop === "insertBefore") {
703
- return (...args) => {
704
- Object.defineProperty(args[0], "_$host", {
705
- get: () => marker.parentNode,
706
- configurable: true
1255
+ function dynamic(source) {
1256
+ const cached = solidJs.createMemo(source, {
1257
+ lazy: true
1258
+ });
1259
+ return props => {
1260
+ return solidJs.createMemo(() => {
1261
+ const component = cached();
1262
+ switch (typeof component) {
1263
+ case "function":
1264
+ Object.assign(component, {
1265
+ [solidJs.$DEVCOMP]: true
707
1266
  });
708
- target[prop](...args);
709
- };
1267
+ return solidJs.untrack(() => component(props));
1268
+ case "string":
1269
+ const el = solidJs.sharedConfig.hydrating ? getNextElement() : createElement(component, solidJs.untrack(() => props.is));
1270
+ spread(el, props);
1271
+ return el;
710
1272
  }
711
- const value = Reflect.get(target, prop);
712
- return typeof value === "function" ? value.bind(target) : value;
713
- }
714
- });
715
- }
716
- function createDynamic(component, props) {
717
- const cached = solidJs.createMemo(component);
718
- return solidJs.createMemo(() => {
719
- const component = cached();
720
- switch (typeof component) {
721
- case "function":
722
- Object.assign(component, {
723
- [solidJs.$DEVCOMP]: true
724
- });
725
- return solidJs.untrack(() => component(props));
726
- case "string":
727
- const isSvg = SVGElements.has(component);
728
- const el = solidJs.sharedConfig.hydrating ? getNextElement() : createElement(component, isSvg, solidJs.untrack(() => props.is));
729
- spread(el, props, isSvg);
730
- return el;
731
- }
732
- });
1273
+ });
1274
+ };
733
1275
  }
734
1276
  function Dynamic(props) {
735
- const others = solidJs.omit(props, "component");
736
- return createDynamic(() => props.component, others);
1277
+ const Comp = dynamic(() => props.component);
1278
+ return solidJs.createComponent(Comp, solidJs.omit(props, "component"));
1279
+ }
1280
+ function createElement(tagName, is = undefined) {
1281
+ return SVGElements.has(tagName) ? document.createElementNS(Namespaces.svg, tagName) : MathMLElements.has(tagName) ? document.createElementNS(Namespaces.mathml, tagName) : document.createElement(tagName, {
1282
+ is
1283
+ });
737
1284
  }
738
1285
 
739
1286
  Object.defineProperty(exports, "Errored", {
@@ -760,6 +1307,14 @@ Object.defineProperty(exports, "NoHydration", {
760
1307
  enumerable: true,
761
1308
  get: function () { return solidJs.NoHydration; }
762
1309
  });
1310
+ Object.defineProperty(exports, "Repeat", {
1311
+ enumerable: true,
1312
+ get: function () { return solidJs.Repeat; }
1313
+ });
1314
+ Object.defineProperty(exports, "Reveal", {
1315
+ enumerable: true,
1316
+ get: function () { return solidJs.Reveal; }
1317
+ });
763
1318
  Object.defineProperty(exports, "Show", {
764
1319
  enumerable: true,
765
1320
  get: function () { return solidJs.Show; }
@@ -776,10 +1331,6 @@ Object.defineProperty(exports, "getOwner", {
776
1331
  enumerable: true,
777
1332
  get: function () { return solidJs.getOwner; }
778
1333
  });
779
- Object.defineProperty(exports, "mergeProps", {
780
- enumerable: true,
781
- get: function () { return solidJs.merge; }
782
- });
783
1334
  Object.defineProperty(exports, "untrack", {
784
1335
  enumerable: true,
785
1336
  get: function () { return solidJs.untrack; }
@@ -787,26 +1338,31 @@ Object.defineProperty(exports, "untrack", {
787
1338
  exports.Assets = voidFn;
788
1339
  exports.ChildProperties = ChildProperties;
789
1340
  exports.DOMElements = DOMElements;
1341
+ exports.DOMWithState = DOMWithState;
790
1342
  exports.DelegatedEvents = DelegatedEvents;
791
1343
  exports.Dynamic = Dynamic;
792
1344
  exports.HydrationScript = voidFn;
1345
+ exports.MathMLElements = MathMLElements;
1346
+ exports.Namespaces = Namespaces;
793
1347
  exports.Portal = Portal;
794
- exports.Properties = Properties;
1348
+ exports.RawTextElements = RawTextElements;
795
1349
  exports.RequestContext = RequestContext;
1350
+ exports.ResponseEnvelope = ResponseEnvelope;
796
1351
  exports.SVGElements = SVGElements;
797
- exports.SVGNamespace = SVGNamespace;
798
- exports.addEventListener = addEventListener;
1352
+ exports.VoidElements = VoidElements;
1353
+ exports.acquireAsset = acquireAsset;
1354
+ exports.addEvent = addEvent;
799
1355
  exports.applyRef = applyRef;
800
1356
  exports.assign = assign;
801
1357
  exports.className = className;
802
- exports.clearDelegatedEvents = clearDelegatedEvents;
803
- exports.createDynamic = createDynamic;
804
1358
  exports.delegateEvents = delegateEvents;
1359
+ exports.dynamic = dynamic;
805
1360
  exports.dynamicProperty = dynamicProperty;
806
1361
  exports.effect = effect;
807
1362
  exports.escape = escape;
808
1363
  exports.generateHydrationScript = voidFn;
809
1364
  exports.getAssets = voidFn;
1365
+ exports.getDelegatedRoot = getDelegatedRoot;
810
1366
  exports.getFirstChild = getFirstChild;
811
1367
  exports.getHydrationKey = getHydrationKey;
812
1368
  exports.getNextElement = getNextElement;
@@ -816,16 +1372,25 @@ exports.getNextSibling = getNextSibling;
816
1372
  exports.getRequestEvent = voidFn;
817
1373
  exports.hydrate = hydrate;
818
1374
  exports.insert = insert;
1375
+ exports.installHydrationRuntime = installHydrationRuntime;
819
1376
  exports.isDev = isDev;
1377
+ exports.isResponseEnvelope = isResponseEnvelope;
820
1378
  exports.isServer = isServer;
821
1379
  exports.memo = memo;
1380
+ exports.mergeProps = mergeProps;
1381
+ exports.redirect = redirect;
822
1382
  exports.ref = ref;
1383
+ exports.registerDelegatedContainer = registerDelegatedContainer;
1384
+ exports.registerDelegatedRoot = registerDelegatedRoot;
1385
+ exports.reload = reload;
823
1386
  exports.render = render;
824
1387
  exports.renderToStream = renderToStream;
825
1388
  exports.renderToString = renderToString;
826
1389
  exports.renderToStringAsync = renderToStringAsync;
827
1390
  exports.resolveSSRNode = resolveSSRNode;
1391
+ exports.respond = respond;
828
1392
  exports.runHydrationEvents = runHydrationEvents;
1393
+ exports.scope = scope;
829
1394
  exports.setAttribute = setAttribute;
830
1395
  exports.setAttributeNS = setAttributeNS;
831
1396
  exports.setProperty = setProperty;
@@ -839,4 +1404,6 @@ exports.ssrHydrationKey = ssrHydrationKey;
839
1404
  exports.ssrStyle = ssrStyle;
840
1405
  exports.style = style;
841
1406
  exports.template = template;
1407
+ exports.unregisterDelegatedContainer = unregisterDelegatedContainer;
1408
+ exports.unregisterDelegatedRoot = unregisterDelegatedRoot;
842
1409
  exports.useAssets = voidFn;