solid-js 1.6.11 → 1.6.12

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2016-2019 Ryan Carniato
3
+ Copyright (c) 2016-2023 Ryan Carniato
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/dist/dev.cjs CHANGED
@@ -676,7 +676,7 @@ function writeSignal(node, value, isComp) {
676
676
  }
677
677
  if (Updates.length > 10e5) {
678
678
  Updates = [];
679
- if ("_SOLID_DEV_") throw new Error("Potential Infinite Loop Detected.");
679
+ if (true) throw new Error("Potential Infinite Loop Detected.");
680
680
  throw new Error();
681
681
  }
682
682
  }, false);
@@ -721,7 +721,8 @@ function runComputation(node, value, time) {
721
721
  node.owned = null;
722
722
  }
723
723
  }
724
- handleError(err);
724
+ node.updatedAt = time + 1;
725
+ return handleError(err);
725
726
  }
726
727
  if (!node.updatedAt || node.updatedAt <= time) {
727
728
  if (node.updatedAt != null && "observers" in node) {
@@ -901,7 +902,7 @@ function lookUpstream(node, ignore) {
901
902
  const source = node.sources[i];
902
903
  if (source.sources) {
903
904
  if (!runningTransition && source.state === STALE || runningTransition && source.tState === STALE) {
904
- if (source !== ignore) runTop(source);
905
+ if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount)) runTop(source);
905
906
  } else if (!runningTransition && source.state === PENDING || runningTransition && source.tState === PENDING) lookUpstream(source, ignore);
906
907
  }
907
908
  }
@@ -1413,7 +1414,7 @@ function lazy(fn) {
1413
1414
  }
1414
1415
  let Comp;
1415
1416
  return createMemo(() => (Comp = comp()) && untrack(() => {
1416
- if ("_SOLID_DEV_") Object.assign(Comp, {
1417
+ if (true) Object.assign(Comp, {
1417
1418
  [$DEVCOMP]: true
1418
1419
  });
1419
1420
  if (!ctx) return Comp(props);
package/dist/dev.js CHANGED
@@ -674,7 +674,7 @@ function writeSignal(node, value, isComp) {
674
674
  }
675
675
  if (Updates.length > 10e5) {
676
676
  Updates = [];
677
- if ("_SOLID_DEV_") throw new Error("Potential Infinite Loop Detected.");
677
+ if (true) throw new Error("Potential Infinite Loop Detected.");
678
678
  throw new Error();
679
679
  }
680
680
  }, false);
@@ -719,7 +719,8 @@ function runComputation(node, value, time) {
719
719
  node.owned = null;
720
720
  }
721
721
  }
722
- handleError(err);
722
+ node.updatedAt = time + 1;
723
+ return handleError(err);
723
724
  }
724
725
  if (!node.updatedAt || node.updatedAt <= time) {
725
726
  if (node.updatedAt != null && "observers" in node) {
@@ -899,7 +900,7 @@ function lookUpstream(node, ignore) {
899
900
  const source = node.sources[i];
900
901
  if (source.sources) {
901
902
  if (!runningTransition && source.state === STALE || runningTransition && source.tState === STALE) {
902
- if (source !== ignore) runTop(source);
903
+ if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount)) runTop(source);
903
904
  } else if (!runningTransition && source.state === PENDING || runningTransition && source.tState === PENDING) lookUpstream(source, ignore);
904
905
  }
905
906
  }
@@ -1411,7 +1412,7 @@ function lazy(fn) {
1411
1412
  }
1412
1413
  let Comp;
1413
1414
  return createMemo(() => (Comp = comp()) && untrack(() => {
1414
- if ("_SOLID_DEV_") Object.assign(Comp, {
1415
+ if (true) Object.assign(Comp, {
1415
1416
  [$DEVCOMP]: true
1416
1417
  });
1417
1418
  if (!ctx) return Comp(props);
package/dist/server.cjs CHANGED
@@ -607,7 +607,7 @@ function Suspense(props) {
607
607
  setHydrateContext({
608
608
  ...ctx,
609
609
  count: 0,
610
- id: ctx.id + "0.f",
610
+ id: ctx.id + "0-f",
611
611
  noHydrate: true
612
612
  });
613
613
  const res = {
@@ -619,7 +619,7 @@ function Suspense(props) {
619
619
  setHydrateContext({
620
620
  ...ctx,
621
621
  count: 0,
622
- id: ctx.id + "0.f"
622
+ id: ctx.id + "0-f"
623
623
  });
624
624
  ctx.writeResource(id, "$$f");
625
625
  return props.fallback;
package/dist/server.js CHANGED
@@ -605,7 +605,7 @@ function Suspense(props) {
605
605
  setHydrateContext({
606
606
  ...ctx,
607
607
  count: 0,
608
- id: ctx.id + "0.f",
608
+ id: ctx.id + "0-f",
609
609
  noHydrate: true
610
610
  });
611
611
  const res = {
@@ -617,7 +617,7 @@ function Suspense(props) {
617
617
  setHydrateContext({
618
618
  ...ctx,
619
619
  count: 0,
620
- id: ctx.id + "0.f"
620
+ id: ctx.id + "0-f"
621
621
  });
622
622
  ctx.writeResource(id, "$$f");
623
623
  return props.fallback;
package/dist/solid.cjs CHANGED
@@ -652,7 +652,8 @@ function runComputation(node, value, time) {
652
652
  node.owned = null;
653
653
  }
654
654
  }
655
- handleError(err);
655
+ node.updatedAt = time + 1;
656
+ return handleError(err);
656
657
  }
657
658
  if (!node.updatedAt || node.updatedAt <= time) {
658
659
  if (node.updatedAt != null && "observers" in node) {
@@ -831,7 +832,7 @@ function lookUpstream(node, ignore) {
831
832
  const source = node.sources[i];
832
833
  if (source.sources) {
833
834
  if (!runningTransition && source.state === STALE || runningTransition && source.tState === STALE) {
834
- if (source !== ignore) runTop(source);
835
+ if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount)) runTop(source);
835
836
  } else if (!runningTransition && source.state === PENDING || runningTransition && source.tState === PENDING) lookUpstream(source, ignore);
836
837
  }
837
838
  }
package/dist/solid.js CHANGED
@@ -650,7 +650,8 @@ function runComputation(node, value, time) {
650
650
  node.owned = null;
651
651
  }
652
652
  }
653
- handleError(err);
653
+ node.updatedAt = time + 1;
654
+ return handleError(err);
654
655
  }
655
656
  if (!node.updatedAt || node.updatedAt <= time) {
656
657
  if (node.updatedAt != null && "observers" in node) {
@@ -829,7 +830,7 @@ function lookUpstream(node, ignore) {
829
830
  const source = node.sources[i];
830
831
  if (source.sources) {
831
832
  if (!runningTransition && source.state === STALE || runningTransition && source.tState === STALE) {
832
- if (source !== ignore) runTop(source);
833
+ if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount)) runTop(source);
833
834
  } else if (!runningTransition && source.state === PENDING || runningTransition && source.tState === PENDING) lookUpstream(source, ignore);
834
835
  }
835
836
  }
@@ -1291,6 +1291,7 @@ export namespace JSX {
1291
1291
  gradientUnits?: FunctionMaybe<SVGUnits>;
1292
1292
  gradientTransform?: FunctionMaybe<string>;
1293
1293
  spreadMethod?: FunctionMaybe<"pad" | "reflect" | "repeat">;
1294
+ href?: FunctionMaybe<string>
1294
1295
  }
1295
1296
  interface GraphicsElementSVGAttributes<T>
1296
1297
  extends CoreSVGAttributes<T>,
@@ -300,7 +300,7 @@ function createHTML(r, {
300
300
  continue;
301
301
  }
302
302
  parseNode(child, childOptions);
303
- i++;
303
+ if (!childOptions.multi && child.type === "comment" && child.content === "#") node.children.splice(i, 1);else i++;
304
304
  }
305
305
  options.counter = childOptions.counter;
306
306
  options.templateId = childOptions.templateId;
@@ -390,8 +390,12 @@ function createHTML(r, {
390
390
  options.templateId = childOptions.templateId;
391
391
  } else if (child.type === "text") {
392
392
  parts.push(`"${child.content}"`);
393
- } else if (child.type === "comment" && child.content === "#") {
394
- parts.push(`exprs[${options.counter++}]`);
393
+ } else if (child.type === "comment") {
394
+ if (child.content === "#") parts.push(`exprs[${options.counter++}]`);else if (child.content) {
395
+ for (let i = 0; i < child.content.split("###").length - 1; i++) {
396
+ parts.push(`exprs[${options.counter++}]`);
397
+ }
398
+ }
395
399
  }
396
400
  });
397
401
  options.exprs.push(`return [${parts.join(", \n")}]`);
package/html/dist/html.js CHANGED
@@ -298,7 +298,7 @@ function createHTML(r, {
298
298
  continue;
299
299
  }
300
300
  parseNode(child, childOptions);
301
- i++;
301
+ if (!childOptions.multi && child.type === "comment" && child.content === "#") node.children.splice(i, 1);else i++;
302
302
  }
303
303
  options.counter = childOptions.counter;
304
304
  options.templateId = childOptions.templateId;
@@ -388,8 +388,12 @@ function createHTML(r, {
388
388
  options.templateId = childOptions.templateId;
389
389
  } else if (child.type === "text") {
390
390
  parts.push(`"${child.content}"`);
391
- } else if (child.type === "comment" && child.content === "#") {
392
- parts.push(`exprs[${options.counter++}]`);
391
+ } else if (child.type === "comment") {
392
+ if (child.content === "#") parts.push(`exprs[${options.counter++}]`);else if (child.content) {
393
+ for (let i = 0; i < child.content.split("###").length - 1; i++) {
394
+ parts.push(`exprs[${options.counter++}]`);
395
+ }
396
+ }
393
397
  }
394
398
  });
395
399
  options.exprs.push(`return [${parts.join(", \n")}]`);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "solid-js",
3
3
  "description": "A declarative JavaScript library for building user interfaces.",
4
- "version": "1.6.11",
4
+ "version": "1.6.12",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
7
7
  "homepage": "https://solidjs.com",
@@ -320,11 +320,8 @@ const $ROOT = Symbol("store-root");
320
320
  function applyState(target, parent, property, merge, key) {
321
321
  const previous = parent[property];
322
322
  if (target === previous) return;
323
- if (!isWrappable(target) || !isWrappable(previous) || key && target[key] !== previous[key]) {
324
- if (target !== previous) {
325
- if (property === $ROOT) return target;
326
- setProperty(parent, property, target);
327
- }
323
+ if (property !== $ROOT && (!isWrappable(target) || !isWrappable(previous) || key && target[key] !== previous[key])) {
324
+ setProperty(parent, property, target);
328
325
  return;
329
326
  }
330
327
  if (Array.isArray(target)) {
package/store/dist/dev.js CHANGED
@@ -318,11 +318,8 @@ const $ROOT = Symbol("store-root");
318
318
  function applyState(target, parent, property, merge, key) {
319
319
  const previous = parent[property];
320
320
  if (target === previous) return;
321
- if (!isWrappable(target) || !isWrappable(previous) || key && target[key] !== previous[key]) {
322
- if (target !== previous) {
323
- if (property === $ROOT) return target;
324
- setProperty(parent, property, target);
325
- }
321
+ if (property !== $ROOT && (!isWrappable(target) || !isWrappable(previous) || key && target[key] !== previous[key])) {
322
+ setProperty(parent, property, target);
326
323
  return;
327
324
  }
328
325
  if (Array.isArray(target)) {
@@ -297,11 +297,8 @@ const $ROOT = Symbol("store-root");
297
297
  function applyState(target, parent, property, merge, key) {
298
298
  const previous = parent[property];
299
299
  if (target === previous) return;
300
- if (!isWrappable(target) || !isWrappable(previous) || key && target[key] !== previous[key]) {
301
- if (target !== previous) {
302
- if (property === $ROOT) return target;
303
- setProperty(parent, property, target);
304
- }
300
+ if (property !== $ROOT && (!isWrappable(target) || !isWrappable(previous) || key && target[key] !== previous[key])) {
301
+ setProperty(parent, property, target);
305
302
  return;
306
303
  }
307
304
  if (Array.isArray(target)) {
@@ -295,11 +295,8 @@ const $ROOT = Symbol("store-root");
295
295
  function applyState(target, parent, property, merge, key) {
296
296
  const previous = parent[property];
297
297
  if (target === previous) return;
298
- if (!isWrappable(target) || !isWrappable(previous) || key && target[key] !== previous[key]) {
299
- if (target !== previous) {
300
- if (property === $ROOT) return target;
301
- setProperty(parent, property, target);
302
- }
298
+ if (property !== $ROOT && (!isWrappable(target) || !isWrappable(previous) || key && target[key] !== previous[key])) {
299
+ setProperty(parent, property, target);
303
300
  return;
304
301
  }
305
302
  if (Array.isArray(target)) {
@@ -68,7 +68,9 @@ export type ArrayFilterFn<T> = (item: T, index: number) => boolean;
68
68
  export type StoreSetter<T, U extends PropertyKey[] = []> = T | CustomPartial<T> | ((prevState: T, traversed: U) => T | CustomPartial<T>);
69
69
  export type Part<T, K extends KeyOf<T> = KeyOf<T>> = K | ([K] extends [never] ? never : readonly K[]) | ([T] extends [readonly unknown[]] ? ArrayFilterFn<T[number]> | StorePathRange : never);
70
70
  type W<T> = Exclude<T, NotWrappable>;
71
- type KeyOf<T> = number extends keyof T ? 0 extends 1 & T ? keyof T : [T] extends [readonly unknown[]] ? number : [T] extends [never] ? never : keyof T : keyof T;
71
+ type KeyOf<T> = number extends keyof T ? 0 extends 1 & T ? keyof T : [T] extends [never] ? never : [
72
+ T
73
+ ] extends [readonly unknown[]] ? number : keyof T : keyof T;
72
74
  type MutableKeyOf<T> = KeyOf<T> & keyof PickMutable<T>;
73
75
  type Rest<T, U extends PropertyKey[], K extends KeyOf<T> = KeyOf<T>> = [T] extends [never] ? never : K extends MutableKeyOf<T> ? [Part<T, K>, ...RestSetterOrContinue<T[K], [K, ...U]>] : K extends KeyOf<T> ? [Part<T, K>, ...RestContinue<T[K], [K, ...U]>] : never;
74
76
  type RestContinue<T, U extends PropertyKey[]> = 0 extends 1 & T ? [...Part<any>[], StoreSetter<any, PropertyKey[]>] : Rest<W<T>, U>;
package/types/jsx.d.ts CHANGED
@@ -1301,6 +1301,7 @@ export namespace JSX {
1301
1301
  gradientUnits?: SVGUnits;
1302
1302
  gradientTransform?: string;
1303
1303
  spreadMethod?: "pad" | "reflect" | "repeat";
1304
+ href?: string
1304
1305
  }
1305
1306
  interface GraphicsElementSVGAttributes<T>
1306
1307
  extends CoreSVGAttributes<T>,
@@ -1,4 +1,27 @@
1
1
  import { Accessor } from "./signal.js";
2
+ /**
3
+ The MIT License (MIT)
4
+
5
+ Copyright (c) 2017 Adam Haile
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in all
15
+ copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ SOFTWARE.
24
+ */
2
25
  /**
3
26
  * reactively transforms an array with a callback function - underlying helper for the `<For>` control flow
4
27
  *
@@ -1,3 +1,26 @@
1
+ /**
2
+ The MIT License (MIT)
3
+
4
+ Copyright (c) 2017 Adam Haile
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
23
+ */
1
24
  import { requestCallback } from "./scheduler.js";
2
25
  import type { JSX } from "../jsx.js";
3
26
  import type { FlowComponent } from "../render/index.js";
package/web/dist/dev.cjs CHANGED
@@ -529,6 +529,7 @@ function escape(html) {}
529
529
  function ssrSpread(props, isSVG, skipChildren) {}
530
530
 
531
531
  const isServer = false;
532
+ const isDev = true;
532
533
  const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
533
534
  function createElement(tagName, isSVG = false) {
534
535
  return isSVG ? document.createElementNS(SVG_NAMESPACE, tagName) : document.createElement(tagName);
@@ -542,37 +543,41 @@ function Portal(props) {
542
543
  useShadow
543
544
  } = props,
544
545
  marker = document.createTextNode(""),
545
- mount = props.mount || document.body;
546
+ mount = () => props.mount || document.body,
547
+ content = solidJs.createMemo(renderPortal());
546
548
  function renderPortal() {
547
549
  if (solidJs.sharedConfig.context) {
548
550
  const [s, set] = solidJs.createSignal(false);
549
- queueMicrotask(() => set(true));
551
+ solidJs.onMount(() => set(true));
550
552
  return () => s() && props.children;
551
553
  } else return () => props.children;
552
554
  }
553
- if (mount instanceof HTMLHeadElement) {
554
- const [clean, setClean] = solidJs.createSignal(false);
555
- const cleanup = () => setClean(true);
556
- solidJs.createRoot(dispose => insert(mount, () => !clean() ? renderPortal()() : dispose(), null));
557
- solidJs.onCleanup(() => {
558
- if (solidJs.sharedConfig.context) queueMicrotask(cleanup);else cleanup();
559
- });
560
- } else {
561
- const container = createElement(props.isSVG ? "g" : "div", props.isSVG),
562
- renderRoot = useShadow && container.attachShadow ? container.attachShadow({
563
- mode: "open"
564
- }) : container;
565
- Object.defineProperty(container, "_$host", {
566
- get() {
567
- return marker.parentNode;
568
- },
569
- configurable: true
570
- });
571
- insert(renderRoot, renderPortal());
572
- mount.appendChild(container);
573
- props.ref && props.ref(container);
574
- solidJs.onCleanup(() => mount.removeChild(container));
575
- }
555
+ solidJs.createRenderEffect(() => {
556
+ const el = mount();
557
+ if (el instanceof HTMLHeadElement) {
558
+ const [clean, setClean] = solidJs.createSignal(false);
559
+ const cleanup = () => setClean(true);
560
+ solidJs.createRoot(dispose => insert(el, () => !clean() ? content() : dispose(), null));
561
+ solidJs.onCleanup(() => {
562
+ if (solidJs.sharedConfig.context) queueMicrotask(cleanup);else cleanup();
563
+ });
564
+ } else {
565
+ const container = createElement(props.isSVG ? "g" : "div", props.isSVG),
566
+ renderRoot = useShadow && container.attachShadow ? container.attachShadow({
567
+ mode: "open"
568
+ }) : container;
569
+ Object.defineProperty(container, "_$host", {
570
+ get() {
571
+ return marker.parentNode;
572
+ },
573
+ configurable: true
574
+ });
575
+ insert(renderRoot, content);
576
+ el.appendChild(container);
577
+ props.ref && props.ref(container);
578
+ solidJs.onCleanup(() => el.removeChild(container));
579
+ }
580
+ });
576
581
  return marker;
577
582
  }
578
583
  function Dynamic(props) {
@@ -682,6 +687,7 @@ exports.getNextMatch = getNextMatch;
682
687
  exports.hydrate = hydrate;
683
688
  exports.innerHTML = innerHTML;
684
689
  exports.insert = insert;
690
+ exports.isDev = isDev;
685
691
  exports.isServer = isServer;
686
692
  exports.render = render;
687
693
  exports.renderToStream = renderToStream;
package/web/dist/dev.js CHANGED
@@ -1,4 +1,4 @@
1
- import { createRoot, createRenderEffect, sharedConfig, untrack, enableHydration, createSignal, onCleanup, splitProps, createMemo, $DEVCOMP } from 'solid-js';
1
+ import { createRoot, createRenderEffect, sharedConfig, untrack, enableHydration, createMemo, createSignal, onMount, onCleanup, splitProps, $DEVCOMP } from 'solid-js';
2
2
  export { ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, createComponent, createRenderEffect as effect, getOwner, createMemo as memo, mergeProps, untrack } from 'solid-js';
3
3
 
4
4
  const booleans = ["allowfullscreen", "async", "autofocus", "autoplay", "checked", "controls", "default", "disabled", "formnovalidate", "hidden", "indeterminate", "ismap", "loop", "multiple", "muted", "nomodule", "novalidate", "open", "playsinline", "readonly", "required", "reversed", "seamless", "selected"];
@@ -528,6 +528,7 @@ function escape(html) {}
528
528
  function ssrSpread(props, isSVG, skipChildren) {}
529
529
 
530
530
  const isServer = false;
531
+ const isDev = true;
531
532
  const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
532
533
  function createElement(tagName, isSVG = false) {
533
534
  return isSVG ? document.createElementNS(SVG_NAMESPACE, tagName) : document.createElement(tagName);
@@ -541,37 +542,41 @@ function Portal(props) {
541
542
  useShadow
542
543
  } = props,
543
544
  marker = document.createTextNode(""),
544
- mount = props.mount || document.body;
545
+ mount = () => props.mount || document.body,
546
+ content = createMemo(renderPortal());
545
547
  function renderPortal() {
546
548
  if (sharedConfig.context) {
547
549
  const [s, set] = createSignal(false);
548
- queueMicrotask(() => set(true));
550
+ onMount(() => set(true));
549
551
  return () => s() && props.children;
550
552
  } else return () => props.children;
551
553
  }
552
- if (mount instanceof HTMLHeadElement) {
553
- const [clean, setClean] = createSignal(false);
554
- const cleanup = () => setClean(true);
555
- createRoot(dispose => insert(mount, () => !clean() ? renderPortal()() : dispose(), null));
556
- onCleanup(() => {
557
- if (sharedConfig.context) queueMicrotask(cleanup);else cleanup();
558
- });
559
- } else {
560
- const container = createElement(props.isSVG ? "g" : "div", props.isSVG),
561
- renderRoot = useShadow && container.attachShadow ? container.attachShadow({
562
- mode: "open"
563
- }) : container;
564
- Object.defineProperty(container, "_$host", {
565
- get() {
566
- return marker.parentNode;
567
- },
568
- configurable: true
569
- });
570
- insert(renderRoot, renderPortal());
571
- mount.appendChild(container);
572
- props.ref && props.ref(container);
573
- onCleanup(() => mount.removeChild(container));
574
- }
554
+ createRenderEffect(() => {
555
+ const el = mount();
556
+ if (el instanceof HTMLHeadElement) {
557
+ const [clean, setClean] = createSignal(false);
558
+ const cleanup = () => setClean(true);
559
+ createRoot(dispose => insert(el, () => !clean() ? content() : dispose(), null));
560
+ onCleanup(() => {
561
+ if (sharedConfig.context) queueMicrotask(cleanup);else cleanup();
562
+ });
563
+ } else {
564
+ const container = createElement(props.isSVG ? "g" : "div", props.isSVG),
565
+ renderRoot = useShadow && container.attachShadow ? container.attachShadow({
566
+ mode: "open"
567
+ }) : container;
568
+ Object.defineProperty(container, "_$host", {
569
+ get() {
570
+ return marker.parentNode;
571
+ },
572
+ configurable: true
573
+ });
574
+ insert(renderRoot, content);
575
+ el.appendChild(container);
576
+ props.ref && props.ref(container);
577
+ onCleanup(() => el.removeChild(container));
578
+ }
579
+ });
575
580
  return marker;
576
581
  }
577
582
  function Dynamic(props) {
@@ -594,4 +599,4 @@ function Dynamic(props) {
594
599
  });
595
600
  }
596
601
 
597
- export { Aliases, voidFn as Assets, ChildProperties, DOMElements, DelegatedEvents, Dynamic, Hydration, voidFn as HydrationScript, NoHydration, Portal, PropAliases, Properties, SVGElements, SVGNamespace, addEventListener, assign, classList, className, clearDelegatedEvents, delegateEvents, dynamicProperty, escape, voidFn as generateHydrationScript, voidFn as getAssets, getHydrationKey, getNextElement, getNextMarker, getNextMatch, hydrate, innerHTML, insert, isServer, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrSpread, ssrStyle, style, template, use, voidFn as useAssets };
602
+ export { Aliases, voidFn as Assets, ChildProperties, DOMElements, DelegatedEvents, Dynamic, Hydration, voidFn as HydrationScript, NoHydration, Portal, PropAliases, Properties, SVGElements, SVGNamespace, addEventListener, assign, classList, className, clearDelegatedEvents, delegateEvents, dynamicProperty, escape, voidFn as generateHydrationScript, voidFn as getAssets, getHydrationKey, getNextElement, getNextMarker, getNextMatch, hydrate, innerHTML, insert, isDev, isServer, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrSpread, ssrStyle, style, template, use, voidFn as useAssets };
@@ -784,6 +784,7 @@ function ssrSpread(props, isSVG, skipChildren) {
784
784
  }
785
785
 
786
786
  const isServer = true;
787
+ const isDev = false;
787
788
  function render() {}
788
789
  function hydrate() {}
789
790
  function insert() {}
@@ -858,6 +859,7 @@ exports.getAssets = getAssets;
858
859
  exports.getHydrationKey = getHydrationKey;
859
860
  exports.hydrate = hydrate;
860
861
  exports.insert = insert;
862
+ exports.isDev = isDev;
861
863
  exports.isServer = isServer;
862
864
  exports.pipeToNodeWritable = pipeToNodeWritable;
863
865
  exports.pipeToWritable = pipeToWritable;
@@ -783,6 +783,7 @@ function ssrSpread(props, isSVG, skipChildren) {
783
783
  }
784
784
 
785
785
  const isServer = true;
786
+ const isDev = false;
786
787
  function render() {}
787
788
  function hydrate() {}
788
789
  function insert() {}
@@ -803,4 +804,4 @@ function Portal(props) {
803
804
  return "";
804
805
  }
805
806
 
806
- export { Assets, Dynamic, Hydration, HydrationScript, NoHydration, Portal, addEventListener, delegateEvents, escape, generateHydrationScript, getAssets, getHydrationKey, hydrate, insert, isServer, pipeToNodeWritable, pipeToWritable, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrSpread, ssrStyle, stringify, useAssets };
807
+ export { Assets, Dynamic, Hydration, HydrationScript, NoHydration, Portal, addEventListener, delegateEvents, escape, generateHydrationScript, getAssets, getHydrationKey, hydrate, insert, isDev, isServer, pipeToNodeWritable, pipeToWritable, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrSpread, ssrStyle, stringify, useAssets };
package/web/dist/web.cjs CHANGED
@@ -101,6 +101,7 @@ function render(code, element, init, options = {}) {
101
101
  function template(html, check, isSVG) {
102
102
  const t = document.createElement("template");
103
103
  t.innerHTML = html;
104
+ if (check && t.innerHTML.split("<").length - 1 !== check) throw `The browser resolved template HTML does not match JSX input:\n${t.innerHTML}\n\n${html}. Is your HTML properly formed?`;
104
105
  let node = t.content.firstChild;
105
106
  if (isSVG) node = node.firstChild;
106
107
  return node;
@@ -246,6 +247,8 @@ function hydrate$1(code, element, options = {}) {
246
247
  function getNextElement(template) {
247
248
  let node, key;
248
249
  if (!solidJs.sharedConfig.context || !(node = solidJs.sharedConfig.registry.get(key = getHydrationKey()))) {
250
+ if (solidJs.sharedConfig.context) console.warn("Unable to find DOM nodes for hydration key:", key);
251
+ if (!template) throw new Error("Unrecoverable Hydration Mismatch. No template for key: " + key);
249
252
  return template.cloneNode(true);
250
253
  }
251
254
  if (solidJs.sharedConfig.completed) solidJs.sharedConfig.completed.add(node);
@@ -435,7 +438,7 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
435
438
  parent.appendChild(value);
436
439
  } else parent.replaceChild(value, parent.firstChild);
437
440
  current = value;
438
- } else ;
441
+ } else console.warn(`Unrecognized value. Skipped inserting`, value);
439
442
  return current;
440
443
  }
441
444
  function normalizeIncomingArray(normalized, array, current, unwrap) {
@@ -526,6 +529,7 @@ function escape(html) {}
526
529
  function ssrSpread(props, isSVG, skipChildren) {}
527
530
 
528
531
  const isServer = false;
532
+ const isDev = false;
529
533
  const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
530
534
  function createElement(tagName, isSVG = false) {
531
535
  return isSVG ? document.createElementNS(SVG_NAMESPACE, tagName) : document.createElement(tagName);
@@ -539,37 +543,41 @@ function Portal(props) {
539
543
  useShadow
540
544
  } = props,
541
545
  marker = document.createTextNode(""),
542
- mount = props.mount || document.body;
546
+ mount = () => props.mount || document.body,
547
+ content = solidJs.createMemo(renderPortal());
543
548
  function renderPortal() {
544
549
  if (solidJs.sharedConfig.context) {
545
550
  const [s, set] = solidJs.createSignal(false);
546
- queueMicrotask(() => set(true));
551
+ solidJs.onMount(() => set(true));
547
552
  return () => s() && props.children;
548
553
  } else return () => props.children;
549
554
  }
550
- if (mount instanceof HTMLHeadElement) {
551
- const [clean, setClean] = solidJs.createSignal(false);
552
- const cleanup = () => setClean(true);
553
- solidJs.createRoot(dispose => insert(mount, () => !clean() ? renderPortal()() : dispose(), null));
554
- solidJs.onCleanup(() => {
555
- if (solidJs.sharedConfig.context) queueMicrotask(cleanup);else cleanup();
556
- });
557
- } else {
558
- const container = createElement(props.isSVG ? "g" : "div", props.isSVG),
559
- renderRoot = useShadow && container.attachShadow ? container.attachShadow({
560
- mode: "open"
561
- }) : container;
562
- Object.defineProperty(container, "_$host", {
563
- get() {
564
- return marker.parentNode;
565
- },
566
- configurable: true
567
- });
568
- insert(renderRoot, renderPortal());
569
- mount.appendChild(container);
570
- props.ref && props.ref(container);
571
- solidJs.onCleanup(() => mount.removeChild(container));
572
- }
555
+ solidJs.createRenderEffect(() => {
556
+ const el = mount();
557
+ if (el instanceof HTMLHeadElement) {
558
+ const [clean, setClean] = solidJs.createSignal(false);
559
+ const cleanup = () => setClean(true);
560
+ solidJs.createRoot(dispose => insert(el, () => !clean() ? content() : dispose(), null));
561
+ solidJs.onCleanup(() => {
562
+ if (solidJs.sharedConfig.context) queueMicrotask(cleanup);else cleanup();
563
+ });
564
+ } else {
565
+ const container = createElement(props.isSVG ? "g" : "div", props.isSVG),
566
+ renderRoot = useShadow && container.attachShadow ? container.attachShadow({
567
+ mode: "open"
568
+ }) : container;
569
+ Object.defineProperty(container, "_$host", {
570
+ get() {
571
+ return marker.parentNode;
572
+ },
573
+ configurable: true
574
+ });
575
+ insert(renderRoot, content);
576
+ el.appendChild(container);
577
+ props.ref && props.ref(container);
578
+ solidJs.onCleanup(() => el.removeChild(container));
579
+ }
580
+ });
573
581
  return marker;
574
582
  }
575
583
  function Dynamic(props) {
@@ -579,6 +587,9 @@ function Dynamic(props) {
579
587
  const component = cached();
580
588
  switch (typeof component) {
581
589
  case "function":
590
+ Object.assign(component, {
591
+ [solidJs.$DEVCOMP]: true
592
+ });
582
593
  return solidJs.untrack(() => component(others));
583
594
  case "string":
584
595
  const isSvg = SVGElements.has(component);
@@ -676,6 +687,7 @@ exports.getNextMatch = getNextMatch;
676
687
  exports.hydrate = hydrate;
677
688
  exports.innerHTML = innerHTML;
678
689
  exports.insert = insert;
690
+ exports.isDev = isDev;
679
691
  exports.isServer = isServer;
680
692
  exports.render = render;
681
693
  exports.renderToStream = renderToStream;
package/web/dist/web.js CHANGED
@@ -1,4 +1,4 @@
1
- import { createRoot, createRenderEffect, sharedConfig, untrack, enableHydration, createSignal, onCleanup, splitProps, createMemo } from 'solid-js';
1
+ import { createRoot, createRenderEffect, sharedConfig, untrack, enableHydration, createMemo, createSignal, onMount, onCleanup, splitProps, $DEVCOMP } from 'solid-js';
2
2
  export { ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, createComponent, createRenderEffect as effect, getOwner, createMemo as memo, mergeProps, untrack } from 'solid-js';
3
3
 
4
4
  const booleans = ["allowfullscreen", "async", "autofocus", "autoplay", "checked", "controls", "default", "disabled", "formnovalidate", "hidden", "indeterminate", "ismap", "loop", "multiple", "muted", "nomodule", "novalidate", "open", "playsinline", "readonly", "required", "reversed", "seamless", "selected"];
@@ -100,6 +100,7 @@ function render(code, element, init, options = {}) {
100
100
  function template(html, check, isSVG) {
101
101
  const t = document.createElement("template");
102
102
  t.innerHTML = html;
103
+ if (check && t.innerHTML.split("<").length - 1 !== check) throw `The browser resolved template HTML does not match JSX input:\n${t.innerHTML}\n\n${html}. Is your HTML properly formed?`;
103
104
  let node = t.content.firstChild;
104
105
  if (isSVG) node = node.firstChild;
105
106
  return node;
@@ -245,6 +246,8 @@ function hydrate$1(code, element, options = {}) {
245
246
  function getNextElement(template) {
246
247
  let node, key;
247
248
  if (!sharedConfig.context || !(node = sharedConfig.registry.get(key = getHydrationKey()))) {
249
+ if (sharedConfig.context) console.warn("Unable to find DOM nodes for hydration key:", key);
250
+ if (!template) throw new Error("Unrecoverable Hydration Mismatch. No template for key: " + key);
248
251
  return template.cloneNode(true);
249
252
  }
250
253
  if (sharedConfig.completed) sharedConfig.completed.add(node);
@@ -434,7 +437,7 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
434
437
  parent.appendChild(value);
435
438
  } else parent.replaceChild(value, parent.firstChild);
436
439
  current = value;
437
- } else ;
440
+ } else console.warn(`Unrecognized value. Skipped inserting`, value);
438
441
  return current;
439
442
  }
440
443
  function normalizeIncomingArray(normalized, array, current, unwrap) {
@@ -525,6 +528,7 @@ function escape(html) {}
525
528
  function ssrSpread(props, isSVG, skipChildren) {}
526
529
 
527
530
  const isServer = false;
531
+ const isDev = false;
528
532
  const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
529
533
  function createElement(tagName, isSVG = false) {
530
534
  return isSVG ? document.createElementNS(SVG_NAMESPACE, tagName) : document.createElement(tagName);
@@ -538,37 +542,41 @@ function Portal(props) {
538
542
  useShadow
539
543
  } = props,
540
544
  marker = document.createTextNode(""),
541
- mount = props.mount || document.body;
545
+ mount = () => props.mount || document.body,
546
+ content = createMemo(renderPortal());
542
547
  function renderPortal() {
543
548
  if (sharedConfig.context) {
544
549
  const [s, set] = createSignal(false);
545
- queueMicrotask(() => set(true));
550
+ onMount(() => set(true));
546
551
  return () => s() && props.children;
547
552
  } else return () => props.children;
548
553
  }
549
- if (mount instanceof HTMLHeadElement) {
550
- const [clean, setClean] = createSignal(false);
551
- const cleanup = () => setClean(true);
552
- createRoot(dispose => insert(mount, () => !clean() ? renderPortal()() : dispose(), null));
553
- onCleanup(() => {
554
- if (sharedConfig.context) queueMicrotask(cleanup);else cleanup();
555
- });
556
- } else {
557
- const container = createElement(props.isSVG ? "g" : "div", props.isSVG),
558
- renderRoot = useShadow && container.attachShadow ? container.attachShadow({
559
- mode: "open"
560
- }) : container;
561
- Object.defineProperty(container, "_$host", {
562
- get() {
563
- return marker.parentNode;
564
- },
565
- configurable: true
566
- });
567
- insert(renderRoot, renderPortal());
568
- mount.appendChild(container);
569
- props.ref && props.ref(container);
570
- onCleanup(() => mount.removeChild(container));
571
- }
554
+ createRenderEffect(() => {
555
+ const el = mount();
556
+ if (el instanceof HTMLHeadElement) {
557
+ const [clean, setClean] = createSignal(false);
558
+ const cleanup = () => setClean(true);
559
+ createRoot(dispose => insert(el, () => !clean() ? content() : dispose(), null));
560
+ onCleanup(() => {
561
+ if (sharedConfig.context) queueMicrotask(cleanup);else cleanup();
562
+ });
563
+ } else {
564
+ const container = createElement(props.isSVG ? "g" : "div", props.isSVG),
565
+ renderRoot = useShadow && container.attachShadow ? container.attachShadow({
566
+ mode: "open"
567
+ }) : container;
568
+ Object.defineProperty(container, "_$host", {
569
+ get() {
570
+ return marker.parentNode;
571
+ },
572
+ configurable: true
573
+ });
574
+ insert(renderRoot, content);
575
+ el.appendChild(container);
576
+ props.ref && props.ref(container);
577
+ onCleanup(() => el.removeChild(container));
578
+ }
579
+ });
572
580
  return marker;
573
581
  }
574
582
  function Dynamic(props) {
@@ -578,6 +586,9 @@ function Dynamic(props) {
578
586
  const component = cached();
579
587
  switch (typeof component) {
580
588
  case "function":
589
+ Object.assign(component, {
590
+ [$DEVCOMP]: true
591
+ });
581
592
  return untrack(() => component(others));
582
593
  case "string":
583
594
  const isSvg = SVGElements.has(component);
@@ -588,4 +599,4 @@ function Dynamic(props) {
588
599
  });
589
600
  }
590
601
 
591
- export { Aliases, voidFn as Assets, ChildProperties, DOMElements, DelegatedEvents, Dynamic, Hydration, voidFn as HydrationScript, NoHydration, Portal, PropAliases, Properties, SVGElements, SVGNamespace, addEventListener, assign, classList, className, clearDelegatedEvents, delegateEvents, dynamicProperty, escape, voidFn as generateHydrationScript, voidFn as getAssets, getHydrationKey, getNextElement, getNextMarker, getNextMatch, hydrate, innerHTML, insert, isServer, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrSpread, ssrStyle, style, template, use, voidFn as useAssets };
602
+ export { Aliases, voidFn as Assets, ChildProperties, DOMElements, DelegatedEvents, Dynamic, Hydration, voidFn as HydrationScript, NoHydration, Portal, PropAliases, Properties, SVGElements, SVGNamespace, addEventListener, assign, classList, className, clearDelegatedEvents, delegateEvents, dynamicProperty, escape, voidFn as generateHydrationScript, voidFn as getAssets, getHydrationKey, getNextElement, getNextMarker, getNextMatch, hydrate, innerHTML, insert, isDev, isServer, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrSpread, ssrStyle, style, template, use, voidFn as useAssets };
@@ -3,7 +3,8 @@ import { JSX, Accessor, ComponentProps, ValidComponent } from "solid-js";
3
3
  export * from "./client.js";
4
4
  export { For, Show, Suspense, SuspenseList, Switch, Match, Index, ErrorBoundary, mergeProps } from "solid-js";
5
5
  export * from "./server-mock.js";
6
- export declare const isServer = false;
6
+ export declare const isServer: boolean;
7
+ export declare const isDev: boolean;
7
8
  export declare const hydrate: typeof hydrateCore;
8
9
  /**
9
10
  * renders components somewhere else in the DOM