@solidjs/web 2.0.0-rc.14 → 2.0.0-rc.16

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 (58) hide show
  1. package/README.md +1 -1
  2. package/dist/server.dev.js +475 -591
  3. package/dist/server.js +459 -489
  4. package/dist/server.observe.js +459 -498
  5. package/dist/web.dev.js +206 -220
  6. package/dist/web.js +196 -208
  7. package/dist/web.observe.js +206 -213
  8. package/frames/dist/client.dev.js +664 -643
  9. package/frames/dist/client.js +593 -582
  10. package/frames/dist/client.observe.js +624 -589
  11. package/frames/dist/regions.js +43 -2
  12. package/frames/dist/server.dev.js +578 -450
  13. package/frames/dist/server.js +578 -397
  14. package/frames/dist/server.observe.js +578 -397
  15. package/frames/dist/trace.js +4 -1
  16. package/frames/dist/wire.js +371 -6
  17. package/package.json +13 -13
  18. package/serialization/dist/decode.js +11 -9
  19. package/serialization/dist/serialization.js +11 -9
  20. package/serialization/types/serializer-decode.d.ts +2 -2
  21. package/server-functions/dist/client.dev.js +5 -2
  22. package/server-functions/dist/client.js +3 -2
  23. package/server-functions/dist/client.observe.js +5 -2
  24. package/server-functions/dist/rich-args.js +33 -1
  25. package/server-functions/dist/server.dev.js +218 -35
  26. package/server-functions/dist/server.js +218 -35
  27. package/server-functions/dist/server.observe.js +218 -35
  28. package/skills/server-components/SKILL.md +74 -185
  29. package/types/client.d.ts +112 -10
  30. package/types/constants.d.ts +2 -1
  31. package/types/frames/assets-tier.d.ts +2 -2
  32. package/types/frames/client.d.ts +8 -3
  33. package/types/frames/frame-client.d.ts +121 -157
  34. package/types/frames/frame-morph.d.ts +28 -0
  35. package/types/frames/frame-sink.d.ts +13 -9
  36. package/types/frames/frame-transport.d.ts +30 -1
  37. package/types/frames/regions-tier.d.ts +15 -0
  38. package/types/frames/serializer-decode.d.ts +2 -2
  39. package/types/frames/server.d.ts +1 -53
  40. package/types/frames/wire-tier.d.ts +54 -1
  41. package/types/head.d.ts +1 -0
  42. package/types/index.d.ts +57 -50
  43. package/types/index.server.d.ts +3 -27
  44. package/types/jsx.d.ts +14 -17
  45. package/types/observe.d.ts +14 -7
  46. package/types/render.d.ts +3 -1
  47. package/types/response.d.ts +31 -8
  48. package/types/serializer-decode.d.ts +2 -2
  49. package/types/server-functions/argument-codec.d.ts +21 -0
  50. package/types/server-functions/client.d.ts +18 -5
  51. package/types/server-functions/server.d.ts +6 -2
  52. package/types/server-functions/shared.d.ts +19 -0
  53. package/types/server-mock.d.ts +9 -2
  54. package/types/server-observe.d.ts +3 -2
  55. package/types/server.d.ts +124 -67
  56. package/frames/dist/bind.dev.js +0 -326
  57. package/frames/dist/bind.js +0 -295
  58. package/types/frames/bind-tier.d.ts +0 -60
@@ -1,6 +1,6 @@
1
- import { createRenderEffect, createMemo, OBSERVE, enableHydration, $PROXY, untrack, runWithOwner, createRoot, getOwner, ROOT_ERROR_HOOK, flatten, flush, createComponent, omit, createOwner, createSignal, createEffect, onCleanup } from 'solid-js';
2
- export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, getOwner, merge as mergeProps, untrack } from 'solid-js';
3
- import { sharedConfig, sourceKeys, SOURCE_PROXY, resolvedTable, viewOf, OmitView, hasStaticKeys, SOURCE_MEMO, sourceHas, SOURCE_OMIT, sourceGet, SOURCE_PLAIN } from 'solid-js/internal';
1
+ import { createRenderEffect, createMemo, OBSERVE, enableHydration, $PROXY, untrack, runWithOwner, createRoot, getOwner, ROOT_ERROR_HOOK, flatten, flush, createComponent, omit, createOwner, createSignal, createEffect } from 'solid-js';
2
+ export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, dynamicComponent, getOwner, merge as mergeProps, untrack } from 'solid-js';
3
+ import { sharedConfig, enableServerComponentHydration, resolvedTable, viewOf, OmitView, hasStaticKeys, SOURCE_MEMO, sourceHas, SOURCE_OMIT, sourceGet, sourceKeys, SOURCE_PROXY, SOURCE_PLAIN, dynamicCore } from 'solid-js/internal';
4
4
 
5
5
  const DOMWithState = {
6
6
  INPUT: {
@@ -56,8 +56,10 @@ const transparentOptions = {
56
56
  sync: true
57
57
  };
58
58
  let spreadName;
59
- function setSpreadName(name) {
59
+ let spreadLoc;
60
+ function setSpreadName(name, loc) {
60
61
  spreadName = name;
62
+ spreadLoc = loc;
61
63
  }
62
64
  const syncOptions = {
63
65
  sync: true
@@ -65,7 +67,8 @@ const syncOptions = {
65
67
  function effect(fn, effectFn, options) {
66
68
  if (spreadName !== undefined && (options === undefined || options.name === undefined)) options = {
67
69
  ...options,
68
- name: spreadName + ".spread"
70
+ name: spreadName + ".spread",
71
+ loc: spreadLoc
69
72
  };
70
73
  const nodeOptions = options ? {
71
74
  sync: true,
@@ -79,40 +82,39 @@ function memo(fn) {
79
82
  }
80
83
 
81
84
  function reconcileArrays(parentNode, a, b, marker) {
85
+ const isLive = n => {
86
+ if (!n) return false;
87
+ const tag = n[$$SLOT];
88
+ return n.parentNode === parentNode && (!tag || tag === marker);
89
+ };
82
90
  let bLength = b.length,
83
91
  aEnd = a.length,
84
92
  bEnd = bLength,
85
93
  aStart = 0,
86
94
  bStart = 0,
87
95
  tail = a[aEnd - 1],
88
- tailTag = tail[$$SLOT],
89
- after = tail.parentNode === parentNode && (!tailTag || tailTag === marker) ? tail.nextSibling : marker || null,
96
+ after = isLive(tail) ? tail.nextSibling : marker || null,
90
97
  map = null,
91
98
  anchor,
92
99
  anchorTag;
93
- const isLive = n => {
94
- if (!n) return false;
95
- const tag = n[$$SLOT];
96
- return n.parentNode === parentNode && (!tag || tag === marker);
97
- };
98
100
  while (aStart < aEnd || bStart < bEnd) {
99
- if (a[aStart] === b[bStart] && isLive(a[aStart])) {
101
+ if (a[aStart] === b[bStart]) {
100
102
  aStart++;
101
103
  bStart++;
102
104
  continue;
103
105
  }
104
- while (a[aEnd - 1] === b[bEnd - 1] && isLive(a[aEnd - 1])) {
106
+ while (aEnd > aStart && bEnd > bStart && a[aEnd - 1] === b[bEnd - 1]) {
105
107
  aEnd--;
106
108
  bEnd--;
107
109
  }
108
110
  if (aEnd === aStart) {
109
111
  let node;
110
112
  if (bEnd < bLength) {
111
- if (bStart) {
112
- const prev = b[bStart - 1];
113
- const prevTag = prev[$$SLOT];
114
- node = prev.parentNode === parentNode && (!prevTag || prevTag === marker) ? prev.nextSibling : after;
115
- } else node = b[bEnd - bStart];
113
+ if (bStart && isLive(node = b[bStart - 1])) node = node.nextSibling;else {
114
+ let k = bEnd;
115
+ while (k < bLength && !isLive(b[k])) k++;
116
+ node = k < bLength ? b[k] : after;
117
+ }
116
118
  } else node = after;
117
119
  while (bStart < bEnd) {
118
120
  const n = b[bStart++];
@@ -122,10 +124,7 @@ function reconcileArrays(parentNode, a, b, marker) {
122
124
  } else if (bEnd === bStart) {
123
125
  while (aStart < aEnd) {
124
126
  const n = a[aStart++];
125
- if (!map || !map.has(n)) {
126
- const tag = n[$$SLOT];
127
- if (n.parentNode === parentNode && (!tag || tag === marker)) n.remove();
128
- }
127
+ if ((!map || !map.has(n)) && isLive(n)) n.remove();
129
128
  }
130
129
  } else if ((anchor = a[aStart]) === b[bEnd - 1] && b[bStart] === a[aEnd - 1] && anchor.parentNode === parentNode && (!(anchorTag = anchor[$$SLOT]) || anchorTag === marker)) {
131
130
  if (marker) {
@@ -144,6 +143,10 @@ function reconcileArrays(parentNode, a, b, marker) {
144
143
  } while (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]);
145
144
  }
146
145
  } else {
146
+ if (!isLive(a[aStart])) {
147
+ aStart++;
148
+ continue;
149
+ }
147
150
  if (!map) {
148
151
  map = new Map();
149
152
  let i = bStart;
@@ -160,31 +163,19 @@ function reconcileArrays(parentNode, a, b, marker) {
160
163
  sequence++;
161
164
  }
162
165
  if (sequence > index - bStart) {
163
- const head = a[aStart];
164
- const headTag = head[$$SLOT];
165
- const node = head.parentNode === parentNode && (!headTag || headTag === marker) ? head : after;
166
+ const node = a[aStart];
166
167
  while (bStart < index) {
167
168
  const n = b[bStart++];
168
169
  parentNode.insertBefore(n, node);
169
170
  if (marker) n[$$SLOT] = marker;
170
171
  }
171
172
  } else {
172
- const oldNode = a[aStart++];
173
173
  const newNode = b[bStart++];
174
- const oldTag = oldNode[$$SLOT];
175
- if (oldNode.parentNode === parentNode && (!oldTag || oldTag === marker)) {
176
- parentNode.replaceChild(newNode, oldNode);
177
- } else {
178
- parentNode.insertBefore(newNode, after);
179
- }
174
+ parentNode.replaceChild(newNode, a[aStart++]);
180
175
  if (marker) newNode[$$SLOT] = marker;
181
176
  }
182
177
  } else aStart++;
183
- } else {
184
- const n = a[aStart++];
185
- const nTag = n[$$SLOT];
186
- if (n.parentNode === parentNode && (!nTag || nTag === marker)) n.remove();
187
- }
178
+ } else a[aStart++].remove();
188
179
  }
189
180
  }
190
181
  }
@@ -232,6 +223,10 @@ function qualifierValue(name, value) {
232
223
  function asciiLowerCase(value) {
233
224
  return value.replace(/[A-Z]/g, c => String.fromCharCode(c.charCodeAt(0) + 32));
234
225
  }
226
+ const JSON_SCRIPT_TYPE = /^(?:importmap|speculationrules)$|^[\t\n\r ]*(?:application\/json|text\/json|[\w!#$%&'*+.^`|~-]+\/[\w!#$%&'*+.^`|~-]*\+json)[\t\n\r ]*(?:;|$)/i;
227
+ function headBodyText(tag, props, text) {
228
+ return tag === "script" && JSON_SCRIPT_TYPE.test(String(props.type)) ? text.replace(/</g, "\\u003C") : text;
229
+ }
235
230
  function resourceIdentity(tag, props) {
236
231
  const url = String(props.href || props.src || "");
237
232
  let id = "res:" + tag + ":" + (props.rel || "") + ":" + url.length + ":" + url;
@@ -402,6 +397,13 @@ function takeHydrationValue(key) {
402
397
  value: v
403
398
  };
404
399
  }
400
+ function setLinkClaim(_handler) {
401
+ return false;
402
+ }
403
+ function hasServerLinkState() {
404
+ const registry = globalThis._$HY && globalThis._$HY.r;
405
+ return !!registry && registry.links === 1;
406
+ }
405
407
  const getTraceContext = voidFn;
406
408
  function render(code, element, init, options = {}) {
407
409
  let disposer;
@@ -534,17 +536,31 @@ function findOwner(target, state) {
534
536
  function setProperty(node, name, value) {
535
537
  if (isHydrating(node)) return;
536
538
  const nodeName = node.nodeName;
537
- 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;
539
+ if (name === "value" && nodeName === "SELECT") writeSelectValue(node, value);else if ((name === "value" || name === "defaultValue") && (nodeName === "INPUT" || nodeName === "TEXTAREA")) {
540
+ if (value == null && /^(checkbox|radio)$/.test(node.type)) node.removeAttribute("value");else node[name] = value ?? "";
541
+ } else node[name] = value;
542
+ reclaimAttribute(node, name);
538
543
  }
539
544
  let claimHandlers = null;
545
+ const claimAttributeSets = [];
540
546
  const CLAIM_SEAM = Symbol.for("solid.element-claims");
541
- function registerElementClaim(handler) {
547
+ function registerElementClaim(handler, options) {
542
548
  (claimHandlers || (claimHandlers = globalThis[CLAIM_SEAM] = [])).push(handler);
549
+ claimAttributeSets.push(options?.attributes || ["href", "action"]);
543
550
  return () => {
544
551
  const index = claimHandlers.indexOf(handler);
545
- index > -1 && claimHandlers.splice(index, 1);
552
+ if (index > -1) {
553
+ claimHandlers.splice(index, 1);
554
+ claimAttributeSets.splice(index, 1);
555
+ }
546
556
  };
547
557
  }
558
+ function runClaimHandlers(handlers, node) {
559
+ for (let i = 0; i < handlers.length; i++) handlers[i](node);
560
+ }
561
+ function reclaimAttribute(node, name) {
562
+ if (claimHandlers !== null && node._$claimed && claimAttributeSets.some(set => set.includes(name.slice(name.indexOf(":") + 1)))) runClaimHandlers(claimHandlers, node);
563
+ }
548
564
  const CLAIMED_ELEMENTS = "a[href], form[action]";
549
565
  function claimElementTree(root) {
550
566
  const handlers = globalThis[CLAIM_SEAM];
@@ -552,17 +568,20 @@ function claimElementTree(root) {
552
568
  const isElement = root.nodeType === 1;
553
569
  if (!isElement && root.nodeType !== 11) return root;
554
570
  if (isElement && root.matches(CLAIMED_ELEMENTS)) {
555
- for (let i = 0; i < handlers.length; i++) handlers[i](root);
571
+ root._$claimed = true;
572
+ runClaimHandlers(handlers, root);
556
573
  }
557
574
  const found = root.querySelectorAll(CLAIMED_ELEMENTS);
558
575
  for (let i = 0; i < found.length; i++) {
559
- for (let j = 0; j < handlers.length; j++) handlers[j](found[i]);
576
+ found[i]._$claimed = true;
577
+ runClaimHandlers(handlers, found[i]);
560
578
  }
561
579
  return root;
562
580
  }
563
- function claimElement(node) {
564
- if (claimHandlers !== null) {
565
- for (let i = 0; i < claimHandlers.length; i++) claimHandlers[i](node);
581
+ function claimElement(node, owner) {
582
+ if (claimHandlers !== null && !node._$claimed) {
583
+ node._$claimed = true;
584
+ if (owner === undefined) runClaimHandlers(claimHandlers, node);else runWithOwner(owner, () => runClaimHandlers(claimHandlers, node));
566
585
  }
567
586
  return node;
568
587
  }
@@ -579,11 +598,12 @@ function setAttribute(node, name, value) {
579
598
  }
580
599
  }
581
600
  if (selectMultiple) node._$multiple = true;
582
- if (claimHandlers !== null && (name === "href" || name === "action")) claimElement(node);
601
+ reclaimAttribute(node, name);
583
602
  }
584
603
  function setAttributeNS(node, namespace, name, value) {
585
604
  if (isHydrating(node)) return;
586
605
  if (value == null || value === false) node.removeAttributeNS(namespace, name.indexOf(":") > -1 ? name.split(":").pop() : name);else node.setAttributeNS(namespace, name, value === true ? "" : value);
606
+ reclaimAttribute(node, name);
587
607
  }
588
608
  function className(node, value, prev) {
589
609
  if (typeof value === "number") value = "" + value;
@@ -696,7 +716,7 @@ function readShallow(value) {
696
716
  if (value === null || typeof value !== "object") return value;
697
717
  if (Array.isArray(value)) return value.map(readShallow);
698
718
  if (value[$PROXY] !== value) return value;
699
- const keys = sourceKeys(value, SOURCE_PROXY);
719
+ const keys = Reflect.ownKeys(value);
700
720
  const out = {};
701
721
  for (let i = 0; i < keys.length; i++) {
702
722
  const k = keys[i];
@@ -708,21 +728,24 @@ function setStyleProperty(node, name, value) {
708
728
  if (isHydrating(node)) return;
709
729
  value != null ? node.style.setProperty(name, value) : node.style.removeProperty(name);
710
730
  }
711
- function spread(node, props, skipChildren, skip, name) {
731
+ function spread(node, props, skipChildren, skip, name, loc) {
712
732
  if (name !== undefined) {
713
733
  const outer = spreadName;
714
- setSpreadName(name);
734
+ const outerLoc = spreadLoc;
735
+ setSpreadName(name, loc);
715
736
  try {
716
737
  return spread(node, props, skipChildren, skip);
717
738
  } finally {
718
- setSpreadName(outer);
739
+ setSpreadName(outer, outerLoc);
719
740
  }
720
741
  }
721
742
  const prevProps = {};
743
+ const owner = claimHandlers !== null && (node.localName === "a" || node.localName === "form") ? getOwner() : undefined;
722
744
  const apply = newProps => {
723
745
  const r = newProps.ref;
724
746
  if (r !== prevProps.ref && (typeof r === "function" || Array.isArray(r))) ref(() => r, node);
725
747
  assign(node, newProps, true, prevProps, true);
748
+ if (owner !== undefined) claimElement(node, owner);
726
749
  };
727
750
  if (Array.isArray(props)) {
728
751
  effect(() => collectSources({}, props, undefined, skip), apply);
@@ -842,6 +865,7 @@ const SCOPE_OPTIONS = {
842
865
  scope: true
843
866
  };
844
867
  let hydrationRt = null;
868
+ let selectInsert = null;
845
869
  function installHydrationRuntime() {
846
870
  hydrationRt = {
847
871
  claimInitial(parent, multi, initial) {
@@ -916,7 +940,8 @@ function isPlaceholderScaffolding(node, t) {
916
940
  function insert(parent, accessor, marker, initial, options) {
917
941
  if (spreadName !== undefined && (options === undefined || options.name === undefined)) options = {
918
942
  ...options,
919
- name: spreadName + ".children"
943
+ name: spreadName + ".children",
944
+ loc: spreadLoc
920
945
  };
921
946
  const multi = marker !== undefined;
922
947
  const host = options && options.host;
@@ -936,11 +961,14 @@ function insert(parent, accessor, marker, initial, options) {
936
961
  initial = [placeholder];
937
962
  }
938
963
  let current = initial;
939
- effect(prev => {
964
+ let ran = false;
965
+ effect(() => {
940
966
  if (hydrationRt !== null) current = hydrationRt.reclaimRegion(current, parent, marker);
941
967
  const value = normalize(accessor(), current, multi, true);
968
+ const again = ran;
969
+ ran = true;
942
970
  if (typeof value !== "function") return value;
943
- const innerOptions = prev !== undefined && !(options && options.schedule) ? {
971
+ const innerOptions = again && !(options && options.schedule) ? {
944
972
  ...options,
945
973
  schedule: true
946
974
  } : options;
@@ -1264,7 +1292,7 @@ function createHeadElement(tag, props) {
1264
1292
  if (v == null || v === false) continue;
1265
1293
  el.setAttribute(name, v === true ? "" : String(v));
1266
1294
  }
1267
- if (props.children != null) el.textContent = String(props.children);
1295
+ if (props.children != null) el.textContent = headBodyText(tag, props, String(props.children));
1268
1296
  return el;
1269
1297
  }
1270
1298
  function renderHeadElement(t, identity, existing) {
@@ -1287,7 +1315,7 @@ function headElementMatches(el, t) {
1287
1315
  } else if (el.getAttribute(name) !== (v === true ? "" : String(v))) return false;
1288
1316
  }
1289
1317
  const children = t.props.children;
1290
- return (children == null ? "" : String(children)) === el.textContent;
1318
+ return (children == null ? "" : headBodyText(t.tag, t.props, String(children))) === el.textContent;
1291
1319
  }
1292
1320
  function mountHeadResource(tag, props) {
1293
1321
  const identity = resourceIdentity(tag, props);
@@ -1403,7 +1431,22 @@ function loadModuleAssets(mapping) {
1403
1431
  function hydrate(code, element, options = {}) {
1404
1432
  enableHydration();
1405
1433
  installHydrationRuntime();
1406
- if (globalThis._$HY.done) return render(code, element, [...element.childNodes], options);
1434
+ const hy = globalThis._$HY;
1435
+ const id = options.renderId || "";
1436
+ if (hy.s && !hy.s[id] && !hy.s[""] && !hy.done && document.readyState === "loading") {
1437
+ let started, disposer;
1438
+ const start = () => started || (started = true, disposer = hydrate(code, element, options));
1439
+ (hy.sp || (hy.sp = [])).push([id, start]);
1440
+ hy.sw = key => hy.sp.forEach(([k, f]) => (!key || k === key) && queueMicrotask(f));
1441
+ document.addEventListener("DOMContentLoaded", start, {
1442
+ once: true
1443
+ });
1444
+ return () => {
1445
+ started = true;
1446
+ disposer && disposer();
1447
+ };
1448
+ }
1449
+ if (hy.done) return render(code, element, [...element.childNodes], options);
1407
1450
  const head = (element.nodeType === 9 ? element : element.ownerDocument).head;
1408
1451
  if (head && element.contains(head)) {
1409
1452
  let n = head.firstChild;
@@ -1582,13 +1625,32 @@ function isHydrating(node) {
1582
1625
  if (!sharedConfig.hydrating) return false;
1583
1626
  if (sharedConfig.isClaiming && !sharedConfig.isClaiming()) return false;
1584
1627
  if (!node || node.isConnected) return true;
1585
- const roots = sharedConfig.claimRoots;
1586
- if (roots) {
1587
- for (let i = 0; i < roots.length; i++) {
1588
- if (roots[i].contains(node)) return true;
1628
+ return serverComponentClaims !== null && serverComponentClaims.claimed(node);
1629
+ }
1630
+ let serverComponentClaims = null;
1631
+ function installServerComponentHydration() {
1632
+ enableServerComponentHydration();
1633
+ if (serverComponentClaims !== null) return;
1634
+ serverComponentClaims = {
1635
+ claimed(node) {
1636
+ const roots = sharedConfig.claimRoots;
1637
+ if (roots) {
1638
+ for (let i = 0; i < roots.length; i++) {
1639
+ if (roots[i].contains(node)) return true;
1640
+ }
1641
+ }
1642
+ return false;
1643
+ },
1644
+ inFrame(element) {
1645
+ const frames = element.querySelectorAll("[data-fid]");
1646
+ const frameCount = frames.length;
1647
+ if (frameCount === 0) return undefined;
1648
+ return node => {
1649
+ for (let j = 0; j < frameCount; j++) if (frames[j].contains(node)) return true;
1650
+ return false;
1651
+ };
1589
1652
  }
1590
- }
1591
- return false;
1653
+ };
1592
1654
  }
1593
1655
  function classListToObject(classList) {
1594
1656
  if (Array.isArray(classList)) {
@@ -1640,8 +1702,10 @@ function assignProp(node, prop, value, prev, skipRef, nodeName) {
1640
1702
  }
1641
1703
  } else if (hasNamespace && prop.slice(0, 5) === "prop:" || ChildProperties.has(prop) || DOMWithState[nodeName]?.[prop]) {
1642
1704
  if (hasNamespace) prop = prop.slice(5);else if (isHydrating(node)) return value;
1643
- if (prop === "value" && nodeName === "SELECT") queueMicrotask(() => node.value = value) || (node.value = value);else if ((prop === "value" || prop === "defaultValue") && (nodeName === "INPUT" || nodeName === "TEXTAREA"))
1644
- node[prop] = value ?? "";else node[prop] = value;
1705
+ if (prop === "value" && nodeName === "SELECT") writeSelectValue(node, value);else if ((prop === "value" || prop === "defaultValue") && (nodeName === "INPUT" || nodeName === "TEXTAREA")) {
1706
+ if (value == null && /^(checkbox|radio)$/.test(node.type)) node.removeAttribute("value");else node[prop] = value ?? "";
1707
+ } else node[prop] = value;
1708
+ reclaimAttribute(node, prop);
1645
1709
  } else {
1646
1710
  const ns = hasNamespace && Namespaces[prop.split(":")[0]];
1647
1711
  if (ns) setAttributeNS(node, ns, prop, value);else setAttribute(node, prop, value);
@@ -1656,14 +1720,13 @@ function eventHandler(e, container, state) {
1656
1720
  if (prev === true || prev === container || !container.contains(prev)) return;
1657
1721
  resumeNode = prev;
1658
1722
  }
1659
- const owner = state && (state.owners.size === 1 && state.owners.has(container) ? container : findOwner(e.target, state)?.owner);
1660
- if (state && !owner) return;
1661
- if (owner && owner === resumeNode) return;
1662
- e[$$EVENT_OWNER] = owner || true;
1723
+ const owner = state.owners.size === 1 && state.owners.has(container) ? container : findOwner(e.target, state)?.owner;
1724
+ if (!owner) return;
1725
+ if (owner === resumeNode) return;
1726
+ e[$$EVENT_OWNER] = owner;
1663
1727
  let node = resumeNode || e.target;
1664
1728
  const key = EVENT_KEY + e.type;
1665
1729
  const oriTarget = e.target;
1666
- const boundary = owner || container || e.currentTarget;
1667
1730
  const retarget = value => Object.defineProperty(e, "target", {
1668
1731
  configurable: true,
1669
1732
  value
@@ -1680,19 +1743,19 @@ function eventHandler(e, container, state) {
1680
1743
  };
1681
1744
  const walkUpTree = () => {
1682
1745
  while (node && handleNode()) {
1683
- if (node === boundary || node.parentNode === boundary) break;
1746
+ if (node === owner || node.parentNode === owner) break;
1684
1747
  node = node._$host || node.parentNode || node.host;
1685
1748
  }
1686
1749
  };
1687
1750
  Object.defineProperty(e, "currentTarget", {
1688
1751
  configurable: true,
1689
1752
  get() {
1690
- return node || boundary || document;
1753
+ return node || owner;
1691
1754
  }
1692
1755
  });
1693
1756
  if (resumeNode) {
1694
1757
  if (resumeNode === e.target) node = resumeNode._$host || resumeNode.parentNode || resumeNode.host;
1695
- if (node && node !== boundary) walkUpTree();
1758
+ if (node && node !== owner) walkUpTree();
1696
1759
  } else if (e.composedPath) {
1697
1760
  const path = e.composedPath();
1698
1761
  if (path.length) {
@@ -1705,7 +1768,7 @@ function eventHandler(e, container, state) {
1705
1768
  walkUpTree();
1706
1769
  break;
1707
1770
  }
1708
- if (node === boundary || node.parentNode === boundary) {
1771
+ if (node === owner || node.parentNode === owner) {
1709
1772
  break;
1710
1773
  }
1711
1774
  }
@@ -1729,7 +1792,10 @@ function insertExpression(parent, value, current, marker) {
1729
1792
  return value;
1730
1793
  }
1731
1794
  if (value === current) return value;
1732
- if (hydrationRt !== null && sharedConfig.hydrating && current == null && value && [].concat(value).every(n => n?.parentNode === parent) && value.length !== 0) return value;
1795
+ if (hydrationRt !== null && sharedConfig.hydrating && value && value.length !== 0) {
1796
+ const tracked = [].concat(current ?? []);
1797
+ if ([].concat(value).every(n => (n === tracked[0] && tracked.shift(), n?.parentNode === parent)) && !tracked.length) return value;
1798
+ }
1733
1799
  const t = typeof value,
1734
1800
  multi = marker !== undefined;
1735
1801
  if (t === "string" || t === "number") {
@@ -1779,8 +1845,34 @@ function insertExpression(parent, value, current, marker) {
1779
1845
  appendNodes(parent, value);
1780
1846
  }
1781
1847
  } else ;
1848
+ selectInsert && selectInsert(parent);
1782
1849
  return value;
1783
1850
  }
1851
+ function selectChange(e) {
1852
+ (e = e.currentTarget || e)._$v = null;
1853
+ e.removeEventListener("change", selectChange, true);
1854
+ }
1855
+ function writeSelectValue(node, value) {
1856
+ const had = node._$v && node._$v.map,
1857
+ has = value != null && value.map;
1858
+ if (has) had || node.addEventListener("change", selectChange, true);else had && node.removeEventListener("change", selectChange, true);
1859
+ if (value == null) {
1860
+ node._$v = null;
1861
+ return queueMicrotask(() => node.value = value) || (node.value = value);
1862
+ }
1863
+ node._$v = value;
1864
+ (selectInsert ||= p => {
1865
+ p && p._$v == null && (p = p.parentNode);
1866
+ const v = p && p._$v;
1867
+ if (v == null) return;
1868
+ if (v.map) {
1869
+ const o = [...p.options];
1870
+ for (let i = 0; i < o.length; i++) o[i].selected = v.some(x => x == o[i].value);
1871
+ v.every(x => o.some(el => el.value == x)) && selectChange(p);
1872
+ } else p.value = v, p.selectedIndex > -1 && p.value == v && (p._$v = null);
1873
+ })(node);
1874
+ queueMicrotask(() => selectInsert(node));
1875
+ }
1784
1876
  function normalize(value, current, multi, doNotUnwrap) {
1785
1877
  value = flatten(value, {
1786
1878
  skipNonRendered: true,
@@ -1788,7 +1880,7 @@ function normalize(value, current, multi, doNotUnwrap) {
1788
1880
  });
1789
1881
  if (doNotUnwrap && typeof value === "function") return value;
1790
1882
  if (multi && !Array.isArray(value)) value = [value != null ? value : ""];
1791
- if (sharedConfig.hydrating && Array.isArray(value)) {
1883
+ if (hydrationRt !== null && sharedConfig.hydrating && Array.isArray(value)) {
1792
1884
  for (let i = 0, len = value.length; i < len; i++) {
1793
1885
  const item = value[i],
1794
1886
  prev = current && current[i],
@@ -1859,22 +1951,12 @@ function cleanChildren(parent, current, marker, replacement) {
1859
1951
  }
1860
1952
  function gatherHydratable(element, root) {
1861
1953
  const templates = element.querySelectorAll(root ? `[_hk^="${root.replace(/["\\]/g, "\\$&")}"]` : `*[_hk]`);
1862
- const frames = root ? null : element.querySelectorAll("[data-fid]");
1863
- const frameCount = frames ? frames.length : 0;
1954
+ const inFrame = root || serverComponentClaims === null ? undefined : serverComponentClaims.inFrame(element);
1864
1955
  const registry = sharedConfig.registry;
1865
1956
  for (let i = 0; i < templates.length; i++) {
1866
1957
  const node = templates[i];
1958
+ if (inFrame !== undefined && inFrame(node)) continue;
1867
1959
  const key = node.getAttribute("_hk");
1868
- if (frameCount !== 0) {
1869
- let inFrame = false;
1870
- for (let j = 0; j < frameCount; j++) {
1871
- if (frames[j].contains(node)) {
1872
- inFrame = true;
1873
- break;
1874
- }
1875
- }
1876
- if (inFrame) continue;
1877
- }
1878
1960
  if (!registry.has(key)) registry.set(key, node);
1879
1961
  }
1880
1962
  }
@@ -1916,6 +1998,7 @@ function composeMiddleware(middlewares) {
1916
1998
  function ssr(template, ...nodes) {}
1917
1999
  function ssrElement(name, props, children, needsId, skip, attrs) {}
1918
2000
  function ssrElementAttribute(key, value) {}
2001
+ function ssrLinkClaim(attrs) {}
1919
2002
  function ssrClassName(value) {}
1920
2003
  function ssrStyle(value) {}
1921
2004
  function ssrStyleProperty(name, value) {}
@@ -1927,17 +2010,24 @@ function resolveSSRNode(node, result, top, nested) {}
1927
2010
  function escape(s, attr) {}
1928
2011
 
1929
2012
  const ENVELOPE = Symbol.for("solid.ResponseEnvelope");
1930
- // PURE-annotated factory (same convention as solid's MockPromise): the brand
1931
- const ResponseEnvelope = /* @__PURE__ */(() => {
1932
- class ResponseEnvelope {
1933
- constructor(response, value) {
1934
- this.response = response;
1935
- this.value = value;
1936
- }
2013
+ let EnvelopeClass;
2014
+ const ResponseEnvelope = function ResponseEnvelope(response, value) {
2015
+ if (!EnvelopeClass) {
2016
+ EnvelopeClass = class extends Response {
2017
+ constructor(response, value) {
2018
+ super(response ? response.body : null, response && {
2019
+ status: response.status,
2020
+ statusText: response.statusText,
2021
+ headers: copyHeaders(response.headers)
2022
+ });
2023
+ this.response = response ? this : undefined;
2024
+ this.value = value;
2025
+ }
2026
+ };
2027
+ EnvelopeClass.prototype[ENVELOPE] = true;
1937
2028
  }
1938
- ResponseEnvelope.prototype[ENVELOPE] = true;
1939
- return ResponseEnvelope;
1940
- })();
2029
+ return new EnvelopeClass(response, value);
2030
+ };
1941
2031
  function isResponseEnvelope(value) {
1942
2032
  return !!(value && typeof value === "object" && value[ENVELOPE]);
1943
2033
  }
@@ -1962,6 +2052,16 @@ function isSafeError(value) {
1962
2052
  const REVALIDATE_HEADER = "X-Revalidate";
1963
2053
  const REVALIDATE_ALL = "*";
1964
2054
  const RESPONSE_HEADER_VALUE_LIMIT = 4096;
2055
+ function copyHeaders(init) {
2056
+ const source = init;
2057
+ if (!source || !source.getSetCookie) return new Headers(init);
2058
+ const headers = new Headers();
2059
+ source.forEach((value, key) => {
2060
+ if (key !== "set-cookie") headers.append(key, value);
2061
+ });
2062
+ for (const cookie of source.getSetCookie()) headers.append("Set-Cookie", cookie);
2063
+ return headers;
2064
+ }
1965
2065
  function initWithRevalidate(init = {}) {
1966
2066
  const resolved = typeof init === "number" ? {
1967
2067
  status: init
@@ -1970,18 +2070,7 @@ function initWithRevalidate(init = {}) {
1970
2070
  revalidate,
1971
2071
  ...responseInit
1972
2072
  } = resolved;
1973
- let headers;
1974
- if (responseInit.headers && responseInit.headers.getSetCookie) {
1975
- headers = new Headers();
1976
- responseInit.headers.forEach((value, key) => {
1977
- if (key !== "set-cookie") headers.append(key, value);
1978
- });
1979
- for (const cookie of responseInit.headers.getSetCookie()) {
1980
- headers.append("Set-Cookie", cookie);
1981
- }
1982
- } else {
1983
- headers = new Headers(responseInit.headers);
1984
- }
2073
+ const headers = copyHeaders(responseInit.headers);
1985
2074
  if (revalidate !== undefined) {
1986
2075
  const list = Array.isArray(revalidate) ? revalidate : [revalidate];
1987
2076
  if (list.length > 1 && list.includes(REVALIDATE_ALL)) {
@@ -2045,7 +2134,12 @@ function respond(value, init = {}) {
2045
2134
  }), value);
2046
2135
  }
2047
2136
  headers.set("Content-Type", "application/json");
2048
- return new ResponseEnvelope(new Response(JSON.stringify(value), {
2137
+ return new ResponseEnvelope(new Response(new ReadableStream({
2138
+ pull(controller) {
2139
+ controller.enqueue(new TextEncoder().encode(JSON.stringify(value)));
2140
+ controller.close();
2141
+ }
2142
+ }), {
2049
2143
  ...responseInit,
2050
2144
  headers
2051
2145
  }), value);
@@ -2105,110 +2199,9 @@ function portalImpl(props) {
2105
2199
  });
2106
2200
  return treeMarker;
2107
2201
  }
2108
- const COMPONENT_BINDING = Symbol.for("solid.component-binding");
2109
- const FLIGHT = Symbol("solid.dynamic-flight");
2110
- function bindingOf(value) {
2111
- return value !== null && (typeof value === "function" || typeof value === "object") && value[COMPONENT_BINDING] || undefined;
2112
- }
2113
2202
  function dynamic(source, options) {
2114
2203
  return dynamicCore(source, options, staticElement);
2115
2204
  }
2116
- function dynamicComponent(source, options) {
2117
- return dynamicCore(source, options);
2118
- }
2119
- function dynamicCore(source, options, tagArm) {
2120
- if (options?.static) return staticDynamic(untrack(source), tagArm);
2121
- const sites = new Set();
2122
- let deliveredAddress;
2123
- const resolveBinding = (next, prev) => {
2124
- const binding = bindingOf(next);
2125
- if (!binding) return next;
2126
- deliveredAddress = binding.address;
2127
- const prevBinding = bindingOf(prev);
2128
- if (prevBinding && prevBinding.component === binding.component) {
2129
- for (const deliver of sites) deliver(binding.address);
2130
- return prev;
2131
- }
2132
- return next;
2133
- };
2134
- const sameInstance = (prev, next) => {
2135
- if (prev === next) return true;
2136
- const held = bindingOf(prev);
2137
- const incoming = bindingOf(next);
2138
- if (!held || !incoming || held.component !== incoming.component) return false;
2139
- if (held.address === incoming.address) return true;
2140
- if (deliveredAddress === undefined) return false;
2141
- if (incoming.address !== deliveredAddress) {
2142
- deliveredAddress = incoming.address;
2143
- for (const deliver of sites) deliver(incoming.address);
2144
- }
2145
- return true;
2146
- };
2147
- const cached = createMemo(prev => {
2148
- const next = source();
2149
- if (!next || typeof next.then !== "function") return resolveBinding(next, prev);
2150
- return {
2151
- [FLIGHT]: next
2152
- };
2153
- }, {
2154
- lazy: true,
2155
- equals: sameInstance
2156
- });
2157
- return props => {
2158
- if (sharedConfig.hydrating) {
2159
- try {
2160
- untrack(cached);
2161
- } catch {}
2162
- }
2163
- let latest = 0;
2164
- const value = createMemo(prev => {
2165
- const c = cached();
2166
- if (!c || !c[FLIGHT]) return resolveBinding(c, prev);
2167
- const next = c[FLIGHT];
2168
- const token = ++latest;
2169
- return {
2170
- then: (onFulfilled, onRejected) => next.then(resolved => {
2171
- const landed = token === latest ? resolveBinding(resolved, prev) : resolved;
2172
- return onFulfilled ? onFulfilled(landed) : landed;
2173
- }, onRejected)
2174
- };
2175
- }, {
2176
- equals: sameInstance
2177
- });
2178
- return createMemo(() => {
2179
- const component = value();
2180
- switch (typeof component) {
2181
- case "function":
2182
- {
2183
- const binding = bindingOf(component);
2184
- if (binding) {
2185
- const [address, setAddress] = createSignal(deliveredAddress ??= binding.address, {
2186
- ownedWrite: true
2187
- });
2188
- sites.add(setAddress);
2189
- onCleanup(() => sites.delete(setAddress));
2190
- return untrack(() => binding.component(props, address));
2191
- }
2192
- return untrack(() => component(props));
2193
- }
2194
- case "string":
2195
- return tagArm ? tagArm(component, props) : undefined;
2196
- }
2197
- });
2198
- };
2199
- }
2200
- function staticDynamic(component, tagArm) {
2201
- if (typeof component === "function") {
2202
- const binding = bindingOf(component);
2203
- if (binding) {
2204
- const address = () => binding.address;
2205
- return props => untrack(() => binding.component(props, address));
2206
- }
2207
- return props => untrack(() => component(props));
2208
- }
2209
- if (typeof component === "string" && tagArm) return props => tagArm(component, props);
2210
- return () => undefined;
2211
- }
2212
2205
  function staticElement(tag, props) {
2213
2206
  const hydrating = sharedConfig.hydrating;
2214
2207
  const el = hydrating ? getNextElement() : createElement(tag, untrack(() => props.is), untrack(() => props.xmlns));
@@ -2255,4 +2248,4 @@ _moduleUrl) {
2255
2248
  function httpStatus(_code, _text) {}
2256
2249
  function httpHeader(_name, _value, _options) {}
2257
2250
 
2258
- export { ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, HREF, HydrationScript, MathMLElements, NULL_BODY_STATUSES, Namespaces, Portal, RESPONSE_HEADER_VALUE_LIMIT, REVALIDATE_ALL, REVALIDATE_HEADER, RawTextElements, RequestContext, ResponseEnvelope, SAFE_ERROR, SVGElements, VoidElements, acquireAsset, addEvent, applyRef, assign, claimElement, claimElementTree, className, clearFlashCookie, clientOnly, commitEventResponse, composeMiddleware, configureServerErrors, createRequestEvent, createResponseStub, createSSRResponse, delegateEvents, dispatchAsInteraction, dynamic, dynamicComponent, dynamicProperty, effect, escape, generateHydrationScript, getDelegatedRoot, getExpectedRedirectStatus, getFirstChild, getHydrationKey, getHydrationWriter, getNextElement, getNextMarker, getNextMatch, getNextSibling, getRequestEvent, getServerFunctionMetadata, getServerFunctionRPC, getTraceContext, 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, reportRequestFailure, resolveSSRNode, respond, runHydrationEvents, scope, serializeCookie, setAttribute, setAttributeNS, setProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassName, ssrElement, ssrElementAttribute, ssrGroup, ssrHydrationKey, ssrStyle, ssrStyleProperties, ssrStyleProperty, style, takeHydrationValue, template, unregisterDelegatedContainer, unregisterDelegatedRoot, useHead, waitAsset, warmAsset };
2251
+ export { ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, HREF, HydrationScript, MathMLElements, NULL_BODY_STATUSES, Namespaces, Portal, RESPONSE_HEADER_VALUE_LIMIT, REVALIDATE_ALL, REVALIDATE_HEADER, RawTextElements, RequestContext, ResponseEnvelope, SAFE_ERROR, SVGElements, VoidElements, acquireAsset, addEvent, applyRef, assign, claimElement, claimElementTree, className, clearFlashCookie, clientOnly, commitEventResponse, composeMiddleware, configureServerErrors, createRequestEvent, createResponseStub, createSSRResponse, delegateEvents, dispatchAsInteraction, dynamic, dynamicProperty, effect, escape, generateHydrationScript, getDelegatedRoot, getExpectedRedirectStatus, getFirstChild, getHydrationKey, getHydrationWriter, getNextElement, getNextMarker, getNextMatch, getNextSibling, getRequestEvent, getServerFunctionMetadata, getServerFunctionRPC, getTraceContext, hasFlashCookie, hasServerLinkState, httpHeader, httpStatus, hydrate, insert, installHydrationRuntime, installServerComponentHydration, isDev, isHref, isResponseEnvelope, isSafeError, isServer, isServerFunction, markSafeError, memo, parseCookieHeader, readShallow, redirect, ref, registerDelegatedContainer, registerDelegatedRoot, registerElementClaim, reload, render, renderToStream, renderToString, reportRequestFailure, resolveSSRNode, respond, runHydrationEvents, scope, serializeCookie, setAttribute, setAttributeNS, setLinkClaim, setProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassName, ssrElement, ssrElementAttribute, ssrGroup, ssrHydrationKey, ssrLinkClaim, ssrStyle, ssrStyleProperties, ssrStyleProperty, style, takeHydrationValue, template, unregisterDelegatedContainer, unregisterDelegatedRoot, useHead, waitAsset, warmAsset };