@solidjs/web 2.0.0-beta.1 → 2.0.0-beta.11

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.
package/dist/web.js CHANGED
@@ -1,8 +1,34 @@
1
- import { createRenderEffect, createMemo, sharedConfig, untrack, runWithOwner, createRoot, flatten, omit, enableHydration } from 'solid-js';
2
- export { Errored, For, Hydration, Loading, Match, NoHydration, Show, Switch, createComponent, getOwner, merge as mergeProps, untrack } from 'solid-js';
1
+ import { createRenderEffect, createMemo, sharedConfig, untrack, runWithOwner, flatten, createRoot, merge, createComponent, omit, enableHydration, flush } from 'solid-js';
2
+ export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, getOwner, untrack } from 'solid-js';
3
3
 
4
- const Properties = /*#__PURE__*/new Set([
5
- "value", "checked", "selected", "muted"]);
4
+ const DOMWithState = {
5
+ INPUT: {
6
+ value: 1,
7
+ defaultValue: 2,
8
+ checked: 1,
9
+ defaultChecked: 2
10
+ },
11
+ SELECT: {
12
+ value: 1
13
+ },
14
+ OPTION: {
15
+ value: 1,
16
+ selected: 1,
17
+ defaultSelected: 2
18
+ },
19
+ TEXTAREA: {
20
+ value: 1,
21
+ defaultValue: 2
22
+ },
23
+ VIDEO: {
24
+ muted: 1,
25
+ defaultMuted: 2
26
+ },
27
+ AUDIO: {
28
+ muted: 1,
29
+ defaultMuted: 2
30
+ }
31
+ };
6
32
  const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
7
33
  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"]);
8
34
  const SVGElements = /*#__PURE__*/new Set([
@@ -10,18 +36,32 @@ const SVGElements = /*#__PURE__*/new Set([
10
36
  "set", "stop",
11
37
  "svg", "switch", "symbol", "text", "textPath",
12
38
  "tref", "tspan", "use", "view", "vkern"]);
13
- const SVGNamespace = {
39
+ 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"]);
40
+ const Namespaces = {
41
+ svg: "http://www.w3.org/2000/svg",
42
+ mathml: "http://www.w3.org/1998/Math/MathML",
14
43
  xlink: "http://www.w3.org/1999/xlink",
15
44
  xml: "http://www.w3.org/XML/1998/namespace"
16
45
  };
46
+ const VoidElements = /*#__PURE__*/new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]);
47
+ const RawTextElements = /*#__PURE__*/new Set(["style", "script", "noscript", "template", "textarea", "title"]);
17
48
  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",
18
49
  "webview",
19
50
  "isindex", "listing", "multicol", "nextid", "noindex", "search"]);
20
51
 
21
- const effect = (fn, effectFn, initial) => createRenderEffect(fn, effectFn, initial, {
22
- transparent: true
23
- });
24
- const memo = fn => createMemo(() => fn());
52
+ const transparentOptions = {
53
+ transparent: true,
54
+ sync: true
55
+ };
56
+ const syncOptions = {
57
+ sync: true
58
+ };
59
+ const effect = (fn, effectFn, options) => createRenderEffect(fn, effectFn, options ? {
60
+ transparent: true,
61
+ sync: true,
62
+ ...options
63
+ } : transparentOptions);
64
+ const memo = fn => createMemo(() => fn(), syncOptions);
25
65
 
26
66
  function reconcileArrays(parentNode, a, b) {
27
67
  let bLength = b.length,
@@ -50,10 +90,12 @@ function reconcileArrays(parentNode, a, b) {
50
90
  aStart++;
51
91
  }
52
92
  } else if (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]) {
53
- const node = a[--aEnd].nextSibling;
54
- parentNode.insertBefore(b[bStart++], a[aStart++].nextSibling);
55
- parentNode.insertBefore(b[--bEnd], node);
56
- a[aEnd] = b[bEnd];
93
+ const anchor = a[aStart];
94
+ do {
95
+ parentNode.insertBefore(a[--aEnd], anchor);
96
+ bStart++;
97
+ if (aStart >= aEnd - 1 || bStart >= bEnd) break;
98
+ } while (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]);
57
99
  } else {
58
100
  if (!map) {
59
101
  map = new Map();
@@ -81,27 +123,35 @@ function reconcileArrays(parentNode, a, b) {
81
123
  }
82
124
 
83
125
  const $$EVENTS = "_$DX_DELEGATE";
84
- function render(code, element, init, options = {}) {
126
+ const INNER_OWNED = {};
127
+ function render$1(code, element, init, options = {}) {
128
+ const renderRoot = getChildRoot(element);
85
129
  let disposer;
86
130
  createRoot(dispose => {
87
131
  disposer = dispose;
88
- element === document ? flatten(code) : insert(element, code(), element.firstChild ? null : undefined, init);
132
+ if (element === document) {
133
+ const tree = code();
134
+ effect(() => flatten(tree), () => {});
135
+ } else {
136
+ const tree = code();
137
+ insert(element, () => tree, renderRoot.firstChild ? null : undefined, init, options.insertOptions);
138
+ }
89
139
  }, {
90
140
  id: options.renderId
91
141
  });
92
142
  return () => {
93
143
  disposer();
94
- element.textContent = "";
144
+ renderRoot.textContent = "";
95
145
  };
96
146
  }
97
- function template(html, isImportNode, isSVG, isMathML) {
147
+ function create(html, bypassGuard, flag) {
148
+ const t = document.createElement("template");
149
+ t.innerHTML = html;
150
+ return flag === 2 ? t.content.firstChild.firstChild : t.content.firstChild;
151
+ }
152
+ function template(html, flag) {
98
153
  let node;
99
- const create = bypassGuard => {
100
- const t = isMathML ? document.createElementNS("http://www.w3.org/1998/Math/MathML", "template") : document.createElement("template");
101
- t.innerHTML = html;
102
- return isSVG ? t.content.firstChild.firstChild : isMathML ? t.firstChild : t.content.firstChild;
103
- };
104
- const fn = isImportNode ? bypassGuard => untrack(() => document.importNode(node || (node = create()), true)) : bypassGuard => (node || (node = create())).cloneNode(true);
154
+ const fn = flag === 1 ? bypassGuard => document.importNode(node || (node = create(html, bypassGuard, flag)), true) : bypassGuard => (node || (node = create(html, bypassGuard, flag))).cloneNode(true);
105
155
  return fn;
106
156
  }
107
157
  function delegateEvents(eventNames, document = window.document) {
@@ -130,16 +180,16 @@ function setAttribute(node, name, value) {
130
180
  }
131
181
  function setAttributeNS(node, namespace, name, value) {
132
182
  if (isHydrating(node)) return;
133
- if (value == null) node.removeAttributeNS(namespace, name);else node.setAttributeNS(namespace, name, value);
183
+ if (value == null || value === false) node.removeAttributeNS(namespace, name.indexOf(":") > -1 ? name.split(":").pop() : name);else node.setAttributeNS(namespace, name, value === true ? "" : value);
134
184
  }
135
- function className(node, value, isSVG, prev) {
185
+ function className(node, value, prev) {
136
186
  if (isHydrating(node)) return;
137
187
  if (value == null || value === false) {
138
188
  prev && node.removeAttribute("class");
139
189
  return;
140
190
  }
141
191
  if (typeof value === "string") {
142
- value !== prev && (isSVG ? node.setAttribute("class", value) : node.className = value);
192
+ value !== prev && node.setAttribute("class", value);
143
193
  return;
144
194
  }
145
195
  if (typeof prev === "string") {
@@ -153,13 +203,13 @@ function className(node, value, isSVG, prev) {
153
203
  for (i = 0, len = prevKeys.length; i < len; i++) {
154
204
  const key = prevKeys[i];
155
205
  if (!key || key === "undefined" || value[key]) continue;
156
- toggleClassKey(node, key, false);
206
+ node.classList.remove(key);
157
207
  }
158
208
  for (i = 0, len = classKeys.length; i < len; i++) {
159
209
  const key = classKeys[i],
160
210
  classValue = !!value[key];
161
211
  if (!key || key === "undefined" || prev[key] === classValue || !classValue) continue;
162
- toggleClassKey(node, key, true);
212
+ node.classList.add(key);
163
213
  }
164
214
  }
165
215
  function addEventListener(node, name, handler, delegate) {
@@ -182,7 +232,6 @@ function style(node, value, prev) {
182
232
  if (typeof value === "string") return nodeStyle.cssText = value;
183
233
  typeof prev === "string" && (nodeStyle.cssText = prev = undefined);
184
234
  prev || (prev = {});
185
- value || (value = {});
186
235
  let v, s;
187
236
  for (s in value) {
188
237
  v = value[s];
@@ -194,14 +243,9 @@ function style(node, value, prev) {
194
243
  function setStyleProperty(node, name, value) {
195
244
  value != null ? node.style.setProperty(name, value) : node.style.removeProperty(name);
196
245
  }
197
- function spread(node, props = {}, isSVG, skipChildren) {
246
+ function spread(node, props = {}, skipChildren) {
198
247
  const prevProps = {};
199
- if (!skipChildren) {
200
- effect(() => normalize(props.children, prevProps.children), value => {
201
- insertExpression(node, value, prevProps.children);
202
- prevProps.children = value;
203
- });
204
- }
248
+ if (!skipChildren) insert(node, () => props.children);
205
249
  effect(() => {
206
250
  const r = props.ref;
207
251
  (typeof r === "function" || Array.isArray(r)) && ref(() => r, node);
@@ -213,7 +257,7 @@ function spread(node, props = {}, isSVG, skipChildren) {
213
257
  newProps[prop] = props[prop];
214
258
  }
215
259
  return newProps;
216
- }, props => assign(node, props, isSVG, true, prevProps, true));
260
+ }, props => assign(node, props, true, prevProps, true));
217
261
  return prevProps;
218
262
  }
219
263
  function dynamicProperty(props, key) {
@@ -233,11 +277,12 @@ function ref(fn, element) {
233
277
  const resolved = untrack(fn);
234
278
  runWithOwner(null, () => applyRef(resolved, element));
235
279
  }
236
- function insert(parent, accessor, marker, initial) {
280
+ function insert(parent, accessor, marker, initial, options) {
281
+ const childRoot = getChildRoot(parent);
237
282
  const multi = marker !== undefined;
238
283
  if (multi && !initial) initial = [];
239
284
  if (isHydrating(parent)) {
240
- if (!multi && initial === undefined && parent) initial = [...parent.childNodes];
285
+ if (!multi && initial === undefined && parent) initial = [...childRoot.childNodes];
241
286
  if (Array.isArray(initial)) {
242
287
  let j = 0;
243
288
  for (let i = 0; i < initial.length; i++) {
@@ -250,27 +295,64 @@ function insert(parent, accessor, marker, initial) {
250
295
  accessor = normalize(accessor, initial, multi, true);
251
296
  if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker);
252
297
  }
253
- effect(prev => normalize(accessor, prev, multi), (value, current) => insertExpression(parent, value, current, marker), initial);
254
- }
255
- function assign(node, props, isSVG, skipChildren, prevProps = {}, skipRef = false) {
298
+ if (multi && initial.length === 0) {
299
+ const placeholder = document.createTextNode("");
300
+ childRoot.insertBefore(placeholder, marker);
301
+ initial = [placeholder];
302
+ }
303
+ let current = initial;
304
+ effect(prev => {
305
+ const value = normalize(accessor(), current, multi, true);
306
+ if (typeof value !== "function") return value;
307
+ effect(() => normalize(value, current, multi), inner => {
308
+ insertExpression(parent, inner, current, marker);
309
+ current = inner;
310
+ }, prev !== undefined && !(options && options.schedule) ? {
311
+ ...options,
312
+ schedule: true
313
+ } : options);
314
+ return INNER_OWNED;
315
+ }, value => {
316
+ if (value === INNER_OWNED) return;
317
+ insertExpression(parent, value, current, marker);
318
+ current = value;
319
+ }, options);
320
+ }
321
+ function assign(node, props, skipChildren, prevProps = {}, skipRef = false) {
322
+ const nodeName = node.nodeName;
256
323
  props || (props = {});
257
324
  for (const prop in prevProps) {
258
325
  if (!(prop in props)) {
259
326
  if (prop === "children") continue;
260
- prevProps[prop] = assignProp(node, prop, null, prevProps[prop], isSVG, skipRef);
327
+ prevProps[prop] = assignProp(node, prop, null, prevProps[prop], skipRef, nodeName);
261
328
  }
262
329
  }
263
330
  for (const prop in props) {
264
331
  if (prop === "children") {
265
- if (!skipChildren) insertExpression(node, props.children);
332
+ if (!skipChildren) insertExpression(node, normalize(props.children, undefined, false));
266
333
  continue;
267
334
  }
268
- const value = props[prop];
269
- prevProps[prop] = assignProp(node, prop, value, prevProps[prop], isSVG, skipRef);
335
+ prevProps[prop] = assignProp(node, prop, props[prop], prevProps[prop], skipRef, nodeName);
336
+ }
337
+ }
338
+ function loadModuleAssets(mapping) {
339
+ const hy = globalThis._$HY;
340
+ if (!hy) return;
341
+ const pending = [];
342
+ for (const moduleUrl in mapping) {
343
+ if (hy.modules[moduleUrl]) continue;
344
+ const entryUrl = mapping[moduleUrl];
345
+ if (!hy.loading[moduleUrl]) {
346
+ hy.loading[moduleUrl] = import(entryUrl).then(mod => {
347
+ hy.modules[moduleUrl] = mod;
348
+ });
349
+ }
350
+ pending.push(hy.loading[moduleUrl]);
270
351
  }
352
+ return pending.length ? Promise.all(pending).then(() => {}) : undefined;
271
353
  }
272
354
  function hydrate$1(code, element, options = {}) {
273
- if (globalThis._$HY.done) return render(code, element, [...element.childNodes], options);
355
+ if (globalThis._$HY.done) return render$1(code, element, [...getChildRoot(element).childNodes], options);
274
356
  options.renderId ||= "";
275
357
  if (!globalThis._$HY.modules) globalThis._$HY.modules = {};
276
358
  if (!globalThis._$HY.loading) globalThis._$HY.loading = {};
@@ -279,6 +361,7 @@ function hydrate$1(code, element, options = {}) {
279
361
  sharedConfig.load = id => globalThis._$HY.r[id];
280
362
  sharedConfig.has = id => id in globalThis._$HY.r;
281
363
  sharedConfig.gather = root => gatherHydratable(element, root);
364
+ sharedConfig.loadModuleAssets = loadModuleAssets;
282
365
  sharedConfig.cleanupFragment = id => {
283
366
  const tpl = document.getElementById("pl-" + id);
284
367
  if (tpl) {
@@ -297,9 +380,27 @@ function hydrate$1(code, element, options = {}) {
297
380
  };
298
381
  sharedConfig.registry = new Map();
299
382
  sharedConfig.hydrating = true;
383
+ const rootMapping = globalThis._$HY.r && globalThis._$HY.r["_assets"];
384
+ if (rootMapping && typeof rootMapping === "object") {
385
+ const p = loadModuleAssets(rootMapping);
386
+ if (p) {
387
+ gatherHydratable(element, options.renderId);
388
+ let disposer;
389
+ p.then(() => {
390
+ try {
391
+ disposer = render$1(code, element, [...getChildRoot(element).childNodes], options);
392
+ } finally {
393
+ sharedConfig.hydrating = false;
394
+ }
395
+ }, () => {
396
+ sharedConfig.hydrating = false;
397
+ });
398
+ return () => disposer && disposer();
399
+ }
400
+ }
300
401
  try {
301
402
  gatherHydratable(element, options.renderId);
302
- return render(code, element, [...element.childNodes], options);
403
+ return render$1(code, element, [...getChildRoot(element).childNodes], options);
303
404
  } finally {
304
405
  sharedConfig.hydrating = false;
305
406
  }
@@ -342,7 +443,7 @@ function getNextMarker(start) {
342
443
  return [end, current];
343
444
  }
344
445
  function getFirstChild(node, expectedTag) {
345
- const child = node.firstChild;
446
+ const child = getChildRoot(node).firstChild;
346
447
  return child;
347
448
  }
348
449
  function getNextSibling(node, expectedTag) {
@@ -375,14 +476,24 @@ function runHydrationEvents() {
375
476
  function isHydrating(node) {
376
477
  return sharedConfig.hydrating && (!node || node.isConnected);
377
478
  }
378
- function toggleClassKey(node, key, value) {
379
- const classNames = key.trim().split(/\s+/);
380
- for (let i = 0, nameLen = classNames.length; i < nameLen; i++) node.classList.toggle(classNames[i], value);
479
+ function getChildRoot(node) {
480
+ return node && node.localName === "template" ? node.content : node;
381
481
  }
382
482
  function classListToObject(classList) {
383
483
  if (Array.isArray(classList)) {
384
484
  const result = {};
385
485
  flattenClassList(classList, result);
486
+ classList = result;
487
+ }
488
+ if (classList && typeof classList === "object") {
489
+ const result = {},
490
+ keys = Object.keys(classList);
491
+ for (let i = 0, len = keys.length; i < len; i++) {
492
+ const key = keys[i];
493
+ if (!classList[key]) continue;
494
+ const classNames = key.trim().split(/\s+/);
495
+ for (let j = 0, nameLen = classNames.length; j < nameLen; j++) classNames[j] && (result[classNames[j]] = true);
496
+ }
386
497
  return result;
387
498
  }
388
499
  return classList;
@@ -393,18 +504,20 @@ function flattenClassList(list, result) {
393
504
  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;
394
505
  }
395
506
  }
396
- function assignProp(node, prop, value, prev, isSVG, skipRef) {
397
- let forceProp;
507
+ function assignProp(node, prop, value, prev, skipRef, nodeName) {
398
508
  if (prop === "style") return style(node, value, prev), value;
399
- if (prop === "class") return className(node, value, isSVG, prev), value;
400
- if (value === prev) return prev;
509
+ if (prop === "class") return className(node, value, prev), value;
510
+ if (value === prev && DOMWithState[nodeName]?.[prop] !== 1) return prev;
401
511
  if (prop === "ref") {
402
512
  if (!skipRef && value) ref(() => value, node);
403
- } else if (prop.slice(0, 3) === "on:") {
513
+ return value;
514
+ }
515
+ const hasNamespace = prop.indexOf(":") > -1;
516
+ if (hasNamespace && prop.slice(0, 3) === "on:") {
404
517
  const e = prop.slice(3);
405
518
  prev && node.removeEventListener(e, prev, typeof prev !== "function" && prev);
406
519
  value && node.addEventListener(e, value, typeof value !== "function" && value);
407
- } else if (prop.slice(0, 2) === "on") {
520
+ } else if (!hasNamespace && prop.slice(0, 2) === "on") {
408
521
  const name = prop.slice(2).toLowerCase();
409
522
  const delegate = DelegatedEvents.has(name);
410
523
  if (!delegate && prev) {
@@ -415,11 +528,11 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
415
528
  addEventListener(node, name, value, delegate);
416
529
  delegate && delegateEvents([name]);
417
530
  }
418
- } else if ((forceProp = prop.slice(0, 5) === "prop:") || ChildProperties.has(prop) || !isSVG && Properties.has(prop)) {
419
- if (forceProp) prop = prop.slice(5);else if (isHydrating(node)) return value;
420
- if (prop === "value" && node.nodeName === "SELECT") queueMicrotask(() => node.value = value) || (node.value = value);else node[prop] = value;
531
+ } else if (hasNamespace && prop.slice(0, 5) === "prop:" || ChildProperties.has(prop) || DOMWithState[nodeName]?.[prop]) {
532
+ if (hasNamespace) prop = prop.slice(5);else if (isHydrating(node)) return value;
533
+ if (prop === "value" && nodeName === "SELECT") queueMicrotask(() => node.value = value) || (node.value = value);else node[prop] = value;
421
534
  } else {
422
- const ns = isSVG && prop.indexOf(":") > -1 && SVGNamespace[prop.split(":")[0]];
535
+ const ns = hasNamespace && Namespaces[prop.split(":")[0]];
423
536
  if (ns) setAttributeNS(node, ns, prop, value);else setAttribute(node, prop, value);
424
537
  }
425
538
  return value;
@@ -477,21 +590,22 @@ function eventHandler(e) {
477
590
  function insertExpression(parent, value, current, marker) {
478
591
  if (isHydrating(parent)) return;
479
592
  if (value === current) return;
593
+ const childRoot = getChildRoot(parent);
480
594
  const t = typeof value,
481
595
  multi = marker !== undefined;
482
596
  if (t === "string" || t === "number") {
483
597
  const tc = typeof current;
484
598
  if (tc === "string" || tc === "number") {
485
- parent.firstChild.data = value;
486
- } else parent.textContent = value;
599
+ childRoot.firstChild.data = value;
600
+ } else childRoot.textContent = value;
487
601
  } else if (value === undefined) {
488
602
  cleanChildren(parent, current, marker);
489
603
  } else if (value.nodeType) {
490
604
  if (Array.isArray(current)) {
491
605
  cleanChildren(parent, current, multi ? marker : null, value);
492
- } else if (current === undefined || !parent.firstChild) {
493
- parent.appendChild(value);
494
- } else parent.replaceChild(value, parent.firstChild);
606
+ } else if (current === undefined || !childRoot.firstChild) {
607
+ childRoot.appendChild(value);
608
+ } else childRoot.replaceChild(value, childRoot.firstChild);
495
609
  } else if (Array.isArray(value)) {
496
610
  const currentArray = current && Array.isArray(current);
497
611
  if (value.length === 0) {
@@ -499,7 +613,7 @@ function insertExpression(parent, value, current, marker) {
499
613
  } else if (currentArray) {
500
614
  if (current.length === 0) {
501
615
  appendNodes(parent, value, marker);
502
- } else reconcileArrays(parent, current, value);
616
+ } else reconcileArrays(childRoot, current, value);
503
617
  } else {
504
618
  current && cleanChildren(parent);
505
619
  appendNodes(parent, value);
@@ -524,9 +638,11 @@ function normalize(value, current, multi, doNotUnwrap) {
524
638
  return value;
525
639
  }
526
640
  function appendNodes(parent, array, marker = null) {
641
+ parent = getChildRoot(parent);
527
642
  for (let i = 0, len = array.length; i < len; i++) parent.insertBefore(array[i], marker);
528
643
  }
529
644
  function cleanChildren(parent, current, marker, replacement) {
645
+ parent = getChildRoot(parent);
530
646
  if (marker === undefined) return parent.textContent = "";
531
647
  if (current.length) {
532
648
  let inserted = false;
@@ -575,13 +691,21 @@ function ssrHydrationKey() {}
575
691
  function resolveSSRNode(node) {}
576
692
  function escape(html) {}
577
693
 
694
+ const mergeProps = merge;
578
695
  const isServer = false;
579
696
  const isDev = false;
580
- const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
581
- function createElement(tagName, isSVG = false, is = undefined) {
582
- return isSVG ? document.createElementNS(SVG_NAMESPACE, tagName) : document.createElement(tagName, {
583
- is
584
- });
697
+ function render(code, element, init, options = {}) {
698
+ try {
699
+ const dispose = render$1(code, element, init, {
700
+ ...options,
701
+ insertOptions: {
702
+ schedule: true
703
+ }
704
+ });
705
+ flush();
706
+ return dispose;
707
+ } finally {
708
+ }
585
709
  }
586
710
  const hydrate = (...args) => {
587
711
  enableHydration();
@@ -607,6 +731,33 @@ function Portal(props) {
607
731
  });
608
732
  return treeMarker;
609
733
  }
734
+ function dynamic(source) {
735
+ const cached = createMemo(source, {
736
+ lazy: true
737
+ });
738
+ return props => {
739
+ return createMemo(() => {
740
+ const component = cached();
741
+ switch (typeof component) {
742
+ case "function":
743
+ return untrack(() => component(props));
744
+ case "string":
745
+ const el = sharedConfig.hydrating ? getNextElement() : createElement(component, untrack(() => props.is));
746
+ spread(el, props);
747
+ return el;
748
+ }
749
+ });
750
+ };
751
+ }
752
+ function Dynamic(props) {
753
+ const Comp = dynamic(() => props.component);
754
+ return createComponent(Comp, omit(props, "component"));
755
+ }
756
+ function createElement(tagName, is = undefined) {
757
+ return SVGElements.has(tagName) ? document.createElementNS(Namespaces.svg, tagName) : MathMLElements.has(tagName) ? document.createElementNS(Namespaces.mathml, tagName) : document.createElement(tagName, {
758
+ is
759
+ });
760
+ }
610
761
  function createElementProxy(el, marker) {
611
762
  return new Proxy(el, {
612
763
  get(target, prop) {
@@ -624,24 +775,5 @@ function createElementProxy(el, marker) {
624
775
  }
625
776
  });
626
777
  }
627
- function createDynamic(component, props) {
628
- const cached = createMemo(component);
629
- return createMemo(() => {
630
- const component = cached();
631
- switch (typeof component) {
632
- case "function":
633
- return untrack(() => component(props));
634
- case "string":
635
- const isSvg = SVGElements.has(component);
636
- const el = sharedConfig.hydrating ? getNextElement() : createElement(component, isSvg, untrack(() => props.is));
637
- spread(el, props, isSvg);
638
- return el;
639
- }
640
- });
641
- }
642
- function Dynamic(props) {
643
- const others = omit(props, "component");
644
- return createDynamic(() => props.component, others);
645
- }
646
778
 
647
- export { voidFn as Assets, ChildProperties, DOMElements, DelegatedEvents, Dynamic, voidFn as HydrationScript, Portal, Properties, RequestContext, SVGElements, SVGNamespace, addEventListener, applyRef, assign, className, clearDelegatedEvents, createDynamic, delegateEvents, dynamicProperty, effect, escape, voidFn as generateHydrationScript, voidFn as getAssets, getFirstChild, getHydrationKey, getNextElement, getNextMarker, getNextMatch, getNextSibling, voidFn as getRequestEvent, hydrate, insert, isDev, isServer, memo, ref, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, setProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrStyle, style, template, voidFn as useAssets };
779
+ export { voidFn as Assets, ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, voidFn as HydrationScript, MathMLElements, Namespaces, Portal, RawTextElements, RequestContext, SVGElements, VoidElements, addEventListener, applyRef, assign, className, clearDelegatedEvents, delegateEvents, dynamic, dynamicProperty, effect, escape, voidFn as generateHydrationScript, voidFn as getAssets, getFirstChild, getHydrationKey, getNextElement, getNextMarker, getNextMatch, getNextSibling, voidFn as getRequestEvent, hydrate, insert, isDev, isServer, memo, mergeProps, ref, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, setProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrStyle, style, template, voidFn as useAssets };