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
@@ -219,10 +219,10 @@ function closeWithError(destination, error) {
|
|
219
219
|
}
|
220
220
|
|
221
221
|
// eslint-disable-next-line no-unused-vars
|
222
|
-
var CLIENT_REFERENCE_TAG
|
222
|
+
var CLIENT_REFERENCE_TAG = Symbol.for('react.client.reference');
|
223
223
|
var SERVER_REFERENCE_TAG = Symbol.for('react.server.reference');
|
224
224
|
function isClientReference(reference) {
|
225
|
-
return reference.$$typeof === CLIENT_REFERENCE_TAG
|
225
|
+
return reference.$$typeof === CLIENT_REFERENCE_TAG;
|
226
226
|
}
|
227
227
|
function isServerReference(reference) {
|
228
228
|
return reference.$$typeof === SERVER_REFERENCE_TAG;
|
@@ -234,7 +234,7 @@ function registerClientReference(proxyImplementation, id, exportName) {
|
|
234
234
|
function registerClientReferenceImpl(proxyImplementation, id, async) {
|
235
235
|
return Object.defineProperties(proxyImplementation, {
|
236
236
|
$$typeof: {
|
237
|
-
value: CLIENT_REFERENCE_TAG
|
237
|
+
value: CLIENT_REFERENCE_TAG
|
238
238
|
},
|
239
239
|
$$id: {
|
240
240
|
value: id
|
@@ -255,14 +255,6 @@ function bind() {
|
|
255
255
|
var newFn = FunctionBind.apply(this, arguments);
|
256
256
|
|
257
257
|
if (this.$$typeof === SERVER_REFERENCE_TAG) {
|
258
|
-
{
|
259
|
-
var thisBind = arguments[0];
|
260
|
-
|
261
|
-
if (thisBind != null) {
|
262
|
-
error('Cannot bind "this" of a Server Action. Pass null or undefined as the first argument to .bind().');
|
263
|
-
}
|
264
|
-
}
|
265
|
-
|
266
258
|
var args = ArraySlice.call(arguments, 1);
|
267
259
|
return Object.defineProperties(newFn, {
|
268
260
|
$$typeof: {
|
@@ -289,16 +281,13 @@ function registerServerReference(reference, id, exportName) {
|
|
289
281
|
value: SERVER_REFERENCE_TAG
|
290
282
|
},
|
291
283
|
$$id: {
|
292
|
-
value: exportName === null ? id : id + '#' + exportName
|
293
|
-
configurable: true
|
284
|
+
value: exportName === null ? id : id + '#' + exportName
|
294
285
|
},
|
295
286
|
$$bound: {
|
296
|
-
value: null
|
297
|
-
configurable: true
|
287
|
+
value: null
|
298
288
|
},
|
299
289
|
bind: {
|
300
|
-
value: bind
|
301
|
-
configurable: true
|
290
|
+
value: bind
|
302
291
|
}
|
303
292
|
});
|
304
293
|
}
|
@@ -337,10 +326,6 @@ var deepProxyHandlers = {
|
|
337
326
|
// $FlowFixMe[prop-missing]
|
338
327
|
return Object.prototype[Symbol.toPrimitive];
|
339
328
|
|
340
|
-
case Symbol.toStringTag:
|
341
|
-
// $FlowFixMe[prop-missing]
|
342
|
-
return Object.prototype[Symbol.toStringTag];
|
343
|
-
|
344
329
|
case 'Provider':
|
345
330
|
throw new Error("Cannot render a Client Context Provider on the Server. " + "Instead, you can export a Client Component wrapper " + "that itself renders a Client Context Provider.");
|
346
331
|
} // eslint-disable-next-line react-internal/safe-string-coercion
|
@@ -382,10 +367,6 @@ function getReference(target, name) {
|
|
382
367
|
// $FlowFixMe[prop-missing]
|
383
368
|
return Object.prototype[Symbol.toPrimitive];
|
384
369
|
|
385
|
-
case Symbol.toStringTag:
|
386
|
-
// $FlowFixMe[prop-missing]
|
387
|
-
return Object.prototype[Symbol.toStringTag];
|
388
|
-
|
389
370
|
case '__esModule':
|
390
371
|
// Something is conditionally checking which export to use. We'll pretend to be
|
391
372
|
// an ESM compat module but then we'll check again on the client.
|
@@ -426,10 +407,6 @@ function getReference(target, name) {
|
|
426
407
|
|
427
408
|
}
|
428
409
|
|
429
|
-
if (typeof name === 'symbol') {
|
430
|
-
throw new Error('Cannot read Symbol exports. Only named exports are supported on a client module ' + 'imported on the server.');
|
431
|
-
}
|
432
|
-
|
433
410
|
var cachedReference = target[name];
|
434
411
|
|
435
412
|
if (!cachedReference) {
|
@@ -771,7 +748,6 @@ function createHints() {
|
|
771
748
|
return new Set();
|
772
749
|
}
|
773
750
|
|
774
|
-
var supportsRequestStorage = true;
|
775
751
|
var requestStorage = new async_hooks.AsyncLocalStorage();
|
776
752
|
|
777
753
|
// ATTENTION
|
@@ -780,7 +756,7 @@ var requestStorage = new async_hooks.AsyncLocalStorage();
|
|
780
756
|
// The Symbol used to tag the ReactElement-like types.
|
781
757
|
var REACT_ELEMENT_TYPE = Symbol.for('react.element');
|
782
758
|
var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
|
783
|
-
var
|
759
|
+
var REACT_SERVER_CONTEXT_TYPE = Symbol.for('react.server_context');
|
784
760
|
var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');
|
785
761
|
var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');
|
786
762
|
var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');
|
@@ -804,6 +780,146 @@ function getIteratorFn(maybeIterable) {
|
|
804
780
|
return null;
|
805
781
|
}
|
806
782
|
|
783
|
+
// Forming a reverse tree.
|
784
|
+
// The structure of a context snapshot is an implementation of this file.
|
785
|
+
// Currently, it's implemented as tracking the current active node.
|
786
|
+
|
787
|
+
|
788
|
+
var rootContextSnapshot = null; // We assume that this runtime owns the "current" field on all ReactContext instances.
|
789
|
+
// This global (actually thread local) state represents what state all those "current",
|
790
|
+
// fields are currently in.
|
791
|
+
|
792
|
+
var currentActiveSnapshot = null;
|
793
|
+
|
794
|
+
function popNode(prev) {
|
795
|
+
{
|
796
|
+
prev.context._currentValue = prev.parentValue;
|
797
|
+
}
|
798
|
+
}
|
799
|
+
|
800
|
+
function pushNode(next) {
|
801
|
+
{
|
802
|
+
next.context._currentValue = next.value;
|
803
|
+
}
|
804
|
+
}
|
805
|
+
|
806
|
+
function popToNearestCommonAncestor(prev, next) {
|
807
|
+
if (prev === next) ; else {
|
808
|
+
popNode(prev);
|
809
|
+
var parentPrev = prev.parent;
|
810
|
+
var parentNext = next.parent;
|
811
|
+
|
812
|
+
if (parentPrev === null) {
|
813
|
+
if (parentNext !== null) {
|
814
|
+
throw new Error('The stacks must reach the root at the same time. This is a bug in React.');
|
815
|
+
}
|
816
|
+
} else {
|
817
|
+
if (parentNext === null) {
|
818
|
+
throw new Error('The stacks must reach the root at the same time. This is a bug in React.');
|
819
|
+
}
|
820
|
+
|
821
|
+
popToNearestCommonAncestor(parentPrev, parentNext); // On the way back, we push the new ones that weren't common.
|
822
|
+
|
823
|
+
pushNode(next);
|
824
|
+
}
|
825
|
+
}
|
826
|
+
}
|
827
|
+
|
828
|
+
function popAllPrevious(prev) {
|
829
|
+
popNode(prev);
|
830
|
+
var parentPrev = prev.parent;
|
831
|
+
|
832
|
+
if (parentPrev !== null) {
|
833
|
+
popAllPrevious(parentPrev);
|
834
|
+
}
|
835
|
+
}
|
836
|
+
|
837
|
+
function pushAllNext(next) {
|
838
|
+
var parentNext = next.parent;
|
839
|
+
|
840
|
+
if (parentNext !== null) {
|
841
|
+
pushAllNext(parentNext);
|
842
|
+
}
|
843
|
+
|
844
|
+
pushNode(next);
|
845
|
+
}
|
846
|
+
|
847
|
+
function popPreviousToCommonLevel(prev, next) {
|
848
|
+
popNode(prev);
|
849
|
+
var parentPrev = prev.parent;
|
850
|
+
|
851
|
+
if (parentPrev === null) {
|
852
|
+
throw new Error('The depth must equal at least at zero before reaching the root. This is a bug in React.');
|
853
|
+
}
|
854
|
+
|
855
|
+
if (parentPrev.depth === next.depth) {
|
856
|
+
// We found the same level. Now we just need to find a shared ancestor.
|
857
|
+
popToNearestCommonAncestor(parentPrev, next);
|
858
|
+
} else {
|
859
|
+
// We must still be deeper.
|
860
|
+
popPreviousToCommonLevel(parentPrev, next);
|
861
|
+
}
|
862
|
+
}
|
863
|
+
|
864
|
+
function popNextToCommonLevel(prev, next) {
|
865
|
+
var parentNext = next.parent;
|
866
|
+
|
867
|
+
if (parentNext === null) {
|
868
|
+
throw new Error('The depth must equal at least at zero before reaching the root. This is a bug in React.');
|
869
|
+
}
|
870
|
+
|
871
|
+
if (prev.depth === parentNext.depth) {
|
872
|
+
// We found the same level. Now we just need to find a shared ancestor.
|
873
|
+
popToNearestCommonAncestor(prev, parentNext);
|
874
|
+
} else {
|
875
|
+
// We must still be deeper.
|
876
|
+
popNextToCommonLevel(prev, parentNext);
|
877
|
+
}
|
878
|
+
|
879
|
+
pushNode(next);
|
880
|
+
} // Perform context switching to the new snapshot.
|
881
|
+
// To make it cheap to read many contexts, while not suspending, we make the switch eagerly by
|
882
|
+
// updating all the context's current values. That way reads, always just read the current value.
|
883
|
+
// At the cost of updating contexts even if they're never read by this subtree.
|
884
|
+
|
885
|
+
|
886
|
+
function switchContext(newSnapshot) {
|
887
|
+
// The basic algorithm we need to do is to pop back any contexts that are no longer on the stack.
|
888
|
+
// We also need to update any new contexts that are now on the stack with the deepest value.
|
889
|
+
// The easiest way to update new contexts is to just reapply them in reverse order from the
|
890
|
+
// perspective of the backpointers. To avoid allocating a lot when switching, we use the stack
|
891
|
+
// for that. Therefore this algorithm is recursive.
|
892
|
+
// 1) First we pop which ever snapshot tree was deepest. Popping old contexts as we go.
|
893
|
+
// 2) Then we find the nearest common ancestor from there. Popping old contexts as we go.
|
894
|
+
// 3) Then we reapply new contexts on the way back up the stack.
|
895
|
+
var prev = currentActiveSnapshot;
|
896
|
+
var next = newSnapshot;
|
897
|
+
|
898
|
+
if (prev !== next) {
|
899
|
+
if (prev === null) {
|
900
|
+
// $FlowFixMe[incompatible-call]: This has to be non-null since it's not equal to prev.
|
901
|
+
pushAllNext(next);
|
902
|
+
} else if (next === null) {
|
903
|
+
popAllPrevious(prev);
|
904
|
+
} else if (prev.depth === next.depth) {
|
905
|
+
popToNearestCommonAncestor(prev, next);
|
906
|
+
} else if (prev.depth > next.depth) {
|
907
|
+
popPreviousToCommonLevel(prev, next);
|
908
|
+
} else {
|
909
|
+
popNextToCommonLevel(prev, next);
|
910
|
+
}
|
911
|
+
|
912
|
+
currentActiveSnapshot = next;
|
913
|
+
}
|
914
|
+
}
|
915
|
+
function getActiveContext() {
|
916
|
+
return currentActiveSnapshot;
|
917
|
+
}
|
918
|
+
function readContext$1(context) {
|
919
|
+
var value = context._currentValue ;
|
920
|
+
return value;
|
921
|
+
}
|
922
|
+
|
807
923
|
// Corresponds to ReactFiberWakeable and ReactFizzWakeable modules. Generally,
|
808
924
|
// changes to one module should be reflected in the others.
|
809
925
|
// TODO: Rename this module and the corresponding Fiber one to "Thenable"
|
@@ -932,13 +1048,29 @@ function prepareToUseHooksForComponent(prevThenableState) {
|
|
932
1048
|
thenableState = prevThenableState;
|
933
1049
|
}
|
934
1050
|
function getThenableStateAfterSuspending() {
|
935
|
-
|
936
|
-
// which is not really supported anymore, it will be empty. We use the empty set as a
|
937
|
-
// marker to know if this was a replay of the same component or first attempt.
|
938
|
-
var state = thenableState || createThenableState();
|
1051
|
+
var state = thenableState;
|
939
1052
|
thenableState = null;
|
940
1053
|
return state;
|
941
1054
|
}
|
1055
|
+
|
1056
|
+
function readContext(context) {
|
1057
|
+
{
|
1058
|
+
if (context.$$typeof !== REACT_SERVER_CONTEXT_TYPE) {
|
1059
|
+
if (isClientReference(context)) {
|
1060
|
+
error('Cannot read a Client Context from a Server Component.');
|
1061
|
+
} else {
|
1062
|
+
error('Only createServerContext is supported in Server Components.');
|
1063
|
+
}
|
1064
|
+
}
|
1065
|
+
|
1066
|
+
if (currentRequest$1 === null) {
|
1067
|
+
error('Context can only be read while React is rendering. ' + 'In classes, you can read it in the render method or getDerivedStateFromProps. ' + 'In function components, you can read it directly in the function body, but not ' + 'inside Hooks like useReducer() or useMemo().');
|
1068
|
+
}
|
1069
|
+
}
|
1070
|
+
|
1071
|
+
return readContext$1(context);
|
1072
|
+
}
|
1073
|
+
|
942
1074
|
var HooksDispatcher = {
|
943
1075
|
useMemo: function (nextCreate) {
|
944
1076
|
return nextCreate();
|
@@ -949,8 +1081,8 @@ var HooksDispatcher = {
|
|
949
1081
|
useDebugValue: function () {},
|
950
1082
|
useDeferredValue: unsupportedHook,
|
951
1083
|
useTransition: unsupportedHook,
|
952
|
-
readContext:
|
953
|
-
useContext:
|
1084
|
+
readContext: readContext,
|
1085
|
+
useContext: readContext,
|
954
1086
|
useReducer: unsupportedHook,
|
955
1087
|
useRef: unsupportedHook,
|
956
1088
|
useState: unsupportedHook,
|
@@ -983,10 +1115,6 @@ function unsupportedRefresh() {
|
|
983
1115
|
throw new Error('Refreshing the cache is not supported in Server Components.');
|
984
1116
|
}
|
985
1117
|
|
986
|
-
function unsupportedContext() {
|
987
|
-
throw new Error('Cannot read a Client Context from a Server Component.');
|
988
|
-
}
|
989
|
-
|
990
1118
|
function useId() {
|
991
1119
|
if (currentRequest$1 === null) {
|
992
1120
|
throw new Error('useId can only be used while React is rendering');
|
@@ -1012,22 +1140,20 @@ function use(usable) {
|
|
1012
1140
|
}
|
1013
1141
|
|
1014
1142
|
return trackUsedThenable(thenableState, thenable, index);
|
1015
|
-
} else if (usable.$$typeof ===
|
1016
|
-
|
1143
|
+
} else if (usable.$$typeof === REACT_SERVER_CONTEXT_TYPE) {
|
1144
|
+
var context = usable;
|
1145
|
+
return readContext(context);
|
1017
1146
|
}
|
1018
1147
|
}
|
1019
1148
|
|
1020
|
-
|
1021
|
-
if (usable
|
1022
|
-
|
1023
|
-
throw new Error('Cannot read a Client Context from a Server Component.');
|
1024
|
-
} else {
|
1025
|
-
throw new Error('Cannot use() an already resolved Client Reference.');
|
1149
|
+
{
|
1150
|
+
if (isClientReference(usable)) {
|
1151
|
+
error('Cannot use() an already resolved Client Reference.');
|
1026
1152
|
}
|
1027
|
-
}
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1153
|
+
} // eslint-disable-next-line react-internal/safe-string-coercion
|
1154
|
+
|
1155
|
+
|
1156
|
+
throw new Error('An unsupported type was passed to use(): ' + String(usable));
|
1031
1157
|
}
|
1032
1158
|
|
1033
1159
|
function createSignal() {
|
@@ -1165,10 +1291,6 @@ function describeValueForErrorMessage(value) {
|
|
1165
1291
|
return '[...]';
|
1166
1292
|
}
|
1167
1293
|
|
1168
|
-
if (value !== null && value.$$typeof === CLIENT_REFERENCE_TAG) {
|
1169
|
-
return describeClientReference();
|
1170
|
-
}
|
1171
|
-
|
1172
1294
|
var name = objectName(value);
|
1173
1295
|
|
1174
1296
|
if (name === 'Object') {
|
@@ -1179,15 +1301,7 @@ function describeValueForErrorMessage(value) {
|
|
1179
1301
|
}
|
1180
1302
|
|
1181
1303
|
case 'function':
|
1182
|
-
|
1183
|
-
if (value.$$typeof === CLIENT_REFERENCE_TAG) {
|
1184
|
-
return describeClientReference();
|
1185
|
-
}
|
1186
|
-
|
1187
|
-
var _name = value.displayName || value.name;
|
1188
|
-
|
1189
|
-
return _name ? 'function ' + _name : 'function';
|
1190
|
-
}
|
1304
|
+
return 'function';
|
1191
1305
|
|
1192
1306
|
default:
|
1193
1307
|
// eslint-disable-next-line react-internal/safe-string-coercion
|
@@ -1233,12 +1347,6 @@ function describeElementType(type) {
|
|
1233
1347
|
return '';
|
1234
1348
|
}
|
1235
1349
|
|
1236
|
-
var CLIENT_REFERENCE_TAG = Symbol.for('react.client.reference');
|
1237
|
-
|
1238
|
-
function describeClientReference(ref) {
|
1239
|
-
return 'client';
|
1240
|
-
}
|
1241
|
-
|
1242
1350
|
function describeObjectForErrorMessage(objectOrArray, expandedName) {
|
1243
1351
|
var objKind = objectName(objectOrArray);
|
1244
1352
|
|
@@ -1317,8 +1425,6 @@ function describeObjectForErrorMessage(objectOrArray, expandedName) {
|
|
1317
1425
|
} else {
|
1318
1426
|
if (objectOrArray.$$typeof === REACT_ELEMENT_TYPE) {
|
1319
1427
|
str = '<' + describeElementType(objectOrArray.type) + '/>';
|
1320
|
-
} else if (objectOrArray.$$typeof === CLIENT_REFERENCE_TAG) {
|
1321
|
-
return describeClientReference();
|
1322
1428
|
} else if (jsxPropsParents.has(objectOrArray)) {
|
1323
1429
|
// Print JSX
|
1324
1430
|
var _type = jsxPropsParents.get(objectOrArray);
|
@@ -1369,9 +1475,9 @@ function describeObjectForErrorMessage(objectOrArray, expandedName) {
|
|
1369
1475
|
str += ', ';
|
1370
1476
|
}
|
1371
1477
|
|
1372
|
-
var
|
1373
|
-
str += describeKeyForErrorMessage(
|
1374
|
-
var _value3 = _object[
|
1478
|
+
var _name = _names[_i3];
|
1479
|
+
str += describeKeyForErrorMessage(_name) + ': ';
|
1480
|
+
var _value3 = _object[_name];
|
1375
1481
|
|
1376
1482
|
var _substr3 = void 0;
|
1377
1483
|
|
@@ -1381,7 +1487,7 @@ function describeObjectForErrorMessage(objectOrArray, expandedName) {
|
|
1381
1487
|
_substr3 = describeValueForErrorMessage(_value3);
|
1382
1488
|
}
|
1383
1489
|
|
1384
|
-
if (
|
1490
|
+
if (_name === expandedName) {
|
1385
1491
|
start = str.length;
|
1386
1492
|
length = _substr3.length;
|
1387
1493
|
str += _substr3;
|
@@ -1436,7 +1542,7 @@ function defaultPostponeHandler(reason) {// Noop
|
|
1436
1542
|
var OPEN = 0;
|
1437
1543
|
var CLOSING = 1;
|
1438
1544
|
var CLOSED = 2;
|
1439
|
-
function createRequest(model, bundlerConfig, onError, identifierPrefix, onPostpone
|
1545
|
+
function createRequest(model, bundlerConfig, onError, context, identifierPrefix, onPostpone) {
|
1440
1546
|
if (ReactCurrentCache.current !== null && ReactCurrentCache.current !== DefaultCacheDispatcher) {
|
1441
1547
|
throw new Error('Currently React only supports one RSC renderer at a time.');
|
1442
1548
|
}
|
@@ -1467,19 +1573,21 @@ function createRequest(model, bundlerConfig, onError, identifierPrefix, onPostpo
|
|
1467
1573
|
writtenSymbols: new Map(),
|
1468
1574
|
writtenClientReferences: new Map(),
|
1469
1575
|
writtenServerReferences: new Map(),
|
1576
|
+
writtenProviders: new Map(),
|
1470
1577
|
writtenObjects: new WeakMap(),
|
1471
1578
|
identifierPrefix: identifierPrefix || '',
|
1472
1579
|
identifierCount: 1,
|
1473
1580
|
taintCleanupQueue: cleanupQueue,
|
1474
1581
|
onError: onError === undefined ? defaultErrorHandler : onError,
|
1475
|
-
onPostpone: onPostpone === undefined ? defaultPostponeHandler : onPostpone
|
1582
|
+
onPostpone: onPostpone === undefined ? defaultPostponeHandler : onPostpone,
|
1583
|
+
// $FlowFixMe[missing-this-annot]
|
1584
|
+
toJSON: function (key, value) {
|
1585
|
+
return resolveModelToJSON(request, this, key, value);
|
1586
|
+
}
|
1476
1587
|
};
|
1477
|
-
|
1478
|
-
|
1479
|
-
|
1480
|
-
}
|
1481
|
-
|
1482
|
-
var rootTask = createTask(request, model, null, false, abortSet);
|
1588
|
+
request.pendingChunks++;
|
1589
|
+
var rootContext = createRootContext();
|
1590
|
+
var rootTask = createTask(request, model, rootContext, abortSet);
|
1483
1591
|
pingedTasks.push(rootTask);
|
1484
1592
|
return request;
|
1485
1593
|
}
|
@@ -1495,18 +1603,13 @@ function resolveRequest() {
|
|
1495
1603
|
return null;
|
1496
1604
|
}
|
1497
1605
|
|
1498
|
-
function
|
1499
|
-
|
1500
|
-
|
1501
|
-
|
1502
|
-
{
|
1503
|
-
// If this came from Flight, forward any debug info into this new row.
|
1504
|
-
var debugInfo = thenable._debugInfo;
|
1606
|
+
function createRootContext(reqContext) {
|
1607
|
+
return importServerContexts();
|
1608
|
+
}
|
1505
1609
|
|
1506
|
-
|
1507
|
-
|
1508
|
-
|
1509
|
-
}
|
1610
|
+
function serializeThenable(request, thenable) {
|
1611
|
+
request.pendingChunks++;
|
1612
|
+
var newTask = createTask(request, null, getActiveContext(), request.abortableTasks);
|
1510
1613
|
|
1511
1614
|
switch (thenable.status) {
|
1512
1615
|
case 'fulfilled':
|
@@ -1642,136 +1745,14 @@ function createLazyWrapperAroundWakeable(wakeable) {
|
|
1642
1745
|
_payload: thenable,
|
1643
1746
|
_init: readThenable
|
1644
1747
|
};
|
1645
|
-
|
1646
|
-
{
|
1647
|
-
// If this came from React, transfer the debug info.
|
1648
|
-
lazyType._debugInfo = thenable._debugInfo || [];
|
1649
|
-
}
|
1650
|
-
|
1651
1748
|
return lazyType;
|
1652
1749
|
}
|
1653
1750
|
|
1654
|
-
function
|
1655
|
-
// Reset the task's thenable state before continuing, so that if a later
|
1656
|
-
// component suspends we can reuse the same task object. If the same
|
1657
|
-
// component suspends again, the thenable state will be restored.
|
1658
|
-
var prevThenableState = task.thenableState;
|
1659
|
-
task.thenableState = null;
|
1660
|
-
|
1661
|
-
{
|
1662
|
-
if (debugID === null) {
|
1663
|
-
// We don't have a chunk to assign debug info. We need to outline this
|
1664
|
-
// component to assign it an ID.
|
1665
|
-
return outlineTask(request, task);
|
1666
|
-
} else if (prevThenableState !== null) ; else {
|
1667
|
-
// This is a new component in the same task so we can emit more debug info.
|
1668
|
-
var componentName = Component.displayName || Component.name || '';
|
1669
|
-
request.pendingChunks++;
|
1670
|
-
emitDebugChunk(request, debugID, {
|
1671
|
-
name: componentName,
|
1672
|
-
env: request.environmentName
|
1673
|
-
});
|
1674
|
-
}
|
1675
|
-
}
|
1676
|
-
|
1677
|
-
prepareToUseHooksForComponent(prevThenableState); // The secondArg is always undefined in Server Components since refs error early.
|
1678
|
-
|
1679
|
-
var secondArg = undefined;
|
1680
|
-
var result = Component(props, secondArg);
|
1681
|
-
|
1682
|
-
if (typeof result === 'object' && result !== null && typeof result.then === 'function') {
|
1683
|
-
// When the return value is in children position we can resolve it immediately,
|
1684
|
-
// to its value without a wrapper if it's synchronously available.
|
1685
|
-
var thenable = result;
|
1686
|
-
|
1687
|
-
if (thenable.status === 'fulfilled') {
|
1688
|
-
return thenable.value;
|
1689
|
-
} // TODO: Once we accept Promises as children on the client, we can just return
|
1690
|
-
// the thenable here.
|
1691
|
-
|
1692
|
-
|
1693
|
-
result = createLazyWrapperAroundWakeable(result);
|
1694
|
-
} // Track this element's key on the Server Component on the keyPath context..
|
1695
|
-
|
1696
|
-
|
1697
|
-
var prevKeyPath = task.keyPath;
|
1698
|
-
var prevImplicitSlot = task.implicitSlot;
|
1699
|
-
|
1700
|
-
if (key !== null) {
|
1701
|
-
// Append the key to the path. Technically a null key should really add the child
|
1702
|
-
// index. We don't do that to hold the payload small and implementation simple.
|
1703
|
-
task.keyPath = prevKeyPath === null ? key : prevKeyPath + ',' + key;
|
1704
|
-
} else if (prevKeyPath === null) {
|
1705
|
-
// This sequence of Server Components has no keys. This means that it was rendered
|
1706
|
-
// in a slot that needs to assign an implicit key. Even if children below have
|
1707
|
-
// explicit keys, they should not be used for the outer most key since it might
|
1708
|
-
// collide with other slots in that set.
|
1709
|
-
task.implicitSlot = true;
|
1710
|
-
}
|
1711
|
-
|
1712
|
-
var json = renderModelDestructive(request, task, emptyRoot, '', result);
|
1713
|
-
task.keyPath = prevKeyPath;
|
1714
|
-
task.implicitSlot = prevImplicitSlot;
|
1715
|
-
return json;
|
1716
|
-
}
|
1717
|
-
|
1718
|
-
function renderFragment(request, task, children) {
|
1719
|
-
{
|
1720
|
-
var debugInfo = children._debugInfo;
|
1721
|
-
|
1722
|
-
if (debugInfo) {
|
1723
|
-
// If this came from Flight, forward any debug info into this new row.
|
1724
|
-
if (debugID === null) {
|
1725
|
-
// We don't have a chunk to assign debug info. We need to outline this
|
1726
|
-
// component to assign it an ID.
|
1727
|
-
return outlineTask(request, task);
|
1728
|
-
} else {
|
1729
|
-
// Forward any debug info we have the first time we see it.
|
1730
|
-
// We do this after init so that we have received all the debug info
|
1731
|
-
// from the server by the time we emit it.
|
1732
|
-
forwardDebugInfo(request, debugID, debugInfo);
|
1733
|
-
}
|
1734
|
-
}
|
1735
|
-
}
|
1736
|
-
|
1737
|
-
{
|
1738
|
-
return children;
|
1739
|
-
}
|
1740
|
-
}
|
1741
|
-
|
1742
|
-
function renderClientElement(task, type, key, props) {
|
1743
|
-
{
|
1744
|
-
return [REACT_ELEMENT_TYPE, type, key, props];
|
1745
|
-
} // We prepend the terminal client element that actually gets serialized with
|
1746
|
-
} // The chunk ID we're currently rendering that we can assign debug data to.
|
1747
|
-
|
1748
|
-
|
1749
|
-
var debugID = null;
|
1750
|
-
|
1751
|
-
function outlineTask(request, task) {
|
1752
|
-
var newTask = createTask(request, task.model, // the currently rendering element
|
1753
|
-
task.keyPath, // unlike outlineModel this one carries along context
|
1754
|
-
task.implicitSlot, request.abortableTasks);
|
1755
|
-
retryTask(request, newTask);
|
1756
|
-
|
1757
|
-
if (newTask.status === COMPLETED) {
|
1758
|
-
// We completed synchronously so we can refer to this by reference. This
|
1759
|
-
// makes it behaves the same as prod during deserialization.
|
1760
|
-
return serializeByValueID(newTask.id);
|
1761
|
-
} // This didn't complete synchronously so it wouldn't have even if we didn't
|
1762
|
-
// outline it, so this would reduce to a lazy reference even in prod.
|
1763
|
-
|
1764
|
-
|
1765
|
-
return serializeLazyID(newTask.id);
|
1766
|
-
}
|
1767
|
-
|
1768
|
-
function renderElement(request, task, type, key, ref, props) {
|
1751
|
+
function attemptResolveElement(request, type, key, ref, props, prevThenableState) {
|
1769
1752
|
if (ref !== null && ref !== undefined) {
|
1770
1753
|
// When the ref moves to the regular props object this will implicitly
|
1771
1754
|
// throw for functions. We could probably relax it to a DEV warning for other
|
1772
1755
|
// cases.
|
1773
|
-
// TODO: `ref` is now just a prop when `enableRefAsProp` is on. Should we
|
1774
|
-
// do what the above comment says?
|
1775
1756
|
throw new Error('Refs cannot be used in Server Components, nor passed to Client Components.');
|
1776
1757
|
}
|
1777
1758
|
|
@@ -1786,36 +1767,47 @@ function renderElement(request, task, type, key, ref, props) {
|
|
1786
1767
|
if (typeof type === 'function') {
|
1787
1768
|
if (isClientReference(type)) {
|
1788
1769
|
// This is a reference to a Client Component.
|
1789
|
-
return
|
1790
|
-
} // This is a
|
1770
|
+
return [REACT_ELEMENT_TYPE, type, key, props];
|
1771
|
+
} // This is a server-side component.
|
1772
|
+
|
1773
|
+
|
1774
|
+
prepareToUseHooksForComponent(prevThenableState);
|
1775
|
+
var result = type(props);
|
1791
1776
|
|
1777
|
+
if (typeof result === 'object' && result !== null && typeof result.then === 'function') {
|
1778
|
+
// When the return value is in children position we can resolve it immediately,
|
1779
|
+
// to its value without a wrapper if it's synchronously available.
|
1780
|
+
var thenable = result;
|
1792
1781
|
|
1793
|
-
|
1782
|
+
if (thenable.status === 'fulfilled') {
|
1783
|
+
return thenable.value;
|
1784
|
+
} // TODO: Once we accept Promises as children on the client, we can just return
|
1785
|
+
// the thenable here.
|
1786
|
+
|
1787
|
+
|
1788
|
+
return createLazyWrapperAroundWakeable(result);
|
1789
|
+
}
|
1790
|
+
|
1791
|
+
return result;
|
1794
1792
|
} else if (typeof type === 'string') {
|
1795
1793
|
// This is a host element. E.g. HTML.
|
1796
|
-
return
|
1794
|
+
return [REACT_ELEMENT_TYPE, type, key, props];
|
1797
1795
|
} else if (typeof type === 'symbol') {
|
1798
|
-
if (type === REACT_FRAGMENT_TYPE
|
1796
|
+
if (type === REACT_FRAGMENT_TYPE) {
|
1799
1797
|
// For key-less fragments, we add a small optimization to avoid serializing
|
1800
1798
|
// it as a wrapper.
|
1801
|
-
|
1802
|
-
|
1803
|
-
|
1804
|
-
task.implicitSlot = true;
|
1805
|
-
}
|
1806
|
-
|
1807
|
-
var json = renderModelDestructive(request, task, emptyRoot, '', props.children);
|
1808
|
-
task.implicitSlot = prevImplicitSlot;
|
1809
|
-
return json;
|
1799
|
+
// TODO: If a key is specified, we should propagate its key to any children.
|
1800
|
+
// Same as if a Server Component has a key.
|
1801
|
+
return props.children;
|
1810
1802
|
} // This might be a built-in React component. We'll let the client decide.
|
1811
1803
|
// Any built-in works as long as its props are serializable.
|
1812
1804
|
|
1813
1805
|
|
1814
|
-
return
|
1806
|
+
return [REACT_ELEMENT_TYPE, type, key, props];
|
1815
1807
|
} else if (type != null && typeof type === 'object') {
|
1816
1808
|
if (isClientReference(type)) {
|
1817
1809
|
// This is a reference to a Client Component.
|
1818
|
-
return
|
1810
|
+
return [REACT_ELEMENT_TYPE, type, key, props];
|
1819
1811
|
}
|
1820
1812
|
|
1821
1813
|
switch (type.$$typeof) {
|
@@ -1824,17 +1816,19 @@ function renderElement(request, task, type, key, ref, props) {
|
|
1824
1816
|
var payload = type._payload;
|
1825
1817
|
var init = type._init;
|
1826
1818
|
var wrappedType = init(payload);
|
1827
|
-
return
|
1819
|
+
return attemptResolveElement(request, wrappedType, key, ref, props, prevThenableState);
|
1828
1820
|
}
|
1829
1821
|
|
1830
1822
|
case REACT_FORWARD_REF_TYPE:
|
1831
1823
|
{
|
1832
|
-
|
1824
|
+
var render = type.render;
|
1825
|
+
prepareToUseHooksForComponent(prevThenableState);
|
1826
|
+
return render(props, undefined);
|
1833
1827
|
}
|
1834
1828
|
|
1835
1829
|
case REACT_MEMO_TYPE:
|
1836
1830
|
{
|
1837
|
-
return
|
1831
|
+
return attemptResolveElement(request, type.type, key, ref, props, prevThenableState);
|
1838
1832
|
}
|
1839
1833
|
}
|
1840
1834
|
}
|
@@ -1854,51 +1848,16 @@ function pingTask(request, task) {
|
|
1854
1848
|
}
|
1855
1849
|
}
|
1856
1850
|
|
1857
|
-
function createTask(request, model,
|
1858
|
-
request.pendingChunks++;
|
1851
|
+
function createTask(request, model, context, abortSet) {
|
1859
1852
|
var id = request.nextChunkId++;
|
1860
|
-
|
1861
|
-
if (typeof model === 'object' && model !== null) {
|
1862
|
-
// If we're about to write this into a new task we can assign it an ID early so that
|
1863
|
-
// any other references can refer to the value we're about to write.
|
1864
|
-
{
|
1865
|
-
request.writtenObjects.set(model, id);
|
1866
|
-
}
|
1867
|
-
}
|
1868
|
-
|
1869
1853
|
var task = {
|
1870
1854
|
id: id,
|
1871
1855
|
status: PENDING$1,
|
1872
1856
|
model: model,
|
1873
|
-
|
1874
|
-
implicitSlot: implicitSlot,
|
1857
|
+
context: context,
|
1875
1858
|
ping: function () {
|
1876
1859
|
return pingTask(request, task);
|
1877
1860
|
},
|
1878
|
-
toJSON: function (parentPropertyName, value) {
|
1879
|
-
var parent = this; // Make sure that `parent[parentPropertyName]` wasn't JSONified before `value` was passed to us
|
1880
|
-
|
1881
|
-
{
|
1882
|
-
// $FlowFixMe[incompatible-use]
|
1883
|
-
var originalValue = parent[parentPropertyName];
|
1884
|
-
|
1885
|
-
if (typeof originalValue === 'object' && originalValue !== value && !(originalValue instanceof Date)) {
|
1886
|
-
if (objectName(originalValue) !== 'Object') {
|
1887
|
-
var jsxParentType = jsxChildrenParents.get(parent);
|
1888
|
-
|
1889
|
-
if (typeof jsxParentType === 'string') {
|
1890
|
-
error('%s objects cannot be rendered as text children. Try formatting it using toString().%s', objectName(originalValue), describeObjectForErrorMessage(parent, parentPropertyName));
|
1891
|
-
} else {
|
1892
|
-
error('Only plain objects can be passed to Client Components from Server Components. ' + '%s objects are not supported.%s', objectName(originalValue), describeObjectForErrorMessage(parent, parentPropertyName));
|
1893
|
-
}
|
1894
|
-
} else {
|
1895
|
-
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));
|
1896
|
-
}
|
1897
|
-
}
|
1898
|
-
}
|
1899
|
-
|
1900
|
-
return renderModel(request, task, parent, parentPropertyName, value);
|
1901
|
-
},
|
1902
1861
|
thenableState: null
|
1903
1862
|
};
|
1904
1863
|
abortSet.add(task);
|
@@ -1967,13 +1926,13 @@ function encodeReferenceChunk(request, id, reference) {
|
|
1967
1926
|
return stringToChunk(row);
|
1968
1927
|
}
|
1969
1928
|
|
1970
|
-
function serializeClientReference(request, parent,
|
1929
|
+
function serializeClientReference(request, parent, key, clientReference) {
|
1971
1930
|
var clientReferenceKey = getClientReferenceKey(clientReference);
|
1972
1931
|
var writtenClientReferences = request.writtenClientReferences;
|
1973
1932
|
var existingId = writtenClientReferences.get(clientReferenceKey);
|
1974
1933
|
|
1975
1934
|
if (existingId !== undefined) {
|
1976
|
-
if (parent[0] === REACT_ELEMENT_TYPE &&
|
1935
|
+
if (parent[0] === REACT_ELEMENT_TYPE && key === '1') {
|
1977
1936
|
// If we're encoding the "type" of an element, we can refer
|
1978
1937
|
// to that by a lazy reference instead of directly since React
|
1979
1938
|
// knows how to deal with lazy values. This lets us suspend
|
@@ -1992,7 +1951,7 @@ function serializeClientReference(request, parent, parentPropertyName, clientRef
|
|
1992
1951
|
emitImportChunk(request, importId, clientReferenceMetadata);
|
1993
1952
|
writtenClientReferences.set(clientReferenceKey, importId);
|
1994
1953
|
|
1995
|
-
if (parent[0] === REACT_ELEMENT_TYPE &&
|
1954
|
+
if (parent[0] === REACT_ELEMENT_TYPE && key === '1') {
|
1996
1955
|
// If we're encoding the "type" of an element, we can refer
|
1997
1956
|
// to that by a lazy reference instead of directly since React
|
1998
1957
|
// knows how to deal with lazy values. This lets us suspend
|
@@ -2012,14 +1971,13 @@ function serializeClientReference(request, parent, parentPropertyName, clientRef
|
|
2012
1971
|
}
|
2013
1972
|
|
2014
1973
|
function outlineModel(request, value) {
|
2015
|
-
|
2016
|
-
|
2017
|
-
request.abortableTasks);
|
1974
|
+
request.pendingChunks++;
|
1975
|
+
var newTask = createTask(request, value, getActiveContext(), request.abortableTasks);
|
2018
1976
|
retryTask(request, newTask);
|
2019
1977
|
return newTask.id;
|
2020
1978
|
}
|
2021
1979
|
|
2022
|
-
function serializeServerReference(request, serverReference) {
|
1980
|
+
function serializeServerReference(request, parent, key, serverReference) {
|
2023
1981
|
var writtenServerReferences = request.writtenServerReferences;
|
2024
1982
|
var existingId = writtenServerReferences.get(serverReference);
|
2025
1983
|
|
@@ -2099,77 +2057,110 @@ function escapeStringValue(value) {
|
|
2099
2057
|
return value;
|
2100
2058
|
}
|
2101
2059
|
}
|
2102
|
-
|
2103
2060
|
var modelRoot = false;
|
2104
2061
|
|
2105
|
-
function
|
2106
|
-
|
2107
|
-
|
2062
|
+
function resolveModelToJSON(request, parent, key, value) {
|
2063
|
+
// Make sure that `parent[key]` wasn't JSONified before `value` was passed to us
|
2064
|
+
{
|
2065
|
+
// $FlowFixMe[incompatible-use]
|
2066
|
+
var originalValue = parent[key];
|
2108
2067
|
|
2109
|
-
|
2110
|
-
|
2111
|
-
|
2112
|
-
|
2113
|
-
|
2114
|
-
|
2115
|
-
|
2116
|
-
|
2117
|
-
|
2118
|
-
|
2068
|
+
if (typeof originalValue === 'object' && originalValue !== value && !(originalValue instanceof Date)) {
|
2069
|
+
if (objectName(originalValue) !== 'Object') {
|
2070
|
+
var jsxParentType = jsxChildrenParents.get(parent);
|
2071
|
+
|
2072
|
+
if (typeof jsxParentType === 'string') {
|
2073
|
+
error('%s objects cannot be rendered as text children. Try formatting it using toString().%s', objectName(originalValue), describeObjectForErrorMessage(parent, key));
|
2074
|
+
} else {
|
2075
|
+
error('Only plain objects can be passed to Client Components from Server Components. ' + '%s objects are not supported.%s', objectName(originalValue), describeObjectForErrorMessage(parent, key));
|
2076
|
+
}
|
2077
|
+
} else {
|
2078
|
+
error('Only plain objects can be passed to Client Components from Server Components. ' + 'Objects with toJSON methods are not supported. Convert it manually ' + 'to a simple value before passing it to props.%s', describeObjectForErrorMessage(parent, key));
|
2079
|
+
}
|
2080
|
+
}
|
2081
|
+
} // Special Symbols
|
2119
2082
|
|
2120
|
-
var model = task.model;
|
2121
|
-
var wasReactNode = typeof model === 'object' && model !== null && (model.$$typeof === REACT_ELEMENT_TYPE || model.$$typeof === REACT_LAZY_TYPE);
|
2122
2083
|
|
2123
|
-
|
2124
|
-
|
2125
|
-
|
2126
|
-
|
2127
|
-
var newTask = createTask(request, task.model, task.keyPath, task.implicitSlot, request.abortableTasks);
|
2128
|
-
var ping = newTask.ping;
|
2129
|
-
x.then(ping, ping);
|
2130
|
-
newTask.thenableState = getThenableStateAfterSuspending(); // Restore the context. We assume that this will be restored by the inner
|
2131
|
-
// functions in case nothing throws so we don't use "finally" here.
|
2084
|
+
switch (value) {
|
2085
|
+
case REACT_ELEMENT_TYPE:
|
2086
|
+
return '$';
|
2087
|
+
}
|
2132
2088
|
|
2133
|
-
task.keyPath = prevKeyPath;
|
2134
|
-
task.implicitSlot = prevImplicitSlot;
|
2135
2089
|
|
2136
|
-
|
2137
|
-
|
2138
|
-
|
2090
|
+
while (typeof value === 'object' && value !== null && (value.$$typeof === REACT_ELEMENT_TYPE || value.$$typeof === REACT_LAZY_TYPE)) {
|
2091
|
+
|
2092
|
+
try {
|
2093
|
+
switch (value.$$typeof) {
|
2094
|
+
case REACT_ELEMENT_TYPE:
|
2095
|
+
{
|
2096
|
+
var writtenObjects = request.writtenObjects;
|
2097
|
+
var existingId = writtenObjects.get(value);
|
2098
|
+
|
2099
|
+
if (existingId !== undefined) {
|
2100
|
+
if (existingId === -1) {
|
2101
|
+
// Seen but not yet outlined.
|
2102
|
+
var newId = outlineModel(request, value);
|
2103
|
+
return serializeByValueID(newId);
|
2104
|
+
} else if (modelRoot === value) {
|
2105
|
+
// This is the ID we're currently emitting so we need to write it
|
2106
|
+
// once but if we discover it again, we refer to it by id.
|
2107
|
+
modelRoot = null;
|
2108
|
+
} else {
|
2109
|
+
// We've already emitted this as an outlined object, so we can
|
2110
|
+
// just refer to that by its existing ID.
|
2111
|
+
return serializeByValueID(existingId);
|
2112
|
+
}
|
2113
|
+
} else {
|
2114
|
+
// This is the first time we've seen this object. We may never see it again
|
2115
|
+
// so we'll inline it. Mark it as seen. If we see it again, we'll outline.
|
2116
|
+
writtenObjects.set(value, -1);
|
2117
|
+
} // TODO: Concatenate keys of parents onto children.
|
2139
2118
|
|
2140
|
-
return serializeByValueID(newTask.id);
|
2141
|
-
}
|
2142
|
-
} // Restore the context. We assume that this will be restored by the inner
|
2143
|
-
// functions in case nothing throws so we don't use "finally" here.
|
2144
2119
|
|
2120
|
+
var element = value; // Attempt to render the Server Component.
|
2145
2121
|
|
2146
|
-
|
2147
|
-
|
2122
|
+
value = attemptResolveElement(request, element.type, element.key, element.ref, element.props, null);
|
2123
|
+
break;
|
2124
|
+
}
|
2148
2125
|
|
2149
|
-
|
2150
|
-
|
2126
|
+
case REACT_LAZY_TYPE:
|
2127
|
+
{
|
2128
|
+
var payload = value._payload;
|
2129
|
+
var init = value._init;
|
2130
|
+
value = init(payload);
|
2131
|
+
break;
|
2132
|
+
}
|
2133
|
+
}
|
2134
|
+
} catch (thrownValue) {
|
2135
|
+
var x = thrownValue === SuspenseException ? // This is a special type of exception used for Suspense. For historical
|
2136
|
+
// reasons, the rest of the Suspense implementation expects the thrown
|
2137
|
+
// value to be a thenable, because before `use` existed that was the
|
2138
|
+
// (unstable) API for suspending. This implementation detail can change
|
2139
|
+
// later, once we deprecate the old API in favor of `use`.
|
2140
|
+
getSuspendedThenable() : thrownValue;
|
2141
|
+
|
2142
|
+
if (typeof x === 'object' && x !== null) {
|
2143
|
+
// $FlowFixMe[method-unbinding]
|
2144
|
+
if (typeof x.then === 'function') {
|
2145
|
+
// Something suspended, we'll need to create a new task and resolve it later.
|
2146
|
+
request.pendingChunks++;
|
2147
|
+
var newTask = createTask(request, value, getActiveContext(), request.abortableTasks);
|
2148
|
+
var ping = newTask.ping;
|
2149
|
+
x.then(ping, ping);
|
2150
|
+
newTask.thenableState = getThenableStateAfterSuspending();
|
2151
|
+
return serializeLazyID(newTask.id);
|
2152
|
+
}
|
2153
|
+
} // Something errored. We'll still send everything we have up until this point.
|
2151
2154
|
// We'll replace this element with a lazy reference that throws on the client
|
2152
2155
|
// once it gets rendered.
|
2156
|
+
|
2157
|
+
|
2153
2158
|
request.pendingChunks++;
|
2154
2159
|
var errorId = request.nextChunkId++;
|
2155
2160
|
var digest = logRecoverableError(request, x);
|
2156
2161
|
emitErrorChunk(request, errorId, digest, x);
|
2157
2162
|
return serializeLazyID(errorId);
|
2158
|
-
}
|
2159
|
-
// it by value because it'll just error the whole parent row anyway so we can
|
2160
|
-
// just stop any siblings and error the whole parent row.
|
2161
|
-
|
2162
|
-
|
2163
|
-
throw x;
|
2164
|
-
}
|
2165
|
-
}
|
2166
|
-
|
2167
|
-
function renderModelDestructive(request, task, parent, parentPropertyName, value) {
|
2168
|
-
// Set the currently rendering model
|
2169
|
-
task.model = value; // Special Symbol, that's very common.
|
2170
|
-
|
2171
|
-
if (value === REACT_ELEMENT_TYPE) {
|
2172
|
-
return '$';
|
2163
|
+
}
|
2173
2164
|
}
|
2174
2165
|
|
2175
2166
|
if (value === null) {
|
@@ -2177,152 +2168,61 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
|
|
2177
2168
|
}
|
2178
2169
|
|
2179
2170
|
if (typeof value === 'object') {
|
2180
|
-
switch (value.$$typeof) {
|
2181
|
-
case REACT_ELEMENT_TYPE:
|
2182
|
-
{
|
2183
|
-
var _writtenObjects = request.writtenObjects;
|
2184
|
-
|
2185
|
-
var _existingId = _writtenObjects.get(value);
|
2186
|
-
|
2187
|
-
if (_existingId !== undefined) {
|
2188
|
-
if (modelRoot === value) {
|
2189
|
-
// This is the ID we're currently emitting so we need to write it
|
2190
|
-
// once but if we discover it again, we refer to it by id.
|
2191
|
-
modelRoot = null;
|
2192
|
-
} else if (_existingId === -1) {
|
2193
|
-
// Seen but not yet outlined.
|
2194
|
-
// TODO: If we throw here we can treat this as suspending which causes an outline
|
2195
|
-
// but that is able to reuse the same task if we're already in one but then that
|
2196
|
-
// will be a lazy future value rather than guaranteed to exist but maybe that's good.
|
2197
|
-
var newId = outlineModel(request, value);
|
2198
|
-
return serializeByValueID(newId);
|
2199
|
-
} else {
|
2200
|
-
// We've already emitted this as an outlined object, so we can refer to that by its
|
2201
|
-
// existing ID. TODO: We should use a lazy reference since, unlike plain objects,
|
2202
|
-
// elements might suspend so it might not have emitted yet even if we have the ID for
|
2203
|
-
// it. However, this creates an extra wrapper when it's not needed. We should really
|
2204
|
-
// detect whether this already was emitted and synchronously available. In that
|
2205
|
-
// case we can refer to it synchronously and only make it lazy otherwise.
|
2206
|
-
// We currently don't have a data structure that lets us see that though.
|
2207
|
-
return serializeByValueID(_existingId);
|
2208
|
-
}
|
2209
|
-
} else {
|
2210
|
-
// This is the first time we've seen this object. We may never see it again
|
2211
|
-
// so we'll inline it. Mark it as seen. If we see it again, we'll outline.
|
2212
|
-
_writtenObjects.set(value, -1);
|
2213
|
-
}
|
2214
|
-
|
2215
|
-
var element = value;
|
2216
|
-
|
2217
|
-
{
|
2218
|
-
var debugInfo = value._debugInfo;
|
2219
|
-
|
2220
|
-
if (debugInfo) {
|
2221
|
-
// If this came from Flight, forward any debug info into this new row.
|
2222
|
-
if (debugID === null) {
|
2223
|
-
// We don't have a chunk to assign debug info. We need to outline this
|
2224
|
-
// component to assign it an ID.
|
2225
|
-
return outlineTask(request, task);
|
2226
|
-
} else {
|
2227
|
-
// Forward any debug info we have the first time we see it.
|
2228
|
-
forwardDebugInfo(request, debugID, debugInfo);
|
2229
|
-
}
|
2230
|
-
}
|
2231
|
-
}
|
2232
|
-
|
2233
|
-
var props = element.props;
|
2234
|
-
var ref;
|
2235
|
-
|
2236
|
-
{
|
2237
|
-
ref = element.ref;
|
2238
|
-
} // Attempt to render the Server Component.
|
2239
|
-
|
2240
|
-
|
2241
|
-
return renderElement(request, task, element.type, // $FlowFixMe[incompatible-call] the key of an element is null | string
|
2242
|
-
element.key, ref, props);
|
2243
|
-
}
|
2244
|
-
|
2245
|
-
case REACT_LAZY_TYPE:
|
2246
|
-
{
|
2247
|
-
// Reset the task's thenable state before continuing. If there was one, it was
|
2248
|
-
// from suspending the lazy before.
|
2249
|
-
task.thenableState = null;
|
2250
|
-
var lazy = value;
|
2251
|
-
var payload = lazy._payload;
|
2252
|
-
var init = lazy._init;
|
2253
|
-
var resolvedModel = init(payload);
|
2254
|
-
|
2255
|
-
{
|
2256
|
-
var _debugInfo = lazy._debugInfo;
|
2257
|
-
|
2258
|
-
if (_debugInfo) {
|
2259
|
-
// If this came from Flight, forward any debug info into this new row.
|
2260
|
-
if (debugID === null) {
|
2261
|
-
// We don't have a chunk to assign debug info. We need to outline this
|
2262
|
-
// component to assign it an ID.
|
2263
|
-
return outlineTask(request, task);
|
2264
|
-
} else {
|
2265
|
-
// Forward any debug info we have the first time we see it.
|
2266
|
-
// We do this after init so that we have received all the debug info
|
2267
|
-
// from the server by the time we emit it.
|
2268
|
-
forwardDebugInfo(request, debugID, _debugInfo);
|
2269
|
-
}
|
2270
|
-
}
|
2271
|
-
}
|
2272
|
-
|
2273
|
-
return renderModelDestructive(request, task, emptyRoot, '', resolvedModel);
|
2274
|
-
}
|
2275
|
-
}
|
2276
2171
|
|
2277
2172
|
if (isClientReference(value)) {
|
2278
|
-
return serializeClientReference(request, parent,
|
2173
|
+
return serializeClientReference(request, parent, key, value);
|
2279
2174
|
}
|
2280
2175
|
|
2281
|
-
var
|
2282
|
-
|
2176
|
+
var _writtenObjects = request.writtenObjects;
|
2177
|
+
|
2178
|
+
var _existingId = _writtenObjects.get(value); // $FlowFixMe[method-unbinding]
|
2179
|
+
|
2283
2180
|
|
2284
2181
|
if (typeof value.then === 'function') {
|
2285
|
-
if (
|
2182
|
+
if (_existingId !== undefined) {
|
2286
2183
|
if (modelRoot === value) {
|
2287
2184
|
// This is the ID we're currently emitting so we need to write it
|
2288
2185
|
// once but if we discover it again, we refer to it by id.
|
2289
2186
|
modelRoot = null;
|
2290
2187
|
} else {
|
2291
2188
|
// We've seen this promise before, so we can just refer to the same result.
|
2292
|
-
return serializePromiseID(
|
2189
|
+
return serializePromiseID(_existingId);
|
2293
2190
|
}
|
2294
2191
|
} // We assume that any object with a .then property is a "Thenable" type,
|
2295
2192
|
// or a Promise type. Either of which can be represented by a Promise.
|
2296
2193
|
|
2297
2194
|
|
2298
|
-
var promiseId = serializeThenable(request,
|
2299
|
-
|
2195
|
+
var promiseId = serializeThenable(request, value);
|
2196
|
+
|
2197
|
+
_writtenObjects.set(value, promiseId);
|
2198
|
+
|
2300
2199
|
return serializePromiseID(promiseId);
|
2301
2200
|
}
|
2302
2201
|
|
2303
|
-
if (
|
2304
|
-
if (
|
2305
|
-
// This is the ID we're currently emitting so we need to write it
|
2306
|
-
// once but if we discover it again, we refer to it by id.
|
2307
|
-
modelRoot = null;
|
2308
|
-
} else if (existingId === -1) {
|
2202
|
+
if (_existingId !== undefined) {
|
2203
|
+
if (_existingId === -1) {
|
2309
2204
|
// Seen but not yet outlined.
|
2310
2205
|
var _newId = outlineModel(request, value);
|
2311
2206
|
|
2312
2207
|
return serializeByValueID(_newId);
|
2208
|
+
} else if (modelRoot === value) {
|
2209
|
+
// This is the ID we're currently emitting so we need to write it
|
2210
|
+
// once but if we discover it again, we refer to it by id.
|
2211
|
+
modelRoot = null;
|
2313
2212
|
} else {
|
2314
2213
|
// We've already emitted this as an outlined object, so we can
|
2315
2214
|
// just refer to that by its existing ID.
|
2316
|
-
return serializeByValueID(
|
2215
|
+
return serializeByValueID(_existingId);
|
2317
2216
|
}
|
2318
2217
|
} else {
|
2319
2218
|
// This is the first time we've seen this object. We may never see it again
|
2320
2219
|
// so we'll inline it. Mark it as seen. If we see it again, we'll outline.
|
2321
|
-
|
2220
|
+
_writtenObjects.set(value, -1);
|
2322
2221
|
}
|
2323
2222
|
|
2324
2223
|
if (isArray(value)) {
|
2325
|
-
return
|
2224
|
+
// $FlowFixMe[incompatible-return]
|
2225
|
+
return value;
|
2326
2226
|
}
|
2327
2227
|
|
2328
2228
|
if (value instanceof Map) {
|
@@ -2336,7 +2236,7 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
|
|
2336
2236
|
var iteratorFn = getIteratorFn(value);
|
2337
2237
|
|
2338
2238
|
if (iteratorFn) {
|
2339
|
-
return
|
2239
|
+
return Array.from(value);
|
2340
2240
|
} // Verify that this is a simple plain object.
|
2341
2241
|
|
2342
2242
|
|
@@ -2348,14 +2248,14 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
|
|
2348
2248
|
|
2349
2249
|
{
|
2350
2250
|
if (objectName(value) !== 'Object') {
|
2351
|
-
error('Only plain objects can be passed to Client Components from Server Components. ' + '%s objects are not supported.%s', objectName(value), describeObjectForErrorMessage(parent,
|
2251
|
+
error('Only plain objects can be passed to Client Components from Server Components. ' + '%s objects are not supported.%s', objectName(value), describeObjectForErrorMessage(parent, key));
|
2352
2252
|
} else if (!isSimpleObject(value)) {
|
2353
|
-
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,
|
2253
|
+
error('Only plain objects can be passed to Client Components from Server Components. ' + 'Classes or other objects with methods are not supported.%s', describeObjectForErrorMessage(parent, key));
|
2354
2254
|
} else if (Object.getOwnPropertySymbols) {
|
2355
2255
|
var symbols = Object.getOwnPropertySymbols(value);
|
2356
2256
|
|
2357
2257
|
if (symbols.length > 0) {
|
2358
|
-
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,
|
2258
|
+
error('Only plain objects can be passed to Client Components from Server Components. ' + 'Objects with symbol properties like %s are not supported.%s', symbols[0].description, describeObjectForErrorMessage(parent, key));
|
2359
2259
|
}
|
2360
2260
|
}
|
2361
2261
|
} // $FlowFixMe[incompatible-return]
|
@@ -2370,9 +2270,9 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
|
|
2370
2270
|
if (value[value.length - 1] === 'Z') {
|
2371
2271
|
// Possibly a Date, whose toJSON automatically calls toISOString
|
2372
2272
|
// $FlowFixMe[incompatible-use]
|
2373
|
-
var
|
2273
|
+
var _originalValue = parent[key];
|
2374
2274
|
|
2375
|
-
if (
|
2275
|
+
if (_originalValue instanceof Date) {
|
2376
2276
|
return serializeDateFromDateJSON(value);
|
2377
2277
|
}
|
2378
2278
|
}
|
@@ -2400,21 +2300,19 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
|
|
2400
2300
|
}
|
2401
2301
|
|
2402
2302
|
if (typeof value === 'function') {
|
2303
|
+
|
2403
2304
|
if (isClientReference(value)) {
|
2404
|
-
return serializeClientReference(request, parent,
|
2305
|
+
return serializeClientReference(request, parent, key, value);
|
2405
2306
|
}
|
2406
2307
|
|
2407
2308
|
if (isServerReference(value)) {
|
2408
|
-
return serializeServerReference(request, value);
|
2309
|
+
return serializeServerReference(request, parent, key, value);
|
2409
2310
|
}
|
2410
2311
|
|
2411
|
-
if (/^on[A-Z]/.test(
|
2412
|
-
throw new Error('Event handlers cannot be passed to Client Component props.' + describeObjectForErrorMessage(parent,
|
2413
|
-
} else if ((jsxChildrenParents.has(parent) || jsxPropsParents.has(parent) && parentPropertyName === 'children')) {
|
2414
|
-
var componentName = value.displayName || value.name || 'Component';
|
2415
|
-
throw new Error('Functions are not valid as a child of Client Components. This may happen if ' + 'you return ' + componentName + ' instead of <' + componentName + ' /> from render. ' + 'Or maybe you meant to call this function rather than return it.' + describeObjectForErrorMessage(parent, parentPropertyName));
|
2312
|
+
if (/^on[A-Z]/.test(key)) {
|
2313
|
+
throw new Error('Event handlers cannot be passed to Client Component props.' + describeObjectForErrorMessage(parent, key) + '\nIf you need interactivity, consider converting part of this to a Client Component.');
|
2416
2314
|
} else {
|
2417
|
-
throw new Error('Functions cannot be passed directly to Client Components ' + 'unless you explicitly expose it by marking it with "use server".
|
2315
|
+
throw new Error('Functions cannot be passed directly to Client Components ' + 'unless you explicitly expose it by marking it with "use server".' + describeObjectForErrorMessage(parent, key));
|
2418
2316
|
}
|
2419
2317
|
}
|
2420
2318
|
|
@@ -2432,7 +2330,7 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
|
|
2432
2330
|
|
2433
2331
|
if (Symbol.for(name) !== value) {
|
2434
2332
|
throw new Error('Only global symbols received from Symbol.for(...) can be passed to Client Components. ' + ("The symbol Symbol.for(" + // $FlowFixMe[incompatible-type] `description` might be undefined
|
2435
|
-
value.description + ") cannot be found among global symbols.") + describeObjectForErrorMessage(parent,
|
2333
|
+
value.description + ") cannot be found among global symbols.") + describeObjectForErrorMessage(parent, key));
|
2436
2334
|
}
|
2437
2335
|
|
2438
2336
|
request.pendingChunks++;
|
@@ -2447,40 +2345,17 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
|
|
2447
2345
|
return serializeBigInt(value);
|
2448
2346
|
}
|
2449
2347
|
|
2450
|
-
throw new Error("Type " + typeof value + " is not supported in Client Component props." + describeObjectForErrorMessage(parent,
|
2348
|
+
throw new Error("Type " + typeof value + " is not supported in Client Component props." + describeObjectForErrorMessage(parent, key));
|
2451
2349
|
}
|
2452
2350
|
|
2453
2351
|
function logPostpone(request, reason) {
|
2454
|
-
var
|
2455
|
-
|
2456
|
-
|
2457
|
-
try {
|
2458
|
-
var onPostpone = request.onPostpone;
|
2459
|
-
|
2460
|
-
if (supportsRequestStorage) {
|
2461
|
-
// Exit the request context while running callbacks.
|
2462
|
-
requestStorage.run(undefined, onPostpone, reason);
|
2463
|
-
}
|
2464
|
-
} finally {
|
2465
|
-
currentRequest = prevRequest;
|
2466
|
-
}
|
2352
|
+
var onPostpone = request.onPostpone;
|
2353
|
+
onPostpone(reason);
|
2467
2354
|
}
|
2468
2355
|
|
2469
2356
|
function logRecoverableError(request, error) {
|
2470
|
-
var
|
2471
|
-
|
2472
|
-
var errorDigest;
|
2473
|
-
|
2474
|
-
try {
|
2475
|
-
var onError = request.onError;
|
2476
|
-
|
2477
|
-
if (supportsRequestStorage) {
|
2478
|
-
// Exit the request context while running callbacks.
|
2479
|
-
errorDigest = requestStorage.run(undefined, onError, error);
|
2480
|
-
}
|
2481
|
-
} finally {
|
2482
|
-
currentRequest = prevRequest;
|
2483
|
-
}
|
2357
|
+
var onError = request.onError;
|
2358
|
+
var errorDigest = onError(error);
|
2484
2359
|
|
2485
2360
|
if (errorDigest != null && typeof errorDigest !== 'string') {
|
2486
2361
|
// eslint-disable-next-line react-internal/prod-error-codes
|
@@ -2539,11 +2414,8 @@ function emitErrorChunk(request, id, digest, error) {
|
|
2539
2414
|
message = String(error.message); // eslint-disable-next-line react-internal/safe-string-coercion
|
2540
2415
|
|
2541
2416
|
stack = String(error.stack);
|
2542
|
-
} else if (typeof error === 'object' && error !== null) {
|
2543
|
-
message = describeObjectForErrorMessage(error);
|
2544
2417
|
} else {
|
2545
|
-
|
2546
|
-
message = String(error);
|
2418
|
+
message = 'Error: ' + error;
|
2547
2419
|
}
|
2548
2420
|
} catch (x) {
|
2549
2421
|
message = 'An error occurred but serializing the error message failed.';
|
@@ -2583,79 +2455,62 @@ function emitSymbolChunk(request, id, name) {
|
|
2583
2455
|
request.completedImportChunks.push(processedChunk);
|
2584
2456
|
}
|
2585
2457
|
|
2586
|
-
function emitModelChunk(request, id,
|
2587
|
-
|
2588
|
-
|
2589
|
-
|
2590
|
-
|
2591
|
-
|
2592
|
-
function emitDebugChunk(request, id, debugInfo) {
|
2458
|
+
function emitModelChunk(request, id, model) {
|
2459
|
+
// Track the root so we know that we have to emit this object even though it
|
2460
|
+
// already has an ID. This is needed because we might see this object twice
|
2461
|
+
// in the same toJSON if it is cyclic.
|
2462
|
+
modelRoot = model; // $FlowFixMe[incompatible-type] stringify can return null
|
2593
2463
|
|
2594
|
-
|
2595
|
-
var
|
2596
|
-
var row = serializeRowHeader('D', id) + json + '\n';
|
2464
|
+
var json = stringify(model, request.toJSON);
|
2465
|
+
var row = id.toString(16) + ':' + json + '\n';
|
2597
2466
|
var processedChunk = stringToChunk(row);
|
2598
2467
|
request.completedRegularChunks.push(processedChunk);
|
2599
2468
|
}
|
2600
2469
|
|
2601
|
-
function forwardDebugInfo(request, id, debugInfo) {
|
2602
|
-
for (var i = 0; i < debugInfo.length; i++) {
|
2603
|
-
request.pendingChunks++;
|
2604
|
-
emitDebugChunk(request, id, debugInfo[i]);
|
2605
|
-
}
|
2606
|
-
}
|
2607
|
-
|
2608
|
-
var emptyRoot = {};
|
2609
|
-
|
2610
2470
|
function retryTask(request, task) {
|
2611
2471
|
if (task.status !== PENDING$1) {
|
2612
2472
|
// We completed this by other means before we had a chance to retry it.
|
2613
2473
|
return;
|
2614
2474
|
}
|
2615
2475
|
|
2616
|
-
|
2476
|
+
switchContext(task.context);
|
2617
2477
|
|
2618
2478
|
try {
|
2619
|
-
|
2620
|
-
// already has an ID. This is needed because we might see this object twice
|
2621
|
-
// in the same toJSON if it is cyclic.
|
2622
|
-
modelRoot = task.model;
|
2479
|
+
var value = task.model;
|
2623
2480
|
|
2624
|
-
if (
|
2625
|
-
|
2626
|
-
debugID = task.id;
|
2627
|
-
} // We call the destructive form that mutates this task. That way if something
|
2628
|
-
// suspends again, we can reuse the same task instead of spawning a new one.
|
2481
|
+
if (typeof value === 'object' && value !== null && value.$$typeof === REACT_ELEMENT_TYPE) {
|
2482
|
+
request.writtenObjects.set(value, task.id); // TODO: Concatenate keys of parents onto children.
|
2629
2483
|
|
2484
|
+
var element = value; // When retrying a component, reuse the thenableState from the
|
2485
|
+
// previous attempt.
|
2630
2486
|
|
2631
|
-
|
2487
|
+
var prevThenableState = task.thenableState; // Attempt to render the Server Component.
|
2488
|
+
// Doing this here lets us reuse this same task if the next component
|
2489
|
+
// also suspends.
|
2632
2490
|
|
2633
|
-
|
2634
|
-
|
2635
|
-
//
|
2636
|
-
debugID = null;
|
2637
|
-
} // Track the root again for the resolved object.
|
2491
|
+
task.model = value;
|
2492
|
+
value = attemptResolveElement(request, element.type, element.key, element.ref, element.props, prevThenableState); // Successfully finished this component. We're going to keep rendering
|
2493
|
+
// using the same task, but we reset its thenable state before continuing.
|
2638
2494
|
|
2495
|
+
task.thenableState = null; // Keep rendering and reuse the same task. This inner loop is separate
|
2496
|
+
// from the render above because we don't need to reset the thenable state
|
2497
|
+
// until the next time something suspends and retries.
|
2639
2498
|
|
2640
|
-
|
2499
|
+
while (typeof value === 'object' && value !== null && value.$$typeof === REACT_ELEMENT_TYPE) {
|
2500
|
+
request.writtenObjects.set(value, task.id); // TODO: Concatenate keys of parents onto children.
|
2641
2501
|
|
2642
|
-
|
2643
|
-
|
2644
|
-
|
2502
|
+
var nextElement = value;
|
2503
|
+
task.model = value;
|
2504
|
+
value = attemptResolveElement(request, nextElement.type, nextElement.key, nextElement.ref, nextElement.props, null);
|
2505
|
+
}
|
2506
|
+
} // Track that this object is outlined and has an id.
|
2645
2507
|
|
2646
|
-
|
2647
|
-
|
2648
|
-
|
2649
|
-
// $FlowFixMe[incompatible-type] stringify can return null for undefined but we never do
|
2650
|
-
json = stringify(resolvedModel, task.toJSON);
|
2651
|
-
} else {
|
2652
|
-
// If the value is a string, it means it's a terminal value and we already escaped it
|
2653
|
-
// We don't need to escape it again so it's not passed the toJSON replacer.
|
2654
|
-
// $FlowFixMe[incompatible-type] stringify can return null for undefined but we never do
|
2655
|
-
json = stringify(resolvedModel);
|
2508
|
+
|
2509
|
+
if (typeof value === 'object' && value !== null) {
|
2510
|
+
request.writtenObjects.set(value, task.id);
|
2656
2511
|
}
|
2657
2512
|
|
2658
|
-
emitModelChunk(request, task.id,
|
2513
|
+
emitModelChunk(request, task.id, value);
|
2659
2514
|
request.abortableTasks.delete(task);
|
2660
2515
|
task.status = COMPLETED;
|
2661
2516
|
} catch (thrownValue) {
|
@@ -2681,10 +2536,6 @@ function retryTask(request, task) {
|
|
2681
2536
|
task.status = ERRORED$1;
|
2682
2537
|
var digest = logRecoverableError(request, x);
|
2683
2538
|
emitErrorChunk(request, task.id, digest, x);
|
2684
|
-
} finally {
|
2685
|
-
{
|
2686
|
-
debugID = prevDebugID;
|
2687
|
-
}
|
2688
2539
|
}
|
2689
2540
|
}
|
2690
2541
|
|
@@ -2899,6 +2750,11 @@ function abort(request, reason) {
|
|
2899
2750
|
}
|
2900
2751
|
}
|
2901
2752
|
|
2753
|
+
function importServerContexts(contexts) {
|
2754
|
+
|
2755
|
+
return rootContextSnapshot;
|
2756
|
+
}
|
2757
|
+
|
2902
2758
|
function resolveServerReference(bundlerConfig, id) {
|
2903
2759
|
var idx = id.lastIndexOf('#');
|
2904
2760
|
var specifier = id.slice(0, idx);
|
@@ -3624,7 +3480,7 @@ function createCancelHandler(request, reason) {
|
|
3624
3480
|
}
|
3625
3481
|
|
3626
3482
|
function renderToPipeableStream(model, webpackMap, options) {
|
3627
|
-
var request = createRequest(model, webpackMap, options ? options.onError : undefined, options ? options.
|
3483
|
+
var request = createRequest(model, webpackMap, options ? options.onError : undefined, options ? options.context : undefined, options ? options.identifierPrefix : undefined, options ? options.onPostpone : undefined);
|
3628
3484
|
var hasStartedFlowing = false;
|
3629
3485
|
startWork(request);
|
3630
3486
|
return {
|