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