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) {
|
@@ -721,7 +698,7 @@ typeof async_hooks === 'object' ? async_hooks.executionAsyncId : null;
|
|
721
698
|
// The Symbol used to tag the ReactElement-like types.
|
722
699
|
var REACT_ELEMENT_TYPE = Symbol.for('react.element');
|
723
700
|
var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
|
724
|
-
var
|
701
|
+
var REACT_SERVER_CONTEXT_TYPE = Symbol.for('react.server_context');
|
725
702
|
var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');
|
726
703
|
var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');
|
727
704
|
var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');
|
@@ -745,6 +722,146 @@ function getIteratorFn(maybeIterable) {
|
|
745
722
|
return null;
|
746
723
|
}
|
747
724
|
|
725
|
+
// Forming a reverse tree.
|
726
|
+
// The structure of a context snapshot is an implementation of this file.
|
727
|
+
// Currently, it's implemented as tracking the current active node.
|
728
|
+
|
729
|
+
|
730
|
+
var rootContextSnapshot = null; // We assume that this runtime owns the "current" field on all ReactContext instances.
|
731
|
+
// This global (actually thread local) state represents what state all those "current",
|
732
|
+
// fields are currently in.
|
733
|
+
|
734
|
+
var currentActiveSnapshot = null;
|
735
|
+
|
736
|
+
function popNode(prev) {
|
737
|
+
{
|
738
|
+
prev.context._currentValue = prev.parentValue;
|
739
|
+
}
|
740
|
+
}
|
741
|
+
|
742
|
+
function pushNode(next) {
|
743
|
+
{
|
744
|
+
next.context._currentValue = next.value;
|
745
|
+
}
|
746
|
+
}
|
747
|
+
|
748
|
+
function popToNearestCommonAncestor(prev, next) {
|
749
|
+
if (prev === next) ; else {
|
750
|
+
popNode(prev);
|
751
|
+
var parentPrev = prev.parent;
|
752
|
+
var parentNext = next.parent;
|
753
|
+
|
754
|
+
if (parentPrev === null) {
|
755
|
+
if (parentNext !== null) {
|
756
|
+
throw new Error('The stacks must reach the root at the same time. This is a bug in React.');
|
757
|
+
}
|
758
|
+
} else {
|
759
|
+
if (parentNext === null) {
|
760
|
+
throw new Error('The stacks must reach the root at the same time. This is a bug in React.');
|
761
|
+
}
|
762
|
+
|
763
|
+
popToNearestCommonAncestor(parentPrev, parentNext); // On the way back, we push the new ones that weren't common.
|
764
|
+
|
765
|
+
pushNode(next);
|
766
|
+
}
|
767
|
+
}
|
768
|
+
}
|
769
|
+
|
770
|
+
function popAllPrevious(prev) {
|
771
|
+
popNode(prev);
|
772
|
+
var parentPrev = prev.parent;
|
773
|
+
|
774
|
+
if (parentPrev !== null) {
|
775
|
+
popAllPrevious(parentPrev);
|
776
|
+
}
|
777
|
+
}
|
778
|
+
|
779
|
+
function pushAllNext(next) {
|
780
|
+
var parentNext = next.parent;
|
781
|
+
|
782
|
+
if (parentNext !== null) {
|
783
|
+
pushAllNext(parentNext);
|
784
|
+
}
|
785
|
+
|
786
|
+
pushNode(next);
|
787
|
+
}
|
788
|
+
|
789
|
+
function popPreviousToCommonLevel(prev, next) {
|
790
|
+
popNode(prev);
|
791
|
+
var parentPrev = prev.parent;
|
792
|
+
|
793
|
+
if (parentPrev === null) {
|
794
|
+
throw new Error('The depth must equal at least at zero before reaching the root. This is a bug in React.');
|
795
|
+
}
|
796
|
+
|
797
|
+
if (parentPrev.depth === next.depth) {
|
798
|
+
// We found the same level. Now we just need to find a shared ancestor.
|
799
|
+
popToNearestCommonAncestor(parentPrev, next);
|
800
|
+
} else {
|
801
|
+
// We must still be deeper.
|
802
|
+
popPreviousToCommonLevel(parentPrev, next);
|
803
|
+
}
|
804
|
+
}
|
805
|
+
|
806
|
+
function popNextToCommonLevel(prev, next) {
|
807
|
+
var parentNext = next.parent;
|
808
|
+
|
809
|
+
if (parentNext === null) {
|
810
|
+
throw new Error('The depth must equal at least at zero before reaching the root. This is a bug in React.');
|
811
|
+
}
|
812
|
+
|
813
|
+
if (prev.depth === parentNext.depth) {
|
814
|
+
// We found the same level. Now we just need to find a shared ancestor.
|
815
|
+
popToNearestCommonAncestor(prev, parentNext);
|
816
|
+
} else {
|
817
|
+
// We must still be deeper.
|
818
|
+
popNextToCommonLevel(prev, parentNext);
|
819
|
+
}
|
820
|
+
|
821
|
+
pushNode(next);
|
822
|
+
} // Perform context switching to the new snapshot.
|
823
|
+
// To make it cheap to read many contexts, while not suspending, we make the switch eagerly by
|
824
|
+
// updating all the context's current values. That way reads, always just read the current value.
|
825
|
+
// At the cost of updating contexts even if they're never read by this subtree.
|
826
|
+
|
827
|
+
|
828
|
+
function switchContext(newSnapshot) {
|
829
|
+
// The basic algorithm we need to do is to pop back any contexts that are no longer on the stack.
|
830
|
+
// We also need to update any new contexts that are now on the stack with the deepest value.
|
831
|
+
// The easiest way to update new contexts is to just reapply them in reverse order from the
|
832
|
+
// perspective of the backpointers. To avoid allocating a lot when switching, we use the stack
|
833
|
+
// for that. Therefore this algorithm is recursive.
|
834
|
+
// 1) First we pop which ever snapshot tree was deepest. Popping old contexts as we go.
|
835
|
+
// 2) Then we find the nearest common ancestor from there. Popping old contexts as we go.
|
836
|
+
// 3) Then we reapply new contexts on the way back up the stack.
|
837
|
+
var prev = currentActiveSnapshot;
|
838
|
+
var next = newSnapshot;
|
839
|
+
|
840
|
+
if (prev !== next) {
|
841
|
+
if (prev === null) {
|
842
|
+
// $FlowFixMe[incompatible-call]: This has to be non-null since it's not equal to prev.
|
843
|
+
pushAllNext(next);
|
844
|
+
} else if (next === null) {
|
845
|
+
popAllPrevious(prev);
|
846
|
+
} else if (prev.depth === next.depth) {
|
847
|
+
popToNearestCommonAncestor(prev, next);
|
848
|
+
} else if (prev.depth > next.depth) {
|
849
|
+
popPreviousToCommonLevel(prev, next);
|
850
|
+
} else {
|
851
|
+
popNextToCommonLevel(prev, next);
|
852
|
+
}
|
853
|
+
|
854
|
+
currentActiveSnapshot = next;
|
855
|
+
}
|
856
|
+
}
|
857
|
+
function getActiveContext() {
|
858
|
+
return currentActiveSnapshot;
|
859
|
+
}
|
860
|
+
function readContext$1(context) {
|
861
|
+
var value = context._currentValue ;
|
862
|
+
return value;
|
863
|
+
}
|
864
|
+
|
748
865
|
// Corresponds to ReactFiberWakeable and ReactFizzWakeable modules. Generally,
|
749
866
|
// changes to one module should be reflected in the others.
|
750
867
|
// TODO: Rename this module and the corresponding Fiber one to "Thenable"
|
@@ -873,13 +990,29 @@ function prepareToUseHooksForComponent(prevThenableState) {
|
|
873
990
|
thenableState = prevThenableState;
|
874
991
|
}
|
875
992
|
function getThenableStateAfterSuspending() {
|
876
|
-
|
877
|
-
// which is not really supported anymore, it will be empty. We use the empty set as a
|
878
|
-
// marker to know if this was a replay of the same component or first attempt.
|
879
|
-
var state = thenableState || createThenableState();
|
993
|
+
var state = thenableState;
|
880
994
|
thenableState = null;
|
881
995
|
return state;
|
882
996
|
}
|
997
|
+
|
998
|
+
function readContext(context) {
|
999
|
+
{
|
1000
|
+
if (context.$$typeof !== REACT_SERVER_CONTEXT_TYPE) {
|
1001
|
+
if (isClientReference(context)) {
|
1002
|
+
error('Cannot read a Client Context from a Server Component.');
|
1003
|
+
} else {
|
1004
|
+
error('Only createServerContext is supported in Server Components.');
|
1005
|
+
}
|
1006
|
+
}
|
1007
|
+
|
1008
|
+
if (currentRequest$1 === null) {
|
1009
|
+
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().');
|
1010
|
+
}
|
1011
|
+
}
|
1012
|
+
|
1013
|
+
return readContext$1(context);
|
1014
|
+
}
|
1015
|
+
|
883
1016
|
var HooksDispatcher = {
|
884
1017
|
useMemo: function (nextCreate) {
|
885
1018
|
return nextCreate();
|
@@ -890,8 +1023,8 @@ var HooksDispatcher = {
|
|
890
1023
|
useDebugValue: function () {},
|
891
1024
|
useDeferredValue: unsupportedHook,
|
892
1025
|
useTransition: unsupportedHook,
|
893
|
-
readContext:
|
894
|
-
useContext:
|
1026
|
+
readContext: readContext,
|
1027
|
+
useContext: readContext,
|
895
1028
|
useReducer: unsupportedHook,
|
896
1029
|
useRef: unsupportedHook,
|
897
1030
|
useState: unsupportedHook,
|
@@ -924,10 +1057,6 @@ function unsupportedRefresh() {
|
|
924
1057
|
throw new Error('Refreshing the cache is not supported in Server Components.');
|
925
1058
|
}
|
926
1059
|
|
927
|
-
function unsupportedContext() {
|
928
|
-
throw new Error('Cannot read a Client Context from a Server Component.');
|
929
|
-
}
|
930
|
-
|
931
1060
|
function useId() {
|
932
1061
|
if (currentRequest$1 === null) {
|
933
1062
|
throw new Error('useId can only be used while React is rendering');
|
@@ -953,22 +1082,20 @@ function use(usable) {
|
|
953
1082
|
}
|
954
1083
|
|
955
1084
|
return trackUsedThenable(thenableState, thenable, index);
|
956
|
-
} else if (usable.$$typeof ===
|
957
|
-
|
1085
|
+
} else if (usable.$$typeof === REACT_SERVER_CONTEXT_TYPE) {
|
1086
|
+
var context = usable;
|
1087
|
+
return readContext(context);
|
958
1088
|
}
|
959
1089
|
}
|
960
1090
|
|
961
|
-
|
962
|
-
if (usable
|
963
|
-
|
964
|
-
throw new Error('Cannot read a Client Context from a Server Component.');
|
965
|
-
} else {
|
966
|
-
throw new Error('Cannot use() an already resolved Client Reference.');
|
1091
|
+
{
|
1092
|
+
if (isClientReference(usable)) {
|
1093
|
+
error('Cannot use() an already resolved Client Reference.');
|
967
1094
|
}
|
968
|
-
}
|
969
|
-
|
970
|
-
|
971
|
-
|
1095
|
+
} // eslint-disable-next-line react-internal/safe-string-coercion
|
1096
|
+
|
1097
|
+
|
1098
|
+
throw new Error('An unsupported type was passed to use(): ' + String(usable));
|
972
1099
|
}
|
973
1100
|
|
974
1101
|
function createSignal() {
|
@@ -1106,10 +1233,6 @@ function describeValueForErrorMessage(value) {
|
|
1106
1233
|
return '[...]';
|
1107
1234
|
}
|
1108
1235
|
|
1109
|
-
if (value !== null && value.$$typeof === CLIENT_REFERENCE_TAG) {
|
1110
|
-
return describeClientReference();
|
1111
|
-
}
|
1112
|
-
|
1113
1236
|
var name = objectName(value);
|
1114
1237
|
|
1115
1238
|
if (name === 'Object') {
|
@@ -1120,15 +1243,7 @@ function describeValueForErrorMessage(value) {
|
|
1120
1243
|
}
|
1121
1244
|
|
1122
1245
|
case 'function':
|
1123
|
-
|
1124
|
-
if (value.$$typeof === CLIENT_REFERENCE_TAG) {
|
1125
|
-
return describeClientReference();
|
1126
|
-
}
|
1127
|
-
|
1128
|
-
var _name = value.displayName || value.name;
|
1129
|
-
|
1130
|
-
return _name ? 'function ' + _name : 'function';
|
1131
|
-
}
|
1246
|
+
return 'function';
|
1132
1247
|
|
1133
1248
|
default:
|
1134
1249
|
// eslint-disable-next-line react-internal/safe-string-coercion
|
@@ -1174,12 +1289,6 @@ function describeElementType(type) {
|
|
1174
1289
|
return '';
|
1175
1290
|
}
|
1176
1291
|
|
1177
|
-
var CLIENT_REFERENCE_TAG = Symbol.for('react.client.reference');
|
1178
|
-
|
1179
|
-
function describeClientReference(ref) {
|
1180
|
-
return 'client';
|
1181
|
-
}
|
1182
|
-
|
1183
1292
|
function describeObjectForErrorMessage(objectOrArray, expandedName) {
|
1184
1293
|
var objKind = objectName(objectOrArray);
|
1185
1294
|
|
@@ -1258,8 +1367,6 @@ function describeObjectForErrorMessage(objectOrArray, expandedName) {
|
|
1258
1367
|
} else {
|
1259
1368
|
if (objectOrArray.$$typeof === REACT_ELEMENT_TYPE) {
|
1260
1369
|
str = '<' + describeElementType(objectOrArray.type) + '/>';
|
1261
|
-
} else if (objectOrArray.$$typeof === CLIENT_REFERENCE_TAG) {
|
1262
|
-
return describeClientReference();
|
1263
1370
|
} else if (jsxPropsParents.has(objectOrArray)) {
|
1264
1371
|
// Print JSX
|
1265
1372
|
var _type = jsxPropsParents.get(objectOrArray);
|
@@ -1310,9 +1417,9 @@ function describeObjectForErrorMessage(objectOrArray, expandedName) {
|
|
1310
1417
|
str += ', ';
|
1311
1418
|
}
|
1312
1419
|
|
1313
|
-
var
|
1314
|
-
str += describeKeyForErrorMessage(
|
1315
|
-
var _value3 = _object[
|
1420
|
+
var _name = _names[_i3];
|
1421
|
+
str += describeKeyForErrorMessage(_name) + ': ';
|
1422
|
+
var _value3 = _object[_name];
|
1316
1423
|
|
1317
1424
|
var _substr3 = void 0;
|
1318
1425
|
|
@@ -1322,7 +1429,7 @@ function describeObjectForErrorMessage(objectOrArray, expandedName) {
|
|
1322
1429
|
_substr3 = describeValueForErrorMessage(_value3);
|
1323
1430
|
}
|
1324
1431
|
|
1325
|
-
if (
|
1432
|
+
if (_name === expandedName) {
|
1326
1433
|
start = str.length;
|
1327
1434
|
length = _substr3.length;
|
1328
1435
|
str += _substr3;
|
@@ -1377,7 +1484,7 @@ function defaultPostponeHandler(reason) {// Noop
|
|
1377
1484
|
var OPEN = 0;
|
1378
1485
|
var CLOSING = 1;
|
1379
1486
|
var CLOSED = 2;
|
1380
|
-
function createRequest(model, bundlerConfig, onError, identifierPrefix, onPostpone
|
1487
|
+
function createRequest(model, bundlerConfig, onError, context, identifierPrefix, onPostpone) {
|
1381
1488
|
if (ReactCurrentCache.current !== null && ReactCurrentCache.current !== DefaultCacheDispatcher) {
|
1382
1489
|
throw new Error('Currently React only supports one RSC renderer at a time.');
|
1383
1490
|
}
|
@@ -1408,19 +1515,21 @@ function createRequest(model, bundlerConfig, onError, identifierPrefix, onPostpo
|
|
1408
1515
|
writtenSymbols: new Map(),
|
1409
1516
|
writtenClientReferences: new Map(),
|
1410
1517
|
writtenServerReferences: new Map(),
|
1518
|
+
writtenProviders: new Map(),
|
1411
1519
|
writtenObjects: new WeakMap(),
|
1412
1520
|
identifierPrefix: identifierPrefix || '',
|
1413
1521
|
identifierCount: 1,
|
1414
1522
|
taintCleanupQueue: cleanupQueue,
|
1415
1523
|
onError: onError === undefined ? defaultErrorHandler : onError,
|
1416
|
-
onPostpone: onPostpone === undefined ? defaultPostponeHandler : onPostpone
|
1524
|
+
onPostpone: onPostpone === undefined ? defaultPostponeHandler : onPostpone,
|
1525
|
+
// $FlowFixMe[missing-this-annot]
|
1526
|
+
toJSON: function (key, value) {
|
1527
|
+
return resolveModelToJSON(request, this, key, value);
|
1528
|
+
}
|
1417
1529
|
};
|
1418
|
-
|
1419
|
-
|
1420
|
-
|
1421
|
-
}
|
1422
|
-
|
1423
|
-
var rootTask = createTask(request, model, null, false, abortSet);
|
1530
|
+
request.pendingChunks++;
|
1531
|
+
var rootContext = createRootContext();
|
1532
|
+
var rootTask = createTask(request, model, rootContext, abortSet);
|
1424
1533
|
pingedTasks.push(rootTask);
|
1425
1534
|
return request;
|
1426
1535
|
}
|
@@ -1436,18 +1545,13 @@ function resolveRequest() {
|
|
1436
1545
|
return null;
|
1437
1546
|
}
|
1438
1547
|
|
1439
|
-
function
|
1440
|
-
|
1441
|
-
|
1442
|
-
|
1443
|
-
{
|
1444
|
-
// If this came from Flight, forward any debug info into this new row.
|
1445
|
-
var debugInfo = thenable._debugInfo;
|
1548
|
+
function createRootContext(reqContext) {
|
1549
|
+
return importServerContexts();
|
1550
|
+
}
|
1446
1551
|
|
1447
|
-
|
1448
|
-
|
1449
|
-
|
1450
|
-
}
|
1552
|
+
function serializeThenable(request, thenable) {
|
1553
|
+
request.pendingChunks++;
|
1554
|
+
var newTask = createTask(request, null, getActiveContext(), request.abortableTasks);
|
1451
1555
|
|
1452
1556
|
switch (thenable.status) {
|
1453
1557
|
case 'fulfilled':
|
@@ -1583,136 +1687,14 @@ function createLazyWrapperAroundWakeable(wakeable) {
|
|
1583
1687
|
_payload: thenable,
|
1584
1688
|
_init: readThenable
|
1585
1689
|
};
|
1586
|
-
|
1587
|
-
{
|
1588
|
-
// If this came from React, transfer the debug info.
|
1589
|
-
lazyType._debugInfo = thenable._debugInfo || [];
|
1590
|
-
}
|
1591
|
-
|
1592
1690
|
return lazyType;
|
1593
1691
|
}
|
1594
1692
|
|
1595
|
-
function
|
1596
|
-
// Reset the task's thenable state before continuing, so that if a later
|
1597
|
-
// component suspends we can reuse the same task object. If the same
|
1598
|
-
// component suspends again, the thenable state will be restored.
|
1599
|
-
var prevThenableState = task.thenableState;
|
1600
|
-
task.thenableState = null;
|
1601
|
-
|
1602
|
-
{
|
1603
|
-
if (debugID === null) {
|
1604
|
-
// We don't have a chunk to assign debug info. We need to outline this
|
1605
|
-
// component to assign it an ID.
|
1606
|
-
return outlineTask(request, task);
|
1607
|
-
} else if (prevThenableState !== null) ; else {
|
1608
|
-
// This is a new component in the same task so we can emit more debug info.
|
1609
|
-
var componentName = Component.displayName || Component.name || '';
|
1610
|
-
request.pendingChunks++;
|
1611
|
-
emitDebugChunk(request, debugID, {
|
1612
|
-
name: componentName,
|
1613
|
-
env: request.environmentName
|
1614
|
-
});
|
1615
|
-
}
|
1616
|
-
}
|
1617
|
-
|
1618
|
-
prepareToUseHooksForComponent(prevThenableState); // The secondArg is always undefined in Server Components since refs error early.
|
1619
|
-
|
1620
|
-
var secondArg = undefined;
|
1621
|
-
var result = Component(props, secondArg);
|
1622
|
-
|
1623
|
-
if (typeof result === 'object' && result !== null && typeof result.then === 'function') {
|
1624
|
-
// When the return value is in children position we can resolve it immediately,
|
1625
|
-
// to its value without a wrapper if it's synchronously available.
|
1626
|
-
var thenable = result;
|
1627
|
-
|
1628
|
-
if (thenable.status === 'fulfilled') {
|
1629
|
-
return thenable.value;
|
1630
|
-
} // TODO: Once we accept Promises as children on the client, we can just return
|
1631
|
-
// the thenable here.
|
1632
|
-
|
1633
|
-
|
1634
|
-
result = createLazyWrapperAroundWakeable(result);
|
1635
|
-
} // Track this element's key on the Server Component on the keyPath context..
|
1636
|
-
|
1637
|
-
|
1638
|
-
var prevKeyPath = task.keyPath;
|
1639
|
-
var prevImplicitSlot = task.implicitSlot;
|
1640
|
-
|
1641
|
-
if (key !== null) {
|
1642
|
-
// Append the key to the path. Technically a null key should really add the child
|
1643
|
-
// index. We don't do that to hold the payload small and implementation simple.
|
1644
|
-
task.keyPath = prevKeyPath === null ? key : prevKeyPath + ',' + key;
|
1645
|
-
} else if (prevKeyPath === null) {
|
1646
|
-
// This sequence of Server Components has no keys. This means that it was rendered
|
1647
|
-
// in a slot that needs to assign an implicit key. Even if children below have
|
1648
|
-
// explicit keys, they should not be used for the outer most key since it might
|
1649
|
-
// collide with other slots in that set.
|
1650
|
-
task.implicitSlot = true;
|
1651
|
-
}
|
1652
|
-
|
1653
|
-
var json = renderModelDestructive(request, task, emptyRoot, '', result);
|
1654
|
-
task.keyPath = prevKeyPath;
|
1655
|
-
task.implicitSlot = prevImplicitSlot;
|
1656
|
-
return json;
|
1657
|
-
}
|
1658
|
-
|
1659
|
-
function renderFragment(request, task, children) {
|
1660
|
-
{
|
1661
|
-
var debugInfo = children._debugInfo;
|
1662
|
-
|
1663
|
-
if (debugInfo) {
|
1664
|
-
// If this came from Flight, forward any debug info into this new row.
|
1665
|
-
if (debugID === null) {
|
1666
|
-
// We don't have a chunk to assign debug info. We need to outline this
|
1667
|
-
// component to assign it an ID.
|
1668
|
-
return outlineTask(request, task);
|
1669
|
-
} else {
|
1670
|
-
// Forward any debug info we have the first time we see it.
|
1671
|
-
// We do this after init so that we have received all the debug info
|
1672
|
-
// from the server by the time we emit it.
|
1673
|
-
forwardDebugInfo(request, debugID, debugInfo);
|
1674
|
-
}
|
1675
|
-
}
|
1676
|
-
}
|
1677
|
-
|
1678
|
-
{
|
1679
|
-
return children;
|
1680
|
-
}
|
1681
|
-
}
|
1682
|
-
|
1683
|
-
function renderClientElement(task, type, key, props) {
|
1684
|
-
{
|
1685
|
-
return [REACT_ELEMENT_TYPE, type, key, props];
|
1686
|
-
} // We prepend the terminal client element that actually gets serialized with
|
1687
|
-
} // The chunk ID we're currently rendering that we can assign debug data to.
|
1688
|
-
|
1689
|
-
|
1690
|
-
var debugID = null;
|
1691
|
-
|
1692
|
-
function outlineTask(request, task) {
|
1693
|
-
var newTask = createTask(request, task.model, // the currently rendering element
|
1694
|
-
task.keyPath, // unlike outlineModel this one carries along context
|
1695
|
-
task.implicitSlot, request.abortableTasks);
|
1696
|
-
retryTask(request, newTask);
|
1697
|
-
|
1698
|
-
if (newTask.status === COMPLETED) {
|
1699
|
-
// We completed synchronously so we can refer to this by reference. This
|
1700
|
-
// makes it behaves the same as prod during deserialization.
|
1701
|
-
return serializeByValueID(newTask.id);
|
1702
|
-
} // This didn't complete synchronously so it wouldn't have even if we didn't
|
1703
|
-
// outline it, so this would reduce to a lazy reference even in prod.
|
1704
|
-
|
1705
|
-
|
1706
|
-
return serializeLazyID(newTask.id);
|
1707
|
-
}
|
1708
|
-
|
1709
|
-
function renderElement(request, task, type, key, ref, props) {
|
1693
|
+
function attemptResolveElement(request, type, key, ref, props, prevThenableState) {
|
1710
1694
|
if (ref !== null && ref !== undefined) {
|
1711
1695
|
// When the ref moves to the regular props object this will implicitly
|
1712
1696
|
// throw for functions. We could probably relax it to a DEV warning for other
|
1713
1697
|
// cases.
|
1714
|
-
// TODO: `ref` is now just a prop when `enableRefAsProp` is on. Should we
|
1715
|
-
// do what the above comment says?
|
1716
1698
|
throw new Error('Refs cannot be used in Server Components, nor passed to Client Components.');
|
1717
1699
|
}
|
1718
1700
|
|
@@ -1727,36 +1709,47 @@ function renderElement(request, task, type, key, ref, props) {
|
|
1727
1709
|
if (typeof type === 'function') {
|
1728
1710
|
if (isClientReference(type)) {
|
1729
1711
|
// This is a reference to a Client Component.
|
1730
|
-
return
|
1731
|
-
} // This is a
|
1712
|
+
return [REACT_ELEMENT_TYPE, type, key, props];
|
1713
|
+
} // This is a server-side component.
|
1714
|
+
|
1715
|
+
|
1716
|
+
prepareToUseHooksForComponent(prevThenableState);
|
1717
|
+
var result = type(props);
|
1718
|
+
|
1719
|
+
if (typeof result === 'object' && result !== null && typeof result.then === 'function') {
|
1720
|
+
// When the return value is in children position we can resolve it immediately,
|
1721
|
+
// to its value without a wrapper if it's synchronously available.
|
1722
|
+
var thenable = result;
|
1732
1723
|
|
1724
|
+
if (thenable.status === 'fulfilled') {
|
1725
|
+
return thenable.value;
|
1726
|
+
} // TODO: Once we accept Promises as children on the client, we can just return
|
1727
|
+
// the thenable here.
|
1733
1728
|
|
1734
|
-
|
1729
|
+
|
1730
|
+
return createLazyWrapperAroundWakeable(result);
|
1731
|
+
}
|
1732
|
+
|
1733
|
+
return result;
|
1735
1734
|
} else if (typeof type === 'string') {
|
1736
1735
|
// This is a host element. E.g. HTML.
|
1737
|
-
return
|
1736
|
+
return [REACT_ELEMENT_TYPE, type, key, props];
|
1738
1737
|
} else if (typeof type === 'symbol') {
|
1739
|
-
if (type === REACT_FRAGMENT_TYPE
|
1738
|
+
if (type === REACT_FRAGMENT_TYPE) {
|
1740
1739
|
// For key-less fragments, we add a small optimization to avoid serializing
|
1741
1740
|
// it as a wrapper.
|
1742
|
-
|
1743
|
-
|
1744
|
-
|
1745
|
-
task.implicitSlot = true;
|
1746
|
-
}
|
1747
|
-
|
1748
|
-
var json = renderModelDestructive(request, task, emptyRoot, '', props.children);
|
1749
|
-
task.implicitSlot = prevImplicitSlot;
|
1750
|
-
return json;
|
1741
|
+
// TODO: If a key is specified, we should propagate its key to any children.
|
1742
|
+
// Same as if a Server Component has a key.
|
1743
|
+
return props.children;
|
1751
1744
|
} // This might be a built-in React component. We'll let the client decide.
|
1752
1745
|
// Any built-in works as long as its props are serializable.
|
1753
1746
|
|
1754
1747
|
|
1755
|
-
return
|
1748
|
+
return [REACT_ELEMENT_TYPE, type, key, props];
|
1756
1749
|
} else if (type != null && typeof type === 'object') {
|
1757
1750
|
if (isClientReference(type)) {
|
1758
1751
|
// This is a reference to a Client Component.
|
1759
|
-
return
|
1752
|
+
return [REACT_ELEMENT_TYPE, type, key, props];
|
1760
1753
|
}
|
1761
1754
|
|
1762
1755
|
switch (type.$$typeof) {
|
@@ -1765,17 +1758,19 @@ function renderElement(request, task, type, key, ref, props) {
|
|
1765
1758
|
var payload = type._payload;
|
1766
1759
|
var init = type._init;
|
1767
1760
|
var wrappedType = init(payload);
|
1768
|
-
return
|
1761
|
+
return attemptResolveElement(request, wrappedType, key, ref, props, prevThenableState);
|
1769
1762
|
}
|
1770
1763
|
|
1771
1764
|
case REACT_FORWARD_REF_TYPE:
|
1772
1765
|
{
|
1773
|
-
|
1766
|
+
var render = type.render;
|
1767
|
+
prepareToUseHooksForComponent(prevThenableState);
|
1768
|
+
return render(props, undefined);
|
1774
1769
|
}
|
1775
1770
|
|
1776
1771
|
case REACT_MEMO_TYPE:
|
1777
1772
|
{
|
1778
|
-
return
|
1773
|
+
return attemptResolveElement(request, type.type, key, ref, props, prevThenableState);
|
1779
1774
|
}
|
1780
1775
|
}
|
1781
1776
|
}
|
@@ -1795,51 +1790,16 @@ function pingTask(request, task) {
|
|
1795
1790
|
}
|
1796
1791
|
}
|
1797
1792
|
|
1798
|
-
function createTask(request, model,
|
1799
|
-
request.pendingChunks++;
|
1793
|
+
function createTask(request, model, context, abortSet) {
|
1800
1794
|
var id = request.nextChunkId++;
|
1801
|
-
|
1802
|
-
if (typeof model === 'object' && model !== null) {
|
1803
|
-
// If we're about to write this into a new task we can assign it an ID early so that
|
1804
|
-
// any other references can refer to the value we're about to write.
|
1805
|
-
{
|
1806
|
-
request.writtenObjects.set(model, id);
|
1807
|
-
}
|
1808
|
-
}
|
1809
|
-
|
1810
1795
|
var task = {
|
1811
1796
|
id: id,
|
1812
1797
|
status: PENDING$1,
|
1813
1798
|
model: model,
|
1814
|
-
|
1815
|
-
implicitSlot: implicitSlot,
|
1799
|
+
context: context,
|
1816
1800
|
ping: function () {
|
1817
1801
|
return pingTask(request, task);
|
1818
1802
|
},
|
1819
|
-
toJSON: function (parentPropertyName, value) {
|
1820
|
-
var parent = this; // Make sure that `parent[parentPropertyName]` wasn't JSONified before `value` was passed to us
|
1821
|
-
|
1822
|
-
{
|
1823
|
-
// $FlowFixMe[incompatible-use]
|
1824
|
-
var originalValue = parent[parentPropertyName];
|
1825
|
-
|
1826
|
-
if (typeof originalValue === 'object' && originalValue !== value && !(originalValue instanceof Date)) {
|
1827
|
-
if (objectName(originalValue) !== 'Object') {
|
1828
|
-
var jsxParentType = jsxChildrenParents.get(parent);
|
1829
|
-
|
1830
|
-
if (typeof jsxParentType === 'string') {
|
1831
|
-
error('%s objects cannot be rendered as text children. Try formatting it using toString().%s', objectName(originalValue), describeObjectForErrorMessage(parent, parentPropertyName));
|
1832
|
-
} else {
|
1833
|
-
error('Only plain objects can be passed to Client Components from Server Components. ' + '%s objects are not supported.%s', objectName(originalValue), describeObjectForErrorMessage(parent, parentPropertyName));
|
1834
|
-
}
|
1835
|
-
} else {
|
1836
|
-
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));
|
1837
|
-
}
|
1838
|
-
}
|
1839
|
-
}
|
1840
|
-
|
1841
|
-
return renderModel(request, task, parent, parentPropertyName, value);
|
1842
|
-
},
|
1843
1803
|
thenableState: null
|
1844
1804
|
};
|
1845
1805
|
abortSet.add(task);
|
@@ -1908,13 +1868,13 @@ function encodeReferenceChunk(request, id, reference) {
|
|
1908
1868
|
return stringToChunk(row);
|
1909
1869
|
}
|
1910
1870
|
|
1911
|
-
function serializeClientReference(request, parent,
|
1871
|
+
function serializeClientReference(request, parent, key, clientReference) {
|
1912
1872
|
var clientReferenceKey = getClientReferenceKey(clientReference);
|
1913
1873
|
var writtenClientReferences = request.writtenClientReferences;
|
1914
1874
|
var existingId = writtenClientReferences.get(clientReferenceKey);
|
1915
1875
|
|
1916
1876
|
if (existingId !== undefined) {
|
1917
|
-
if (parent[0] === REACT_ELEMENT_TYPE &&
|
1877
|
+
if (parent[0] === REACT_ELEMENT_TYPE && key === '1') {
|
1918
1878
|
// If we're encoding the "type" of an element, we can refer
|
1919
1879
|
// to that by a lazy reference instead of directly since React
|
1920
1880
|
// knows how to deal with lazy values. This lets us suspend
|
@@ -1933,7 +1893,7 @@ function serializeClientReference(request, parent, parentPropertyName, clientRef
|
|
1933
1893
|
emitImportChunk(request, importId, clientReferenceMetadata);
|
1934
1894
|
writtenClientReferences.set(clientReferenceKey, importId);
|
1935
1895
|
|
1936
|
-
if (parent[0] === REACT_ELEMENT_TYPE &&
|
1896
|
+
if (parent[0] === REACT_ELEMENT_TYPE && key === '1') {
|
1937
1897
|
// If we're encoding the "type" of an element, we can refer
|
1938
1898
|
// to that by a lazy reference instead of directly since React
|
1939
1899
|
// knows how to deal with lazy values. This lets us suspend
|
@@ -1953,14 +1913,13 @@ function serializeClientReference(request, parent, parentPropertyName, clientRef
|
|
1953
1913
|
}
|
1954
1914
|
|
1955
1915
|
function outlineModel(request, value) {
|
1956
|
-
|
1957
|
-
|
1958
|
-
request.abortableTasks);
|
1916
|
+
request.pendingChunks++;
|
1917
|
+
var newTask = createTask(request, value, getActiveContext(), request.abortableTasks);
|
1959
1918
|
retryTask(request, newTask);
|
1960
1919
|
return newTask.id;
|
1961
1920
|
}
|
1962
1921
|
|
1963
|
-
function serializeServerReference(request, serverReference) {
|
1922
|
+
function serializeServerReference(request, parent, key, serverReference) {
|
1964
1923
|
var writtenServerReferences = request.writtenServerReferences;
|
1965
1924
|
var existingId = writtenServerReferences.get(serverReference);
|
1966
1925
|
|
@@ -2040,77 +1999,110 @@ function escapeStringValue(value) {
|
|
2040
1999
|
return value;
|
2041
2000
|
}
|
2042
2001
|
}
|
2043
|
-
|
2044
2002
|
var modelRoot = false;
|
2045
2003
|
|
2046
|
-
function
|
2047
|
-
|
2048
|
-
|
2004
|
+
function resolveModelToJSON(request, parent, key, value) {
|
2005
|
+
// Make sure that `parent[key]` wasn't JSONified before `value` was passed to us
|
2006
|
+
{
|
2007
|
+
// $FlowFixMe[incompatible-use]
|
2008
|
+
var originalValue = parent[key];
|
2049
2009
|
|
2050
|
-
|
2051
|
-
|
2052
|
-
|
2053
|
-
var x = thrownValue === SuspenseException ? // This is a special type of exception used for Suspense. For historical
|
2054
|
-
// reasons, the rest of the Suspense implementation expects the thrown
|
2055
|
-
// value to be a thenable, because before `use` existed that was the
|
2056
|
-
// (unstable) API for suspending. This implementation detail can change
|
2057
|
-
// later, once we deprecate the old API in favor of `use`.
|
2058
|
-
getSuspendedThenable() : thrownValue; // If the suspended/errored value was an element or lazy it can be reduced
|
2059
|
-
// to a lazy reference, so that it doesn't error the parent.
|
2010
|
+
if (typeof originalValue === 'object' && originalValue !== value && !(originalValue instanceof Date)) {
|
2011
|
+
if (objectName(originalValue) !== 'Object') {
|
2012
|
+
var jsxParentType = jsxChildrenParents.get(parent);
|
2060
2013
|
|
2061
|
-
|
2062
|
-
|
2014
|
+
if (typeof jsxParentType === 'string') {
|
2015
|
+
error('%s objects cannot be rendered as text children. Try formatting it using toString().%s', objectName(originalValue), describeObjectForErrorMessage(parent, key));
|
2016
|
+
} else {
|
2017
|
+
error('Only plain objects can be passed to Client Components from Server Components. ' + '%s objects are not supported.%s', objectName(originalValue), describeObjectForErrorMessage(parent, key));
|
2018
|
+
}
|
2019
|
+
} else {
|
2020
|
+
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));
|
2021
|
+
}
|
2022
|
+
}
|
2023
|
+
} // Special Symbols
|
2063
2024
|
|
2064
|
-
if (typeof x === 'object' && x !== null) {
|
2065
|
-
// $FlowFixMe[method-unbinding]
|
2066
|
-
if (typeof x.then === 'function') {
|
2067
|
-
// Something suspended, we'll need to create a new task and resolve it later.
|
2068
|
-
var newTask = createTask(request, task.model, task.keyPath, task.implicitSlot, request.abortableTasks);
|
2069
|
-
var ping = newTask.ping;
|
2070
|
-
x.then(ping, ping);
|
2071
|
-
newTask.thenableState = getThenableStateAfterSuspending(); // Restore the context. We assume that this will be restored by the inner
|
2072
|
-
// functions in case nothing throws so we don't use "finally" here.
|
2073
2025
|
|
2074
|
-
|
2075
|
-
|
2026
|
+
switch (value) {
|
2027
|
+
case REACT_ELEMENT_TYPE:
|
2028
|
+
return '$';
|
2029
|
+
}
|
2076
2030
|
|
2077
|
-
if (wasReactNode) {
|
2078
|
-
return serializeLazyID(newTask.id);
|
2079
|
-
}
|
2080
2031
|
|
2081
|
-
|
2082
|
-
}
|
2083
|
-
} // Restore the context. We assume that this will be restored by the inner
|
2084
|
-
// functions in case nothing throws so we don't use "finally" here.
|
2032
|
+
while (typeof value === 'object' && value !== null && (value.$$typeof === REACT_ELEMENT_TYPE || value.$$typeof === REACT_LAZY_TYPE)) {
|
2085
2033
|
|
2034
|
+
try {
|
2035
|
+
switch (value.$$typeof) {
|
2036
|
+
case REACT_ELEMENT_TYPE:
|
2037
|
+
{
|
2038
|
+
var writtenObjects = request.writtenObjects;
|
2039
|
+
var existingId = writtenObjects.get(value);
|
2040
|
+
|
2041
|
+
if (existingId !== undefined) {
|
2042
|
+
if (existingId === -1) {
|
2043
|
+
// Seen but not yet outlined.
|
2044
|
+
var newId = outlineModel(request, value);
|
2045
|
+
return serializeByValueID(newId);
|
2046
|
+
} else if (modelRoot === value) {
|
2047
|
+
// This is the ID we're currently emitting so we need to write it
|
2048
|
+
// once but if we discover it again, we refer to it by id.
|
2049
|
+
modelRoot = null;
|
2050
|
+
} else {
|
2051
|
+
// We've already emitted this as an outlined object, so we can
|
2052
|
+
// just refer to that by its existing ID.
|
2053
|
+
return serializeByValueID(existingId);
|
2054
|
+
}
|
2055
|
+
} else {
|
2056
|
+
// This is the first time we've seen this object. We may never see it again
|
2057
|
+
// so we'll inline it. Mark it as seen. If we see it again, we'll outline.
|
2058
|
+
writtenObjects.set(value, -1);
|
2059
|
+
} // TODO: Concatenate keys of parents onto children.
|
2086
2060
|
|
2087
|
-
task.keyPath = prevKeyPath;
|
2088
|
-
task.implicitSlot = prevImplicitSlot;
|
2089
2061
|
|
2090
|
-
|
2091
|
-
|
2062
|
+
var element = value; // Attempt to render the Server Component.
|
2063
|
+
|
2064
|
+
value = attemptResolveElement(request, element.type, element.key, element.ref, element.props, null);
|
2065
|
+
break;
|
2066
|
+
}
|
2067
|
+
|
2068
|
+
case REACT_LAZY_TYPE:
|
2069
|
+
{
|
2070
|
+
var payload = value._payload;
|
2071
|
+
var init = value._init;
|
2072
|
+
value = init(payload);
|
2073
|
+
break;
|
2074
|
+
}
|
2075
|
+
}
|
2076
|
+
} catch (thrownValue) {
|
2077
|
+
var x = thrownValue === SuspenseException ? // This is a special type of exception used for Suspense. For historical
|
2078
|
+
// reasons, the rest of the Suspense implementation expects the thrown
|
2079
|
+
// value to be a thenable, because before `use` existed that was the
|
2080
|
+
// (unstable) API for suspending. This implementation detail can change
|
2081
|
+
// later, once we deprecate the old API in favor of `use`.
|
2082
|
+
getSuspendedThenable() : thrownValue;
|
2083
|
+
|
2084
|
+
if (typeof x === 'object' && x !== null) {
|
2085
|
+
// $FlowFixMe[method-unbinding]
|
2086
|
+
if (typeof x.then === 'function') {
|
2087
|
+
// Something suspended, we'll need to create a new task and resolve it later.
|
2088
|
+
request.pendingChunks++;
|
2089
|
+
var newTask = createTask(request, value, getActiveContext(), request.abortableTasks);
|
2090
|
+
var ping = newTask.ping;
|
2091
|
+
x.then(ping, ping);
|
2092
|
+
newTask.thenableState = getThenableStateAfterSuspending();
|
2093
|
+
return serializeLazyID(newTask.id);
|
2094
|
+
}
|
2095
|
+
} // Something errored. We'll still send everything we have up until this point.
|
2092
2096
|
// We'll replace this element with a lazy reference that throws on the client
|
2093
2097
|
// once it gets rendered.
|
2098
|
+
|
2099
|
+
|
2094
2100
|
request.pendingChunks++;
|
2095
2101
|
var errorId = request.nextChunkId++;
|
2096
2102
|
var digest = logRecoverableError(request, x);
|
2097
2103
|
emitErrorChunk(request, errorId, digest, x);
|
2098
2104
|
return serializeLazyID(errorId);
|
2099
|
-
}
|
2100
|
-
// it by value because it'll just error the whole parent row anyway so we can
|
2101
|
-
// just stop any siblings and error the whole parent row.
|
2102
|
-
|
2103
|
-
|
2104
|
-
throw x;
|
2105
|
-
}
|
2106
|
-
}
|
2107
|
-
|
2108
|
-
function renderModelDestructive(request, task, parent, parentPropertyName, value) {
|
2109
|
-
// Set the currently rendering model
|
2110
|
-
task.model = value; // Special Symbol, that's very common.
|
2111
|
-
|
2112
|
-
if (value === REACT_ELEMENT_TYPE) {
|
2113
|
-
return '$';
|
2105
|
+
}
|
2114
2106
|
}
|
2115
2107
|
|
2116
2108
|
if (value === null) {
|
@@ -2118,152 +2110,61 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
|
|
2118
2110
|
}
|
2119
2111
|
|
2120
2112
|
if (typeof value === 'object') {
|
2121
|
-
switch (value.$$typeof) {
|
2122
|
-
case REACT_ELEMENT_TYPE:
|
2123
|
-
{
|
2124
|
-
var _writtenObjects = request.writtenObjects;
|
2125
|
-
|
2126
|
-
var _existingId = _writtenObjects.get(value);
|
2127
|
-
|
2128
|
-
if (_existingId !== undefined) {
|
2129
|
-
if (modelRoot === value) {
|
2130
|
-
// This is the ID we're currently emitting so we need to write it
|
2131
|
-
// once but if we discover it again, we refer to it by id.
|
2132
|
-
modelRoot = null;
|
2133
|
-
} else if (_existingId === -1) {
|
2134
|
-
// Seen but not yet outlined.
|
2135
|
-
// TODO: If we throw here we can treat this as suspending which causes an outline
|
2136
|
-
// but that is able to reuse the same task if we're already in one but then that
|
2137
|
-
// will be a lazy future value rather than guaranteed to exist but maybe that's good.
|
2138
|
-
var newId = outlineModel(request, value);
|
2139
|
-
return serializeByValueID(newId);
|
2140
|
-
} else {
|
2141
|
-
// We've already emitted this as an outlined object, so we can refer to that by its
|
2142
|
-
// existing ID. TODO: We should use a lazy reference since, unlike plain objects,
|
2143
|
-
// elements might suspend so it might not have emitted yet even if we have the ID for
|
2144
|
-
// it. However, this creates an extra wrapper when it's not needed. We should really
|
2145
|
-
// detect whether this already was emitted and synchronously available. In that
|
2146
|
-
// case we can refer to it synchronously and only make it lazy otherwise.
|
2147
|
-
// We currently don't have a data structure that lets us see that though.
|
2148
|
-
return serializeByValueID(_existingId);
|
2149
|
-
}
|
2150
|
-
} else {
|
2151
|
-
// This is the first time we've seen this object. We may never see it again
|
2152
|
-
// so we'll inline it. Mark it as seen. If we see it again, we'll outline.
|
2153
|
-
_writtenObjects.set(value, -1);
|
2154
|
-
}
|
2155
|
-
|
2156
|
-
var element = value;
|
2157
|
-
|
2158
|
-
{
|
2159
|
-
var debugInfo = value._debugInfo;
|
2160
|
-
|
2161
|
-
if (debugInfo) {
|
2162
|
-
// If this came from Flight, forward any debug info into this new row.
|
2163
|
-
if (debugID === null) {
|
2164
|
-
// We don't have a chunk to assign debug info. We need to outline this
|
2165
|
-
// component to assign it an ID.
|
2166
|
-
return outlineTask(request, task);
|
2167
|
-
} else {
|
2168
|
-
// Forward any debug info we have the first time we see it.
|
2169
|
-
forwardDebugInfo(request, debugID, debugInfo);
|
2170
|
-
}
|
2171
|
-
}
|
2172
|
-
}
|
2173
|
-
|
2174
|
-
var props = element.props;
|
2175
|
-
var ref;
|
2176
|
-
|
2177
|
-
{
|
2178
|
-
ref = element.ref;
|
2179
|
-
} // Attempt to render the Server Component.
|
2180
|
-
|
2181
|
-
|
2182
|
-
return renderElement(request, task, element.type, // $FlowFixMe[incompatible-call] the key of an element is null | string
|
2183
|
-
element.key, ref, props);
|
2184
|
-
}
|
2185
|
-
|
2186
|
-
case REACT_LAZY_TYPE:
|
2187
|
-
{
|
2188
|
-
// Reset the task's thenable state before continuing. If there was one, it was
|
2189
|
-
// from suspending the lazy before.
|
2190
|
-
task.thenableState = null;
|
2191
|
-
var lazy = value;
|
2192
|
-
var payload = lazy._payload;
|
2193
|
-
var init = lazy._init;
|
2194
|
-
var resolvedModel = init(payload);
|
2195
|
-
|
2196
|
-
{
|
2197
|
-
var _debugInfo = lazy._debugInfo;
|
2198
|
-
|
2199
|
-
if (_debugInfo) {
|
2200
|
-
// If this came from Flight, forward any debug info into this new row.
|
2201
|
-
if (debugID === null) {
|
2202
|
-
// We don't have a chunk to assign debug info. We need to outline this
|
2203
|
-
// component to assign it an ID.
|
2204
|
-
return outlineTask(request, task);
|
2205
|
-
} else {
|
2206
|
-
// Forward any debug info we have the first time we see it.
|
2207
|
-
// We do this after init so that we have received all the debug info
|
2208
|
-
// from the server by the time we emit it.
|
2209
|
-
forwardDebugInfo(request, debugID, _debugInfo);
|
2210
|
-
}
|
2211
|
-
}
|
2212
|
-
}
|
2213
|
-
|
2214
|
-
return renderModelDestructive(request, task, emptyRoot, '', resolvedModel);
|
2215
|
-
}
|
2216
|
-
}
|
2217
2113
|
|
2218
2114
|
if (isClientReference(value)) {
|
2219
|
-
return serializeClientReference(request, parent,
|
2115
|
+
return serializeClientReference(request, parent, key, value);
|
2220
2116
|
}
|
2221
2117
|
|
2222
|
-
var
|
2223
|
-
|
2118
|
+
var _writtenObjects = request.writtenObjects;
|
2119
|
+
|
2120
|
+
var _existingId = _writtenObjects.get(value); // $FlowFixMe[method-unbinding]
|
2121
|
+
|
2224
2122
|
|
2225
2123
|
if (typeof value.then === 'function') {
|
2226
|
-
if (
|
2124
|
+
if (_existingId !== undefined) {
|
2227
2125
|
if (modelRoot === value) {
|
2228
2126
|
// This is the ID we're currently emitting so we need to write it
|
2229
2127
|
// once but if we discover it again, we refer to it by id.
|
2230
2128
|
modelRoot = null;
|
2231
2129
|
} else {
|
2232
2130
|
// We've seen this promise before, so we can just refer to the same result.
|
2233
|
-
return serializePromiseID(
|
2131
|
+
return serializePromiseID(_existingId);
|
2234
2132
|
}
|
2235
2133
|
} // We assume that any object with a .then property is a "Thenable" type,
|
2236
2134
|
// or a Promise type. Either of which can be represented by a Promise.
|
2237
2135
|
|
2238
2136
|
|
2239
|
-
var promiseId = serializeThenable(request,
|
2240
|
-
|
2137
|
+
var promiseId = serializeThenable(request, value);
|
2138
|
+
|
2139
|
+
_writtenObjects.set(value, promiseId);
|
2140
|
+
|
2241
2141
|
return serializePromiseID(promiseId);
|
2242
2142
|
}
|
2243
2143
|
|
2244
|
-
if (
|
2245
|
-
if (
|
2246
|
-
// This is the ID we're currently emitting so we need to write it
|
2247
|
-
// once but if we discover it again, we refer to it by id.
|
2248
|
-
modelRoot = null;
|
2249
|
-
} else if (existingId === -1) {
|
2144
|
+
if (_existingId !== undefined) {
|
2145
|
+
if (_existingId === -1) {
|
2250
2146
|
// Seen but not yet outlined.
|
2251
2147
|
var _newId = outlineModel(request, value);
|
2252
2148
|
|
2253
2149
|
return serializeByValueID(_newId);
|
2150
|
+
} else if (modelRoot === value) {
|
2151
|
+
// This is the ID we're currently emitting so we need to write it
|
2152
|
+
// once but if we discover it again, we refer to it by id.
|
2153
|
+
modelRoot = null;
|
2254
2154
|
} else {
|
2255
2155
|
// We've already emitted this as an outlined object, so we can
|
2256
2156
|
// just refer to that by its existing ID.
|
2257
|
-
return serializeByValueID(
|
2157
|
+
return serializeByValueID(_existingId);
|
2258
2158
|
}
|
2259
2159
|
} else {
|
2260
2160
|
// This is the first time we've seen this object. We may never see it again
|
2261
2161
|
// so we'll inline it. Mark it as seen. If we see it again, we'll outline.
|
2262
|
-
|
2162
|
+
_writtenObjects.set(value, -1);
|
2263
2163
|
}
|
2264
2164
|
|
2265
2165
|
if (isArray(value)) {
|
2266
|
-
return
|
2166
|
+
// $FlowFixMe[incompatible-return]
|
2167
|
+
return value;
|
2267
2168
|
}
|
2268
2169
|
|
2269
2170
|
if (value instanceof Map) {
|
@@ -2277,7 +2178,7 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
|
|
2277
2178
|
var iteratorFn = getIteratorFn(value);
|
2278
2179
|
|
2279
2180
|
if (iteratorFn) {
|
2280
|
-
return
|
2181
|
+
return Array.from(value);
|
2281
2182
|
} // Verify that this is a simple plain object.
|
2282
2183
|
|
2283
2184
|
|
@@ -2289,14 +2190,14 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
|
|
2289
2190
|
|
2290
2191
|
{
|
2291
2192
|
if (objectName(value) !== 'Object') {
|
2292
|
-
error('Only plain objects can be passed to Client Components from Server Components. ' + '%s objects are not supported.%s', objectName(value), describeObjectForErrorMessage(parent,
|
2193
|
+
error('Only plain objects can be passed to Client Components from Server Components. ' + '%s objects are not supported.%s', objectName(value), describeObjectForErrorMessage(parent, key));
|
2293
2194
|
} else if (!isSimpleObject(value)) {
|
2294
|
-
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,
|
2195
|
+
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));
|
2295
2196
|
} else if (Object.getOwnPropertySymbols) {
|
2296
2197
|
var symbols = Object.getOwnPropertySymbols(value);
|
2297
2198
|
|
2298
2199
|
if (symbols.length > 0) {
|
2299
|
-
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,
|
2200
|
+
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));
|
2300
2201
|
}
|
2301
2202
|
}
|
2302
2203
|
} // $FlowFixMe[incompatible-return]
|
@@ -2311,9 +2212,9 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
|
|
2311
2212
|
if (value[value.length - 1] === 'Z') {
|
2312
2213
|
// Possibly a Date, whose toJSON automatically calls toISOString
|
2313
2214
|
// $FlowFixMe[incompatible-use]
|
2314
|
-
var
|
2215
|
+
var _originalValue = parent[key];
|
2315
2216
|
|
2316
|
-
if (
|
2217
|
+
if (_originalValue instanceof Date) {
|
2317
2218
|
return serializeDateFromDateJSON(value);
|
2318
2219
|
}
|
2319
2220
|
}
|
@@ -2341,21 +2242,19 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
|
|
2341
2242
|
}
|
2342
2243
|
|
2343
2244
|
if (typeof value === 'function') {
|
2245
|
+
|
2344
2246
|
if (isClientReference(value)) {
|
2345
|
-
return serializeClientReference(request, parent,
|
2247
|
+
return serializeClientReference(request, parent, key, value);
|
2346
2248
|
}
|
2347
2249
|
|
2348
2250
|
if (isServerReference(value)) {
|
2349
|
-
return serializeServerReference(request, value);
|
2251
|
+
return serializeServerReference(request, parent, key, value);
|
2350
2252
|
}
|
2351
2253
|
|
2352
|
-
if (/^on[A-Z]/.test(
|
2353
|
-
throw new Error('Event handlers cannot be passed to Client Component props.' + describeObjectForErrorMessage(parent,
|
2354
|
-
} else if ((jsxChildrenParents.has(parent) || jsxPropsParents.has(parent) && parentPropertyName === 'children')) {
|
2355
|
-
var componentName = value.displayName || value.name || 'Component';
|
2356
|
-
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));
|
2254
|
+
if (/^on[A-Z]/.test(key)) {
|
2255
|
+
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.');
|
2357
2256
|
} else {
|
2358
|
-
throw new Error('Functions cannot be passed directly to Client Components ' + 'unless you explicitly expose it by marking it with "use server".
|
2257
|
+
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));
|
2359
2258
|
}
|
2360
2259
|
}
|
2361
2260
|
|
@@ -2373,7 +2272,7 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
|
|
2373
2272
|
|
2374
2273
|
if (Symbol.for(name) !== value) {
|
2375
2274
|
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
|
2376
|
-
value.description + ") cannot be found among global symbols.") + describeObjectForErrorMessage(parent,
|
2275
|
+
value.description + ") cannot be found among global symbols.") + describeObjectForErrorMessage(parent, key));
|
2377
2276
|
}
|
2378
2277
|
|
2379
2278
|
request.pendingChunks++;
|
@@ -2388,44 +2287,17 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
|
|
2388
2287
|
return serializeBigInt(value);
|
2389
2288
|
}
|
2390
2289
|
|
2391
|
-
throw new Error("Type " + typeof value + " is not supported in Client Component props." + describeObjectForErrorMessage(parent,
|
2290
|
+
throw new Error("Type " + typeof value + " is not supported in Client Component props." + describeObjectForErrorMessage(parent, key));
|
2392
2291
|
}
|
2393
2292
|
|
2394
2293
|
function logPostpone(request, reason) {
|
2395
|
-
var
|
2396
|
-
|
2397
|
-
|
2398
|
-
try {
|
2399
|
-
var onPostpone = request.onPostpone;
|
2400
|
-
|
2401
|
-
if (supportsRequestStorage) {
|
2402
|
-
// Exit the request context while running callbacks.
|
2403
|
-
requestStorage.run(undefined, onPostpone, reason);
|
2404
|
-
} else {
|
2405
|
-
onPostpone(reason);
|
2406
|
-
}
|
2407
|
-
} finally {
|
2408
|
-
currentRequest = prevRequest;
|
2409
|
-
}
|
2294
|
+
var onPostpone = request.onPostpone;
|
2295
|
+
onPostpone(reason);
|
2410
2296
|
}
|
2411
2297
|
|
2412
2298
|
function logRecoverableError(request, error) {
|
2413
|
-
var
|
2414
|
-
|
2415
|
-
var errorDigest;
|
2416
|
-
|
2417
|
-
try {
|
2418
|
-
var onError = request.onError;
|
2419
|
-
|
2420
|
-
if (supportsRequestStorage) {
|
2421
|
-
// Exit the request context while running callbacks.
|
2422
|
-
errorDigest = requestStorage.run(undefined, onError, error);
|
2423
|
-
} else {
|
2424
|
-
errorDigest = onError(error);
|
2425
|
-
}
|
2426
|
-
} finally {
|
2427
|
-
currentRequest = prevRequest;
|
2428
|
-
}
|
2299
|
+
var onError = request.onError;
|
2300
|
+
var errorDigest = onError(error);
|
2429
2301
|
|
2430
2302
|
if (errorDigest != null && typeof errorDigest !== 'string') {
|
2431
2303
|
// eslint-disable-next-line react-internal/prod-error-codes
|
@@ -2484,11 +2356,8 @@ function emitErrorChunk(request, id, digest, error) {
|
|
2484
2356
|
message = String(error.message); // eslint-disable-next-line react-internal/safe-string-coercion
|
2485
2357
|
|
2486
2358
|
stack = String(error.stack);
|
2487
|
-
} else if (typeof error === 'object' && error !== null) {
|
2488
|
-
message = describeObjectForErrorMessage(error);
|
2489
2359
|
} else {
|
2490
|
-
|
2491
|
-
message = String(error);
|
2360
|
+
message = 'Error: ' + error;
|
2492
2361
|
}
|
2493
2362
|
} catch (x) {
|
2494
2363
|
message = 'An error occurred but serializing the error message failed.';
|
@@ -2528,79 +2397,62 @@ function emitSymbolChunk(request, id, name) {
|
|
2528
2397
|
request.completedImportChunks.push(processedChunk);
|
2529
2398
|
}
|
2530
2399
|
|
2531
|
-
function emitModelChunk(request, id,
|
2532
|
-
|
2533
|
-
|
2534
|
-
|
2535
|
-
|
2536
|
-
|
2537
|
-
function emitDebugChunk(request, id, debugInfo) {
|
2400
|
+
function emitModelChunk(request, id, model) {
|
2401
|
+
// Track the root so we know that we have to emit this object even though it
|
2402
|
+
// already has an ID. This is needed because we might see this object twice
|
2403
|
+
// in the same toJSON if it is cyclic.
|
2404
|
+
modelRoot = model; // $FlowFixMe[incompatible-type] stringify can return null
|
2538
2405
|
|
2539
|
-
|
2540
|
-
var
|
2541
|
-
var row = serializeRowHeader('D', id) + json + '\n';
|
2406
|
+
var json = stringify(model, request.toJSON);
|
2407
|
+
var row = id.toString(16) + ':' + json + '\n';
|
2542
2408
|
var processedChunk = stringToChunk(row);
|
2543
2409
|
request.completedRegularChunks.push(processedChunk);
|
2544
2410
|
}
|
2545
2411
|
|
2546
|
-
function forwardDebugInfo(request, id, debugInfo) {
|
2547
|
-
for (var i = 0; i < debugInfo.length; i++) {
|
2548
|
-
request.pendingChunks++;
|
2549
|
-
emitDebugChunk(request, id, debugInfo[i]);
|
2550
|
-
}
|
2551
|
-
}
|
2552
|
-
|
2553
|
-
var emptyRoot = {};
|
2554
|
-
|
2555
2412
|
function retryTask(request, task) {
|
2556
2413
|
if (task.status !== PENDING$1) {
|
2557
2414
|
// We completed this by other means before we had a chance to retry it.
|
2558
2415
|
return;
|
2559
2416
|
}
|
2560
2417
|
|
2561
|
-
|
2418
|
+
switchContext(task.context);
|
2562
2419
|
|
2563
2420
|
try {
|
2564
|
-
|
2565
|
-
// already has an ID. This is needed because we might see this object twice
|
2566
|
-
// in the same toJSON if it is cyclic.
|
2567
|
-
modelRoot = task.model;
|
2421
|
+
var value = task.model;
|
2568
2422
|
|
2569
|
-
if (
|
2570
|
-
|
2571
|
-
debugID = task.id;
|
2572
|
-
} // We call the destructive form that mutates this task. That way if something
|
2573
|
-
// suspends again, we can reuse the same task instead of spawning a new one.
|
2423
|
+
if (typeof value === 'object' && value !== null && value.$$typeof === REACT_ELEMENT_TYPE) {
|
2424
|
+
request.writtenObjects.set(value, task.id); // TODO: Concatenate keys of parents onto children.
|
2574
2425
|
|
2426
|
+
var element = value; // When retrying a component, reuse the thenableState from the
|
2427
|
+
// previous attempt.
|
2575
2428
|
|
2576
|
-
|
2429
|
+
var prevThenableState = task.thenableState; // Attempt to render the Server Component.
|
2430
|
+
// Doing this here lets us reuse this same task if the next component
|
2431
|
+
// also suspends.
|
2577
2432
|
|
2578
|
-
|
2579
|
-
|
2580
|
-
//
|
2581
|
-
debugID = null;
|
2582
|
-
} // Track the root again for the resolved object.
|
2433
|
+
task.model = value;
|
2434
|
+
value = attemptResolveElement(request, element.type, element.key, element.ref, element.props, prevThenableState); // Successfully finished this component. We're going to keep rendering
|
2435
|
+
// using the same task, but we reset its thenable state before continuing.
|
2583
2436
|
|
2437
|
+
task.thenableState = null; // Keep rendering and reuse the same task. This inner loop is separate
|
2438
|
+
// from the render above because we don't need to reset the thenable state
|
2439
|
+
// until the next time something suspends and retries.
|
2584
2440
|
|
2585
|
-
|
2441
|
+
while (typeof value === 'object' && value !== null && value.$$typeof === REACT_ELEMENT_TYPE) {
|
2442
|
+
request.writtenObjects.set(value, task.id); // TODO: Concatenate keys of parents onto children.
|
2586
2443
|
|
2587
|
-
|
2588
|
-
|
2589
|
-
|
2444
|
+
var nextElement = value;
|
2445
|
+
task.model = value;
|
2446
|
+
value = attemptResolveElement(request, nextElement.type, nextElement.key, nextElement.ref, nextElement.props, null);
|
2447
|
+
}
|
2448
|
+
} // Track that this object is outlined and has an id.
|
2590
2449
|
|
2591
|
-
|
2592
|
-
|
2593
|
-
|
2594
|
-
// $FlowFixMe[incompatible-type] stringify can return null for undefined but we never do
|
2595
|
-
json = stringify(resolvedModel, task.toJSON);
|
2596
|
-
} else {
|
2597
|
-
// If the value is a string, it means it's a terminal value and we already escaped it
|
2598
|
-
// We don't need to escape it again so it's not passed the toJSON replacer.
|
2599
|
-
// $FlowFixMe[incompatible-type] stringify can return null for undefined but we never do
|
2600
|
-
json = stringify(resolvedModel);
|
2450
|
+
|
2451
|
+
if (typeof value === 'object' && value !== null) {
|
2452
|
+
request.writtenObjects.set(value, task.id);
|
2601
2453
|
}
|
2602
2454
|
|
2603
|
-
emitModelChunk(request, task.id,
|
2455
|
+
emitModelChunk(request, task.id, value);
|
2604
2456
|
request.abortableTasks.delete(task);
|
2605
2457
|
task.status = COMPLETED;
|
2606
2458
|
} catch (thrownValue) {
|
@@ -2626,10 +2478,6 @@ function retryTask(request, task) {
|
|
2626
2478
|
task.status = ERRORED$1;
|
2627
2479
|
var digest = logRecoverableError(request, x);
|
2628
2480
|
emitErrorChunk(request, task.id, digest, x);
|
2629
|
-
} finally {
|
2630
|
-
{
|
2631
|
-
debugID = prevDebugID;
|
2632
|
-
}
|
2633
2481
|
}
|
2634
2482
|
}
|
2635
2483
|
|
@@ -2846,6 +2694,11 @@ function abort(request, reason) {
|
|
2846
2694
|
}
|
2847
2695
|
}
|
2848
2696
|
|
2697
|
+
function importServerContexts(contexts) {
|
2698
|
+
|
2699
|
+
return rootContextSnapshot;
|
2700
|
+
}
|
2701
|
+
|
2849
2702
|
// This is the parsed shape of the wire format which is why it is
|
2850
2703
|
// condensed to only the essentialy information
|
2851
2704
|
var ID = 0;
|
@@ -3549,7 +3402,7 @@ function decodeFormState(actionResult, body, serverManifest) {
|
|
3549
3402
|
}
|
3550
3403
|
|
3551
3404
|
function renderToReadableStream(model, webpackMap, options) {
|
3552
|
-
var request = createRequest(model, webpackMap, options ? options.onError : undefined, options ? options.
|
3405
|
+
var request = createRequest(model, webpackMap, options ? options.onError : undefined, options ? options.context : undefined, options ? options.identifierPrefix : undefined, options ? options.onPostpone : undefined);
|
3553
3406
|
|
3554
3407
|
if (options && options.signal) {
|
3555
3408
|
var signal = options.signal;
|