@solidjs/web 2.0.0-rc.6 → 2.0.0-rc.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.
Files changed (82) hide show
  1. package/dist/{server.cjs → server.dev.js} +274 -272
  2. package/dist/server.js +119 -36
  3. package/dist/{dev.js → web.dev.js} +131 -399
  4. package/dist/web.js +78 -388
  5. package/dist/{web.cjs → web.observe.js} +174 -622
  6. package/frames/dist/client.dev.js +11 -3
  7. package/frames/dist/client.js +11 -3
  8. package/frames/dist/{server.cjs → server.dev.js} +375 -125
  9. package/frames/dist/server.js +253 -32
  10. package/frames/package.json +7 -15
  11. package/package.json +88 -251
  12. package/serialization/decode/package.json +3 -9
  13. package/serialization/dist/decode.js +18 -4
  14. package/serialization/dist/serialization.js +18 -4
  15. package/serialization/package.json +3 -9
  16. package/serialization/types/serializer-decode.d.ts +49 -2
  17. package/server-functions/dist/client.js +13 -14
  18. package/server-functions/dist/server.dev.js +359 -85
  19. package/server-functions/dist/server.js +352 -86
  20. package/server-functions/package.json +6 -24
  21. package/server-functions/rich-args/package.json +3 -9
  22. package/storage/package.json +3 -9
  23. package/types/client.d.ts +17 -3
  24. package/types/frames/frame-client.d.ts +1 -1
  25. package/types/frames/serializer-decode.d.ts +49 -2
  26. package/types/head.d.ts +3 -0
  27. package/types/index.d.ts +18 -7
  28. package/types/index.server.d.ts +31 -9
  29. package/types/render.d.ts +3 -1
  30. package/types/serializer-decode.d.ts +49 -2
  31. package/types/server-functions/flash.d.ts +12 -3
  32. package/types/server-functions/server.d.ts +50 -3
  33. package/types/server-mock.d.ts +43 -7
  34. package/types/server.d.ts +48 -6
  35. package/dist/dev.cjs +0 -2590
  36. package/frames/dist/client.cjs +0 -2035
  37. package/frames/dist/client.dev.cjs +0 -2055
  38. package/serialization/dist/decode.cjs +0 -141
  39. package/serialization/dist/serialization.cjs +0 -261
  40. package/serialization/types-cjs/index.d.cts +0 -101
  41. package/serialization/types-cjs/package.json +0 -3
  42. package/serialization/types-cjs/serializer-decode.d.cts +0 -172
  43. package/serialization/types-cjs/serializer.d.cts +0 -101
  44. package/server-functions/dist/client.cjs +0 -1070
  45. package/server-functions/dist/rich-args.cjs +0 -11
  46. package/server-functions/dist/server.cjs +0 -2133
  47. package/server-functions/dist/server.dev.cjs +0 -2153
  48. package/storage/dist/storage.cjs +0 -12
  49. package/storage/types-cjs/index.d.cts +0 -28
  50. package/storage/types-cjs/package.json +0 -3
  51. package/types/patch-driver.d.ts +0 -3
  52. package/types-cjs/client.d.cts +0 -200
  53. package/types-cjs/constants.d.cts +0 -20
  54. package/types-cjs/cookies.d.cts +0 -41
  55. package/types-cjs/frames/client.d.cts +0 -36
  56. package/types-cjs/frames/frame-client.d.cts +0 -370
  57. package/types-cjs/frames/frame-container-plugin.d.cts +0 -71
  58. package/types-cjs/frames/frame-sink.d.cts +0 -92
  59. package/types-cjs/frames/frame-transport.d.cts +0 -189
  60. package/types-cjs/frames/serializer-decode.d.cts +0 -172
  61. package/types-cjs/frames/serializer.d.cts +0 -101
  62. package/types-cjs/frames/server.d.cts +0 -52
  63. package/types-cjs/head.d.cts +0 -16
  64. package/types-cjs/index.d.cts +0 -180
  65. package/types-cjs/index.server.d.cts +0 -125
  66. package/types-cjs/jsx-properties.d.cts +0 -93
  67. package/types-cjs/jsx.d.cts +0 -4146
  68. package/types-cjs/package.json +0 -3
  69. package/types-cjs/patch-driver.d.cts +0 -3
  70. package/types-cjs/reconcile.d.cts +0 -1
  71. package/types-cjs/render.d.cts +0 -4
  72. package/types-cjs/response.d.cts +0 -81
  73. package/types-cjs/serializer-decode.d.cts +0 -172
  74. package/types-cjs/serializer.d.cts +0 -101
  75. package/types-cjs/server-functions/client.d.cts +0 -184
  76. package/types-cjs/server-functions/flash.d.cts +0 -27
  77. package/types-cjs/server-functions/registry.d.cts +0 -100
  78. package/types-cjs/server-functions/rich-args.d.cts +0 -1
  79. package/types-cjs/server-functions/server.d.cts +0 -522
  80. package/types-cjs/server-functions/shared.d.cts +0 -283
  81. package/types-cjs/server-mock.d.cts +0 -301
  82. package/types-cjs/server.d.cts +0 -366
@@ -1,4 +1,4 @@
1
- import { createRenderEffect, createMemo, sharedConfig, enableHydration, untrack, runWithOwner, resetErrorHalt, enforceLoadingBoundary, createRoot, flatten, flush, getOwner, createOwner, patchableRaw, storeHasOptimisticFamily, storeIsShallow, registerRowOps, registerSlotPatch, onCleanup, registerPatch, createComponent, omit, createSignal, $DEVCOMP, createEffect } from 'solid-js';
1
+ import { createRenderEffect, getOwner, createMemo, sharedConfig, enableHydration, $PROXY, untrack, runWithOwner, resetErrorHalt, enforceLoadingBoundary, createRoot, flatten, flush, mergeSources, OBSERVE, createComponent, omit, createOwner, createSignal, $DEVCOMP, onCleanup, createEffect } from 'solid-js';
2
2
  export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, getOwner, merge as mergeProps, untrack } from 'solid-js';
3
3
 
4
4
  const DOMWithState = {
@@ -57,12 +57,32 @@ const transparentOptions = {
57
57
  const syncOptions = {
58
58
  sync: true
59
59
  };
60
+ let bindingEffect = null;
61
+ function tagElement(node) {
62
+ if (bindingEffect !== null && bindingEffect._devElement === undefined) bindingEffect._devElement = node;
63
+ }
60
64
  function effect(fn, effectFn, options) {
61
- createRenderEffect(fn, effectFn, options ? {
65
+ const nodeOptions = options ? {
62
66
  sync: true,
63
67
  ...options,
64
68
  transparent: !options.scope
65
- } : transparentOptions);
69
+ } : transparentOptions;
70
+ {
71
+ let node = null;
72
+ createRenderEffect(prev => {
73
+ node = getOwner();
74
+ return fn(prev);
75
+ }, (value, prev) => {
76
+ const outer = bindingEffect;
77
+ bindingEffect = node;
78
+ try {
79
+ return effectFn(value, prev);
80
+ } finally {
81
+ bindingEffect = outer;
82
+ }
83
+ }, nodeOptions);
84
+ return;
85
+ }
66
86
  }
67
87
  function memo(fn) {
68
88
  return createMemo(() => fn(), syncOptions);
@@ -211,12 +231,24 @@ function classifyHeadTag(desc) {
211
231
  resource: false
212
232
  };
213
233
  }
234
+ function qualifierValue(name, value) {
235
+ if (value == null || value === false) return null;
236
+ if (name === "imagesrcset" || name === "imagesizes") return typeof value === "string" && value !== "" ? value : null;
237
+ const v = value === true ? "" : String(value);
238
+ if (name === "as") return asciiLowerCase(v);
239
+ if (name !== "crossorigin") return v;
240
+ return v.length === 15 && v.toLowerCase() === "use-credentials" ? v.toLowerCase() : "anonymous";
241
+ }
242
+ function asciiLowerCase(value) {
243
+ return value.replace(/[A-Z]/g, c => String.fromCharCode(c.charCodeAt(0) + 32));
244
+ }
214
245
  function resourceIdentity(tag, props) {
215
- let id = "res:" + tag + ":" + (props.rel || "") + ":" + (props.href || props.src || "");
246
+ const url = String(props.href || props.src || "");
247
+ let id = "res:" + tag + ":" + (props.rel || "") + ":" + url.length + ":" + url;
216
248
  for (let i = 0; i < RESOURCE_QUALIFIERS.length; i++) {
217
249
  const q = RESOURCE_QUALIFIERS[i];
218
- const value = props[q];
219
- if (value != null) id += ":" + q + "=" + (value === true ? "" : value);
250
+ const value = qualifierValue(q, props[q]);
251
+ if (value !== null) id += ":" + q + "=" + value.length + ":" + value;
220
252
  }
221
253
  return id;
222
254
  }
@@ -356,10 +388,6 @@ const waitAsset = promise => {
356
388
  }
357
389
  gate();
358
390
  };
359
- let listDriver;
360
- function installListDriver(driver) {
361
- listDriver = driver;
362
- }
363
391
  const $$EVENT_OWNER = "_$SOLID_EVENT_OWNER";
364
392
  const $$EVENT_TUPLE = Symbol();
365
393
  const hasOwn = Object.prototype.hasOwnProperty;
@@ -414,6 +442,7 @@ function render(code, element, init, options = {}) {
414
442
  }
415
443
  function create(html, bypassGuard, flag) {
416
444
  if (isHydrating() && !bypassGuard) throw new Error("Failed attempt to create new DOM elements during hydration. Check that the libraries you are using support hydration.");
445
+ if (/^<(html|head|body)[\s>]/i.test(html)) throw new Error("Document shell templates (<html>, <head>, <body>) cannot be client-created: " + "a <template> parse strips those tags. Render this component through hydrate(), " + "where the document shell already exists.");
417
446
  const t = document.createElement("template");
418
447
  t.innerHTML = html;
419
448
  return flag === 2 ? t.content.firstChild.firstChild : t.content.firstChild;
@@ -464,10 +493,27 @@ function unregisterDelegatedContainer(container, owner = container) {
464
493
  }
465
494
  function attachDelegatedEvent(name, container, state) {
466
495
  if (state.handlers.has(name)) return;
467
- const handler = e => eventHandler(e, container, state);
496
+ const handler = e => dispatchAsInteraction(e, () => eventHandler(e, container, state)) ;
468
497
  state.handlers.set(name, handler);
469
498
  container.addEventListener(name, handler);
470
499
  }
500
+ function describeEventTarget(target) {
501
+ if (!target || typeof target.tagName !== "string") return undefined;
502
+ const tag = target.tagName.toLowerCase();
503
+ let out = tag;
504
+ if (target.id) out += `#${target.id}`;else if (typeof target.name === "string" && target.name) out += `[name=${target.name}]`;
505
+ if (tag !== "input" && tag !== "textarea" && tag !== "select") {
506
+ const text = (target.textContent || "").trim().replace(/\s+/g, " ");
507
+ if (text) out += ` "${text.length > 30 ? text.slice(0, 29) + "…" : text}"`;
508
+ }
509
+ return out;
510
+ }
511
+ function dispatchAsInteraction(e, fn) {
512
+ return OBSERVE.attribution.withInteraction({
513
+ type: e.type,
514
+ target: describeEventTarget(e.target)
515
+ }, fn);
516
+ }
471
517
  function getDelegatedRoot(node) {
472
518
  while (node) {
473
519
  if (delegatedContainers.get(node)?.roots) return node;
@@ -487,6 +533,7 @@ function findOwner(target, state) {
487
533
  }
488
534
  }
489
535
  function setProperty(node, name, value) {
536
+ tagElement(node);
490
537
  if (isHydrating(node)) return;
491
538
  const nodeName = node.nodeName;
492
539
  if (name === "value" && nodeName === "SELECT") queueMicrotask(() => node.value = value) || (node.value = value);else if ((name === "value" || name === "defaultValue") && (nodeName === "INPUT" || nodeName === "TEXTAREA")) node[name] = value ?? "";else node[name] = value;
@@ -522,6 +569,7 @@ function claimElement(node) {
522
569
  return node;
523
570
  }
524
571
  function setAttribute(node, name, value) {
572
+ tagElement(node);
525
573
  if (isHydrating(node)) return;
526
574
  const selectMultiple = name === "multiple" && node.localName === "select";
527
575
  if (value == null || value === false) node.removeAttribute(name);else {
@@ -537,10 +585,12 @@ function setAttribute(node, name, value) {
537
585
  if (claimHandlers !== null && (name === "href" || name === "action")) claimElement(node);
538
586
  }
539
587
  function setAttributeNS(node, namespace, name, value) {
588
+ tagElement(node);
540
589
  if (isHydrating(node)) return;
541
590
  if (value == null || value === false) node.removeAttributeNS(namespace, name.indexOf(":") > -1 ? name.split(":").pop() : name);else node.setAttributeNS(namespace, name, value === true ? "" : value);
542
591
  }
543
592
  function className(node, value, prev) {
593
+ tagElement(node);
544
594
  if (typeof value === "number") value = "" + value;
545
595
  if (typeof prev === "number") prev = "" + prev;
546
596
  if (isHydrating(node)) {
@@ -594,15 +644,21 @@ function addEvent(node, name, handler, delegate) {
594
644
  }
595
645
  if (Array.isArray(handler)) {
596
646
  const handlerFn = handler[0];
597
- const listener = e => handlerFn.call(node, handler[1], e);
647
+ const listener = e => dispatchAsInteraction(e, () => handlerFn.call(node, handler[1], e)) ;
598
648
  listener[$$EVENT_TUPLE] = handler;
599
649
  node.addEventListener(name, listener);
600
650
  return listener;
601
651
  }
652
+ if (typeof handler === "function") {
653
+ const listener = e => dispatchAsInteraction(e, () => handler.call(node, e));
654
+ node.addEventListener(name, listener);
655
+ return listener;
656
+ }
602
657
  node.addEventListener(name, handler, typeof handler !== "function" && handler);
603
658
  return handler;
604
659
  }
605
660
  function style(node, value, prev) {
661
+ tagElement(node);
606
662
  if (isHydrating(node)) return;
607
663
  if (!value) {
608
664
  if (prev || node._$styles) {
@@ -642,13 +698,29 @@ function style(node, value, prev) {
642
698
  }
643
699
  }
644
700
  }
701
+ function readShallow(value) {
702
+ if (value === null || typeof value !== "object") return value;
703
+ if (Array.isArray(value)) return value.map(readShallow);
704
+ if (value[$PROXY] !== value) return value;
705
+ const keys = ownKeys(value);
706
+ const out = {};
707
+ for (let i = 0; i < keys.length; i++) {
708
+ const k = keys[i];
709
+ if (typeof k === "string") out[k] = value[k];
710
+ }
711
+ return out;
712
+ }
713
+ function ownKeys(o) {
714
+ return o[$PROXY] === o ? Reflect.ownKeys(o) : Object.keys(o);
715
+ }
645
716
  function setStyleProperty(node, name, value) {
717
+ tagElement(node);
646
718
  if (isHydrating(node)) return;
647
719
  value != null ? node.style.setProperty(name, value) : node.style.removeProperty(name);
648
720
  }
649
- function spread(node, props = {}, skipChildren) {
721
+ function spread(node, props, skipChildren) {
650
722
  const prevProps = {};
651
- const get = typeof props === "function" ? props : () => props;
723
+ const get = () => (typeof props === "function" ? props() : props) ?? {};
652
724
  if (!skipChildren) insert(node, () => {
653
725
  const source = get();
654
726
  return hasOwn.call(source, "children") ? source.children : undefined;
@@ -661,15 +733,27 @@ function spread(node, props = {}, skipChildren) {
661
733
  effect(() => {
662
734
  const source = get();
663
735
  const newProps = {};
664
- for (const prop in source) {
665
- if (!hasOwn.call(source, prop)) continue;
666
- if (prop === "children" || prop === "ref") continue;
667
- newProps[prop] = source[prop];
668
- }
736
+ const sources = mergeSources(source);
737
+ if (sources !== undefined) {
738
+ for (let i = 0; i < sources.length; i++) {
739
+ let s = sources[i];
740
+ if (typeof s === "function") s = s();
741
+ if (s != null) collectProps(newProps, s);
742
+ }
743
+ } else collectProps(newProps, source);
669
744
  return newProps;
670
745
  }, props => assign(node, props, true, prevProps, true));
671
746
  return prevProps;
672
747
  }
748
+ function collectProps(out, s) {
749
+ const keys = ownKeys(s);
750
+ for (let i = 0; i < keys.length; i++) {
751
+ const prop = keys[i];
752
+ if (typeof prop !== "string" || prop === "children" || prop === "ref") continue;
753
+ const v = s[prop];
754
+ out[prop] = prop === "style" || prop === "class" ? readShallow(v) : v;
755
+ }
756
+ }
673
757
  function dynamicProperty(props, key) {
674
758
  const src = props[key];
675
759
  Object.defineProperty(props, key, {
@@ -694,19 +778,6 @@ function scope(fn) {
694
778
  const SCOPE_OPTIONS = {
695
779
  scope: true
696
780
  };
697
- let insertionParent = null;
698
- function getInsertionParent() {
699
- return insertionParent;
700
- }
701
- function withInsertionParent(parent, fn) {
702
- const prev = insertionParent;
703
- insertionParent = parent;
704
- try {
705
- return fn();
706
- } finally {
707
- insertionParent = prev;
708
- }
709
- }
710
781
  let hydrationRt = null;
711
782
  function installHydrationRuntime() {
712
783
  hydrationRt = {
@@ -768,13 +839,8 @@ function insert(parent, accessor, marker, initial, options) {
768
839
  const host = options && options.host;
769
840
  if (multi && !initial) initial = [];
770
841
  if (hydrationRt !== null) initial = hydrationRt.claimInitial(parent, multi, initial);
771
- if (listDriver !== undefined && typeof accessor === "function" && accessor.$ll !== undefined) {
772
- const listAccessor = accessor;
773
- const owner = getOwner();
774
- if (listDriver(parent, accessor, marker, () => runWithOwner(owner, () => insert(parent, () => listAccessor(), marker, marker !== undefined ? [] : undefined, options)))) return;
775
- }
776
842
  if (typeof accessor !== "function") {
777
- accessor = withInsertionParent(parent, () => normalize(accessor, initial, multi, true));
843
+ accessor = normalize(accessor, initial, multi, true);
778
844
  if (typeof accessor !== "function") {
779
845
  insertExpression(parent, accessor, initial, marker);
780
846
  host && tagHost(accessor, host);
@@ -789,9 +855,9 @@ function insert(parent, accessor, marker, initial, options) {
789
855
  let current = initial;
790
856
  effect(prev => {
791
857
  if (hydrationRt !== null) current = hydrationRt.reclaimRegion(current, parent, marker);
792
- const value = withInsertionParent(parent, () => normalize(accessor(), current, multi, true));
858
+ const value = normalize(accessor(), current, multi, true);
793
859
  if (typeof value !== "function") return value;
794
- effect(() => (hydrationRt !== null && (current = hydrationRt.reclaimRegion(current, parent, marker)), withInsertionParent(parent, () => normalize(value, current, multi))), inner => {
860
+ effect(() => (hydrationRt !== null && (current = hydrationRt.reclaimRegion(current, parent, marker)), normalize(value, current, multi)), inner => {
795
861
  current = insertExpression(parent, inner, current, marker);
796
862
  host && tagHost(current, host);
797
863
  }, prev !== undefined && !(options && options.schedule) ? {
@@ -810,6 +876,7 @@ function insert(parent, accessor, marker, initial, options) {
810
876
  } : SCOPE_OPTIONS : options);
811
877
  }
812
878
  function assign(node, props, skipChildren, prevProps = {}, skipRef = false) {
879
+ tagElement(node);
813
880
  const nodeName = node.nodeName;
814
881
  props || (props = {});
815
882
  for (const prop in prevProps) {
@@ -832,10 +899,16 @@ function assetEntryKey(descriptor) {
832
899
  if (descriptor.policy === "exclusive") return "x|" + descriptor.key;
833
900
  return descriptor.type === "inline-style" ? "i|" + descriptor.id : descriptor.type + "|" + descriptor.href;
834
901
  }
835
- function findAssetElement(selector, attr, value) {
902
+ function findAssetElement(selector, attr, value, qualifiers) {
836
903
  const nodes = document.querySelectorAll(selector);
837
- for (let i = 0; i < nodes.length; i++) {
838
- if (nodes[i].getAttribute(attr) === value) return nodes[i];
904
+ outer: for (let i = 0; i < nodes.length; i++) {
905
+ if (nodes[i].getAttribute(attr) !== value) continue;
906
+ if (!qualifiers) return nodes[i];
907
+ for (let q = 0; q < RESOURCE_QUALIFIERS.length; q++) {
908
+ const name = RESOURCE_QUALIFIERS[q];
909
+ if (qualifierValue(name, qualifiers[name]) !== qualifierValue(name, nodes[i].getAttribute(name))) continue outer;
910
+ }
911
+ return nodes[i];
839
912
  }
840
913
  return null;
841
914
  }
@@ -1141,8 +1214,8 @@ function mountHeadResource(tag, props) {
1141
1214
  headMountedResources.add(identity);
1142
1215
  const url = props.href || props.src;
1143
1216
  let el = null;
1144
- if (url != null) {
1145
- if (tag === "link") el = findAssetElement(`link[rel="${props.rel}"]`, "href", url);else if (tag === "script") el = findAssetElement("script[src]", "src", url);else el = findAssetElement("style[href]", "href", url);
1217
+ if (tag === "link" && url == null && typeof props.imagesrcset === "string") el = findAssetElement(`link[rel="${props.rel}"]`, "href", null, props);else if (url != null) {
1218
+ if (tag === "link") el = findAssetElement(`link[rel="${props.rel}"]`, "href", url, props);else if (tag === "script") el = findAssetElement("script[src]", "src", url);else el = findAssetElement("style[href]", "href", url);
1146
1219
  }
1147
1220
  if (!el) document.head.appendChild(createHeadElement(tag, props));
1148
1221
  }
@@ -1323,9 +1396,14 @@ function hydrate(code, element, options = {}) {
1323
1396
  sharedConfig.hydrating = false;
1324
1397
  }
1325
1398
  }, err => {
1326
- console.error("Hydration module preload failed, falling back to client render:", err);
1327
1399
  sharedConfig.hydrating = false;
1328
1400
  sharedConfig.registry = undefined;
1401
+ if (element.nodeType === 9) {
1402
+ console.error("Hydration module preload failed for a document root; a document shell cannot " + "be client-rendered, so hydration was abandoned and the page is not interactive.");
1403
+ (globalThis.reportError || console.error)(err);
1404
+ return;
1405
+ }
1406
+ console.error("Hydration module preload failed, falling back to client render:", err);
1329
1407
  disposer = render(code, element, [...element.childNodes], options);
1330
1408
  });
1331
1409
  return () => disposer && disposer();
@@ -1615,6 +1693,7 @@ function eventHandler(e, container, state) {
1615
1693
  retarget(oriTarget);
1616
1694
  }
1617
1695
  function insertExpression(parent, value, current, marker) {
1696
+ tagElement(parent);
1618
1697
  if (hydrationRt !== null && isHydrating(parent)) {
1619
1698
  if (value && value !== current) {
1620
1699
  const arr = Array.isArray(value);
@@ -1775,331 +1854,6 @@ function getHydrationKey() {
1775
1854
  }
1776
1855
  const RequestContext = Symbol();
1777
1856
 
1778
- const PURE_ROW = Symbol.for("solid.pure-row");
1779
- const arm = () => {
1780
- installListDriver(driveList);
1781
- };
1782
- function rowProof(fn) {
1783
- arm();
1784
- fn[PURE_ROW] = true;
1785
- return fn;
1786
- }
1787
- let rowCollector = null;
1788
- const lisPositions = sources => {
1789
- const n = sources.length;
1790
- const tails = [];
1791
- const tailsIdx = [];
1792
- const prev = new Array(n).fill(-1);
1793
- for (let j = 0; j < n; j++) {
1794
- const v = sources[j];
1795
- if (v === -1) continue;
1796
- let lo = 0,
1797
- hi = tails.length;
1798
- while (lo < hi) {
1799
- const mid = lo + hi >> 1;
1800
- if (tails[mid] < v) lo = mid + 1;else hi = mid;
1801
- }
1802
- if (lo > 0) prev[j] = tailsIdx[lo - 1];
1803
- tails[lo] = v;
1804
- tailsIdx[lo] = j;
1805
- }
1806
- const stable = new Set();
1807
- let k = tailsIdx.length ? tailsIdx[tails.length - 1] : -1;
1808
- while (k >= 0) {
1809
- stable.add(k);
1810
- k = prev[k];
1811
- }
1812
- return stable;
1813
- };
1814
- const driveList = (parent, listFn, marker, lateClassic) => {
1815
- const meta = listFn.$ll;
1816
- if (meta.row?.[PURE_ROW] !== true) return false;
1817
- if (typeof meta.keyed === "function") return false;
1818
- const evalOwner = createOwner({
1819
- id: "&each"
1820
- });
1821
- let subject = runWithOwner(evalOwner, () => untrack(meta.each));
1822
- evalOwner.dispose();
1823
- let raw = subject != null ? patchableRaw(subject) : undefined;
1824
- if (raw === undefined || !Array.isArray(raw)) return false;
1825
- const optimistic = storeHasOptimisticFamily(subject);
1826
- if (optimistic) raw = untrack(() => Array.from(subject));
1827
- const hydrating = !!sharedConfig.hydrating;
1828
- if (hydrating && raw.length === 0) return false;
1829
- let domRows;
1830
- let rowIds;
1831
- if (hydrating) {
1832
- if (marker !== undefined) return false;
1833
- domRows = Array.from(parent.children);
1834
- if (domRows.length !== raw.length) return false;
1835
- rowIds = new Array(raw.length);
1836
- for (let i = 0; i < domRows.length; i++) {
1837
- const key = domRows[i].getAttribute("_hk");
1838
- if (key === null || !key.endsWith("0") || key.length < 2) return false;
1839
- rowIds[i] = key.slice(0, -1);
1840
- }
1841
- }
1842
- const rowFn = meta.row;
1843
- const endAnchor = marker ?? null;
1844
- const shallow = storeIsShallow(subject);
1845
- let lastBodies = null;
1846
- let lastUnbinds = null;
1847
- const collectBind = (abs, build) => {
1848
- const prevC = rowCollector;
1849
- rowCollector = {
1850
- row: shallow ? subject[abs] : undefined,
1851
- bodies: [],
1852
- unbinds: []
1853
- };
1854
- try {
1855
- return build();
1856
- } finally {
1857
- lastBodies = rowCollector.bodies;
1858
- lastUnbinds = rowCollector.unbinds;
1859
- rowCollector = prevC;
1860
- }
1861
- };
1862
- const listOwner = createOwner();
1863
- let declined = false;
1864
- const bindRow = (abs, claimId) => {
1865
- {
1866
- const o = listOwner;
1867
- const prevChild = o._firstChild;
1868
- const prevDisposal = o._disposal;
1869
- const node = collectBind(abs, () => runWithOwner(listOwner, () => claimId !== undefined ? runWithOwner(createOwner({
1870
- id: claimId
1871
- }), () => untrack(() => rowFn(subject[abs]))) : untrack(() => rowFn(subject[abs]))));
1872
- if (o._firstChild !== prevChild || o._disposal !== prevDisposal) {
1873
- console.warn("A patch-mode list row created reactive computations or cleanups " + "during build (likely a handler/attribute value expression calling " + "createEffect/onCleanup). This work attaches to the LIST, not the " + "row, and will not dispose when the row is removed. Move owned " + "work into effects/refs (which opt the row out of patch mode).");
1874
- }
1875
- return node;
1876
- }
1877
- };
1878
- let entries = new Array(raw.length);
1879
- let rowBodies = shallow ? new Array(raw.length) : null;
1880
- let rowUnbinds = new Array(raw.length);
1881
- const runUnbinds = list => {
1882
- if (list !== undefined) for (let u = 0; u < list.length; u++) list[u]();
1883
- };
1884
- const unbindAllRows = () => {
1885
- for (let j = 0; j < rowUnbinds.length; j++) runUnbinds(rowUnbinds[j]);
1886
- rowUnbinds = [];
1887
- };
1888
- let prevRaws = raw.slice();
1889
- try {
1890
- if (hydrating) {
1891
- for (let i = 0; i < raw.length; i++) {
1892
- entries[i] = bindRow(i, rowIds[i]);
1893
- if (rowBodies !== null) rowBodies[i] = lastBodies;
1894
- rowUnbinds[i] = lastUnbinds;
1895
- }
1896
- } else {
1897
- for (let i = 0; i < raw.length; i++) {
1898
- const node = bindRow(i);
1899
- entries[i] = node;
1900
- if (rowBodies !== null) rowBodies[i] = lastBodies;
1901
- rowUnbinds[i] = lastUnbinds;
1902
- parent.insertBefore(node, endAnchor);
1903
- }
1904
- }
1905
- } catch (err) {
1906
- unbindAllRows();
1907
- runUnbinds(lastUnbinds ?? undefined);
1908
- for (let j = 0; j < entries.length; j++) {
1909
- const n = entries[j];
1910
- if (n !== undefined && n.parentNode === parent) n.remove();
1911
- }
1912
- listOwner.dispose();
1913
- throw err;
1914
- }
1915
- const identityOps = nextArr => {
1916
- const keyOf = r => {
1917
- const w = r != null ? patchableRaw(r) : undefined;
1918
- return w !== undefined ? w : r;
1919
- };
1920
- const oldIndex = new Map();
1921
- for (let j = 0; j < prevRaws.length; j++) {
1922
- const k = keyOf(prevRaws[j]);
1923
- const existing = oldIndex.get(k);
1924
- if (existing === undefined) oldIndex.set(k, j);else if (Array.isArray(existing)) existing.push(j);else oldIndex.set(k, [existing, j]);
1925
- }
1926
- const sources = new Array(nextArr.length);
1927
- for (let k = 0; k < nextArr.length; k++) {
1928
- const m = oldIndex.get(keyOf(nextArr[k]));
1929
- if (m === undefined) sources[k] = -1;else if (Array.isArray(m)) {
1930
- sources[k] = m.shift();
1931
- if (m.length === 1) oldIndex.set(keyOf(nextArr[k]), m[0]);
1932
- } else {
1933
- sources[k] = m;
1934
- oldIndex.delete(keyOf(nextArr[k]));
1935
- }
1936
- }
1937
- return {
1938
- prefix: 0,
1939
- sources
1940
- };
1941
- };
1942
- let resyncNeeded = false;
1943
- const applyOps = (next, ops) => {
1944
- if (declined) return;
1945
- if (resyncNeeded) ops = null;
1946
- if (ops === null) ops = identityOps(next);
1947
- const {
1948
- prefix,
1949
- sources
1950
- } = ops;
1951
- const built = new Array(sources.length);
1952
- const builtBodies = rowBodies !== null ? new Array(sources.length) : null;
1953
- const builtUnbinds = new Array(sources.length);
1954
- let j = 0;
1955
- try {
1956
- for (; j < sources.length; j++) {
1957
- const abs = prefix + j;
1958
- const src = sources[j];
1959
- if (src === -1 || refRebuild && src >= 0 && next[abs] !== prevRaws[src]) {
1960
- built[j] = bindRow(abs);
1961
- if (builtBodies !== null) builtBodies[j] = lastBodies;
1962
- builtUnbinds[j] = lastUnbinds;
1963
- }
1964
- }
1965
- } catch (err) {
1966
- for (let k = 0; k < j; k++) runUnbinds(builtUnbinds[k]);
1967
- runUnbinds(lastUnbinds ?? undefined);
1968
- resyncNeeded = true;
1969
- throw err;
1970
- }
1971
- const retained = new Set();
1972
- for (let k = 0; k < sources.length; k++) {
1973
- if (sources[k] >= 0 && built[k] === undefined) retained.add(sources[k]);
1974
- }
1975
- for (let k = prefix; k < entries.length; k++) {
1976
- if (!retained.has(k)) {
1977
- entries[k].remove();
1978
- runUnbinds(rowUnbinds[k]);
1979
- }
1980
- }
1981
- const newEntries = new Array(prefix + sources.length);
1982
- const newBodies = rowBodies !== null ? new Array(prefix + sources.length) : null;
1983
- const newUnbinds = new Array(prefix + sources.length);
1984
- for (let i = 0; i < prefix; i++) {
1985
- newEntries[i] = entries[i];
1986
- if (newBodies !== null) newBodies[i] = rowBodies[i];
1987
- newUnbinds[i] = rowUnbinds[i];
1988
- }
1989
- const stable = lisPositions(sources);
1990
- let anchor = endAnchor;
1991
- for (let k = sources.length - 1; k >= 0; k--) {
1992
- const abs = prefix + k;
1993
- const src = sources[k];
1994
- let node;
1995
- if (built[k] !== undefined) {
1996
- node = built[k];
1997
- if (newBodies !== null) newBodies[abs] = builtBodies[k];
1998
- newUnbinds[abs] = builtUnbinds[k];
1999
- parent.insertBefore(node, anchor);
2000
- } else {
2001
- node = entries[src];
2002
- if (newBodies !== null) newBodies[abs] = rowBodies[src];
2003
- newUnbinds[abs] = rowUnbinds[src];
2004
- if (!stable.has(k)) parent.insertBefore(node, anchor);
2005
- }
2006
- newEntries[abs] = node;
2007
- anchor = node;
2008
- }
2009
- entries = newEntries;
2010
- if (newBodies !== null) rowBodies = newBodies;
2011
- rowUnbinds = newUnbinds;
2012
- prevRaws = next.slice();
2013
- resyncNeeded = false;
2014
- };
2015
- let unbindOps = runWithOwner(listOwner, () => registerRowOps(subject, applyOps));
2016
- const refRebuild = shallow && typeof meta.keyed !== "function";
2017
- const rebuildSlot = i => {
2018
- runUnbinds(rowUnbinds[i]);
2019
- const old = entries[i];
2020
- const node = bindRow(i);
2021
- rowBodies[i] = lastBodies;
2022
- rowUnbinds[i] = lastUnbinds;
2023
- parent.insertBefore(node, old);
2024
- old.remove();
2025
- entries[i] = node;
2026
- };
2027
- const applySlot = (i, next, prev) => {
2028
- if (declined) return;
2029
- if (resyncNeeded) {
2030
- const live = subject != null ? patchableRaw(subject) : undefined;
2031
- if (live !== undefined && Array.isArray(live)) applyOps(live, null);
2032
- return;
2033
- }
2034
- if (refRebuild) {
2035
- rebuildSlot(i);
2036
- prevRaws[i] = next;
2037
- return;
2038
- }
2039
- const bodies = rowBodies[i];
2040
- if (bodies !== undefined) {
2041
- for (let b = 0; b < bodies.length; b++) bodies[b](next, prev, false);
2042
- }
2043
- prevRaws[i] = next;
2044
- };
2045
- let unbindSlots = shallow ? runWithOwner(listOwner, () => registerSlotPatch(subject, applySlot)) : null;
2046
- runWithOwner(listOwner, () => effect(() => meta.each(), value => {
2047
- if (declined || value === subject) return;
2048
- const nextRaw = value != null ? patchableRaw(value) : undefined;
2049
- unbindOps();
2050
- unbindSlots?.();
2051
- if (nextRaw !== undefined && Array.isArray(nextRaw) && storeIsShallow(value) !== shallow) {
2052
- for (let j = 0; j < entries.length; j++) entries[j].remove();
2053
- entries = [];
2054
- prevRaws = [];
2055
- unbindAllRows();
2056
- subject = value;
2057
- declined = true;
2058
- listOwner.dispose();
2059
- lateClassic?.();
2060
- return;
2061
- }
2062
- if (nextRaw === undefined || !Array.isArray(nextRaw)) {
2063
- for (let j = 0; j < entries.length; j++) entries[j].remove();
2064
- entries = [];
2065
- prevRaws = [];
2066
- unbindAllRows();
2067
- subject = value;
2068
- declined = true;
2069
- listOwner.dispose();
2070
- lateClassic?.();
2071
- return;
2072
- }
2073
- const swapOps = identityOps(nextRaw);
2074
- subject = value;
2075
- unbindOps = runWithOwner(listOwner, () => registerRowOps(subject, applyOps));
2076
- if (shallow) unbindSlots = runWithOwner(listOwner, () => registerSlotPatch(subject, applySlot));
2077
- applyOps(nextRaw, swapOps);
2078
- }));
2079
- onCleanup(() => {
2080
- unbindOps();
2081
- unbindSlots?.();
2082
- unbindAllRows();
2083
- listOwner.dispose();
2084
- });
2085
- return true;
2086
- };
2087
- const patchDriver = (subject, body) => {
2088
- const raw = patchableRaw(subject);
2089
- if (raw !== undefined) {
2090
- if (!sharedConfig.hydrating) body(raw, undefined, true);
2091
- const unbind = registerPatch(subject, body);
2092
- if (rowCollector !== null) rowCollector.unbinds.push(unbind);
2093
- else onCleanup(unbind);
2094
- } else if (rowCollector !== null && subject === rowCollector.row) {
2095
- rowCollector.bodies.push(body);
2096
- if (!sharedConfig.hydrating) body(subject, undefined, true);
2097
- } else {
2098
- effect(() => body(subject, subject, false),
2099
- () => untrack(() => body(subject, undefined, true)));
2100
- }
2101
- };
2102
-
2103
1857
  function throwInBrowser(func) {
2104
1858
  const err = new Error(`${func.name} is not supported in the browser, returning undefined`);
2105
1859
  console.error(err);
@@ -2317,7 +2071,7 @@ const COMPONENT_BINDING = Symbol.for("solid.component-binding");
2317
2071
  function bindingOf(value) {
2318
2072
  return value !== null && (typeof value === "function" || typeof value === "object") && value[COMPONENT_BINDING] || undefined;
2319
2073
  }
2320
- function dynamic(source) {
2074
+ function dynamic(source, _options) {
2321
2075
  let latest = 0;
2322
2076
  const sites = new Set();
2323
2077
  let deliveredAddress;
@@ -2361,24 +2115,9 @@ function dynamic(source) {
2361
2115
  return untrack(() => component(props));
2362
2116
  }
2363
2117
  case "string":
2364
- {
2365
- if (sharedConfig.hydrating) {
2366
- const el = getNextElement();
2367
- spread(el, props);
2368
- return el;
2369
- }
2370
- const owner = getOwner();
2371
- let el;
2372
- return () => {
2373
- if (!el) {
2374
- runWithOwner(owner, () => {
2375
- el = createElement(component, untrack(() => props.is));
2376
- spread(el, props);
2377
- });
2378
- }
2379
- return el;
2380
- };
2381
- }
2118
+ const el = sharedConfig.hydrating ? getNextElement() : createElement(component, untrack(() => props.is));
2119
+ spread(el, props);
2120
+ return el;
2382
2121
  }
2383
2122
  });
2384
2123
  };
@@ -2387,15 +2126,8 @@ function Dynamic(props) {
2387
2126
  const Comp = dynamic(() => props.component);
2388
2127
  return createComponent(Comp, omit(props, "component"));
2389
2128
  }
2390
- const AmbiguousSVGElements = /*#__PURE__*/new Set(["a", "script", "style", "title"]);
2391
2129
  function createElement(tagName, is = undefined) {
2392
- if (SVGElements.has(tagName)) return document.createElementNS(Namespaces.svg, tagName);
2393
- if (MathMLElements.has(tagName)) return document.createElementNS(Namespaces.mathml, tagName);
2394
- if (AmbiguousSVGElements.has(tagName)) {
2395
- const parent = getInsertionParent();
2396
- if (parent && parent.namespaceURI === Namespaces.svg && parent.localName !== "foreignObject") return document.createElementNS(Namespaces.svg, tagName);
2397
- }
2398
- return document.createElement(tagName, {
2130
+ return SVGElements.has(tagName) ? document.createElementNS(Namespaces.svg, tagName) : MathMLElements.has(tagName) ? document.createElementNS(Namespaces.mathml, tagName) : document.createElement(tagName, {
2399
2131
  is
2400
2132
  });
2401
2133
  }
@@ -2427,4 +2159,4 @@ _moduleUrl) {
2427
2159
  function httpStatus(_code, _text) {}
2428
2160
  function httpHeader(_name, _value, _options) {}
2429
2161
 
2430
- export { ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, HREF, HydrationScript, MathMLElements, NULL_BODY_STATUSES, Namespaces, Portal, RESPONSE_HEADER_VALUE_LIMIT, REVALIDATE_HEADER, RawTextElements, RequestContext, ResponseEnvelope, SAFE_ERROR, SVGElements, VoidElements, acquireAsset, addEvent, applyRef, assign, claimElement, claimElementTree, className, clearFlashCookie, clientOnly, commitEventResponse, composeMiddleware, createRequestEvent, createResponseStub, createSSRResponse, delegateEvents, driveList, dynamic, dynamicProperty, effect, escape, generateHydrationScript, getDelegatedRoot, getExpectedRedirectStatus, getFirstChild, getHydrationKey, getInsertionParent, getNextElement, getNextMarker, getNextMatch, getNextSibling, getRequestEvent, getServerFunctionMetadata, getServerFunctionRPC, hasFlashCookie, httpHeader, httpStatus, hydrate, insert, installHydrationRuntime, installListDriver, isDev, isHref, isResponseEnvelope, isSafeError, isServer, isServerFunction, listDriver, markSafeError, memo, parseCookieHeader, patchDriver, redirect, ref, registerDelegatedContainer, registerDelegatedRoot, registerElementClaim, reload, render, renderToStream, renderToString, resolveSSRNode, respond, rowProof, runHydrationEvents, scope, serializeCookie, setAttribute, setAttributeNS, setProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassName, ssrElement, ssrGroup, ssrHydrationKey, ssrStyle, ssrStyleProperty, style, template, unregisterDelegatedContainer, unregisterDelegatedRoot, useHead, waitAsset, warmAsset };
2162
+ export { ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, HREF, HydrationScript, MathMLElements, NULL_BODY_STATUSES, Namespaces, Portal, RESPONSE_HEADER_VALUE_LIMIT, REVALIDATE_HEADER, RawTextElements, RequestContext, ResponseEnvelope, SAFE_ERROR, SVGElements, VoidElements, acquireAsset, addEvent, applyRef, assign, claimElement, claimElementTree, className, clearFlashCookie, clientOnly, commitEventResponse, composeMiddleware, createRequestEvent, createResponseStub, createSSRResponse, delegateEvents, dynamic, dynamicProperty, effect, escape, generateHydrationScript, getDelegatedRoot, getExpectedRedirectStatus, getFirstChild, getHydrationKey, getNextElement, getNextMarker, getNextMatch, getNextSibling, getRequestEvent, getServerFunctionMetadata, getServerFunctionRPC, hasFlashCookie, httpHeader, httpStatus, hydrate, insert, installHydrationRuntime, isDev, isHref, isResponseEnvelope, isSafeError, isServer, isServerFunction, markSafeError, memo, parseCookieHeader, readShallow, redirect, ref, registerDelegatedContainer, registerDelegatedRoot, registerElementClaim, reload, render, renderToStream, renderToString, resolveSSRNode, respond, runHydrationEvents, scope, serializeCookie, setAttribute, setAttributeNS, setProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassName, ssrElement, ssrGroup, ssrHydrationKey, ssrStyle, ssrStyleProperty, style, template, unregisterDelegatedContainer, unregisterDelegatedRoot, useHead, waitAsset, warmAsset };