react-server-dom-webpack 18.3.0-canary-14898b6a9-20240318 → 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.
- package/cjs/react-server-dom-webpack-client.browser.development.js +91 -189
- package/cjs/react-server-dom-webpack-client.browser.production.js +60 -43
- package/cjs/react-server-dom-webpack-client.browser.production.min.js +24 -23
- package/cjs/react-server-dom-webpack-client.browser.production.min.js.map +1 -1
- package/cjs/react-server-dom-webpack-client.edge.development.js +96 -241
- package/cjs/react-server-dom-webpack-client.edge.production.js +65 -84
- package/cjs/react-server-dom-webpack-client.edge.production.min.js +29 -29
- package/cjs/react-server-dom-webpack-client.edge.production.min.js.map +1 -1
- package/cjs/react-server-dom-webpack-client.node.development.js +96 -241
- package/cjs/react-server-dom-webpack-client.node.production.js +65 -84
- package/cjs/react-server-dom-webpack-client.node.production.min.js +29 -28
- package/cjs/react-server-dom-webpack-client.node.production.min.js.map +1 -1
- package/cjs/react-server-dom-webpack-client.node.unbundled.development.js +96 -241
- package/cjs/react-server-dom-webpack-client.node.unbundled.production.js +65 -84
- package/cjs/react-server-dom-webpack-client.node.unbundled.production.min.js +30 -30
- package/cjs/react-server-dom-webpack-client.node.unbundled.production.min.js.map +1 -1
- package/cjs/react-server-dom-webpack-node-register.js.map +1 -1
- package/cjs/react-server-dom-webpack-plugin.js.map +1 -1
- package/cjs/react-server-dom-webpack-server.browser.development.js +406 -550
- package/cjs/react-server-dom-webpack-server.browser.production.js +351 -373
- package/cjs/react-server-dom-webpack-server.browser.production.min.js +68 -65
- package/cjs/react-server-dom-webpack-server.browser.production.min.js.map +1 -1
- package/cjs/react-server-dom-webpack-server.edge.development.js +406 -553
- package/cjs/react-server-dom-webpack-server.edge.production.js +350 -375
- package/cjs/react-server-dom-webpack-server.edge.production.min.js +69 -66
- package/cjs/react-server-dom-webpack-server.edge.production.min.js.map +1 -1
- package/cjs/react-server-dom-webpack-server.node.development.js +406 -550
- package/cjs/react-server-dom-webpack-server.node.production.js +350 -372
- package/cjs/react-server-dom-webpack-server.node.production.min.js +72 -70
- package/cjs/react-server-dom-webpack-server.node.production.min.js.map +1 -1
- package/cjs/react-server-dom-webpack-server.node.unbundled.development.js +406 -550
- package/cjs/react-server-dom-webpack-server.node.unbundled.production.js +350 -372
- package/cjs/react-server-dom-webpack-server.node.unbundled.production.min.js +69 -67
- package/cjs/react-server-dom-webpack-server.node.unbundled.production.min.js.map +1 -1
- package/package.json +3 -3
- package/umd/react-server-dom-webpack-client.browser.development.js +91 -189
- package/umd/react-server-dom-webpack-client.browser.production.min.js +23 -22
- package/umd/react-server-dom-webpack-server.browser.development.js +406 -550
- package/umd/react-server-dom-webpack-server.browser.production.min.js +52 -52
@@ -152,10 +152,10 @@ function closeWithError(destination, error) {
|
|
152
152
|
}
|
153
153
|
|
154
154
|
// eslint-disable-next-line no-unused-vars
|
155
|
-
var CLIENT_REFERENCE_TAG
|
155
|
+
var CLIENT_REFERENCE_TAG = Symbol.for('react.client.reference');
|
156
156
|
var SERVER_REFERENCE_TAG = Symbol.for('react.server.reference');
|
157
157
|
function isClientReference(reference) {
|
158
|
-
return reference.$$typeof === CLIENT_REFERENCE_TAG
|
158
|
+
return reference.$$typeof === CLIENT_REFERENCE_TAG;
|
159
159
|
}
|
160
160
|
function isServerReference(reference) {
|
161
161
|
return reference.$$typeof === SERVER_REFERENCE_TAG;
|
@@ -167,7 +167,7 @@ function registerClientReference(proxyImplementation, id, exportName) {
|
|
167
167
|
function registerClientReferenceImpl(proxyImplementation, id, async) {
|
168
168
|
return Object.defineProperties(proxyImplementation, {
|
169
169
|
$$typeof: {
|
170
|
-
value: CLIENT_REFERENCE_TAG
|
170
|
+
value: CLIENT_REFERENCE_TAG
|
171
171
|
},
|
172
172
|
$$id: {
|
173
173
|
value: id
|
@@ -188,14 +188,6 @@ function bind() {
|
|
188
188
|
var newFn = FunctionBind.apply(this, arguments);
|
189
189
|
|
190
190
|
if (this.$$typeof === SERVER_REFERENCE_TAG) {
|
191
|
-
{
|
192
|
-
var thisBind = arguments[0];
|
193
|
-
|
194
|
-
if (thisBind != null) {
|
195
|
-
error('Cannot bind "this" of a Server Action. Pass null or undefined as the first argument to .bind().');
|
196
|
-
}
|
197
|
-
}
|
198
|
-
|
199
191
|
var args = ArraySlice.call(arguments, 1);
|
200
192
|
return Object.defineProperties(newFn, {
|
201
193
|
$$typeof: {
|
@@ -222,16 +214,13 @@ function registerServerReference(reference, id, exportName) {
|
|
222
214
|
value: SERVER_REFERENCE_TAG
|
223
215
|
},
|
224
216
|
$$id: {
|
225
|
-
value: exportName === null ? id : id + '#' + exportName
|
226
|
-
configurable: true
|
217
|
+
value: exportName === null ? id : id + '#' + exportName
|
227
218
|
},
|
228
219
|
$$bound: {
|
229
|
-
value: null
|
230
|
-
configurable: true
|
220
|
+
value: null
|
231
221
|
},
|
232
222
|
bind: {
|
233
|
-
value: bind
|
234
|
-
configurable: true
|
223
|
+
value: bind
|
235
224
|
}
|
236
225
|
});
|
237
226
|
}
|
@@ -270,10 +259,6 @@ var deepProxyHandlers = {
|
|
270
259
|
// $FlowFixMe[prop-missing]
|
271
260
|
return Object.prototype[Symbol.toPrimitive];
|
272
261
|
|
273
|
-
case Symbol.toStringTag:
|
274
|
-
// $FlowFixMe[prop-missing]
|
275
|
-
return Object.prototype[Symbol.toStringTag];
|
276
|
-
|
277
262
|
case 'Provider':
|
278
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.");
|
279
264
|
} // eslint-disable-next-line react-internal/safe-string-coercion
|
@@ -315,10 +300,6 @@ function getReference(target, name) {
|
|
315
300
|
// $FlowFixMe[prop-missing]
|
316
301
|
return Object.prototype[Symbol.toPrimitive];
|
317
302
|
|
318
|
-
case Symbol.toStringTag:
|
319
|
-
// $FlowFixMe[prop-missing]
|
320
|
-
return Object.prototype[Symbol.toStringTag];
|
321
|
-
|
322
303
|
case '__esModule':
|
323
304
|
// Something is conditionally checking which export to use. We'll pretend to be
|
324
305
|
// an ESM compat module but then we'll check again on the client.
|
@@ -359,10 +340,6 @@ function getReference(target, name) {
|
|
359
340
|
|
360
341
|
}
|
361
342
|
|
362
|
-
if (typeof name === 'symbol') {
|
363
|
-
throw new Error('Cannot read Symbol exports. Only named exports are supported on a client module ' + 'imported on the server.');
|
364
|
-
}
|
365
|
-
|
366
343
|
var cachedReference = target[name];
|
367
344
|
|
368
345
|
if (!cachedReference) {
|
@@ -704,16 +681,13 @@ function createHints() {
|
|
704
681
|
return new Set();
|
705
682
|
}
|
706
683
|
|
707
|
-
var supportsRequestStorage = false;
|
708
|
-
var requestStorage = null;
|
709
|
-
|
710
684
|
// ATTENTION
|
711
685
|
// When adding new symbols to this file,
|
712
686
|
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
|
713
687
|
// The Symbol used to tag the ReactElement-like types.
|
714
688
|
var REACT_ELEMENT_TYPE = Symbol.for('react.element');
|
715
689
|
var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
|
716
|
-
var
|
690
|
+
var REACT_SERVER_CONTEXT_TYPE = Symbol.for('react.server_context');
|
717
691
|
var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');
|
718
692
|
var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');
|
719
693
|
var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');
|
@@ -737,6 +711,146 @@ function getIteratorFn(maybeIterable) {
|
|
737
711
|
return null;
|
738
712
|
}
|
739
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
|
+
|
740
854
|
// Corresponds to ReactFiberWakeable and ReactFizzWakeable modules. Generally,
|
741
855
|
// changes to one module should be reflected in the others.
|
742
856
|
// TODO: Rename this module and the corresponding Fiber one to "Thenable"
|
@@ -865,13 +979,29 @@ function prepareToUseHooksForComponent(prevThenableState) {
|
|
865
979
|
thenableState = prevThenableState;
|
866
980
|
}
|
867
981
|
function getThenableStateAfterSuspending() {
|
868
|
-
|
869
|
-
// which is not really supported anymore, it will be empty. We use the empty set as a
|
870
|
-
// marker to know if this was a replay of the same component or first attempt.
|
871
|
-
var state = thenableState || createThenableState();
|
982
|
+
var state = thenableState;
|
872
983
|
thenableState = null;
|
873
984
|
return state;
|
874
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
|
+
|
875
1005
|
var HooksDispatcher = {
|
876
1006
|
useMemo: function (nextCreate) {
|
877
1007
|
return nextCreate();
|
@@ -882,8 +1012,8 @@ var HooksDispatcher = {
|
|
882
1012
|
useDebugValue: function () {},
|
883
1013
|
useDeferredValue: unsupportedHook,
|
884
1014
|
useTransition: unsupportedHook,
|
885
|
-
readContext:
|
886
|
-
useContext:
|
1015
|
+
readContext: readContext,
|
1016
|
+
useContext: readContext,
|
887
1017
|
useReducer: unsupportedHook,
|
888
1018
|
useRef: unsupportedHook,
|
889
1019
|
useState: unsupportedHook,
|
@@ -916,10 +1046,6 @@ function unsupportedRefresh() {
|
|
916
1046
|
throw new Error('Refreshing the cache is not supported in Server Components.');
|
917
1047
|
}
|
918
1048
|
|
919
|
-
function unsupportedContext() {
|
920
|
-
throw new Error('Cannot read a Client Context from a Server Component.');
|
921
|
-
}
|
922
|
-
|
923
1049
|
function useId() {
|
924
1050
|
if (currentRequest$1 === null) {
|
925
1051
|
throw new Error('useId can only be used while React is rendering');
|
@@ -945,22 +1071,20 @@ function use(usable) {
|
|
945
1071
|
}
|
946
1072
|
|
947
1073
|
return trackUsedThenable(thenableState, thenable, index);
|
948
|
-
} else if (usable.$$typeof ===
|
949
|
-
|
1074
|
+
} else if (usable.$$typeof === REACT_SERVER_CONTEXT_TYPE) {
|
1075
|
+
var context = usable;
|
1076
|
+
return readContext(context);
|
950
1077
|
}
|
951
1078
|
}
|
952
1079
|
|
953
|
-
|
954
|
-
if (usable
|
955
|
-
|
956
|
-
throw new Error('Cannot read a Client Context from a Server Component.');
|
957
|
-
} else {
|
958
|
-
throw new Error('Cannot use() an already resolved Client Reference.');
|
1080
|
+
{
|
1081
|
+
if (isClientReference(usable)) {
|
1082
|
+
error('Cannot use() an already resolved Client Reference.');
|
959
1083
|
}
|
960
|
-
}
|
961
|
-
|
962
|
-
|
963
|
-
|
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));
|
964
1088
|
}
|
965
1089
|
|
966
1090
|
function createSignal() {
|
@@ -1098,10 +1222,6 @@ function describeValueForErrorMessage(value) {
|
|
1098
1222
|
return '[...]';
|
1099
1223
|
}
|
1100
1224
|
|
1101
|
-
if (value !== null && value.$$typeof === CLIENT_REFERENCE_TAG) {
|
1102
|
-
return describeClientReference();
|
1103
|
-
}
|
1104
|
-
|
1105
1225
|
var name = objectName(value);
|
1106
1226
|
|
1107
1227
|
if (name === 'Object') {
|
@@ -1112,15 +1232,7 @@ function describeValueForErrorMessage(value) {
|
|
1112
1232
|
}
|
1113
1233
|
|
1114
1234
|
case 'function':
|
1115
|
-
|
1116
|
-
if (value.$$typeof === CLIENT_REFERENCE_TAG) {
|
1117
|
-
return describeClientReference();
|
1118
|
-
}
|
1119
|
-
|
1120
|
-
var _name = value.displayName || value.name;
|
1121
|
-
|
1122
|
-
return _name ? 'function ' + _name : 'function';
|
1123
|
-
}
|
1235
|
+
return 'function';
|
1124
1236
|
|
1125
1237
|
default:
|
1126
1238
|
// eslint-disable-next-line react-internal/safe-string-coercion
|
@@ -1166,12 +1278,6 @@ function describeElementType(type) {
|
|
1166
1278
|
return '';
|
1167
1279
|
}
|
1168
1280
|
|
1169
|
-
var CLIENT_REFERENCE_TAG = Symbol.for('react.client.reference');
|
1170
|
-
|
1171
|
-
function describeClientReference(ref) {
|
1172
|
-
return 'client';
|
1173
|
-
}
|
1174
|
-
|
1175
1281
|
function describeObjectForErrorMessage(objectOrArray, expandedName) {
|
1176
1282
|
var objKind = objectName(objectOrArray);
|
1177
1283
|
|
@@ -1250,8 +1356,6 @@ function describeObjectForErrorMessage(objectOrArray, expandedName) {
|
|
1250
1356
|
} else {
|
1251
1357
|
if (objectOrArray.$$typeof === REACT_ELEMENT_TYPE) {
|
1252
1358
|
str = '<' + describeElementType(objectOrArray.type) + '/>';
|
1253
|
-
} else if (objectOrArray.$$typeof === CLIENT_REFERENCE_TAG) {
|
1254
|
-
return describeClientReference();
|
1255
1359
|
} else if (jsxPropsParents.has(objectOrArray)) {
|
1256
1360
|
// Print JSX
|
1257
1361
|
var _type = jsxPropsParents.get(objectOrArray);
|
@@ -1302,9 +1406,9 @@ function describeObjectForErrorMessage(objectOrArray, expandedName) {
|
|
1302
1406
|
str += ', ';
|
1303
1407
|
}
|
1304
1408
|
|
1305
|
-
var
|
1306
|
-
str += describeKeyForErrorMessage(
|
1307
|
-
var _value3 = _object[
|
1409
|
+
var _name = _names[_i3];
|
1410
|
+
str += describeKeyForErrorMessage(_name) + ': ';
|
1411
|
+
var _value3 = _object[_name];
|
1308
1412
|
|
1309
1413
|
var _substr3 = void 0;
|
1310
1414
|
|
@@ -1314,7 +1418,7 @@ function describeObjectForErrorMessage(objectOrArray, expandedName) {
|
|
1314
1418
|
_substr3 = describeValueForErrorMessage(_value3);
|
1315
1419
|
}
|
1316
1420
|
|
1317
|
-
if (
|
1421
|
+
if (_name === expandedName) {
|
1318
1422
|
start = str.length;
|
1319
1423
|
length = _substr3.length;
|
1320
1424
|
str += _substr3;
|
@@ -1369,7 +1473,7 @@ function defaultPostponeHandler(reason) {// Noop
|
|
1369
1473
|
var OPEN = 0;
|
1370
1474
|
var CLOSING = 1;
|
1371
1475
|
var CLOSED = 2;
|
1372
|
-
function createRequest(model, bundlerConfig, onError, identifierPrefix, onPostpone
|
1476
|
+
function createRequest(model, bundlerConfig, onError, context, identifierPrefix, onPostpone) {
|
1373
1477
|
if (ReactCurrentCache.current !== null && ReactCurrentCache.current !== DefaultCacheDispatcher) {
|
1374
1478
|
throw new Error('Currently React only supports one RSC renderer at a time.');
|
1375
1479
|
}
|
@@ -1400,19 +1504,21 @@ function createRequest(model, bundlerConfig, onError, identifierPrefix, onPostpo
|
|
1400
1504
|
writtenSymbols: new Map(),
|
1401
1505
|
writtenClientReferences: new Map(),
|
1402
1506
|
writtenServerReferences: new Map(),
|
1507
|
+
writtenProviders: new Map(),
|
1403
1508
|
writtenObjects: new WeakMap(),
|
1404
1509
|
identifierPrefix: identifierPrefix || '',
|
1405
1510
|
identifierCount: 1,
|
1406
1511
|
taintCleanupQueue: cleanupQueue,
|
1407
1512
|
onError: onError === undefined ? defaultErrorHandler : onError,
|
1408
|
-
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
|
+
}
|
1409
1518
|
};
|
1410
|
-
|
1411
|
-
|
1412
|
-
|
1413
|
-
}
|
1414
|
-
|
1415
|
-
var rootTask = createTask(request, model, null, false, abortSet);
|
1519
|
+
request.pendingChunks++;
|
1520
|
+
var rootContext = createRootContext();
|
1521
|
+
var rootTask = createTask(request, model, rootContext, abortSet);
|
1416
1522
|
pingedTasks.push(rootTask);
|
1417
1523
|
return request;
|
1418
1524
|
}
|
@@ -1423,18 +1529,13 @@ function resolveRequest() {
|
|
1423
1529
|
return null;
|
1424
1530
|
}
|
1425
1531
|
|
1426
|
-
function
|
1427
|
-
|
1428
|
-
|
1429
|
-
|
1430
|
-
{
|
1431
|
-
// If this came from Flight, forward any debug info into this new row.
|
1432
|
-
var debugInfo = thenable._debugInfo;
|
1532
|
+
function createRootContext(reqContext) {
|
1533
|
+
return importServerContexts();
|
1534
|
+
}
|
1433
1535
|
|
1434
|
-
|
1435
|
-
|
1436
|
-
|
1437
|
-
}
|
1536
|
+
function serializeThenable(request, thenable) {
|
1537
|
+
request.pendingChunks++;
|
1538
|
+
var newTask = createTask(request, null, getActiveContext(), request.abortableTasks);
|
1438
1539
|
|
1439
1540
|
switch (thenable.status) {
|
1440
1541
|
case 'fulfilled':
|
@@ -1570,136 +1671,14 @@ function createLazyWrapperAroundWakeable(wakeable) {
|
|
1570
1671
|
_payload: thenable,
|
1571
1672
|
_init: readThenable
|
1572
1673
|
};
|
1573
|
-
|
1574
|
-
{
|
1575
|
-
// If this came from React, transfer the debug info.
|
1576
|
-
lazyType._debugInfo = thenable._debugInfo || [];
|
1577
|
-
}
|
1578
|
-
|
1579
1674
|
return lazyType;
|
1580
1675
|
}
|
1581
1676
|
|
1582
|
-
function
|
1583
|
-
// Reset the task's thenable state before continuing, so that if a later
|
1584
|
-
// component suspends we can reuse the same task object. If the same
|
1585
|
-
// component suspends again, the thenable state will be restored.
|
1586
|
-
var prevThenableState = task.thenableState;
|
1587
|
-
task.thenableState = null;
|
1588
|
-
|
1589
|
-
{
|
1590
|
-
if (debugID === null) {
|
1591
|
-
// We don't have a chunk to assign debug info. We need to outline this
|
1592
|
-
// component to assign it an ID.
|
1593
|
-
return outlineTask(request, task);
|
1594
|
-
} else if (prevThenableState !== null) ; else {
|
1595
|
-
// This is a new component in the same task so we can emit more debug info.
|
1596
|
-
var componentName = Component.displayName || Component.name || '';
|
1597
|
-
request.pendingChunks++;
|
1598
|
-
emitDebugChunk(request, debugID, {
|
1599
|
-
name: componentName,
|
1600
|
-
env: request.environmentName
|
1601
|
-
});
|
1602
|
-
}
|
1603
|
-
}
|
1604
|
-
|
1605
|
-
prepareToUseHooksForComponent(prevThenableState); // The secondArg is always undefined in Server Components since refs error early.
|
1606
|
-
|
1607
|
-
var secondArg = undefined;
|
1608
|
-
var result = Component(props, secondArg);
|
1609
|
-
|
1610
|
-
if (typeof result === 'object' && result !== null && typeof result.then === 'function') {
|
1611
|
-
// When the return value is in children position we can resolve it immediately,
|
1612
|
-
// to its value without a wrapper if it's synchronously available.
|
1613
|
-
var thenable = result;
|
1614
|
-
|
1615
|
-
if (thenable.status === 'fulfilled') {
|
1616
|
-
return thenable.value;
|
1617
|
-
} // TODO: Once we accept Promises as children on the client, we can just return
|
1618
|
-
// the thenable here.
|
1619
|
-
|
1620
|
-
|
1621
|
-
result = createLazyWrapperAroundWakeable(result);
|
1622
|
-
} // Track this element's key on the Server Component on the keyPath context..
|
1623
|
-
|
1624
|
-
|
1625
|
-
var prevKeyPath = task.keyPath;
|
1626
|
-
var prevImplicitSlot = task.implicitSlot;
|
1627
|
-
|
1628
|
-
if (key !== null) {
|
1629
|
-
// Append the key to the path. Technically a null key should really add the child
|
1630
|
-
// index. We don't do that to hold the payload small and implementation simple.
|
1631
|
-
task.keyPath = prevKeyPath === null ? key : prevKeyPath + ',' + key;
|
1632
|
-
} else if (prevKeyPath === null) {
|
1633
|
-
// This sequence of Server Components has no keys. This means that it was rendered
|
1634
|
-
// in a slot that needs to assign an implicit key. Even if children below have
|
1635
|
-
// explicit keys, they should not be used for the outer most key since it might
|
1636
|
-
// collide with other slots in that set.
|
1637
|
-
task.implicitSlot = true;
|
1638
|
-
}
|
1639
|
-
|
1640
|
-
var json = renderModelDestructive(request, task, emptyRoot, '', result);
|
1641
|
-
task.keyPath = prevKeyPath;
|
1642
|
-
task.implicitSlot = prevImplicitSlot;
|
1643
|
-
return json;
|
1644
|
-
}
|
1645
|
-
|
1646
|
-
function renderFragment(request, task, children) {
|
1647
|
-
{
|
1648
|
-
var debugInfo = children._debugInfo;
|
1649
|
-
|
1650
|
-
if (debugInfo) {
|
1651
|
-
// If this came from Flight, forward any debug info into this new row.
|
1652
|
-
if (debugID === null) {
|
1653
|
-
// We don't have a chunk to assign debug info. We need to outline this
|
1654
|
-
// component to assign it an ID.
|
1655
|
-
return outlineTask(request, task);
|
1656
|
-
} else {
|
1657
|
-
// Forward any debug info we have the first time we see it.
|
1658
|
-
// We do this after init so that we have received all the debug info
|
1659
|
-
// from the server by the time we emit it.
|
1660
|
-
forwardDebugInfo(request, debugID, debugInfo);
|
1661
|
-
}
|
1662
|
-
}
|
1663
|
-
}
|
1664
|
-
|
1665
|
-
{
|
1666
|
-
return children;
|
1667
|
-
}
|
1668
|
-
}
|
1669
|
-
|
1670
|
-
function renderClientElement(task, type, key, props) {
|
1671
|
-
{
|
1672
|
-
return [REACT_ELEMENT_TYPE, type, key, props];
|
1673
|
-
} // We prepend the terminal client element that actually gets serialized with
|
1674
|
-
} // The chunk ID we're currently rendering that we can assign debug data to.
|
1675
|
-
|
1676
|
-
|
1677
|
-
var debugID = null;
|
1678
|
-
|
1679
|
-
function outlineTask(request, task) {
|
1680
|
-
var newTask = createTask(request, task.model, // the currently rendering element
|
1681
|
-
task.keyPath, // unlike outlineModel this one carries along context
|
1682
|
-
task.implicitSlot, request.abortableTasks);
|
1683
|
-
retryTask(request, newTask);
|
1684
|
-
|
1685
|
-
if (newTask.status === COMPLETED) {
|
1686
|
-
// We completed synchronously so we can refer to this by reference. This
|
1687
|
-
// makes it behaves the same as prod during deserialization.
|
1688
|
-
return serializeByValueID(newTask.id);
|
1689
|
-
} // This didn't complete synchronously so it wouldn't have even if we didn't
|
1690
|
-
// outline it, so this would reduce to a lazy reference even in prod.
|
1691
|
-
|
1692
|
-
|
1693
|
-
return serializeLazyID(newTask.id);
|
1694
|
-
}
|
1695
|
-
|
1696
|
-
function renderElement(request, task, type, key, ref, props) {
|
1677
|
+
function attemptResolveElement(request, type, key, ref, props, prevThenableState) {
|
1697
1678
|
if (ref !== null && ref !== undefined) {
|
1698
1679
|
// When the ref moves to the regular props object this will implicitly
|
1699
1680
|
// throw for functions. We could probably relax it to a DEV warning for other
|
1700
1681
|
// cases.
|
1701
|
-
// TODO: `ref` is now just a prop when `enableRefAsProp` is on. Should we
|
1702
|
-
// do what the above comment says?
|
1703
1682
|
throw new Error('Refs cannot be used in Server Components, nor passed to Client Components.');
|
1704
1683
|
}
|
1705
1684
|
|
@@ -1714,36 +1693,47 @@ function renderElement(request, task, type, key, ref, props) {
|
|
1714
1693
|
if (typeof type === 'function') {
|
1715
1694
|
if (isClientReference(type)) {
|
1716
1695
|
// This is a reference to a Client Component.
|
1717
|
-
return
|
1718
|
-
} // This is a
|
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);
|
1719
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;
|
1720
1707
|
|
1721
|
-
|
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
|
+
|
1713
|
+
|
1714
|
+
return createLazyWrapperAroundWakeable(result);
|
1715
|
+
}
|
1716
|
+
|
1717
|
+
return result;
|
1722
1718
|
} else if (typeof type === 'string') {
|
1723
1719
|
// This is a host element. E.g. HTML.
|
1724
|
-
return
|
1720
|
+
return [REACT_ELEMENT_TYPE, type, key, props];
|
1725
1721
|
} else if (typeof type === 'symbol') {
|
1726
|
-
if (type === REACT_FRAGMENT_TYPE
|
1722
|
+
if (type === REACT_FRAGMENT_TYPE) {
|
1727
1723
|
// For key-less fragments, we add a small optimization to avoid serializing
|
1728
1724
|
// it as a wrapper.
|
1729
|
-
|
1730
|
-
|
1731
|
-
|
1732
|
-
task.implicitSlot = true;
|
1733
|
-
}
|
1734
|
-
|
1735
|
-
var json = renderModelDestructive(request, task, emptyRoot, '', props.children);
|
1736
|
-
task.implicitSlot = prevImplicitSlot;
|
1737
|
-
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;
|
1738
1728
|
} // This might be a built-in React component. We'll let the client decide.
|
1739
1729
|
// Any built-in works as long as its props are serializable.
|
1740
1730
|
|
1741
1731
|
|
1742
|
-
return
|
1732
|
+
return [REACT_ELEMENT_TYPE, type, key, props];
|
1743
1733
|
} else if (type != null && typeof type === 'object') {
|
1744
1734
|
if (isClientReference(type)) {
|
1745
1735
|
// This is a reference to a Client Component.
|
1746
|
-
return
|
1736
|
+
return [REACT_ELEMENT_TYPE, type, key, props];
|
1747
1737
|
}
|
1748
1738
|
|
1749
1739
|
switch (type.$$typeof) {
|
@@ -1752,17 +1742,19 @@ function renderElement(request, task, type, key, ref, props) {
|
|
1752
1742
|
var payload = type._payload;
|
1753
1743
|
var init = type._init;
|
1754
1744
|
var wrappedType = init(payload);
|
1755
|
-
return
|
1745
|
+
return attemptResolveElement(request, wrappedType, key, ref, props, prevThenableState);
|
1756
1746
|
}
|
1757
1747
|
|
1758
1748
|
case REACT_FORWARD_REF_TYPE:
|
1759
1749
|
{
|
1760
|
-
|
1750
|
+
var render = type.render;
|
1751
|
+
prepareToUseHooksForComponent(prevThenableState);
|
1752
|
+
return render(props, undefined);
|
1761
1753
|
}
|
1762
1754
|
|
1763
1755
|
case REACT_MEMO_TYPE:
|
1764
1756
|
{
|
1765
|
-
return
|
1757
|
+
return attemptResolveElement(request, type.type, key, ref, props, prevThenableState);
|
1766
1758
|
}
|
1767
1759
|
}
|
1768
1760
|
}
|
@@ -1782,51 +1774,16 @@ function pingTask(request, task) {
|
|
1782
1774
|
}
|
1783
1775
|
}
|
1784
1776
|
|
1785
|
-
function createTask(request, model,
|
1786
|
-
request.pendingChunks++;
|
1777
|
+
function createTask(request, model, context, abortSet) {
|
1787
1778
|
var id = request.nextChunkId++;
|
1788
|
-
|
1789
|
-
if (typeof model === 'object' && model !== null) {
|
1790
|
-
// If we're about to write this into a new task we can assign it an ID early so that
|
1791
|
-
// any other references can refer to the value we're about to write.
|
1792
|
-
{
|
1793
|
-
request.writtenObjects.set(model, id);
|
1794
|
-
}
|
1795
|
-
}
|
1796
|
-
|
1797
1779
|
var task = {
|
1798
1780
|
id: id,
|
1799
1781
|
status: PENDING$1,
|
1800
1782
|
model: model,
|
1801
|
-
|
1802
|
-
implicitSlot: implicitSlot,
|
1783
|
+
context: context,
|
1803
1784
|
ping: function () {
|
1804
1785
|
return pingTask(request, task);
|
1805
1786
|
},
|
1806
|
-
toJSON: function (parentPropertyName, value) {
|
1807
|
-
var parent = this; // Make sure that `parent[parentPropertyName]` wasn't JSONified before `value` was passed to us
|
1808
|
-
|
1809
|
-
{
|
1810
|
-
// $FlowFixMe[incompatible-use]
|
1811
|
-
var originalValue = parent[parentPropertyName];
|
1812
|
-
|
1813
|
-
if (typeof originalValue === 'object' && originalValue !== value && !(originalValue instanceof Date)) {
|
1814
|
-
if (objectName(originalValue) !== 'Object') {
|
1815
|
-
var jsxParentType = jsxChildrenParents.get(parent);
|
1816
|
-
|
1817
|
-
if (typeof jsxParentType === 'string') {
|
1818
|
-
error('%s objects cannot be rendered as text children. Try formatting it using toString().%s', objectName(originalValue), describeObjectForErrorMessage(parent, parentPropertyName));
|
1819
|
-
} else {
|
1820
|
-
error('Only plain objects can be passed to Client Components from Server Components. ' + '%s objects are not supported.%s', objectName(originalValue), describeObjectForErrorMessage(parent, parentPropertyName));
|
1821
|
-
}
|
1822
|
-
} else {
|
1823
|
-
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));
|
1824
|
-
}
|
1825
|
-
}
|
1826
|
-
}
|
1827
|
-
|
1828
|
-
return renderModel(request, task, parent, parentPropertyName, value);
|
1829
|
-
},
|
1830
1787
|
thenableState: null
|
1831
1788
|
};
|
1832
1789
|
abortSet.add(task);
|
@@ -1895,13 +1852,13 @@ function encodeReferenceChunk(request, id, reference) {
|
|
1895
1852
|
return stringToChunk(row);
|
1896
1853
|
}
|
1897
1854
|
|
1898
|
-
function serializeClientReference(request, parent,
|
1855
|
+
function serializeClientReference(request, parent, key, clientReference) {
|
1899
1856
|
var clientReferenceKey = getClientReferenceKey(clientReference);
|
1900
1857
|
var writtenClientReferences = request.writtenClientReferences;
|
1901
1858
|
var existingId = writtenClientReferences.get(clientReferenceKey);
|
1902
1859
|
|
1903
1860
|
if (existingId !== undefined) {
|
1904
|
-
if (parent[0] === REACT_ELEMENT_TYPE &&
|
1861
|
+
if (parent[0] === REACT_ELEMENT_TYPE && key === '1') {
|
1905
1862
|
// If we're encoding the "type" of an element, we can refer
|
1906
1863
|
// to that by a lazy reference instead of directly since React
|
1907
1864
|
// knows how to deal with lazy values. This lets us suspend
|
@@ -1920,7 +1877,7 @@ function serializeClientReference(request, parent, parentPropertyName, clientRef
|
|
1920
1877
|
emitImportChunk(request, importId, clientReferenceMetadata);
|
1921
1878
|
writtenClientReferences.set(clientReferenceKey, importId);
|
1922
1879
|
|
1923
|
-
if (parent[0] === REACT_ELEMENT_TYPE &&
|
1880
|
+
if (parent[0] === REACT_ELEMENT_TYPE && key === '1') {
|
1924
1881
|
// If we're encoding the "type" of an element, we can refer
|
1925
1882
|
// to that by a lazy reference instead of directly since React
|
1926
1883
|
// knows how to deal with lazy values. This lets us suspend
|
@@ -1940,14 +1897,13 @@ function serializeClientReference(request, parent, parentPropertyName, clientRef
|
|
1940
1897
|
}
|
1941
1898
|
|
1942
1899
|
function outlineModel(request, value) {
|
1943
|
-
|
1944
|
-
|
1945
|
-
request.abortableTasks);
|
1900
|
+
request.pendingChunks++;
|
1901
|
+
var newTask = createTask(request, value, getActiveContext(), request.abortableTasks);
|
1946
1902
|
retryTask(request, newTask);
|
1947
1903
|
return newTask.id;
|
1948
1904
|
}
|
1949
1905
|
|
1950
|
-
function serializeServerReference(request, serverReference) {
|
1906
|
+
function serializeServerReference(request, parent, key, serverReference) {
|
1951
1907
|
var writtenServerReferences = request.writtenServerReferences;
|
1952
1908
|
var existingId = writtenServerReferences.get(serverReference);
|
1953
1909
|
|
@@ -2027,77 +1983,110 @@ function escapeStringValue(value) {
|
|
2027
1983
|
return value;
|
2028
1984
|
}
|
2029
1985
|
}
|
2030
|
-
|
2031
1986
|
var modelRoot = false;
|
2032
1987
|
|
2033
|
-
function
|
2034
|
-
|
2035
|
-
|
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];
|
2036
1993
|
|
2037
|
-
|
2038
|
-
|
2039
|
-
|
2040
|
-
|
2041
|
-
|
2042
|
-
|
2043
|
-
|
2044
|
-
|
2045
|
-
|
2046
|
-
|
1994
|
+
if (typeof originalValue === 'object' && originalValue !== value && !(originalValue instanceof Date)) {
|
1995
|
+
if (objectName(originalValue) !== 'Object') {
|
1996
|
+
var jsxParentType = jsxChildrenParents.get(parent);
|
1997
|
+
|
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
|
2047
2008
|
|
2048
|
-
var model = task.model;
|
2049
|
-
var wasReactNode = typeof model === 'object' && model !== null && (model.$$typeof === REACT_ELEMENT_TYPE || model.$$typeof === REACT_LAZY_TYPE);
|
2050
2009
|
|
2051
|
-
|
2052
|
-
|
2053
|
-
|
2054
|
-
|
2055
|
-
var newTask = createTask(request, task.model, task.keyPath, task.implicitSlot, request.abortableTasks);
|
2056
|
-
var ping = newTask.ping;
|
2057
|
-
x.then(ping, ping);
|
2058
|
-
newTask.thenableState = getThenableStateAfterSuspending(); // Restore the context. We assume that this will be restored by the inner
|
2059
|
-
// functions in case nothing throws so we don't use "finally" here.
|
2010
|
+
switch (value) {
|
2011
|
+
case REACT_ELEMENT_TYPE:
|
2012
|
+
return '$';
|
2013
|
+
}
|
2060
2014
|
|
2061
|
-
task.keyPath = prevKeyPath;
|
2062
|
-
task.implicitSlot = prevImplicitSlot;
|
2063
2015
|
|
2064
|
-
|
2065
|
-
|
2066
|
-
|
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.
|
2067
2044
|
|
2068
|
-
return serializeByValueID(newTask.id);
|
2069
|
-
}
|
2070
|
-
} // Restore the context. We assume that this will be restored by the inner
|
2071
|
-
// functions in case nothing throws so we don't use "finally" here.
|
2072
2045
|
|
2046
|
+
var element = value; // Attempt to render the Server Component.
|
2073
2047
|
|
2074
|
-
|
2075
|
-
|
2048
|
+
value = attemptResolveElement(request, element.type, element.key, element.ref, element.props, null);
|
2049
|
+
break;
|
2050
|
+
}
|
2076
2051
|
|
2077
|
-
|
2078
|
-
|
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.
|
2079
2080
|
// We'll replace this element with a lazy reference that throws on the client
|
2080
2081
|
// once it gets rendered.
|
2082
|
+
|
2083
|
+
|
2081
2084
|
request.pendingChunks++;
|
2082
2085
|
var errorId = request.nextChunkId++;
|
2083
2086
|
var digest = logRecoverableError(request, x);
|
2084
2087
|
emitErrorChunk(request, errorId, digest, x);
|
2085
2088
|
return serializeLazyID(errorId);
|
2086
|
-
}
|
2087
|
-
// it by value because it'll just error the whole parent row anyway so we can
|
2088
|
-
// just stop any siblings and error the whole parent row.
|
2089
|
-
|
2090
|
-
|
2091
|
-
throw x;
|
2092
|
-
}
|
2093
|
-
}
|
2094
|
-
|
2095
|
-
function renderModelDestructive(request, task, parent, parentPropertyName, value) {
|
2096
|
-
// Set the currently rendering model
|
2097
|
-
task.model = value; // Special Symbol, that's very common.
|
2098
|
-
|
2099
|
-
if (value === REACT_ELEMENT_TYPE) {
|
2100
|
-
return '$';
|
2089
|
+
}
|
2101
2090
|
}
|
2102
2091
|
|
2103
2092
|
if (value === null) {
|
@@ -2105,152 +2094,61 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
|
|
2105
2094
|
}
|
2106
2095
|
|
2107
2096
|
if (typeof value === 'object') {
|
2108
|
-
switch (value.$$typeof) {
|
2109
|
-
case REACT_ELEMENT_TYPE:
|
2110
|
-
{
|
2111
|
-
var _writtenObjects = request.writtenObjects;
|
2112
|
-
|
2113
|
-
var _existingId = _writtenObjects.get(value);
|
2114
|
-
|
2115
|
-
if (_existingId !== undefined) {
|
2116
|
-
if (modelRoot === value) {
|
2117
|
-
// This is the ID we're currently emitting so we need to write it
|
2118
|
-
// once but if we discover it again, we refer to it by id.
|
2119
|
-
modelRoot = null;
|
2120
|
-
} else if (_existingId === -1) {
|
2121
|
-
// Seen but not yet outlined.
|
2122
|
-
// TODO: If we throw here we can treat this as suspending which causes an outline
|
2123
|
-
// but that is able to reuse the same task if we're already in one but then that
|
2124
|
-
// will be a lazy future value rather than guaranteed to exist but maybe that's good.
|
2125
|
-
var newId = outlineModel(request, value);
|
2126
|
-
return serializeByValueID(newId);
|
2127
|
-
} else {
|
2128
|
-
// We've already emitted this as an outlined object, so we can refer to that by its
|
2129
|
-
// existing ID. TODO: We should use a lazy reference since, unlike plain objects,
|
2130
|
-
// elements might suspend so it might not have emitted yet even if we have the ID for
|
2131
|
-
// it. However, this creates an extra wrapper when it's not needed. We should really
|
2132
|
-
// detect whether this already was emitted and synchronously available. In that
|
2133
|
-
// case we can refer to it synchronously and only make it lazy otherwise.
|
2134
|
-
// We currently don't have a data structure that lets us see that though.
|
2135
|
-
return serializeByValueID(_existingId);
|
2136
|
-
}
|
2137
|
-
} else {
|
2138
|
-
// This is the first time we've seen this object. We may never see it again
|
2139
|
-
// so we'll inline it. Mark it as seen. If we see it again, we'll outline.
|
2140
|
-
_writtenObjects.set(value, -1);
|
2141
|
-
}
|
2142
|
-
|
2143
|
-
var element = value;
|
2144
|
-
|
2145
|
-
{
|
2146
|
-
var debugInfo = value._debugInfo;
|
2147
|
-
|
2148
|
-
if (debugInfo) {
|
2149
|
-
// If this came from Flight, forward any debug info into this new row.
|
2150
|
-
if (debugID === null) {
|
2151
|
-
// We don't have a chunk to assign debug info. We need to outline this
|
2152
|
-
// component to assign it an ID.
|
2153
|
-
return outlineTask(request, task);
|
2154
|
-
} else {
|
2155
|
-
// Forward any debug info we have the first time we see it.
|
2156
|
-
forwardDebugInfo(request, debugID, debugInfo);
|
2157
|
-
}
|
2158
|
-
}
|
2159
|
-
}
|
2160
|
-
|
2161
|
-
var props = element.props;
|
2162
|
-
var ref;
|
2163
|
-
|
2164
|
-
{
|
2165
|
-
ref = element.ref;
|
2166
|
-
} // Attempt to render the Server Component.
|
2167
|
-
|
2168
|
-
|
2169
|
-
return renderElement(request, task, element.type, // $FlowFixMe[incompatible-call] the key of an element is null | string
|
2170
|
-
element.key, ref, props);
|
2171
|
-
}
|
2172
|
-
|
2173
|
-
case REACT_LAZY_TYPE:
|
2174
|
-
{
|
2175
|
-
// Reset the task's thenable state before continuing. If there was one, it was
|
2176
|
-
// from suspending the lazy before.
|
2177
|
-
task.thenableState = null;
|
2178
|
-
var lazy = value;
|
2179
|
-
var payload = lazy._payload;
|
2180
|
-
var init = lazy._init;
|
2181
|
-
var resolvedModel = init(payload);
|
2182
|
-
|
2183
|
-
{
|
2184
|
-
var _debugInfo = lazy._debugInfo;
|
2185
|
-
|
2186
|
-
if (_debugInfo) {
|
2187
|
-
// If this came from Flight, forward any debug info into this new row.
|
2188
|
-
if (debugID === null) {
|
2189
|
-
// We don't have a chunk to assign debug info. We need to outline this
|
2190
|
-
// component to assign it an ID.
|
2191
|
-
return outlineTask(request, task);
|
2192
|
-
} else {
|
2193
|
-
// Forward any debug info we have the first time we see it.
|
2194
|
-
// We do this after init so that we have received all the debug info
|
2195
|
-
// from the server by the time we emit it.
|
2196
|
-
forwardDebugInfo(request, debugID, _debugInfo);
|
2197
|
-
}
|
2198
|
-
}
|
2199
|
-
}
|
2200
|
-
|
2201
|
-
return renderModelDestructive(request, task, emptyRoot, '', resolvedModel);
|
2202
|
-
}
|
2203
|
-
}
|
2204
2097
|
|
2205
2098
|
if (isClientReference(value)) {
|
2206
|
-
return serializeClientReference(request, parent,
|
2099
|
+
return serializeClientReference(request, parent, key, value);
|
2207
2100
|
}
|
2208
2101
|
|
2209
|
-
var
|
2210
|
-
|
2102
|
+
var _writtenObjects = request.writtenObjects;
|
2103
|
+
|
2104
|
+
var _existingId = _writtenObjects.get(value); // $FlowFixMe[method-unbinding]
|
2105
|
+
|
2211
2106
|
|
2212
2107
|
if (typeof value.then === 'function') {
|
2213
|
-
if (
|
2108
|
+
if (_existingId !== undefined) {
|
2214
2109
|
if (modelRoot === value) {
|
2215
2110
|
// This is the ID we're currently emitting so we need to write it
|
2216
2111
|
// once but if we discover it again, we refer to it by id.
|
2217
2112
|
modelRoot = null;
|
2218
2113
|
} else {
|
2219
2114
|
// We've seen this promise before, so we can just refer to the same result.
|
2220
|
-
return serializePromiseID(
|
2115
|
+
return serializePromiseID(_existingId);
|
2221
2116
|
}
|
2222
2117
|
} // We assume that any object with a .then property is a "Thenable" type,
|
2223
2118
|
// or a Promise type. Either of which can be represented by a Promise.
|
2224
2119
|
|
2225
2120
|
|
2226
|
-
var promiseId = serializeThenable(request,
|
2227
|
-
|
2121
|
+
var promiseId = serializeThenable(request, value);
|
2122
|
+
|
2123
|
+
_writtenObjects.set(value, promiseId);
|
2124
|
+
|
2228
2125
|
return serializePromiseID(promiseId);
|
2229
2126
|
}
|
2230
2127
|
|
2231
|
-
if (
|
2232
|
-
if (
|
2233
|
-
// This is the ID we're currently emitting so we need to write it
|
2234
|
-
// once but if we discover it again, we refer to it by id.
|
2235
|
-
modelRoot = null;
|
2236
|
-
} else if (existingId === -1) {
|
2128
|
+
if (_existingId !== undefined) {
|
2129
|
+
if (_existingId === -1) {
|
2237
2130
|
// Seen but not yet outlined.
|
2238
2131
|
var _newId = outlineModel(request, value);
|
2239
2132
|
|
2240
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;
|
2241
2138
|
} else {
|
2242
2139
|
// We've already emitted this as an outlined object, so we can
|
2243
2140
|
// just refer to that by its existing ID.
|
2244
|
-
return serializeByValueID(
|
2141
|
+
return serializeByValueID(_existingId);
|
2245
2142
|
}
|
2246
2143
|
} else {
|
2247
2144
|
// This is the first time we've seen this object. We may never see it again
|
2248
2145
|
// so we'll inline it. Mark it as seen. If we see it again, we'll outline.
|
2249
|
-
|
2146
|
+
_writtenObjects.set(value, -1);
|
2250
2147
|
}
|
2251
2148
|
|
2252
2149
|
if (isArray(value)) {
|
2253
|
-
return
|
2150
|
+
// $FlowFixMe[incompatible-return]
|
2151
|
+
return value;
|
2254
2152
|
}
|
2255
2153
|
|
2256
2154
|
if (value instanceof Map) {
|
@@ -2264,7 +2162,7 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
|
|
2264
2162
|
var iteratorFn = getIteratorFn(value);
|
2265
2163
|
|
2266
2164
|
if (iteratorFn) {
|
2267
|
-
return
|
2165
|
+
return Array.from(value);
|
2268
2166
|
} // Verify that this is a simple plain object.
|
2269
2167
|
|
2270
2168
|
|
@@ -2276,14 +2174,14 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
|
|
2276
2174
|
|
2277
2175
|
{
|
2278
2176
|
if (objectName(value) !== 'Object') {
|
2279
|
-
error('Only plain objects can be passed to Client Components from Server Components. ' + '%s objects are not supported.%s', objectName(value), describeObjectForErrorMessage(parent,
|
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));
|
2280
2178
|
} else if (!isSimpleObject(value)) {
|
2281
|
-
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,
|
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));
|
2282
2180
|
} else if (Object.getOwnPropertySymbols) {
|
2283
2181
|
var symbols = Object.getOwnPropertySymbols(value);
|
2284
2182
|
|
2285
2183
|
if (symbols.length > 0) {
|
2286
|
-
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,
|
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));
|
2287
2185
|
}
|
2288
2186
|
}
|
2289
2187
|
} // $FlowFixMe[incompatible-return]
|
@@ -2298,9 +2196,9 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
|
|
2298
2196
|
if (value[value.length - 1] === 'Z') {
|
2299
2197
|
// Possibly a Date, whose toJSON automatically calls toISOString
|
2300
2198
|
// $FlowFixMe[incompatible-use]
|
2301
|
-
var
|
2199
|
+
var _originalValue = parent[key];
|
2302
2200
|
|
2303
|
-
if (
|
2201
|
+
if (_originalValue instanceof Date) {
|
2304
2202
|
return serializeDateFromDateJSON(value);
|
2305
2203
|
}
|
2306
2204
|
}
|
@@ -2328,21 +2226,19 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
|
|
2328
2226
|
}
|
2329
2227
|
|
2330
2228
|
if (typeof value === 'function') {
|
2229
|
+
|
2331
2230
|
if (isClientReference(value)) {
|
2332
|
-
return serializeClientReference(request, parent,
|
2231
|
+
return serializeClientReference(request, parent, key, value);
|
2333
2232
|
}
|
2334
2233
|
|
2335
2234
|
if (isServerReference(value)) {
|
2336
|
-
return serializeServerReference(request, value);
|
2235
|
+
return serializeServerReference(request, parent, key, value);
|
2337
2236
|
}
|
2338
2237
|
|
2339
|
-
if (/^on[A-Z]/.test(
|
2340
|
-
throw new Error('Event handlers cannot be passed to Client Component props.' + describeObjectForErrorMessage(parent,
|
2341
|
-
} else if ((jsxChildrenParents.has(parent) || jsxPropsParents.has(parent) && parentPropertyName === 'children')) {
|
2342
|
-
var componentName = value.displayName || value.name || 'Component';
|
2343
|
-
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.');
|
2344
2240
|
} else {
|
2345
|
-
throw new Error('Functions cannot be passed directly to Client Components ' + 'unless you explicitly expose it by marking it with "use server".
|
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));
|
2346
2242
|
}
|
2347
2243
|
}
|
2348
2244
|
|
@@ -2360,7 +2256,7 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
|
|
2360
2256
|
|
2361
2257
|
if (Symbol.for(name) !== value) {
|
2362
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
|
2363
|
-
value.description + ") cannot be found among global symbols.") + describeObjectForErrorMessage(parent,
|
2259
|
+
value.description + ") cannot be found among global symbols.") + describeObjectForErrorMessage(parent, key));
|
2364
2260
|
}
|
2365
2261
|
|
2366
2262
|
request.pendingChunks++;
|
@@ -2375,38 +2271,17 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
|
|
2375
2271
|
return serializeBigInt(value);
|
2376
2272
|
}
|
2377
2273
|
|
2378
|
-
throw new Error("Type " + typeof value + " is not supported in Client Component props." + describeObjectForErrorMessage(parent,
|
2274
|
+
throw new Error("Type " + typeof value + " is not supported in Client Component props." + describeObjectForErrorMessage(parent, key));
|
2379
2275
|
}
|
2380
2276
|
|
2381
2277
|
function logPostpone(request, reason) {
|
2382
|
-
var
|
2383
|
-
|
2384
|
-
|
2385
|
-
try {
|
2386
|
-
var onPostpone = request.onPostpone;
|
2387
|
-
|
2388
|
-
if (supportsRequestStorage) ; else {
|
2389
|
-
onPostpone(reason);
|
2390
|
-
}
|
2391
|
-
} finally {
|
2392
|
-
currentRequest = prevRequest;
|
2393
|
-
}
|
2278
|
+
var onPostpone = request.onPostpone;
|
2279
|
+
onPostpone(reason);
|
2394
2280
|
}
|
2395
2281
|
|
2396
2282
|
function logRecoverableError(request, error) {
|
2397
|
-
var
|
2398
|
-
|
2399
|
-
var errorDigest;
|
2400
|
-
|
2401
|
-
try {
|
2402
|
-
var onError = request.onError;
|
2403
|
-
|
2404
|
-
if (supportsRequestStorage) ; else {
|
2405
|
-
errorDigest = onError(error);
|
2406
|
-
}
|
2407
|
-
} finally {
|
2408
|
-
currentRequest = prevRequest;
|
2409
|
-
}
|
2283
|
+
var onError = request.onError;
|
2284
|
+
var errorDigest = onError(error);
|
2410
2285
|
|
2411
2286
|
if (errorDigest != null && typeof errorDigest !== 'string') {
|
2412
2287
|
// eslint-disable-next-line react-internal/prod-error-codes
|
@@ -2465,11 +2340,8 @@ function emitErrorChunk(request, id, digest, error) {
|
|
2465
2340
|
message = String(error.message); // eslint-disable-next-line react-internal/safe-string-coercion
|
2466
2341
|
|
2467
2342
|
stack = String(error.stack);
|
2468
|
-
} else if (typeof error === 'object' && error !== null) {
|
2469
|
-
message = describeObjectForErrorMessage(error);
|
2470
2343
|
} else {
|
2471
|
-
|
2472
|
-
message = String(error);
|
2344
|
+
message = 'Error: ' + error;
|
2473
2345
|
}
|
2474
2346
|
} catch (x) {
|
2475
2347
|
message = 'An error occurred but serializing the error message failed.';
|
@@ -2509,79 +2381,62 @@ function emitSymbolChunk(request, id, name) {
|
|
2509
2381
|
request.completedImportChunks.push(processedChunk);
|
2510
2382
|
}
|
2511
2383
|
|
2512
|
-
function emitModelChunk(request, id,
|
2513
|
-
|
2514
|
-
|
2515
|
-
|
2516
|
-
|
2517
|
-
|
2518
|
-
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
|
2519
2389
|
|
2520
|
-
|
2521
|
-
var
|
2522
|
-
var row = serializeRowHeader('D', id) + json + '\n';
|
2390
|
+
var json = stringify(model, request.toJSON);
|
2391
|
+
var row = id.toString(16) + ':' + json + '\n';
|
2523
2392
|
var processedChunk = stringToChunk(row);
|
2524
2393
|
request.completedRegularChunks.push(processedChunk);
|
2525
2394
|
}
|
2526
2395
|
|
2527
|
-
function forwardDebugInfo(request, id, debugInfo) {
|
2528
|
-
for (var i = 0; i < debugInfo.length; i++) {
|
2529
|
-
request.pendingChunks++;
|
2530
|
-
emitDebugChunk(request, id, debugInfo[i]);
|
2531
|
-
}
|
2532
|
-
}
|
2533
|
-
|
2534
|
-
var emptyRoot = {};
|
2535
|
-
|
2536
2396
|
function retryTask(request, task) {
|
2537
2397
|
if (task.status !== PENDING$1) {
|
2538
2398
|
// We completed this by other means before we had a chance to retry it.
|
2539
2399
|
return;
|
2540
2400
|
}
|
2541
2401
|
|
2542
|
-
|
2402
|
+
switchContext(task.context);
|
2543
2403
|
|
2544
2404
|
try {
|
2545
|
-
|
2546
|
-
// already has an ID. This is needed because we might see this object twice
|
2547
|
-
// in the same toJSON if it is cyclic.
|
2548
|
-
modelRoot = task.model;
|
2405
|
+
var value = task.model;
|
2549
2406
|
|
2550
|
-
if (
|
2551
|
-
|
2552
|
-
debugID = task.id;
|
2553
|
-
} // We call the destructive form that mutates this task. That way if something
|
2554
|
-
// 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.
|
2555
2409
|
|
2410
|
+
var element = value; // When retrying a component, reuse the thenableState from the
|
2411
|
+
// previous attempt.
|
2556
2412
|
|
2557
|
-
|
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.
|
2558
2416
|
|
2559
|
-
|
2560
|
-
|
2561
|
-
//
|
2562
|
-
debugID = null;
|
2563
|
-
} // 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.
|
2564
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.
|
2565
2424
|
|
2566
|
-
|
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.
|
2567
2427
|
|
2568
|
-
|
2569
|
-
|
2570
|
-
|
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.
|
2571
2433
|
|
2572
|
-
|
2573
|
-
|
2574
|
-
|
2575
|
-
// $FlowFixMe[incompatible-type] stringify can return null for undefined but we never do
|
2576
|
-
json = stringify(resolvedModel, task.toJSON);
|
2577
|
-
} else {
|
2578
|
-
// If the value is a string, it means it's a terminal value and we already escaped it
|
2579
|
-
// We don't need to escape it again so it's not passed the toJSON replacer.
|
2580
|
-
// $FlowFixMe[incompatible-type] stringify can return null for undefined but we never do
|
2581
|
-
json = stringify(resolvedModel);
|
2434
|
+
|
2435
|
+
if (typeof value === 'object' && value !== null) {
|
2436
|
+
request.writtenObjects.set(value, task.id);
|
2582
2437
|
}
|
2583
2438
|
|
2584
|
-
emitModelChunk(request, task.id,
|
2439
|
+
emitModelChunk(request, task.id, value);
|
2585
2440
|
request.abortableTasks.delete(task);
|
2586
2441
|
task.status = COMPLETED;
|
2587
2442
|
} catch (thrownValue) {
|
@@ -2607,10 +2462,6 @@ function retryTask(request, task) {
|
|
2607
2462
|
task.status = ERRORED$1;
|
2608
2463
|
var digest = logRecoverableError(request, x);
|
2609
2464
|
emitErrorChunk(request, task.id, digest, x);
|
2610
|
-
} finally {
|
2611
|
-
{
|
2612
|
-
debugID = prevDebugID;
|
2613
|
-
}
|
2614
2465
|
}
|
2615
2466
|
}
|
2616
2467
|
|
@@ -2823,6 +2674,11 @@ function abort(request, reason) {
|
|
2823
2674
|
}
|
2824
2675
|
}
|
2825
2676
|
|
2677
|
+
function importServerContexts(contexts) {
|
2678
|
+
|
2679
|
+
return rootContextSnapshot;
|
2680
|
+
}
|
2681
|
+
|
2826
2682
|
// This is the parsed shape of the wire format which is why it is
|
2827
2683
|
// condensed to only the essentialy information
|
2828
2684
|
var ID = 0;
|
@@ -3545,7 +3401,7 @@ function decodeFormState(actionResult, body, serverManifest) {
|
|
3545
3401
|
}
|
3546
3402
|
|
3547
3403
|
function renderToReadableStream(model, webpackMap, options) {
|
3548
|
-
var request = createRequest(model, webpackMap, options ? options.onError : undefined, options ? options.
|
3404
|
+
var request = createRequest(model, webpackMap, options ? options.onError : undefined, options ? options.context : undefined, options ? options.identifierPrefix : undefined, options ? options.onPostpone : undefined);
|
3549
3405
|
|
3550
3406
|
if (options && options.signal) {
|
3551
3407
|
var signal = options.signal;
|