@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
package/dist/web.js CHANGED
@@ -1,6 +1,6 @@
1
- import { createRenderEffect, createMemo, 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, 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: {
@@ -71,40 +71,39 @@ function memo(fn) {
71
71
  }
72
72
 
73
73
  function reconcileArrays(parentNode, a, b, marker) {
74
+ const isLive = n => {
75
+ if (!n) return false;
76
+ const tag = n[$$SLOT];
77
+ return n.parentNode === parentNode && (!tag || tag === marker);
78
+ };
74
79
  let bLength = b.length,
75
80
  aEnd = a.length,
76
81
  bEnd = bLength,
77
82
  aStart = 0,
78
83
  bStart = 0,
79
84
  tail = a[aEnd - 1],
80
- tailTag = tail[$$SLOT],
81
- after = tail.parentNode === parentNode && (!tailTag || tailTag === marker) ? tail.nextSibling : marker || null,
85
+ after = isLive(tail) ? tail.nextSibling : marker || null,
82
86
  map = null,
83
87
  anchor,
84
88
  anchorTag;
85
- const isLive = n => {
86
- if (!n) return false;
87
- const tag = n[$$SLOT];
88
- return n.parentNode === parentNode && (!tag || tag === marker);
89
- };
90
89
  while (aStart < aEnd || bStart < bEnd) {
91
- if (a[aStart] === b[bStart] && isLive(a[aStart])) {
90
+ if (a[aStart] === b[bStart]) {
92
91
  aStart++;
93
92
  bStart++;
94
93
  continue;
95
94
  }
96
- while (a[aEnd - 1] === b[bEnd - 1] && isLive(a[aEnd - 1])) {
95
+ while (aEnd > aStart && bEnd > bStart && a[aEnd - 1] === b[bEnd - 1]) {
97
96
  aEnd--;
98
97
  bEnd--;
99
98
  }
100
99
  if (aEnd === aStart) {
101
100
  let node;
102
101
  if (bEnd < bLength) {
103
- if (bStart) {
104
- const prev = b[bStart - 1];
105
- const prevTag = prev[$$SLOT];
106
- node = prev.parentNode === parentNode && (!prevTag || prevTag === marker) ? prev.nextSibling : after;
107
- } else node = b[bEnd - bStart];
102
+ if (bStart && isLive(node = b[bStart - 1])) node = node.nextSibling;else {
103
+ let k = bEnd;
104
+ while (k < bLength && !isLive(b[k])) k++;
105
+ node = k < bLength ? b[k] : after;
106
+ }
108
107
  } else node = after;
109
108
  while (bStart < bEnd) {
110
109
  const n = b[bStart++];
@@ -114,10 +113,7 @@ function reconcileArrays(parentNode, a, b, marker) {
114
113
  } else if (bEnd === bStart) {
115
114
  while (aStart < aEnd) {
116
115
  const n = a[aStart++];
117
- if (!map || !map.has(n)) {
118
- const tag = n[$$SLOT];
119
- if (n.parentNode === parentNode && (!tag || tag === marker)) n.remove();
120
- }
116
+ if ((!map || !map.has(n)) && isLive(n)) n.remove();
121
117
  }
122
118
  } else if ((anchor = a[aStart]) === b[bEnd - 1] && b[bStart] === a[aEnd - 1] && anchor.parentNode === parentNode && (!(anchorTag = anchor[$$SLOT]) || anchorTag === marker)) {
123
119
  if (marker) {
@@ -136,6 +132,10 @@ function reconcileArrays(parentNode, a, b, marker) {
136
132
  } while (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]);
137
133
  }
138
134
  } else {
135
+ if (!isLive(a[aStart])) {
136
+ aStart++;
137
+ continue;
138
+ }
139
139
  if (!map) {
140
140
  map = new Map();
141
141
  let i = bStart;
@@ -152,31 +152,19 @@ function reconcileArrays(parentNode, a, b, marker) {
152
152
  sequence++;
153
153
  }
154
154
  if (sequence > index - bStart) {
155
- const head = a[aStart];
156
- const headTag = head[$$SLOT];
157
- const node = head.parentNode === parentNode && (!headTag || headTag === marker) ? head : after;
155
+ const node = a[aStart];
158
156
  while (bStart < index) {
159
157
  const n = b[bStart++];
160
158
  parentNode.insertBefore(n, node);
161
159
  if (marker) n[$$SLOT] = marker;
162
160
  }
163
161
  } else {
164
- const oldNode = a[aStart++];
165
162
  const newNode = b[bStart++];
166
- const oldTag = oldNode[$$SLOT];
167
- if (oldNode.parentNode === parentNode && (!oldTag || oldTag === marker)) {
168
- parentNode.replaceChild(newNode, oldNode);
169
- } else {
170
- parentNode.insertBefore(newNode, after);
171
- }
163
+ parentNode.replaceChild(newNode, a[aStart++]);
172
164
  if (marker) newNode[$$SLOT] = marker;
173
165
  }
174
166
  } else aStart++;
175
- } else {
176
- const n = a[aStart++];
177
- const nTag = n[$$SLOT];
178
- if (n.parentNode === parentNode && (!nTag || nTag === marker)) n.remove();
179
- }
167
+ } else a[aStart++].remove();
180
168
  }
181
169
  }
182
170
  }
@@ -224,6 +212,10 @@ function qualifierValue(name, value) {
224
212
  function asciiLowerCase(value) {
225
213
  return value.replace(/[A-Z]/g, c => String.fromCharCode(c.charCodeAt(0) + 32));
226
214
  }
215
+ const JSON_SCRIPT_TYPE = /^(?:importmap|speculationrules)$|^[\t\n\r ]*(?:application\/json|text\/json|[\w!#$%&'*+.^`|~-]+\/[\w!#$%&'*+.^`|~-]*\+json)[\t\n\r ]*(?:;|$)/i;
216
+ function headBodyText(tag, props, text) {
217
+ return tag === "script" && JSON_SCRIPT_TYPE.test(String(props.type)) ? text.replace(/</g, "\\u003C") : text;
218
+ }
227
219
  function resourceIdentity(tag, props) {
228
220
  const url = String(props.href || props.src || "");
229
221
  let id = "res:" + tag + ":" + (props.rel || "") + ":" + url.length + ":" + url;
@@ -394,6 +386,13 @@ function takeHydrationValue(key) {
394
386
  value: v
395
387
  };
396
388
  }
389
+ function setLinkClaim(_handler) {
390
+ return false;
391
+ }
392
+ function hasServerLinkState() {
393
+ const registry = globalThis._$HY && globalThis._$HY.r;
394
+ return !!registry && registry.links === 1;
395
+ }
397
396
  const getTraceContext = voidFn;
398
397
  function render(code, element, init, options = {}) {
399
398
  let disposer;
@@ -506,17 +505,31 @@ function findOwner(target, state) {
506
505
  function setProperty(node, name, value) {
507
506
  if (isHydrating(node)) return;
508
507
  const nodeName = node.nodeName;
509
- 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;
508
+ if (name === "value" && nodeName === "SELECT") writeSelectValue(node, value);else if ((name === "value" || name === "defaultValue") && (nodeName === "INPUT" || nodeName === "TEXTAREA")) {
509
+ if (value == null && /^(checkbox|radio)$/.test(node.type)) node.removeAttribute("value");else node[name] = value ?? "";
510
+ } else node[name] = value;
511
+ reclaimAttribute(node, name);
510
512
  }
511
513
  let claimHandlers = null;
514
+ const claimAttributeSets = [];
512
515
  const CLAIM_SEAM = Symbol.for("solid.element-claims");
513
- function registerElementClaim(handler) {
516
+ function registerElementClaim(handler, options) {
514
517
  (claimHandlers || (claimHandlers = globalThis[CLAIM_SEAM] = [])).push(handler);
518
+ claimAttributeSets.push(options?.attributes || ["href", "action"]);
515
519
  return () => {
516
520
  const index = claimHandlers.indexOf(handler);
517
- index > -1 && claimHandlers.splice(index, 1);
521
+ if (index > -1) {
522
+ claimHandlers.splice(index, 1);
523
+ claimAttributeSets.splice(index, 1);
524
+ }
518
525
  };
519
526
  }
527
+ function runClaimHandlers(handlers, node) {
528
+ for (let i = 0; i < handlers.length; i++) handlers[i](node);
529
+ }
530
+ function reclaimAttribute(node, name) {
531
+ if (claimHandlers !== null && node._$claimed && claimAttributeSets.some(set => set.includes(name.slice(name.indexOf(":") + 1)))) runClaimHandlers(claimHandlers, node);
532
+ }
520
533
  const CLAIMED_ELEMENTS = "a[href], form[action]";
521
534
  function claimElementTree(root) {
522
535
  const handlers = globalThis[CLAIM_SEAM];
@@ -524,17 +537,20 @@ function claimElementTree(root) {
524
537
  const isElement = root.nodeType === 1;
525
538
  if (!isElement && root.nodeType !== 11) return root;
526
539
  if (isElement && root.matches(CLAIMED_ELEMENTS)) {
527
- for (let i = 0; i < handlers.length; i++) handlers[i](root);
540
+ root._$claimed = true;
541
+ runClaimHandlers(handlers, root);
528
542
  }
529
543
  const found = root.querySelectorAll(CLAIMED_ELEMENTS);
530
544
  for (let i = 0; i < found.length; i++) {
531
- for (let j = 0; j < handlers.length; j++) handlers[j](found[i]);
545
+ found[i]._$claimed = true;
546
+ runClaimHandlers(handlers, found[i]);
532
547
  }
533
548
  return root;
534
549
  }
535
- function claimElement(node) {
536
- if (claimHandlers !== null) {
537
- for (let i = 0; i < claimHandlers.length; i++) claimHandlers[i](node);
550
+ function claimElement(node, owner) {
551
+ if (claimHandlers !== null && !node._$claimed) {
552
+ node._$claimed = true;
553
+ if (owner === undefined) runClaimHandlers(claimHandlers, node);else runWithOwner(owner, () => runClaimHandlers(claimHandlers, node));
538
554
  }
539
555
  return node;
540
556
  }
@@ -551,11 +567,12 @@ function setAttribute(node, name, value) {
551
567
  }
552
568
  }
553
569
  if (selectMultiple) node._$multiple = true;
554
- if (claimHandlers !== null && (name === "href" || name === "action")) claimElement(node);
570
+ reclaimAttribute(node, name);
555
571
  }
556
572
  function setAttributeNS(node, namespace, name, value) {
557
573
  if (isHydrating(node)) return;
558
574
  if (value == null || value === false) node.removeAttributeNS(namespace, name.indexOf(":") > -1 ? name.split(":").pop() : name);else node.setAttributeNS(namespace, name, value === true ? "" : value);
575
+ reclaimAttribute(node, name);
559
576
  }
560
577
  function className(node, value, prev) {
561
578
  if (typeof value === "number") value = "" + value;
@@ -663,7 +680,7 @@ function readShallow(value) {
663
680
  if (value === null || typeof value !== "object") return value;
664
681
  if (Array.isArray(value)) return value.map(readShallow);
665
682
  if (value[$PROXY] !== value) return value;
666
- const keys = sourceKeys(value, SOURCE_PROXY);
683
+ const keys = Reflect.ownKeys(value);
667
684
  const out = {};
668
685
  for (let i = 0; i < keys.length; i++) {
669
686
  const k = keys[i];
@@ -675,12 +692,14 @@ function setStyleProperty(node, name, value) {
675
692
  if (isHydrating(node)) return;
676
693
  value != null ? node.style.setProperty(name, value) : node.style.removeProperty(name);
677
694
  }
678
- function spread(node, props, skipChildren, skip, name) {
695
+ function spread(node, props, skipChildren, skip, name, loc) {
679
696
  const prevProps = {};
697
+ const owner = claimHandlers !== null && (node.localName === "a" || node.localName === "form") ? getOwner() : undefined;
680
698
  const apply = newProps => {
681
699
  const r = newProps.ref;
682
700
  if (r !== prevProps.ref && (typeof r === "function" || Array.isArray(r))) ref(() => r, node);
683
701
  assign(node, newProps, true, prevProps, true);
702
+ if (owner !== undefined) claimElement(node, owner);
684
703
  };
685
704
  if (Array.isArray(props)) {
686
705
  effect(() => collectSources({}, props, undefined, skip), apply);
@@ -800,6 +819,7 @@ const SCOPE_OPTIONS = {
800
819
  scope: true
801
820
  };
802
821
  let hydrationRt = null;
822
+ let selectInsert = null;
803
823
  function installHydrationRuntime() {
804
824
  hydrationRt = {
805
825
  claimInitial(parent, multi, initial) {
@@ -890,11 +910,14 @@ function insert(parent, accessor, marker, initial, options) {
890
910
  initial = [placeholder];
891
911
  }
892
912
  let current = initial;
893
- effect(prev => {
913
+ let ran = false;
914
+ effect(() => {
894
915
  if (hydrationRt !== null) current = hydrationRt.reclaimRegion(current, parent, marker);
895
916
  const value = normalize(accessor(), current, multi, true);
917
+ const again = ran;
918
+ ran = true;
896
919
  if (typeof value !== "function") return value;
897
- const innerOptions = prev !== undefined && !(options && options.schedule) ? {
920
+ const innerOptions = again && !(options && options.schedule) ? {
898
921
  ...options,
899
922
  schedule: true
900
923
  } : options;
@@ -1218,7 +1241,7 @@ function createHeadElement(tag, props) {
1218
1241
  if (v == null || v === false) continue;
1219
1242
  el.setAttribute(name, v === true ? "" : String(v));
1220
1243
  }
1221
- if (props.children != null) el.textContent = String(props.children);
1244
+ if (props.children != null) el.textContent = headBodyText(tag, props, String(props.children));
1222
1245
  return el;
1223
1246
  }
1224
1247
  function renderHeadElement(t, identity, existing) {
@@ -1241,7 +1264,7 @@ function headElementMatches(el, t) {
1241
1264
  } else if (el.getAttribute(name) !== (v === true ? "" : String(v))) return false;
1242
1265
  }
1243
1266
  const children = t.props.children;
1244
- return (children == null ? "" : String(children)) === el.textContent;
1267
+ return (children == null ? "" : headBodyText(t.tag, t.props, String(children))) === el.textContent;
1245
1268
  }
1246
1269
  function mountHeadResource(tag, props) {
1247
1270
  const identity = resourceIdentity(tag, props);
@@ -1357,7 +1380,22 @@ function loadModuleAssets(mapping) {
1357
1380
  function hydrate(code, element, options = {}) {
1358
1381
  enableHydration();
1359
1382
  installHydrationRuntime();
1360
- if (globalThis._$HY.done) return render(code, element, [...element.childNodes], options);
1383
+ const hy = globalThis._$HY;
1384
+ const id = options.renderId || "";
1385
+ if (hy.s && !hy.s[id] && !hy.s[""] && !hy.done && document.readyState === "loading") {
1386
+ let started, disposer;
1387
+ const start = () => started || (started = true, disposer = hydrate(code, element, options));
1388
+ (hy.sp || (hy.sp = [])).push([id, start]);
1389
+ hy.sw = key => hy.sp.forEach(([k, f]) => (!key || k === key) && queueMicrotask(f));
1390
+ document.addEventListener("DOMContentLoaded", start, {
1391
+ once: true
1392
+ });
1393
+ return () => {
1394
+ started = true;
1395
+ disposer && disposer();
1396
+ };
1397
+ }
1398
+ if (hy.done) return render(code, element, [...element.childNodes], options);
1361
1399
  const head = (element.nodeType === 9 ? element : element.ownerDocument).head;
1362
1400
  if (head && element.contains(head)) {
1363
1401
  let n = head.firstChild;
@@ -1536,13 +1574,32 @@ function isHydrating(node) {
1536
1574
  if (!sharedConfig.hydrating) return false;
1537
1575
  if (sharedConfig.isClaiming && !sharedConfig.isClaiming()) return false;
1538
1576
  if (!node || node.isConnected) return true;
1539
- const roots = sharedConfig.claimRoots;
1540
- if (roots) {
1541
- for (let i = 0; i < roots.length; i++) {
1542
- if (roots[i].contains(node)) return true;
1577
+ return serverComponentClaims !== null && serverComponentClaims.claimed(node);
1578
+ }
1579
+ let serverComponentClaims = null;
1580
+ function installServerComponentHydration() {
1581
+ enableServerComponentHydration();
1582
+ if (serverComponentClaims !== null) return;
1583
+ serverComponentClaims = {
1584
+ claimed(node) {
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;
1589
+ }
1590
+ }
1591
+ return false;
1592
+ },
1593
+ inFrame(element) {
1594
+ const frames = element.querySelectorAll("[data-fid]");
1595
+ const frameCount = frames.length;
1596
+ if (frameCount === 0) return undefined;
1597
+ return node => {
1598
+ for (let j = 0; j < frameCount; j++) if (frames[j].contains(node)) return true;
1599
+ return false;
1600
+ };
1543
1601
  }
1544
- }
1545
- return false;
1602
+ };
1546
1603
  }
1547
1604
  function classListToObject(classList) {
1548
1605
  if (Array.isArray(classList)) {
@@ -1594,8 +1651,10 @@ function assignProp(node, prop, value, prev, skipRef, nodeName) {
1594
1651
  }
1595
1652
  } else if (hasNamespace && prop.slice(0, 5) === "prop:" || ChildProperties.has(prop) || DOMWithState[nodeName]?.[prop]) {
1596
1653
  if (hasNamespace) prop = prop.slice(5);else if (isHydrating(node)) return value;
1597
- if (prop === "value" && nodeName === "SELECT") queueMicrotask(() => node.value = value) || (node.value = value);else if ((prop === "value" || prop === "defaultValue") && (nodeName === "INPUT" || nodeName === "TEXTAREA"))
1598
- node[prop] = value ?? "";else node[prop] = value;
1654
+ if (prop === "value" && nodeName === "SELECT") writeSelectValue(node, value);else if ((prop === "value" || prop === "defaultValue") && (nodeName === "INPUT" || nodeName === "TEXTAREA")) {
1655
+ if (value == null && /^(checkbox|radio)$/.test(node.type)) node.removeAttribute("value");else node[prop] = value ?? "";
1656
+ } else node[prop] = value;
1657
+ reclaimAttribute(node, prop);
1599
1658
  } else {
1600
1659
  const ns = hasNamespace && Namespaces[prop.split(":")[0]];
1601
1660
  if (ns) setAttributeNS(node, ns, prop, value);else setAttribute(node, prop, value);
@@ -1610,14 +1669,13 @@ function eventHandler(e, container, state) {
1610
1669
  if (prev === true || prev === container || !container.contains(prev)) return;
1611
1670
  resumeNode = prev;
1612
1671
  }
1613
- const owner = state && (state.owners.size === 1 && state.owners.has(container) ? container : findOwner(e.target, state)?.owner);
1614
- if (state && !owner) return;
1615
- if (owner && owner === resumeNode) return;
1616
- e[$$EVENT_OWNER] = owner || true;
1672
+ const owner = state.owners.size === 1 && state.owners.has(container) ? container : findOwner(e.target, state)?.owner;
1673
+ if (!owner) return;
1674
+ if (owner === resumeNode) return;
1675
+ e[$$EVENT_OWNER] = owner;
1617
1676
  let node = resumeNode || e.target;
1618
1677
  const key = EVENT_KEY + e.type;
1619
1678
  const oriTarget = e.target;
1620
- const boundary = owner || container || e.currentTarget;
1621
1679
  const retarget = value => Object.defineProperty(e, "target", {
1622
1680
  configurable: true,
1623
1681
  value
@@ -1634,19 +1692,19 @@ function eventHandler(e, container, state) {
1634
1692
  };
1635
1693
  const walkUpTree = () => {
1636
1694
  while (node && handleNode()) {
1637
- if (node === boundary || node.parentNode === boundary) break;
1695
+ if (node === owner || node.parentNode === owner) break;
1638
1696
  node = node._$host || node.parentNode || node.host;
1639
1697
  }
1640
1698
  };
1641
1699
  Object.defineProperty(e, "currentTarget", {
1642
1700
  configurable: true,
1643
1701
  get() {
1644
- return node || boundary || document;
1702
+ return node || owner;
1645
1703
  }
1646
1704
  });
1647
1705
  if (resumeNode) {
1648
1706
  if (resumeNode === e.target) node = resumeNode._$host || resumeNode.parentNode || resumeNode.host;
1649
- if (node && node !== boundary) walkUpTree();
1707
+ if (node && node !== owner) walkUpTree();
1650
1708
  } else if (e.composedPath) {
1651
1709
  const path = e.composedPath();
1652
1710
  if (path.length) {
@@ -1659,7 +1717,7 @@ function eventHandler(e, container, state) {
1659
1717
  walkUpTree();
1660
1718
  break;
1661
1719
  }
1662
- if (node === boundary || node.parentNode === boundary) {
1720
+ if (node === owner || node.parentNode === owner) {
1663
1721
  break;
1664
1722
  }
1665
1723
  }
@@ -1683,7 +1741,10 @@ function insertExpression(parent, value, current, marker) {
1683
1741
  return value;
1684
1742
  }
1685
1743
  if (value === current) return value;
1686
- if (hydrationRt !== null && sharedConfig.hydrating && current == null && value && [].concat(value).every(n => n?.parentNode === parent) && value.length !== 0) return value;
1744
+ if (hydrationRt !== null && sharedConfig.hydrating && value && value.length !== 0) {
1745
+ const tracked = [].concat(current ?? []);
1746
+ if ([].concat(value).every(n => (n === tracked[0] && tracked.shift(), n?.parentNode === parent)) && !tracked.length) return value;
1747
+ }
1687
1748
  const t = typeof value,
1688
1749
  multi = marker !== undefined;
1689
1750
  if (t === "string" || t === "number") {
@@ -1733,8 +1794,34 @@ function insertExpression(parent, value, current, marker) {
1733
1794
  appendNodes(parent, value);
1734
1795
  }
1735
1796
  } else ;
1797
+ selectInsert && selectInsert(parent);
1736
1798
  return value;
1737
1799
  }
1800
+ function selectChange(e) {
1801
+ (e = e.currentTarget || e)._$v = null;
1802
+ e.removeEventListener("change", selectChange, true);
1803
+ }
1804
+ function writeSelectValue(node, value) {
1805
+ const had = node._$v && node._$v.map,
1806
+ has = value != null && value.map;
1807
+ if (has) had || node.addEventListener("change", selectChange, true);else had && node.removeEventListener("change", selectChange, true);
1808
+ if (value == null) {
1809
+ node._$v = null;
1810
+ return queueMicrotask(() => node.value = value) || (node.value = value);
1811
+ }
1812
+ node._$v = value;
1813
+ (selectInsert ||= p => {
1814
+ p && p._$v == null && (p = p.parentNode);
1815
+ const v = p && p._$v;
1816
+ if (v == null) return;
1817
+ if (v.map) {
1818
+ const o = [...p.options];
1819
+ for (let i = 0; i < o.length; i++) o[i].selected = v.some(x => x == o[i].value);
1820
+ v.every(x => o.some(el => el.value == x)) && selectChange(p);
1821
+ } else p.value = v, p.selectedIndex > -1 && p.value == v && (p._$v = null);
1822
+ })(node);
1823
+ queueMicrotask(() => selectInsert(node));
1824
+ }
1738
1825
  function normalize(value, current, multi, doNotUnwrap) {
1739
1826
  value = flatten(value, {
1740
1827
  skipNonRendered: true,
@@ -1742,7 +1829,7 @@ function normalize(value, current, multi, doNotUnwrap) {
1742
1829
  });
1743
1830
  if (doNotUnwrap && typeof value === "function") return value;
1744
1831
  if (multi && !Array.isArray(value)) value = [value != null ? value : ""];
1745
- if (sharedConfig.hydrating && Array.isArray(value)) {
1832
+ if (hydrationRt !== null && sharedConfig.hydrating && Array.isArray(value)) {
1746
1833
  for (let i = 0, len = value.length; i < len; i++) {
1747
1834
  const item = value[i],
1748
1835
  prev = current && current[i],
@@ -1813,22 +1900,12 @@ function cleanChildren(parent, current, marker, replacement) {
1813
1900
  }
1814
1901
  function gatherHydratable(element, root) {
1815
1902
  const templates = element.querySelectorAll(root ? `[_hk^="${root.replace(/["\\]/g, "\\$&")}"]` : `*[_hk]`);
1816
- const frames = root ? null : element.querySelectorAll("[data-fid]");
1817
- const frameCount = frames ? frames.length : 0;
1903
+ const inFrame = root || serverComponentClaims === null ? undefined : serverComponentClaims.inFrame(element);
1818
1904
  const registry = sharedConfig.registry;
1819
1905
  for (let i = 0; i < templates.length; i++) {
1820
1906
  const node = templates[i];
1907
+ if (inFrame !== undefined && inFrame(node)) continue;
1821
1908
  const key = node.getAttribute("_hk");
1822
- if (frameCount !== 0) {
1823
- let inFrame = false;
1824
- for (let j = 0; j < frameCount; j++) {
1825
- if (frames[j].contains(node)) {
1826
- inFrame = true;
1827
- break;
1828
- }
1829
- }
1830
- if (inFrame) continue;
1831
- }
1832
1909
  if (!registry.has(key)) registry.set(key, node);
1833
1910
  }
1834
1911
  }
@@ -1870,6 +1947,7 @@ function composeMiddleware(middlewares) {
1870
1947
  function ssr(template, ...nodes) {}
1871
1948
  function ssrElement(name, props, children, needsId, skip, attrs) {}
1872
1949
  function ssrElementAttribute(key, value) {}
1950
+ function ssrLinkClaim(attrs) {}
1873
1951
  function ssrClassName(value) {}
1874
1952
  function ssrStyle(value) {}
1875
1953
  function ssrStyleProperty(name, value) {}
@@ -1881,17 +1959,24 @@ function resolveSSRNode(node, result, top, nested) {}
1881
1959
  function escape(s, attr) {}
1882
1960
 
1883
1961
  const ENVELOPE = Symbol.for("solid.ResponseEnvelope");
1884
- // PURE-annotated factory (same convention as solid's MockPromise): the brand
1885
- const ResponseEnvelope = /* @__PURE__ */(() => {
1886
- class ResponseEnvelope {
1887
- constructor(response, value) {
1888
- this.response = response;
1889
- this.value = value;
1890
- }
1962
+ let EnvelopeClass;
1963
+ const ResponseEnvelope = function ResponseEnvelope(response, value) {
1964
+ if (!EnvelopeClass) {
1965
+ EnvelopeClass = class extends Response {
1966
+ constructor(response, value) {
1967
+ super(response ? response.body : null, response && {
1968
+ status: response.status,
1969
+ statusText: response.statusText,
1970
+ headers: copyHeaders(response.headers)
1971
+ });
1972
+ this.response = response ? this : undefined;
1973
+ this.value = value;
1974
+ }
1975
+ };
1976
+ EnvelopeClass.prototype[ENVELOPE] = true;
1891
1977
  }
1892
- ResponseEnvelope.prototype[ENVELOPE] = true;
1893
- return ResponseEnvelope;
1894
- })();
1978
+ return new EnvelopeClass(response, value);
1979
+ };
1895
1980
  function isResponseEnvelope(value) {
1896
1981
  return !!(value && typeof value === "object" && value[ENVELOPE]);
1897
1982
  }
@@ -1916,6 +2001,16 @@ function isSafeError(value) {
1916
2001
  const REVALIDATE_HEADER = "X-Revalidate";
1917
2002
  const REVALIDATE_ALL = "*";
1918
2003
  const RESPONSE_HEADER_VALUE_LIMIT = 4096;
2004
+ function copyHeaders(init) {
2005
+ const source = init;
2006
+ if (!source || !source.getSetCookie) return new Headers(init);
2007
+ const headers = new Headers();
2008
+ source.forEach((value, key) => {
2009
+ if (key !== "set-cookie") headers.append(key, value);
2010
+ });
2011
+ for (const cookie of source.getSetCookie()) headers.append("Set-Cookie", cookie);
2012
+ return headers;
2013
+ }
1919
2014
  function initWithRevalidate(init = {}) {
1920
2015
  const resolved = typeof init === "number" ? {
1921
2016
  status: init
@@ -1924,18 +2019,7 @@ function initWithRevalidate(init = {}) {
1924
2019
  revalidate,
1925
2020
  ...responseInit
1926
2021
  } = resolved;
1927
- let headers;
1928
- if (responseInit.headers && responseInit.headers.getSetCookie) {
1929
- headers = new Headers();
1930
- responseInit.headers.forEach((value, key) => {
1931
- if (key !== "set-cookie") headers.append(key, value);
1932
- });
1933
- for (const cookie of responseInit.headers.getSetCookie()) {
1934
- headers.append("Set-Cookie", cookie);
1935
- }
1936
- } else {
1937
- headers = new Headers(responseInit.headers);
1938
- }
2022
+ const headers = copyHeaders(responseInit.headers);
1939
2023
  if (revalidate !== undefined) {
1940
2024
  const list = Array.isArray(revalidate) ? revalidate : [revalidate];
1941
2025
  if (list.length > 1 && list.includes(REVALIDATE_ALL)) {
@@ -1999,7 +2083,12 @@ function respond(value, init = {}) {
1999
2083
  }), value);
2000
2084
  }
2001
2085
  headers.set("Content-Type", "application/json");
2002
- return new ResponseEnvelope(new Response(JSON.stringify(value), {
2086
+ return new ResponseEnvelope(new Response(new ReadableStream({
2087
+ pull(controller) {
2088
+ controller.enqueue(new TextEncoder().encode(JSON.stringify(value)));
2089
+ controller.close();
2090
+ }
2091
+ }), {
2003
2092
  ...responseInit,
2004
2093
  headers
2005
2094
  }), value);
@@ -2059,110 +2148,9 @@ function portalImpl(props) {
2059
2148
  });
2060
2149
  return treeMarker;
2061
2150
  }
2062
- const COMPONENT_BINDING = Symbol.for("solid.component-binding");
2063
- const FLIGHT = Symbol("solid.dynamic-flight");
2064
- function bindingOf(value) {
2065
- return value !== null && (typeof value === "function" || typeof value === "object") && value[COMPONENT_BINDING] || undefined;
2066
- }
2067
2151
  function dynamic(source, options) {
2068
2152
  return dynamicCore(source, options, staticElement);
2069
2153
  }
2070
- function dynamicComponent(source, options) {
2071
- return dynamicCore(source, options);
2072
- }
2073
- function dynamicCore(source, options, tagArm) {
2074
- if (options?.static) return staticDynamic(untrack(source), tagArm);
2075
- const sites = new Set();
2076
- let deliveredAddress;
2077
- const resolveBinding = (next, prev) => {
2078
- const binding = bindingOf(next);
2079
- if (!binding) return next;
2080
- deliveredAddress = binding.address;
2081
- const prevBinding = bindingOf(prev);
2082
- if (prevBinding && prevBinding.component === binding.component) {
2083
- for (const deliver of sites) deliver(binding.address);
2084
- return prev;
2085
- }
2086
- return next;
2087
- };
2088
- const sameInstance = (prev, next) => {
2089
- if (prev === next) return true;
2090
- const held = bindingOf(prev);
2091
- const incoming = bindingOf(next);
2092
- if (!held || !incoming || held.component !== incoming.component) return false;
2093
- if (held.address === incoming.address) return true;
2094
- if (deliveredAddress === undefined) return false;
2095
- if (incoming.address !== deliveredAddress) {
2096
- deliveredAddress = incoming.address;
2097
- for (const deliver of sites) deliver(incoming.address);
2098
- }
2099
- return true;
2100
- };
2101
- const cached = createMemo(prev => {
2102
- const next = source();
2103
- if (!next || typeof next.then !== "function") return resolveBinding(next, prev);
2104
- return {
2105
- [FLIGHT]: next
2106
- };
2107
- }, {
2108
- lazy: true,
2109
- equals: sameInstance
2110
- });
2111
- return props => {
2112
- if (sharedConfig.hydrating) {
2113
- try {
2114
- untrack(cached);
2115
- } catch {}
2116
- }
2117
- let latest = 0;
2118
- const value = createMemo(prev => {
2119
- const c = cached();
2120
- if (!c || !c[FLIGHT]) return resolveBinding(c, prev);
2121
- const next = c[FLIGHT];
2122
- const token = ++latest;
2123
- return {
2124
- then: (onFulfilled, onRejected) => next.then(resolved => {
2125
- const landed = token === latest ? resolveBinding(resolved, prev) : resolved;
2126
- return onFulfilled ? onFulfilled(landed) : landed;
2127
- }, onRejected)
2128
- };
2129
- }, {
2130
- equals: sameInstance
2131
- });
2132
- return createMemo(() => {
2133
- const component = value();
2134
- switch (typeof component) {
2135
- case "function":
2136
- {
2137
- const binding = bindingOf(component);
2138
- if (binding) {
2139
- const [address, setAddress] = createSignal(deliveredAddress ??= binding.address, {
2140
- ownedWrite: true
2141
- });
2142
- sites.add(setAddress);
2143
- onCleanup(() => sites.delete(setAddress));
2144
- return untrack(() => binding.component(props, address));
2145
- }
2146
- return untrack(() => component(props));
2147
- }
2148
- case "string":
2149
- return tagArm ? tagArm(component, props) : undefined;
2150
- }
2151
- });
2152
- };
2153
- }
2154
- function staticDynamic(component, tagArm) {
2155
- if (typeof component === "function") {
2156
- const binding = bindingOf(component);
2157
- if (binding) {
2158
- const address = () => binding.address;
2159
- return props => untrack(() => binding.component(props, address));
2160
- }
2161
- return props => untrack(() => component(props));
2162
- }
2163
- if (typeof component === "string" && tagArm) return props => tagArm(component, props);
2164
- return () => undefined;
2165
- }
2166
2154
  function staticElement(tag, props) {
2167
2155
  const hydrating = sharedConfig.hydrating;
2168
2156
  const el = hydrating ? getNextElement() : createElement(tag, untrack(() => props.is), untrack(() => props.xmlns));
@@ -2209,4 +2197,4 @@ _moduleUrl) {
2209
2197
  function httpStatus(_code, _text) {}
2210
2198
  function httpHeader(_name, _value, _options) {}
2211
2199
 
2212
- 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 };
2200
+ 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 };