@solidjs/web 2.0.0-rc.3 → 2.0.0-rc.5

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 (65) hide show
  1. package/dist/dev.cjs +398 -17
  2. package/dist/dev.js +396 -19
  3. package/dist/server.cjs +166 -38
  4. package/dist/server.js +165 -39
  5. package/dist/web.cjs +369 -17
  6. package/dist/web.js +367 -19
  7. package/frames/dist/client.cjs +41 -8
  8. package/frames/dist/client.dev.cjs +41 -8
  9. package/frames/dist/client.dev.js +41 -8
  10. package/frames/dist/client.js +41 -8
  11. package/frames/dist/server.cjs +432 -44
  12. package/frames/dist/server.js +432 -44
  13. package/package.json +2 -2
  14. package/serialization/dist/decode.cjs +4 -2
  15. package/serialization/dist/decode.js +4 -2
  16. package/serialization/dist/serialization.cjs +12 -8
  17. package/serialization/dist/serialization.js +12 -8
  18. package/serialization/types/index.d.ts +7 -0
  19. package/serialization/types/serializer-decode.d.ts +14 -1
  20. package/serialization/types/serializer.d.ts +7 -0
  21. package/serialization/types-cjs/index.d.cts +7 -0
  22. package/serialization/types-cjs/serializer-decode.d.cts +14 -1
  23. package/serialization/types-cjs/serializer.d.cts +7 -0
  24. package/server-functions/dist/client.cjs +271 -47
  25. package/server-functions/dist/client.js +264 -47
  26. package/server-functions/dist/server.cjs +872 -131
  27. package/server-functions/dist/server.dev.cjs +892 -131
  28. package/server-functions/dist/server.dev.js +884 -131
  29. package/server-functions/dist/server.js +864 -131
  30. package/types/client.d.ts +4 -2
  31. package/types/cookies.d.ts +6 -14
  32. package/types/frames/frame-client.d.ts +4 -0
  33. package/types/frames/serializer-decode.d.ts +14 -1
  34. package/types/frames/serializer.d.ts +7 -0
  35. package/types/index.d.ts +1 -0
  36. package/types/jsx.d.ts +11 -16
  37. package/types/patch-driver.d.ts +3 -0
  38. package/types/response.d.ts +20 -1
  39. package/types/serializer-decode.d.ts +14 -1
  40. package/types/serializer.d.ts +7 -0
  41. package/types/server-functions/client.d.ts +58 -7
  42. package/types/server-functions/flash.d.ts +9 -0
  43. package/types/server-functions/registry.d.ts +38 -1
  44. package/types/server-functions/server.d.ts +66 -14
  45. package/types/server-functions/shared.d.ts +122 -16
  46. package/types/server-mock.d.ts +17 -2
  47. package/types/server.d.ts +16 -2
  48. package/types-cjs/client.d.cts +4 -2
  49. package/types-cjs/cookies.d.cts +6 -14
  50. package/types-cjs/frames/frame-client.d.cts +4 -0
  51. package/types-cjs/frames/serializer-decode.d.cts +14 -1
  52. package/types-cjs/frames/serializer.d.cts +7 -0
  53. package/types-cjs/index.d.cts +1 -0
  54. package/types-cjs/jsx.d.cts +11 -16
  55. package/types-cjs/patch-driver.d.cts +3 -0
  56. package/types-cjs/response.d.cts +20 -1
  57. package/types-cjs/serializer-decode.d.cts +14 -1
  58. package/types-cjs/serializer.d.cts +7 -0
  59. package/types-cjs/server-functions/client.d.cts +58 -7
  60. package/types-cjs/server-functions/flash.d.cts +9 -0
  61. package/types-cjs/server-functions/registry.d.cts +38 -1
  62. package/types-cjs/server-functions/server.d.cts +66 -14
  63. package/types-cjs/server-functions/shared.d.cts +122 -16
  64. package/types-cjs/server-mock.d.cts +17 -2
  65. package/types-cjs/server.d.cts +16 -2
package/dist/dev.js CHANGED
@@ -1,4 +1,4 @@
1
- import { createRenderEffect, createMemo, sharedConfig, enableHydration, untrack, runWithOwner, resetErrorHalt, enforceLoadingBoundary, createRoot, flatten, flush, createComponent, omit, createOwner, createSignal, $DEVCOMP, onCleanup, getOwner, createEffect } from 'solid-js';
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';
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 = {
@@ -214,7 +214,8 @@ function resourceIdentity(tag, props) {
214
214
  let id = "res:" + tag + ":" + (props.rel || "") + ":" + (props.href || props.src || "");
215
215
  for (let i = 0; i < RESOURCE_QUALIFIERS.length; i++) {
216
216
  const q = RESOURCE_QUALIFIERS[i];
217
- if (props[q] != null) id += ":" + q + "=" + props[q];
217
+ const value = props[q];
218
+ if (value != null) id += ":" + q + "=" + (value === true ? "" : value);
218
219
  }
219
220
  return id;
220
221
  }
@@ -287,6 +288,7 @@ function decodeSafe(text) {
287
288
  }
288
289
  }
289
290
  function serializeCookie(name, value, options = {}) {
291
+ assertServableCookie(name, options);
290
292
  let cookie = `${encodeURIComponent(name)}=${encodeURIComponent(value)}`;
291
293
  cookie += `; Path=${options.path === undefined ? "/" : options.path}`;
292
294
  if (options.domain) cookie += `; Domain=${options.domain}`;
@@ -294,12 +296,32 @@ function serializeCookie(name, value, options = {}) {
294
296
  if (options.expires) cookie += `; Expires=${options.expires.toUTCString()}`;
295
297
  if (options.httpOnly) cookie += "; HttpOnly";
296
298
  if (options.secure) cookie += "; Secure";
299
+ if (options.partitioned) cookie += "; Partitioned";
297
300
  if (options.sameSite) {
298
301
  const sameSite = options.sameSite.toLowerCase();
299
302
  cookie += `; SameSite=${sameSite === "none" ? "None" : sameSite === "strict" ? "Strict" : "Lax"}`;
300
303
  }
301
304
  return cookie;
302
305
  }
306
+ function assertServableCookie(name, options) {
307
+ const reject = reason => {
308
+ throw new Error(`serializeCookie: every browser silently rejects this cookie — ${reason}. ` + `It would never come back on a request, with no error anywhere.`);
309
+ };
310
+ const lower = name.toLowerCase();
311
+ if (lower.startsWith("__host-")) {
312
+ if (!options.secure) reject(`the __Host- prefix on \`${name}\` requires \`secure: true\``);
313
+ if (options.path !== undefined && options.path !== "/") reject(`the __Host- prefix on \`${name}\` requires \`Path=/\` (got \`${options.path}\`) — ` + `host-locking is the prefix's whole contract, so it cannot be path-scoped`);
314
+ if (options.domain) reject(`the __Host- prefix on \`${name}\` forbids \`Domain\` (got \`${options.domain}\`)`);
315
+ } else if (lower.startsWith("__secure-") && !options.secure) {
316
+ reject(`the __Secure- prefix on \`${name}\` requires \`secure: true\``);
317
+ }
318
+ if (options.sameSite && options.sameSite.toLowerCase() === "none" && !options.secure) {
319
+ reject("`SameSite=None` requires `secure: true`");
320
+ }
321
+ if (options.partitioned && !options.secure) {
322
+ reject("`Partitioned` requires `secure: true`");
323
+ }
324
+ }
303
325
  const FLASH_COOKIE = "flash";
304
326
  const FLASH_MATCHER = new RegExp(`(?:^|;\\s*)${FLASH_COOKIE}=([^;]+)`);
305
327
  function hasFlashCookie(cookieHeader) {
@@ -333,6 +355,10 @@ const waitAsset = promise => {
333
355
  }
334
356
  gate();
335
357
  };
358
+ let listDriver;
359
+ function installListDriver(driver) {
360
+ listDriver = driver;
361
+ }
336
362
  const $$EVENT_OWNER = "_$SOLID_EVENT_OWNER";
337
363
  const INNER_OWNED = {};
338
364
  const delegatedEvents = new Set();
@@ -584,16 +610,18 @@ function setStyleProperty(node, name, value) {
584
610
  }
585
611
  function spread(node, props = {}, skipChildren) {
586
612
  const prevProps = {};
587
- if (!skipChildren) insert(node, () => props.children);
613
+ const get = typeof props === "function" ? props : () => props;
614
+ if (!skipChildren) insert(node, () => get().children);
588
615
  effect(() => {
589
- const r = props.ref;
616
+ const r = get().ref;
590
617
  (typeof r === "function" || Array.isArray(r)) && ref(() => r, node);
591
618
  }, () => {});
592
619
  effect(() => {
620
+ const source = get();
593
621
  const newProps = {};
594
- for (const prop in props) {
622
+ for (const prop in source) {
595
623
  if (prop === "children" || prop === "ref") continue;
596
- newProps[prop] = props[prop];
624
+ newProps[prop] = source[prop];
597
625
  }
598
626
  return newProps;
599
627
  }, props => assign(node, props, true, prevProps, true));
@@ -616,11 +644,6 @@ function ref(fn, element) {
616
644
  const resolved = untrack(fn);
617
645
  runWithOwner(null, () => applyRef(resolved, element));
618
646
  }
619
- const PURE_ROW = Symbol.for("solid.pure-row");
620
- function rowProof(fn) {
621
- fn[PURE_ROW] = true;
622
- return fn;
623
- }
624
647
  function scope(fn) {
625
648
  fn.$s = true;
626
649
  return fn;
@@ -684,16 +707,16 @@ function stripTextSeparators(nodes) {
684
707
  nodes.length = j;
685
708
  return nodes;
686
709
  }
687
- function patchDriver(subject, body) {
688
- {
689
- effect(() => body(subject, subject, false), () => body(subject, undefined, true));
690
- }
691
- }
692
710
  function insert(parent, accessor, marker, initial, options) {
693
711
  const multi = marker !== undefined;
694
712
  const host = options && options.host;
695
713
  if (multi && !initial) initial = [];
696
714
  if (hydrationRt !== null) initial = hydrationRt.claimInitial(parent, multi, initial);
715
+ if (listDriver !== undefined && typeof accessor === "function" && accessor.$ll !== undefined) {
716
+ const listAccessor = accessor;
717
+ const owner = getOwner();
718
+ if (listDriver(parent, accessor, marker, () => runWithOwner(owner, () => insert(parent, () => listAccessor(), marker, marker !== undefined ? [] : undefined, options)))) return;
719
+ }
697
720
  if (typeof accessor !== "function") {
698
721
  accessor = normalize(accessor, initial, multi, true);
699
722
  if (typeof accessor !== "function") {
@@ -1172,6 +1195,15 @@ function hydrate(code, element, options = {}) {
1172
1195
  enableHydration();
1173
1196
  installHydrationRuntime();
1174
1197
  if (globalThis._$HY.done) return render(code, element, [...element.childNodes], options);
1198
+ const head = (element.nodeType === 9 ? element : element.ownerDocument).head;
1199
+ if (head && element.contains(head)) {
1200
+ let n = head.firstChild;
1201
+ while (n && n.nodeType === 1 && n.hasAttribute("data-dh") && !n.hasAttribute("data-dhf")) {
1202
+ const next = n.nextSibling;
1203
+ head.appendChild(n);
1204
+ n = next;
1205
+ }
1206
+ }
1175
1207
  options.renderId ||= "";
1176
1208
  if (!globalThis._$HY.modules) globalThis._$HY.modules = {};
1177
1209
  if (!globalThis._$HY.loading) globalThis._$HY.loading = {};
@@ -1685,6 +1717,331 @@ function getHydrationKey() {
1685
1717
  }
1686
1718
  const RequestContext = Symbol();
1687
1719
 
1720
+ const PURE_ROW = Symbol.for("solid.pure-row");
1721
+ const arm = () => {
1722
+ installListDriver(driveList);
1723
+ };
1724
+ function rowProof(fn) {
1725
+ arm();
1726
+ fn[PURE_ROW] = true;
1727
+ return fn;
1728
+ }
1729
+ let rowCollector = null;
1730
+ const lisPositions = sources => {
1731
+ const n = sources.length;
1732
+ const tails = [];
1733
+ const tailsIdx = [];
1734
+ const prev = new Array(n).fill(-1);
1735
+ for (let j = 0; j < n; j++) {
1736
+ const v = sources[j];
1737
+ if (v === -1) continue;
1738
+ let lo = 0,
1739
+ hi = tails.length;
1740
+ while (lo < hi) {
1741
+ const mid = lo + hi >> 1;
1742
+ if (tails[mid] < v) lo = mid + 1;else hi = mid;
1743
+ }
1744
+ if (lo > 0) prev[j] = tailsIdx[lo - 1];
1745
+ tails[lo] = v;
1746
+ tailsIdx[lo] = j;
1747
+ }
1748
+ const stable = new Set();
1749
+ let k = tailsIdx.length ? tailsIdx[tails.length - 1] : -1;
1750
+ while (k >= 0) {
1751
+ stable.add(k);
1752
+ k = prev[k];
1753
+ }
1754
+ return stable;
1755
+ };
1756
+ const driveList = (parent, listFn, marker, lateClassic) => {
1757
+ const meta = listFn.$ll;
1758
+ if (meta.row?.[PURE_ROW] !== true) return false;
1759
+ if (typeof meta.keyed === "function") return false;
1760
+ const evalOwner = createOwner({
1761
+ id: "&each"
1762
+ });
1763
+ let subject = runWithOwner(evalOwner, () => untrack(meta.each));
1764
+ evalOwner.dispose();
1765
+ let raw = subject != null ? patchableRaw(subject) : undefined;
1766
+ if (raw === undefined || !Array.isArray(raw)) return false;
1767
+ const optimistic = storeHasOptimisticFamily(subject);
1768
+ if (optimistic) raw = untrack(() => Array.from(subject));
1769
+ const hydrating = !!sharedConfig.hydrating;
1770
+ if (hydrating && raw.length === 0) return false;
1771
+ let domRows;
1772
+ let rowIds;
1773
+ if (hydrating) {
1774
+ if (marker !== undefined) return false;
1775
+ domRows = Array.from(parent.children);
1776
+ if (domRows.length !== raw.length) return false;
1777
+ rowIds = new Array(raw.length);
1778
+ for (let i = 0; i < domRows.length; i++) {
1779
+ const key = domRows[i].getAttribute("_hk");
1780
+ if (key === null || !key.endsWith("0") || key.length < 2) return false;
1781
+ rowIds[i] = key.slice(0, -1);
1782
+ }
1783
+ }
1784
+ const rowFn = meta.row;
1785
+ const endAnchor = marker ?? null;
1786
+ const shallow = storeIsShallow(subject);
1787
+ let lastBodies = null;
1788
+ let lastUnbinds = null;
1789
+ const collectBind = (abs, build) => {
1790
+ const prevC = rowCollector;
1791
+ rowCollector = {
1792
+ row: shallow ? subject[abs] : undefined,
1793
+ bodies: [],
1794
+ unbinds: []
1795
+ };
1796
+ try {
1797
+ return build();
1798
+ } finally {
1799
+ lastBodies = rowCollector.bodies;
1800
+ lastUnbinds = rowCollector.unbinds;
1801
+ rowCollector = prevC;
1802
+ }
1803
+ };
1804
+ const listOwner = createOwner();
1805
+ let declined = false;
1806
+ const bindRow = (abs, claimId) => {
1807
+ {
1808
+ const o = listOwner;
1809
+ const prevChild = o._firstChild;
1810
+ const prevDisposal = o._disposal;
1811
+ const node = collectBind(abs, () => runWithOwner(listOwner, () => claimId !== undefined ? runWithOwner(createOwner({
1812
+ id: claimId
1813
+ }), () => untrack(() => rowFn(subject[abs]))) : untrack(() => rowFn(subject[abs]))));
1814
+ if (o._firstChild !== prevChild || o._disposal !== prevDisposal) {
1815
+ 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).");
1816
+ }
1817
+ return node;
1818
+ }
1819
+ };
1820
+ let entries = new Array(raw.length);
1821
+ let rowBodies = shallow ? new Array(raw.length) : null;
1822
+ let rowUnbinds = new Array(raw.length);
1823
+ const runUnbinds = list => {
1824
+ if (list !== undefined) for (let u = 0; u < list.length; u++) list[u]();
1825
+ };
1826
+ const unbindAllRows = () => {
1827
+ for (let j = 0; j < rowUnbinds.length; j++) runUnbinds(rowUnbinds[j]);
1828
+ rowUnbinds = [];
1829
+ };
1830
+ let prevRaws = raw.slice();
1831
+ try {
1832
+ if (hydrating) {
1833
+ for (let i = 0; i < raw.length; i++) {
1834
+ entries[i] = bindRow(i, rowIds[i]);
1835
+ if (rowBodies !== null) rowBodies[i] = lastBodies;
1836
+ rowUnbinds[i] = lastUnbinds;
1837
+ }
1838
+ } else {
1839
+ for (let i = 0; i < raw.length; i++) {
1840
+ const node = bindRow(i);
1841
+ entries[i] = node;
1842
+ if (rowBodies !== null) rowBodies[i] = lastBodies;
1843
+ rowUnbinds[i] = lastUnbinds;
1844
+ parent.insertBefore(node, endAnchor);
1845
+ }
1846
+ }
1847
+ } catch (err) {
1848
+ unbindAllRows();
1849
+ runUnbinds(lastUnbinds ?? undefined);
1850
+ for (let j = 0; j < entries.length; j++) {
1851
+ const n = entries[j];
1852
+ if (n !== undefined && n.parentNode === parent) n.remove();
1853
+ }
1854
+ listOwner.dispose();
1855
+ throw err;
1856
+ }
1857
+ const identityOps = nextArr => {
1858
+ const keyOf = r => {
1859
+ const w = r != null ? patchableRaw(r) : undefined;
1860
+ return w !== undefined ? w : r;
1861
+ };
1862
+ const oldIndex = new Map();
1863
+ for (let j = 0; j < prevRaws.length; j++) {
1864
+ const k = keyOf(prevRaws[j]);
1865
+ const existing = oldIndex.get(k);
1866
+ if (existing === undefined) oldIndex.set(k, j);else if (Array.isArray(existing)) existing.push(j);else oldIndex.set(k, [existing, j]);
1867
+ }
1868
+ const sources = new Array(nextArr.length);
1869
+ for (let k = 0; k < nextArr.length; k++) {
1870
+ const m = oldIndex.get(keyOf(nextArr[k]));
1871
+ if (m === undefined) sources[k] = -1;else if (Array.isArray(m)) {
1872
+ sources[k] = m.shift();
1873
+ if (m.length === 1) oldIndex.set(keyOf(nextArr[k]), m[0]);
1874
+ } else {
1875
+ sources[k] = m;
1876
+ oldIndex.delete(keyOf(nextArr[k]));
1877
+ }
1878
+ }
1879
+ return {
1880
+ prefix: 0,
1881
+ sources
1882
+ };
1883
+ };
1884
+ let resyncNeeded = false;
1885
+ const applyOps = (next, ops) => {
1886
+ if (declined) return;
1887
+ if (resyncNeeded) ops = null;
1888
+ if (ops === null) ops = identityOps(next);
1889
+ const {
1890
+ prefix,
1891
+ sources
1892
+ } = ops;
1893
+ const built = new Array(sources.length);
1894
+ const builtBodies = rowBodies !== null ? new Array(sources.length) : null;
1895
+ const builtUnbinds = new Array(sources.length);
1896
+ let j = 0;
1897
+ try {
1898
+ for (; j < sources.length; j++) {
1899
+ const abs = prefix + j;
1900
+ const src = sources[j];
1901
+ if (src === -1 || refRebuild && src >= 0 && next[abs] !== prevRaws[src]) {
1902
+ built[j] = bindRow(abs);
1903
+ if (builtBodies !== null) builtBodies[j] = lastBodies;
1904
+ builtUnbinds[j] = lastUnbinds;
1905
+ }
1906
+ }
1907
+ } catch (err) {
1908
+ for (let k = 0; k < j; k++) runUnbinds(builtUnbinds[k]);
1909
+ runUnbinds(lastUnbinds ?? undefined);
1910
+ resyncNeeded = true;
1911
+ throw err;
1912
+ }
1913
+ const retained = new Set();
1914
+ for (let k = 0; k < sources.length; k++) {
1915
+ if (sources[k] >= 0 && built[k] === undefined) retained.add(sources[k]);
1916
+ }
1917
+ for (let k = prefix; k < entries.length; k++) {
1918
+ if (!retained.has(k)) {
1919
+ entries[k].remove();
1920
+ runUnbinds(rowUnbinds[k]);
1921
+ }
1922
+ }
1923
+ const newEntries = new Array(prefix + sources.length);
1924
+ const newBodies = rowBodies !== null ? new Array(prefix + sources.length) : null;
1925
+ const newUnbinds = new Array(prefix + sources.length);
1926
+ for (let i = 0; i < prefix; i++) {
1927
+ newEntries[i] = entries[i];
1928
+ if (newBodies !== null) newBodies[i] = rowBodies[i];
1929
+ newUnbinds[i] = rowUnbinds[i];
1930
+ }
1931
+ const stable = lisPositions(sources);
1932
+ let anchor = endAnchor;
1933
+ for (let k = sources.length - 1; k >= 0; k--) {
1934
+ const abs = prefix + k;
1935
+ const src = sources[k];
1936
+ let node;
1937
+ if (built[k] !== undefined) {
1938
+ node = built[k];
1939
+ if (newBodies !== null) newBodies[abs] = builtBodies[k];
1940
+ newUnbinds[abs] = builtUnbinds[k];
1941
+ parent.insertBefore(node, anchor);
1942
+ } else {
1943
+ node = entries[src];
1944
+ if (newBodies !== null) newBodies[abs] = rowBodies[src];
1945
+ newUnbinds[abs] = rowUnbinds[src];
1946
+ if (!stable.has(k)) parent.insertBefore(node, anchor);
1947
+ }
1948
+ newEntries[abs] = node;
1949
+ anchor = node;
1950
+ }
1951
+ entries = newEntries;
1952
+ if (newBodies !== null) rowBodies = newBodies;
1953
+ rowUnbinds = newUnbinds;
1954
+ prevRaws = next.slice();
1955
+ resyncNeeded = false;
1956
+ };
1957
+ let unbindOps = runWithOwner(listOwner, () => registerRowOps(subject, applyOps));
1958
+ const refRebuild = shallow && typeof meta.keyed !== "function";
1959
+ const rebuildSlot = i => {
1960
+ runUnbinds(rowUnbinds[i]);
1961
+ const old = entries[i];
1962
+ const node = bindRow(i);
1963
+ rowBodies[i] = lastBodies;
1964
+ rowUnbinds[i] = lastUnbinds;
1965
+ parent.insertBefore(node, old);
1966
+ old.remove();
1967
+ entries[i] = node;
1968
+ };
1969
+ const applySlot = (i, next, prev) => {
1970
+ if (declined) return;
1971
+ if (resyncNeeded) {
1972
+ const live = subject != null ? patchableRaw(subject) : undefined;
1973
+ if (live !== undefined && Array.isArray(live)) applyOps(live, null);
1974
+ return;
1975
+ }
1976
+ if (refRebuild) {
1977
+ rebuildSlot(i);
1978
+ prevRaws[i] = next;
1979
+ return;
1980
+ }
1981
+ const bodies = rowBodies[i];
1982
+ if (bodies !== undefined) {
1983
+ for (let b = 0; b < bodies.length; b++) bodies[b](next, prev, false);
1984
+ }
1985
+ prevRaws[i] = next;
1986
+ };
1987
+ let unbindSlots = shallow ? runWithOwner(listOwner, () => registerSlotPatch(subject, applySlot)) : null;
1988
+ runWithOwner(listOwner, () => effect(() => meta.each(), value => {
1989
+ if (declined || value === subject) return;
1990
+ const nextRaw = value != null ? patchableRaw(value) : undefined;
1991
+ unbindOps();
1992
+ unbindSlots?.();
1993
+ if (nextRaw !== undefined && Array.isArray(nextRaw) && storeIsShallow(value) !== shallow) {
1994
+ for (let j = 0; j < entries.length; j++) entries[j].remove();
1995
+ entries = [];
1996
+ prevRaws = [];
1997
+ unbindAllRows();
1998
+ subject = value;
1999
+ declined = true;
2000
+ listOwner.dispose();
2001
+ lateClassic?.();
2002
+ return;
2003
+ }
2004
+ if (nextRaw === undefined || !Array.isArray(nextRaw)) {
2005
+ for (let j = 0; j < entries.length; j++) entries[j].remove();
2006
+ entries = [];
2007
+ prevRaws = [];
2008
+ unbindAllRows();
2009
+ subject = value;
2010
+ declined = true;
2011
+ listOwner.dispose();
2012
+ lateClassic?.();
2013
+ return;
2014
+ }
2015
+ const swapOps = identityOps(nextRaw);
2016
+ subject = value;
2017
+ unbindOps = runWithOwner(listOwner, () => registerRowOps(subject, applyOps));
2018
+ if (shallow) unbindSlots = runWithOwner(listOwner, () => registerSlotPatch(subject, applySlot));
2019
+ applyOps(nextRaw, swapOps);
2020
+ }));
2021
+ onCleanup(() => {
2022
+ unbindOps();
2023
+ unbindSlots?.();
2024
+ unbindAllRows();
2025
+ listOwner.dispose();
2026
+ });
2027
+ return true;
2028
+ };
2029
+ const patchDriver = (subject, body) => {
2030
+ const raw = patchableRaw(subject);
2031
+ if (raw !== undefined) {
2032
+ if (!sharedConfig.hydrating) body(raw, undefined, true);
2033
+ const unbind = registerPatch(subject, body);
2034
+ if (rowCollector !== null) rowCollector.unbinds.push(unbind);
2035
+ else onCleanup(unbind);
2036
+ } else if (rowCollector !== null && subject === rowCollector.row) {
2037
+ rowCollector.bodies.push(body);
2038
+ if (!sharedConfig.hydrating) body(subject, undefined, true);
2039
+ } else {
2040
+ effect(() => body(subject, subject, false),
2041
+ () => untrack(() => body(subject, undefined, true)));
2042
+ }
2043
+ };
2044
+
1688
2045
  function throwInBrowser(func) {
1689
2046
  const err = new Error(`${func.name} is not supported in the browser, returning undefined`);
1690
2047
  console.error(err);
@@ -1758,6 +2115,7 @@ function isSafeError(value) {
1758
2115
  return !!(value && (typeof value === "object" || typeof value === "function") && value[SAFE_ERROR]);
1759
2116
  }
1760
2117
  const REVALIDATE_HEADER = "X-Revalidate";
2118
+ const RESPONSE_HEADER_VALUE_LIMIT = 4096;
1761
2119
  function initWithRevalidate(init = {}) {
1762
2120
  const resolved = typeof init === "number" ? {
1763
2121
  status: init
@@ -1778,7 +2136,13 @@ function initWithRevalidate(init = {}) {
1778
2136
  } else {
1779
2137
  headers = new Headers(responseInit.headers);
1780
2138
  }
1781
- revalidate !== undefined && headers.set(REVALIDATE_HEADER, revalidate.toString());
2139
+ if (revalidate !== undefined) {
2140
+ const keys = revalidate.toString();
2141
+ if (keys.length > RESPONSE_HEADER_VALUE_LIMIT) {
2142
+ throw new TypeError(`revalidate names ${keys.length} characters of cache keys; past ` + `${RESPONSE_HEADER_VALUE_LIMIT} the ${REVALIDATE_HEADER} header would overflow ` + `receivers (an 8 KiB proxy buffer holds the whole header block) and the response ` + `dies at the socket after the mutation committed. Split the invalidation across ` + `calls or use coarser keys — a dropped key would be a silently stale cache, so ` + `the runtime refuses rather than trims.`);
2143
+ }
2144
+ headers.set(REVALIDATE_HEADER, keys);
2145
+ }
1782
2146
  return {
1783
2147
  responseInit,
1784
2148
  headers
@@ -1795,7 +2159,13 @@ function redirect(url, init = 302) {
1795
2159
  if (responseInit.status === undefined) {
1796
2160
  responseInit.status = 302;
1797
2161
  }
1798
- headers.set("Location", String(url));
2162
+ const target = typeof url === "string" ? url : url[HREF];
2163
+ const location = typeof target === "string" ? target : String(url);
2164
+ const encoded = location.replace(/[^\x00-\x7f]/gu, encodeURIComponent);
2165
+ if (encoded.length > RESPONSE_HEADER_VALUE_LIMIT) {
2166
+ throw new TypeError(`redirect() target is ${encoded.length} characters; past ` + `${RESPONSE_HEADER_VALUE_LIMIT} the Location header (and the scripted transport's ` + `redirect header) would overflow receivers and the response dies at the socket. ` + `A target this size is usually unbounded input echoed into the url — carry the ` + `state server-side instead. Refused rather than trimmed: a cut target is a ` + `different address.`);
2167
+ }
2168
+ headers.set("Location", encoded);
1799
2169
  return new Response(null, {
1800
2170
  ...responseInit,
1801
2171
  headers
@@ -1811,11 +2181,18 @@ function reload(init = {}) {
1811
2181
  headers
1812
2182
  });
1813
2183
  }
2184
+ const NULL_BODY_STATUSES = new Set([204, 205, 304]);
1814
2185
  function respond(value, init = {}) {
1815
2186
  const {
1816
2187
  responseInit,
1817
2188
  headers
1818
2189
  } = initWithRevalidate(init);
2190
+ if (NULL_BODY_STATUSES.has(responseInit.status)) {
2191
+ return new ResponseEnvelope(new Response(null, {
2192
+ ...responseInit,
2193
+ headers
2194
+ }), value);
2195
+ }
1819
2196
  headers.set("Content-Type", "application/json");
1820
2197
  return new ResponseEnvelope(new Response(JSON.stringify(value), {
1821
2198
  ...responseInit,
@@ -1969,4 +2346,4 @@ _moduleUrl) {
1969
2346
  function httpStatus(_code, _text) {}
1970
2347
  function httpHeader(_name, _value, _options) {}
1971
2348
 
1972
- export { ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, HREF, HydrationScript, MathMLElements, Namespaces, Portal, 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, 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 };
2349
+ 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, 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 };