@solidjs/web 2.0.0-beta.2 → 2.0.0-beta.4

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.cjs CHANGED
@@ -205,12 +205,7 @@ function setStyleProperty(node, name, value) {
205
205
  }
206
206
  function spread(node, props = {}, isSVG, skipChildren) {
207
207
  const prevProps = {};
208
- if (!skipChildren) {
209
- effect(() => normalize(props.children, prevProps.children), value => {
210
- insertExpression(node, value, prevProps.children);
211
- prevProps.children = value;
212
- });
213
- }
208
+ if (!skipChildren) insert(node, () => props.children);
214
209
  effect(() => {
215
210
  const r = props.ref;
216
211
  (typeof r === "function" || Array.isArray(r)) && ref(() => r, node);
@@ -260,7 +255,7 @@ function insert(parent, accessor, marker, initial) {
260
255
  if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker);
261
256
  }
262
257
  accessor = memo(accessor, true);
263
- if (multi && initial.length === 0 && !isHydrating(parent)) {
258
+ if (multi && initial.length === 0) {
264
259
  const placeholder = document.createTextNode("");
265
260
  parent.insertBefore(placeholder, marker);
266
261
  initial = [placeholder];
@@ -315,7 +310,11 @@ function hydrate$1(code, element, options = {}) {
315
310
  {
316
311
  solidJs.sharedConfig.verifyHydration = () => {
317
312
  if (solidJs.sharedConfig.registry && solidJs.sharedConfig.registry.size) {
318
- const orphaned = [...solidJs.sharedConfig.registry.values()];
313
+ const orphaned = [];
314
+ for (const [key, node] of solidJs.sharedConfig.registry.entries()) {
315
+ if (node.isConnected) orphaned.push(node);else solidJs.sharedConfig.registry.delete(key);
316
+ }
317
+ if (!orphaned.length) return;
319
318
  console.warn(`Hydration completed with ${orphaned.length} unclaimed server-rendered node(s):\n` + orphaned.map(node => ` ${node.outerHTML.slice(0, 100)}`).join("\n"));
320
319
  }
321
320
  };
@@ -565,6 +564,7 @@ function insertExpression(parent, value, current, marker) {
565
564
  appendNodes(parent, value, marker);
566
565
  } else reconcileArrays(parent, current, value);
567
566
  } else {
567
+ if (current && current.nodeType) clearHydrationRegistry(current);
568
568
  current && cleanChildren(parent);
569
569
  appendNodes(parent, value);
570
570
  }
@@ -590,6 +590,18 @@ function normalize(value, current, multi, doNotUnwrap) {
590
590
  function appendNodes(parent, array, marker = null) {
591
591
  for (let i = 0, len = array.length; i < len; i++) parent.insertBefore(array[i], marker);
592
592
  }
593
+ function clearHydrationRegistry(node) {
594
+ if (!solidJs.sharedConfig.registry || !node || node.nodeType !== 1) return;
595
+ const key = node.getAttribute("_hk");
596
+ if (key) solidJs.sharedConfig.registry.delete(key);
597
+ const descendants = node.querySelectorAll?.(`*[_hk]`);
598
+ if (descendants) {
599
+ for (let i = 0; i < descendants.length; i++) {
600
+ const descendantKey = descendants[i].getAttribute("_hk");
601
+ if (descendantKey) solidJs.sharedConfig.registry.delete(descendantKey);
602
+ }
603
+ }
604
+ }
593
605
  function cleanChildren(parent, current, marker, replacement) {
594
606
  if (marker === undefined) return parent.textContent = "";
595
607
  if (current.length) {
@@ -598,7 +610,10 @@ function cleanChildren(parent, current, marker, replacement) {
598
610
  const el = current[i];
599
611
  if (replacement !== el) {
600
612
  const isParent = el.parentNode === parent;
601
- if (replacement && !inserted && !i) isParent ? parent.replaceChild(replacement, el) : parent.insertBefore(replacement, marker);else isParent && el.remove();
613
+ if (replacement && !inserted && !i) isParent ? (clearHydrationRegistry(el), parent.replaceChild(replacement, el)) : parent.insertBefore(replacement, marker);else if (isParent) {
614
+ clearHydrationRegistry(el);
615
+ el.remove();
616
+ }
602
617
  } else inserted = true;
603
618
  }
604
619
  } else if (replacement) parent.insertBefore(replacement, marker);
@@ -640,28 +655,9 @@ function resolveSSRNode(node) {}
640
655
  function escape(html) {}
641
656
 
642
657
  function render(...args) {
643
- let unhandledAsync = false;
644
- {
645
- solidJs.setOnUnhandledAsync(() => {
646
- unhandledAsync = true;
647
- });
648
- }
658
+ solidJs.enforceLoadingBoundary(true);
649
659
  const result = render$1(...args);
650
- {
651
- solidJs.setOnUnhandledAsync(null);
652
- if (unhandledAsync) {
653
- const message = "Async content was used in JSX without a <Loading> boundary. " + "Wrap async content in <Loading> to show a fallback while loading.";
654
- result();
655
- const container = args[1];
656
- container.textContent = "";
657
- const msg = document.createElement("pre");
658
- msg.style.cssText = "color:#e53e3e;background:#fff5f5;border:2px solid #e53e3e;" + "border-radius:4px;padding:16px;margin:16px;font-family:monospace;" + "white-space:pre-wrap;word-break:break-word;";
659
- msg.textContent = message;
660
- container.appendChild(msg);
661
- console.error(message);
662
- return () => {};
663
- }
664
- }
660
+ solidJs.enforceLoadingBoundary(false);
665
661
  return result;
666
662
  }
667
663
  const isServer = false;
package/dist/dev.js CHANGED
@@ -1,4 +1,4 @@
1
- import { createRenderEffect, createMemo as createMemo$1, sharedConfig, untrack, runWithOwner, flatten, createRoot, omit, $DEVCOMP, enableHydration, setOnUnhandledAsync } from 'solid-js';
1
+ import { createRenderEffect, createMemo as createMemo$1, sharedConfig, untrack, runWithOwner, flatten, createRoot, omit, $DEVCOMP, enableHydration, enforceLoadingBoundary } from 'solid-js';
2
2
  export { Errored, For, Hydration, Loading, Match, NoHydration, Show, Switch, createComponent, getOwner, merge as mergeProps, untrack } from 'solid-js';
3
3
  import { createMemo } from '@solidjs/signals';
4
4
 
@@ -204,12 +204,7 @@ function setStyleProperty(node, name, value) {
204
204
  }
205
205
  function spread(node, props = {}, isSVG, skipChildren) {
206
206
  const prevProps = {};
207
- if (!skipChildren) {
208
- effect(() => normalize(props.children, prevProps.children), value => {
209
- insertExpression(node, value, prevProps.children);
210
- prevProps.children = value;
211
- });
212
- }
207
+ if (!skipChildren) insert(node, () => props.children);
213
208
  effect(() => {
214
209
  const r = props.ref;
215
210
  (typeof r === "function" || Array.isArray(r)) && ref(() => r, node);
@@ -259,7 +254,7 @@ function insert(parent, accessor, marker, initial) {
259
254
  if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker);
260
255
  }
261
256
  accessor = memo(accessor, true);
262
- if (multi && initial.length === 0 && !isHydrating(parent)) {
257
+ if (multi && initial.length === 0) {
263
258
  const placeholder = document.createTextNode("");
264
259
  parent.insertBefore(placeholder, marker);
265
260
  initial = [placeholder];
@@ -314,7 +309,11 @@ function hydrate$1(code, element, options = {}) {
314
309
  {
315
310
  sharedConfig.verifyHydration = () => {
316
311
  if (sharedConfig.registry && sharedConfig.registry.size) {
317
- const orphaned = [...sharedConfig.registry.values()];
312
+ const orphaned = [];
313
+ for (const [key, node] of sharedConfig.registry.entries()) {
314
+ if (node.isConnected) orphaned.push(node);else sharedConfig.registry.delete(key);
315
+ }
316
+ if (!orphaned.length) return;
318
317
  console.warn(`Hydration completed with ${orphaned.length} unclaimed server-rendered node(s):\n` + orphaned.map(node => ` ${node.outerHTML.slice(0, 100)}`).join("\n"));
319
318
  }
320
319
  };
@@ -564,6 +563,7 @@ function insertExpression(parent, value, current, marker) {
564
563
  appendNodes(parent, value, marker);
565
564
  } else reconcileArrays(parent, current, value);
566
565
  } else {
566
+ if (current && current.nodeType) clearHydrationRegistry(current);
567
567
  current && cleanChildren(parent);
568
568
  appendNodes(parent, value);
569
569
  }
@@ -589,6 +589,18 @@ function normalize(value, current, multi, doNotUnwrap) {
589
589
  function appendNodes(parent, array, marker = null) {
590
590
  for (let i = 0, len = array.length; i < len; i++) parent.insertBefore(array[i], marker);
591
591
  }
592
+ function clearHydrationRegistry(node) {
593
+ if (!sharedConfig.registry || !node || node.nodeType !== 1) return;
594
+ const key = node.getAttribute("_hk");
595
+ if (key) sharedConfig.registry.delete(key);
596
+ const descendants = node.querySelectorAll?.(`*[_hk]`);
597
+ if (descendants) {
598
+ for (let i = 0; i < descendants.length; i++) {
599
+ const descendantKey = descendants[i].getAttribute("_hk");
600
+ if (descendantKey) sharedConfig.registry.delete(descendantKey);
601
+ }
602
+ }
603
+ }
592
604
  function cleanChildren(parent, current, marker, replacement) {
593
605
  if (marker === undefined) return parent.textContent = "";
594
606
  if (current.length) {
@@ -597,7 +609,10 @@ function cleanChildren(parent, current, marker, replacement) {
597
609
  const el = current[i];
598
610
  if (replacement !== el) {
599
611
  const isParent = el.parentNode === parent;
600
- if (replacement && !inserted && !i) isParent ? parent.replaceChild(replacement, el) : parent.insertBefore(replacement, marker);else isParent && el.remove();
612
+ if (replacement && !inserted && !i) isParent ? (clearHydrationRegistry(el), parent.replaceChild(replacement, el)) : parent.insertBefore(replacement, marker);else if (isParent) {
613
+ clearHydrationRegistry(el);
614
+ el.remove();
615
+ }
601
616
  } else inserted = true;
602
617
  }
603
618
  } else if (replacement) parent.insertBefore(replacement, marker);
@@ -639,28 +654,9 @@ function resolveSSRNode(node) {}
639
654
  function escape(html) {}
640
655
 
641
656
  function render(...args) {
642
- let unhandledAsync = false;
643
- {
644
- setOnUnhandledAsync(() => {
645
- unhandledAsync = true;
646
- });
647
- }
657
+ enforceLoadingBoundary(true);
648
658
  const result = render$1(...args);
649
- {
650
- setOnUnhandledAsync(null);
651
- if (unhandledAsync) {
652
- const message = "Async content was used in JSX without a <Loading> boundary. " + "Wrap async content in <Loading> to show a fallback while loading.";
653
- result();
654
- const container = args[1];
655
- container.textContent = "";
656
- const msg = document.createElement("pre");
657
- msg.style.cssText = "color:#e53e3e;background:#fff5f5;border:2px solid #e53e3e;" + "border-radius:4px;padding:16px;margin:16px;font-family:monospace;" + "white-space:pre-wrap;word-break:break-word;";
658
- msg.textContent = message;
659
- container.appendChild(msg);
660
- console.error(message);
661
- return () => {};
662
- }
663
- }
659
+ enforceLoadingBoundary(false);
664
660
  return result;
665
661
  }
666
662
  const isServer = false;
package/dist/web.cjs CHANGED
@@ -200,12 +200,7 @@ function setStyleProperty(node, name, value) {
200
200
  }
201
201
  function spread(node, props = {}, isSVG, skipChildren) {
202
202
  const prevProps = {};
203
- if (!skipChildren) {
204
- effect(() => normalize(props.children, prevProps.children), value => {
205
- insertExpression(node, value, prevProps.children);
206
- prevProps.children = value;
207
- });
208
- }
203
+ if (!skipChildren) insert(node, () => props.children);
209
204
  effect(() => {
210
205
  const r = props.ref;
211
206
  (typeof r === "function" || Array.isArray(r)) && ref(() => r, node);
@@ -255,7 +250,7 @@ function insert(parent, accessor, marker, initial) {
255
250
  if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker);
256
251
  }
257
252
  accessor = memo(accessor, true);
258
- if (multi && initial.length === 0 && !isHydrating(parent)) {
253
+ if (multi && initial.length === 0) {
259
254
  const placeholder = document.createTextNode("");
260
255
  parent.insertBefore(placeholder, marker);
261
256
  initial = [placeholder];
@@ -511,6 +506,7 @@ function insertExpression(parent, value, current, marker) {
511
506
  appendNodes(parent, value, marker);
512
507
  } else reconcileArrays(parent, current, value);
513
508
  } else {
509
+ if (current && current.nodeType) clearHydrationRegistry(current);
514
510
  current && cleanChildren(parent);
515
511
  appendNodes(parent, value);
516
512
  }
@@ -536,6 +532,18 @@ function normalize(value, current, multi, doNotUnwrap) {
536
532
  function appendNodes(parent, array, marker = null) {
537
533
  for (let i = 0, len = array.length; i < len; i++) parent.insertBefore(array[i], marker);
538
534
  }
535
+ function clearHydrationRegistry(node) {
536
+ if (!solidJs.sharedConfig.registry || !node || node.nodeType !== 1) return;
537
+ const key = node.getAttribute("_hk");
538
+ if (key) solidJs.sharedConfig.registry.delete(key);
539
+ const descendants = node.querySelectorAll?.(`*[_hk]`);
540
+ if (descendants) {
541
+ for (let i = 0; i < descendants.length; i++) {
542
+ const descendantKey = descendants[i].getAttribute("_hk");
543
+ if (descendantKey) solidJs.sharedConfig.registry.delete(descendantKey);
544
+ }
545
+ }
546
+ }
539
547
  function cleanChildren(parent, current, marker, replacement) {
540
548
  if (marker === undefined) return parent.textContent = "";
541
549
  if (current.length) {
@@ -544,7 +552,10 @@ function cleanChildren(parent, current, marker, replacement) {
544
552
  const el = current[i];
545
553
  if (replacement !== el) {
546
554
  const isParent = el.parentNode === parent;
547
- if (replacement && !inserted && !i) isParent ? parent.replaceChild(replacement, el) : parent.insertBefore(replacement, marker);else isParent && el.remove();
555
+ if (replacement && !inserted && !i) isParent ? (clearHydrationRegistry(el), parent.replaceChild(replacement, el)) : parent.insertBefore(replacement, marker);else if (isParent) {
556
+ clearHydrationRegistry(el);
557
+ el.remove();
558
+ }
548
559
  } else inserted = true;
549
560
  }
550
561
  } else if (replacement) parent.insertBefore(replacement, marker);
package/dist/web.js CHANGED
@@ -199,12 +199,7 @@ function setStyleProperty(node, name, value) {
199
199
  }
200
200
  function spread(node, props = {}, isSVG, skipChildren) {
201
201
  const prevProps = {};
202
- if (!skipChildren) {
203
- effect(() => normalize(props.children, prevProps.children), value => {
204
- insertExpression(node, value, prevProps.children);
205
- prevProps.children = value;
206
- });
207
- }
202
+ if (!skipChildren) insert(node, () => props.children);
208
203
  effect(() => {
209
204
  const r = props.ref;
210
205
  (typeof r === "function" || Array.isArray(r)) && ref(() => r, node);
@@ -254,7 +249,7 @@ function insert(parent, accessor, marker, initial) {
254
249
  if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker);
255
250
  }
256
251
  accessor = memo(accessor, true);
257
- if (multi && initial.length === 0 && !isHydrating(parent)) {
252
+ if (multi && initial.length === 0) {
258
253
  const placeholder = document.createTextNode("");
259
254
  parent.insertBefore(placeholder, marker);
260
255
  initial = [placeholder];
@@ -510,6 +505,7 @@ function insertExpression(parent, value, current, marker) {
510
505
  appendNodes(parent, value, marker);
511
506
  } else reconcileArrays(parent, current, value);
512
507
  } else {
508
+ if (current && current.nodeType) clearHydrationRegistry(current);
513
509
  current && cleanChildren(parent);
514
510
  appendNodes(parent, value);
515
511
  }
@@ -535,6 +531,18 @@ function normalize(value, current, multi, doNotUnwrap) {
535
531
  function appendNodes(parent, array, marker = null) {
536
532
  for (let i = 0, len = array.length; i < len; i++) parent.insertBefore(array[i], marker);
537
533
  }
534
+ function clearHydrationRegistry(node) {
535
+ if (!sharedConfig.registry || !node || node.nodeType !== 1) return;
536
+ const key = node.getAttribute("_hk");
537
+ if (key) sharedConfig.registry.delete(key);
538
+ const descendants = node.querySelectorAll?.(`*[_hk]`);
539
+ if (descendants) {
540
+ for (let i = 0; i < descendants.length; i++) {
541
+ const descendantKey = descendants[i].getAttribute("_hk");
542
+ if (descendantKey) sharedConfig.registry.delete(descendantKey);
543
+ }
544
+ }
545
+ }
538
546
  function cleanChildren(parent, current, marker, replacement) {
539
547
  if (marker === undefined) return parent.textContent = "";
540
548
  if (current.length) {
@@ -543,7 +551,10 @@ function cleanChildren(parent, current, marker, replacement) {
543
551
  const el = current[i];
544
552
  if (replacement !== el) {
545
553
  const isParent = el.parentNode === parent;
546
- if (replacement && !inserted && !i) isParent ? parent.replaceChild(replacement, el) : parent.insertBefore(replacement, marker);else isParent && el.remove();
554
+ if (replacement && !inserted && !i) isParent ? (clearHydrationRegistry(el), parent.replaceChild(replacement, el)) : parent.insertBefore(replacement, marker);else if (isParent) {
555
+ clearHydrationRegistry(el);
556
+ el.remove();
557
+ }
547
558
  } else inserted = true;
548
559
  }
549
560
  } else if (replacement) parent.insertBefore(replacement, marker);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@solidjs/web",
3
3
  "description": "Solid's web runtime for the browser and the server",
4
- "version": "2.0.0-beta.2",
4
+ "version": "2.0.0-beta.4",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
7
7
  "homepage": "https://solidjs.com",
@@ -75,11 +75,11 @@
75
75
  "seroval-plugins": "^1.1.0"
76
76
  },
77
77
  "peerDependencies": {
78
- "solid-js": "^2.0.0-beta.2",
79
- "@solidjs/signals": "^0.12.0"
78
+ "solid-js": "^2.0.0-beta.4",
79
+ "@solidjs/signals": "^0.13.6"
80
80
  },
81
81
  "devDependencies": {
82
- "solid-js": "2.0.0-beta.2"
82
+ "solid-js": "2.0.0-beta.4"
83
83
  },
84
84
  "scripts": {
85
85
  "build": "npm-run-all -nl build:*",