react-server-dom-webpack 18.3.0-canary-a870b2d54-20240314 → 18.3.0-canary-4b84f1161-20240318

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 (39) hide show
  1. package/cjs/react-server-dom-webpack-client.browser.development.js +176 -272
  2. package/cjs/react-server-dom-webpack-client.browser.production.js +146 -127
  3. package/cjs/react-server-dom-webpack-client.browser.production.min.js +25 -24
  4. package/cjs/react-server-dom-webpack-client.browser.production.min.js.map +1 -1
  5. package/cjs/react-server-dom-webpack-client.edge.development.js +181 -324
  6. package/cjs/react-server-dom-webpack-client.edge.production.js +151 -168
  7. package/cjs/react-server-dom-webpack-client.edge.production.min.js +30 -30
  8. package/cjs/react-server-dom-webpack-client.edge.production.min.js.map +1 -1
  9. package/cjs/react-server-dom-webpack-client.node.development.js +181 -324
  10. package/cjs/react-server-dom-webpack-client.node.production.js +151 -168
  11. package/cjs/react-server-dom-webpack-client.node.production.min.js +29 -28
  12. package/cjs/react-server-dom-webpack-client.node.production.min.js.map +1 -1
  13. package/cjs/react-server-dom-webpack-client.node.unbundled.development.js +181 -324
  14. package/cjs/react-server-dom-webpack-client.node.unbundled.production.js +151 -168
  15. package/cjs/react-server-dom-webpack-client.node.unbundled.production.min.js +30 -30
  16. package/cjs/react-server-dom-webpack-client.node.unbundled.production.min.js.map +1 -1
  17. package/cjs/react-server-dom-webpack-node-register.js.map +1 -1
  18. package/cjs/react-server-dom-webpack-plugin.js.map +1 -1
  19. package/cjs/react-server-dom-webpack-server.browser.development.js +424 -587
  20. package/cjs/react-server-dom-webpack-server.browser.production.js +368 -403
  21. package/cjs/react-server-dom-webpack-server.browser.production.min.js +68 -65
  22. package/cjs/react-server-dom-webpack-server.browser.production.min.js.map +1 -1
  23. package/cjs/react-server-dom-webpack-server.edge.development.js +424 -590
  24. package/cjs/react-server-dom-webpack-server.edge.production.js +369 -407
  25. package/cjs/react-server-dom-webpack-server.edge.production.min.js +69 -67
  26. package/cjs/react-server-dom-webpack-server.edge.production.min.js.map +1 -1
  27. package/cjs/react-server-dom-webpack-server.node.development.js +423 -586
  28. package/cjs/react-server-dom-webpack-server.node.production.js +368 -403
  29. package/cjs/react-server-dom-webpack-server.node.production.min.js +72 -70
  30. package/cjs/react-server-dom-webpack-server.node.production.min.js.map +1 -1
  31. package/cjs/react-server-dom-webpack-server.node.unbundled.development.js +423 -586
  32. package/cjs/react-server-dom-webpack-server.node.unbundled.production.js +368 -403
  33. package/cjs/react-server-dom-webpack-server.node.unbundled.production.min.js +69 -67
  34. package/cjs/react-server-dom-webpack-server.node.unbundled.production.min.js.map +1 -1
  35. package/package.json +11 -5
  36. package/umd/react-server-dom-webpack-client.browser.development.js +176 -272
  37. package/umd/react-server-dom-webpack-client.browser.production.min.js +23 -22
  38. package/umd/react-server-dom-webpack-server.browser.development.js +424 -587
  39. package/umd/react-server-dom-webpack-server.browser.production.min.js +52 -52
@@ -62,7 +62,7 @@ var enablePostpone = false;
62
62
  function scheduleWork(callback) {
63
63
  callback();
64
64
  }
65
- var VIEW_SIZE = 512;
65
+ var VIEW_SIZE = 2048;
66
66
  var currentView = null;
67
67
  var writtenBytes = 0;
68
68
  function beginWriting(destination) {
@@ -75,15 +75,9 @@ function writeChunk(destination, chunk) {
75
75
  }
76
76
 
77
77
  if (chunk.byteLength > VIEW_SIZE) {
78
- {
79
- if (precomputedChunkSet.has(chunk)) {
80
- error('A large precomputed chunk was passed to writeChunk without being copied.' + ' Large chunks get enqueued directly and are not copied. This is incompatible with precomputed chunks because you cannot enqueue the same precomputed chunk twice.' + ' Use "cloneChunk" to make a copy of this large precomputed chunk before writing it. This is a bug in React.');
81
- }
82
- } // this chunk may overflow a single view which implies it was not
78
+ // this chunk may overflow a single view which implies it was not
83
79
  // one that is cached by the streaming renderer. We will enqueu
84
80
  // it directly and expect it is not re-used
85
-
86
-
87
81
  if (writtenBytes > 0) {
88
82
  destination.enqueue(new Uint8Array(currentView.buffer, 0, writtenBytes));
89
83
  currentView = new Uint8Array(VIEW_SIZE);
@@ -138,7 +132,6 @@ var textEncoder = new TextEncoder();
138
132
  function stringToChunk(content) {
139
133
  return textEncoder.encode(content);
140
134
  }
141
- var precomputedChunkSet = new Set() ;
142
135
  function byteLengthOfChunk(chunk) {
143
136
  return chunk.byteLength;
144
137
  }
@@ -159,10 +152,10 @@ function closeWithError(destination, error) {
159
152
  }
160
153
 
161
154
  // eslint-disable-next-line no-unused-vars
162
- var CLIENT_REFERENCE_TAG$1 = Symbol.for('react.client.reference');
155
+ var CLIENT_REFERENCE_TAG = Symbol.for('react.client.reference');
163
156
  var SERVER_REFERENCE_TAG = Symbol.for('react.server.reference');
164
157
  function isClientReference(reference) {
165
- return reference.$$typeof === CLIENT_REFERENCE_TAG$1;
158
+ return reference.$$typeof === CLIENT_REFERENCE_TAG;
166
159
  }
167
160
  function isServerReference(reference) {
168
161
  return reference.$$typeof === SERVER_REFERENCE_TAG;
@@ -174,7 +167,7 @@ function registerClientReference(proxyImplementation, id, exportName) {
174
167
  function registerClientReferenceImpl(proxyImplementation, id, async) {
175
168
  return Object.defineProperties(proxyImplementation, {
176
169
  $$typeof: {
177
- value: CLIENT_REFERENCE_TAG$1
170
+ value: CLIENT_REFERENCE_TAG
178
171
  },
179
172
  $$id: {
180
173
  value: id
@@ -195,14 +188,6 @@ function bind() {
195
188
  var newFn = FunctionBind.apply(this, arguments);
196
189
 
197
190
  if (this.$$typeof === SERVER_REFERENCE_TAG) {
198
- {
199
- var thisBind = arguments[0];
200
-
201
- if (thisBind != null) {
202
- error('Cannot bind "this" of a Server Action. Pass null or undefined as the first argument to .bind().');
203
- }
204
- }
205
-
206
191
  var args = ArraySlice.call(arguments, 1);
207
192
  return Object.defineProperties(newFn, {
208
193
  $$typeof: {
@@ -229,16 +214,13 @@ function registerServerReference(reference, id, exportName) {
229
214
  value: SERVER_REFERENCE_TAG
230
215
  },
231
216
  $$id: {
232
- value: exportName === null ? id : id + '#' + exportName,
233
- configurable: true
217
+ value: exportName === null ? id : id + '#' + exportName
234
218
  },
235
219
  $$bound: {
236
- value: null,
237
- configurable: true
220
+ value: null
238
221
  },
239
222
  bind: {
240
- value: bind,
241
- configurable: true
223
+ value: bind
242
224
  }
243
225
  });
244
226
  }
@@ -277,10 +259,6 @@ var deepProxyHandlers = {
277
259
  // $FlowFixMe[prop-missing]
278
260
  return Object.prototype[Symbol.toPrimitive];
279
261
 
280
- case Symbol.toStringTag:
281
- // $FlowFixMe[prop-missing]
282
- return Object.prototype[Symbol.toStringTag];
283
-
284
262
  case 'Provider':
285
263
  throw new Error("Cannot render a Client Context Provider on the Server. " + "Instead, you can export a Client Component wrapper " + "that itself renders a Client Context Provider.");
286
264
  } // eslint-disable-next-line react-internal/safe-string-coercion
@@ -322,10 +300,6 @@ function getReference(target, name) {
322
300
  // $FlowFixMe[prop-missing]
323
301
  return Object.prototype[Symbol.toPrimitive];
324
302
 
325
- case Symbol.toStringTag:
326
- // $FlowFixMe[prop-missing]
327
- return Object.prototype[Symbol.toStringTag];
328
-
329
303
  case '__esModule':
330
304
  // Something is conditionally checking which export to use. We'll pretend to be
331
305
  // an ESM compat module but then we'll check again on the client.
@@ -366,10 +340,6 @@ function getReference(target, name) {
366
340
 
367
341
  }
368
342
 
369
- if (typeof name === 'symbol') {
370
- throw new Error('Cannot read Symbol exports. Only named exports are supported on a client module ' + 'imported on the server.');
371
- }
372
-
373
343
  var cachedReference = target[name];
374
344
 
375
345
  if (!cachedReference) {
@@ -462,9 +432,7 @@ function getServerReferenceBoundArguments(config, serverReference) {
462
432
 
463
433
  var ReactDOMSharedInternals = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
464
434
 
465
- var ReactDOMCurrentDispatcher = ReactDOMSharedInternals.ReactDOMCurrentDispatcher;
466
- var previousDispatcher = ReactDOMCurrentDispatcher.current;
467
- ReactDOMCurrentDispatcher.current = {
435
+ var ReactDOMFlightServerDispatcher = {
468
436
  prefetchDNS: prefetchDNS,
469
437
  preconnect: preconnect,
470
438
  preload: preload,
@@ -490,8 +458,6 @@ function prefetchDNS(href) {
490
458
 
491
459
  hints.add(key);
492
460
  emitHint(request, 'D', href);
493
- } else {
494
- previousDispatcher.prefetchDNS(href);
495
461
  }
496
462
  }
497
463
  }
@@ -518,8 +484,6 @@ function preconnect(href, crossOrigin) {
518
484
  } else {
519
485
  emitHint(request, 'C', href);
520
486
  }
521
- } else {
522
- previousDispatcher.preconnect(href, crossOrigin);
523
487
  }
524
488
  }
525
489
  }
@@ -553,8 +517,6 @@ function preload(href, as, options) {
553
517
  } else {
554
518
  emitHint(request, 'L', [href, as]);
555
519
  }
556
- } else {
557
- previousDispatcher.preload(href, as, options);
558
520
  }
559
521
  }
560
522
  }
@@ -582,8 +544,6 @@ function preloadModule$1(href, options) {
582
544
  } else {
583
545
  return emitHint(request, 'm', href);
584
546
  }
585
- } else {
586
- previousDispatcher.preloadModule(href, options);
587
547
  }
588
548
  }
589
549
  }
@@ -613,21 +573,19 @@ function preinitStyle(href, precedence, options) {
613
573
  } else {
614
574
  return emitHint(request, 'S', href);
615
575
  }
616
- } else {
617
- previousDispatcher.preinitStyle(href, precedence, options);
618
576
  }
619
577
  }
620
578
  }
621
579
  }
622
580
 
623
- function preinitScript(src, options) {
581
+ function preinitScript(href, options) {
624
582
  {
625
- if (typeof src === 'string') {
583
+ if (typeof href === 'string') {
626
584
  var request = resolveRequest();
627
585
 
628
586
  if (request) {
629
587
  var hints = getHints(request);
630
- var key = 'X|' + src;
588
+ var key = 'X|' + href;
631
589
 
632
590
  if (hints.has(key)) {
633
591
  // duplicate hint
@@ -638,25 +596,23 @@ function preinitScript(src, options) {
638
596
  var trimmed = trimOptions(options);
639
597
 
640
598
  if (trimmed) {
641
- return emitHint(request, 'X', [src, trimmed]);
599
+ return emitHint(request, 'X', [href, trimmed]);
642
600
  } else {
643
- return emitHint(request, 'X', src);
601
+ return emitHint(request, 'X', href);
644
602
  }
645
- } else {
646
- previousDispatcher.preinitScript(src, options);
647
603
  }
648
604
  }
649
605
  }
650
606
  }
651
607
 
652
- function preinitModuleScript(src, options) {
608
+ function preinitModuleScript(href, options) {
653
609
  {
654
- if (typeof src === 'string') {
610
+ if (typeof href === 'string') {
655
611
  var request = resolveRequest();
656
612
 
657
613
  if (request) {
658
614
  var hints = getHints(request);
659
- var key = 'M|' + src;
615
+ var key = 'M|' + href;
660
616
 
661
617
  if (hints.has(key)) {
662
618
  // duplicate hint
@@ -667,12 +623,10 @@ function preinitModuleScript(src, options) {
667
623
  var trimmed = trimOptions(options);
668
624
 
669
625
  if (trimmed) {
670
- return emitHint(request, 'M', [src, trimmed]);
626
+ return emitHint(request, 'M', [href, trimmed]);
671
627
  } else {
672
- return emitHint(request, 'M', src);
628
+ return emitHint(request, 'M', href);
673
629
  }
674
- } else {
675
- previousDispatcher.preinitModuleScript(src, options);
676
630
  }
677
631
  }
678
632
  }
@@ -714,7 +668,10 @@ function getImagePreloadKey(href, imageSrcSet, imageSizes) {
714
668
  return "[image]" + uniquePart;
715
669
  }
716
670
 
717
- // This module registers the host dispatcher so it needs to be imported
671
+ var ReactDOMCurrentDispatcher = ReactDOMSharedInternals.Dispatcher;
672
+ function prepareHostDispatcher() {
673
+ ReactDOMCurrentDispatcher.current = ReactDOMFlightServerDispatcher;
674
+ } // Used to distinguish these contexts from ones used in other renderers.
718
675
  // small, smaller than how we encode undefined, and is unambiguous. We could use
719
676
  // a different tuple structure to encode this instead but this makes the runtime
720
677
  // cost cheaper by eliminating a type checks in more positions.
@@ -724,16 +681,13 @@ function createHints() {
724
681
  return new Set();
725
682
  }
726
683
 
727
- var supportsRequestStorage = false;
728
- var requestStorage = null;
729
-
730
684
  // ATTENTION
731
685
  // When adding new symbols to this file,
732
686
  // Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
733
687
  // The Symbol used to tag the ReactElement-like types.
734
688
  var REACT_ELEMENT_TYPE = Symbol.for('react.element');
735
689
  var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
736
- var REACT_CONTEXT_TYPE = Symbol.for('react.context');
690
+ var REACT_SERVER_CONTEXT_TYPE = Symbol.for('react.server_context');
737
691
  var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');
738
692
  var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');
739
693
  var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');
@@ -757,6 +711,146 @@ function getIteratorFn(maybeIterable) {
757
711
  return null;
758
712
  }
759
713
 
714
+ // Forming a reverse tree.
715
+ // The structure of a context snapshot is an implementation of this file.
716
+ // Currently, it's implemented as tracking the current active node.
717
+
718
+
719
+ var rootContextSnapshot = null; // We assume that this runtime owns the "current" field on all ReactContext instances.
720
+ // This global (actually thread local) state represents what state all those "current",
721
+ // fields are currently in.
722
+
723
+ var currentActiveSnapshot = null;
724
+
725
+ function popNode(prev) {
726
+ {
727
+ prev.context._currentValue = prev.parentValue;
728
+ }
729
+ }
730
+
731
+ function pushNode(next) {
732
+ {
733
+ next.context._currentValue = next.value;
734
+ }
735
+ }
736
+
737
+ function popToNearestCommonAncestor(prev, next) {
738
+ if (prev === next) ; else {
739
+ popNode(prev);
740
+ var parentPrev = prev.parent;
741
+ var parentNext = next.parent;
742
+
743
+ if (parentPrev === null) {
744
+ if (parentNext !== null) {
745
+ throw new Error('The stacks must reach the root at the same time. This is a bug in React.');
746
+ }
747
+ } else {
748
+ if (parentNext === null) {
749
+ throw new Error('The stacks must reach the root at the same time. This is a bug in React.');
750
+ }
751
+
752
+ popToNearestCommonAncestor(parentPrev, parentNext); // On the way back, we push the new ones that weren't common.
753
+
754
+ pushNode(next);
755
+ }
756
+ }
757
+ }
758
+
759
+ function popAllPrevious(prev) {
760
+ popNode(prev);
761
+ var parentPrev = prev.parent;
762
+
763
+ if (parentPrev !== null) {
764
+ popAllPrevious(parentPrev);
765
+ }
766
+ }
767
+
768
+ function pushAllNext(next) {
769
+ var parentNext = next.parent;
770
+
771
+ if (parentNext !== null) {
772
+ pushAllNext(parentNext);
773
+ }
774
+
775
+ pushNode(next);
776
+ }
777
+
778
+ function popPreviousToCommonLevel(prev, next) {
779
+ popNode(prev);
780
+ var parentPrev = prev.parent;
781
+
782
+ if (parentPrev === null) {
783
+ throw new Error('The depth must equal at least at zero before reaching the root. This is a bug in React.');
784
+ }
785
+
786
+ if (parentPrev.depth === next.depth) {
787
+ // We found the same level. Now we just need to find a shared ancestor.
788
+ popToNearestCommonAncestor(parentPrev, next);
789
+ } else {
790
+ // We must still be deeper.
791
+ popPreviousToCommonLevel(parentPrev, next);
792
+ }
793
+ }
794
+
795
+ function popNextToCommonLevel(prev, next) {
796
+ var parentNext = next.parent;
797
+
798
+ if (parentNext === null) {
799
+ throw new Error('The depth must equal at least at zero before reaching the root. This is a bug in React.');
800
+ }
801
+
802
+ if (prev.depth === parentNext.depth) {
803
+ // We found the same level. Now we just need to find a shared ancestor.
804
+ popToNearestCommonAncestor(prev, parentNext);
805
+ } else {
806
+ // We must still be deeper.
807
+ popNextToCommonLevel(prev, parentNext);
808
+ }
809
+
810
+ pushNode(next);
811
+ } // Perform context switching to the new snapshot.
812
+ // To make it cheap to read many contexts, while not suspending, we make the switch eagerly by
813
+ // updating all the context's current values. That way reads, always just read the current value.
814
+ // At the cost of updating contexts even if they're never read by this subtree.
815
+
816
+
817
+ function switchContext(newSnapshot) {
818
+ // The basic algorithm we need to do is to pop back any contexts that are no longer on the stack.
819
+ // We also need to update any new contexts that are now on the stack with the deepest value.
820
+ // The easiest way to update new contexts is to just reapply them in reverse order from the
821
+ // perspective of the backpointers. To avoid allocating a lot when switching, we use the stack
822
+ // for that. Therefore this algorithm is recursive.
823
+ // 1) First we pop which ever snapshot tree was deepest. Popping old contexts as we go.
824
+ // 2) Then we find the nearest common ancestor from there. Popping old contexts as we go.
825
+ // 3) Then we reapply new contexts on the way back up the stack.
826
+ var prev = currentActiveSnapshot;
827
+ var next = newSnapshot;
828
+
829
+ if (prev !== next) {
830
+ if (prev === null) {
831
+ // $FlowFixMe[incompatible-call]: This has to be non-null since it's not equal to prev.
832
+ pushAllNext(next);
833
+ } else if (next === null) {
834
+ popAllPrevious(prev);
835
+ } else if (prev.depth === next.depth) {
836
+ popToNearestCommonAncestor(prev, next);
837
+ } else if (prev.depth > next.depth) {
838
+ popPreviousToCommonLevel(prev, next);
839
+ } else {
840
+ popNextToCommonLevel(prev, next);
841
+ }
842
+
843
+ currentActiveSnapshot = next;
844
+ }
845
+ }
846
+ function getActiveContext() {
847
+ return currentActiveSnapshot;
848
+ }
849
+ function readContext$1(context) {
850
+ var value = context._currentValue ;
851
+ return value;
852
+ }
853
+
760
854
  // Corresponds to ReactFiberWakeable and ReactFizzWakeable modules. Generally,
761
855
  // changes to one module should be reflected in the others.
762
856
  // TODO: Rename this module and the corresponding Fiber one to "Thenable"
@@ -885,13 +979,29 @@ function prepareToUseHooksForComponent(prevThenableState) {
885
979
  thenableState = prevThenableState;
886
980
  }
887
981
  function getThenableStateAfterSuspending() {
888
- // If you use() to Suspend this should always exist but if you throw a Promise instead,
889
- // which is not really supported anymore, it will be empty. We use the empty set as a
890
- // marker to know if this was a replay of the same component or first attempt.
891
- var state = thenableState || createThenableState();
982
+ var state = thenableState;
892
983
  thenableState = null;
893
984
  return state;
894
985
  }
986
+
987
+ function readContext(context) {
988
+ {
989
+ if (context.$$typeof !== REACT_SERVER_CONTEXT_TYPE) {
990
+ if (isClientReference(context)) {
991
+ error('Cannot read a Client Context from a Server Component.');
992
+ } else {
993
+ error('Only createServerContext is supported in Server Components.');
994
+ }
995
+ }
996
+
997
+ if (currentRequest$1 === null) {
998
+ error('Context can only be read while React is rendering. ' + 'In classes, you can read it in the render method or getDerivedStateFromProps. ' + 'In function components, you can read it directly in the function body, but not ' + 'inside Hooks like useReducer() or useMemo().');
999
+ }
1000
+ }
1001
+
1002
+ return readContext$1(context);
1003
+ }
1004
+
895
1005
  var HooksDispatcher = {
896
1006
  useMemo: function (nextCreate) {
897
1007
  return nextCreate();
@@ -902,8 +1012,8 @@ var HooksDispatcher = {
902
1012
  useDebugValue: function () {},
903
1013
  useDeferredValue: unsupportedHook,
904
1014
  useTransition: unsupportedHook,
905
- readContext: unsupportedContext,
906
- useContext: unsupportedContext,
1015
+ readContext: readContext,
1016
+ useContext: readContext,
907
1017
  useReducer: unsupportedHook,
908
1018
  useRef: unsupportedHook,
909
1019
  useState: unsupportedHook,
@@ -936,10 +1046,6 @@ function unsupportedRefresh() {
936
1046
  throw new Error('Refreshing the cache is not supported in Server Components.');
937
1047
  }
938
1048
 
939
- function unsupportedContext() {
940
- throw new Error('Cannot read a Client Context from a Server Component.');
941
- }
942
-
943
1049
  function useId() {
944
1050
  if (currentRequest$1 === null) {
945
1051
  throw new Error('useId can only be used while React is rendering');
@@ -965,22 +1071,20 @@ function use(usable) {
965
1071
  }
966
1072
 
967
1073
  return trackUsedThenable(thenableState, thenable, index);
968
- } else if (usable.$$typeof === REACT_CONTEXT_TYPE) {
969
- unsupportedContext();
1074
+ } else if (usable.$$typeof === REACT_SERVER_CONTEXT_TYPE) {
1075
+ var context = usable;
1076
+ return readContext(context);
970
1077
  }
971
1078
  }
972
1079
 
973
- if (isClientReference(usable)) {
974
- if (usable.value != null && usable.value.$$typeof === REACT_CONTEXT_TYPE) {
975
- // Show a more specific message since it's a common mistake.
976
- throw new Error('Cannot read a Client Context from a Server Component.');
977
- } else {
978
- throw new Error('Cannot use() an already resolved Client Reference.');
1080
+ {
1081
+ if (isClientReference(usable)) {
1082
+ error('Cannot use() an already resolved Client Reference.');
979
1083
  }
980
- } else {
981
- throw new Error( // eslint-disable-next-line react-internal/safe-string-coercion
982
- 'An unsupported type was passed to use(): ' + String(usable));
983
- }
1084
+ } // eslint-disable-next-line react-internal/safe-string-coercion
1085
+
1086
+
1087
+ throw new Error('An unsupported type was passed to use(): ' + String(usable));
984
1088
  }
985
1089
 
986
1090
  function createSignal() {
@@ -1118,10 +1222,6 @@ function describeValueForErrorMessage(value) {
1118
1222
  return '[...]';
1119
1223
  }
1120
1224
 
1121
- if (value !== null && value.$$typeof === CLIENT_REFERENCE_TAG) {
1122
- return describeClientReference();
1123
- }
1124
-
1125
1225
  var name = objectName(value);
1126
1226
 
1127
1227
  if (name === 'Object') {
@@ -1132,15 +1232,7 @@ function describeValueForErrorMessage(value) {
1132
1232
  }
1133
1233
 
1134
1234
  case 'function':
1135
- {
1136
- if (value.$$typeof === CLIENT_REFERENCE_TAG) {
1137
- return describeClientReference();
1138
- }
1139
-
1140
- var _name = value.displayName || value.name;
1141
-
1142
- return _name ? 'function ' + _name : 'function';
1143
- }
1235
+ return 'function';
1144
1236
 
1145
1237
  default:
1146
1238
  // eslint-disable-next-line react-internal/safe-string-coercion
@@ -1186,12 +1278,6 @@ function describeElementType(type) {
1186
1278
  return '';
1187
1279
  }
1188
1280
 
1189
- var CLIENT_REFERENCE_TAG = Symbol.for('react.client.reference');
1190
-
1191
- function describeClientReference(ref) {
1192
- return 'client';
1193
- }
1194
-
1195
1281
  function describeObjectForErrorMessage(objectOrArray, expandedName) {
1196
1282
  var objKind = objectName(objectOrArray);
1197
1283
 
@@ -1270,8 +1356,6 @@ function describeObjectForErrorMessage(objectOrArray, expandedName) {
1270
1356
  } else {
1271
1357
  if (objectOrArray.$$typeof === REACT_ELEMENT_TYPE) {
1272
1358
  str = '<' + describeElementType(objectOrArray.type) + '/>';
1273
- } else if (objectOrArray.$$typeof === CLIENT_REFERENCE_TAG) {
1274
- return describeClientReference();
1275
1359
  } else if (jsxPropsParents.has(objectOrArray)) {
1276
1360
  // Print JSX
1277
1361
  var _type = jsxPropsParents.get(objectOrArray);
@@ -1322,9 +1406,9 @@ function describeObjectForErrorMessage(objectOrArray, expandedName) {
1322
1406
  str += ', ';
1323
1407
  }
1324
1408
 
1325
- var _name2 = _names[_i3];
1326
- str += describeKeyForErrorMessage(_name2) + ': ';
1327
- var _value3 = _object[_name2];
1409
+ var _name = _names[_i3];
1410
+ str += describeKeyForErrorMessage(_name) + ': ';
1411
+ var _value3 = _object[_name];
1328
1412
 
1329
1413
  var _substr3 = void 0;
1330
1414
 
@@ -1334,7 +1418,7 @@ function describeObjectForErrorMessage(objectOrArray, expandedName) {
1334
1418
  _substr3 = describeValueForErrorMessage(_value3);
1335
1419
  }
1336
1420
 
1337
- if (_name2 === expandedName) {
1421
+ if (_name === expandedName) {
1338
1422
  start = str.length;
1339
1423
  length = _substr3.length;
1340
1424
  str += _substr3;
@@ -1389,11 +1473,12 @@ function defaultPostponeHandler(reason) {// Noop
1389
1473
  var OPEN = 0;
1390
1474
  var CLOSING = 1;
1391
1475
  var CLOSED = 2;
1392
- function createRequest(model, bundlerConfig, onError, identifierPrefix, onPostpone, environmentName) {
1476
+ function createRequest(model, bundlerConfig, onError, context, identifierPrefix, onPostpone) {
1393
1477
  if (ReactCurrentCache.current !== null && ReactCurrentCache.current !== DefaultCacheDispatcher) {
1394
1478
  throw new Error('Currently React only supports one RSC renderer at a time.');
1395
1479
  }
1396
1480
 
1481
+ prepareHostDispatcher();
1397
1482
  ReactCurrentCache.current = DefaultCacheDispatcher;
1398
1483
  var abortSet = new Set();
1399
1484
  var pingedTasks = [];
@@ -1419,19 +1504,21 @@ function createRequest(model, bundlerConfig, onError, identifierPrefix, onPostpo
1419
1504
  writtenSymbols: new Map(),
1420
1505
  writtenClientReferences: new Map(),
1421
1506
  writtenServerReferences: new Map(),
1507
+ writtenProviders: new Map(),
1422
1508
  writtenObjects: new WeakMap(),
1423
1509
  identifierPrefix: identifierPrefix || '',
1424
1510
  identifierCount: 1,
1425
1511
  taintCleanupQueue: cleanupQueue,
1426
1512
  onError: onError === undefined ? defaultErrorHandler : onError,
1427
- onPostpone: onPostpone === undefined ? defaultPostponeHandler : onPostpone
1513
+ onPostpone: onPostpone === undefined ? defaultPostponeHandler : onPostpone,
1514
+ // $FlowFixMe[missing-this-annot]
1515
+ toJSON: function (key, value) {
1516
+ return resolveModelToJSON(request, this, key, value);
1517
+ }
1428
1518
  };
1429
-
1430
- {
1431
- request.environmentName = environmentName === undefined ? 'Server' : environmentName;
1432
- }
1433
-
1434
- var rootTask = createTask(request, model, null, false, abortSet);
1519
+ request.pendingChunks++;
1520
+ var rootContext = createRootContext();
1521
+ var rootTask = createTask(request, model, rootContext, abortSet);
1435
1522
  pingedTasks.push(rootTask);
1436
1523
  return request;
1437
1524
  }
@@ -1442,18 +1529,13 @@ function resolveRequest() {
1442
1529
  return null;
1443
1530
  }
1444
1531
 
1445
- function serializeThenable(request, task, thenable) {
1446
- var newTask = createTask(request, null, task.keyPath, // the server component sequence continues through Promise-as-a-child.
1447
- task.implicitSlot, request.abortableTasks);
1448
-
1449
- {
1450
- // If this came from Flight, forward any debug info into this new row.
1451
- var debugInfo = thenable._debugInfo;
1532
+ function createRootContext(reqContext) {
1533
+ return importServerContexts();
1534
+ }
1452
1535
 
1453
- if (debugInfo) {
1454
- forwardDebugInfo(request, newTask.id, debugInfo);
1455
- }
1456
- }
1536
+ function serializeThenable(request, thenable) {
1537
+ request.pendingChunks++;
1538
+ var newTask = createTask(request, null, getActiveContext(), request.abortableTasks);
1457
1539
 
1458
1540
  switch (thenable.status) {
1459
1541
  case 'fulfilled':
@@ -1589,136 +1671,14 @@ function createLazyWrapperAroundWakeable(wakeable) {
1589
1671
  _payload: thenable,
1590
1672
  _init: readThenable
1591
1673
  };
1592
-
1593
- {
1594
- // If this came from React, transfer the debug info.
1595
- lazyType._debugInfo = thenable._debugInfo || [];
1596
- }
1597
-
1598
1674
  return lazyType;
1599
1675
  }
1600
1676
 
1601
- function renderFunctionComponent(request, task, key, Component, props) {
1602
- // Reset the task's thenable state before continuing, so that if a later
1603
- // component suspends we can reuse the same task object. If the same
1604
- // component suspends again, the thenable state will be restored.
1605
- var prevThenableState = task.thenableState;
1606
- task.thenableState = null;
1607
-
1608
- {
1609
- if (debugID === null) {
1610
- // We don't have a chunk to assign debug info. We need to outline this
1611
- // component to assign it an ID.
1612
- return outlineTask(request, task);
1613
- } else if (prevThenableState !== null) ; else {
1614
- // This is a new component in the same task so we can emit more debug info.
1615
- var componentName = Component.displayName || Component.name || '';
1616
- request.pendingChunks++;
1617
- emitDebugChunk(request, debugID, {
1618
- name: componentName,
1619
- env: request.environmentName
1620
- });
1621
- }
1622
- }
1623
-
1624
- prepareToUseHooksForComponent(prevThenableState); // The secondArg is always undefined in Server Components since refs error early.
1625
-
1626
- var secondArg = undefined;
1627
- var result = Component(props, secondArg);
1628
-
1629
- if (typeof result === 'object' && result !== null && typeof result.then === 'function') {
1630
- // When the return value is in children position we can resolve it immediately,
1631
- // to its value without a wrapper if it's synchronously available.
1632
- var thenable = result;
1633
-
1634
- if (thenable.status === 'fulfilled') {
1635
- return thenable.value;
1636
- } // TODO: Once we accept Promises as children on the client, we can just return
1637
- // the thenable here.
1638
-
1639
-
1640
- result = createLazyWrapperAroundWakeable(result);
1641
- } // Track this element's key on the Server Component on the keyPath context..
1642
-
1643
-
1644
- var prevKeyPath = task.keyPath;
1645
- var prevImplicitSlot = task.implicitSlot;
1646
-
1647
- if (key !== null) {
1648
- // Append the key to the path. Technically a null key should really add the child
1649
- // index. We don't do that to hold the payload small and implementation simple.
1650
- task.keyPath = prevKeyPath === null ? key : prevKeyPath + ',' + key;
1651
- } else if (prevKeyPath === null) {
1652
- // This sequence of Server Components has no keys. This means that it was rendered
1653
- // in a slot that needs to assign an implicit key. Even if children below have
1654
- // explicit keys, they should not be used for the outer most key since it might
1655
- // collide with other slots in that set.
1656
- task.implicitSlot = true;
1657
- }
1658
-
1659
- var json = renderModelDestructive(request, task, emptyRoot, '', result);
1660
- task.keyPath = prevKeyPath;
1661
- task.implicitSlot = prevImplicitSlot;
1662
- return json;
1663
- }
1664
-
1665
- function renderFragment(request, task, children) {
1666
- {
1667
- var debugInfo = children._debugInfo;
1668
-
1669
- if (debugInfo) {
1670
- // If this came from Flight, forward any debug info into this new row.
1671
- if (debugID === null) {
1672
- // We don't have a chunk to assign debug info. We need to outline this
1673
- // component to assign it an ID.
1674
- return outlineTask(request, task);
1675
- } else {
1676
- // Forward any debug info we have the first time we see it.
1677
- // We do this after init so that we have received all the debug info
1678
- // from the server by the time we emit it.
1679
- forwardDebugInfo(request, debugID, debugInfo);
1680
- }
1681
- }
1682
- }
1683
-
1684
- {
1685
- return children;
1686
- }
1687
- }
1688
-
1689
- function renderClientElement(task, type, key, props) {
1690
- {
1691
- return [REACT_ELEMENT_TYPE, type, key, props];
1692
- } // We prepend the terminal client element that actually gets serialized with
1693
- } // The chunk ID we're currently rendering that we can assign debug data to.
1694
-
1695
-
1696
- var debugID = null;
1697
-
1698
- function outlineTask(request, task) {
1699
- var newTask = createTask(request, task.model, // the currently rendering element
1700
- task.keyPath, // unlike outlineModel this one carries along context
1701
- task.implicitSlot, request.abortableTasks);
1702
- retryTask(request, newTask);
1703
-
1704
- if (newTask.status === COMPLETED) {
1705
- // We completed synchronously so we can refer to this by reference. This
1706
- // makes it behaves the same as prod during deserialization.
1707
- return serializeByValueID(newTask.id);
1708
- } // This didn't complete synchronously so it wouldn't have even if we didn't
1709
- // outline it, so this would reduce to a lazy reference even in prod.
1710
-
1711
-
1712
- return serializeLazyID(newTask.id);
1713
- }
1714
-
1715
- function renderElement(request, task, type, key, ref, props) {
1677
+ function attemptResolveElement(request, type, key, ref, props, prevThenableState) {
1716
1678
  if (ref !== null && ref !== undefined) {
1717
1679
  // When the ref moves to the regular props object this will implicitly
1718
1680
  // throw for functions. We could probably relax it to a DEV warning for other
1719
1681
  // cases.
1720
- // TODO: `ref` is now just a prop when `enableRefAsProp` is on. Should we
1721
- // do what the above comment says?
1722
1682
  throw new Error('Refs cannot be used in Server Components, nor passed to Client Components.');
1723
1683
  }
1724
1684
 
@@ -1733,36 +1693,47 @@ function renderElement(request, task, type, key, ref, props) {
1733
1693
  if (typeof type === 'function') {
1734
1694
  if (isClientReference(type)) {
1735
1695
  // This is a reference to a Client Component.
1736
- return renderClientElement(task, type, key, props);
1737
- } // This is a Server Component.
1696
+ return [REACT_ELEMENT_TYPE, type, key, props];
1697
+ } // This is a server-side component.
1698
+
1699
+
1700
+ prepareToUseHooksForComponent(prevThenableState);
1701
+ var result = type(props);
1702
+
1703
+ if (typeof result === 'object' && result !== null && typeof result.then === 'function') {
1704
+ // When the return value is in children position we can resolve it immediately,
1705
+ // to its value without a wrapper if it's synchronously available.
1706
+ var thenable = result;
1707
+
1708
+ if (thenable.status === 'fulfilled') {
1709
+ return thenable.value;
1710
+ } // TODO: Once we accept Promises as children on the client, we can just return
1711
+ // the thenable here.
1712
+
1738
1713
 
1714
+ return createLazyWrapperAroundWakeable(result);
1715
+ }
1739
1716
 
1740
- return renderFunctionComponent(request, task, key, type, props);
1717
+ return result;
1741
1718
  } else if (typeof type === 'string') {
1742
1719
  // This is a host element. E.g. HTML.
1743
- return renderClientElement(task, type, key, props);
1720
+ return [REACT_ELEMENT_TYPE, type, key, props];
1744
1721
  } else if (typeof type === 'symbol') {
1745
- if (type === REACT_FRAGMENT_TYPE && key === null) {
1722
+ if (type === REACT_FRAGMENT_TYPE) {
1746
1723
  // For key-less fragments, we add a small optimization to avoid serializing
1747
1724
  // it as a wrapper.
1748
- var prevImplicitSlot = task.implicitSlot;
1749
-
1750
- if (task.keyPath === null) {
1751
- task.implicitSlot = true;
1752
- }
1753
-
1754
- var json = renderModelDestructive(request, task, emptyRoot, '', props.children);
1755
- task.implicitSlot = prevImplicitSlot;
1756
- return json;
1725
+ // TODO: If a key is specified, we should propagate its key to any children.
1726
+ // Same as if a Server Component has a key.
1727
+ return props.children;
1757
1728
  } // This might be a built-in React component. We'll let the client decide.
1758
1729
  // Any built-in works as long as its props are serializable.
1759
1730
 
1760
1731
 
1761
- return renderClientElement(task, type, key, props);
1732
+ return [REACT_ELEMENT_TYPE, type, key, props];
1762
1733
  } else if (type != null && typeof type === 'object') {
1763
1734
  if (isClientReference(type)) {
1764
1735
  // This is a reference to a Client Component.
1765
- return renderClientElement(task, type, key, props);
1736
+ return [REACT_ELEMENT_TYPE, type, key, props];
1766
1737
  }
1767
1738
 
1768
1739
  switch (type.$$typeof) {
@@ -1771,17 +1742,19 @@ function renderElement(request, task, type, key, ref, props) {
1771
1742
  var payload = type._payload;
1772
1743
  var init = type._init;
1773
1744
  var wrappedType = init(payload);
1774
- return renderElement(request, task, wrappedType, key, ref, props);
1745
+ return attemptResolveElement(request, wrappedType, key, ref, props, prevThenableState);
1775
1746
  }
1776
1747
 
1777
1748
  case REACT_FORWARD_REF_TYPE:
1778
1749
  {
1779
- return renderFunctionComponent(request, task, key, type.render, props);
1750
+ var render = type.render;
1751
+ prepareToUseHooksForComponent(prevThenableState);
1752
+ return render(props, undefined);
1780
1753
  }
1781
1754
 
1782
1755
  case REACT_MEMO_TYPE:
1783
1756
  {
1784
- return renderElement(request, task, type.type, key, ref, props);
1757
+ return attemptResolveElement(request, type.type, key, ref, props, prevThenableState);
1785
1758
  }
1786
1759
  }
1787
1760
  }
@@ -1801,51 +1774,16 @@ function pingTask(request, task) {
1801
1774
  }
1802
1775
  }
1803
1776
 
1804
- function createTask(request, model, keyPath, implicitSlot, abortSet) {
1805
- request.pendingChunks++;
1777
+ function createTask(request, model, context, abortSet) {
1806
1778
  var id = request.nextChunkId++;
1807
-
1808
- if (typeof model === 'object' && model !== null) {
1809
- // If we're about to write this into a new task we can assign it an ID early so that
1810
- // any other references can refer to the value we're about to write.
1811
- {
1812
- request.writtenObjects.set(model, id);
1813
- }
1814
- }
1815
-
1816
1779
  var task = {
1817
1780
  id: id,
1818
1781
  status: PENDING$1,
1819
1782
  model: model,
1820
- keyPath: keyPath,
1821
- implicitSlot: implicitSlot,
1783
+ context: context,
1822
1784
  ping: function () {
1823
1785
  return pingTask(request, task);
1824
1786
  },
1825
- toJSON: function (parentPropertyName, value) {
1826
- var parent = this; // Make sure that `parent[parentPropertyName]` wasn't JSONified before `value` was passed to us
1827
-
1828
- {
1829
- // $FlowFixMe[incompatible-use]
1830
- var originalValue = parent[parentPropertyName];
1831
-
1832
- if (typeof originalValue === 'object' && originalValue !== value && !(originalValue instanceof Date)) {
1833
- if (objectName(originalValue) !== 'Object') {
1834
- var jsxParentType = jsxChildrenParents.get(parent);
1835
-
1836
- if (typeof jsxParentType === 'string') {
1837
- error('%s objects cannot be rendered as text children. Try formatting it using toString().%s', objectName(originalValue), describeObjectForErrorMessage(parent, parentPropertyName));
1838
- } else {
1839
- error('Only plain objects can be passed to Client Components from Server Components. ' + '%s objects are not supported.%s', objectName(originalValue), describeObjectForErrorMessage(parent, parentPropertyName));
1840
- }
1841
- } else {
1842
- error('Only plain objects can be passed to Client Components from Server Components. ' + 'Objects with toJSON methods are not supported. Convert it manually ' + 'to a simple value before passing it to props.%s', describeObjectForErrorMessage(parent, parentPropertyName));
1843
- }
1844
- }
1845
- }
1846
-
1847
- return renderModel(request, task, parent, parentPropertyName, value);
1848
- },
1849
1787
  thenableState: null
1850
1788
  };
1851
1789
  abortSet.add(task);
@@ -1914,13 +1852,13 @@ function encodeReferenceChunk(request, id, reference) {
1914
1852
  return stringToChunk(row);
1915
1853
  }
1916
1854
 
1917
- function serializeClientReference(request, parent, parentPropertyName, clientReference) {
1855
+ function serializeClientReference(request, parent, key, clientReference) {
1918
1856
  var clientReferenceKey = getClientReferenceKey(clientReference);
1919
1857
  var writtenClientReferences = request.writtenClientReferences;
1920
1858
  var existingId = writtenClientReferences.get(clientReferenceKey);
1921
1859
 
1922
1860
  if (existingId !== undefined) {
1923
- if (parent[0] === REACT_ELEMENT_TYPE && parentPropertyName === '1') {
1861
+ if (parent[0] === REACT_ELEMENT_TYPE && key === '1') {
1924
1862
  // If we're encoding the "type" of an element, we can refer
1925
1863
  // to that by a lazy reference instead of directly since React
1926
1864
  // knows how to deal with lazy values. This lets us suspend
@@ -1939,7 +1877,7 @@ function serializeClientReference(request, parent, parentPropertyName, clientRef
1939
1877
  emitImportChunk(request, importId, clientReferenceMetadata);
1940
1878
  writtenClientReferences.set(clientReferenceKey, importId);
1941
1879
 
1942
- if (parent[0] === REACT_ELEMENT_TYPE && parentPropertyName === '1') {
1880
+ if (parent[0] === REACT_ELEMENT_TYPE && key === '1') {
1943
1881
  // If we're encoding the "type" of an element, we can refer
1944
1882
  // to that by a lazy reference instead of directly since React
1945
1883
  // knows how to deal with lazy values. This lets us suspend
@@ -1959,14 +1897,13 @@ function serializeClientReference(request, parent, parentPropertyName, clientRef
1959
1897
  }
1960
1898
 
1961
1899
  function outlineModel(request, value) {
1962
- var newTask = createTask(request, value, null, // The way we use outlining is for reusing an object.
1963
- false, // It makes no sense for that use case to be contextual.
1964
- request.abortableTasks);
1900
+ request.pendingChunks++;
1901
+ var newTask = createTask(request, value, getActiveContext(), request.abortableTasks);
1965
1902
  retryTask(request, newTask);
1966
1903
  return newTask.id;
1967
1904
  }
1968
1905
 
1969
- function serializeServerReference(request, serverReference) {
1906
+ function serializeServerReference(request, parent, key, serverReference) {
1970
1907
  var writtenServerReferences = request.writtenServerReferences;
1971
1908
  var existingId = writtenServerReferences.get(serverReference);
1972
1909
 
@@ -2046,77 +1983,110 @@ function escapeStringValue(value) {
2046
1983
  return value;
2047
1984
  }
2048
1985
  }
2049
-
2050
1986
  var modelRoot = false;
2051
1987
 
2052
- function renderModel(request, task, parent, key, value) {
2053
- var prevKeyPath = task.keyPath;
2054
- var prevImplicitSlot = task.implicitSlot;
1988
+ function resolveModelToJSON(request, parent, key, value) {
1989
+ // Make sure that `parent[key]` wasn't JSONified before `value` was passed to us
1990
+ {
1991
+ // $FlowFixMe[incompatible-use]
1992
+ var originalValue = parent[key];
2055
1993
 
2056
- try {
2057
- return renderModelDestructive(request, task, parent, key, value);
2058
- } catch (thrownValue) {
2059
- var x = thrownValue === SuspenseException ? // This is a special type of exception used for Suspense. For historical
2060
- // reasons, the rest of the Suspense implementation expects the thrown
2061
- // value to be a thenable, because before `use` existed that was the
2062
- // (unstable) API for suspending. This implementation detail can change
2063
- // later, once we deprecate the old API in favor of `use`.
2064
- getSuspendedThenable() : thrownValue; // If the suspended/errored value was an element or lazy it can be reduced
2065
- // to a lazy reference, so that it doesn't error the parent.
1994
+ if (typeof originalValue === 'object' && originalValue !== value && !(originalValue instanceof Date)) {
1995
+ if (objectName(originalValue) !== 'Object') {
1996
+ var jsxParentType = jsxChildrenParents.get(parent);
2066
1997
 
2067
- var model = task.model;
2068
- var wasReactNode = typeof model === 'object' && model !== null && (model.$$typeof === REACT_ELEMENT_TYPE || model.$$typeof === REACT_LAZY_TYPE);
1998
+ if (typeof jsxParentType === 'string') {
1999
+ error('%s objects cannot be rendered as text children. Try formatting it using toString().%s', objectName(originalValue), describeObjectForErrorMessage(parent, key));
2000
+ } else {
2001
+ error('Only plain objects can be passed to Client Components from Server Components. ' + '%s objects are not supported.%s', objectName(originalValue), describeObjectForErrorMessage(parent, key));
2002
+ }
2003
+ } else {
2004
+ error('Only plain objects can be passed to Client Components from Server Components. ' + 'Objects with toJSON methods are not supported. Convert it manually ' + 'to a simple value before passing it to props.%s', describeObjectForErrorMessage(parent, key));
2005
+ }
2006
+ }
2007
+ } // Special Symbols
2069
2008
 
2070
- if (typeof x === 'object' && x !== null) {
2071
- // $FlowFixMe[method-unbinding]
2072
- if (typeof x.then === 'function') {
2073
- // Something suspended, we'll need to create a new task and resolve it later.
2074
- var newTask = createTask(request, task.model, task.keyPath, task.implicitSlot, request.abortableTasks);
2075
- var ping = newTask.ping;
2076
- x.then(ping, ping);
2077
- newTask.thenableState = getThenableStateAfterSuspending(); // Restore the context. We assume that this will be restored by the inner
2078
- // functions in case nothing throws so we don't use "finally" here.
2079
2009
 
2080
- task.keyPath = prevKeyPath;
2081
- task.implicitSlot = prevImplicitSlot;
2010
+ switch (value) {
2011
+ case REACT_ELEMENT_TYPE:
2012
+ return '$';
2013
+ }
2082
2014
 
2083
- if (wasReactNode) {
2084
- return serializeLazyID(newTask.id);
2085
- }
2086
2015
 
2087
- return serializeByValueID(newTask.id);
2088
- }
2089
- } // Restore the context. We assume that this will be restored by the inner
2090
- // functions in case nothing throws so we don't use "finally" here.
2016
+ while (typeof value === 'object' && value !== null && (value.$$typeof === REACT_ELEMENT_TYPE || value.$$typeof === REACT_LAZY_TYPE)) {
2017
+
2018
+ try {
2019
+ switch (value.$$typeof) {
2020
+ case REACT_ELEMENT_TYPE:
2021
+ {
2022
+ var writtenObjects = request.writtenObjects;
2023
+ var existingId = writtenObjects.get(value);
2024
+
2025
+ if (existingId !== undefined) {
2026
+ if (existingId === -1) {
2027
+ // Seen but not yet outlined.
2028
+ var newId = outlineModel(request, value);
2029
+ return serializeByValueID(newId);
2030
+ } else if (modelRoot === value) {
2031
+ // This is the ID we're currently emitting so we need to write it
2032
+ // once but if we discover it again, we refer to it by id.
2033
+ modelRoot = null;
2034
+ } else {
2035
+ // We've already emitted this as an outlined object, so we can
2036
+ // just refer to that by its existing ID.
2037
+ return serializeByValueID(existingId);
2038
+ }
2039
+ } else {
2040
+ // This is the first time we've seen this object. We may never see it again
2041
+ // so we'll inline it. Mark it as seen. If we see it again, we'll outline.
2042
+ writtenObjects.set(value, -1);
2043
+ } // TODO: Concatenate keys of parents onto children.
2091
2044
 
2092
2045
 
2093
- task.keyPath = prevKeyPath;
2094
- task.implicitSlot = prevImplicitSlot;
2046
+ var element = value; // Attempt to render the Server Component.
2047
+
2048
+ value = attemptResolveElement(request, element.type, element.key, element.ref, element.props, null);
2049
+ break;
2050
+ }
2095
2051
 
2096
- if (wasReactNode) {
2097
- // Something errored. We'll still send everything we have up until this point.
2052
+ case REACT_LAZY_TYPE:
2053
+ {
2054
+ var payload = value._payload;
2055
+ var init = value._init;
2056
+ value = init(payload);
2057
+ break;
2058
+ }
2059
+ }
2060
+ } catch (thrownValue) {
2061
+ var x = thrownValue === SuspenseException ? // This is a special type of exception used for Suspense. For historical
2062
+ // reasons, the rest of the Suspense implementation expects the thrown
2063
+ // value to be a thenable, because before `use` existed that was the
2064
+ // (unstable) API for suspending. This implementation detail can change
2065
+ // later, once we deprecate the old API in favor of `use`.
2066
+ getSuspendedThenable() : thrownValue;
2067
+
2068
+ if (typeof x === 'object' && x !== null) {
2069
+ // $FlowFixMe[method-unbinding]
2070
+ if (typeof x.then === 'function') {
2071
+ // Something suspended, we'll need to create a new task and resolve it later.
2072
+ request.pendingChunks++;
2073
+ var newTask = createTask(request, value, getActiveContext(), request.abortableTasks);
2074
+ var ping = newTask.ping;
2075
+ x.then(ping, ping);
2076
+ newTask.thenableState = getThenableStateAfterSuspending();
2077
+ return serializeLazyID(newTask.id);
2078
+ }
2079
+ } // Something errored. We'll still send everything we have up until this point.
2098
2080
  // We'll replace this element with a lazy reference that throws on the client
2099
2081
  // once it gets rendered.
2082
+
2083
+
2100
2084
  request.pendingChunks++;
2101
2085
  var errorId = request.nextChunkId++;
2102
2086
  var digest = logRecoverableError(request, x);
2103
2087
  emitErrorChunk(request, errorId, digest, x);
2104
2088
  return serializeLazyID(errorId);
2105
- } // Something errored but it was not in a React Node. There's no need to serialize
2106
- // it by value because it'll just error the whole parent row anyway so we can
2107
- // just stop any siblings and error the whole parent row.
2108
-
2109
-
2110
- throw x;
2111
- }
2112
- }
2113
-
2114
- function renderModelDestructive(request, task, parent, parentPropertyName, value) {
2115
- // Set the currently rendering model
2116
- task.model = value; // Special Symbol, that's very common.
2117
-
2118
- if (value === REACT_ELEMENT_TYPE) {
2119
- return '$';
2089
+ }
2120
2090
  }
2121
2091
 
2122
2092
  if (value === null) {
@@ -2124,152 +2094,61 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
2124
2094
  }
2125
2095
 
2126
2096
  if (typeof value === 'object') {
2127
- switch (value.$$typeof) {
2128
- case REACT_ELEMENT_TYPE:
2129
- {
2130
- var _writtenObjects = request.writtenObjects;
2131
-
2132
- var _existingId = _writtenObjects.get(value);
2133
-
2134
- if (_existingId !== undefined) {
2135
- if (modelRoot === value) {
2136
- // This is the ID we're currently emitting so we need to write it
2137
- // once but if we discover it again, we refer to it by id.
2138
- modelRoot = null;
2139
- } else if (_existingId === -1) {
2140
- // Seen but not yet outlined.
2141
- // TODO: If we throw here we can treat this as suspending which causes an outline
2142
- // but that is able to reuse the same task if we're already in one but then that
2143
- // will be a lazy future value rather than guaranteed to exist but maybe that's good.
2144
- var newId = outlineModel(request, value);
2145
- return serializeByValueID(newId);
2146
- } else {
2147
- // We've already emitted this as an outlined object, so we can refer to that by its
2148
- // existing ID. TODO: We should use a lazy reference since, unlike plain objects,
2149
- // elements might suspend so it might not have emitted yet even if we have the ID for
2150
- // it. However, this creates an extra wrapper when it's not needed. We should really
2151
- // detect whether this already was emitted and synchronously available. In that
2152
- // case we can refer to it synchronously and only make it lazy otherwise.
2153
- // We currently don't have a data structure that lets us see that though.
2154
- return serializeByValueID(_existingId);
2155
- }
2156
- } else {
2157
- // This is the first time we've seen this object. We may never see it again
2158
- // so we'll inline it. Mark it as seen. If we see it again, we'll outline.
2159
- _writtenObjects.set(value, -1);
2160
- }
2161
-
2162
- var element = value;
2163
-
2164
- {
2165
- var debugInfo = value._debugInfo;
2166
-
2167
- if (debugInfo) {
2168
- // If this came from Flight, forward any debug info into this new row.
2169
- if (debugID === null) {
2170
- // We don't have a chunk to assign debug info. We need to outline this
2171
- // component to assign it an ID.
2172
- return outlineTask(request, task);
2173
- } else {
2174
- // Forward any debug info we have the first time we see it.
2175
- forwardDebugInfo(request, debugID, debugInfo);
2176
- }
2177
- }
2178
- }
2179
-
2180
- var props = element.props;
2181
- var ref;
2182
-
2183
- {
2184
- ref = element.ref;
2185
- } // Attempt to render the Server Component.
2186
-
2187
-
2188
- return renderElement(request, task, element.type, // $FlowFixMe[incompatible-call] the key of an element is null | string
2189
- element.key, ref, props);
2190
- }
2191
-
2192
- case REACT_LAZY_TYPE:
2193
- {
2194
- // Reset the task's thenable state before continuing. If there was one, it was
2195
- // from suspending the lazy before.
2196
- task.thenableState = null;
2197
- var lazy = value;
2198
- var payload = lazy._payload;
2199
- var init = lazy._init;
2200
- var resolvedModel = init(payload);
2201
-
2202
- {
2203
- var _debugInfo = lazy._debugInfo;
2204
-
2205
- if (_debugInfo) {
2206
- // If this came from Flight, forward any debug info into this new row.
2207
- if (debugID === null) {
2208
- // We don't have a chunk to assign debug info. We need to outline this
2209
- // component to assign it an ID.
2210
- return outlineTask(request, task);
2211
- } else {
2212
- // Forward any debug info we have the first time we see it.
2213
- // We do this after init so that we have received all the debug info
2214
- // from the server by the time we emit it.
2215
- forwardDebugInfo(request, debugID, _debugInfo);
2216
- }
2217
- }
2218
- }
2219
-
2220
- return renderModelDestructive(request, task, emptyRoot, '', resolvedModel);
2221
- }
2222
- }
2223
2097
 
2224
2098
  if (isClientReference(value)) {
2225
- return serializeClientReference(request, parent, parentPropertyName, value);
2099
+ return serializeClientReference(request, parent, key, value);
2226
2100
  }
2227
2101
 
2228
- var writtenObjects = request.writtenObjects;
2229
- var existingId = writtenObjects.get(value); // $FlowFixMe[method-unbinding]
2102
+ var _writtenObjects = request.writtenObjects;
2103
+
2104
+ var _existingId = _writtenObjects.get(value); // $FlowFixMe[method-unbinding]
2105
+
2230
2106
 
2231
2107
  if (typeof value.then === 'function') {
2232
- if (existingId !== undefined) {
2108
+ if (_existingId !== undefined) {
2233
2109
  if (modelRoot === value) {
2234
2110
  // This is the ID we're currently emitting so we need to write it
2235
2111
  // once but if we discover it again, we refer to it by id.
2236
2112
  modelRoot = null;
2237
2113
  } else {
2238
2114
  // We've seen this promise before, so we can just refer to the same result.
2239
- return serializePromiseID(existingId);
2115
+ return serializePromiseID(_existingId);
2240
2116
  }
2241
2117
  } // We assume that any object with a .then property is a "Thenable" type,
2242
2118
  // or a Promise type. Either of which can be represented by a Promise.
2243
2119
 
2244
2120
 
2245
- var promiseId = serializeThenable(request, task, value);
2246
- writtenObjects.set(value, promiseId);
2121
+ var promiseId = serializeThenable(request, value);
2122
+
2123
+ _writtenObjects.set(value, promiseId);
2124
+
2247
2125
  return serializePromiseID(promiseId);
2248
2126
  }
2249
2127
 
2250
- if (existingId !== undefined) {
2251
- if (modelRoot === value) {
2252
- // This is the ID we're currently emitting so we need to write it
2253
- // once but if we discover it again, we refer to it by id.
2254
- modelRoot = null;
2255
- } else if (existingId === -1) {
2128
+ if (_existingId !== undefined) {
2129
+ if (_existingId === -1) {
2256
2130
  // Seen but not yet outlined.
2257
2131
  var _newId = outlineModel(request, value);
2258
2132
 
2259
2133
  return serializeByValueID(_newId);
2134
+ } else if (modelRoot === value) {
2135
+ // This is the ID we're currently emitting so we need to write it
2136
+ // once but if we discover it again, we refer to it by id.
2137
+ modelRoot = null;
2260
2138
  } else {
2261
2139
  // We've already emitted this as an outlined object, so we can
2262
2140
  // just refer to that by its existing ID.
2263
- return serializeByValueID(existingId);
2141
+ return serializeByValueID(_existingId);
2264
2142
  }
2265
2143
  } else {
2266
2144
  // This is the first time we've seen this object. We may never see it again
2267
2145
  // so we'll inline it. Mark it as seen. If we see it again, we'll outline.
2268
- writtenObjects.set(value, -1);
2146
+ _writtenObjects.set(value, -1);
2269
2147
  }
2270
2148
 
2271
2149
  if (isArray(value)) {
2272
- return renderFragment(request, task, value);
2150
+ // $FlowFixMe[incompatible-return]
2151
+ return value;
2273
2152
  }
2274
2153
 
2275
2154
  if (value instanceof Map) {
@@ -2283,7 +2162,7 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
2283
2162
  var iteratorFn = getIteratorFn(value);
2284
2163
 
2285
2164
  if (iteratorFn) {
2286
- return renderFragment(request, task, Array.from(value));
2165
+ return Array.from(value);
2287
2166
  } // Verify that this is a simple plain object.
2288
2167
 
2289
2168
 
@@ -2295,14 +2174,14 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
2295
2174
 
2296
2175
  {
2297
2176
  if (objectName(value) !== 'Object') {
2298
- error('Only plain objects can be passed to Client Components from Server Components. ' + '%s objects are not supported.%s', objectName(value), describeObjectForErrorMessage(parent, parentPropertyName));
2177
+ error('Only plain objects can be passed to Client Components from Server Components. ' + '%s objects are not supported.%s', objectName(value), describeObjectForErrorMessage(parent, key));
2299
2178
  } else if (!isSimpleObject(value)) {
2300
- error('Only plain objects can be passed to Client Components from Server Components. ' + 'Classes or other objects with methods are not supported.%s', describeObjectForErrorMessage(parent, parentPropertyName));
2179
+ error('Only plain objects can be passed to Client Components from Server Components. ' + 'Classes or other objects with methods are not supported.%s', describeObjectForErrorMessage(parent, key));
2301
2180
  } else if (Object.getOwnPropertySymbols) {
2302
2181
  var symbols = Object.getOwnPropertySymbols(value);
2303
2182
 
2304
2183
  if (symbols.length > 0) {
2305
- error('Only plain objects can be passed to Client Components from Server Components. ' + 'Objects with symbol properties like %s are not supported.%s', symbols[0].description, describeObjectForErrorMessage(parent, parentPropertyName));
2184
+ error('Only plain objects can be passed to Client Components from Server Components. ' + 'Objects with symbol properties like %s are not supported.%s', symbols[0].description, describeObjectForErrorMessage(parent, key));
2306
2185
  }
2307
2186
  }
2308
2187
  } // $FlowFixMe[incompatible-return]
@@ -2317,9 +2196,9 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
2317
2196
  if (value[value.length - 1] === 'Z') {
2318
2197
  // Possibly a Date, whose toJSON automatically calls toISOString
2319
2198
  // $FlowFixMe[incompatible-use]
2320
- var originalValue = parent[parentPropertyName];
2199
+ var _originalValue = parent[key];
2321
2200
 
2322
- if (originalValue instanceof Date) {
2201
+ if (_originalValue instanceof Date) {
2323
2202
  return serializeDateFromDateJSON(value);
2324
2203
  }
2325
2204
  }
@@ -2347,21 +2226,19 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
2347
2226
  }
2348
2227
 
2349
2228
  if (typeof value === 'function') {
2229
+
2350
2230
  if (isClientReference(value)) {
2351
- return serializeClientReference(request, parent, parentPropertyName, value);
2231
+ return serializeClientReference(request, parent, key, value);
2352
2232
  }
2353
2233
 
2354
2234
  if (isServerReference(value)) {
2355
- return serializeServerReference(request, value);
2235
+ return serializeServerReference(request, parent, key, value);
2356
2236
  }
2357
2237
 
2358
- if (/^on[A-Z]/.test(parentPropertyName)) {
2359
- throw new Error('Event handlers cannot be passed to Client Component props.' + describeObjectForErrorMessage(parent, parentPropertyName) + '\nIf you need interactivity, consider converting part of this to a Client Component.');
2360
- } else if ((jsxChildrenParents.has(parent) || jsxPropsParents.has(parent) && parentPropertyName === 'children')) {
2361
- var componentName = value.displayName || value.name || 'Component';
2362
- throw new Error('Functions are not valid as a child of Client Components. This may happen if ' + 'you return ' + componentName + ' instead of <' + componentName + ' /> from render. ' + 'Or maybe you meant to call this function rather than return it.' + describeObjectForErrorMessage(parent, parentPropertyName));
2238
+ if (/^on[A-Z]/.test(key)) {
2239
+ throw new Error('Event handlers cannot be passed to Client Component props.' + describeObjectForErrorMessage(parent, key) + '\nIf you need interactivity, consider converting part of this to a Client Component.');
2363
2240
  } else {
2364
- throw new Error('Functions cannot be passed directly to Client Components ' + 'unless you explicitly expose it by marking it with "use server". ' + 'Or maybe you meant to call this function rather than return it.' + describeObjectForErrorMessage(parent, parentPropertyName));
2241
+ throw new Error('Functions cannot be passed directly to Client Components ' + 'unless you explicitly expose it by marking it with "use server".' + describeObjectForErrorMessage(parent, key));
2365
2242
  }
2366
2243
  }
2367
2244
 
@@ -2379,7 +2256,7 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
2379
2256
 
2380
2257
  if (Symbol.for(name) !== value) {
2381
2258
  throw new Error('Only global symbols received from Symbol.for(...) can be passed to Client Components. ' + ("The symbol Symbol.for(" + // $FlowFixMe[incompatible-type] `description` might be undefined
2382
- value.description + ") cannot be found among global symbols.") + describeObjectForErrorMessage(parent, parentPropertyName));
2259
+ value.description + ") cannot be found among global symbols.") + describeObjectForErrorMessage(parent, key));
2383
2260
  }
2384
2261
 
2385
2262
  request.pendingChunks++;
@@ -2394,38 +2271,17 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
2394
2271
  return serializeBigInt(value);
2395
2272
  }
2396
2273
 
2397
- throw new Error("Type " + typeof value + " is not supported in Client Component props." + describeObjectForErrorMessage(parent, parentPropertyName));
2274
+ throw new Error("Type " + typeof value + " is not supported in Client Component props." + describeObjectForErrorMessage(parent, key));
2398
2275
  }
2399
2276
 
2400
2277
  function logPostpone(request, reason) {
2401
- var prevRequest = currentRequest;
2402
- currentRequest = null;
2403
-
2404
- try {
2405
- var onPostpone = request.onPostpone;
2406
-
2407
- if (supportsRequestStorage) ; else {
2408
- onPostpone(reason);
2409
- }
2410
- } finally {
2411
- currentRequest = prevRequest;
2412
- }
2278
+ var onPostpone = request.onPostpone;
2279
+ onPostpone(reason);
2413
2280
  }
2414
2281
 
2415
2282
  function logRecoverableError(request, error) {
2416
- var prevRequest = currentRequest;
2417
- currentRequest = null;
2418
- var errorDigest;
2419
-
2420
- try {
2421
- var onError = request.onError;
2422
-
2423
- if (supportsRequestStorage) ; else {
2424
- errorDigest = onError(error);
2425
- }
2426
- } finally {
2427
- currentRequest = prevRequest;
2428
- }
2283
+ var onError = request.onError;
2284
+ var errorDigest = onError(error);
2429
2285
 
2430
2286
  if (errorDigest != null && typeof errorDigest !== 'string') {
2431
2287
  // eslint-disable-next-line react-internal/prod-error-codes
@@ -2484,11 +2340,8 @@ function emitErrorChunk(request, id, digest, error) {
2484
2340
  message = String(error.message); // eslint-disable-next-line react-internal/safe-string-coercion
2485
2341
 
2486
2342
  stack = String(error.stack);
2487
- } else if (typeof error === 'object' && error !== null) {
2488
- message = describeObjectForErrorMessage(error);
2489
2343
  } else {
2490
- // eslint-disable-next-line react-internal/safe-string-coercion
2491
- message = String(error);
2344
+ message = 'Error: ' + error;
2492
2345
  }
2493
2346
  } catch (x) {
2494
2347
  message = 'An error occurred but serializing the error message failed.';
@@ -2528,79 +2381,62 @@ function emitSymbolChunk(request, id, name) {
2528
2381
  request.completedImportChunks.push(processedChunk);
2529
2382
  }
2530
2383
 
2531
- function emitModelChunk(request, id, json) {
2532
- var row = id.toString(16) + ':' + json + '\n';
2533
- var processedChunk = stringToChunk(row);
2534
- request.completedRegularChunks.push(processedChunk);
2535
- }
2536
-
2537
- function emitDebugChunk(request, id, debugInfo) {
2384
+ function emitModelChunk(request, id, model) {
2385
+ // Track the root so we know that we have to emit this object even though it
2386
+ // already has an ID. This is needed because we might see this object twice
2387
+ // in the same toJSON if it is cyclic.
2388
+ modelRoot = model; // $FlowFixMe[incompatible-type] stringify can return null
2538
2389
 
2539
-
2540
- var json = stringify(debugInfo);
2541
- var row = serializeRowHeader('D', id) + json + '\n';
2390
+ var json = stringify(model, request.toJSON);
2391
+ var row = id.toString(16) + ':' + json + '\n';
2542
2392
  var processedChunk = stringToChunk(row);
2543
2393
  request.completedRegularChunks.push(processedChunk);
2544
2394
  }
2545
2395
 
2546
- function forwardDebugInfo(request, id, debugInfo) {
2547
- for (var i = 0; i < debugInfo.length; i++) {
2548
- request.pendingChunks++;
2549
- emitDebugChunk(request, id, debugInfo[i]);
2550
- }
2551
- }
2552
-
2553
- var emptyRoot = {};
2554
-
2555
2396
  function retryTask(request, task) {
2556
2397
  if (task.status !== PENDING$1) {
2557
2398
  // We completed this by other means before we had a chance to retry it.
2558
2399
  return;
2559
2400
  }
2560
2401
 
2561
- var prevDebugID = debugID;
2402
+ switchContext(task.context);
2562
2403
 
2563
2404
  try {
2564
- // Track the root so we know that we have to emit this object even though it
2565
- // already has an ID. This is needed because we might see this object twice
2566
- // in the same toJSON if it is cyclic.
2567
- modelRoot = task.model;
2405
+ var value = task.model;
2568
2406
 
2569
- if (true) {
2570
- // Track the ID of the current task so we can assign debug info to this id.
2571
- debugID = task.id;
2572
- } // We call the destructive form that mutates this task. That way if something
2573
- // suspends again, we can reuse the same task instead of spawning a new one.
2407
+ if (typeof value === 'object' && value !== null && value.$$typeof === REACT_ELEMENT_TYPE) {
2408
+ request.writtenObjects.set(value, task.id); // TODO: Concatenate keys of parents onto children.
2574
2409
 
2410
+ var element = value; // When retrying a component, reuse the thenableState from the
2411
+ // previous attempt.
2575
2412
 
2576
- var resolvedModel = renderModelDestructive(request, task, emptyRoot, '', task.model);
2413
+ var prevThenableState = task.thenableState; // Attempt to render the Server Component.
2414
+ // Doing this here lets us reuse this same task if the next component
2415
+ // also suspends.
2577
2416
 
2578
- if (true) {
2579
- // We're now past rendering this task and future renders will spawn new tasks for their
2580
- // debug info.
2581
- debugID = null;
2582
- } // Track the root again for the resolved object.
2417
+ task.model = value;
2418
+ value = attemptResolveElement(request, element.type, element.key, element.ref, element.props, prevThenableState); // Successfully finished this component. We're going to keep rendering
2419
+ // using the same task, but we reset its thenable state before continuing.
2583
2420
 
2421
+ task.thenableState = null; // Keep rendering and reuse the same task. This inner loop is separate
2422
+ // from the render above because we don't need to reset the thenable state
2423
+ // until the next time something suspends and retries.
2584
2424
 
2585
- modelRoot = resolvedModel; // The keyPath resets at any terminal child node.
2425
+ while (typeof value === 'object' && value !== null && value.$$typeof === REACT_ELEMENT_TYPE) {
2426
+ request.writtenObjects.set(value, task.id); // TODO: Concatenate keys of parents onto children.
2586
2427
 
2587
- task.keyPath = null;
2588
- task.implicitSlot = false;
2589
- var json;
2428
+ var nextElement = value;
2429
+ task.model = value;
2430
+ value = attemptResolveElement(request, nextElement.type, nextElement.key, nextElement.ref, nextElement.props, null);
2431
+ }
2432
+ } // Track that this object is outlined and has an id.
2590
2433
 
2591
- if (typeof resolvedModel === 'object' && resolvedModel !== null) {
2592
- // Object might contain unresolved values like additional elements.
2593
- // This is simulating what the JSON loop would do if this was part of it.
2594
- // $FlowFixMe[incompatible-type] stringify can return null for undefined but we never do
2595
- json = stringify(resolvedModel, task.toJSON);
2596
- } else {
2597
- // If the value is a string, it means it's a terminal value and we already escaped it
2598
- // We don't need to escape it again so it's not passed the toJSON replacer.
2599
- // $FlowFixMe[incompatible-type] stringify can return null for undefined but we never do
2600
- json = stringify(resolvedModel);
2434
+
2435
+ if (typeof value === 'object' && value !== null) {
2436
+ request.writtenObjects.set(value, task.id);
2601
2437
  }
2602
2438
 
2603
- emitModelChunk(request, task.id, json);
2439
+ emitModelChunk(request, task.id, value);
2604
2440
  request.abortableTasks.delete(task);
2605
2441
  task.status = COMPLETED;
2606
2442
  } catch (thrownValue) {
@@ -2626,10 +2462,6 @@ function retryTask(request, task) {
2626
2462
  task.status = ERRORED$1;
2627
2463
  var digest = logRecoverableError(request, x);
2628
2464
  emitErrorChunk(request, task.id, digest, x);
2629
- } finally {
2630
- {
2631
- debugID = prevDebugID;
2632
- }
2633
2465
  }
2634
2466
  }
2635
2467
 
@@ -2842,6 +2674,11 @@ function abort(request, reason) {
2842
2674
  }
2843
2675
  }
2844
2676
 
2677
+ function importServerContexts(contexts) {
2678
+
2679
+ return rootContextSnapshot;
2680
+ }
2681
+
2845
2682
  // This is the parsed shape of the wire format which is why it is
2846
2683
  // condensed to only the essentialy information
2847
2684
  var ID = 0;
@@ -3564,7 +3401,7 @@ function decodeFormState(actionResult, body, serverManifest) {
3564
3401
  }
3565
3402
 
3566
3403
  function renderToReadableStream(model, webpackMap, options) {
3567
- var request = createRequest(model, webpackMap, options ? options.onError : undefined, options ? options.identifierPrefix : undefined, options ? options.onPostpone : undefined, options ? options.environmentName : undefined);
3404
+ var request = createRequest(model, webpackMap, options ? options.onError : undefined, options ? options.context : undefined, options ? options.identifierPrefix : undefined, options ? options.onPostpone : undefined);
3568
3405
 
3569
3406
  if (options && options.signal) {
3570
3407
  var signal = options.signal;