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