@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.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { createRenderEffect, createMemo, getOwner, createRoot, $PROXY,
|
|
1
|
+
import { createRenderEffect, createMemo, getOwner, createRoot, $PROXY, runWithOwner, createOwner, onCleanup, createComponent, omit, getNextChildId } from 'solid-js';
|
|
2
2
|
export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, dynamicComponent, getOwner, merge as mergeProps, untrack } from 'solid-js';
|
|
3
3
|
import { sharedConfig, ssrSanitizeError, beginEdgesRender, reportServerError, viewOf, sourceOwners, ssrHandleError, inServerComponentScope, creationStamp, dynamicCore, getProjectionTrace, shareAsyncIterable } from 'solid-js/internal';
|
|
4
4
|
export { ssrScope as scope } from 'solid-js/internal';
|
|
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 = {
|
|
@@ -271,7 +271,15 @@ function rewriteTree(value, visit, withPath) {
|
|
|
271
271
|
} catch (err) {
|
|
272
272
|
if (err !== CYCLE) throw err;
|
|
273
273
|
}
|
|
274
|
-
|
|
274
|
+
const memo = state.memo || (state.memo = new Map());
|
|
275
|
+
const marks = {
|
|
276
|
+
at: new Map(),
|
|
277
|
+
stack: [],
|
|
278
|
+
changed: new Set(),
|
|
279
|
+
next: 0
|
|
280
|
+
};
|
|
281
|
+
mark(value, visit, path, memo, marks);
|
|
282
|
+
return clone(value, memo, marks.changed);
|
|
275
283
|
}
|
|
276
284
|
function shape(value) {
|
|
277
285
|
return Array.isArray(value) ? 1 : Object.getPrototypeOf(value) === Object.prototype ? 2 : 0;
|
|
@@ -319,28 +327,73 @@ function cow(value, visit, path, depth, state) {
|
|
|
319
327
|
if (ancestors !== undefined) ancestors.delete(value);
|
|
320
328
|
return out;
|
|
321
329
|
}
|
|
322
|
-
function
|
|
323
|
-
|
|
330
|
+
function mark(value, visit, path, memo, m) {
|
|
331
|
+
const seen = m.at.get(value);
|
|
332
|
+
if (seen !== undefined) return seen;
|
|
333
|
+
if (memo.has(value)) return -1;
|
|
324
334
|
const r = visit(value, path);
|
|
325
335
|
if (r !== DESCEND) {
|
|
326
336
|
memo.set(value, r);
|
|
327
|
-
return
|
|
337
|
+
return -1;
|
|
328
338
|
}
|
|
329
339
|
const s = shape(value);
|
|
330
|
-
if (s === 0) return
|
|
331
|
-
const
|
|
340
|
+
if (s === 0) return -1;
|
|
341
|
+
const index = m.next++;
|
|
342
|
+
let low = index;
|
|
343
|
+
let changed = false;
|
|
344
|
+
let open = false;
|
|
345
|
+
const keys = s === 1 ? value : Object.keys(value);
|
|
346
|
+
for (let i = 0; i < keys.length; i++) {
|
|
347
|
+
const k = s === 1 ? i : keys[i];
|
|
348
|
+
const c = value[k];
|
|
349
|
+
if (c === null || typeof c !== "object") continue;
|
|
350
|
+
if (!open) {
|
|
351
|
+
open = true;
|
|
352
|
+
m.at.set(value, index);
|
|
353
|
+
m.stack.push(value);
|
|
354
|
+
}
|
|
355
|
+
const l = mark(c, visit, undefined , memo, m);
|
|
356
|
+
if (l >= 0 && l < low) low = l;
|
|
357
|
+
if (memo.has(c) && memo.get(c) !== c || l === Infinity && m.changed.has(c)) changed = true;
|
|
358
|
+
}
|
|
359
|
+
if (!open) return -1;
|
|
360
|
+
if (low === index) {
|
|
361
|
+
m.at.set(value, Infinity);
|
|
362
|
+
if (m.stack[m.stack.length - 1] === value) {
|
|
363
|
+
m.stack.pop();
|
|
364
|
+
if (changed) m.changed.add(value);
|
|
365
|
+
return Infinity;
|
|
366
|
+
}
|
|
367
|
+
const members = m.stack.splice(m.stack.lastIndexOf(value));
|
|
368
|
+
if (!changed) for (const n of members) if (m.changed.has(n)) {
|
|
369
|
+
changed = true;
|
|
370
|
+
break;
|
|
371
|
+
}
|
|
372
|
+
for (const n of members) {
|
|
373
|
+
m.at.set(n, Infinity);
|
|
374
|
+
if (changed) m.changed.add(n);
|
|
375
|
+
}
|
|
376
|
+
return Infinity;
|
|
377
|
+
}
|
|
378
|
+
if (changed) m.changed.add(value);
|
|
379
|
+
return low;
|
|
380
|
+
}
|
|
381
|
+
function clone(value, memo, changed) {
|
|
382
|
+
if (memo.has(value)) return memo.get(value);
|
|
383
|
+
if (!changed.has(value)) return value;
|
|
384
|
+
const out = Array.isArray(value) ? value.slice() : {
|
|
332
385
|
...value
|
|
333
386
|
};
|
|
334
387
|
memo.set(value, out);
|
|
335
|
-
if (
|
|
388
|
+
if (Array.isArray(value)) {
|
|
336
389
|
for (let i = 0; i < value.length; i++) {
|
|
337
390
|
const c = value[i];
|
|
338
|
-
if (c !== null && typeof c === "object") out[i] = clone(c,
|
|
391
|
+
if (c !== null && typeof c === "object") out[i] = clone(c, memo, changed);
|
|
339
392
|
}
|
|
340
393
|
} else {
|
|
341
394
|
for (const k of Object.keys(value)) {
|
|
342
395
|
const c = value[k];
|
|
343
|
-
if (c !== null && typeof c === "object") out[k] = clone(c,
|
|
396
|
+
if (c !== null && typeof c === "object") out[k] = clone(c, memo, changed);
|
|
344
397
|
}
|
|
345
398
|
}
|
|
346
399
|
return out;
|
|
@@ -467,7 +520,6 @@ function createKeyedSerializer(serialize, onError, onDone) {
|
|
|
467
520
|
pendingWrites++;
|
|
468
521
|
let settled = false;
|
|
469
522
|
let failed = false;
|
|
470
|
-
let started = false;
|
|
471
523
|
let cancel = null;
|
|
472
524
|
const settle = () => {
|
|
473
525
|
if (settled) return;
|
|
@@ -481,17 +533,14 @@ function createKeyedSerializer(serialize, onError, onDone) {
|
|
|
481
533
|
stream = serialize(key, value, {
|
|
482
534
|
onError: onError && (err => {
|
|
483
535
|
failed = true;
|
|
484
|
-
onError(err);
|
|
536
|
+
onError(err, key);
|
|
485
537
|
if (cancel) {
|
|
486
538
|
cancel();
|
|
487
539
|
settle();
|
|
488
540
|
}
|
|
489
541
|
}),
|
|
490
542
|
onDone: settle
|
|
491
|
-
},
|
|
492
|
-
if (initial) started = true;
|
|
493
|
-
return !closed;
|
|
494
|
-
});
|
|
543
|
+
}, () => !closed);
|
|
495
544
|
} catch (err) {
|
|
496
545
|
settle();
|
|
497
546
|
throw err;
|
|
@@ -538,22 +587,67 @@ function createHydrationSerializer({
|
|
|
538
587
|
onDone,
|
|
539
588
|
scopeId,
|
|
540
589
|
onError,
|
|
541
|
-
plugins
|
|
590
|
+
plugins,
|
|
591
|
+
late
|
|
542
592
|
}) {
|
|
543
593
|
const resolvedPlugins = resolveSerializerPlugins(plugins);
|
|
544
594
|
const disabledFeatures = defaultDisabledFeatures() | serializeOnlyDisabledFeatures();
|
|
545
595
|
const refs = new Map();
|
|
546
|
-
|
|
596
|
+
const serialize = (key, value, callbacks, live) => crossSerializeStream(value, {
|
|
547
597
|
scopeId,
|
|
548
598
|
refs,
|
|
549
599
|
plugins: resolvedPlugins,
|
|
550
600
|
disabledFeatures,
|
|
551
601
|
onSerialize(data, initial) {
|
|
552
|
-
if (!live(
|
|
602
|
+
if (!live()) return;
|
|
553
603
|
onData(initial ? HYDRATION_GLOBAL + '["' + serializeKey(key) + '"]=' + data : data);
|
|
554
604
|
},
|
|
555
605
|
...callbacks
|
|
556
|
-
})
|
|
606
|
+
});
|
|
607
|
+
return createKeyedSerializer(late ? late(serialize, refs, onData, scopeId) : serialize, onError, onDone);
|
|
608
|
+
}
|
|
609
|
+
function rejectUnserializedKey(serialize, refs, onData, scopeId, plain) {
|
|
610
|
+
let taken = 0;
|
|
611
|
+
let fresh = [];
|
|
612
|
+
const set = refs.set;
|
|
613
|
+
refs.set = (value, id) => {
|
|
614
|
+
taken++;
|
|
615
|
+
fresh.push(value);
|
|
616
|
+
return set.call(refs, value, id);
|
|
617
|
+
};
|
|
618
|
+
Object.defineProperty(refs, "size", {
|
|
619
|
+
get: () => taken
|
|
620
|
+
});
|
|
621
|
+
return (key, value, callbacks, live) => {
|
|
622
|
+
const sent = [];
|
|
623
|
+
const failed = () => {
|
|
624
|
+
for (const ref of fresh) refs.delete(ref);
|
|
625
|
+
fresh = [];
|
|
626
|
+
const ids = new Set();
|
|
627
|
+
for (const ref of sent) {
|
|
628
|
+
const id = refs.get(ref);
|
|
629
|
+
if (ref instanceof Promise) ids.add(id + 1);else if (isStream(ref) || Object.getPrototypeOf(ref) === Object.prototype && !Object.keys(ref).length) ids.add(id);
|
|
630
|
+
}
|
|
631
|
+
if (!ids.size) return;
|
|
632
|
+
const text = plain && plain(key);
|
|
633
|
+
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))}";
|
|
634
|
+
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]);
|
|
635
|
+
onData("($R=>{const e=new Error(" + message + ");" + body + "})(" + (scopeId == null ? "$R" : '$R["' + serializeKey(scopeId) + '"]') + ")");
|
|
636
|
+
};
|
|
637
|
+
return serialize(key, value, {
|
|
638
|
+
...callbacks,
|
|
639
|
+
onError: callbacks.onError && (err => {
|
|
640
|
+
if (live()) failed();
|
|
641
|
+
callbacks.onError(err);
|
|
642
|
+
})
|
|
643
|
+
},
|
|
644
|
+
() => {
|
|
645
|
+
if (!live()) return false;
|
|
646
|
+
sent.push(...fresh);
|
|
647
|
+
fresh = [];
|
|
648
|
+
return true;
|
|
649
|
+
});
|
|
650
|
+
};
|
|
557
651
|
}
|
|
558
652
|
function getLocalHeaderScript(id) {
|
|
559
653
|
return getCrossReferenceHeader(id) + ";";
|
|
@@ -872,7 +966,7 @@ function resolveAssets(moduleUrl, manifest) {
|
|
|
872
966
|
if (!manifest) return null;
|
|
873
967
|
const base = manifest._base;
|
|
874
968
|
const entry = manifest[moduleUrl];
|
|
875
|
-
if (!entry) return null;
|
|
969
|
+
if (!entry || typeof entry !== "object") return null;
|
|
876
970
|
const css = [];
|
|
877
971
|
const js = [];
|
|
878
972
|
let preloads;
|
|
@@ -881,7 +975,7 @@ function resolveAssets(moduleUrl, manifest) {
|
|
|
881
975
|
if (visited.has(key)) return;
|
|
882
976
|
visited.add(key);
|
|
883
977
|
const e = manifest[key];
|
|
884
|
-
if (!e) return;
|
|
978
|
+
if (!e || typeof e !== "object") return;
|
|
885
979
|
js.push(joinAssetPath(base, e.file));
|
|
886
980
|
if (e.css) for (let i = 0; i < e.css.length; i++) css.push(joinAssetPath(base, e.css[i]));
|
|
887
981
|
if (e.preloads) {
|
|
@@ -918,18 +1012,19 @@ function registerEntryAssets(manifest) {
|
|
|
918
1012
|
const ctx = sharedConfig.context;
|
|
919
1013
|
if (!ctx?.registerAsset) return;
|
|
920
1014
|
for (const key in manifest) {
|
|
921
|
-
|
|
1015
|
+
const entry = manifest[key];
|
|
1016
|
+
if (entry && entry.isEntry) {
|
|
922
1017
|
const assets = resolveAssets(key, manifest);
|
|
923
1018
|
if (assets) {
|
|
924
1019
|
if (assets.preloads) for (let i = 0; i < assets.preloads.length; i++) ctx.registerAsset("preload", assets.preloads[i]);
|
|
925
1020
|
for (let i = 0; i < assets.css.length; i++) ctx.registerAsset("style", assets.css[i]);
|
|
926
|
-
for (let i = 1; i < assets.js.length; i++) ctx.registerAsset("module", assets.js[i]);
|
|
1021
|
+
for (let i = 1; i < assets.js.length; i++) ctx.registerAsset("module", assets.js[i], true);
|
|
927
1022
|
}
|
|
928
1023
|
return;
|
|
929
1024
|
}
|
|
930
1025
|
}
|
|
931
1026
|
}
|
|
932
|
-
function createAssetTracking() {
|
|
1027
|
+
function createAssetTracking(lowPriorityPreloads) {
|
|
933
1028
|
const boundaryModules = new Map();
|
|
934
1029
|
const boundaryStyles = new Map();
|
|
935
1030
|
const emittedAssets = new Set();
|
|
@@ -941,6 +1036,7 @@ function createAssetTracking() {
|
|
|
941
1036
|
emittedAssets,
|
|
942
1037
|
inlineStyles,
|
|
943
1038
|
preloadLinks: null,
|
|
1039
|
+
lowModules: lowPriorityPreloads !== false ? new Set() : null,
|
|
944
1040
|
registerInlineStyle(desc) {
|
|
945
1041
|
let entry = inlineStyles.get(desc.id);
|
|
946
1042
|
if (!entry) {
|
|
@@ -1038,6 +1134,7 @@ function isSetAttr(value) {
|
|
|
1038
1134
|
return value != null && value !== false && value !== "";
|
|
1039
1135
|
}
|
|
1040
1136
|
const PRELOAD_LINK_ATTRIBUTES = ["type", "crossorigin", "integrity", "referrerpolicy", "fetchpriority", "media", "imagesrcset", "imagesizes"];
|
|
1137
|
+
const SSR_NODE = /*#__PURE__*/Symbol.for("solid.ssrNode");
|
|
1041
1138
|
function registerPreloadLink(tracking, headRegistry, link, nonce) {
|
|
1042
1139
|
if (!link || typeof link !== "object") {
|
|
1043
1140
|
return null;
|
|
@@ -1245,7 +1342,7 @@ function emitHeadResource(registry, context, tracking, emitResource, nonce, desc
|
|
|
1245
1342
|
if (plain && props.href != null) {
|
|
1246
1343
|
const isCss = isCssUrl(props.href);
|
|
1247
1344
|
if (rel === "stylesheet" ? isCss : !isCss) {
|
|
1248
|
-
context.registerAsset(rel === "stylesheet" ? "style" : "module", props.href);
|
|
1345
|
+
context.registerAsset(rel === "stylesheet" ? "style" : "module", props.href, true);
|
|
1249
1346
|
return;
|
|
1250
1347
|
}
|
|
1251
1348
|
}
|
|
@@ -1489,6 +1586,10 @@ function nonceDestination(tag, props) {
|
|
|
1489
1586
|
return "script";
|
|
1490
1587
|
}
|
|
1491
1588
|
}
|
|
1589
|
+
function modulePreloadLink(url, scriptAttr, lowModules) {
|
|
1590
|
+
const priority = lowModules && !lowModules.has(url) ? ' fetchpriority="low"' : "";
|
|
1591
|
+
return `<link rel="modulepreload" href="${url}"${priority}${scriptAttr}>`;
|
|
1592
|
+
}
|
|
1492
1593
|
function nonceAttr(nonce, destination) {
|
|
1493
1594
|
if (!nonce || !destination) return "";
|
|
1494
1595
|
return destination === "script" ? nonce.scriptAttr : nonce.styleAttr;
|
|
@@ -1564,7 +1665,8 @@ function tagInfo(tag) {
|
|
|
1564
1665
|
textarea: tag === "textarea",
|
|
1565
1666
|
raw: tag === "script" || tag === "style",
|
|
1566
1667
|
formDefaults,
|
|
1567
|
-
formAttributes
|
|
1668
|
+
formAttributes,
|
|
1669
|
+
sel: tag === "select" ? 1 : tag === "option" ? 2 : 0
|
|
1568
1670
|
};
|
|
1569
1671
|
if (tagInfos.size < 512) tagInfos.set(tag, info);
|
|
1570
1672
|
}
|
|
@@ -1602,7 +1704,7 @@ function renderToString(code, options = {}) {
|
|
|
1602
1704
|
},
|
|
1603
1705
|
onError: serializerErrorHook(options.onError)
|
|
1604
1706
|
});
|
|
1605
|
-
const tracking = createAssetTracking();
|
|
1707
|
+
const tracking = createAssetTracking(options.lowPriorityPreloads);
|
|
1606
1708
|
const headRegistry = createHeadRegistry();
|
|
1607
1709
|
let closed = false;
|
|
1608
1710
|
sharedConfig.context = {
|
|
@@ -1622,7 +1724,7 @@ function renderToString(code, options = {}) {
|
|
|
1622
1724
|
}
|
|
1623
1725
|
serializer.write(id, p);
|
|
1624
1726
|
},
|
|
1625
|
-
registerAsset(type, value) {
|
|
1727
|
+
registerAsset(type, value, defaultPriority) {
|
|
1626
1728
|
if (type === "preload") {
|
|
1627
1729
|
registerPreloadLink(tracking, headRegistry, value, nonce);
|
|
1628
1730
|
return;
|
|
@@ -1639,6 +1741,7 @@ function renderToString(code, options = {}) {
|
|
|
1639
1741
|
}
|
|
1640
1742
|
styles.add(value);
|
|
1641
1743
|
}
|
|
1744
|
+
if (defaultPriority && tracking.lowModules) tracking.lowModules.add(value);
|
|
1642
1745
|
tracking.emittedAssets.add(value);
|
|
1643
1746
|
}
|
|
1644
1747
|
};
|
|
@@ -1665,7 +1768,7 @@ function renderToString(code, options = {}) {
|
|
|
1665
1768
|
closed = true;
|
|
1666
1769
|
serializer.close();
|
|
1667
1770
|
const head = renderShellHead(headRegistry, nonce, null, noScripts, traceMetaMarkup(context.trace));
|
|
1668
|
-
const document = withShellEnd(assembleDocument(
|
|
1771
|
+
const document = withShellEnd(assembleDocument(html, tracking.emittedAssets, tracking.preloadLinks, tracking.inlineStyles, scripts.length ? scripts : "", nonce, head, onHead, tracking.lowModules), context, renderId, nonce, noScripts);
|
|
1669
1772
|
if (render) render.shell();
|
|
1670
1773
|
if (requestEvent && requestEvent.response) {
|
|
1671
1774
|
commitResponseStub(requestEvent.response, {
|
|
@@ -1714,9 +1817,7 @@ function renderToStream(code, options = {}) {
|
|
|
1714
1817
|
let rootOwner;
|
|
1715
1818
|
let serializer;
|
|
1716
1819
|
let disconnected = false;
|
|
1717
|
-
let failed = false;
|
|
1718
1820
|
let onFailed;
|
|
1719
|
-
let onDisconnectedBeforeShell;
|
|
1720
1821
|
const defuse = p => {
|
|
1721
1822
|
if (p && typeof p.then === "function") p.then(undefined, () => {});
|
|
1722
1823
|
};
|
|
@@ -1728,22 +1829,23 @@ function renderToStream(code, options = {}) {
|
|
|
1728
1829
|
close() {}
|
|
1729
1830
|
};
|
|
1730
1831
|
const onFailure = complete => {
|
|
1731
|
-
if (
|
|
1832
|
+
if (dead) return complete(undefined, disconnected || undefined);
|
|
1732
1833
|
const prev = onFailed;
|
|
1733
|
-
onFailed = prev ? sink => {
|
|
1734
|
-
prev(sink);
|
|
1735
|
-
complete(sink);
|
|
1834
|
+
onFailed = prev ? (sink, gone) => {
|
|
1835
|
+
prev(sink, gone);
|
|
1836
|
+
complete(sink, gone);
|
|
1736
1837
|
} : complete;
|
|
1737
1838
|
};
|
|
1738
1839
|
const abandon = (disconnect, quiet) => {
|
|
1739
1840
|
if (dead) return;
|
|
1740
1841
|
dead = true;
|
|
1741
1842
|
completed = true;
|
|
1742
|
-
if (disconnect) disconnected =
|
|
1843
|
+
if (disconnect) disconnected = disconnect;
|
|
1743
1844
|
if (render) settleRender(render, rootOwner, disconnect ? "abandoned" : "error");
|
|
1744
1845
|
const sink = writable;
|
|
1745
1846
|
buffer = {
|
|
1746
|
-
write() {}
|
|
1847
|
+
write() {},
|
|
1848
|
+
flush() {}
|
|
1747
1849
|
};
|
|
1748
1850
|
writable = {
|
|
1749
1851
|
end() {}
|
|
@@ -1768,10 +1870,7 @@ function renderToStream(code, options = {}) {
|
|
|
1768
1870
|
for (const p of stubBatch.values()) defuse(p);
|
|
1769
1871
|
stubBatch = null;
|
|
1770
1872
|
}
|
|
1771
|
-
|
|
1772
|
-
failed = true;
|
|
1773
|
-
onFailed && onFailed(sink);
|
|
1774
|
-
} else if (!sink && onDisconnectedBeforeShell) onDisconnectedBeforeShell();
|
|
1873
|
+
onFailed && onFailed(sink, disconnect);
|
|
1775
1874
|
};
|
|
1776
1875
|
const failRender = err => {
|
|
1777
1876
|
reportFailure(err, "failed");
|
|
@@ -1830,21 +1929,71 @@ function renderToStream(code, options = {}) {
|
|
|
1830
1929
|
let stableOrder = false;
|
|
1831
1930
|
let parkedWrites = null;
|
|
1832
1931
|
const byKey = (a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0;
|
|
1833
|
-
|
|
1834
|
-
|
|
1932
|
+
let stranded = false;
|
|
1933
|
+
let writingRecord = false;
|
|
1934
|
+
let recordFailed = false;
|
|
1935
|
+
const plainRecords = new WeakMap();
|
|
1936
|
+
const caught = new Set();
|
|
1937
|
+
let unclaimed = null;
|
|
1938
|
+
const rejected = new Map();
|
|
1939
|
+
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`;
|
|
1940
|
+
const plainFor = (id, value) => {
|
|
1941
|
+
const keyed = value !== null && typeof value === "object";
|
|
1942
|
+
let plain = keyed && plainRecords.get(value);
|
|
1943
|
+
if (!plain) {
|
|
1944
|
+
plain = new Error(plainMessage(id, value));
|
|
1945
|
+
if (keyed) plainRecords.set(value, plain);
|
|
1946
|
+
}
|
|
1947
|
+
return plain;
|
|
1948
|
+
};
|
|
1949
|
+
const claim = () => {
|
|
1950
|
+
if (unclaimed) {
|
|
1951
|
+
for (const reason of unclaimed) if (!caught.has(reason)) stranded = true;
|
|
1952
|
+
unclaimed = null;
|
|
1953
|
+
}
|
|
1954
|
+
return stranded;
|
|
1955
|
+
};
|
|
1956
|
+
const claimLater = reason => {
|
|
1957
|
+
if (firstFlushed || stranded || caught.has(reason)) return;
|
|
1958
|
+
if (!unclaimed) {
|
|
1959
|
+
unclaimed = new Set();
|
|
1960
|
+
deferFlush(() => {
|
|
1961
|
+
if (!rootHoles && claim()) abandon();
|
|
1962
|
+
});
|
|
1963
|
+
}
|
|
1964
|
+
unclaimed.add(reason);
|
|
1965
|
+
};
|
|
1966
|
+
const handOver = (id, value, error) => {
|
|
1967
|
+
if (!error || options.serializer) return serializer.write(id, value);
|
|
1968
|
+
let plain = value !== null && typeof value === "object" && plainRecords.get(value);
|
|
1969
|
+
if (!plain) {
|
|
1970
|
+
recordFailed = false;
|
|
1971
|
+
writingRecord = true;
|
|
1972
|
+
try {
|
|
1973
|
+
serializer.write(id, value);
|
|
1974
|
+
} finally {
|
|
1975
|
+
writingRecord = false;
|
|
1976
|
+
}
|
|
1977
|
+
if (!recordFailed) return;
|
|
1978
|
+
plain = plainFor(id, value);
|
|
1979
|
+
}
|
|
1980
|
+
serializer.write(id, plain);
|
|
1981
|
+
};
|
|
1982
|
+
const write = (id, value, error) => {
|
|
1983
|
+
if (stableOrder && !dead) (parkedWrites ||= []).push([id, value, error]);else handOver(id, value, error);
|
|
1835
1984
|
};
|
|
1836
1985
|
const flushParkedWrites = () => {
|
|
1837
1986
|
if (!parkedWrites) return;
|
|
1838
1987
|
const writes = parkedWrites.sort(byKey);
|
|
1839
1988
|
parkedWrites = null;
|
|
1840
|
-
for (let i = 0; i < writes.length; i++)
|
|
1989
|
+
for (let i = 0; i < writes.length; i++) handOver(writes[i][0], writes[i][1], writes[i][2]);
|
|
1841
1990
|
};
|
|
1842
1991
|
const flushStubBatch = () => {
|
|
1843
1992
|
if (!stubBatch) return;
|
|
1844
1993
|
const entries = [...stubBatch];
|
|
1845
1994
|
stubBatch = null;
|
|
1846
1995
|
if (stableOrder) entries.sort(byKey);
|
|
1847
|
-
for (let i = 0; i < entries.length; i++)
|
|
1996
|
+
for (let i = 0; i < entries.length; i++) handOver(entries[i][0], entries[i][1]);
|
|
1848
1997
|
};
|
|
1849
1998
|
let headerEmitted = false;
|
|
1850
1999
|
const pushTask = task => {
|
|
@@ -1862,6 +2011,7 @@ function renderToStream(code, options = {}) {
|
|
|
1862
2011
|
const onDone = () => {
|
|
1863
2012
|
if (dead) return;
|
|
1864
2013
|
writeTasks();
|
|
2014
|
+
if (claim()) return abandon();
|
|
1865
2015
|
lastBlockingSize = blockingPromises.size;
|
|
1866
2016
|
doShell();
|
|
1867
2017
|
onCompleteAll && onCompleteAll({
|
|
@@ -1905,7 +2055,7 @@ function renderToStream(code, options = {}) {
|
|
|
1905
2055
|
},
|
|
1906
2056
|
asset(type, value) {
|
|
1907
2057
|
if (type === "module") {
|
|
1908
|
-
buffer.write(
|
|
2058
|
+
buffer.write(modulePreloadLink(value, nonceAttr(nonce, "script"), tracking.lowModules));
|
|
1909
2059
|
} else if (type === "preload") {
|
|
1910
2060
|
buffer.write(`<link${value.attrHtml}>`);
|
|
1911
2061
|
} else if (type === "inline-style") {
|
|
@@ -1915,7 +2065,7 @@ function renderToStream(code, options = {}) {
|
|
|
1915
2065
|
}
|
|
1916
2066
|
},
|
|
1917
2067
|
shell(shellHtml, meta) {
|
|
1918
|
-
buffer.write(withShellEnd(assembleDocument(shellHtml, meta.preloads, meta.preloadLinks, meta.inlineStyles, meta.tasks.length ? meta.tasks : "", nonce, meta.head, onHead), context, renderId, nonce, noScripts));
|
|
2068
|
+
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));
|
|
1919
2069
|
},
|
|
1920
2070
|
...options.sink
|
|
1921
2071
|
};
|
|
@@ -1924,7 +2074,19 @@ function renderToStream(code, options = {}) {
|
|
|
1924
2074
|
plugins: options.plugins,
|
|
1925
2075
|
onData: payload => sink.data(payload),
|
|
1926
2076
|
onDone,
|
|
1927
|
-
onError:
|
|
2077
|
+
onError: (err, key) => {
|
|
2078
|
+
const rejection = !options.serializer && !writingRecord && rejected.has(key);
|
|
2079
|
+
const reason = rejection && rejected.get(key);
|
|
2080
|
+
if (!rejection || reason === null || typeof reason !== "object" || !plainRecords.has(reason)) reportFailure(err, "serialize");
|
|
2081
|
+
if (writingRecord) recordFailed = true;else if (rejection) {
|
|
2082
|
+
plainFor(key, reason);
|
|
2083
|
+
claimLater(reason);
|
|
2084
|
+
} else if (!options.serializer && !firstFlushed && !stranded) {
|
|
2085
|
+
stranded = true;
|
|
2086
|
+
deferFlush(() => abandon());
|
|
2087
|
+
}
|
|
2088
|
+
},
|
|
2089
|
+
late: (serialize, refs, onData, scopeId) => rejectUnserializedKey(serialize, refs, onData, scopeId, key => !firstFlushed && rejected.has(key) ? plainMessage(key, rejected.get(key)) : undefined)
|
|
1928
2090
|
});
|
|
1929
2091
|
let rootAssetsSerialized = false;
|
|
1930
2092
|
const serializeRootAssets = () => {
|
|
@@ -2003,7 +2165,10 @@ function renderToStream(code, options = {}) {
|
|
|
2003
2165
|
raced.catch(() => {});
|
|
2004
2166
|
pendingSerialized.set(id, settle);
|
|
2005
2167
|
const drop = () => pendingSerialized.delete(id);
|
|
2006
|
-
p.then(drop,
|
|
2168
|
+
p.then(drop, reason => {
|
|
2169
|
+
drop();
|
|
2170
|
+
rejected.set(id, reason);
|
|
2171
|
+
});
|
|
2007
2172
|
return raced;
|
|
2008
2173
|
};
|
|
2009
2174
|
const abandonSubtree = (key, error) => {
|
|
@@ -2076,7 +2241,7 @@ function renderToStream(code, options = {}) {
|
|
|
2076
2241
|
tmp += payload;
|
|
2077
2242
|
}
|
|
2078
2243
|
};
|
|
2079
|
-
const tracking = createAssetTracking();
|
|
2244
|
+
const tracking = createAssetTracking(options.lowPriorityPreloads);
|
|
2080
2245
|
const headRegistry = createHeadRegistry();
|
|
2081
2246
|
let headScriptFlushed = false;
|
|
2082
2247
|
const emitHeadOps = (key, ops) => {
|
|
@@ -2101,7 +2266,7 @@ function renderToStream(code, options = {}) {
|
|
|
2101
2266
|
}
|
|
2102
2267
|
}, nonce, tags);
|
|
2103
2268
|
},
|
|
2104
|
-
registerAsset(type, value) {
|
|
2269
|
+
registerAsset(type, value, defaultPriority) {
|
|
2105
2270
|
if (type === "preload") {
|
|
2106
2271
|
const entry = registerPreloadLink(tracking, headRegistry, value, nonce);
|
|
2107
2272
|
if (entry && firstFlushed) sink.asset("preload", entry);
|
|
@@ -2123,6 +2288,7 @@ function renderToStream(code, options = {}) {
|
|
|
2123
2288
|
}
|
|
2124
2289
|
styles.add(value);
|
|
2125
2290
|
}
|
|
2291
|
+
if (defaultPriority && tracking.lowModules) tracking.lowModules.add(value);
|
|
2126
2292
|
if (!tracking.emittedAssets.has(value)) {
|
|
2127
2293
|
tracking.emittedAssets.add(value);
|
|
2128
2294
|
if (firstFlushed) sink.asset(type, value);
|
|
@@ -2149,12 +2315,17 @@ function renderToStream(code, options = {}) {
|
|
|
2149
2315
|
const last = html.indexOf(`<!--!$/${id}-->`, first + placeholder.length);
|
|
2150
2316
|
html = html.slice(0, first) + resolveSSRSync(escape(payloadFn())) + html.slice(last + placeholder.length + 1);
|
|
2151
2317
|
},
|
|
2152
|
-
serialize(id, p, deferStream) {
|
|
2318
|
+
serialize(id, p, deferStream, errorRecord) {
|
|
2153
2319
|
p = guardChannel(p);
|
|
2154
2320
|
if (p && typeof p === "object" && typeof p.then === "function") {
|
|
2155
2321
|
if (!firstFlushed && deferStream) {
|
|
2156
2322
|
blockingPromises.add(p);
|
|
2157
|
-
p.then(d => write(id, d)).catch(e =>
|
|
2323
|
+
p.then(d => write(id, d)).catch(e => {
|
|
2324
|
+
rejected.set(id, e);
|
|
2325
|
+
const r = Promise.reject(e);
|
|
2326
|
+
r.catch(() => {});
|
|
2327
|
+
write(id, r);
|
|
2328
|
+
});
|
|
2158
2329
|
return;
|
|
2159
2330
|
}
|
|
2160
2331
|
p = trackSerialized(id, p);
|
|
@@ -2163,7 +2334,7 @@ function renderToStream(code, options = {}) {
|
|
|
2163
2334
|
return;
|
|
2164
2335
|
}
|
|
2165
2336
|
}
|
|
2166
|
-
write(id, p);
|
|
2337
|
+
write(id, p, errorRecord);
|
|
2167
2338
|
},
|
|
2168
2339
|
escape: escape,
|
|
2169
2340
|
resolve: resolveSSRNode,
|
|
@@ -2237,7 +2408,7 @@ function renderToStream(code, options = {}) {
|
|
|
2237
2408
|
const styles = collectStreamStyles(key, tracking, headStyles);
|
|
2238
2409
|
const headOps = error ? null : flushHeadFragment(headRegistry, key, nonce);
|
|
2239
2410
|
if (headOps) emitHeadOps(key, headOps);
|
|
2240
|
-
sink.fragment(key,
|
|
2411
|
+
sink.fragment(key, value !== undefined ? value : error ? "" : " ", {
|
|
2241
2412
|
styles,
|
|
2242
2413
|
revealGroup,
|
|
2243
2414
|
error: error ? ssrSanitizeError(error, null, undefined, undefined, errorScope) : error
|
|
@@ -2268,13 +2439,22 @@ function renderToStream(code, options = {}) {
|
|
|
2268
2439
|
context.failRender = failRender;
|
|
2269
2440
|
context.errorPolicy = options.onError;
|
|
2270
2441
|
context._errorScope = errorScope;
|
|
2442
|
+
context.contained = (error, wire) => {
|
|
2443
|
+
caught.add(error);
|
|
2444
|
+
caught.add(wire);
|
|
2445
|
+
};
|
|
2271
2446
|
context.flushed = () => firstFlushed;
|
|
2272
2447
|
context.trace = requestEvent ? traceForEvent(requestEvent) : traceFor(context, undefined);
|
|
2273
2448
|
render = timeDocument(context, context.trace);
|
|
2274
2449
|
registerEntryAssets(manifest);
|
|
2275
2450
|
context.writer = createHydrationWriter(context, () => !completed);
|
|
2276
2451
|
const signal = options.signal;
|
|
2277
|
-
|
|
2452
|
+
let cancelled = false;
|
|
2453
|
+
const onAbort = signal ? () => {
|
|
2454
|
+
if (dead) return;
|
|
2455
|
+
cancelled = true;
|
|
2456
|
+
abandon("signal", !!(signal.reason && signal.reason.quiet === true));
|
|
2457
|
+
} : undefined;
|
|
2278
2458
|
const endEdges = context.edges ? beginEdgesRender() : undefined;
|
|
2279
2459
|
let html;
|
|
2280
2460
|
try {
|
|
@@ -2380,7 +2560,7 @@ function renderToStream(code, options = {}) {
|
|
|
2380
2560
|
flushStubBatch();
|
|
2381
2561
|
const head = renderShellHead(headRegistry, nonce, k => registry.has(k), noScripts, traceMetaMarkup(context.trace));
|
|
2382
2562
|
if (render) render.shell();
|
|
2383
|
-
sink.shell(
|
|
2563
|
+
sink.shell(html, {
|
|
2384
2564
|
preloads: tracking.emittedAssets,
|
|
2385
2565
|
preloadLinks: tracking.preloadLinks,
|
|
2386
2566
|
inlineStyles: tracking.inlineStyles,
|
|
@@ -2436,9 +2616,12 @@ function renderToStream(code, options = {}) {
|
|
|
2436
2616
|
const pipeToImpl = w => {
|
|
2437
2617
|
let resolve;
|
|
2438
2618
|
const p = new Promise(r => resolve = r);
|
|
2439
|
-
|
|
2619
|
+
let closeOnAbort = () => w.close().catch(() => {});
|
|
2620
|
+
onFailure((sink, gone) => {
|
|
2440
2621
|
try {
|
|
2441
|
-
if (
|
|
2622
|
+
if (!gone) {
|
|
2623
|
+
if (sink) sink.end();else w.close().catch(() => {});
|
|
2624
|
+
} else if (gone === "signal") closeOnAbort();
|
|
2442
2625
|
} catch (_) {}
|
|
2443
2626
|
resolve();
|
|
2444
2627
|
});
|
|
@@ -2453,6 +2636,7 @@ function renderToStream(code, options = {}) {
|
|
|
2453
2636
|
return;
|
|
2454
2637
|
}
|
|
2455
2638
|
if (!shellCompleted) return flush();
|
|
2639
|
+
if (claim()) return abandon();
|
|
2456
2640
|
const encoder = new TextEncoder();
|
|
2457
2641
|
const writer = w.getWriter();
|
|
2458
2642
|
let pendingWrites = Promise.resolve();
|
|
@@ -2464,6 +2648,10 @@ function renderToStream(code, options = {}) {
|
|
|
2464
2648
|
}
|
|
2465
2649
|
};
|
|
2466
2650
|
writer.closed && writer.closed.catch(failed);
|
|
2651
|
+
closeOnAbort = () => {
|
|
2652
|
+
ended = true;
|
|
2653
|
+
pendingWrites.then(() => writer.close()).catch(() => {});
|
|
2654
|
+
};
|
|
2467
2655
|
buffer = writable = coalesceWrites(payload => {
|
|
2468
2656
|
pendingWrites = pendingWrites.then(() => writer.write(encoder.encode(payload))).catch(failed);
|
|
2469
2657
|
}, () => {
|
|
@@ -2495,7 +2683,7 @@ function renderToStream(code, options = {}) {
|
|
|
2495
2683
|
event: requestEvent
|
|
2496
2684
|
});
|
|
2497
2685
|
};
|
|
2498
|
-
const p = new Promise(resolve => {
|
|
2686
|
+
const p = new Promise((resolve, reject) => {
|
|
2499
2687
|
function complete() {
|
|
2500
2688
|
freezeHead();
|
|
2501
2689
|
dispose();
|
|
@@ -2508,11 +2696,12 @@ function renderToStream(code, options = {}) {
|
|
|
2508
2696
|
complete();
|
|
2509
2697
|
};
|
|
2510
2698
|
} else onCompleteAll = complete;
|
|
2511
|
-
onFailure(() => resolve(tmp));
|
|
2699
|
+
onFailure(() => cancelled ? reject(signal.reason) : resolve(tmp));
|
|
2512
2700
|
function flush() {
|
|
2513
2701
|
allSettled(blockingPromises).then(awaited => {
|
|
2514
2702
|
scheduleFlush(() => {
|
|
2515
2703
|
if (dead) return;
|
|
2704
|
+
sharedConfig.context = context;
|
|
2516
2705
|
try {
|
|
2517
2706
|
if (blockingPromises.size !== lastBlockingSize || !resolveRootHoles() || blockingPromises.size !== lastBlockingSize || !headShellReady(headRegistry, p => blockingPromises.add(p))) return flush();
|
|
2518
2707
|
} catch (err) {
|
|
@@ -2530,15 +2719,12 @@ function renderToStream(code, options = {}) {
|
|
|
2530
2719
|
pipe(w) {
|
|
2531
2720
|
claimConsumer("pipe");
|
|
2532
2721
|
const abandoned = w[SHELL_ABANDONED];
|
|
2533
|
-
onFailure(sink => {
|
|
2722
|
+
onFailure((sink, gone) => {
|
|
2534
2723
|
try {
|
|
2535
|
-
sink ? sink.end() : abandoned ? abandoned() : w.end();
|
|
2724
|
+
if (!gone) sink ? sink.end() : abandoned ? abandoned() : w.end();else if (!sink && abandoned) abandoned();else if (gone === "signal") w.end();
|
|
2536
2725
|
} catch (_) {}
|
|
2537
2726
|
});
|
|
2538
|
-
if (abandoned)
|
|
2539
|
-
w[ABANDON_RENDER] = abandon;
|
|
2540
|
-
if (disconnected) abandoned();else onDisconnectedBeforeShell = abandoned;
|
|
2541
|
-
}
|
|
2727
|
+
if (abandoned) w[ABANDON_RENDER] = abandon;
|
|
2542
2728
|
function flush() {
|
|
2543
2729
|
allSettled(blockingPromises).then(awaited => {
|
|
2544
2730
|
scheduleFlush(() => {
|
|
@@ -2550,6 +2736,7 @@ function renderToStream(code, options = {}) {
|
|
|
2550
2736
|
return;
|
|
2551
2737
|
}
|
|
2552
2738
|
if (!shellCompleted) return flush();
|
|
2739
|
+
if (claim()) return abandon();
|
|
2553
2740
|
const sink = guardSink(w);
|
|
2554
2741
|
buffer = writable = coalesceWrites(sink.write, sink.end);
|
|
2555
2742
|
buffer.write(tmp);
|
|
@@ -2615,6 +2802,8 @@ function buildAsyncWrap(err, node) {
|
|
|
2615
2802
|
fn.$rw = true;
|
|
2616
2803
|
if (suppress) fn.$lhSuppress = true;
|
|
2617
2804
|
if (node.$lhSkip) fn.$lhSkip = true;
|
|
2805
|
+
if (node.$lhInTag) fn.$lhInTag = true;
|
|
2806
|
+
if (node.$lhAttr) fn.$lhAttr = node.$lhAttr;
|
|
2618
2807
|
if (node.$lhBinding) fn.$lhBinding = node.$lhBinding;
|
|
2619
2808
|
return {
|
|
2620
2809
|
fn,
|
|
@@ -2816,7 +3005,8 @@ function createLiveHoles(sink, scoped, settled, errorScope) {
|
|
|
2816
3005
|
t: [""],
|
|
2817
3006
|
h: [],
|
|
2818
3007
|
p: [],
|
|
2819
|
-
rows: null
|
|
3008
|
+
rows: null,
|
|
3009
|
+
$: SSR_NODE
|
|
2820
3010
|
};
|
|
2821
3011
|
try {
|
|
2822
3012
|
result.rows = resolveValue(holeValue(hole), result);
|
|
@@ -2915,16 +3105,41 @@ function createLiveHoles(sink, scoped, settled, errorScope) {
|
|
|
2915
3105
|
},
|
|
2916
3106
|
nest(hole) {
|
|
2917
3107
|
const s = engine.scope;
|
|
2918
|
-
if (!s || s.h === hole || hole.$lhSkip || inScope && !inScope()) return undefined;
|
|
3108
|
+
if (!s || s.h === hole || hole.$lhSkip || hole.$lhInTag || inScope && !inScope()) return undefined;
|
|
2919
3109
|
engine.scope = scopeFor(hole);
|
|
2920
3110
|
return s;
|
|
2921
3111
|
},
|
|
2922
3112
|
content(hole) {
|
|
3113
|
+
if (hole.$lhInTag) {
|
|
3114
|
+
const cap = hole.$lhAttr;
|
|
3115
|
+
if (!cap || cap.adopted || engine.suppressed || engine.sweeping) return null;
|
|
3116
|
+
const r = tryResolveFunctionHole(hole);
|
|
3117
|
+
if (typeof r !== "string") {
|
|
3118
|
+
const res = {
|
|
3119
|
+
t: [""],
|
|
3120
|
+
h: [],
|
|
3121
|
+
p: [],
|
|
3122
|
+
$: SSR_NODE
|
|
3123
|
+
};
|
|
3124
|
+
appendResolvedNode(res, r);
|
|
3125
|
+
return res;
|
|
3126
|
+
}
|
|
3127
|
+
if (--cap.waiting === 0 && !cap.closed) {
|
|
3128
|
+
try {
|
|
3129
|
+
cap.base = attrPartsText(cap.parts);
|
|
3130
|
+
} catch (err) {
|
|
3131
|
+
cap.base = null;
|
|
3132
|
+
}
|
|
3133
|
+
if (cap.base !== null) engine.attr(cap);
|
|
3134
|
+
}
|
|
3135
|
+
return r;
|
|
3136
|
+
}
|
|
2923
3137
|
if (hole.$lhSuppress) {
|
|
2924
3138
|
const r = {
|
|
2925
3139
|
t: [""],
|
|
2926
3140
|
h: [],
|
|
2927
|
-
p: []
|
|
3141
|
+
p: [],
|
|
3142
|
+
$: SSR_NODE
|
|
2928
3143
|
};
|
|
2929
3144
|
let rows = null;
|
|
2930
3145
|
const b = hole.$lhBinding;
|
|
@@ -3028,7 +3243,8 @@ function createLiveHoles(sink, scoped, settled, errorScope) {
|
|
|
3028
3243
|
const r = {
|
|
3029
3244
|
t: [""],
|
|
3030
3245
|
h: [],
|
|
3031
|
-
p: []
|
|
3246
|
+
p: [],
|
|
3247
|
+
$: SSR_NODE
|
|
3032
3248
|
};
|
|
3033
3249
|
engine.suppressed++;
|
|
3034
3250
|
try {
|
|
@@ -3047,13 +3263,15 @@ function createLiveHoles(sink, scoped, settled, errorScope) {
|
|
|
3047
3263
|
res = {
|
|
3048
3264
|
t: ["", ""],
|
|
3049
3265
|
h: [escalated.fn],
|
|
3050
|
-
p: [escalated.p]
|
|
3266
|
+
p: [escalated.p],
|
|
3267
|
+
$: SSR_NODE
|
|
3051
3268
|
};
|
|
3052
3269
|
} else {
|
|
3053
3270
|
res = {
|
|
3054
3271
|
t: [""],
|
|
3055
3272
|
h: [],
|
|
3056
|
-
p: []
|
|
3273
|
+
p: [],
|
|
3274
|
+
$: SSR_NODE
|
|
3057
3275
|
};
|
|
3058
3276
|
try {
|
|
3059
3277
|
rows = resolveValue(value, res);
|
|
@@ -3083,20 +3301,59 @@ function createLiveHoles(sink, scoped, settled, errorScope) {
|
|
|
3083
3301
|
t[t.length - 1] += close;
|
|
3084
3302
|
sink.openBinding(key, b);
|
|
3085
3303
|
return {
|
|
3086
|
-
t,
|
|
3304
|
+
t: t,
|
|
3087
3305
|
h: res.h,
|
|
3088
|
-
p: res.p
|
|
3306
|
+
p: res.p,
|
|
3307
|
+
$: SSR_NODE
|
|
3089
3308
|
};
|
|
3090
3309
|
},
|
|
3091
3310
|
mint() {
|
|
3092
3311
|
return nextId++;
|
|
3093
3312
|
},
|
|
3313
|
+
open(text, off, hole) {
|
|
3314
|
+
const pending = hole && hole.$lhAttr;
|
|
3315
|
+
let inject;
|
|
3316
|
+
let id;
|
|
3317
|
+
if (pending && !pending.adopted && text.startsWith(pending.inject, off)) {
|
|
3318
|
+
pending.adopted = true;
|
|
3319
|
+
({
|
|
3320
|
+
id,
|
|
3321
|
+
inject
|
|
3322
|
+
} = pending);
|
|
3323
|
+
} else {
|
|
3324
|
+
id = nextId++;
|
|
3325
|
+
inject = ` data-lha="${id}"`;
|
|
3326
|
+
text = text.slice(0, off) + inject + text.slice(off);
|
|
3327
|
+
}
|
|
3328
|
+
const prefix = text.slice(off + inject.length);
|
|
3329
|
+
return {
|
|
3330
|
+
id,
|
|
3331
|
+
parts: [prefix],
|
|
3332
|
+
base: prefix,
|
|
3333
|
+
inject,
|
|
3334
|
+
waiting: 0,
|
|
3335
|
+
text
|
|
3336
|
+
};
|
|
3337
|
+
},
|
|
3338
|
+
retry(fn, cap) {
|
|
3339
|
+
if (typeof fn !== "function") return;
|
|
3340
|
+
fn.$lhInTag = true;
|
|
3341
|
+
if (cap) {
|
|
3342
|
+
fn.$lhAttr = cap;
|
|
3343
|
+
cap.waiting++;
|
|
3344
|
+
}
|
|
3345
|
+
},
|
|
3094
3346
|
active() {
|
|
3095
3347
|
return (!inScope || inScope()) && !(settled && settled());
|
|
3096
3348
|
},
|
|
3097
3349
|
attr(cap) {
|
|
3098
|
-
|
|
3099
|
-
|
|
3350
|
+
if (cap.waiting) {
|
|
3351
|
+
cap.owner = getOwner();
|
|
3352
|
+
cap.ctx = sharedConfig.context;
|
|
3353
|
+
return;
|
|
3354
|
+
}
|
|
3355
|
+
const owner = cap.owner !== undefined ? cap.owner : getOwner();
|
|
3356
|
+
const holeCtx = cap.ctx !== undefined ? cap.ctx : sharedConfig.context;
|
|
3100
3357
|
const b = {
|
|
3101
3358
|
key: "lha:" + cap.id,
|
|
3102
3359
|
children: [],
|
|
@@ -3111,29 +3368,7 @@ function createLiveHoles(sink, scoped, settled, errorScope) {
|
|
|
3111
3368
|
engine.gateHit = false;
|
|
3112
3369
|
let html = "";
|
|
3113
3370
|
try {
|
|
3114
|
-
|
|
3115
|
-
let groupVal = null;
|
|
3116
|
-
const run = () => {
|
|
3117
|
-
for (const part of cap.parts) {
|
|
3118
|
-
if (typeof part === "string") {
|
|
3119
|
-
html += part;
|
|
3120
|
-
continue;
|
|
3121
|
-
}
|
|
3122
|
-
let v;
|
|
3123
|
-
if (part.g) {
|
|
3124
|
-
if (group !== part.g) {
|
|
3125
|
-
group = part.g;
|
|
3126
|
-
groupVal = part.g();
|
|
3127
|
-
}
|
|
3128
|
-
v = groupVal[part.i];
|
|
3129
|
-
} else {
|
|
3130
|
-
v = part.f();
|
|
3131
|
-
}
|
|
3132
|
-
const vt = typeof v;
|
|
3133
|
-
if (vt === "string" || vt === "number") html += v;
|
|
3134
|
-
}
|
|
3135
|
-
};
|
|
3136
|
-
swept(owner, holeCtx, run);
|
|
3371
|
+
swept(owner, holeCtx, () => html = attrPartsText(cap.parts));
|
|
3137
3372
|
} catch (err) {
|
|
3138
3373
|
if (ssrHandleError(err, true)) {
|
|
3139
3374
|
if (!engine.sweptOwners) return;
|
|
@@ -3240,10 +3475,35 @@ function rowPatch(a, b) {
|
|
|
3240
3475
|
}
|
|
3241
3476
|
}
|
|
3242
3477
|
}
|
|
3478
|
+
function attrPartsText(parts) {
|
|
3479
|
+
let html = "";
|
|
3480
|
+
let group = null;
|
|
3481
|
+
let groupVal = null;
|
|
3482
|
+
for (const part of parts) {
|
|
3483
|
+
if (typeof part === "string") {
|
|
3484
|
+
html += part;
|
|
3485
|
+
continue;
|
|
3486
|
+
}
|
|
3487
|
+
let v;
|
|
3488
|
+
if (part.g) {
|
|
3489
|
+
if (group !== part.g) {
|
|
3490
|
+
group = part.g;
|
|
3491
|
+
groupVal = part.g();
|
|
3492
|
+
}
|
|
3493
|
+
v = groupVal[part.i];
|
|
3494
|
+
} else {
|
|
3495
|
+
v = part.f();
|
|
3496
|
+
}
|
|
3497
|
+
const vt = typeof v;
|
|
3498
|
+
if (vt === "string" || vt === "number") html += v;
|
|
3499
|
+
}
|
|
3500
|
+
return html;
|
|
3501
|
+
}
|
|
3243
3502
|
function ssr(t) {
|
|
3244
3503
|
const len = arguments.length;
|
|
3245
3504
|
if (len === 1) return {
|
|
3246
|
-
t
|
|
3505
|
+
t: t,
|
|
3506
|
+
$: SSR_NODE
|
|
3247
3507
|
};
|
|
3248
3508
|
let s = t[0];
|
|
3249
3509
|
let result = null;
|
|
@@ -3259,30 +3519,18 @@ function ssr(t) {
|
|
|
3259
3519
|
seg: -1,
|
|
3260
3520
|
off: hp.openOff[0]
|
|
3261
3521
|
};
|
|
3262
|
-
const captureStart =
|
|
3522
|
+
const captureStart = hole => {
|
|
3263
3523
|
if (cap) return true;
|
|
3264
3524
|
if (!lastOpen || live.suppressed || live.sweeping || !live.active()) return false;
|
|
3525
|
+
if (lastOpen.r === null && result !== null && result.t.length === 1) {
|
|
3526
|
+
lastOpen.r = result;
|
|
3527
|
+
lastOpen.seg = 0;
|
|
3528
|
+
}
|
|
3265
3529
|
if (lastOpen.r !== result || result !== null && lastOpen.seg !== result.t.length - 1) {
|
|
3266
3530
|
return false;
|
|
3267
3531
|
}
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
let prefix;
|
|
3271
|
-
if (result === null) {
|
|
3272
|
-
s = s.slice(0, lastOpen.off) + inject + s.slice(lastOpen.off);
|
|
3273
|
-
prefix = s.slice(lastOpen.off + inject.length);
|
|
3274
|
-
} else {
|
|
3275
|
-
const seg = result.t[lastOpen.seg];
|
|
3276
|
-
result.t[lastOpen.seg] = seg.slice(0, lastOpen.off) + inject + seg.slice(lastOpen.off);
|
|
3277
|
-
prefix = result.t[lastOpen.seg].slice(lastOpen.off + inject.length);
|
|
3278
|
-
}
|
|
3279
|
-
cap = {
|
|
3280
|
-
id,
|
|
3281
|
-
parts: [prefix],
|
|
3282
|
-
base: prefix,
|
|
3283
|
-
at: lastOpen.seg,
|
|
3284
|
-
inject
|
|
3285
|
-
};
|
|
3532
|
+
cap = live.open(result === null ? s : result.t[lastOpen.seg], lastOpen.off, hole);
|
|
3533
|
+
if (result === null) s = cap.text;else result.t[lastOpen.seg] = cap.text;
|
|
3286
3534
|
return true;
|
|
3287
3535
|
};
|
|
3288
3536
|
for (let i = 1; i < len; i++) {
|
|
@@ -3313,7 +3561,8 @@ function ssr(t) {
|
|
|
3313
3561
|
result = {
|
|
3314
3562
|
t: [s],
|
|
3315
3563
|
h: [],
|
|
3316
|
-
p: []
|
|
3564
|
+
p: [],
|
|
3565
|
+
$: SSR_NODE
|
|
3317
3566
|
};
|
|
3318
3567
|
s = "";
|
|
3319
3568
|
}
|
|
@@ -3323,18 +3572,23 @@ function ssr(t) {
|
|
|
3323
3572
|
if (Array.isArray(lastGroupVal)) {
|
|
3324
3573
|
value = lastGroupVal[lastGroupIdx++];
|
|
3325
3574
|
hasValue = true;
|
|
3326
|
-
if (live && !hp.pos[i - 1] && captureStart()) {
|
|
3575
|
+
if (live && !hp.pos[i - 1] && captureStart(hole)) {
|
|
3327
3576
|
cap.parts.push({
|
|
3328
3577
|
g: hole,
|
|
3329
3578
|
i: lastGroupIdx - 1
|
|
3330
3579
|
});
|
|
3331
3580
|
}
|
|
3332
3581
|
} else {
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3582
|
+
const slot = ssrGroupSlot(lastGroupVal.fn, lastGroupIdx++);
|
|
3583
|
+
if (live && !hp.pos[i - 1]) {
|
|
3584
|
+
const capturing = captureStart(hole);
|
|
3585
|
+
if (capturing) cap.parts.push({
|
|
3586
|
+
g: hole,
|
|
3587
|
+
i: lastGroupIdx - 1
|
|
3588
|
+
});
|
|
3589
|
+
live.retry(slot, capturing && cap);
|
|
3336
3590
|
}
|
|
3337
|
-
result.h.push(
|
|
3591
|
+
result.h.push(slot);
|
|
3338
3592
|
result.p.push(lastGroupVal.p);
|
|
3339
3593
|
result.t.push("");
|
|
3340
3594
|
}
|
|
@@ -3354,7 +3608,8 @@ function ssr(t) {
|
|
|
3354
3608
|
result = {
|
|
3355
3609
|
t: [s],
|
|
3356
3610
|
h: [],
|
|
3357
|
-
p: []
|
|
3611
|
+
p: [],
|
|
3612
|
+
$: SSR_NODE
|
|
3358
3613
|
};
|
|
3359
3614
|
s = "";
|
|
3360
3615
|
if (rs.merge !== undefined) mergeTemplateInto(result, rs.merge);else resolveSSRNode(rs.bail, result);
|
|
@@ -3371,7 +3626,8 @@ function ssr(t) {
|
|
|
3371
3626
|
result = {
|
|
3372
3627
|
t: [s],
|
|
3373
3628
|
h: [],
|
|
3374
|
-
p: []
|
|
3629
|
+
p: [],
|
|
3630
|
+
$: SSR_NODE
|
|
3375
3631
|
};
|
|
3376
3632
|
s = "";
|
|
3377
3633
|
}
|
|
@@ -3379,28 +3635,27 @@ function ssr(t) {
|
|
|
3379
3635
|
}
|
|
3380
3636
|
} else if (result !== null) {
|
|
3381
3637
|
const inTag = live && !hp.pos[i - 1];
|
|
3382
|
-
const capturing = inTag && captureStart();
|
|
3638
|
+
const capturing = inTag && captureStart(hole);
|
|
3383
3639
|
const li = capturing ? result.t.length - 1 : 0;
|
|
3384
3640
|
const before = capturing ? result.t[li].length : 0;
|
|
3641
|
+
const pushed = result.h.length;
|
|
3385
3642
|
if (live) live.suppressed++;
|
|
3386
3643
|
try {
|
|
3387
3644
|
resolveSSRNode(hole, result);
|
|
3388
3645
|
} finally {
|
|
3389
3646
|
if (live) live.suppressed--;
|
|
3390
3647
|
}
|
|
3648
|
+
if (inTag) {
|
|
3649
|
+
for (let k = pushed; k < result.h.length; k++) live.retry(result.h[k], capturing && cap);
|
|
3650
|
+
}
|
|
3391
3651
|
if (capturing) {
|
|
3392
|
-
if (result.t.length - 1 === li)
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
});
|
|
3397
|
-
} else {
|
|
3398
|
-
result.t[cap.at] = result.t[cap.at].replace(cap.inject, "");
|
|
3399
|
-
cap = null;
|
|
3400
|
-
}
|
|
3652
|
+
if (result.t.length - 1 === li) cap.base += result.t[li].slice(before);
|
|
3653
|
+
cap.parts.push({
|
|
3654
|
+
f: hole
|
|
3655
|
+
});
|
|
3401
3656
|
}
|
|
3402
3657
|
} else {
|
|
3403
|
-
const capturing = live && !hp.pos[i - 1] && captureStart();
|
|
3658
|
+
const capturing = live && !hp.pos[i - 1] && captureStart(hole);
|
|
3404
3659
|
const scope = live && hp.pos[i - 1] && live.nest(hole);
|
|
3405
3660
|
const r = tryResolveFunctionHole(hole);
|
|
3406
3661
|
if (scope) live.scope = scope;
|
|
@@ -3413,17 +3668,18 @@ function ssr(t) {
|
|
|
3413
3668
|
});
|
|
3414
3669
|
}
|
|
3415
3670
|
} else {
|
|
3416
|
-
if (capturing) {
|
|
3417
|
-
s = s.replace(cap.inject, "");
|
|
3418
|
-
cap = null;
|
|
3419
|
-
}
|
|
3420
3671
|
result = {
|
|
3421
3672
|
t: [s],
|
|
3422
3673
|
h: [],
|
|
3423
|
-
p: []
|
|
3674
|
+
p: [],
|
|
3675
|
+
$: SSR_NODE
|
|
3424
3676
|
};
|
|
3425
3677
|
s = "";
|
|
3426
3678
|
appendResolvedNode(result, r);
|
|
3679
|
+
if (capturing) cap.parts.push({
|
|
3680
|
+
f: hole
|
|
3681
|
+
});
|
|
3682
|
+
if (live && !hp.pos[i - 1]) for (const h of result.h) live.retry(h, capturing && cap);
|
|
3427
3683
|
}
|
|
3428
3684
|
}
|
|
3429
3685
|
} else if (result !== null) {
|
|
@@ -3436,7 +3692,8 @@ function ssr(t) {
|
|
|
3436
3692
|
result = {
|
|
3437
3693
|
t: [s],
|
|
3438
3694
|
h: [],
|
|
3439
|
-
p: []
|
|
3695
|
+
p: [],
|
|
3696
|
+
$: SSR_NODE
|
|
3440
3697
|
};
|
|
3441
3698
|
s = "";
|
|
3442
3699
|
appendResolvedNode(result, r);
|
|
@@ -3472,7 +3729,8 @@ function ssr(t) {
|
|
|
3472
3729
|
if (result === null) s += next;else result.t[result.t.length - 1] += next;
|
|
3473
3730
|
}
|
|
3474
3731
|
if (result === null) return {
|
|
3475
|
-
t: s
|
|
3732
|
+
t: s,
|
|
3733
|
+
$: SSR_NODE
|
|
3476
3734
|
};
|
|
3477
3735
|
return result;
|
|
3478
3736
|
}
|
|
@@ -3552,6 +3810,7 @@ function ssrElement(tag, props, children, needsId, skip, attrs) {
|
|
|
3552
3810
|
}
|
|
3553
3811
|
const info = tagInfo(tag);
|
|
3554
3812
|
const skipChildren = info.isVoid;
|
|
3813
|
+
let sel, optValue, optOwn;
|
|
3555
3814
|
let result = info.open + hk;
|
|
3556
3815
|
let childOwner = null;
|
|
3557
3816
|
const last = sources === null ? 0 : sources.length - 1;
|
|
@@ -3570,6 +3829,11 @@ function ssrElement(tag, props, children, needsId, skip, attrs) {
|
|
|
3570
3829
|
for (let j = s + 1; j <= last; j++) {
|
|
3571
3830
|
if (keysOf[j].includes(prop)) continue nextKey;
|
|
3572
3831
|
}
|
|
3832
|
+
if (info.sel === 1 && prop === "value") {
|
|
3833
|
+
const value = props[prop];
|
|
3834
|
+
sel = ssrSelect(value);
|
|
3835
|
+
continue;
|
|
3836
|
+
}
|
|
3573
3837
|
if (info.textarea && (prop === "value" || prop === "defaultValue")) {
|
|
3574
3838
|
const value = props[prop];
|
|
3575
3839
|
if (value !== null) children = escape(value);
|
|
@@ -3589,6 +3853,9 @@ function ssrElement(tag, props, children, needsId, skip, attrs) {
|
|
|
3589
3853
|
const value = props[key];
|
|
3590
3854
|
if (value == undefined || prop.startsWith("prop:") || prop === "ref" || isEventName(prop)) continue;
|
|
3591
3855
|
if (link !== null && LinkAttributes.has(prop)) link[prop] = value;
|
|
3856
|
+
if (info.sel === 2) {
|
|
3857
|
+
if (prop === "value") optValue = value;else if (prop === "selected" && value) optOwn = true;
|
|
3858
|
+
}
|
|
3592
3859
|
if (prop === "style") {
|
|
3593
3860
|
result += ` style="${ssrStyle(value)}"`;
|
|
3594
3861
|
} else if (prop === "class") {
|
|
@@ -3603,21 +3870,58 @@ function ssrElement(tag, props, children, needsId, skip, attrs) {
|
|
|
3603
3870
|
if (attrs !== undefined) result += typeof attrs === "function" ? attrs() : attrs;
|
|
3604
3871
|
if (link !== null && link.href !== undefined) result += ssrLinkClaim(link);
|
|
3605
3872
|
if (skipChildren) return {
|
|
3606
|
-
t: result + " />"
|
|
3873
|
+
t: result + " />",
|
|
3874
|
+
$: SSR_NODE
|
|
3607
3875
|
};
|
|
3608
|
-
if (
|
|
3609
|
-
if (typeof children
|
|
3876
|
+
if (sel !== undefined) children = ssrIn(sel, () => spreadChildren(info, childOwner, children));else children = spreadChildren(info, childOwner, children);
|
|
3877
|
+
if (info.sel === 2) result += ssrOption(optValue !== undefined || typeof children !== "string" ? optValue : children.replace(/</g, "<").replace(/&/g, "&").replace(/\s+/g, " ").trim(), undefined, optOwn);
|
|
3878
|
+
let thunk = null;
|
|
3879
|
+
if (typeof children === "function" && (ctx === undefined || !ctx.liveHoles)) {
|
|
3880
|
+
thunk = children;
|
|
3881
|
+
ssrTextTail = false;
|
|
3882
|
+
try {
|
|
3883
|
+
children = thunk();
|
|
3884
|
+
} catch (err) {
|
|
3885
|
+
const res = {
|
|
3886
|
+
t: [""],
|
|
3887
|
+
h: [],
|
|
3888
|
+
p: [],
|
|
3889
|
+
$: SSR_NODE
|
|
3890
|
+
};
|
|
3891
|
+
pushSSRAsyncHole(res, err, thunk);
|
|
3892
|
+
return ssr([result + ">", info.close], res);
|
|
3893
|
+
}
|
|
3894
|
+
}
|
|
3610
3895
|
const ct = typeof children;
|
|
3611
3896
|
if (ct === "string" || ct === "number") return {
|
|
3612
|
-
t: result + ">" + children + info.close
|
|
3897
|
+
t: result + ">" + children + info.close,
|
|
3898
|
+
$: SSR_NODE
|
|
3613
3899
|
};
|
|
3614
3900
|
if (children == null || ct === "boolean") return {
|
|
3615
|
-
t: result + ">" + info.close
|
|
3901
|
+
t: result + ">" + info.close,
|
|
3902
|
+
$: SSR_NODE
|
|
3616
3903
|
};
|
|
3617
|
-
if (ct === "object" && !children.h && typeof children.t === "string") return {
|
|
3618
|
-
t: result + ">" + children.t + info.close
|
|
3904
|
+
if (ct === "object" && children.$ === SSR_NODE && !children.h && typeof children.t === "string") return {
|
|
3905
|
+
t: result + ">" + children.t + info.close,
|
|
3906
|
+
$: SSR_NODE
|
|
3619
3907
|
};
|
|
3620
|
-
return ssr([result + ">", info.close], resolveSSRNode(children, undefined, true));
|
|
3908
|
+
if (thunk === null) return ssr([result + ">", info.close], resolveSSRNode(children, undefined, true));
|
|
3909
|
+
const res = {
|
|
3910
|
+
t: [""],
|
|
3911
|
+
h: [],
|
|
3912
|
+
p: [],
|
|
3913
|
+
$: SSR_NODE
|
|
3914
|
+
};
|
|
3915
|
+
try {
|
|
3916
|
+
resolveSSRNode(children, res, false, true);
|
|
3917
|
+
} catch (err) {
|
|
3918
|
+
pushSSRAsyncHole(res, err, thunk);
|
|
3919
|
+
}
|
|
3920
|
+
return ssr([result + ">", info.close], res);
|
|
3921
|
+
}
|
|
3922
|
+
function spreadChildren(info, childOwner, children) {
|
|
3923
|
+
if (childOwner !== null) children = info.raw ? childOwner.children : escape(childOwner.children);
|
|
3924
|
+
return typeof children === "function" ? children() : children;
|
|
3621
3925
|
}
|
|
3622
3926
|
function collectSpreadSources(props, viewKeys, owners) {
|
|
3623
3927
|
for (let i = 0; i < props.length; i++) {
|
|
@@ -3661,110 +3965,37 @@ function ssrLinkClaim(attrs) {
|
|
|
3661
3965
|
if (ctx === undefined || ctx.linkClaim === undefined || attrs["aria-current"] != null) return "";
|
|
3662
3966
|
return ctx.linkClaim(attrs);
|
|
3663
3967
|
}
|
|
3664
|
-
|
|
3665
|
-
|
|
3968
|
+
const SELECT = Symbol();
|
|
3969
|
+
function ssrSelect(value) {
|
|
3970
|
+
const owner = createOwner({
|
|
3971
|
+
transparent: true
|
|
3972
|
+
});
|
|
3973
|
+
const state = {
|
|
3974
|
+
v: value,
|
|
3975
|
+
d: false,
|
|
3976
|
+
o: owner
|
|
3977
|
+
};
|
|
3978
|
+
owner._context = {
|
|
3979
|
+
...owner._context,
|
|
3980
|
+
[SELECT]: state
|
|
3981
|
+
};
|
|
3982
|
+
return state;
|
|
3666
3983
|
}
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
for (let j = i + 1; j < html.length; j++) {
|
|
3670
|
-
const c = html.charCodeAt(j);
|
|
3671
|
-
if (c === 34) {
|
|
3672
|
-
j = html.indexOf('"', j + 1);
|
|
3673
|
-
if (j < 0) return -1;
|
|
3674
|
-
} else if (c === 62) return j;
|
|
3675
|
-
}
|
|
3676
|
-
return -1;
|
|
3984
|
+
function ssrIn(state, fn) {
|
|
3985
|
+
return runWithOwner(state.o, fn);
|
|
3677
3986
|
}
|
|
3678
|
-
function
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
const lt = html.indexOf("<", i);
|
|
3683
|
-
if (lt < 0) return t + html.slice(i);
|
|
3684
|
-
t += html.slice(i, lt);
|
|
3685
|
-
if (!html.startsWith("<!--", lt)) return t;
|
|
3686
|
-
const ce = html.indexOf("-->", lt);
|
|
3687
|
-
if (ce < 0) return t;
|
|
3688
|
-
i = ce + 3;
|
|
3689
|
-
}
|
|
3690
|
-
}
|
|
3691
|
-
function tagIs(html, i, name) {
|
|
3692
|
-
if (!html.startsWith(name, i + 1)) return false;
|
|
3693
|
-
const c = html.charCodeAt(i + 1 + name.length);
|
|
3694
|
-
return c === 32 || c === 62 || c === 9 || c === 10 || c === 13;
|
|
3695
|
-
}
|
|
3696
|
-
let selectValuesActive = false;
|
|
3697
|
-
function ssrSelectValues() {
|
|
3698
|
-
selectValuesActive = true;
|
|
3699
|
-
}
|
|
3700
|
-
function resolveSSRSelectValues(html) {
|
|
3701
|
-
if (!selectValuesActive) return html;
|
|
3702
|
-
let cand = html.indexOf("<select");
|
|
3703
|
-
if (cand < 0) return html;
|
|
3704
|
-
let out = "";
|
|
3705
|
-
let idx = 0;
|
|
3706
|
-
while (cand >= 0) {
|
|
3707
|
-
if (!tagIs(html, cand, "select")) {
|
|
3708
|
-
cand = html.indexOf("<select", cand + 7);
|
|
3709
|
-
continue;
|
|
3710
|
-
}
|
|
3711
|
-
const e0 = tagEnd(html, cand);
|
|
3712
|
-
if (e0 < 0) break;
|
|
3713
|
-
const open = html.slice(cand, e0 + 1);
|
|
3714
|
-
const m = SELECT_VALUE_ATTR.exec(open);
|
|
3715
|
-
if (!m) {
|
|
3716
|
-
cand = html.indexOf("<select", e0 + 1);
|
|
3717
|
-
continue;
|
|
3718
|
-
}
|
|
3719
|
-
const bound = decodeSSREntities(m[1] ?? "");
|
|
3720
|
-
const sel = {
|
|
3721
|
-
values: /\smultiple(?=[\s>=])/.test(open) ? bound.split(",") : [bound],
|
|
3722
|
-
strip: cand + m.index,
|
|
3723
|
-
stripEnd: cand + m.index + m[0].length,
|
|
3724
|
-
body: e0 + 1,
|
|
3725
|
-
marks: [],
|
|
3726
|
-
defaulted: false
|
|
3727
|
-
};
|
|
3728
|
-
let committed = false;
|
|
3729
|
-
let i = html.indexOf("<", e0 + 1);
|
|
3730
|
-
while (i >= 0) {
|
|
3731
|
-
let e;
|
|
3732
|
-
if (html.charCodeAt(i + 1) === 33) {
|
|
3733
|
-
e = html.charCodeAt(i + 2) === 45 ? html.indexOf("-->", i) : html.indexOf(">", i);
|
|
3734
|
-
if (e < 0) break;
|
|
3735
|
-
if (html.charCodeAt(i + 2) === 45) e += 2;
|
|
3736
|
-
} else {
|
|
3737
|
-
e = tagEnd(html, i);
|
|
3738
|
-
if (e < 0) break;
|
|
3739
|
-
if (html.startsWith("</select>", i)) {
|
|
3740
|
-
out += html.slice(idx, sel.strip) + html.slice(sel.stripEnd, sel.body);
|
|
3741
|
-
let seg = sel.body;
|
|
3742
|
-
if (!sel.defaulted) {
|
|
3743
|
-
for (let k = 0; k < sel.marks.length; k++) {
|
|
3744
|
-
out += html.slice(seg, sel.marks[k]) + " selected";
|
|
3745
|
-
seg = sel.marks[k];
|
|
3746
|
-
}
|
|
3747
|
-
}
|
|
3748
|
-
out += html.slice(seg, i);
|
|
3749
|
-
idx = i;
|
|
3750
|
-
committed = true;
|
|
3751
|
-
break;
|
|
3752
|
-
} else if (tagIs(html, i, "option")) {
|
|
3753
|
-
const attrs = html.slice(i + 7, e);
|
|
3754
|
-
if (/\sselected(?=[\s=]|$)/.test(attrs)) sel.defaulted = true;else {
|
|
3755
|
-
const vm = SELECT_VALUE_ATTR.exec(attrs);
|
|
3756
|
-
const value = vm ? decodeSSREntities(vm[1] ?? "") : decodeSSREntities(optionText(html, e + 1)).replace(/\s+/g, " ").trim();
|
|
3757
|
-
if (sel.values.includes(value)) sel.marks.push(e);
|
|
3758
|
-
}
|
|
3759
|
-
}
|
|
3760
|
-
}
|
|
3761
|
-
i = html.indexOf("<", e + 1);
|
|
3762
|
-
}
|
|
3763
|
-
if (!committed) break;
|
|
3764
|
-
cand = html.indexOf("<select", idx);
|
|
3987
|
+
function ssrOption(value, state, own) {
|
|
3988
|
+
if (state === undefined) {
|
|
3989
|
+
const o = getOwner();
|
|
3990
|
+
if (!o || !(state = o._context[SELECT])) return "";
|
|
3765
3991
|
}
|
|
3766
|
-
if (
|
|
3767
|
-
|
|
3992
|
+
if (own) return state.d = true, "";
|
|
3993
|
+
if (state.d) return "";
|
|
3994
|
+
if (typeof value === "function") value = value();
|
|
3995
|
+
if (value == null) return "";
|
|
3996
|
+
value = String(value);
|
|
3997
|
+
const v = state.v;
|
|
3998
|
+
return v != null && (v.map ? v.some(x => x != null && String(x) === value) : String(v) === value) ? " selected" : "";
|
|
3768
3999
|
}
|
|
3769
4000
|
function escape(s, attr) {
|
|
3770
4001
|
const t = typeof s;
|
|
@@ -3871,7 +4102,7 @@ function tryJoinPlainSSRArray(nodes) {
|
|
|
3871
4102
|
let out = "";
|
|
3872
4103
|
for (let i = 0, len = nodes.length; i < len; i++) {
|
|
3873
4104
|
const node = nodes[i];
|
|
3874
|
-
if (node == null || typeof node !== "object" || node.h || typeof node.t !== "string") {
|
|
4105
|
+
if (node == null || typeof node !== "object" || node.$ !== SSR_NODE || node.h || typeof node.t !== "string") {
|
|
3875
4106
|
return undefined;
|
|
3876
4107
|
}
|
|
3877
4108
|
out += node.t;
|
|
@@ -3912,7 +4143,7 @@ function withShellEnd(html, context, renderId, nonce, noScripts) {
|
|
|
3912
4143
|
const at = html.indexOf("</body>", html.length - 512);
|
|
3913
4144
|
return at < 0 ? html + marker : html.slice(0, at) + marker + html.slice(at);
|
|
3914
4145
|
}
|
|
3915
|
-
function assembleDocument(html, emittedAssets, preloadLinks, inlineStyles, scripts, nonce, headTags, onHead) {
|
|
4146
|
+
function assembleDocument(html, emittedAssets, preloadLinks, inlineStyles, scripts, nonce, headTags, onHead, lowModules) {
|
|
3916
4147
|
const scriptTag = scripts ? `<script${nonceAttr(nonce, "script")}>${scripts}</script>` : "";
|
|
3917
4148
|
const title = headTags ? headTags.title : null;
|
|
3918
4149
|
let headTagsHtml = headTags ? headTags.html : "";
|
|
@@ -3936,7 +4167,7 @@ function assembleDocument(html, emittedAssets, preloadLinks, inlineStyles, scrip
|
|
|
3936
4167
|
if (title != null) {
|
|
3937
4168
|
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>`;
|
|
3938
4169
|
}
|
|
3939
|
-
onHead(headPrelude + headTagsHtml + titleHtml + renderHeadAssets(emittedAssets, preloadLinks, inlineStyles, nonce));
|
|
4170
|
+
onHead(headPrelude + headTagsHtml + titleHtml + renderHeadAssets(emittedAssets, preloadLinks, inlineStyles, nonce, lowModules));
|
|
3940
4171
|
}
|
|
3941
4172
|
if (!scriptTag) return html;
|
|
3942
4173
|
const xs = html.indexOf("<!--xs-->");
|
|
@@ -3956,19 +4187,19 @@ function assembleDocument(html, emittedAssets, preloadLinks, inlineStyles, scrip
|
|
|
3956
4187
|
headTagsHtml = `<title data-dh="title">${winner}</title>` + headTagsHtml;
|
|
3957
4188
|
}
|
|
3958
4189
|
}
|
|
3959
|
-
const head = headTagsHtml + renderHeadAssets(emittedAssets, preloadLinks, inlineStyles, nonce);
|
|
4190
|
+
const head = headTagsHtml + renderHeadAssets(emittedAssets, preloadLinks, inlineStyles, nonce, lowModules);
|
|
3960
4191
|
if (!scriptTag) return html.slice(0, headIdx) + head + html.slice(headIdx);
|
|
3961
4192
|
const xsIdx = html.indexOf("<!--xs-->");
|
|
3962
4193
|
if (xsIdx === -1) return html.slice(0, headIdx) + head + html.slice(headIdx) + scriptTag;
|
|
3963
4194
|
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);
|
|
3964
4195
|
}
|
|
3965
|
-
function renderHeadAssets(emittedAssets, preloadLinks, inlineStyles, nonce) {
|
|
4196
|
+
function renderHeadAssets(emittedAssets, preloadLinks, inlineStyles, nonce, lowModules) {
|
|
3966
4197
|
let head = "";
|
|
3967
4198
|
const styleAttr = nonceAttr(nonce, "style");
|
|
3968
4199
|
const scriptAttr = nonceAttr(nonce, "script");
|
|
3969
4200
|
if (emittedAssets && emittedAssets.size) {
|
|
3970
4201
|
for (const url of emittedAssets) {
|
|
3971
|
-
head += isCssUrl(url) ? `<link rel="stylesheet" href="${url}"${styleAttr}>` :
|
|
4202
|
+
head += isCssUrl(url) ? `<link rel="stylesheet" href="${url}"${styleAttr}>` : modulePreloadLink(url, scriptAttr, lowModules);
|
|
3972
4203
|
}
|
|
3973
4204
|
}
|
|
3974
4205
|
if (preloadLinks) {
|
|
@@ -4099,12 +4330,12 @@ function tryResolveString(node, nested) {
|
|
|
4099
4330
|
}
|
|
4100
4331
|
return s;
|
|
4101
4332
|
}
|
|
4333
|
+
if (node.$ !== SSR_NODE) {
|
|
4334
|
+
return "";
|
|
4335
|
+
}
|
|
4102
4336
|
if (node.h && node.h.length > 0) return {
|
|
4103
4337
|
merge: node
|
|
4104
4338
|
};
|
|
4105
|
-
if (node.t === undefined) {
|
|
4106
|
-
return "";
|
|
4107
|
-
}
|
|
4108
4339
|
ssrTextTail = false;
|
|
4109
4340
|
return Array.isArray(node.t) ? node.t[0] : node.t;
|
|
4110
4341
|
}
|
|
@@ -4124,7 +4355,8 @@ function tryResolveString(node, nested) {
|
|
|
4124
4355
|
function resolveSSRNode(node, result = {
|
|
4125
4356
|
t: [""],
|
|
4126
4357
|
h: [],
|
|
4127
|
-
p: []
|
|
4358
|
+
p: [],
|
|
4359
|
+
$: SSR_NODE
|
|
4128
4360
|
}, top, nested) {
|
|
4129
4361
|
if (!nested) ssrTextTail = false;
|
|
4130
4362
|
const t = typeof node;
|
|
@@ -4143,7 +4375,7 @@ function resolveSSRNode(node, result = {
|
|
|
4143
4375
|
if (slotLive) slotLive.suppressed--;
|
|
4144
4376
|
}
|
|
4145
4377
|
} else if (t === "object") {
|
|
4146
|
-
if (node.h) {
|
|
4378
|
+
if (node.$ !== SSR_NODE) ; else if (node.h) {
|
|
4147
4379
|
result.t[result.t.length - 1] += node.t[0];
|
|
4148
4380
|
if (node.t.length > 1) {
|
|
4149
4381
|
result.t.push(...node.t.slice(1));
|
|
@@ -4151,10 +4383,10 @@ function resolveSSRNode(node, result = {
|
|
|
4151
4383
|
result.p.push(...node.p);
|
|
4152
4384
|
}
|
|
4153
4385
|
ssrTextTail = false;
|
|
4154
|
-
} else
|
|
4386
|
+
} else {
|
|
4155
4387
|
result.t[result.t.length - 1] += node.t;
|
|
4156
4388
|
ssrTextTail = false;
|
|
4157
|
-
}
|
|
4389
|
+
}
|
|
4158
4390
|
} else if (t === "function") {
|
|
4159
4391
|
const live = sharedConfig.context && sharedConfig.context.liveHoles;
|
|
4160
4392
|
let liveNode = null;
|
|
@@ -4168,14 +4400,7 @@ function resolveSSRNode(node, result = {
|
|
|
4168
4400
|
try {
|
|
4169
4401
|
resolveSSRNode(node(), result, false, true);
|
|
4170
4402
|
} catch (err) {
|
|
4171
|
-
|
|
4172
|
-
if (wrap) {
|
|
4173
|
-
if (ssrTextTail) result.t[result.t.length - 1] += "<!--!$-->";
|
|
4174
|
-
result.h.push(wrap.fn);
|
|
4175
|
-
result.p.push(wrap.p);
|
|
4176
|
-
result.t.push("");
|
|
4177
|
-
ssrTextTail = true;
|
|
4178
|
-
}
|
|
4403
|
+
pushSSRAsyncHole(result, err, node);
|
|
4179
4404
|
} finally {
|
|
4180
4405
|
if (scope) live.scope = scope;
|
|
4181
4406
|
}
|
|
@@ -4183,6 +4408,16 @@ function resolveSSRNode(node, result = {
|
|
|
4183
4408
|
}
|
|
4184
4409
|
return result;
|
|
4185
4410
|
}
|
|
4411
|
+
function pushSSRAsyncHole(result, err, node) {
|
|
4412
|
+
const wrap = buildAsyncWrap(err, node);
|
|
4413
|
+
if (wrap) {
|
|
4414
|
+
if (ssrTextTail) result.t[result.t.length - 1] += "<!--!$-->";
|
|
4415
|
+
result.h.push(wrap.fn);
|
|
4416
|
+
result.p.push(wrap.p);
|
|
4417
|
+
result.t.push("");
|
|
4418
|
+
ssrTextTail = true;
|
|
4419
|
+
}
|
|
4420
|
+
}
|
|
4186
4421
|
function resolveSSRSync(node) {
|
|
4187
4422
|
const res = resolveSSRNode(node);
|
|
4188
4423
|
if (!res.h.length) return res.t[0];
|
|
@@ -4565,6 +4800,10 @@ function registerElementClaim() {
|
|
|
4565
4800
|
return noopCleanup;
|
|
4566
4801
|
}
|
|
4567
4802
|
function noopCleanup() {}
|
|
4803
|
+
function setTrustedTypesPolicy() {}
|
|
4804
|
+
function trustedHTML(html) {
|
|
4805
|
+
return html;
|
|
4806
|
+
}
|
|
4568
4807
|
function claimElement(node) {
|
|
4569
4808
|
return node;
|
|
4570
4809
|
}
|
|
@@ -4714,4 +4953,4 @@ function httpHeader(name, value, options) {
|
|
|
4714
4953
|
}
|
|
4715
4954
|
}
|
|
4716
4955
|
|
|
4717
|
-
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,
|
|
4956
|
+
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 };
|