@solidjs/web 2.0.0-rc.20 → 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 +521 -280
- package/dist/server.js +518 -279
- package/dist/server.observe.js +518 -279
- package/dist/web.dev.js +142 -106
- package/dist/web.js +120 -105
- package/dist/web.observe.js +120 -105
- 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 +124 -68
- package/frames/dist/server.js +124 -68
- package/frames/dist/server.observe.js +124 -68
- package/frames/dist/wire.js +1 -1
- package/package.json +2 -2
- package/serialization/dist/serialization.js +53 -12
- package/serialization/types/index.d.ts +42 -0
- package/serialization/types/serializer.d.ts +42 -0
- 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/server-functions/dist/rich-args.js +27 -9
- package/server-functions/dist/server.dev.js +122 -36
- package/server-functions/dist/server.js +122 -36
- package/server-functions/dist/server.observe.js +122 -36
- 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 +42 -0
- package/types/frames/tree-rewrite.d.ts +7 -0
- package/types/serializer.d.ts +42 -0
- package/types/server-functions/client.d.ts +0 -1
- package/types/server-functions/server.d.ts +0 -1
- package/types/server-functions/shared.d.ts +3 -2
- package/types/server-functions/uploads.d.ts +3 -0
- package/types/server-mock.d.ts +35 -8
- package/types/server.d.ts +89 -18
package/dist/server.dev.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { createRenderEffect, getOwner, createMemo, OBSERVE, DEV, createRoot, $PROXY,
|
|
1
|
+
import { createRenderEffect, getOwner, createMemo, OBSERVE, DEV, 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';
|
|
5
|
-
import { createStream, Feature,
|
|
5
|
+
import { createStream, Feature, crossSerializeStream, isStream, getCrossReferenceHeader } from 'seroval';
|
|
6
6
|
import { AbortSignalPlugin, CustomEventPlugin, DOMExceptionPlugin, EventPlugin, FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin } from 'seroval-plugins/web';
|
|
7
7
|
|
|
8
8
|
const DOMWithState = {
|
|
@@ -367,7 +367,15 @@ function rewriteTree(value, visit, withPath) {
|
|
|
367
367
|
} catch (err) {
|
|
368
368
|
if (err !== CYCLE) throw err;
|
|
369
369
|
}
|
|
370
|
-
|
|
370
|
+
const memo = state.memo || (state.memo = new Map());
|
|
371
|
+
const marks = {
|
|
372
|
+
at: new Map(),
|
|
373
|
+
stack: [],
|
|
374
|
+
changed: new Set(),
|
|
375
|
+
next: 0
|
|
376
|
+
};
|
|
377
|
+
mark(value, visit, path, memo, marks);
|
|
378
|
+
return clone(value, memo, marks.changed);
|
|
371
379
|
}
|
|
372
380
|
function shape(value) {
|
|
373
381
|
return Array.isArray(value) ? 1 : Object.getPrototypeOf(value) === Object.prototype ? 2 : 0;
|
|
@@ -415,28 +423,73 @@ function cow(value, visit, path, depth, state) {
|
|
|
415
423
|
if (ancestors !== undefined) ancestors.delete(value);
|
|
416
424
|
return out;
|
|
417
425
|
}
|
|
418
|
-
function
|
|
419
|
-
|
|
426
|
+
function mark(value, visit, path, memo, m) {
|
|
427
|
+
const seen = m.at.get(value);
|
|
428
|
+
if (seen !== undefined) return seen;
|
|
429
|
+
if (memo.has(value)) return -1;
|
|
420
430
|
const r = visit(value, path);
|
|
421
431
|
if (r !== DESCEND) {
|
|
422
432
|
memo.set(value, r);
|
|
423
|
-
return
|
|
433
|
+
return -1;
|
|
424
434
|
}
|
|
425
435
|
const s = shape(value);
|
|
426
|
-
if (s === 0) return
|
|
427
|
-
const
|
|
436
|
+
if (s === 0) return -1;
|
|
437
|
+
const index = m.next++;
|
|
438
|
+
let low = index;
|
|
439
|
+
let changed = false;
|
|
440
|
+
let open = false;
|
|
441
|
+
const keys = s === 1 ? value : Object.keys(value);
|
|
442
|
+
for (let i = 0; i < keys.length; i++) {
|
|
443
|
+
const k = s === 1 ? i : keys[i];
|
|
444
|
+
const c = value[k];
|
|
445
|
+
if (c === null || typeof c !== "object") continue;
|
|
446
|
+
if (!open) {
|
|
447
|
+
open = true;
|
|
448
|
+
m.at.set(value, index);
|
|
449
|
+
m.stack.push(value);
|
|
450
|
+
}
|
|
451
|
+
const l = mark(c, visit, undefined , memo, m);
|
|
452
|
+
if (l >= 0 && l < low) low = l;
|
|
453
|
+
if (memo.has(c) && memo.get(c) !== c || l === Infinity && m.changed.has(c)) changed = true;
|
|
454
|
+
}
|
|
455
|
+
if (!open) return -1;
|
|
456
|
+
if (low === index) {
|
|
457
|
+
m.at.set(value, Infinity);
|
|
458
|
+
if (m.stack[m.stack.length - 1] === value) {
|
|
459
|
+
m.stack.pop();
|
|
460
|
+
if (changed) m.changed.add(value);
|
|
461
|
+
return Infinity;
|
|
462
|
+
}
|
|
463
|
+
const members = m.stack.splice(m.stack.lastIndexOf(value));
|
|
464
|
+
if (!changed) for (const n of members) if (m.changed.has(n)) {
|
|
465
|
+
changed = true;
|
|
466
|
+
break;
|
|
467
|
+
}
|
|
468
|
+
for (const n of members) {
|
|
469
|
+
m.at.set(n, Infinity);
|
|
470
|
+
if (changed) m.changed.add(n);
|
|
471
|
+
}
|
|
472
|
+
return Infinity;
|
|
473
|
+
}
|
|
474
|
+
if (changed) m.changed.add(value);
|
|
475
|
+
return low;
|
|
476
|
+
}
|
|
477
|
+
function clone(value, memo, changed) {
|
|
478
|
+
if (memo.has(value)) return memo.get(value);
|
|
479
|
+
if (!changed.has(value)) return value;
|
|
480
|
+
const out = Array.isArray(value) ? value.slice() : {
|
|
428
481
|
...value
|
|
429
482
|
};
|
|
430
483
|
memo.set(value, out);
|
|
431
|
-
if (
|
|
484
|
+
if (Array.isArray(value)) {
|
|
432
485
|
for (let i = 0; i < value.length; i++) {
|
|
433
486
|
const c = value[i];
|
|
434
|
-
if (c !== null && typeof c === "object") out[i] = clone(c,
|
|
487
|
+
if (c !== null && typeof c === "object") out[i] = clone(c, memo, changed);
|
|
435
488
|
}
|
|
436
489
|
} else {
|
|
437
490
|
for (const k of Object.keys(value)) {
|
|
438
491
|
const c = value[k];
|
|
439
|
-
if (c !== null && typeof c === "object") out[k] = clone(c,
|
|
492
|
+
if (c !== null && typeof c === "object") out[k] = clone(c, memo, changed);
|
|
440
493
|
}
|
|
441
494
|
}
|
|
442
495
|
return out;
|
|
@@ -563,7 +616,6 @@ function createKeyedSerializer(serialize, onError, onDone) {
|
|
|
563
616
|
pendingWrites++;
|
|
564
617
|
let settled = false;
|
|
565
618
|
let failed = false;
|
|
566
|
-
let started = false;
|
|
567
619
|
let cancel = null;
|
|
568
620
|
const settle = () => {
|
|
569
621
|
if (settled) return;
|
|
@@ -577,17 +629,14 @@ function createKeyedSerializer(serialize, onError, onDone) {
|
|
|
577
629
|
stream = serialize(key, value, {
|
|
578
630
|
onError: onError && (err => {
|
|
579
631
|
failed = true;
|
|
580
|
-
onError(err);
|
|
632
|
+
onError(err, key);
|
|
581
633
|
if (cancel) {
|
|
582
634
|
cancel();
|
|
583
635
|
settle();
|
|
584
636
|
}
|
|
585
637
|
}),
|
|
586
638
|
onDone: settle
|
|
587
|
-
},
|
|
588
|
-
if (initial) started = true;
|
|
589
|
-
return !closed;
|
|
590
|
-
});
|
|
639
|
+
}, () => !closed);
|
|
591
640
|
} catch (err) {
|
|
592
641
|
settle();
|
|
593
642
|
throw err;
|
|
@@ -634,22 +683,67 @@ function createHydrationSerializer({
|
|
|
634
683
|
onDone,
|
|
635
684
|
scopeId,
|
|
636
685
|
onError,
|
|
637
|
-
plugins
|
|
686
|
+
plugins,
|
|
687
|
+
late
|
|
638
688
|
}) {
|
|
639
689
|
const resolvedPlugins = resolveSerializerPlugins(plugins);
|
|
640
690
|
const disabledFeatures = defaultDisabledFeatures() | serializeOnlyDisabledFeatures();
|
|
641
691
|
const refs = new Map();
|
|
642
|
-
|
|
692
|
+
const serialize = (key, value, callbacks, live) => crossSerializeStream(value, {
|
|
643
693
|
scopeId,
|
|
644
694
|
refs,
|
|
645
695
|
plugins: resolvedPlugins,
|
|
646
696
|
disabledFeatures,
|
|
647
697
|
onSerialize(data, initial) {
|
|
648
|
-
if (!live(
|
|
698
|
+
if (!live()) return;
|
|
649
699
|
onData(initial ? HYDRATION_GLOBAL + '["' + serializeKey(key) + '"]=' + data : data);
|
|
650
700
|
},
|
|
651
701
|
...callbacks
|
|
652
|
-
})
|
|
702
|
+
});
|
|
703
|
+
return createKeyedSerializer(late ? late(serialize, refs, onData, scopeId) : serialize, onError, onDone);
|
|
704
|
+
}
|
|
705
|
+
function rejectUnserializedKey(serialize, refs, onData, scopeId, plain) {
|
|
706
|
+
let taken = 0;
|
|
707
|
+
let fresh = [];
|
|
708
|
+
const set = refs.set;
|
|
709
|
+
refs.set = (value, id) => {
|
|
710
|
+
taken++;
|
|
711
|
+
fresh.push(value);
|
|
712
|
+
return set.call(refs, value, id);
|
|
713
|
+
};
|
|
714
|
+
Object.defineProperty(refs, "size", {
|
|
715
|
+
get: () => taken
|
|
716
|
+
});
|
|
717
|
+
return (key, value, callbacks, live) => {
|
|
718
|
+
const sent = [];
|
|
719
|
+
const failed = () => {
|
|
720
|
+
for (const ref of fresh) refs.delete(ref);
|
|
721
|
+
fresh = [];
|
|
722
|
+
const ids = new Set();
|
|
723
|
+
for (const ref of sent) {
|
|
724
|
+
const id = refs.get(ref);
|
|
725
|
+
if (ref instanceof Promise) ids.add(id + 1);else if (isStream(ref) || Object.getPrototypeOf(ref) === Object.prototype && !Object.keys(ref).length) ids.add(id);
|
|
726
|
+
}
|
|
727
|
+
if (!ids.size) return;
|
|
728
|
+
const text = plain && plain(key);
|
|
729
|
+
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))}";
|
|
730
|
+
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]);
|
|
731
|
+
onData("($R=>{const e=new Error(" + message + ");" + body + "})(" + (scopeId == null ? "$R" : '$R["' + serializeKey(scopeId) + '"]') + ")");
|
|
732
|
+
};
|
|
733
|
+
return serialize(key, value, {
|
|
734
|
+
...callbacks,
|
|
735
|
+
onError: callbacks.onError && (err => {
|
|
736
|
+
if (live()) failed();
|
|
737
|
+
callbacks.onError(err);
|
|
738
|
+
})
|
|
739
|
+
},
|
|
740
|
+
() => {
|
|
741
|
+
if (!live()) return false;
|
|
742
|
+
sent.push(...fresh);
|
|
743
|
+
fresh = [];
|
|
744
|
+
return true;
|
|
745
|
+
});
|
|
746
|
+
};
|
|
653
747
|
}
|
|
654
748
|
function getLocalHeaderScript(id) {
|
|
655
749
|
return getCrossReferenceHeader(id) + ";";
|
|
@@ -1055,7 +1149,7 @@ function resolveAssets(moduleUrl, manifest) {
|
|
|
1055
1149
|
if (!manifest) return null;
|
|
1056
1150
|
const base = manifest._base;
|
|
1057
1151
|
const entry = manifest[moduleUrl];
|
|
1058
|
-
if (!entry) return null;
|
|
1152
|
+
if (!entry || typeof entry !== "object") return null;
|
|
1059
1153
|
const css = [];
|
|
1060
1154
|
const js = [];
|
|
1061
1155
|
let preloads;
|
|
@@ -1064,7 +1158,7 @@ function resolveAssets(moduleUrl, manifest) {
|
|
|
1064
1158
|
if (visited.has(key)) return;
|
|
1065
1159
|
visited.add(key);
|
|
1066
1160
|
const e = manifest[key];
|
|
1067
|
-
if (!e) return;
|
|
1161
|
+
if (!e || typeof e !== "object") return;
|
|
1068
1162
|
js.push(joinAssetPath(base, e.file));
|
|
1069
1163
|
if (e.css) for (let i = 0; i < e.css.length; i++) css.push(joinAssetPath(base, e.css[i]));
|
|
1070
1164
|
if (e.preloads) {
|
|
@@ -1103,18 +1197,19 @@ function registerEntryAssets(manifest) {
|
|
|
1103
1197
|
const ctx = sharedConfig.context;
|
|
1104
1198
|
if (!ctx?.registerAsset) return;
|
|
1105
1199
|
for (const key in manifest) {
|
|
1106
|
-
|
|
1200
|
+
const entry = manifest[key];
|
|
1201
|
+
if (entry && entry.isEntry) {
|
|
1107
1202
|
const assets = resolveAssets(key, manifest);
|
|
1108
1203
|
if (assets) {
|
|
1109
1204
|
if (assets.preloads) for (let i = 0; i < assets.preloads.length; i++) ctx.registerAsset("preload", assets.preloads[i]);
|
|
1110
1205
|
for (let i = 0; i < assets.css.length; i++) ctx.registerAsset("style", assets.css[i]);
|
|
1111
|
-
for (let i = 1; i < assets.js.length; i++) ctx.registerAsset("module", assets.js[i]);
|
|
1206
|
+
for (let i = 1; i < assets.js.length; i++) ctx.registerAsset("module", assets.js[i], true);
|
|
1112
1207
|
}
|
|
1113
1208
|
return;
|
|
1114
1209
|
}
|
|
1115
1210
|
}
|
|
1116
1211
|
}
|
|
1117
|
-
function createAssetTracking() {
|
|
1212
|
+
function createAssetTracking(lowPriorityPreloads) {
|
|
1118
1213
|
const boundaryModules = new Map();
|
|
1119
1214
|
const boundaryStyles = new Map();
|
|
1120
1215
|
const emittedAssets = new Set();
|
|
@@ -1126,6 +1221,7 @@ function createAssetTracking() {
|
|
|
1126
1221
|
emittedAssets,
|
|
1127
1222
|
inlineStyles,
|
|
1128
1223
|
preloadLinks: null,
|
|
1224
|
+
lowModules: lowPriorityPreloads !== false ? new Set() : null,
|
|
1129
1225
|
registerInlineStyle(desc) {
|
|
1130
1226
|
let entry = inlineStyles.get(desc.id);
|
|
1131
1227
|
if (!entry) {
|
|
@@ -1237,6 +1333,7 @@ function preloadInvalid(field, message, value) {
|
|
|
1237
1333
|
}
|
|
1238
1334
|
});
|
|
1239
1335
|
}
|
|
1336
|
+
const SSR_NODE = /*#__PURE__*/Symbol.for("solid.ssrNode");
|
|
1240
1337
|
function unrecognizedInsert(node) {
|
|
1241
1338
|
devCheck({
|
|
1242
1339
|
code: "UNRECOGNIZED_INSERT_VALUE",
|
|
@@ -1503,7 +1600,7 @@ function emitHeadResource(registry, context, tracking, emitResource, nonce, desc
|
|
|
1503
1600
|
if (plain && props.href != null) {
|
|
1504
1601
|
const isCss = isCssUrl(props.href);
|
|
1505
1602
|
if (rel === "stylesheet" ? isCss : !isCss) {
|
|
1506
|
-
context.registerAsset(rel === "stylesheet" ? "style" : "module", props.href);
|
|
1603
|
+
context.registerAsset(rel === "stylesheet" ? "style" : "module", props.href, true);
|
|
1507
1604
|
return;
|
|
1508
1605
|
}
|
|
1509
1606
|
}
|
|
@@ -1752,6 +1849,10 @@ function nonceDestination(tag, props) {
|
|
|
1752
1849
|
return "script";
|
|
1753
1850
|
}
|
|
1754
1851
|
}
|
|
1852
|
+
function modulePreloadLink(url, scriptAttr, lowModules) {
|
|
1853
|
+
const priority = lowModules && !lowModules.has(url) ? ' fetchpriority="low"' : "";
|
|
1854
|
+
return `<link rel="modulepreload" href="${url}"${priority}${scriptAttr}>`;
|
|
1855
|
+
}
|
|
1755
1856
|
function nonceAttr(nonce, destination) {
|
|
1756
1857
|
if (!nonce || !destination) return "";
|
|
1757
1858
|
return destination === "script" ? nonce.scriptAttr : nonce.styleAttr;
|
|
@@ -1829,7 +1930,8 @@ function tagInfo(tag) {
|
|
|
1829
1930
|
textarea: tag === "textarea",
|
|
1830
1931
|
raw: tag === "script" || tag === "style",
|
|
1831
1932
|
formDefaults,
|
|
1832
|
-
formAttributes
|
|
1933
|
+
formAttributes,
|
|
1934
|
+
sel: tag === "select" ? 1 : tag === "option" ? 2 : 0
|
|
1833
1935
|
};
|
|
1834
1936
|
if (tagInfos.size < 512) tagInfos.set(tag, info);
|
|
1835
1937
|
}
|
|
@@ -1867,7 +1969,7 @@ function renderToString(code, options = {}) {
|
|
|
1867
1969
|
},
|
|
1868
1970
|
onError: serializerErrorHook(options.onError)
|
|
1869
1971
|
});
|
|
1870
|
-
const tracking = createAssetTracking();
|
|
1972
|
+
const tracking = createAssetTracking(options.lowPriorityPreloads);
|
|
1871
1973
|
const headRegistry = createHeadRegistry();
|
|
1872
1974
|
let closed = false;
|
|
1873
1975
|
sharedConfig.context = {
|
|
@@ -1887,7 +1989,7 @@ function renderToString(code, options = {}) {
|
|
|
1887
1989
|
}
|
|
1888
1990
|
serializer.write(id, p);
|
|
1889
1991
|
},
|
|
1890
|
-
registerAsset(type, value) {
|
|
1992
|
+
registerAsset(type, value, defaultPriority) {
|
|
1891
1993
|
if (type === "preload") {
|
|
1892
1994
|
registerPreloadLink(tracking, headRegistry, value, nonce);
|
|
1893
1995
|
return;
|
|
@@ -1904,6 +2006,7 @@ function renderToString(code, options = {}) {
|
|
|
1904
2006
|
}
|
|
1905
2007
|
styles.add(value);
|
|
1906
2008
|
}
|
|
2009
|
+
if (defaultPriority && tracking.lowModules) tracking.lowModules.add(value);
|
|
1907
2010
|
tracking.emittedAssets.add(value);
|
|
1908
2011
|
}
|
|
1909
2012
|
};
|
|
@@ -1930,7 +2033,7 @@ function renderToString(code, options = {}) {
|
|
|
1930
2033
|
closed = true;
|
|
1931
2034
|
serializer.close();
|
|
1932
2035
|
const head = renderShellHead(headRegistry, nonce, null, noScripts, traceMetaMarkup(context.trace));
|
|
1933
|
-
const document = withShellEnd(assembleDocument(
|
|
2036
|
+
const document = withShellEnd(assembleDocument(html, tracking.emittedAssets, tracking.preloadLinks, tracking.inlineStyles, scripts.length ? scripts : "", nonce, head, onHead, tracking.lowModules), context, renderId, nonce, noScripts);
|
|
1934
2037
|
if (render) render.shell();
|
|
1935
2038
|
if (requestEvent && requestEvent.response) {
|
|
1936
2039
|
commitResponseStub(requestEvent.response, {
|
|
@@ -1979,9 +2082,7 @@ function renderToStream(code, options = {}) {
|
|
|
1979
2082
|
let rootOwner;
|
|
1980
2083
|
let serializer;
|
|
1981
2084
|
let disconnected = false;
|
|
1982
|
-
let failed = false;
|
|
1983
2085
|
let onFailed;
|
|
1984
|
-
let onDisconnectedBeforeShell;
|
|
1985
2086
|
const defuse = p => {
|
|
1986
2087
|
if (p && typeof p.then === "function") p.then(undefined, () => {});
|
|
1987
2088
|
};
|
|
@@ -1993,11 +2094,11 @@ function renderToStream(code, options = {}) {
|
|
|
1993
2094
|
close() {}
|
|
1994
2095
|
};
|
|
1995
2096
|
const onFailure = complete => {
|
|
1996
|
-
if (
|
|
2097
|
+
if (dead) return complete(undefined, disconnected || undefined);
|
|
1997
2098
|
const prev = onFailed;
|
|
1998
|
-
onFailed = prev ? sink => {
|
|
1999
|
-
prev(sink);
|
|
2000
|
-
complete(sink);
|
|
2099
|
+
onFailed = prev ? (sink, gone) => {
|
|
2100
|
+
prev(sink, gone);
|
|
2101
|
+
complete(sink, gone);
|
|
2001
2102
|
} : complete;
|
|
2002
2103
|
};
|
|
2003
2104
|
const abandon = (disconnect, quiet) => {
|
|
@@ -2015,11 +2116,12 @@ function renderToStream(code, options = {}) {
|
|
|
2015
2116
|
}, null);
|
|
2016
2117
|
dead = true;
|
|
2017
2118
|
completed = true;
|
|
2018
|
-
if (disconnect) disconnected =
|
|
2119
|
+
if (disconnect) disconnected = disconnect;
|
|
2019
2120
|
if (render) settleRender(render, rootOwner, disconnect ? "abandoned" : "error");
|
|
2020
2121
|
const sink = writable;
|
|
2021
2122
|
buffer = {
|
|
2022
|
-
write() {}
|
|
2123
|
+
write() {},
|
|
2124
|
+
flush() {}
|
|
2023
2125
|
};
|
|
2024
2126
|
writable = {
|
|
2025
2127
|
end() {}
|
|
@@ -2044,10 +2146,7 @@ function renderToStream(code, options = {}) {
|
|
|
2044
2146
|
for (const p of stubBatch.values()) defuse(p);
|
|
2045
2147
|
stubBatch = null;
|
|
2046
2148
|
}
|
|
2047
|
-
|
|
2048
|
-
failed = true;
|
|
2049
|
-
onFailed && onFailed(sink);
|
|
2050
|
-
} else if (!sink && onDisconnectedBeforeShell) onDisconnectedBeforeShell();
|
|
2149
|
+
onFailed && onFailed(sink, disconnect);
|
|
2051
2150
|
};
|
|
2052
2151
|
const failRender = err => {
|
|
2053
2152
|
reportFailure(err, "failed");
|
|
@@ -2116,21 +2215,71 @@ function renderToStream(code, options = {}) {
|
|
|
2116
2215
|
let stableOrder = false;
|
|
2117
2216
|
let parkedWrites = null;
|
|
2118
2217
|
const byKey = (a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0;
|
|
2119
|
-
|
|
2120
|
-
|
|
2218
|
+
let stranded = false;
|
|
2219
|
+
let writingRecord = false;
|
|
2220
|
+
let recordFailed = false;
|
|
2221
|
+
const plainRecords = new WeakMap();
|
|
2222
|
+
const caught = new Set();
|
|
2223
|
+
let unclaimed = null;
|
|
2224
|
+
const rejected = new Map();
|
|
2225
|
+
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`;
|
|
2226
|
+
const plainFor = (id, value) => {
|
|
2227
|
+
const keyed = value !== null && typeof value === "object";
|
|
2228
|
+
let plain = keyed && plainRecords.get(value);
|
|
2229
|
+
if (!plain) {
|
|
2230
|
+
plain = new Error(plainMessage(id, value));
|
|
2231
|
+
if (keyed) plainRecords.set(value, plain);
|
|
2232
|
+
}
|
|
2233
|
+
return plain;
|
|
2234
|
+
};
|
|
2235
|
+
const claim = () => {
|
|
2236
|
+
if (unclaimed) {
|
|
2237
|
+
for (const reason of unclaimed) if (!caught.has(reason)) stranded = true;
|
|
2238
|
+
unclaimed = null;
|
|
2239
|
+
}
|
|
2240
|
+
return stranded;
|
|
2241
|
+
};
|
|
2242
|
+
const claimLater = reason => {
|
|
2243
|
+
if (firstFlushed || stranded || caught.has(reason)) return;
|
|
2244
|
+
if (!unclaimed) {
|
|
2245
|
+
unclaimed = new Set();
|
|
2246
|
+
deferFlush(() => {
|
|
2247
|
+
if (!rootHoles && claim()) abandon();
|
|
2248
|
+
});
|
|
2249
|
+
}
|
|
2250
|
+
unclaimed.add(reason);
|
|
2251
|
+
};
|
|
2252
|
+
const handOver = (id, value, error) => {
|
|
2253
|
+
if (!error || options.serializer) return serializer.write(id, value);
|
|
2254
|
+
let plain = value !== null && typeof value === "object" && plainRecords.get(value);
|
|
2255
|
+
if (!plain) {
|
|
2256
|
+
recordFailed = false;
|
|
2257
|
+
writingRecord = true;
|
|
2258
|
+
try {
|
|
2259
|
+
serializer.write(id, value);
|
|
2260
|
+
} finally {
|
|
2261
|
+
writingRecord = false;
|
|
2262
|
+
}
|
|
2263
|
+
if (!recordFailed) return;
|
|
2264
|
+
plain = plainFor(id, value);
|
|
2265
|
+
}
|
|
2266
|
+
serializer.write(id, plain);
|
|
2267
|
+
};
|
|
2268
|
+
const write = (id, value, error) => {
|
|
2269
|
+
if (stableOrder && !dead) (parkedWrites ||= []).push([id, value, error]);else handOver(id, value, error);
|
|
2121
2270
|
};
|
|
2122
2271
|
const flushParkedWrites = () => {
|
|
2123
2272
|
if (!parkedWrites) return;
|
|
2124
2273
|
const writes = parkedWrites.sort(byKey);
|
|
2125
2274
|
parkedWrites = null;
|
|
2126
|
-
for (let i = 0; i < writes.length; i++)
|
|
2275
|
+
for (let i = 0; i < writes.length; i++) handOver(writes[i][0], writes[i][1], writes[i][2]);
|
|
2127
2276
|
};
|
|
2128
2277
|
const flushStubBatch = () => {
|
|
2129
2278
|
if (!stubBatch) return;
|
|
2130
2279
|
const entries = [...stubBatch];
|
|
2131
2280
|
stubBatch = null;
|
|
2132
2281
|
if (stableOrder) entries.sort(byKey);
|
|
2133
|
-
for (let i = 0; i < entries.length; i++)
|
|
2282
|
+
for (let i = 0; i < entries.length; i++) handOver(entries[i][0], entries[i][1]);
|
|
2134
2283
|
};
|
|
2135
2284
|
let headerEmitted = false;
|
|
2136
2285
|
const pushTask = task => {
|
|
@@ -2148,6 +2297,7 @@ function renderToStream(code, options = {}) {
|
|
|
2148
2297
|
const onDone = () => {
|
|
2149
2298
|
if (dead) return;
|
|
2150
2299
|
writeTasks();
|
|
2300
|
+
if (claim()) return abandon();
|
|
2151
2301
|
lastBlockingSize = blockingPromises.size;
|
|
2152
2302
|
doShell();
|
|
2153
2303
|
onCompleteAll && onCompleteAll({
|
|
@@ -2191,7 +2341,7 @@ function renderToStream(code, options = {}) {
|
|
|
2191
2341
|
},
|
|
2192
2342
|
asset(type, value) {
|
|
2193
2343
|
if (type === "module") {
|
|
2194
|
-
buffer.write(
|
|
2344
|
+
buffer.write(modulePreloadLink(value, nonceAttr(nonce, "script"), tracking.lowModules));
|
|
2195
2345
|
} else if (type === "preload") {
|
|
2196
2346
|
buffer.write(`<link${value.attrHtml}>`);
|
|
2197
2347
|
} else if (type === "inline-style") {
|
|
@@ -2201,7 +2351,7 @@ function renderToStream(code, options = {}) {
|
|
|
2201
2351
|
}
|
|
2202
2352
|
},
|
|
2203
2353
|
shell(shellHtml, meta) {
|
|
2204
|
-
buffer.write(withShellEnd(assembleDocument(shellHtml, meta.preloads, meta.preloadLinks, meta.inlineStyles, meta.tasks.length ? meta.tasks : "", nonce, meta.head, onHead), context, renderId, nonce, noScripts));
|
|
2354
|
+
buffer.write(withShellEnd(assembleDocument(shellHtml, meta.preloads, meta.preloadLinks, meta.inlineStyles, meta.tasks.length ? meta.tasks : "", nonce, meta.head, onHead, tracking.lowModules), context, renderId, nonce, noScripts));
|
|
2205
2355
|
},
|
|
2206
2356
|
...options.sink
|
|
2207
2357
|
};
|
|
@@ -2210,7 +2360,19 @@ function renderToStream(code, options = {}) {
|
|
|
2210
2360
|
plugins: options.plugins,
|
|
2211
2361
|
onData: payload => sink.data(payload),
|
|
2212
2362
|
onDone,
|
|
2213
|
-
onError:
|
|
2363
|
+
onError: (err, key) => {
|
|
2364
|
+
const rejection = !options.serializer && !writingRecord && rejected.has(key);
|
|
2365
|
+
const reason = rejection && rejected.get(key);
|
|
2366
|
+
if (!rejection || reason === null || typeof reason !== "object" || !plainRecords.has(reason)) reportFailure(err, "serialize");
|
|
2367
|
+
if (writingRecord) recordFailed = true;else if (rejection) {
|
|
2368
|
+
plainFor(key, reason);
|
|
2369
|
+
claimLater(reason);
|
|
2370
|
+
} else if (!options.serializer && !firstFlushed && !stranded) {
|
|
2371
|
+
stranded = true;
|
|
2372
|
+
deferFlush(() => abandon());
|
|
2373
|
+
}
|
|
2374
|
+
},
|
|
2375
|
+
late: (serialize, refs, onData, scopeId) => rejectUnserializedKey(serialize, refs, onData, scopeId, key => !firstFlushed && rejected.has(key) ? plainMessage(key, rejected.get(key)) : undefined)
|
|
2214
2376
|
});
|
|
2215
2377
|
let rootAssetsSerialized = false;
|
|
2216
2378
|
const serializeRootAssets = () => {
|
|
@@ -2289,7 +2451,10 @@ function renderToStream(code, options = {}) {
|
|
|
2289
2451
|
raced.catch(() => {});
|
|
2290
2452
|
pendingSerialized.set(id, settle);
|
|
2291
2453
|
const drop = () => pendingSerialized.delete(id);
|
|
2292
|
-
p.then(drop,
|
|
2454
|
+
p.then(drop, reason => {
|
|
2455
|
+
drop();
|
|
2456
|
+
rejected.set(id, reason);
|
|
2457
|
+
});
|
|
2293
2458
|
return raced;
|
|
2294
2459
|
};
|
|
2295
2460
|
const abandonSubtree = (key, error) => {
|
|
@@ -2378,7 +2543,7 @@ function renderToStream(code, options = {}) {
|
|
|
2378
2543
|
tmp += payload;
|
|
2379
2544
|
}
|
|
2380
2545
|
};
|
|
2381
|
-
const tracking = createAssetTracking();
|
|
2546
|
+
const tracking = createAssetTracking(options.lowPriorityPreloads);
|
|
2382
2547
|
const headRegistry = createHeadRegistry();
|
|
2383
2548
|
let headScriptFlushed = false;
|
|
2384
2549
|
const emitHeadOps = (key, ops) => {
|
|
@@ -2403,7 +2568,7 @@ function renderToStream(code, options = {}) {
|
|
|
2403
2568
|
}
|
|
2404
2569
|
}, nonce, tags);
|
|
2405
2570
|
},
|
|
2406
|
-
registerAsset(type, value) {
|
|
2571
|
+
registerAsset(type, value, defaultPriority) {
|
|
2407
2572
|
if (type === "preload") {
|
|
2408
2573
|
const entry = registerPreloadLink(tracking, headRegistry, value, nonce);
|
|
2409
2574
|
if (entry && firstFlushed) sink.asset("preload", entry);
|
|
@@ -2425,6 +2590,7 @@ function renderToStream(code, options = {}) {
|
|
|
2425
2590
|
}
|
|
2426
2591
|
styles.add(value);
|
|
2427
2592
|
}
|
|
2593
|
+
if (defaultPriority && tracking.lowModules) tracking.lowModules.add(value);
|
|
2428
2594
|
if (!tracking.emittedAssets.has(value)) {
|
|
2429
2595
|
tracking.emittedAssets.add(value);
|
|
2430
2596
|
if (firstFlushed) sink.asset(type, value);
|
|
@@ -2451,12 +2617,17 @@ function renderToStream(code, options = {}) {
|
|
|
2451
2617
|
const last = html.indexOf(`<!--!$/${id}-->`, first + placeholder.length);
|
|
2452
2618
|
html = html.slice(0, first) + resolveSSRSync(escape(payloadFn())) + html.slice(last + placeholder.length + 1);
|
|
2453
2619
|
},
|
|
2454
|
-
serialize(id, p, deferStream) {
|
|
2620
|
+
serialize(id, p, deferStream, errorRecord) {
|
|
2455
2621
|
p = guardChannel(p);
|
|
2456
2622
|
if (p && typeof p === "object" && typeof p.then === "function") {
|
|
2457
2623
|
if (!firstFlushed && deferStream) {
|
|
2458
2624
|
blockingPromises.add(p);
|
|
2459
|
-
p.then(d => write(id, d)).catch(e =>
|
|
2625
|
+
p.then(d => write(id, d)).catch(e => {
|
|
2626
|
+
rejected.set(id, e);
|
|
2627
|
+
const r = Promise.reject(e);
|
|
2628
|
+
r.catch(() => {});
|
|
2629
|
+
write(id, r);
|
|
2630
|
+
});
|
|
2460
2631
|
return;
|
|
2461
2632
|
}
|
|
2462
2633
|
p = trackSerialized(id, p);
|
|
@@ -2465,7 +2636,7 @@ function renderToStream(code, options = {}) {
|
|
|
2465
2636
|
return;
|
|
2466
2637
|
}
|
|
2467
2638
|
}
|
|
2468
|
-
write(id, p);
|
|
2639
|
+
write(id, p, errorRecord);
|
|
2469
2640
|
},
|
|
2470
2641
|
escape: escape,
|
|
2471
2642
|
resolve: resolveSSRNode,
|
|
@@ -2539,7 +2710,7 @@ function renderToStream(code, options = {}) {
|
|
|
2539
2710
|
const styles = collectStreamStyles(key, tracking, headStyles);
|
|
2540
2711
|
const headOps = error ? null : flushHeadFragment(headRegistry, key, nonce);
|
|
2541
2712
|
if (headOps) emitHeadOps(key, headOps);
|
|
2542
|
-
sink.fragment(key,
|
|
2713
|
+
sink.fragment(key, value !== undefined ? value : error ? "" : " ", {
|
|
2543
2714
|
styles,
|
|
2544
2715
|
revealGroup,
|
|
2545
2716
|
error: error ? ssrSanitizeError(error, null, undefined, undefined, errorScope) : error
|
|
@@ -2570,13 +2741,22 @@ function renderToStream(code, options = {}) {
|
|
|
2570
2741
|
context.failRender = failRender;
|
|
2571
2742
|
context.errorPolicy = options.onError;
|
|
2572
2743
|
context._errorScope = errorScope;
|
|
2744
|
+
context.contained = (error, wire) => {
|
|
2745
|
+
caught.add(error);
|
|
2746
|
+
caught.add(wire);
|
|
2747
|
+
};
|
|
2573
2748
|
context.flushed = () => firstFlushed;
|
|
2574
2749
|
context.trace = requestEvent ? traceForEvent(requestEvent) : traceFor(context, undefined);
|
|
2575
2750
|
render = timeDocument(context, context.trace, "stream", requestEvent);
|
|
2576
2751
|
registerEntryAssets(manifest);
|
|
2577
2752
|
context.writer = createHydrationWriter(context, () => !completed);
|
|
2578
2753
|
const signal = options.signal;
|
|
2579
|
-
|
|
2754
|
+
let cancelled = false;
|
|
2755
|
+
const onAbort = signal ? () => {
|
|
2756
|
+
if (dead) return;
|
|
2757
|
+
cancelled = true;
|
|
2758
|
+
abandon("signal", !!(signal.reason && signal.reason.quiet === true));
|
|
2759
|
+
} : undefined;
|
|
2580
2760
|
const endEdges = context.edges ? beginEdgesRender() : undefined;
|
|
2581
2761
|
let html;
|
|
2582
2762
|
try {
|
|
@@ -2682,7 +2862,7 @@ function renderToStream(code, options = {}) {
|
|
|
2682
2862
|
flushStubBatch();
|
|
2683
2863
|
const head = renderShellHead(headRegistry, nonce, k => registry.has(k), noScripts, traceMetaMarkup(context.trace));
|
|
2684
2864
|
if (render) render.shell();
|
|
2685
|
-
sink.shell(
|
|
2865
|
+
sink.shell(html, {
|
|
2686
2866
|
preloads: tracking.emittedAssets,
|
|
2687
2867
|
preloadLinks: tracking.preloadLinks,
|
|
2688
2868
|
inlineStyles: tracking.inlineStyles,
|
|
@@ -2738,9 +2918,12 @@ function renderToStream(code, options = {}) {
|
|
|
2738
2918
|
const pipeToImpl = w => {
|
|
2739
2919
|
let resolve;
|
|
2740
2920
|
const p = new Promise(r => resolve = r);
|
|
2741
|
-
|
|
2921
|
+
let closeOnAbort = () => w.close().catch(() => {});
|
|
2922
|
+
onFailure((sink, gone) => {
|
|
2742
2923
|
try {
|
|
2743
|
-
if (
|
|
2924
|
+
if (!gone) {
|
|
2925
|
+
if (sink) sink.end();else w.close().catch(() => {});
|
|
2926
|
+
} else if (gone === "signal") closeOnAbort();
|
|
2744
2927
|
} catch (_) {}
|
|
2745
2928
|
resolve();
|
|
2746
2929
|
});
|
|
@@ -2755,6 +2938,7 @@ function renderToStream(code, options = {}) {
|
|
|
2755
2938
|
return;
|
|
2756
2939
|
}
|
|
2757
2940
|
if (!shellCompleted) return flush();
|
|
2941
|
+
if (claim()) return abandon();
|
|
2758
2942
|
const encoder = new TextEncoder();
|
|
2759
2943
|
const writer = w.getWriter();
|
|
2760
2944
|
let pendingWrites = Promise.resolve();
|
|
@@ -2766,6 +2950,10 @@ function renderToStream(code, options = {}) {
|
|
|
2766
2950
|
}
|
|
2767
2951
|
};
|
|
2768
2952
|
writer.closed && writer.closed.catch(failed);
|
|
2953
|
+
closeOnAbort = () => {
|
|
2954
|
+
ended = true;
|
|
2955
|
+
pendingWrites.then(() => writer.close()).catch(() => {});
|
|
2956
|
+
};
|
|
2769
2957
|
buffer = writable = coalesceWrites(payload => {
|
|
2770
2958
|
pendingWrites = pendingWrites.then(() => writer.write(encoder.encode(payload))).catch(failed);
|
|
2771
2959
|
}, () => {
|
|
@@ -2797,7 +2985,7 @@ function renderToStream(code, options = {}) {
|
|
|
2797
2985
|
event: requestEvent
|
|
2798
2986
|
});
|
|
2799
2987
|
};
|
|
2800
|
-
const p = new Promise(resolve => {
|
|
2988
|
+
const p = new Promise((resolve, reject) => {
|
|
2801
2989
|
function complete() {
|
|
2802
2990
|
freezeHead();
|
|
2803
2991
|
dispose();
|
|
@@ -2810,11 +2998,12 @@ function renderToStream(code, options = {}) {
|
|
|
2810
2998
|
complete();
|
|
2811
2999
|
};
|
|
2812
3000
|
} else onCompleteAll = complete;
|
|
2813
|
-
onFailure(() => resolve(tmp));
|
|
3001
|
+
onFailure(() => cancelled ? reject(signal.reason) : resolve(tmp));
|
|
2814
3002
|
function flush() {
|
|
2815
3003
|
allSettled(blockingPromises).then(awaited => {
|
|
2816
3004
|
scheduleFlush(() => {
|
|
2817
3005
|
if (dead) return;
|
|
3006
|
+
sharedConfig.context = context;
|
|
2818
3007
|
try {
|
|
2819
3008
|
if (blockingPromises.size !== lastBlockingSize || !resolveRootHoles() || blockingPromises.size !== lastBlockingSize || !headShellReady(headRegistry, p => blockingPromises.add(p))) return flush();
|
|
2820
3009
|
} catch (err) {
|
|
@@ -2832,15 +3021,12 @@ function renderToStream(code, options = {}) {
|
|
|
2832
3021
|
pipe(w) {
|
|
2833
3022
|
claimConsumer("pipe");
|
|
2834
3023
|
const abandoned = w[SHELL_ABANDONED];
|
|
2835
|
-
onFailure(sink => {
|
|
3024
|
+
onFailure((sink, gone) => {
|
|
2836
3025
|
try {
|
|
2837
|
-
sink ? sink.end() : abandoned ? abandoned() : w.end();
|
|
3026
|
+
if (!gone) sink ? sink.end() : abandoned ? abandoned() : w.end();else if (!sink && abandoned) abandoned();else if (gone === "signal") w.end();
|
|
2838
3027
|
} catch (_) {}
|
|
2839
3028
|
});
|
|
2840
|
-
if (abandoned)
|
|
2841
|
-
w[ABANDON_RENDER] = abandon;
|
|
2842
|
-
if (disconnected) abandoned();else onDisconnectedBeforeShell = abandoned;
|
|
2843
|
-
}
|
|
3029
|
+
if (abandoned) w[ABANDON_RENDER] = abandon;
|
|
2844
3030
|
function flush() {
|
|
2845
3031
|
allSettled(blockingPromises).then(awaited => {
|
|
2846
3032
|
scheduleFlush(() => {
|
|
@@ -2852,6 +3038,7 @@ function renderToStream(code, options = {}) {
|
|
|
2852
3038
|
return;
|
|
2853
3039
|
}
|
|
2854
3040
|
if (!shellCompleted) return flush();
|
|
3041
|
+
if (claim()) return abandon();
|
|
2855
3042
|
const sink = guardSink(w);
|
|
2856
3043
|
buffer = writable = coalesceWrites(sink.write, sink.end);
|
|
2857
3044
|
buffer.write(tmp);
|
|
@@ -2917,6 +3104,8 @@ function buildAsyncWrap(err, node) {
|
|
|
2917
3104
|
fn.$rw = true;
|
|
2918
3105
|
if (suppress) fn.$lhSuppress = true;
|
|
2919
3106
|
if (node.$lhSkip) fn.$lhSkip = true;
|
|
3107
|
+
if (node.$lhInTag) fn.$lhInTag = true;
|
|
3108
|
+
if (node.$lhAttr) fn.$lhAttr = node.$lhAttr;
|
|
2920
3109
|
if (node.$lhBinding) fn.$lhBinding = node.$lhBinding;
|
|
2921
3110
|
return {
|
|
2922
3111
|
fn,
|
|
@@ -3129,7 +3318,8 @@ function createLiveHoles(sink, scoped, settled, errorScope) {
|
|
|
3129
3318
|
t: [""],
|
|
3130
3319
|
h: [],
|
|
3131
3320
|
p: [],
|
|
3132
|
-
rows: null
|
|
3321
|
+
rows: null,
|
|
3322
|
+
$: SSR_NODE
|
|
3133
3323
|
};
|
|
3134
3324
|
try {
|
|
3135
3325
|
result.rows = resolveValue(holeValue(hole), result);
|
|
@@ -3228,16 +3418,41 @@ function createLiveHoles(sink, scoped, settled, errorScope) {
|
|
|
3228
3418
|
},
|
|
3229
3419
|
nest(hole) {
|
|
3230
3420
|
const s = engine.scope;
|
|
3231
|
-
if (!s || s.h === hole || hole.$lhSkip || inScope && !inScope()) return undefined;
|
|
3421
|
+
if (!s || s.h === hole || hole.$lhSkip || hole.$lhInTag || inScope && !inScope()) return undefined;
|
|
3232
3422
|
engine.scope = scopeFor(hole);
|
|
3233
3423
|
return s;
|
|
3234
3424
|
},
|
|
3235
3425
|
content(hole) {
|
|
3426
|
+
if (hole.$lhInTag) {
|
|
3427
|
+
const cap = hole.$lhAttr;
|
|
3428
|
+
if (!cap || cap.adopted || engine.suppressed || engine.sweeping) return null;
|
|
3429
|
+
const r = tryResolveFunctionHole(hole);
|
|
3430
|
+
if (typeof r !== "string") {
|
|
3431
|
+
const res = {
|
|
3432
|
+
t: [""],
|
|
3433
|
+
h: [],
|
|
3434
|
+
p: [],
|
|
3435
|
+
$: SSR_NODE
|
|
3436
|
+
};
|
|
3437
|
+
appendResolvedNode(res, r);
|
|
3438
|
+
return res;
|
|
3439
|
+
}
|
|
3440
|
+
if (--cap.waiting === 0 && !cap.closed) {
|
|
3441
|
+
try {
|
|
3442
|
+
cap.base = attrPartsText(cap.parts);
|
|
3443
|
+
} catch (err) {
|
|
3444
|
+
cap.base = null;
|
|
3445
|
+
}
|
|
3446
|
+
if (cap.base !== null) engine.attr(cap);
|
|
3447
|
+
}
|
|
3448
|
+
return r;
|
|
3449
|
+
}
|
|
3236
3450
|
if (hole.$lhSuppress) {
|
|
3237
3451
|
const r = {
|
|
3238
3452
|
t: [""],
|
|
3239
3453
|
h: [],
|
|
3240
|
-
p: []
|
|
3454
|
+
p: [],
|
|
3455
|
+
$: SSR_NODE
|
|
3241
3456
|
};
|
|
3242
3457
|
let rows = null;
|
|
3243
3458
|
const b = hole.$lhBinding;
|
|
@@ -3342,7 +3557,8 @@ function createLiveHoles(sink, scoped, settled, errorScope) {
|
|
|
3342
3557
|
const r = {
|
|
3343
3558
|
t: [""],
|
|
3344
3559
|
h: [],
|
|
3345
|
-
p: []
|
|
3560
|
+
p: [],
|
|
3561
|
+
$: SSR_NODE
|
|
3346
3562
|
};
|
|
3347
3563
|
engine.suppressed++;
|
|
3348
3564
|
try {
|
|
@@ -3361,13 +3577,15 @@ function createLiveHoles(sink, scoped, settled, errorScope) {
|
|
|
3361
3577
|
res = {
|
|
3362
3578
|
t: ["", ""],
|
|
3363
3579
|
h: [escalated.fn],
|
|
3364
|
-
p: [escalated.p]
|
|
3580
|
+
p: [escalated.p],
|
|
3581
|
+
$: SSR_NODE
|
|
3365
3582
|
};
|
|
3366
3583
|
} else {
|
|
3367
3584
|
res = {
|
|
3368
3585
|
t: [""],
|
|
3369
3586
|
h: [],
|
|
3370
|
-
p: []
|
|
3587
|
+
p: [],
|
|
3588
|
+
$: SSR_NODE
|
|
3371
3589
|
};
|
|
3372
3590
|
try {
|
|
3373
3591
|
rows = resolveValue(value, res);
|
|
@@ -3397,20 +3615,59 @@ function createLiveHoles(sink, scoped, settled, errorScope) {
|
|
|
3397
3615
|
t[t.length - 1] += close;
|
|
3398
3616
|
sink.openBinding(key, b);
|
|
3399
3617
|
return {
|
|
3400
|
-
t,
|
|
3618
|
+
t: t,
|
|
3401
3619
|
h: res.h,
|
|
3402
|
-
p: res.p
|
|
3620
|
+
p: res.p,
|
|
3621
|
+
$: SSR_NODE
|
|
3403
3622
|
};
|
|
3404
3623
|
},
|
|
3405
3624
|
mint() {
|
|
3406
3625
|
return nextId++;
|
|
3407
3626
|
},
|
|
3627
|
+
open(text, off, hole) {
|
|
3628
|
+
const pending = hole && hole.$lhAttr;
|
|
3629
|
+
let inject;
|
|
3630
|
+
let id;
|
|
3631
|
+
if (pending && !pending.adopted && text.startsWith(pending.inject, off)) {
|
|
3632
|
+
pending.adopted = true;
|
|
3633
|
+
({
|
|
3634
|
+
id,
|
|
3635
|
+
inject
|
|
3636
|
+
} = pending);
|
|
3637
|
+
} else {
|
|
3638
|
+
id = nextId++;
|
|
3639
|
+
inject = ` data-lha="${id}"`;
|
|
3640
|
+
text = text.slice(0, off) + inject + text.slice(off);
|
|
3641
|
+
}
|
|
3642
|
+
const prefix = text.slice(off + inject.length);
|
|
3643
|
+
return {
|
|
3644
|
+
id,
|
|
3645
|
+
parts: [prefix],
|
|
3646
|
+
base: prefix,
|
|
3647
|
+
inject,
|
|
3648
|
+
waiting: 0,
|
|
3649
|
+
text
|
|
3650
|
+
};
|
|
3651
|
+
},
|
|
3652
|
+
retry(fn, cap) {
|
|
3653
|
+
if (typeof fn !== "function") return;
|
|
3654
|
+
fn.$lhInTag = true;
|
|
3655
|
+
if (cap) {
|
|
3656
|
+
fn.$lhAttr = cap;
|
|
3657
|
+
cap.waiting++;
|
|
3658
|
+
}
|
|
3659
|
+
},
|
|
3408
3660
|
active() {
|
|
3409
3661
|
return (!inScope || inScope()) && !(settled && settled());
|
|
3410
3662
|
},
|
|
3411
3663
|
attr(cap) {
|
|
3412
|
-
|
|
3413
|
-
|
|
3664
|
+
if (cap.waiting) {
|
|
3665
|
+
cap.owner = getOwner();
|
|
3666
|
+
cap.ctx = sharedConfig.context;
|
|
3667
|
+
return;
|
|
3668
|
+
}
|
|
3669
|
+
const owner = cap.owner !== undefined ? cap.owner : getOwner();
|
|
3670
|
+
const holeCtx = cap.ctx !== undefined ? cap.ctx : sharedConfig.context;
|
|
3414
3671
|
const b = {
|
|
3415
3672
|
key: "lha:" + cap.id,
|
|
3416
3673
|
children: [],
|
|
@@ -3425,29 +3682,7 @@ function createLiveHoles(sink, scoped, settled, errorScope) {
|
|
|
3425
3682
|
engine.gateHit = false;
|
|
3426
3683
|
let html = "";
|
|
3427
3684
|
try {
|
|
3428
|
-
|
|
3429
|
-
let groupVal = null;
|
|
3430
|
-
const run = () => {
|
|
3431
|
-
for (const part of cap.parts) {
|
|
3432
|
-
if (typeof part === "string") {
|
|
3433
|
-
html += part;
|
|
3434
|
-
continue;
|
|
3435
|
-
}
|
|
3436
|
-
let v;
|
|
3437
|
-
if (part.g) {
|
|
3438
|
-
if (group !== part.g) {
|
|
3439
|
-
group = part.g;
|
|
3440
|
-
groupVal = part.g();
|
|
3441
|
-
}
|
|
3442
|
-
v = groupVal[part.i];
|
|
3443
|
-
} else {
|
|
3444
|
-
v = part.f();
|
|
3445
|
-
}
|
|
3446
|
-
const vt = typeof v;
|
|
3447
|
-
if (vt === "string" || vt === "number") html += v;
|
|
3448
|
-
}
|
|
3449
|
-
};
|
|
3450
|
-
swept(owner, holeCtx, run);
|
|
3685
|
+
swept(owner, holeCtx, () => html = attrPartsText(cap.parts));
|
|
3451
3686
|
} catch (err) {
|
|
3452
3687
|
if (ssrHandleError(err, true)) {
|
|
3453
3688
|
if (!engine.sweptOwners) return;
|
|
@@ -3561,10 +3796,35 @@ function rowPatch(a, b) {
|
|
|
3561
3796
|
}
|
|
3562
3797
|
}
|
|
3563
3798
|
}
|
|
3799
|
+
function attrPartsText(parts) {
|
|
3800
|
+
let html = "";
|
|
3801
|
+
let group = null;
|
|
3802
|
+
let groupVal = null;
|
|
3803
|
+
for (const part of parts) {
|
|
3804
|
+
if (typeof part === "string") {
|
|
3805
|
+
html += part;
|
|
3806
|
+
continue;
|
|
3807
|
+
}
|
|
3808
|
+
let v;
|
|
3809
|
+
if (part.g) {
|
|
3810
|
+
if (group !== part.g) {
|
|
3811
|
+
group = part.g;
|
|
3812
|
+
groupVal = part.g();
|
|
3813
|
+
}
|
|
3814
|
+
v = groupVal[part.i];
|
|
3815
|
+
} else {
|
|
3816
|
+
v = part.f();
|
|
3817
|
+
}
|
|
3818
|
+
const vt = typeof v;
|
|
3819
|
+
if (vt === "string" || vt === "number") html += v;
|
|
3820
|
+
}
|
|
3821
|
+
return html;
|
|
3822
|
+
}
|
|
3564
3823
|
function ssr(t) {
|
|
3565
3824
|
const len = arguments.length;
|
|
3566
3825
|
if (len === 1) return {
|
|
3567
|
-
t
|
|
3826
|
+
t: t,
|
|
3827
|
+
$: SSR_NODE
|
|
3568
3828
|
};
|
|
3569
3829
|
let s = t[0];
|
|
3570
3830
|
let result = null;
|
|
@@ -3580,30 +3840,18 @@ function ssr(t) {
|
|
|
3580
3840
|
seg: -1,
|
|
3581
3841
|
off: hp.openOff[0]
|
|
3582
3842
|
};
|
|
3583
|
-
const captureStart =
|
|
3843
|
+
const captureStart = hole => {
|
|
3584
3844
|
if (cap) return true;
|
|
3585
3845
|
if (!lastOpen || live.suppressed || live.sweeping || !live.active()) return false;
|
|
3846
|
+
if (lastOpen.r === null && result !== null && result.t.length === 1) {
|
|
3847
|
+
lastOpen.r = result;
|
|
3848
|
+
lastOpen.seg = 0;
|
|
3849
|
+
}
|
|
3586
3850
|
if (lastOpen.r !== result || result !== null && lastOpen.seg !== result.t.length - 1) {
|
|
3587
3851
|
return false;
|
|
3588
3852
|
}
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
let prefix;
|
|
3592
|
-
if (result === null) {
|
|
3593
|
-
s = s.slice(0, lastOpen.off) + inject + s.slice(lastOpen.off);
|
|
3594
|
-
prefix = s.slice(lastOpen.off + inject.length);
|
|
3595
|
-
} else {
|
|
3596
|
-
const seg = result.t[lastOpen.seg];
|
|
3597
|
-
result.t[lastOpen.seg] = seg.slice(0, lastOpen.off) + inject + seg.slice(lastOpen.off);
|
|
3598
|
-
prefix = result.t[lastOpen.seg].slice(lastOpen.off + inject.length);
|
|
3599
|
-
}
|
|
3600
|
-
cap = {
|
|
3601
|
-
id,
|
|
3602
|
-
parts: [prefix],
|
|
3603
|
-
base: prefix,
|
|
3604
|
-
at: lastOpen.seg,
|
|
3605
|
-
inject
|
|
3606
|
-
};
|
|
3853
|
+
cap = live.open(result === null ? s : result.t[lastOpen.seg], lastOpen.off, hole);
|
|
3854
|
+
if (result === null) s = cap.text;else result.t[lastOpen.seg] = cap.text;
|
|
3607
3855
|
return true;
|
|
3608
3856
|
};
|
|
3609
3857
|
for (let i = 1; i < len; i++) {
|
|
@@ -3634,7 +3882,8 @@ function ssr(t) {
|
|
|
3634
3882
|
result = {
|
|
3635
3883
|
t: [s],
|
|
3636
3884
|
h: [],
|
|
3637
|
-
p: []
|
|
3885
|
+
p: [],
|
|
3886
|
+
$: SSR_NODE
|
|
3638
3887
|
};
|
|
3639
3888
|
s = "";
|
|
3640
3889
|
}
|
|
@@ -3644,18 +3893,23 @@ function ssr(t) {
|
|
|
3644
3893
|
if (Array.isArray(lastGroupVal)) {
|
|
3645
3894
|
value = lastGroupVal[lastGroupIdx++];
|
|
3646
3895
|
hasValue = true;
|
|
3647
|
-
if (live && !hp.pos[i - 1] && captureStart()) {
|
|
3896
|
+
if (live && !hp.pos[i - 1] && captureStart(hole)) {
|
|
3648
3897
|
cap.parts.push({
|
|
3649
3898
|
g: hole,
|
|
3650
3899
|
i: lastGroupIdx - 1
|
|
3651
3900
|
});
|
|
3652
3901
|
}
|
|
3653
3902
|
} else {
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3903
|
+
const slot = ssrGroupSlot(lastGroupVal.fn, lastGroupIdx++);
|
|
3904
|
+
if (live && !hp.pos[i - 1]) {
|
|
3905
|
+
const capturing = captureStart(hole);
|
|
3906
|
+
if (capturing) cap.parts.push({
|
|
3907
|
+
g: hole,
|
|
3908
|
+
i: lastGroupIdx - 1
|
|
3909
|
+
});
|
|
3910
|
+
live.retry(slot, capturing && cap);
|
|
3657
3911
|
}
|
|
3658
|
-
result.h.push(
|
|
3912
|
+
result.h.push(slot);
|
|
3659
3913
|
result.p.push(lastGroupVal.p);
|
|
3660
3914
|
result.t.push("");
|
|
3661
3915
|
}
|
|
@@ -3675,7 +3929,8 @@ function ssr(t) {
|
|
|
3675
3929
|
result = {
|
|
3676
3930
|
t: [s],
|
|
3677
3931
|
h: [],
|
|
3678
|
-
p: []
|
|
3932
|
+
p: [],
|
|
3933
|
+
$: SSR_NODE
|
|
3679
3934
|
};
|
|
3680
3935
|
s = "";
|
|
3681
3936
|
if (rs.merge !== undefined) mergeTemplateInto(result, rs.merge);else resolveSSRNode(rs.bail, result);
|
|
@@ -3693,7 +3948,8 @@ function ssr(t) {
|
|
|
3693
3948
|
result = {
|
|
3694
3949
|
t: [s],
|
|
3695
3950
|
h: [],
|
|
3696
|
-
p: []
|
|
3951
|
+
p: [],
|
|
3952
|
+
$: SSR_NODE
|
|
3697
3953
|
};
|
|
3698
3954
|
s = "";
|
|
3699
3955
|
}
|
|
@@ -3701,28 +3957,27 @@ function ssr(t) {
|
|
|
3701
3957
|
}
|
|
3702
3958
|
} else if (result !== null) {
|
|
3703
3959
|
const inTag = live && !hp.pos[i - 1];
|
|
3704
|
-
const capturing = inTag && captureStart();
|
|
3960
|
+
const capturing = inTag && captureStart(hole);
|
|
3705
3961
|
const li = capturing ? result.t.length - 1 : 0;
|
|
3706
3962
|
const before = capturing ? result.t[li].length : 0;
|
|
3963
|
+
const pushed = result.h.length;
|
|
3707
3964
|
if (live) live.suppressed++;
|
|
3708
3965
|
try {
|
|
3709
3966
|
resolveSSRNode(hole, result);
|
|
3710
3967
|
} finally {
|
|
3711
3968
|
if (live) live.suppressed--;
|
|
3712
3969
|
}
|
|
3970
|
+
if (inTag) {
|
|
3971
|
+
for (let k = pushed; k < result.h.length; k++) live.retry(result.h[k], capturing && cap);
|
|
3972
|
+
}
|
|
3713
3973
|
if (capturing) {
|
|
3714
|
-
if (result.t.length - 1 === li)
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
});
|
|
3719
|
-
} else {
|
|
3720
|
-
result.t[cap.at] = result.t[cap.at].replace(cap.inject, "");
|
|
3721
|
-
cap = null;
|
|
3722
|
-
}
|
|
3974
|
+
if (result.t.length - 1 === li) cap.base += result.t[li].slice(before);
|
|
3975
|
+
cap.parts.push({
|
|
3976
|
+
f: hole
|
|
3977
|
+
});
|
|
3723
3978
|
}
|
|
3724
3979
|
} else {
|
|
3725
|
-
const capturing = live && !hp.pos[i - 1] && captureStart();
|
|
3980
|
+
const capturing = live && !hp.pos[i - 1] && captureStart(hole);
|
|
3726
3981
|
const scope = live && hp.pos[i - 1] && live.nest(hole);
|
|
3727
3982
|
const r = tryResolveFunctionHole(hole);
|
|
3728
3983
|
if (scope) live.scope = scope;
|
|
@@ -3735,17 +3990,18 @@ function ssr(t) {
|
|
|
3735
3990
|
});
|
|
3736
3991
|
}
|
|
3737
3992
|
} else {
|
|
3738
|
-
if (capturing) {
|
|
3739
|
-
s = s.replace(cap.inject, "");
|
|
3740
|
-
cap = null;
|
|
3741
|
-
}
|
|
3742
3993
|
result = {
|
|
3743
3994
|
t: [s],
|
|
3744
3995
|
h: [],
|
|
3745
|
-
p: []
|
|
3996
|
+
p: [],
|
|
3997
|
+
$: SSR_NODE
|
|
3746
3998
|
};
|
|
3747
3999
|
s = "";
|
|
3748
4000
|
appendResolvedNode(result, r);
|
|
4001
|
+
if (capturing) cap.parts.push({
|
|
4002
|
+
f: hole
|
|
4003
|
+
});
|
|
4004
|
+
if (live && !hp.pos[i - 1]) for (const h of result.h) live.retry(h, capturing && cap);
|
|
3749
4005
|
}
|
|
3750
4006
|
}
|
|
3751
4007
|
if (devNext !== undefined) checkUnscopedHole(devNext, t, i - 1, hole);
|
|
@@ -3759,7 +4015,8 @@ function ssr(t) {
|
|
|
3759
4015
|
result = {
|
|
3760
4016
|
t: [s],
|
|
3761
4017
|
h: [],
|
|
3762
|
-
p: []
|
|
4018
|
+
p: [],
|
|
4019
|
+
$: SSR_NODE
|
|
3763
4020
|
};
|
|
3764
4021
|
s = "";
|
|
3765
4022
|
appendResolvedNode(result, r);
|
|
@@ -3795,7 +4052,8 @@ function ssr(t) {
|
|
|
3795
4052
|
if (result === null) s += next;else result.t[result.t.length - 1] += next;
|
|
3796
4053
|
}
|
|
3797
4054
|
if (result === null) return {
|
|
3798
|
-
t: s
|
|
4055
|
+
t: s,
|
|
4056
|
+
$: SSR_NODE
|
|
3799
4057
|
};
|
|
3800
4058
|
return result;
|
|
3801
4059
|
}
|
|
@@ -3875,6 +4133,7 @@ function ssrElement(tag, props, children, needsId, skip, attrs) {
|
|
|
3875
4133
|
}
|
|
3876
4134
|
const info = tagInfo(tag);
|
|
3877
4135
|
const skipChildren = info.isVoid;
|
|
4136
|
+
let sel, optValue, optOwn;
|
|
3878
4137
|
let result = info.open + hk;
|
|
3879
4138
|
let childOwner = null;
|
|
3880
4139
|
const last = sources === null ? 0 : sources.length - 1;
|
|
@@ -3893,6 +4152,11 @@ function ssrElement(tag, props, children, needsId, skip, attrs) {
|
|
|
3893
4152
|
for (let j = s + 1; j <= last; j++) {
|
|
3894
4153
|
if (keysOf[j].includes(prop)) continue nextKey;
|
|
3895
4154
|
}
|
|
4155
|
+
if (info.sel === 1 && prop === "value") {
|
|
4156
|
+
const value = props[prop];
|
|
4157
|
+
sel = ssrSelect(value);
|
|
4158
|
+
continue;
|
|
4159
|
+
}
|
|
3896
4160
|
if (info.textarea && (prop === "value" || prop === "defaultValue")) {
|
|
3897
4161
|
const value = props[prop];
|
|
3898
4162
|
if (value !== null) children = escape(value);
|
|
@@ -3912,6 +4176,9 @@ function ssrElement(tag, props, children, needsId, skip, attrs) {
|
|
|
3912
4176
|
const value = props[key];
|
|
3913
4177
|
if (value == undefined || prop.startsWith("prop:") || prop === "ref" || isEventName(prop)) continue;
|
|
3914
4178
|
if (link !== null && LinkAttributes.has(prop)) link[prop] = value;
|
|
4179
|
+
if (info.sel === 2) {
|
|
4180
|
+
if (prop === "value") optValue = value;else if (prop === "selected" && value) optOwn = true;
|
|
4181
|
+
}
|
|
3915
4182
|
if (prop === "style") {
|
|
3916
4183
|
result += ` style="${ssrStyle(value)}"`;
|
|
3917
4184
|
} else if (prop === "class") {
|
|
@@ -3926,21 +4193,58 @@ function ssrElement(tag, props, children, needsId, skip, attrs) {
|
|
|
3926
4193
|
if (attrs !== undefined) result += typeof attrs === "function" ? attrs() : attrs;
|
|
3927
4194
|
if (link !== null && link.href !== undefined) result += ssrLinkClaim(link);
|
|
3928
4195
|
if (skipChildren) return {
|
|
3929
|
-
t: result + " />"
|
|
4196
|
+
t: result + " />",
|
|
4197
|
+
$: SSR_NODE
|
|
3930
4198
|
};
|
|
3931
|
-
if (
|
|
3932
|
-
if (typeof children
|
|
4199
|
+
if (sel !== undefined) children = ssrIn(sel, () => spreadChildren(info, childOwner, children));else children = spreadChildren(info, childOwner, children);
|
|
4200
|
+
if (info.sel === 2) result += ssrOption(optValue !== undefined || typeof children !== "string" ? optValue : children.replace(/</g, "<").replace(/&/g, "&").replace(/\s+/g, " ").trim(), undefined, optOwn);
|
|
4201
|
+
let thunk = null;
|
|
4202
|
+
if (typeof children === "function" && (ctx === undefined || !ctx.liveHoles)) {
|
|
4203
|
+
thunk = children;
|
|
4204
|
+
ssrTextTail = false;
|
|
4205
|
+
try {
|
|
4206
|
+
children = thunk();
|
|
4207
|
+
} catch (err) {
|
|
4208
|
+
const res = {
|
|
4209
|
+
t: [""],
|
|
4210
|
+
h: [],
|
|
4211
|
+
p: [],
|
|
4212
|
+
$: SSR_NODE
|
|
4213
|
+
};
|
|
4214
|
+
pushSSRAsyncHole(res, err, thunk);
|
|
4215
|
+
return ssr([result + ">", info.close], res);
|
|
4216
|
+
}
|
|
4217
|
+
}
|
|
3933
4218
|
const ct = typeof children;
|
|
3934
4219
|
if (ct === "string" || ct === "number") return {
|
|
3935
|
-
t: result + ">" + children + info.close
|
|
4220
|
+
t: result + ">" + children + info.close,
|
|
4221
|
+
$: SSR_NODE
|
|
3936
4222
|
};
|
|
3937
4223
|
if (children == null || ct === "boolean") return {
|
|
3938
|
-
t: result + ">" + info.close
|
|
4224
|
+
t: result + ">" + info.close,
|
|
4225
|
+
$: SSR_NODE
|
|
4226
|
+
};
|
|
4227
|
+
if (ct === "object" && children.$ === SSR_NODE && !children.h && typeof children.t === "string") return {
|
|
4228
|
+
t: result + ">" + children.t + info.close,
|
|
4229
|
+
$: SSR_NODE
|
|
3939
4230
|
};
|
|
3940
|
-
if (
|
|
3941
|
-
|
|
4231
|
+
if (thunk === null) return ssr([result + ">", info.close], resolveSSRNode(children, undefined, true));
|
|
4232
|
+
const res = {
|
|
4233
|
+
t: [""],
|
|
4234
|
+
h: [],
|
|
4235
|
+
p: [],
|
|
4236
|
+
$: SSR_NODE
|
|
3942
4237
|
};
|
|
3943
|
-
|
|
4238
|
+
try {
|
|
4239
|
+
resolveSSRNode(children, res, false, true);
|
|
4240
|
+
} catch (err) {
|
|
4241
|
+
pushSSRAsyncHole(res, err, thunk);
|
|
4242
|
+
}
|
|
4243
|
+
return ssr([result + ">", info.close], res);
|
|
4244
|
+
}
|
|
4245
|
+
function spreadChildren(info, childOwner, children) {
|
|
4246
|
+
if (childOwner !== null) children = info.raw ? childOwner.children : escape(childOwner.children);
|
|
4247
|
+
return typeof children === "function" ? children() : children;
|
|
3944
4248
|
}
|
|
3945
4249
|
function collectSpreadSources(props, viewKeys, owners) {
|
|
3946
4250
|
for (let i = 0; i < props.length; i++) {
|
|
@@ -3984,110 +4288,37 @@ function ssrLinkClaim(attrs) {
|
|
|
3984
4288
|
if (ctx === undefined || ctx.linkClaim === undefined || attrs["aria-current"] != null) return "";
|
|
3985
4289
|
return ctx.linkClaim(attrs);
|
|
3986
4290
|
}
|
|
3987
|
-
|
|
3988
|
-
|
|
4291
|
+
const SELECT = Symbol();
|
|
4292
|
+
function ssrSelect(value) {
|
|
4293
|
+
const owner = createOwner({
|
|
4294
|
+
transparent: true
|
|
4295
|
+
});
|
|
4296
|
+
const state = {
|
|
4297
|
+
v: value,
|
|
4298
|
+
d: false,
|
|
4299
|
+
o: owner
|
|
4300
|
+
};
|
|
4301
|
+
owner._context = {
|
|
4302
|
+
...owner._context,
|
|
4303
|
+
[SELECT]: state
|
|
4304
|
+
};
|
|
4305
|
+
return state;
|
|
3989
4306
|
}
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
for (let j = i + 1; j < html.length; j++) {
|
|
3993
|
-
const c = html.charCodeAt(j);
|
|
3994
|
-
if (c === 34) {
|
|
3995
|
-
j = html.indexOf('"', j + 1);
|
|
3996
|
-
if (j < 0) return -1;
|
|
3997
|
-
} else if (c === 62) return j;
|
|
3998
|
-
}
|
|
3999
|
-
return -1;
|
|
4307
|
+
function ssrIn(state, fn) {
|
|
4308
|
+
return runWithOwner(state.o, fn);
|
|
4000
4309
|
}
|
|
4001
|
-
function
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
const lt = html.indexOf("<", i);
|
|
4006
|
-
if (lt < 0) return t + html.slice(i);
|
|
4007
|
-
t += html.slice(i, lt);
|
|
4008
|
-
if (!html.startsWith("<!--", lt)) return t;
|
|
4009
|
-
const ce = html.indexOf("-->", lt);
|
|
4010
|
-
if (ce < 0) return t;
|
|
4011
|
-
i = ce + 3;
|
|
4012
|
-
}
|
|
4013
|
-
}
|
|
4014
|
-
function tagIs(html, i, name) {
|
|
4015
|
-
if (!html.startsWith(name, i + 1)) return false;
|
|
4016
|
-
const c = html.charCodeAt(i + 1 + name.length);
|
|
4017
|
-
return c === 32 || c === 62 || c === 9 || c === 10 || c === 13;
|
|
4018
|
-
}
|
|
4019
|
-
let selectValuesActive = false;
|
|
4020
|
-
function ssrSelectValues() {
|
|
4021
|
-
selectValuesActive = true;
|
|
4022
|
-
}
|
|
4023
|
-
function resolveSSRSelectValues(html) {
|
|
4024
|
-
if (!selectValuesActive) return html;
|
|
4025
|
-
let cand = html.indexOf("<select");
|
|
4026
|
-
if (cand < 0) return html;
|
|
4027
|
-
let out = "";
|
|
4028
|
-
let idx = 0;
|
|
4029
|
-
while (cand >= 0) {
|
|
4030
|
-
if (!tagIs(html, cand, "select")) {
|
|
4031
|
-
cand = html.indexOf("<select", cand + 7);
|
|
4032
|
-
continue;
|
|
4033
|
-
}
|
|
4034
|
-
const e0 = tagEnd(html, cand);
|
|
4035
|
-
if (e0 < 0) break;
|
|
4036
|
-
const open = html.slice(cand, e0 + 1);
|
|
4037
|
-
const m = SELECT_VALUE_ATTR.exec(open);
|
|
4038
|
-
if (!m) {
|
|
4039
|
-
cand = html.indexOf("<select", e0 + 1);
|
|
4040
|
-
continue;
|
|
4041
|
-
}
|
|
4042
|
-
const bound = decodeSSREntities(m[1] ?? "");
|
|
4043
|
-
const sel = {
|
|
4044
|
-
values: /\smultiple(?=[\s>=])/.test(open) ? bound.split(",") : [bound],
|
|
4045
|
-
strip: cand + m.index,
|
|
4046
|
-
stripEnd: cand + m.index + m[0].length,
|
|
4047
|
-
body: e0 + 1,
|
|
4048
|
-
marks: [],
|
|
4049
|
-
defaulted: false
|
|
4050
|
-
};
|
|
4051
|
-
let committed = false;
|
|
4052
|
-
let i = html.indexOf("<", e0 + 1);
|
|
4053
|
-
while (i >= 0) {
|
|
4054
|
-
let e;
|
|
4055
|
-
if (html.charCodeAt(i + 1) === 33) {
|
|
4056
|
-
e = html.charCodeAt(i + 2) === 45 ? html.indexOf("-->", i) : html.indexOf(">", i);
|
|
4057
|
-
if (e < 0) break;
|
|
4058
|
-
if (html.charCodeAt(i + 2) === 45) e += 2;
|
|
4059
|
-
} else {
|
|
4060
|
-
e = tagEnd(html, i);
|
|
4061
|
-
if (e < 0) break;
|
|
4062
|
-
if (html.startsWith("</select>", i)) {
|
|
4063
|
-
out += html.slice(idx, sel.strip) + html.slice(sel.stripEnd, sel.body);
|
|
4064
|
-
let seg = sel.body;
|
|
4065
|
-
if (!sel.defaulted) {
|
|
4066
|
-
for (let k = 0; k < sel.marks.length; k++) {
|
|
4067
|
-
out += html.slice(seg, sel.marks[k]) + " selected";
|
|
4068
|
-
seg = sel.marks[k];
|
|
4069
|
-
}
|
|
4070
|
-
}
|
|
4071
|
-
out += html.slice(seg, i);
|
|
4072
|
-
idx = i;
|
|
4073
|
-
committed = true;
|
|
4074
|
-
break;
|
|
4075
|
-
} else if (tagIs(html, i, "option")) {
|
|
4076
|
-
const attrs = html.slice(i + 7, e);
|
|
4077
|
-
if (/\sselected(?=[\s=]|$)/.test(attrs)) sel.defaulted = true;else {
|
|
4078
|
-
const vm = SELECT_VALUE_ATTR.exec(attrs);
|
|
4079
|
-
const value = vm ? decodeSSREntities(vm[1] ?? "") : decodeSSREntities(optionText(html, e + 1)).replace(/\s+/g, " ").trim();
|
|
4080
|
-
if (sel.values.includes(value)) sel.marks.push(e);
|
|
4081
|
-
}
|
|
4082
|
-
}
|
|
4083
|
-
}
|
|
4084
|
-
i = html.indexOf("<", e + 1);
|
|
4085
|
-
}
|
|
4086
|
-
if (!committed) break;
|
|
4087
|
-
cand = html.indexOf("<select", idx);
|
|
4310
|
+
function ssrOption(value, state, own) {
|
|
4311
|
+
if (state === undefined) {
|
|
4312
|
+
const o = getOwner();
|
|
4313
|
+
if (!o || !(state = o._context[SELECT])) return "";
|
|
4088
4314
|
}
|
|
4089
|
-
if (
|
|
4090
|
-
|
|
4315
|
+
if (own) return state.d = true, "";
|
|
4316
|
+
if (state.d) return "";
|
|
4317
|
+
if (typeof value === "function") value = value();
|
|
4318
|
+
if (value == null) return "";
|
|
4319
|
+
value = String(value);
|
|
4320
|
+
const v = state.v;
|
|
4321
|
+
return v != null && (v.map ? v.some(x => x != null && String(x) === value) : String(v) === value) ? " selected" : "";
|
|
4091
4322
|
}
|
|
4092
4323
|
function escape(s, attr) {
|
|
4093
4324
|
const t = typeof s;
|
|
@@ -4195,7 +4426,7 @@ function tryJoinPlainSSRArray(nodes) {
|
|
|
4195
4426
|
let out = "";
|
|
4196
4427
|
for (let i = 0, len = nodes.length; i < len; i++) {
|
|
4197
4428
|
const node = nodes[i];
|
|
4198
|
-
if (node == null || typeof node !== "object" || node.h || typeof node.t !== "string") {
|
|
4429
|
+
if (node == null || typeof node !== "object" || node.$ !== SSR_NODE || node.h || typeof node.t !== "string") {
|
|
4199
4430
|
return undefined;
|
|
4200
4431
|
}
|
|
4201
4432
|
out += node.t;
|
|
@@ -4236,7 +4467,7 @@ function withShellEnd(html, context, renderId, nonce, noScripts) {
|
|
|
4236
4467
|
const at = html.indexOf("</body>", html.length - 512);
|
|
4237
4468
|
return at < 0 ? html + marker : html.slice(0, at) + marker + html.slice(at);
|
|
4238
4469
|
}
|
|
4239
|
-
function assembleDocument(html, emittedAssets, preloadLinks, inlineStyles, scripts, nonce, headTags, onHead) {
|
|
4470
|
+
function assembleDocument(html, emittedAssets, preloadLinks, inlineStyles, scripts, nonce, headTags, onHead, lowModules) {
|
|
4240
4471
|
const scriptTag = scripts ? `<script${nonceAttr(nonce, "script")}>${scripts}</script>` : "";
|
|
4241
4472
|
const title = headTags ? headTags.title : null;
|
|
4242
4473
|
let headTagsHtml = headTags ? headTags.html : "";
|
|
@@ -4260,7 +4491,7 @@ function assembleDocument(html, emittedAssets, preloadLinks, inlineStyles, scrip
|
|
|
4260
4491
|
if (title != null) {
|
|
4261
4492
|
titleHtml = headTags.noScripts ? `<title data-dh="title">${escape(title)}</title>` : `<script${nonceAttr(nonce, "script")}>(function(x,t){(t=document.querySelector("title"))?(t.hasAttribute("data-dh")||t.setAttribute("data-dhf",t.textContent),t.textContent=x):(document.title=x,t=document.querySelector("title"));t&&t.setAttribute("data-dh","title")})(${JSON.stringify(title).replace(/</g, "\\u003C")})</script>`;
|
|
4262
4493
|
}
|
|
4263
|
-
onHead(headPrelude + headTagsHtml + titleHtml + renderHeadAssets(emittedAssets, preloadLinks, inlineStyles, nonce));
|
|
4494
|
+
onHead(headPrelude + headTagsHtml + titleHtml + renderHeadAssets(emittedAssets, preloadLinks, inlineStyles, nonce, lowModules));
|
|
4264
4495
|
}
|
|
4265
4496
|
if (!scriptTag) return html;
|
|
4266
4497
|
const xs = html.indexOf("<!--xs-->");
|
|
@@ -4280,19 +4511,19 @@ function assembleDocument(html, emittedAssets, preloadLinks, inlineStyles, scrip
|
|
|
4280
4511
|
headTagsHtml = `<title data-dh="title">${winner}</title>` + headTagsHtml;
|
|
4281
4512
|
}
|
|
4282
4513
|
}
|
|
4283
|
-
const head = headTagsHtml + renderHeadAssets(emittedAssets, preloadLinks, inlineStyles, nonce);
|
|
4514
|
+
const head = headTagsHtml + renderHeadAssets(emittedAssets, preloadLinks, inlineStyles, nonce, lowModules);
|
|
4284
4515
|
if (!scriptTag) return html.slice(0, headIdx) + head + html.slice(headIdx);
|
|
4285
4516
|
const xsIdx = html.indexOf("<!--xs-->");
|
|
4286
4517
|
if (xsIdx === -1) return html.slice(0, headIdx) + head + html.slice(headIdx) + scriptTag;
|
|
4287
4518
|
return xsIdx < headIdx ? html.slice(0, xsIdx) + scriptTag + html.slice(xsIdx, headIdx) + head + html.slice(headIdx) : html.slice(0, headIdx) + head + html.slice(headIdx, xsIdx) + scriptTag + html.slice(xsIdx);
|
|
4288
4519
|
}
|
|
4289
|
-
function renderHeadAssets(emittedAssets, preloadLinks, inlineStyles, nonce) {
|
|
4520
|
+
function renderHeadAssets(emittedAssets, preloadLinks, inlineStyles, nonce, lowModules) {
|
|
4290
4521
|
let head = "";
|
|
4291
4522
|
const styleAttr = nonceAttr(nonce, "style");
|
|
4292
4523
|
const scriptAttr = nonceAttr(nonce, "script");
|
|
4293
4524
|
if (emittedAssets && emittedAssets.size) {
|
|
4294
4525
|
for (const url of emittedAssets) {
|
|
4295
|
-
head += isCssUrl(url) ? `<link rel="stylesheet" href="${url}"${styleAttr}>` :
|
|
4526
|
+
head += isCssUrl(url) ? `<link rel="stylesheet" href="${url}"${styleAttr}>` : modulePreloadLink(url, scriptAttr, lowModules);
|
|
4296
4527
|
}
|
|
4297
4528
|
}
|
|
4298
4529
|
if (preloadLinks) {
|
|
@@ -4423,13 +4654,13 @@ function tryResolveString(node, nested) {
|
|
|
4423
4654
|
}
|
|
4424
4655
|
return s;
|
|
4425
4656
|
}
|
|
4426
|
-
if (node
|
|
4427
|
-
merge: node
|
|
4428
|
-
};
|
|
4429
|
-
if (node.t === undefined) {
|
|
4657
|
+
if (node.$ !== SSR_NODE) {
|
|
4430
4658
|
unrecognizedInsert(node);
|
|
4431
4659
|
return "";
|
|
4432
4660
|
}
|
|
4661
|
+
if (node.h && node.h.length > 0) return {
|
|
4662
|
+
merge: node
|
|
4663
|
+
};
|
|
4433
4664
|
ssrTextTail = false;
|
|
4434
4665
|
return Array.isArray(node.t) ? node.t[0] : node.t;
|
|
4435
4666
|
}
|
|
@@ -4449,7 +4680,8 @@ function tryResolveString(node, nested) {
|
|
|
4449
4680
|
function resolveSSRNode(node, result = {
|
|
4450
4681
|
t: [""],
|
|
4451
4682
|
h: [],
|
|
4452
|
-
p: []
|
|
4683
|
+
p: [],
|
|
4684
|
+
$: SSR_NODE
|
|
4453
4685
|
}, top, nested) {
|
|
4454
4686
|
if (!nested) ssrTextTail = false;
|
|
4455
4687
|
const t = typeof node;
|
|
@@ -4468,7 +4700,9 @@ function resolveSSRNode(node, result = {
|
|
|
4468
4700
|
if (slotLive) slotLive.suppressed--;
|
|
4469
4701
|
}
|
|
4470
4702
|
} else if (t === "object") {
|
|
4471
|
-
if (node
|
|
4703
|
+
if (node.$ !== SSR_NODE) {
|
|
4704
|
+
unrecognizedInsert(node);
|
|
4705
|
+
} else if (node.h) {
|
|
4472
4706
|
result.t[result.t.length - 1] += node.t[0];
|
|
4473
4707
|
if (node.t.length > 1) {
|
|
4474
4708
|
result.t.push(...node.t.slice(1));
|
|
@@ -4476,10 +4710,10 @@ function resolveSSRNode(node, result = {
|
|
|
4476
4710
|
result.p.push(...node.p);
|
|
4477
4711
|
}
|
|
4478
4712
|
ssrTextTail = false;
|
|
4479
|
-
} else
|
|
4713
|
+
} else {
|
|
4480
4714
|
result.t[result.t.length - 1] += node.t;
|
|
4481
4715
|
ssrTextTail = false;
|
|
4482
|
-
}
|
|
4716
|
+
}
|
|
4483
4717
|
} else if (t === "function") {
|
|
4484
4718
|
const live = sharedConfig.context && sharedConfig.context.liveHoles;
|
|
4485
4719
|
let liveNode = null;
|
|
@@ -4493,14 +4727,7 @@ function resolveSSRNode(node, result = {
|
|
|
4493
4727
|
try {
|
|
4494
4728
|
resolveSSRNode(node(), result, false, true);
|
|
4495
4729
|
} catch (err) {
|
|
4496
|
-
|
|
4497
|
-
if (wrap) {
|
|
4498
|
-
if (ssrTextTail) result.t[result.t.length - 1] += "<!--!$-->";
|
|
4499
|
-
result.h.push(wrap.fn);
|
|
4500
|
-
result.p.push(wrap.p);
|
|
4501
|
-
result.t.push("");
|
|
4502
|
-
ssrTextTail = true;
|
|
4503
|
-
}
|
|
4730
|
+
pushSSRAsyncHole(result, err, node);
|
|
4504
4731
|
} finally {
|
|
4505
4732
|
if (scope) live.scope = scope;
|
|
4506
4733
|
}
|
|
@@ -4508,6 +4735,16 @@ function resolveSSRNode(node, result = {
|
|
|
4508
4735
|
}
|
|
4509
4736
|
return result;
|
|
4510
4737
|
}
|
|
4738
|
+
function pushSSRAsyncHole(result, err, node) {
|
|
4739
|
+
const wrap = buildAsyncWrap(err, node);
|
|
4740
|
+
if (wrap) {
|
|
4741
|
+
if (ssrTextTail) result.t[result.t.length - 1] += "<!--!$-->";
|
|
4742
|
+
result.h.push(wrap.fn);
|
|
4743
|
+
result.p.push(wrap.p);
|
|
4744
|
+
result.t.push("");
|
|
4745
|
+
ssrTextTail = true;
|
|
4746
|
+
}
|
|
4747
|
+
}
|
|
4511
4748
|
function resolveSSRSync(node) {
|
|
4512
4749
|
const res = resolveSSRNode(node);
|
|
4513
4750
|
if (!res.h.length) return res.t[0];
|
|
@@ -4913,6 +5150,10 @@ function registerElementClaim() {
|
|
|
4913
5150
|
return noopCleanup;
|
|
4914
5151
|
}
|
|
4915
5152
|
function noopCleanup() {}
|
|
5153
|
+
function setTrustedTypesPolicy() {}
|
|
5154
|
+
function trustedHTML(html) {
|
|
5155
|
+
return html;
|
|
5156
|
+
}
|
|
4916
5157
|
function claimElement(node) {
|
|
4917
5158
|
return node;
|
|
4918
5159
|
}
|
|
@@ -5062,4 +5303,4 @@ function httpHeader(name, value, options) {
|
|
|
5062
5303
|
}
|
|
5063
5304
|
}
|
|
5064
5305
|
|
|
5065
|
-
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,
|
|
5306
|
+
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 };
|