@solidjs/web 2.0.0-rc.21 → 2.0.0-rc.22
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/server.dev.js +380 -239
- package/dist/server.js +377 -238
- package/dist/server.observe.js +377 -238
- package/dist/web.dev.js +125 -82
- package/dist/web.js +103 -81
- package/dist/web.observe.js +103 -81
- package/frames/dist/client.dev.js +7 -2
- package/frames/dist/client.js +7 -2
- package/frames/dist/client.observe.js +7 -2
- package/frames/dist/server.dev.js +122 -62
- package/frames/dist/server.js +122 -62
- package/frames/dist/server.observe.js +122 -62
- package/frames/dist/wire.js +1 -1
- package/package.json +2 -2
- package/serialization/dist/serialization.js +5 -4
- package/serialization/types/index.d.ts +8 -1
- package/serialization/types/serializer.d.ts +8 -1
- package/server-functions/dist/client.dev.js +5 -3
- package/server-functions/dist/client.js +5 -3
- package/server-functions/dist/client.observe.js +5 -3
- package/types/client.d.ts +54 -3
- package/types/constants.d.ts +2 -1
- package/types/frames/frame-client.d.ts +2 -0
- package/types/frames/serializer.d.ts +8 -1
- package/types/frames/tree-rewrite.d.ts +7 -0
- package/types/serializer.d.ts +8 -1
- package/types/server-functions/shared.d.ts +3 -2
- package/types/server.d.ts +48 -7
|
@@ -20,7 +20,15 @@ function rewriteTree(value, visit, withPath) {
|
|
|
20
20
|
} catch (err) {
|
|
21
21
|
if (err !== CYCLE) throw err;
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
const memo = state.memo || (state.memo = new Map());
|
|
24
|
+
const marks = {
|
|
25
|
+
at: new Map(),
|
|
26
|
+
stack: [],
|
|
27
|
+
changed: new Set(),
|
|
28
|
+
next: 0
|
|
29
|
+
};
|
|
30
|
+
mark(value, visit, path, memo, marks);
|
|
31
|
+
return clone(value, memo, marks.changed);
|
|
24
32
|
}
|
|
25
33
|
function shape(value) {
|
|
26
34
|
return Array.isArray(value) ? 1 : Object.getPrototypeOf(value) === Object.prototype ? 2 : 0;
|
|
@@ -68,28 +76,73 @@ function cow(value, visit, path, depth, state) {
|
|
|
68
76
|
if (ancestors !== undefined) ancestors.delete(value);
|
|
69
77
|
return out;
|
|
70
78
|
}
|
|
71
|
-
function
|
|
72
|
-
|
|
79
|
+
function mark(value, visit, path, memo, m) {
|
|
80
|
+
const seen = m.at.get(value);
|
|
81
|
+
if (seen !== undefined) return seen;
|
|
82
|
+
if (memo.has(value)) return -1;
|
|
73
83
|
const r = visit(value, path);
|
|
74
84
|
if (r !== DESCEND) {
|
|
75
85
|
memo.set(value, r);
|
|
76
|
-
return
|
|
86
|
+
return -1;
|
|
77
87
|
}
|
|
78
88
|
const s = shape(value);
|
|
79
|
-
if (s === 0) return
|
|
80
|
-
const
|
|
89
|
+
if (s === 0) return -1;
|
|
90
|
+
const index = m.next++;
|
|
91
|
+
let low = index;
|
|
92
|
+
let changed = false;
|
|
93
|
+
let open = false;
|
|
94
|
+
const keys = s === 1 ? value : Object.keys(value);
|
|
95
|
+
for (let i = 0; i < keys.length; i++) {
|
|
96
|
+
const k = s === 1 ? i : keys[i];
|
|
97
|
+
const c = value[k];
|
|
98
|
+
if (c === null || typeof c !== "object") continue;
|
|
99
|
+
if (!open) {
|
|
100
|
+
open = true;
|
|
101
|
+
m.at.set(value, index);
|
|
102
|
+
m.stack.push(value);
|
|
103
|
+
}
|
|
104
|
+
const l = mark(c, visit, path === undefined ? undefined : s === 1 ? `${path}[${k}]` : `${path}.${k}`, memo, m);
|
|
105
|
+
if (l >= 0 && l < low) low = l;
|
|
106
|
+
if (memo.has(c) && memo.get(c) !== c || l === Infinity && m.changed.has(c)) changed = true;
|
|
107
|
+
}
|
|
108
|
+
if (!open) return -1;
|
|
109
|
+
if (low === index) {
|
|
110
|
+
m.at.set(value, Infinity);
|
|
111
|
+
if (m.stack[m.stack.length - 1] === value) {
|
|
112
|
+
m.stack.pop();
|
|
113
|
+
if (changed) m.changed.add(value);
|
|
114
|
+
return Infinity;
|
|
115
|
+
}
|
|
116
|
+
const members = m.stack.splice(m.stack.lastIndexOf(value));
|
|
117
|
+
if (!changed) for (const n of members) if (m.changed.has(n)) {
|
|
118
|
+
changed = true;
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
for (const n of members) {
|
|
122
|
+
m.at.set(n, Infinity);
|
|
123
|
+
if (changed) m.changed.add(n);
|
|
124
|
+
}
|
|
125
|
+
return Infinity;
|
|
126
|
+
}
|
|
127
|
+
if (changed) m.changed.add(value);
|
|
128
|
+
return low;
|
|
129
|
+
}
|
|
130
|
+
function clone(value, memo, changed) {
|
|
131
|
+
if (memo.has(value)) return memo.get(value);
|
|
132
|
+
if (!changed.has(value)) return value;
|
|
133
|
+
const out = Array.isArray(value) ? value.slice() : {
|
|
81
134
|
...value
|
|
82
135
|
};
|
|
83
136
|
memo.set(value, out);
|
|
84
|
-
if (
|
|
137
|
+
if (Array.isArray(value)) {
|
|
85
138
|
for (let i = 0; i < value.length; i++) {
|
|
86
139
|
const c = value[i];
|
|
87
|
-
if (c !== null && typeof c === "object") out[i] = clone(c,
|
|
140
|
+
if (c !== null && typeof c === "object") out[i] = clone(c, memo, changed);
|
|
88
141
|
}
|
|
89
142
|
} else {
|
|
90
143
|
for (const k of Object.keys(value)) {
|
|
91
144
|
const c = value[k];
|
|
92
|
-
if (c !== null && typeof c === "object") out[k] = clone(c,
|
|
145
|
+
if (c !== null && typeof c === "object") out[k] = clone(c, memo, changed);
|
|
93
146
|
}
|
|
94
147
|
}
|
|
95
148
|
return out;
|
|
@@ -255,7 +308,7 @@ function createKeyedSerializer(serialize, onError, onDone) {
|
|
|
255
308
|
stream = serialize(key, value, {
|
|
256
309
|
onError: onError && (err => {
|
|
257
310
|
failed = true;
|
|
258
|
-
onError(err);
|
|
311
|
+
onError(err, key);
|
|
259
312
|
if (cancel) {
|
|
260
313
|
cancel();
|
|
261
314
|
settle();
|
|
@@ -1017,10 +1070,9 @@ function frameStream(makeCode, options) {
|
|
|
1017
1070
|
};
|
|
1018
1071
|
}
|
|
1019
1072
|
function slotRange(occurrence) {
|
|
1020
|
-
return {
|
|
1021
|
-
t: `<!--slot:${occurrence}:start--><!--slot:${occurrence}:end-->`,
|
|
1073
|
+
return Object.assign(markup(`<!--slot:${occurrence}:start--><!--slot:${occurrence}:end-->`), {
|
|
1022
1074
|
$slot: true
|
|
1023
|
-
};
|
|
1075
|
+
});
|
|
1024
1076
|
}
|
|
1025
1077
|
function argBorderForm(value, needs) {
|
|
1026
1078
|
return toBorderForm(noteTraces(value, needs));
|
|
@@ -1157,6 +1209,16 @@ function suppressedFill(render) {
|
|
|
1157
1209
|
live.suppressed--;
|
|
1158
1210
|
}
|
|
1159
1211
|
}
|
|
1212
|
+
const SSR_NODE = Symbol.for("solid.ssrNode");
|
|
1213
|
+
const markup = (t, h, p) => h ? {
|
|
1214
|
+
t,
|
|
1215
|
+
h,
|
|
1216
|
+
p,
|
|
1217
|
+
$: SSR_NODE
|
|
1218
|
+
} : {
|
|
1219
|
+
t,
|
|
1220
|
+
$: SSR_NODE
|
|
1221
|
+
};
|
|
1160
1222
|
let parked = null;
|
|
1161
1223
|
let parkedIds = 0;
|
|
1162
1224
|
const PARKED = /<!--sc-n:(\d+)-->/;
|
|
@@ -1167,9 +1229,7 @@ function park(render) {
|
|
|
1167
1229
|
render,
|
|
1168
1230
|
out: undefined
|
|
1169
1231
|
});
|
|
1170
|
-
return {
|
|
1171
|
-
t: `<!--sc-n:${id}-->`
|
|
1172
|
-
};
|
|
1232
|
+
return markup(`<!--sc-n:${id}-->`);
|
|
1173
1233
|
}
|
|
1174
1234
|
const runParked = (entry, owner) => entry.out || (entry.out = entry.render(owner));
|
|
1175
1235
|
function placeParked(node, nested, owner) {
|
|
@@ -1187,22 +1247,14 @@ function expandParked(node, nested, owner) {
|
|
|
1187
1247
|
if (!node.h) return splitParked(node.t, nested, owner) || node;
|
|
1188
1248
|
const out = [];
|
|
1189
1249
|
node.t.forEach((t, i) => {
|
|
1190
|
-
out.push(splitParked(t, nested, owner) ||
|
|
1191
|
-
|
|
1192
|
-
});
|
|
1193
|
-
if (i < node.h.length) out.push({
|
|
1194
|
-
t: ["", ""],
|
|
1195
|
-
h: [node.h[i]],
|
|
1196
|
-
p: [node.p[i]]
|
|
1197
|
-
});
|
|
1250
|
+
out.push(splitParked(t, nested, owner) || markup(t));
|
|
1251
|
+
if (i < node.h.length) out.push(markup(["", ""], [node.h[i]], [node.p[i]]));
|
|
1198
1252
|
});
|
|
1199
1253
|
return out;
|
|
1200
1254
|
}
|
|
1201
1255
|
function splitParked(t, nested, owner) {
|
|
1202
1256
|
const parts = typeof t === "string" ? t.split(PARKED) : [t];
|
|
1203
|
-
return parts.length > 1 ? parts.map((part, i) => i & 1 ? runParked(nested.get(+part), owner) :
|
|
1204
|
-
t: part
|
|
1205
|
-
}) : undefined;
|
|
1257
|
+
return parts.length > 1 ? parts.map((part, i) => i & 1 ? runParked(nested.get(+part), owner) : markup(part)) : undefined;
|
|
1206
1258
|
}
|
|
1207
1259
|
function createDocumentSlotProps(clientProps, frameId) {
|
|
1208
1260
|
const counts = Object.create(null);
|
|
@@ -1235,11 +1287,7 @@ function createDocumentSlotProps(clientProps, frameId) {
|
|
|
1235
1287
|
const getters = new Map();
|
|
1236
1288
|
const repeats = new Map();
|
|
1237
1289
|
const range = (occurrence, content, tail) => {
|
|
1238
|
-
const r = [{
|
|
1239
|
-
t: `<!--slot:${occurrence}:start-->`
|
|
1240
|
-
}, content, tail, {
|
|
1241
|
-
t: `<!--slot:${occurrence}:end-->`
|
|
1242
|
-
}];
|
|
1290
|
+
const r = [markup(`<!--slot:${occurrence}:start-->`), content, tail, markup(`<!--slot:${occurrence}:end-->`)];
|
|
1243
1291
|
r.$slot = true;
|
|
1244
1292
|
return r;
|
|
1245
1293
|
};
|
|
@@ -1360,11 +1408,7 @@ function createDocumentSlotProps(clientProps, frameId) {
|
|
|
1360
1408
|
resolved[key] = () => {
|
|
1361
1409
|
if (region.locked) return [];
|
|
1362
1410
|
region.used = true;
|
|
1363
|
-
return [
|
|
1364
|
-
t: frameElementOpen(childId)
|
|
1365
|
-
}, region.nested && region.nested.size ? placeParked(value, region.nested, getOwner()) : value, {
|
|
1366
|
-
t: FRAME_ELEMENT_CLOSE
|
|
1367
|
-
}];
|
|
1411
|
+
return [markup(frameElementOpen(childId)), region.nested && region.nested.size ? placeParked(value, region.nested, getOwner()) : value, markup(FRAME_ELEMENT_CLOSE)];
|
|
1368
1412
|
};
|
|
1369
1413
|
} else if (ssrAsyncValue && isAsyncValue(value)) {
|
|
1370
1414
|
let readable = value;
|
|
@@ -1659,9 +1703,7 @@ function frameTransformDirectResult(value, {
|
|
|
1659
1703
|
const address = frameAddress(id, args);
|
|
1660
1704
|
const wrapped = props => {
|
|
1661
1705
|
const siteId = documentSiteId(id);
|
|
1662
|
-
return [
|
|
1663
|
-
t: frameElementOpen(siteId, address.slice(id.length + 1))
|
|
1664
|
-
},
|
|
1706
|
+
return [markup(frameElementOpen(siteId, address.slice(id.length + 1))),
|
|
1665
1707
|
serverOwned(() => {
|
|
1666
1708
|
const page = sharedConfig.context;
|
|
1667
1709
|
armDocumentLiveHoles(page);
|
|
@@ -1677,9 +1719,7 @@ function frameTransformDirectResult(value, {
|
|
|
1677
1719
|
} finally {
|
|
1678
1720
|
sharedConfig.context = page;
|
|
1679
1721
|
}
|
|
1680
|
-
}),
|
|
1681
|
-
t: FRAME_ELEMENT_CLOSE
|
|
1682
|
-
}];
|
|
1722
|
+
}), markup(FRAME_ELEMENT_CLOSE)];
|
|
1683
1723
|
};
|
|
1684
1724
|
wrapped[SERVER_COMPONENT] = id;
|
|
1685
1725
|
wrapped[SERVER_COMPONENT_SOURCE] = component;
|
|
@@ -1822,10 +1862,9 @@ function createSlotProps(sink, frame) {
|
|
|
1822
1862
|
if (repeat) return repeat;
|
|
1823
1863
|
if (sweeping && !live.scope) {
|
|
1824
1864
|
live.gateHit = true;
|
|
1825
|
-
return {
|
|
1826
|
-
t: "",
|
|
1865
|
+
return Object.assign(markup(""), {
|
|
1827
1866
|
$slot: true
|
|
1828
|
-
};
|
|
1867
|
+
});
|
|
1829
1868
|
}
|
|
1830
1869
|
const raw = callArgs[0];
|
|
1831
1870
|
let occurrence = keyedId(prop, raw);
|
|
@@ -2226,25 +2265,23 @@ function snapshot(shared, have) {
|
|
|
2226
2265
|
});
|
|
2227
2266
|
open.r[k] = record;
|
|
2228
2267
|
};
|
|
2229
|
-
|
|
2230
|
-
|
|
2268
|
+
const containers = [];
|
|
2269
|
+
const spliced = new Set();
|
|
2270
|
+
for (const entry of shared.records.values()) {
|
|
2271
|
+
const {
|
|
2231
2272
|
id,
|
|
2232
|
-
version,
|
|
2233
2273
|
k,
|
|
2234
2274
|
record
|
|
2235
|
-
}
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
k
|
|
2245
|
-
record
|
|
2246
|
-
} of shared.records.values()) {
|
|
2247
|
-
if (!k.startsWith("hole:lh:") || k.endsWith(":error") || !record || record.value == null) continue;
|
|
2275
|
+
} = entry;
|
|
2276
|
+
if (id !== shared.id || !record) continue;
|
|
2277
|
+
if (k === "" || /^seg:[^:]+$/.test(k)) {
|
|
2278
|
+
if (typeof record.value === "string") containers.push({
|
|
2279
|
+
e: entry,
|
|
2280
|
+
value: record.value
|
|
2281
|
+
});
|
|
2282
|
+
continue;
|
|
2283
|
+
}
|
|
2284
|
+
if (!k.startsWith("hole:lh:") || k.endsWith(":error") || record.value == null) continue;
|
|
2248
2285
|
const n = k.slice(8);
|
|
2249
2286
|
const startMark = `<!--lh:${n}-->`;
|
|
2250
2287
|
const endMark = `<!--lh:/${n}-->`;
|
|
@@ -2254,9 +2291,32 @@ function snapshot(shared, have) {
|
|
|
2254
2291
|
const end = c.value.indexOf(endMark, start);
|
|
2255
2292
|
if (end < 0) continue;
|
|
2256
2293
|
c.value = c.value.slice(0, start + startMark.length) + record.value + c.value.slice(end);
|
|
2294
|
+
spliced.add(entry);
|
|
2257
2295
|
break;
|
|
2258
2296
|
}
|
|
2259
2297
|
}
|
|
2298
|
+
if (!conditional) {
|
|
2299
|
+
for (const e of shared.records.values()) {
|
|
2300
|
+
const {
|
|
2301
|
+
id,
|
|
2302
|
+
version,
|
|
2303
|
+
k,
|
|
2304
|
+
record
|
|
2305
|
+
} = e;
|
|
2306
|
+
if (spliced.has(e)) continue;
|
|
2307
|
+
const c = containers.find(c => c.e === e);
|
|
2308
|
+
if (c && c.value !== record.value) {
|
|
2309
|
+
const holes = {};
|
|
2310
|
+
if (record.holes) for (const key in record.holes) if (key.startsWith("lha:")) holes[key] = record.holes[key];
|
|
2311
|
+
put(id, version, k, withHoles({
|
|
2312
|
+
...record,
|
|
2313
|
+
value: c.value,
|
|
2314
|
+
digest: k ? textDigest(c.value) : record.digest
|
|
2315
|
+
}, holeDigests(c.value, null, holes)));
|
|
2316
|
+
} else put(id, version, k, record);
|
|
2317
|
+
}
|
|
2318
|
+
return out;
|
|
2319
|
+
}
|
|
2260
2320
|
for (const e of shared.records.values()) {
|
|
2261
2321
|
const {
|
|
2262
2322
|
id,
|
package/frames/dist/wire.js
CHANGED
|
@@ -364,7 +364,7 @@ function connect(response, wire, address, binding, host, bump, begin) {
|
|
|
364
364
|
const dead = error || cancelled || new Error("Frame stream ended before the frame completed.");
|
|
365
365
|
connection.done = true;
|
|
366
366
|
resolveEnd({
|
|
367
|
-
open: open.size,
|
|
367
|
+
open: cancelled !== undefined ? Math.max(open.size, 1) : open.size,
|
|
368
368
|
error: dead,
|
|
369
369
|
sweep: () => {
|
|
370
370
|
for (const [id, version] of open) host.apply({
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solidjs/web",
|
|
3
3
|
"description": "Solid's web runtime: client rendering, hydration, SSR, and DOM-specific control flow (Portal, Dynamic).",
|
|
4
|
-
"version": "2.0.0-rc.
|
|
4
|
+
"version": "2.0.0-rc.22",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://solidjs.com",
|
|
@@ -379,7 +379,7 @@
|
|
|
379
379
|
"seroval-plugins": "1.7.0"
|
|
380
380
|
},
|
|
381
381
|
"peerDependencies": {
|
|
382
|
-
"solid-js": "^2.0.0-rc.
|
|
382
|
+
"solid-js": "^2.0.0-rc.22"
|
|
383
383
|
},
|
|
384
384
|
"devDependencies": {
|
|
385
385
|
"@codspeed/vitest-plugin": "^5.4.0",
|
|
@@ -269,7 +269,7 @@ function createKeyedSerializer(serialize, onError, onDone) {
|
|
|
269
269
|
stream = serialize(key, value, {
|
|
270
270
|
onError: onError && (err => {
|
|
271
271
|
failed = true;
|
|
272
|
-
onError(err);
|
|
272
|
+
onError(err, key);
|
|
273
273
|
if (cancel) {
|
|
274
274
|
cancel();
|
|
275
275
|
settle();
|
|
@@ -342,7 +342,7 @@ function createHydrationSerializer({
|
|
|
342
342
|
});
|
|
343
343
|
return createKeyedSerializer(late ? late(serialize, refs, onData, scopeId) : serialize, onError, onDone);
|
|
344
344
|
}
|
|
345
|
-
function rejectUnserializedKey(serialize, refs, onData, scopeId) {
|
|
345
|
+
function rejectUnserializedKey(serialize, refs, onData, scopeId, plain) {
|
|
346
346
|
let taken = 0;
|
|
347
347
|
let fresh = [];
|
|
348
348
|
const set = refs.set;
|
|
@@ -365,8 +365,9 @@ function rejectUnserializedKey(serialize, refs, onData, scopeId) {
|
|
|
365
365
|
if (ref instanceof Promise) ids.add(id + 1);else if (isStream(ref) || Object.getPrototypeOf(ref) === Object.prototype && !Object.keys(ref).length) ids.add(id);
|
|
366
366
|
}
|
|
367
367
|
if (!ids.size) return;
|
|
368
|
-
const
|
|
369
|
-
const
|
|
368
|
+
const text = plain && plain(key);
|
|
369
|
+
const body = "for(const i of[" + [...ids] + "]){const v=$R[i];v&&(v.f?" + (text === undefined ? "v.f(e)" : "(v.f(e),v.p.s||(v.p.s=2,v.p.v=e))") + ":v.throw&&v.throw(e))}";
|
|
370
|
+
const message = JSON.stringify(text === undefined ? "Serialization failed: the hydration value for key " + JSON.stringify(key) + " could not be serialized on the server" : text).replace(/[<\u2028\u2029]/g, c => KEY_ESCAPES[c]);
|
|
370
371
|
onData("($R=>{const e=new Error(" + message + ");" + body + "})(" + (scopeId == null ? "$R" : '$R["' + serializeKey(scopeId) + '"]') + ")");
|
|
371
372
|
};
|
|
372
373
|
return serialize(key, value, {
|
|
@@ -127,9 +127,16 @@ export declare function createHydrationSerializer(options: HydrationSerializerOp
|
|
|
127
127
|
* reference a slot the client never filled and resolve `undefined`; it
|
|
128
128
|
* parses the value again and fails on its own. seroval takes the next index
|
|
129
129
|
* from `refs.size`, so the size counts every index ever taken.
|
|
130
|
+
*
|
|
131
|
+
* `plain(key)` answers with a message when the failure is the key's own
|
|
132
|
+
* rejection and the renderer sends a plain `Error` in its place (#4709): an
|
|
133
|
+
* `<Errored>` drew its fallback from that error, so the promise is rejected
|
|
134
|
+
* with the message and marked the way seroval marks a rejection. The
|
|
135
|
+
* hydrating read then throws it in the claim pass, against the fallback's
|
|
136
|
+
* markup.
|
|
130
137
|
* @internal
|
|
131
138
|
*/
|
|
132
|
-
export declare function rejectUnserializedKey(serialize: any, refs: any, onData: any, scopeId: any): (key: any, value: any, callbacks: any, live: any) => any; /**
|
|
139
|
+
export declare function rejectUnserializedKey(serialize: any, refs: any, onData: any, scopeId: any, plain: any): (key: any, value: any, callbacks: any, live: any) => any; /**
|
|
133
140
|
* Renderer primitive — returns the cross-reference bootstrap script SSR
|
|
134
141
|
* emits ahead of hydration data for a render scope. Not meant for
|
|
135
142
|
* hand-written code.
|
|
@@ -127,9 +127,16 @@ export declare function createHydrationSerializer(options: HydrationSerializerOp
|
|
|
127
127
|
* reference a slot the client never filled and resolve `undefined`; it
|
|
128
128
|
* parses the value again and fails on its own. seroval takes the next index
|
|
129
129
|
* from `refs.size`, so the size counts every index ever taken.
|
|
130
|
+
*
|
|
131
|
+
* `plain(key)` answers with a message when the failure is the key's own
|
|
132
|
+
* rejection and the renderer sends a plain `Error` in its place (#4709): an
|
|
133
|
+
* `<Errored>` drew its fallback from that error, so the promise is rejected
|
|
134
|
+
* with the message and marked the way seroval marks a rejection. The
|
|
135
|
+
* hydrating read then throws it in the claim pass, against the fallback's
|
|
136
|
+
* markup.
|
|
130
137
|
* @internal
|
|
131
138
|
*/
|
|
132
|
-
export declare function rejectUnserializedKey(serialize: any, refs: any, onData: any, scopeId: any): (key: any, value: any, callbacks: any, live: any) => any; /**
|
|
139
|
+
export declare function rejectUnserializedKey(serialize: any, refs: any, onData: any, scopeId: any, plain: any): (key: any, value: any, callbacks: any, live: any) => any; /**
|
|
133
140
|
* Renderer primitive — returns the cross-reference bootstrap script SSR
|
|
134
141
|
* emits ahead of hydration data for a render scope. Not meant for
|
|
135
142
|
* hand-written code.
|
|
@@ -205,8 +205,8 @@ function hasFlightMetadata(response) {
|
|
|
205
205
|
}
|
|
206
206
|
async function deliverFlightData(response, data) {
|
|
207
207
|
if (data) await Promise.allSettled(Object.values(data).flatMap(s => s && typeof s == "object" ? Object.values(s) : []));
|
|
208
|
-
const folded =
|
|
209
|
-
const metadata = hasFlightMetadata(response);
|
|
208
|
+
const folded = response.headers.get(SINGLE_FLIGHT_HEADER)?.split(",");
|
|
209
|
+
const metadata = !folded || hasFlightMetadata(response);
|
|
210
210
|
for (const source of getFlightDataSourceIds()) {
|
|
211
211
|
if (!metadata && !folded.includes(source)) continue;
|
|
212
212
|
const consumer = getFlightDataConsumer(source);
|
|
@@ -1074,7 +1074,8 @@ async function dispatchServerFunction(base, id, options, args, meta, callArgs =
|
|
|
1074
1074
|
throw serverFunctionFailure(response, undefined);
|
|
1075
1075
|
}
|
|
1076
1076
|
const failed = response.headers.has(ERROR_HEADER);
|
|
1077
|
-
|
|
1077
|
+
const mutation = !isReadCall(options) && getFlightDataSourceIds().length > 0;
|
|
1078
|
+
if (mutation) {
|
|
1078
1079
|
const folded = response.headers.has(SINGLE_FLIGHT_HEADER);
|
|
1079
1080
|
const metadata = hasFlightMetadata(response);
|
|
1080
1081
|
if (metadata || folded) {
|
|
@@ -1098,6 +1099,7 @@ async function dispatchServerFunction(base, id, options, args, meta, callArgs =
|
|
|
1098
1099
|
if (failed) {
|
|
1099
1100
|
throw serverFunctionFailure(response, result);
|
|
1100
1101
|
}
|
|
1102
|
+
if (mutation) await deliverFlightData(response);
|
|
1101
1103
|
if (controller && result?.[Symbol.asyncIterator]) {
|
|
1102
1104
|
return {
|
|
1103
1105
|
[Symbol.asyncIterator]() {
|
|
@@ -98,8 +98,8 @@ function hasFlightMetadata(response) {
|
|
|
98
98
|
}
|
|
99
99
|
async function deliverFlightData(response, data) {
|
|
100
100
|
if (data) await Promise.allSettled(Object.values(data).flatMap(s => s && typeof s == "object" ? Object.values(s) : []));
|
|
101
|
-
const folded =
|
|
102
|
-
const metadata = hasFlightMetadata(response);
|
|
101
|
+
const folded = response.headers.get(SINGLE_FLIGHT_HEADER)?.split(",");
|
|
102
|
+
const metadata = !folded || hasFlightMetadata(response);
|
|
103
103
|
for (const source of getFlightDataSourceIds()) {
|
|
104
104
|
if (!metadata && !folded.includes(source)) continue;
|
|
105
105
|
const consumer = getFlightDataConsumer(source);
|
|
@@ -938,7 +938,8 @@ async function dispatchServerFunction(base, id, options, args, meta, callArgs =
|
|
|
938
938
|
throw serverFunctionFailure(response, undefined);
|
|
939
939
|
}
|
|
940
940
|
const failed = response.headers.has(ERROR_HEADER);
|
|
941
|
-
|
|
941
|
+
const mutation = !isReadCall(options) && getFlightDataSourceIds().length > 0;
|
|
942
|
+
if (mutation) {
|
|
942
943
|
const folded = response.headers.has(SINGLE_FLIGHT_HEADER);
|
|
943
944
|
const metadata = hasFlightMetadata(response);
|
|
944
945
|
if (metadata || folded) {
|
|
@@ -962,6 +963,7 @@ async function dispatchServerFunction(base, id, options, args, meta, callArgs =
|
|
|
962
963
|
if (failed) {
|
|
963
964
|
throw serverFunctionFailure(response, result);
|
|
964
965
|
}
|
|
966
|
+
if (mutation) await deliverFlightData(response);
|
|
965
967
|
if (controller && result?.[Symbol.asyncIterator]) {
|
|
966
968
|
return {
|
|
967
969
|
[Symbol.asyncIterator]() {
|
|
@@ -205,8 +205,8 @@ function hasFlightMetadata(response) {
|
|
|
205
205
|
}
|
|
206
206
|
async function deliverFlightData(response, data) {
|
|
207
207
|
if (data) await Promise.allSettled(Object.values(data).flatMap(s => s && typeof s == "object" ? Object.values(s) : []));
|
|
208
|
-
const folded =
|
|
209
|
-
const metadata = hasFlightMetadata(response);
|
|
208
|
+
const folded = response.headers.get(SINGLE_FLIGHT_HEADER)?.split(",");
|
|
209
|
+
const metadata = !folded || hasFlightMetadata(response);
|
|
210
210
|
for (const source of getFlightDataSourceIds()) {
|
|
211
211
|
if (!metadata && !folded.includes(source)) continue;
|
|
212
212
|
const consumer = getFlightDataConsumer(source);
|
|
@@ -1074,7 +1074,8 @@ async function dispatchServerFunction(base, id, options, args, meta, callArgs =
|
|
|
1074
1074
|
throw serverFunctionFailure(response, undefined);
|
|
1075
1075
|
}
|
|
1076
1076
|
const failed = response.headers.has(ERROR_HEADER);
|
|
1077
|
-
|
|
1077
|
+
const mutation = !isReadCall(options) && getFlightDataSourceIds().length > 0;
|
|
1078
|
+
if (mutation) {
|
|
1078
1079
|
const folded = response.headers.has(SINGLE_FLIGHT_HEADER);
|
|
1079
1080
|
const metadata = hasFlightMetadata(response);
|
|
1080
1081
|
if (metadata || folded) {
|
|
@@ -1098,6 +1099,7 @@ async function dispatchServerFunction(base, id, options, args, meta, callArgs =
|
|
|
1098
1099
|
if (failed) {
|
|
1099
1100
|
throw serverFunctionFailure(response, result);
|
|
1100
1101
|
}
|
|
1102
|
+
if (mutation) await deliverFlightData(response);
|
|
1101
1103
|
if (controller && result?.[Symbol.asyncIterator]) {
|
|
1102
1104
|
return {
|
|
1103
1105
|
[Symbol.asyncIterator]() {
|
package/types/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getOwner, createComponent, untrack, merge as mergeProps } from "solid-js";
|
|
1
|
+
import { getOwner, createComponent, untrack, merge as mergeProps, heldRead } from "solid-js";
|
|
2
2
|
import type { ClientErrorHook, Owner } from "solid-js";
|
|
3
3
|
import { effect, memo } from "./render.js";
|
|
4
4
|
import { JSX } from "./jsx.js";
|
|
@@ -100,6 +100,15 @@ export declare function HydrationScript(_props?: {
|
|
|
100
100
|
eventNames?: string[];
|
|
101
101
|
}): null;
|
|
102
102
|
export { effect, memo, untrack, getOwner, createComponent };
|
|
103
|
+
/**
|
|
104
|
+
* Compiled grouped effects read it after their values: a stateful DOM prop
|
|
105
|
+
* (`value`, `checked`, …) whose value did not change is not written again
|
|
106
|
+
* while the effect is a stale reader of an open hold (#4872). The hold's
|
|
107
|
+
* landing re-runs the effect and writes the bound value.
|
|
108
|
+
*
|
|
109
|
+
* @internal Compiler output only.
|
|
110
|
+
*/
|
|
111
|
+
export { heldRead };
|
|
103
112
|
/**
|
|
104
113
|
* Compiler-emitted prop-spread helper. The JSX transform emits
|
|
105
114
|
* `mergeProps(...)` when compiling prop spreads on components — not a
|
|
@@ -175,6 +184,33 @@ export declare function render(code: () => JSX.Element, element: MountableElemen
|
|
|
175
184
|
*/
|
|
176
185
|
onError?: ClientErrorHook;
|
|
177
186
|
}): () => void;
|
|
187
|
+
/**
|
|
188
|
+
* Sets the Trusted Types policy that HTML is parsed through.
|
|
189
|
+
*
|
|
190
|
+
* A page that enforces `require-trusted-types-for 'script'` rejects a plain
|
|
191
|
+
* string assigned to `innerHTML`. With a policy set, the runtime assigns the
|
|
192
|
+
* `TrustedHTML` that `policy.createHTML(html)` returns. It is asked for two
|
|
193
|
+
* kinds of HTML: the static markup the compiler emitted for a template, and
|
|
194
|
+
* the HTML a server component sends, which the frames client parses. The app
|
|
195
|
+
* creates the policy, so its name and its checks stay under the app's
|
|
196
|
+
* Content Security Policy:
|
|
197
|
+
*
|
|
198
|
+
* ```ts
|
|
199
|
+
* setTrustedTypesPolicy(trustedTypes.createPolicy("my-app", { createHTML: html => html }));
|
|
200
|
+
* ```
|
|
201
|
+
*
|
|
202
|
+
* Call it before the first render. `undefined` goes back to plain strings.
|
|
203
|
+
*/
|
|
204
|
+
export declare function setTrustedTypesPolicy(policy: {
|
|
205
|
+
createHTML(html: string): unknown;
|
|
206
|
+
} | undefined): void;
|
|
207
|
+
/**
|
|
208
|
+
* What a parse assigns to `innerHTML` for `html`: the policy's `TrustedHTML`
|
|
209
|
+
* when `setTrustedTypesPolicy` set one, otherwise the string. Integration
|
|
210
|
+
* plumbing for the frames client, which parses outside this module.
|
|
211
|
+
* @internal
|
|
212
|
+
*/
|
|
213
|
+
export declare function trustedHTML(html: string): string;
|
|
178
214
|
export declare function template(html: string, flag?: 1 | 2): () => Element;
|
|
179
215
|
export declare function delegateEvents(eventNames: string[]): void;
|
|
180
216
|
export declare function registerDelegatedRoot(root: MountableElement): void;
|
|
@@ -215,6 +251,19 @@ export declare function setProperty(node: Element, name: string, value: any): vo
|
|
|
215
251
|
* @internal Compiler output only.
|
|
216
252
|
*/
|
|
217
253
|
export declare function setStatefulProperty(node: Element, name: string, value: any): void;
|
|
254
|
+
/**
|
|
255
|
+
* An event handler expression from dev-compiled DOM output (#1742):
|
|
256
|
+
* `onClick={props.onClick}` compiles to `strictHandler(() => props.onClick)`
|
|
257
|
+
* where production output inlines `props.onClick`. A handler is bound once,
|
|
258
|
+
* where its element is created, so a reactive read in the expression is a
|
|
259
|
+
* mistake: dev warns `STRICT_READ_UNTRACKED` (a pending async read throws
|
|
260
|
+
* `PENDING_ASYNC_UNTRACKED_READ`). The read still tracks, so dev re-mounts
|
|
261
|
+
* on a change exactly as production does. Production compile output never
|
|
262
|
+
* imports it, so it tree-shakes away.
|
|
263
|
+
*
|
|
264
|
+
* @internal Compiler output only.
|
|
265
|
+
*/
|
|
266
|
+
export declare function strictHandler<T>(fn: () => T): T;
|
|
218
267
|
/**
|
|
219
268
|
* Options for `registerElementClaim`.
|
|
220
269
|
* @internal
|
|
@@ -275,8 +324,8 @@ export declare function style(node: Element, value: {
|
|
|
275
324
|
* read per key; a clsx-style class array is re-mapped element-wise (className
|
|
276
325
|
* allocates for an array anyway; measured at parity).
|
|
277
326
|
*
|
|
278
|
-
* The proxy's keys are read with `Reflect.ownKeys` directly —
|
|
279
|
-
* `sourceKeys(value, SOURCE_PROXY)`
|
|
327
|
+
* The proxy's keys are read with `Reflect.ownKeys` directly — the keys
|
|
328
|
+
* `sourceKeys(value, SOURCE_PROXY)` returns by definition (`leafOf` is
|
|
280
329
|
* the identity for a proxy kind; `leafKeys` answers a proxy with one
|
|
281
330
|
* `ownKeys` trap) — rather than through `sourceKeys`, whose kind argument is
|
|
282
331
|
* a runtime value: calling it here retained the merge/omit view walkers
|
|
@@ -294,6 +343,8 @@ export declare function applyRef<T extends Element = Element>(r: ((element: NoIn
|
|
|
294
343
|
export declare function ref(fn: () => ((element: Element) => void) | ((element: Element) => void)[], element: Element): void;
|
|
295
344
|
/** Compiler-emitted primitive; not for hand-written code. @internal */
|
|
296
345
|
export declare function scope<T extends () => any>(fn: T): T;
|
|
346
|
+
/** Integration plumbing for Portal. @internal */
|
|
347
|
+
export declare function installHostTagging(): void;
|
|
297
348
|
export declare function installHydrationRuntime(): void;
|
|
298
349
|
/**
|
|
299
350
|
* Compiler-emitted primitive; not for hand-written code.
|
package/types/constants.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ declare const DOMWithState: Record<string, Record<string, 1 | 2>>;
|
|
|
8
8
|
declare const ChildProperties: Set<string>;
|
|
9
9
|
declare const LinkAttributes: Set<string>;
|
|
10
10
|
declare const $$SLOT: unique symbol;
|
|
11
|
+
declare const $$INDEX: unique symbol;
|
|
11
12
|
declare const $$HOST: unique symbol;
|
|
12
13
|
declare const DelegatedEvents: Set<string>;
|
|
13
14
|
declare const SVGElements: Set<string>;
|
|
@@ -19,4 +20,4 @@ declare const DOMElements: Set<string>;
|
|
|
19
20
|
declare const COMPOSED_BODY_FRAMING: ReadonlySet<string>;
|
|
20
21
|
declare function isHttpNavigationTarget(target: string): boolean;
|
|
21
22
|
declare function isEventName(name: string): boolean;
|
|
22
|
-
export { DOMWithState, ChildProperties, LinkAttributes, DelegatedEvents, SVGElements, MathMLElements, VoidElements, RawTextElements, Namespaces, DOMElements, $$SLOT, $$HOST, COMPOSED_BODY_FRAMING, isHttpNavigationTarget, isEventName };
|
|
23
|
+
export { DOMWithState, ChildProperties, LinkAttributes, DelegatedEvents, SVGElements, MathMLElements, VoidElements, RawTextElements, Namespaces, DOMElements, $$SLOT, $$INDEX, $$HOST, COMPOSED_BODY_FRAMING, isHttpNavigationTarget, isEventName };
|
|
@@ -500,6 +500,8 @@ export declare function makeFrameElement(id: any): HTMLElement;
|
|
|
500
500
|
/** Whether `node` is a frame boundary/region element (carries our id attr).
|
|
501
501
|
* @internal */
|
|
502
502
|
export declare function isFrameElement(node: any): any;
|
|
503
|
+
/** @internal */
|
|
504
|
+
export declare function setTrustedHTML(wrap: ((html: string) => unknown) | undefined): void;
|
|
503
505
|
/** Parse an HTML string into a document fragment, preserving comments. */
|
|
504
506
|
export declare function parseFragment(html: any): DocumentFragment;
|
|
505
507
|
/** The `<!--pl-KEY-->` comment closing a placeholder range, or null. */
|
|
@@ -127,9 +127,16 @@ export declare function createHydrationSerializer(options: HydrationSerializerOp
|
|
|
127
127
|
* reference a slot the client never filled and resolve `undefined`; it
|
|
128
128
|
* parses the value again and fails on its own. seroval takes the next index
|
|
129
129
|
* from `refs.size`, so the size counts every index ever taken.
|
|
130
|
+
*
|
|
131
|
+
* `plain(key)` answers with a message when the failure is the key's own
|
|
132
|
+
* rejection and the renderer sends a plain `Error` in its place (#4709): an
|
|
133
|
+
* `<Errored>` drew its fallback from that error, so the promise is rejected
|
|
134
|
+
* with the message and marked the way seroval marks a rejection. The
|
|
135
|
+
* hydrating read then throws it in the claim pass, against the fallback's
|
|
136
|
+
* markup.
|
|
130
137
|
* @internal
|
|
131
138
|
*/
|
|
132
|
-
export declare function rejectUnserializedKey(serialize: any, refs: any, onData: any, scopeId: any): (key: any, value: any, callbacks: any, live: any) => any; /**
|
|
139
|
+
export declare function rejectUnserializedKey(serialize: any, refs: any, onData: any, scopeId: any, plain: any): (key: any, value: any, callbacks: any, live: any) => any; /**
|
|
133
140
|
* Renderer primitive — returns the cross-reference bootstrap script SSR
|
|
134
141
|
* emits ahead of hydration data for a render scope. Not meant for
|
|
135
142
|
* hand-written code.
|
|
@@ -26,6 +26,13 @@
|
|
|
26
26
|
* the first pass — a cycle revisits its nodes on every level down to the
|
|
27
27
|
* catch — and every node of the clone pass answer from the record, so a
|
|
28
28
|
* visitor's side effects run once per node whichever way the walk went.
|
|
29
|
+
* The clone pass is copy-on-write too (#4846): it first marks, a strongly
|
|
30
|
+
* connected component at a time, the containers a replacement is reachable
|
|
31
|
+
* from, and copies only those. A subtree with nothing to replace keeps its
|
|
32
|
+
* identity on the cyclic path as on the acyclic one, so a value the
|
|
33
|
+
* serializer also writes in another record (an async memo's answer a store
|
|
34
|
+
* holds) stays one reference, and a cycle with nothing to replace comes
|
|
35
|
+
* back as itself.
|
|
29
36
|
* Walks that replace nothing never pay the lookup. A value reachable at two
|
|
30
37
|
* paths is one node: its replacement is shared (one seat for one iterable —
|
|
31
38
|
* the identity the input had, which the serializer writes once and the
|
package/types/serializer.d.ts
CHANGED
|
@@ -127,9 +127,16 @@ export declare function createHydrationSerializer(options: HydrationSerializerOp
|
|
|
127
127
|
* reference a slot the client never filled and resolve `undefined`; it
|
|
128
128
|
* parses the value again and fails on its own. seroval takes the next index
|
|
129
129
|
* from `refs.size`, so the size counts every index ever taken.
|
|
130
|
+
*
|
|
131
|
+
* `plain(key)` answers with a message when the failure is the key's own
|
|
132
|
+
* rejection and the renderer sends a plain `Error` in its place (#4709): an
|
|
133
|
+
* `<Errored>` drew its fallback from that error, so the promise is rejected
|
|
134
|
+
* with the message and marked the way seroval marks a rejection. The
|
|
135
|
+
* hydrating read then throws it in the claim pass, against the fallback's
|
|
136
|
+
* markup.
|
|
130
137
|
* @internal
|
|
131
138
|
*/
|
|
132
|
-
export declare function rejectUnserializedKey(serialize: any, refs: any, onData: any, scopeId: any): (key: any, value: any, callbacks: any, live: any) => any; /**
|
|
139
|
+
export declare function rejectUnserializedKey(serialize: any, refs: any, onData: any, scopeId: any, plain: any): (key: any, value: any, callbacks: any, live: any) => any; /**
|
|
133
140
|
* Renderer primitive — returns the cross-reference bootstrap script SSR
|
|
134
141
|
* emits ahead of hydration data for a render scope. Not meant for
|
|
135
142
|
* hand-written code.
|