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

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 +783 -223
  3. package/dist/dev.js +757 -217
  4. package/dist/server.cjs +742 -186
  5. package/dist/server.js +714 -183
  6. package/dist/web.cjs +772 -196
  7. package/dist/web.js +746 -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 +370 -0
  16. package/server-functions/dist/client.js +363 -0
  17. package/server-functions/dist/server.cjs +542 -0
  18. package/server-functions/dist/server.js +531 -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 +63 -0
  32. package/types/server-functions/server.d.ts +188 -0
  33. package/types/server-functions/shared.d.ts +171 -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 +63 -0
  45. package/types-cjs/server-functions/server.d.cts +188 -0
  46. package/types-cjs/server-functions/shared.d.cts +171 -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/web.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,53 +141,136 @@ 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
  let disposer;
90
- solidJs.createRoot(dispose => {
91
- disposer = dispose;
92
- element === document ? solidJs.flatten(code) : insert(element, code(), element.firstChild ? null : undefined, init);
93
- }, {
94
- id: options.renderId
95
- });
179
+ registerDelegatedRoot(element);
180
+ try {
181
+ solidJs.createRoot(dispose => {
182
+ disposer = dispose;
183
+ if (element === document) {
184
+ const tree = code();
185
+ effect(() => solidJs.flatten(tree), () => {});
186
+ } else {
187
+ const tree = code();
188
+ insert(element, () => tree, element.firstChild ? null : undefined, init, options.insertOptions);
189
+ }
190
+ }, {
191
+ id: options.renderId
192
+ });
193
+ } catch (err) {
194
+ if (disposer) disposer();
195
+ unregisterDelegatedRoot(element);
196
+ throw err;
197
+ }
96
198
  return () => {
97
199
  disposer();
200
+ unregisterDelegatedRoot(element);
98
201
  element.textContent = "";
99
202
  };
100
203
  }
101
- function template(html, isImportNode, isSVG, isMathML) {
204
+ function create(html, bypassGuard, flag) {
205
+ const t = document.createElement("template");
206
+ t.innerHTML = html;
207
+ return flag === 2 ? t.content.firstChild.firstChild : t.content.firstChild;
208
+ }
209
+ function template(html, flag) {
102
210
  let node;
103
- const create = bypassGuard => {
104
- const t = isMathML ? document.createElementNS("http://www.w3.org/1998/Math/MathML", "template") : document.createElement("template");
105
- t.innerHTML = html;
106
- return isSVG ? t.content.firstChild.firstChild : isMathML ? t.firstChild : t.content.firstChild;
107
- };
108
- const fn = isImportNode ? bypassGuard => solidJs.untrack(() => document.importNode(node || (node = create()), true)) : bypassGuard => (node || (node = create())).cloneNode(true);
211
+ const fn = flag === 1 ? bypassGuard => document.importNode(node || (node = create(html, bypassGuard, flag)), true) : bypassGuard => (node || (node = create(html, bypassGuard, flag))).cloneNode(true);
109
212
  return fn;
110
213
  }
111
- function delegateEvents(eventNames, document = window.document) {
112
- const e = document[$$EVENTS] || (document[$$EVENTS] = new Set());
214
+ function delegateEvents(eventNames) {
113
215
  for (let i = 0, l = eventNames.length; i < l; i++) {
114
216
  const name = eventNames[i];
115
- if (!e.has(name)) {
116
- e.add(name);
117
- document.addEventListener(name, eventHandler);
217
+ if (!delegatedEvents.has(name)) {
218
+ delegatedEvents.add(name);
219
+ delegatedContainers.forEach((state, container) => attachDelegatedEvent(name, container, state));
118
220
  }
119
221
  }
120
222
  }
121
- function clearDelegatedEvents(document = window.document) {
122
- if (document[$$EVENTS]) {
123
- for (let name of document[$$EVENTS].keys()) document.removeEventListener(name, eventHandler);
124
- delete document[$$EVENTS];
223
+ function registerDelegatedRoot(root) {
224
+ const state = registerDelegatedContainer(root, root);
225
+ if (state) state.roots = (state.roots || 0) + 1;
226
+ }
227
+ function unregisterDelegatedRoot(root) {
228
+ const state = delegatedContainers.get(root);
229
+ if (state) state.roots > 1 ? state.roots-- : delete state.roots;
230
+ unregisterDelegatedContainer(root, root);
231
+ }
232
+ function registerDelegatedContainer(container, owner = container) {
233
+ if (!container || !owner) return;
234
+ let state = delegatedContainers.get(container);
235
+ if (!state) delegatedContainers.set(container, state = {
236
+ owners: new Map(),
237
+ handlers: new Map()
238
+ });
239
+ state.owners.set(owner, (state.owners.get(owner) || 0) + 1);
240
+ delegatedEvents.forEach(name => attachDelegatedEvent(name, container, state));
241
+ return state;
242
+ }
243
+ function unregisterDelegatedContainer(container, owner = container) {
244
+ const state = delegatedContainers.get(container);
245
+ if (!state) return;
246
+ const count = state.owners.get(owner);
247
+ if (count > 1) state.owners.set(owner, count - 1);else state.owners.delete(owner);
248
+ if (state.owners.size) return;
249
+ state.handlers.forEach((handler, name) => container.removeEventListener(name, handler));
250
+ delegatedContainers.delete(container);
251
+ }
252
+ function attachDelegatedEvent(name, container, state) {
253
+ if (state.handlers.has(name)) return;
254
+ const handler = e => eventHandler(e, container, state);
255
+ state.handlers.set(name, handler);
256
+ container.addEventListener(name, handler);
257
+ }
258
+ function getDelegatedRoot(node) {
259
+ while (node) {
260
+ if (delegatedContainers.get(node)?.roots) return node;
261
+ node = node._$host || node.parentNode || node.host;
262
+ }
263
+ }
264
+ function findOwner(target, state) {
265
+ let node = target;
266
+ let distance = 0;
267
+ while (node) {
268
+ if (state.owners.has(node)) return {
269
+ owner: node,
270
+ distance
271
+ };
272
+ distance++;
273
+ node = node._$host || node.parentNode || node.host;
125
274
  }
126
275
  }
127
276
  function setProperty(node, name, value) {
@@ -134,16 +283,16 @@ function setAttribute(node, name, value) {
134
283
  }
135
284
  function setAttributeNS(node, namespace, name, value) {
136
285
  if (isHydrating(node)) return;
137
- if (value == null) node.removeAttributeNS(namespace, name);else node.setAttributeNS(namespace, name, value);
286
+ if (value == null || value === false) node.removeAttributeNS(namespace, name.indexOf(":") > -1 ? name.split(":").pop() : name);else node.setAttributeNS(namespace, name, value === true ? "" : value);
138
287
  }
139
- function className(node, value, isSVG, prev) {
288
+ function className(node, value, prev) {
140
289
  if (isHydrating(node)) return;
141
290
  if (value == null || value === false) {
142
291
  prev && node.removeAttribute("class");
143
292
  return;
144
293
  }
145
294
  if (typeof value === "string") {
146
- value !== prev && (isSVG ? node.setAttribute("class", value) : node.className = value);
295
+ value !== prev && node.setAttribute("class", value);
147
296
  return;
148
297
  }
149
298
  if (typeof prev === "string") {
@@ -157,16 +306,16 @@ function className(node, value, isSVG, prev) {
157
306
  for (i = 0, len = prevKeys.length; i < len; i++) {
158
307
  const key = prevKeys[i];
159
308
  if (!key || key === "undefined" || value[key]) continue;
160
- toggleClassKey(node, key, false);
309
+ node.classList.remove(key);
161
310
  }
162
311
  for (i = 0, len = classKeys.length; i < len; i++) {
163
312
  const key = classKeys[i],
164
313
  classValue = !!value[key];
165
314
  if (!key || key === "undefined" || prev[key] === classValue || !classValue) continue;
166
- toggleClassKey(node, key, true);
315
+ node.classList.add(key);
167
316
  }
168
317
  }
169
- function addEventListener(node, name, handler, delegate) {
318
+ function addEvent(node, name, handler, delegate) {
170
319
  if (delegate) {
171
320
  if (Array.isArray(handler)) {
172
321
  node[`$$${name}`] = handler[0];
@@ -179,33 +328,48 @@ function addEventListener(node, name, handler, delegate) {
179
328
  }
180
329
  function style(node, value, prev) {
181
330
  if (!value) {
182
- if (prev) setAttribute(node, "style");
331
+ if (prev || node._$styles) {
332
+ setAttribute(node, "style");
333
+ node._$styles = undefined;
334
+ }
183
335
  return;
184
336
  }
185
337
  const nodeStyle = node.style;
186
- if (typeof value === "string") return nodeStyle.cssText = value;
187
- typeof prev === "string" && (nodeStyle.cssText = prev = undefined);
188
- prev || (prev = {});
189
- value || (value = {});
338
+ if (typeof value === "string") {
339
+ node._$styles = undefined;
340
+ return nodeStyle.cssText = value;
341
+ }
342
+ if (typeof prev === "string") {
343
+ nodeStyle.cssText = "";
344
+ prev = undefined;
345
+ }
346
+ let applied = node._$styles;
347
+ if (!applied) {
348
+ applied = node._$styles = prev ? {
349
+ ...prev
350
+ } : {};
351
+ }
190
352
  let v, s;
353
+ for (s in applied) {
354
+ if (value[s] == null) {
355
+ nodeStyle.removeProperty(s);
356
+ delete applied[s];
357
+ }
358
+ }
191
359
  for (s in value) {
192
360
  v = value[s];
193
- if (v !== prev[s]) nodeStyle.setProperty(s, v);
194
- delete prev[s];
361
+ if (v != null && v !== applied[s]) {
362
+ nodeStyle.setProperty(s, v);
363
+ applied[s] = v;
364
+ }
195
365
  }
196
- for (s in prev) value[s] == null && nodeStyle.removeProperty(s);
197
366
  }
198
367
  function setStyleProperty(node, name, value) {
199
368
  value != null ? node.style.setProperty(name, value) : node.style.removeProperty(name);
200
369
  }
201
- function spread(node, props = {}, isSVG, skipChildren) {
370
+ function spread(node, props = {}, skipChildren) {
202
371
  const prevProps = {};
203
- if (!skipChildren) {
204
- effect(() => normalize(props.children, prevProps.children), value => {
205
- insertExpression(node, value, prevProps.children);
206
- prevProps.children = value;
207
- });
208
- }
372
+ if (!skipChildren) insert(node, () => props.children);
209
373
  effect(() => {
210
374
  const r = props.ref;
211
375
  (typeof r === "function" || Array.isArray(r)) && ref(() => r, node);
@@ -217,7 +381,7 @@ function spread(node, props = {}, isSVG, skipChildren) {
217
381
  newProps[prop] = props[prop];
218
382
  }
219
383
  return newProps;
220
- }, props => assign(node, props, isSVG, true, prevProps, true));
384
+ }, props => assign(node, props, true, prevProps, true));
221
385
  return prevProps;
222
386
  }
223
387
  function dynamicProperty(props, key) {
@@ -237,49 +401,235 @@ function ref(fn, element) {
237
401
  const resolved = solidJs.untrack(fn);
238
402
  solidJs.runWithOwner(null, () => applyRef(resolved, element));
239
403
  }
240
- function insert(parent, accessor, marker, initial) {
241
- const multi = marker !== undefined;
242
- if (multi && !initial) initial = [];
243
- if (isHydrating(parent)) {
244
- if (!multi && initial === undefined && parent) initial = [...parent.childNodes];
245
- if (Array.isArray(initial)) {
246
- let j = 0;
247
- for (let i = 0; i < initial.length; i++) {
248
- if (initial[i].nodeType === 8 && initial[i].nodeValue === "!$") initial[i].remove();else initial[j++] = initial[i];
404
+ function scope(fn) {
405
+ fn.$s = true;
406
+ return fn;
407
+ }
408
+ const SCOPE_OPTIONS = {
409
+ scope: true
410
+ };
411
+ let hydrationRt = null;
412
+ function installHydrationRuntime() {
413
+ hydrationRt = {
414
+ claimInitial(parent, multi, initial) {
415
+ if (isHydrating(parent)) {
416
+ if (!multi && initial === undefined && parent) initial = [...parent.childNodes];
417
+ if (Array.isArray(initial)) stripTextSeparators(initial);
249
418
  }
250
- initial.length = j;
419
+ return initial;
420
+ },
421
+ reclaimRegion(current, parent, marker) {
422
+ if (!solidJs.sharedConfig.hydrating || !current || !parent.isConnected) return current;
423
+ const first = Array.isArray(current) ? current[0] : current;
424
+ if (!first || !first.nodeType || first.isConnected) return current;
425
+ let nodes;
426
+ if (marker) {
427
+ nodes = [];
428
+ let node = marker.previousSibling,
429
+ depth = 0;
430
+ while (node) {
431
+ if (node.nodeType === 8) {
432
+ const v = node.nodeValue;
433
+ if (v === "/") depth++;else if (v === "$") {
434
+ if (depth === 0) break;
435
+ depth--;
436
+ }
437
+ }
438
+ nodes.unshift(node);
439
+ node = node.previousSibling;
440
+ }
441
+ } else nodes = [...parent.childNodes];
442
+ return stripTextSeparators(nodes);
443
+ },
444
+ dedupEvent(e) {
445
+ return !!(solidJs.sharedConfig.registry && solidJs.sharedConfig.events && solidJs.sharedConfig.events.find(([el, ev]) => ev === e));
251
446
  }
447
+ };
448
+ }
449
+ function stripTextSeparators(nodes) {
450
+ let j = 0;
451
+ for (let i = 0; i < nodes.length; i++) {
452
+ if (nodes[i].nodeType === 8 && nodes[i].nodeValue === "!$") nodes[i].remove();else nodes[j++] = nodes[i];
252
453
  }
454
+ nodes.length = j;
455
+ return nodes;
456
+ }
457
+ function insert(parent, accessor, marker, initial, options) {
458
+ const multi = marker !== undefined;
459
+ const host = options && options.host;
460
+ if (multi && !initial) initial = [];
461
+ if (hydrationRt !== null) initial = hydrationRt.claimInitial(parent, multi, initial);
253
462
  if (typeof accessor !== "function") {
254
463
  accessor = normalize(accessor, initial, multi, true);
255
- if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker);
464
+ if (typeof accessor !== "function") {
465
+ insertExpression(parent, accessor, initial, marker);
466
+ host && tagHost(accessor, host);
467
+ return;
468
+ }
256
469
  }
257
- accessor = memo(accessor, true);
258
- if (multi && initial.length === 0 && !isHydrating(parent)) {
470
+ if (multi && initial.length === 0) {
259
471
  const placeholder = document.createTextNode("");
260
472
  parent.insertBefore(placeholder, marker);
261
473
  initial = [placeholder];
262
474
  }
263
- effect(prev => normalize(accessor, prev, multi), (value, current) => insertExpression(parent, value, current, marker), initial);
475
+ let current = initial;
476
+ effect(prev => {
477
+ if (hydrationRt !== null) current = hydrationRt.reclaimRegion(current, parent, marker);
478
+ const value = normalize(accessor(), current, multi, true);
479
+ if (typeof value !== "function") return value;
480
+ effect(() => (hydrationRt !== null && (current = hydrationRt.reclaimRegion(current, parent, marker)), normalize(value, current, multi)), inner => {
481
+ insertExpression(parent, inner, current, marker);
482
+ current = inner;
483
+ host && tagHost(current, host);
484
+ }, prev !== undefined && !(options && options.schedule) ? {
485
+ ...options,
486
+ schedule: true
487
+ } : options);
488
+ return INNER_OWNED;
489
+ }, value => {
490
+ if (value === INNER_OWNED) return;
491
+ insertExpression(parent, value, current, marker);
492
+ current = value;
493
+ host && tagHost(current, host);
494
+ },
495
+ accessor.$s ? options ? {
496
+ ...options,
497
+ scope: true
498
+ } : SCOPE_OPTIONS : options);
264
499
  }
265
- function assign(node, props, isSVG, skipChildren, prevProps = {}, skipRef = false) {
500
+ function assign(node, props, skipChildren, prevProps = {}, skipRef = false) {
501
+ const nodeName = node.nodeName;
266
502
  props || (props = {});
267
503
  for (const prop in prevProps) {
268
504
  if (!(prop in props)) {
269
505
  if (prop === "children") continue;
270
- prevProps[prop] = assignProp(node, prop, null, prevProps[prop], isSVG, skipRef);
506
+ prevProps[prop] = assignProp(node, prop, null, prevProps[prop], skipRef, nodeName);
271
507
  }
272
508
  }
273
509
  for (const prop in props) {
274
510
  if (prop === "children") {
275
- if (!skipChildren) insertExpression(node, props.children);
511
+ if (!skipChildren) insertExpression(node, normalize(props.children, undefined, false));
276
512
  continue;
277
513
  }
278
- const value = props[prop];
279
- prevProps[prop] = assignProp(node, prop, value, prevProps[prop], isSVG, skipRef);
514
+ prevProps[prop] = assignProp(node, prop, props[prop], prevProps[prop], skipRef, nodeName);
515
+ }
516
+ }
517
+ const ASSET_REMOVAL_GRACE = 100;
518
+ const assetRegistry = new Map();
519
+ function assetEntryKey(descriptor) {
520
+ if (descriptor.policy === "exclusive") return "x|" + descriptor.key;
521
+ return descriptor.type === "inline-style" ? "i|" + descriptor.id : descriptor.type + "|" + descriptor.href;
522
+ }
523
+ function findAssetElement(selector, attr, value) {
524
+ const nodes = document.querySelectorAll(selector);
525
+ for (let i = 0; i < nodes.length; i++) {
526
+ if (nodes[i].getAttribute(attr) === value) return nodes[i];
527
+ }
528
+ return null;
529
+ }
530
+ function mountAssetElement(descriptor) {
531
+ let el;
532
+ if (descriptor.type === "inline-style") {
533
+ el = findAssetElement("style[data-asset]", "data-asset", descriptor.id);
534
+ if (!el) {
535
+ el = document.createElement("style");
536
+ el.setAttribute("data-asset", descriptor.id);
537
+ el.textContent = descriptor.content || "";
538
+ }
539
+ } else {
540
+ const rel = descriptor.type === "module" ? "modulepreload" : "stylesheet";
541
+ el = findAssetElement(`link[rel="${rel}"]`, "href", descriptor.href);
542
+ if (!el) {
543
+ el = document.createElement("link");
544
+ el.rel = rel;
545
+ el.href = descriptor.href;
546
+ }
547
+ }
548
+ if (descriptor.attrs) {
549
+ for (const name in descriptor.attrs) el.setAttribute(name, descriptor.attrs[name]);
550
+ }
551
+ if (!el.isConnected) document.head.appendChild(el);
552
+ return el;
553
+ }
554
+ function acquireAsset(descriptor) {
555
+ const key = assetEntryKey(descriptor);
556
+ let entry = assetRegistry.get(key);
557
+ if (descriptor.policy === "exclusive") {
558
+ if (!entry) {
559
+ entry = {
560
+ original: descriptor.get(),
561
+ set: descriptor.set,
562
+ writers: []
563
+ };
564
+ assetRegistry.set(key, entry);
565
+ }
566
+ const writer = {
567
+ value: descriptor.value
568
+ };
569
+ entry.writers.push(writer);
570
+ entry.set(writer.value);
571
+ let released = false;
572
+ return () => {
573
+ if (released) return;
574
+ released = true;
575
+ const index = entry.writers.indexOf(writer);
576
+ const wasTop = index === entry.writers.length - 1;
577
+ entry.writers.splice(index, 1);
578
+ if (!wasTop) return;
579
+ if (entry.writers.length) {
580
+ entry.set(entry.writers[entry.writers.length - 1].value);
581
+ } else {
582
+ entry.set(entry.original);
583
+ assetRegistry.delete(key);
584
+ }
585
+ };
586
+ }
587
+ if (!entry) {
588
+ entry = {
589
+ count: 0,
590
+ element: null,
591
+ timer: null
592
+ };
593
+ assetRegistry.set(key, entry);
594
+ }
595
+ if (entry.timer) {
596
+ clearTimeout(entry.timer);
597
+ entry.timer = null;
598
+ }
599
+ entry.count++;
600
+ if (!entry.element || !entry.element.isConnected) entry.element = mountAssetElement(descriptor);
601
+ let released = false;
602
+ return () => {
603
+ if (released) return;
604
+ released = true;
605
+ if (--entry.count > 0) return;
606
+ entry.timer = setTimeout(() => {
607
+ assetRegistry.delete(key);
608
+ entry.element && entry.element.remove();
609
+ }, ASSET_REMOVAL_GRACE);
610
+ };
611
+ }
612
+ function loadModuleAssets(mapping) {
613
+ const hy = globalThis._$HY;
614
+ if (!hy) return;
615
+ const pending = [];
616
+ for (const key in mapping) {
617
+ if (hy.modules[key]) continue;
618
+ const entryUrl = mapping[key];
619
+ if (!hy.loading[key]) {
620
+ hy.loading[key] = import(entryUrl).then(mod => {
621
+ hy.modules[key] = mod;
622
+ }, err => {
623
+ delete hy.loading[key];
624
+ throw err;
625
+ });
626
+ }
627
+ pending.push(hy.loading[key]);
280
628
  }
629
+ return pending.length ? Promise.all(pending).then(() => {}) : undefined;
281
630
  }
282
631
  function hydrate$1(code, element, options = {}) {
632
+ installHydrationRuntime();
283
633
  if (globalThis._$HY.done) return render$1(code, element, [...element.childNodes], options);
284
634
  options.renderId ||= "";
285
635
  if (!globalThis._$HY.modules) globalThis._$HY.modules = {};
@@ -289,6 +639,7 @@ function hydrate$1(code, element, options = {}) {
289
639
  solidJs.sharedConfig.load = id => globalThis._$HY.r[id];
290
640
  solidJs.sharedConfig.has = id => id in globalThis._$HY.r;
291
641
  solidJs.sharedConfig.gather = root => gatherHydratable(element, root);
642
+ solidJs.sharedConfig.loadModuleAssets = loadModuleAssets;
292
643
  solidJs.sharedConfig.cleanupFragment = id => {
293
644
  const tpl = document.getElementById("pl-" + id);
294
645
  if (tpl) {
@@ -307,6 +658,27 @@ function hydrate$1(code, element, options = {}) {
307
658
  };
308
659
  solidJs.sharedConfig.registry = new Map();
309
660
  solidJs.sharedConfig.hydrating = true;
661
+ const rootMapping = globalThis._$HY.r && globalThis._$HY.r["_assets"];
662
+ if (rootMapping && typeof rootMapping === "object") {
663
+ const p = loadModuleAssets(rootMapping);
664
+ if (p) {
665
+ gatherHydratable(element, options.renderId);
666
+ let disposer;
667
+ p.then(() => {
668
+ try {
669
+ disposer = render$1(code, element, [...element.childNodes], options);
670
+ } finally {
671
+ solidJs.sharedConfig.hydrating = false;
672
+ }
673
+ }, err => {
674
+ console.error("Hydration module preload failed, falling back to client render:", err);
675
+ solidJs.sharedConfig.hydrating = false;
676
+ solidJs.sharedConfig.registry = undefined;
677
+ disposer = render$1(code, element, [...element.childNodes], options);
678
+ });
679
+ return () => disposer && disposer();
680
+ }
681
+ }
310
682
  try {
311
683
  gatherHydratable(element, options.renderId);
312
684
  return render$1(code, element, [...element.childNodes], options);
@@ -372,7 +744,32 @@ function runHydrationEvents() {
372
744
  const [el, e] = events[0];
373
745
  if (!completed.has(el)) return;
374
746
  events.shift();
375
- eventHandler(e);
747
+ let matchContainer, matchState, matchDistance, matches;
748
+ for (const [container, state] of delegatedContainers) {
749
+ if (!state.handlers.has(e.type)) continue;
750
+ const entry = findOwner(e.target, state);
751
+ if (!entry) continue;
752
+ if (matchContainer) {
753
+ if (!matches) matches = [{
754
+ container: matchContainer,
755
+ state: matchState,
756
+ distance: matchDistance
757
+ }];
758
+ matches.push({
759
+ container,
760
+ state,
761
+ distance: entry.distance
762
+ });
763
+ } else {
764
+ matchContainer = container;
765
+ matchState = state;
766
+ matchDistance = entry.distance;
767
+ }
768
+ }
769
+ if (matches) {
770
+ matches.sort((a, b) => a.distance - b.distance);
771
+ for (let i = 0; i < matches.length; i++) eventHandler(e, matches[i].container, matches[i].state);
772
+ } else if (matchContainer) eventHandler(e, matchContainer, matchState);
376
773
  }
377
774
  if (solidJs.sharedConfig.done) {
378
775
  solidJs.sharedConfig.events = _$HY.events = null;
@@ -385,14 +782,21 @@ function runHydrationEvents() {
385
782
  function isHydrating(node) {
386
783
  return solidJs.sharedConfig.hydrating && (!node || node.isConnected);
387
784
  }
388
- function toggleClassKey(node, key, value) {
389
- const classNames = key.trim().split(/\s+/);
390
- for (let i = 0, nameLen = classNames.length; i < nameLen; i++) node.classList.toggle(classNames[i], value);
391
- }
392
785
  function classListToObject(classList) {
393
786
  if (Array.isArray(classList)) {
394
787
  const result = {};
395
788
  flattenClassList(classList, result);
789
+ classList = result;
790
+ }
791
+ if (classList && typeof classList === "object") {
792
+ const result = {},
793
+ keys = Object.keys(classList);
794
+ for (let i = 0, len = keys.length; i < len; i++) {
795
+ const key = keys[i];
796
+ if (!classList[key]) continue;
797
+ const classNames = key.trim().split(/\s+/);
798
+ for (let j = 0, nameLen = classNames.length; j < nameLen; j++) classNames[j] && (result[classNames[j]] = true);
799
+ }
396
800
  return result;
397
801
  }
398
802
  return classList;
@@ -403,18 +807,16 @@ function flattenClassList(list, result) {
403
807
  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;
404
808
  }
405
809
  }
406
- function assignProp(node, prop, value, prev, isSVG, skipRef) {
407
- let forceProp;
810
+ function assignProp(node, prop, value, prev, skipRef, nodeName) {
408
811
  if (prop === "style") return style(node, value, prev), value;
409
- if (prop === "class") return className(node, value, isSVG, prev), value;
410
- if (value === prev) return prev;
812
+ if (prop === "class") return className(node, value, prev), value;
813
+ if (value === prev && DOMWithState[nodeName]?.[prop] !== 1) return prev;
411
814
  if (prop === "ref") {
412
815
  if (!skipRef && value) ref(() => value, node);
413
- } else if (prop.slice(0, 3) === "on:") {
414
- const e = prop.slice(3);
415
- prev && node.removeEventListener(e, prev, typeof prev !== "function" && prev);
416
- value && node.addEventListener(e, value, typeof value !== "function" && value);
417
- } else if (prop.slice(0, 2) === "on") {
816
+ return value;
817
+ }
818
+ const hasNamespace = prop.indexOf(":") > -1;
819
+ if (!hasNamespace && prop.slice(0, 2) === "on") {
418
820
  const name = prop.slice(2).toLowerCase();
419
821
  const delegate = DelegatedEvents.has(name);
420
822
  if (!delegate && prev) {
@@ -422,26 +824,33 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
422
824
  node.removeEventListener(name, h);
423
825
  }
424
826
  if (delegate || value) {
425
- addEventListener(node, name, value, delegate);
827
+ addEvent(node, name, value, delegate);
426
828
  delegate && delegateEvents([name]);
427
829
  }
428
- } else if ((forceProp = prop.slice(0, 5) === "prop:") || ChildProperties.has(prop) || !isSVG && Properties.has(prop)) {
429
- if (forceProp) prop = prop.slice(5);else if (isHydrating(node)) return value;
430
- if (prop === "value" && node.nodeName === "SELECT") queueMicrotask(() => node.value = value) || (node.value = value);else node[prop] = value;
830
+ } else if (hasNamespace && prop.slice(0, 5) === "prop:" || ChildProperties.has(prop) || DOMWithState[nodeName]?.[prop]) {
831
+ if (hasNamespace) prop = prop.slice(5);else if (isHydrating(node)) return value;
832
+ if (prop === "value" && nodeName === "SELECT") queueMicrotask(() => node.value = value) || (node.value = value);else node[prop] = value;
431
833
  } else {
432
- const ns = isSVG && prop.indexOf(":") > -1 && SVGNamespace[prop.split(":")[0]];
834
+ const ns = hasNamespace && Namespaces[prop.split(":")[0]];
433
835
  if (ns) setAttributeNS(node, ns, prop, value);else setAttribute(node, prop, value);
434
836
  }
435
837
  return value;
436
838
  }
437
- function eventHandler(e) {
438
- if (solidJs.sharedConfig.registry && solidJs.sharedConfig.events) {
439
- if (solidJs.sharedConfig.events.find(([el, ev]) => ev === e)) return;
839
+ function eventHandler(e, container, state) {
840
+ if (hydrationRt !== null && hydrationRt.dedupEvent(e)) return;
841
+ const prev = e[$$EVENT_OWNER];
842
+ let resumeNode;
843
+ if (prev) {
844
+ if (prev === true || prev === container || !container.contains(prev)) return;
845
+ resumeNode = prev;
440
846
  }
441
- let node = e.target;
847
+ const owner = state && (state.owners.size === 1 && state.owners.has(container) ? container : findOwner(e.target, state)?.owner);
848
+ if (state && !owner) return;
849
+ e[$$EVENT_OWNER] = owner || true;
850
+ let node = resumeNode || e.target;
442
851
  const key = `$$${e.type}`;
443
852
  const oriTarget = e.target;
444
- const oriCurrentTarget = e.currentTarget;
853
+ const boundary = owner || container || e.currentTarget;
445
854
  const retarget = value => Object.defineProperty(e, "target", {
446
855
  configurable: true,
447
856
  value
@@ -457,35 +866,43 @@ function eventHandler(e) {
457
866
  return true;
458
867
  };
459
868
  const walkUpTree = () => {
460
- while (handleNode() && (node = node._$host || node.parentNode || node.host));
869
+ while (handleNode()) {
870
+ if (node === boundary || node.parentNode === boundary) break;
871
+ node = node._$host || node.parentNode || node.host;
872
+ }
461
873
  };
462
874
  Object.defineProperty(e, "currentTarget", {
463
875
  configurable: true,
464
876
  get() {
465
- return node || document;
877
+ return node || boundary || document;
466
878
  }
467
879
  });
468
- if (e.composedPath) {
880
+ if (resumeNode) {
881
+ if (resumeNode === e.target) node = resumeNode._$host || resumeNode.parentNode || resumeNode.host;
882
+ if (node && node !== boundary) walkUpTree();
883
+ } else if (e.composedPath) {
469
884
  const path = e.composedPath();
470
- retarget(path[0]);
471
- for (let i = 0; i < path.length - 2; i++) {
472
- node = path[i];
473
- if (!handleNode()) break;
474
- if (node._$host) {
475
- node = node._$host;
476
- walkUpTree();
477
- break;
478
- }
479
- if (node.parentNode === oriCurrentTarget) {
480
- break;
885
+ if (path.length) {
886
+ retarget(path[0]);
887
+ for (let i = 0; i < path.length; i++) {
888
+ node = path[i];
889
+ if (!handleNode()) break;
890
+ if (node._$host) {
891
+ node = node._$host;
892
+ walkUpTree();
893
+ break;
894
+ }
895
+ if (node === boundary || node.parentNode === boundary) {
896
+ break;
897
+ }
481
898
  }
482
- }
899
+ } else walkUpTree();
483
900
  }
484
901
  else walkUpTree();
485
902
  retarget(oriTarget);
486
903
  }
487
904
  function insertExpression(parent, value, current, marker) {
488
- if (isHydrating(parent)) return;
905
+ if (hydrationRt !== null && isHydrating(parent)) return;
489
906
  if (value === current) return;
490
907
  const t = typeof value,
491
908
  multi = marker !== undefined;
@@ -493,15 +910,25 @@ function insertExpression(parent, value, current, marker) {
493
910
  const tc = typeof current;
494
911
  if (tc === "string" || tc === "number") {
495
912
  parent.firstChild.data = value;
496
- } else parent.textContent = value;
913
+ } else {
914
+ if (ownsAllChildren(parent, current)) parent.textContent = value;else {
915
+ removeOwnedChildren(parent, current);
916
+ parent.insertBefore(document.createTextNode(value), parent.firstChild);
917
+ }
918
+ }
497
919
  } else if (value === undefined) {
498
920
  cleanChildren(parent, current, marker);
499
921
  } else if (value.nodeType) {
500
922
  if (Array.isArray(current)) {
501
923
  cleanChildren(parent, current, multi ? marker : null, value);
502
- } else if (current === undefined || !parent.firstChild) {
924
+ } else if (current && current.nodeType) {
925
+ current.parentNode === parent ? parent.replaceChild(value, current) : parent.appendChild(value);
926
+ } else if (current && parent.firstChild) {
927
+ parent.replaceChild(value, parent.firstChild);
928
+ } else {
503
929
  parent.appendChild(value);
504
- } else parent.replaceChild(value, parent.firstChild);
930
+ }
931
+ if (marker) value[$$SLOT] = marker;
505
932
  } else if (Array.isArray(value)) {
506
933
  const currentArray = current && Array.isArray(current);
507
934
  if (value.length === 0) {
@@ -509,9 +936,9 @@ function insertExpression(parent, value, current, marker) {
509
936
  } else if (currentArray) {
510
937
  if (current.length === 0) {
511
938
  appendNodes(parent, value, marker);
512
- } else reconcileArrays(parent, current, value);
939
+ } else reconcileArrays(parent, current, value, marker);
513
940
  } else {
514
- current && cleanChildren(parent);
941
+ current && cleanChildren(parent, current);
515
942
  appendNodes(parent, value);
516
943
  }
517
944
  } else ;
@@ -533,21 +960,64 @@ function normalize(value, current, multi, doNotUnwrap) {
533
960
  }
534
961
  return value;
535
962
  }
963
+ function tagHost(value, host) {
964
+ if (Array.isArray(value)) {
965
+ for (let i = 0, len = value.length; i < len; i++) tagHost(value[i], host);
966
+ } else if (value && value.nodeType && value[$$HOST] !== host) {
967
+ value[$$HOST] = host;
968
+ Object.defineProperty(value, "_$host", {
969
+ get: host,
970
+ configurable: true
971
+ });
972
+ }
973
+ }
536
974
  function appendNodes(parent, array, marker = null) {
537
- for (let i = 0, len = array.length; i < len; i++) parent.insertBefore(array[i], marker);
975
+ for (let i = 0, len = array.length; i < len; i++) {
976
+ const n = array[i];
977
+ parent.insertBefore(n, marker);
978
+ if (marker) n[$$SLOT] = marker;
979
+ }
980
+ }
981
+ function ownsAllChildren(parent, current) {
982
+ if (current == null) return true;
983
+ if (Array.isArray(current)) {
984
+ return current.length ? parent.firstChild === current[0] && parent.lastChild === current[current.length - 1] : parent.firstChild === null;
985
+ }
986
+ if (current === "") return parent.firstChild === null;
987
+ if (current.nodeType) return parent.firstChild === current && parent.lastChild === current;
988
+ const first = parent.firstChild;
989
+ return first !== null && first.nodeType === 3 && parent.lastChild === first;
990
+ }
991
+ function removeOwnedChildren(parent, current) {
992
+ if (Array.isArray(current)) {
993
+ for (let i = 0; i < current.length; i++) {
994
+ const el = current[i];
995
+ if (el.parentNode === parent) el.remove();
996
+ }
997
+ } else if (current.nodeType) {
998
+ if (current.parentNode === parent) current.remove();
999
+ } else {
1000
+ const first = parent.firstChild;
1001
+ if (first && first.nodeType === 3) first.remove();
1002
+ }
538
1003
  }
539
1004
  function cleanChildren(parent, current, marker, replacement) {
540
- if (marker === undefined) return parent.textContent = "";
1005
+ if (marker === undefined) {
1006
+ if (ownsAllChildren(parent, current)) return parent.textContent = "";
1007
+ return removeOwnedChildren(parent, current);
1008
+ }
541
1009
  if (current.length) {
542
1010
  let inserted = false;
543
1011
  for (let i = current.length - 1; i >= 0; i--) {
544
1012
  const el = current[i];
545
1013
  if (replacement !== el) {
546
- const isParent = el.parentNode === parent;
547
- if (replacement && !inserted && !i) isParent ? parent.replaceChild(replacement, el) : parent.insertBefore(replacement, marker);else isParent && el.remove();
1014
+ const tag = el[$$SLOT];
1015
+ const owns = el.parentNode === parent && (!tag || tag === marker);
1016
+ if (replacement && !inserted && !i) owns ? parent.replaceChild(replacement, el) : parent.insertBefore(replacement, marker);else if (owns) el.remove();
548
1017
  } else inserted = true;
549
1018
  }
550
1019
  } else if (replacement) parent.insertBefore(replacement, marker);
1020
+ if (replacement && marker) replacement[$$SLOT] = marker;
551
1021
  }
552
1022
  function gatherHydratable(element, root) {
553
1023
  const templates = element.querySelectorAll(`*[_hk]`);
@@ -585,77 +1055,163 @@ function ssrHydrationKey() {}
585
1055
  function resolveSSRNode(node) {}
586
1056
  function escape(html) {}
587
1057
 
588
- function render(...args) {
589
- const result = render$1(...args);
590
- return result;
1058
+ const ENVELOPE = Symbol.for("solid.ResponseEnvelope");
1059
+ class ResponseEnvelope {
1060
+ constructor(response, value) {
1061
+ this.response = response;
1062
+ this.value = value;
1063
+ }
1064
+ }
1065
+ ResponseEnvelope.prototype[ENVELOPE] = true;
1066
+ function isResponseEnvelope(value) {
1067
+ return !!(value && typeof value === "object" && value[ENVELOPE]);
591
1068
  }
1069
+ function initWithRevalidate(init) {
1070
+ const {
1071
+ revalidate,
1072
+ ...responseInit
1073
+ } = init;
1074
+ const headers = new Headers(responseInit.headers);
1075
+ revalidate !== undefined && headers.set("X-Revalidate", revalidate.toString());
1076
+ return {
1077
+ responseInit,
1078
+ headers
1079
+ };
1080
+ }
1081
+ function redirect(url, init = 302) {
1082
+ const {
1083
+ responseInit,
1084
+ headers
1085
+ } = initWithRevalidate(typeof init === "number" ? {
1086
+ status: init
1087
+ } : init);
1088
+ if (responseInit.status === undefined) {
1089
+ responseInit.status = 302;
1090
+ }
1091
+ headers.set("Location", url);
1092
+ return new Response(null, {
1093
+ ...responseInit,
1094
+ headers
1095
+ });
1096
+ }
1097
+ function reload(init = {}) {
1098
+ const {
1099
+ responseInit,
1100
+ headers
1101
+ } = initWithRevalidate(init);
1102
+ return new Response(null, {
1103
+ ...responseInit,
1104
+ headers
1105
+ });
1106
+ }
1107
+ function respond(value, init = {}) {
1108
+ const {
1109
+ responseInit,
1110
+ headers
1111
+ } = initWithRevalidate(init);
1112
+ headers.set("Content-Type", "application/json");
1113
+ return new ResponseEnvelope(new Response(JSON.stringify(value), {
1114
+ ...responseInit,
1115
+ headers
1116
+ }), value);
1117
+ }
1118
+
1119
+ const mergeProps = solidJs.merge;
592
1120
  const isServer = false;
593
1121
  const isDev = false;
594
- const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
595
- function createElement(tagName, isSVG = false, is = undefined) {
596
- return isSVG ? document.createElementNS(SVG_NAMESPACE, tagName) : document.createElement(tagName, {
597
- is
598
- });
1122
+ function render(code, element, init, options = {}) {
1123
+ try {
1124
+ const dispose = render$1(code, element, init, {
1125
+ ...options,
1126
+ insertOptions: {
1127
+ schedule: true
1128
+ }
1129
+ });
1130
+ solidJs.flush();
1131
+ return dispose;
1132
+ } finally {
1133
+ }
599
1134
  }
600
1135
  const hydrate = (...args) => {
601
1136
  solidJs.enableHydration();
602
1137
  return hydrate$1(...args);
603
1138
  };
604
1139
  function Portal(props) {
1140
+ return solidJs.runWithOwner(solidJs.createOwner(), () => portalImpl(props));
1141
+ }
1142
+ function portalImpl(props) {
605
1143
  const treeMarker = document.createTextNode(""),
606
1144
  startMarker = document.createTextNode(""),
607
1145
  endMarker = document.createTextNode(""),
608
- mount = () => createElementProxy(props.mount || document.body, treeMarker);
609
- let content = solidJs.createMemo(() => [startMarker, props.children]);
610
- solidJs.createRenderEffect(() => [mount(), content()], ([m, c]) => {
1146
+ mount = () => props.mount || document.body,
1147
+ content = solidJs.createMemo(() => [startMarker, props.children], {
1148
+ ssrSource: "client"
1149
+ });
1150
+ solidJs.createRenderEffect(
1151
+ () => [mount(), content(), solidJs.getOwner()], ([, c, owner]) => {
1152
+ const m = solidJs.untrack(mount);
611
1153
  m.appendChild(endMarker);
612
- insert(m, c, endMarker);
1154
+ const dispose = solidJs.runWithOwner(owner, () => solidJs.createRoot(d => {
1155
+ insert(m, c, endMarker, undefined, {
1156
+ host: () => treeMarker.parentNode
1157
+ });
1158
+ return d;
1159
+ }));
613
1160
  return () => {
1161
+ dispose();
614
1162
  let c = startMarker;
615
- while (c && c !== endMarker) {
1163
+ while (c) {
616
1164
  const n = c.nextSibling;
617
1165
  m.removeChild(c);
1166
+ if (c === endMarker) break;
618
1167
  c = n;
619
1168
  }
620
1169
  };
1170
+ },
1171
+ {
1172
+ schedule: true,
1173
+ ssrSource: "client"
621
1174
  });
622
- return treeMarker;
623
- }
624
- function createElementProxy(el, marker) {
625
- return new Proxy(el, {
626
- get(target, prop) {
627
- if (prop === "appendChild" || prop === "insertBefore") {
628
- return (...args) => {
629
- Object.defineProperty(args[0], "_$host", {
630
- get: () => marker.parentNode,
631
- configurable: true
632
- });
633
- target[prop](...args);
634
- };
635
- }
636
- const value = Reflect.get(target, prop);
637
- return typeof value === "function" ? value.bind(target) : value;
638
- }
1175
+ solidJs.createEffect(mount, () => {
1176
+ const m = solidJs.untrack(mount);
1177
+ const ownerRoot = getDelegatedRoot(treeMarker);
1178
+ if (!ownerRoot || ownerRoot.contains(m)) return;
1179
+ registerDelegatedContainer(m, ownerRoot);
1180
+ return () => unregisterDelegatedContainer(m, ownerRoot);
1181
+ }, {
1182
+ ssrSource: "client"
1183
+ });
1184
+ if (solidJs.sharedConfig.hydrating) return solidJs.createMemo(() => treeMarker, {
1185
+ ssrSource: "client"
639
1186
  });
1187
+ return treeMarker;
640
1188
  }
641
- function createDynamic(component, props) {
642
- const cached = solidJs.createMemo(component);
643
- return solidJs.createMemo(() => {
644
- const component = cached();
645
- switch (typeof component) {
646
- case "function":
647
- return solidJs.untrack(() => component(props));
648
- case "string":
649
- const isSvg = SVGElements.has(component);
650
- const el = solidJs.sharedConfig.hydrating ? getNextElement() : createElement(component, isSvg, solidJs.untrack(() => props.is));
651
- spread(el, props, isSvg);
652
- return el;
653
- }
1189
+ function dynamic(source) {
1190
+ const cached = solidJs.createMemo(source, {
1191
+ lazy: true
654
1192
  });
1193
+ return props => {
1194
+ return solidJs.createMemo(() => {
1195
+ const component = cached();
1196
+ switch (typeof component) {
1197
+ case "function":
1198
+ return solidJs.untrack(() => component(props));
1199
+ case "string":
1200
+ const el = solidJs.sharedConfig.hydrating ? getNextElement() : createElement(component, solidJs.untrack(() => props.is));
1201
+ spread(el, props);
1202
+ return el;
1203
+ }
1204
+ });
1205
+ };
655
1206
  }
656
1207
  function Dynamic(props) {
657
- const others = solidJs.omit(props, "component");
658
- return createDynamic(() => props.component, others);
1208
+ const Comp = dynamic(() => props.component);
1209
+ return solidJs.createComponent(Comp, solidJs.omit(props, "component"));
1210
+ }
1211
+ function createElement(tagName, is = undefined) {
1212
+ return SVGElements.has(tagName) ? document.createElementNS(Namespaces.svg, tagName) : MathMLElements.has(tagName) ? document.createElementNS(Namespaces.mathml, tagName) : document.createElement(tagName, {
1213
+ is
1214
+ });
659
1215
  }
660
1216
 
661
1217
  Object.defineProperty(exports, "Errored", {
@@ -682,6 +1238,14 @@ Object.defineProperty(exports, "NoHydration", {
682
1238
  enumerable: true,
683
1239
  get: function () { return solidJs.NoHydration; }
684
1240
  });
1241
+ Object.defineProperty(exports, "Repeat", {
1242
+ enumerable: true,
1243
+ get: function () { return solidJs.Repeat; }
1244
+ });
1245
+ Object.defineProperty(exports, "Reveal", {
1246
+ enumerable: true,
1247
+ get: function () { return solidJs.Reveal; }
1248
+ });
685
1249
  Object.defineProperty(exports, "Show", {
686
1250
  enumerable: true,
687
1251
  get: function () { return solidJs.Show; }
@@ -698,10 +1262,6 @@ Object.defineProperty(exports, "getOwner", {
698
1262
  enumerable: true,
699
1263
  get: function () { return solidJs.getOwner; }
700
1264
  });
701
- Object.defineProperty(exports, "mergeProps", {
702
- enumerable: true,
703
- get: function () { return solidJs.merge; }
704
- });
705
1265
  Object.defineProperty(exports, "untrack", {
706
1266
  enumerable: true,
707
1267
  get: function () { return solidJs.untrack; }
@@ -709,26 +1269,31 @@ Object.defineProperty(exports, "untrack", {
709
1269
  exports.Assets = voidFn;
710
1270
  exports.ChildProperties = ChildProperties;
711
1271
  exports.DOMElements = DOMElements;
1272
+ exports.DOMWithState = DOMWithState;
712
1273
  exports.DelegatedEvents = DelegatedEvents;
713
1274
  exports.Dynamic = Dynamic;
714
1275
  exports.HydrationScript = voidFn;
1276
+ exports.MathMLElements = MathMLElements;
1277
+ exports.Namespaces = Namespaces;
715
1278
  exports.Portal = Portal;
716
- exports.Properties = Properties;
1279
+ exports.RawTextElements = RawTextElements;
717
1280
  exports.RequestContext = RequestContext;
1281
+ exports.ResponseEnvelope = ResponseEnvelope;
718
1282
  exports.SVGElements = SVGElements;
719
- exports.SVGNamespace = SVGNamespace;
720
- exports.addEventListener = addEventListener;
1283
+ exports.VoidElements = VoidElements;
1284
+ exports.acquireAsset = acquireAsset;
1285
+ exports.addEvent = addEvent;
721
1286
  exports.applyRef = applyRef;
722
1287
  exports.assign = assign;
723
1288
  exports.className = className;
724
- exports.clearDelegatedEvents = clearDelegatedEvents;
725
- exports.createDynamic = createDynamic;
726
1289
  exports.delegateEvents = delegateEvents;
1290
+ exports.dynamic = dynamic;
727
1291
  exports.dynamicProperty = dynamicProperty;
728
1292
  exports.effect = effect;
729
1293
  exports.escape = escape;
730
1294
  exports.generateHydrationScript = voidFn;
731
1295
  exports.getAssets = voidFn;
1296
+ exports.getDelegatedRoot = getDelegatedRoot;
732
1297
  exports.getFirstChild = getFirstChild;
733
1298
  exports.getHydrationKey = getHydrationKey;
734
1299
  exports.getNextElement = getNextElement;
@@ -738,16 +1303,25 @@ exports.getNextSibling = getNextSibling;
738
1303
  exports.getRequestEvent = voidFn;
739
1304
  exports.hydrate = hydrate;
740
1305
  exports.insert = insert;
1306
+ exports.installHydrationRuntime = installHydrationRuntime;
741
1307
  exports.isDev = isDev;
1308
+ exports.isResponseEnvelope = isResponseEnvelope;
742
1309
  exports.isServer = isServer;
743
1310
  exports.memo = memo;
1311
+ exports.mergeProps = mergeProps;
1312
+ exports.redirect = redirect;
744
1313
  exports.ref = ref;
1314
+ exports.registerDelegatedContainer = registerDelegatedContainer;
1315
+ exports.registerDelegatedRoot = registerDelegatedRoot;
1316
+ exports.reload = reload;
745
1317
  exports.render = render;
746
1318
  exports.renderToStream = renderToStream;
747
1319
  exports.renderToString = renderToString;
748
1320
  exports.renderToStringAsync = renderToStringAsync;
749
1321
  exports.resolveSSRNode = resolveSSRNode;
1322
+ exports.respond = respond;
750
1323
  exports.runHydrationEvents = runHydrationEvents;
1324
+ exports.scope = scope;
751
1325
  exports.setAttribute = setAttribute;
752
1326
  exports.setAttributeNS = setAttributeNS;
753
1327
  exports.setProperty = setProperty;
@@ -761,4 +1335,6 @@ exports.ssrHydrationKey = ssrHydrationKey;
761
1335
  exports.ssrStyle = ssrStyle;
762
1336
  exports.style = style;
763
1337
  exports.template = template;
1338
+ exports.unregisterDelegatedContainer = unregisterDelegatedContainer;
1339
+ exports.unregisterDelegatedRoot = unregisterDelegatedRoot;
764
1340
  exports.useAssets = voidFn;