@solidjs/web 2.0.0-rc.21 → 2.0.0-rc.23
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 +403 -242
- package/dist/server.js +400 -241
- package/dist/server.observe.js +400 -241
- package/dist/web.dev.js +140 -100
- package/dist/web.js +118 -99
- package/dist/web.observe.js +118 -99
- 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 +6 -5
- 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 +16 -7
- package/server-functions/dist/client.js +16 -7
- package/server-functions/dist/client.observe.js +16 -7
- package/server-functions/dist/server.dev.js +20 -38
- package/server-functions/dist/server.js +20 -38
- package/server-functions/dist/server.observe.js +20 -38
- package/types/client.d.ts +54 -2
- 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
- package/types/trace.d.ts +18 -0
package/dist/server.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createRenderEffect, createMemo, getOwner, createRoot, $PROXY,
|
|
1
|
+
import { createRenderEffect, createMemo, getOwner, createRoot, $PROXY, runWithOwner, createOwner, onCleanup, createComponent, omit, getNextChildId } from 'solid-js';
|
|
2
2
|
export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, dynamicComponent, getOwner, merge as mergeProps, untrack } from 'solid-js';
|
|
3
3
|
import { sharedConfig, ssrSanitizeError, beginEdgesRender, reportServerError, viewOf, sourceOwners, ssrHandleError, inServerComponentScope, creationStamp, dynamicCore, getProjectionTrace, shareAsyncIterable } from 'solid-js/internal';
|
|
4
4
|
export { ssrScope as scope } from 'solid-js/internal';
|
|
@@ -255,6 +255,24 @@ function traceMetaMarkup(record) {
|
|
|
255
255
|
}
|
|
256
256
|
return markup;
|
|
257
257
|
}
|
|
258
|
+
function sharedCacheMayStore(cacheControl, cdnCacheControl) {
|
|
259
|
+
return mayStore(cacheControl, true) || mayStore(cdnCacheControl, false);
|
|
260
|
+
}
|
|
261
|
+
const DIRECTIVE = /([^\s=,]+)\s*(=\s*(?:"(?:[^"\\]|\\.)*"?|[^,]*))?/g;
|
|
262
|
+
function mayStore(value, asks) {
|
|
263
|
+
if (value === null) return false;
|
|
264
|
+
let shared = !asks;
|
|
265
|
+
for (const [, directive, argument] of value.matchAll(DIRECTIVE)) {
|
|
266
|
+
const name = directive.toLowerCase();
|
|
267
|
+
if (name === "no-store" || name === "private" && !argument) return false;
|
|
268
|
+
if (name === "public" || name === "s-maxage") shared = true;
|
|
269
|
+
}
|
|
270
|
+
return shared;
|
|
271
|
+
}
|
|
272
|
+
function withholdForSharedCache(record, event) {
|
|
273
|
+
const headers = event && event.response && event.response.headers;
|
|
274
|
+
if (record.emit && headers && sharedCacheMayStore(headers.get("Cache-Control"), headers.get("CDN-Cache-Control"))) record.emit = false;
|
|
275
|
+
}
|
|
258
276
|
|
|
259
277
|
const DESCEND = Symbol("descend");
|
|
260
278
|
const CYCLE = {};
|
|
@@ -271,7 +289,15 @@ function rewriteTree(value, visit, withPath) {
|
|
|
271
289
|
} catch (err) {
|
|
272
290
|
if (err !== CYCLE) throw err;
|
|
273
291
|
}
|
|
274
|
-
|
|
292
|
+
const memo = state.memo || (state.memo = new Map());
|
|
293
|
+
const marks = {
|
|
294
|
+
at: new Map(),
|
|
295
|
+
stack: [],
|
|
296
|
+
changed: new Set(),
|
|
297
|
+
next: 0
|
|
298
|
+
};
|
|
299
|
+
mark(value, visit, path, memo, marks);
|
|
300
|
+
return clone(value, memo, marks.changed);
|
|
275
301
|
}
|
|
276
302
|
function shape(value) {
|
|
277
303
|
return Array.isArray(value) ? 1 : Object.getPrototypeOf(value) === Object.prototype ? 2 : 0;
|
|
@@ -319,28 +345,73 @@ function cow(value, visit, path, depth, state) {
|
|
|
319
345
|
if (ancestors !== undefined) ancestors.delete(value);
|
|
320
346
|
return out;
|
|
321
347
|
}
|
|
322
|
-
function
|
|
323
|
-
|
|
348
|
+
function mark(value, visit, path, memo, m) {
|
|
349
|
+
const seen = m.at.get(value);
|
|
350
|
+
if (seen !== undefined) return seen;
|
|
351
|
+
if (memo.has(value)) return -1;
|
|
324
352
|
const r = visit(value, path);
|
|
325
353
|
if (r !== DESCEND) {
|
|
326
354
|
memo.set(value, r);
|
|
327
|
-
return
|
|
355
|
+
return -1;
|
|
328
356
|
}
|
|
329
357
|
const s = shape(value);
|
|
330
|
-
if (s === 0) return
|
|
331
|
-
const
|
|
358
|
+
if (s === 0) return -1;
|
|
359
|
+
const index = m.next++;
|
|
360
|
+
let low = index;
|
|
361
|
+
let changed = false;
|
|
362
|
+
let open = false;
|
|
363
|
+
const keys = s === 1 ? value : Object.keys(value);
|
|
364
|
+
for (let i = 0; i < keys.length; i++) {
|
|
365
|
+
const k = s === 1 ? i : keys[i];
|
|
366
|
+
const c = value[k];
|
|
367
|
+
if (c === null || typeof c !== "object") continue;
|
|
368
|
+
if (!open) {
|
|
369
|
+
open = true;
|
|
370
|
+
m.at.set(value, index);
|
|
371
|
+
m.stack.push(value);
|
|
372
|
+
}
|
|
373
|
+
const l = mark(c, visit, undefined , memo, m);
|
|
374
|
+
if (l >= 0 && l < low) low = l;
|
|
375
|
+
if (memo.has(c) && memo.get(c) !== c || l === Infinity && m.changed.has(c)) changed = true;
|
|
376
|
+
}
|
|
377
|
+
if (!open) return -1;
|
|
378
|
+
if (low === index) {
|
|
379
|
+
m.at.set(value, Infinity);
|
|
380
|
+
if (m.stack[m.stack.length - 1] === value) {
|
|
381
|
+
m.stack.pop();
|
|
382
|
+
if (changed) m.changed.add(value);
|
|
383
|
+
return Infinity;
|
|
384
|
+
}
|
|
385
|
+
const members = m.stack.splice(m.stack.lastIndexOf(value));
|
|
386
|
+
if (!changed) for (const n of members) if (m.changed.has(n)) {
|
|
387
|
+
changed = true;
|
|
388
|
+
break;
|
|
389
|
+
}
|
|
390
|
+
for (const n of members) {
|
|
391
|
+
m.at.set(n, Infinity);
|
|
392
|
+
if (changed) m.changed.add(n);
|
|
393
|
+
}
|
|
394
|
+
return Infinity;
|
|
395
|
+
}
|
|
396
|
+
if (changed) m.changed.add(value);
|
|
397
|
+
return low;
|
|
398
|
+
}
|
|
399
|
+
function clone(value, memo, changed) {
|
|
400
|
+
if (memo.has(value)) return memo.get(value);
|
|
401
|
+
if (!changed.has(value)) return value;
|
|
402
|
+
const out = Array.isArray(value) ? value.slice() : {
|
|
332
403
|
...value
|
|
333
404
|
};
|
|
334
405
|
memo.set(value, out);
|
|
335
|
-
if (
|
|
406
|
+
if (Array.isArray(value)) {
|
|
336
407
|
for (let i = 0; i < value.length; i++) {
|
|
337
408
|
const c = value[i];
|
|
338
|
-
if (c !== null && typeof c === "object") out[i] = clone(c,
|
|
409
|
+
if (c !== null && typeof c === "object") out[i] = clone(c, memo, changed);
|
|
339
410
|
}
|
|
340
411
|
} else {
|
|
341
412
|
for (const k of Object.keys(value)) {
|
|
342
413
|
const c = value[k];
|
|
343
|
-
if (c !== null && typeof c === "object") out[k] = clone(c,
|
|
414
|
+
if (c !== null && typeof c === "object") out[k] = clone(c, memo, changed);
|
|
344
415
|
}
|
|
345
416
|
}
|
|
346
417
|
return out;
|
|
@@ -480,7 +551,7 @@ function createKeyedSerializer(serialize, onError, onDone) {
|
|
|
480
551
|
stream = serialize(key, value, {
|
|
481
552
|
onError: onError && (err => {
|
|
482
553
|
failed = true;
|
|
483
|
-
onError(err);
|
|
554
|
+
onError(err, key);
|
|
484
555
|
if (cancel) {
|
|
485
556
|
cancel();
|
|
486
557
|
settle();
|
|
@@ -553,7 +624,7 @@ function createHydrationSerializer({
|
|
|
553
624
|
});
|
|
554
625
|
return createKeyedSerializer(late ? late(serialize, refs, onData, scopeId) : serialize, onError, onDone);
|
|
555
626
|
}
|
|
556
|
-
function rejectUnserializedKey(serialize, refs, onData, scopeId) {
|
|
627
|
+
function rejectUnserializedKey(serialize, refs, onData, scopeId, plain) {
|
|
557
628
|
let taken = 0;
|
|
558
629
|
let fresh = [];
|
|
559
630
|
const set = refs.set;
|
|
@@ -576,8 +647,9 @@ function rejectUnserializedKey(serialize, refs, onData, scopeId) {
|
|
|
576
647
|
if (ref instanceof Promise) ids.add(id + 1);else if (isStream(ref) || Object.getPrototypeOf(ref) === Object.prototype && !Object.keys(ref).length) ids.add(id);
|
|
577
648
|
}
|
|
578
649
|
if (!ids.size) return;
|
|
579
|
-
const
|
|
580
|
-
const
|
|
650
|
+
const text = plain && plain(key);
|
|
651
|
+
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))}";
|
|
652
|
+
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]);
|
|
581
653
|
onData("($R=>{const e=new Error(" + message + ");" + body + "})(" + (scopeId == null ? "$R" : '$R["' + serializeKey(scopeId) + '"]') + ")");
|
|
582
654
|
};
|
|
583
655
|
return serialize(key, value, {
|
|
@@ -1080,6 +1152,7 @@ function isSetAttr(value) {
|
|
|
1080
1152
|
return value != null && value !== false && value !== "";
|
|
1081
1153
|
}
|
|
1082
1154
|
const PRELOAD_LINK_ATTRIBUTES = ["type", "crossorigin", "integrity", "referrerpolicy", "fetchpriority", "media", "imagesrcset", "imagesizes"];
|
|
1155
|
+
const SSR_NODE = /*#__PURE__*/Symbol.for("solid.ssrNode");
|
|
1083
1156
|
function registerPreloadLink(tracking, headRegistry, link, nonce) {
|
|
1084
1157
|
if (!link || typeof link !== "object") {
|
|
1085
1158
|
return null;
|
|
@@ -1610,7 +1683,8 @@ function tagInfo(tag) {
|
|
|
1610
1683
|
textarea: tag === "textarea",
|
|
1611
1684
|
raw: tag === "script" || tag === "style",
|
|
1612
1685
|
formDefaults,
|
|
1613
|
-
formAttributes
|
|
1686
|
+
formAttributes,
|
|
1687
|
+
sel: tag === "select" ? 1 : tag === "option" ? 2 : 0
|
|
1614
1688
|
};
|
|
1615
1689
|
if (tagInfos.size < 512) tagInfos.set(tag, info);
|
|
1616
1690
|
}
|
|
@@ -1711,8 +1785,9 @@ function renderToString(code, options = {}) {
|
|
|
1711
1785
|
serializeFragmentAssets("", tracking.boundaryModules, sharedConfig.context, renderId);
|
|
1712
1786
|
closed = true;
|
|
1713
1787
|
serializer.close();
|
|
1788
|
+
withholdForSharedCache(context.trace, requestEvent);
|
|
1714
1789
|
const head = renderShellHead(headRegistry, nonce, null, noScripts, traceMetaMarkup(context.trace));
|
|
1715
|
-
const document = withShellEnd(assembleDocument(
|
|
1790
|
+
const document = withShellEnd(assembleDocument(html, tracking.emittedAssets, tracking.preloadLinks, tracking.inlineStyles, scripts.length ? scripts : "", nonce, head, onHead, tracking.lowModules), context, renderId, nonce, noScripts);
|
|
1716
1791
|
if (render) render.shell();
|
|
1717
1792
|
if (requestEvent && requestEvent.response) {
|
|
1718
1793
|
commitResponseStub(requestEvent.response, {
|
|
@@ -1788,7 +1863,8 @@ function renderToStream(code, options = {}) {
|
|
|
1788
1863
|
if (render) settleRender(render, rootOwner, disconnect ? "abandoned" : "error");
|
|
1789
1864
|
const sink = writable;
|
|
1790
1865
|
buffer = {
|
|
1791
|
-
write() {}
|
|
1866
|
+
write() {},
|
|
1867
|
+
flush() {}
|
|
1792
1868
|
};
|
|
1793
1869
|
writable = {
|
|
1794
1870
|
end() {}
|
|
@@ -1872,24 +1948,64 @@ function renderToStream(code, options = {}) {
|
|
|
1872
1948
|
let stableOrder = false;
|
|
1873
1949
|
let parkedWrites = null;
|
|
1874
1950
|
const byKey = (a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0;
|
|
1875
|
-
let writing = 0;
|
|
1876
1951
|
let stranded = false;
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1952
|
+
let writingRecord = false;
|
|
1953
|
+
let recordFailed = false;
|
|
1954
|
+
const plainRecords = new WeakMap();
|
|
1955
|
+
const caught = new Set();
|
|
1956
|
+
let unclaimed = null;
|
|
1957
|
+
const rejected = new Map();
|
|
1958
|
+
const plainMessage = (id, value) => value != null && typeof value.message === "string" ? value.message : `The error record for key ${JSON.stringify(id)} could not be serialized on the server`;
|
|
1959
|
+
const plainFor = (id, value) => {
|
|
1960
|
+
const keyed = value !== null && typeof value === "object";
|
|
1961
|
+
let plain = keyed && plainRecords.get(value);
|
|
1962
|
+
if (!plain) {
|
|
1963
|
+
plain = new Error(plainMessage(id, value));
|
|
1964
|
+
if (keyed) plainRecords.set(value, plain);
|
|
1965
|
+
}
|
|
1966
|
+
return plain;
|
|
1967
|
+
};
|
|
1968
|
+
const claim = () => {
|
|
1969
|
+
if (unclaimed) {
|
|
1970
|
+
for (const reason of unclaimed) if (!caught.has(reason)) stranded = true;
|
|
1971
|
+
unclaimed = null;
|
|
1972
|
+
}
|
|
1973
|
+
return stranded;
|
|
1974
|
+
};
|
|
1975
|
+
const claimLater = reason => {
|
|
1976
|
+
if (firstFlushed || stranded || caught.has(reason)) return;
|
|
1977
|
+
if (!unclaimed) {
|
|
1978
|
+
unclaimed = new Set();
|
|
1979
|
+
deferFlush(() => {
|
|
1980
|
+
if (!rootHoles && claim()) abandon();
|
|
1981
|
+
});
|
|
1982
|
+
}
|
|
1983
|
+
unclaimed.add(reason);
|
|
1984
|
+
};
|
|
1985
|
+
const handOver = (id, value, error) => {
|
|
1986
|
+
if (!error || options.serializer) return serializer.write(id, value);
|
|
1987
|
+
let plain = value !== null && typeof value === "object" && plainRecords.get(value);
|
|
1988
|
+
if (!plain) {
|
|
1989
|
+
recordFailed = false;
|
|
1990
|
+
writingRecord = true;
|
|
1991
|
+
try {
|
|
1992
|
+
serializer.write(id, value);
|
|
1993
|
+
} finally {
|
|
1994
|
+
writingRecord = false;
|
|
1995
|
+
}
|
|
1996
|
+
if (!recordFailed) return;
|
|
1997
|
+
plain = plainFor(id, value);
|
|
1883
1998
|
}
|
|
1999
|
+
serializer.write(id, plain);
|
|
1884
2000
|
};
|
|
1885
|
-
const write = (id, value) => {
|
|
1886
|
-
if (stableOrder && !dead) (parkedWrites ||= []).push([id, value]);else handOver(id, value);
|
|
2001
|
+
const write = (id, value, error) => {
|
|
2002
|
+
if (stableOrder && !dead) (parkedWrites ||= []).push([id, value, error]);else handOver(id, value, error);
|
|
1887
2003
|
};
|
|
1888
2004
|
const flushParkedWrites = () => {
|
|
1889
2005
|
if (!parkedWrites) return;
|
|
1890
2006
|
const writes = parkedWrites.sort(byKey);
|
|
1891
2007
|
parkedWrites = null;
|
|
1892
|
-
for (let i = 0; i < writes.length; i++) handOver(writes[i][0], writes[i][1]);
|
|
2008
|
+
for (let i = 0; i < writes.length; i++) handOver(writes[i][0], writes[i][1], writes[i][2]);
|
|
1893
2009
|
};
|
|
1894
2010
|
const flushStubBatch = () => {
|
|
1895
2011
|
if (!stubBatch) return;
|
|
@@ -1914,7 +2030,7 @@ function renderToStream(code, options = {}) {
|
|
|
1914
2030
|
const onDone = () => {
|
|
1915
2031
|
if (dead) return;
|
|
1916
2032
|
writeTasks();
|
|
1917
|
-
if (
|
|
2033
|
+
if (claim()) return abandon();
|
|
1918
2034
|
lastBlockingSize = blockingPromises.size;
|
|
1919
2035
|
doShell();
|
|
1920
2036
|
onCompleteAll && onCompleteAll({
|
|
@@ -1977,11 +2093,19 @@ function renderToStream(code, options = {}) {
|
|
|
1977
2093
|
plugins: options.plugins,
|
|
1978
2094
|
onData: payload => sink.data(payload),
|
|
1979
2095
|
onDone,
|
|
1980
|
-
onError: err => {
|
|
1981
|
-
|
|
1982
|
-
|
|
2096
|
+
onError: (err, key) => {
|
|
2097
|
+
const rejection = !options.serializer && !writingRecord && rejected.has(key);
|
|
2098
|
+
const reason = rejection && rejected.get(key);
|
|
2099
|
+
if (!rejection || reason === null || typeof reason !== "object" || !plainRecords.has(reason)) reportFailure(err, "serialize");
|
|
2100
|
+
if (writingRecord) recordFailed = true;else if (rejection) {
|
|
2101
|
+
plainFor(key, reason);
|
|
2102
|
+
claimLater(reason);
|
|
2103
|
+
} else if (!options.serializer && !firstFlushed && !stranded) {
|
|
2104
|
+
stranded = true;
|
|
2105
|
+
deferFlush(() => abandon());
|
|
2106
|
+
}
|
|
1983
2107
|
},
|
|
1984
|
-
late: rejectUnserializedKey
|
|
2108
|
+
late: (serialize, refs, onData, scopeId) => rejectUnserializedKey(serialize, refs, onData, scopeId, key => !firstFlushed && rejected.has(key) ? plainMessage(key, rejected.get(key)) : undefined)
|
|
1985
2109
|
});
|
|
1986
2110
|
let rootAssetsSerialized = false;
|
|
1987
2111
|
const serializeRootAssets = () => {
|
|
@@ -2060,7 +2184,10 @@ function renderToStream(code, options = {}) {
|
|
|
2060
2184
|
raced.catch(() => {});
|
|
2061
2185
|
pendingSerialized.set(id, settle);
|
|
2062
2186
|
const drop = () => pendingSerialized.delete(id);
|
|
2063
|
-
p.then(drop,
|
|
2187
|
+
p.then(drop, reason => {
|
|
2188
|
+
drop();
|
|
2189
|
+
rejected.set(id, reason);
|
|
2190
|
+
});
|
|
2064
2191
|
return raced;
|
|
2065
2192
|
};
|
|
2066
2193
|
const abandonSubtree = (key, error) => {
|
|
@@ -2207,12 +2334,17 @@ function renderToStream(code, options = {}) {
|
|
|
2207
2334
|
const last = html.indexOf(`<!--!$/${id}-->`, first + placeholder.length);
|
|
2208
2335
|
html = html.slice(0, first) + resolveSSRSync(escape(payloadFn())) + html.slice(last + placeholder.length + 1);
|
|
2209
2336
|
},
|
|
2210
|
-
serialize(id, p, deferStream) {
|
|
2337
|
+
serialize(id, p, deferStream, errorRecord) {
|
|
2211
2338
|
p = guardChannel(p);
|
|
2212
2339
|
if (p && typeof p === "object" && typeof p.then === "function") {
|
|
2213
2340
|
if (!firstFlushed && deferStream) {
|
|
2214
2341
|
blockingPromises.add(p);
|
|
2215
|
-
p.then(d => write(id, d)).catch(e =>
|
|
2342
|
+
p.then(d => write(id, d)).catch(e => {
|
|
2343
|
+
rejected.set(id, e);
|
|
2344
|
+
const r = Promise.reject(e);
|
|
2345
|
+
r.catch(() => {});
|
|
2346
|
+
write(id, r);
|
|
2347
|
+
});
|
|
2216
2348
|
return;
|
|
2217
2349
|
}
|
|
2218
2350
|
p = trackSerialized(id, p);
|
|
@@ -2221,7 +2353,7 @@ function renderToStream(code, options = {}) {
|
|
|
2221
2353
|
return;
|
|
2222
2354
|
}
|
|
2223
2355
|
}
|
|
2224
|
-
write(id, p);
|
|
2356
|
+
write(id, p, errorRecord);
|
|
2225
2357
|
},
|
|
2226
2358
|
escape: escape,
|
|
2227
2359
|
resolve: resolveSSRNode,
|
|
@@ -2295,7 +2427,7 @@ function renderToStream(code, options = {}) {
|
|
|
2295
2427
|
const styles = collectStreamStyles(key, tracking, headStyles);
|
|
2296
2428
|
const headOps = error ? null : flushHeadFragment(headRegistry, key, nonce);
|
|
2297
2429
|
if (headOps) emitHeadOps(key, headOps);
|
|
2298
|
-
sink.fragment(key,
|
|
2430
|
+
sink.fragment(key, value !== undefined ? value : error ? "" : " ", {
|
|
2299
2431
|
styles,
|
|
2300
2432
|
revealGroup,
|
|
2301
2433
|
error: error ? ssrSanitizeError(error, null, undefined, undefined, errorScope) : error
|
|
@@ -2326,6 +2458,10 @@ function renderToStream(code, options = {}) {
|
|
|
2326
2458
|
context.failRender = failRender;
|
|
2327
2459
|
context.errorPolicy = options.onError;
|
|
2328
2460
|
context._errorScope = errorScope;
|
|
2461
|
+
context.contained = (error, wire) => {
|
|
2462
|
+
caught.add(error);
|
|
2463
|
+
caught.add(wire);
|
|
2464
|
+
};
|
|
2329
2465
|
context.flushed = () => firstFlushed;
|
|
2330
2466
|
context.trace = requestEvent ? traceForEvent(requestEvent) : traceFor(context, undefined);
|
|
2331
2467
|
render = timeDocument(context, context.trace);
|
|
@@ -2441,9 +2577,10 @@ function renderToStream(code, options = {}) {
|
|
|
2441
2577
|
}
|
|
2442
2578
|
serializeRootAssets();
|
|
2443
2579
|
flushStubBatch();
|
|
2580
|
+
withholdForSharedCache(context.trace, requestEvent);
|
|
2444
2581
|
const head = renderShellHead(headRegistry, nonce, k => registry.has(k), noScripts, traceMetaMarkup(context.trace));
|
|
2445
2582
|
if (render) render.shell();
|
|
2446
|
-
sink.shell(
|
|
2583
|
+
sink.shell(html, {
|
|
2447
2584
|
preloads: tracking.emittedAssets,
|
|
2448
2585
|
preloadLinks: tracking.preloadLinks,
|
|
2449
2586
|
inlineStyles: tracking.inlineStyles,
|
|
@@ -2519,7 +2656,7 @@ function renderToStream(code, options = {}) {
|
|
|
2519
2656
|
return;
|
|
2520
2657
|
}
|
|
2521
2658
|
if (!shellCompleted) return flush();
|
|
2522
|
-
if (
|
|
2659
|
+
if (claim()) return abandon();
|
|
2523
2660
|
const encoder = new TextEncoder();
|
|
2524
2661
|
const writer = w.getWriter();
|
|
2525
2662
|
let pendingWrites = Promise.resolve();
|
|
@@ -2619,7 +2756,7 @@ function renderToStream(code, options = {}) {
|
|
|
2619
2756
|
return;
|
|
2620
2757
|
}
|
|
2621
2758
|
if (!shellCompleted) return flush();
|
|
2622
|
-
if (
|
|
2759
|
+
if (claim()) return abandon();
|
|
2623
2760
|
const sink = guardSink(w);
|
|
2624
2761
|
buffer = writable = coalesceWrites(sink.write, sink.end);
|
|
2625
2762
|
buffer.write(tmp);
|
|
@@ -2685,6 +2822,8 @@ function buildAsyncWrap(err, node) {
|
|
|
2685
2822
|
fn.$rw = true;
|
|
2686
2823
|
if (suppress) fn.$lhSuppress = true;
|
|
2687
2824
|
if (node.$lhSkip) fn.$lhSkip = true;
|
|
2825
|
+
if (node.$lhInTag) fn.$lhInTag = true;
|
|
2826
|
+
if (node.$lhAttr) fn.$lhAttr = node.$lhAttr;
|
|
2688
2827
|
if (node.$lhBinding) fn.$lhBinding = node.$lhBinding;
|
|
2689
2828
|
return {
|
|
2690
2829
|
fn,
|
|
@@ -2886,7 +3025,8 @@ function createLiveHoles(sink, scoped, settled, errorScope) {
|
|
|
2886
3025
|
t: [""],
|
|
2887
3026
|
h: [],
|
|
2888
3027
|
p: [],
|
|
2889
|
-
rows: null
|
|
3028
|
+
rows: null,
|
|
3029
|
+
$: SSR_NODE
|
|
2890
3030
|
};
|
|
2891
3031
|
try {
|
|
2892
3032
|
result.rows = resolveValue(holeValue(hole), result);
|
|
@@ -2985,16 +3125,41 @@ function createLiveHoles(sink, scoped, settled, errorScope) {
|
|
|
2985
3125
|
},
|
|
2986
3126
|
nest(hole) {
|
|
2987
3127
|
const s = engine.scope;
|
|
2988
|
-
if (!s || s.h === hole || hole.$lhSkip || inScope && !inScope()) return undefined;
|
|
3128
|
+
if (!s || s.h === hole || hole.$lhSkip || hole.$lhInTag || inScope && !inScope()) return undefined;
|
|
2989
3129
|
engine.scope = scopeFor(hole);
|
|
2990
3130
|
return s;
|
|
2991
3131
|
},
|
|
2992
3132
|
content(hole) {
|
|
3133
|
+
if (hole.$lhInTag) {
|
|
3134
|
+
const cap = hole.$lhAttr;
|
|
3135
|
+
if (!cap || cap.adopted || engine.suppressed || engine.sweeping) return null;
|
|
3136
|
+
const r = tryResolveFunctionHole(hole);
|
|
3137
|
+
if (typeof r !== "string") {
|
|
3138
|
+
const res = {
|
|
3139
|
+
t: [""],
|
|
3140
|
+
h: [],
|
|
3141
|
+
p: [],
|
|
3142
|
+
$: SSR_NODE
|
|
3143
|
+
};
|
|
3144
|
+
appendResolvedNode(res, r);
|
|
3145
|
+
return res;
|
|
3146
|
+
}
|
|
3147
|
+
if (--cap.waiting === 0 && !cap.closed) {
|
|
3148
|
+
try {
|
|
3149
|
+
cap.base = attrPartsText(cap.parts);
|
|
3150
|
+
} catch (err) {
|
|
3151
|
+
cap.base = null;
|
|
3152
|
+
}
|
|
3153
|
+
if (cap.base !== null) engine.attr(cap);
|
|
3154
|
+
}
|
|
3155
|
+
return r;
|
|
3156
|
+
}
|
|
2993
3157
|
if (hole.$lhSuppress) {
|
|
2994
3158
|
const r = {
|
|
2995
3159
|
t: [""],
|
|
2996
3160
|
h: [],
|
|
2997
|
-
p: []
|
|
3161
|
+
p: [],
|
|
3162
|
+
$: SSR_NODE
|
|
2998
3163
|
};
|
|
2999
3164
|
let rows = null;
|
|
3000
3165
|
const b = hole.$lhBinding;
|
|
@@ -3098,7 +3263,8 @@ function createLiveHoles(sink, scoped, settled, errorScope) {
|
|
|
3098
3263
|
const r = {
|
|
3099
3264
|
t: [""],
|
|
3100
3265
|
h: [],
|
|
3101
|
-
p: []
|
|
3266
|
+
p: [],
|
|
3267
|
+
$: SSR_NODE
|
|
3102
3268
|
};
|
|
3103
3269
|
engine.suppressed++;
|
|
3104
3270
|
try {
|
|
@@ -3117,13 +3283,15 @@ function createLiveHoles(sink, scoped, settled, errorScope) {
|
|
|
3117
3283
|
res = {
|
|
3118
3284
|
t: ["", ""],
|
|
3119
3285
|
h: [escalated.fn],
|
|
3120
|
-
p: [escalated.p]
|
|
3286
|
+
p: [escalated.p],
|
|
3287
|
+
$: SSR_NODE
|
|
3121
3288
|
};
|
|
3122
3289
|
} else {
|
|
3123
3290
|
res = {
|
|
3124
3291
|
t: [""],
|
|
3125
3292
|
h: [],
|
|
3126
|
-
p: []
|
|
3293
|
+
p: [],
|
|
3294
|
+
$: SSR_NODE
|
|
3127
3295
|
};
|
|
3128
3296
|
try {
|
|
3129
3297
|
rows = resolveValue(value, res);
|
|
@@ -3153,20 +3321,59 @@ function createLiveHoles(sink, scoped, settled, errorScope) {
|
|
|
3153
3321
|
t[t.length - 1] += close;
|
|
3154
3322
|
sink.openBinding(key, b);
|
|
3155
3323
|
return {
|
|
3156
|
-
t,
|
|
3324
|
+
t: t,
|
|
3157
3325
|
h: res.h,
|
|
3158
|
-
p: res.p
|
|
3326
|
+
p: res.p,
|
|
3327
|
+
$: SSR_NODE
|
|
3159
3328
|
};
|
|
3160
3329
|
},
|
|
3161
3330
|
mint() {
|
|
3162
3331
|
return nextId++;
|
|
3163
3332
|
},
|
|
3333
|
+
open(text, off, hole) {
|
|
3334
|
+
const pending = hole && hole.$lhAttr;
|
|
3335
|
+
let inject;
|
|
3336
|
+
let id;
|
|
3337
|
+
if (pending && !pending.adopted && text.startsWith(pending.inject, off)) {
|
|
3338
|
+
pending.adopted = true;
|
|
3339
|
+
({
|
|
3340
|
+
id,
|
|
3341
|
+
inject
|
|
3342
|
+
} = pending);
|
|
3343
|
+
} else {
|
|
3344
|
+
id = nextId++;
|
|
3345
|
+
inject = ` data-lha="${id}"`;
|
|
3346
|
+
text = text.slice(0, off) + inject + text.slice(off);
|
|
3347
|
+
}
|
|
3348
|
+
const prefix = text.slice(off + inject.length);
|
|
3349
|
+
return {
|
|
3350
|
+
id,
|
|
3351
|
+
parts: [prefix],
|
|
3352
|
+
base: prefix,
|
|
3353
|
+
inject,
|
|
3354
|
+
waiting: 0,
|
|
3355
|
+
text
|
|
3356
|
+
};
|
|
3357
|
+
},
|
|
3358
|
+
retry(fn, cap) {
|
|
3359
|
+
if (typeof fn !== "function") return;
|
|
3360
|
+
fn.$lhInTag = true;
|
|
3361
|
+
if (cap) {
|
|
3362
|
+
fn.$lhAttr = cap;
|
|
3363
|
+
cap.waiting++;
|
|
3364
|
+
}
|
|
3365
|
+
},
|
|
3164
3366
|
active() {
|
|
3165
3367
|
return (!inScope || inScope()) && !(settled && settled());
|
|
3166
3368
|
},
|
|
3167
3369
|
attr(cap) {
|
|
3168
|
-
|
|
3169
|
-
|
|
3370
|
+
if (cap.waiting) {
|
|
3371
|
+
cap.owner = getOwner();
|
|
3372
|
+
cap.ctx = sharedConfig.context;
|
|
3373
|
+
return;
|
|
3374
|
+
}
|
|
3375
|
+
const owner = cap.owner !== undefined ? cap.owner : getOwner();
|
|
3376
|
+
const holeCtx = cap.ctx !== undefined ? cap.ctx : sharedConfig.context;
|
|
3170
3377
|
const b = {
|
|
3171
3378
|
key: "lha:" + cap.id,
|
|
3172
3379
|
children: [],
|
|
@@ -3181,29 +3388,7 @@ function createLiveHoles(sink, scoped, settled, errorScope) {
|
|
|
3181
3388
|
engine.gateHit = false;
|
|
3182
3389
|
let html = "";
|
|
3183
3390
|
try {
|
|
3184
|
-
|
|
3185
|
-
let groupVal = null;
|
|
3186
|
-
const run = () => {
|
|
3187
|
-
for (const part of cap.parts) {
|
|
3188
|
-
if (typeof part === "string") {
|
|
3189
|
-
html += part;
|
|
3190
|
-
continue;
|
|
3191
|
-
}
|
|
3192
|
-
let v;
|
|
3193
|
-
if (part.g) {
|
|
3194
|
-
if (group !== part.g) {
|
|
3195
|
-
group = part.g;
|
|
3196
|
-
groupVal = part.g();
|
|
3197
|
-
}
|
|
3198
|
-
v = groupVal[part.i];
|
|
3199
|
-
} else {
|
|
3200
|
-
v = part.f();
|
|
3201
|
-
}
|
|
3202
|
-
const vt = typeof v;
|
|
3203
|
-
if (vt === "string" || vt === "number") html += v;
|
|
3204
|
-
}
|
|
3205
|
-
};
|
|
3206
|
-
swept(owner, holeCtx, run);
|
|
3391
|
+
swept(owner, holeCtx, () => html = attrPartsText(cap.parts));
|
|
3207
3392
|
} catch (err) {
|
|
3208
3393
|
if (ssrHandleError(err, true)) {
|
|
3209
3394
|
if (!engine.sweptOwners) return;
|
|
@@ -3310,10 +3495,35 @@ function rowPatch(a, b) {
|
|
|
3310
3495
|
}
|
|
3311
3496
|
}
|
|
3312
3497
|
}
|
|
3498
|
+
function attrPartsText(parts) {
|
|
3499
|
+
let html = "";
|
|
3500
|
+
let group = null;
|
|
3501
|
+
let groupVal = null;
|
|
3502
|
+
for (const part of parts) {
|
|
3503
|
+
if (typeof part === "string") {
|
|
3504
|
+
html += part;
|
|
3505
|
+
continue;
|
|
3506
|
+
}
|
|
3507
|
+
let v;
|
|
3508
|
+
if (part.g) {
|
|
3509
|
+
if (group !== part.g) {
|
|
3510
|
+
group = part.g;
|
|
3511
|
+
groupVal = part.g();
|
|
3512
|
+
}
|
|
3513
|
+
v = groupVal[part.i];
|
|
3514
|
+
} else {
|
|
3515
|
+
v = part.f();
|
|
3516
|
+
}
|
|
3517
|
+
const vt = typeof v;
|
|
3518
|
+
if (vt === "string" || vt === "number") html += v;
|
|
3519
|
+
}
|
|
3520
|
+
return html;
|
|
3521
|
+
}
|
|
3313
3522
|
function ssr(t) {
|
|
3314
3523
|
const len = arguments.length;
|
|
3315
3524
|
if (len === 1) return {
|
|
3316
|
-
t
|
|
3525
|
+
t: t,
|
|
3526
|
+
$: SSR_NODE
|
|
3317
3527
|
};
|
|
3318
3528
|
let s = t[0];
|
|
3319
3529
|
let result = null;
|
|
@@ -3329,30 +3539,18 @@ function ssr(t) {
|
|
|
3329
3539
|
seg: -1,
|
|
3330
3540
|
off: hp.openOff[0]
|
|
3331
3541
|
};
|
|
3332
|
-
const captureStart =
|
|
3542
|
+
const captureStart = hole => {
|
|
3333
3543
|
if (cap) return true;
|
|
3334
3544
|
if (!lastOpen || live.suppressed || live.sweeping || !live.active()) return false;
|
|
3545
|
+
if (lastOpen.r === null && result !== null && result.t.length === 1) {
|
|
3546
|
+
lastOpen.r = result;
|
|
3547
|
+
lastOpen.seg = 0;
|
|
3548
|
+
}
|
|
3335
3549
|
if (lastOpen.r !== result || result !== null && lastOpen.seg !== result.t.length - 1) {
|
|
3336
3550
|
return false;
|
|
3337
3551
|
}
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
let prefix;
|
|
3341
|
-
if (result === null) {
|
|
3342
|
-
s = s.slice(0, lastOpen.off) + inject + s.slice(lastOpen.off);
|
|
3343
|
-
prefix = s.slice(lastOpen.off + inject.length);
|
|
3344
|
-
} else {
|
|
3345
|
-
const seg = result.t[lastOpen.seg];
|
|
3346
|
-
result.t[lastOpen.seg] = seg.slice(0, lastOpen.off) + inject + seg.slice(lastOpen.off);
|
|
3347
|
-
prefix = result.t[lastOpen.seg].slice(lastOpen.off + inject.length);
|
|
3348
|
-
}
|
|
3349
|
-
cap = {
|
|
3350
|
-
id,
|
|
3351
|
-
parts: [prefix],
|
|
3352
|
-
base: prefix,
|
|
3353
|
-
at: lastOpen.seg,
|
|
3354
|
-
inject
|
|
3355
|
-
};
|
|
3552
|
+
cap = live.open(result === null ? s : result.t[lastOpen.seg], lastOpen.off, hole);
|
|
3553
|
+
if (result === null) s = cap.text;else result.t[lastOpen.seg] = cap.text;
|
|
3356
3554
|
return true;
|
|
3357
3555
|
};
|
|
3358
3556
|
for (let i = 1; i < len; i++) {
|
|
@@ -3383,7 +3581,8 @@ function ssr(t) {
|
|
|
3383
3581
|
result = {
|
|
3384
3582
|
t: [s],
|
|
3385
3583
|
h: [],
|
|
3386
|
-
p: []
|
|
3584
|
+
p: [],
|
|
3585
|
+
$: SSR_NODE
|
|
3387
3586
|
};
|
|
3388
3587
|
s = "";
|
|
3389
3588
|
}
|
|
@@ -3393,18 +3592,23 @@ function ssr(t) {
|
|
|
3393
3592
|
if (Array.isArray(lastGroupVal)) {
|
|
3394
3593
|
value = lastGroupVal[lastGroupIdx++];
|
|
3395
3594
|
hasValue = true;
|
|
3396
|
-
if (live && !hp.pos[i - 1] && captureStart()) {
|
|
3595
|
+
if (live && !hp.pos[i - 1] && captureStart(hole)) {
|
|
3397
3596
|
cap.parts.push({
|
|
3398
3597
|
g: hole,
|
|
3399
3598
|
i: lastGroupIdx - 1
|
|
3400
3599
|
});
|
|
3401
3600
|
}
|
|
3402
3601
|
} else {
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3602
|
+
const slot = ssrGroupSlot(lastGroupVal.fn, lastGroupIdx++);
|
|
3603
|
+
if (live && !hp.pos[i - 1]) {
|
|
3604
|
+
const capturing = captureStart(hole);
|
|
3605
|
+
if (capturing) cap.parts.push({
|
|
3606
|
+
g: hole,
|
|
3607
|
+
i: lastGroupIdx - 1
|
|
3608
|
+
});
|
|
3609
|
+
live.retry(slot, capturing && cap);
|
|
3406
3610
|
}
|
|
3407
|
-
result.h.push(
|
|
3611
|
+
result.h.push(slot);
|
|
3408
3612
|
result.p.push(lastGroupVal.p);
|
|
3409
3613
|
result.t.push("");
|
|
3410
3614
|
}
|
|
@@ -3424,7 +3628,8 @@ function ssr(t) {
|
|
|
3424
3628
|
result = {
|
|
3425
3629
|
t: [s],
|
|
3426
3630
|
h: [],
|
|
3427
|
-
p: []
|
|
3631
|
+
p: [],
|
|
3632
|
+
$: SSR_NODE
|
|
3428
3633
|
};
|
|
3429
3634
|
s = "";
|
|
3430
3635
|
if (rs.merge !== undefined) mergeTemplateInto(result, rs.merge);else resolveSSRNode(rs.bail, result);
|
|
@@ -3441,7 +3646,8 @@ function ssr(t) {
|
|
|
3441
3646
|
result = {
|
|
3442
3647
|
t: [s],
|
|
3443
3648
|
h: [],
|
|
3444
|
-
p: []
|
|
3649
|
+
p: [],
|
|
3650
|
+
$: SSR_NODE
|
|
3445
3651
|
};
|
|
3446
3652
|
s = "";
|
|
3447
3653
|
}
|
|
@@ -3449,28 +3655,27 @@ function ssr(t) {
|
|
|
3449
3655
|
}
|
|
3450
3656
|
} else if (result !== null) {
|
|
3451
3657
|
const inTag = live && !hp.pos[i - 1];
|
|
3452
|
-
const capturing = inTag && captureStart();
|
|
3658
|
+
const capturing = inTag && captureStart(hole);
|
|
3453
3659
|
const li = capturing ? result.t.length - 1 : 0;
|
|
3454
3660
|
const before = capturing ? result.t[li].length : 0;
|
|
3661
|
+
const pushed = result.h.length;
|
|
3455
3662
|
if (live) live.suppressed++;
|
|
3456
3663
|
try {
|
|
3457
3664
|
resolveSSRNode(hole, result);
|
|
3458
3665
|
} finally {
|
|
3459
3666
|
if (live) live.suppressed--;
|
|
3460
3667
|
}
|
|
3668
|
+
if (inTag) {
|
|
3669
|
+
for (let k = pushed; k < result.h.length; k++) live.retry(result.h[k], capturing && cap);
|
|
3670
|
+
}
|
|
3461
3671
|
if (capturing) {
|
|
3462
|
-
if (result.t.length - 1 === li)
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
});
|
|
3467
|
-
} else {
|
|
3468
|
-
result.t[cap.at] = result.t[cap.at].replace(cap.inject, "");
|
|
3469
|
-
cap = null;
|
|
3470
|
-
}
|
|
3672
|
+
if (result.t.length - 1 === li) cap.base += result.t[li].slice(before);
|
|
3673
|
+
cap.parts.push({
|
|
3674
|
+
f: hole
|
|
3675
|
+
});
|
|
3471
3676
|
}
|
|
3472
3677
|
} else {
|
|
3473
|
-
const capturing = live && !hp.pos[i - 1] && captureStart();
|
|
3678
|
+
const capturing = live && !hp.pos[i - 1] && captureStart(hole);
|
|
3474
3679
|
const scope = live && hp.pos[i - 1] && live.nest(hole);
|
|
3475
3680
|
const r = tryResolveFunctionHole(hole);
|
|
3476
3681
|
if (scope) live.scope = scope;
|
|
@@ -3483,17 +3688,18 @@ function ssr(t) {
|
|
|
3483
3688
|
});
|
|
3484
3689
|
}
|
|
3485
3690
|
} else {
|
|
3486
|
-
if (capturing) {
|
|
3487
|
-
s = s.replace(cap.inject, "");
|
|
3488
|
-
cap = null;
|
|
3489
|
-
}
|
|
3490
3691
|
result = {
|
|
3491
3692
|
t: [s],
|
|
3492
3693
|
h: [],
|
|
3493
|
-
p: []
|
|
3694
|
+
p: [],
|
|
3695
|
+
$: SSR_NODE
|
|
3494
3696
|
};
|
|
3495
3697
|
s = "";
|
|
3496
3698
|
appendResolvedNode(result, r);
|
|
3699
|
+
if (capturing) cap.parts.push({
|
|
3700
|
+
f: hole
|
|
3701
|
+
});
|
|
3702
|
+
if (live && !hp.pos[i - 1]) for (const h of result.h) live.retry(h, capturing && cap);
|
|
3497
3703
|
}
|
|
3498
3704
|
}
|
|
3499
3705
|
} else if (result !== null) {
|
|
@@ -3506,7 +3712,8 @@ function ssr(t) {
|
|
|
3506
3712
|
result = {
|
|
3507
3713
|
t: [s],
|
|
3508
3714
|
h: [],
|
|
3509
|
-
p: []
|
|
3715
|
+
p: [],
|
|
3716
|
+
$: SSR_NODE
|
|
3510
3717
|
};
|
|
3511
3718
|
s = "";
|
|
3512
3719
|
appendResolvedNode(result, r);
|
|
@@ -3542,7 +3749,8 @@ function ssr(t) {
|
|
|
3542
3749
|
if (result === null) s += next;else result.t[result.t.length - 1] += next;
|
|
3543
3750
|
}
|
|
3544
3751
|
if (result === null) return {
|
|
3545
|
-
t: s
|
|
3752
|
+
t: s,
|
|
3753
|
+
$: SSR_NODE
|
|
3546
3754
|
};
|
|
3547
3755
|
return result;
|
|
3548
3756
|
}
|
|
@@ -3604,14 +3812,14 @@ function ssrElement(tag, props, children, needsId, skip, attrs) {
|
|
|
3604
3812
|
let i = 0;
|
|
3605
3813
|
for (; i < props.length; i++) {
|
|
3606
3814
|
const s = props[i];
|
|
3607
|
-
if (s
|
|
3815
|
+
if (!s || typeof s === "function" || $PROXY in s) break;
|
|
3608
3816
|
}
|
|
3609
3817
|
if (i === props.length) sources = props;else {
|
|
3610
3818
|
viewKeys = [];
|
|
3611
3819
|
owners = [];
|
|
3612
3820
|
collectSpreadSources(props, viewKeys, owners);
|
|
3613
3821
|
}
|
|
3614
|
-
} else if (props
|
|
3822
|
+
} else if (!props) {
|
|
3615
3823
|
props = {};
|
|
3616
3824
|
} else if ($PROXY in props) {
|
|
3617
3825
|
if (viewOf(props) !== undefined) {
|
|
@@ -3622,6 +3830,7 @@ function ssrElement(tag, props, children, needsId, skip, attrs) {
|
|
|
3622
3830
|
}
|
|
3623
3831
|
const info = tagInfo(tag);
|
|
3624
3832
|
const skipChildren = info.isVoid;
|
|
3833
|
+
let sel, optValue, optOwn;
|
|
3625
3834
|
let result = info.open + hk;
|
|
3626
3835
|
let childOwner = null;
|
|
3627
3836
|
const last = sources === null ? 0 : sources.length - 1;
|
|
@@ -3640,6 +3849,11 @@ function ssrElement(tag, props, children, needsId, skip, attrs) {
|
|
|
3640
3849
|
for (let j = s + 1; j <= last; j++) {
|
|
3641
3850
|
if (keysOf[j].includes(prop)) continue nextKey;
|
|
3642
3851
|
}
|
|
3852
|
+
if (info.sel === 1 && prop === "value") {
|
|
3853
|
+
const value = props[prop];
|
|
3854
|
+
sel = ssrSelect(value);
|
|
3855
|
+
continue;
|
|
3856
|
+
}
|
|
3643
3857
|
if (info.textarea && (prop === "value" || prop === "defaultValue")) {
|
|
3644
3858
|
const value = props[prop];
|
|
3645
3859
|
if (value !== null) children = escape(value);
|
|
@@ -3659,6 +3873,9 @@ function ssrElement(tag, props, children, needsId, skip, attrs) {
|
|
|
3659
3873
|
const value = props[key];
|
|
3660
3874
|
if (value == undefined || prop.startsWith("prop:") || prop === "ref" || isEventName(prop)) continue;
|
|
3661
3875
|
if (link !== null && LinkAttributes.has(prop)) link[prop] = value;
|
|
3876
|
+
if (info.sel === 2) {
|
|
3877
|
+
if (prop === "value") optValue = value;else if (prop === "selected" && value) optOwn = true;
|
|
3878
|
+
}
|
|
3662
3879
|
if (prop === "style") {
|
|
3663
3880
|
result += ` style="${ssrStyle(value)}"`;
|
|
3664
3881
|
} else if (prop === "class") {
|
|
@@ -3673,10 +3890,11 @@ function ssrElement(tag, props, children, needsId, skip, attrs) {
|
|
|
3673
3890
|
if (attrs !== undefined) result += typeof attrs === "function" ? attrs() : attrs;
|
|
3674
3891
|
if (link !== null && link.href !== undefined) result += ssrLinkClaim(link);
|
|
3675
3892
|
if (skipChildren) return {
|
|
3676
|
-
t: result + " />"
|
|
3893
|
+
t: result + " />",
|
|
3894
|
+
$: SSR_NODE
|
|
3677
3895
|
};
|
|
3678
|
-
if (
|
|
3679
|
-
if (typeof children
|
|
3896
|
+
if (sel !== undefined) children = ssrIn(sel, () => spreadChildren(info, childOwner, children));else children = spreadChildren(info, childOwner, children);
|
|
3897
|
+
if (info.sel === 2) result += ssrOption(optValue !== undefined || typeof children !== "string" ? optValue : children.replace(/</g, "<").replace(/&/g, "&").replace(/\s+/g, " ").trim(), undefined, optOwn);
|
|
3680
3898
|
let thunk = null;
|
|
3681
3899
|
if (typeof children === "function" && (ctx === undefined || !ctx.liveHoles)) {
|
|
3682
3900
|
thunk = children;
|
|
@@ -3687,7 +3905,8 @@ function ssrElement(tag, props, children, needsId, skip, attrs) {
|
|
|
3687
3905
|
const res = {
|
|
3688
3906
|
t: [""],
|
|
3689
3907
|
h: [],
|
|
3690
|
-
p: []
|
|
3908
|
+
p: [],
|
|
3909
|
+
$: SSR_NODE
|
|
3691
3910
|
};
|
|
3692
3911
|
pushSSRAsyncHole(res, err, thunk);
|
|
3693
3912
|
return ssr([result + ">", info.close], res);
|
|
@@ -3695,19 +3914,23 @@ function ssrElement(tag, props, children, needsId, skip, attrs) {
|
|
|
3695
3914
|
}
|
|
3696
3915
|
const ct = typeof children;
|
|
3697
3916
|
if (ct === "string" || ct === "number") return {
|
|
3698
|
-
t: result + ">" + children + info.close
|
|
3917
|
+
t: result + ">" + children + info.close,
|
|
3918
|
+
$: SSR_NODE
|
|
3699
3919
|
};
|
|
3700
3920
|
if (children == null || ct === "boolean") return {
|
|
3701
|
-
t: result + ">" + info.close
|
|
3921
|
+
t: result + ">" + info.close,
|
|
3922
|
+
$: SSR_NODE
|
|
3702
3923
|
};
|
|
3703
|
-
if (ct === "object" && !children.h && typeof children.t === "string") return {
|
|
3704
|
-
t: result + ">" + children.t + info.close
|
|
3924
|
+
if (ct === "object" && children.$ === SSR_NODE && !children.h && typeof children.t === "string") return {
|
|
3925
|
+
t: result + ">" + children.t + info.close,
|
|
3926
|
+
$: SSR_NODE
|
|
3705
3927
|
};
|
|
3706
3928
|
if (thunk === null) return ssr([result + ">", info.close], resolveSSRNode(children, undefined, true));
|
|
3707
3929
|
const res = {
|
|
3708
3930
|
t: [""],
|
|
3709
3931
|
h: [],
|
|
3710
|
-
p: []
|
|
3932
|
+
p: [],
|
|
3933
|
+
$: SSR_NODE
|
|
3711
3934
|
};
|
|
3712
3935
|
try {
|
|
3713
3936
|
resolveSSRNode(children, res, false, true);
|
|
@@ -3716,11 +3939,15 @@ function ssrElement(tag, props, children, needsId, skip, attrs) {
|
|
|
3716
3939
|
}
|
|
3717
3940
|
return ssr([result + ">", info.close], res);
|
|
3718
3941
|
}
|
|
3942
|
+
function spreadChildren(info, childOwner, children) {
|
|
3943
|
+
if (childOwner !== null) children = info.raw ? childOwner.children : escape(childOwner.children);
|
|
3944
|
+
return typeof children === "function" ? children() : children;
|
|
3945
|
+
}
|
|
3719
3946
|
function collectSpreadSources(props, viewKeys, owners) {
|
|
3720
3947
|
for (let i = 0; i < props.length; i++) {
|
|
3721
3948
|
let s = props[i];
|
|
3722
3949
|
if (typeof s === "function") s = s();
|
|
3723
|
-
if (s
|
|
3950
|
+
if (s) sourceOwners(s, viewKeys, owners);
|
|
3724
3951
|
}
|
|
3725
3952
|
}
|
|
3726
3953
|
function spreadFormAttribute(prop, info, keys, keysOf, skip) {
|
|
@@ -3758,110 +3985,37 @@ function ssrLinkClaim(attrs) {
|
|
|
3758
3985
|
if (ctx === undefined || ctx.linkClaim === undefined || attrs["aria-current"] != null) return "";
|
|
3759
3986
|
return ctx.linkClaim(attrs);
|
|
3760
3987
|
}
|
|
3761
|
-
|
|
3762
|
-
|
|
3988
|
+
const SELECT = Symbol();
|
|
3989
|
+
function ssrSelect(value) {
|
|
3990
|
+
const owner = createOwner({
|
|
3991
|
+
transparent: true
|
|
3992
|
+
});
|
|
3993
|
+
const state = {
|
|
3994
|
+
v: value,
|
|
3995
|
+
d: false,
|
|
3996
|
+
o: owner
|
|
3997
|
+
};
|
|
3998
|
+
owner._context = {
|
|
3999
|
+
...owner._context,
|
|
4000
|
+
[SELECT]: state
|
|
4001
|
+
};
|
|
4002
|
+
return state;
|
|
3763
4003
|
}
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
for (let j = i + 1; j < html.length; j++) {
|
|
3767
|
-
const c = html.charCodeAt(j);
|
|
3768
|
-
if (c === 34) {
|
|
3769
|
-
j = html.indexOf('"', j + 1);
|
|
3770
|
-
if (j < 0) return -1;
|
|
3771
|
-
} else if (c === 62) return j;
|
|
3772
|
-
}
|
|
3773
|
-
return -1;
|
|
4004
|
+
function ssrIn(state, fn) {
|
|
4005
|
+
return runWithOwner(state.o, fn);
|
|
3774
4006
|
}
|
|
3775
|
-
function
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
const lt = html.indexOf("<", i);
|
|
3780
|
-
if (lt < 0) return t + html.slice(i);
|
|
3781
|
-
t += html.slice(i, lt);
|
|
3782
|
-
if (!html.startsWith("<!--", lt)) return t;
|
|
3783
|
-
const ce = html.indexOf("-->", lt);
|
|
3784
|
-
if (ce < 0) return t;
|
|
3785
|
-
i = ce + 3;
|
|
3786
|
-
}
|
|
3787
|
-
}
|
|
3788
|
-
function tagIs(html, i, name) {
|
|
3789
|
-
if (!html.startsWith(name, i + 1)) return false;
|
|
3790
|
-
const c = html.charCodeAt(i + 1 + name.length);
|
|
3791
|
-
return c === 32 || c === 62 || c === 9 || c === 10 || c === 13;
|
|
3792
|
-
}
|
|
3793
|
-
let selectValuesActive = false;
|
|
3794
|
-
function ssrSelectValues() {
|
|
3795
|
-
selectValuesActive = true;
|
|
3796
|
-
}
|
|
3797
|
-
function resolveSSRSelectValues(html) {
|
|
3798
|
-
if (!selectValuesActive) return html;
|
|
3799
|
-
let cand = html.indexOf("<select");
|
|
3800
|
-
if (cand < 0) return html;
|
|
3801
|
-
let out = "";
|
|
3802
|
-
let idx = 0;
|
|
3803
|
-
while (cand >= 0) {
|
|
3804
|
-
if (!tagIs(html, cand, "select")) {
|
|
3805
|
-
cand = html.indexOf("<select", cand + 7);
|
|
3806
|
-
continue;
|
|
3807
|
-
}
|
|
3808
|
-
const e0 = tagEnd(html, cand);
|
|
3809
|
-
if (e0 < 0) break;
|
|
3810
|
-
const open = html.slice(cand, e0 + 1);
|
|
3811
|
-
const m = SELECT_VALUE_ATTR.exec(open);
|
|
3812
|
-
if (!m) {
|
|
3813
|
-
cand = html.indexOf("<select", e0 + 1);
|
|
3814
|
-
continue;
|
|
3815
|
-
}
|
|
3816
|
-
const bound = decodeSSREntities(m[1] ?? "");
|
|
3817
|
-
const sel = {
|
|
3818
|
-
values: /\smultiple(?=[\s>=])/.test(open) ? bound.split(",") : [bound],
|
|
3819
|
-
strip: cand + m.index,
|
|
3820
|
-
stripEnd: cand + m.index + m[0].length,
|
|
3821
|
-
body: e0 + 1,
|
|
3822
|
-
marks: [],
|
|
3823
|
-
defaulted: false
|
|
3824
|
-
};
|
|
3825
|
-
let committed = false;
|
|
3826
|
-
let i = html.indexOf("<", e0 + 1);
|
|
3827
|
-
while (i >= 0) {
|
|
3828
|
-
let e;
|
|
3829
|
-
if (html.charCodeAt(i + 1) === 33) {
|
|
3830
|
-
e = html.charCodeAt(i + 2) === 45 ? html.indexOf("-->", i) : html.indexOf(">", i);
|
|
3831
|
-
if (e < 0) break;
|
|
3832
|
-
if (html.charCodeAt(i + 2) === 45) e += 2;
|
|
3833
|
-
} else {
|
|
3834
|
-
e = tagEnd(html, i);
|
|
3835
|
-
if (e < 0) break;
|
|
3836
|
-
if (html.startsWith("</select>", i)) {
|
|
3837
|
-
out += html.slice(idx, sel.strip) + html.slice(sel.stripEnd, sel.body);
|
|
3838
|
-
let seg = sel.body;
|
|
3839
|
-
if (!sel.defaulted) {
|
|
3840
|
-
for (let k = 0; k < sel.marks.length; k++) {
|
|
3841
|
-
out += html.slice(seg, sel.marks[k]) + " selected";
|
|
3842
|
-
seg = sel.marks[k];
|
|
3843
|
-
}
|
|
3844
|
-
}
|
|
3845
|
-
out += html.slice(seg, i);
|
|
3846
|
-
idx = i;
|
|
3847
|
-
committed = true;
|
|
3848
|
-
break;
|
|
3849
|
-
} else if (tagIs(html, i, "option")) {
|
|
3850
|
-
const attrs = html.slice(i + 7, e);
|
|
3851
|
-
if (/\sselected(?=[\s=]|$)/.test(attrs)) sel.defaulted = true;else {
|
|
3852
|
-
const vm = SELECT_VALUE_ATTR.exec(attrs);
|
|
3853
|
-
const value = vm ? decodeSSREntities(vm[1] ?? "") : decodeSSREntities(optionText(html, e + 1)).replace(/\s+/g, " ").trim();
|
|
3854
|
-
if (sel.values.includes(value)) sel.marks.push(e);
|
|
3855
|
-
}
|
|
3856
|
-
}
|
|
3857
|
-
}
|
|
3858
|
-
i = html.indexOf("<", e + 1);
|
|
3859
|
-
}
|
|
3860
|
-
if (!committed) break;
|
|
3861
|
-
cand = html.indexOf("<select", idx);
|
|
4007
|
+
function ssrOption(value, state, own) {
|
|
4008
|
+
if (state === undefined) {
|
|
4009
|
+
const o = getOwner();
|
|
4010
|
+
if (!o || !(state = o._context[SELECT])) return "";
|
|
3862
4011
|
}
|
|
3863
|
-
if (
|
|
3864
|
-
|
|
4012
|
+
if (own) return state.d = true, "";
|
|
4013
|
+
if (state.d) return "";
|
|
4014
|
+
if (typeof value === "function") value = value();
|
|
4015
|
+
if (value == null) return "";
|
|
4016
|
+
value = String(value);
|
|
4017
|
+
const v = state.v;
|
|
4018
|
+
return v != null && (v.map ? v.some(x => x != null && String(x) === value) : String(v) === value) ? " selected" : "";
|
|
3865
4019
|
}
|
|
3866
4020
|
function escape(s, attr) {
|
|
3867
4021
|
const t = typeof s;
|
|
@@ -3968,7 +4122,7 @@ function tryJoinPlainSSRArray(nodes) {
|
|
|
3968
4122
|
let out = "";
|
|
3969
4123
|
for (let i = 0, len = nodes.length; i < len; i++) {
|
|
3970
4124
|
const node = nodes[i];
|
|
3971
|
-
if (node == null || typeof node !== "object" || node.h || typeof node.t !== "string") {
|
|
4125
|
+
if (node == null || typeof node !== "object" || node.$ !== SSR_NODE || node.h || typeof node.t !== "string") {
|
|
3972
4126
|
return undefined;
|
|
3973
4127
|
}
|
|
3974
4128
|
out += node.t;
|
|
@@ -4196,12 +4350,12 @@ function tryResolveString(node, nested) {
|
|
|
4196
4350
|
}
|
|
4197
4351
|
return s;
|
|
4198
4352
|
}
|
|
4353
|
+
if (node.$ !== SSR_NODE) {
|
|
4354
|
+
return "";
|
|
4355
|
+
}
|
|
4199
4356
|
if (node.h && node.h.length > 0) return {
|
|
4200
4357
|
merge: node
|
|
4201
4358
|
};
|
|
4202
|
-
if (node.t === undefined) {
|
|
4203
|
-
return "";
|
|
4204
|
-
}
|
|
4205
4359
|
ssrTextTail = false;
|
|
4206
4360
|
return Array.isArray(node.t) ? node.t[0] : node.t;
|
|
4207
4361
|
}
|
|
@@ -4221,7 +4375,8 @@ function tryResolveString(node, nested) {
|
|
|
4221
4375
|
function resolveSSRNode(node, result = {
|
|
4222
4376
|
t: [""],
|
|
4223
4377
|
h: [],
|
|
4224
|
-
p: []
|
|
4378
|
+
p: [],
|
|
4379
|
+
$: SSR_NODE
|
|
4225
4380
|
}, top, nested) {
|
|
4226
4381
|
if (!nested) ssrTextTail = false;
|
|
4227
4382
|
const t = typeof node;
|
|
@@ -4240,7 +4395,7 @@ function resolveSSRNode(node, result = {
|
|
|
4240
4395
|
if (slotLive) slotLive.suppressed--;
|
|
4241
4396
|
}
|
|
4242
4397
|
} else if (t === "object") {
|
|
4243
|
-
if (node.h) {
|
|
4398
|
+
if (node.$ !== SSR_NODE) ; else if (node.h) {
|
|
4244
4399
|
result.t[result.t.length - 1] += node.t[0];
|
|
4245
4400
|
if (node.t.length > 1) {
|
|
4246
4401
|
result.t.push(...node.t.slice(1));
|
|
@@ -4248,10 +4403,10 @@ function resolveSSRNode(node, result = {
|
|
|
4248
4403
|
result.p.push(...node.p);
|
|
4249
4404
|
}
|
|
4250
4405
|
ssrTextTail = false;
|
|
4251
|
-
} else
|
|
4406
|
+
} else {
|
|
4252
4407
|
result.t[result.t.length - 1] += node.t;
|
|
4253
4408
|
ssrTextTail = false;
|
|
4254
|
-
}
|
|
4409
|
+
}
|
|
4255
4410
|
} else if (t === "function") {
|
|
4256
4411
|
const live = sharedConfig.context && sharedConfig.context.liveHoles;
|
|
4257
4412
|
let liveNode = null;
|
|
@@ -4665,6 +4820,10 @@ function registerElementClaim() {
|
|
|
4665
4820
|
return noopCleanup;
|
|
4666
4821
|
}
|
|
4667
4822
|
function noopCleanup() {}
|
|
4823
|
+
function setTrustedTypesPolicy() {}
|
|
4824
|
+
function trustedHTML(html) {
|
|
4825
|
+
return html;
|
|
4826
|
+
}
|
|
4668
4827
|
function claimElement(node) {
|
|
4669
4828
|
return node;
|
|
4670
4829
|
}
|
|
@@ -4814,4 +4973,4 @@ function httpHeader(name, value, options) {
|
|
|
4814
4973
|
}
|
|
4815
4974
|
}
|
|
4816
4975
|
|
|
4817
|
-
export { ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, HREF, HydrationScript, MathMLElements, NULL_BODY_STATUSES, Namespaces, Portal, RESPONSE_HEADER_VALUE_LIMIT, REVALIDATE_ALL, REVALIDATE_HEADER, RawTextElements, RequestContext, ResponseEnvelope, SAFE_ERROR, SVGElements, VoidElements, notSup as acquireAsset, notSup as addEvent, applyRef, notSup as assign, claimElement, claimElementTree, notSup as className, clearFlashCookie, clientOnly, commitEventResponse, commitResponseStub, composeMiddleware, configureServerErrors, createLiveHoles, createRequestEvent, createResponseStub, createSSRResponse, notSup as delegateEvents, dispatchAsInteraction, dynamic, notSup as dynamicProperty, effect, escape, generateHydrationScript, notSup as getDelegatedRoot, getExpectedRedirectStatus, getHydrationKey, getHydrationWriter, notSup as getNextElement, notSup as getNextMarker, notSup as getNextMatch, getRequestEvent, getServerFunctionMetadata, getServerFunctionRPC, getTraceContext, hasFlashCookie, hasServerLinkState, httpHeader, httpStatus, notSup as hydrate, notSup as insert, isDev, isHref, isResponseEnvelope, isSafeError, isServer, isServerFunction, markSafeError, memo, parseCookieHeader, notSup as readShallow, redirect, notSup as ref, notSup as registerDelegatedContainer, notSup as registerDelegatedRoot, registerElementClaim, reload, notSup as render, renderToStream, renderToString, reportRequestFailure, resolveSSRNode,
|
|
4976
|
+
export { ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, HREF, HydrationScript, MathMLElements, NULL_BODY_STATUSES, Namespaces, Portal, RESPONSE_HEADER_VALUE_LIMIT, REVALIDATE_ALL, REVALIDATE_HEADER, RawTextElements, RequestContext, ResponseEnvelope, SAFE_ERROR, SVGElements, VoidElements, notSup as acquireAsset, notSup as addEvent, applyRef, notSup as assign, claimElement, claimElementTree, notSup as className, clearFlashCookie, clientOnly, commitEventResponse, commitResponseStub, composeMiddleware, configureServerErrors, createLiveHoles, createRequestEvent, createResponseStub, createSSRResponse, notSup as delegateEvents, dispatchAsInteraction, dynamic, notSup as dynamicProperty, effect, escape, generateHydrationScript, notSup as getDelegatedRoot, getExpectedRedirectStatus, getHydrationKey, getHydrationWriter, notSup as getNextElement, notSup as getNextMarker, notSup as getNextMatch, getRequestEvent, getServerFunctionMetadata, getServerFunctionRPC, getTraceContext, hasFlashCookie, hasServerLinkState, notSup as heldRead, httpHeader, httpStatus, notSup as hydrate, notSup as insert, isDev, isHref, isResponseEnvelope, isSafeError, isServer, isServerFunction, markSafeError, memo, parseCookieHeader, notSup as readShallow, redirect, notSup as ref, notSup as registerDelegatedContainer, notSup as registerDelegatedRoot, registerElementClaim, reload, notSup as render, renderToStream, renderToString, reportRequestFailure, resolveSSRNode, respond, notSup as runHydrationEvents, serializeCookie, notSup as setAttribute, notSup as setAttributeNS, setLinkClaim, notSup as setProperty, notSup as setStatefulProperty, notSup as setStyleProperty, setTrustedTypesPolicy, notSup as spread, ssr, ssrAttribute, ssrClassName, ssrElement, ssrElementAttribute, ssrGroup, ssrHydrationKey, ssrIn, ssrLinkClaim, ssrOption, ssrSelect, ssrStyle, ssrStyleProperties, ssrStyleProperty, notSup as strictHandler, notSup as style, takeHydrationValue, notSup as template, trustedHTML, notSup as unregisterDelegatedContainer, notSup as unregisterDelegatedRoot, useHead };
|