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
@@ -132,15 +132,9 @@ function writeViewChunk(destination, chunk) {
132
132
  }
133
133
 
134
134
  if (chunk.byteLength > VIEW_SIZE) {
135
- {
136
- if (precomputedChunkSet && precomputedChunkSet.has(chunk)) {
137
- 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.');
138
- }
139
- } // this chunk may overflow a single view which implies it was not
135
+ // this chunk may overflow a single view which implies it was not
140
136
  // one that is cached by the streaming renderer. We will enqueu
141
137
  // it directly and expect it is not re-used
142
-
143
-
144
138
  if (writtenBytes > 0) {
145
139
  writeToDestination(destination, currentView.subarray(0, writtenBytes));
146
140
  currentView = new Uint8Array(VIEW_SIZE);
@@ -216,7 +210,6 @@ var textEncoder = new util.TextEncoder();
216
210
  function stringToChunk(content) {
217
211
  return content;
218
212
  }
219
- var precomputedChunkSet = new Set() ;
220
213
  function byteLengthOfChunk(chunk) {
221
214
  return typeof chunk === 'string' ? Buffer.byteLength(chunk, 'utf8') : chunk.byteLength;
222
215
  }
@@ -226,10 +219,10 @@ function closeWithError(destination, error) {
226
219
  }
227
220
 
228
221
  // eslint-disable-next-line no-unused-vars
229
- var CLIENT_REFERENCE_TAG$1 = Symbol.for('react.client.reference');
222
+ var CLIENT_REFERENCE_TAG = Symbol.for('react.client.reference');
230
223
  var SERVER_REFERENCE_TAG = Symbol.for('react.server.reference');
231
224
  function isClientReference(reference) {
232
- return reference.$$typeof === CLIENT_REFERENCE_TAG$1;
225
+ return reference.$$typeof === CLIENT_REFERENCE_TAG;
233
226
  }
234
227
  function isServerReference(reference) {
235
228
  return reference.$$typeof === SERVER_REFERENCE_TAG;
@@ -241,7 +234,7 @@ function registerClientReference(proxyImplementation, id, exportName) {
241
234
  function registerClientReferenceImpl(proxyImplementation, id, async) {
242
235
  return Object.defineProperties(proxyImplementation, {
243
236
  $$typeof: {
244
- value: CLIENT_REFERENCE_TAG$1
237
+ value: CLIENT_REFERENCE_TAG
245
238
  },
246
239
  $$id: {
247
240
  value: id
@@ -262,14 +255,6 @@ function bind() {
262
255
  var newFn = FunctionBind.apply(this, arguments);
263
256
 
264
257
  if (this.$$typeof === SERVER_REFERENCE_TAG) {
265
- {
266
- var thisBind = arguments[0];
267
-
268
- if (thisBind != null) {
269
- error('Cannot bind "this" of a Server Action. Pass null or undefined as the first argument to .bind().');
270
- }
271
- }
272
-
273
258
  var args = ArraySlice.call(arguments, 1);
274
259
  return Object.defineProperties(newFn, {
275
260
  $$typeof: {
@@ -296,16 +281,13 @@ function registerServerReference(reference, id, exportName) {
296
281
  value: SERVER_REFERENCE_TAG
297
282
  },
298
283
  $$id: {
299
- value: exportName === null ? id : id + '#' + exportName,
300
- configurable: true
284
+ value: exportName === null ? id : id + '#' + exportName
301
285
  },
302
286
  $$bound: {
303
- value: null,
304
- configurable: true
287
+ value: null
305
288
  },
306
289
  bind: {
307
- value: bind,
308
- configurable: true
290
+ value: bind
309
291
  }
310
292
  });
311
293
  }
@@ -344,10 +326,6 @@ var deepProxyHandlers = {
344
326
  // $FlowFixMe[prop-missing]
345
327
  return Object.prototype[Symbol.toPrimitive];
346
328
 
347
- case Symbol.toStringTag:
348
- // $FlowFixMe[prop-missing]
349
- return Object.prototype[Symbol.toStringTag];
350
-
351
329
  case 'Provider':
352
330
  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.");
353
331
  } // eslint-disable-next-line react-internal/safe-string-coercion
@@ -389,10 +367,6 @@ function getReference(target, name) {
389
367
  // $FlowFixMe[prop-missing]
390
368
  return Object.prototype[Symbol.toPrimitive];
391
369
 
392
- case Symbol.toStringTag:
393
- // $FlowFixMe[prop-missing]
394
- return Object.prototype[Symbol.toStringTag];
395
-
396
370
  case '__esModule':
397
371
  // Something is conditionally checking which export to use. We'll pretend to be
398
372
  // an ESM compat module but then we'll check again on the client.
@@ -433,10 +407,6 @@ function getReference(target, name) {
433
407
 
434
408
  }
435
409
 
436
- if (typeof name === 'symbol') {
437
- throw new Error('Cannot read Symbol exports. Only named exports are supported on a client module ' + 'imported on the server.');
438
- }
439
-
440
410
  var cachedReference = target[name];
441
411
 
442
412
  if (!cachedReference) {
@@ -529,9 +499,7 @@ function getServerReferenceBoundArguments(config, serverReference) {
529
499
 
530
500
  var ReactDOMSharedInternals = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
531
501
 
532
- var ReactDOMCurrentDispatcher = ReactDOMSharedInternals.ReactDOMCurrentDispatcher;
533
- var previousDispatcher = ReactDOMCurrentDispatcher.current;
534
- ReactDOMCurrentDispatcher.current = {
502
+ var ReactDOMFlightServerDispatcher = {
535
503
  prefetchDNS: prefetchDNS,
536
504
  preconnect: preconnect,
537
505
  preload: preload,
@@ -557,8 +525,6 @@ function prefetchDNS(href) {
557
525
 
558
526
  hints.add(key);
559
527
  emitHint(request, 'D', href);
560
- } else {
561
- previousDispatcher.prefetchDNS(href);
562
528
  }
563
529
  }
564
530
  }
@@ -585,8 +551,6 @@ function preconnect(href, crossOrigin) {
585
551
  } else {
586
552
  emitHint(request, 'C', href);
587
553
  }
588
- } else {
589
- previousDispatcher.preconnect(href, crossOrigin);
590
554
  }
591
555
  }
592
556
  }
@@ -620,8 +584,6 @@ function preload(href, as, options) {
620
584
  } else {
621
585
  emitHint(request, 'L', [href, as]);
622
586
  }
623
- } else {
624
- previousDispatcher.preload(href, as, options);
625
587
  }
626
588
  }
627
589
  }
@@ -649,8 +611,6 @@ function preloadModule$1(href, options) {
649
611
  } else {
650
612
  return emitHint(request, 'm', href);
651
613
  }
652
- } else {
653
- previousDispatcher.preloadModule(href, options);
654
614
  }
655
615
  }
656
616
  }
@@ -680,21 +640,19 @@ function preinitStyle(href, precedence, options) {
680
640
  } else {
681
641
  return emitHint(request, 'S', href);
682
642
  }
683
- } else {
684
- previousDispatcher.preinitStyle(href, precedence, options);
685
643
  }
686
644
  }
687
645
  }
688
646
  }
689
647
 
690
- function preinitScript(src, options) {
648
+ function preinitScript(href, options) {
691
649
  {
692
- if (typeof src === 'string') {
650
+ if (typeof href === 'string') {
693
651
  var request = resolveRequest();
694
652
 
695
653
  if (request) {
696
654
  var hints = getHints(request);
697
- var key = 'X|' + src;
655
+ var key = 'X|' + href;
698
656
 
699
657
  if (hints.has(key)) {
700
658
  // duplicate hint
@@ -705,25 +663,23 @@ function preinitScript(src, options) {
705
663
  var trimmed = trimOptions(options);
706
664
 
707
665
  if (trimmed) {
708
- return emitHint(request, 'X', [src, trimmed]);
666
+ return emitHint(request, 'X', [href, trimmed]);
709
667
  } else {
710
- return emitHint(request, 'X', src);
668
+ return emitHint(request, 'X', href);
711
669
  }
712
- } else {
713
- previousDispatcher.preinitScript(src, options);
714
670
  }
715
671
  }
716
672
  }
717
673
  }
718
674
 
719
- function preinitModuleScript(src, options) {
675
+ function preinitModuleScript(href, options) {
720
676
  {
721
- if (typeof src === 'string') {
677
+ if (typeof href === 'string') {
722
678
  var request = resolveRequest();
723
679
 
724
680
  if (request) {
725
681
  var hints = getHints(request);
726
- var key = 'M|' + src;
682
+ var key = 'M|' + href;
727
683
 
728
684
  if (hints.has(key)) {
729
685
  // duplicate hint
@@ -734,12 +690,10 @@ function preinitModuleScript(src, options) {
734
690
  var trimmed = trimOptions(options);
735
691
 
736
692
  if (trimmed) {
737
- return emitHint(request, 'M', [src, trimmed]);
693
+ return emitHint(request, 'M', [href, trimmed]);
738
694
  } else {
739
- return emitHint(request, 'M', src);
695
+ return emitHint(request, 'M', href);
740
696
  }
741
- } else {
742
- previousDispatcher.preinitModuleScript(src, options);
743
697
  }
744
698
  }
745
699
  }
@@ -781,7 +735,10 @@ function getImagePreloadKey(href, imageSrcSet, imageSizes) {
781
735
  return "[image]" + uniquePart;
782
736
  }
783
737
 
784
- // This module registers the host dispatcher so it needs to be imported
738
+ var ReactDOMCurrentDispatcher = ReactDOMSharedInternals.Dispatcher;
739
+ function prepareHostDispatcher() {
740
+ ReactDOMCurrentDispatcher.current = ReactDOMFlightServerDispatcher;
741
+ } // Used to distinguish these contexts from ones used in other renderers.
785
742
  // small, smaller than how we encode undefined, and is unambiguous. We could use
786
743
  // a different tuple structure to encode this instead but this makes the runtime
787
744
  // cost cheaper by eliminating a type checks in more positions.
@@ -791,7 +748,6 @@ function createHints() {
791
748
  return new Set();
792
749
  }
793
750
 
794
- var supportsRequestStorage = true;
795
751
  var requestStorage = new async_hooks.AsyncLocalStorage();
796
752
 
797
753
  // ATTENTION
@@ -800,7 +756,7 @@ var requestStorage = new async_hooks.AsyncLocalStorage();
800
756
  // The Symbol used to tag the ReactElement-like types.
801
757
  var REACT_ELEMENT_TYPE = Symbol.for('react.element');
802
758
  var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
803
- var REACT_CONTEXT_TYPE = Symbol.for('react.context');
759
+ var REACT_SERVER_CONTEXT_TYPE = Symbol.for('react.server_context');
804
760
  var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');
805
761
  var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');
806
762
  var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');
@@ -824,6 +780,146 @@ function getIteratorFn(maybeIterable) {
824
780
  return null;
825
781
  }
826
782
 
783
+ // Forming a reverse tree.
784
+ // The structure of a context snapshot is an implementation of this file.
785
+ // Currently, it's implemented as tracking the current active node.
786
+
787
+
788
+ var rootContextSnapshot = null; // We assume that this runtime owns the "current" field on all ReactContext instances.
789
+ // This global (actually thread local) state represents what state all those "current",
790
+ // fields are currently in.
791
+
792
+ var currentActiveSnapshot = null;
793
+
794
+ function popNode(prev) {
795
+ {
796
+ prev.context._currentValue = prev.parentValue;
797
+ }
798
+ }
799
+
800
+ function pushNode(next) {
801
+ {
802
+ next.context._currentValue = next.value;
803
+ }
804
+ }
805
+
806
+ function popToNearestCommonAncestor(prev, next) {
807
+ if (prev === next) ; else {
808
+ popNode(prev);
809
+ var parentPrev = prev.parent;
810
+ var parentNext = next.parent;
811
+
812
+ if (parentPrev === null) {
813
+ if (parentNext !== null) {
814
+ throw new Error('The stacks must reach the root at the same time. This is a bug in React.');
815
+ }
816
+ } else {
817
+ if (parentNext === null) {
818
+ throw new Error('The stacks must reach the root at the same time. This is a bug in React.');
819
+ }
820
+
821
+ popToNearestCommonAncestor(parentPrev, parentNext); // On the way back, we push the new ones that weren't common.
822
+
823
+ pushNode(next);
824
+ }
825
+ }
826
+ }
827
+
828
+ function popAllPrevious(prev) {
829
+ popNode(prev);
830
+ var parentPrev = prev.parent;
831
+
832
+ if (parentPrev !== null) {
833
+ popAllPrevious(parentPrev);
834
+ }
835
+ }
836
+
837
+ function pushAllNext(next) {
838
+ var parentNext = next.parent;
839
+
840
+ if (parentNext !== null) {
841
+ pushAllNext(parentNext);
842
+ }
843
+
844
+ pushNode(next);
845
+ }
846
+
847
+ function popPreviousToCommonLevel(prev, next) {
848
+ popNode(prev);
849
+ var parentPrev = prev.parent;
850
+
851
+ if (parentPrev === null) {
852
+ throw new Error('The depth must equal at least at zero before reaching the root. This is a bug in React.');
853
+ }
854
+
855
+ if (parentPrev.depth === next.depth) {
856
+ // We found the same level. Now we just need to find a shared ancestor.
857
+ popToNearestCommonAncestor(parentPrev, next);
858
+ } else {
859
+ // We must still be deeper.
860
+ popPreviousToCommonLevel(parentPrev, next);
861
+ }
862
+ }
863
+
864
+ function popNextToCommonLevel(prev, next) {
865
+ var parentNext = next.parent;
866
+
867
+ if (parentNext === null) {
868
+ throw new Error('The depth must equal at least at zero before reaching the root. This is a bug in React.');
869
+ }
870
+
871
+ if (prev.depth === parentNext.depth) {
872
+ // We found the same level. Now we just need to find a shared ancestor.
873
+ popToNearestCommonAncestor(prev, parentNext);
874
+ } else {
875
+ // We must still be deeper.
876
+ popNextToCommonLevel(prev, parentNext);
877
+ }
878
+
879
+ pushNode(next);
880
+ } // Perform context switching to the new snapshot.
881
+ // To make it cheap to read many contexts, while not suspending, we make the switch eagerly by
882
+ // updating all the context's current values. That way reads, always just read the current value.
883
+ // At the cost of updating contexts even if they're never read by this subtree.
884
+
885
+
886
+ function switchContext(newSnapshot) {
887
+ // The basic algorithm we need to do is to pop back any contexts that are no longer on the stack.
888
+ // We also need to update any new contexts that are now on the stack with the deepest value.
889
+ // The easiest way to update new contexts is to just reapply them in reverse order from the
890
+ // perspective of the backpointers. To avoid allocating a lot when switching, we use the stack
891
+ // for that. Therefore this algorithm is recursive.
892
+ // 1) First we pop which ever snapshot tree was deepest. Popping old contexts as we go.
893
+ // 2) Then we find the nearest common ancestor from there. Popping old contexts as we go.
894
+ // 3) Then we reapply new contexts on the way back up the stack.
895
+ var prev = currentActiveSnapshot;
896
+ var next = newSnapshot;
897
+
898
+ if (prev !== next) {
899
+ if (prev === null) {
900
+ // $FlowFixMe[incompatible-call]: This has to be non-null since it's not equal to prev.
901
+ pushAllNext(next);
902
+ } else if (next === null) {
903
+ popAllPrevious(prev);
904
+ } else if (prev.depth === next.depth) {
905
+ popToNearestCommonAncestor(prev, next);
906
+ } else if (prev.depth > next.depth) {
907
+ popPreviousToCommonLevel(prev, next);
908
+ } else {
909
+ popNextToCommonLevel(prev, next);
910
+ }
911
+
912
+ currentActiveSnapshot = next;
913
+ }
914
+ }
915
+ function getActiveContext() {
916
+ return currentActiveSnapshot;
917
+ }
918
+ function readContext$1(context) {
919
+ var value = context._currentValue ;
920
+ return value;
921
+ }
922
+
827
923
  // Corresponds to ReactFiberWakeable and ReactFizzWakeable modules. Generally,
828
924
  // changes to one module should be reflected in the others.
829
925
  // TODO: Rename this module and the corresponding Fiber one to "Thenable"
@@ -952,13 +1048,29 @@ function prepareToUseHooksForComponent(prevThenableState) {
952
1048
  thenableState = prevThenableState;
953
1049
  }
954
1050
  function getThenableStateAfterSuspending() {
955
- // If you use() to Suspend this should always exist but if you throw a Promise instead,
956
- // which is not really supported anymore, it will be empty. We use the empty set as a
957
- // marker to know if this was a replay of the same component or first attempt.
958
- var state = thenableState || createThenableState();
1051
+ var state = thenableState;
959
1052
  thenableState = null;
960
1053
  return state;
961
1054
  }
1055
+
1056
+ function readContext(context) {
1057
+ {
1058
+ if (context.$$typeof !== REACT_SERVER_CONTEXT_TYPE) {
1059
+ if (isClientReference(context)) {
1060
+ error('Cannot read a Client Context from a Server Component.');
1061
+ } else {
1062
+ error('Only createServerContext is supported in Server Components.');
1063
+ }
1064
+ }
1065
+
1066
+ if (currentRequest$1 === null) {
1067
+ 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().');
1068
+ }
1069
+ }
1070
+
1071
+ return readContext$1(context);
1072
+ }
1073
+
962
1074
  var HooksDispatcher = {
963
1075
  useMemo: function (nextCreate) {
964
1076
  return nextCreate();
@@ -969,8 +1081,8 @@ var HooksDispatcher = {
969
1081
  useDebugValue: function () {},
970
1082
  useDeferredValue: unsupportedHook,
971
1083
  useTransition: unsupportedHook,
972
- readContext: unsupportedContext,
973
- useContext: unsupportedContext,
1084
+ readContext: readContext,
1085
+ useContext: readContext,
974
1086
  useReducer: unsupportedHook,
975
1087
  useRef: unsupportedHook,
976
1088
  useState: unsupportedHook,
@@ -1003,10 +1115,6 @@ function unsupportedRefresh() {
1003
1115
  throw new Error('Refreshing the cache is not supported in Server Components.');
1004
1116
  }
1005
1117
 
1006
- function unsupportedContext() {
1007
- throw new Error('Cannot read a Client Context from a Server Component.');
1008
- }
1009
-
1010
1118
  function useId() {
1011
1119
  if (currentRequest$1 === null) {
1012
1120
  throw new Error('useId can only be used while React is rendering');
@@ -1032,22 +1140,20 @@ function use(usable) {
1032
1140
  }
1033
1141
 
1034
1142
  return trackUsedThenable(thenableState, thenable, index);
1035
- } else if (usable.$$typeof === REACT_CONTEXT_TYPE) {
1036
- unsupportedContext();
1143
+ } else if (usable.$$typeof === REACT_SERVER_CONTEXT_TYPE) {
1144
+ var context = usable;
1145
+ return readContext(context);
1037
1146
  }
1038
1147
  }
1039
1148
 
1040
- if (isClientReference(usable)) {
1041
- if (usable.value != null && usable.value.$$typeof === REACT_CONTEXT_TYPE) {
1042
- // Show a more specific message since it's a common mistake.
1043
- throw new Error('Cannot read a Client Context from a Server Component.');
1044
- } else {
1045
- throw new Error('Cannot use() an already resolved Client Reference.');
1149
+ {
1150
+ if (isClientReference(usable)) {
1151
+ error('Cannot use() an already resolved Client Reference.');
1046
1152
  }
1047
- } else {
1048
- throw new Error( // eslint-disable-next-line react-internal/safe-string-coercion
1049
- 'An unsupported type was passed to use(): ' + String(usable));
1050
- }
1153
+ } // eslint-disable-next-line react-internal/safe-string-coercion
1154
+
1155
+
1156
+ throw new Error('An unsupported type was passed to use(): ' + String(usable));
1051
1157
  }
1052
1158
 
1053
1159
  function createSignal() {
@@ -1185,10 +1291,6 @@ function describeValueForErrorMessage(value) {
1185
1291
  return '[...]';
1186
1292
  }
1187
1293
 
1188
- if (value !== null && value.$$typeof === CLIENT_REFERENCE_TAG) {
1189
- return describeClientReference();
1190
- }
1191
-
1192
1294
  var name = objectName(value);
1193
1295
 
1194
1296
  if (name === 'Object') {
@@ -1199,15 +1301,7 @@ function describeValueForErrorMessage(value) {
1199
1301
  }
1200
1302
 
1201
1303
  case 'function':
1202
- {
1203
- if (value.$$typeof === CLIENT_REFERENCE_TAG) {
1204
- return describeClientReference();
1205
- }
1206
-
1207
- var _name = value.displayName || value.name;
1208
-
1209
- return _name ? 'function ' + _name : 'function';
1210
- }
1304
+ return 'function';
1211
1305
 
1212
1306
  default:
1213
1307
  // eslint-disable-next-line react-internal/safe-string-coercion
@@ -1253,12 +1347,6 @@ function describeElementType(type) {
1253
1347
  return '';
1254
1348
  }
1255
1349
 
1256
- var CLIENT_REFERENCE_TAG = Symbol.for('react.client.reference');
1257
-
1258
- function describeClientReference(ref) {
1259
- return 'client';
1260
- }
1261
-
1262
1350
  function describeObjectForErrorMessage(objectOrArray, expandedName) {
1263
1351
  var objKind = objectName(objectOrArray);
1264
1352
 
@@ -1337,8 +1425,6 @@ function describeObjectForErrorMessage(objectOrArray, expandedName) {
1337
1425
  } else {
1338
1426
  if (objectOrArray.$$typeof === REACT_ELEMENT_TYPE) {
1339
1427
  str = '<' + describeElementType(objectOrArray.type) + '/>';
1340
- } else if (objectOrArray.$$typeof === CLIENT_REFERENCE_TAG) {
1341
- return describeClientReference();
1342
1428
  } else if (jsxPropsParents.has(objectOrArray)) {
1343
1429
  // Print JSX
1344
1430
  var _type = jsxPropsParents.get(objectOrArray);
@@ -1389,9 +1475,9 @@ function describeObjectForErrorMessage(objectOrArray, expandedName) {
1389
1475
  str += ', ';
1390
1476
  }
1391
1477
 
1392
- var _name2 = _names[_i3];
1393
- str += describeKeyForErrorMessage(_name2) + ': ';
1394
- var _value3 = _object[_name2];
1478
+ var _name = _names[_i3];
1479
+ str += describeKeyForErrorMessage(_name) + ': ';
1480
+ var _value3 = _object[_name];
1395
1481
 
1396
1482
  var _substr3 = void 0;
1397
1483
 
@@ -1401,7 +1487,7 @@ function describeObjectForErrorMessage(objectOrArray, expandedName) {
1401
1487
  _substr3 = describeValueForErrorMessage(_value3);
1402
1488
  }
1403
1489
 
1404
- if (_name2 === expandedName) {
1490
+ if (_name === expandedName) {
1405
1491
  start = str.length;
1406
1492
  length = _substr3.length;
1407
1493
  str += _substr3;
@@ -1456,11 +1542,12 @@ function defaultPostponeHandler(reason) {// Noop
1456
1542
  var OPEN = 0;
1457
1543
  var CLOSING = 1;
1458
1544
  var CLOSED = 2;
1459
- function createRequest(model, bundlerConfig, onError, identifierPrefix, onPostpone, environmentName) {
1545
+ function createRequest(model, bundlerConfig, onError, context, identifierPrefix, onPostpone) {
1460
1546
  if (ReactCurrentCache.current !== null && ReactCurrentCache.current !== DefaultCacheDispatcher) {
1461
1547
  throw new Error('Currently React only supports one RSC renderer at a time.');
1462
1548
  }
1463
1549
 
1550
+ prepareHostDispatcher();
1464
1551
  ReactCurrentCache.current = DefaultCacheDispatcher;
1465
1552
  var abortSet = new Set();
1466
1553
  var pingedTasks = [];
@@ -1486,19 +1573,21 @@ function createRequest(model, bundlerConfig, onError, identifierPrefix, onPostpo
1486
1573
  writtenSymbols: new Map(),
1487
1574
  writtenClientReferences: new Map(),
1488
1575
  writtenServerReferences: new Map(),
1576
+ writtenProviders: new Map(),
1489
1577
  writtenObjects: new WeakMap(),
1490
1578
  identifierPrefix: identifierPrefix || '',
1491
1579
  identifierCount: 1,
1492
1580
  taintCleanupQueue: cleanupQueue,
1493
1581
  onError: onError === undefined ? defaultErrorHandler : onError,
1494
- onPostpone: onPostpone === undefined ? defaultPostponeHandler : onPostpone
1582
+ onPostpone: onPostpone === undefined ? defaultPostponeHandler : onPostpone,
1583
+ // $FlowFixMe[missing-this-annot]
1584
+ toJSON: function (key, value) {
1585
+ return resolveModelToJSON(request, this, key, value);
1586
+ }
1495
1587
  };
1496
-
1497
- {
1498
- request.environmentName = environmentName === undefined ? 'Server' : environmentName;
1499
- }
1500
-
1501
- var rootTask = createTask(request, model, null, false, abortSet);
1588
+ request.pendingChunks++;
1589
+ var rootContext = createRootContext();
1590
+ var rootTask = createTask(request, model, rootContext, abortSet);
1502
1591
  pingedTasks.push(rootTask);
1503
1592
  return request;
1504
1593
  }
@@ -1514,18 +1603,13 @@ function resolveRequest() {
1514
1603
  return null;
1515
1604
  }
1516
1605
 
1517
- function serializeThenable(request, task, thenable) {
1518
- var newTask = createTask(request, null, task.keyPath, // the server component sequence continues through Promise-as-a-child.
1519
- task.implicitSlot, request.abortableTasks);
1520
-
1521
- {
1522
- // If this came from Flight, forward any debug info into this new row.
1523
- var debugInfo = thenable._debugInfo;
1606
+ function createRootContext(reqContext) {
1607
+ return importServerContexts();
1608
+ }
1524
1609
 
1525
- if (debugInfo) {
1526
- forwardDebugInfo(request, newTask.id, debugInfo);
1527
- }
1528
- }
1610
+ function serializeThenable(request, thenable) {
1611
+ request.pendingChunks++;
1612
+ var newTask = createTask(request, null, getActiveContext(), request.abortableTasks);
1529
1613
 
1530
1614
  switch (thenable.status) {
1531
1615
  case 'fulfilled':
@@ -1661,136 +1745,14 @@ function createLazyWrapperAroundWakeable(wakeable) {
1661
1745
  _payload: thenable,
1662
1746
  _init: readThenable
1663
1747
  };
1664
-
1665
- {
1666
- // If this came from React, transfer the debug info.
1667
- lazyType._debugInfo = thenable._debugInfo || [];
1668
- }
1669
-
1670
1748
  return lazyType;
1671
1749
  }
1672
1750
 
1673
- function renderFunctionComponent(request, task, key, Component, props) {
1674
- // Reset the task's thenable state before continuing, so that if a later
1675
- // component suspends we can reuse the same task object. If the same
1676
- // component suspends again, the thenable state will be restored.
1677
- var prevThenableState = task.thenableState;
1678
- task.thenableState = null;
1679
-
1680
- {
1681
- if (debugID === null) {
1682
- // We don't have a chunk to assign debug info. We need to outline this
1683
- // component to assign it an ID.
1684
- return outlineTask(request, task);
1685
- } else if (prevThenableState !== null) ; else {
1686
- // This is a new component in the same task so we can emit more debug info.
1687
- var componentName = Component.displayName || Component.name || '';
1688
- request.pendingChunks++;
1689
- emitDebugChunk(request, debugID, {
1690
- name: componentName,
1691
- env: request.environmentName
1692
- });
1693
- }
1694
- }
1695
-
1696
- prepareToUseHooksForComponent(prevThenableState); // The secondArg is always undefined in Server Components since refs error early.
1697
-
1698
- var secondArg = undefined;
1699
- var result = Component(props, secondArg);
1700
-
1701
- if (typeof result === 'object' && result !== null && typeof result.then === 'function') {
1702
- // When the return value is in children position we can resolve it immediately,
1703
- // to its value without a wrapper if it's synchronously available.
1704
- var thenable = result;
1705
-
1706
- if (thenable.status === 'fulfilled') {
1707
- return thenable.value;
1708
- } // TODO: Once we accept Promises as children on the client, we can just return
1709
- // the thenable here.
1710
-
1711
-
1712
- result = createLazyWrapperAroundWakeable(result);
1713
- } // Track this element's key on the Server Component on the keyPath context..
1714
-
1715
-
1716
- var prevKeyPath = task.keyPath;
1717
- var prevImplicitSlot = task.implicitSlot;
1718
-
1719
- if (key !== null) {
1720
- // Append the key to the path. Technically a null key should really add the child
1721
- // index. We don't do that to hold the payload small and implementation simple.
1722
- task.keyPath = prevKeyPath === null ? key : prevKeyPath + ',' + key;
1723
- } else if (prevKeyPath === null) {
1724
- // This sequence of Server Components has no keys. This means that it was rendered
1725
- // in a slot that needs to assign an implicit key. Even if children below have
1726
- // explicit keys, they should not be used for the outer most key since it might
1727
- // collide with other slots in that set.
1728
- task.implicitSlot = true;
1729
- }
1730
-
1731
- var json = renderModelDestructive(request, task, emptyRoot, '', result);
1732
- task.keyPath = prevKeyPath;
1733
- task.implicitSlot = prevImplicitSlot;
1734
- return json;
1735
- }
1736
-
1737
- function renderFragment(request, task, children) {
1738
- {
1739
- var debugInfo = children._debugInfo;
1740
-
1741
- if (debugInfo) {
1742
- // If this came from Flight, forward any debug info into this new row.
1743
- if (debugID === null) {
1744
- // We don't have a chunk to assign debug info. We need to outline this
1745
- // component to assign it an ID.
1746
- return outlineTask(request, task);
1747
- } else {
1748
- // Forward any debug info we have the first time we see it.
1749
- // We do this after init so that we have received all the debug info
1750
- // from the server by the time we emit it.
1751
- forwardDebugInfo(request, debugID, debugInfo);
1752
- }
1753
- }
1754
- }
1755
-
1756
- {
1757
- return children;
1758
- }
1759
- }
1760
-
1761
- function renderClientElement(task, type, key, props) {
1762
- {
1763
- return [REACT_ELEMENT_TYPE, type, key, props];
1764
- } // We prepend the terminal client element that actually gets serialized with
1765
- } // The chunk ID we're currently rendering that we can assign debug data to.
1766
-
1767
-
1768
- var debugID = null;
1769
-
1770
- function outlineTask(request, task) {
1771
- var newTask = createTask(request, task.model, // the currently rendering element
1772
- task.keyPath, // unlike outlineModel this one carries along context
1773
- task.implicitSlot, request.abortableTasks);
1774
- retryTask(request, newTask);
1775
-
1776
- if (newTask.status === COMPLETED) {
1777
- // We completed synchronously so we can refer to this by reference. This
1778
- // makes it behaves the same as prod during deserialization.
1779
- return serializeByValueID(newTask.id);
1780
- } // This didn't complete synchronously so it wouldn't have even if we didn't
1781
- // outline it, so this would reduce to a lazy reference even in prod.
1782
-
1783
-
1784
- return serializeLazyID(newTask.id);
1785
- }
1786
-
1787
- function renderElement(request, task, type, key, ref, props) {
1751
+ function attemptResolveElement(request, type, key, ref, props, prevThenableState) {
1788
1752
  if (ref !== null && ref !== undefined) {
1789
1753
  // When the ref moves to the regular props object this will implicitly
1790
1754
  // throw for functions. We could probably relax it to a DEV warning for other
1791
1755
  // cases.
1792
- // TODO: `ref` is now just a prop when `enableRefAsProp` is on. Should we
1793
- // do what the above comment says?
1794
1756
  throw new Error('Refs cannot be used in Server Components, nor passed to Client Components.');
1795
1757
  }
1796
1758
 
@@ -1805,36 +1767,47 @@ function renderElement(request, task, type, key, ref, props) {
1805
1767
  if (typeof type === 'function') {
1806
1768
  if (isClientReference(type)) {
1807
1769
  // This is a reference to a Client Component.
1808
- return renderClientElement(task, type, key, props);
1809
- } // This is a Server Component.
1770
+ return [REACT_ELEMENT_TYPE, type, key, props];
1771
+ } // This is a server-side component.
1772
+
1810
1773
 
1774
+ prepareToUseHooksForComponent(prevThenableState);
1775
+ var result = type(props);
1776
+
1777
+ if (typeof result === 'object' && result !== null && typeof result.then === 'function') {
1778
+ // When the return value is in children position we can resolve it immediately,
1779
+ // to its value without a wrapper if it's synchronously available.
1780
+ var thenable = result;
1781
+
1782
+ if (thenable.status === 'fulfilled') {
1783
+ return thenable.value;
1784
+ } // TODO: Once we accept Promises as children on the client, we can just return
1785
+ // the thenable here.
1786
+
1787
+
1788
+ return createLazyWrapperAroundWakeable(result);
1789
+ }
1811
1790
 
1812
- return renderFunctionComponent(request, task, key, type, props);
1791
+ return result;
1813
1792
  } else if (typeof type === 'string') {
1814
1793
  // This is a host element. E.g. HTML.
1815
- return renderClientElement(task, type, key, props);
1794
+ return [REACT_ELEMENT_TYPE, type, key, props];
1816
1795
  } else if (typeof type === 'symbol') {
1817
- if (type === REACT_FRAGMENT_TYPE && key === null) {
1796
+ if (type === REACT_FRAGMENT_TYPE) {
1818
1797
  // For key-less fragments, we add a small optimization to avoid serializing
1819
1798
  // it as a wrapper.
1820
- var prevImplicitSlot = task.implicitSlot;
1821
-
1822
- if (task.keyPath === null) {
1823
- task.implicitSlot = true;
1824
- }
1825
-
1826
- var json = renderModelDestructive(request, task, emptyRoot, '', props.children);
1827
- task.implicitSlot = prevImplicitSlot;
1828
- return json;
1799
+ // TODO: If a key is specified, we should propagate its key to any children.
1800
+ // Same as if a Server Component has a key.
1801
+ return props.children;
1829
1802
  } // This might be a built-in React component. We'll let the client decide.
1830
1803
  // Any built-in works as long as its props are serializable.
1831
1804
 
1832
1805
 
1833
- return renderClientElement(task, type, key, props);
1806
+ return [REACT_ELEMENT_TYPE, type, key, props];
1834
1807
  } else if (type != null && typeof type === 'object') {
1835
1808
  if (isClientReference(type)) {
1836
1809
  // This is a reference to a Client Component.
1837
- return renderClientElement(task, type, key, props);
1810
+ return [REACT_ELEMENT_TYPE, type, key, props];
1838
1811
  }
1839
1812
 
1840
1813
  switch (type.$$typeof) {
@@ -1843,17 +1816,19 @@ function renderElement(request, task, type, key, ref, props) {
1843
1816
  var payload = type._payload;
1844
1817
  var init = type._init;
1845
1818
  var wrappedType = init(payload);
1846
- return renderElement(request, task, wrappedType, key, ref, props);
1819
+ return attemptResolveElement(request, wrappedType, key, ref, props, prevThenableState);
1847
1820
  }
1848
1821
 
1849
1822
  case REACT_FORWARD_REF_TYPE:
1850
1823
  {
1851
- return renderFunctionComponent(request, task, key, type.render, props);
1824
+ var render = type.render;
1825
+ prepareToUseHooksForComponent(prevThenableState);
1826
+ return render(props, undefined);
1852
1827
  }
1853
1828
 
1854
1829
  case REACT_MEMO_TYPE:
1855
1830
  {
1856
- return renderElement(request, task, type.type, key, ref, props);
1831
+ return attemptResolveElement(request, type.type, key, ref, props, prevThenableState);
1857
1832
  }
1858
1833
  }
1859
1834
  }
@@ -1873,51 +1848,16 @@ function pingTask(request, task) {
1873
1848
  }
1874
1849
  }
1875
1850
 
1876
- function createTask(request, model, keyPath, implicitSlot, abortSet) {
1877
- request.pendingChunks++;
1851
+ function createTask(request, model, context, abortSet) {
1878
1852
  var id = request.nextChunkId++;
1879
-
1880
- if (typeof model === 'object' && model !== null) {
1881
- // If we're about to write this into a new task we can assign it an ID early so that
1882
- // any other references can refer to the value we're about to write.
1883
- {
1884
- request.writtenObjects.set(model, id);
1885
- }
1886
- }
1887
-
1888
1853
  var task = {
1889
1854
  id: id,
1890
1855
  status: PENDING$1,
1891
1856
  model: model,
1892
- keyPath: keyPath,
1893
- implicitSlot: implicitSlot,
1857
+ context: context,
1894
1858
  ping: function () {
1895
1859
  return pingTask(request, task);
1896
1860
  },
1897
- toJSON: function (parentPropertyName, value) {
1898
- var parent = this; // Make sure that `parent[parentPropertyName]` wasn't JSONified before `value` was passed to us
1899
-
1900
- {
1901
- // $FlowFixMe[incompatible-use]
1902
- var originalValue = parent[parentPropertyName];
1903
-
1904
- if (typeof originalValue === 'object' && originalValue !== value && !(originalValue instanceof Date)) {
1905
- if (objectName(originalValue) !== 'Object') {
1906
- var jsxParentType = jsxChildrenParents.get(parent);
1907
-
1908
- if (typeof jsxParentType === 'string') {
1909
- error('%s objects cannot be rendered as text children. Try formatting it using toString().%s', objectName(originalValue), describeObjectForErrorMessage(parent, parentPropertyName));
1910
- } else {
1911
- error('Only plain objects can be passed to Client Components from Server Components. ' + '%s objects are not supported.%s', objectName(originalValue), describeObjectForErrorMessage(parent, parentPropertyName));
1912
- }
1913
- } else {
1914
- 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));
1915
- }
1916
- }
1917
- }
1918
-
1919
- return renderModel(request, task, parent, parentPropertyName, value);
1920
- },
1921
1861
  thenableState: null
1922
1862
  };
1923
1863
  abortSet.add(task);
@@ -1986,13 +1926,13 @@ function encodeReferenceChunk(request, id, reference) {
1986
1926
  return stringToChunk(row);
1987
1927
  }
1988
1928
 
1989
- function serializeClientReference(request, parent, parentPropertyName, clientReference) {
1929
+ function serializeClientReference(request, parent, key, clientReference) {
1990
1930
  var clientReferenceKey = getClientReferenceKey(clientReference);
1991
1931
  var writtenClientReferences = request.writtenClientReferences;
1992
1932
  var existingId = writtenClientReferences.get(clientReferenceKey);
1993
1933
 
1994
1934
  if (existingId !== undefined) {
1995
- if (parent[0] === REACT_ELEMENT_TYPE && parentPropertyName === '1') {
1935
+ if (parent[0] === REACT_ELEMENT_TYPE && key === '1') {
1996
1936
  // If we're encoding the "type" of an element, we can refer
1997
1937
  // to that by a lazy reference instead of directly since React
1998
1938
  // knows how to deal with lazy values. This lets us suspend
@@ -2011,7 +1951,7 @@ function serializeClientReference(request, parent, parentPropertyName, clientRef
2011
1951
  emitImportChunk(request, importId, clientReferenceMetadata);
2012
1952
  writtenClientReferences.set(clientReferenceKey, importId);
2013
1953
 
2014
- if (parent[0] === REACT_ELEMENT_TYPE && parentPropertyName === '1') {
1954
+ if (parent[0] === REACT_ELEMENT_TYPE && key === '1') {
2015
1955
  // If we're encoding the "type" of an element, we can refer
2016
1956
  // to that by a lazy reference instead of directly since React
2017
1957
  // knows how to deal with lazy values. This lets us suspend
@@ -2031,14 +1971,13 @@ function serializeClientReference(request, parent, parentPropertyName, clientRef
2031
1971
  }
2032
1972
 
2033
1973
  function outlineModel(request, value) {
2034
- var newTask = createTask(request, value, null, // The way we use outlining is for reusing an object.
2035
- false, // It makes no sense for that use case to be contextual.
2036
- request.abortableTasks);
1974
+ request.pendingChunks++;
1975
+ var newTask = createTask(request, value, getActiveContext(), request.abortableTasks);
2037
1976
  retryTask(request, newTask);
2038
1977
  return newTask.id;
2039
1978
  }
2040
1979
 
2041
- function serializeServerReference(request, serverReference) {
1980
+ function serializeServerReference(request, parent, key, serverReference) {
2042
1981
  var writtenServerReferences = request.writtenServerReferences;
2043
1982
  var existingId = writtenServerReferences.get(serverReference);
2044
1983
 
@@ -2118,77 +2057,110 @@ function escapeStringValue(value) {
2118
2057
  return value;
2119
2058
  }
2120
2059
  }
2121
-
2122
2060
  var modelRoot = false;
2123
2061
 
2124
- function renderModel(request, task, parent, key, value) {
2125
- var prevKeyPath = task.keyPath;
2126
- var prevImplicitSlot = task.implicitSlot;
2062
+ function resolveModelToJSON(request, parent, key, value) {
2063
+ // Make sure that `parent[key]` wasn't JSONified before `value` was passed to us
2064
+ {
2065
+ // $FlowFixMe[incompatible-use]
2066
+ var originalValue = parent[key];
2127
2067
 
2128
- try {
2129
- return renderModelDestructive(request, task, parent, key, value);
2130
- } catch (thrownValue) {
2131
- var x = thrownValue === SuspenseException ? // This is a special type of exception used for Suspense. For historical
2132
- // reasons, the rest of the Suspense implementation expects the thrown
2133
- // value to be a thenable, because before `use` existed that was the
2134
- // (unstable) API for suspending. This implementation detail can change
2135
- // later, once we deprecate the old API in favor of `use`.
2136
- getSuspendedThenable() : thrownValue; // If the suspended/errored value was an element or lazy it can be reduced
2137
- // to a lazy reference, so that it doesn't error the parent.
2068
+ if (typeof originalValue === 'object' && originalValue !== value && !(originalValue instanceof Date)) {
2069
+ if (objectName(originalValue) !== 'Object') {
2070
+ var jsxParentType = jsxChildrenParents.get(parent);
2138
2071
 
2139
- var model = task.model;
2140
- var wasReactNode = typeof model === 'object' && model !== null && (model.$$typeof === REACT_ELEMENT_TYPE || model.$$typeof === REACT_LAZY_TYPE);
2072
+ if (typeof jsxParentType === 'string') {
2073
+ error('%s objects cannot be rendered as text children. Try formatting it using toString().%s', objectName(originalValue), describeObjectForErrorMessage(parent, key));
2074
+ } else {
2075
+ error('Only plain objects can be passed to Client Components from Server Components. ' + '%s objects are not supported.%s', objectName(originalValue), describeObjectForErrorMessage(parent, key));
2076
+ }
2077
+ } else {
2078
+ 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));
2079
+ }
2080
+ }
2081
+ } // Special Symbols
2141
2082
 
2142
- if (typeof x === 'object' && x !== null) {
2143
- // $FlowFixMe[method-unbinding]
2144
- if (typeof x.then === 'function') {
2145
- // Something suspended, we'll need to create a new task and resolve it later.
2146
- var newTask = createTask(request, task.model, task.keyPath, task.implicitSlot, request.abortableTasks);
2147
- var ping = newTask.ping;
2148
- x.then(ping, ping);
2149
- newTask.thenableState = getThenableStateAfterSuspending(); // Restore the context. We assume that this will be restored by the inner
2150
- // functions in case nothing throws so we don't use "finally" here.
2151
2083
 
2152
- task.keyPath = prevKeyPath;
2153
- task.implicitSlot = prevImplicitSlot;
2084
+ switch (value) {
2085
+ case REACT_ELEMENT_TYPE:
2086
+ return '$';
2087
+ }
2154
2088
 
2155
- if (wasReactNode) {
2156
- return serializeLazyID(newTask.id);
2157
- }
2158
2089
 
2159
- return serializeByValueID(newTask.id);
2160
- }
2161
- } // Restore the context. We assume that this will be restored by the inner
2162
- // functions in case nothing throws so we don't use "finally" here.
2090
+ while (typeof value === 'object' && value !== null && (value.$$typeof === REACT_ELEMENT_TYPE || value.$$typeof === REACT_LAZY_TYPE)) {
2091
+
2092
+ try {
2093
+ switch (value.$$typeof) {
2094
+ case REACT_ELEMENT_TYPE:
2095
+ {
2096
+ var writtenObjects = request.writtenObjects;
2097
+ var existingId = writtenObjects.get(value);
2098
+
2099
+ if (existingId !== undefined) {
2100
+ if (existingId === -1) {
2101
+ // Seen but not yet outlined.
2102
+ var newId = outlineModel(request, value);
2103
+ return serializeByValueID(newId);
2104
+ } else if (modelRoot === value) {
2105
+ // This is the ID we're currently emitting so we need to write it
2106
+ // once but if we discover it again, we refer to it by id.
2107
+ modelRoot = null;
2108
+ } else {
2109
+ // We've already emitted this as an outlined object, so we can
2110
+ // just refer to that by its existing ID.
2111
+ return serializeByValueID(existingId);
2112
+ }
2113
+ } else {
2114
+ // This is the first time we've seen this object. We may never see it again
2115
+ // so we'll inline it. Mark it as seen. If we see it again, we'll outline.
2116
+ writtenObjects.set(value, -1);
2117
+ } // TODO: Concatenate keys of parents onto children.
2163
2118
 
2164
2119
 
2165
- task.keyPath = prevKeyPath;
2166
- task.implicitSlot = prevImplicitSlot;
2120
+ var element = value; // Attempt to render the Server Component.
2167
2121
 
2168
- if (wasReactNode) {
2169
- // Something errored. We'll still send everything we have up until this point.
2122
+ value = attemptResolveElement(request, element.type, element.key, element.ref, element.props, null);
2123
+ break;
2124
+ }
2125
+
2126
+ case REACT_LAZY_TYPE:
2127
+ {
2128
+ var payload = value._payload;
2129
+ var init = value._init;
2130
+ value = init(payload);
2131
+ break;
2132
+ }
2133
+ }
2134
+ } catch (thrownValue) {
2135
+ var x = thrownValue === SuspenseException ? // This is a special type of exception used for Suspense. For historical
2136
+ // reasons, the rest of the Suspense implementation expects the thrown
2137
+ // value to be a thenable, because before `use` existed that was the
2138
+ // (unstable) API for suspending. This implementation detail can change
2139
+ // later, once we deprecate the old API in favor of `use`.
2140
+ getSuspendedThenable() : thrownValue;
2141
+
2142
+ if (typeof x === 'object' && x !== null) {
2143
+ // $FlowFixMe[method-unbinding]
2144
+ if (typeof x.then === 'function') {
2145
+ // Something suspended, we'll need to create a new task and resolve it later.
2146
+ request.pendingChunks++;
2147
+ var newTask = createTask(request, value, getActiveContext(), request.abortableTasks);
2148
+ var ping = newTask.ping;
2149
+ x.then(ping, ping);
2150
+ newTask.thenableState = getThenableStateAfterSuspending();
2151
+ return serializeLazyID(newTask.id);
2152
+ }
2153
+ } // Something errored. We'll still send everything we have up until this point.
2170
2154
  // We'll replace this element with a lazy reference that throws on the client
2171
2155
  // once it gets rendered.
2156
+
2157
+
2172
2158
  request.pendingChunks++;
2173
2159
  var errorId = request.nextChunkId++;
2174
2160
  var digest = logRecoverableError(request, x);
2175
2161
  emitErrorChunk(request, errorId, digest, x);
2176
2162
  return serializeLazyID(errorId);
2177
- } // Something errored but it was not in a React Node. There's no need to serialize
2178
- // it by value because it'll just error the whole parent row anyway so we can
2179
- // just stop any siblings and error the whole parent row.
2180
-
2181
-
2182
- throw x;
2183
- }
2184
- }
2185
-
2186
- function renderModelDestructive(request, task, parent, parentPropertyName, value) {
2187
- // Set the currently rendering model
2188
- task.model = value; // Special Symbol, that's very common.
2189
-
2190
- if (value === REACT_ELEMENT_TYPE) {
2191
- return '$';
2163
+ }
2192
2164
  }
2193
2165
 
2194
2166
  if (value === null) {
@@ -2196,152 +2168,61 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
2196
2168
  }
2197
2169
 
2198
2170
  if (typeof value === 'object') {
2199
- switch (value.$$typeof) {
2200
- case REACT_ELEMENT_TYPE:
2201
- {
2202
- var _writtenObjects = request.writtenObjects;
2203
-
2204
- var _existingId = _writtenObjects.get(value);
2205
-
2206
- if (_existingId !== undefined) {
2207
- if (modelRoot === value) {
2208
- // This is the ID we're currently emitting so we need to write it
2209
- // once but if we discover it again, we refer to it by id.
2210
- modelRoot = null;
2211
- } else if (_existingId === -1) {
2212
- // Seen but not yet outlined.
2213
- // TODO: If we throw here we can treat this as suspending which causes an outline
2214
- // but that is able to reuse the same task if we're already in one but then that
2215
- // will be a lazy future value rather than guaranteed to exist but maybe that's good.
2216
- var newId = outlineModel(request, value);
2217
- return serializeByValueID(newId);
2218
- } else {
2219
- // We've already emitted this as an outlined object, so we can refer to that by its
2220
- // existing ID. TODO: We should use a lazy reference since, unlike plain objects,
2221
- // elements might suspend so it might not have emitted yet even if we have the ID for
2222
- // it. However, this creates an extra wrapper when it's not needed. We should really
2223
- // detect whether this already was emitted and synchronously available. In that
2224
- // case we can refer to it synchronously and only make it lazy otherwise.
2225
- // We currently don't have a data structure that lets us see that though.
2226
- return serializeByValueID(_existingId);
2227
- }
2228
- } else {
2229
- // This is the first time we've seen this object. We may never see it again
2230
- // so we'll inline it. Mark it as seen. If we see it again, we'll outline.
2231
- _writtenObjects.set(value, -1);
2232
- }
2233
-
2234
- var element = value;
2235
-
2236
- {
2237
- var debugInfo = value._debugInfo;
2238
-
2239
- if (debugInfo) {
2240
- // If this came from Flight, forward any debug info into this new row.
2241
- if (debugID === null) {
2242
- // We don't have a chunk to assign debug info. We need to outline this
2243
- // component to assign it an ID.
2244
- return outlineTask(request, task);
2245
- } else {
2246
- // Forward any debug info we have the first time we see it.
2247
- forwardDebugInfo(request, debugID, debugInfo);
2248
- }
2249
- }
2250
- }
2251
-
2252
- var props = element.props;
2253
- var ref;
2254
-
2255
- {
2256
- ref = element.ref;
2257
- } // Attempt to render the Server Component.
2258
-
2259
-
2260
- return renderElement(request, task, element.type, // $FlowFixMe[incompatible-call] the key of an element is null | string
2261
- element.key, ref, props);
2262
- }
2263
-
2264
- case REACT_LAZY_TYPE:
2265
- {
2266
- // Reset the task's thenable state before continuing. If there was one, it was
2267
- // from suspending the lazy before.
2268
- task.thenableState = null;
2269
- var lazy = value;
2270
- var payload = lazy._payload;
2271
- var init = lazy._init;
2272
- var resolvedModel = init(payload);
2273
-
2274
- {
2275
- var _debugInfo = lazy._debugInfo;
2276
-
2277
- if (_debugInfo) {
2278
- // If this came from Flight, forward any debug info into this new row.
2279
- if (debugID === null) {
2280
- // We don't have a chunk to assign debug info. We need to outline this
2281
- // component to assign it an ID.
2282
- return outlineTask(request, task);
2283
- } else {
2284
- // Forward any debug info we have the first time we see it.
2285
- // We do this after init so that we have received all the debug info
2286
- // from the server by the time we emit it.
2287
- forwardDebugInfo(request, debugID, _debugInfo);
2288
- }
2289
- }
2290
- }
2291
-
2292
- return renderModelDestructive(request, task, emptyRoot, '', resolvedModel);
2293
- }
2294
- }
2295
2171
 
2296
2172
  if (isClientReference(value)) {
2297
- return serializeClientReference(request, parent, parentPropertyName, value);
2173
+ return serializeClientReference(request, parent, key, value);
2298
2174
  }
2299
2175
 
2300
- var writtenObjects = request.writtenObjects;
2301
- var existingId = writtenObjects.get(value); // $FlowFixMe[method-unbinding]
2176
+ var _writtenObjects = request.writtenObjects;
2177
+
2178
+ var _existingId = _writtenObjects.get(value); // $FlowFixMe[method-unbinding]
2179
+
2302
2180
 
2303
2181
  if (typeof value.then === 'function') {
2304
- if (existingId !== undefined) {
2182
+ if (_existingId !== undefined) {
2305
2183
  if (modelRoot === value) {
2306
2184
  // This is the ID we're currently emitting so we need to write it
2307
2185
  // once but if we discover it again, we refer to it by id.
2308
2186
  modelRoot = null;
2309
2187
  } else {
2310
2188
  // We've seen this promise before, so we can just refer to the same result.
2311
- return serializePromiseID(existingId);
2189
+ return serializePromiseID(_existingId);
2312
2190
  }
2313
2191
  } // We assume that any object with a .then property is a "Thenable" type,
2314
2192
  // or a Promise type. Either of which can be represented by a Promise.
2315
2193
 
2316
2194
 
2317
- var promiseId = serializeThenable(request, task, value);
2318
- writtenObjects.set(value, promiseId);
2195
+ var promiseId = serializeThenable(request, value);
2196
+
2197
+ _writtenObjects.set(value, promiseId);
2198
+
2319
2199
  return serializePromiseID(promiseId);
2320
2200
  }
2321
2201
 
2322
- if (existingId !== undefined) {
2323
- if (modelRoot === value) {
2324
- // This is the ID we're currently emitting so we need to write it
2325
- // once but if we discover it again, we refer to it by id.
2326
- modelRoot = null;
2327
- } else if (existingId === -1) {
2202
+ if (_existingId !== undefined) {
2203
+ if (_existingId === -1) {
2328
2204
  // Seen but not yet outlined.
2329
2205
  var _newId = outlineModel(request, value);
2330
2206
 
2331
2207
  return serializeByValueID(_newId);
2208
+ } else if (modelRoot === value) {
2209
+ // This is the ID we're currently emitting so we need to write it
2210
+ // once but if we discover it again, we refer to it by id.
2211
+ modelRoot = null;
2332
2212
  } else {
2333
2213
  // We've already emitted this as an outlined object, so we can
2334
2214
  // just refer to that by its existing ID.
2335
- return serializeByValueID(existingId);
2215
+ return serializeByValueID(_existingId);
2336
2216
  }
2337
2217
  } else {
2338
2218
  // This is the first time we've seen this object. We may never see it again
2339
2219
  // so we'll inline it. Mark it as seen. If we see it again, we'll outline.
2340
- writtenObjects.set(value, -1);
2220
+ _writtenObjects.set(value, -1);
2341
2221
  }
2342
2222
 
2343
2223
  if (isArray(value)) {
2344
- return renderFragment(request, task, value);
2224
+ // $FlowFixMe[incompatible-return]
2225
+ return value;
2345
2226
  }
2346
2227
 
2347
2228
  if (value instanceof Map) {
@@ -2355,7 +2236,7 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
2355
2236
  var iteratorFn = getIteratorFn(value);
2356
2237
 
2357
2238
  if (iteratorFn) {
2358
- return renderFragment(request, task, Array.from(value));
2239
+ return Array.from(value);
2359
2240
  } // Verify that this is a simple plain object.
2360
2241
 
2361
2242
 
@@ -2367,14 +2248,14 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
2367
2248
 
2368
2249
  {
2369
2250
  if (objectName(value) !== 'Object') {
2370
- error('Only plain objects can be passed to Client Components from Server Components. ' + '%s objects are not supported.%s', objectName(value), describeObjectForErrorMessage(parent, parentPropertyName));
2251
+ error('Only plain objects can be passed to Client Components from Server Components. ' + '%s objects are not supported.%s', objectName(value), describeObjectForErrorMessage(parent, key));
2371
2252
  } else if (!isSimpleObject(value)) {
2372
- 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));
2253
+ 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));
2373
2254
  } else if (Object.getOwnPropertySymbols) {
2374
2255
  var symbols = Object.getOwnPropertySymbols(value);
2375
2256
 
2376
2257
  if (symbols.length > 0) {
2377
- 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));
2258
+ 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));
2378
2259
  }
2379
2260
  }
2380
2261
  } // $FlowFixMe[incompatible-return]
@@ -2389,9 +2270,9 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
2389
2270
  if (value[value.length - 1] === 'Z') {
2390
2271
  // Possibly a Date, whose toJSON automatically calls toISOString
2391
2272
  // $FlowFixMe[incompatible-use]
2392
- var originalValue = parent[parentPropertyName];
2273
+ var _originalValue = parent[key];
2393
2274
 
2394
- if (originalValue instanceof Date) {
2275
+ if (_originalValue instanceof Date) {
2395
2276
  return serializeDateFromDateJSON(value);
2396
2277
  }
2397
2278
  }
@@ -2419,21 +2300,19 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
2419
2300
  }
2420
2301
 
2421
2302
  if (typeof value === 'function') {
2303
+
2422
2304
  if (isClientReference(value)) {
2423
- return serializeClientReference(request, parent, parentPropertyName, value);
2305
+ return serializeClientReference(request, parent, key, value);
2424
2306
  }
2425
2307
 
2426
2308
  if (isServerReference(value)) {
2427
- return serializeServerReference(request, value);
2309
+ return serializeServerReference(request, parent, key, value);
2428
2310
  }
2429
2311
 
2430
- if (/^on[A-Z]/.test(parentPropertyName)) {
2431
- 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.');
2432
- } else if ((jsxChildrenParents.has(parent) || jsxPropsParents.has(parent) && parentPropertyName === 'children')) {
2433
- var componentName = value.displayName || value.name || 'Component';
2434
- 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));
2312
+ if (/^on[A-Z]/.test(key)) {
2313
+ 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.');
2435
2314
  } else {
2436
- 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));
2315
+ 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));
2437
2316
  }
2438
2317
  }
2439
2318
 
@@ -2451,7 +2330,7 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
2451
2330
 
2452
2331
  if (Symbol.for(name) !== value) {
2453
2332
  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
2454
- value.description + ") cannot be found among global symbols.") + describeObjectForErrorMessage(parent, parentPropertyName));
2333
+ value.description + ") cannot be found among global symbols.") + describeObjectForErrorMessage(parent, key));
2455
2334
  }
2456
2335
 
2457
2336
  request.pendingChunks++;
@@ -2466,40 +2345,17 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
2466
2345
  return serializeBigInt(value);
2467
2346
  }
2468
2347
 
2469
- throw new Error("Type " + typeof value + " is not supported in Client Component props." + describeObjectForErrorMessage(parent, parentPropertyName));
2348
+ throw new Error("Type " + typeof value + " is not supported in Client Component props." + describeObjectForErrorMessage(parent, key));
2470
2349
  }
2471
2350
 
2472
2351
  function logPostpone(request, reason) {
2473
- var prevRequest = currentRequest;
2474
- currentRequest = null;
2475
-
2476
- try {
2477
- var onPostpone = request.onPostpone;
2478
-
2479
- if (supportsRequestStorage) {
2480
- // Exit the request context while running callbacks.
2481
- requestStorage.run(undefined, onPostpone, reason);
2482
- }
2483
- } finally {
2484
- currentRequest = prevRequest;
2485
- }
2352
+ var onPostpone = request.onPostpone;
2353
+ onPostpone(reason);
2486
2354
  }
2487
2355
 
2488
2356
  function logRecoverableError(request, error) {
2489
- var prevRequest = currentRequest;
2490
- currentRequest = null;
2491
- var errorDigest;
2492
-
2493
- try {
2494
- var onError = request.onError;
2495
-
2496
- if (supportsRequestStorage) {
2497
- // Exit the request context while running callbacks.
2498
- errorDigest = requestStorage.run(undefined, onError, error);
2499
- }
2500
- } finally {
2501
- currentRequest = prevRequest;
2502
- }
2357
+ var onError = request.onError;
2358
+ var errorDigest = onError(error);
2503
2359
 
2504
2360
  if (errorDigest != null && typeof errorDigest !== 'string') {
2505
2361
  // eslint-disable-next-line react-internal/prod-error-codes
@@ -2558,11 +2414,8 @@ function emitErrorChunk(request, id, digest, error) {
2558
2414
  message = String(error.message); // eslint-disable-next-line react-internal/safe-string-coercion
2559
2415
 
2560
2416
  stack = String(error.stack);
2561
- } else if (typeof error === 'object' && error !== null) {
2562
- message = describeObjectForErrorMessage(error);
2563
2417
  } else {
2564
- // eslint-disable-next-line react-internal/safe-string-coercion
2565
- message = String(error);
2418
+ message = 'Error: ' + error;
2566
2419
  }
2567
2420
  } catch (x) {
2568
2421
  message = 'An error occurred but serializing the error message failed.';
@@ -2602,79 +2455,62 @@ function emitSymbolChunk(request, id, name) {
2602
2455
  request.completedImportChunks.push(processedChunk);
2603
2456
  }
2604
2457
 
2605
- function emitModelChunk(request, id, json) {
2606
- var row = id.toString(16) + ':' + json + '\n';
2607
- var processedChunk = stringToChunk(row);
2608
- request.completedRegularChunks.push(processedChunk);
2609
- }
2610
-
2611
- function emitDebugChunk(request, id, debugInfo) {
2458
+ function emitModelChunk(request, id, model) {
2459
+ // Track the root so we know that we have to emit this object even though it
2460
+ // already has an ID. This is needed because we might see this object twice
2461
+ // in the same toJSON if it is cyclic.
2462
+ modelRoot = model; // $FlowFixMe[incompatible-type] stringify can return null
2612
2463
 
2613
-
2614
- var json = stringify(debugInfo);
2615
- var row = serializeRowHeader('D', id) + json + '\n';
2464
+ var json = stringify(model, request.toJSON);
2465
+ var row = id.toString(16) + ':' + json + '\n';
2616
2466
  var processedChunk = stringToChunk(row);
2617
2467
  request.completedRegularChunks.push(processedChunk);
2618
2468
  }
2619
2469
 
2620
- function forwardDebugInfo(request, id, debugInfo) {
2621
- for (var i = 0; i < debugInfo.length; i++) {
2622
- request.pendingChunks++;
2623
- emitDebugChunk(request, id, debugInfo[i]);
2624
- }
2625
- }
2626
-
2627
- var emptyRoot = {};
2628
-
2629
2470
  function retryTask(request, task) {
2630
2471
  if (task.status !== PENDING$1) {
2631
2472
  // We completed this by other means before we had a chance to retry it.
2632
2473
  return;
2633
2474
  }
2634
2475
 
2635
- var prevDebugID = debugID;
2476
+ switchContext(task.context);
2636
2477
 
2637
2478
  try {
2638
- // Track the root so we know that we have to emit this object even though it
2639
- // already has an ID. This is needed because we might see this object twice
2640
- // in the same toJSON if it is cyclic.
2641
- modelRoot = task.model;
2479
+ var value = task.model;
2642
2480
 
2643
- if (true) {
2644
- // Track the ID of the current task so we can assign debug info to this id.
2645
- debugID = task.id;
2646
- } // We call the destructive form that mutates this task. That way if something
2647
- // suspends again, we can reuse the same task instead of spawning a new one.
2481
+ if (typeof value === 'object' && value !== null && value.$$typeof === REACT_ELEMENT_TYPE) {
2482
+ request.writtenObjects.set(value, task.id); // TODO: Concatenate keys of parents onto children.
2648
2483
 
2484
+ var element = value; // When retrying a component, reuse the thenableState from the
2485
+ // previous attempt.
2649
2486
 
2650
- var resolvedModel = renderModelDestructive(request, task, emptyRoot, '', task.model);
2487
+ var prevThenableState = task.thenableState; // Attempt to render the Server Component.
2488
+ // Doing this here lets us reuse this same task if the next component
2489
+ // also suspends.
2651
2490
 
2652
- if (true) {
2653
- // We're now past rendering this task and future renders will spawn new tasks for their
2654
- // debug info.
2655
- debugID = null;
2656
- } // Track the root again for the resolved object.
2491
+ task.model = value;
2492
+ value = attemptResolveElement(request, element.type, element.key, element.ref, element.props, prevThenableState); // Successfully finished this component. We're going to keep rendering
2493
+ // using the same task, but we reset its thenable state before continuing.
2657
2494
 
2495
+ task.thenableState = null; // Keep rendering and reuse the same task. This inner loop is separate
2496
+ // from the render above because we don't need to reset the thenable state
2497
+ // until the next time something suspends and retries.
2658
2498
 
2659
- modelRoot = resolvedModel; // The keyPath resets at any terminal child node.
2499
+ while (typeof value === 'object' && value !== null && value.$$typeof === REACT_ELEMENT_TYPE) {
2500
+ request.writtenObjects.set(value, task.id); // TODO: Concatenate keys of parents onto children.
2660
2501
 
2661
- task.keyPath = null;
2662
- task.implicitSlot = false;
2663
- var json;
2502
+ var nextElement = value;
2503
+ task.model = value;
2504
+ value = attemptResolveElement(request, nextElement.type, nextElement.key, nextElement.ref, nextElement.props, null);
2505
+ }
2506
+ } // Track that this object is outlined and has an id.
2664
2507
 
2665
- if (typeof resolvedModel === 'object' && resolvedModel !== null) {
2666
- // Object might contain unresolved values like additional elements.
2667
- // This is simulating what the JSON loop would do if this was part of it.
2668
- // $FlowFixMe[incompatible-type] stringify can return null for undefined but we never do
2669
- json = stringify(resolvedModel, task.toJSON);
2670
- } else {
2671
- // If the value is a string, it means it's a terminal value and we already escaped it
2672
- // We don't need to escape it again so it's not passed the toJSON replacer.
2673
- // $FlowFixMe[incompatible-type] stringify can return null for undefined but we never do
2674
- json = stringify(resolvedModel);
2508
+
2509
+ if (typeof value === 'object' && value !== null) {
2510
+ request.writtenObjects.set(value, task.id);
2675
2511
  }
2676
2512
 
2677
- emitModelChunk(request, task.id, json);
2513
+ emitModelChunk(request, task.id, value);
2678
2514
  request.abortableTasks.delete(task);
2679
2515
  task.status = COMPLETED;
2680
2516
  } catch (thrownValue) {
@@ -2700,10 +2536,6 @@ function retryTask(request, task) {
2700
2536
  task.status = ERRORED$1;
2701
2537
  var digest = logRecoverableError(request, x);
2702
2538
  emitErrorChunk(request, task.id, digest, x);
2703
- } finally {
2704
- {
2705
- debugID = prevDebugID;
2706
- }
2707
2539
  }
2708
2540
  }
2709
2541
 
@@ -2918,6 +2750,11 @@ function abort(request, reason) {
2918
2750
  }
2919
2751
  }
2920
2752
 
2753
+ function importServerContexts(contexts) {
2754
+
2755
+ return rootContextSnapshot;
2756
+ }
2757
+
2921
2758
  function resolveServerReference(bundlerConfig, id) {
2922
2759
  var idx = id.lastIndexOf('#');
2923
2760
  var specifier = id.slice(0, idx);
@@ -3643,7 +3480,7 @@ function createCancelHandler(request, reason) {
3643
3480
  }
3644
3481
 
3645
3482
  function renderToPipeableStream(model, webpackMap, options) {
3646
- var request = createRequest(model, webpackMap, options ? options.onError : undefined, options ? options.identifierPrefix : undefined, options ? options.onPostpone : undefined, options ? options.environmentName : undefined);
3483
+ var request = createRequest(model, webpackMap, options ? options.onError : undefined, options ? options.context : undefined, options ? options.identifierPrefix : undefined, options ? options.onPostpone : undefined);
3647
3484
  var hasStartedFlowing = false;
3648
3485
  startWork(request);
3649
3486
  return {