@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.observe.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { createRenderEffect, createMemo, OBSERVE, getOwner, createRoot, $PROXY,
|
|
1
|
+
import { createRenderEffect, createMemo, OBSERVE, 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';
|
|
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 = {
|
|
@@ -355,7 +355,15 @@ function rewriteTree(value, visit, withPath) {
|
|
|
355
355
|
} catch (err) {
|
|
356
356
|
if (err !== CYCLE) throw err;
|
|
357
357
|
}
|
|
358
|
-
|
|
358
|
+
const memo = state.memo || (state.memo = new Map());
|
|
359
|
+
const marks = {
|
|
360
|
+
at: new Map(),
|
|
361
|
+
stack: [],
|
|
362
|
+
changed: new Set(),
|
|
363
|
+
next: 0
|
|
364
|
+
};
|
|
365
|
+
mark(value, visit, path, memo, marks);
|
|
366
|
+
return clone(value, memo, marks.changed);
|
|
359
367
|
}
|
|
360
368
|
function shape(value) {
|
|
361
369
|
return Array.isArray(value) ? 1 : Object.getPrototypeOf(value) === Object.prototype ? 2 : 0;
|
|
@@ -403,28 +411,73 @@ function cow(value, visit, path, depth, state) {
|
|
|
403
411
|
if (ancestors !== undefined) ancestors.delete(value);
|
|
404
412
|
return out;
|
|
405
413
|
}
|
|
406
|
-
function
|
|
407
|
-
|
|
414
|
+
function mark(value, visit, path, memo, m) {
|
|
415
|
+
const seen = m.at.get(value);
|
|
416
|
+
if (seen !== undefined) return seen;
|
|
417
|
+
if (memo.has(value)) return -1;
|
|
408
418
|
const r = visit(value, path);
|
|
409
419
|
if (r !== DESCEND) {
|
|
410
420
|
memo.set(value, r);
|
|
411
|
-
return
|
|
421
|
+
return -1;
|
|
412
422
|
}
|
|
413
423
|
const s = shape(value);
|
|
414
|
-
if (s === 0) return
|
|
415
|
-
const
|
|
424
|
+
if (s === 0) return -1;
|
|
425
|
+
const index = m.next++;
|
|
426
|
+
let low = index;
|
|
427
|
+
let changed = false;
|
|
428
|
+
let open = false;
|
|
429
|
+
const keys = s === 1 ? value : Object.keys(value);
|
|
430
|
+
for (let i = 0; i < keys.length; i++) {
|
|
431
|
+
const k = s === 1 ? i : keys[i];
|
|
432
|
+
const c = value[k];
|
|
433
|
+
if (c === null || typeof c !== "object") continue;
|
|
434
|
+
if (!open) {
|
|
435
|
+
open = true;
|
|
436
|
+
m.at.set(value, index);
|
|
437
|
+
m.stack.push(value);
|
|
438
|
+
}
|
|
439
|
+
const l = mark(c, visit, undefined , memo, m);
|
|
440
|
+
if (l >= 0 && l < low) low = l;
|
|
441
|
+
if (memo.has(c) && memo.get(c) !== c || l === Infinity && m.changed.has(c)) changed = true;
|
|
442
|
+
}
|
|
443
|
+
if (!open) return -1;
|
|
444
|
+
if (low === index) {
|
|
445
|
+
m.at.set(value, Infinity);
|
|
446
|
+
if (m.stack[m.stack.length - 1] === value) {
|
|
447
|
+
m.stack.pop();
|
|
448
|
+
if (changed) m.changed.add(value);
|
|
449
|
+
return Infinity;
|
|
450
|
+
}
|
|
451
|
+
const members = m.stack.splice(m.stack.lastIndexOf(value));
|
|
452
|
+
if (!changed) for (const n of members) if (m.changed.has(n)) {
|
|
453
|
+
changed = true;
|
|
454
|
+
break;
|
|
455
|
+
}
|
|
456
|
+
for (const n of members) {
|
|
457
|
+
m.at.set(n, Infinity);
|
|
458
|
+
if (changed) m.changed.add(n);
|
|
459
|
+
}
|
|
460
|
+
return Infinity;
|
|
461
|
+
}
|
|
462
|
+
if (changed) m.changed.add(value);
|
|
463
|
+
return low;
|
|
464
|
+
}
|
|
465
|
+
function clone(value, memo, changed) {
|
|
466
|
+
if (memo.has(value)) return memo.get(value);
|
|
467
|
+
if (!changed.has(value)) return value;
|
|
468
|
+
const out = Array.isArray(value) ? value.slice() : {
|
|
416
469
|
...value
|
|
417
470
|
};
|
|
418
471
|
memo.set(value, out);
|
|
419
|
-
if (
|
|
472
|
+
if (Array.isArray(value)) {
|
|
420
473
|
for (let i = 0; i < value.length; i++) {
|
|
421
474
|
const c = value[i];
|
|
422
|
-
if (c !== null && typeof c === "object") out[i] = clone(c,
|
|
475
|
+
if (c !== null && typeof c === "object") out[i] = clone(c, memo, changed);
|
|
423
476
|
}
|
|
424
477
|
} else {
|
|
425
478
|
for (const k of Object.keys(value)) {
|
|
426
479
|
const c = value[k];
|
|
427
|
-
if (c !== null && typeof c === "object") out[k] = clone(c,
|
|
480
|
+
if (c !== null && typeof c === "object") out[k] = clone(c, memo, changed);
|
|
428
481
|
}
|
|
429
482
|
}
|
|
430
483
|
return out;
|
|
@@ -551,7 +604,6 @@ function createKeyedSerializer(serialize, onError, onDone) {
|
|
|
551
604
|
pendingWrites++;
|
|
552
605
|
let settled = false;
|
|
553
606
|
let failed = false;
|
|
554
|
-
let started = false;
|
|
555
607
|
let cancel = null;
|
|
556
608
|
const settle = () => {
|
|
557
609
|
if (settled) return;
|
|
@@ -565,17 +617,14 @@ function createKeyedSerializer(serialize, onError, onDone) {
|
|
|
565
617
|
stream = serialize(key, value, {
|
|
566
618
|
onError: onError && (err => {
|
|
567
619
|
failed = true;
|
|
568
|
-
onError(err);
|
|
620
|
+
onError(err, key);
|
|
569
621
|
if (cancel) {
|
|
570
622
|
cancel();
|
|
571
623
|
settle();
|
|
572
624
|
}
|
|
573
625
|
}),
|
|
574
626
|
onDone: settle
|
|
575
|
-
},
|
|
576
|
-
if (initial) started = true;
|
|
577
|
-
return !closed;
|
|
578
|
-
});
|
|
627
|
+
}, () => !closed);
|
|
579
628
|
} catch (err) {
|
|
580
629
|
settle();
|
|
581
630
|
throw err;
|
|
@@ -622,22 +671,67 @@ function createHydrationSerializer({
|
|
|
622
671
|
onDone,
|
|
623
672
|
scopeId,
|
|
624
673
|
onError,
|
|
625
|
-
plugins
|
|
674
|
+
plugins,
|
|
675
|
+
late
|
|
626
676
|
}) {
|
|
627
677
|
const resolvedPlugins = resolveSerializerPlugins(plugins);
|
|
628
678
|
const disabledFeatures = defaultDisabledFeatures() | serializeOnlyDisabledFeatures();
|
|
629
679
|
const refs = new Map();
|
|
630
|
-
|
|
680
|
+
const serialize = (key, value, callbacks, live) => crossSerializeStream(value, {
|
|
631
681
|
scopeId,
|
|
632
682
|
refs,
|
|
633
683
|
plugins: resolvedPlugins,
|
|
634
684
|
disabledFeatures,
|
|
635
685
|
onSerialize(data, initial) {
|
|
636
|
-
if (!live(
|
|
686
|
+
if (!live()) return;
|
|
637
687
|
onData(initial ? HYDRATION_GLOBAL + '["' + serializeKey(key) + '"]=' + data : data);
|
|
638
688
|
},
|
|
639
689
|
...callbacks
|
|
640
|
-
})
|
|
690
|
+
});
|
|
691
|
+
return createKeyedSerializer(late ? late(serialize, refs, onData, scopeId) : serialize, onError, onDone);
|
|
692
|
+
}
|
|
693
|
+
function rejectUnserializedKey(serialize, refs, onData, scopeId, plain) {
|
|
694
|
+
let taken = 0;
|
|
695
|
+
let fresh = [];
|
|
696
|
+
const set = refs.set;
|
|
697
|
+
refs.set = (value, id) => {
|
|
698
|
+
taken++;
|
|
699
|
+
fresh.push(value);
|
|
700
|
+
return set.call(refs, value, id);
|
|
701
|
+
};
|
|
702
|
+
Object.defineProperty(refs, "size", {
|
|
703
|
+
get: () => taken
|
|
704
|
+
});
|
|
705
|
+
return (key, value, callbacks, live) => {
|
|
706
|
+
const sent = [];
|
|
707
|
+
const failed = () => {
|
|
708
|
+
for (const ref of fresh) refs.delete(ref);
|
|
709
|
+
fresh = [];
|
|
710
|
+
const ids = new Set();
|
|
711
|
+
for (const ref of sent) {
|
|
712
|
+
const id = refs.get(ref);
|
|
713
|
+
if (ref instanceof Promise) ids.add(id + 1);else if (isStream(ref) || Object.getPrototypeOf(ref) === Object.prototype && !Object.keys(ref).length) ids.add(id);
|
|
714
|
+
}
|
|
715
|
+
if (!ids.size) return;
|
|
716
|
+
const text = plain && plain(key);
|
|
717
|
+
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))}";
|
|
718
|
+
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]);
|
|
719
|
+
onData("($R=>{const e=new Error(" + message + ");" + body + "})(" + (scopeId == null ? "$R" : '$R["' + serializeKey(scopeId) + '"]') + ")");
|
|
720
|
+
};
|
|
721
|
+
return serialize(key, value, {
|
|
722
|
+
...callbacks,
|
|
723
|
+
onError: callbacks.onError && (err => {
|
|
724
|
+
if (live()) failed();
|
|
725
|
+
callbacks.onError(err);
|
|
726
|
+
})
|
|
727
|
+
},
|
|
728
|
+
() => {
|
|
729
|
+
if (!live()) return false;
|
|
730
|
+
sent.push(...fresh);
|
|
731
|
+
fresh = [];
|
|
732
|
+
return true;
|
|
733
|
+
});
|
|
734
|
+
};
|
|
641
735
|
}
|
|
642
736
|
function getLocalHeaderScript(id) {
|
|
643
737
|
return getCrossReferenceHeader(id) + ";";
|
|
@@ -968,7 +1062,7 @@ function resolveAssets(moduleUrl, manifest) {
|
|
|
968
1062
|
if (!manifest) return null;
|
|
969
1063
|
const base = manifest._base;
|
|
970
1064
|
const entry = manifest[moduleUrl];
|
|
971
|
-
if (!entry) return null;
|
|
1065
|
+
if (!entry || typeof entry !== "object") return null;
|
|
972
1066
|
const css = [];
|
|
973
1067
|
const js = [];
|
|
974
1068
|
let preloads;
|
|
@@ -977,7 +1071,7 @@ function resolveAssets(moduleUrl, manifest) {
|
|
|
977
1071
|
if (visited.has(key)) return;
|
|
978
1072
|
visited.add(key);
|
|
979
1073
|
const e = manifest[key];
|
|
980
|
-
if (!e) return;
|
|
1074
|
+
if (!e || typeof e !== "object") return;
|
|
981
1075
|
js.push(joinAssetPath(base, e.file));
|
|
982
1076
|
if (e.css) for (let i = 0; i < e.css.length; i++) css.push(joinAssetPath(base, e.css[i]));
|
|
983
1077
|
if (e.preloads) {
|
|
@@ -1014,18 +1108,19 @@ function registerEntryAssets(manifest) {
|
|
|
1014
1108
|
const ctx = sharedConfig.context;
|
|
1015
1109
|
if (!ctx?.registerAsset) return;
|
|
1016
1110
|
for (const key in manifest) {
|
|
1017
|
-
|
|
1111
|
+
const entry = manifest[key];
|
|
1112
|
+
if (entry && entry.isEntry) {
|
|
1018
1113
|
const assets = resolveAssets(key, manifest);
|
|
1019
1114
|
if (assets) {
|
|
1020
1115
|
if (assets.preloads) for (let i = 0; i < assets.preloads.length; i++) ctx.registerAsset("preload", assets.preloads[i]);
|
|
1021
1116
|
for (let i = 0; i < assets.css.length; i++) ctx.registerAsset("style", assets.css[i]);
|
|
1022
|
-
for (let i = 1; i < assets.js.length; i++) ctx.registerAsset("module", assets.js[i]);
|
|
1117
|
+
for (let i = 1; i < assets.js.length; i++) ctx.registerAsset("module", assets.js[i], true);
|
|
1023
1118
|
}
|
|
1024
1119
|
return;
|
|
1025
1120
|
}
|
|
1026
1121
|
}
|
|
1027
1122
|
}
|
|
1028
|
-
function createAssetTracking() {
|
|
1123
|
+
function createAssetTracking(lowPriorityPreloads) {
|
|
1029
1124
|
const boundaryModules = new Map();
|
|
1030
1125
|
const boundaryStyles = new Map();
|
|
1031
1126
|
const emittedAssets = new Set();
|
|
@@ -1037,6 +1132,7 @@ function createAssetTracking() {
|
|
|
1037
1132
|
emittedAssets,
|
|
1038
1133
|
inlineStyles,
|
|
1039
1134
|
preloadLinks: null,
|
|
1135
|
+
lowModules: lowPriorityPreloads !== false ? new Set() : null,
|
|
1040
1136
|
registerInlineStyle(desc) {
|
|
1041
1137
|
let entry = inlineStyles.get(desc.id);
|
|
1042
1138
|
if (!entry) {
|
|
@@ -1134,6 +1230,7 @@ function isSetAttr(value) {
|
|
|
1134
1230
|
return value != null && value !== false && value !== "";
|
|
1135
1231
|
}
|
|
1136
1232
|
const PRELOAD_LINK_ATTRIBUTES = ["type", "crossorigin", "integrity", "referrerpolicy", "fetchpriority", "media", "imagesrcset", "imagesizes"];
|
|
1233
|
+
const SSR_NODE = /*#__PURE__*/Symbol.for("solid.ssrNode");
|
|
1137
1234
|
function registerPreloadLink(tracking, headRegistry, link, nonce) {
|
|
1138
1235
|
if (!link || typeof link !== "object") {
|
|
1139
1236
|
return null;
|
|
@@ -1341,7 +1438,7 @@ function emitHeadResource(registry, context, tracking, emitResource, nonce, desc
|
|
|
1341
1438
|
if (plain && props.href != null) {
|
|
1342
1439
|
const isCss = isCssUrl(props.href);
|
|
1343
1440
|
if (rel === "stylesheet" ? isCss : !isCss) {
|
|
1344
|
-
context.registerAsset(rel === "stylesheet" ? "style" : "module", props.href);
|
|
1441
|
+
context.registerAsset(rel === "stylesheet" ? "style" : "module", props.href, true);
|
|
1345
1442
|
return;
|
|
1346
1443
|
}
|
|
1347
1444
|
}
|
|
@@ -1585,6 +1682,10 @@ function nonceDestination(tag, props) {
|
|
|
1585
1682
|
return "script";
|
|
1586
1683
|
}
|
|
1587
1684
|
}
|
|
1685
|
+
function modulePreloadLink(url, scriptAttr, lowModules) {
|
|
1686
|
+
const priority = lowModules && !lowModules.has(url) ? ' fetchpriority="low"' : "";
|
|
1687
|
+
return `<link rel="modulepreload" href="${url}"${priority}${scriptAttr}>`;
|
|
1688
|
+
}
|
|
1588
1689
|
function nonceAttr(nonce, destination) {
|
|
1589
1690
|
if (!nonce || !destination) return "";
|
|
1590
1691
|
return destination === "script" ? nonce.scriptAttr : nonce.styleAttr;
|
|
@@ -1660,7 +1761,8 @@ function tagInfo(tag) {
|
|
|
1660
1761
|
textarea: tag === "textarea",
|
|
1661
1762
|
raw: tag === "script" || tag === "style",
|
|
1662
1763
|
formDefaults,
|
|
1663
|
-
formAttributes
|
|
1764
|
+
formAttributes,
|
|
1765
|
+
sel: tag === "select" ? 1 : tag === "option" ? 2 : 0
|
|
1664
1766
|
};
|
|
1665
1767
|
if (tagInfos.size < 512) tagInfos.set(tag, info);
|
|
1666
1768
|
}
|
|
@@ -1698,7 +1800,7 @@ function renderToString(code, options = {}) {
|
|
|
1698
1800
|
},
|
|
1699
1801
|
onError: serializerErrorHook(options.onError)
|
|
1700
1802
|
});
|
|
1701
|
-
const tracking = createAssetTracking();
|
|
1803
|
+
const tracking = createAssetTracking(options.lowPriorityPreloads);
|
|
1702
1804
|
const headRegistry = createHeadRegistry();
|
|
1703
1805
|
let closed = false;
|
|
1704
1806
|
sharedConfig.context = {
|
|
@@ -1718,7 +1820,7 @@ function renderToString(code, options = {}) {
|
|
|
1718
1820
|
}
|
|
1719
1821
|
serializer.write(id, p);
|
|
1720
1822
|
},
|
|
1721
|
-
registerAsset(type, value) {
|
|
1823
|
+
registerAsset(type, value, defaultPriority) {
|
|
1722
1824
|
if (type === "preload") {
|
|
1723
1825
|
registerPreloadLink(tracking, headRegistry, value, nonce);
|
|
1724
1826
|
return;
|
|
@@ -1735,6 +1837,7 @@ function renderToString(code, options = {}) {
|
|
|
1735
1837
|
}
|
|
1736
1838
|
styles.add(value);
|
|
1737
1839
|
}
|
|
1840
|
+
if (defaultPriority && tracking.lowModules) tracking.lowModules.add(value);
|
|
1738
1841
|
tracking.emittedAssets.add(value);
|
|
1739
1842
|
}
|
|
1740
1843
|
};
|
|
@@ -1761,7 +1864,7 @@ function renderToString(code, options = {}) {
|
|
|
1761
1864
|
closed = true;
|
|
1762
1865
|
serializer.close();
|
|
1763
1866
|
const head = renderShellHead(headRegistry, nonce, null, noScripts, traceMetaMarkup(context.trace));
|
|
1764
|
-
const document = withShellEnd(assembleDocument(
|
|
1867
|
+
const document = withShellEnd(assembleDocument(html, tracking.emittedAssets, tracking.preloadLinks, tracking.inlineStyles, scripts.length ? scripts : "", nonce, head, onHead, tracking.lowModules), context, renderId, nonce, noScripts);
|
|
1765
1868
|
if (render) render.shell();
|
|
1766
1869
|
if (requestEvent && requestEvent.response) {
|
|
1767
1870
|
commitResponseStub(requestEvent.response, {
|
|
@@ -1810,9 +1913,7 @@ function renderToStream(code, options = {}) {
|
|
|
1810
1913
|
let rootOwner;
|
|
1811
1914
|
let serializer;
|
|
1812
1915
|
let disconnected = false;
|
|
1813
|
-
let failed = false;
|
|
1814
1916
|
let onFailed;
|
|
1815
|
-
let onDisconnectedBeforeShell;
|
|
1816
1917
|
const defuse = p => {
|
|
1817
1918
|
if (p && typeof p.then === "function") p.then(undefined, () => {});
|
|
1818
1919
|
};
|
|
@@ -1824,11 +1925,11 @@ function renderToStream(code, options = {}) {
|
|
|
1824
1925
|
close() {}
|
|
1825
1926
|
};
|
|
1826
1927
|
const onFailure = complete => {
|
|
1827
|
-
if (
|
|
1928
|
+
if (dead) return complete(undefined, disconnected || undefined);
|
|
1828
1929
|
const prev = onFailed;
|
|
1829
|
-
onFailed = prev ? sink => {
|
|
1830
|
-
prev(sink);
|
|
1831
|
-
complete(sink);
|
|
1930
|
+
onFailed = prev ? (sink, gone) => {
|
|
1931
|
+
prev(sink, gone);
|
|
1932
|
+
complete(sink, gone);
|
|
1832
1933
|
} : complete;
|
|
1833
1934
|
};
|
|
1834
1935
|
const abandon = (disconnect, quiet) => {
|
|
@@ -1846,11 +1947,12 @@ function renderToStream(code, options = {}) {
|
|
|
1846
1947
|
}, null);
|
|
1847
1948
|
dead = true;
|
|
1848
1949
|
completed = true;
|
|
1849
|
-
if (disconnect) disconnected =
|
|
1950
|
+
if (disconnect) disconnected = disconnect;
|
|
1850
1951
|
if (render) settleRender(render, rootOwner, disconnect ? "abandoned" : "error");
|
|
1851
1952
|
const sink = writable;
|
|
1852
1953
|
buffer = {
|
|
1853
|
-
write() {}
|
|
1954
|
+
write() {},
|
|
1955
|
+
flush() {}
|
|
1854
1956
|
};
|
|
1855
1957
|
writable = {
|
|
1856
1958
|
end() {}
|
|
@@ -1875,10 +1977,7 @@ function renderToStream(code, options = {}) {
|
|
|
1875
1977
|
for (const p of stubBatch.values()) defuse(p);
|
|
1876
1978
|
stubBatch = null;
|
|
1877
1979
|
}
|
|
1878
|
-
|
|
1879
|
-
failed = true;
|
|
1880
|
-
onFailed && onFailed(sink);
|
|
1881
|
-
} else if (!sink && onDisconnectedBeforeShell) onDisconnectedBeforeShell();
|
|
1980
|
+
onFailed && onFailed(sink, disconnect);
|
|
1882
1981
|
};
|
|
1883
1982
|
const failRender = err => {
|
|
1884
1983
|
reportFailure(err, "failed");
|
|
@@ -1947,21 +2046,71 @@ function renderToStream(code, options = {}) {
|
|
|
1947
2046
|
let stableOrder = false;
|
|
1948
2047
|
let parkedWrites = null;
|
|
1949
2048
|
const byKey = (a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0;
|
|
1950
|
-
|
|
1951
|
-
|
|
2049
|
+
let stranded = false;
|
|
2050
|
+
let writingRecord = false;
|
|
2051
|
+
let recordFailed = false;
|
|
2052
|
+
const plainRecords = new WeakMap();
|
|
2053
|
+
const caught = new Set();
|
|
2054
|
+
let unclaimed = null;
|
|
2055
|
+
const rejected = new Map();
|
|
2056
|
+
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`;
|
|
2057
|
+
const plainFor = (id, value) => {
|
|
2058
|
+
const keyed = value !== null && typeof value === "object";
|
|
2059
|
+
let plain = keyed && plainRecords.get(value);
|
|
2060
|
+
if (!plain) {
|
|
2061
|
+
plain = new Error(plainMessage(id, value));
|
|
2062
|
+
if (keyed) plainRecords.set(value, plain);
|
|
2063
|
+
}
|
|
2064
|
+
return plain;
|
|
2065
|
+
};
|
|
2066
|
+
const claim = () => {
|
|
2067
|
+
if (unclaimed) {
|
|
2068
|
+
for (const reason of unclaimed) if (!caught.has(reason)) stranded = true;
|
|
2069
|
+
unclaimed = null;
|
|
2070
|
+
}
|
|
2071
|
+
return stranded;
|
|
2072
|
+
};
|
|
2073
|
+
const claimLater = reason => {
|
|
2074
|
+
if (firstFlushed || stranded || caught.has(reason)) return;
|
|
2075
|
+
if (!unclaimed) {
|
|
2076
|
+
unclaimed = new Set();
|
|
2077
|
+
deferFlush(() => {
|
|
2078
|
+
if (!rootHoles && claim()) abandon();
|
|
2079
|
+
});
|
|
2080
|
+
}
|
|
2081
|
+
unclaimed.add(reason);
|
|
2082
|
+
};
|
|
2083
|
+
const handOver = (id, value, error) => {
|
|
2084
|
+
if (!error || options.serializer) return serializer.write(id, value);
|
|
2085
|
+
let plain = value !== null && typeof value === "object" && plainRecords.get(value);
|
|
2086
|
+
if (!plain) {
|
|
2087
|
+
recordFailed = false;
|
|
2088
|
+
writingRecord = true;
|
|
2089
|
+
try {
|
|
2090
|
+
serializer.write(id, value);
|
|
2091
|
+
} finally {
|
|
2092
|
+
writingRecord = false;
|
|
2093
|
+
}
|
|
2094
|
+
if (!recordFailed) return;
|
|
2095
|
+
plain = plainFor(id, value);
|
|
2096
|
+
}
|
|
2097
|
+
serializer.write(id, plain);
|
|
2098
|
+
};
|
|
2099
|
+
const write = (id, value, error) => {
|
|
2100
|
+
if (stableOrder && !dead) (parkedWrites ||= []).push([id, value, error]);else handOver(id, value, error);
|
|
1952
2101
|
};
|
|
1953
2102
|
const flushParkedWrites = () => {
|
|
1954
2103
|
if (!parkedWrites) return;
|
|
1955
2104
|
const writes = parkedWrites.sort(byKey);
|
|
1956
2105
|
parkedWrites = null;
|
|
1957
|
-
for (let i = 0; i < writes.length; i++)
|
|
2106
|
+
for (let i = 0; i < writes.length; i++) handOver(writes[i][0], writes[i][1], writes[i][2]);
|
|
1958
2107
|
};
|
|
1959
2108
|
const flushStubBatch = () => {
|
|
1960
2109
|
if (!stubBatch) return;
|
|
1961
2110
|
const entries = [...stubBatch];
|
|
1962
2111
|
stubBatch = null;
|
|
1963
2112
|
if (stableOrder) entries.sort(byKey);
|
|
1964
|
-
for (let i = 0; i < entries.length; i++)
|
|
2113
|
+
for (let i = 0; i < entries.length; i++) handOver(entries[i][0], entries[i][1]);
|
|
1965
2114
|
};
|
|
1966
2115
|
let headerEmitted = false;
|
|
1967
2116
|
const pushTask = task => {
|
|
@@ -1979,6 +2128,7 @@ function renderToStream(code, options = {}) {
|
|
|
1979
2128
|
const onDone = () => {
|
|
1980
2129
|
if (dead) return;
|
|
1981
2130
|
writeTasks();
|
|
2131
|
+
if (claim()) return abandon();
|
|
1982
2132
|
lastBlockingSize = blockingPromises.size;
|
|
1983
2133
|
doShell();
|
|
1984
2134
|
onCompleteAll && onCompleteAll({
|
|
@@ -2022,7 +2172,7 @@ function renderToStream(code, options = {}) {
|
|
|
2022
2172
|
},
|
|
2023
2173
|
asset(type, value) {
|
|
2024
2174
|
if (type === "module") {
|
|
2025
|
-
buffer.write(
|
|
2175
|
+
buffer.write(modulePreloadLink(value, nonceAttr(nonce, "script"), tracking.lowModules));
|
|
2026
2176
|
} else if (type === "preload") {
|
|
2027
2177
|
buffer.write(`<link${value.attrHtml}>`);
|
|
2028
2178
|
} else if (type === "inline-style") {
|
|
@@ -2032,7 +2182,7 @@ function renderToStream(code, options = {}) {
|
|
|
2032
2182
|
}
|
|
2033
2183
|
},
|
|
2034
2184
|
shell(shellHtml, meta) {
|
|
2035
|
-
buffer.write(withShellEnd(assembleDocument(shellHtml, meta.preloads, meta.preloadLinks, meta.inlineStyles, meta.tasks.length ? meta.tasks : "", nonce, meta.head, onHead), context, renderId, nonce, noScripts));
|
|
2185
|
+
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));
|
|
2036
2186
|
},
|
|
2037
2187
|
...options.sink
|
|
2038
2188
|
};
|
|
@@ -2041,7 +2191,19 @@ function renderToStream(code, options = {}) {
|
|
|
2041
2191
|
plugins: options.plugins,
|
|
2042
2192
|
onData: payload => sink.data(payload),
|
|
2043
2193
|
onDone,
|
|
2044
|
-
onError:
|
|
2194
|
+
onError: (err, key) => {
|
|
2195
|
+
const rejection = !options.serializer && !writingRecord && rejected.has(key);
|
|
2196
|
+
const reason = rejection && rejected.get(key);
|
|
2197
|
+
if (!rejection || reason === null || typeof reason !== "object" || !plainRecords.has(reason)) reportFailure(err, "serialize");
|
|
2198
|
+
if (writingRecord) recordFailed = true;else if (rejection) {
|
|
2199
|
+
plainFor(key, reason);
|
|
2200
|
+
claimLater(reason);
|
|
2201
|
+
} else if (!options.serializer && !firstFlushed && !stranded) {
|
|
2202
|
+
stranded = true;
|
|
2203
|
+
deferFlush(() => abandon());
|
|
2204
|
+
}
|
|
2205
|
+
},
|
|
2206
|
+
late: (serialize, refs, onData, scopeId) => rejectUnserializedKey(serialize, refs, onData, scopeId, key => !firstFlushed && rejected.has(key) ? plainMessage(key, rejected.get(key)) : undefined)
|
|
2045
2207
|
});
|
|
2046
2208
|
let rootAssetsSerialized = false;
|
|
2047
2209
|
const serializeRootAssets = () => {
|
|
@@ -2120,7 +2282,10 @@ function renderToStream(code, options = {}) {
|
|
|
2120
2282
|
raced.catch(() => {});
|
|
2121
2283
|
pendingSerialized.set(id, settle);
|
|
2122
2284
|
const drop = () => pendingSerialized.delete(id);
|
|
2123
|
-
p.then(drop,
|
|
2285
|
+
p.then(drop, reason => {
|
|
2286
|
+
drop();
|
|
2287
|
+
rejected.set(id, reason);
|
|
2288
|
+
});
|
|
2124
2289
|
return raced;
|
|
2125
2290
|
};
|
|
2126
2291
|
const abandonSubtree = (key, error) => {
|
|
@@ -2209,7 +2374,7 @@ function renderToStream(code, options = {}) {
|
|
|
2209
2374
|
tmp += payload;
|
|
2210
2375
|
}
|
|
2211
2376
|
};
|
|
2212
|
-
const tracking = createAssetTracking();
|
|
2377
|
+
const tracking = createAssetTracking(options.lowPriorityPreloads);
|
|
2213
2378
|
const headRegistry = createHeadRegistry();
|
|
2214
2379
|
let headScriptFlushed = false;
|
|
2215
2380
|
const emitHeadOps = (key, ops) => {
|
|
@@ -2234,7 +2399,7 @@ function renderToStream(code, options = {}) {
|
|
|
2234
2399
|
}
|
|
2235
2400
|
}, nonce, tags);
|
|
2236
2401
|
},
|
|
2237
|
-
registerAsset(type, value) {
|
|
2402
|
+
registerAsset(type, value, defaultPriority) {
|
|
2238
2403
|
if (type === "preload") {
|
|
2239
2404
|
const entry = registerPreloadLink(tracking, headRegistry, value, nonce);
|
|
2240
2405
|
if (entry && firstFlushed) sink.asset("preload", entry);
|
|
@@ -2256,6 +2421,7 @@ function renderToStream(code, options = {}) {
|
|
|
2256
2421
|
}
|
|
2257
2422
|
styles.add(value);
|
|
2258
2423
|
}
|
|
2424
|
+
if (defaultPriority && tracking.lowModules) tracking.lowModules.add(value);
|
|
2259
2425
|
if (!tracking.emittedAssets.has(value)) {
|
|
2260
2426
|
tracking.emittedAssets.add(value);
|
|
2261
2427
|
if (firstFlushed) sink.asset(type, value);
|
|
@@ -2282,12 +2448,17 @@ function renderToStream(code, options = {}) {
|
|
|
2282
2448
|
const last = html.indexOf(`<!--!$/${id}-->`, first + placeholder.length);
|
|
2283
2449
|
html = html.slice(0, first) + resolveSSRSync(escape(payloadFn())) + html.slice(last + placeholder.length + 1);
|
|
2284
2450
|
},
|
|
2285
|
-
serialize(id, p, deferStream) {
|
|
2451
|
+
serialize(id, p, deferStream, errorRecord) {
|
|
2286
2452
|
p = guardChannel(p);
|
|
2287
2453
|
if (p && typeof p === "object" && typeof p.then === "function") {
|
|
2288
2454
|
if (!firstFlushed && deferStream) {
|
|
2289
2455
|
blockingPromises.add(p);
|
|
2290
|
-
p.then(d => write(id, d)).catch(e =>
|
|
2456
|
+
p.then(d => write(id, d)).catch(e => {
|
|
2457
|
+
rejected.set(id, e);
|
|
2458
|
+
const r = Promise.reject(e);
|
|
2459
|
+
r.catch(() => {});
|
|
2460
|
+
write(id, r);
|
|
2461
|
+
});
|
|
2291
2462
|
return;
|
|
2292
2463
|
}
|
|
2293
2464
|
p = trackSerialized(id, p);
|
|
@@ -2296,7 +2467,7 @@ function renderToStream(code, options = {}) {
|
|
|
2296
2467
|
return;
|
|
2297
2468
|
}
|
|
2298
2469
|
}
|
|
2299
|
-
write(id, p);
|
|
2470
|
+
write(id, p, errorRecord);
|
|
2300
2471
|
},
|
|
2301
2472
|
escape: escape,
|
|
2302
2473
|
resolve: resolveSSRNode,
|
|
@@ -2370,7 +2541,7 @@ function renderToStream(code, options = {}) {
|
|
|
2370
2541
|
const styles = collectStreamStyles(key, tracking, headStyles);
|
|
2371
2542
|
const headOps = error ? null : flushHeadFragment(headRegistry, key, nonce);
|
|
2372
2543
|
if (headOps) emitHeadOps(key, headOps);
|
|
2373
|
-
sink.fragment(key,
|
|
2544
|
+
sink.fragment(key, value !== undefined ? value : error ? "" : " ", {
|
|
2374
2545
|
styles,
|
|
2375
2546
|
revealGroup,
|
|
2376
2547
|
error: error ? ssrSanitizeError(error, null, undefined, undefined, errorScope) : error
|
|
@@ -2401,13 +2572,22 @@ function renderToStream(code, options = {}) {
|
|
|
2401
2572
|
context.failRender = failRender;
|
|
2402
2573
|
context.errorPolicy = options.onError;
|
|
2403
2574
|
context._errorScope = errorScope;
|
|
2575
|
+
context.contained = (error, wire) => {
|
|
2576
|
+
caught.add(error);
|
|
2577
|
+
caught.add(wire);
|
|
2578
|
+
};
|
|
2404
2579
|
context.flushed = () => firstFlushed;
|
|
2405
2580
|
context.trace = requestEvent ? traceForEvent(requestEvent) : traceFor(context, undefined);
|
|
2406
2581
|
render = timeDocument(context, context.trace, "stream", requestEvent);
|
|
2407
2582
|
registerEntryAssets(manifest);
|
|
2408
2583
|
context.writer = createHydrationWriter(context, () => !completed);
|
|
2409
2584
|
const signal = options.signal;
|
|
2410
|
-
|
|
2585
|
+
let cancelled = false;
|
|
2586
|
+
const onAbort = signal ? () => {
|
|
2587
|
+
if (dead) return;
|
|
2588
|
+
cancelled = true;
|
|
2589
|
+
abandon("signal", !!(signal.reason && signal.reason.quiet === true));
|
|
2590
|
+
} : undefined;
|
|
2411
2591
|
const endEdges = context.edges ? beginEdgesRender() : undefined;
|
|
2412
2592
|
let html;
|
|
2413
2593
|
try {
|
|
@@ -2513,7 +2693,7 @@ function renderToStream(code, options = {}) {
|
|
|
2513
2693
|
flushStubBatch();
|
|
2514
2694
|
const head = renderShellHead(headRegistry, nonce, k => registry.has(k), noScripts, traceMetaMarkup(context.trace));
|
|
2515
2695
|
if (render) render.shell();
|
|
2516
|
-
sink.shell(
|
|
2696
|
+
sink.shell(html, {
|
|
2517
2697
|
preloads: tracking.emittedAssets,
|
|
2518
2698
|
preloadLinks: tracking.preloadLinks,
|
|
2519
2699
|
inlineStyles: tracking.inlineStyles,
|
|
@@ -2569,9 +2749,12 @@ function renderToStream(code, options = {}) {
|
|
|
2569
2749
|
const pipeToImpl = w => {
|
|
2570
2750
|
let resolve;
|
|
2571
2751
|
const p = new Promise(r => resolve = r);
|
|
2572
|
-
|
|
2752
|
+
let closeOnAbort = () => w.close().catch(() => {});
|
|
2753
|
+
onFailure((sink, gone) => {
|
|
2573
2754
|
try {
|
|
2574
|
-
if (
|
|
2755
|
+
if (!gone) {
|
|
2756
|
+
if (sink) sink.end();else w.close().catch(() => {});
|
|
2757
|
+
} else if (gone === "signal") closeOnAbort();
|
|
2575
2758
|
} catch (_) {}
|
|
2576
2759
|
resolve();
|
|
2577
2760
|
});
|
|
@@ -2586,6 +2769,7 @@ function renderToStream(code, options = {}) {
|
|
|
2586
2769
|
return;
|
|
2587
2770
|
}
|
|
2588
2771
|
if (!shellCompleted) return flush();
|
|
2772
|
+
if (claim()) return abandon();
|
|
2589
2773
|
const encoder = new TextEncoder();
|
|
2590
2774
|
const writer = w.getWriter();
|
|
2591
2775
|
let pendingWrites = Promise.resolve();
|
|
@@ -2597,6 +2781,10 @@ function renderToStream(code, options = {}) {
|
|
|
2597
2781
|
}
|
|
2598
2782
|
};
|
|
2599
2783
|
writer.closed && writer.closed.catch(failed);
|
|
2784
|
+
closeOnAbort = () => {
|
|
2785
|
+
ended = true;
|
|
2786
|
+
pendingWrites.then(() => writer.close()).catch(() => {});
|
|
2787
|
+
};
|
|
2600
2788
|
buffer = writable = coalesceWrites(payload => {
|
|
2601
2789
|
pendingWrites = pendingWrites.then(() => writer.write(encoder.encode(payload))).catch(failed);
|
|
2602
2790
|
}, () => {
|
|
@@ -2628,7 +2816,7 @@ function renderToStream(code, options = {}) {
|
|
|
2628
2816
|
event: requestEvent
|
|
2629
2817
|
});
|
|
2630
2818
|
};
|
|
2631
|
-
const p = new Promise(resolve => {
|
|
2819
|
+
const p = new Promise((resolve, reject) => {
|
|
2632
2820
|
function complete() {
|
|
2633
2821
|
freezeHead();
|
|
2634
2822
|
dispose();
|
|
@@ -2641,11 +2829,12 @@ function renderToStream(code, options = {}) {
|
|
|
2641
2829
|
complete();
|
|
2642
2830
|
};
|
|
2643
2831
|
} else onCompleteAll = complete;
|
|
2644
|
-
onFailure(() => resolve(tmp));
|
|
2832
|
+
onFailure(() => cancelled ? reject(signal.reason) : resolve(tmp));
|
|
2645
2833
|
function flush() {
|
|
2646
2834
|
allSettled(blockingPromises).then(awaited => {
|
|
2647
2835
|
scheduleFlush(() => {
|
|
2648
2836
|
if (dead) return;
|
|
2837
|
+
sharedConfig.context = context;
|
|
2649
2838
|
try {
|
|
2650
2839
|
if (blockingPromises.size !== lastBlockingSize || !resolveRootHoles() || blockingPromises.size !== lastBlockingSize || !headShellReady(headRegistry, p => blockingPromises.add(p))) return flush();
|
|
2651
2840
|
} catch (err) {
|
|
@@ -2663,15 +2852,12 @@ function renderToStream(code, options = {}) {
|
|
|
2663
2852
|
pipe(w) {
|
|
2664
2853
|
claimConsumer("pipe");
|
|
2665
2854
|
const abandoned = w[SHELL_ABANDONED];
|
|
2666
|
-
onFailure(sink => {
|
|
2855
|
+
onFailure((sink, gone) => {
|
|
2667
2856
|
try {
|
|
2668
|
-
sink ? sink.end() : abandoned ? abandoned() : w.end();
|
|
2857
|
+
if (!gone) sink ? sink.end() : abandoned ? abandoned() : w.end();else if (!sink && abandoned) abandoned();else if (gone === "signal") w.end();
|
|
2669
2858
|
} catch (_) {}
|
|
2670
2859
|
});
|
|
2671
|
-
if (abandoned)
|
|
2672
|
-
w[ABANDON_RENDER] = abandon;
|
|
2673
|
-
if (disconnected) abandoned();else onDisconnectedBeforeShell = abandoned;
|
|
2674
|
-
}
|
|
2860
|
+
if (abandoned) w[ABANDON_RENDER] = abandon;
|
|
2675
2861
|
function flush() {
|
|
2676
2862
|
allSettled(blockingPromises).then(awaited => {
|
|
2677
2863
|
scheduleFlush(() => {
|
|
@@ -2683,6 +2869,7 @@ function renderToStream(code, options = {}) {
|
|
|
2683
2869
|
return;
|
|
2684
2870
|
}
|
|
2685
2871
|
if (!shellCompleted) return flush();
|
|
2872
|
+
if (claim()) return abandon();
|
|
2686
2873
|
const sink = guardSink(w);
|
|
2687
2874
|
buffer = writable = coalesceWrites(sink.write, sink.end);
|
|
2688
2875
|
buffer.write(tmp);
|
|
@@ -2748,6 +2935,8 @@ function buildAsyncWrap(err, node) {
|
|
|
2748
2935
|
fn.$rw = true;
|
|
2749
2936
|
if (suppress) fn.$lhSuppress = true;
|
|
2750
2937
|
if (node.$lhSkip) fn.$lhSkip = true;
|
|
2938
|
+
if (node.$lhInTag) fn.$lhInTag = true;
|
|
2939
|
+
if (node.$lhAttr) fn.$lhAttr = node.$lhAttr;
|
|
2751
2940
|
if (node.$lhBinding) fn.$lhBinding = node.$lhBinding;
|
|
2752
2941
|
return {
|
|
2753
2942
|
fn,
|
|
@@ -2949,7 +3138,8 @@ function createLiveHoles(sink, scoped, settled, errorScope) {
|
|
|
2949
3138
|
t: [""],
|
|
2950
3139
|
h: [],
|
|
2951
3140
|
p: [],
|
|
2952
|
-
rows: null
|
|
3141
|
+
rows: null,
|
|
3142
|
+
$: SSR_NODE
|
|
2953
3143
|
};
|
|
2954
3144
|
try {
|
|
2955
3145
|
result.rows = resolveValue(holeValue(hole), result);
|
|
@@ -3048,16 +3238,41 @@ function createLiveHoles(sink, scoped, settled, errorScope) {
|
|
|
3048
3238
|
},
|
|
3049
3239
|
nest(hole) {
|
|
3050
3240
|
const s = engine.scope;
|
|
3051
|
-
if (!s || s.h === hole || hole.$lhSkip || inScope && !inScope()) return undefined;
|
|
3241
|
+
if (!s || s.h === hole || hole.$lhSkip || hole.$lhInTag || inScope && !inScope()) return undefined;
|
|
3052
3242
|
engine.scope = scopeFor(hole);
|
|
3053
3243
|
return s;
|
|
3054
3244
|
},
|
|
3055
3245
|
content(hole) {
|
|
3246
|
+
if (hole.$lhInTag) {
|
|
3247
|
+
const cap = hole.$lhAttr;
|
|
3248
|
+
if (!cap || cap.adopted || engine.suppressed || engine.sweeping) return null;
|
|
3249
|
+
const r = tryResolveFunctionHole(hole);
|
|
3250
|
+
if (typeof r !== "string") {
|
|
3251
|
+
const res = {
|
|
3252
|
+
t: [""],
|
|
3253
|
+
h: [],
|
|
3254
|
+
p: [],
|
|
3255
|
+
$: SSR_NODE
|
|
3256
|
+
};
|
|
3257
|
+
appendResolvedNode(res, r);
|
|
3258
|
+
return res;
|
|
3259
|
+
}
|
|
3260
|
+
if (--cap.waiting === 0 && !cap.closed) {
|
|
3261
|
+
try {
|
|
3262
|
+
cap.base = attrPartsText(cap.parts);
|
|
3263
|
+
} catch (err) {
|
|
3264
|
+
cap.base = null;
|
|
3265
|
+
}
|
|
3266
|
+
if (cap.base !== null) engine.attr(cap);
|
|
3267
|
+
}
|
|
3268
|
+
return r;
|
|
3269
|
+
}
|
|
3056
3270
|
if (hole.$lhSuppress) {
|
|
3057
3271
|
const r = {
|
|
3058
3272
|
t: [""],
|
|
3059
3273
|
h: [],
|
|
3060
|
-
p: []
|
|
3274
|
+
p: [],
|
|
3275
|
+
$: SSR_NODE
|
|
3061
3276
|
};
|
|
3062
3277
|
let rows = null;
|
|
3063
3278
|
const b = hole.$lhBinding;
|
|
@@ -3161,7 +3376,8 @@ function createLiveHoles(sink, scoped, settled, errorScope) {
|
|
|
3161
3376
|
const r = {
|
|
3162
3377
|
t: [""],
|
|
3163
3378
|
h: [],
|
|
3164
|
-
p: []
|
|
3379
|
+
p: [],
|
|
3380
|
+
$: SSR_NODE
|
|
3165
3381
|
};
|
|
3166
3382
|
engine.suppressed++;
|
|
3167
3383
|
try {
|
|
@@ -3180,13 +3396,15 @@ function createLiveHoles(sink, scoped, settled, errorScope) {
|
|
|
3180
3396
|
res = {
|
|
3181
3397
|
t: ["", ""],
|
|
3182
3398
|
h: [escalated.fn],
|
|
3183
|
-
p: [escalated.p]
|
|
3399
|
+
p: [escalated.p],
|
|
3400
|
+
$: SSR_NODE
|
|
3184
3401
|
};
|
|
3185
3402
|
} else {
|
|
3186
3403
|
res = {
|
|
3187
3404
|
t: [""],
|
|
3188
3405
|
h: [],
|
|
3189
|
-
p: []
|
|
3406
|
+
p: [],
|
|
3407
|
+
$: SSR_NODE
|
|
3190
3408
|
};
|
|
3191
3409
|
try {
|
|
3192
3410
|
rows = resolveValue(value, res);
|
|
@@ -3216,20 +3434,59 @@ function createLiveHoles(sink, scoped, settled, errorScope) {
|
|
|
3216
3434
|
t[t.length - 1] += close;
|
|
3217
3435
|
sink.openBinding(key, b);
|
|
3218
3436
|
return {
|
|
3219
|
-
t,
|
|
3437
|
+
t: t,
|
|
3220
3438
|
h: res.h,
|
|
3221
|
-
p: res.p
|
|
3439
|
+
p: res.p,
|
|
3440
|
+
$: SSR_NODE
|
|
3222
3441
|
};
|
|
3223
3442
|
},
|
|
3224
3443
|
mint() {
|
|
3225
3444
|
return nextId++;
|
|
3226
3445
|
},
|
|
3446
|
+
open(text, off, hole) {
|
|
3447
|
+
const pending = hole && hole.$lhAttr;
|
|
3448
|
+
let inject;
|
|
3449
|
+
let id;
|
|
3450
|
+
if (pending && !pending.adopted && text.startsWith(pending.inject, off)) {
|
|
3451
|
+
pending.adopted = true;
|
|
3452
|
+
({
|
|
3453
|
+
id,
|
|
3454
|
+
inject
|
|
3455
|
+
} = pending);
|
|
3456
|
+
} else {
|
|
3457
|
+
id = nextId++;
|
|
3458
|
+
inject = ` data-lha="${id}"`;
|
|
3459
|
+
text = text.slice(0, off) + inject + text.slice(off);
|
|
3460
|
+
}
|
|
3461
|
+
const prefix = text.slice(off + inject.length);
|
|
3462
|
+
return {
|
|
3463
|
+
id,
|
|
3464
|
+
parts: [prefix],
|
|
3465
|
+
base: prefix,
|
|
3466
|
+
inject,
|
|
3467
|
+
waiting: 0,
|
|
3468
|
+
text
|
|
3469
|
+
};
|
|
3470
|
+
},
|
|
3471
|
+
retry(fn, cap) {
|
|
3472
|
+
if (typeof fn !== "function") return;
|
|
3473
|
+
fn.$lhInTag = true;
|
|
3474
|
+
if (cap) {
|
|
3475
|
+
fn.$lhAttr = cap;
|
|
3476
|
+
cap.waiting++;
|
|
3477
|
+
}
|
|
3478
|
+
},
|
|
3227
3479
|
active() {
|
|
3228
3480
|
return (!inScope || inScope()) && !(settled && settled());
|
|
3229
3481
|
},
|
|
3230
3482
|
attr(cap) {
|
|
3231
|
-
|
|
3232
|
-
|
|
3483
|
+
if (cap.waiting) {
|
|
3484
|
+
cap.owner = getOwner();
|
|
3485
|
+
cap.ctx = sharedConfig.context;
|
|
3486
|
+
return;
|
|
3487
|
+
}
|
|
3488
|
+
const owner = cap.owner !== undefined ? cap.owner : getOwner();
|
|
3489
|
+
const holeCtx = cap.ctx !== undefined ? cap.ctx : sharedConfig.context;
|
|
3233
3490
|
const b = {
|
|
3234
3491
|
key: "lha:" + cap.id,
|
|
3235
3492
|
children: [],
|
|
@@ -3244,29 +3501,7 @@ function createLiveHoles(sink, scoped, settled, errorScope) {
|
|
|
3244
3501
|
engine.gateHit = false;
|
|
3245
3502
|
let html = "";
|
|
3246
3503
|
try {
|
|
3247
|
-
|
|
3248
|
-
let groupVal = null;
|
|
3249
|
-
const run = () => {
|
|
3250
|
-
for (const part of cap.parts) {
|
|
3251
|
-
if (typeof part === "string") {
|
|
3252
|
-
html += part;
|
|
3253
|
-
continue;
|
|
3254
|
-
}
|
|
3255
|
-
let v;
|
|
3256
|
-
if (part.g) {
|
|
3257
|
-
if (group !== part.g) {
|
|
3258
|
-
group = part.g;
|
|
3259
|
-
groupVal = part.g();
|
|
3260
|
-
}
|
|
3261
|
-
v = groupVal[part.i];
|
|
3262
|
-
} else {
|
|
3263
|
-
v = part.f();
|
|
3264
|
-
}
|
|
3265
|
-
const vt = typeof v;
|
|
3266
|
-
if (vt === "string" || vt === "number") html += v;
|
|
3267
|
-
}
|
|
3268
|
-
};
|
|
3269
|
-
swept(owner, holeCtx, run);
|
|
3504
|
+
swept(owner, holeCtx, () => html = attrPartsText(cap.parts));
|
|
3270
3505
|
} catch (err) {
|
|
3271
3506
|
if (ssrHandleError(err, true)) {
|
|
3272
3507
|
if (!engine.sweptOwners) return;
|
|
@@ -3373,10 +3608,35 @@ function rowPatch(a, b) {
|
|
|
3373
3608
|
}
|
|
3374
3609
|
}
|
|
3375
3610
|
}
|
|
3611
|
+
function attrPartsText(parts) {
|
|
3612
|
+
let html = "";
|
|
3613
|
+
let group = null;
|
|
3614
|
+
let groupVal = null;
|
|
3615
|
+
for (const part of parts) {
|
|
3616
|
+
if (typeof part === "string") {
|
|
3617
|
+
html += part;
|
|
3618
|
+
continue;
|
|
3619
|
+
}
|
|
3620
|
+
let v;
|
|
3621
|
+
if (part.g) {
|
|
3622
|
+
if (group !== part.g) {
|
|
3623
|
+
group = part.g;
|
|
3624
|
+
groupVal = part.g();
|
|
3625
|
+
}
|
|
3626
|
+
v = groupVal[part.i];
|
|
3627
|
+
} else {
|
|
3628
|
+
v = part.f();
|
|
3629
|
+
}
|
|
3630
|
+
const vt = typeof v;
|
|
3631
|
+
if (vt === "string" || vt === "number") html += v;
|
|
3632
|
+
}
|
|
3633
|
+
return html;
|
|
3634
|
+
}
|
|
3376
3635
|
function ssr(t) {
|
|
3377
3636
|
const len = arguments.length;
|
|
3378
3637
|
if (len === 1) return {
|
|
3379
|
-
t
|
|
3638
|
+
t: t,
|
|
3639
|
+
$: SSR_NODE
|
|
3380
3640
|
};
|
|
3381
3641
|
let s = t[0];
|
|
3382
3642
|
let result = null;
|
|
@@ -3392,30 +3652,18 @@ function ssr(t) {
|
|
|
3392
3652
|
seg: -1,
|
|
3393
3653
|
off: hp.openOff[0]
|
|
3394
3654
|
};
|
|
3395
|
-
const captureStart =
|
|
3655
|
+
const captureStart = hole => {
|
|
3396
3656
|
if (cap) return true;
|
|
3397
3657
|
if (!lastOpen || live.suppressed || live.sweeping || !live.active()) return false;
|
|
3658
|
+
if (lastOpen.r === null && result !== null && result.t.length === 1) {
|
|
3659
|
+
lastOpen.r = result;
|
|
3660
|
+
lastOpen.seg = 0;
|
|
3661
|
+
}
|
|
3398
3662
|
if (lastOpen.r !== result || result !== null && lastOpen.seg !== result.t.length - 1) {
|
|
3399
3663
|
return false;
|
|
3400
3664
|
}
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
let prefix;
|
|
3404
|
-
if (result === null) {
|
|
3405
|
-
s = s.slice(0, lastOpen.off) + inject + s.slice(lastOpen.off);
|
|
3406
|
-
prefix = s.slice(lastOpen.off + inject.length);
|
|
3407
|
-
} else {
|
|
3408
|
-
const seg = result.t[lastOpen.seg];
|
|
3409
|
-
result.t[lastOpen.seg] = seg.slice(0, lastOpen.off) + inject + seg.slice(lastOpen.off);
|
|
3410
|
-
prefix = result.t[lastOpen.seg].slice(lastOpen.off + inject.length);
|
|
3411
|
-
}
|
|
3412
|
-
cap = {
|
|
3413
|
-
id,
|
|
3414
|
-
parts: [prefix],
|
|
3415
|
-
base: prefix,
|
|
3416
|
-
at: lastOpen.seg,
|
|
3417
|
-
inject
|
|
3418
|
-
};
|
|
3665
|
+
cap = live.open(result === null ? s : result.t[lastOpen.seg], lastOpen.off, hole);
|
|
3666
|
+
if (result === null) s = cap.text;else result.t[lastOpen.seg] = cap.text;
|
|
3419
3667
|
return true;
|
|
3420
3668
|
};
|
|
3421
3669
|
for (let i = 1; i < len; i++) {
|
|
@@ -3446,7 +3694,8 @@ function ssr(t) {
|
|
|
3446
3694
|
result = {
|
|
3447
3695
|
t: [s],
|
|
3448
3696
|
h: [],
|
|
3449
|
-
p: []
|
|
3697
|
+
p: [],
|
|
3698
|
+
$: SSR_NODE
|
|
3450
3699
|
};
|
|
3451
3700
|
s = "";
|
|
3452
3701
|
}
|
|
@@ -3456,18 +3705,23 @@ function ssr(t) {
|
|
|
3456
3705
|
if (Array.isArray(lastGroupVal)) {
|
|
3457
3706
|
value = lastGroupVal[lastGroupIdx++];
|
|
3458
3707
|
hasValue = true;
|
|
3459
|
-
if (live && !hp.pos[i - 1] && captureStart()) {
|
|
3708
|
+
if (live && !hp.pos[i - 1] && captureStart(hole)) {
|
|
3460
3709
|
cap.parts.push({
|
|
3461
3710
|
g: hole,
|
|
3462
3711
|
i: lastGroupIdx - 1
|
|
3463
3712
|
});
|
|
3464
3713
|
}
|
|
3465
3714
|
} else {
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3715
|
+
const slot = ssrGroupSlot(lastGroupVal.fn, lastGroupIdx++);
|
|
3716
|
+
if (live && !hp.pos[i - 1]) {
|
|
3717
|
+
const capturing = captureStart(hole);
|
|
3718
|
+
if (capturing) cap.parts.push({
|
|
3719
|
+
g: hole,
|
|
3720
|
+
i: lastGroupIdx - 1
|
|
3721
|
+
});
|
|
3722
|
+
live.retry(slot, capturing && cap);
|
|
3469
3723
|
}
|
|
3470
|
-
result.h.push(
|
|
3724
|
+
result.h.push(slot);
|
|
3471
3725
|
result.p.push(lastGroupVal.p);
|
|
3472
3726
|
result.t.push("");
|
|
3473
3727
|
}
|
|
@@ -3487,7 +3741,8 @@ function ssr(t) {
|
|
|
3487
3741
|
result = {
|
|
3488
3742
|
t: [s],
|
|
3489
3743
|
h: [],
|
|
3490
|
-
p: []
|
|
3744
|
+
p: [],
|
|
3745
|
+
$: SSR_NODE
|
|
3491
3746
|
};
|
|
3492
3747
|
s = "";
|
|
3493
3748
|
if (rs.merge !== undefined) mergeTemplateInto(result, rs.merge);else resolveSSRNode(rs.bail, result);
|
|
@@ -3504,7 +3759,8 @@ function ssr(t) {
|
|
|
3504
3759
|
result = {
|
|
3505
3760
|
t: [s],
|
|
3506
3761
|
h: [],
|
|
3507
|
-
p: []
|
|
3762
|
+
p: [],
|
|
3763
|
+
$: SSR_NODE
|
|
3508
3764
|
};
|
|
3509
3765
|
s = "";
|
|
3510
3766
|
}
|
|
@@ -3512,28 +3768,27 @@ function ssr(t) {
|
|
|
3512
3768
|
}
|
|
3513
3769
|
} else if (result !== null) {
|
|
3514
3770
|
const inTag = live && !hp.pos[i - 1];
|
|
3515
|
-
const capturing = inTag && captureStart();
|
|
3771
|
+
const capturing = inTag && captureStart(hole);
|
|
3516
3772
|
const li = capturing ? result.t.length - 1 : 0;
|
|
3517
3773
|
const before = capturing ? result.t[li].length : 0;
|
|
3774
|
+
const pushed = result.h.length;
|
|
3518
3775
|
if (live) live.suppressed++;
|
|
3519
3776
|
try {
|
|
3520
3777
|
resolveSSRNode(hole, result);
|
|
3521
3778
|
} finally {
|
|
3522
3779
|
if (live) live.suppressed--;
|
|
3523
3780
|
}
|
|
3781
|
+
if (inTag) {
|
|
3782
|
+
for (let k = pushed; k < result.h.length; k++) live.retry(result.h[k], capturing && cap);
|
|
3783
|
+
}
|
|
3524
3784
|
if (capturing) {
|
|
3525
|
-
if (result.t.length - 1 === li)
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
});
|
|
3530
|
-
} else {
|
|
3531
|
-
result.t[cap.at] = result.t[cap.at].replace(cap.inject, "");
|
|
3532
|
-
cap = null;
|
|
3533
|
-
}
|
|
3785
|
+
if (result.t.length - 1 === li) cap.base += result.t[li].slice(before);
|
|
3786
|
+
cap.parts.push({
|
|
3787
|
+
f: hole
|
|
3788
|
+
});
|
|
3534
3789
|
}
|
|
3535
3790
|
} else {
|
|
3536
|
-
const capturing = live && !hp.pos[i - 1] && captureStart();
|
|
3791
|
+
const capturing = live && !hp.pos[i - 1] && captureStart(hole);
|
|
3537
3792
|
const scope = live && hp.pos[i - 1] && live.nest(hole);
|
|
3538
3793
|
const r = tryResolveFunctionHole(hole);
|
|
3539
3794
|
if (scope) live.scope = scope;
|
|
@@ -3546,17 +3801,18 @@ function ssr(t) {
|
|
|
3546
3801
|
});
|
|
3547
3802
|
}
|
|
3548
3803
|
} else {
|
|
3549
|
-
if (capturing) {
|
|
3550
|
-
s = s.replace(cap.inject, "");
|
|
3551
|
-
cap = null;
|
|
3552
|
-
}
|
|
3553
3804
|
result = {
|
|
3554
3805
|
t: [s],
|
|
3555
3806
|
h: [],
|
|
3556
|
-
p: []
|
|
3807
|
+
p: [],
|
|
3808
|
+
$: SSR_NODE
|
|
3557
3809
|
};
|
|
3558
3810
|
s = "";
|
|
3559
3811
|
appendResolvedNode(result, r);
|
|
3812
|
+
if (capturing) cap.parts.push({
|
|
3813
|
+
f: hole
|
|
3814
|
+
});
|
|
3815
|
+
if (live && !hp.pos[i - 1]) for (const h of result.h) live.retry(h, capturing && cap);
|
|
3560
3816
|
}
|
|
3561
3817
|
}
|
|
3562
3818
|
} else if (result !== null) {
|
|
@@ -3569,7 +3825,8 @@ function ssr(t) {
|
|
|
3569
3825
|
result = {
|
|
3570
3826
|
t: [s],
|
|
3571
3827
|
h: [],
|
|
3572
|
-
p: []
|
|
3828
|
+
p: [],
|
|
3829
|
+
$: SSR_NODE
|
|
3573
3830
|
};
|
|
3574
3831
|
s = "";
|
|
3575
3832
|
appendResolvedNode(result, r);
|
|
@@ -3605,7 +3862,8 @@ function ssr(t) {
|
|
|
3605
3862
|
if (result === null) s += next;else result.t[result.t.length - 1] += next;
|
|
3606
3863
|
}
|
|
3607
3864
|
if (result === null) return {
|
|
3608
|
-
t: s
|
|
3865
|
+
t: s,
|
|
3866
|
+
$: SSR_NODE
|
|
3609
3867
|
};
|
|
3610
3868
|
return result;
|
|
3611
3869
|
}
|
|
@@ -3685,6 +3943,7 @@ function ssrElement(tag, props, children, needsId, skip, attrs) {
|
|
|
3685
3943
|
}
|
|
3686
3944
|
const info = tagInfo(tag);
|
|
3687
3945
|
const skipChildren = info.isVoid;
|
|
3946
|
+
let sel, optValue, optOwn;
|
|
3688
3947
|
let result = info.open + hk;
|
|
3689
3948
|
let childOwner = null;
|
|
3690
3949
|
const last = sources === null ? 0 : sources.length - 1;
|
|
@@ -3703,6 +3962,11 @@ function ssrElement(tag, props, children, needsId, skip, attrs) {
|
|
|
3703
3962
|
for (let j = s + 1; j <= last; j++) {
|
|
3704
3963
|
if (keysOf[j].includes(prop)) continue nextKey;
|
|
3705
3964
|
}
|
|
3965
|
+
if (info.sel === 1 && prop === "value") {
|
|
3966
|
+
const value = props[prop];
|
|
3967
|
+
sel = ssrSelect(value);
|
|
3968
|
+
continue;
|
|
3969
|
+
}
|
|
3706
3970
|
if (info.textarea && (prop === "value" || prop === "defaultValue")) {
|
|
3707
3971
|
const value = props[prop];
|
|
3708
3972
|
if (value !== null) children = escape(value);
|
|
@@ -3722,6 +3986,9 @@ function ssrElement(tag, props, children, needsId, skip, attrs) {
|
|
|
3722
3986
|
const value = props[key];
|
|
3723
3987
|
if (value == undefined || prop.startsWith("prop:") || prop === "ref" || isEventName(prop)) continue;
|
|
3724
3988
|
if (link !== null && LinkAttributes.has(prop)) link[prop] = value;
|
|
3989
|
+
if (info.sel === 2) {
|
|
3990
|
+
if (prop === "value") optValue = value;else if (prop === "selected" && value) optOwn = true;
|
|
3991
|
+
}
|
|
3725
3992
|
if (prop === "style") {
|
|
3726
3993
|
result += ` style="${ssrStyle(value)}"`;
|
|
3727
3994
|
} else if (prop === "class") {
|
|
@@ -3736,21 +4003,58 @@ function ssrElement(tag, props, children, needsId, skip, attrs) {
|
|
|
3736
4003
|
if (attrs !== undefined) result += typeof attrs === "function" ? attrs() : attrs;
|
|
3737
4004
|
if (link !== null && link.href !== undefined) result += ssrLinkClaim(link);
|
|
3738
4005
|
if (skipChildren) return {
|
|
3739
|
-
t: result + " />"
|
|
4006
|
+
t: result + " />",
|
|
4007
|
+
$: SSR_NODE
|
|
3740
4008
|
};
|
|
3741
|
-
if (
|
|
3742
|
-
if (typeof children
|
|
4009
|
+
if (sel !== undefined) children = ssrIn(sel, () => spreadChildren(info, childOwner, children));else children = spreadChildren(info, childOwner, children);
|
|
4010
|
+
if (info.sel === 2) result += ssrOption(optValue !== undefined || typeof children !== "string" ? optValue : children.replace(/</g, "<").replace(/&/g, "&").replace(/\s+/g, " ").trim(), undefined, optOwn);
|
|
4011
|
+
let thunk = null;
|
|
4012
|
+
if (typeof children === "function" && (ctx === undefined || !ctx.liveHoles)) {
|
|
4013
|
+
thunk = children;
|
|
4014
|
+
ssrTextTail = false;
|
|
4015
|
+
try {
|
|
4016
|
+
children = thunk();
|
|
4017
|
+
} catch (err) {
|
|
4018
|
+
const res = {
|
|
4019
|
+
t: [""],
|
|
4020
|
+
h: [],
|
|
4021
|
+
p: [],
|
|
4022
|
+
$: SSR_NODE
|
|
4023
|
+
};
|
|
4024
|
+
pushSSRAsyncHole(res, err, thunk);
|
|
4025
|
+
return ssr([result + ">", info.close], res);
|
|
4026
|
+
}
|
|
4027
|
+
}
|
|
3743
4028
|
const ct = typeof children;
|
|
3744
4029
|
if (ct === "string" || ct === "number") return {
|
|
3745
|
-
t: result + ">" + children + info.close
|
|
4030
|
+
t: result + ">" + children + info.close,
|
|
4031
|
+
$: SSR_NODE
|
|
3746
4032
|
};
|
|
3747
4033
|
if (children == null || ct === "boolean") return {
|
|
3748
|
-
t: result + ">" + info.close
|
|
4034
|
+
t: result + ">" + info.close,
|
|
4035
|
+
$: SSR_NODE
|
|
4036
|
+
};
|
|
4037
|
+
if (ct === "object" && children.$ === SSR_NODE && !children.h && typeof children.t === "string") return {
|
|
4038
|
+
t: result + ">" + children.t + info.close,
|
|
4039
|
+
$: SSR_NODE
|
|
3749
4040
|
};
|
|
3750
|
-
if (
|
|
3751
|
-
|
|
4041
|
+
if (thunk === null) return ssr([result + ">", info.close], resolveSSRNode(children, undefined, true));
|
|
4042
|
+
const res = {
|
|
4043
|
+
t: [""],
|
|
4044
|
+
h: [],
|
|
4045
|
+
p: [],
|
|
4046
|
+
$: SSR_NODE
|
|
3752
4047
|
};
|
|
3753
|
-
|
|
4048
|
+
try {
|
|
4049
|
+
resolveSSRNode(children, res, false, true);
|
|
4050
|
+
} catch (err) {
|
|
4051
|
+
pushSSRAsyncHole(res, err, thunk);
|
|
4052
|
+
}
|
|
4053
|
+
return ssr([result + ">", info.close], res);
|
|
4054
|
+
}
|
|
4055
|
+
function spreadChildren(info, childOwner, children) {
|
|
4056
|
+
if (childOwner !== null) children = info.raw ? childOwner.children : escape(childOwner.children);
|
|
4057
|
+
return typeof children === "function" ? children() : children;
|
|
3754
4058
|
}
|
|
3755
4059
|
function collectSpreadSources(props, viewKeys, owners) {
|
|
3756
4060
|
for (let i = 0; i < props.length; i++) {
|
|
@@ -3794,110 +4098,37 @@ function ssrLinkClaim(attrs) {
|
|
|
3794
4098
|
if (ctx === undefined || ctx.linkClaim === undefined || attrs["aria-current"] != null) return "";
|
|
3795
4099
|
return ctx.linkClaim(attrs);
|
|
3796
4100
|
}
|
|
3797
|
-
|
|
3798
|
-
|
|
4101
|
+
const SELECT = Symbol();
|
|
4102
|
+
function ssrSelect(value) {
|
|
4103
|
+
const owner = createOwner({
|
|
4104
|
+
transparent: true
|
|
4105
|
+
});
|
|
4106
|
+
const state = {
|
|
4107
|
+
v: value,
|
|
4108
|
+
d: false,
|
|
4109
|
+
o: owner
|
|
4110
|
+
};
|
|
4111
|
+
owner._context = {
|
|
4112
|
+
...owner._context,
|
|
4113
|
+
[SELECT]: state
|
|
4114
|
+
};
|
|
4115
|
+
return state;
|
|
3799
4116
|
}
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
for (let j = i + 1; j < html.length; j++) {
|
|
3803
|
-
const c = html.charCodeAt(j);
|
|
3804
|
-
if (c === 34) {
|
|
3805
|
-
j = html.indexOf('"', j + 1);
|
|
3806
|
-
if (j < 0) return -1;
|
|
3807
|
-
} else if (c === 62) return j;
|
|
3808
|
-
}
|
|
3809
|
-
return -1;
|
|
4117
|
+
function ssrIn(state, fn) {
|
|
4118
|
+
return runWithOwner(state.o, fn);
|
|
3810
4119
|
}
|
|
3811
|
-
function
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
const lt = html.indexOf("<", i);
|
|
3816
|
-
if (lt < 0) return t + html.slice(i);
|
|
3817
|
-
t += html.slice(i, lt);
|
|
3818
|
-
if (!html.startsWith("<!--", lt)) return t;
|
|
3819
|
-
const ce = html.indexOf("-->", lt);
|
|
3820
|
-
if (ce < 0) return t;
|
|
3821
|
-
i = ce + 3;
|
|
3822
|
-
}
|
|
3823
|
-
}
|
|
3824
|
-
function tagIs(html, i, name) {
|
|
3825
|
-
if (!html.startsWith(name, i + 1)) return false;
|
|
3826
|
-
const c = html.charCodeAt(i + 1 + name.length);
|
|
3827
|
-
return c === 32 || c === 62 || c === 9 || c === 10 || c === 13;
|
|
3828
|
-
}
|
|
3829
|
-
let selectValuesActive = false;
|
|
3830
|
-
function ssrSelectValues() {
|
|
3831
|
-
selectValuesActive = true;
|
|
3832
|
-
}
|
|
3833
|
-
function resolveSSRSelectValues(html) {
|
|
3834
|
-
if (!selectValuesActive) return html;
|
|
3835
|
-
let cand = html.indexOf("<select");
|
|
3836
|
-
if (cand < 0) return html;
|
|
3837
|
-
let out = "";
|
|
3838
|
-
let idx = 0;
|
|
3839
|
-
while (cand >= 0) {
|
|
3840
|
-
if (!tagIs(html, cand, "select")) {
|
|
3841
|
-
cand = html.indexOf("<select", cand + 7);
|
|
3842
|
-
continue;
|
|
3843
|
-
}
|
|
3844
|
-
const e0 = tagEnd(html, cand);
|
|
3845
|
-
if (e0 < 0) break;
|
|
3846
|
-
const open = html.slice(cand, e0 + 1);
|
|
3847
|
-
const m = SELECT_VALUE_ATTR.exec(open);
|
|
3848
|
-
if (!m) {
|
|
3849
|
-
cand = html.indexOf("<select", e0 + 1);
|
|
3850
|
-
continue;
|
|
3851
|
-
}
|
|
3852
|
-
const bound = decodeSSREntities(m[1] ?? "");
|
|
3853
|
-
const sel = {
|
|
3854
|
-
values: /\smultiple(?=[\s>=])/.test(open) ? bound.split(",") : [bound],
|
|
3855
|
-
strip: cand + m.index,
|
|
3856
|
-
stripEnd: cand + m.index + m[0].length,
|
|
3857
|
-
body: e0 + 1,
|
|
3858
|
-
marks: [],
|
|
3859
|
-
defaulted: false
|
|
3860
|
-
};
|
|
3861
|
-
let committed = false;
|
|
3862
|
-
let i = html.indexOf("<", e0 + 1);
|
|
3863
|
-
while (i >= 0) {
|
|
3864
|
-
let e;
|
|
3865
|
-
if (html.charCodeAt(i + 1) === 33) {
|
|
3866
|
-
e = html.charCodeAt(i + 2) === 45 ? html.indexOf("-->", i) : html.indexOf(">", i);
|
|
3867
|
-
if (e < 0) break;
|
|
3868
|
-
if (html.charCodeAt(i + 2) === 45) e += 2;
|
|
3869
|
-
} else {
|
|
3870
|
-
e = tagEnd(html, i);
|
|
3871
|
-
if (e < 0) break;
|
|
3872
|
-
if (html.startsWith("</select>", i)) {
|
|
3873
|
-
out += html.slice(idx, sel.strip) + html.slice(sel.stripEnd, sel.body);
|
|
3874
|
-
let seg = sel.body;
|
|
3875
|
-
if (!sel.defaulted) {
|
|
3876
|
-
for (let k = 0; k < sel.marks.length; k++) {
|
|
3877
|
-
out += html.slice(seg, sel.marks[k]) + " selected";
|
|
3878
|
-
seg = sel.marks[k];
|
|
3879
|
-
}
|
|
3880
|
-
}
|
|
3881
|
-
out += html.slice(seg, i);
|
|
3882
|
-
idx = i;
|
|
3883
|
-
committed = true;
|
|
3884
|
-
break;
|
|
3885
|
-
} else if (tagIs(html, i, "option")) {
|
|
3886
|
-
const attrs = html.slice(i + 7, e);
|
|
3887
|
-
if (/\sselected(?=[\s=]|$)/.test(attrs)) sel.defaulted = true;else {
|
|
3888
|
-
const vm = SELECT_VALUE_ATTR.exec(attrs);
|
|
3889
|
-
const value = vm ? decodeSSREntities(vm[1] ?? "") : decodeSSREntities(optionText(html, e + 1)).replace(/\s+/g, " ").trim();
|
|
3890
|
-
if (sel.values.includes(value)) sel.marks.push(e);
|
|
3891
|
-
}
|
|
3892
|
-
}
|
|
3893
|
-
}
|
|
3894
|
-
i = html.indexOf("<", e + 1);
|
|
3895
|
-
}
|
|
3896
|
-
if (!committed) break;
|
|
3897
|
-
cand = html.indexOf("<select", idx);
|
|
4120
|
+
function ssrOption(value, state, own) {
|
|
4121
|
+
if (state === undefined) {
|
|
4122
|
+
const o = getOwner();
|
|
4123
|
+
if (!o || !(state = o._context[SELECT])) return "";
|
|
3898
4124
|
}
|
|
3899
|
-
if (
|
|
3900
|
-
|
|
4125
|
+
if (own) return state.d = true, "";
|
|
4126
|
+
if (state.d) return "";
|
|
4127
|
+
if (typeof value === "function") value = value();
|
|
4128
|
+
if (value == null) return "";
|
|
4129
|
+
value = String(value);
|
|
4130
|
+
const v = state.v;
|
|
4131
|
+
return v != null && (v.map ? v.some(x => x != null && String(x) === value) : String(v) === value) ? " selected" : "";
|
|
3901
4132
|
}
|
|
3902
4133
|
function escape(s, attr) {
|
|
3903
4134
|
const t = typeof s;
|
|
@@ -4004,7 +4235,7 @@ function tryJoinPlainSSRArray(nodes) {
|
|
|
4004
4235
|
let out = "";
|
|
4005
4236
|
for (let i = 0, len = nodes.length; i < len; i++) {
|
|
4006
4237
|
const node = nodes[i];
|
|
4007
|
-
if (node == null || typeof node !== "object" || node.h || typeof node.t !== "string") {
|
|
4238
|
+
if (node == null || typeof node !== "object" || node.$ !== SSR_NODE || node.h || typeof node.t !== "string") {
|
|
4008
4239
|
return undefined;
|
|
4009
4240
|
}
|
|
4010
4241
|
out += node.t;
|
|
@@ -4045,7 +4276,7 @@ function withShellEnd(html, context, renderId, nonce, noScripts) {
|
|
|
4045
4276
|
const at = html.indexOf("</body>", html.length - 512);
|
|
4046
4277
|
return at < 0 ? html + marker : html.slice(0, at) + marker + html.slice(at);
|
|
4047
4278
|
}
|
|
4048
|
-
function assembleDocument(html, emittedAssets, preloadLinks, inlineStyles, scripts, nonce, headTags, onHead) {
|
|
4279
|
+
function assembleDocument(html, emittedAssets, preloadLinks, inlineStyles, scripts, nonce, headTags, onHead, lowModules) {
|
|
4049
4280
|
const scriptTag = scripts ? `<script${nonceAttr(nonce, "script")}>${scripts}</script>` : "";
|
|
4050
4281
|
const title = headTags ? headTags.title : null;
|
|
4051
4282
|
let headTagsHtml = headTags ? headTags.html : "";
|
|
@@ -4069,7 +4300,7 @@ function assembleDocument(html, emittedAssets, preloadLinks, inlineStyles, scrip
|
|
|
4069
4300
|
if (title != null) {
|
|
4070
4301
|
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>`;
|
|
4071
4302
|
}
|
|
4072
|
-
onHead(headPrelude + headTagsHtml + titleHtml + renderHeadAssets(emittedAssets, preloadLinks, inlineStyles, nonce));
|
|
4303
|
+
onHead(headPrelude + headTagsHtml + titleHtml + renderHeadAssets(emittedAssets, preloadLinks, inlineStyles, nonce, lowModules));
|
|
4073
4304
|
}
|
|
4074
4305
|
if (!scriptTag) return html;
|
|
4075
4306
|
const xs = html.indexOf("<!--xs-->");
|
|
@@ -4089,19 +4320,19 @@ function assembleDocument(html, emittedAssets, preloadLinks, inlineStyles, scrip
|
|
|
4089
4320
|
headTagsHtml = `<title data-dh="title">${winner}</title>` + headTagsHtml;
|
|
4090
4321
|
}
|
|
4091
4322
|
}
|
|
4092
|
-
const head = headTagsHtml + renderHeadAssets(emittedAssets, preloadLinks, inlineStyles, nonce);
|
|
4323
|
+
const head = headTagsHtml + renderHeadAssets(emittedAssets, preloadLinks, inlineStyles, nonce, lowModules);
|
|
4093
4324
|
if (!scriptTag) return html.slice(0, headIdx) + head + html.slice(headIdx);
|
|
4094
4325
|
const xsIdx = html.indexOf("<!--xs-->");
|
|
4095
4326
|
if (xsIdx === -1) return html.slice(0, headIdx) + head + html.slice(headIdx) + scriptTag;
|
|
4096
4327
|
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);
|
|
4097
4328
|
}
|
|
4098
|
-
function renderHeadAssets(emittedAssets, preloadLinks, inlineStyles, nonce) {
|
|
4329
|
+
function renderHeadAssets(emittedAssets, preloadLinks, inlineStyles, nonce, lowModules) {
|
|
4099
4330
|
let head = "";
|
|
4100
4331
|
const styleAttr = nonceAttr(nonce, "style");
|
|
4101
4332
|
const scriptAttr = nonceAttr(nonce, "script");
|
|
4102
4333
|
if (emittedAssets && emittedAssets.size) {
|
|
4103
4334
|
for (const url of emittedAssets) {
|
|
4104
|
-
head += isCssUrl(url) ? `<link rel="stylesheet" href="${url}"${styleAttr}>` :
|
|
4335
|
+
head += isCssUrl(url) ? `<link rel="stylesheet" href="${url}"${styleAttr}>` : modulePreloadLink(url, scriptAttr, lowModules);
|
|
4105
4336
|
}
|
|
4106
4337
|
}
|
|
4107
4338
|
if (preloadLinks) {
|
|
@@ -4232,12 +4463,12 @@ function tryResolveString(node, nested) {
|
|
|
4232
4463
|
}
|
|
4233
4464
|
return s;
|
|
4234
4465
|
}
|
|
4466
|
+
if (node.$ !== SSR_NODE) {
|
|
4467
|
+
return "";
|
|
4468
|
+
}
|
|
4235
4469
|
if (node.h && node.h.length > 0) return {
|
|
4236
4470
|
merge: node
|
|
4237
4471
|
};
|
|
4238
|
-
if (node.t === undefined) {
|
|
4239
|
-
return "";
|
|
4240
|
-
}
|
|
4241
4472
|
ssrTextTail = false;
|
|
4242
4473
|
return Array.isArray(node.t) ? node.t[0] : node.t;
|
|
4243
4474
|
}
|
|
@@ -4257,7 +4488,8 @@ function tryResolveString(node, nested) {
|
|
|
4257
4488
|
function resolveSSRNode(node, result = {
|
|
4258
4489
|
t: [""],
|
|
4259
4490
|
h: [],
|
|
4260
|
-
p: []
|
|
4491
|
+
p: [],
|
|
4492
|
+
$: SSR_NODE
|
|
4261
4493
|
}, top, nested) {
|
|
4262
4494
|
if (!nested) ssrTextTail = false;
|
|
4263
4495
|
const t = typeof node;
|
|
@@ -4276,7 +4508,7 @@ function resolveSSRNode(node, result = {
|
|
|
4276
4508
|
if (slotLive) slotLive.suppressed--;
|
|
4277
4509
|
}
|
|
4278
4510
|
} else if (t === "object") {
|
|
4279
|
-
if (node.h) {
|
|
4511
|
+
if (node.$ !== SSR_NODE) ; else if (node.h) {
|
|
4280
4512
|
result.t[result.t.length - 1] += node.t[0];
|
|
4281
4513
|
if (node.t.length > 1) {
|
|
4282
4514
|
result.t.push(...node.t.slice(1));
|
|
@@ -4284,10 +4516,10 @@ function resolveSSRNode(node, result = {
|
|
|
4284
4516
|
result.p.push(...node.p);
|
|
4285
4517
|
}
|
|
4286
4518
|
ssrTextTail = false;
|
|
4287
|
-
} else
|
|
4519
|
+
} else {
|
|
4288
4520
|
result.t[result.t.length - 1] += node.t;
|
|
4289
4521
|
ssrTextTail = false;
|
|
4290
|
-
}
|
|
4522
|
+
}
|
|
4291
4523
|
} else if (t === "function") {
|
|
4292
4524
|
const live = sharedConfig.context && sharedConfig.context.liveHoles;
|
|
4293
4525
|
let liveNode = null;
|
|
@@ -4301,14 +4533,7 @@ function resolveSSRNode(node, result = {
|
|
|
4301
4533
|
try {
|
|
4302
4534
|
resolveSSRNode(node(), result, false, true);
|
|
4303
4535
|
} catch (err) {
|
|
4304
|
-
|
|
4305
|
-
if (wrap) {
|
|
4306
|
-
if (ssrTextTail) result.t[result.t.length - 1] += "<!--!$-->";
|
|
4307
|
-
result.h.push(wrap.fn);
|
|
4308
|
-
result.p.push(wrap.p);
|
|
4309
|
-
result.t.push("");
|
|
4310
|
-
ssrTextTail = true;
|
|
4311
|
-
}
|
|
4536
|
+
pushSSRAsyncHole(result, err, node);
|
|
4312
4537
|
} finally {
|
|
4313
4538
|
if (scope) live.scope = scope;
|
|
4314
4539
|
}
|
|
@@ -4316,6 +4541,16 @@ function resolveSSRNode(node, result = {
|
|
|
4316
4541
|
}
|
|
4317
4542
|
return result;
|
|
4318
4543
|
}
|
|
4544
|
+
function pushSSRAsyncHole(result, err, node) {
|
|
4545
|
+
const wrap = buildAsyncWrap(err, node);
|
|
4546
|
+
if (wrap) {
|
|
4547
|
+
if (ssrTextTail) result.t[result.t.length - 1] += "<!--!$-->";
|
|
4548
|
+
result.h.push(wrap.fn);
|
|
4549
|
+
result.p.push(wrap.p);
|
|
4550
|
+
result.t.push("");
|
|
4551
|
+
ssrTextTail = true;
|
|
4552
|
+
}
|
|
4553
|
+
}
|
|
4319
4554
|
function resolveSSRSync(node) {
|
|
4320
4555
|
const res = resolveSSRNode(node);
|
|
4321
4556
|
if (!res.h.length) return res.t[0];
|
|
@@ -4720,6 +4955,10 @@ function registerElementClaim() {
|
|
|
4720
4955
|
return noopCleanup;
|
|
4721
4956
|
}
|
|
4722
4957
|
function noopCleanup() {}
|
|
4958
|
+
function setTrustedTypesPolicy() {}
|
|
4959
|
+
function trustedHTML(html) {
|
|
4960
|
+
return html;
|
|
4961
|
+
}
|
|
4723
4962
|
function claimElement(node) {
|
|
4724
4963
|
return node;
|
|
4725
4964
|
}
|
|
@@ -4869,4 +5108,4 @@ function httpHeader(name, value, options) {
|
|
|
4869
5108
|
}
|
|
4870
5109
|
}
|
|
4871
5110
|
|
|
4872
|
-
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,
|
|
5111
|
+
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 };
|