@solidjs/web 2.0.0-beta.6 → 2.0.0-beta.8

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/server.js CHANGED
@@ -4,39 +4,6 @@ import { Serializer, Feature, getCrossReferenceHeader } from 'seroval';
4
4
  import { AbortSignalPlugin, CustomEventPlugin, DOMExceptionPlugin, EventPlugin, FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin } from 'seroval-plugins/web';
5
5
  import { createMemo } from '@solidjs/signals';
6
6
 
7
- const DOMWithState = {
8
- INPUT: {
9
- value: 1,
10
- defaultValue: 1,
11
- checked: 1,
12
- defaultChecked: 1
13
- },
14
- SELECT: {
15
- value: 1
16
- },
17
- OPTION: {
18
- value: 1,
19
- selected: 1,
20
- defaultSelected: 1
21
- },
22
- TEXTAREA: {
23
- value: 1,
24
- defaultValue: 1
25
- },
26
- VIDEO: {
27
- muted: 1,
28
- defaultMuted: 1
29
- },
30
- AUDIO: {
31
- muted: 1,
32
- defaultMuted: 1
33
- }
34
- };
35
- for (const tagName in DOMWithState) {
36
- for (const propName in DOMWithState[tagName]) {
37
- DOMWithState[tagName]["prop:" + propName] = 1;
38
- }
39
- }
40
7
  const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
41
8
  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"]);
42
9
  const SVGElements = /*#__PURE__*/new Set([
@@ -55,16 +22,20 @@ const DOMElements = /*#__PURE__*/new Set(["html", "base", "head", "link", "meta"
55
22
  "webview",
56
23
  "isindex", "listing", "multicol", "nextid", "noindex", "search"]);
57
24
 
58
- const effect = (fn, effectFn, initial) => createRenderEffect(fn, effectFn, initial, {
25
+ const transparentOptions = {
59
26
  transparent: true
60
- });
61
- const memo = (fn, transparent) => transparent ? fn.$r ? fn : createMemo(() => fn(), undefined, {
27
+ };
28
+ const effect = (fn, effectFn, options) => createRenderEffect(fn, effectFn, options ? {
29
+ transparent: true,
30
+ ...options
31
+ } : transparentOptions);
32
+ const memo = (fn, transparent) => transparent ? fn.$r ? fn : createMemo(() => fn(), {
62
33
  transparent: true
63
34
  }) : createMemo$1(() => fn());
64
35
 
65
- const ES2017FLAG = Feature.AggregateError
66
- | Feature.BigIntTypedArray;
67
- const GLOBAL_IDENTIFIER = '_$HY.r';
36
+ const ES2017FLAG = Feature.AggregateError |
37
+ Feature.BigIntTypedArray;
38
+ const GLOBAL_IDENTIFIER = "_$HY.r";
68
39
  function createSerializer({
69
40
  onData,
70
41
  onDone,
@@ -87,7 +58,7 @@ function createSerializer({
87
58
  });
88
59
  }
89
60
  function getLocalHeaderScript(id) {
90
- return getCrossReferenceHeader(id) + ';';
61
+ return getCrossReferenceHeader(id) + ";";
91
62
  }
92
63
 
93
64
  function resolveAssets(moduleUrl, manifest) {
@@ -143,11 +114,11 @@ function createAssetTracking() {
143
114
  currentBoundaryId = v;
144
115
  },
145
116
  registerModule(moduleUrl, entryUrl) {
146
- if (!currentBoundaryId) return;
147
- let map = boundaryModules.get(currentBoundaryId);
117
+ const id = currentBoundaryId || "";
118
+ let map = boundaryModules.get(id);
148
119
  if (!map) {
149
120
  map = {};
150
- boundaryModules.set(currentBoundaryId, map);
121
+ boundaryModules.set(id, map);
151
122
  }
152
123
  map[moduleUrl] = entryUrl;
153
124
  },
@@ -175,7 +146,7 @@ function applyAssetTracking(context, tracking, manifest) {
175
146
  if (manifest) context.resolveAssets = moduleUrl => resolveAssets(moduleUrl, manifest);
176
147
  }
177
148
  const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
178
- const REPLACE_SCRIPT = `function $df(e,n,o,t){if(!(n=document.getElementById(e))||!(o=document.getElementById("pl-"+e)))return 0;for(;o&&8!==o.nodeType&&o.nodeValue!=="pl-"+e;)t=o.nextSibling,o.remove(),o=t;_$HY.done?o.remove():o.replaceWith(n.content),n.remove(),_$HY.fe(e);return 1}function $dfl(e,o,n){if(!(o=document.getElementById("pl-"+e)))return 0;if(o._$fl)return 1;for(n=o.nextSibling;n;){if(8===n.nodeType&&n.nodeValue==="pl-"+e){o.parentNode&&o.parentNode.insertBefore(o.content.cloneNode(!0),n),o._$fl=1;return 1}n=n.nextSibling}return 0}function $dflj(e,i){for(i=0;i<e.length;i++)if($dfl(e[i]))return e[i];return null}function $dfs(e,c,d){(_$HY.sc=_$HY.sc||{})[e]=c,d&&((_$HY.sd=_$HY.sd||{})[e]=1)}function $dfg(e,g,i,k){if(!(g=_$HY.sg&&_$HY.sg[e]))return;for(i=0;i<g.length;i++)if(_$HY.sc&&_$HY.sc[g[i]]>0)return;for(i=0;i<g.length;i++)k=g[i],delete _$HY.sg[k],$df(k)}function $dfc(e){if(--_$HY.sc[e]<=0){delete _$HY.sc[e],_$HY.sg&&_$HY.sg[e]?$dfg(e):!(_$HY.sd&&_$HY.sd[e])&&$df(e);_$HY.sd&&delete _$HY.sd[e]}}function $dfj(e,i,n){for(i=0;i<e.length;i++)if(_$HY.sc&&_$HY.sc[e[i]]>0){for(n=0;n<e.length;n++)(_$HY.sg=_$HY.sg||{})[e[n]]=e;return}for(i=0;i<e.length;i++)$df(e[i])}`;
149
+ const REPLACE_SCRIPT = `function $df(e,n,o,t){if(!(n=document.getElementById(e))||!(o=document.getElementById("pl-"+e)))return 0;for(;o&&8!==o.nodeType&&o.nodeValue!=="pl-"+e;)t=o.nextSibling,o.remove(),o=t;_$HY.done?o.remove():o.replaceWith(n.content),n.remove(),_$HY.fe(e);return 1}function $dfl(e,o,n){if(!(o=document.getElementById("pl-"+e)))return 0;if(o._$fl)return 1;for(n=o.nextSibling;n;){if(8===n.nodeType&&n.nodeValue==="pl-"+e){o.parentNode&&o.parentNode.insertBefore(o.content.cloneNode(!0),n),o._$fl=1;return 1}n=n.nextSibling}return 0}function $dflj(e,i){for(i=0;i<e.length;i++)$dfl(e[i])}function $dfs(e,c,d){(_$HY.sc=_$HY.sc||{})[e]=c,d&&((_$HY.sd=_$HY.sd||{})[e]=1)}function $dfg(e,g,i,k){if(!(g=_$HY.sg&&_$HY.sg[e]))return;for(i=0;i<g.length;i++)if(_$HY.sc&&_$HY.sc[g[i]]>0)return;for(i=0;i<g.length;i++)k=g[i],delete _$HY.sg[k],$df(k)}function $dfc(e){if(--_$HY.sc[e]<=0){delete _$HY.sc[e],_$HY.sg&&_$HY.sg[e]?$dfg(e):!(_$HY.sd&&_$HY.sd[e])&&$df(e);_$HY.sd&&delete _$HY.sd[e]}}function $dfj(e,i,n){for(i=0;i<e.length;i++)if(_$HY.sc&&_$HY.sc[e[i]]>0){for(n=0;n<e.length;n++)(_$HY.sg=_$HY.sg||{})[e[n]]=e;return}for(i=0;i<e.length;i++)$df(e[i])}`;
179
150
  function renderToString(code, options = {}) {
180
151
  const {
181
152
  renderId = "",
@@ -230,6 +201,7 @@ function renderToString(code, options = {}) {
230
201
  }, {
231
202
  id: renderId
232
203
  });
204
+ serializeFragmentAssets("", tracking.boundaryModules, sharedConfig.context);
233
205
  sharedConfig.context.noHydrate = true;
234
206
  serializer.close();
235
207
  html = injectAssets(sharedConfig.context.assets, html);
@@ -248,10 +220,12 @@ function renderToStream(code, options = {}) {
248
220
  } = options;
249
221
  let dispose;
250
222
  const blockingPromises = new Set();
223
+ let headerEmitted = false;
251
224
  const pushTask = task => {
252
225
  if (noScripts) return;
253
- if (!tasks && !firstFlushed) {
254
- tasks = getLocalHeaderScript(renderId);
226
+ if (!headerEmitted) {
227
+ headerEmitted = true;
228
+ tasks += getLocalHeaderScript(renderId);
255
229
  }
256
230
  tasks += task + ";";
257
231
  if (!timer && firstFlushed) {
@@ -277,8 +251,15 @@ function renderToStream(code, options = {}) {
277
251
  onDone,
278
252
  onError: options.onError
279
253
  });
254
+ let rootAssetsSerialized = false;
255
+ const serializeRootAssets = () => {
256
+ if (rootAssetsSerialized) return;
257
+ rootAssetsSerialized = true;
258
+ serializeFragmentAssets("", tracking.boundaryModules, context);
259
+ };
280
260
  const flushEnd = () => {
281
261
  if (!registry.size) {
262
+ serializeRootAssets();
282
263
  queue(() => queue(() => serializer.flush()));
283
264
  }
284
265
  };
@@ -486,13 +467,32 @@ function renderToStream(code, options = {}) {
486
467
  function doShell() {
487
468
  if (shellCompleted) return;
488
469
  if (rootHoles) {
470
+ const pending = [];
489
471
  for (const {
490
472
  id,
491
473
  fn
492
474
  } of rootHoles) {
493
475
  const marker = `<!--rh${id}-->`;
494
476
  const res = resolveSSRNode(fn);
495
- html = html.replace(marker, !res.h.length ? res.t[0] : "");
477
+ if (!res.h.length) {
478
+ html = html.replace(marker, res.t[0]);
479
+ } else {
480
+ let out = res.t[0];
481
+ for (let j = 0; j < res.h.length; j++) {
482
+ const newId = nextHoleId++;
483
+ pending.push({
484
+ id: newId,
485
+ fn: res.h[j]
486
+ });
487
+ out += `<!--rh${newId}-->` + res.t[j + 1];
488
+ }
489
+ html = html.replace(marker, out);
490
+ for (const p of res.p) blockingPromises.add(p);
491
+ }
492
+ }
493
+ if (pending.length) {
494
+ rootHoles = pending;
495
+ return;
496
496
  }
497
497
  rootHoles = null;
498
498
  }
@@ -503,6 +503,7 @@ function renderToStream(code, options = {}) {
503
503
  if (url.endsWith(".css")) headStyles.add(url);
504
504
  }
505
505
  html = injectPreloadLinks(tracking.emittedAssets, html);
506
+ serializeRootAssets();
506
507
  if (tasks.length) html = injectScripts(html, tasks, nonce);
507
508
  buffer.write(html);
508
509
  tasks = "";
@@ -529,48 +530,56 @@ function renderToStream(code, options = {}) {
529
530
  queue(flushEnd);
530
531
  },
531
532
  pipe(w) {
532
- allSettled(blockingPromises).then(() => {
533
- setTimeout(() => {
534
- doShell();
535
- buffer = writable = w;
536
- buffer.write(tmp);
537
- firstFlushed = true;
538
- if (completed) {
539
- dispose();
540
- writable.end();
541
- } else flushEnd();
533
+ function flush() {
534
+ allSettled(blockingPromises).then(() => {
535
+ setTimeout(() => {
536
+ doShell();
537
+ if (!shellCompleted) return flush();
538
+ buffer = writable = w;
539
+ buffer.write(tmp);
540
+ firstFlushed = true;
541
+ if (completed) {
542
+ dispose();
543
+ writable.end();
544
+ } else flushEnd();
545
+ });
542
546
  });
543
- });
547
+ }
548
+ flush();
544
549
  },
545
550
  pipeTo(w) {
546
- return allSettled(blockingPromises).then(() => {
547
- let resolve;
548
- const p = new Promise(r => resolve = r);
549
- setTimeout(() => {
550
- doShell();
551
- const encoder = new TextEncoder();
552
- const writer = w.getWriter();
553
- writable = {
554
- end() {
555
- writer.releaseLock();
556
- w.close().catch(() => {});
557
- resolve();
558
- }
559
- };
560
- buffer = {
561
- write(payload) {
562
- writer.write(encoder.encode(payload)).catch(() => {});
563
- }
564
- };
565
- buffer.write(tmp);
566
- firstFlushed = true;
567
- if (completed) {
568
- dispose();
569
- writable.end();
570
- } else flushEnd();
551
+ let resolve;
552
+ const p = new Promise(r => resolve = r);
553
+ function flush() {
554
+ allSettled(blockingPromises).then(() => {
555
+ setTimeout(() => {
556
+ doShell();
557
+ if (!shellCompleted) return flush();
558
+ const encoder = new TextEncoder();
559
+ const writer = w.getWriter();
560
+ writable = {
561
+ end() {
562
+ writer.releaseLock();
563
+ w.close().catch(() => {});
564
+ resolve();
565
+ }
566
+ };
567
+ buffer = {
568
+ write(payload) {
569
+ writer.write(encoder.encode(payload)).catch(() => {});
570
+ }
571
+ };
572
+ buffer.write(tmp);
573
+ firstFlushed = true;
574
+ if (completed) {
575
+ dispose();
576
+ writable.end();
577
+ } else flushEnd();
578
+ });
571
579
  });
572
- return p;
573
- });
580
+ }
581
+ flush();
582
+ return p;
574
583
  }
575
584
  };
576
585
  }
package/dist/web.cjs CHANGED
@@ -6,9 +6,9 @@ var signals = require('@solidjs/signals');
6
6
  const DOMWithState = {
7
7
  INPUT: {
8
8
  value: 1,
9
- defaultValue: 1,
9
+ defaultValue: 2,
10
10
  checked: 1,
11
- defaultChecked: 1
11
+ defaultChecked: 2
12
12
  },
13
13
  SELECT: {
14
14
  value: 1
@@ -16,26 +16,21 @@ const DOMWithState = {
16
16
  OPTION: {
17
17
  value: 1,
18
18
  selected: 1,
19
- defaultSelected: 1
19
+ defaultSelected: 2
20
20
  },
21
21
  TEXTAREA: {
22
22
  value: 1,
23
- defaultValue: 1
23
+ defaultValue: 2
24
24
  },
25
25
  VIDEO: {
26
26
  muted: 1,
27
- defaultMuted: 1
27
+ defaultMuted: 2
28
28
  },
29
29
  AUDIO: {
30
30
  muted: 1,
31
- defaultMuted: 1
31
+ defaultMuted: 2
32
32
  }
33
33
  };
34
- for (const tagName in DOMWithState) {
35
- for (const propName in DOMWithState[tagName]) {
36
- DOMWithState[tagName]["prop:" + propName] = 1;
37
- }
38
- }
39
34
  const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
40
35
  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"]);
41
36
  const SVGElements = /*#__PURE__*/new Set([
@@ -54,10 +49,14 @@ const DOMElements = /*#__PURE__*/new Set(["html", "base", "head", "link", "meta"
54
49
  "webview",
55
50
  "isindex", "listing", "multicol", "nextid", "noindex", "search"]);
56
51
 
57
- const effect = (fn, effectFn, initial) => solidJs.createRenderEffect(fn, effectFn, initial, {
52
+ const transparentOptions = {
58
53
  transparent: true
59
- });
60
- const memo = (fn, transparent) => transparent ? fn.$r ? fn : signals.createMemo(() => fn(), undefined, {
54
+ };
55
+ const effect = (fn, effectFn, options) => solidJs.createRenderEffect(fn, effectFn, options ? {
56
+ transparent: true,
57
+ ...options
58
+ } : transparentOptions);
59
+ const memo = (fn, transparent) => transparent ? fn.$r ? fn : signals.createMemo(() => fn(), {
61
60
  transparent: true
62
61
  }) : solidJs.createMemo(() => fn());
63
62
 
@@ -120,16 +119,17 @@ function reconcileArrays(parentNode, a, b) {
120
119
 
121
120
  const $$EVENTS = "_$DX_DELEGATE";
122
121
  function render$1(code, element, init, options = {}) {
122
+ const renderRoot = getChildRoot(element);
123
123
  let disposer;
124
124
  solidJs.createRoot(dispose => {
125
125
  disposer = dispose;
126
- element === document ? solidJs.flatten(code) : insert(element, code(), element.firstChild ? null : undefined, init);
126
+ element === document ? solidJs.flatten(code) : insert(element, code(), renderRoot.firstChild ? null : undefined, init);
127
127
  }, {
128
128
  id: options.renderId
129
129
  });
130
130
  return () => {
131
131
  disposer();
132
- element.textContent = "";
132
+ renderRoot.textContent = "";
133
133
  };
134
134
  }
135
135
  function create(html, bypassGuard, flag) {
@@ -266,11 +266,12 @@ function ref(fn, element) {
266
266
  const resolved = solidJs.untrack(fn);
267
267
  solidJs.runWithOwner(null, () => applyRef(resolved, element));
268
268
  }
269
- function insert(parent, accessor, marker, initial) {
269
+ function insert(parent, accessor, marker, initial, options) {
270
+ const childRoot = getChildRoot(parent);
270
271
  const multi = marker !== undefined;
271
272
  if (multi && !initial) initial = [];
272
273
  if (isHydrating(parent)) {
273
- if (!multi && initial === undefined && parent) initial = [...parent.childNodes];
274
+ if (!multi && initial === undefined && parent) initial = [...childRoot.childNodes];
274
275
  if (Array.isArray(initial)) {
275
276
  let j = 0;
276
277
  for (let i = 0; i < initial.length; i++) {
@@ -286,10 +287,10 @@ function insert(parent, accessor, marker, initial) {
286
287
  accessor = memo(accessor, true);
287
288
  if (multi && initial.length === 0) {
288
289
  const placeholder = document.createTextNode("");
289
- parent.insertBefore(placeholder, marker);
290
+ childRoot.insertBefore(placeholder, marker);
290
291
  initial = [placeholder];
291
292
  }
292
- effect(prev => normalize(accessor, prev, multi), (value, current) => insertExpression(parent, value, current, marker), initial);
293
+ effect((prev = initial) => normalize(accessor, prev, multi), (value, current = initial) => insertExpression(parent, value, current, marker), options);
293
294
  }
294
295
  function assign(node, props, skipChildren, prevProps = {}, skipRef = false) {
295
296
  const nodeName = node.nodeName;
@@ -308,8 +309,24 @@ function assign(node, props, skipChildren, prevProps = {}, skipRef = false) {
308
309
  prevProps[prop] = assignProp(node, prop, props[prop], prevProps[prop], skipRef, nodeName);
309
310
  }
310
311
  }
312
+ function loadModuleAssets(mapping) {
313
+ const hy = globalThis._$HY;
314
+ if (!hy) return;
315
+ const pending = [];
316
+ for (const moduleUrl in mapping) {
317
+ if (hy.modules[moduleUrl]) continue;
318
+ const entryUrl = mapping[moduleUrl];
319
+ if (!hy.loading[moduleUrl]) {
320
+ hy.loading[moduleUrl] = import(entryUrl).then(mod => {
321
+ hy.modules[moduleUrl] = mod;
322
+ });
323
+ }
324
+ pending.push(hy.loading[moduleUrl]);
325
+ }
326
+ return pending.length ? Promise.all(pending).then(() => {}) : undefined;
327
+ }
311
328
  function hydrate$1(code, element, options = {}) {
312
- if (globalThis._$HY.done) return render$1(code, element, [...element.childNodes], options);
329
+ if (globalThis._$HY.done) return render$1(code, element, [...getChildRoot(element).childNodes], options);
313
330
  options.renderId ||= "";
314
331
  if (!globalThis._$HY.modules) globalThis._$HY.modules = {};
315
332
  if (!globalThis._$HY.loading) globalThis._$HY.loading = {};
@@ -318,6 +335,7 @@ function hydrate$1(code, element, options = {}) {
318
335
  solidJs.sharedConfig.load = id => globalThis._$HY.r[id];
319
336
  solidJs.sharedConfig.has = id => id in globalThis._$HY.r;
320
337
  solidJs.sharedConfig.gather = root => gatherHydratable(element, root);
338
+ solidJs.sharedConfig.loadModuleAssets = loadModuleAssets;
321
339
  solidJs.sharedConfig.cleanupFragment = id => {
322
340
  const tpl = document.getElementById("pl-" + id);
323
341
  if (tpl) {
@@ -336,9 +354,27 @@ function hydrate$1(code, element, options = {}) {
336
354
  };
337
355
  solidJs.sharedConfig.registry = new Map();
338
356
  solidJs.sharedConfig.hydrating = true;
357
+ const rootMapping = globalThis._$HY.r && globalThis._$HY.r["_assets"];
358
+ if (rootMapping && typeof rootMapping === "object") {
359
+ const p = loadModuleAssets(rootMapping);
360
+ if (p) {
361
+ gatherHydratable(element, options.renderId);
362
+ let disposer;
363
+ p.then(() => {
364
+ try {
365
+ disposer = render$1(code, element, [...getChildRoot(element).childNodes], options);
366
+ } finally {
367
+ solidJs.sharedConfig.hydrating = false;
368
+ }
369
+ }, () => {
370
+ solidJs.sharedConfig.hydrating = false;
371
+ });
372
+ return () => disposer && disposer();
373
+ }
374
+ }
339
375
  try {
340
376
  gatherHydratable(element, options.renderId);
341
- return render$1(code, element, [...element.childNodes], options);
377
+ return render$1(code, element, [...getChildRoot(element).childNodes], options);
342
378
  } finally {
343
379
  solidJs.sharedConfig.hydrating = false;
344
380
  }
@@ -381,7 +417,7 @@ function getNextMarker(start) {
381
417
  return [end, current];
382
418
  }
383
419
  function getFirstChild(node, expectedTag) {
384
- const child = node.firstChild;
420
+ const child = getChildRoot(node).firstChild;
385
421
  return child;
386
422
  }
387
423
  function getNextSibling(node, expectedTag) {
@@ -414,6 +450,9 @@ function runHydrationEvents() {
414
450
  function isHydrating(node) {
415
451
  return solidJs.sharedConfig.hydrating && (!node || node.isConnected);
416
452
  }
453
+ function getChildRoot(node) {
454
+ return node && node.localName === "template" ? node.content : node;
455
+ }
417
456
  function toggleClassKey(node, key, value) {
418
457
  const classNames = key.trim().split(/\s+/);
419
458
  for (let i = 0, nameLen = classNames.length; i < nameLen; i++) node.classList.toggle(classNames[i], value);
@@ -435,7 +474,7 @@ function flattenClassList(list, result) {
435
474
  function assignProp(node, prop, value, prev, skipRef, nodeName) {
436
475
  if (prop === "style") return style(node, value, prev), value;
437
476
  if (prop === "class") return className(node, value, prev), value;
438
- if (value === prev && !DOMWithState[nodeName]?.[prop]) return prev;
477
+ if (value === prev && DOMWithState[nodeName]?.[prop] !== 1) return prev;
439
478
  if (prop === "ref") {
440
479
  if (!skipRef && value) ref(() => value, node);
441
480
  return value;
@@ -518,21 +557,22 @@ function eventHandler(e) {
518
557
  function insertExpression(parent, value, current, marker) {
519
558
  if (isHydrating(parent)) return;
520
559
  if (value === current) return;
560
+ const childRoot = getChildRoot(parent);
521
561
  const t = typeof value,
522
562
  multi = marker !== undefined;
523
563
  if (t === "string" || t === "number") {
524
564
  const tc = typeof current;
525
565
  if (tc === "string" || tc === "number") {
526
- parent.firstChild.data = value;
527
- } else parent.textContent = value;
566
+ childRoot.firstChild.data = value;
567
+ } else childRoot.textContent = value;
528
568
  } else if (value === undefined) {
529
569
  cleanChildren(parent, current, marker);
530
570
  } else if (value.nodeType) {
531
571
  if (Array.isArray(current)) {
532
572
  cleanChildren(parent, current, multi ? marker : null, value);
533
- } else if (current === undefined || !parent.firstChild) {
534
- parent.appendChild(value);
535
- } else parent.replaceChild(value, parent.firstChild);
573
+ } else if (current === undefined || !childRoot.firstChild) {
574
+ childRoot.appendChild(value);
575
+ } else childRoot.replaceChild(value, childRoot.firstChild);
536
576
  } else if (Array.isArray(value)) {
537
577
  const currentArray = current && Array.isArray(current);
538
578
  if (value.length === 0) {
@@ -540,7 +580,7 @@ function insertExpression(parent, value, current, marker) {
540
580
  } else if (currentArray) {
541
581
  if (current.length === 0) {
542
582
  appendNodes(parent, value, marker);
543
- } else reconcileArrays(parent, current, value);
583
+ } else reconcileArrays(childRoot, current, value);
544
584
  } else {
545
585
  current && cleanChildren(parent);
546
586
  appendNodes(parent, value);
@@ -565,9 +605,11 @@ function normalize(value, current, multi, doNotUnwrap) {
565
605
  return value;
566
606
  }
567
607
  function appendNodes(parent, array, marker = null) {
608
+ parent = getChildRoot(parent);
568
609
  for (let i = 0, len = array.length; i < len; i++) parent.insertBefore(array[i], marker);
569
610
  }
570
611
  function cleanChildren(parent, current, marker, replacement) {
612
+ parent = getChildRoot(parent);
571
613
  if (marker === undefined) return parent.textContent = "";
572
614
  if (current.length) {
573
615
  let inserted = false;
@@ -616,17 +658,33 @@ function ssrHydrationKey() {}
616
658
  function resolveSSRNode(node) {}
617
659
  function escape(html) {}
618
660
 
619
- function render(...args) {
620
- const result = render$1(...args);
621
- return result;
622
- }
623
661
  const isServer = false;
624
662
  const isDev = false;
625
- const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
626
- function createElement(tagName, isSVG = false, is = undefined) {
627
- return isSVG ? document.createElementNS(SVG_NAMESPACE, tagName) : document.createElement(tagName, {
628
- is
663
+ function render(code, element, init, options = {}) {
664
+ const renderRoot = element.localName === "template" ? element.content : element;
665
+ let disposer;
666
+ solidJs.createRoot(dispose => {
667
+ disposer = dispose;
668
+ if (element === document) {
669
+ solidJs.flatten(code);
670
+ return;
671
+ }
672
+ const marker = renderRoot.firstChild ? null : undefined;
673
+ try {
674
+ const tree = code();
675
+ insert(element, () => tree, marker, init, {
676
+ schedule: true
677
+ });
678
+ } finally {
679
+ }
680
+ }, {
681
+ id: options.renderId
629
682
  });
683
+ solidJs.flush();
684
+ return () => {
685
+ disposer();
686
+ renderRoot.textContent = "";
687
+ };
630
688
  }
631
689
  const hydrate = (...args) => {
632
690
  solidJs.enableHydration();
@@ -652,6 +710,29 @@ function Portal(props) {
652
710
  });
653
711
  return treeMarker;
654
712
  }
713
+ function createDynamic(component, props) {
714
+ const cached = solidJs.createMemo(component);
715
+ return solidJs.createMemo(() => {
716
+ const component = cached();
717
+ switch (typeof component) {
718
+ case "function":
719
+ return solidJs.untrack(() => component(props));
720
+ case "string":
721
+ const el = solidJs.sharedConfig.hydrating ? getNextElement() : createElement(component, solidJs.untrack(() => props.is));
722
+ spread(el, props);
723
+ return el;
724
+ }
725
+ });
726
+ }
727
+ function Dynamic(props) {
728
+ const others = solidJs.omit(props, "component");
729
+ return createDynamic(() => props.component, others);
730
+ }
731
+ function createElement(tagName, is = undefined) {
732
+ return SVGElements.has(tagName) ? document.createElementNS(Namespaces.svg, tagName) : MathMLElements.has(tagName) ? document.createElementNS(Namespaces.mathml, tagName) : document.createElement(tagName, {
733
+ is
734
+ });
735
+ }
655
736
  function createElementProxy(el, marker) {
656
737
  return new Proxy(el, {
657
738
  get(target, prop) {
@@ -669,25 +750,6 @@ function createElementProxy(el, marker) {
669
750
  }
670
751
  });
671
752
  }
672
- function createDynamic(component, props) {
673
- const cached = solidJs.createMemo(component);
674
- return solidJs.createMemo(() => {
675
- const component = cached();
676
- switch (typeof component) {
677
- case "function":
678
- return solidJs.untrack(() => component(props));
679
- case "string":
680
- const isSvg = SVGElements.has(component);
681
- const el = solidJs.sharedConfig.hydrating ? getNextElement() : createElement(component, isSvg, solidJs.untrack(() => props.is));
682
- spread(el, props, isSvg);
683
- return el;
684
- }
685
- });
686
- }
687
- function Dynamic(props) {
688
- const others = solidJs.omit(props, "component");
689
- return createDynamic(() => props.component, others);
690
- }
691
753
 
692
754
  Object.defineProperty(exports, "Errored", {
693
755
  enumerable: true,
@@ -713,6 +775,10 @@ Object.defineProperty(exports, "NoHydration", {
713
775
  enumerable: true,
714
776
  get: function () { return solidJs.NoHydration; }
715
777
  });
778
+ Object.defineProperty(exports, "Repeat", {
779
+ enumerable: true,
780
+ get: function () { return solidJs.Repeat; }
781
+ });
716
782
  Object.defineProperty(exports, "Reveal", {
717
783
  enumerable: true,
718
784
  get: function () { return solidJs.Reveal; }