@solidjs/web 2.0.0-rc.14 → 2.0.0-rc.16
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/README.md +1 -1
- package/dist/server.dev.js +475 -591
- package/dist/server.js +459 -489
- package/dist/server.observe.js +459 -498
- package/dist/web.dev.js +206 -220
- package/dist/web.js +196 -208
- package/dist/web.observe.js +206 -213
- package/frames/dist/client.dev.js +664 -643
- package/frames/dist/client.js +593 -582
- package/frames/dist/client.observe.js +624 -589
- package/frames/dist/regions.js +43 -2
- package/frames/dist/server.dev.js +578 -450
- package/frames/dist/server.js +578 -397
- package/frames/dist/server.observe.js +578 -397
- package/frames/dist/trace.js +4 -1
- package/frames/dist/wire.js +371 -6
- package/package.json +13 -13
- package/serialization/dist/decode.js +11 -9
- package/serialization/dist/serialization.js +11 -9
- package/serialization/types/serializer-decode.d.ts +2 -2
- package/server-functions/dist/client.dev.js +5 -2
- package/server-functions/dist/client.js +3 -2
- package/server-functions/dist/client.observe.js +5 -2
- package/server-functions/dist/rich-args.js +33 -1
- package/server-functions/dist/server.dev.js +218 -35
- package/server-functions/dist/server.js +218 -35
- package/server-functions/dist/server.observe.js +218 -35
- package/skills/server-components/SKILL.md +74 -185
- package/types/client.d.ts +112 -10
- package/types/constants.d.ts +2 -1
- package/types/frames/assets-tier.d.ts +2 -2
- package/types/frames/client.d.ts +8 -3
- package/types/frames/frame-client.d.ts +121 -157
- package/types/frames/frame-morph.d.ts +28 -0
- package/types/frames/frame-sink.d.ts +13 -9
- package/types/frames/frame-transport.d.ts +30 -1
- package/types/frames/regions-tier.d.ts +15 -0
- package/types/frames/serializer-decode.d.ts +2 -2
- package/types/frames/server.d.ts +1 -53
- package/types/frames/wire-tier.d.ts +54 -1
- package/types/head.d.ts +1 -0
- package/types/index.d.ts +57 -50
- package/types/index.server.d.ts +3 -27
- package/types/jsx.d.ts +14 -17
- package/types/observe.d.ts +14 -7
- package/types/render.d.ts +3 -1
- package/types/response.d.ts +31 -8
- package/types/serializer-decode.d.ts +2 -2
- package/types/server-functions/argument-codec.d.ts +21 -0
- package/types/server-functions/client.d.ts +18 -5
- package/types/server-functions/server.d.ts +6 -2
- package/types/server-functions/shared.d.ts +19 -0
- package/types/server-mock.d.ts +9 -2
- package/types/server-observe.d.ts +3 -2
- package/types/server.d.ts +124 -67
- package/frames/dist/bind.dev.js +0 -326
- package/frames/dist/bind.js +0 -295
- package/types/frames/bind-tier.d.ts +0 -60
package/frames/dist/server.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { sharedConfig, ssrSanitizeError, creationStamp, ssrHandleError, runInServerComponentScope, shareAsyncIterable, getProjectionTrace } from 'solid-js/internal';
|
|
2
|
-
import {
|
|
3
|
-
import { isResponseEnvelope, renderToStream, createLiveHoles
|
|
1
|
+
import { sharedConfig, ssrSanitizeError, creationStamp, ssrHandleError, runInServerComponentScope, trackFillReads, shareAsyncIterable, getProjectionTrace } from 'solid-js/internal';
|
|
2
|
+
import { getOwner, NoHydration, runWithOwner, createMemo, createOwner, Hydration } from 'solid-js';
|
|
3
|
+
import { isResponseEnvelope, renderToStream, createLiveHoles } from '@solidjs/web';
|
|
4
4
|
import { Feature, createStream, toCrossJSONStream } from 'seroval';
|
|
5
5
|
import { AbortSignalPlugin, CustomEventPlugin, DOMExceptionPlugin, EventPlugin, FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin } from 'seroval-plugins/web';
|
|
6
|
-
import {
|
|
6
|
+
import { frameAddress, getEventServerFunctionInvocation, ChunkReader, serializeStream, guardFailures, armLiveBody, createEventChunk, createChunk, textDigest } from '@solidjs/web/server-functions/server';
|
|
7
7
|
|
|
8
8
|
const DESCEND = Symbol("descend");
|
|
9
9
|
const CYCLE = {};
|
|
@@ -132,9 +132,7 @@ function toBorderForm(value, envelopeContainers) {
|
|
|
132
132
|
}
|
|
133
133
|
function isShareableIterable(value) {
|
|
134
134
|
try {
|
|
135
|
-
|
|
136
|
-
if (typeof ReadableStream !== "undefined" && value instanceof ReadableStream) return false;
|
|
137
|
-
return typeof value[Symbol.asyncIterator] === "function";
|
|
135
|
+
return typeof value[Symbol.asyncIterator] === "function" && !(typeof ReadableStream !== "undefined" && value instanceof ReadableStream);
|
|
138
136
|
} catch {
|
|
139
137
|
return false;
|
|
140
138
|
}
|
|
@@ -209,14 +207,16 @@ function resolveSerializerPlugins(customPlugins) {
|
|
|
209
207
|
}
|
|
210
208
|
const jsonCodecDisabledFeatures = () => Feature.RegExp;
|
|
211
209
|
const JSON_CODEC_DEPTH_LIMIT = 64;
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
210
|
+
const RESOLVED_PLUGINS = Symbol.for("solid.codec.resolvedPlugins");
|
|
211
|
+
function resolveCodecOptions(options = {}) {
|
|
212
|
+
const {
|
|
213
|
+
plugins,
|
|
214
|
+
disabledFeatures,
|
|
215
|
+
depthLimit,
|
|
216
|
+
serializeErrorStacks
|
|
217
|
+
} = options;
|
|
218
218
|
return {
|
|
219
|
-
plugins: resolveSerializerPlugins(plugins),
|
|
219
|
+
plugins: options[RESOLVED_PLUGINS] || resolveSerializerPlugins(plugins),
|
|
220
220
|
disabledFeatures: disabledFeatures === undefined ? jsonCodecDisabledFeatures() : disabledFeatures,
|
|
221
221
|
depthLimit: depthLimit === undefined ? JSON_CODEC_DEPTH_LIMIT : depthLimit,
|
|
222
222
|
serializeErrorStacks
|
|
@@ -295,8 +295,17 @@ function createJSONSerializer({
|
|
|
295
295
|
function records() {
|
|
296
296
|
return undefined;
|
|
297
297
|
}
|
|
298
|
-
function
|
|
299
|
-
|
|
298
|
+
function frameRecordCensus(event, message, own) {
|
|
299
|
+
const r = message.r;
|
|
300
|
+
let counted = !r;
|
|
301
|
+
for (const key in r) {
|
|
302
|
+
if (key === ":complete" || key === ":bound") continue;
|
|
303
|
+
counted = true;
|
|
304
|
+
countEvent(event, key === "" ? "html" : key.endsWith(":error") ? "error" : key.startsWith("slot:") ? "slot" : key.startsWith("seg:") && r[key] && r[key].kind === "html" ? "fragment" : key, own);
|
|
305
|
+
}
|
|
306
|
+
if (counted) event.chunks++;
|
|
307
|
+
}
|
|
308
|
+
function countEvent(event, type, own) {
|
|
300
309
|
switch (type) {
|
|
301
310
|
case "html":
|
|
302
311
|
if (!own) event.regions++;else if (event.shellMs === undefined) event.shellMs = performance.now() - event.at;
|
|
@@ -331,9 +340,8 @@ function observeFrame(frame) {
|
|
|
331
340
|
};
|
|
332
341
|
let settled = false;
|
|
333
342
|
return {
|
|
334
|
-
chunk(
|
|
335
|
-
|
|
336
|
-
frameCensus(event, chunk.type, chunk.id === frame.id);
|
|
343
|
+
chunk(message) {
|
|
344
|
+
frameRecordCensus(event, message, message.id === frame.id);
|
|
337
345
|
},
|
|
338
346
|
settle(outcome, error) {
|
|
339
347
|
if (settled) return;
|
|
@@ -486,14 +494,41 @@ function createFrameSink(write, frame, have, hooks) {
|
|
|
486
494
|
} = frame;
|
|
487
495
|
const tiers = new Set();
|
|
488
496
|
let staged = [];
|
|
489
|
-
const
|
|
490
|
-
if (swept) swept.emitted = true;
|
|
497
|
+
const send = message => {
|
|
491
498
|
if (staged.length) {
|
|
492
|
-
|
|
499
|
+
message.tiers = staged;
|
|
493
500
|
staged = [];
|
|
494
501
|
}
|
|
495
|
-
write(
|
|
502
|
+
write(message);
|
|
496
503
|
};
|
|
504
|
+
let queue = [];
|
|
505
|
+
let open = null;
|
|
506
|
+
let scheduled = false;
|
|
507
|
+
const flush = () => {
|
|
508
|
+
scheduled = false;
|
|
509
|
+
open = null;
|
|
510
|
+
const out = queue;
|
|
511
|
+
queue = [];
|
|
512
|
+
for (const message of out) send(message);
|
|
513
|
+
};
|
|
514
|
+
const put = (fid, r) => {
|
|
515
|
+
if (swept) swept.emitted = true;
|
|
516
|
+
showing(r);
|
|
517
|
+
let merge = open && open.id === fid;
|
|
518
|
+
if (merge) for (const key in r) if (key in open.r) merge = false;
|
|
519
|
+
if (merge) Object.assign(open.r, r);else queue.push(open = {
|
|
520
|
+
id: fid,
|
|
521
|
+
version,
|
|
522
|
+
r
|
|
523
|
+
});
|
|
524
|
+
if (!scheduled) {
|
|
525
|
+
scheduled = true;
|
|
526
|
+
queueMicrotask(flush);
|
|
527
|
+
}
|
|
528
|
+
};
|
|
529
|
+
const putError = (fid, key, error) => put(fid, {
|
|
530
|
+
[key ? `${/^lha?:/.test(key) ? "hole" : "seg"}:${key}:error` : ":error"]: error
|
|
531
|
+
});
|
|
497
532
|
const needs = name => {
|
|
498
533
|
if (!tiers.has(name)) {
|
|
499
534
|
tiers.add(name);
|
|
@@ -503,36 +538,44 @@ function createFrameSink(write, frame, have, hooks) {
|
|
|
503
538
|
let conditional = false;
|
|
504
539
|
const skipped = new Set();
|
|
505
540
|
const attrText = new Map();
|
|
506
|
-
const
|
|
507
|
-
|
|
541
|
+
const holeDigest = new Map();
|
|
542
|
+
if (have) for (const key in have) key.startsWith("lh:") && holeDigest.set(key, have[key]);
|
|
543
|
+
function showing(r) {
|
|
544
|
+
if ("" in r) holeDigest.clear();
|
|
545
|
+
for (const k in r) {
|
|
546
|
+
const record = r[k];
|
|
547
|
+
if (k.startsWith("hole:lh:") && !k.endsWith(":error")) holeDigest.set(k.slice(5), record.digest);
|
|
548
|
+
if (record) for (const key in record.holes) key.startsWith("lh:") && holeDigest.set(key, record.holes[key]);
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
const html = (value, digest, holes) => withHoles({
|
|
552
|
+
kind: "html",
|
|
553
|
+
value,
|
|
554
|
+
digest
|
|
555
|
+
}, holes);
|
|
556
|
+
const emitDiffering = source => {
|
|
557
|
+
for (const m of source.matchAll(HOLE_RANGE)) {
|
|
508
558
|
const key = "lh:" + m[1];
|
|
509
559
|
const digest = textDigest(stripHoleMarkers(m[2]));
|
|
510
560
|
if (have[key] === digest) continue;
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
version,
|
|
515
|
-
key,
|
|
516
|
-
html: m[2],
|
|
517
|
-
digest
|
|
518
|
-
}, holeDigests(m[2], null)));
|
|
561
|
+
put(id, {
|
|
562
|
+
["hole:" + key]: html(m[2], digest, holeDigests(m[2], null))
|
|
563
|
+
});
|
|
519
564
|
}
|
|
520
|
-
for (const m of
|
|
565
|
+
for (const m of source.matchAll(ATTR_ADDRESS)) {
|
|
521
566
|
const text = attrText.get("lha:" + m[1]);
|
|
522
567
|
if (text === undefined) continue;
|
|
523
568
|
const digest = textDigest(text);
|
|
524
569
|
if (have["lha:" + m[1]] === digest) continue;
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
digest
|
|
570
|
+
put(id, {
|
|
571
|
+
["attr:" + m[1]]: {
|
|
572
|
+
kind: "attrs",
|
|
573
|
+
value: text,
|
|
574
|
+
digest
|
|
575
|
+
}
|
|
532
576
|
});
|
|
533
577
|
}
|
|
534
578
|
};
|
|
535
|
-
const styledKeys = new Set();
|
|
536
579
|
const bindings = new Map();
|
|
537
580
|
const sweepMinted = new Set();
|
|
538
581
|
const argRefVersions = new Map();
|
|
@@ -543,34 +586,27 @@ function createFrameSink(write, frame, have, hooks) {
|
|
|
543
586
|
const sweep = () => {
|
|
544
587
|
epoch++;
|
|
545
588
|
const pass = swept = {
|
|
546
|
-
|
|
589
|
+
r: {},
|
|
547
590
|
emitted: false
|
|
548
591
|
};
|
|
549
592
|
try {
|
|
550
|
-
for (const b of [...bindings
|
|
593
|
+
for (const [key, b] of [...bindings]) {
|
|
594
|
+
if (bindings.get(key) !== b) continue;
|
|
551
595
|
try {
|
|
552
596
|
b.sweep();
|
|
553
597
|
} catch (_) {
|
|
554
598
|
}
|
|
555
599
|
}
|
|
556
|
-
|
|
600
|
+
for (const _ in pass.r) {
|
|
601
|
+
put(id, pass.r);
|
|
602
|
+
break;
|
|
603
|
+
}
|
|
604
|
+
flush();
|
|
557
605
|
if (pass.emitted && hooks && hooks.onYield) hooks.onYield();
|
|
558
606
|
} finally {
|
|
559
607
|
swept = null;
|
|
560
608
|
}
|
|
561
609
|
};
|
|
562
|
-
const emitOps = ops => {
|
|
563
|
-
if (ops.length === 1) emit(Object.assign({
|
|
564
|
-
type: ops[0].type,
|
|
565
|
-
id,
|
|
566
|
-
version
|
|
567
|
-
}, ops[0]));else if (ops.length) emit({
|
|
568
|
-
type: "ops",
|
|
569
|
-
id,
|
|
570
|
-
version,
|
|
571
|
-
ops
|
|
572
|
-
});
|
|
573
|
-
};
|
|
574
610
|
const scheduleSweep = () => {
|
|
575
611
|
if (closed || sweepScheduled || !bindings.size) return;
|
|
576
612
|
sweepScheduled = true;
|
|
@@ -585,52 +621,47 @@ function createFrameSink(write, frame, have, hooks) {
|
|
|
585
621
|
tagRegion(key, childId) {
|
|
586
622
|
if (!regionKeys.has(key)) regionKeys.set(key, childId);
|
|
587
623
|
},
|
|
588
|
-
shell(
|
|
589
|
-
const digest = textDigest(frameSkeleton(
|
|
624
|
+
shell(source, meta = {}) {
|
|
625
|
+
const digest = textDigest(frameSkeleton(source));
|
|
590
626
|
if (have && have[""] === digest) {
|
|
591
627
|
conditional = true;
|
|
592
|
-
emitDiffering(
|
|
628
|
+
emitDiffering(source);
|
|
593
629
|
return;
|
|
594
630
|
}
|
|
595
631
|
if (meta.preloads && meta.preloads.size || meta.preloadLinks) {
|
|
596
|
-
const
|
|
597
|
-
type: "assets",
|
|
598
|
-
id,
|
|
599
|
-
version,
|
|
600
|
-
key: ""
|
|
601
|
-
};
|
|
632
|
+
const record = {};
|
|
602
633
|
if (meta.preloads && meta.preloads.size) {
|
|
603
634
|
const styles = [];
|
|
604
635
|
const modules = [];
|
|
605
636
|
for (const url of meta.preloads) {
|
|
606
637
|
(url.endsWith(".css") ? styles : modules).push(url);
|
|
607
638
|
}
|
|
608
|
-
if (styles.length)
|
|
609
|
-
if (modules.length)
|
|
639
|
+
if (styles.length) record.styles = styles;
|
|
640
|
+
if (modules.length) record.modules = modules;
|
|
610
641
|
}
|
|
611
642
|
if (meta.preloadLinks) {
|
|
612
|
-
|
|
643
|
+
record.preloads = [];
|
|
613
644
|
for (const entry of meta.preloadLinks) {
|
|
614
|
-
|
|
645
|
+
record.preloads.push(wirePreload(entry));
|
|
615
646
|
}
|
|
616
647
|
}
|
|
617
648
|
needs("assets");
|
|
618
|
-
|
|
649
|
+
put(id, {
|
|
650
|
+
"seg::assets": record
|
|
651
|
+
});
|
|
619
652
|
}
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
version,
|
|
624
|
-
html,
|
|
625
|
-
digest
|
|
626
|
-
}, holeDigests(html, attrText)));
|
|
653
|
+
put(id, {
|
|
654
|
+
"": html(source, digest, holeDigests(source, attrText))
|
|
655
|
+
});
|
|
627
656
|
},
|
|
628
657
|
data(record) {
|
|
629
658
|
if (record && typeof record.key === "string" && (record.key.endsWith("_fr") || /^\d+$/.test(record.key))) {
|
|
630
659
|
return;
|
|
631
660
|
}
|
|
661
|
+
if (swept) swept.emitted = true;
|
|
662
|
+
flush();
|
|
632
663
|
if (typeof record === "string") {
|
|
633
|
-
|
|
664
|
+
send({
|
|
634
665
|
type: "data",
|
|
635
666
|
id,
|
|
636
667
|
version,
|
|
@@ -638,7 +669,7 @@ function createFrameSink(write, frame, have, hooks) {
|
|
|
638
669
|
});
|
|
639
670
|
scheduleSweep();
|
|
640
671
|
} else {
|
|
641
|
-
|
|
672
|
+
send({
|
|
642
673
|
type: "data",
|
|
643
674
|
id,
|
|
644
675
|
version,
|
|
@@ -655,73 +686,40 @@ function createFrameSink(write, frame, have, hooks) {
|
|
|
655
686
|
skipped.add(key);
|
|
656
687
|
scheduleSweep();
|
|
657
688
|
if (meta.error) {
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
id: fid,
|
|
661
|
-
version,
|
|
662
|
-
key,
|
|
663
|
-
error: {
|
|
664
|
-
message: String(meta.error && meta.error.message || meta.error)
|
|
665
|
-
}
|
|
689
|
+
putError(fid, key, {
|
|
690
|
+
message: String(meta.error && meta.error.message || meta.error)
|
|
666
691
|
});
|
|
667
692
|
} else emitDiffering(value);
|
|
668
693
|
return;
|
|
669
694
|
}
|
|
670
695
|
const links = meta.styles && meta.styles.links || [];
|
|
671
696
|
const inline = meta.styles && meta.styles.inline || [];
|
|
697
|
+
const r = {};
|
|
672
698
|
if (links.length || inline.length) {
|
|
673
|
-
|
|
674
|
-
const chunk = {
|
|
675
|
-
type: "assets",
|
|
676
|
-
id: fid,
|
|
677
|
-
version,
|
|
678
|
-
key
|
|
679
|
-
};
|
|
699
|
+
const record = {};
|
|
680
700
|
if (links.length) {
|
|
681
|
-
|
|
701
|
+
record.styles = links.map(e => typeof e === "string" ? e : e.attrs ? {
|
|
682
702
|
href: e.href,
|
|
683
703
|
attrs: e.attrs
|
|
684
704
|
} : e.href);
|
|
685
705
|
}
|
|
686
706
|
if (inline.length) {
|
|
687
|
-
|
|
707
|
+
record.inlineStyles = inline.map(e => ({
|
|
688
708
|
id: e.id,
|
|
689
709
|
content: e.content,
|
|
690
710
|
attrs: e.attrs
|
|
691
711
|
}));
|
|
692
712
|
}
|
|
693
713
|
needs("assets");
|
|
694
|
-
|
|
714
|
+
r[`seg:${key}:assets`] = record;
|
|
695
715
|
}
|
|
696
|
-
|
|
697
|
-
type: "fragment",
|
|
698
|
-
id: fid,
|
|
699
|
-
version,
|
|
700
|
-
key,
|
|
701
|
-
html: value,
|
|
702
|
-
digest: textDigest(value)
|
|
703
|
-
}, holeDigests(value, attrText)));
|
|
716
|
+
r[`seg:${key}`] = html(value, textDigest(value), holeDigests(value, attrText));
|
|
704
717
|
scheduleSweep();
|
|
705
|
-
if (meta.error) {
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
key,
|
|
711
|
-
error: {
|
|
712
|
-
message: String(meta.error && meta.error.message || meta.error)
|
|
713
|
-
}
|
|
714
|
-
});
|
|
715
|
-
}
|
|
716
|
-
if (!meta.revealGroup) {
|
|
717
|
-
emit({
|
|
718
|
-
type: "reveal",
|
|
719
|
-
id: fid,
|
|
720
|
-
version,
|
|
721
|
-
keys: [key],
|
|
722
|
-
waitForStyles: !!links.length
|
|
723
|
-
});
|
|
724
|
-
}
|
|
718
|
+
if (meta.error) r[`seg:${key}:error`] = {
|
|
719
|
+
message: String(meta.error && meta.error.message || meta.error)
|
|
720
|
+
};
|
|
721
|
+
if (!meta.revealGroup) r[`seg:${key}:reveal`] = true;
|
|
722
|
+
put(fid, r);
|
|
725
723
|
},
|
|
726
724
|
reveal(keys, meta = {}) {
|
|
727
725
|
const byFrame = new Map();
|
|
@@ -732,38 +730,27 @@ function createFrameSink(write, frame, have, hooks) {
|
|
|
732
730
|
if (!group) byFrame.set(fid, group = []);
|
|
733
731
|
group.push(key);
|
|
734
732
|
}
|
|
733
|
+
const gate = meta.fallback ? "fallback" : "reveal";
|
|
735
734
|
for (const [fid, groupKeys] of byFrame) {
|
|
736
|
-
|
|
737
|
-
for (const key of groupKeys)
|
|
738
|
-
|
|
739
|
-
type: "reveal",
|
|
740
|
-
id: fid,
|
|
741
|
-
version,
|
|
742
|
-
keys: groupKeys,
|
|
743
|
-
waitForStyles
|
|
744
|
-
};
|
|
745
|
-
if (meta.fallback) chunk.fallback = true;
|
|
746
|
-
emit(chunk);
|
|
735
|
+
const r = {};
|
|
736
|
+
for (const key of groupKeys) r[`seg:${key}:${gate}`] = true;
|
|
737
|
+
put(fid, r);
|
|
747
738
|
}
|
|
748
739
|
},
|
|
749
740
|
asset(type, value) {
|
|
750
741
|
if (type === "module") {
|
|
751
742
|
needs("assets");
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
key: "",
|
|
757
|
-
modules: [value]
|
|
743
|
+
put(id, {
|
|
744
|
+
"seg::assets": {
|
|
745
|
+
modules: [value]
|
|
746
|
+
}
|
|
758
747
|
});
|
|
759
748
|
} else if (type === "preload") {
|
|
760
749
|
needs("assets");
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
key: "",
|
|
766
|
-
preloads: [wirePreload(value)]
|
|
750
|
+
put(id, {
|
|
751
|
+
"seg::assets": {
|
|
752
|
+
preloads: [wirePreload(value)]
|
|
753
|
+
}
|
|
767
754
|
});
|
|
768
755
|
}
|
|
769
756
|
},
|
|
@@ -771,64 +758,69 @@ function createFrameSink(write, frame, have, hooks) {
|
|
|
771
758
|
if (closed) return;
|
|
772
759
|
if (bindings.size && !swept) sweep();
|
|
773
760
|
closed = true;
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
761
|
+
put(id, bound ? {
|
|
762
|
+
":complete": true,
|
|
763
|
+
":bound": bound
|
|
764
|
+
} : {
|
|
765
|
+
":complete": true
|
|
766
|
+
});
|
|
767
|
+
flush();
|
|
781
768
|
},
|
|
782
769
|
error(errorId, error) {
|
|
783
|
-
|
|
784
|
-
type: "error",
|
|
785
|
-
id,
|
|
786
|
-
version,
|
|
787
|
-
key: errorId,
|
|
788
|
-
error
|
|
789
|
-
});
|
|
770
|
+
putError(id, errorId, error);
|
|
790
771
|
},
|
|
772
|
+
flush,
|
|
791
773
|
slot(key, args) {
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
args
|
|
774
|
+
put(id, {
|
|
775
|
+
[`slot:${key}`]: {
|
|
776
|
+
kind: "slot",
|
|
777
|
+
args
|
|
778
|
+
}
|
|
798
779
|
});
|
|
799
780
|
},
|
|
800
|
-
region(childId,
|
|
781
|
+
region(childId, value) {
|
|
801
782
|
needs("regions");
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
783
|
+
put(childId, {
|
|
784
|
+
"": {
|
|
785
|
+
kind: "html",
|
|
786
|
+
value
|
|
787
|
+
}
|
|
807
788
|
});
|
|
808
789
|
},
|
|
809
|
-
hole(key,
|
|
810
|
-
const
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
html,
|
|
814
|
-
digest: textDigest(html)
|
|
790
|
+
hole(key, source, rows) {
|
|
791
|
+
const record = {
|
|
792
|
+
kind: "html",
|
|
793
|
+
digest: textDigest(source)
|
|
815
794
|
};
|
|
816
|
-
|
|
795
|
+
const base = holeDigest.get(key);
|
|
796
|
+
if (rows && base && hooks && hooks.live) {
|
|
797
|
+
record.rows = rows;
|
|
798
|
+
record.base = base;
|
|
799
|
+
} else record.value = source;
|
|
800
|
+
withHoles(record, holeDigests(record.rows ? rows.r.map(r => r[1]).join("") : source, null));
|
|
801
|
+
const r = {
|
|
802
|
+
["hole:" + key]: record
|
|
803
|
+
};
|
|
804
|
+
showing(r);
|
|
805
|
+
swept ? Object.assign(swept.r, r) : put(id, r);
|
|
817
806
|
},
|
|
818
807
|
attr(key, attrs, removed) {
|
|
819
|
-
const
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
attrs,
|
|
808
|
+
const record = {
|
|
809
|
+
kind: "attrs",
|
|
810
|
+
value: attrs,
|
|
823
811
|
digest: textDigest(attrs)
|
|
824
812
|
};
|
|
825
|
-
if (removed && removed.length)
|
|
826
|
-
|
|
813
|
+
if (removed && removed.length) record.removed = removed;
|
|
814
|
+
const r = {
|
|
815
|
+
["attr:" + key]: record
|
|
816
|
+
};
|
|
817
|
+
swept ? Object.assign(swept.r, r) : put(id, r);
|
|
827
818
|
},
|
|
828
819
|
attrBaseline(key, text) {
|
|
829
820
|
attrText.set(key, text);
|
|
830
821
|
},
|
|
831
822
|
openBinding(key, b) {
|
|
823
|
+
if (/^lha?:/.test(key)) needs("wire");
|
|
832
824
|
bindings.set(key, b);
|
|
833
825
|
},
|
|
834
826
|
closeBinding(key) {
|
|
@@ -853,9 +845,6 @@ function createFrameSink(write, frame, have, hooks) {
|
|
|
853
845
|
}
|
|
854
846
|
};
|
|
855
847
|
}
|
|
856
|
-
function renderToFrameStream(code, options = {}) {
|
|
857
|
-
return frameStream(() => code, options);
|
|
858
|
-
}
|
|
859
848
|
function renderServerComponent(component, options = {}) {
|
|
860
849
|
return frameStream((sink, frame) => {
|
|
861
850
|
const props = createSlotProps(sink, frame);
|
|
@@ -864,8 +853,9 @@ function renderServerComponent(component, options = {}) {
|
|
|
864
853
|
if (ctx) {
|
|
865
854
|
ctx.commit = sink.commit;
|
|
866
855
|
ctx.commitEpoch = () => sink.epoch;
|
|
867
|
-
|
|
868
|
-
ctx.
|
|
856
|
+
let unsettled = !!options.live;
|
|
857
|
+
if (!unsettled) ctx.unsettled = () => void (unsettled = true);
|
|
858
|
+
ctx.liveHoles = createLiveHoles(sink, false, () => !unsettled, ctx._errorScope);
|
|
869
859
|
}
|
|
870
860
|
return serverComponentScope(() => component(props));
|
|
871
861
|
};
|
|
@@ -898,6 +888,7 @@ function frameStream(makeCode, options) {
|
|
|
898
888
|
function finish() {
|
|
899
889
|
if (ended) return;
|
|
900
890
|
ended = true;
|
|
891
|
+
sink.flush();
|
|
901
892
|
if (timer) clearTimeout(timer);
|
|
902
893
|
if (upstream) upstream.removeEventListener("abort", onSignal);
|
|
903
894
|
w.end && w.end();
|
|
@@ -918,19 +909,20 @@ function frameStream(makeCode, options) {
|
|
|
918
909
|
finish();
|
|
919
910
|
render.abort(upstream.reason);
|
|
920
911
|
}
|
|
921
|
-
const emit =
|
|
922
|
-
if (observation) observation.chunk(
|
|
923
|
-
w.write(
|
|
924
|
-
if (bounded && !flushed &&
|
|
912
|
+
const emit = message => {
|
|
913
|
+
if (observation) observation.chunk(message);
|
|
914
|
+
w.write(message);
|
|
915
|
+
if (bounded && !flushed && message.id === id && message.r && "" in message.r) {
|
|
925
916
|
flushed = true;
|
|
926
917
|
if (maxDurationMs > 0 && maxDurationMs !== Infinity) timer = setTimeout(() => cut("time"), maxDurationMs);
|
|
927
918
|
}
|
|
928
919
|
};
|
|
929
|
-
const sink = createFrameSink(emit, frame, options.resume && options.resume.have,
|
|
930
|
-
|
|
920
|
+
const sink = createFrameSink(emit, frame, options.resume && options.resume.have, {
|
|
921
|
+
live: options.live,
|
|
922
|
+
onYield: bounded ? () => {
|
|
931
923
|
if (flushed && maxYields > 0 && ++yields >= maxYields) cut("yields");
|
|
932
|
-
}
|
|
933
|
-
}
|
|
924
|
+
} : undefined
|
|
925
|
+
});
|
|
934
926
|
if (options.live) sink.needs("wire");
|
|
935
927
|
w.write({
|
|
936
928
|
type: "start",
|
|
@@ -965,6 +957,7 @@ function frameStream(makeCode, options) {
|
|
|
965
957
|
finish();
|
|
966
958
|
}
|
|
967
959
|
if (w[ANNOUNCE]) w[ANNOUNCE](sink.announce());
|
|
960
|
+
sink.flush();
|
|
968
961
|
}
|
|
969
962
|
return {
|
|
970
963
|
pipe: stream,
|
|
@@ -986,56 +979,21 @@ function frameStream(makeCode, options) {
|
|
|
986
979
|
function slotRange(occurrence) {
|
|
987
980
|
return {
|
|
988
981
|
t: `<!--slot:${occurrence}:start--><!--slot:${occurrence}:end-->`,
|
|
989
|
-
$slot: true
|
|
990
|
-
$occurrence: occurrence
|
|
982
|
+
$slot: true
|
|
991
983
|
};
|
|
992
984
|
}
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
function isRangeKey(key) {
|
|
996
|
-
const c = key.charCodeAt(0);
|
|
997
|
-
return c === 36 || c >= 48 && c <= 57 || RANGE_KEYS.has(key);
|
|
998
|
-
}
|
|
999
|
-
function slotProxy(range, occurrence, face, content, onData, needs) {
|
|
1000
|
-
return new Proxy(range, {
|
|
1001
|
-
get(target, key, receiver) {
|
|
1002
|
-
if (typeof key !== "string" || isRangeKey(key)) return Reflect.get(target, key, receiver);
|
|
1003
|
-
if (onData) onData = void onData();
|
|
1004
|
-
if (face !== SLOT_FACE_MARKUP) needs("bind");
|
|
1005
|
-
return slotValue(occurrence, key, content ? content[key] : undefined, face);
|
|
1006
|
-
}
|
|
1007
|
-
});
|
|
1008
|
-
}
|
|
1009
|
-
function argBorderForm(value, key, occurrence, needs) {
|
|
1010
|
-
return toBorderForm(withoutStandIns(value, key, occurrence, needs));
|
|
985
|
+
function argBorderForm(value, needs) {
|
|
986
|
+
return toBorderForm(noteTraces(value, needs));
|
|
1011
987
|
}
|
|
1012
|
-
function
|
|
1013
|
-
return rewriteTree(value,
|
|
988
|
+
function noteTraces(value, needs) {
|
|
989
|
+
return rewriteTree(value, v => {
|
|
1014
990
|
if (isContainerTraced(v)) {
|
|
1015
991
|
needs("trace");
|
|
1016
992
|
return v;
|
|
1017
993
|
}
|
|
1018
|
-
if (Object.getPrototypeOf(v) === Object.prototype && isSlotValue(v)) {
|
|
1019
|
-
return undefined;
|
|
1020
|
-
}
|
|
1021
994
|
return DESCEND;
|
|
1022
995
|
}, true);
|
|
1023
996
|
}
|
|
1024
|
-
function slotFace(range, content) {
|
|
1025
|
-
if (content == null) return SLOT_FACE_DATA;
|
|
1026
|
-
if (typeof content !== "object" || Array.isArray(content)) return SLOT_FACE_MARKUP;
|
|
1027
|
-
if (isServerContent(content)) {
|
|
1028
|
-
let data = false;
|
|
1029
|
-
for (const key in content) {
|
|
1030
|
-
if (!NODE_KEYS.has(key)) {
|
|
1031
|
-
data = true;
|
|
1032
|
-
break;
|
|
1033
|
-
}
|
|
1034
|
-
}
|
|
1035
|
-
if (!data) return SLOT_FACE_MARKUP;
|
|
1036
|
-
}
|
|
1037
|
-
return SLOT_FACE_DATA;
|
|
1038
|
-
}
|
|
1039
997
|
const OCCURRENCE_UNSAFE = /[^A-Za-z0-9_.-]/g;
|
|
1040
998
|
function encodeOccurrenceKey(key) {
|
|
1041
999
|
return String(key).replace(OCCURRENCE_UNSAFE, c => {
|
|
@@ -1090,12 +1048,19 @@ function structuralArgsKey(raw) {
|
|
|
1090
1048
|
};
|
|
1091
1049
|
return walk(raw, true) ? out : undefined;
|
|
1092
1050
|
}
|
|
1093
|
-
function
|
|
1094
|
-
const
|
|
1095
|
-
if (
|
|
1096
|
-
|
|
1097
|
-
|
|
1051
|
+
function argDigest(value) {
|
|
1052
|
+
const t = typeof value;
|
|
1053
|
+
if (value == null || t !== "object" && t !== "function" && value === value) return value;
|
|
1054
|
+
if (isContainerTraced(value)) return value;
|
|
1055
|
+
try {
|
|
1056
|
+
const key = structuralArgsKey([value]);
|
|
1057
|
+
return key === undefined ? value : key;
|
|
1058
|
+
} catch (_) {
|
|
1059
|
+
return value;
|
|
1060
|
+
}
|
|
1098
1061
|
}
|
|
1062
|
+
const PENDING_ARG = {};
|
|
1063
|
+
const noDigest = () => NaN;
|
|
1099
1064
|
function isAsyncValue(v) {
|
|
1100
1065
|
return !!v && typeof v === "object" && (typeof v.then === "function" || typeof v[Symbol.asyncIterator] === "function");
|
|
1101
1066
|
}
|
|
@@ -1111,6 +1076,37 @@ function tapFirstYield(iterable) {
|
|
|
1111
1076
|
rest
|
|
1112
1077
|
};
|
|
1113
1078
|
}
|
|
1079
|
+
function packOccurrences(occs) {
|
|
1080
|
+
const out = [];
|
|
1081
|
+
let prop = "",
|
|
1082
|
+
a = -1,
|
|
1083
|
+
b = -1;
|
|
1084
|
+
const flush = () => a >= 0 && out.push(prop + "#" + (a === b ? a : a + "-" + b));
|
|
1085
|
+
for (const o of occs) {
|
|
1086
|
+
const m = /^(.*)#(\d+)$/.exec(o);
|
|
1087
|
+
if (m && m[1] === prop && +m[2] === b + 1 && a >= 0) {
|
|
1088
|
+
b++;
|
|
1089
|
+
continue;
|
|
1090
|
+
}
|
|
1091
|
+
flush();
|
|
1092
|
+
a = b = -1;
|
|
1093
|
+
if (m) {
|
|
1094
|
+
prop = m[1];
|
|
1095
|
+
a = b = +m[2];
|
|
1096
|
+
} else out.push(o);
|
|
1097
|
+
}
|
|
1098
|
+
flush();
|
|
1099
|
+
return out.join(" ");
|
|
1100
|
+
}
|
|
1101
|
+
function hasAsyncHoles(node, depth = 0) {
|
|
1102
|
+
if (!node || typeof node !== "object" || depth > 64) return false;
|
|
1103
|
+
if (Array.isArray(node)) {
|
|
1104
|
+
for (const n of node) if (hasAsyncHoles(n, depth + 1)) return true;
|
|
1105
|
+
return false;
|
|
1106
|
+
}
|
|
1107
|
+
if (node.h && node.h.length) return true;
|
|
1108
|
+
return false;
|
|
1109
|
+
}
|
|
1114
1110
|
function suppressedFill(render) {
|
|
1115
1111
|
const live = sharedConfig.context && sharedConfig.context.liveHoles;
|
|
1116
1112
|
if (!live) return render();
|
|
@@ -1121,25 +1117,96 @@ function suppressedFill(render) {
|
|
|
1121
1117
|
live.suppressed--;
|
|
1122
1118
|
}
|
|
1123
1119
|
}
|
|
1120
|
+
let parked = null;
|
|
1121
|
+
let parkedIds = 0;
|
|
1122
|
+
const PARKED = /<!--sc-n:(\d+)-->/;
|
|
1123
|
+
function park(render) {
|
|
1124
|
+
if (!parked) return render();
|
|
1125
|
+
const id = ++parkedIds;
|
|
1126
|
+
parked.set(id, {
|
|
1127
|
+
render,
|
|
1128
|
+
out: undefined
|
|
1129
|
+
});
|
|
1130
|
+
return {
|
|
1131
|
+
t: `<!--sc-n:${id}-->`
|
|
1132
|
+
};
|
|
1133
|
+
}
|
|
1134
|
+
const runParked = (entry, owner) => entry.out || (entry.out = entry.render(owner));
|
|
1135
|
+
function placeParked(node, nested, owner) {
|
|
1136
|
+
const out = expandParked(node, nested, owner);
|
|
1137
|
+
for (const entry of nested.values()) runParked(entry, owner);
|
|
1138
|
+
return out;
|
|
1139
|
+
}
|
|
1140
|
+
function expandParked(node, nested, owner) {
|
|
1141
|
+
if (Array.isArray(node)) {
|
|
1142
|
+
const out = node.map(n => expandParked(n, nested, owner));
|
|
1143
|
+
out.$slot = node.$slot;
|
|
1144
|
+
return out;
|
|
1145
|
+
}
|
|
1146
|
+
if (!node || node.t === undefined) return node;
|
|
1147
|
+
if (!node.h) return splitParked(node.t, nested, owner) || node;
|
|
1148
|
+
const out = [];
|
|
1149
|
+
node.t.forEach((t, i) => {
|
|
1150
|
+
out.push(splitParked(t, nested, owner) || {
|
|
1151
|
+
t
|
|
1152
|
+
});
|
|
1153
|
+
if (i < node.h.length) out.push({
|
|
1154
|
+
t: ["", ""],
|
|
1155
|
+
h: [node.h[i]],
|
|
1156
|
+
p: [node.p[i]]
|
|
1157
|
+
});
|
|
1158
|
+
});
|
|
1159
|
+
return out;
|
|
1160
|
+
}
|
|
1161
|
+
function splitParked(t, nested, owner) {
|
|
1162
|
+
const parts = typeof t === "string" ? t.split(PARKED) : [t];
|
|
1163
|
+
return parts.length > 1 ? parts.map((part, i) => i & 1 ? runParked(nested.get(+part), owner) : {
|
|
1164
|
+
t: part
|
|
1165
|
+
}) : undefined;
|
|
1166
|
+
}
|
|
1124
1167
|
function createDocumentSlotProps(clientProps, frameId) {
|
|
1125
1168
|
const counts = Object.create(null);
|
|
1169
|
+
let depsBatch = null;
|
|
1170
|
+
let depsN = 0;
|
|
1171
|
+
let wideSent = 0;
|
|
1172
|
+
const depsContext = sharedConfig.context;
|
|
1173
|
+
const noteDeps = (occurrence, reads, untracked) => {
|
|
1174
|
+
if (!depsContext || !depsContext.serialize || !depsContext.edges) return;
|
|
1175
|
+
const own = `sc-${frameId}-${occurrence}-`;
|
|
1176
|
+
const batch = () => {
|
|
1177
|
+
if (depsBatch) return depsBatch;
|
|
1178
|
+
queueMicrotask(() => {
|
|
1179
|
+
const b = {};
|
|
1180
|
+
for (const sid in depsBatch) b[sid] = packOccurrences(depsBatch[sid]);
|
|
1181
|
+
depsBatch = null;
|
|
1182
|
+
const wide = depsContext.edgeWide?.s || null;
|
|
1183
|
+
if (wide && wide.size > wideSent) {
|
|
1184
|
+
b["*"] = [...wide].slice(wideSent).join(" ");
|
|
1185
|
+
wideSent = wide.size;
|
|
1186
|
+
}
|
|
1187
|
+
if (depsN === 0 || Object.keys(b).length) depsContext.serialize(`sc:deps:${frameId}:${depsN++}`, b);
|
|
1188
|
+
});
|
|
1189
|
+
return depsBatch = Object.create(null);
|
|
1190
|
+
};
|
|
1191
|
+
const b = batch();
|
|
1192
|
+
if (reads) for (const sid of reads) if (!sid.startsWith(own)) (b[sid] ||= []).push(occurrence);
|
|
1193
|
+
if (untracked) (b["!"] ||= []).push(occurrence);
|
|
1194
|
+
};
|
|
1126
1195
|
const getters = new Map();
|
|
1127
1196
|
const repeats = new Map();
|
|
1128
|
-
const range = (occurrence, content) => {
|
|
1197
|
+
const range = (occurrence, content, tail) => {
|
|
1129
1198
|
const r = [{
|
|
1130
1199
|
t: `<!--slot:${occurrence}:start-->`
|
|
1131
|
-
}, content, {
|
|
1200
|
+
}, content, tail, {
|
|
1132
1201
|
t: `<!--slot:${occurrence}:end-->`
|
|
1133
1202
|
}];
|
|
1134
1203
|
r.$slot = true;
|
|
1135
|
-
r
|
|
1136
|
-
const face = slotFace(r, content);
|
|
1137
|
-
r.$face = face;
|
|
1138
|
-
return slotProxy(r, occurrence, face, face === SLOT_FACE_DATA ? content : undefined, undefined, documentNeeds);
|
|
1204
|
+
return r;
|
|
1139
1205
|
};
|
|
1140
1206
|
const zoneOwner = getOwner ? getOwner() : null;
|
|
1141
|
-
const scoped = (occurrence, render) => {
|
|
1207
|
+
const scoped = (occurrence, render, owner) => {
|
|
1142
1208
|
const id = `sc-${frameId}-${occurrence}-`;
|
|
1209
|
+
if (owner) return runWithOwner(owner, () => runWithHydrationScope(id, render));
|
|
1143
1210
|
const run = () => Hydration ? Hydration({
|
|
1144
1211
|
id,
|
|
1145
1212
|
get children() {
|
|
@@ -1159,18 +1226,13 @@ function createDocumentSlotProps(clientProps, frameId) {
|
|
|
1159
1226
|
if (!fn) {
|
|
1160
1227
|
fn = (...callArgs) => {
|
|
1161
1228
|
if (callArgs.length === 0 || callArgs[0] === undefined) {
|
|
1162
|
-
|
|
1163
|
-
const repeat = repeats.get(rk);
|
|
1164
|
-
if (repeat) return repeat;
|
|
1165
|
-
const out = suppressedFill(() => scoped(prop, () => {
|
|
1229
|
+
return park(owner => suppressedFill(() => scoped(prop, () => {
|
|
1166
1230
|
const value = clientProps[prop];
|
|
1167
1231
|
return range(prop, typeof value === "function" ? value() : value);
|
|
1168
|
-
}));
|
|
1169
|
-
if (out.$face === SLOT_FACE_DATA) repeats.set(rk, out);
|
|
1170
|
-
return out;
|
|
1232
|
+
}, owner)));
|
|
1171
1233
|
}
|
|
1172
1234
|
const raw = callArgs[0];
|
|
1173
|
-
const rk =
|
|
1235
|
+
const rk = keyedId(prop, raw);
|
|
1174
1236
|
const repeat = rk !== undefined && repeats.get(rk);
|
|
1175
1237
|
if (repeat) return repeat;
|
|
1176
1238
|
const occurrence = occurrenceId(prop, raw, counts);
|
|
@@ -1178,10 +1240,10 @@ function createDocumentSlotProps(clientProps, frameId) {
|
|
|
1178
1240
|
if (typeof slot !== "function") return range(occurrence, undefined);
|
|
1179
1241
|
const context = sharedConfig.context;
|
|
1180
1242
|
const recordKey = `sc:slot:${frameId}:${occurrence}`;
|
|
1243
|
+
const deferred = !!parked;
|
|
1181
1244
|
let settleRecord;
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
}
|
|
1245
|
+
const declare = () => context && context.async && context.serialize(recordKey, new Promise(resolve => settleRecord = resolve));
|
|
1246
|
+
deferred || declare();
|
|
1185
1247
|
try {
|
|
1186
1248
|
const resolved = {};
|
|
1187
1249
|
const liveArgs = sharedConfig.context && sharedConfig.context.live && sharedConfig.context.live.args;
|
|
@@ -1189,6 +1251,7 @@ function createDocumentSlotProps(clientProps, frameId) {
|
|
|
1189
1251
|
const evals = {};
|
|
1190
1252
|
const states = {};
|
|
1191
1253
|
const minted = {};
|
|
1254
|
+
const nestedOf = {};
|
|
1192
1255
|
for (const key of Object.keys(raw)) {
|
|
1193
1256
|
if (key === "$key") continue;
|
|
1194
1257
|
const desc = Object.getOwnPropertyDescriptor(raw, key);
|
|
@@ -1207,6 +1270,8 @@ function createDocumentSlotProps(clientProps, frameId) {
|
|
|
1207
1270
|
if (evaluate) {
|
|
1208
1271
|
evals[key] = evaluate;
|
|
1209
1272
|
const stampBefore = scopeStamp();
|
|
1273
|
+
const outer = parked;
|
|
1274
|
+
const nested = nestedOf[key] = parked = new Map();
|
|
1210
1275
|
try {
|
|
1211
1276
|
value = evaluate();
|
|
1212
1277
|
states[key] = {
|
|
@@ -1214,6 +1279,9 @@ function createDocumentSlotProps(clientProps, frameId) {
|
|
|
1214
1279
|
last: value
|
|
1215
1280
|
};
|
|
1216
1281
|
} catch (err) {
|
|
1282
|
+
parked = outer;
|
|
1283
|
+
for (const entry of nested.values()) runParked(entry);
|
|
1284
|
+
nested.clear();
|
|
1217
1285
|
const blocked = ssrHandleError && ssrHandleError(err);
|
|
1218
1286
|
if (!blocked) throw err;
|
|
1219
1287
|
const state = states[key] = {
|
|
@@ -1226,6 +1294,7 @@ function createDocumentSlotProps(clientProps, frameId) {
|
|
|
1226
1294
|
if (liveArgs) liveArgs.commit();
|
|
1227
1295
|
});
|
|
1228
1296
|
}
|
|
1297
|
+
parked = outer;
|
|
1229
1298
|
if (scopeStamp() !== stampBefore) minted[key] = true;
|
|
1230
1299
|
}
|
|
1231
1300
|
vals[key] = value;
|
|
@@ -1242,6 +1311,7 @@ function createDocumentSlotProps(clientProps, frameId) {
|
|
|
1242
1311
|
key,
|
|
1243
1312
|
childId,
|
|
1244
1313
|
value,
|
|
1314
|
+
nested: nestedOf[key],
|
|
1245
1315
|
used: false,
|
|
1246
1316
|
locked: false
|
|
1247
1317
|
};
|
|
@@ -1252,7 +1322,7 @@ function createDocumentSlotProps(clientProps, frameId) {
|
|
|
1252
1322
|
region.used = true;
|
|
1253
1323
|
return [{
|
|
1254
1324
|
t: frameElementOpen(childId)
|
|
1255
|
-
}, value, {
|
|
1325
|
+
}, region.nested && region.nested.size ? placeParked(value, region.nested, getOwner()) : value, {
|
|
1256
1326
|
t: FRAME_ELEMENT_CLOSE
|
|
1257
1327
|
}];
|
|
1258
1328
|
};
|
|
@@ -1273,49 +1343,67 @@ function createDocumentSlotProps(clientProps, frameId) {
|
|
|
1273
1343
|
configurable: true
|
|
1274
1344
|
});
|
|
1275
1345
|
} else {
|
|
1276
|
-
resolved[key] = vals[key] =
|
|
1346
|
+
resolved[key] = vals[key] = noteTraces(value, documentNeeds);
|
|
1277
1347
|
}
|
|
1278
1348
|
}
|
|
1279
|
-
const
|
|
1280
|
-
const
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
for (const
|
|
1284
|
-
|
|
1285
|
-
const region = regions.find(r => r.key === key);
|
|
1286
|
-
if (region) {
|
|
1287
|
-
args[key] = {
|
|
1288
|
-
$frame: region.childId
|
|
1289
|
-
};
|
|
1290
|
-
continue;
|
|
1291
|
-
}
|
|
1292
|
-
if (!isContainerTraced(value) && isServerContent(value)) continue;
|
|
1293
|
-
args[key] = argBorderForm(value, key, occurrence, documentNeeds);
|
|
1294
|
-
}
|
|
1295
|
-
settleRecord ? settleRecord({
|
|
1296
|
-
...args
|
|
1297
|
-
}) : context.serialize(recordKey, {
|
|
1298
|
-
...args
|
|
1299
|
-
});
|
|
1300
|
-
for (const region of unused) {
|
|
1349
|
+
for (const key in nestedOf) if (!regions.some(r => r.key === key)) for (const entry of nestedOf[key].values()) runParked(entry);
|
|
1350
|
+
const flip = () => {
|
|
1351
|
+
if (flip.done || !context) return;
|
|
1352
|
+
flip.done = true;
|
|
1353
|
+
for (const region of regions) {
|
|
1354
|
+
if (region.used) continue;
|
|
1301
1355
|
region.locked = true;
|
|
1302
|
-
context.serialize(`sc:region:${region.childId}`, resolveRegionHtml(context, region.value));
|
|
1356
|
+
context.serialize(`sc:region:${region.childId}`, resolveRegionHtml(context, region.nested && region.nested.size ? placeParked(region.value, region.nested) : region.value));
|
|
1303
1357
|
}
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1358
|
+
};
|
|
1359
|
+
flip.$lhSkip = true;
|
|
1360
|
+
const finish = owner => {
|
|
1361
|
+
if (deferred) declare();
|
|
1362
|
+
try {
|
|
1363
|
+
const tracked = trackFillReads(() => suppressedFill(() => scoped(occurrence, () => range(occurrence, slot(resolved), flip), owner)));
|
|
1364
|
+
const out = tracked.result;
|
|
1365
|
+
noteDeps(occurrence, tracked.reads, tracked.untracked || hasAsyncHoles(out));
|
|
1366
|
+
if (context) {
|
|
1367
|
+
const args = {};
|
|
1368
|
+
for (const key of Object.keys(vals)) {
|
|
1369
|
+
const value = vals[key];
|
|
1370
|
+
const region = regions.find(r => r.key === key);
|
|
1371
|
+
if (region) {
|
|
1372
|
+
args[key] = {
|
|
1373
|
+
$frame: region.childId
|
|
1374
|
+
};
|
|
1375
|
+
continue;
|
|
1376
|
+
}
|
|
1377
|
+
if (!isContainerTraced(value) && isServerContent(value)) continue;
|
|
1378
|
+
args[key] = argBorderForm(value, documentNeeds);
|
|
1379
|
+
}
|
|
1380
|
+
settleRecord ? settleRecord({
|
|
1381
|
+
...args
|
|
1382
|
+
}) : context.serialize(recordKey, {
|
|
1383
|
+
...args
|
|
1314
1384
|
});
|
|
1385
|
+
if (liveArgs) {
|
|
1386
|
+
for (const key of Object.keys(evals)) {
|
|
1387
|
+
if (regions.some(r => r.key === key)) continue;
|
|
1388
|
+
if (minted[key]) continue;
|
|
1389
|
+
const ledgerKey = `${frameId}:${occurrence}:${key}`;
|
|
1390
|
+
openArgBinding(liveArgs, ledgerKey, occurrence, key, evals[key], states[key], value => {
|
|
1391
|
+
args[key] = argBorderForm(value, documentNeeds);
|
|
1392
|
+
liveArgs.slot(frameId, occurrence, {
|
|
1393
|
+
...args
|
|
1394
|
+
});
|
|
1395
|
+
});
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1315
1398
|
}
|
|
1399
|
+
return out;
|
|
1400
|
+
} catch (error) {
|
|
1401
|
+
settleRecord && settleRecord(undefined);
|
|
1402
|
+
throw error;
|
|
1316
1403
|
}
|
|
1317
|
-
}
|
|
1318
|
-
|
|
1404
|
+
};
|
|
1405
|
+
const out = park(finish);
|
|
1406
|
+
if (rk !== undefined && rk === occurrence) repeats.has(rk) || repeats.set(rk, out);
|
|
1319
1407
|
return out;
|
|
1320
1408
|
} catch (error) {
|
|
1321
1409
|
settleRecord && settleRecord(undefined);
|
|
@@ -1331,9 +1419,40 @@ function createDocumentSlotProps(clientProps, frameId) {
|
|
|
1331
1419
|
}
|
|
1332
1420
|
const FRAME_TAG = "solid-frame";
|
|
1333
1421
|
const FRAME_ID_ATTR = "data-fid";
|
|
1334
|
-
|
|
1422
|
+
const FRAME_ARGS_ATTR = "data-fa";
|
|
1423
|
+
function frameElementOpen(id, args) {
|
|
1335
1424
|
const escaped = sharedConfig.context ? sharedConfig.context.escape(String(id), true) : String(id);
|
|
1336
|
-
return `<${FRAME_TAG} ${FRAME_ID_ATTR}="${escaped}" style="display:contents">`;
|
|
1425
|
+
return `<${FRAME_TAG} ${FRAME_ID_ATTR}="${escaped}"${args ? ` ${FRAME_ARGS_ATTR}="${args}"` : ""} style="display:contents">`;
|
|
1426
|
+
}
|
|
1427
|
+
const DOCUMENT_SITES = Symbol();
|
|
1428
|
+
function contextSites(ctx) {
|
|
1429
|
+
if (ctx[DOCUMENT_SITES]) return ctx[DOCUMENT_SITES];
|
|
1430
|
+
const proto = Object.getPrototypeOf(ctx);
|
|
1431
|
+
if (proto && proto[DOCUMENT_SITES]) return ctx[DOCUMENT_SITES] = proto[DOCUMENT_SITES];
|
|
1432
|
+
if (proto && typeof proto.escape === "function") return ctx[DOCUMENT_SITES] = contextSites(proto);
|
|
1433
|
+
return ctx[DOCUMENT_SITES] = {
|
|
1434
|
+
byOwner: new Map(),
|
|
1435
|
+
counts: Object.create(null)
|
|
1436
|
+
};
|
|
1437
|
+
}
|
|
1438
|
+
function mintSiteId(sites, fnId) {
|
|
1439
|
+
const n = sites.counts[fnId] || 0;
|
|
1440
|
+
sites.counts[fnId] = n + 1;
|
|
1441
|
+
return n === 0 ? fnId : fnId + "~" + (n + 1);
|
|
1442
|
+
}
|
|
1443
|
+
function documentSiteId(fnId) {
|
|
1444
|
+
const ctx = sharedConfig.context;
|
|
1445
|
+
if (!ctx) return fnId;
|
|
1446
|
+
const sites = contextSites(ctx);
|
|
1447
|
+
const owner = getOwner ? getOwner() : null;
|
|
1448
|
+
if (!owner) return mintSiteId(sites, fnId);
|
|
1449
|
+
let byFn = sites.byOwner.get(owner);
|
|
1450
|
+
if (!byFn) sites.byOwner.set(owner, byFn = new Map());
|
|
1451
|
+
const prev = byFn.get(fnId);
|
|
1452
|
+
if (prev) return prev;
|
|
1453
|
+
const siteId = mintSiteId(sites, fnId);
|
|
1454
|
+
byFn.set(fnId, siteId);
|
|
1455
|
+
return siteId;
|
|
1337
1456
|
}
|
|
1338
1457
|
const FRAME_ELEMENT_CLOSE = `</${FRAME_TAG}>`;
|
|
1339
1458
|
function documentNeeds(name) {
|
|
@@ -1355,6 +1474,7 @@ function armDocumentLiveHoles(ctx) {
|
|
|
1355
1474
|
if (live.holes) {
|
|
1356
1475
|
ctx.commit = live.commit;
|
|
1357
1476
|
ctx.commitEpoch = live.commitEpoch;
|
|
1477
|
+
ctx.unsettled = live.unsettled;
|
|
1358
1478
|
}
|
|
1359
1479
|
return;
|
|
1360
1480
|
}
|
|
@@ -1363,6 +1483,7 @@ function armDocumentLiveHoles(ctx) {
|
|
|
1363
1483
|
if (live) live.holes = null;
|
|
1364
1484
|
return;
|
|
1365
1485
|
}
|
|
1486
|
+
let unsettled = false;
|
|
1366
1487
|
const bindings = new Map();
|
|
1367
1488
|
let epoch = 0;
|
|
1368
1489
|
let sweepScheduled = false;
|
|
@@ -1370,7 +1491,7 @@ function armDocumentLiveHoles(ctx) {
|
|
|
1370
1491
|
let swept = null;
|
|
1371
1492
|
const sweep = () => {
|
|
1372
1493
|
epoch++;
|
|
1373
|
-
const
|
|
1494
|
+
const r = swept = {};
|
|
1374
1495
|
try {
|
|
1375
1496
|
for (const b of [...bindings.values()]) {
|
|
1376
1497
|
try {
|
|
@@ -1381,12 +1502,8 @@ function armDocumentLiveHoles(ctx) {
|
|
|
1381
1502
|
} finally {
|
|
1382
1503
|
swept = null;
|
|
1383
1504
|
}
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
const pushOps = ops => {
|
|
1387
|
-
if (ops.length === 1) push(ops[0]);else if (ops.length) push({
|
|
1388
|
-
type: "ops",
|
|
1389
|
-
ops
|
|
1505
|
+
for (const _ in r) return push({
|
|
1506
|
+
r
|
|
1390
1507
|
});
|
|
1391
1508
|
};
|
|
1392
1509
|
const scheduleSweep = () => {
|
|
@@ -1401,51 +1518,62 @@ function armDocumentLiveHoles(ctx) {
|
|
|
1401
1518
|
ctx.serialize("sc:live", new ReadableStream({
|
|
1402
1519
|
start(c) {
|
|
1403
1520
|
channel = c;
|
|
1521
|
+
},
|
|
1522
|
+
cancel() {
|
|
1523
|
+
closed = true;
|
|
1404
1524
|
}
|
|
1405
1525
|
}));
|
|
1406
|
-
const push =
|
|
1407
|
-
if (!closed) channel.enqueue(
|
|
1526
|
+
const push = batch => {
|
|
1527
|
+
if (!closed) channel.enqueue(batch);
|
|
1408
1528
|
};
|
|
1529
|
+
const write = r => swept ? Object.assign(swept, r) : push({
|
|
1530
|
+
r
|
|
1531
|
+
});
|
|
1409
1532
|
ctx.liveHoles = live.holes = createLiveHoles({
|
|
1410
1533
|
openBinding(key, b) {
|
|
1534
|
+
documentNeeds("wire");
|
|
1411
1535
|
bindings.set(key, b);
|
|
1412
1536
|
},
|
|
1413
1537
|
closeBinding(key) {
|
|
1414
1538
|
bindings.delete(key);
|
|
1415
1539
|
},
|
|
1416
|
-
hole(key,
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1540
|
+
hole(key, value) {
|
|
1541
|
+
write({
|
|
1542
|
+
["hole:" + key]: {
|
|
1543
|
+
kind: "html",
|
|
1544
|
+
value,
|
|
1545
|
+
digest: textDigest(value)
|
|
1546
|
+
}
|
|
1547
|
+
});
|
|
1424
1548
|
},
|
|
1425
|
-
attr(key,
|
|
1426
|
-
const
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
digest: textDigest(attrs)
|
|
1549
|
+
attr(key, value, removed) {
|
|
1550
|
+
const record = {
|
|
1551
|
+
kind: "attrs",
|
|
1552
|
+
value,
|
|
1553
|
+
digest: textDigest(value)
|
|
1431
1554
|
};
|
|
1432
|
-
if (removed && removed.length)
|
|
1433
|
-
|
|
1555
|
+
if (removed && removed.length) record.removed = removed;
|
|
1556
|
+
write({
|
|
1557
|
+
["attr:" + key]: record
|
|
1558
|
+
});
|
|
1434
1559
|
},
|
|
1435
1560
|
error(key, error) {
|
|
1436
1561
|
push({
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1562
|
+
r: {
|
|
1563
|
+
[`hole:${key}:error`]: error
|
|
1564
|
+
}
|
|
1440
1565
|
});
|
|
1441
1566
|
},
|
|
1442
1567
|
commit: scheduleSweep,
|
|
1443
1568
|
get epoch() {
|
|
1444
1569
|
return epoch;
|
|
1445
1570
|
}
|
|
1446
|
-
}, true);
|
|
1571
|
+
}, true, () => !unsettled, ctx._errorScope);
|
|
1447
1572
|
ctx.commit = live.commit = scheduleSweep;
|
|
1448
1573
|
ctx.commitEpoch = live.commitEpoch = () => epoch;
|
|
1574
|
+
ctx.unsettled = live.unsettled = () => {
|
|
1575
|
+
unsettled = true;
|
|
1576
|
+
};
|
|
1449
1577
|
live.args = {
|
|
1450
1578
|
openBinding(key, b) {
|
|
1451
1579
|
bindings.set(key, b);
|
|
@@ -1455,19 +1583,23 @@ function armDocumentLiveHoles(ctx) {
|
|
|
1455
1583
|
},
|
|
1456
1584
|
slot(fid, occurrence, args) {
|
|
1457
1585
|
push({
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1586
|
+
r: {
|
|
1587
|
+
[`slot:${occurrence}`]: {
|
|
1588
|
+
kind: "slot",
|
|
1589
|
+
args
|
|
1590
|
+
}
|
|
1591
|
+
},
|
|
1592
|
+
fid
|
|
1462
1593
|
});
|
|
1463
1594
|
},
|
|
1464
1595
|
commit: scheduleSweep
|
|
1465
1596
|
};
|
|
1466
1597
|
live.error = (fid, error) => {
|
|
1467
1598
|
push({
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1599
|
+
r: {
|
|
1600
|
+
":error": error
|
|
1601
|
+
},
|
|
1602
|
+
fid
|
|
1471
1603
|
});
|
|
1472
1604
|
};
|
|
1473
1605
|
live.end = () => {
|
|
@@ -1484,31 +1616,34 @@ function frameTransformDirectResult(value, {
|
|
|
1484
1616
|
}) {
|
|
1485
1617
|
if (typeof value !== "function") return value;
|
|
1486
1618
|
const component = value;
|
|
1487
|
-
const
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1619
|
+
const address = frameAddress(id, args);
|
|
1620
|
+
const wrapped = props => {
|
|
1621
|
+
const siteId = documentSiteId(id);
|
|
1622
|
+
return [{
|
|
1623
|
+
t: frameElementOpen(siteId, address.slice(id.length + 1))
|
|
1624
|
+
},
|
|
1625
|
+
serverOwned(() => {
|
|
1626
|
+
const page = sharedConfig.context;
|
|
1627
|
+
armDocumentLiveHoles(page);
|
|
1628
|
+
if (tierUrls && page && page.live && !page.live.tierUrls) page.live.tierUrls = tierUrls;
|
|
1629
|
+
const ctx = Object.create(page);
|
|
1630
|
+
ctx.frameId = siteId;
|
|
1631
|
+
sharedConfig.context = ctx;
|
|
1632
|
+
try {
|
|
1633
|
+
const slotProps = createDocumentSlotProps(props, siteId);
|
|
1634
|
+
const live = !!wrapped[LIVE_SOURCE];
|
|
1635
|
+
if (live) documentNeeds("wire");
|
|
1636
|
+
return serverComponentScope(() => component(slotProps), live);
|
|
1637
|
+
} finally {
|
|
1638
|
+
sharedConfig.context = page;
|
|
1639
|
+
}
|
|
1640
|
+
}), {
|
|
1641
|
+
t: FRAME_ELEMENT_CLOSE
|
|
1642
|
+
}];
|
|
1643
|
+
};
|
|
1509
1644
|
wrapped[SERVER_COMPONENT] = id;
|
|
1510
1645
|
wrapped[SERVER_COMPONENT_SOURCE] = component;
|
|
1511
|
-
wrapped[SERVER_COMPONENT_ADDRESS] =
|
|
1646
|
+
wrapped[SERVER_COMPONENT_ADDRESS] = address;
|
|
1512
1647
|
return wrapped;
|
|
1513
1648
|
}
|
|
1514
1649
|
function resolveRegionHtml(ctx, node) {
|
|
@@ -1611,6 +1746,15 @@ function createSlotProps(sink, frame) {
|
|
|
1611
1746
|
const counts = Object.create(null);
|
|
1612
1747
|
const getters = new Map();
|
|
1613
1748
|
const repeats = new Map();
|
|
1749
|
+
let pass = null;
|
|
1750
|
+
let passRepeats = null;
|
|
1751
|
+
const recs = new Map();
|
|
1752
|
+
const forget = occurrence => {
|
|
1753
|
+
const rec = recs.get(occurrence);
|
|
1754
|
+
if (!rec) return;
|
|
1755
|
+
recs.delete(occurrence);
|
|
1756
|
+
for (const key in rec.vals) sink.closeBinding(`${occurrence}:${key}`);
|
|
1757
|
+
};
|
|
1614
1758
|
const needs = sink.needs || (() => {});
|
|
1615
1759
|
return new Proxy(Object.create(null), {
|
|
1616
1760
|
has() {
|
|
@@ -1623,25 +1767,38 @@ function createSlotProps(sink, frame) {
|
|
|
1623
1767
|
if (!fn) {
|
|
1624
1768
|
fn = (...callArgs) => {
|
|
1625
1769
|
if (callArgs.length === 0 || callArgs[0] === undefined) {
|
|
1626
|
-
return
|
|
1770
|
+
return slotRange(prop);
|
|
1627
1771
|
}
|
|
1628
|
-
const rk = repeatKey(prop, callArgs[0]);
|
|
1629
|
-
const repeat = rk !== undefined && repeats.get(rk);
|
|
1630
|
-
if (repeat) return repeat;
|
|
1631
1772
|
const live = sharedConfig.context && sharedConfig.context.liveHoles;
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1773
|
+
const sweeping = !!live && live.sweeping;
|
|
1774
|
+
let rmap = repeats;
|
|
1775
|
+
if (sweeping) {
|
|
1776
|
+
if (pass !== live.visit) passRepeats = new Map();
|
|
1777
|
+
pass = live.visit;
|
|
1778
|
+
rmap = passRepeats;
|
|
1779
|
+
}
|
|
1780
|
+
const rk = keyedId(prop, callArgs[0]);
|
|
1781
|
+
const repeat = rk !== undefined && rmap.get(rk);
|
|
1782
|
+
if (repeat) return repeat;
|
|
1783
|
+
if (sweeping && !live.scope) {
|
|
1784
|
+
live.gateHit = true;
|
|
1785
|
+
return {
|
|
1786
|
+
t: "",
|
|
1787
|
+
$slot: true
|
|
1788
|
+
};
|
|
1641
1789
|
}
|
|
1642
1790
|
const raw = callArgs[0];
|
|
1643
|
-
|
|
1791
|
+
let occurrence = keyedId(prop, raw);
|
|
1792
|
+
if (occurrence === undefined) {
|
|
1793
|
+
const positional = sweeping ? undefined : occurrenceId(prop, raw, counts);
|
|
1794
|
+
occurrence = live ? live.slotId(prop, positional) : positional;
|
|
1795
|
+
}
|
|
1796
|
+
if (sweeping && live.dry) return slotRange(occurrence);
|
|
1797
|
+
const prev = recs.get(occurrence);
|
|
1798
|
+
let changed = !prev;
|
|
1799
|
+
const digest = live && live.scope ? argDigest : noDigest;
|
|
1644
1800
|
const args = {};
|
|
1801
|
+
const vals = {};
|
|
1645
1802
|
const opened = [];
|
|
1646
1803
|
for (const key of Object.keys(raw)) {
|
|
1647
1804
|
if (key === "$key") continue;
|
|
@@ -1657,6 +1814,7 @@ function createSlotProps(sink, frame) {
|
|
|
1657
1814
|
let evaluate = null;
|
|
1658
1815
|
let value;
|
|
1659
1816
|
let state = null;
|
|
1817
|
+
let pending = false;
|
|
1660
1818
|
const stampBefore = scopeStamp();
|
|
1661
1819
|
try {
|
|
1662
1820
|
if (desc.get) {
|
|
@@ -1678,6 +1836,7 @@ function createSlotProps(sink, frame) {
|
|
|
1678
1836
|
settled: false,
|
|
1679
1837
|
last: undefined
|
|
1680
1838
|
};
|
|
1839
|
+
pending = true;
|
|
1681
1840
|
const pendingState = state;
|
|
1682
1841
|
value = retryArgUntilSettled(evaluate, blocked, key, occurrence, v => {
|
|
1683
1842
|
pendingState.settled = true;
|
|
@@ -1689,6 +1848,7 @@ function createSlotProps(sink, frame) {
|
|
|
1689
1848
|
const t = typeof value;
|
|
1690
1849
|
if (value == null || t === "string" || t === "number" || t === "boolean") {
|
|
1691
1850
|
args[key] = value;
|
|
1851
|
+
vals[key] = digest(value);
|
|
1692
1852
|
if (evaluate) state = {
|
|
1693
1853
|
settled: true,
|
|
1694
1854
|
last: value
|
|
@@ -1698,21 +1858,27 @@ function createSlotProps(sink, frame) {
|
|
|
1698
1858
|
if (resolved.h.length) {
|
|
1699
1859
|
throw new Error("Async server content in a slot arg needs a boundary (arg '" + key + "' of " + occurrence + "). Wrap the async read in a <Suspense>, or move it above the slot.");
|
|
1700
1860
|
}
|
|
1701
|
-
|
|
1861
|
+
vals[key] = "<" + resolved.t[0];
|
|
1862
|
+
if (!prev || prev.vals[key] !== vals[key]) sink.region(childId, resolved.t[0]);
|
|
1702
1863
|
args[key] = {
|
|
1703
1864
|
$frame: childId
|
|
1704
1865
|
};
|
|
1705
1866
|
} else {
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1867
|
+
vals[key] = pending ? PENDING_ARG : digest(value);
|
|
1868
|
+
if (prev && prev.vals[key] === vals[key]) args[key] = prev.args[key];else {
|
|
1869
|
+
const ref = prev ? `arg:${occurrence}:${key}@${sink.nextArgRef(`${occurrence}:${key}`)}` : `arg:${occurrence}:${key}`;
|
|
1870
|
+
if (prev) sink.mintRef(ref);
|
|
1871
|
+
ctx.serialize(ref, argBorderForm(value, needs));
|
|
1872
|
+
args[key] = {
|
|
1873
|
+
$ref: ref
|
|
1874
|
+
};
|
|
1875
|
+
}
|
|
1711
1876
|
if (evaluate && !state) state = {
|
|
1712
1877
|
settled: true,
|
|
1713
1878
|
last: value
|
|
1714
1879
|
};
|
|
1715
1880
|
}
|
|
1881
|
+
if (prev && prev.vals[key] !== vals[key]) changed = true;
|
|
1716
1882
|
if (evaluate && state && !mintedEval) opened.push({
|
|
1717
1883
|
key,
|
|
1718
1884
|
evaluate,
|
|
@@ -1722,9 +1888,18 @@ function createSlotProps(sink, frame) {
|
|
|
1722
1888
|
ctx.registerFragment = origRegister;
|
|
1723
1889
|
}
|
|
1724
1890
|
}
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1891
|
+
if (prev) for (const key in prev.vals) if (!(key in vals)) changed = true;
|
|
1892
|
+
const rec = changed ? {
|
|
1893
|
+
args,
|
|
1894
|
+
vals
|
|
1895
|
+
} : prev;
|
|
1896
|
+
if (changed) {
|
|
1897
|
+
recs.set(occurrence, rec);
|
|
1898
|
+
sink.slot(occurrence, {
|
|
1899
|
+
...args
|
|
1900
|
+
});
|
|
1901
|
+
}
|
|
1902
|
+
if (live && live.visit) live.seen(occurrence, () => recs.get(occurrence) === rec && forget(occurrence));
|
|
1728
1903
|
const ctx = sharedConfig.context;
|
|
1729
1904
|
for (const b of opened) {
|
|
1730
1905
|
const key = b.key;
|
|
@@ -1732,23 +1907,23 @@ function createSlotProps(sink, frame) {
|
|
|
1732
1907
|
openArgBinding(sink, ledgerKey, occurrence, key, b.evaluate, b.state, value => {
|
|
1733
1908
|
const t = typeof value;
|
|
1734
1909
|
if (value == null || t === "string" || t === "number" || t === "boolean") {
|
|
1735
|
-
args[key] = value;
|
|
1910
|
+
rec.args[key] = value;
|
|
1736
1911
|
} else {
|
|
1737
1912
|
const ref = `arg:${occurrence}:${key}@${sink.nextArgRef(ledgerKey)}`;
|
|
1738
1913
|
sink.mintRef(ref);
|
|
1739
|
-
ctx.serialize(ref, argBorderForm(value,
|
|
1740
|
-
args[key] = {
|
|
1914
|
+
ctx.serialize(ref, argBorderForm(value, needs));
|
|
1915
|
+
rec.args[key] = {
|
|
1741
1916
|
$ref: ref
|
|
1742
1917
|
};
|
|
1743
1918
|
}
|
|
1919
|
+
rec.vals[key] = digest(value);
|
|
1744
1920
|
sink.slot(occurrence, {
|
|
1745
|
-
...args
|
|
1921
|
+
...rec.args
|
|
1746
1922
|
});
|
|
1747
1923
|
});
|
|
1748
1924
|
}
|
|
1749
|
-
const
|
|
1750
|
-
|
|
1751
|
-
if (keyed) repeats.set(rk, out);
|
|
1925
|
+
const out = slotRange(occurrence);
|
|
1926
|
+
if (rk !== undefined && rk === occurrence) rmap.set(rk, out);
|
|
1752
1927
|
return out;
|
|
1753
1928
|
};
|
|
1754
1929
|
fn.$lhSkip = true;
|
|
@@ -1794,6 +1969,7 @@ function serverComponentResponse(component, options = {}, init = {}) {
|
|
|
1794
1969
|
});
|
|
1795
1970
|
let closed = false;
|
|
1796
1971
|
let stopLive = null;
|
|
1972
|
+
let failed = false;
|
|
1797
1973
|
const body = new ReadableStream({
|
|
1798
1974
|
start(controller) {
|
|
1799
1975
|
const end = () => {
|
|
@@ -1812,10 +1988,11 @@ function serverComponentResponse(component, options = {}, init = {}) {
|
|
|
1812
1988
|
teardown.abort();
|
|
1813
1989
|
});
|
|
1814
1990
|
stream.pipe({
|
|
1815
|
-
write(
|
|
1991
|
+
write(message) {
|
|
1992
|
+
if (message.r && ":error" in message.r) failed = true;
|
|
1816
1993
|
if (closed) return;
|
|
1817
1994
|
try {
|
|
1818
|
-
controller.enqueue(frame(JSON.stringify(
|
|
1995
|
+
controller.enqueue(frame(JSON.stringify(message)));
|
|
1819
1996
|
} catch (_) {
|
|
1820
1997
|
closed = true;
|
|
1821
1998
|
}
|
|
@@ -1835,6 +2012,10 @@ function serverComponentResponse(component, options = {}, init = {}) {
|
|
|
1835
2012
|
});
|
|
1836
2013
|
}
|
|
1837
2014
|
});
|
|
2015
|
+
if (failed) {
|
|
2016
|
+
headers.set("Cache-Control", "no-store");
|
|
2017
|
+
for (const name of [...headers.keys()]) if (name === "surrogate-control" || name.endsWith("cdn-cache-control")) headers.delete(name);
|
|
2018
|
+
}
|
|
1838
2019
|
return new Response(body, {
|
|
1839
2020
|
status: init.status || 200,
|
|
1840
2021
|
headers
|
|
@@ -1969,10 +2150,10 @@ function frameFlightResponse({
|
|
|
1969
2150
|
let closed = false;
|
|
1970
2151
|
const body = new ReadableStream({
|
|
1971
2152
|
async start(controller) {
|
|
1972
|
-
const write =
|
|
2153
|
+
const write = message => {
|
|
1973
2154
|
if (closed) return;
|
|
1974
2155
|
try {
|
|
1975
|
-
controller.enqueue(createChunk(JSON.stringify(
|
|
2156
|
+
controller.enqueue(createChunk(JSON.stringify(message)));
|
|
1976
2157
|
} catch (_) {
|
|
1977
2158
|
closed = true;
|
|
1978
2159
|
}
|
|
@@ -2051,4 +2232,4 @@ function asyncArg(value) {
|
|
|
2051
2232
|
return value;
|
|
2052
2233
|
}
|
|
2053
2234
|
|
|
2054
|
-
export { FRAME_HAVE_BUDGET, FRAME_HAVE_HEADER, FRAME_STREAM_HEADER, FRAME_TIERS_HEADER, SERVER_COMPONENT_BOOTSTRAP, ServerComponentPlugin, asyncArg,
|
|
2235
|
+
export { FRAME_HAVE_BUDGET, FRAME_HAVE_HEADER, FRAME_STREAM_HEADER, FRAME_TIERS_HEADER, SERVER_COMPONENT_BOOTSTRAP, ServerComponentPlugin, asyncArg, frameTransformDirectResult, frameTransformFlightResult, frameTransformResult, isFrameStreamResponse };
|