@solidjs/web 2.0.0-rc.13 → 2.0.0-rc.15
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 +317 -185
- package/dist/server.js +298 -161
- package/dist/server.observe.js +299 -171
- package/dist/web.dev.js +207 -189
- package/dist/web.js +180 -178
- package/dist/web.observe.js +180 -180
- package/frames/dist/assets.js +92 -0
- package/frames/dist/bind.dev.js +326 -0
- package/frames/dist/bind.js +295 -0
- package/frames/dist/client.dev.js +665 -1114
- package/frames/dist/client.js +630 -1087
- package/frames/dist/client.observe.js +629 -1087
- package/frames/dist/regions.js +130 -0
- package/frames/dist/server.dev.js +400 -201
- package/frames/dist/server.js +397 -198
- package/frames/dist/server.observe.js +397 -198
- package/frames/dist/trace.js +45 -0
- package/frames/dist/wire.js +133 -0
- package/package.json +30 -4
- package/performance-tracks/dist/performance-tracks.dev.js +2 -1
- package/performance-tracks/dist/performance-tracks.observe.js +2 -1
- package/performance-tracks/types/index.d.ts +8 -6
- package/serialization/dist/decode.js +38 -9
- package/serialization/dist/serialization.js +40 -11
- package/serialization/types/serializer-decode.d.ts +24 -2
- package/server-functions/dist/client.dev.js +101 -62
- package/server-functions/dist/client.js +101 -62
- package/server-functions/dist/client.observe.js +101 -62
- package/server-functions/dist/server.dev.js +178 -67
- package/server-functions/dist/server.js +178 -67
- package/server-functions/dist/server.observe.js +178 -67
- package/skills/server-components/SKILL.md +65 -43
- package/types/client.d.ts +120 -8
- package/types/constants.d.ts +3 -1
- package/types/diagnostics.d.ts +8 -0
- package/types/frames/assets-tier.d.ts +78 -0
- package/types/frames/bind-tier.d.ts +60 -0
- package/types/frames/client.d.ts +37 -3
- package/types/frames/frame-client.d.ts +249 -78
- package/types/frames/frame-container-plugin.d.ts +2 -2
- package/types/frames/frame-sink.d.ts +33 -0
- package/types/frames/frame-transport.d.ts +66 -18
- package/types/frames/regions-tier.d.ts +45 -0
- package/types/frames/serializer-decode.d.ts +24 -2
- package/types/frames/server.d.ts +33 -9
- package/types/frames/trace-tier.d.ts +2 -0
- package/types/frames/wire-tier.d.ts +116 -0
- package/types/head.d.ts +1 -0
- package/types/index.d.ts +61 -16
- package/types/index.server.d.ts +3 -18
- package/types/jsx.d.ts +4 -13
- package/types/observe.d.ts +4 -2
- package/types/response.d.ts +26 -4
- package/types/serializer-decode.d.ts +24 -2
- package/types/server-functions/client.d.ts +30 -0
- package/types/server-functions/registry.d.ts +4 -1
- package/types/server-functions/shared.d.ts +12 -8
- package/types/server-mock.d.ts +22 -3
- package/types/server.d.ts +119 -17
package/frames/dist/server.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { sharedConfig, ssrSanitizeError, creationStamp, ssrHandleError, runInServerComponentScope, shareAsyncIterable, getProjectionTrace } from 'solid-js/internal';
|
|
2
|
-
import {
|
|
3
|
-
import { isResponseEnvelope, renderToStream, createLiveHoles, CLAIMS_STREAM, CLAIMS_DOCUMENT, SLOT_FACE_DATA, slotValue, SLOT_FACE_STREAM,
|
|
2
|
+
import { getOwner, NoHydration, runWithOwner, createMemo, Hydration, createOwner } from 'solid-js';
|
|
3
|
+
import { isResponseEnvelope, renderToStream, createLiveHoles, CLAIMS_STREAM, CLAIMS_DOCUMENT, SLOT_FACE_DATA, SLOT_FACE_MARKUP, slotValue, SLOT_FACE_STREAM, isSlotValue } 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,17 +132,15 @@ 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
|
}
|
|
141
139
|
}
|
|
142
|
-
function materialize(marker) {
|
|
140
|
+
function materialize(marker, claiming) {
|
|
143
141
|
let value = state.materialized.get(marker.$tr);
|
|
144
142
|
if (value === undefined) {
|
|
145
|
-
value = state.materializeTrace(marker);
|
|
143
|
+
value = state.materializeTrace(marker, claiming);
|
|
146
144
|
state.materialized.set(marker.$tr, value);
|
|
147
145
|
if (value !== null && typeof value === "object") state.materializedValues.add(value);
|
|
148
146
|
}
|
|
@@ -200,14 +198,14 @@ setContainerTraceStreamMint(iterable => {
|
|
|
200
198
|
})();
|
|
201
199
|
return stream;
|
|
202
200
|
});
|
|
203
|
-
const DEFAULT_WEB_PLUGINS = Object.freeze([AbortSignalPlugin,
|
|
201
|
+
const DEFAULT_WEB_PLUGINS = /* @__PURE__ */Object.freeze([AbortSignalPlugin,
|
|
204
202
|
CustomEventPlugin, DOMExceptionPlugin, EventPlugin,
|
|
205
203
|
FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin,
|
|
206
204
|
ContainerTracePlugin]);
|
|
207
205
|
function resolveSerializerPlugins(customPlugins) {
|
|
208
206
|
return customPlugins ? [...customPlugins, ...DEFAULT_WEB_PLUGINS] : [...DEFAULT_WEB_PLUGINS];
|
|
209
207
|
}
|
|
210
|
-
const
|
|
208
|
+
const jsonCodecDisabledFeatures = () => Feature.RegExp;
|
|
211
209
|
const JSON_CODEC_DEPTH_LIMIT = 64;
|
|
212
210
|
function resolveCodecOptions({
|
|
213
211
|
plugins,
|
|
@@ -217,13 +215,12 @@ function resolveCodecOptions({
|
|
|
217
215
|
} = {}) {
|
|
218
216
|
return {
|
|
219
217
|
plugins: resolveSerializerPlugins(plugins),
|
|
220
|
-
disabledFeatures: disabledFeatures === undefined ?
|
|
218
|
+
disabledFeatures: disabledFeatures === undefined ? jsonCodecDisabledFeatures() : disabledFeatures,
|
|
221
219
|
depthLimit: depthLimit === undefined ? JSON_CODEC_DEPTH_LIMIT : depthLimit,
|
|
222
220
|
serializeErrorStacks
|
|
223
221
|
};
|
|
224
222
|
}
|
|
225
223
|
|
|
226
|
-
Feature.AggregateError | Feature.BigIntTypedArray;
|
|
227
224
|
const serializeOnlyDisabledFeatures = serializeErrorStacks => (serializeErrorStacks === undefined ? process.env.NODE_ENV === "development" : serializeErrorStacks) ? 0 : Feature.ErrorPrototypeStack;
|
|
228
225
|
function createJSONSerializer({
|
|
229
226
|
onData,
|
|
@@ -349,6 +346,7 @@ function observeFrame(frame) {
|
|
|
349
346
|
}
|
|
350
347
|
|
|
351
348
|
const FRAME_STREAM_HEADER = "X-Frame-Stream";
|
|
349
|
+
const FRAME_TIERS_HEADER = "X-Frame-Tiers";
|
|
352
350
|
const FRAME_HAVE_HEADER = "X-Frame-Have";
|
|
353
351
|
const FRAME_HAVE_BUDGET = 4096;
|
|
354
352
|
function decodeHaveList(text) {
|
|
@@ -479,11 +477,27 @@ function withHoles(chunk, holes) {
|
|
|
479
477
|
}
|
|
480
478
|
return chunk;
|
|
481
479
|
}
|
|
482
|
-
function createFrameSink(
|
|
480
|
+
function createFrameSink(write, frame, have, hooks) {
|
|
483
481
|
const {
|
|
484
482
|
id,
|
|
485
483
|
version
|
|
486
484
|
} = frame;
|
|
485
|
+
const tiers = new Set();
|
|
486
|
+
let staged = [];
|
|
487
|
+
const emit = chunk => {
|
|
488
|
+
if (swept) swept.emitted = true;
|
|
489
|
+
if (staged.length) {
|
|
490
|
+
chunk.tiers = staged;
|
|
491
|
+
staged = [];
|
|
492
|
+
}
|
|
493
|
+
write(chunk);
|
|
494
|
+
};
|
|
495
|
+
const needs = name => {
|
|
496
|
+
if (!tiers.has(name)) {
|
|
497
|
+
tiers.add(name);
|
|
498
|
+
staged.push(name);
|
|
499
|
+
}
|
|
500
|
+
};
|
|
487
501
|
let conditional = false;
|
|
488
502
|
const skipped = new Set();
|
|
489
503
|
const attrText = new Map();
|
|
@@ -523,15 +537,38 @@ function createFrameSink(emit, frame, have) {
|
|
|
523
537
|
let sweepScheduled = false;
|
|
524
538
|
let closed = false;
|
|
525
539
|
let epoch = 0;
|
|
540
|
+
let swept = null;
|
|
526
541
|
const sweep = () => {
|
|
527
542
|
epoch++;
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
543
|
+
const pass = swept = {
|
|
544
|
+
ops: [],
|
|
545
|
+
emitted: false
|
|
546
|
+
};
|
|
547
|
+
try {
|
|
548
|
+
for (const b of [...bindings.values()]) {
|
|
549
|
+
try {
|
|
550
|
+
b.sweep();
|
|
551
|
+
} catch (_) {
|
|
552
|
+
}
|
|
532
553
|
}
|
|
554
|
+
emitOps(pass.ops);
|
|
555
|
+
if (pass.emitted && hooks && hooks.onYield) hooks.onYield();
|
|
556
|
+
} finally {
|
|
557
|
+
swept = null;
|
|
533
558
|
}
|
|
534
559
|
};
|
|
560
|
+
const emitOps = ops => {
|
|
561
|
+
if (ops.length === 1) emit(Object.assign({
|
|
562
|
+
type: ops[0].type,
|
|
563
|
+
id,
|
|
564
|
+
version
|
|
565
|
+
}, ops[0]));else if (ops.length) emit({
|
|
566
|
+
type: "ops",
|
|
567
|
+
id,
|
|
568
|
+
version,
|
|
569
|
+
ops
|
|
570
|
+
});
|
|
571
|
+
};
|
|
535
572
|
const scheduleSweep = () => {
|
|
536
573
|
if (closed || sweepScheduled || !bindings.size) return;
|
|
537
574
|
sweepScheduled = true;
|
|
@@ -575,6 +612,7 @@ function createFrameSink(emit, frame, have) {
|
|
|
575
612
|
chunk.preloads.push(wirePreload(entry));
|
|
576
613
|
}
|
|
577
614
|
}
|
|
615
|
+
needs("assets");
|
|
578
616
|
emit(chunk);
|
|
579
617
|
}
|
|
580
618
|
emit(withHoles({
|
|
@@ -650,6 +688,7 @@ function createFrameSink(emit, frame, have) {
|
|
|
650
688
|
attrs: e.attrs
|
|
651
689
|
}));
|
|
652
690
|
}
|
|
691
|
+
needs("assets");
|
|
653
692
|
emit(chunk);
|
|
654
693
|
}
|
|
655
694
|
emit(withHoles({
|
|
@@ -707,6 +746,7 @@ function createFrameSink(emit, frame, have) {
|
|
|
707
746
|
},
|
|
708
747
|
asset(type, value) {
|
|
709
748
|
if (type === "module") {
|
|
749
|
+
needs("assets");
|
|
710
750
|
emit({
|
|
711
751
|
type: "assets",
|
|
712
752
|
id,
|
|
@@ -715,6 +755,7 @@ function createFrameSink(emit, frame, have) {
|
|
|
715
755
|
modules: [value]
|
|
716
756
|
});
|
|
717
757
|
} else if (type === "preload") {
|
|
758
|
+
needs("assets");
|
|
718
759
|
emit({
|
|
719
760
|
type: "assets",
|
|
720
761
|
id,
|
|
@@ -724,14 +765,17 @@ function createFrameSink(emit, frame, have) {
|
|
|
724
765
|
});
|
|
725
766
|
}
|
|
726
767
|
},
|
|
727
|
-
end() {
|
|
728
|
-
if (
|
|
768
|
+
end(bound) {
|
|
769
|
+
if (closed) return;
|
|
770
|
+
if (bindings.size && !swept) sweep();
|
|
729
771
|
closed = true;
|
|
730
|
-
|
|
772
|
+
const chunk = {
|
|
731
773
|
type: "complete",
|
|
732
774
|
id,
|
|
733
775
|
version
|
|
734
|
-
}
|
|
776
|
+
};
|
|
777
|
+
if (bound) chunk.bound = bound;
|
|
778
|
+
emit(chunk);
|
|
735
779
|
},
|
|
736
780
|
error(errorId, error) {
|
|
737
781
|
emit({
|
|
@@ -752,6 +796,7 @@ function createFrameSink(emit, frame, have) {
|
|
|
752
796
|
});
|
|
753
797
|
},
|
|
754
798
|
region(childId, html) {
|
|
799
|
+
needs("regions");
|
|
755
800
|
emit({
|
|
756
801
|
type: "html",
|
|
757
802
|
id: childId,
|
|
@@ -760,26 +805,23 @@ function createFrameSink(emit, frame, have) {
|
|
|
760
805
|
});
|
|
761
806
|
},
|
|
762
807
|
hole(key, html) {
|
|
763
|
-
|
|
808
|
+
const op = {
|
|
764
809
|
type: "hole",
|
|
765
|
-
id,
|
|
766
|
-
version,
|
|
767
810
|
key,
|
|
768
811
|
html,
|
|
769
812
|
digest: textDigest(html)
|
|
770
|
-
}
|
|
813
|
+
};
|
|
814
|
+
swept ? swept.ops.push(op) : emitOps([op]);
|
|
771
815
|
},
|
|
772
816
|
attr(key, attrs, removed) {
|
|
773
|
-
const
|
|
817
|
+
const op = {
|
|
774
818
|
type: "attr",
|
|
775
|
-
id,
|
|
776
|
-
version,
|
|
777
819
|
key,
|
|
778
820
|
attrs,
|
|
779
821
|
digest: textDigest(attrs)
|
|
780
822
|
};
|
|
781
|
-
if (removed && removed.length)
|
|
782
|
-
|
|
823
|
+
if (removed && removed.length) op.removed = removed;
|
|
824
|
+
swept ? swept.ops.push(op) : emitOps([op]);
|
|
783
825
|
},
|
|
784
826
|
attrBaseline(key, text) {
|
|
785
827
|
attrText.set(key, text);
|
|
@@ -801,12 +843,14 @@ function createFrameSink(emit, frame, have) {
|
|
|
801
843
|
commit: scheduleSweep,
|
|
802
844
|
get epoch() {
|
|
803
845
|
return epoch;
|
|
846
|
+
},
|
|
847
|
+
needs,
|
|
848
|
+
announce() {
|
|
849
|
+
staged = [];
|
|
850
|
+
return [...tiers];
|
|
804
851
|
}
|
|
805
852
|
};
|
|
806
853
|
}
|
|
807
|
-
function renderToFrameStream(code, options = {}) {
|
|
808
|
-
return frameStream(() => code, options);
|
|
809
|
-
}
|
|
810
854
|
function renderServerComponent(component, options = {}) {
|
|
811
855
|
return frameStream((sink, frame) => {
|
|
812
856
|
const props = createSlotProps(sink, frame);
|
|
@@ -822,6 +866,10 @@ function renderServerComponent(component, options = {}) {
|
|
|
822
866
|
};
|
|
823
867
|
}, options);
|
|
824
868
|
}
|
|
869
|
+
const DEFAULT_MAX_YIELDS = 64;
|
|
870
|
+
const DEFAULT_MAX_DURATION_MS = 30_000;
|
|
871
|
+
const DISCONNECTED = Symbol("solid.frames.disconnected");
|
|
872
|
+
const ANNOUNCE = Symbol("solid.frames.announce");
|
|
825
873
|
function frameStream(makeCode, options) {
|
|
826
874
|
const {
|
|
827
875
|
id = "",
|
|
@@ -831,30 +879,77 @@ function frameStream(makeCode, options) {
|
|
|
831
879
|
id,
|
|
832
880
|
version
|
|
833
881
|
};
|
|
882
|
+
const bounded = !options.live;
|
|
883
|
+
const maxYields = bounded ? options.maxYields ?? DEFAULT_MAX_YIELDS : 0;
|
|
884
|
+
const maxDurationMs = bounded ? options.maxDurationMs ?? DEFAULT_MAX_DURATION_MS : 0;
|
|
834
885
|
function stream(w) {
|
|
835
886
|
const observation = observeFrame(frame);
|
|
836
|
-
const
|
|
837
|
-
|
|
887
|
+
const render = new AbortController();
|
|
888
|
+
const upstream = options.signal;
|
|
889
|
+
let ended = false;
|
|
890
|
+
let flushed = false;
|
|
891
|
+
let yields = 0;
|
|
892
|
+
let timer;
|
|
893
|
+
function finish() {
|
|
894
|
+
if (ended) return;
|
|
895
|
+
ended = true;
|
|
896
|
+
if (timer) clearTimeout(timer);
|
|
897
|
+
if (upstream) upstream.removeEventListener("abort", onSignal);
|
|
898
|
+
w.end && w.end();
|
|
899
|
+
}
|
|
900
|
+
function cut(bound) {
|
|
901
|
+
if (ended) return;
|
|
902
|
+
sink.end(bound);
|
|
903
|
+
observation && observation.settle("complete");
|
|
904
|
+
finish();
|
|
905
|
+
render.abort({
|
|
906
|
+
quiet: true,
|
|
907
|
+
bound
|
|
908
|
+
});
|
|
909
|
+
}
|
|
910
|
+
function onSignal() {
|
|
911
|
+
const gone = upstream.reason && upstream.reason[DISCONNECTED];
|
|
912
|
+
if (bounded && flushed && !gone) return cut("time");
|
|
913
|
+
finish();
|
|
914
|
+
render.abort(upstream.reason);
|
|
915
|
+
}
|
|
916
|
+
const emit = chunk => {
|
|
917
|
+
if (observation) observation.chunk(chunk);
|
|
838
918
|
w.write(chunk);
|
|
839
|
-
|
|
840
|
-
|
|
919
|
+
if (bounded && !flushed && chunk.type === "html" && chunk.id === id) {
|
|
920
|
+
flushed = true;
|
|
921
|
+
if (maxDurationMs > 0 && maxDurationMs !== Infinity) timer = setTimeout(() => cut("time"), maxDurationMs);
|
|
922
|
+
}
|
|
923
|
+
};
|
|
924
|
+
const sink = createFrameSink(emit, frame, options.resume && options.resume.have, bounded ? {
|
|
925
|
+
onYield() {
|
|
926
|
+
if (flushed && maxYields > 0 && ++yields >= maxYields) cut("yields");
|
|
927
|
+
}
|
|
928
|
+
} : undefined);
|
|
929
|
+
if (options.live) sink.needs("wire");
|
|
841
930
|
w.write({
|
|
842
931
|
type: "start",
|
|
843
932
|
id,
|
|
844
933
|
version
|
|
845
934
|
});
|
|
935
|
+
if (upstream && upstream.aborted) return finish();
|
|
936
|
+
if (upstream) upstream.addEventListener("abort", onSignal, {
|
|
937
|
+
once: true
|
|
938
|
+
});
|
|
846
939
|
const code = makeCode(sink, frame);
|
|
847
940
|
try {
|
|
848
941
|
renderToStream(() => serverOwned(code), {
|
|
849
942
|
serializer: createJSONSerializer,
|
|
850
943
|
...options,
|
|
944
|
+
signal: render.signal,
|
|
851
945
|
sink
|
|
852
946
|
}).pipe({
|
|
853
947
|
write() {},
|
|
854
948
|
end() {
|
|
949
|
+
if (ended) return;
|
|
855
950
|
sink.end();
|
|
856
951
|
observation && observation.settle("complete");
|
|
857
|
-
|
|
952
|
+
finish();
|
|
858
953
|
}
|
|
859
954
|
});
|
|
860
955
|
} catch (err) {
|
|
@@ -862,8 +957,9 @@ function frameStream(makeCode, options) {
|
|
|
862
957
|
sink.error("", wire instanceof Error ? wire.message : String(wire));
|
|
863
958
|
sink.end();
|
|
864
959
|
observation && observation.settle("error", err);
|
|
865
|
-
|
|
960
|
+
finish();
|
|
866
961
|
}
|
|
962
|
+
if (w[ANNOUNCE]) w[ANNOUNCE](sink.announce());
|
|
867
963
|
}
|
|
868
964
|
return {
|
|
869
965
|
pipe: stream,
|
|
@@ -895,21 +991,25 @@ function isRangeKey(key) {
|
|
|
895
991
|
const c = key.charCodeAt(0);
|
|
896
992
|
return c === 36 || c >= 48 && c <= 57 || RANGE_KEYS.has(key);
|
|
897
993
|
}
|
|
898
|
-
function slotProxy(range, occurrence, face, content, onData) {
|
|
994
|
+
function slotProxy(range, occurrence, face, content, onData, needs) {
|
|
899
995
|
return new Proxy(range, {
|
|
900
996
|
get(target, key, receiver) {
|
|
901
997
|
if (typeof key !== "string" || isRangeKey(key)) return Reflect.get(target, key, receiver);
|
|
902
998
|
if (onData) onData = void onData();
|
|
999
|
+
if (face !== SLOT_FACE_MARKUP) needs("bind");
|
|
903
1000
|
return slotValue(occurrence, key, content ? content[key] : undefined, face);
|
|
904
1001
|
}
|
|
905
1002
|
});
|
|
906
1003
|
}
|
|
907
|
-
function argBorderForm(value, key, occurrence) {
|
|
908
|
-
return toBorderForm(withoutStandIns(value));
|
|
1004
|
+
function argBorderForm(value, key, occurrence, needs) {
|
|
1005
|
+
return toBorderForm(withoutStandIns(value, key, occurrence, needs));
|
|
909
1006
|
}
|
|
910
|
-
function withoutStandIns(value, key, occurrence) {
|
|
1007
|
+
function withoutStandIns(value, key, occurrence, needs) {
|
|
911
1008
|
return rewriteTree(value, (v, path) => {
|
|
912
|
-
if (isContainerTraced(v))
|
|
1009
|
+
if (isContainerTraced(v)) {
|
|
1010
|
+
needs("trace");
|
|
1011
|
+
return v;
|
|
1012
|
+
}
|
|
913
1013
|
if (Object.getPrototypeOf(v) === Object.prototype && isSlotValue(v)) {
|
|
914
1014
|
return undefined;
|
|
915
1015
|
}
|
|
@@ -1030,7 +1130,7 @@ function createDocumentSlotProps(clientProps, frameId) {
|
|
|
1030
1130
|
r.$occurrence = occurrence;
|
|
1031
1131
|
const face = slotFace(r, content);
|
|
1032
1132
|
r.$face = face;
|
|
1033
|
-
return slotProxy(r, occurrence, face, face === SLOT_FACE_DATA ? content : undefined);
|
|
1133
|
+
return slotProxy(r, occurrence, face, face === SLOT_FACE_DATA ? content : undefined, undefined, documentNeeds);
|
|
1034
1134
|
};
|
|
1035
1135
|
const zoneOwner = getOwner ? getOwner() : null;
|
|
1036
1136
|
const scoped = (occurrence, render) => {
|
|
@@ -1071,136 +1171,151 @@ function createDocumentSlotProps(clientProps, frameId) {
|
|
|
1071
1171
|
const occurrence = occurrenceId(prop, raw, counts);
|
|
1072
1172
|
const slot = clientProps[prop];
|
|
1073
1173
|
if (typeof slot !== "function") return range(occurrence, undefined);
|
|
1074
|
-
const
|
|
1075
|
-
const
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
const
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1174
|
+
const context = sharedConfig.context;
|
|
1175
|
+
const recordKey = `sc:slot:${frameId}:${occurrence}`;
|
|
1176
|
+
let settleRecord;
|
|
1177
|
+
if (context && context.async) {
|
|
1178
|
+
context.serialize(recordKey, new Promise(resolve => settleRecord = resolve));
|
|
1179
|
+
}
|
|
1180
|
+
try {
|
|
1181
|
+
const resolved = {};
|
|
1182
|
+
const liveArgs = sharedConfig.context && sharedConfig.context.live && sharedConfig.context.live.args;
|
|
1183
|
+
const vals = {};
|
|
1184
|
+
const evals = {};
|
|
1185
|
+
const states = {};
|
|
1186
|
+
const minted = {};
|
|
1187
|
+
for (const key of Object.keys(raw)) {
|
|
1188
|
+
if (key === "$key") continue;
|
|
1189
|
+
const desc = Object.getOwnPropertyDescriptor(raw, key);
|
|
1190
|
+
let evaluate = null;
|
|
1191
|
+
let value;
|
|
1192
|
+
if (desc.get) {
|
|
1193
|
+
const get = desc.get;
|
|
1194
|
+
evaluate = () => unwrapThunks(get.call(raw));
|
|
1195
|
+
} else {
|
|
1196
|
+
value = desc.value;
|
|
1197
|
+
if (typeof value === "function") {
|
|
1198
|
+
const fn = value;
|
|
1199
|
+
evaluate = () => unwrapThunks(fn);
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
if (evaluate) {
|
|
1203
|
+
evals[key] = evaluate;
|
|
1204
|
+
const stampBefore = scopeStamp();
|
|
1205
|
+
try {
|
|
1206
|
+
value = evaluate();
|
|
1207
|
+
states[key] = {
|
|
1208
|
+
settled: true,
|
|
1209
|
+
last: value
|
|
1210
|
+
};
|
|
1211
|
+
} catch (err) {
|
|
1212
|
+
const blocked = ssrHandleError && ssrHandleError(err);
|
|
1213
|
+
if (!blocked) throw err;
|
|
1214
|
+
const state = states[key] = {
|
|
1215
|
+
settled: false,
|
|
1216
|
+
last: undefined
|
|
1217
|
+
};
|
|
1218
|
+
value = retryArgUntilSettled(evaluate, blocked, key, occurrence, v => {
|
|
1219
|
+
state.settled = true;
|
|
1220
|
+
state.last = v;
|
|
1221
|
+
if (liveArgs) liveArgs.commit();
|
|
1222
|
+
});
|
|
1223
|
+
}
|
|
1224
|
+
if (scopeStamp() !== stampBefore) minted[key] = true;
|
|
1093
1225
|
}
|
|
1226
|
+
vals[key] = value;
|
|
1094
1227
|
}
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
const
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1228
|
+
const regions = [];
|
|
1229
|
+
for (const key of Object.keys(vals)) {
|
|
1230
|
+
const value = vals[key];
|
|
1231
|
+
if (isContainerTraced(value)) {
|
|
1232
|
+
documentNeeds("trace");
|
|
1233
|
+
resolved[key] = value;
|
|
1234
|
+
} else if (isServerContent(value)) {
|
|
1235
|
+
const childId = `${frameId}.${occurrence}.${key}`;
|
|
1236
|
+
const region = {
|
|
1237
|
+
key,
|
|
1238
|
+
childId,
|
|
1239
|
+
value,
|
|
1240
|
+
used: false,
|
|
1241
|
+
locked: false
|
|
1103
1242
|
};
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1243
|
+
regions.push(region);
|
|
1244
|
+
documentNeeds("regions");
|
|
1245
|
+
resolved[key] = () => {
|
|
1246
|
+
if (region.locked) return [];
|
|
1247
|
+
region.used = true;
|
|
1248
|
+
return [{
|
|
1249
|
+
t: frameElementOpen(childId)
|
|
1250
|
+
}, value, {
|
|
1251
|
+
t: FRAME_ELEMENT_CLOSE
|
|
1252
|
+
}];
|
|
1110
1253
|
};
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1254
|
+
} else if (ssrAsyncValue && isAsyncValue(value)) {
|
|
1255
|
+
let readable = value;
|
|
1256
|
+
if (typeof value.then !== "function") {
|
|
1257
|
+
const {
|
|
1258
|
+
first,
|
|
1259
|
+
rest
|
|
1260
|
+
} = tapFirstYield(value);
|
|
1261
|
+
readable = first;
|
|
1262
|
+
vals[key] = rest;
|
|
1263
|
+
}
|
|
1264
|
+
const read = ssrAsyncValue(readable);
|
|
1265
|
+
Object.defineProperty(resolved, key, {
|
|
1266
|
+
get: read,
|
|
1267
|
+
enumerable: true,
|
|
1268
|
+
configurable: true
|
|
1115
1269
|
});
|
|
1270
|
+
} else {
|
|
1271
|
+
resolved[key] = vals[key] = withoutStandIns(value, key, occurrence, documentNeeds);
|
|
1116
1272
|
}
|
|
1117
|
-
if (scopeStamp() !== stampBefore) minted[key] = true;
|
|
1118
1273
|
}
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
};
|
|
1135
|
-
regions.push(region);
|
|
1136
|
-
resolved[key] = () => {
|
|
1137
|
-
if (region.locked) return [];
|
|
1138
|
-
region.used = true;
|
|
1139
|
-
return [{
|
|
1140
|
-
t: frameElementOpen(childId)
|
|
1141
|
-
}, value, {
|
|
1142
|
-
t: FRAME_ELEMENT_CLOSE
|
|
1143
|
-
}];
|
|
1144
|
-
};
|
|
1145
|
-
} else if (ssrAsyncValue && isAsyncValue(value)) {
|
|
1146
|
-
let readable = value;
|
|
1147
|
-
if (typeof value.then !== "function") {
|
|
1148
|
-
const {
|
|
1149
|
-
first,
|
|
1150
|
-
rest
|
|
1151
|
-
} = tapFirstYield(value);
|
|
1152
|
-
readable = first;
|
|
1153
|
-
vals[key] = rest;
|
|
1274
|
+
const out = suppressedFill(() => scoped(occurrence, () => range(occurrence, slot(resolved))));
|
|
1275
|
+
const unused = regions.filter(r => !r.used);
|
|
1276
|
+
if (context) {
|
|
1277
|
+
const args = {};
|
|
1278
|
+
for (const key of Object.keys(vals)) {
|
|
1279
|
+
const value = vals[key];
|
|
1280
|
+
const region = regions.find(r => r.key === key);
|
|
1281
|
+
if (region) {
|
|
1282
|
+
args[key] = {
|
|
1283
|
+
$frame: region.childId
|
|
1284
|
+
};
|
|
1285
|
+
continue;
|
|
1286
|
+
}
|
|
1287
|
+
if (!isContainerTraced(value) && isServerContent(value)) continue;
|
|
1288
|
+
args[key] = argBorderForm(value, key, occurrence, documentNeeds);
|
|
1154
1289
|
}
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
configurable: true
|
|
1290
|
+
settleRecord ? settleRecord({
|
|
1291
|
+
...args
|
|
1292
|
+
}) : context.serialize(recordKey, {
|
|
1293
|
+
...args
|
|
1160
1294
|
});
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
}
|
|
1165
|
-
const out = suppressedFill(() => scoped(occurrence, () => range(occurrence, slot(resolved))));
|
|
1166
|
-
const unused = regions.filter(r => !r.used);
|
|
1167
|
-
if (sharedConfig.context) {
|
|
1168
|
-
const args = {};
|
|
1169
|
-
for (const key of Object.keys(vals)) {
|
|
1170
|
-
const value = vals[key];
|
|
1171
|
-
const region = regions.find(r => r.key === key);
|
|
1172
|
-
if (region) {
|
|
1173
|
-
args[key] = {
|
|
1174
|
-
$frame: region.childId
|
|
1175
|
-
};
|
|
1176
|
-
continue;
|
|
1295
|
+
for (const region of unused) {
|
|
1296
|
+
region.locked = true;
|
|
1297
|
+
context.serialize(`sc:region:${region.childId}`, resolveRegionHtml(context, region.value));
|
|
1177
1298
|
}
|
|
1178
|
-
if (
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
if (liveArgs) {
|
|
1189
|
-
for (const key of Object.keys(evals)) {
|
|
1190
|
-
if (regions.some(r => r.key === key)) continue;
|
|
1191
|
-
if (minted[key]) continue;
|
|
1192
|
-
const ledgerKey = `${frameId}:${occurrence}:${key}`;
|
|
1193
|
-
openArgBinding(liveArgs, ledgerKey, occurrence, key, evals[key], states[key], value => {
|
|
1194
|
-
args[key] = argBorderForm(value);
|
|
1195
|
-
liveArgs.slot(frameId, occurrence, {
|
|
1196
|
-
...args
|
|
1299
|
+
if (liveArgs) {
|
|
1300
|
+
for (const key of Object.keys(evals)) {
|
|
1301
|
+
if (regions.some(r => r.key === key)) continue;
|
|
1302
|
+
if (minted[key]) continue;
|
|
1303
|
+
const ledgerKey = `${frameId}:${occurrence}:${key}`;
|
|
1304
|
+
openArgBinding(liveArgs, ledgerKey, occurrence, key, evals[key], states[key], value => {
|
|
1305
|
+
args[key] = argBorderForm(value, key, occurrence, documentNeeds);
|
|
1306
|
+
liveArgs.slot(frameId, occurrence, {
|
|
1307
|
+
...args
|
|
1308
|
+
});
|
|
1197
1309
|
});
|
|
1198
|
-
}
|
|
1310
|
+
}
|
|
1199
1311
|
}
|
|
1200
1312
|
}
|
|
1313
|
+
if (rk !== undefined && (rk === occurrence || out.$face === SLOT_FACE_DATA)) repeats.has(rk) || repeats.set(rk, out);
|
|
1314
|
+
return out;
|
|
1315
|
+
} catch (error) {
|
|
1316
|
+
settleRecord && settleRecord(undefined);
|
|
1317
|
+
throw error;
|
|
1201
1318
|
}
|
|
1202
|
-
if (rk !== undefined && (rk === occurrence || out.$face === SLOT_FACE_DATA)) repeats.has(rk) || repeats.set(rk, out);
|
|
1203
|
-
return out;
|
|
1204
1319
|
};
|
|
1205
1320
|
fn.$lhSkip = true;
|
|
1206
1321
|
getters.set(prop, fn);
|
|
@@ -1215,7 +1330,48 @@ function frameElementOpen(id) {
|
|
|
1215
1330
|
const escaped = sharedConfig.context ? sharedConfig.context.escape(String(id), true) : String(id);
|
|
1216
1331
|
return `<${FRAME_TAG} ${FRAME_ID_ATTR}="${escaped}" style="display:contents">`;
|
|
1217
1332
|
}
|
|
1333
|
+
const DOCUMENT_SITES = Symbol();
|
|
1334
|
+
function contextSites(ctx) {
|
|
1335
|
+
if (ctx[DOCUMENT_SITES]) return ctx[DOCUMENT_SITES];
|
|
1336
|
+
const proto = Object.getPrototypeOf(ctx);
|
|
1337
|
+
if (proto && proto[DOCUMENT_SITES]) return ctx[DOCUMENT_SITES] = proto[DOCUMENT_SITES];
|
|
1338
|
+
if (proto && typeof proto.escape === "function") return ctx[DOCUMENT_SITES] = contextSites(proto);
|
|
1339
|
+
return ctx[DOCUMENT_SITES] = {
|
|
1340
|
+
byOwner: new Map(),
|
|
1341
|
+
counts: Object.create(null)
|
|
1342
|
+
};
|
|
1343
|
+
}
|
|
1344
|
+
function mintSiteId(sites, fnId) {
|
|
1345
|
+
const n = sites.counts[fnId] || 0;
|
|
1346
|
+
sites.counts[fnId] = n + 1;
|
|
1347
|
+
return n === 0 ? fnId : fnId + "~" + (n + 1);
|
|
1348
|
+
}
|
|
1349
|
+
function documentSiteId(fnId) {
|
|
1350
|
+
const ctx = sharedConfig.context;
|
|
1351
|
+
if (!ctx) return fnId;
|
|
1352
|
+
const sites = contextSites(ctx);
|
|
1353
|
+
const owner = getOwner ? getOwner() : null;
|
|
1354
|
+
if (!owner) return mintSiteId(sites, fnId);
|
|
1355
|
+
let byFn = sites.byOwner.get(owner);
|
|
1356
|
+
if (!byFn) sites.byOwner.set(owner, byFn = new Map());
|
|
1357
|
+
const prev = byFn.get(fnId);
|
|
1358
|
+
if (prev) return prev;
|
|
1359
|
+
const siteId = mintSiteId(sites, fnId);
|
|
1360
|
+
byFn.set(fnId, siteId);
|
|
1361
|
+
return siteId;
|
|
1362
|
+
}
|
|
1218
1363
|
const FRAME_ELEMENT_CLOSE = `</${FRAME_TAG}>`;
|
|
1364
|
+
function documentNeeds(name) {
|
|
1365
|
+
const ctx = sharedConfig.context;
|
|
1366
|
+
const live = ctx && ctx.live;
|
|
1367
|
+
if (!live || !ctx.serialize) return;
|
|
1368
|
+
const tiers = live.tiers || (live.tiers = []);
|
|
1369
|
+
if (tiers.includes(name)) return;
|
|
1370
|
+
tiers.push(name);
|
|
1371
|
+
ctx.serialize("sc:tiers", tiers.slice());
|
|
1372
|
+
const url = live.tierUrls && live.tierUrls[name];
|
|
1373
|
+
if (url && ctx.registerAsset) ctx.registerAsset("module", url);
|
|
1374
|
+
}
|
|
1219
1375
|
function armDocumentLiveHoles(ctx) {
|
|
1220
1376
|
if (!ctx || ctx.liveHoles !== undefined) return;
|
|
1221
1377
|
const live = ctx.live;
|
|
@@ -1236,14 +1392,27 @@ function armDocumentLiveHoles(ctx) {
|
|
|
1236
1392
|
let epoch = 0;
|
|
1237
1393
|
let sweepScheduled = false;
|
|
1238
1394
|
let closed = false;
|
|
1395
|
+
let swept = null;
|
|
1239
1396
|
const sweep = () => {
|
|
1240
1397
|
epoch++;
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1398
|
+
const ops = swept = [];
|
|
1399
|
+
try {
|
|
1400
|
+
for (const b of [...bindings.values()]) {
|
|
1401
|
+
try {
|
|
1402
|
+
b.sweep();
|
|
1403
|
+
} catch (_) {
|
|
1404
|
+
}
|
|
1245
1405
|
}
|
|
1406
|
+
} finally {
|
|
1407
|
+
swept = null;
|
|
1246
1408
|
}
|
|
1409
|
+
pushOps(ops);
|
|
1410
|
+
};
|
|
1411
|
+
const pushOps = ops => {
|
|
1412
|
+
if (ops.length === 1) push(ops[0]);else if (ops.length) push({
|
|
1413
|
+
type: "ops",
|
|
1414
|
+
ops
|
|
1415
|
+
});
|
|
1247
1416
|
};
|
|
1248
1417
|
const scheduleSweep = () => {
|
|
1249
1418
|
if (closed || sweepScheduled || !bindings.size) return;
|
|
@@ -1257,6 +1426,9 @@ function armDocumentLiveHoles(ctx) {
|
|
|
1257
1426
|
ctx.serialize("sc:live", new ReadableStream({
|
|
1258
1427
|
start(c) {
|
|
1259
1428
|
channel = c;
|
|
1429
|
+
},
|
|
1430
|
+
cancel() {
|
|
1431
|
+
closed = true;
|
|
1260
1432
|
}
|
|
1261
1433
|
}));
|
|
1262
1434
|
const push = op => {
|
|
@@ -1270,12 +1442,13 @@ function armDocumentLiveHoles(ctx) {
|
|
|
1270
1442
|
bindings.delete(key);
|
|
1271
1443
|
},
|
|
1272
1444
|
hole(key, html) {
|
|
1273
|
-
|
|
1445
|
+
const op = {
|
|
1274
1446
|
type: "hole",
|
|
1275
1447
|
key,
|
|
1276
1448
|
html,
|
|
1277
1449
|
digest: textDigest(html)
|
|
1278
|
-
}
|
|
1450
|
+
};
|
|
1451
|
+
swept ? swept.push(op) : pushOps([op]);
|
|
1279
1452
|
},
|
|
1280
1453
|
attr(key, attrs, removed) {
|
|
1281
1454
|
const op = {
|
|
@@ -1285,7 +1458,7 @@ function armDocumentLiveHoles(ctx) {
|
|
|
1285
1458
|
digest: textDigest(attrs)
|
|
1286
1459
|
};
|
|
1287
1460
|
if (removed && removed.length) op.removed = removed;
|
|
1288
|
-
push(op);
|
|
1461
|
+
swept ? swept.push(op) : pushOps([op]);
|
|
1289
1462
|
},
|
|
1290
1463
|
error(key, error) {
|
|
1291
1464
|
push({
|
|
@@ -1318,6 +1491,13 @@ function armDocumentLiveHoles(ctx) {
|
|
|
1318
1491
|
},
|
|
1319
1492
|
commit: scheduleSweep
|
|
1320
1493
|
};
|
|
1494
|
+
live.error = (fid, error) => {
|
|
1495
|
+
push({
|
|
1496
|
+
type: "error",
|
|
1497
|
+
fid,
|
|
1498
|
+
error
|
|
1499
|
+
});
|
|
1500
|
+
};
|
|
1321
1501
|
live.end = () => {
|
|
1322
1502
|
if (closed) return;
|
|
1323
1503
|
if (bindings.size) sweep();
|
|
@@ -1327,28 +1507,36 @@ function armDocumentLiveHoles(ctx) {
|
|
|
1327
1507
|
}
|
|
1328
1508
|
function frameTransformDirectResult(value, {
|
|
1329
1509
|
id,
|
|
1330
|
-
args
|
|
1510
|
+
args,
|
|
1511
|
+
tierUrls
|
|
1331
1512
|
}) {
|
|
1332
1513
|
if (typeof value !== "function") return value;
|
|
1333
1514
|
const component = value;
|
|
1334
|
-
const wrapped = props =>
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1515
|
+
const wrapped = props => {
|
|
1516
|
+
const siteId = documentSiteId(id);
|
|
1517
|
+
return [{
|
|
1518
|
+
t: frameElementOpen(siteId)
|
|
1519
|
+
},
|
|
1520
|
+
serverOwned(() => {
|
|
1521
|
+
const page = sharedConfig.context;
|
|
1522
|
+
armDocumentLiveHoles(page);
|
|
1523
|
+
if (tierUrls && page && page.live && !page.live.tierUrls) page.live.tierUrls = tierUrls;
|
|
1524
|
+
const ctx = Object.create(page);
|
|
1525
|
+
ctx.claims = CLAIMS_DOCUMENT;
|
|
1526
|
+
ctx.frameId = siteId;
|
|
1527
|
+
sharedConfig.context = ctx;
|
|
1528
|
+
try {
|
|
1529
|
+
const slotProps = createDocumentSlotProps(props, siteId);
|
|
1530
|
+
const live = !!wrapped[LIVE_SOURCE];
|
|
1531
|
+
if (live) documentNeeds("wire");
|
|
1532
|
+
return serverComponentScope(() => component(slotProps), live);
|
|
1533
|
+
} finally {
|
|
1534
|
+
sharedConfig.context = page;
|
|
1535
|
+
}
|
|
1536
|
+
}), {
|
|
1537
|
+
t: FRAME_ELEMENT_CLOSE
|
|
1538
|
+
}];
|
|
1539
|
+
};
|
|
1352
1540
|
wrapped[SERVER_COMPONENT] = id;
|
|
1353
1541
|
wrapped[SERVER_COMPONENT_SOURCE] = component;
|
|
1354
1542
|
wrapped[SERVER_COMPONENT_ADDRESS] = frameAddress(id, args);
|
|
@@ -1454,6 +1642,7 @@ function createSlotProps(sink, frame) {
|
|
|
1454
1642
|
const counts = Object.create(null);
|
|
1455
1643
|
const getters = new Map();
|
|
1456
1644
|
const repeats = new Map();
|
|
1645
|
+
const needs = sink.needs || (() => {});
|
|
1457
1646
|
return new Proxy(Object.create(null), {
|
|
1458
1647
|
has() {
|
|
1459
1648
|
return true;
|
|
@@ -1465,7 +1654,7 @@ function createSlotProps(sink, frame) {
|
|
|
1465
1654
|
if (!fn) {
|
|
1466
1655
|
fn = (...callArgs) => {
|
|
1467
1656
|
if (callArgs.length === 0 || callArgs[0] === undefined) {
|
|
1468
|
-
return slotProxy(slotRange(prop), prop, SLOT_FACE_STREAM, undefined);
|
|
1657
|
+
return slotProxy(slotRange(prop), prop, SLOT_FACE_STREAM, undefined, undefined, needs);
|
|
1469
1658
|
}
|
|
1470
1659
|
const rk = repeatKey(prop, callArgs[0]);
|
|
1471
1660
|
const repeat = rk !== undefined && repeats.get(rk);
|
|
@@ -1546,7 +1735,7 @@ function createSlotProps(sink, frame) {
|
|
|
1546
1735
|
};
|
|
1547
1736
|
} else {
|
|
1548
1737
|
const ref = `arg:${occurrence}:${key}`;
|
|
1549
|
-
ctx.serialize(ref, argBorderForm(value, key, occurrence));
|
|
1738
|
+
ctx.serialize(ref, argBorderForm(value, key, occurrence, needs));
|
|
1550
1739
|
args[key] = {
|
|
1551
1740
|
$ref: ref
|
|
1552
1741
|
};
|
|
@@ -1578,7 +1767,7 @@ function createSlotProps(sink, frame) {
|
|
|
1578
1767
|
} else {
|
|
1579
1768
|
const ref = `arg:${occurrence}:${key}@${sink.nextArgRef(ledgerKey)}`;
|
|
1580
1769
|
sink.mintRef(ref);
|
|
1581
|
-
ctx.serialize(ref, argBorderForm(value));
|
|
1770
|
+
ctx.serialize(ref, argBorderForm(value, key, occurrence, needs));
|
|
1582
1771
|
args[key] = {
|
|
1583
1772
|
$ref: ref
|
|
1584
1773
|
};
|
|
@@ -1589,7 +1778,7 @@ function createSlotProps(sink, frame) {
|
|
|
1589
1778
|
});
|
|
1590
1779
|
}
|
|
1591
1780
|
const keyed = rk === occurrence;
|
|
1592
|
-
const out = slotProxy(slotRange(occurrence), occurrence, SLOT_FACE_STREAM, undefined, rk === undefined || keyed ? undefined : () => repeats.has(rk) || repeats.set(rk, out));
|
|
1781
|
+
const out = slotProxy(slotRange(occurrence), occurrence, SLOT_FACE_STREAM, undefined, rk === undefined || keyed ? undefined : () => repeats.has(rk) || repeats.set(rk, out), needs);
|
|
1593
1782
|
if (keyed) repeats.set(rk, out);
|
|
1594
1783
|
return out;
|
|
1595
1784
|
};
|
|
@@ -1636,6 +1825,7 @@ function serverComponentResponse(component, options = {}, init = {}) {
|
|
|
1636
1825
|
});
|
|
1637
1826
|
let closed = false;
|
|
1638
1827
|
let stopLive = null;
|
|
1828
|
+
let failed = false;
|
|
1639
1829
|
const body = new ReadableStream({
|
|
1640
1830
|
start(controller) {
|
|
1641
1831
|
const end = () => {
|
|
@@ -1648,9 +1838,6 @@ function serverComponentResponse(component, options = {}, init = {}) {
|
|
|
1648
1838
|
} catch (_) {}
|
|
1649
1839
|
};
|
|
1650
1840
|
if (teardown.signal.aborted) return end();
|
|
1651
|
-
teardown.signal.addEventListener("abort", end, {
|
|
1652
|
-
once: true
|
|
1653
|
-
});
|
|
1654
1841
|
if (live) stopLive = armLiveBody(controller, () => {
|
|
1655
1842
|
closed = true;
|
|
1656
1843
|
disarm();
|
|
@@ -1658,6 +1845,7 @@ function serverComponentResponse(component, options = {}, init = {}) {
|
|
|
1658
1845
|
});
|
|
1659
1846
|
stream.pipe({
|
|
1660
1847
|
write(chunk) {
|
|
1848
|
+
if (chunk.type === "error" && !chunk.key) failed = true;
|
|
1661
1849
|
if (closed) return;
|
|
1662
1850
|
try {
|
|
1663
1851
|
controller.enqueue(frame(JSON.stringify(chunk)));
|
|
@@ -1665,16 +1853,25 @@ function serverComponentResponse(component, options = {}, init = {}) {
|
|
|
1665
1853
|
closed = true;
|
|
1666
1854
|
}
|
|
1667
1855
|
},
|
|
1668
|
-
end
|
|
1856
|
+
end,
|
|
1857
|
+
[ANNOUNCE](tiers) {
|
|
1858
|
+
if (tiers.length) headers.set(FRAME_TIERS_HEADER, tiers.join(","));
|
|
1859
|
+
}
|
|
1669
1860
|
});
|
|
1670
1861
|
},
|
|
1671
1862
|
cancel() {
|
|
1672
1863
|
closed = true;
|
|
1673
1864
|
disarm();
|
|
1674
1865
|
if (stopLive) stopLive();
|
|
1675
|
-
teardown.abort(
|
|
1866
|
+
teardown.abort({
|
|
1867
|
+
[DISCONNECTED]: true
|
|
1868
|
+
});
|
|
1676
1869
|
}
|
|
1677
1870
|
});
|
|
1871
|
+
if (failed) {
|
|
1872
|
+
headers.set("Cache-Control", "no-store");
|
|
1873
|
+
for (const name of [...headers.keys()]) if (name === "surrogate-control" || name.endsWith("cdn-cache-control")) headers.delete(name);
|
|
1874
|
+
}
|
|
1678
1875
|
return new Response(body, {
|
|
1679
1876
|
status: init.status || 200,
|
|
1680
1877
|
headers
|
|
@@ -1874,7 +2071,9 @@ function frameFlightResponse({
|
|
|
1874
2071
|
cancel() {
|
|
1875
2072
|
closed = true;
|
|
1876
2073
|
disarm();
|
|
1877
|
-
teardown.abort(
|
|
2074
|
+
teardown.abort({
|
|
2075
|
+
[DISCONNECTED]: true
|
|
2076
|
+
});
|
|
1878
2077
|
}
|
|
1879
2078
|
});
|
|
1880
2079
|
return new Response(body, {
|
|
@@ -1889,4 +2088,4 @@ function asyncArg(value) {
|
|
|
1889
2088
|
return value;
|
|
1890
2089
|
}
|
|
1891
2090
|
|
|
1892
|
-
export { FRAME_HAVE_BUDGET, FRAME_HAVE_HEADER, FRAME_STREAM_HEADER, SERVER_COMPONENT_BOOTSTRAP, ServerComponentPlugin, asyncArg,
|
|
2091
|
+
export { FRAME_HAVE_BUDGET, FRAME_HAVE_HEADER, FRAME_STREAM_HEADER, FRAME_TIERS_HEADER, SERVER_COMPONENT_BOOTSTRAP, ServerComponentPlugin, asyncArg, frameTransformDirectResult, frameTransformFlightResult, frameTransformResult, isFrameStreamResponse };
|