solid-js 1.6.7 → 1.6.9

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.
@@ -134,6 +134,7 @@ declare type HydrationContext = {
134
134
  resources: Record<string, any>;
135
135
  suspense: Record<string, SuspenseContextType>;
136
136
  registerFragment: (v: string) => (v?: string, err?: any) => boolean;
137
+ lazy: Record<string, Promise<any>>;
137
138
  async?: boolean;
138
139
  noHydrate: boolean;
139
140
  };
@@ -23,7 +23,7 @@ function createRenderer$1({
23
23
  while (typeof current === "function") current = current();
24
24
  if (value === current) return current;
25
25
  const t = typeof value,
26
- multi = marker !== undefined;
26
+ multi = marker !== undefined;
27
27
  if (t === "string" || t === "number") {
28
28
  if (t === "number") value = value.toString();
29
29
  if (multi) {
@@ -85,7 +85,7 @@ function createRenderer$1({
85
85
  let dynamic = false;
86
86
  for (let i = 0, len = array.length; i < len; i++) {
87
87
  let item = array[i],
88
- t;
88
+ t;
89
89
  if (item == null || item === true || item === false) ; else if (Array.isArray(item)) {
90
90
  dynamic = normalizeIncomingArray(normalized, item) || dynamic;
91
91
  } else if ((t = typeof item) === "string" || t === "number") {
@@ -104,12 +104,12 @@ function createRenderer$1({
104
104
  }
105
105
  function reconcileArrays(parentNode, a, b) {
106
106
  let bLength = b.length,
107
- aEnd = a.length,
108
- bEnd = bLength,
109
- aStart = 0,
110
- bStart = 0,
111
- after = getNextSibling(a[aEnd - 1]),
112
- map = null;
107
+ aEnd = a.length,
108
+ bEnd = bLength,
109
+ aStart = 0,
110
+ bStart = 0,
111
+ after = getNextSibling(a[aEnd - 1]),
112
+ map = null;
113
113
  while (aStart < aEnd || bStart < bEnd) {
114
114
  if (a[aStart] === b[bStart]) {
115
115
  aStart++;
@@ -143,8 +143,8 @@ function createRenderer$1({
143
143
  if (index != null) {
144
144
  if (bStart < index && index < bEnd) {
145
145
  let i = aStart,
146
- sequence = 1,
147
- t;
146
+ sequence = 1,
147
+ t;
148
148
  while (++i < aEnd && i < bEnd) {
149
149
  if ((t = map.get(a[i])) == null || t !== index + sequence) break;
150
150
  sequence++;
@@ -21,7 +21,7 @@ function createRenderer$1({
21
21
  while (typeof current === "function") current = current();
22
22
  if (value === current) return current;
23
23
  const t = typeof value,
24
- multi = marker !== undefined;
24
+ multi = marker !== undefined;
25
25
  if (t === "string" || t === "number") {
26
26
  if (t === "number") value = value.toString();
27
27
  if (multi) {
@@ -83,7 +83,7 @@ function createRenderer$1({
83
83
  let dynamic = false;
84
84
  for (let i = 0, len = array.length; i < len; i++) {
85
85
  let item = array[i],
86
- t;
86
+ t;
87
87
  if (item == null || item === true || item === false) ; else if (Array.isArray(item)) {
88
88
  dynamic = normalizeIncomingArray(normalized, item) || dynamic;
89
89
  } else if ((t = typeof item) === "string" || t === "number") {
@@ -102,12 +102,12 @@ function createRenderer$1({
102
102
  }
103
103
  function reconcileArrays(parentNode, a, b) {
104
104
  let bLength = b.length,
105
- aEnd = a.length,
106
- bEnd = bLength,
107
- aStart = 0,
108
- bStart = 0,
109
- after = getNextSibling(a[aEnd - 1]),
110
- map = null;
105
+ aEnd = a.length,
106
+ bEnd = bLength,
107
+ aStart = 0,
108
+ bStart = 0,
109
+ after = getNextSibling(a[aEnd - 1]),
110
+ map = null;
111
111
  while (aStart < aEnd || bStart < bEnd) {
112
112
  if (a[aStart] === b[bStart]) {
113
113
  aStart++;
@@ -141,8 +141,8 @@ function createRenderer$1({
141
141
  if (index != null) {
142
142
  if (bStart < index && index < bEnd) {
143
143
  let i = aStart,
144
- sequence = 1,
145
- t;
144
+ sequence = 1,
145
+ t;
146
146
  while (++i < aEnd && i < bEnd) {
147
147
  if ((t = map.get(a[i])) == null || t !== index + sequence) break;
148
148
  sequence++;
@@ -23,7 +23,7 @@ function createRenderer$1({
23
23
  while (typeof current === "function") current = current();
24
24
  if (value === current) return current;
25
25
  const t = typeof value,
26
- multi = marker !== undefined;
26
+ multi = marker !== undefined;
27
27
  if (t === "string" || t === "number") {
28
28
  if (t === "number") value = value.toString();
29
29
  if (multi) {
@@ -85,7 +85,7 @@ function createRenderer$1({
85
85
  let dynamic = false;
86
86
  for (let i = 0, len = array.length; i < len; i++) {
87
87
  let item = array[i],
88
- t;
88
+ t;
89
89
  if (item == null || item === true || item === false) ; else if (Array.isArray(item)) {
90
90
  dynamic = normalizeIncomingArray(normalized, item) || dynamic;
91
91
  } else if ((t = typeof item) === "string" || t === "number") {
@@ -104,12 +104,12 @@ function createRenderer$1({
104
104
  }
105
105
  function reconcileArrays(parentNode, a, b) {
106
106
  let bLength = b.length,
107
- aEnd = a.length,
108
- bEnd = bLength,
109
- aStart = 0,
110
- bStart = 0,
111
- after = getNextSibling(a[aEnd - 1]),
112
- map = null;
107
+ aEnd = a.length,
108
+ bEnd = bLength,
109
+ aStart = 0,
110
+ bStart = 0,
111
+ after = getNextSibling(a[aEnd - 1]),
112
+ map = null;
113
113
  while (aStart < aEnd || bStart < bEnd) {
114
114
  if (a[aStart] === b[bStart]) {
115
115
  aStart++;
@@ -143,8 +143,8 @@ function createRenderer$1({
143
143
  if (index != null) {
144
144
  if (bStart < index && index < bEnd) {
145
145
  let i = aStart,
146
- sequence = 1,
147
- t;
146
+ sequence = 1,
147
+ t;
148
148
  while (++i < aEnd && i < bEnd) {
149
149
  if ((t = map.get(a[i])) == null || t !== index + sequence) break;
150
150
  sequence++;
@@ -21,7 +21,7 @@ function createRenderer$1({
21
21
  while (typeof current === "function") current = current();
22
22
  if (value === current) return current;
23
23
  const t = typeof value,
24
- multi = marker !== undefined;
24
+ multi = marker !== undefined;
25
25
  if (t === "string" || t === "number") {
26
26
  if (t === "number") value = value.toString();
27
27
  if (multi) {
@@ -83,7 +83,7 @@ function createRenderer$1({
83
83
  let dynamic = false;
84
84
  for (let i = 0, len = array.length; i < len; i++) {
85
85
  let item = array[i],
86
- t;
86
+ t;
87
87
  if (item == null || item === true || item === false) ; else if (Array.isArray(item)) {
88
88
  dynamic = normalizeIncomingArray(normalized, item) || dynamic;
89
89
  } else if ((t = typeof item) === "string" || t === "number") {
@@ -102,12 +102,12 @@ function createRenderer$1({
102
102
  }
103
103
  function reconcileArrays(parentNode, a, b) {
104
104
  let bLength = b.length,
105
- aEnd = a.length,
106
- bEnd = bLength,
107
- aStart = 0,
108
- bStart = 0,
109
- after = getNextSibling(a[aEnd - 1]),
110
- map = null;
105
+ aEnd = a.length,
106
+ bEnd = bLength,
107
+ aStart = 0,
108
+ bStart = 0,
109
+ after = getNextSibling(a[aEnd - 1]),
110
+ map = null;
111
111
  while (aStart < aEnd || bStart < bEnd) {
112
112
  if (a[aStart] === b[bStart]) {
113
113
  aStart++;
@@ -141,8 +141,8 @@ function createRenderer$1({
141
141
  if (index != null) {
142
142
  if (bStart < index && index < bEnd) {
143
143
  let i = aStart,
144
- sequence = 1,
145
- t;
144
+ sequence = 1,
145
+ t;
146
146
  while (++i < aEnd && i < bEnd) {
147
147
  if ((t = map.get(a[i])) == null || t !== index + sequence) break;
148
148
  sequence++;
package/web/dist/dev.cjs CHANGED
@@ -31,12 +31,12 @@ const DOMElements = /*#__PURE__*/new Set(["html", "base", "head", "link", "meta"
31
31
 
32
32
  function reconcileArrays(parentNode, a, b) {
33
33
  let bLength = b.length,
34
- aEnd = a.length,
35
- bEnd = bLength,
36
- aStart = 0,
37
- bStart = 0,
38
- after = a[aEnd - 1].nextSibling,
39
- map = null;
34
+ aEnd = a.length,
35
+ bEnd = bLength,
36
+ aStart = 0,
37
+ bStart = 0,
38
+ after = a[aEnd - 1].nextSibling,
39
+ map = null;
40
40
  while (aStart < aEnd || bStart < bEnd) {
41
41
  if (a[aStart] === b[bStart]) {
42
42
  aStart++;
@@ -70,8 +70,8 @@ function reconcileArrays(parentNode, a, b) {
70
70
  if (index != null) {
71
71
  if (bStart < index && index < bEnd) {
72
72
  let i = aStart,
73
- sequence = 1,
74
- t;
73
+ sequence = 1,
74
+ t;
75
75
  while (++i < aEnd && i < bEnd) {
76
76
  if ((t = map.get(a[i])) == null || t !== index + sequence) break;
77
77
  sequence++;
@@ -144,7 +144,7 @@ function addEventListener(node, name, handler, delegate) {
144
144
  }
145
145
  function classList(node, value, prev = {}) {
146
146
  const classKeys = Object.keys(value || {}),
147
- prevKeys = Object.keys(prev);
147
+ prevKeys = Object.keys(prev);
148
148
  let i, len;
149
149
  for (i = 0, len = prevKeys.length; i < len; i++) {
150
150
  const key = prevKeys[i];
@@ -154,7 +154,7 @@ function classList(node, value, prev = {}) {
154
154
  }
155
155
  for (i = 0, len = classKeys.length; i < len; i++) {
156
156
  const key = classKeys[i],
157
- classValue = !!value[key];
157
+ classValue = !!value[key];
158
158
  if (!key || key === "undefined" || prev[key] === classValue || !classValue) continue;
159
159
  toggleClassKey(node, key, true);
160
160
  prev[key] = classValue;
@@ -261,8 +261,8 @@ function getNextMatch(el, nodeName) {
261
261
  }
262
262
  function getNextMarker(start) {
263
263
  let end = start,
264
- count = 0,
265
- current = [];
264
+ count = 0,
265
+ current = [];
266
266
  if (solidJs.sharedConfig.context) {
267
267
  while (end) {
268
268
  if (end.nodeType === 8) {
@@ -354,7 +354,14 @@ function eventHandler(e) {
354
354
  });
355
355
  if (solidJs.sharedConfig.registry && !solidJs.sharedConfig.done) {
356
356
  solidJs.sharedConfig.done = true;
357
- document.querySelectorAll("[id^=pl-]").forEach(elem => elem.remove());
357
+ document.querySelectorAll("[id^=pl-]").forEach(elem => {
358
+ while (elem && elem.nodeType !== 8 && elem.nodeValue !== "pl-" + e) {
359
+ let x = elem.nextSibling;
360
+ elem.remove();
361
+ elem = x;
362
+ }
363
+ elem && elem.remove();
364
+ });
358
365
  }
359
366
  while (node) {
360
367
  const handler = node[key];
@@ -371,7 +378,7 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
371
378
  while (typeof current === "function") current = current();
372
379
  if (value === current) return current;
373
380
  const t = typeof value,
374
- multi = marker !== undefined;
381
+ multi = marker !== undefined;
375
382
  parent = multi && current[0] && current[0].parentNode || parent;
376
383
  if (t === "string" || t === "number") {
377
384
  if (solidJs.sharedConfig.context) return current;
@@ -438,7 +445,7 @@ function normalizeIncomingArray(normalized, array, current, unwrap) {
438
445
  let dynamic = false;
439
446
  for (let i = 0, len = array.length; i < len; i++) {
440
447
  let item = array[i],
441
- prev = current && current[i];
448
+ prev = current && current[i];
442
449
  if (item instanceof Node) {
443
450
  normalized.push(item);
444
451
  } else if (item == null || item === true || item === false) ; else if (Array.isArray(item)) {
@@ -532,10 +539,10 @@ const hydrate = (...args) => {
532
539
  };
533
540
  function Portal(props) {
534
541
  const {
535
- useShadow
536
- } = props,
537
- marker = document.createTextNode(""),
538
- mount = props.mount || document.body;
542
+ useShadow
543
+ } = props,
544
+ marker = document.createTextNode(""),
545
+ mount = props.mount || document.body;
539
546
  function renderPortal() {
540
547
  if (solidJs.sharedConfig.context) {
541
548
  const [s, set] = solidJs.createSignal(false);
@@ -552,9 +559,9 @@ function Portal(props) {
552
559
  });
553
560
  } else {
554
561
  const container = createElement(props.isSVG ? "g" : "div", props.isSVG),
555
- renderRoot = useShadow && container.attachShadow ? container.attachShadow({
556
- mode: "open"
557
- }) : container;
562
+ renderRoot = useShadow && container.attachShadow ? container.attachShadow({
563
+ mode: "open"
564
+ }) : container;
558
565
  Object.defineProperty(container, "_$host", {
559
566
  get() {
560
567
  return marker.parentNode;
package/web/dist/dev.js CHANGED
@@ -30,12 +30,12 @@ const DOMElements = /*#__PURE__*/new Set(["html", "base", "head", "link", "meta"
30
30
 
31
31
  function reconcileArrays(parentNode, a, b) {
32
32
  let bLength = b.length,
33
- aEnd = a.length,
34
- bEnd = bLength,
35
- aStart = 0,
36
- bStart = 0,
37
- after = a[aEnd - 1].nextSibling,
38
- map = null;
33
+ aEnd = a.length,
34
+ bEnd = bLength,
35
+ aStart = 0,
36
+ bStart = 0,
37
+ after = a[aEnd - 1].nextSibling,
38
+ map = null;
39
39
  while (aStart < aEnd || bStart < bEnd) {
40
40
  if (a[aStart] === b[bStart]) {
41
41
  aStart++;
@@ -69,8 +69,8 @@ function reconcileArrays(parentNode, a, b) {
69
69
  if (index != null) {
70
70
  if (bStart < index && index < bEnd) {
71
71
  let i = aStart,
72
- sequence = 1,
73
- t;
72
+ sequence = 1,
73
+ t;
74
74
  while (++i < aEnd && i < bEnd) {
75
75
  if ((t = map.get(a[i])) == null || t !== index + sequence) break;
76
76
  sequence++;
@@ -143,7 +143,7 @@ function addEventListener(node, name, handler, delegate) {
143
143
  }
144
144
  function classList(node, value, prev = {}) {
145
145
  const classKeys = Object.keys(value || {}),
146
- prevKeys = Object.keys(prev);
146
+ prevKeys = Object.keys(prev);
147
147
  let i, len;
148
148
  for (i = 0, len = prevKeys.length; i < len; i++) {
149
149
  const key = prevKeys[i];
@@ -153,7 +153,7 @@ function classList(node, value, prev = {}) {
153
153
  }
154
154
  for (i = 0, len = classKeys.length; i < len; i++) {
155
155
  const key = classKeys[i],
156
- classValue = !!value[key];
156
+ classValue = !!value[key];
157
157
  if (!key || key === "undefined" || prev[key] === classValue || !classValue) continue;
158
158
  toggleClassKey(node, key, true);
159
159
  prev[key] = classValue;
@@ -260,8 +260,8 @@ function getNextMatch(el, nodeName) {
260
260
  }
261
261
  function getNextMarker(start) {
262
262
  let end = start,
263
- count = 0,
264
- current = [];
263
+ count = 0,
264
+ current = [];
265
265
  if (sharedConfig.context) {
266
266
  while (end) {
267
267
  if (end.nodeType === 8) {
@@ -353,7 +353,14 @@ function eventHandler(e) {
353
353
  });
354
354
  if (sharedConfig.registry && !sharedConfig.done) {
355
355
  sharedConfig.done = true;
356
- document.querySelectorAll("[id^=pl-]").forEach(elem => elem.remove());
356
+ document.querySelectorAll("[id^=pl-]").forEach(elem => {
357
+ while (elem && elem.nodeType !== 8 && elem.nodeValue !== "pl-" + e) {
358
+ let x = elem.nextSibling;
359
+ elem.remove();
360
+ elem = x;
361
+ }
362
+ elem && elem.remove();
363
+ });
357
364
  }
358
365
  while (node) {
359
366
  const handler = node[key];
@@ -370,7 +377,7 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
370
377
  while (typeof current === "function") current = current();
371
378
  if (value === current) return current;
372
379
  const t = typeof value,
373
- multi = marker !== undefined;
380
+ multi = marker !== undefined;
374
381
  parent = multi && current[0] && current[0].parentNode || parent;
375
382
  if (t === "string" || t === "number") {
376
383
  if (sharedConfig.context) return current;
@@ -437,7 +444,7 @@ function normalizeIncomingArray(normalized, array, current, unwrap) {
437
444
  let dynamic = false;
438
445
  for (let i = 0, len = array.length; i < len; i++) {
439
446
  let item = array[i],
440
- prev = current && current[i];
447
+ prev = current && current[i];
441
448
  if (item instanceof Node) {
442
449
  normalized.push(item);
443
450
  } else if (item == null || item === true || item === false) ; else if (Array.isArray(item)) {
@@ -531,10 +538,10 @@ const hydrate = (...args) => {
531
538
  };
532
539
  function Portal(props) {
533
540
  const {
534
- useShadow
535
- } = props,
536
- marker = document.createTextNode(""),
537
- mount = props.mount || document.body;
541
+ useShadow
542
+ } = props,
543
+ marker = document.createTextNode(""),
544
+ mount = props.mount || document.body;
538
545
  function renderPortal() {
539
546
  if (sharedConfig.context) {
540
547
  const [s, set] = createSignal(false);
@@ -551,9 +558,9 @@ function Portal(props) {
551
558
  });
552
559
  } else {
553
560
  const container = createElement(props.isSVG ? "g" : "div", props.isSVG),
554
- renderRoot = useShadow && container.attachShadow ? container.attachShadow({
555
- mode: "open"
556
- }) : container;
561
+ renderRoot = useShadow && container.attachShadow ? container.attachShadow({
562
+ mode: "open"
563
+ }) : container;
557
564
  Object.defineProperty(container, "_$host", {
558
565
  get() {
559
566
  return marker.parentNode;
@@ -261,13 +261,14 @@ function toRefParam(index) {
261
261
  return ref;
262
262
  }
263
263
 
264
- const REPLACE_SCRIPT = `function $df(e,t,d,l){d=document.getElementById(e),(l=document.getElementById("pl-"+e))&&l.replaceWith(...d.childNodes),d.remove(),_$HY.set(e,t),_$HY.fe(e)}`;
264
+ const REPLACE_SCRIPT = `function $df(e,t,n,o,d){if(n=document.getElementById(e),o=document.getElementById("pl-"+e)){for(;o&&8!==o.nodeType&&o.nodeValue!=="pl-"+e;)d=o.nextSibling,o.remove(),o=d;o.replaceWith(n.content)}n.remove(),_$HY.set(e,t),_$HY.fe(e)}`;
265
265
  function renderToString(code, options = {}) {
266
266
  let scripts = "";
267
267
  solidJs.sharedConfig.context = {
268
268
  id: options.renderId || "",
269
269
  count: 0,
270
270
  suspense: {},
271
+ lazy: {},
271
272
  assets: [],
272
273
  nonce: options.nonce,
273
274
  writeResource(id, p, error) {
@@ -349,6 +350,7 @@ function renderToStream(code, options = {}) {
349
350
  count: 0,
350
351
  async: true,
351
352
  resources: {},
353
+ lazy: {},
352
354
  suspense: {},
353
355
  assets: [],
354
356
  nonce,
@@ -390,7 +392,7 @@ function renderToStream(code, options = {}) {
390
392
  Promise.resolve().then(() => html = replacePlaceholder(html, key, value !== undefined ? value : ""));
391
393
  error && pushTask(serializeSet(dedupe, key, error, serializeError));
392
394
  } else {
393
- buffer.write(`<div hidden id="${key}">${value !== undefined ? value : " "}</div>`);
395
+ buffer.write(`<template id="${key}">${value !== undefined ? value : " "}</template>`);
394
396
  pushTask(`${keys.length ? keys.map(k => `_$HY.unset("${k}")`).join(";") + ";" : ""}$df("${key}"${error ? "," + serializeError(error) : ""})${!scriptFlushed ? ";" + REPLACE_SCRIPT : ""}`);
395
397
  scriptFlushed = true;
396
398
  }
@@ -493,10 +495,10 @@ function ssr(t, ...nodes) {
493
495
  function ssrClassList(value) {
494
496
  if (!value) return "";
495
497
  let classKeys = Object.keys(value),
496
- result = "";
498
+ result = "";
497
499
  for (let i = 0, len = classKeys.length; i < len; i++) {
498
500
  const key = classKeys[i],
499
- classValue = !!value[key];
501
+ classValue = !!value[key];
500
502
  if (!key || key === "undefined" || !classValue) continue;
501
503
  i && (result += " ");
502
504
  result += key;
@@ -577,7 +579,7 @@ function escape(s, attr) {
577
579
  let iAmp = s.indexOf("&");
578
580
  if (iDelim < 0 && iAmp < 0) return s;
579
581
  let left = 0,
580
- out = "";
582
+ out = "";
581
583
  while (iDelim >= 0 && iAmp >= 0) {
582
584
  if (iDelim < iAmp) {
583
585
  if (left < iDelim) out += s.substring(left, iDelim);
@@ -641,7 +643,8 @@ function generateHydrationScript({
641
643
  function Hydration(props) {
642
644
  if (!solidJs.sharedConfig.context.noHydrate) return props.children;
643
645
  const context = solidJs.sharedConfig.context;
644
- solidJs.sharedConfig.context = { ...context,
646
+ solidJs.sharedConfig.context = {
647
+ ...context,
645
648
  count: 0,
646
649
  id: `${context.id}${context.count++}-`,
647
650
  noHydrate: false
@@ -699,21 +702,12 @@ function serializeSet(registry, key, value, serializer = stringify) {
699
702
  return `_$HY.set("${key}", ${serializer(value)})`;
700
703
  }
701
704
  function replacePlaceholder(html, key, value) {
702
- const nextRegex = /(<[/]?span[^>]*>)/g;
703
- const marker = `<span id="pl-${key}">`;
705
+ const marker = `<template id="pl-${key}">`;
706
+ const close = `<!pl-${key}>`;
704
707
  const first = html.indexOf(marker);
705
708
  if (first === -1) return html;
706
- nextRegex.lastIndex = first + marker.length;
707
- let match;
708
- let open = 0,
709
- close = 0;
710
- while (match = nextRegex.exec(html)) {
711
- if (match[0][1] === "/") {
712
- close++;
713
- if (close > open) break;
714
- } else open++;
715
- }
716
- return html.slice(0, first) + value + html.slice(nextRegex.lastIndex);
709
+ const last = html.indexOf(close, first + marker.length);
710
+ return html.slice(0, first) + value + html.slice(last + close.length);
717
711
  }
718
712
  function Assets(props) {
719
713
  useAssets(() => props.children);
@@ -792,7 +786,7 @@ function delegateEvents() {}
792
786
  function Dynamic(props) {
793
787
  const [p, others] = solidJs.splitProps(props, ["component"]);
794
788
  const comp = p.component,
795
- t = typeof comp;
789
+ t = typeof comp;
796
790
  if (comp) {
797
791
  if (t === "function") return comp(others);else if (t === "string") {
798
792
  return ssrElement(comp, others, undefined, true);
@@ -260,13 +260,14 @@ function toRefParam(index) {
260
260
  return ref;
261
261
  }
262
262
 
263
- const REPLACE_SCRIPT = `function $df(e,t,d,l){d=document.getElementById(e),(l=document.getElementById("pl-"+e))&&l.replaceWith(...d.childNodes),d.remove(),_$HY.set(e,t),_$HY.fe(e)}`;
263
+ const REPLACE_SCRIPT = `function $df(e,t,n,o,d){if(n=document.getElementById(e),o=document.getElementById("pl-"+e)){for(;o&&8!==o.nodeType&&o.nodeValue!=="pl-"+e;)d=o.nextSibling,o.remove(),o=d;o.replaceWith(n.content)}n.remove(),_$HY.set(e,t),_$HY.fe(e)}`;
264
264
  function renderToString(code, options = {}) {
265
265
  let scripts = "";
266
266
  sharedConfig.context = {
267
267
  id: options.renderId || "",
268
268
  count: 0,
269
269
  suspense: {},
270
+ lazy: {},
270
271
  assets: [],
271
272
  nonce: options.nonce,
272
273
  writeResource(id, p, error) {
@@ -348,6 +349,7 @@ function renderToStream(code, options = {}) {
348
349
  count: 0,
349
350
  async: true,
350
351
  resources: {},
352
+ lazy: {},
351
353
  suspense: {},
352
354
  assets: [],
353
355
  nonce,
@@ -389,7 +391,7 @@ function renderToStream(code, options = {}) {
389
391
  Promise.resolve().then(() => html = replacePlaceholder(html, key, value !== undefined ? value : ""));
390
392
  error && pushTask(serializeSet(dedupe, key, error, serializeError));
391
393
  } else {
392
- buffer.write(`<div hidden id="${key}">${value !== undefined ? value : " "}</div>`);
394
+ buffer.write(`<template id="${key}">${value !== undefined ? value : " "}</template>`);
393
395
  pushTask(`${keys.length ? keys.map(k => `_$HY.unset("${k}")`).join(";") + ";" : ""}$df("${key}"${error ? "," + serializeError(error) : ""})${!scriptFlushed ? ";" + REPLACE_SCRIPT : ""}`);
394
396
  scriptFlushed = true;
395
397
  }
@@ -492,10 +494,10 @@ function ssr(t, ...nodes) {
492
494
  function ssrClassList(value) {
493
495
  if (!value) return "";
494
496
  let classKeys = Object.keys(value),
495
- result = "";
497
+ result = "";
496
498
  for (let i = 0, len = classKeys.length; i < len; i++) {
497
499
  const key = classKeys[i],
498
- classValue = !!value[key];
500
+ classValue = !!value[key];
499
501
  if (!key || key === "undefined" || !classValue) continue;
500
502
  i && (result += " ");
501
503
  result += key;
@@ -576,7 +578,7 @@ function escape(s, attr) {
576
578
  let iAmp = s.indexOf("&");
577
579
  if (iDelim < 0 && iAmp < 0) return s;
578
580
  let left = 0,
579
- out = "";
581
+ out = "";
580
582
  while (iDelim >= 0 && iAmp >= 0) {
581
583
  if (iDelim < iAmp) {
582
584
  if (left < iDelim) out += s.substring(left, iDelim);
@@ -640,7 +642,8 @@ function generateHydrationScript({
640
642
  function Hydration(props) {
641
643
  if (!sharedConfig.context.noHydrate) return props.children;
642
644
  const context = sharedConfig.context;
643
- sharedConfig.context = { ...context,
645
+ sharedConfig.context = {
646
+ ...context,
644
647
  count: 0,
645
648
  id: `${context.id}${context.count++}-`,
646
649
  noHydrate: false
@@ -698,21 +701,12 @@ function serializeSet(registry, key, value, serializer = stringify) {
698
701
  return `_$HY.set("${key}", ${serializer(value)})`;
699
702
  }
700
703
  function replacePlaceholder(html, key, value) {
701
- const nextRegex = /(<[/]?span[^>]*>)/g;
702
- const marker = `<span id="pl-${key}">`;
704
+ const marker = `<template id="pl-${key}">`;
705
+ const close = `<!pl-${key}>`;
703
706
  const first = html.indexOf(marker);
704
707
  if (first === -1) return html;
705
- nextRegex.lastIndex = first + marker.length;
706
- let match;
707
- let open = 0,
708
- close = 0;
709
- while (match = nextRegex.exec(html)) {
710
- if (match[0][1] === "/") {
711
- close++;
712
- if (close > open) break;
713
- } else open++;
714
- }
715
- return html.slice(0, first) + value + html.slice(nextRegex.lastIndex);
708
+ const last = html.indexOf(close, first + marker.length);
709
+ return html.slice(0, first) + value + html.slice(last + close.length);
716
710
  }
717
711
  function Assets(props) {
718
712
  useAssets(() => props.children);
@@ -791,7 +785,7 @@ function delegateEvents() {}
791
785
  function Dynamic(props) {
792
786
  const [p, others] = splitProps(props, ["component"]);
793
787
  const comp = p.component,
794
- t = typeof comp;
788
+ t = typeof comp;
795
789
  if (comp) {
796
790
  if (t === "function") return comp(others);else if (t === "string") {
797
791
  return ssrElement(comp, others, undefined, true);