@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/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) {
@@ -306,7 +657,35 @@ function hydrate$1(code, element, options = {}) {
306
657
  }
307
658
  };
308
659
  solidJs.sharedConfig.registry = new Map();
660
+ if (!solidJs.sharedConfig.boundaryScopes) solidJs.sharedConfig.boundaryScopes = new Map();
661
+ solidJs.sharedConfig.captureBoundaryScope = id => {
662
+ if (solidJs.sharedConfig.registry) solidJs.sharedConfig.boundaryScopes.set(id, {
663
+ registry: solidJs.sharedConfig.registry,
664
+ gather: solidJs.sharedConfig.gather
665
+ });
666
+ };
309
667
  solidJs.sharedConfig.hydrating = true;
668
+ const rootMapping = globalThis._$HY.r && globalThis._$HY.r["_assets"];
669
+ if (rootMapping && typeof rootMapping === "object") {
670
+ const p = loadModuleAssets(rootMapping);
671
+ if (p) {
672
+ gatherHydratable(element, options.renderId);
673
+ let disposer;
674
+ p.then(() => {
675
+ try {
676
+ disposer = render$1(code, element, [...element.childNodes], options);
677
+ } finally {
678
+ solidJs.sharedConfig.hydrating = false;
679
+ }
680
+ }, err => {
681
+ console.error("Hydration module preload failed, falling back to client render:", err);
682
+ solidJs.sharedConfig.hydrating = false;
683
+ solidJs.sharedConfig.registry = undefined;
684
+ disposer = render$1(code, element, [...element.childNodes], options);
685
+ });
686
+ return () => disposer && disposer();
687
+ }
688
+ }
310
689
  try {
311
690
  gatherHydratable(element, options.renderId);
312
691
  return render$1(code, element, [...element.childNodes], options);
@@ -372,7 +751,32 @@ function runHydrationEvents() {
372
751
  const [el, e] = events[0];
373
752
  if (!completed.has(el)) return;
374
753
  events.shift();
375
- eventHandler(e);
754
+ let matchContainer, matchState, matchDistance, matches;
755
+ for (const [container, state] of delegatedContainers) {
756
+ if (!state.handlers.has(e.type)) continue;
757
+ const entry = findOwner(e.target, state);
758
+ if (!entry) continue;
759
+ if (matchContainer) {
760
+ if (!matches) matches = [{
761
+ container: matchContainer,
762
+ state: matchState,
763
+ distance: matchDistance
764
+ }];
765
+ matches.push({
766
+ container,
767
+ state,
768
+ distance: entry.distance
769
+ });
770
+ } else {
771
+ matchContainer = container;
772
+ matchState = state;
773
+ matchDistance = entry.distance;
774
+ }
775
+ }
776
+ if (matches) {
777
+ matches.sort((a, b) => a.distance - b.distance);
778
+ for (let i = 0; i < matches.length; i++) eventHandler(e, matches[i].container, matches[i].state);
779
+ } else if (matchContainer) eventHandler(e, matchContainer, matchState);
376
780
  }
377
781
  if (solidJs.sharedConfig.done) {
378
782
  solidJs.sharedConfig.events = _$HY.events = null;
@@ -385,14 +789,21 @@ function runHydrationEvents() {
385
789
  function isHydrating(node) {
386
790
  return solidJs.sharedConfig.hydrating && (!node || node.isConnected);
387
791
  }
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
792
  function classListToObject(classList) {
393
793
  if (Array.isArray(classList)) {
394
794
  const result = {};
395
795
  flattenClassList(classList, result);
796
+ classList = result;
797
+ }
798
+ if (classList && typeof classList === "object") {
799
+ const result = {},
800
+ keys = Object.keys(classList);
801
+ for (let i = 0, len = keys.length; i < len; i++) {
802
+ const key = keys[i];
803
+ if (!classList[key]) continue;
804
+ const classNames = key.trim().split(/\s+/);
805
+ for (let j = 0, nameLen = classNames.length; j < nameLen; j++) classNames[j] && (result[classNames[j]] = true);
806
+ }
396
807
  return result;
397
808
  }
398
809
  return classList;
@@ -403,18 +814,16 @@ function flattenClassList(list, result) {
403
814
  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
815
  }
405
816
  }
406
- function assignProp(node, prop, value, prev, isSVG, skipRef) {
407
- let forceProp;
817
+ function assignProp(node, prop, value, prev, skipRef, nodeName) {
408
818
  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;
819
+ if (prop === "class") return className(node, value, prev), value;
820
+ if (value === prev && DOMWithState[nodeName]?.[prop] !== 1) return prev;
411
821
  if (prop === "ref") {
412
822
  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") {
823
+ return value;
824
+ }
825
+ const hasNamespace = prop.indexOf(":") > -1;
826
+ if (!hasNamespace && prop.slice(0, 2) === "on") {
418
827
  const name = prop.slice(2).toLowerCase();
419
828
  const delegate = DelegatedEvents.has(name);
420
829
  if (!delegate && prev) {
@@ -422,26 +831,33 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
422
831
  node.removeEventListener(name, h);
423
832
  }
424
833
  if (delegate || value) {
425
- addEventListener(node, name, value, delegate);
834
+ addEvent(node, name, value, delegate);
426
835
  delegate && delegateEvents([name]);
427
836
  }
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;
837
+ } else if (hasNamespace && prop.slice(0, 5) === "prop:" || ChildProperties.has(prop) || DOMWithState[nodeName]?.[prop]) {
838
+ if (hasNamespace) prop = prop.slice(5);else if (isHydrating(node)) return value;
839
+ if (prop === "value" && nodeName === "SELECT") queueMicrotask(() => node.value = value) || (node.value = value);else node[prop] = value;
431
840
  } else {
432
- const ns = isSVG && prop.indexOf(":") > -1 && SVGNamespace[prop.split(":")[0]];
841
+ const ns = hasNamespace && Namespaces[prop.split(":")[0]];
433
842
  if (ns) setAttributeNS(node, ns, prop, value);else setAttribute(node, prop, value);
434
843
  }
435
844
  return value;
436
845
  }
437
- function eventHandler(e) {
438
- if (solidJs.sharedConfig.registry && solidJs.sharedConfig.events) {
439
- if (solidJs.sharedConfig.events.find(([el, ev]) => ev === e)) return;
846
+ function eventHandler(e, container, state) {
847
+ if (hydrationRt !== null && hydrationRt.dedupEvent(e)) return;
848
+ const prev = e[$$EVENT_OWNER];
849
+ let resumeNode;
850
+ if (prev) {
851
+ if (prev === true || prev === container || !container.contains(prev)) return;
852
+ resumeNode = prev;
440
853
  }
441
- let node = e.target;
854
+ const owner = state && (state.owners.size === 1 && state.owners.has(container) ? container : findOwner(e.target, state)?.owner);
855
+ if (state && !owner) return;
856
+ e[$$EVENT_OWNER] = owner || true;
857
+ let node = resumeNode || e.target;
442
858
  const key = `$$${e.type}`;
443
859
  const oriTarget = e.target;
444
- const oriCurrentTarget = e.currentTarget;
860
+ const boundary = owner || container || e.currentTarget;
445
861
  const retarget = value => Object.defineProperty(e, "target", {
446
862
  configurable: true,
447
863
  value
@@ -457,35 +873,43 @@ function eventHandler(e) {
457
873
  return true;
458
874
  };
459
875
  const walkUpTree = () => {
460
- while (handleNode() && (node = node._$host || node.parentNode || node.host));
876
+ while (handleNode()) {
877
+ if (node === boundary || node.parentNode === boundary) break;
878
+ node = node._$host || node.parentNode || node.host;
879
+ }
461
880
  };
462
881
  Object.defineProperty(e, "currentTarget", {
463
882
  configurable: true,
464
883
  get() {
465
- return node || document;
884
+ return node || boundary || document;
466
885
  }
467
886
  });
468
- if (e.composedPath) {
887
+ if (resumeNode) {
888
+ if (resumeNode === e.target) node = resumeNode._$host || resumeNode.parentNode || resumeNode.host;
889
+ if (node && node !== boundary) walkUpTree();
890
+ } else if (e.composedPath) {
469
891
  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;
892
+ if (path.length) {
893
+ retarget(path[0]);
894
+ for (let i = 0; i < path.length; i++) {
895
+ node = path[i];
896
+ if (!handleNode()) break;
897
+ if (node._$host) {
898
+ node = node._$host;
899
+ walkUpTree();
900
+ break;
901
+ }
902
+ if (node === boundary || node.parentNode === boundary) {
903
+ break;
904
+ }
481
905
  }
482
- }
906
+ } else walkUpTree();
483
907
  }
484
908
  else walkUpTree();
485
909
  retarget(oriTarget);
486
910
  }
487
911
  function insertExpression(parent, value, current, marker) {
488
- if (isHydrating(parent)) return;
912
+ if (hydrationRt !== null && isHydrating(parent)) return;
489
913
  if (value === current) return;
490
914
  const t = typeof value,
491
915
  multi = marker !== undefined;
@@ -493,15 +917,25 @@ function insertExpression(parent, value, current, marker) {
493
917
  const tc = typeof current;
494
918
  if (tc === "string" || tc === "number") {
495
919
  parent.firstChild.data = value;
496
- } else parent.textContent = value;
920
+ } else {
921
+ if (ownsAllChildren(parent, current)) parent.textContent = value;else {
922
+ removeOwnedChildren(parent, current);
923
+ parent.insertBefore(document.createTextNode(value), parent.firstChild);
924
+ }
925
+ }
497
926
  } else if (value === undefined) {
498
927
  cleanChildren(parent, current, marker);
499
928
  } else if (value.nodeType) {
500
929
  if (Array.isArray(current)) {
501
930
  cleanChildren(parent, current, multi ? marker : null, value);
502
- } else if (current === undefined || !parent.firstChild) {
931
+ } else if (current && current.nodeType) {
932
+ current.parentNode === parent ? parent.replaceChild(value, current) : parent.appendChild(value);
933
+ } else if (current && parent.firstChild) {
934
+ parent.replaceChild(value, parent.firstChild);
935
+ } else {
503
936
  parent.appendChild(value);
504
- } else parent.replaceChild(value, parent.firstChild);
937
+ }
938
+ if (marker) value[$$SLOT] = marker;
505
939
  } else if (Array.isArray(value)) {
506
940
  const currentArray = current && Array.isArray(current);
507
941
  if (value.length === 0) {
@@ -509,9 +943,9 @@ function insertExpression(parent, value, current, marker) {
509
943
  } else if (currentArray) {
510
944
  if (current.length === 0) {
511
945
  appendNodes(parent, value, marker);
512
- } else reconcileArrays(parent, current, value);
946
+ } else reconcileArrays(parent, current, value, marker);
513
947
  } else {
514
- current && cleanChildren(parent);
948
+ current && cleanChildren(parent, current);
515
949
  appendNodes(parent, value);
516
950
  }
517
951
  } else ;
@@ -533,21 +967,64 @@ function normalize(value, current, multi, doNotUnwrap) {
533
967
  }
534
968
  return value;
535
969
  }
970
+ function tagHost(value, host) {
971
+ if (Array.isArray(value)) {
972
+ for (let i = 0, len = value.length; i < len; i++) tagHost(value[i], host);
973
+ } else if (value && value.nodeType && value[$$HOST] !== host) {
974
+ value[$$HOST] = host;
975
+ Object.defineProperty(value, "_$host", {
976
+ get: host,
977
+ configurable: true
978
+ });
979
+ }
980
+ }
536
981
  function appendNodes(parent, array, marker = null) {
537
- for (let i = 0, len = array.length; i < len; i++) parent.insertBefore(array[i], marker);
982
+ for (let i = 0, len = array.length; i < len; i++) {
983
+ const n = array[i];
984
+ parent.insertBefore(n, marker);
985
+ if (marker) n[$$SLOT] = marker;
986
+ }
987
+ }
988
+ function ownsAllChildren(parent, current) {
989
+ if (current == null) return true;
990
+ if (Array.isArray(current)) {
991
+ return current.length ? parent.firstChild === current[0] && parent.lastChild === current[current.length - 1] : parent.firstChild === null;
992
+ }
993
+ if (current === "") return parent.firstChild === null;
994
+ if (current.nodeType) return parent.firstChild === current && parent.lastChild === current;
995
+ const first = parent.firstChild;
996
+ return first !== null && first.nodeType === 3 && parent.lastChild === first;
997
+ }
998
+ function removeOwnedChildren(parent, current) {
999
+ if (Array.isArray(current)) {
1000
+ for (let i = 0; i < current.length; i++) {
1001
+ const el = current[i];
1002
+ if (el.parentNode === parent) el.remove();
1003
+ }
1004
+ } else if (current.nodeType) {
1005
+ if (current.parentNode === parent) current.remove();
1006
+ } else {
1007
+ const first = parent.firstChild;
1008
+ if (first && first.nodeType === 3) first.remove();
1009
+ }
538
1010
  }
539
1011
  function cleanChildren(parent, current, marker, replacement) {
540
- if (marker === undefined) return parent.textContent = "";
1012
+ if (marker === undefined) {
1013
+ if (ownsAllChildren(parent, current)) return parent.textContent = "";
1014
+ return removeOwnedChildren(parent, current);
1015
+ }
541
1016
  if (current.length) {
542
1017
  let inserted = false;
543
1018
  for (let i = current.length - 1; i >= 0; i--) {
544
1019
  const el = current[i];
545
1020
  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();
1021
+ const tag = el[$$SLOT];
1022
+ const owns = el.parentNode === parent && (!tag || tag === marker);
1023
+ if (replacement && !inserted && !i) owns ? parent.replaceChild(replacement, el) : parent.insertBefore(replacement, marker);else if (owns) el.remove();
548
1024
  } else inserted = true;
549
1025
  }
550
1026
  } else if (replacement) parent.insertBefore(replacement, marker);
1027
+ if (replacement && marker) replacement[$$SLOT] = marker;
551
1028
  }
552
1029
  function gatherHydratable(element, root) {
553
1030
  const templates = element.querySelectorAll(`*[_hk]`);
@@ -585,77 +1062,163 @@ function ssrHydrationKey() {}
585
1062
  function resolveSSRNode(node) {}
586
1063
  function escape(html) {}
587
1064
 
588
- function render(...args) {
589
- const result = render$1(...args);
590
- return result;
1065
+ const ENVELOPE = Symbol.for("solid.ResponseEnvelope");
1066
+ class ResponseEnvelope {
1067
+ constructor(response, value) {
1068
+ this.response = response;
1069
+ this.value = value;
1070
+ }
1071
+ }
1072
+ ResponseEnvelope.prototype[ENVELOPE] = true;
1073
+ function isResponseEnvelope(value) {
1074
+ return !!(value && typeof value === "object" && value[ENVELOPE]);
591
1075
  }
1076
+ function initWithRevalidate(init) {
1077
+ const {
1078
+ revalidate,
1079
+ ...responseInit
1080
+ } = init;
1081
+ const headers = new Headers(responseInit.headers);
1082
+ revalidate !== undefined && headers.set("X-Revalidate", revalidate.toString());
1083
+ return {
1084
+ responseInit,
1085
+ headers
1086
+ };
1087
+ }
1088
+ function redirect(url, init = 302) {
1089
+ const {
1090
+ responseInit,
1091
+ headers
1092
+ } = initWithRevalidate(typeof init === "number" ? {
1093
+ status: init
1094
+ } : init);
1095
+ if (responseInit.status === undefined) {
1096
+ responseInit.status = 302;
1097
+ }
1098
+ headers.set("Location", url);
1099
+ return new Response(null, {
1100
+ ...responseInit,
1101
+ headers
1102
+ });
1103
+ }
1104
+ function reload(init = {}) {
1105
+ const {
1106
+ responseInit,
1107
+ headers
1108
+ } = initWithRevalidate(init);
1109
+ return new Response(null, {
1110
+ ...responseInit,
1111
+ headers
1112
+ });
1113
+ }
1114
+ function respond(value, init = {}) {
1115
+ const {
1116
+ responseInit,
1117
+ headers
1118
+ } = initWithRevalidate(init);
1119
+ headers.set("Content-Type", "application/json");
1120
+ return new ResponseEnvelope(new Response(JSON.stringify(value), {
1121
+ ...responseInit,
1122
+ headers
1123
+ }), value);
1124
+ }
1125
+
1126
+ const mergeProps = solidJs.merge;
592
1127
  const isServer = false;
593
1128
  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
- });
1129
+ function render(code, element, init, options = {}) {
1130
+ try {
1131
+ const dispose = render$1(code, element, init, {
1132
+ ...options,
1133
+ insertOptions: {
1134
+ schedule: true
1135
+ }
1136
+ });
1137
+ solidJs.flush();
1138
+ return dispose;
1139
+ } finally {
1140
+ }
599
1141
  }
600
1142
  const hydrate = (...args) => {
601
1143
  solidJs.enableHydration();
602
1144
  return hydrate$1(...args);
603
1145
  };
604
1146
  function Portal(props) {
1147
+ return solidJs.runWithOwner(solidJs.createOwner(), () => portalImpl(props));
1148
+ }
1149
+ function portalImpl(props) {
605
1150
  const treeMarker = document.createTextNode(""),
606
1151
  startMarker = document.createTextNode(""),
607
1152
  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]) => {
1153
+ mount = () => props.mount || document.body,
1154
+ content = solidJs.createMemo(() => [startMarker, props.children], {
1155
+ ssrSource: "client"
1156
+ });
1157
+ solidJs.createRenderEffect(
1158
+ () => [mount(), content(), solidJs.getOwner()], ([, c, owner]) => {
1159
+ const m = solidJs.untrack(mount);
611
1160
  m.appendChild(endMarker);
612
- insert(m, c, endMarker);
1161
+ const dispose = solidJs.runWithOwner(owner, () => solidJs.createRoot(d => {
1162
+ insert(m, c, endMarker, undefined, {
1163
+ host: () => treeMarker.parentNode
1164
+ });
1165
+ return d;
1166
+ }));
613
1167
  return () => {
1168
+ dispose();
614
1169
  let c = startMarker;
615
- while (c && c !== endMarker) {
1170
+ while (c) {
616
1171
  const n = c.nextSibling;
617
1172
  m.removeChild(c);
1173
+ if (c === endMarker) break;
618
1174
  c = n;
619
1175
  }
620
1176
  };
1177
+ },
1178
+ {
1179
+ schedule: true,
1180
+ ssrSource: "client"
621
1181
  });
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
- }
1182
+ solidJs.createEffect(mount, () => {
1183
+ const m = solidJs.untrack(mount);
1184
+ const ownerRoot = getDelegatedRoot(treeMarker);
1185
+ if (!ownerRoot || ownerRoot.contains(m)) return;
1186
+ registerDelegatedContainer(m, ownerRoot);
1187
+ return () => unregisterDelegatedContainer(m, ownerRoot);
1188
+ }, {
1189
+ ssrSource: "client"
1190
+ });
1191
+ if (solidJs.sharedConfig.hydrating) return solidJs.createMemo(() => treeMarker, {
1192
+ ssrSource: "client"
639
1193
  });
1194
+ return treeMarker;
640
1195
  }
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
- }
1196
+ function dynamic(source) {
1197
+ const cached = solidJs.createMemo(source, {
1198
+ lazy: true
654
1199
  });
1200
+ return props => {
1201
+ return solidJs.createMemo(() => {
1202
+ const component = cached();
1203
+ switch (typeof component) {
1204
+ case "function":
1205
+ return solidJs.untrack(() => component(props));
1206
+ case "string":
1207
+ const el = solidJs.sharedConfig.hydrating ? getNextElement() : createElement(component, solidJs.untrack(() => props.is));
1208
+ spread(el, props);
1209
+ return el;
1210
+ }
1211
+ });
1212
+ };
655
1213
  }
656
1214
  function Dynamic(props) {
657
- const others = solidJs.omit(props, "component");
658
- return createDynamic(() => props.component, others);
1215
+ const Comp = dynamic(() => props.component);
1216
+ return solidJs.createComponent(Comp, solidJs.omit(props, "component"));
1217
+ }
1218
+ function createElement(tagName, is = undefined) {
1219
+ return SVGElements.has(tagName) ? document.createElementNS(Namespaces.svg, tagName) : MathMLElements.has(tagName) ? document.createElementNS(Namespaces.mathml, tagName) : document.createElement(tagName, {
1220
+ is
1221
+ });
659
1222
  }
660
1223
 
661
1224
  Object.defineProperty(exports, "Errored", {
@@ -682,6 +1245,14 @@ Object.defineProperty(exports, "NoHydration", {
682
1245
  enumerable: true,
683
1246
  get: function () { return solidJs.NoHydration; }
684
1247
  });
1248
+ Object.defineProperty(exports, "Repeat", {
1249
+ enumerable: true,
1250
+ get: function () { return solidJs.Repeat; }
1251
+ });
1252
+ Object.defineProperty(exports, "Reveal", {
1253
+ enumerable: true,
1254
+ get: function () { return solidJs.Reveal; }
1255
+ });
685
1256
  Object.defineProperty(exports, "Show", {
686
1257
  enumerable: true,
687
1258
  get: function () { return solidJs.Show; }
@@ -698,10 +1269,6 @@ Object.defineProperty(exports, "getOwner", {
698
1269
  enumerable: true,
699
1270
  get: function () { return solidJs.getOwner; }
700
1271
  });
701
- Object.defineProperty(exports, "mergeProps", {
702
- enumerable: true,
703
- get: function () { return solidJs.merge; }
704
- });
705
1272
  Object.defineProperty(exports, "untrack", {
706
1273
  enumerable: true,
707
1274
  get: function () { return solidJs.untrack; }
@@ -709,26 +1276,31 @@ Object.defineProperty(exports, "untrack", {
709
1276
  exports.Assets = voidFn;
710
1277
  exports.ChildProperties = ChildProperties;
711
1278
  exports.DOMElements = DOMElements;
1279
+ exports.DOMWithState = DOMWithState;
712
1280
  exports.DelegatedEvents = DelegatedEvents;
713
1281
  exports.Dynamic = Dynamic;
714
1282
  exports.HydrationScript = voidFn;
1283
+ exports.MathMLElements = MathMLElements;
1284
+ exports.Namespaces = Namespaces;
715
1285
  exports.Portal = Portal;
716
- exports.Properties = Properties;
1286
+ exports.RawTextElements = RawTextElements;
717
1287
  exports.RequestContext = RequestContext;
1288
+ exports.ResponseEnvelope = ResponseEnvelope;
718
1289
  exports.SVGElements = SVGElements;
719
- exports.SVGNamespace = SVGNamespace;
720
- exports.addEventListener = addEventListener;
1290
+ exports.VoidElements = VoidElements;
1291
+ exports.acquireAsset = acquireAsset;
1292
+ exports.addEvent = addEvent;
721
1293
  exports.applyRef = applyRef;
722
1294
  exports.assign = assign;
723
1295
  exports.className = className;
724
- exports.clearDelegatedEvents = clearDelegatedEvents;
725
- exports.createDynamic = createDynamic;
726
1296
  exports.delegateEvents = delegateEvents;
1297
+ exports.dynamic = dynamic;
727
1298
  exports.dynamicProperty = dynamicProperty;
728
1299
  exports.effect = effect;
729
1300
  exports.escape = escape;
730
1301
  exports.generateHydrationScript = voidFn;
731
1302
  exports.getAssets = voidFn;
1303
+ exports.getDelegatedRoot = getDelegatedRoot;
732
1304
  exports.getFirstChild = getFirstChild;
733
1305
  exports.getHydrationKey = getHydrationKey;
734
1306
  exports.getNextElement = getNextElement;
@@ -738,16 +1310,25 @@ exports.getNextSibling = getNextSibling;
738
1310
  exports.getRequestEvent = voidFn;
739
1311
  exports.hydrate = hydrate;
740
1312
  exports.insert = insert;
1313
+ exports.installHydrationRuntime = installHydrationRuntime;
741
1314
  exports.isDev = isDev;
1315
+ exports.isResponseEnvelope = isResponseEnvelope;
742
1316
  exports.isServer = isServer;
743
1317
  exports.memo = memo;
1318
+ exports.mergeProps = mergeProps;
1319
+ exports.redirect = redirect;
744
1320
  exports.ref = ref;
1321
+ exports.registerDelegatedContainer = registerDelegatedContainer;
1322
+ exports.registerDelegatedRoot = registerDelegatedRoot;
1323
+ exports.reload = reload;
745
1324
  exports.render = render;
746
1325
  exports.renderToStream = renderToStream;
747
1326
  exports.renderToString = renderToString;
748
1327
  exports.renderToStringAsync = renderToStringAsync;
749
1328
  exports.resolveSSRNode = resolveSSRNode;
1329
+ exports.respond = respond;
750
1330
  exports.runHydrationEvents = runHydrationEvents;
1331
+ exports.scope = scope;
751
1332
  exports.setAttribute = setAttribute;
752
1333
  exports.setAttributeNS = setAttributeNS;
753
1334
  exports.setProperty = setProperty;
@@ -761,4 +1342,6 @@ exports.ssrHydrationKey = ssrHydrationKey;
761
1342
  exports.ssrStyle = ssrStyle;
762
1343
  exports.style = style;
763
1344
  exports.template = template;
1345
+ exports.unregisterDelegatedContainer = unregisterDelegatedContainer;
1346
+ exports.unregisterDelegatedRoot = unregisterDelegatedRoot;
764
1347
  exports.useAssets = voidFn;