@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,
@@ -281,6 +348,7 @@ function observeFrame(frame) {
281
348
  }
282
349
 
283
350
  const FRAME_STREAM_HEADER = "X-Frame-Stream";
351
+ const FRAME_TIERS_HEADER = "X-Frame-Tiers";
284
352
  const FRAME_HAVE_HEADER = "X-Frame-Have";
285
353
  const FRAME_HAVE_BUDGET = 4096;
286
354
  function decodeHaveList(text) {
@@ -411,11 +479,27 @@ function withHoles(chunk, holes) {
411
479
  }
412
480
  return chunk;
413
481
  }
414
- function createFrameSink(emit, frame, have) {
482
+ function createFrameSink(write, frame, have, hooks) {
415
483
  const {
416
484
  id,
417
485
  version
418
486
  } = frame;
487
+ const tiers = new Set();
488
+ let staged = [];
489
+ const emit = chunk => {
490
+ if (swept) swept.emitted = true;
491
+ if (staged.length) {
492
+ chunk.tiers = staged;
493
+ staged = [];
494
+ }
495
+ write(chunk);
496
+ };
497
+ const needs = name => {
498
+ if (!tiers.has(name)) {
499
+ tiers.add(name);
500
+ staged.push(name);
501
+ }
502
+ };
419
503
  let conditional = false;
420
504
  const skipped = new Set();
421
505
  const attrText = new Map();
@@ -455,15 +539,38 @@ function createFrameSink(emit, frame, have) {
455
539
  let sweepScheduled = false;
456
540
  let closed = false;
457
541
  let epoch = 0;
542
+ let swept = null;
458
543
  const sweep = () => {
459
544
  epoch++;
460
- for (const b of [...bindings.values()]) {
461
- try {
462
- b.sweep();
463
- } catch (_) {
545
+ const pass = swept = {
546
+ ops: [],
547
+ emitted: false
548
+ };
549
+ try {
550
+ for (const b of [...bindings.values()]) {
551
+ try {
552
+ b.sweep();
553
+ } catch (_) {
554
+ }
464
555
  }
556
+ emitOps(pass.ops);
557
+ if (pass.emitted && hooks && hooks.onYield) hooks.onYield();
558
+ } finally {
559
+ swept = null;
465
560
  }
466
561
  };
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
+ };
467
574
  const scheduleSweep = () => {
468
575
  if (closed || sweepScheduled || !bindings.size) return;
469
576
  sweepScheduled = true;
@@ -507,6 +614,7 @@ function createFrameSink(emit, frame, have) {
507
614
  chunk.preloads.push(wirePreload(entry));
508
615
  }
509
616
  }
617
+ needs("assets");
510
618
  emit(chunk);
511
619
  }
512
620
  emit(withHoles({
@@ -582,6 +690,7 @@ function createFrameSink(emit, frame, have) {
582
690
  attrs: e.attrs
583
691
  }));
584
692
  }
693
+ needs("assets");
585
694
  emit(chunk);
586
695
  }
587
696
  emit(withHoles({
@@ -639,6 +748,7 @@ function createFrameSink(emit, frame, have) {
639
748
  },
640
749
  asset(type, value) {
641
750
  if (type === "module") {
751
+ needs("assets");
642
752
  emit({
643
753
  type: "assets",
644
754
  id,
@@ -647,6 +757,7 @@ function createFrameSink(emit, frame, have) {
647
757
  modules: [value]
648
758
  });
649
759
  } else if (type === "preload") {
760
+ needs("assets");
650
761
  emit({
651
762
  type: "assets",
652
763
  id,
@@ -656,14 +767,17 @@ function createFrameSink(emit, frame, have) {
656
767
  });
657
768
  }
658
769
  },
659
- end() {
660
- if (bindings.size) sweep();
770
+ end(bound) {
771
+ if (closed) return;
772
+ if (bindings.size && !swept) sweep();
661
773
  closed = true;
662
- emit({
774
+ const chunk = {
663
775
  type: "complete",
664
776
  id,
665
777
  version
666
- });
778
+ };
779
+ if (bound) chunk.bound = bound;
780
+ emit(chunk);
667
781
  },
668
782
  error(errorId, error) {
669
783
  emit({
@@ -684,6 +798,7 @@ function createFrameSink(emit, frame, have) {
684
798
  });
685
799
  },
686
800
  region(childId, html) {
801
+ needs("regions");
687
802
  emit({
688
803
  type: "html",
689
804
  id: childId,
@@ -692,26 +807,23 @@ function createFrameSink(emit, frame, have) {
692
807
  });
693
808
  },
694
809
  hole(key, html) {
695
- emit({
810
+ const op = {
696
811
  type: "hole",
697
- id,
698
- version,
699
812
  key,
700
813
  html,
701
814
  digest: textDigest(html)
702
- });
815
+ };
816
+ swept ? swept.ops.push(op) : emitOps([op]);
703
817
  },
704
818
  attr(key, attrs, removed) {
705
- const chunk = {
819
+ const op = {
706
820
  type: "attr",
707
- id,
708
- version,
709
821
  key,
710
822
  attrs,
711
823
  digest: textDigest(attrs)
712
824
  };
713
- if (removed && removed.length) chunk.removed = removed;
714
- emit(chunk);
825
+ if (removed && removed.length) op.removed = removed;
826
+ swept ? swept.ops.push(op) : emitOps([op]);
715
827
  },
716
828
  attrBaseline(key, text) {
717
829
  attrText.set(key, text);
@@ -733,6 +845,11 @@ function createFrameSink(emit, frame, have) {
733
845
  commit: scheduleSweep,
734
846
  get epoch() {
735
847
  return epoch;
848
+ },
849
+ needs,
850
+ announce() {
851
+ staged = [];
852
+ return [...tiers];
736
853
  }
737
854
  };
738
855
  }
@@ -754,6 +871,10 @@ function renderServerComponent(component, options = {}) {
754
871
  };
755
872
  }, options);
756
873
  }
874
+ const DEFAULT_MAX_YIELDS = 64;
875
+ const DEFAULT_MAX_DURATION_MS = 30_000;
876
+ const DISCONNECTED = Symbol("solid.frames.disconnected");
877
+ const ANNOUNCE = Symbol("solid.frames.announce");
757
878
  function frameStream(makeCode, options) {
758
879
  const {
759
880
  id = "",
@@ -763,30 +884,77 @@ function frameStream(makeCode, options) {
763
884
  id,
764
885
  version
765
886
  };
887
+ const bounded = !options.live;
888
+ const maxYields = bounded ? options.maxYields ?? DEFAULT_MAX_YIELDS : 0;
889
+ const maxDurationMs = bounded ? options.maxDurationMs ?? DEFAULT_MAX_DURATION_MS : 0;
766
890
  function stream(w) {
767
891
  const observation = observeFrame(frame);
768
- const emit = observation ? chunk => {
769
- observation.chunk(chunk);
892
+ const render = new AbortController();
893
+ const upstream = options.signal;
894
+ let ended = false;
895
+ let flushed = false;
896
+ let yields = 0;
897
+ let timer;
898
+ function finish() {
899
+ if (ended) return;
900
+ ended = true;
901
+ if (timer) clearTimeout(timer);
902
+ if (upstream) upstream.removeEventListener("abort", onSignal);
903
+ w.end && w.end();
904
+ }
905
+ function cut(bound) {
906
+ if (ended) return;
907
+ sink.end(bound);
908
+ observation && observation.settle("complete");
909
+ finish();
910
+ render.abort({
911
+ quiet: true,
912
+ bound
913
+ });
914
+ }
915
+ function onSignal() {
916
+ const gone = upstream.reason && upstream.reason[DISCONNECTED];
917
+ if (bounded && flushed && !gone) return cut("time");
918
+ finish();
919
+ render.abort(upstream.reason);
920
+ }
921
+ const emit = chunk => {
922
+ if (observation) observation.chunk(chunk);
770
923
  w.write(chunk);
771
- } : chunk => w.write(chunk);
772
- const sink = createFrameSink(emit, frame, options.resume && options.resume.have);
924
+ if (bounded && !flushed && chunk.type === "html" && chunk.id === id) {
925
+ flushed = true;
926
+ if (maxDurationMs > 0 && maxDurationMs !== Infinity) timer = setTimeout(() => cut("time"), maxDurationMs);
927
+ }
928
+ };
929
+ const sink = createFrameSink(emit, frame, options.resume && options.resume.have, bounded ? {
930
+ onYield() {
931
+ if (flushed && maxYields > 0 && ++yields >= maxYields) cut("yields");
932
+ }
933
+ } : undefined);
934
+ if (options.live) sink.needs("wire");
773
935
  w.write({
774
936
  type: "start",
775
937
  id,
776
938
  version
777
939
  });
940
+ if (upstream && upstream.aborted) return finish();
941
+ if (upstream) upstream.addEventListener("abort", onSignal, {
942
+ once: true
943
+ });
778
944
  const code = makeCode(sink, frame);
779
945
  try {
780
946
  renderToStream(() => serverOwned(code), {
781
947
  serializer: createJSONSerializer,
782
948
  ...options,
949
+ signal: render.signal,
783
950
  sink
784
951
  }).pipe({
785
952
  write() {},
786
953
  end() {
954
+ if (ended) return;
787
955
  sink.end();
788
956
  observation && observation.settle("complete");
789
- w.end && w.end();
957
+ finish();
790
958
  }
791
959
  });
792
960
  } catch (err) {
@@ -794,8 +962,9 @@ function frameStream(makeCode, options) {
794
962
  sink.error("", wire instanceof Error ? wire.message : String(wire));
795
963
  sink.end();
796
964
  observation && observation.settle("error", err);
797
- w.end && w.end();
965
+ finish();
798
966
  }
967
+ if (w[ANNOUNCE]) w[ANNOUNCE](sink.announce());
799
968
  }
800
969
  return {
801
970
  pipe: stream,
@@ -817,9 +986,56 @@ function frameStream(makeCode, options) {
817
986
  function slotRange(occurrence) {
818
987
  return {
819
988
  t: `<!--slot:${occurrence}:start--><!--slot:${occurrence}:end-->`,
820
- $slot: true
989
+ $slot: true,
990
+ $occurrence: occurrence
821
991
  };
822
992
  }
993
+ const RANGE_KEYS = new Set(["t", "h", "p", "then", "length", "slice", "constructor", "toString", "valueOf", "toJSON"]);
994
+ const NODE_KEYS = new Set(["t", "h", "p"]);
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));
1011
+ }
1012
+ function withoutStandIns(value, key, occurrence, needs) {
1013
+ return rewriteTree(value, (v, path) => {
1014
+ if (isContainerTraced(v)) {
1015
+ needs("trace");
1016
+ return v;
1017
+ }
1018
+ if (Object.getPrototypeOf(v) === Object.prototype && isSlotValue(v)) {
1019
+ return undefined;
1020
+ }
1021
+ return DESCEND;
1022
+ }, true);
1023
+ }
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
+ }
823
1039
  const OCCURRENCE_UNSAFE = /[^A-Za-z0-9_.-]/g;
824
1040
  function encodeOccurrenceKey(key) {
825
1041
  return String(key).replace(OCCURRENCE_UNSAFE, c => {
@@ -828,14 +1044,58 @@ function encodeOccurrenceKey(key) {
828
1044
  });
829
1045
  }
830
1046
  function occurrenceId(prop, raw, counts) {
831
- const k = raw.$key;
832
- if (typeof k === "string" || typeof k === "number") {
833
- return `${prop}#${encodeOccurrenceKey(k)}`;
834
- }
1047
+ const keyed = keyedId(prop, raw);
1048
+ if (keyed !== undefined) return keyed;
835
1049
  const n = counts[prop] || 0;
836
1050
  counts[prop] = n + 1;
837
1051
  return `${prop}#${n}`;
838
1052
  }
1053
+ function keyedId(prop, raw) {
1054
+ const k = raw.$key;
1055
+ return typeof k === "string" || typeof k === "number" ? `${prop}#${encodeOccurrenceKey(k)}` : undefined;
1056
+ }
1057
+ function structuralArgsKey(raw) {
1058
+ let out = "";
1059
+ let ancestors;
1060
+ const walk = (v, top) => {
1061
+ 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 {
1062
+ const isArray = Array.isArray(v);
1063
+ if (!isArray) {
1064
+ const proto = Object.getPrototypeOf(v);
1065
+ if (proto !== Object.prototype && proto !== null) return false;
1066
+ }
1067
+ if (ancestors === undefined) ancestors = new Set();else if (ancestors.has(v)) return false;
1068
+ ancestors.add(v);
1069
+ try {
1070
+ if (isArray) {
1071
+ out += "[";
1072
+ for (const item of v) if (!walk(item)) return false;
1073
+ out += "]";
1074
+ } else {
1075
+ out += "{";
1076
+ for (const k of Object.keys(v).sort()) {
1077
+ if (top && k === "$key") continue;
1078
+ const desc = Object.getOwnPropertyDescriptor(v, k);
1079
+ if (desc.get || desc.set) return false;
1080
+ out += "k" + k.length + ":" + k;
1081
+ if (!walk(desc.value)) return false;
1082
+ }
1083
+ out += "}";
1084
+ }
1085
+ } finally {
1086
+ ancestors.delete(v);
1087
+ }
1088
+ }
1089
+ return true;
1090
+ };
1091
+ return walk(raw, true) ? out : undefined;
1092
+ }
1093
+ function repeatKey(prop, raw) {
1094
+ const keyed = keyedId(prop, raw);
1095
+ if (keyed !== undefined) return keyed;
1096
+ const structural = structuralArgsKey(raw);
1097
+ return structural === undefined ? undefined : prop + "\0" + structural;
1098
+ }
839
1099
  function isAsyncValue(v) {
840
1100
  return !!v && typeof v === "object" && (typeof v.then === "function" || typeof v[Symbol.asyncIterator] === "function");
841
1101
  }
@@ -864,6 +1124,7 @@ function suppressedFill(render) {
864
1124
  function createDocumentSlotProps(clientProps, frameId) {
865
1125
  const counts = Object.create(null);
866
1126
  const getters = new Map();
1127
+ const repeats = new Map();
867
1128
  const range = (occurrence, content) => {
868
1129
  const r = [{
869
1130
  t: `<!--slot:${occurrence}:start-->`
@@ -871,7 +1132,10 @@ function createDocumentSlotProps(clientProps, frameId) {
871
1132
  t: `<!--slot:${occurrence}:end-->`
872
1133
  }];
873
1134
  r.$slot = true;
874
- return r;
1135
+ r.$occurrence = occurrence;
1136
+ const face = slotFace(r, content);
1137
+ r.$face = face;
1138
+ return slotProxy(r, occurrence, face, face === SLOT_FACE_DATA ? content : undefined, undefined, documentNeeds);
875
1139
  };
876
1140
  const zoneOwner = getOwner ? getOwner() : null;
877
1141
  const scoped = (occurrence, render) => {
@@ -895,147 +1159,170 @@ function createDocumentSlotProps(clientProps, frameId) {
895
1159
  if (!fn) {
896
1160
  fn = (...callArgs) => {
897
1161
  if (callArgs.length === 0 || callArgs[0] === undefined) {
898
- return suppressedFill(() => scoped(prop, () => {
1162
+ const rk = prop + "\0";
1163
+ const repeat = repeats.get(rk);
1164
+ if (repeat) return repeat;
1165
+ const out = suppressedFill(() => scoped(prop, () => {
899
1166
  const value = clientProps[prop];
900
1167
  return range(prop, typeof value === "function" ? value() : value);
901
1168
  }));
1169
+ if (out.$face === SLOT_FACE_DATA) repeats.set(rk, out);
1170
+ return out;
902
1171
  }
903
1172
  const raw = callArgs[0];
1173
+ const rk = repeatKey(prop, raw);
1174
+ const repeat = rk !== undefined && repeats.get(rk);
1175
+ if (repeat) return repeat;
904
1176
  const occurrence = occurrenceId(prop, raw, counts);
905
1177
  const slot = clientProps[prop];
906
1178
  if (typeof slot !== "function") return range(occurrence, undefined);
907
- const resolved = {};
908
- const liveArgs = sharedConfig.context && sharedConfig.context.live && sharedConfig.context.live.args;
909
- const vals = {};
910
- const evals = {};
911
- const states = {};
912
- const minted = {};
913
- for (const key of Object.keys(raw)) {
914
- if (key === "$key") continue;
915
- const desc = Object.getOwnPropertyDescriptor(raw, key);
916
- let evaluate = null;
917
- let value;
918
- if (desc.get) {
919
- const get = desc.get;
920
- evaluate = () => unwrapThunks(get.call(raw));
921
- } else {
922
- value = desc.value;
923
- if (typeof value === "function") {
924
- const fn = value;
925
- evaluate = () => unwrapThunks(fn);
1179
+ const context = sharedConfig.context;
1180
+ const recordKey = `sc:slot:${frameId}:${occurrence}`;
1181
+ let settleRecord;
1182
+ if (context && context.async) {
1183
+ context.serialize(recordKey, new Promise(resolve => settleRecord = resolve));
1184
+ }
1185
+ try {
1186
+ const resolved = {};
1187
+ const liveArgs = sharedConfig.context && sharedConfig.context.live && sharedConfig.context.live.args;
1188
+ const vals = {};
1189
+ const evals = {};
1190
+ const states = {};
1191
+ const minted = {};
1192
+ for (const key of Object.keys(raw)) {
1193
+ if (key === "$key") continue;
1194
+ const desc = Object.getOwnPropertyDescriptor(raw, key);
1195
+ let evaluate = null;
1196
+ let value;
1197
+ if (desc.get) {
1198
+ const get = desc.get;
1199
+ evaluate = () => unwrapThunks(get.call(raw));
1200
+ } else {
1201
+ value = desc.value;
1202
+ if (typeof value === "function") {
1203
+ const fn = value;
1204
+ evaluate = () => unwrapThunks(fn);
1205
+ }
926
1206
  }
1207
+ if (evaluate) {
1208
+ evals[key] = evaluate;
1209
+ const stampBefore = scopeStamp();
1210
+ try {
1211
+ value = evaluate();
1212
+ states[key] = {
1213
+ settled: true,
1214
+ last: value
1215
+ };
1216
+ } catch (err) {
1217
+ const blocked = ssrHandleError && ssrHandleError(err);
1218
+ if (!blocked) throw err;
1219
+ const state = states[key] = {
1220
+ settled: false,
1221
+ last: undefined
1222
+ };
1223
+ value = retryArgUntilSettled(evaluate, blocked, key, occurrence, v => {
1224
+ state.settled = true;
1225
+ state.last = v;
1226
+ if (liveArgs) liveArgs.commit();
1227
+ });
1228
+ }
1229
+ if (scopeStamp() !== stampBefore) minted[key] = true;
1230
+ }
1231
+ vals[key] = value;
927
1232
  }
928
- if (evaluate) {
929
- evals[key] = evaluate;
930
- const stampBefore = scopeStamp();
931
- try {
932
- value = evaluate();
933
- states[key] = {
934
- settled: true,
935
- last: value
1233
+ const regions = [];
1234
+ for (const key of Object.keys(vals)) {
1235
+ const value = vals[key];
1236
+ if (isContainerTraced(value)) {
1237
+ documentNeeds("trace");
1238
+ resolved[key] = value;
1239
+ } else if (isServerContent(value)) {
1240
+ const childId = `${frameId}.${occurrence}.${key}`;
1241
+ const region = {
1242
+ key,
1243
+ childId,
1244
+ value,
1245
+ used: false,
1246
+ locked: false
936
1247
  };
937
- } catch (err) {
938
- const blocked = ssrHandleError && ssrHandleError(err);
939
- if (!blocked) throw err;
940
- const state = states[key] = {
941
- settled: false,
942
- last: undefined
1248
+ regions.push(region);
1249
+ documentNeeds("regions");
1250
+ resolved[key] = () => {
1251
+ if (region.locked) return [];
1252
+ region.used = true;
1253
+ return [{
1254
+ t: frameElementOpen(childId)
1255
+ }, value, {
1256
+ t: FRAME_ELEMENT_CLOSE
1257
+ }];
943
1258
  };
944
- value = retryArgUntilSettled(evaluate, blocked, key, occurrence, v => {
945
- state.settled = true;
946
- state.last = v;
947
- if (liveArgs) liveArgs.commit();
1259
+ } else if (ssrAsyncValue && isAsyncValue(value)) {
1260
+ let readable = value;
1261
+ if (typeof value.then !== "function") {
1262
+ const {
1263
+ first,
1264
+ rest
1265
+ } = tapFirstYield(value);
1266
+ readable = first;
1267
+ vals[key] = rest;
1268
+ }
1269
+ const read = ssrAsyncValue(readable);
1270
+ Object.defineProperty(resolved, key, {
1271
+ get: read,
1272
+ enumerable: true,
1273
+ configurable: true
948
1274
  });
1275
+ } else {
1276
+ resolved[key] = vals[key] = withoutStandIns(value, key, occurrence, documentNeeds);
949
1277
  }
950
- if (scopeStamp() !== stampBefore) minted[key] = true;
951
1278
  }
952
- vals[key] = value;
953
- }
954
- const regions = [];
955
- for (const key of Object.keys(vals)) {
956
- const value = vals[key];
957
- if (isContainerTraced(value)) {
958
- resolved[key] = value;
959
- } else if (isServerContent(value)) {
960
- const childId = `${frameId}.${occurrence}.${key}`;
961
- const region = {
962
- key,
963
- childId,
964
- value,
965
- used: false,
966
- locked: false
967
- };
968
- regions.push(region);
969
- resolved[key] = () => {
970
- if (region.locked) return [];
971
- region.used = true;
972
- return [{
973
- t: frameElementOpen(childId)
974
- }, value, {
975
- t: FRAME_ELEMENT_CLOSE
976
- }];
977
- };
978
- } else if (ssrAsyncValue && isAsyncValue(value)) {
979
- let readable = value;
980
- if (typeof value.then !== "function") {
981
- const {
982
- first,
983
- rest
984
- } = tapFirstYield(value);
985
- readable = first;
986
- vals[key] = rest;
1279
+ const out = suppressedFill(() => scoped(occurrence, () => range(occurrence, slot(resolved))));
1280
+ const unused = regions.filter(r => !r.used);
1281
+ if (context) {
1282
+ const args = {};
1283
+ for (const key of Object.keys(vals)) {
1284
+ const value = vals[key];
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);
987
1294
  }
988
- const read = ssrAsyncValue(readable);
989
- Object.defineProperty(resolved, key, {
990
- get: read,
991
- enumerable: true,
992
- configurable: true
1295
+ settleRecord ? settleRecord({
1296
+ ...args
1297
+ }) : context.serialize(recordKey, {
1298
+ ...args
993
1299
  });
994
- } else {
995
- resolved[key] = value;
996
- }
997
- }
998
- const out = suppressedFill(() => scoped(occurrence, () => range(occurrence, slot(resolved))));
999
- const unused = regions.filter(r => !r.used);
1000
- if (sharedConfig.context) {
1001
- const args = {};
1002
- for (const key of Object.keys(vals)) {
1003
- const value = vals[key];
1004
- const region = regions.find(r => r.key === key);
1005
- if (region) {
1006
- args[key] = {
1007
- $frame: region.childId
1008
- };
1009
- continue;
1300
+ for (const region of unused) {
1301
+ region.locked = true;
1302
+ context.serialize(`sc:region:${region.childId}`, resolveRegionHtml(context, region.value));
1010
1303
  }
1011
- if (!isContainerTraced(value) && isServerContent(value)) continue;
1012
- args[key] = toBorderForm(value);
1013
- }
1014
- sharedConfig.context.serialize(`sc:slot:${frameId}:${occurrence}`, {
1015
- ...args
1016
- });
1017
- for (const region of unused) {
1018
- region.locked = true;
1019
- sharedConfig.context.serialize(`sc:region:${region.childId}`, resolveRegionHtml(sharedConfig.context, region.value));
1020
- }
1021
- if (liveArgs) {
1022
- for (const key of Object.keys(evals)) {
1023
- if (regions.some(r => r.key === key)) continue;
1024
- if (minted[key]) continue;
1025
- const ledgerKey = `${frameId}:${occurrence}:${key}`;
1026
- openArgBinding(liveArgs, ledgerKey, occurrence, key, evals[key], states[key], value => {
1027
- args[key] = toBorderForm(value);
1028
- liveArgs.slot(frameId, occurrence, {
1029
- ...args
1304
+ if (liveArgs) {
1305
+ for (const key of Object.keys(evals)) {
1306
+ if (regions.some(r => r.key === key)) continue;
1307
+ if (minted[key]) continue;
1308
+ const ledgerKey = `${frameId}:${occurrence}:${key}`;
1309
+ openArgBinding(liveArgs, ledgerKey, occurrence, key, evals[key], states[key], value => {
1310
+ args[key] = argBorderForm(value, key, occurrence, documentNeeds);
1311
+ liveArgs.slot(frameId, occurrence, {
1312
+ ...args
1313
+ });
1030
1314
  });
1031
- });
1315
+ }
1032
1316
  }
1033
1317
  }
1318
+ if (rk !== undefined && (rk === occurrence || out.$face === SLOT_FACE_DATA)) repeats.has(rk) || repeats.set(rk, out);
1319
+ return out;
1320
+ } catch (error) {
1321
+ settleRecord && settleRecord(undefined);
1322
+ throw error;
1034
1323
  }
1035
- return out;
1036
1324
  };
1037
1325
  fn.$lhSkip = true;
1038
- fn[CLAIM_PROP] = prop;
1039
1326
  getters.set(prop, fn);
1040
1327
  }
1041
1328
  return fn;
@@ -1049,6 +1336,17 @@ function frameElementOpen(id) {
1049
1336
  return `<${FRAME_TAG} ${FRAME_ID_ATTR}="${escaped}" style="display:contents">`;
1050
1337
  }
1051
1338
  const FRAME_ELEMENT_CLOSE = `</${FRAME_TAG}>`;
1339
+ function documentNeeds(name) {
1340
+ const ctx = sharedConfig.context;
1341
+ const live = ctx && ctx.live;
1342
+ if (!live || !ctx.serialize) return;
1343
+ const tiers = live.tiers || (live.tiers = []);
1344
+ if (tiers.includes(name)) return;
1345
+ tiers.push(name);
1346
+ ctx.serialize("sc:tiers", tiers.slice());
1347
+ const url = live.tierUrls && live.tierUrls[name];
1348
+ if (url && ctx.registerAsset) ctx.registerAsset("module", url);
1349
+ }
1052
1350
  function armDocumentLiveHoles(ctx) {
1053
1351
  if (!ctx || ctx.liveHoles !== undefined) return;
1054
1352
  const live = ctx.live;
@@ -1060,7 +1358,7 @@ function armDocumentLiveHoles(ctx) {
1060
1358
  }
1061
1359
  return;
1062
1360
  }
1063
- if (!live || !ctx.async || ctx.noHydrate || !ctx.serialize || typeof ReadableStream !== "function") {
1361
+ if (!live || !ctx.async || !ctx.serialize || typeof ReadableStream !== "function") {
1064
1362
  ctx.liveHoles = null;
1065
1363
  if (live) live.holes = null;
1066
1364
  return;
@@ -1069,14 +1367,27 @@ function armDocumentLiveHoles(ctx) {
1069
1367
  let epoch = 0;
1070
1368
  let sweepScheduled = false;
1071
1369
  let closed = false;
1370
+ let swept = null;
1072
1371
  const sweep = () => {
1073
1372
  epoch++;
1074
- for (const b of [...bindings.values()]) {
1075
- try {
1076
- b.sweep();
1077
- } catch (_) {
1373
+ const ops = swept = [];
1374
+ try {
1375
+ for (const b of [...bindings.values()]) {
1376
+ try {
1377
+ b.sweep();
1378
+ } catch (_) {
1379
+ }
1078
1380
  }
1381
+ } finally {
1382
+ swept = null;
1079
1383
  }
1384
+ pushOps(ops);
1385
+ };
1386
+ const pushOps = ops => {
1387
+ if (ops.length === 1) push(ops[0]);else if (ops.length) push({
1388
+ type: "ops",
1389
+ ops
1390
+ });
1080
1391
  };
1081
1392
  const scheduleSweep = () => {
1082
1393
  if (closed || sweepScheduled || !bindings.size) return;
@@ -1103,12 +1414,13 @@ function armDocumentLiveHoles(ctx) {
1103
1414
  bindings.delete(key);
1104
1415
  },
1105
1416
  hole(key, html) {
1106
- push({
1417
+ const op = {
1107
1418
  type: "hole",
1108
1419
  key,
1109
1420
  html,
1110
1421
  digest: textDigest(html)
1111
- });
1422
+ };
1423
+ swept ? swept.push(op) : pushOps([op]);
1112
1424
  },
1113
1425
  attr(key, attrs, removed) {
1114
1426
  const op = {
@@ -1118,7 +1430,7 @@ function armDocumentLiveHoles(ctx) {
1118
1430
  digest: textDigest(attrs)
1119
1431
  };
1120
1432
  if (removed && removed.length) op.removed = removed;
1121
- push(op);
1433
+ swept ? swept.push(op) : pushOps([op]);
1122
1434
  },
1123
1435
  error(key, error) {
1124
1436
  push({
@@ -1151,6 +1463,13 @@ function armDocumentLiveHoles(ctx) {
1151
1463
  },
1152
1464
  commit: scheduleSweep
1153
1465
  };
1466
+ live.error = (fid, error) => {
1467
+ push({
1468
+ type: "error",
1469
+ fid,
1470
+ error
1471
+ });
1472
+ };
1154
1473
  live.end = () => {
1155
1474
  if (closed) return;
1156
1475
  if (bindings.size) sweep();
@@ -1160,7 +1479,8 @@ function armDocumentLiveHoles(ctx) {
1160
1479
  }
1161
1480
  function frameTransformDirectResult(value, {
1162
1481
  id,
1163
- args
1482
+ args,
1483
+ tierUrls
1164
1484
  }) {
1165
1485
  if (typeof value !== "function") return value;
1166
1486
  const component = value;
@@ -1168,10 +1488,21 @@ function frameTransformDirectResult(value, {
1168
1488
  t: frameElementOpen(id)
1169
1489
  },
1170
1490
  serverOwned(() => {
1171
- armDocumentLiveHoles(sharedConfig.context);
1172
- sharedConfig.context.claims = CLAIMS_DOCUMENT;
1173
- const slotProps = createDocumentSlotProps(props, id);
1174
- return serverComponentScope(() => component(slotProps), !!wrapped[LIVE_SOURCE]);
1491
+ const page = sharedConfig.context;
1492
+ armDocumentLiveHoles(page);
1493
+ if (tierUrls && page && page.live && !page.live.tierUrls) page.live.tierUrls = tierUrls;
1494
+ const ctx = Object.create(page);
1495
+ ctx.claims = CLAIMS_DOCUMENT;
1496
+ ctx.frameId = id;
1497
+ sharedConfig.context = ctx;
1498
+ try {
1499
+ const slotProps = createDocumentSlotProps(props, id);
1500
+ const live = !!wrapped[LIVE_SOURCE];
1501
+ if (live) documentNeeds("wire");
1502
+ return serverComponentScope(() => component(slotProps), live);
1503
+ } finally {
1504
+ sharedConfig.context = page;
1505
+ }
1175
1506
  }), {
1176
1507
  t: FRAME_ELEMENT_CLOSE
1177
1508
  }];
@@ -1279,6 +1610,8 @@ function openArgBinding(sink, ledgerKey, occurrence, key, evaluate, state, emit)
1279
1610
  function createSlotProps(sink, frame) {
1280
1611
  const counts = Object.create(null);
1281
1612
  const getters = new Map();
1613
+ const repeats = new Map();
1614
+ const needs = sink.needs || (() => {});
1282
1615
  return new Proxy(Object.create(null), {
1283
1616
  has() {
1284
1617
  return true;
@@ -1290,8 +1623,11 @@ function createSlotProps(sink, frame) {
1290
1623
  if (!fn) {
1291
1624
  fn = (...callArgs) => {
1292
1625
  if (callArgs.length === 0 || callArgs[0] === undefined) {
1293
- return slotRange(prop);
1626
+ return slotProxy(slotRange(prop), prop, SLOT_FACE_STREAM, undefined, undefined, needs);
1294
1627
  }
1628
+ const rk = repeatKey(prop, callArgs[0]);
1629
+ const repeat = rk !== undefined && repeats.get(rk);
1630
+ if (repeat) return repeat;
1295
1631
  const live = sharedConfig.context && sharedConfig.context.liveHoles;
1296
1632
  if (live) {
1297
1633
  if (live.sweeping) {
@@ -1368,7 +1704,7 @@ function createSlotProps(sink, frame) {
1368
1704
  };
1369
1705
  } else {
1370
1706
  const ref = `arg:${occurrence}:${key}`;
1371
- ctx.serialize(ref, toBorderForm(value, true));
1707
+ ctx.serialize(ref, argBorderForm(value, key, occurrence, needs));
1372
1708
  args[key] = {
1373
1709
  $ref: ref
1374
1710
  };
@@ -1400,7 +1736,7 @@ function createSlotProps(sink, frame) {
1400
1736
  } else {
1401
1737
  const ref = `arg:${occurrence}:${key}@${sink.nextArgRef(ledgerKey)}`;
1402
1738
  sink.mintRef(ref);
1403
- ctx.serialize(ref, toBorderForm(value));
1739
+ ctx.serialize(ref, argBorderForm(value, key, occurrence, needs));
1404
1740
  args[key] = {
1405
1741
  $ref: ref
1406
1742
  };
@@ -1410,10 +1746,12 @@ function createSlotProps(sink, frame) {
1410
1746
  });
1411
1747
  });
1412
1748
  }
1413
- return slotRange(occurrence);
1749
+ const keyed = rk === occurrence;
1750
+ const out = slotProxy(slotRange(occurrence), occurrence, SLOT_FACE_STREAM, undefined, rk === undefined || keyed ? undefined : () => repeats.has(rk) || repeats.set(rk, out), needs);
1751
+ if (keyed) repeats.set(rk, out);
1752
+ return out;
1414
1753
  };
1415
1754
  fn.$lhSkip = true;
1416
- fn[CLAIM_PROP] = prop;
1417
1755
  getters.set(prop, fn);
1418
1756
  }
1419
1757
  return fn;
@@ -1468,9 +1806,6 @@ function serverComponentResponse(component, options = {}, init = {}) {
1468
1806
  } catch (_) {}
1469
1807
  };
1470
1808
  if (teardown.signal.aborted) return end();
1471
- teardown.signal.addEventListener("abort", end, {
1472
- once: true
1473
- });
1474
1809
  if (live) stopLive = armLiveBody(controller, () => {
1475
1810
  closed = true;
1476
1811
  disarm();
@@ -1485,14 +1820,19 @@ function serverComponentResponse(component, options = {}, init = {}) {
1485
1820
  closed = true;
1486
1821
  }
1487
1822
  },
1488
- end
1823
+ end,
1824
+ [ANNOUNCE](tiers) {
1825
+ if (tiers.length) headers.set(FRAME_TIERS_HEADER, tiers.join(","));
1826
+ }
1489
1827
  });
1490
1828
  },
1491
1829
  cancel() {
1492
1830
  closed = true;
1493
1831
  disarm();
1494
1832
  if (stopLive) stopLive();
1495
- teardown.abort();
1833
+ teardown.abort({
1834
+ [DISCONNECTED]: true
1835
+ });
1496
1836
  }
1497
1837
  });
1498
1838
  return new Response(body, {
@@ -1694,7 +2034,9 @@ function frameFlightResponse({
1694
2034
  cancel() {
1695
2035
  closed = true;
1696
2036
  disarm();
1697
- teardown.abort();
2037
+ teardown.abort({
2038
+ [DISCONNECTED]: true
2039
+ });
1698
2040
  }
1699
2041
  });
1700
2042
  return new Response(body, {
@@ -1709,4 +2051,4 @@ function asyncArg(value) {
1709
2051
  return value;
1710
2052
  }
1711
2053
 
1712
- export { FRAME_HAVE_BUDGET, FRAME_HAVE_HEADER, FRAME_STREAM_HEADER, SERVER_COMPONENT_BOOTSTRAP, ServerComponentPlugin, asyncArg, createFrameSink, frameTransformDirectResult, frameTransformFlightResult, frameTransformResult, isFrameStreamResponse, renderServerComponent, renderToFrameStream, serverComponentResponse };
2054
+ 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 };