@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/dev.js CHANGED
@@ -1,13 +1,13 @@
1
- import { createRenderEffect, createMemo as createMemo$1, sharedConfig, untrack, runWithOwner, flatten, createRoot, omit, $DEVCOMP, enableHydration, enforceLoadingBoundary } from 'solid-js';
2
- export { Errored, For, Hydration, Loading, Match, NoHydration, Reveal, Show, Switch, createComponent, getOwner, merge as mergeProps, untrack } from 'solid-js';
1
+ import { createRenderEffect, createMemo as createMemo$1, sharedConfig, untrack, runWithOwner, flatten, createRoot, omit, $DEVCOMP, enableHydration, enforceLoadingBoundary, flush } from 'solid-js';
2
+ export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, getOwner, merge as mergeProps, untrack } from 'solid-js';
3
3
  import { createMemo } from '@solidjs/signals';
4
4
 
5
5
  const DOMWithState = {
6
6
  INPUT: {
7
7
  value: 1,
8
- defaultValue: 1,
8
+ defaultValue: 2,
9
9
  checked: 1,
10
- defaultChecked: 1
10
+ defaultChecked: 2
11
11
  },
12
12
  SELECT: {
13
13
  value: 1
@@ -15,26 +15,21 @@ const DOMWithState = {
15
15
  OPTION: {
16
16
  value: 1,
17
17
  selected: 1,
18
- defaultSelected: 1
18
+ defaultSelected: 2
19
19
  },
20
20
  TEXTAREA: {
21
21
  value: 1,
22
- defaultValue: 1
22
+ defaultValue: 2
23
23
  },
24
24
  VIDEO: {
25
25
  muted: 1,
26
- defaultMuted: 1
26
+ defaultMuted: 2
27
27
  },
28
28
  AUDIO: {
29
29
  muted: 1,
30
- defaultMuted: 1
30
+ defaultMuted: 2
31
31
  }
32
32
  };
33
- for (const tagName in DOMWithState) {
34
- for (const propName in DOMWithState[tagName]) {
35
- DOMWithState[tagName]["prop:" + propName] = 1;
36
- }
37
- }
38
33
  const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
39
34
  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"]);
40
35
  const SVGElements = /*#__PURE__*/new Set([
@@ -53,10 +48,14 @@ const DOMElements = /*#__PURE__*/new Set(["html", "base", "head", "link", "meta"
53
48
  "webview",
54
49
  "isindex", "listing", "multicol", "nextid", "noindex", "search"]);
55
50
 
56
- const effect = (fn, effectFn, initial) => createRenderEffect(fn, effectFn, initial, {
51
+ const transparentOptions = {
57
52
  transparent: true
58
- });
59
- const memo = (fn, transparent) => transparent ? fn.$r ? fn : createMemo(() => fn(), undefined, {
53
+ };
54
+ const effect = (fn, effectFn, options) => createRenderEffect(fn, effectFn, options ? {
55
+ transparent: true,
56
+ ...options
57
+ } : transparentOptions);
58
+ const memo = (fn, transparent) => transparent ? fn.$r ? fn : createMemo(() => fn(), {
60
59
  transparent: true
61
60
  }) : createMemo$1(() => fn());
62
61
 
@@ -122,16 +121,17 @@ function render$1(code, element, init, options = {}) {
122
121
  if (!element) {
123
122
  throw new Error("The `element` passed to `render(..., element)` doesn't exist. Make sure `element` exists in the document.");
124
123
  }
124
+ const renderRoot = getChildRoot(element);
125
125
  let disposer;
126
126
  createRoot(dispose => {
127
127
  disposer = dispose;
128
- element === document ? flatten(code) : insert(element, code(), element.firstChild ? null : undefined, init);
128
+ element === document ? flatten(code) : insert(element, code(), renderRoot.firstChild ? null : undefined, init);
129
129
  }, {
130
130
  id: options.renderId
131
131
  });
132
132
  return () => {
133
133
  disposer();
134
- element.textContent = "";
134
+ renderRoot.textContent = "";
135
135
  };
136
136
  }
137
137
  function create(html, bypassGuard, flag) {
@@ -270,11 +270,12 @@ function ref(fn, element) {
270
270
  const resolved = untrack(fn);
271
271
  runWithOwner(null, () => applyRef(resolved, element));
272
272
  }
273
- function insert(parent, accessor, marker, initial) {
273
+ function insert(parent, accessor, marker, initial, options) {
274
+ const childRoot = getChildRoot(parent);
274
275
  const multi = marker !== undefined;
275
276
  if (multi && !initial) initial = [];
276
277
  if (isHydrating(parent)) {
277
- if (!multi && initial === undefined && parent) initial = [...parent.childNodes];
278
+ if (!multi && initial === undefined && parent) initial = [...childRoot.childNodes];
278
279
  if (Array.isArray(initial)) {
279
280
  let j = 0;
280
281
  for (let i = 0; i < initial.length; i++) {
@@ -290,10 +291,10 @@ function insert(parent, accessor, marker, initial) {
290
291
  accessor = memo(accessor, true);
291
292
  if (multi && initial.length === 0) {
292
293
  const placeholder = document.createTextNode("");
293
- parent.insertBefore(placeholder, marker);
294
+ childRoot.insertBefore(placeholder, marker);
294
295
  initial = [placeholder];
295
296
  }
296
- effect(prev => normalize(accessor, prev, multi), (value, current) => insertExpression(parent, value, current, marker), initial);
297
+ effect((prev = initial) => normalize(accessor, prev, multi), (value, current = initial) => insertExpression(parent, value, current, marker), options);
297
298
  }
298
299
  function assign(node, props, skipChildren, prevProps = {}, skipRef = false) {
299
300
  const nodeName = node.nodeName;
@@ -312,8 +313,24 @@ function assign(node, props, skipChildren, prevProps = {}, skipRef = false) {
312
313
  prevProps[prop] = assignProp(node, prop, props[prop], prevProps[prop], skipRef, nodeName);
313
314
  }
314
315
  }
316
+ function loadModuleAssets(mapping) {
317
+ const hy = globalThis._$HY;
318
+ if (!hy) return;
319
+ const pending = [];
320
+ for (const moduleUrl in mapping) {
321
+ if (hy.modules[moduleUrl]) continue;
322
+ const entryUrl = mapping[moduleUrl];
323
+ if (!hy.loading[moduleUrl]) {
324
+ hy.loading[moduleUrl] = import(entryUrl).then(mod => {
325
+ hy.modules[moduleUrl] = mod;
326
+ });
327
+ }
328
+ pending.push(hy.loading[moduleUrl]);
329
+ }
330
+ return pending.length ? Promise.all(pending).then(() => {}) : undefined;
331
+ }
315
332
  function hydrate$1(code, element, options = {}) {
316
- if (globalThis._$HY.done) return render$1(code, element, [...element.childNodes], options);
333
+ if (globalThis._$HY.done) return render$1(code, element, [...getChildRoot(element).childNodes], options);
317
334
  options.renderId ||= "";
318
335
  if (!globalThis._$HY.modules) globalThis._$HY.modules = {};
319
336
  if (!globalThis._$HY.loading) globalThis._$HY.loading = {};
@@ -322,6 +339,7 @@ function hydrate$1(code, element, options = {}) {
322
339
  sharedConfig.load = id => globalThis._$HY.r[id];
323
340
  sharedConfig.has = id => id in globalThis._$HY.r;
324
341
  sharedConfig.gather = root => gatherHydratable(element, root);
342
+ sharedConfig.loadModuleAssets = loadModuleAssets;
325
343
  sharedConfig.cleanupFragment = id => {
326
344
  const tpl = document.getElementById("pl-" + id);
327
345
  if (tpl) {
@@ -350,9 +368,27 @@ function hydrate$1(code, element, options = {}) {
350
368
  }
351
369
  };
352
370
  }
371
+ const rootMapping = globalThis._$HY.r && globalThis._$HY.r["_assets"];
372
+ if (rootMapping && typeof rootMapping === "object") {
373
+ const p = loadModuleAssets(rootMapping);
374
+ if (p) {
375
+ gatherHydratable(element, options.renderId);
376
+ let disposer;
377
+ p.then(() => {
378
+ try {
379
+ disposer = render$1(code, element, [...getChildRoot(element).childNodes], options);
380
+ } finally {
381
+ sharedConfig.hydrating = false;
382
+ }
383
+ }, () => {
384
+ sharedConfig.hydrating = false;
385
+ });
386
+ return () => disposer && disposer();
387
+ }
388
+ }
353
389
  try {
354
390
  gatherHydratable(element, options.renderId);
355
- return render$1(code, element, [...element.childNodes], options);
391
+ return render$1(code, element, [...getChildRoot(element).childNodes], options);
356
392
  } finally {
357
393
  sharedConfig.hydrating = false;
358
394
  }
@@ -401,7 +437,7 @@ function getNextMarker(start) {
401
437
  return [end, current];
402
438
  }
403
439
  function getFirstChild(node, expectedTag) {
404
- const child = node.firstChild;
440
+ const child = getChildRoot(node).firstChild;
405
441
  if (isHydrating() && expectedTag && child?.localName !== expectedTag) {
406
442
  const isMissing = !child || child.nodeType !== 1;
407
443
  console.warn("Hydration structure mismatch: expected <" + expectedTag + "> as first child of", node, "\n " + describeSiblings(node, child, expectedTag, isMissing));
@@ -411,20 +447,21 @@ function getFirstChild(node, expectedTag) {
411
447
  function getNextSibling(node, expectedTag) {
412
448
  const sibling = node.nextSibling;
413
449
  if (isHydrating() && expectedTag && sibling?.localName !== expectedTag) {
414
- const parent = node.parentElement;
450
+ const parent = node.parentNode;
415
451
  const isMissing = !sibling || sibling.nodeType !== 1;
416
452
  console.warn("Hydration structure mismatch: expected <" + expectedTag + "> after", node, "in", parent, "\n " + describeSiblings(parent, sibling, expectedTag, isMissing));
417
453
  }
418
454
  return sibling;
419
455
  }
420
456
  function describeSiblings(parent, mismatchChild, expectedTag, isMissing) {
457
+ if (!parent) return `<${expectedTag} \u2190 parent unavailable>`;
421
458
  const children = [];
422
- let child = parent.firstChild;
459
+ let child = getChildRoot(parent).firstChild;
423
460
  while (child) {
424
461
  if (child.nodeType === 1) children.push(child);
425
462
  child = child.nextSibling;
426
463
  }
427
- const pTag = parent.localName;
464
+ const pTag = parent.localName || "#fragment";
428
465
  if (isMissing) {
429
466
  const tags = children.map(c => `<${c.localName}>`).join("");
430
467
  return `<${pTag}>${tags}<${expectedTag} \u2190 missing></${pTag}>`;
@@ -469,6 +506,9 @@ function runHydrationEvents() {
469
506
  function isHydrating(node) {
470
507
  return sharedConfig.hydrating && (!node || node.isConnected);
471
508
  }
509
+ function getChildRoot(node) {
510
+ return node && node.localName === "template" ? node.content : node;
511
+ }
472
512
  function toggleClassKey(node, key, value) {
473
513
  const classNames = key.trim().split(/\s+/);
474
514
  for (let i = 0, nameLen = classNames.length; i < nameLen; i++) node.classList.toggle(classNames[i], value);
@@ -490,7 +530,7 @@ function flattenClassList(list, result) {
490
530
  function assignProp(node, prop, value, prev, skipRef, nodeName) {
491
531
  if (prop === "style") return style(node, value, prev), value;
492
532
  if (prop === "class") return className(node, value, prev), value;
493
- if (value === prev && !DOMWithState[nodeName]?.[prop]) return prev;
533
+ if (value === prev && DOMWithState[nodeName]?.[prop] !== 1) return prev;
494
534
  if (prop === "ref") {
495
535
  if (!skipRef && value) ref(() => value, node);
496
536
  return value;
@@ -573,21 +613,22 @@ function eventHandler(e) {
573
613
  function insertExpression(parent, value, current, marker) {
574
614
  if (isHydrating(parent)) return;
575
615
  if (value === current) return;
616
+ const childRoot = getChildRoot(parent);
576
617
  const t = typeof value,
577
618
  multi = marker !== undefined;
578
619
  if (t === "string" || t === "number") {
579
620
  const tc = typeof current;
580
621
  if (tc === "string" || tc === "number") {
581
- parent.firstChild.data = value;
582
- } else parent.textContent = value;
622
+ childRoot.firstChild.data = value;
623
+ } else childRoot.textContent = value;
583
624
  } else if (value === undefined) {
584
625
  cleanChildren(parent, current, marker);
585
626
  } else if (value.nodeType) {
586
627
  if (Array.isArray(current)) {
587
628
  cleanChildren(parent, current, multi ? marker : null, value);
588
- } else if (current === undefined || !parent.firstChild) {
589
- parent.appendChild(value);
590
- } else parent.replaceChild(value, parent.firstChild);
629
+ } else if (current === undefined || !childRoot.firstChild) {
630
+ childRoot.appendChild(value);
631
+ } else childRoot.replaceChild(value, childRoot.firstChild);
591
632
  } else if (Array.isArray(value)) {
592
633
  const currentArray = current && Array.isArray(current);
593
634
  if (value.length === 0) {
@@ -595,7 +636,7 @@ function insertExpression(parent, value, current, marker) {
595
636
  } else if (currentArray) {
596
637
  if (current.length === 0) {
597
638
  appendNodes(parent, value, marker);
598
- } else reconcileArrays(parent, current, value);
639
+ } else reconcileArrays(childRoot, current, value);
599
640
  } else {
600
641
  current && cleanChildren(parent);
601
642
  appendNodes(parent, value);
@@ -620,9 +661,11 @@ function normalize(value, current, multi, doNotUnwrap) {
620
661
  return value;
621
662
  }
622
663
  function appendNodes(parent, array, marker = null) {
664
+ parent = getChildRoot(parent);
623
665
  for (let i = 0, len = array.length; i < len; i++) parent.insertBefore(array[i], marker);
624
666
  }
625
667
  function cleanChildren(parent, current, marker, replacement) {
668
+ parent = getChildRoot(parent);
626
669
  if (marker === undefined) return parent.textContent = "";
627
670
  if (current.length) {
628
671
  let inserted = false;
@@ -671,19 +714,38 @@ function ssrHydrationKey() {}
671
714
  function resolveSSRNode(node) {}
672
715
  function escape(html) {}
673
716
 
674
- function render(...args) {
675
- enforceLoadingBoundary(true);
676
- const result = render$1(...args);
677
- enforceLoadingBoundary(false);
678
- return result;
679
- }
680
717
  const isServer = false;
681
718
  const isDev = true;
682
- const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
683
- function createElement(tagName, isSVG = false, is = undefined) {
684
- return isSVG ? document.createElementNS(SVG_NAMESPACE, tagName) : document.createElement(tagName, {
685
- is
719
+ function render(code, element, init, options = {}) {
720
+ if (!element) {
721
+ throw new Error("The `element` passed to `render(..., element)` doesn't exist. Make sure `element` exists in the document.");
722
+ }
723
+ const renderRoot = element.localName === "template" ? element.content : element;
724
+ let disposer;
725
+ createRoot(dispose => {
726
+ disposer = dispose;
727
+ if (element === document) {
728
+ flatten(code);
729
+ return;
730
+ }
731
+ const marker = renderRoot.firstChild ? null : undefined;
732
+ enforceLoadingBoundary(true);
733
+ try {
734
+ const tree = code();
735
+ insert(element, () => tree, marker, init, {
736
+ schedule: true
737
+ });
738
+ } finally {
739
+ enforceLoadingBoundary(false);
740
+ }
741
+ }, {
742
+ id: options.renderId
686
743
  });
744
+ flush();
745
+ return () => {
746
+ disposer();
747
+ renderRoot.textContent = "";
748
+ };
687
749
  }
688
750
  const hydrate = (...args) => {
689
751
  enableHydration();
@@ -709,23 +771,6 @@ function Portal(props) {
709
771
  });
710
772
  return treeMarker;
711
773
  }
712
- function createElementProxy(el, marker) {
713
- return new Proxy(el, {
714
- get(target, prop) {
715
- if (prop === "appendChild" || prop === "insertBefore") {
716
- return (...args) => {
717
- Object.defineProperty(args[0], "_$host", {
718
- get: () => marker.parentNode,
719
- configurable: true
720
- });
721
- target[prop](...args);
722
- };
723
- }
724
- const value = Reflect.get(target, prop);
725
- return typeof value === "function" ? value.bind(target) : value;
726
- }
727
- });
728
- }
729
774
  function createDynamic(component, props) {
730
775
  const cached = createMemo$1(component);
731
776
  return createMemo$1(() => {
@@ -737,9 +782,8 @@ function createDynamic(component, props) {
737
782
  });
738
783
  return untrack(() => component(props));
739
784
  case "string":
740
- const isSvg = SVGElements.has(component);
741
- const el = sharedConfig.hydrating ? getNextElement() : createElement(component, isSvg, untrack(() => props.is));
742
- spread(el, props, isSvg);
785
+ const el = sharedConfig.hydrating ? getNextElement() : createElement(component, untrack(() => props.is));
786
+ spread(el, props);
743
787
  return el;
744
788
  }
745
789
  });
@@ -748,5 +792,27 @@ function Dynamic(props) {
748
792
  const others = omit(props, "component");
749
793
  return createDynamic(() => props.component, others);
750
794
  }
795
+ function createElement(tagName, is = undefined) {
796
+ return SVGElements.has(tagName) ? document.createElementNS(Namespaces.svg, tagName) : MathMLElements.has(tagName) ? document.createElementNS(Namespaces.mathml, tagName) : document.createElement(tagName, {
797
+ is
798
+ });
799
+ }
800
+ function createElementProxy(el, marker) {
801
+ return new Proxy(el, {
802
+ get(target, prop) {
803
+ if (prop === "appendChild" || prop === "insertBefore") {
804
+ return (...args) => {
805
+ Object.defineProperty(args[0], "_$host", {
806
+ get: () => marker.parentNode,
807
+ configurable: true
808
+ });
809
+ target[prop](...args);
810
+ };
811
+ }
812
+ const value = Reflect.get(target, prop);
813
+ return typeof value === "function" ? value.bind(target) : value;
814
+ }
815
+ });
816
+ }
751
817
 
752
818
  export { voidFn as Assets, ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, voidFn as HydrationScript, MathMLElements, Namespaces, Portal, RequestContext, SVGElements, 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 };
package/dist/server.cjs CHANGED
@@ -5,39 +5,6 @@ var seroval = require('seroval');
5
5
  var web = require('seroval-plugins/web');
6
6
  var signals = require('@solidjs/signals');
7
7
 
8
- const DOMWithState = {
9
- INPUT: {
10
- value: 1,
11
- defaultValue: 1,
12
- checked: 1,
13
- defaultChecked: 1
14
- },
15
- SELECT: {
16
- value: 1
17
- },
18
- OPTION: {
19
- value: 1,
20
- selected: 1,
21
- defaultSelected: 1
22
- },
23
- TEXTAREA: {
24
- value: 1,
25
- defaultValue: 1
26
- },
27
- VIDEO: {
28
- muted: 1,
29
- defaultMuted: 1
30
- },
31
- AUDIO: {
32
- muted: 1,
33
- defaultMuted: 1
34
- }
35
- };
36
- for (const tagName in DOMWithState) {
37
- for (const propName in DOMWithState[tagName]) {
38
- DOMWithState[tagName]["prop:" + propName] = 1;
39
- }
40
- }
41
8
  const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
42
9
  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"]);
43
10
  const SVGElements = /*#__PURE__*/new Set([
@@ -56,16 +23,20 @@ const DOMElements = /*#__PURE__*/new Set(["html", "base", "head", "link", "meta"
56
23
  "webview",
57
24
  "isindex", "listing", "multicol", "nextid", "noindex", "search"]);
58
25
 
59
- const effect = (fn, effectFn, initial) => solidJs.createRenderEffect(fn, effectFn, initial, {
26
+ const transparentOptions = {
60
27
  transparent: true
61
- });
62
- const memo = (fn, transparent) => transparent ? fn.$r ? fn : signals.createMemo(() => fn(), undefined, {
28
+ };
29
+ const effect = (fn, effectFn, options) => solidJs.createRenderEffect(fn, effectFn, options ? {
30
+ transparent: true,
31
+ ...options
32
+ } : transparentOptions);
33
+ const memo = (fn, transparent) => transparent ? fn.$r ? fn : signals.createMemo(() => fn(), {
63
34
  transparent: true
64
35
  }) : solidJs.createMemo(() => fn());
65
36
 
66
- const ES2017FLAG = seroval.Feature.AggregateError
67
- | seroval.Feature.BigIntTypedArray;
68
- const GLOBAL_IDENTIFIER = '_$HY.r';
37
+ const ES2017FLAG = seroval.Feature.AggregateError |
38
+ seroval.Feature.BigIntTypedArray;
39
+ const GLOBAL_IDENTIFIER = "_$HY.r";
69
40
  function createSerializer({
70
41
  onData,
71
42
  onDone,
@@ -88,7 +59,7 @@ function createSerializer({
88
59
  });
89
60
  }
90
61
  function getLocalHeaderScript(id) {
91
- return seroval.getCrossReferenceHeader(id) + ';';
62
+ return seroval.getCrossReferenceHeader(id) + ";";
92
63
  }
93
64
 
94
65
  function resolveAssets(moduleUrl, manifest) {
@@ -144,11 +115,11 @@ function createAssetTracking() {
144
115
  currentBoundaryId = v;
145
116
  },
146
117
  registerModule(moduleUrl, entryUrl) {
147
- if (!currentBoundaryId) return;
148
- let map = boundaryModules.get(currentBoundaryId);
118
+ const id = currentBoundaryId || "";
119
+ let map = boundaryModules.get(id);
149
120
  if (!map) {
150
121
  map = {};
151
- boundaryModules.set(currentBoundaryId, map);
122
+ boundaryModules.set(id, map);
152
123
  }
153
124
  map[moduleUrl] = entryUrl;
154
125
  },
@@ -176,7 +147,7 @@ function applyAssetTracking(context, tracking, manifest) {
176
147
  if (manifest) context.resolveAssets = moduleUrl => resolveAssets(moduleUrl, manifest);
177
148
  }
178
149
  const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
179
- 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])}`;
150
+ 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])}`;
180
151
  function renderToString(code, options = {}) {
181
152
  const {
182
153
  renderId = "",
@@ -231,6 +202,7 @@ function renderToString(code, options = {}) {
231
202
  }, {
232
203
  id: renderId
233
204
  });
205
+ serializeFragmentAssets("", tracking.boundaryModules, solidJs.sharedConfig.context);
234
206
  solidJs.sharedConfig.context.noHydrate = true;
235
207
  serializer.close();
236
208
  html = injectAssets(solidJs.sharedConfig.context.assets, html);
@@ -249,10 +221,12 @@ function renderToStream(code, options = {}) {
249
221
  } = options;
250
222
  let dispose;
251
223
  const blockingPromises = new Set();
224
+ let headerEmitted = false;
252
225
  const pushTask = task => {
253
226
  if (noScripts) return;
254
- if (!tasks && !firstFlushed) {
255
- tasks = getLocalHeaderScript(renderId);
227
+ if (!headerEmitted) {
228
+ headerEmitted = true;
229
+ tasks += getLocalHeaderScript(renderId);
256
230
  }
257
231
  tasks += task + ";";
258
232
  if (!timer && firstFlushed) {
@@ -278,8 +252,15 @@ function renderToStream(code, options = {}) {
278
252
  onDone,
279
253
  onError: options.onError
280
254
  });
255
+ let rootAssetsSerialized = false;
256
+ const serializeRootAssets = () => {
257
+ if (rootAssetsSerialized) return;
258
+ rootAssetsSerialized = true;
259
+ serializeFragmentAssets("", tracking.boundaryModules, context);
260
+ };
281
261
  const flushEnd = () => {
282
262
  if (!registry.size) {
263
+ serializeRootAssets();
283
264
  queue(() => queue(() => serializer.flush()));
284
265
  }
285
266
  };
@@ -487,13 +468,32 @@ function renderToStream(code, options = {}) {
487
468
  function doShell() {
488
469
  if (shellCompleted) return;
489
470
  if (rootHoles) {
471
+ const pending = [];
490
472
  for (const {
491
473
  id,
492
474
  fn
493
475
  } of rootHoles) {
494
476
  const marker = `<!--rh${id}-->`;
495
477
  const res = resolveSSRNode(fn);
496
- html = html.replace(marker, !res.h.length ? res.t[0] : "");
478
+ if (!res.h.length) {
479
+ html = html.replace(marker, res.t[0]);
480
+ } else {
481
+ let out = res.t[0];
482
+ for (let j = 0; j < res.h.length; j++) {
483
+ const newId = nextHoleId++;
484
+ pending.push({
485
+ id: newId,
486
+ fn: res.h[j]
487
+ });
488
+ out += `<!--rh${newId}-->` + res.t[j + 1];
489
+ }
490
+ html = html.replace(marker, out);
491
+ for (const p of res.p) blockingPromises.add(p);
492
+ }
493
+ }
494
+ if (pending.length) {
495
+ rootHoles = pending;
496
+ return;
497
497
  }
498
498
  rootHoles = null;
499
499
  }
@@ -504,6 +504,7 @@ function renderToStream(code, options = {}) {
504
504
  if (url.endsWith(".css")) headStyles.add(url);
505
505
  }
506
506
  html = injectPreloadLinks(tracking.emittedAssets, html);
507
+ serializeRootAssets();
507
508
  if (tasks.length) html = injectScripts(html, tasks, nonce);
508
509
  buffer.write(html);
509
510
  tasks = "";
@@ -530,48 +531,56 @@ function renderToStream(code, options = {}) {
530
531
  queue(flushEnd);
531
532
  },
532
533
  pipe(w) {
533
- allSettled(blockingPromises).then(() => {
534
- setTimeout(() => {
535
- doShell();
536
- buffer = writable = w;
537
- buffer.write(tmp);
538
- firstFlushed = true;
539
- if (completed) {
540
- dispose();
541
- writable.end();
542
- } else flushEnd();
534
+ function flush() {
535
+ allSettled(blockingPromises).then(() => {
536
+ setTimeout(() => {
537
+ doShell();
538
+ if (!shellCompleted) return flush();
539
+ buffer = writable = w;
540
+ buffer.write(tmp);
541
+ firstFlushed = true;
542
+ if (completed) {
543
+ dispose();
544
+ writable.end();
545
+ } else flushEnd();
546
+ });
543
547
  });
544
- });
548
+ }
549
+ flush();
545
550
  },
546
551
  pipeTo(w) {
547
- return allSettled(blockingPromises).then(() => {
548
- let resolve;
549
- const p = new Promise(r => resolve = r);
550
- setTimeout(() => {
551
- doShell();
552
- const encoder = new TextEncoder();
553
- const writer = w.getWriter();
554
- writable = {
555
- end() {
556
- writer.releaseLock();
557
- w.close().catch(() => {});
558
- resolve();
559
- }
560
- };
561
- buffer = {
562
- write(payload) {
563
- writer.write(encoder.encode(payload)).catch(() => {});
564
- }
565
- };
566
- buffer.write(tmp);
567
- firstFlushed = true;
568
- if (completed) {
569
- dispose();
570
- writable.end();
571
- } else flushEnd();
552
+ let resolve;
553
+ const p = new Promise(r => resolve = r);
554
+ function flush() {
555
+ allSettled(blockingPromises).then(() => {
556
+ setTimeout(() => {
557
+ doShell();
558
+ if (!shellCompleted) return flush();
559
+ const encoder = new TextEncoder();
560
+ const writer = w.getWriter();
561
+ writable = {
562
+ end() {
563
+ writer.releaseLock();
564
+ w.close().catch(() => {});
565
+ resolve();
566
+ }
567
+ };
568
+ buffer = {
569
+ write(payload) {
570
+ writer.write(encoder.encode(payload)).catch(() => {});
571
+ }
572
+ };
573
+ buffer.write(tmp);
574
+ firstFlushed = true;
575
+ if (completed) {
576
+ dispose();
577
+ writable.end();
578
+ } else flushEnd();
579
+ });
572
580
  });
573
- return p;
574
- });
581
+ }
582
+ flush();
583
+ return p;
575
584
  }
576
585
  };
577
586
  }