@solidjs/web 2.0.0-rc.11 → 2.0.0-rc.14

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.
Files changed (60) hide show
  1. package/dist/server.dev.js +705 -151
  2. package/dist/server.js +604 -123
  3. package/dist/server.observe.js +617 -124
  4. package/dist/web.dev.js +102 -41
  5. package/dist/web.js +75 -37
  6. package/dist/web.observe.js +75 -39
  7. package/frames/dist/assets.js +92 -0
  8. package/frames/dist/bind.dev.js +326 -0
  9. package/frames/dist/bind.js +295 -0
  10. package/frames/dist/client.dev.js +693 -919
  11. package/frames/dist/client.js +636 -917
  12. package/frames/dist/client.observe.js +637 -917
  13. package/frames/dist/regions.js +130 -0
  14. package/frames/dist/server.dev.js +607 -212
  15. package/frames/dist/server.js +554 -212
  16. package/frames/dist/server.observe.js +554 -212
  17. package/frames/dist/trace.js +42 -0
  18. package/frames/dist/wire.js +133 -0
  19. package/package.json +30 -3
  20. package/performance-tracks/dist/performance-tracks.dev.js +2 -1
  21. package/performance-tracks/dist/performance-tracks.observe.js +2 -1
  22. package/performance-tracks/types/index.d.ts +8 -6
  23. package/serialization/dist/decode.js +37 -8
  24. package/serialization/dist/serialization.js +39 -10
  25. package/serialization/types/serializer-decode.d.ts +24 -2
  26. package/server-functions/dist/client.dev.js +178 -72
  27. package/server-functions/dist/client.js +99 -61
  28. package/server-functions/dist/client.observe.js +178 -72
  29. package/server-functions/dist/server.dev.js +117 -56
  30. package/server-functions/dist/server.js +117 -56
  31. package/server-functions/dist/server.observe.js +117 -56
  32. package/skills/server-components/SKILL.md +228 -0
  33. package/types/client.d.ts +37 -2
  34. package/types/constants.d.ts +2 -1
  35. package/types/diagnostics.d.ts +8 -0
  36. package/types/frames/assets-tier.d.ts +78 -0
  37. package/types/frames/bind-tier.d.ts +60 -0
  38. package/types/frames/client.d.ts +37 -3
  39. package/types/frames/frame-client.d.ts +249 -96
  40. package/types/frames/frame-container-plugin.d.ts +2 -10
  41. package/types/frames/frame-sink.d.ts +33 -0
  42. package/types/frames/frame-transport.d.ts +66 -18
  43. package/types/frames/regions-tier.d.ts +45 -0
  44. package/types/frames/serializer-decode.d.ts +24 -2
  45. package/types/frames/server.d.ts +53 -1
  46. package/types/frames/trace-tier.d.ts +2 -0
  47. package/types/frames/tree-rewrite.d.ts +39 -0
  48. package/types/frames/wire-tier.d.ts +116 -0
  49. package/types/index.d.ts +38 -0
  50. package/types/index.server.d.ts +10 -1
  51. package/types/jsx.d.ts +11 -1
  52. package/types/observe.d.ts +182 -12
  53. package/types/request-error-hook.d.ts +5 -0
  54. package/types/serializer-decode.d.ts +24 -2
  55. package/types/server-functions/client.d.ts +26 -0
  56. package/types/server-functions/registry.d.ts +4 -1
  57. package/types/server-functions/shared.d.ts +12 -8
  58. package/types/server-mock.d.ts +13 -1
  59. package/types/server-observe.d.ts +8 -0
  60. package/types/server.d.ts +125 -12
@@ -1,10 +1,100 @@
1
- import { ssrSanitizeError, creationStamp, ssrHandleError, runInServerComponentScope, shareAsyncIterable, getProjectionTrace } from 'solid-js/internal';
2
- import { sharedConfig, NoHydration, getOwner, runWithOwner, createMemo, Hydration, createOwner } from 'solid-js';
3
- import { isResponseEnvelope, renderToStream, createLiveHoles, CLAIMS_STREAM, CLAIMS_DOCUMENT, CLAIM_PROP } from '@solidjs/web';
1
+ import { sharedConfig, ssrSanitizeError, creationStamp, ssrHandleError, runInServerComponentScope, shareAsyncIterable, getProjectionTrace } from 'solid-js/internal';
2
+ import { NoHydration, getOwner, 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
6
  import { textDigest, frameAddress, getEventServerFunctionInvocation, armLiveBody, createEventChunk, createChunk, ChunkReader, serializeStream, guardFailures } from '@solidjs/web/server-functions/server';
7
7
 
8
+ const DESCEND = Symbol("descend");
9
+ const CYCLE = {};
10
+ const TRACK = 16;
11
+ function rewriteTree(value, visit, withPath) {
12
+ if (value === null || typeof value !== "object") return value;
13
+ const path = withPath ? "" : undefined;
14
+ const state = {
15
+ memo: undefined,
16
+ ancestors: undefined
17
+ };
18
+ try {
19
+ return cow(value, visit, path, 0, state);
20
+ } catch (err) {
21
+ if (err !== CYCLE) throw err;
22
+ }
23
+ return clone(value, visit, path, state.memo || (state.memo = new Map()));
24
+ }
25
+ function shape(value) {
26
+ return Array.isArray(value) ? 1 : Object.getPrototypeOf(value) === Object.prototype ? 2 : 0;
27
+ }
28
+ function cow(value, visit, path, depth, state) {
29
+ const memo = state.memo;
30
+ if (memo !== undefined && memo.has(value)) return memo.get(value);
31
+ const r = visit(value, path);
32
+ if (r !== DESCEND) {
33
+ if (r !== value) (memo || (state.memo = new Map())).set(value, r);
34
+ return r;
35
+ }
36
+ const s = shape(value);
37
+ if (s === 0) return value;
38
+ let ancestors;
39
+ if (depth >= TRACK) {
40
+ ancestors = state.ancestors || (state.ancestors = new Set());
41
+ if (ancestors.has(value)) throw CYCLE;
42
+ ancestors.add(value);
43
+ }
44
+ let out = value;
45
+ if (s === 1) {
46
+ for (let i = 0; i < value.length; i++) {
47
+ const c = value[i];
48
+ if (c === null || typeof c !== "object") continue;
49
+ const next = cow(c, visit, path === undefined ? undefined : `${path}[${i}]`, depth + 1, state);
50
+ if (next !== c) {
51
+ if (out === value) out = value.slice();
52
+ out[i] = next;
53
+ }
54
+ }
55
+ } else {
56
+ for (const k of Object.keys(value)) {
57
+ const c = value[k];
58
+ if (c === null || typeof c !== "object") continue;
59
+ const next = cow(c, visit, path === undefined ? undefined : `${path}.${k}`, depth + 1, state);
60
+ if (next !== c) {
61
+ if (out === value) out = {
62
+ ...value
63
+ };
64
+ out[k] = next;
65
+ }
66
+ }
67
+ }
68
+ if (ancestors !== undefined) ancestors.delete(value);
69
+ return out;
70
+ }
71
+ function clone(value, visit, path, memo) {
72
+ if (memo.has(value)) return memo.get(value);
73
+ const r = visit(value, path);
74
+ if (r !== DESCEND) {
75
+ memo.set(value, r);
76
+ return r;
77
+ }
78
+ const s = shape(value);
79
+ if (s === 0) return value;
80
+ const out = s === 1 ? value.slice() : {
81
+ ...value
82
+ };
83
+ memo.set(value, out);
84
+ if (s === 1) {
85
+ for (let i = 0; i < value.length; i++) {
86
+ const c = value[i];
87
+ if (c !== null && typeof c === "object") out[i] = clone(c, visit, path === undefined ? undefined : `${path}[${i}]`, memo);
88
+ }
89
+ } else {
90
+ for (const k of Object.keys(value)) {
91
+ const c = value[k];
92
+ if (c !== null && typeof c === "object") out[k] = clone(c, visit, path === undefined ? undefined : `${path}.${k}`, memo);
93
+ }
94
+ }
95
+ return out;
96
+ }
97
+
8
98
  const STATE = Symbol.for("solid.container-trace-state");
9
99
  const state = globalThis[STATE] || (globalThis[STATE] = {
10
100
  materialized: new WeakMap(),
@@ -29,38 +119,16 @@ function toBorderForm(value, envelopeContainers) {
29
119
  const resolve = state.resolveTrace ;
30
120
  const share = state.shareIterable;
31
121
  if (!resolve && !share) return value;
32
- if (resolve) {
33
- const trace = resolve(value);
34
- if (trace) return {
35
- [TRACE]: trace
36
- };
37
- }
38
- if (share && isShareableIterable(value)) return share(value);
39
- if (Array.isArray(value)) {
40
- let out = value;
41
- for (let i = 0; i < value.length; i++) {
42
- const next = toBorderForm(value[i]);
43
- if (next !== value[i]) {
44
- if (out === value) out = value.slice();
45
- out[i] = next;
46
- }
47
- }
48
- return out;
49
- }
50
- if (Object.getPrototypeOf(value) === Object.prototype) {
51
- let out = value;
52
- for (const key of Object.keys(value)) {
53
- const next = toBorderForm(value[key]);
54
- if (next !== value[key]) {
55
- if (out === value) out = {
56
- ...value
57
- };
58
- out[key] = next;
59
- }
122
+ return rewriteTree(value, v => {
123
+ if (resolve) {
124
+ const trace = resolve(v);
125
+ if (trace) return {
126
+ [TRACE]: trace
127
+ };
60
128
  }
61
- return out;
62
- }
63
- return value;
129
+ if (share && isShareableIterable(v)) return share(v);
130
+ return DESCEND;
131
+ }, false);
64
132
  }
65
133
  function isShareableIterable(value) {
66
134
  try {
@@ -71,10 +139,10 @@ function isShareableIterable(value) {
71
139
  return false;
72
140
  }
73
141
  }
74
- function materialize(marker) {
142
+ function materialize(marker, claiming) {
75
143
  let value = state.materialized.get(marker.$tr);
76
144
  if (value === undefined) {
77
- value = state.materializeTrace(marker);
145
+ value = state.materializeTrace(marker, claiming);
78
146
  state.materialized.set(marker.$tr, value);
79
147
  if (value !== null && typeof value === "object") state.materializedValues.add(value);
80
148
  }
@@ -132,14 +200,14 @@ setContainerTraceStreamMint(iterable => {
132
200
  })();
133
201
  return stream;
134
202
  });
135
- const DEFAULT_WEB_PLUGINS = Object.freeze([AbortSignalPlugin,
203
+ const DEFAULT_WEB_PLUGINS = /* @__PURE__ */Object.freeze([AbortSignalPlugin,
136
204
  CustomEventPlugin, DOMExceptionPlugin, EventPlugin,
137
205
  FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin,
138
206
  ContainerTracePlugin]);
139
207
  function resolveSerializerPlugins(customPlugins) {
140
208
  return customPlugins ? [...customPlugins, ...DEFAULT_WEB_PLUGINS] : [...DEFAULT_WEB_PLUGINS];
141
209
  }
142
- const JSON_CODEC_DISABLED_FEATURES = Feature.RegExp;
210
+ const jsonCodecDisabledFeatures = () => Feature.RegExp;
143
211
  const JSON_CODEC_DEPTH_LIMIT = 64;
144
212
  function resolveCodecOptions({
145
213
  plugins,
@@ -149,13 +217,12 @@ function resolveCodecOptions({
149
217
  } = {}) {
150
218
  return {
151
219
  plugins: resolveSerializerPlugins(plugins),
152
- disabledFeatures: disabledFeatures === undefined ? JSON_CODEC_DISABLED_FEATURES : disabledFeatures,
220
+ disabledFeatures: disabledFeatures === undefined ? jsonCodecDisabledFeatures() : disabledFeatures,
153
221
  depthLimit: depthLimit === undefined ? JSON_CODEC_DEPTH_LIMIT : depthLimit,
154
222
  serializeErrorStacks
155
223
  };
156
224
  }
157
225
 
158
- Feature.AggregateError | Feature.BigIntTypedArray;
159
226
  const serializeOnlyDisabledFeatures = serializeErrorStacks => (serializeErrorStacks === undefined ? process.env.NODE_ENV === "development" : serializeErrorStacks) ? 0 : Feature.ErrorPrototypeStack;
160
227
  function createJSONSerializer({
161
228
  onData,
@@ -282,6 +349,7 @@ function observeFrame(frame) {
282
349
  }
283
350
 
284
351
  const FRAME_STREAM_HEADER = "X-Frame-Stream";
352
+ const FRAME_TIERS_HEADER = "X-Frame-Tiers";
285
353
  const FRAME_HAVE_HEADER = "X-Frame-Have";
286
354
  const FRAME_HAVE_BUDGET = 4096;
287
355
  function decodeHaveList(text) {
@@ -412,11 +480,27 @@ function withHoles(chunk, holes) {
412
480
  }
413
481
  return chunk;
414
482
  }
415
- function createFrameSink(emit, frame, have) {
483
+ function createFrameSink(write, frame, have, hooks) {
416
484
  const {
417
485
  id,
418
486
  version
419
487
  } = frame;
488
+ const tiers = new Set();
489
+ let staged = [];
490
+ const emit = chunk => {
491
+ if (swept) swept.emitted = true;
492
+ if (staged.length) {
493
+ chunk.tiers = staged;
494
+ staged = [];
495
+ }
496
+ write(chunk);
497
+ };
498
+ const needs = name => {
499
+ if (!tiers.has(name)) {
500
+ tiers.add(name);
501
+ staged.push(name);
502
+ }
503
+ };
420
504
  let conditional = false;
421
505
  const skipped = new Set();
422
506
  const attrText = new Map();
@@ -456,15 +540,38 @@ function createFrameSink(emit, frame, have) {
456
540
  let sweepScheduled = false;
457
541
  let closed = false;
458
542
  let epoch = 0;
543
+ let swept = null;
459
544
  const sweep = () => {
460
545
  epoch++;
461
- for (const b of [...bindings.values()]) {
462
- try {
463
- b.sweep();
464
- } catch (_) {
546
+ const pass = swept = {
547
+ ops: [],
548
+ emitted: false
549
+ };
550
+ try {
551
+ for (const b of [...bindings.values()]) {
552
+ try {
553
+ b.sweep();
554
+ } catch (_) {
555
+ }
465
556
  }
557
+ emitOps(pass.ops);
558
+ if (pass.emitted && hooks && hooks.onYield) hooks.onYield();
559
+ } finally {
560
+ swept = null;
466
561
  }
467
562
  };
563
+ const emitOps = ops => {
564
+ if (ops.length === 1) emit(Object.assign({
565
+ type: ops[0].type,
566
+ id,
567
+ version
568
+ }, ops[0]));else if (ops.length) emit({
569
+ type: "ops",
570
+ id,
571
+ version,
572
+ ops
573
+ });
574
+ };
468
575
  const scheduleSweep = () => {
469
576
  if (closed || sweepScheduled || !bindings.size) return;
470
577
  sweepScheduled = true;
@@ -508,6 +615,7 @@ function createFrameSink(emit, frame, have) {
508
615
  chunk.preloads.push(wirePreload(entry));
509
616
  }
510
617
  }
618
+ needs("assets");
511
619
  emit(chunk);
512
620
  }
513
621
  emit(withHoles({
@@ -583,6 +691,7 @@ function createFrameSink(emit, frame, have) {
583
691
  attrs: e.attrs
584
692
  }));
585
693
  }
694
+ needs("assets");
586
695
  emit(chunk);
587
696
  }
588
697
  emit(withHoles({
@@ -640,6 +749,7 @@ function createFrameSink(emit, frame, have) {
640
749
  },
641
750
  asset(type, value) {
642
751
  if (type === "module") {
752
+ needs("assets");
643
753
  emit({
644
754
  type: "assets",
645
755
  id,
@@ -648,6 +758,7 @@ function createFrameSink(emit, frame, have) {
648
758
  modules: [value]
649
759
  });
650
760
  } else if (type === "preload") {
761
+ needs("assets");
651
762
  emit({
652
763
  type: "assets",
653
764
  id,
@@ -657,14 +768,17 @@ function createFrameSink(emit, frame, have) {
657
768
  });
658
769
  }
659
770
  },
660
- end() {
661
- if (bindings.size) sweep();
771
+ end(bound) {
772
+ if (closed) return;
773
+ if (bindings.size && !swept) sweep();
662
774
  closed = true;
663
- emit({
775
+ const chunk = {
664
776
  type: "complete",
665
777
  id,
666
778
  version
667
- });
779
+ };
780
+ if (bound) chunk.bound = bound;
781
+ emit(chunk);
668
782
  },
669
783
  error(errorId, error) {
670
784
  emit({
@@ -685,6 +799,7 @@ function createFrameSink(emit, frame, have) {
685
799
  });
686
800
  },
687
801
  region(childId, html) {
802
+ needs("regions");
688
803
  emit({
689
804
  type: "html",
690
805
  id: childId,
@@ -693,26 +808,23 @@ function createFrameSink(emit, frame, have) {
693
808
  });
694
809
  },
695
810
  hole(key, html) {
696
- emit({
811
+ const op = {
697
812
  type: "hole",
698
- id,
699
- version,
700
813
  key,
701
814
  html,
702
815
  digest: textDigest(html)
703
- });
816
+ };
817
+ swept ? swept.ops.push(op) : emitOps([op]);
704
818
  },
705
819
  attr(key, attrs, removed) {
706
- const chunk = {
820
+ const op = {
707
821
  type: "attr",
708
- id,
709
- version,
710
822
  key,
711
823
  attrs,
712
824
  digest: textDigest(attrs)
713
825
  };
714
- if (removed && removed.length) chunk.removed = removed;
715
- emit(chunk);
826
+ if (removed && removed.length) op.removed = removed;
827
+ swept ? swept.ops.push(op) : emitOps([op]);
716
828
  },
717
829
  attrBaseline(key, text) {
718
830
  attrText.set(key, text);
@@ -734,6 +846,11 @@ function createFrameSink(emit, frame, have) {
734
846
  commit: scheduleSweep,
735
847
  get epoch() {
736
848
  return epoch;
849
+ },
850
+ needs,
851
+ announce() {
852
+ staged = [];
853
+ return [...tiers];
737
854
  }
738
855
  };
739
856
  }
@@ -755,6 +872,10 @@ function renderServerComponent(component, options = {}) {
755
872
  };
756
873
  }, options);
757
874
  }
875
+ const DEFAULT_MAX_YIELDS = 64;
876
+ const DEFAULT_MAX_DURATION_MS = 30_000;
877
+ const DISCONNECTED = Symbol("solid.frames.disconnected");
878
+ const ANNOUNCE = Symbol("solid.frames.announce");
758
879
  function frameStream(makeCode, options) {
759
880
  const {
760
881
  id = "",
@@ -764,30 +885,77 @@ function frameStream(makeCode, options) {
764
885
  id,
765
886
  version
766
887
  };
888
+ const bounded = !options.live;
889
+ const maxYields = bounded ? options.maxYields ?? DEFAULT_MAX_YIELDS : 0;
890
+ const maxDurationMs = bounded ? options.maxDurationMs ?? DEFAULT_MAX_DURATION_MS : 0;
767
891
  function stream(w) {
768
892
  const observation = observeFrame(frame);
769
- const emit = observation ? chunk => {
770
- observation.chunk(chunk);
893
+ const render = new AbortController();
894
+ const upstream = options.signal;
895
+ let ended = false;
896
+ let flushed = false;
897
+ let yields = 0;
898
+ let timer;
899
+ function finish() {
900
+ if (ended) return;
901
+ ended = true;
902
+ if (timer) clearTimeout(timer);
903
+ if (upstream) upstream.removeEventListener("abort", onSignal);
904
+ w.end && w.end();
905
+ }
906
+ function cut(bound) {
907
+ if (ended) return;
908
+ sink.end(bound);
909
+ observation && observation.settle("complete");
910
+ finish();
911
+ render.abort({
912
+ quiet: true,
913
+ bound
914
+ });
915
+ }
916
+ function onSignal() {
917
+ const gone = upstream.reason && upstream.reason[DISCONNECTED];
918
+ if (bounded && flushed && !gone) return cut("time");
919
+ finish();
920
+ render.abort(upstream.reason);
921
+ }
922
+ const emit = chunk => {
923
+ if (observation) observation.chunk(chunk);
771
924
  w.write(chunk);
772
- } : chunk => w.write(chunk);
773
- const sink = createFrameSink(emit, frame, options.resume && options.resume.have);
925
+ if (bounded && !flushed && chunk.type === "html" && chunk.id === id) {
926
+ flushed = true;
927
+ if (maxDurationMs > 0 && maxDurationMs !== Infinity) timer = setTimeout(() => cut("time"), maxDurationMs);
928
+ }
929
+ };
930
+ const sink = createFrameSink(emit, frame, options.resume && options.resume.have, bounded ? {
931
+ onYield() {
932
+ if (flushed && maxYields > 0 && ++yields >= maxYields) cut("yields");
933
+ }
934
+ } : undefined);
935
+ if (options.live) sink.needs("wire");
774
936
  w.write({
775
937
  type: "start",
776
938
  id,
777
939
  version
778
940
  });
941
+ if (upstream && upstream.aborted) return finish();
942
+ if (upstream) upstream.addEventListener("abort", onSignal, {
943
+ once: true
944
+ });
779
945
  const code = makeCode(sink, frame);
780
946
  try {
781
947
  renderToStream(() => serverOwned(code), {
782
948
  serializer: createJSONSerializer,
783
949
  ...options,
950
+ signal: render.signal,
784
951
  sink
785
952
  }).pipe({
786
953
  write() {},
787
954
  end() {
955
+ if (ended) return;
788
956
  sink.end();
789
957
  observation && observation.settle("complete");
790
- w.end && w.end();
958
+ finish();
791
959
  }
792
960
  });
793
961
  } catch (err) {
@@ -795,8 +963,9 @@ function frameStream(makeCode, options) {
795
963
  sink.error("", wire instanceof Error ? wire.message : String(wire));
796
964
  sink.end();
797
965
  observation && observation.settle("error", err);
798
- w.end && w.end();
966
+ finish();
799
967
  }
968
+ if (w[ANNOUNCE]) w[ANNOUNCE](sink.announce());
800
969
  }
801
970
  return {
802
971
  pipe: stream,
@@ -818,9 +987,56 @@ function frameStream(makeCode, options) {
818
987
  function slotRange(occurrence) {
819
988
  return {
820
989
  t: `<!--slot:${occurrence}:start--><!--slot:${occurrence}:end-->`,
821
- $slot: true
990
+ $slot: true,
991
+ $occurrence: occurrence
822
992
  };
823
993
  }
994
+ const RANGE_KEYS = new Set(["t", "h", "p", "then", "length", "slice", "constructor", "toString", "valueOf", "toJSON"]);
995
+ const NODE_KEYS = new Set(["t", "h", "p"]);
996
+ function isRangeKey(key) {
997
+ const c = key.charCodeAt(0);
998
+ return c === 36 || c >= 48 && c <= 57 || RANGE_KEYS.has(key);
999
+ }
1000
+ function slotProxy(range, occurrence, face, content, onData, needs) {
1001
+ return new Proxy(range, {
1002
+ get(target, key, receiver) {
1003
+ if (typeof key !== "string" || isRangeKey(key)) return Reflect.get(target, key, receiver);
1004
+ if (onData) onData = void onData();
1005
+ if (face !== SLOT_FACE_MARKUP) needs("bind");
1006
+ return slotValue(occurrence, key, content ? content[key] : undefined, face);
1007
+ }
1008
+ });
1009
+ }
1010
+ function argBorderForm(value, key, occurrence, needs) {
1011
+ return toBorderForm(withoutStandIns(value, key, occurrence, needs));
1012
+ }
1013
+ function withoutStandIns(value, key, occurrence, needs) {
1014
+ return rewriteTree(value, (v, path) => {
1015
+ if (isContainerTraced(v)) {
1016
+ needs("trace");
1017
+ return v;
1018
+ }
1019
+ if (Object.getPrototypeOf(v) === Object.prototype && isSlotValue(v)) {
1020
+ return undefined;
1021
+ }
1022
+ return DESCEND;
1023
+ }, true);
1024
+ }
1025
+ function slotFace(range, content) {
1026
+ if (content == null) return SLOT_FACE_DATA;
1027
+ if (typeof content !== "object" || Array.isArray(content)) return SLOT_FACE_MARKUP;
1028
+ if (isServerContent(content)) {
1029
+ let data = false;
1030
+ for (const key in content) {
1031
+ if (!NODE_KEYS.has(key)) {
1032
+ data = true;
1033
+ break;
1034
+ }
1035
+ }
1036
+ if (!data) return SLOT_FACE_MARKUP;
1037
+ }
1038
+ return SLOT_FACE_DATA;
1039
+ }
824
1040
  const OCCURRENCE_UNSAFE = /[^A-Za-z0-9_.-]/g;
825
1041
  function encodeOccurrenceKey(key) {
826
1042
  return String(key).replace(OCCURRENCE_UNSAFE, c => {
@@ -829,14 +1045,58 @@ function encodeOccurrenceKey(key) {
829
1045
  });
830
1046
  }
831
1047
  function occurrenceId(prop, raw, counts) {
832
- const k = raw.$key;
833
- if (typeof k === "string" || typeof k === "number") {
834
- return `${prop}#${encodeOccurrenceKey(k)}`;
835
- }
1048
+ const keyed = keyedId(prop, raw);
1049
+ if (keyed !== undefined) return keyed;
836
1050
  const n = counts[prop] || 0;
837
1051
  counts[prop] = n + 1;
838
1052
  return `${prop}#${n}`;
839
1053
  }
1054
+ function keyedId(prop, raw) {
1055
+ const k = raw.$key;
1056
+ return typeof k === "string" || typeof k === "number" ? `${prop}#${encodeOccurrenceKey(k)}` : undefined;
1057
+ }
1058
+ function structuralArgsKey(raw) {
1059
+ let out = "";
1060
+ let ancestors;
1061
+ const walk = (v, top) => {
1062
+ if (v === null) out += "N";else if (typeof v === "string") out += "s" + v.length + ":" + v;else if (typeof v === "boolean") out += v ? "T" : "F";else if (typeof v === "undefined") out += "U";else if (typeof v === "number") out += "n" + v + ";";else if (typeof v === "bigint") out += "b" + v + ";";else if (typeof v !== "object") return false;else {
1063
+ const isArray = Array.isArray(v);
1064
+ if (!isArray) {
1065
+ const proto = Object.getPrototypeOf(v);
1066
+ if (proto !== Object.prototype && proto !== null) return false;
1067
+ }
1068
+ if (ancestors === undefined) ancestors = new Set();else if (ancestors.has(v)) return false;
1069
+ ancestors.add(v);
1070
+ try {
1071
+ if (isArray) {
1072
+ out += "[";
1073
+ for (const item of v) if (!walk(item)) return false;
1074
+ out += "]";
1075
+ } else {
1076
+ out += "{";
1077
+ for (const k of Object.keys(v).sort()) {
1078
+ if (top && k === "$key") continue;
1079
+ const desc = Object.getOwnPropertyDescriptor(v, k);
1080
+ if (desc.get || desc.set) return false;
1081
+ out += "k" + k.length + ":" + k;
1082
+ if (!walk(desc.value)) return false;
1083
+ }
1084
+ out += "}";
1085
+ }
1086
+ } finally {
1087
+ ancestors.delete(v);
1088
+ }
1089
+ }
1090
+ return true;
1091
+ };
1092
+ return walk(raw, true) ? out : undefined;
1093
+ }
1094
+ function repeatKey(prop, raw) {
1095
+ const keyed = keyedId(prop, raw);
1096
+ if (keyed !== undefined) return keyed;
1097
+ const structural = structuralArgsKey(raw);
1098
+ return structural === undefined ? undefined : prop + "\0" + structural;
1099
+ }
840
1100
  function isAsyncValue(v) {
841
1101
  return !!v && typeof v === "object" && (typeof v.then === "function" || typeof v[Symbol.asyncIterator] === "function");
842
1102
  }
@@ -865,6 +1125,7 @@ function suppressedFill(render) {
865
1125
  function createDocumentSlotProps(clientProps, frameId) {
866
1126
  const counts = Object.create(null);
867
1127
  const getters = new Map();
1128
+ const repeats = new Map();
868
1129
  const range = (occurrence, content) => {
869
1130
  const r = [{
870
1131
  t: `<!--slot:${occurrence}:start-->`
@@ -872,7 +1133,10 @@ function createDocumentSlotProps(clientProps, frameId) {
872
1133
  t: `<!--slot:${occurrence}:end-->`
873
1134
  }];
874
1135
  r.$slot = true;
875
- return r;
1136
+ r.$occurrence = occurrence;
1137
+ const face = slotFace(r, content);
1138
+ r.$face = face;
1139
+ return slotProxy(r, occurrence, face, face === SLOT_FACE_DATA ? content : undefined, undefined, documentNeeds);
876
1140
  };
877
1141
  const zoneOwner = getOwner ? getOwner() : null;
878
1142
  const scoped = (occurrence, render) => {
@@ -896,147 +1160,170 @@ function createDocumentSlotProps(clientProps, frameId) {
896
1160
  if (!fn) {
897
1161
  fn = (...callArgs) => {
898
1162
  if (callArgs.length === 0 || callArgs[0] === undefined) {
899
- return suppressedFill(() => scoped(prop, () => {
1163
+ const rk = prop + "\0";
1164
+ const repeat = repeats.get(rk);
1165
+ if (repeat) return repeat;
1166
+ const out = suppressedFill(() => scoped(prop, () => {
900
1167
  const value = clientProps[prop];
901
1168
  return range(prop, typeof value === "function" ? value() : value);
902
1169
  }));
1170
+ if (out.$face === SLOT_FACE_DATA) repeats.set(rk, out);
1171
+ return out;
903
1172
  }
904
1173
  const raw = callArgs[0];
1174
+ const rk = repeatKey(prop, raw);
1175
+ const repeat = rk !== undefined && repeats.get(rk);
1176
+ if (repeat) return repeat;
905
1177
  const occurrence = occurrenceId(prop, raw, counts);
906
1178
  const slot = clientProps[prop];
907
1179
  if (typeof slot !== "function") return range(occurrence, undefined);
908
- const resolved = {};
909
- const liveArgs = sharedConfig.context && sharedConfig.context.live && sharedConfig.context.live.args;
910
- const vals = {};
911
- const evals = {};
912
- const states = {};
913
- const minted = {};
914
- for (const key of Object.keys(raw)) {
915
- if (key === "$key") continue;
916
- const desc = Object.getOwnPropertyDescriptor(raw, key);
917
- let evaluate = null;
918
- let value;
919
- if (desc.get) {
920
- const get = desc.get;
921
- evaluate = () => unwrapThunks(get.call(raw));
922
- } else {
923
- value = desc.value;
924
- if (typeof value === "function") {
925
- const fn = value;
926
- evaluate = () => unwrapThunks(fn);
1180
+ const context = sharedConfig.context;
1181
+ const recordKey = `sc:slot:${frameId}:${occurrence}`;
1182
+ let settleRecord;
1183
+ if (context && context.async) {
1184
+ context.serialize(recordKey, new Promise(resolve => settleRecord = resolve));
1185
+ }
1186
+ try {
1187
+ const resolved = {};
1188
+ const liveArgs = sharedConfig.context && sharedConfig.context.live && sharedConfig.context.live.args;
1189
+ const vals = {};
1190
+ const evals = {};
1191
+ const states = {};
1192
+ const minted = {};
1193
+ for (const key of Object.keys(raw)) {
1194
+ if (key === "$key") continue;
1195
+ const desc = Object.getOwnPropertyDescriptor(raw, key);
1196
+ let evaluate = null;
1197
+ let value;
1198
+ if (desc.get) {
1199
+ const get = desc.get;
1200
+ evaluate = () => unwrapThunks(get.call(raw));
1201
+ } else {
1202
+ value = desc.value;
1203
+ if (typeof value === "function") {
1204
+ const fn = value;
1205
+ evaluate = () => unwrapThunks(fn);
1206
+ }
927
1207
  }
1208
+ if (evaluate) {
1209
+ evals[key] = evaluate;
1210
+ const stampBefore = scopeStamp();
1211
+ try {
1212
+ value = evaluate();
1213
+ states[key] = {
1214
+ settled: true,
1215
+ last: value
1216
+ };
1217
+ } catch (err) {
1218
+ const blocked = ssrHandleError && ssrHandleError(err);
1219
+ if (!blocked) throw err;
1220
+ const state = states[key] = {
1221
+ settled: false,
1222
+ last: undefined
1223
+ };
1224
+ value = retryArgUntilSettled(evaluate, blocked, key, occurrence, v => {
1225
+ state.settled = true;
1226
+ state.last = v;
1227
+ if (liveArgs) liveArgs.commit();
1228
+ });
1229
+ }
1230
+ if (scopeStamp() !== stampBefore) minted[key] = true;
1231
+ }
1232
+ vals[key] = value;
928
1233
  }
929
- if (evaluate) {
930
- evals[key] = evaluate;
931
- const stampBefore = scopeStamp();
932
- try {
933
- value = evaluate();
934
- states[key] = {
935
- settled: true,
936
- last: value
1234
+ const regions = [];
1235
+ for (const key of Object.keys(vals)) {
1236
+ const value = vals[key];
1237
+ if (isContainerTraced(value)) {
1238
+ documentNeeds("trace");
1239
+ resolved[key] = value;
1240
+ } else if (isServerContent(value)) {
1241
+ const childId = `${frameId}.${occurrence}.${key}`;
1242
+ const region = {
1243
+ key,
1244
+ childId,
1245
+ value,
1246
+ used: false,
1247
+ locked: false
937
1248
  };
938
- } catch (err) {
939
- const blocked = ssrHandleError && ssrHandleError(err);
940
- if (!blocked) throw err;
941
- const state = states[key] = {
942
- settled: false,
943
- last: undefined
1249
+ regions.push(region);
1250
+ documentNeeds("regions");
1251
+ resolved[key] = () => {
1252
+ if (region.locked) return [];
1253
+ region.used = true;
1254
+ return [{
1255
+ t: frameElementOpen(childId)
1256
+ }, value, {
1257
+ t: FRAME_ELEMENT_CLOSE
1258
+ }];
944
1259
  };
945
- value = retryArgUntilSettled(evaluate, blocked, key, occurrence, v => {
946
- state.settled = true;
947
- state.last = v;
948
- if (liveArgs) liveArgs.commit();
1260
+ } else if (ssrAsyncValue && isAsyncValue(value)) {
1261
+ let readable = value;
1262
+ if (typeof value.then !== "function") {
1263
+ const {
1264
+ first,
1265
+ rest
1266
+ } = tapFirstYield(value);
1267
+ readable = first;
1268
+ vals[key] = rest;
1269
+ }
1270
+ const read = ssrAsyncValue(readable);
1271
+ Object.defineProperty(resolved, key, {
1272
+ get: read,
1273
+ enumerable: true,
1274
+ configurable: true
949
1275
  });
1276
+ } else {
1277
+ resolved[key] = vals[key] = withoutStandIns(value, key, occurrence, documentNeeds);
950
1278
  }
951
- if (scopeStamp() !== stampBefore) minted[key] = true;
952
1279
  }
953
- vals[key] = value;
954
- }
955
- const regions = [];
956
- for (const key of Object.keys(vals)) {
957
- const value = vals[key];
958
- if (isContainerTraced(value)) {
959
- resolved[key] = value;
960
- } else if (isServerContent(value)) {
961
- const childId = `${frameId}.${occurrence}.${key}`;
962
- const region = {
963
- key,
964
- childId,
965
- value,
966
- used: false,
967
- locked: false
968
- };
969
- regions.push(region);
970
- resolved[key] = () => {
971
- if (region.locked) return [];
972
- region.used = true;
973
- return [{
974
- t: frameElementOpen(childId)
975
- }, value, {
976
- t: FRAME_ELEMENT_CLOSE
977
- }];
978
- };
979
- } else if (ssrAsyncValue && isAsyncValue(value)) {
980
- let readable = value;
981
- if (typeof value.then !== "function") {
982
- const {
983
- first,
984
- rest
985
- } = tapFirstYield(value);
986
- readable = first;
987
- vals[key] = rest;
1280
+ const out = suppressedFill(() => scoped(occurrence, () => range(occurrence, slot(resolved))));
1281
+ const unused = regions.filter(r => !r.used);
1282
+ if (context) {
1283
+ const args = {};
1284
+ for (const key of Object.keys(vals)) {
1285
+ const value = vals[key];
1286
+ const region = regions.find(r => r.key === key);
1287
+ if (region) {
1288
+ args[key] = {
1289
+ $frame: region.childId
1290
+ };
1291
+ continue;
1292
+ }
1293
+ if (!isContainerTraced(value) && isServerContent(value)) continue;
1294
+ args[key] = argBorderForm(value, key, occurrence, documentNeeds);
988
1295
  }
989
- const read = ssrAsyncValue(readable);
990
- Object.defineProperty(resolved, key, {
991
- get: read,
992
- enumerable: true,
993
- configurable: true
1296
+ settleRecord ? settleRecord({
1297
+ ...args
1298
+ }) : context.serialize(recordKey, {
1299
+ ...args
994
1300
  });
995
- } else {
996
- resolved[key] = value;
997
- }
998
- }
999
- const out = suppressedFill(() => scoped(occurrence, () => range(occurrence, slot(resolved))));
1000
- const unused = regions.filter(r => !r.used);
1001
- if (sharedConfig.context) {
1002
- const args = {};
1003
- for (const key of Object.keys(vals)) {
1004
- const value = vals[key];
1005
- const region = regions.find(r => r.key === key);
1006
- if (region) {
1007
- args[key] = {
1008
- $frame: region.childId
1009
- };
1010
- continue;
1301
+ for (const region of unused) {
1302
+ region.locked = true;
1303
+ context.serialize(`sc:region:${region.childId}`, resolveRegionHtml(context, region.value));
1011
1304
  }
1012
- if (!isContainerTraced(value) && isServerContent(value)) continue;
1013
- args[key] = toBorderForm(value);
1014
- }
1015
- sharedConfig.context.serialize(`sc:slot:${frameId}:${occurrence}`, {
1016
- ...args
1017
- });
1018
- for (const region of unused) {
1019
- region.locked = true;
1020
- sharedConfig.context.serialize(`sc:region:${region.childId}`, resolveRegionHtml(sharedConfig.context, region.value));
1021
- }
1022
- if (liveArgs) {
1023
- for (const key of Object.keys(evals)) {
1024
- if (regions.some(r => r.key === key)) continue;
1025
- if (minted[key]) continue;
1026
- const ledgerKey = `${frameId}:${occurrence}:${key}`;
1027
- openArgBinding(liveArgs, ledgerKey, occurrence, key, evals[key], states[key], value => {
1028
- args[key] = toBorderForm(value);
1029
- liveArgs.slot(frameId, occurrence, {
1030
- ...args
1305
+ if (liveArgs) {
1306
+ for (const key of Object.keys(evals)) {
1307
+ if (regions.some(r => r.key === key)) continue;
1308
+ if (minted[key]) continue;
1309
+ const ledgerKey = `${frameId}:${occurrence}:${key}`;
1310
+ openArgBinding(liveArgs, ledgerKey, occurrence, key, evals[key], states[key], value => {
1311
+ args[key] = argBorderForm(value, key, occurrence, documentNeeds);
1312
+ liveArgs.slot(frameId, occurrence, {
1313
+ ...args
1314
+ });
1031
1315
  });
1032
- });
1316
+ }
1033
1317
  }
1034
1318
  }
1319
+ if (rk !== undefined && (rk === occurrence || out.$face === SLOT_FACE_DATA)) repeats.has(rk) || repeats.set(rk, out);
1320
+ return out;
1321
+ } catch (error) {
1322
+ settleRecord && settleRecord(undefined);
1323
+ throw error;
1035
1324
  }
1036
- return out;
1037
1325
  };
1038
1326
  fn.$lhSkip = true;
1039
- fn[CLAIM_PROP] = prop;
1040
1327
  getters.set(prop, fn);
1041
1328
  }
1042
1329
  return fn;
@@ -1050,6 +1337,17 @@ function frameElementOpen(id) {
1050
1337
  return `<${FRAME_TAG} ${FRAME_ID_ATTR}="${escaped}" style="display:contents">`;
1051
1338
  }
1052
1339
  const FRAME_ELEMENT_CLOSE = `</${FRAME_TAG}>`;
1340
+ function documentNeeds(name) {
1341
+ const ctx = sharedConfig.context;
1342
+ const live = ctx && ctx.live;
1343
+ if (!live || !ctx.serialize) return;
1344
+ const tiers = live.tiers || (live.tiers = []);
1345
+ if (tiers.includes(name)) return;
1346
+ tiers.push(name);
1347
+ ctx.serialize("sc:tiers", tiers.slice());
1348
+ const url = live.tierUrls && live.tierUrls[name];
1349
+ if (url && ctx.registerAsset) ctx.registerAsset("module", url);
1350
+ }
1053
1351
  function armDocumentLiveHoles(ctx) {
1054
1352
  if (!ctx || ctx.liveHoles !== undefined) return;
1055
1353
  const live = ctx.live;
@@ -1061,7 +1359,7 @@ function armDocumentLiveHoles(ctx) {
1061
1359
  }
1062
1360
  return;
1063
1361
  }
1064
- if (!live || !ctx.async || ctx.noHydrate || !ctx.serialize || typeof ReadableStream !== "function") {
1362
+ if (!live || !ctx.async || !ctx.serialize || typeof ReadableStream !== "function") {
1065
1363
  ctx.liveHoles = null;
1066
1364
  if (live) live.holes = null;
1067
1365
  return;
@@ -1070,14 +1368,27 @@ function armDocumentLiveHoles(ctx) {
1070
1368
  let epoch = 0;
1071
1369
  let sweepScheduled = false;
1072
1370
  let closed = false;
1371
+ let swept = null;
1073
1372
  const sweep = () => {
1074
1373
  epoch++;
1075
- for (const b of [...bindings.values()]) {
1076
- try {
1077
- b.sweep();
1078
- } catch (_) {
1374
+ const ops = swept = [];
1375
+ try {
1376
+ for (const b of [...bindings.values()]) {
1377
+ try {
1378
+ b.sweep();
1379
+ } catch (_) {
1380
+ }
1079
1381
  }
1382
+ } finally {
1383
+ swept = null;
1080
1384
  }
1385
+ pushOps(ops);
1386
+ };
1387
+ const pushOps = ops => {
1388
+ if (ops.length === 1) push(ops[0]);else if (ops.length) push({
1389
+ type: "ops",
1390
+ ops
1391
+ });
1081
1392
  };
1082
1393
  const scheduleSweep = () => {
1083
1394
  if (closed || sweepScheduled || !bindings.size) return;
@@ -1104,12 +1415,13 @@ function armDocumentLiveHoles(ctx) {
1104
1415
  bindings.delete(key);
1105
1416
  },
1106
1417
  hole(key, html) {
1107
- push({
1418
+ const op = {
1108
1419
  type: "hole",
1109
1420
  key,
1110
1421
  html,
1111
1422
  digest: textDigest(html)
1112
- });
1423
+ };
1424
+ swept ? swept.push(op) : pushOps([op]);
1113
1425
  },
1114
1426
  attr(key, attrs, removed) {
1115
1427
  const op = {
@@ -1119,7 +1431,7 @@ function armDocumentLiveHoles(ctx) {
1119
1431
  digest: textDigest(attrs)
1120
1432
  };
1121
1433
  if (removed && removed.length) op.removed = removed;
1122
- push(op);
1434
+ swept ? swept.push(op) : pushOps([op]);
1123
1435
  },
1124
1436
  error(key, error) {
1125
1437
  push({
@@ -1152,6 +1464,13 @@ function armDocumentLiveHoles(ctx) {
1152
1464
  },
1153
1465
  commit: scheduleSweep
1154
1466
  };
1467
+ live.error = (fid, error) => {
1468
+ push({
1469
+ type: "error",
1470
+ fid,
1471
+ error
1472
+ });
1473
+ };
1155
1474
  live.end = () => {
1156
1475
  if (closed) return;
1157
1476
  if (bindings.size) sweep();
@@ -1161,7 +1480,8 @@ function armDocumentLiveHoles(ctx) {
1161
1480
  }
1162
1481
  function frameTransformDirectResult(value, {
1163
1482
  id,
1164
- args
1483
+ args,
1484
+ tierUrls
1165
1485
  }) {
1166
1486
  if (typeof value !== "function") return value;
1167
1487
  const component = value;
@@ -1169,10 +1489,21 @@ function frameTransformDirectResult(value, {
1169
1489
  t: frameElementOpen(id)
1170
1490
  },
1171
1491
  serverOwned(() => {
1172
- armDocumentLiveHoles(sharedConfig.context);
1173
- sharedConfig.context.claims = CLAIMS_DOCUMENT;
1174
- const slotProps = createDocumentSlotProps(props, id);
1175
- return serverComponentScope(() => component(slotProps), !!wrapped[LIVE_SOURCE]);
1492
+ const page = sharedConfig.context;
1493
+ armDocumentLiveHoles(page);
1494
+ if (tierUrls && page && page.live && !page.live.tierUrls) page.live.tierUrls = tierUrls;
1495
+ const ctx = Object.create(page);
1496
+ ctx.claims = CLAIMS_DOCUMENT;
1497
+ ctx.frameId = id;
1498
+ sharedConfig.context = ctx;
1499
+ try {
1500
+ const slotProps = createDocumentSlotProps(props, id);
1501
+ const live = !!wrapped[LIVE_SOURCE];
1502
+ if (live) documentNeeds("wire");
1503
+ return serverComponentScope(() => component(slotProps), live);
1504
+ } finally {
1505
+ sharedConfig.context = page;
1506
+ }
1176
1507
  }), {
1177
1508
  t: FRAME_ELEMENT_CLOSE
1178
1509
  }];
@@ -1280,6 +1611,8 @@ function openArgBinding(sink, ledgerKey, occurrence, key, evaluate, state, emit)
1280
1611
  function createSlotProps(sink, frame) {
1281
1612
  const counts = Object.create(null);
1282
1613
  const getters = new Map();
1614
+ const repeats = new Map();
1615
+ const needs = sink.needs || (() => {});
1283
1616
  return new Proxy(Object.create(null), {
1284
1617
  has() {
1285
1618
  return true;
@@ -1291,8 +1624,11 @@ function createSlotProps(sink, frame) {
1291
1624
  if (!fn) {
1292
1625
  fn = (...callArgs) => {
1293
1626
  if (callArgs.length === 0 || callArgs[0] === undefined) {
1294
- return slotRange(prop);
1627
+ return slotProxy(slotRange(prop), prop, SLOT_FACE_STREAM, undefined, undefined, needs);
1295
1628
  }
1629
+ const rk = repeatKey(prop, callArgs[0]);
1630
+ const repeat = rk !== undefined && repeats.get(rk);
1631
+ if (repeat) return repeat;
1296
1632
  const live = sharedConfig.context && sharedConfig.context.liveHoles;
1297
1633
  if (live) {
1298
1634
  if (live.sweeping) {
@@ -1369,7 +1705,7 @@ function createSlotProps(sink, frame) {
1369
1705
  };
1370
1706
  } else {
1371
1707
  const ref = `arg:${occurrence}:${key}`;
1372
- ctx.serialize(ref, toBorderForm(value, true));
1708
+ ctx.serialize(ref, argBorderForm(value, key, occurrence, needs));
1373
1709
  args[key] = {
1374
1710
  $ref: ref
1375
1711
  };
@@ -1401,7 +1737,7 @@ function createSlotProps(sink, frame) {
1401
1737
  } else {
1402
1738
  const ref = `arg:${occurrence}:${key}@${sink.nextArgRef(ledgerKey)}`;
1403
1739
  sink.mintRef(ref);
1404
- ctx.serialize(ref, toBorderForm(value));
1740
+ ctx.serialize(ref, argBorderForm(value, key, occurrence, needs));
1405
1741
  args[key] = {
1406
1742
  $ref: ref
1407
1743
  };
@@ -1411,10 +1747,12 @@ function createSlotProps(sink, frame) {
1411
1747
  });
1412
1748
  });
1413
1749
  }
1414
- return slotRange(occurrence);
1750
+ const keyed = rk === occurrence;
1751
+ const out = slotProxy(slotRange(occurrence), occurrence, SLOT_FACE_STREAM, undefined, rk === undefined || keyed ? undefined : () => repeats.has(rk) || repeats.set(rk, out), needs);
1752
+ if (keyed) repeats.set(rk, out);
1753
+ return out;
1415
1754
  };
1416
1755
  fn.$lhSkip = true;
1417
- fn[CLAIM_PROP] = prop;
1418
1756
  getters.set(prop, fn);
1419
1757
  }
1420
1758
  return fn;
@@ -1469,9 +1807,6 @@ function serverComponentResponse(component, options = {}, init = {}) {
1469
1807
  } catch (_) {}
1470
1808
  };
1471
1809
  if (teardown.signal.aborted) return end();
1472
- teardown.signal.addEventListener("abort", end, {
1473
- once: true
1474
- });
1475
1810
  if (live) stopLive = armLiveBody(controller, () => {
1476
1811
  closed = true;
1477
1812
  disarm();
@@ -1486,14 +1821,19 @@ function serverComponentResponse(component, options = {}, init = {}) {
1486
1821
  closed = true;
1487
1822
  }
1488
1823
  },
1489
- end
1824
+ end,
1825
+ [ANNOUNCE](tiers) {
1826
+ if (tiers.length) headers.set(FRAME_TIERS_HEADER, tiers.join(","));
1827
+ }
1490
1828
  });
1491
1829
  },
1492
1830
  cancel() {
1493
1831
  closed = true;
1494
1832
  disarm();
1495
1833
  if (stopLive) stopLive();
1496
- teardown.abort();
1834
+ teardown.abort({
1835
+ [DISCONNECTED]: true
1836
+ });
1497
1837
  }
1498
1838
  });
1499
1839
  return new Response(body, {
@@ -1695,7 +2035,9 @@ function frameFlightResponse({
1695
2035
  cancel() {
1696
2036
  closed = true;
1697
2037
  disarm();
1698
- teardown.abort();
2038
+ teardown.abort({
2039
+ [DISCONNECTED]: true
2040
+ });
1699
2041
  }
1700
2042
  });
1701
2043
  return new Response(body, {
@@ -1710,4 +2052,4 @@ function asyncArg(value) {
1710
2052
  return value;
1711
2053
  }
1712
2054
 
1713
- export { FRAME_HAVE_BUDGET, FRAME_HAVE_HEADER, FRAME_STREAM_HEADER, SERVER_COMPONENT_BOOTSTRAP, ServerComponentPlugin, asyncArg, createFrameSink, frameTransformDirectResult, frameTransformFlightResult, frameTransformResult, isFrameStreamResponse, renderServerComponent, renderToFrameStream, serverComponentResponse };
2055
+ export { FRAME_HAVE_BUDGET, FRAME_HAVE_HEADER, FRAME_STREAM_HEADER, FRAME_TIERS_HEADER, SERVER_COMPONENT_BOOTSTRAP, ServerComponentPlugin, asyncArg, createFrameSink, frameTransformDirectResult, frameTransformFlightResult, frameTransformResult, isFrameStreamResponse, renderServerComponent, renderToFrameStream, serverComponentResponse };