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
@@ -62,7 +62,7 @@ var enablePostpone = false;
|
|
62
62
|
function scheduleWork(callback) {
|
63
63
|
setTimeout(callback, 0);
|
64
64
|
}
|
65
|
-
var VIEW_SIZE =
|
65
|
+
var VIEW_SIZE = 2048;
|
66
66
|
var currentView = null;
|
67
67
|
var writtenBytes = 0;
|
68
68
|
function beginWriting(destination) {
|
@@ -75,15 +75,9 @@ function writeChunk(destination, chunk) {
|
|
75
75
|
}
|
76
76
|
|
77
77
|
if (chunk.byteLength > VIEW_SIZE) {
|
78
|
-
|
79
|
-
if (precomputedChunkSet.has(chunk)) {
|
80
|
-
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.');
|
81
|
-
}
|
82
|
-
} // this chunk may overflow a single view which implies it was not
|
78
|
+
// this chunk may overflow a single view which implies it was not
|
83
79
|
// one that is cached by the streaming renderer. We will enqueu
|
84
80
|
// it directly and expect it is not re-used
|
85
|
-
|
86
|
-
|
87
81
|
if (writtenBytes > 0) {
|
88
82
|
destination.enqueue(new Uint8Array(currentView.buffer, 0, writtenBytes));
|
89
83
|
currentView = new Uint8Array(VIEW_SIZE);
|
@@ -138,7 +132,6 @@ var textEncoder = new TextEncoder();
|
|
138
132
|
function stringToChunk(content) {
|
139
133
|
return textEncoder.encode(content);
|
140
134
|
}
|
141
|
-
var precomputedChunkSet = new Set() ;
|
142
135
|
function byteLengthOfChunk(chunk) {
|
143
136
|
return chunk.byteLength;
|
144
137
|
}
|
@@ -159,10 +152,10 @@ function closeWithError(destination, error) {
|
|
159
152
|
}
|
160
153
|
|
161
154
|
// eslint-disable-next-line no-unused-vars
|
162
|
-
var CLIENT_REFERENCE_TAG
|
155
|
+
var CLIENT_REFERENCE_TAG = Symbol.for('react.client.reference');
|
163
156
|
var SERVER_REFERENCE_TAG = Symbol.for('react.server.reference');
|
164
157
|
function isClientReference(reference) {
|
165
|
-
return reference.$$typeof === CLIENT_REFERENCE_TAG
|
158
|
+
return reference.$$typeof === CLIENT_REFERENCE_TAG;
|
166
159
|
}
|
167
160
|
function isServerReference(reference) {
|
168
161
|
return reference.$$typeof === SERVER_REFERENCE_TAG;
|
@@ -174,7 +167,7 @@ function registerClientReference(proxyImplementation, id, exportName) {
|
|
174
167
|
function registerClientReferenceImpl(proxyImplementation, id, async) {
|
175
168
|
return Object.defineProperties(proxyImplementation, {
|
176
169
|
$$typeof: {
|
177
|
-
value: CLIENT_REFERENCE_TAG
|
170
|
+
value: CLIENT_REFERENCE_TAG
|
178
171
|
},
|
179
172
|
$$id: {
|
180
173
|
value: id
|
@@ -195,14 +188,6 @@ function bind() {
|
|
195
188
|
var newFn = FunctionBind.apply(this, arguments);
|
196
189
|
|
197
190
|
if (this.$$typeof === SERVER_REFERENCE_TAG) {
|
198
|
-
{
|
199
|
-
var thisBind = arguments[0];
|
200
|
-
|
201
|
-
if (thisBind != null) {
|
202
|
-
error('Cannot bind "this" of a Server Action. Pass null or undefined as the first argument to .bind().');
|
203
|
-
}
|
204
|
-
}
|
205
|
-
|
206
191
|
var args = ArraySlice.call(arguments, 1);
|
207
192
|
return Object.defineProperties(newFn, {
|
208
193
|
$$typeof: {
|
@@ -229,16 +214,13 @@ function registerServerReference(reference, id, exportName) {
|
|
229
214
|
value: SERVER_REFERENCE_TAG
|
230
215
|
},
|
231
216
|
$$id: {
|
232
|
-
value: exportName === null ? id : id + '#' + exportName
|
233
|
-
configurable: true
|
217
|
+
value: exportName === null ? id : id + '#' + exportName
|
234
218
|
},
|
235
219
|
$$bound: {
|
236
|
-
value: null
|
237
|
-
configurable: true
|
220
|
+
value: null
|
238
221
|
},
|
239
222
|
bind: {
|
240
|
-
value: bind
|
241
|
-
configurable: true
|
223
|
+
value: bind
|
242
224
|
}
|
243
225
|
});
|
244
226
|
}
|
@@ -277,10 +259,6 @@ var deepProxyHandlers = {
|
|
277
259
|
// $FlowFixMe[prop-missing]
|
278
260
|
return Object.prototype[Symbol.toPrimitive];
|
279
261
|
|
280
|
-
case Symbol.toStringTag:
|
281
|
-
// $FlowFixMe[prop-missing]
|
282
|
-
return Object.prototype[Symbol.toStringTag];
|
283
|
-
|
284
262
|
case 'Provider':
|
285
263
|
throw new Error("Cannot render a Client Context Provider on the Server. " + "Instead, you can export a Client Component wrapper " + "that itself renders a Client Context Provider.");
|
286
264
|
} // eslint-disable-next-line react-internal/safe-string-coercion
|
@@ -322,10 +300,6 @@ function getReference(target, name) {
|
|
322
300
|
// $FlowFixMe[prop-missing]
|
323
301
|
return Object.prototype[Symbol.toPrimitive];
|
324
302
|
|
325
|
-
case Symbol.toStringTag:
|
326
|
-
// $FlowFixMe[prop-missing]
|
327
|
-
return Object.prototype[Symbol.toStringTag];
|
328
|
-
|
329
303
|
case '__esModule':
|
330
304
|
// Something is conditionally checking which export to use. We'll pretend to be
|
331
305
|
// an ESM compat module but then we'll check again on the client.
|
@@ -366,10 +340,6 @@ function getReference(target, name) {
|
|
366
340
|
|
367
341
|
}
|
368
342
|
|
369
|
-
if (typeof name === 'symbol') {
|
370
|
-
throw new Error('Cannot read Symbol exports. Only named exports are supported on a client module ' + 'imported on the server.');
|
371
|
-
}
|
372
|
-
|
373
343
|
var cachedReference = target[name];
|
374
344
|
|
375
345
|
if (!cachedReference) {
|
@@ -462,9 +432,7 @@ function getServerReferenceBoundArguments(config, serverReference) {
|
|
462
432
|
|
463
433
|
var ReactDOMSharedInternals = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
464
434
|
|
465
|
-
var
|
466
|
-
var previousDispatcher = ReactDOMCurrentDispatcher.current;
|
467
|
-
ReactDOMCurrentDispatcher.current = {
|
435
|
+
var ReactDOMFlightServerDispatcher = {
|
468
436
|
prefetchDNS: prefetchDNS,
|
469
437
|
preconnect: preconnect,
|
470
438
|
preload: preload,
|
@@ -490,8 +458,6 @@ function prefetchDNS(href) {
|
|
490
458
|
|
491
459
|
hints.add(key);
|
492
460
|
emitHint(request, 'D', href);
|
493
|
-
} else {
|
494
|
-
previousDispatcher.prefetchDNS(href);
|
495
461
|
}
|
496
462
|
}
|
497
463
|
}
|
@@ -518,8 +484,6 @@ function preconnect(href, crossOrigin) {
|
|
518
484
|
} else {
|
519
485
|
emitHint(request, 'C', href);
|
520
486
|
}
|
521
|
-
} else {
|
522
|
-
previousDispatcher.preconnect(href, crossOrigin);
|
523
487
|
}
|
524
488
|
}
|
525
489
|
}
|
@@ -553,8 +517,6 @@ function preload(href, as, options) {
|
|
553
517
|
} else {
|
554
518
|
emitHint(request, 'L', [href, as]);
|
555
519
|
}
|
556
|
-
} else {
|
557
|
-
previousDispatcher.preload(href, as, options);
|
558
520
|
}
|
559
521
|
}
|
560
522
|
}
|
@@ -582,8 +544,6 @@ function preloadModule$1(href, options) {
|
|
582
544
|
} else {
|
583
545
|
return emitHint(request, 'm', href);
|
584
546
|
}
|
585
|
-
} else {
|
586
|
-
previousDispatcher.preloadModule(href, options);
|
587
547
|
}
|
588
548
|
}
|
589
549
|
}
|
@@ -613,21 +573,19 @@ function preinitStyle(href, precedence, options) {
|
|
613
573
|
} else {
|
614
574
|
return emitHint(request, 'S', href);
|
615
575
|
}
|
616
|
-
} else {
|
617
|
-
previousDispatcher.preinitStyle(href, precedence, options);
|
618
576
|
}
|
619
577
|
}
|
620
578
|
}
|
621
579
|
}
|
622
580
|
|
623
|
-
function preinitScript(
|
581
|
+
function preinitScript(href, options) {
|
624
582
|
{
|
625
|
-
if (typeof
|
583
|
+
if (typeof href === 'string') {
|
626
584
|
var request = resolveRequest();
|
627
585
|
|
628
586
|
if (request) {
|
629
587
|
var hints = getHints(request);
|
630
|
-
var key = 'X|' +
|
588
|
+
var key = 'X|' + href;
|
631
589
|
|
632
590
|
if (hints.has(key)) {
|
633
591
|
// duplicate hint
|
@@ -638,25 +596,23 @@ function preinitScript(src, options) {
|
|
638
596
|
var trimmed = trimOptions(options);
|
639
597
|
|
640
598
|
if (trimmed) {
|
641
|
-
return emitHint(request, 'X', [
|
599
|
+
return emitHint(request, 'X', [href, trimmed]);
|
642
600
|
} else {
|
643
|
-
return emitHint(request, 'X',
|
601
|
+
return emitHint(request, 'X', href);
|
644
602
|
}
|
645
|
-
} else {
|
646
|
-
previousDispatcher.preinitScript(src, options);
|
647
603
|
}
|
648
604
|
}
|
649
605
|
}
|
650
606
|
}
|
651
607
|
|
652
|
-
function preinitModuleScript(
|
608
|
+
function preinitModuleScript(href, options) {
|
653
609
|
{
|
654
|
-
if (typeof
|
610
|
+
if (typeof href === 'string') {
|
655
611
|
var request = resolveRequest();
|
656
612
|
|
657
613
|
if (request) {
|
658
614
|
var hints = getHints(request);
|
659
|
-
var key = 'M|' +
|
615
|
+
var key = 'M|' + href;
|
660
616
|
|
661
617
|
if (hints.has(key)) {
|
662
618
|
// duplicate hint
|
@@ -667,12 +623,10 @@ function preinitModuleScript(src, options) {
|
|
667
623
|
var trimmed = trimOptions(options);
|
668
624
|
|
669
625
|
if (trimmed) {
|
670
|
-
return emitHint(request, 'M', [
|
626
|
+
return emitHint(request, 'M', [href, trimmed]);
|
671
627
|
} else {
|
672
|
-
return emitHint(request, 'M',
|
628
|
+
return emitHint(request, 'M', href);
|
673
629
|
}
|
674
|
-
} else {
|
675
|
-
previousDispatcher.preinitModuleScript(src, options);
|
676
630
|
}
|
677
631
|
}
|
678
632
|
}
|
@@ -714,7 +668,10 @@ function getImagePreloadKey(href, imageSrcSet, imageSizes) {
|
|
714
668
|
return "[image]" + uniquePart;
|
715
669
|
}
|
716
670
|
|
717
|
-
|
671
|
+
var ReactDOMCurrentDispatcher = ReactDOMSharedInternals.Dispatcher;
|
672
|
+
function prepareHostDispatcher() {
|
673
|
+
ReactDOMCurrentDispatcher.current = ReactDOMFlightServerDispatcher;
|
674
|
+
} // Used to distinguish these contexts from ones used in other renderers.
|
718
675
|
// small, smaller than how we encode undefined, and is unambiguous. We could use
|
719
676
|
// a different tuple structure to encode this instead but this makes the runtime
|
720
677
|
// cost cheaper by eliminating a type checks in more positions.
|
@@ -741,7 +698,7 @@ typeof async_hooks === 'object' ? async_hooks.executionAsyncId : null;
|
|
741
698
|
// The Symbol used to tag the ReactElement-like types.
|
742
699
|
var REACT_ELEMENT_TYPE = Symbol.for('react.element');
|
743
700
|
var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
|
744
|
-
var
|
701
|
+
var REACT_SERVER_CONTEXT_TYPE = Symbol.for('react.server_context');
|
745
702
|
var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');
|
746
703
|
var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');
|
747
704
|
var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');
|
@@ -765,6 +722,146 @@ function getIteratorFn(maybeIterable) {
|
|
765
722
|
return null;
|
766
723
|
}
|
767
724
|
|
725
|
+
// Forming a reverse tree.
|
726
|
+
// The structure of a context snapshot is an implementation of this file.
|
727
|
+
// Currently, it's implemented as tracking the current active node.
|
728
|
+
|
729
|
+
|
730
|
+
var rootContextSnapshot = null; // We assume that this runtime owns the "current" field on all ReactContext instances.
|
731
|
+
// This global (actually thread local) state represents what state all those "current",
|
732
|
+
// fields are currently in.
|
733
|
+
|
734
|
+
var currentActiveSnapshot = null;
|
735
|
+
|
736
|
+
function popNode(prev) {
|
737
|
+
{
|
738
|
+
prev.context._currentValue = prev.parentValue;
|
739
|
+
}
|
740
|
+
}
|
741
|
+
|
742
|
+
function pushNode(next) {
|
743
|
+
{
|
744
|
+
next.context._currentValue = next.value;
|
745
|
+
}
|
746
|
+
}
|
747
|
+
|
748
|
+
function popToNearestCommonAncestor(prev, next) {
|
749
|
+
if (prev === next) ; else {
|
750
|
+
popNode(prev);
|
751
|
+
var parentPrev = prev.parent;
|
752
|
+
var parentNext = next.parent;
|
753
|
+
|
754
|
+
if (parentPrev === null) {
|
755
|
+
if (parentNext !== null) {
|
756
|
+
throw new Error('The stacks must reach the root at the same time. This is a bug in React.');
|
757
|
+
}
|
758
|
+
} else {
|
759
|
+
if (parentNext === null) {
|
760
|
+
throw new Error('The stacks must reach the root at the same time. This is a bug in React.');
|
761
|
+
}
|
762
|
+
|
763
|
+
popToNearestCommonAncestor(parentPrev, parentNext); // On the way back, we push the new ones that weren't common.
|
764
|
+
|
765
|
+
pushNode(next);
|
766
|
+
}
|
767
|
+
}
|
768
|
+
}
|
769
|
+
|
770
|
+
function popAllPrevious(prev) {
|
771
|
+
popNode(prev);
|
772
|
+
var parentPrev = prev.parent;
|
773
|
+
|
774
|
+
if (parentPrev !== null) {
|
775
|
+
popAllPrevious(parentPrev);
|
776
|
+
}
|
777
|
+
}
|
778
|
+
|
779
|
+
function pushAllNext(next) {
|
780
|
+
var parentNext = next.parent;
|
781
|
+
|
782
|
+
if (parentNext !== null) {
|
783
|
+
pushAllNext(parentNext);
|
784
|
+
}
|
785
|
+
|
786
|
+
pushNode(next);
|
787
|
+
}
|
788
|
+
|
789
|
+
function popPreviousToCommonLevel(prev, next) {
|
790
|
+
popNode(prev);
|
791
|
+
var parentPrev = prev.parent;
|
792
|
+
|
793
|
+
if (parentPrev === null) {
|
794
|
+
throw new Error('The depth must equal at least at zero before reaching the root. This is a bug in React.');
|
795
|
+
}
|
796
|
+
|
797
|
+
if (parentPrev.depth === next.depth) {
|
798
|
+
// We found the same level. Now we just need to find a shared ancestor.
|
799
|
+
popToNearestCommonAncestor(parentPrev, next);
|
800
|
+
} else {
|
801
|
+
// We must still be deeper.
|
802
|
+
popPreviousToCommonLevel(parentPrev, next);
|
803
|
+
}
|
804
|
+
}
|
805
|
+
|
806
|
+
function popNextToCommonLevel(prev, next) {
|
807
|
+
var parentNext = next.parent;
|
808
|
+
|
809
|
+
if (parentNext === null) {
|
810
|
+
throw new Error('The depth must equal at least at zero before reaching the root. This is a bug in React.');
|
811
|
+
}
|
812
|
+
|
813
|
+
if (prev.depth === parentNext.depth) {
|
814
|
+
// We found the same level. Now we just need to find a shared ancestor.
|
815
|
+
popToNearestCommonAncestor(prev, parentNext);
|
816
|
+
} else {
|
817
|
+
// We must still be deeper.
|
818
|
+
popNextToCommonLevel(prev, parentNext);
|
819
|
+
}
|
820
|
+
|
821
|
+
pushNode(next);
|
822
|
+
} // Perform context switching to the new snapshot.
|
823
|
+
// To make it cheap to read many contexts, while not suspending, we make the switch eagerly by
|
824
|
+
// updating all the context's current values. That way reads, always just read the current value.
|
825
|
+
// At the cost of updating contexts even if they're never read by this subtree.
|
826
|
+
|
827
|
+
|
828
|
+
function switchContext(newSnapshot) {
|
829
|
+
// The basic algorithm we need to do is to pop back any contexts that are no longer on the stack.
|
830
|
+
// We also need to update any new contexts that are now on the stack with the deepest value.
|
831
|
+
// The easiest way to update new contexts is to just reapply them in reverse order from the
|
832
|
+
// perspective of the backpointers. To avoid allocating a lot when switching, we use the stack
|
833
|
+
// for that. Therefore this algorithm is recursive.
|
834
|
+
// 1) First we pop which ever snapshot tree was deepest. Popping old contexts as we go.
|
835
|
+
// 2) Then we find the nearest common ancestor from there. Popping old contexts as we go.
|
836
|
+
// 3) Then we reapply new contexts on the way back up the stack.
|
837
|
+
var prev = currentActiveSnapshot;
|
838
|
+
var next = newSnapshot;
|
839
|
+
|
840
|
+
if (prev !== next) {
|
841
|
+
if (prev === null) {
|
842
|
+
// $FlowFixMe[incompatible-call]: This has to be non-null since it's not equal to prev.
|
843
|
+
pushAllNext(next);
|
844
|
+
} else if (next === null) {
|
845
|
+
popAllPrevious(prev);
|
846
|
+
} else if (prev.depth === next.depth) {
|
847
|
+
popToNearestCommonAncestor(prev, next);
|
848
|
+
} else if (prev.depth > next.depth) {
|
849
|
+
popPreviousToCommonLevel(prev, next);
|
850
|
+
} else {
|
851
|
+
popNextToCommonLevel(prev, next);
|
852
|
+
}
|
853
|
+
|
854
|
+
currentActiveSnapshot = next;
|
855
|
+
}
|
856
|
+
}
|
857
|
+
function getActiveContext() {
|
858
|
+
return currentActiveSnapshot;
|
859
|
+
}
|
860
|
+
function readContext$1(context) {
|
861
|
+
var value = context._currentValue ;
|
862
|
+
return value;
|
863
|
+
}
|
864
|
+
|
768
865
|
// Corresponds to ReactFiberWakeable and ReactFizzWakeable modules. Generally,
|
769
866
|
// changes to one module should be reflected in the others.
|
770
867
|
// TODO: Rename this module and the corresponding Fiber one to "Thenable"
|
@@ -893,13 +990,29 @@ function prepareToUseHooksForComponent(prevThenableState) {
|
|
893
990
|
thenableState = prevThenableState;
|
894
991
|
}
|
895
992
|
function getThenableStateAfterSuspending() {
|
896
|
-
|
897
|
-
// which is not really supported anymore, it will be empty. We use the empty set as a
|
898
|
-
// marker to know if this was a replay of the same component or first attempt.
|
899
|
-
var state = thenableState || createThenableState();
|
993
|
+
var state = thenableState;
|
900
994
|
thenableState = null;
|
901
995
|
return state;
|
902
996
|
}
|
997
|
+
|
998
|
+
function readContext(context) {
|
999
|
+
{
|
1000
|
+
if (context.$$typeof !== REACT_SERVER_CONTEXT_TYPE) {
|
1001
|
+
if (isClientReference(context)) {
|
1002
|
+
error('Cannot read a Client Context from a Server Component.');
|
1003
|
+
} else {
|
1004
|
+
error('Only createServerContext is supported in Server Components.');
|
1005
|
+
}
|
1006
|
+
}
|
1007
|
+
|
1008
|
+
if (currentRequest$1 === null) {
|
1009
|
+
error('Context can only be read while React is rendering. ' + 'In classes, you can read it in the render method or getDerivedStateFromProps. ' + 'In function components, you can read it directly in the function body, but not ' + 'inside Hooks like useReducer() or useMemo().');
|
1010
|
+
}
|
1011
|
+
}
|
1012
|
+
|
1013
|
+
return readContext$1(context);
|
1014
|
+
}
|
1015
|
+
|
903
1016
|
var HooksDispatcher = {
|
904
1017
|
useMemo: function (nextCreate) {
|
905
1018
|
return nextCreate();
|
@@ -910,8 +1023,8 @@ var HooksDispatcher = {
|
|
910
1023
|
useDebugValue: function () {},
|
911
1024
|
useDeferredValue: unsupportedHook,
|
912
1025
|
useTransition: unsupportedHook,
|
913
|
-
readContext:
|
914
|
-
useContext:
|
1026
|
+
readContext: readContext,
|
1027
|
+
useContext: readContext,
|
915
1028
|
useReducer: unsupportedHook,
|
916
1029
|
useRef: unsupportedHook,
|
917
1030
|
useState: unsupportedHook,
|
@@ -944,10 +1057,6 @@ function unsupportedRefresh() {
|
|
944
1057
|
throw new Error('Refreshing the cache is not supported in Server Components.');
|
945
1058
|
}
|
946
1059
|
|
947
|
-
function unsupportedContext() {
|
948
|
-
throw new Error('Cannot read a Client Context from a Server Component.');
|
949
|
-
}
|
950
|
-
|
951
1060
|
function useId() {
|
952
1061
|
if (currentRequest$1 === null) {
|
953
1062
|
throw new Error('useId can only be used while React is rendering');
|
@@ -973,22 +1082,20 @@ function use(usable) {
|
|
973
1082
|
}
|
974
1083
|
|
975
1084
|
return trackUsedThenable(thenableState, thenable, index);
|
976
|
-
} else if (usable.$$typeof ===
|
977
|
-
|
1085
|
+
} else if (usable.$$typeof === REACT_SERVER_CONTEXT_TYPE) {
|
1086
|
+
var context = usable;
|
1087
|
+
return readContext(context);
|
978
1088
|
}
|
979
1089
|
}
|
980
1090
|
|
981
|
-
|
982
|
-
if (usable
|
983
|
-
|
984
|
-
throw new Error('Cannot read a Client Context from a Server Component.');
|
985
|
-
} else {
|
986
|
-
throw new Error('Cannot use() an already resolved Client Reference.');
|
1091
|
+
{
|
1092
|
+
if (isClientReference(usable)) {
|
1093
|
+
error('Cannot use() an already resolved Client Reference.');
|
987
1094
|
}
|
988
|
-
}
|
989
|
-
|
990
|
-
|
991
|
-
|
1095
|
+
} // eslint-disable-next-line react-internal/safe-string-coercion
|
1096
|
+
|
1097
|
+
|
1098
|
+
throw new Error('An unsupported type was passed to use(): ' + String(usable));
|
992
1099
|
}
|
993
1100
|
|
994
1101
|
function createSignal() {
|
@@ -1126,10 +1233,6 @@ function describeValueForErrorMessage(value) {
|
|
1126
1233
|
return '[...]';
|
1127
1234
|
}
|
1128
1235
|
|
1129
|
-
if (value !== null && value.$$typeof === CLIENT_REFERENCE_TAG) {
|
1130
|
-
return describeClientReference();
|
1131
|
-
}
|
1132
|
-
|
1133
1236
|
var name = objectName(value);
|
1134
1237
|
|
1135
1238
|
if (name === 'Object') {
|
@@ -1140,15 +1243,7 @@ function describeValueForErrorMessage(value) {
|
|
1140
1243
|
}
|
1141
1244
|
|
1142
1245
|
case 'function':
|
1143
|
-
|
1144
|
-
if (value.$$typeof === CLIENT_REFERENCE_TAG) {
|
1145
|
-
return describeClientReference();
|
1146
|
-
}
|
1147
|
-
|
1148
|
-
var _name = value.displayName || value.name;
|
1149
|
-
|
1150
|
-
return _name ? 'function ' + _name : 'function';
|
1151
|
-
}
|
1246
|
+
return 'function';
|
1152
1247
|
|
1153
1248
|
default:
|
1154
1249
|
// eslint-disable-next-line react-internal/safe-string-coercion
|
@@ -1194,12 +1289,6 @@ function describeElementType(type) {
|
|
1194
1289
|
return '';
|
1195
1290
|
}
|
1196
1291
|
|
1197
|
-
var CLIENT_REFERENCE_TAG = Symbol.for('react.client.reference');
|
1198
|
-
|
1199
|
-
function describeClientReference(ref) {
|
1200
|
-
return 'client';
|
1201
|
-
}
|
1202
|
-
|
1203
1292
|
function describeObjectForErrorMessage(objectOrArray, expandedName) {
|
1204
1293
|
var objKind = objectName(objectOrArray);
|
1205
1294
|
|
@@ -1278,8 +1367,6 @@ function describeObjectForErrorMessage(objectOrArray, expandedName) {
|
|
1278
1367
|
} else {
|
1279
1368
|
if (objectOrArray.$$typeof === REACT_ELEMENT_TYPE) {
|
1280
1369
|
str = '<' + describeElementType(objectOrArray.type) + '/>';
|
1281
|
-
} else if (objectOrArray.$$typeof === CLIENT_REFERENCE_TAG) {
|
1282
|
-
return describeClientReference();
|
1283
1370
|
} else if (jsxPropsParents.has(objectOrArray)) {
|
1284
1371
|
// Print JSX
|
1285
1372
|
var _type = jsxPropsParents.get(objectOrArray);
|
@@ -1330,9 +1417,9 @@ function describeObjectForErrorMessage(objectOrArray, expandedName) {
|
|
1330
1417
|
str += ', ';
|
1331
1418
|
}
|
1332
1419
|
|
1333
|
-
var
|
1334
|
-
str += describeKeyForErrorMessage(
|
1335
|
-
var _value3 = _object[
|
1420
|
+
var _name = _names[_i3];
|
1421
|
+
str += describeKeyForErrorMessage(_name) + ': ';
|
1422
|
+
var _value3 = _object[_name];
|
1336
1423
|
|
1337
1424
|
var _substr3 = void 0;
|
1338
1425
|
|
@@ -1342,7 +1429,7 @@ function describeObjectForErrorMessage(objectOrArray, expandedName) {
|
|
1342
1429
|
_substr3 = describeValueForErrorMessage(_value3);
|
1343
1430
|
}
|
1344
1431
|
|
1345
|
-
if (
|
1432
|
+
if (_name === expandedName) {
|
1346
1433
|
start = str.length;
|
1347
1434
|
length = _substr3.length;
|
1348
1435
|
str += _substr3;
|
@@ -1397,11 +1484,12 @@ function defaultPostponeHandler(reason) {// Noop
|
|
1397
1484
|
var OPEN = 0;
|
1398
1485
|
var CLOSING = 1;
|
1399
1486
|
var CLOSED = 2;
|
1400
|
-
function createRequest(model, bundlerConfig, onError, identifierPrefix, onPostpone
|
1487
|
+
function createRequest(model, bundlerConfig, onError, context, identifierPrefix, onPostpone) {
|
1401
1488
|
if (ReactCurrentCache.current !== null && ReactCurrentCache.current !== DefaultCacheDispatcher) {
|
1402
1489
|
throw new Error('Currently React only supports one RSC renderer at a time.');
|
1403
1490
|
}
|
1404
1491
|
|
1492
|
+
prepareHostDispatcher();
|
1405
1493
|
ReactCurrentCache.current = DefaultCacheDispatcher;
|
1406
1494
|
var abortSet = new Set();
|
1407
1495
|
var pingedTasks = [];
|
@@ -1427,19 +1515,21 @@ function createRequest(model, bundlerConfig, onError, identifierPrefix, onPostpo
|
|
1427
1515
|
writtenSymbols: new Map(),
|
1428
1516
|
writtenClientReferences: new Map(),
|
1429
1517
|
writtenServerReferences: new Map(),
|
1518
|
+
writtenProviders: new Map(),
|
1430
1519
|
writtenObjects: new WeakMap(),
|
1431
1520
|
identifierPrefix: identifierPrefix || '',
|
1432
1521
|
identifierCount: 1,
|
1433
1522
|
taintCleanupQueue: cleanupQueue,
|
1434
1523
|
onError: onError === undefined ? defaultErrorHandler : onError,
|
1435
|
-
onPostpone: onPostpone === undefined ? defaultPostponeHandler : onPostpone
|
1524
|
+
onPostpone: onPostpone === undefined ? defaultPostponeHandler : onPostpone,
|
1525
|
+
// $FlowFixMe[missing-this-annot]
|
1526
|
+
toJSON: function (key, value) {
|
1527
|
+
return resolveModelToJSON(request, this, key, value);
|
1528
|
+
}
|
1436
1529
|
};
|
1437
|
-
|
1438
|
-
|
1439
|
-
|
1440
|
-
}
|
1441
|
-
|
1442
|
-
var rootTask = createTask(request, model, null, false, abortSet);
|
1530
|
+
request.pendingChunks++;
|
1531
|
+
var rootContext = createRootContext();
|
1532
|
+
var rootTask = createTask(request, model, rootContext, abortSet);
|
1443
1533
|
pingedTasks.push(rootTask);
|
1444
1534
|
return request;
|
1445
1535
|
}
|
@@ -1455,18 +1545,13 @@ function resolveRequest() {
|
|
1455
1545
|
return null;
|
1456
1546
|
}
|
1457
1547
|
|
1458
|
-
function
|
1459
|
-
|
1460
|
-
|
1461
|
-
|
1462
|
-
{
|
1463
|
-
// If this came from Flight, forward any debug info into this new row.
|
1464
|
-
var debugInfo = thenable._debugInfo;
|
1548
|
+
function createRootContext(reqContext) {
|
1549
|
+
return importServerContexts();
|
1550
|
+
}
|
1465
1551
|
|
1466
|
-
|
1467
|
-
|
1468
|
-
|
1469
|
-
}
|
1552
|
+
function serializeThenable(request, thenable) {
|
1553
|
+
request.pendingChunks++;
|
1554
|
+
var newTask = createTask(request, null, getActiveContext(), request.abortableTasks);
|
1470
1555
|
|
1471
1556
|
switch (thenable.status) {
|
1472
1557
|
case 'fulfilled':
|
@@ -1602,136 +1687,14 @@ function createLazyWrapperAroundWakeable(wakeable) {
|
|
1602
1687
|
_payload: thenable,
|
1603
1688
|
_init: readThenable
|
1604
1689
|
};
|
1605
|
-
|
1606
|
-
{
|
1607
|
-
// If this came from React, transfer the debug info.
|
1608
|
-
lazyType._debugInfo = thenable._debugInfo || [];
|
1609
|
-
}
|
1610
|
-
|
1611
1690
|
return lazyType;
|
1612
1691
|
}
|
1613
1692
|
|
1614
|
-
function
|
1615
|
-
// Reset the task's thenable state before continuing, so that if a later
|
1616
|
-
// component suspends we can reuse the same task object. If the same
|
1617
|
-
// component suspends again, the thenable state will be restored.
|
1618
|
-
var prevThenableState = task.thenableState;
|
1619
|
-
task.thenableState = null;
|
1620
|
-
|
1621
|
-
{
|
1622
|
-
if (debugID === null) {
|
1623
|
-
// We don't have a chunk to assign debug info. We need to outline this
|
1624
|
-
// component to assign it an ID.
|
1625
|
-
return outlineTask(request, task);
|
1626
|
-
} else if (prevThenableState !== null) ; else {
|
1627
|
-
// This is a new component in the same task so we can emit more debug info.
|
1628
|
-
var componentName = Component.displayName || Component.name || '';
|
1629
|
-
request.pendingChunks++;
|
1630
|
-
emitDebugChunk(request, debugID, {
|
1631
|
-
name: componentName,
|
1632
|
-
env: request.environmentName
|
1633
|
-
});
|
1634
|
-
}
|
1635
|
-
}
|
1636
|
-
|
1637
|
-
prepareToUseHooksForComponent(prevThenableState); // The secondArg is always undefined in Server Components since refs error early.
|
1638
|
-
|
1639
|
-
var secondArg = undefined;
|
1640
|
-
var result = Component(props, secondArg);
|
1641
|
-
|
1642
|
-
if (typeof result === 'object' && result !== null && typeof result.then === 'function') {
|
1643
|
-
// When the return value is in children position we can resolve it immediately,
|
1644
|
-
// to its value without a wrapper if it's synchronously available.
|
1645
|
-
var thenable = result;
|
1646
|
-
|
1647
|
-
if (thenable.status === 'fulfilled') {
|
1648
|
-
return thenable.value;
|
1649
|
-
} // TODO: Once we accept Promises as children on the client, we can just return
|
1650
|
-
// the thenable here.
|
1651
|
-
|
1652
|
-
|
1653
|
-
result = createLazyWrapperAroundWakeable(result);
|
1654
|
-
} // Track this element's key on the Server Component on the keyPath context..
|
1655
|
-
|
1656
|
-
|
1657
|
-
var prevKeyPath = task.keyPath;
|
1658
|
-
var prevImplicitSlot = task.implicitSlot;
|
1659
|
-
|
1660
|
-
if (key !== null) {
|
1661
|
-
// Append the key to the path. Technically a null key should really add the child
|
1662
|
-
// index. We don't do that to hold the payload small and implementation simple.
|
1663
|
-
task.keyPath = prevKeyPath === null ? key : prevKeyPath + ',' + key;
|
1664
|
-
} else if (prevKeyPath === null) {
|
1665
|
-
// This sequence of Server Components has no keys. This means that it was rendered
|
1666
|
-
// in a slot that needs to assign an implicit key. Even if children below have
|
1667
|
-
// explicit keys, they should not be used for the outer most key since it might
|
1668
|
-
// collide with other slots in that set.
|
1669
|
-
task.implicitSlot = true;
|
1670
|
-
}
|
1671
|
-
|
1672
|
-
var json = renderModelDestructive(request, task, emptyRoot, '', result);
|
1673
|
-
task.keyPath = prevKeyPath;
|
1674
|
-
task.implicitSlot = prevImplicitSlot;
|
1675
|
-
return json;
|
1676
|
-
}
|
1677
|
-
|
1678
|
-
function renderFragment(request, task, children) {
|
1679
|
-
{
|
1680
|
-
var debugInfo = children._debugInfo;
|
1681
|
-
|
1682
|
-
if (debugInfo) {
|
1683
|
-
// If this came from Flight, forward any debug info into this new row.
|
1684
|
-
if (debugID === null) {
|
1685
|
-
// We don't have a chunk to assign debug info. We need to outline this
|
1686
|
-
// component to assign it an ID.
|
1687
|
-
return outlineTask(request, task);
|
1688
|
-
} else {
|
1689
|
-
// Forward any debug info we have the first time we see it.
|
1690
|
-
// We do this after init so that we have received all the debug info
|
1691
|
-
// from the server by the time we emit it.
|
1692
|
-
forwardDebugInfo(request, debugID, debugInfo);
|
1693
|
-
}
|
1694
|
-
}
|
1695
|
-
}
|
1696
|
-
|
1697
|
-
{
|
1698
|
-
return children;
|
1699
|
-
}
|
1700
|
-
}
|
1701
|
-
|
1702
|
-
function renderClientElement(task, type, key, props) {
|
1703
|
-
{
|
1704
|
-
return [REACT_ELEMENT_TYPE, type, key, props];
|
1705
|
-
} // We prepend the terminal client element that actually gets serialized with
|
1706
|
-
} // The chunk ID we're currently rendering that we can assign debug data to.
|
1707
|
-
|
1708
|
-
|
1709
|
-
var debugID = null;
|
1710
|
-
|
1711
|
-
function outlineTask(request, task) {
|
1712
|
-
var newTask = createTask(request, task.model, // the currently rendering element
|
1713
|
-
task.keyPath, // unlike outlineModel this one carries along context
|
1714
|
-
task.implicitSlot, request.abortableTasks);
|
1715
|
-
retryTask(request, newTask);
|
1716
|
-
|
1717
|
-
if (newTask.status === COMPLETED) {
|
1718
|
-
// We completed synchronously so we can refer to this by reference. This
|
1719
|
-
// makes it behaves the same as prod during deserialization.
|
1720
|
-
return serializeByValueID(newTask.id);
|
1721
|
-
} // This didn't complete synchronously so it wouldn't have even if we didn't
|
1722
|
-
// outline it, so this would reduce to a lazy reference even in prod.
|
1723
|
-
|
1724
|
-
|
1725
|
-
return serializeLazyID(newTask.id);
|
1726
|
-
}
|
1727
|
-
|
1728
|
-
function renderElement(request, task, type, key, ref, props) {
|
1693
|
+
function attemptResolveElement(request, type, key, ref, props, prevThenableState) {
|
1729
1694
|
if (ref !== null && ref !== undefined) {
|
1730
1695
|
// When the ref moves to the regular props object this will implicitly
|
1731
1696
|
// throw for functions. We could probably relax it to a DEV warning for other
|
1732
1697
|
// cases.
|
1733
|
-
// TODO: `ref` is now just a prop when `enableRefAsProp` is on. Should we
|
1734
|
-
// do what the above comment says?
|
1735
1698
|
throw new Error('Refs cannot be used in Server Components, nor passed to Client Components.');
|
1736
1699
|
}
|
1737
1700
|
|
@@ -1746,36 +1709,47 @@ function renderElement(request, task, type, key, ref, props) {
|
|
1746
1709
|
if (typeof type === 'function') {
|
1747
1710
|
if (isClientReference(type)) {
|
1748
1711
|
// This is a reference to a Client Component.
|
1749
|
-
return
|
1750
|
-
} // This is a
|
1712
|
+
return [REACT_ELEMENT_TYPE, type, key, props];
|
1713
|
+
} // This is a server-side component.
|
1714
|
+
|
1715
|
+
|
1716
|
+
prepareToUseHooksForComponent(prevThenableState);
|
1717
|
+
var result = type(props);
|
1751
1718
|
|
1719
|
+
if (typeof result === 'object' && result !== null && typeof result.then === 'function') {
|
1720
|
+
// When the return value is in children position we can resolve it immediately,
|
1721
|
+
// to its value without a wrapper if it's synchronously available.
|
1722
|
+
var thenable = result;
|
1752
1723
|
|
1753
|
-
|
1724
|
+
if (thenable.status === 'fulfilled') {
|
1725
|
+
return thenable.value;
|
1726
|
+
} // TODO: Once we accept Promises as children on the client, we can just return
|
1727
|
+
// the thenable here.
|
1728
|
+
|
1729
|
+
|
1730
|
+
return createLazyWrapperAroundWakeable(result);
|
1731
|
+
}
|
1732
|
+
|
1733
|
+
return result;
|
1754
1734
|
} else if (typeof type === 'string') {
|
1755
1735
|
// This is a host element. E.g. HTML.
|
1756
|
-
return
|
1736
|
+
return [REACT_ELEMENT_TYPE, type, key, props];
|
1757
1737
|
} else if (typeof type === 'symbol') {
|
1758
|
-
if (type === REACT_FRAGMENT_TYPE
|
1738
|
+
if (type === REACT_FRAGMENT_TYPE) {
|
1759
1739
|
// For key-less fragments, we add a small optimization to avoid serializing
|
1760
1740
|
// it as a wrapper.
|
1761
|
-
|
1762
|
-
|
1763
|
-
|
1764
|
-
task.implicitSlot = true;
|
1765
|
-
}
|
1766
|
-
|
1767
|
-
var json = renderModelDestructive(request, task, emptyRoot, '', props.children);
|
1768
|
-
task.implicitSlot = prevImplicitSlot;
|
1769
|
-
return json;
|
1741
|
+
// TODO: If a key is specified, we should propagate its key to any children.
|
1742
|
+
// Same as if a Server Component has a key.
|
1743
|
+
return props.children;
|
1770
1744
|
} // This might be a built-in React component. We'll let the client decide.
|
1771
1745
|
// Any built-in works as long as its props are serializable.
|
1772
1746
|
|
1773
1747
|
|
1774
|
-
return
|
1748
|
+
return [REACT_ELEMENT_TYPE, type, key, props];
|
1775
1749
|
} else if (type != null && typeof type === 'object') {
|
1776
1750
|
if (isClientReference(type)) {
|
1777
1751
|
// This is a reference to a Client Component.
|
1778
|
-
return
|
1752
|
+
return [REACT_ELEMENT_TYPE, type, key, props];
|
1779
1753
|
}
|
1780
1754
|
|
1781
1755
|
switch (type.$$typeof) {
|
@@ -1784,17 +1758,19 @@ function renderElement(request, task, type, key, ref, props) {
|
|
1784
1758
|
var payload = type._payload;
|
1785
1759
|
var init = type._init;
|
1786
1760
|
var wrappedType = init(payload);
|
1787
|
-
return
|
1761
|
+
return attemptResolveElement(request, wrappedType, key, ref, props, prevThenableState);
|
1788
1762
|
}
|
1789
1763
|
|
1790
1764
|
case REACT_FORWARD_REF_TYPE:
|
1791
1765
|
{
|
1792
|
-
|
1766
|
+
var render = type.render;
|
1767
|
+
prepareToUseHooksForComponent(prevThenableState);
|
1768
|
+
return render(props, undefined);
|
1793
1769
|
}
|
1794
1770
|
|
1795
1771
|
case REACT_MEMO_TYPE:
|
1796
1772
|
{
|
1797
|
-
return
|
1773
|
+
return attemptResolveElement(request, type.type, key, ref, props, prevThenableState);
|
1798
1774
|
}
|
1799
1775
|
}
|
1800
1776
|
}
|
@@ -1814,51 +1790,16 @@ function pingTask(request, task) {
|
|
1814
1790
|
}
|
1815
1791
|
}
|
1816
1792
|
|
1817
|
-
function createTask(request, model,
|
1818
|
-
request.pendingChunks++;
|
1793
|
+
function createTask(request, model, context, abortSet) {
|
1819
1794
|
var id = request.nextChunkId++;
|
1820
|
-
|
1821
|
-
if (typeof model === 'object' && model !== null) {
|
1822
|
-
// If we're about to write this into a new task we can assign it an ID early so that
|
1823
|
-
// any other references can refer to the value we're about to write.
|
1824
|
-
{
|
1825
|
-
request.writtenObjects.set(model, id);
|
1826
|
-
}
|
1827
|
-
}
|
1828
|
-
|
1829
1795
|
var task = {
|
1830
1796
|
id: id,
|
1831
1797
|
status: PENDING$1,
|
1832
1798
|
model: model,
|
1833
|
-
|
1834
|
-
implicitSlot: implicitSlot,
|
1799
|
+
context: context,
|
1835
1800
|
ping: function () {
|
1836
1801
|
return pingTask(request, task);
|
1837
1802
|
},
|
1838
|
-
toJSON: function (parentPropertyName, value) {
|
1839
|
-
var parent = this; // Make sure that `parent[parentPropertyName]` wasn't JSONified before `value` was passed to us
|
1840
|
-
|
1841
|
-
{
|
1842
|
-
// $FlowFixMe[incompatible-use]
|
1843
|
-
var originalValue = parent[parentPropertyName];
|
1844
|
-
|
1845
|
-
if (typeof originalValue === 'object' && originalValue !== value && !(originalValue instanceof Date)) {
|
1846
|
-
if (objectName(originalValue) !== 'Object') {
|
1847
|
-
var jsxParentType = jsxChildrenParents.get(parent);
|
1848
|
-
|
1849
|
-
if (typeof jsxParentType === 'string') {
|
1850
|
-
error('%s objects cannot be rendered as text children. Try formatting it using toString().%s', objectName(originalValue), describeObjectForErrorMessage(parent, parentPropertyName));
|
1851
|
-
} else {
|
1852
|
-
error('Only plain objects can be passed to Client Components from Server Components. ' + '%s objects are not supported.%s', objectName(originalValue), describeObjectForErrorMessage(parent, parentPropertyName));
|
1853
|
-
}
|
1854
|
-
} else {
|
1855
|
-
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));
|
1856
|
-
}
|
1857
|
-
}
|
1858
|
-
}
|
1859
|
-
|
1860
|
-
return renderModel(request, task, parent, parentPropertyName, value);
|
1861
|
-
},
|
1862
1803
|
thenableState: null
|
1863
1804
|
};
|
1864
1805
|
abortSet.add(task);
|
@@ -1927,13 +1868,13 @@ function encodeReferenceChunk(request, id, reference) {
|
|
1927
1868
|
return stringToChunk(row);
|
1928
1869
|
}
|
1929
1870
|
|
1930
|
-
function serializeClientReference(request, parent,
|
1871
|
+
function serializeClientReference(request, parent, key, clientReference) {
|
1931
1872
|
var clientReferenceKey = getClientReferenceKey(clientReference);
|
1932
1873
|
var writtenClientReferences = request.writtenClientReferences;
|
1933
1874
|
var existingId = writtenClientReferences.get(clientReferenceKey);
|
1934
1875
|
|
1935
1876
|
if (existingId !== undefined) {
|
1936
|
-
if (parent[0] === REACT_ELEMENT_TYPE &&
|
1877
|
+
if (parent[0] === REACT_ELEMENT_TYPE && key === '1') {
|
1937
1878
|
// If we're encoding the "type" of an element, we can refer
|
1938
1879
|
// to that by a lazy reference instead of directly since React
|
1939
1880
|
// knows how to deal with lazy values. This lets us suspend
|
@@ -1952,7 +1893,7 @@ function serializeClientReference(request, parent, parentPropertyName, clientRef
|
|
1952
1893
|
emitImportChunk(request, importId, clientReferenceMetadata);
|
1953
1894
|
writtenClientReferences.set(clientReferenceKey, importId);
|
1954
1895
|
|
1955
|
-
if (parent[0] === REACT_ELEMENT_TYPE &&
|
1896
|
+
if (parent[0] === REACT_ELEMENT_TYPE && key === '1') {
|
1956
1897
|
// If we're encoding the "type" of an element, we can refer
|
1957
1898
|
// to that by a lazy reference instead of directly since React
|
1958
1899
|
// knows how to deal with lazy values. This lets us suspend
|
@@ -1972,14 +1913,13 @@ function serializeClientReference(request, parent, parentPropertyName, clientRef
|
|
1972
1913
|
}
|
1973
1914
|
|
1974
1915
|
function outlineModel(request, value) {
|
1975
|
-
|
1976
|
-
|
1977
|
-
request.abortableTasks);
|
1916
|
+
request.pendingChunks++;
|
1917
|
+
var newTask = createTask(request, value, getActiveContext(), request.abortableTasks);
|
1978
1918
|
retryTask(request, newTask);
|
1979
1919
|
return newTask.id;
|
1980
1920
|
}
|
1981
1921
|
|
1982
|
-
function serializeServerReference(request, serverReference) {
|
1922
|
+
function serializeServerReference(request, parent, key, serverReference) {
|
1983
1923
|
var writtenServerReferences = request.writtenServerReferences;
|
1984
1924
|
var existingId = writtenServerReferences.get(serverReference);
|
1985
1925
|
|
@@ -2059,77 +1999,110 @@ function escapeStringValue(value) {
|
|
2059
1999
|
return value;
|
2060
2000
|
}
|
2061
2001
|
}
|
2062
|
-
|
2063
2002
|
var modelRoot = false;
|
2064
2003
|
|
2065
|
-
function
|
2066
|
-
|
2067
|
-
|
2004
|
+
function resolveModelToJSON(request, parent, key, value) {
|
2005
|
+
// Make sure that `parent[key]` wasn't JSONified before `value` was passed to us
|
2006
|
+
{
|
2007
|
+
// $FlowFixMe[incompatible-use]
|
2008
|
+
var originalValue = parent[key];
|
2068
2009
|
|
2069
|
-
|
2070
|
-
|
2071
|
-
|
2072
|
-
var x = thrownValue === SuspenseException ? // This is a special type of exception used for Suspense. For historical
|
2073
|
-
// reasons, the rest of the Suspense implementation expects the thrown
|
2074
|
-
// value to be a thenable, because before `use` existed that was the
|
2075
|
-
// (unstable) API for suspending. This implementation detail can change
|
2076
|
-
// later, once we deprecate the old API in favor of `use`.
|
2077
|
-
getSuspendedThenable() : thrownValue; // If the suspended/errored value was an element or lazy it can be reduced
|
2078
|
-
// to a lazy reference, so that it doesn't error the parent.
|
2010
|
+
if (typeof originalValue === 'object' && originalValue !== value && !(originalValue instanceof Date)) {
|
2011
|
+
if (objectName(originalValue) !== 'Object') {
|
2012
|
+
var jsxParentType = jsxChildrenParents.get(parent);
|
2079
2013
|
|
2080
|
-
|
2081
|
-
|
2014
|
+
if (typeof jsxParentType === 'string') {
|
2015
|
+
error('%s objects cannot be rendered as text children. Try formatting it using toString().%s', objectName(originalValue), describeObjectForErrorMessage(parent, key));
|
2016
|
+
} else {
|
2017
|
+
error('Only plain objects can be passed to Client Components from Server Components. ' + '%s objects are not supported.%s', objectName(originalValue), describeObjectForErrorMessage(parent, key));
|
2018
|
+
}
|
2019
|
+
} else {
|
2020
|
+
error('Only plain objects can be passed to Client Components from Server Components. ' + 'Objects with toJSON methods are not supported. Convert it manually ' + 'to a simple value before passing it to props.%s', describeObjectForErrorMessage(parent, key));
|
2021
|
+
}
|
2022
|
+
}
|
2023
|
+
} // Special Symbols
|
2082
2024
|
|
2083
|
-
if (typeof x === 'object' && x !== null) {
|
2084
|
-
// $FlowFixMe[method-unbinding]
|
2085
|
-
if (typeof x.then === 'function') {
|
2086
|
-
// Something suspended, we'll need to create a new task and resolve it later.
|
2087
|
-
var newTask = createTask(request, task.model, task.keyPath, task.implicitSlot, request.abortableTasks);
|
2088
|
-
var ping = newTask.ping;
|
2089
|
-
x.then(ping, ping);
|
2090
|
-
newTask.thenableState = getThenableStateAfterSuspending(); // Restore the context. We assume that this will be restored by the inner
|
2091
|
-
// functions in case nothing throws so we don't use "finally" here.
|
2092
2025
|
|
2093
|
-
|
2094
|
-
|
2026
|
+
switch (value) {
|
2027
|
+
case REACT_ELEMENT_TYPE:
|
2028
|
+
return '$';
|
2029
|
+
}
|
2095
2030
|
|
2096
|
-
if (wasReactNode) {
|
2097
|
-
return serializeLazyID(newTask.id);
|
2098
|
-
}
|
2099
2031
|
|
2100
|
-
|
2101
|
-
|
2102
|
-
|
2103
|
-
|
2032
|
+
while (typeof value === 'object' && value !== null && (value.$$typeof === REACT_ELEMENT_TYPE || value.$$typeof === REACT_LAZY_TYPE)) {
|
2033
|
+
|
2034
|
+
try {
|
2035
|
+
switch (value.$$typeof) {
|
2036
|
+
case REACT_ELEMENT_TYPE:
|
2037
|
+
{
|
2038
|
+
var writtenObjects = request.writtenObjects;
|
2039
|
+
var existingId = writtenObjects.get(value);
|
2040
|
+
|
2041
|
+
if (existingId !== undefined) {
|
2042
|
+
if (existingId === -1) {
|
2043
|
+
// Seen but not yet outlined.
|
2044
|
+
var newId = outlineModel(request, value);
|
2045
|
+
return serializeByValueID(newId);
|
2046
|
+
} else if (modelRoot === value) {
|
2047
|
+
// This is the ID we're currently emitting so we need to write it
|
2048
|
+
// once but if we discover it again, we refer to it by id.
|
2049
|
+
modelRoot = null;
|
2050
|
+
} else {
|
2051
|
+
// We've already emitted this as an outlined object, so we can
|
2052
|
+
// just refer to that by its existing ID.
|
2053
|
+
return serializeByValueID(existingId);
|
2054
|
+
}
|
2055
|
+
} else {
|
2056
|
+
// This is the first time we've seen this object. We may never see it again
|
2057
|
+
// so we'll inline it. Mark it as seen. If we see it again, we'll outline.
|
2058
|
+
writtenObjects.set(value, -1);
|
2059
|
+
} // TODO: Concatenate keys of parents onto children.
|
2060
|
+
|
2104
2061
|
|
2062
|
+
var element = value; // Attempt to render the Server Component.
|
2105
2063
|
|
2106
|
-
|
2107
|
-
|
2064
|
+
value = attemptResolveElement(request, element.type, element.key, element.ref, element.props, null);
|
2065
|
+
break;
|
2066
|
+
}
|
2108
2067
|
|
2109
|
-
|
2110
|
-
|
2068
|
+
case REACT_LAZY_TYPE:
|
2069
|
+
{
|
2070
|
+
var payload = value._payload;
|
2071
|
+
var init = value._init;
|
2072
|
+
value = init(payload);
|
2073
|
+
break;
|
2074
|
+
}
|
2075
|
+
}
|
2076
|
+
} catch (thrownValue) {
|
2077
|
+
var x = thrownValue === SuspenseException ? // This is a special type of exception used for Suspense. For historical
|
2078
|
+
// reasons, the rest of the Suspense implementation expects the thrown
|
2079
|
+
// value to be a thenable, because before `use` existed that was the
|
2080
|
+
// (unstable) API for suspending. This implementation detail can change
|
2081
|
+
// later, once we deprecate the old API in favor of `use`.
|
2082
|
+
getSuspendedThenable() : thrownValue;
|
2083
|
+
|
2084
|
+
if (typeof x === 'object' && x !== null) {
|
2085
|
+
// $FlowFixMe[method-unbinding]
|
2086
|
+
if (typeof x.then === 'function') {
|
2087
|
+
// Something suspended, we'll need to create a new task and resolve it later.
|
2088
|
+
request.pendingChunks++;
|
2089
|
+
var newTask = createTask(request, value, getActiveContext(), request.abortableTasks);
|
2090
|
+
var ping = newTask.ping;
|
2091
|
+
x.then(ping, ping);
|
2092
|
+
newTask.thenableState = getThenableStateAfterSuspending();
|
2093
|
+
return serializeLazyID(newTask.id);
|
2094
|
+
}
|
2095
|
+
} // Something errored. We'll still send everything we have up until this point.
|
2111
2096
|
// We'll replace this element with a lazy reference that throws on the client
|
2112
2097
|
// once it gets rendered.
|
2098
|
+
|
2099
|
+
|
2113
2100
|
request.pendingChunks++;
|
2114
2101
|
var errorId = request.nextChunkId++;
|
2115
2102
|
var digest = logRecoverableError(request, x);
|
2116
2103
|
emitErrorChunk(request, errorId, digest, x);
|
2117
2104
|
return serializeLazyID(errorId);
|
2118
|
-
}
|
2119
|
-
// it by value because it'll just error the whole parent row anyway so we can
|
2120
|
-
// just stop any siblings and error the whole parent row.
|
2121
|
-
|
2122
|
-
|
2123
|
-
throw x;
|
2124
|
-
}
|
2125
|
-
}
|
2126
|
-
|
2127
|
-
function renderModelDestructive(request, task, parent, parentPropertyName, value) {
|
2128
|
-
// Set the currently rendering model
|
2129
|
-
task.model = value; // Special Symbol, that's very common.
|
2130
|
-
|
2131
|
-
if (value === REACT_ELEMENT_TYPE) {
|
2132
|
-
return '$';
|
2105
|
+
}
|
2133
2106
|
}
|
2134
2107
|
|
2135
2108
|
if (value === null) {
|
@@ -2137,152 +2110,61 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
|
|
2137
2110
|
}
|
2138
2111
|
|
2139
2112
|
if (typeof value === 'object') {
|
2140
|
-
switch (value.$$typeof) {
|
2141
|
-
case REACT_ELEMENT_TYPE:
|
2142
|
-
{
|
2143
|
-
var _writtenObjects = request.writtenObjects;
|
2144
|
-
|
2145
|
-
var _existingId = _writtenObjects.get(value);
|
2146
|
-
|
2147
|
-
if (_existingId !== undefined) {
|
2148
|
-
if (modelRoot === value) {
|
2149
|
-
// This is the ID we're currently emitting so we need to write it
|
2150
|
-
// once but if we discover it again, we refer to it by id.
|
2151
|
-
modelRoot = null;
|
2152
|
-
} else if (_existingId === -1) {
|
2153
|
-
// Seen but not yet outlined.
|
2154
|
-
// TODO: If we throw here we can treat this as suspending which causes an outline
|
2155
|
-
// but that is able to reuse the same task if we're already in one but then that
|
2156
|
-
// will be a lazy future value rather than guaranteed to exist but maybe that's good.
|
2157
|
-
var newId = outlineModel(request, value);
|
2158
|
-
return serializeByValueID(newId);
|
2159
|
-
} else {
|
2160
|
-
// We've already emitted this as an outlined object, so we can refer to that by its
|
2161
|
-
// existing ID. TODO: We should use a lazy reference since, unlike plain objects,
|
2162
|
-
// elements might suspend so it might not have emitted yet even if we have the ID for
|
2163
|
-
// it. However, this creates an extra wrapper when it's not needed. We should really
|
2164
|
-
// detect whether this already was emitted and synchronously available. In that
|
2165
|
-
// case we can refer to it synchronously and only make it lazy otherwise.
|
2166
|
-
// We currently don't have a data structure that lets us see that though.
|
2167
|
-
return serializeByValueID(_existingId);
|
2168
|
-
}
|
2169
|
-
} else {
|
2170
|
-
// This is the first time we've seen this object. We may never see it again
|
2171
|
-
// so we'll inline it. Mark it as seen. If we see it again, we'll outline.
|
2172
|
-
_writtenObjects.set(value, -1);
|
2173
|
-
}
|
2174
|
-
|
2175
|
-
var element = value;
|
2176
|
-
|
2177
|
-
{
|
2178
|
-
var debugInfo = value._debugInfo;
|
2179
|
-
|
2180
|
-
if (debugInfo) {
|
2181
|
-
// If this came from Flight, forward any debug info into this new row.
|
2182
|
-
if (debugID === null) {
|
2183
|
-
// We don't have a chunk to assign debug info. We need to outline this
|
2184
|
-
// component to assign it an ID.
|
2185
|
-
return outlineTask(request, task);
|
2186
|
-
} else {
|
2187
|
-
// Forward any debug info we have the first time we see it.
|
2188
|
-
forwardDebugInfo(request, debugID, debugInfo);
|
2189
|
-
}
|
2190
|
-
}
|
2191
|
-
}
|
2192
|
-
|
2193
|
-
var props = element.props;
|
2194
|
-
var ref;
|
2195
|
-
|
2196
|
-
{
|
2197
|
-
ref = element.ref;
|
2198
|
-
} // Attempt to render the Server Component.
|
2199
|
-
|
2200
|
-
|
2201
|
-
return renderElement(request, task, element.type, // $FlowFixMe[incompatible-call] the key of an element is null | string
|
2202
|
-
element.key, ref, props);
|
2203
|
-
}
|
2204
|
-
|
2205
|
-
case REACT_LAZY_TYPE:
|
2206
|
-
{
|
2207
|
-
// Reset the task's thenable state before continuing. If there was one, it was
|
2208
|
-
// from suspending the lazy before.
|
2209
|
-
task.thenableState = null;
|
2210
|
-
var lazy = value;
|
2211
|
-
var payload = lazy._payload;
|
2212
|
-
var init = lazy._init;
|
2213
|
-
var resolvedModel = init(payload);
|
2214
|
-
|
2215
|
-
{
|
2216
|
-
var _debugInfo = lazy._debugInfo;
|
2217
|
-
|
2218
|
-
if (_debugInfo) {
|
2219
|
-
// If this came from Flight, forward any debug info into this new row.
|
2220
|
-
if (debugID === null) {
|
2221
|
-
// We don't have a chunk to assign debug info. We need to outline this
|
2222
|
-
// component to assign it an ID.
|
2223
|
-
return outlineTask(request, task);
|
2224
|
-
} else {
|
2225
|
-
// Forward any debug info we have the first time we see it.
|
2226
|
-
// We do this after init so that we have received all the debug info
|
2227
|
-
// from the server by the time we emit it.
|
2228
|
-
forwardDebugInfo(request, debugID, _debugInfo);
|
2229
|
-
}
|
2230
|
-
}
|
2231
|
-
}
|
2232
|
-
|
2233
|
-
return renderModelDestructive(request, task, emptyRoot, '', resolvedModel);
|
2234
|
-
}
|
2235
|
-
}
|
2236
2113
|
|
2237
2114
|
if (isClientReference(value)) {
|
2238
|
-
return serializeClientReference(request, parent,
|
2115
|
+
return serializeClientReference(request, parent, key, value);
|
2239
2116
|
}
|
2240
2117
|
|
2241
|
-
var
|
2242
|
-
|
2118
|
+
var _writtenObjects = request.writtenObjects;
|
2119
|
+
|
2120
|
+
var _existingId = _writtenObjects.get(value); // $FlowFixMe[method-unbinding]
|
2121
|
+
|
2243
2122
|
|
2244
2123
|
if (typeof value.then === 'function') {
|
2245
|
-
if (
|
2124
|
+
if (_existingId !== undefined) {
|
2246
2125
|
if (modelRoot === value) {
|
2247
2126
|
// This is the ID we're currently emitting so we need to write it
|
2248
2127
|
// once but if we discover it again, we refer to it by id.
|
2249
2128
|
modelRoot = null;
|
2250
2129
|
} else {
|
2251
2130
|
// We've seen this promise before, so we can just refer to the same result.
|
2252
|
-
return serializePromiseID(
|
2131
|
+
return serializePromiseID(_existingId);
|
2253
2132
|
}
|
2254
2133
|
} // We assume that any object with a .then property is a "Thenable" type,
|
2255
2134
|
// or a Promise type. Either of which can be represented by a Promise.
|
2256
2135
|
|
2257
2136
|
|
2258
|
-
var promiseId = serializeThenable(request,
|
2259
|
-
|
2137
|
+
var promiseId = serializeThenable(request, value);
|
2138
|
+
|
2139
|
+
_writtenObjects.set(value, promiseId);
|
2140
|
+
|
2260
2141
|
return serializePromiseID(promiseId);
|
2261
2142
|
}
|
2262
2143
|
|
2263
|
-
if (
|
2264
|
-
if (
|
2265
|
-
// This is the ID we're currently emitting so we need to write it
|
2266
|
-
// once but if we discover it again, we refer to it by id.
|
2267
|
-
modelRoot = null;
|
2268
|
-
} else if (existingId === -1) {
|
2144
|
+
if (_existingId !== undefined) {
|
2145
|
+
if (_existingId === -1) {
|
2269
2146
|
// Seen but not yet outlined.
|
2270
2147
|
var _newId = outlineModel(request, value);
|
2271
2148
|
|
2272
2149
|
return serializeByValueID(_newId);
|
2150
|
+
} else if (modelRoot === value) {
|
2151
|
+
// This is the ID we're currently emitting so we need to write it
|
2152
|
+
// once but if we discover it again, we refer to it by id.
|
2153
|
+
modelRoot = null;
|
2273
2154
|
} else {
|
2274
2155
|
// We've already emitted this as an outlined object, so we can
|
2275
2156
|
// just refer to that by its existing ID.
|
2276
|
-
return serializeByValueID(
|
2157
|
+
return serializeByValueID(_existingId);
|
2277
2158
|
}
|
2278
2159
|
} else {
|
2279
2160
|
// This is the first time we've seen this object. We may never see it again
|
2280
2161
|
// so we'll inline it. Mark it as seen. If we see it again, we'll outline.
|
2281
|
-
|
2162
|
+
_writtenObjects.set(value, -1);
|
2282
2163
|
}
|
2283
2164
|
|
2284
2165
|
if (isArray(value)) {
|
2285
|
-
return
|
2166
|
+
// $FlowFixMe[incompatible-return]
|
2167
|
+
return value;
|
2286
2168
|
}
|
2287
2169
|
|
2288
2170
|
if (value instanceof Map) {
|
@@ -2296,7 +2178,7 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
|
|
2296
2178
|
var iteratorFn = getIteratorFn(value);
|
2297
2179
|
|
2298
2180
|
if (iteratorFn) {
|
2299
|
-
return
|
2181
|
+
return Array.from(value);
|
2300
2182
|
} // Verify that this is a simple plain object.
|
2301
2183
|
|
2302
2184
|
|
@@ -2308,14 +2190,14 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
|
|
2308
2190
|
|
2309
2191
|
{
|
2310
2192
|
if (objectName(value) !== 'Object') {
|
2311
|
-
error('Only plain objects can be passed to Client Components from Server Components. ' + '%s objects are not supported.%s', objectName(value), describeObjectForErrorMessage(parent,
|
2193
|
+
error('Only plain objects can be passed to Client Components from Server Components. ' + '%s objects are not supported.%s', objectName(value), describeObjectForErrorMessage(parent, key));
|
2312
2194
|
} else if (!isSimpleObject(value)) {
|
2313
|
-
error('Only plain objects can be passed to Client Components from Server Components. ' + 'Classes or other objects with methods are not supported.%s', describeObjectForErrorMessage(parent,
|
2195
|
+
error('Only plain objects can be passed to Client Components from Server Components. ' + 'Classes or other objects with methods are not supported.%s', describeObjectForErrorMessage(parent, key));
|
2314
2196
|
} else if (Object.getOwnPropertySymbols) {
|
2315
2197
|
var symbols = Object.getOwnPropertySymbols(value);
|
2316
2198
|
|
2317
2199
|
if (symbols.length > 0) {
|
2318
|
-
error('Only plain objects can be passed to Client Components from Server Components. ' + 'Objects with symbol properties like %s are not supported.%s', symbols[0].description, describeObjectForErrorMessage(parent,
|
2200
|
+
error('Only plain objects can be passed to Client Components from Server Components. ' + 'Objects with symbol properties like %s are not supported.%s', symbols[0].description, describeObjectForErrorMessage(parent, key));
|
2319
2201
|
}
|
2320
2202
|
}
|
2321
2203
|
} // $FlowFixMe[incompatible-return]
|
@@ -2330,9 +2212,9 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
|
|
2330
2212
|
if (value[value.length - 1] === 'Z') {
|
2331
2213
|
// Possibly a Date, whose toJSON automatically calls toISOString
|
2332
2214
|
// $FlowFixMe[incompatible-use]
|
2333
|
-
var
|
2215
|
+
var _originalValue = parent[key];
|
2334
2216
|
|
2335
|
-
if (
|
2217
|
+
if (_originalValue instanceof Date) {
|
2336
2218
|
return serializeDateFromDateJSON(value);
|
2337
2219
|
}
|
2338
2220
|
}
|
@@ -2360,21 +2242,19 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
|
|
2360
2242
|
}
|
2361
2243
|
|
2362
2244
|
if (typeof value === 'function') {
|
2245
|
+
|
2363
2246
|
if (isClientReference(value)) {
|
2364
|
-
return serializeClientReference(request, parent,
|
2247
|
+
return serializeClientReference(request, parent, key, value);
|
2365
2248
|
}
|
2366
2249
|
|
2367
2250
|
if (isServerReference(value)) {
|
2368
|
-
return serializeServerReference(request, value);
|
2251
|
+
return serializeServerReference(request, parent, key, value);
|
2369
2252
|
}
|
2370
2253
|
|
2371
|
-
if (/^on[A-Z]/.test(
|
2372
|
-
throw new Error('Event handlers cannot be passed to Client Component props.' + describeObjectForErrorMessage(parent,
|
2373
|
-
} else if ((jsxChildrenParents.has(parent) || jsxPropsParents.has(parent) && parentPropertyName === 'children')) {
|
2374
|
-
var componentName = value.displayName || value.name || 'Component';
|
2375
|
-
throw new Error('Functions are not valid as a child of Client Components. This may happen if ' + 'you return ' + componentName + ' instead of <' + componentName + ' /> from render. ' + 'Or maybe you meant to call this function rather than return it.' + describeObjectForErrorMessage(parent, parentPropertyName));
|
2254
|
+
if (/^on[A-Z]/.test(key)) {
|
2255
|
+
throw new Error('Event handlers cannot be passed to Client Component props.' + describeObjectForErrorMessage(parent, key) + '\nIf you need interactivity, consider converting part of this to a Client Component.');
|
2376
2256
|
} else {
|
2377
|
-
throw new Error('Functions cannot be passed directly to Client Components ' + 'unless you explicitly expose it by marking it with "use server".
|
2257
|
+
throw new Error('Functions cannot be passed directly to Client Components ' + 'unless you explicitly expose it by marking it with "use server".' + describeObjectForErrorMessage(parent, key));
|
2378
2258
|
}
|
2379
2259
|
}
|
2380
2260
|
|
@@ -2392,7 +2272,7 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
|
|
2392
2272
|
|
2393
2273
|
if (Symbol.for(name) !== value) {
|
2394
2274
|
throw new Error('Only global symbols received from Symbol.for(...) can be passed to Client Components. ' + ("The symbol Symbol.for(" + // $FlowFixMe[incompatible-type] `description` might be undefined
|
2395
|
-
value.description + ") cannot be found among global symbols.") + describeObjectForErrorMessage(parent,
|
2275
|
+
value.description + ") cannot be found among global symbols.") + describeObjectForErrorMessage(parent, key));
|
2396
2276
|
}
|
2397
2277
|
|
2398
2278
|
request.pendingChunks++;
|
@@ -2407,44 +2287,17 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
|
|
2407
2287
|
return serializeBigInt(value);
|
2408
2288
|
}
|
2409
2289
|
|
2410
|
-
throw new Error("Type " + typeof value + " is not supported in Client Component props." + describeObjectForErrorMessage(parent,
|
2290
|
+
throw new Error("Type " + typeof value + " is not supported in Client Component props." + describeObjectForErrorMessage(parent, key));
|
2411
2291
|
}
|
2412
2292
|
|
2413
2293
|
function logPostpone(request, reason) {
|
2414
|
-
var
|
2415
|
-
|
2416
|
-
|
2417
|
-
try {
|
2418
|
-
var onPostpone = request.onPostpone;
|
2419
|
-
|
2420
|
-
if (supportsRequestStorage) {
|
2421
|
-
// Exit the request context while running callbacks.
|
2422
|
-
requestStorage.run(undefined, onPostpone, reason);
|
2423
|
-
} else {
|
2424
|
-
onPostpone(reason);
|
2425
|
-
}
|
2426
|
-
} finally {
|
2427
|
-
currentRequest = prevRequest;
|
2428
|
-
}
|
2294
|
+
var onPostpone = request.onPostpone;
|
2295
|
+
onPostpone(reason);
|
2429
2296
|
}
|
2430
2297
|
|
2431
2298
|
function logRecoverableError(request, error) {
|
2432
|
-
var
|
2433
|
-
|
2434
|
-
var errorDigest;
|
2435
|
-
|
2436
|
-
try {
|
2437
|
-
var onError = request.onError;
|
2438
|
-
|
2439
|
-
if (supportsRequestStorage) {
|
2440
|
-
// Exit the request context while running callbacks.
|
2441
|
-
errorDigest = requestStorage.run(undefined, onError, error);
|
2442
|
-
} else {
|
2443
|
-
errorDigest = onError(error);
|
2444
|
-
}
|
2445
|
-
} finally {
|
2446
|
-
currentRequest = prevRequest;
|
2447
|
-
}
|
2299
|
+
var onError = request.onError;
|
2300
|
+
var errorDigest = onError(error);
|
2448
2301
|
|
2449
2302
|
if (errorDigest != null && typeof errorDigest !== 'string') {
|
2450
2303
|
// eslint-disable-next-line react-internal/prod-error-codes
|
@@ -2503,11 +2356,8 @@ function emitErrorChunk(request, id, digest, error) {
|
|
2503
2356
|
message = String(error.message); // eslint-disable-next-line react-internal/safe-string-coercion
|
2504
2357
|
|
2505
2358
|
stack = String(error.stack);
|
2506
|
-
} else if (typeof error === 'object' && error !== null) {
|
2507
|
-
message = describeObjectForErrorMessage(error);
|
2508
2359
|
} else {
|
2509
|
-
|
2510
|
-
message = String(error);
|
2360
|
+
message = 'Error: ' + error;
|
2511
2361
|
}
|
2512
2362
|
} catch (x) {
|
2513
2363
|
message = 'An error occurred but serializing the error message failed.';
|
@@ -2547,79 +2397,62 @@ function emitSymbolChunk(request, id, name) {
|
|
2547
2397
|
request.completedImportChunks.push(processedChunk);
|
2548
2398
|
}
|
2549
2399
|
|
2550
|
-
function emitModelChunk(request, id,
|
2551
|
-
|
2552
|
-
|
2553
|
-
|
2554
|
-
|
2555
|
-
|
2556
|
-
function emitDebugChunk(request, id, debugInfo) {
|
2400
|
+
function emitModelChunk(request, id, model) {
|
2401
|
+
// Track the root so we know that we have to emit this object even though it
|
2402
|
+
// already has an ID. This is needed because we might see this object twice
|
2403
|
+
// in the same toJSON if it is cyclic.
|
2404
|
+
modelRoot = model; // $FlowFixMe[incompatible-type] stringify can return null
|
2557
2405
|
|
2558
|
-
|
2559
|
-
var
|
2560
|
-
var row = serializeRowHeader('D', id) + json + '\n';
|
2406
|
+
var json = stringify(model, request.toJSON);
|
2407
|
+
var row = id.toString(16) + ':' + json + '\n';
|
2561
2408
|
var processedChunk = stringToChunk(row);
|
2562
2409
|
request.completedRegularChunks.push(processedChunk);
|
2563
2410
|
}
|
2564
2411
|
|
2565
|
-
function forwardDebugInfo(request, id, debugInfo) {
|
2566
|
-
for (var i = 0; i < debugInfo.length; i++) {
|
2567
|
-
request.pendingChunks++;
|
2568
|
-
emitDebugChunk(request, id, debugInfo[i]);
|
2569
|
-
}
|
2570
|
-
}
|
2571
|
-
|
2572
|
-
var emptyRoot = {};
|
2573
|
-
|
2574
2412
|
function retryTask(request, task) {
|
2575
2413
|
if (task.status !== PENDING$1) {
|
2576
2414
|
// We completed this by other means before we had a chance to retry it.
|
2577
2415
|
return;
|
2578
2416
|
}
|
2579
2417
|
|
2580
|
-
|
2418
|
+
switchContext(task.context);
|
2581
2419
|
|
2582
2420
|
try {
|
2583
|
-
|
2584
|
-
// already has an ID. This is needed because we might see this object twice
|
2585
|
-
// in the same toJSON if it is cyclic.
|
2586
|
-
modelRoot = task.model;
|
2421
|
+
var value = task.model;
|
2587
2422
|
|
2588
|
-
if (
|
2589
|
-
|
2590
|
-
debugID = task.id;
|
2591
|
-
} // We call the destructive form that mutates this task. That way if something
|
2592
|
-
// suspends again, we can reuse the same task instead of spawning a new one.
|
2423
|
+
if (typeof value === 'object' && value !== null && value.$$typeof === REACT_ELEMENT_TYPE) {
|
2424
|
+
request.writtenObjects.set(value, task.id); // TODO: Concatenate keys of parents onto children.
|
2593
2425
|
|
2426
|
+
var element = value; // When retrying a component, reuse the thenableState from the
|
2427
|
+
// previous attempt.
|
2594
2428
|
|
2595
|
-
|
2429
|
+
var prevThenableState = task.thenableState; // Attempt to render the Server Component.
|
2430
|
+
// Doing this here lets us reuse this same task if the next component
|
2431
|
+
// also suspends.
|
2596
2432
|
|
2597
|
-
|
2598
|
-
|
2599
|
-
//
|
2600
|
-
debugID = null;
|
2601
|
-
} // Track the root again for the resolved object.
|
2433
|
+
task.model = value;
|
2434
|
+
value = attemptResolveElement(request, element.type, element.key, element.ref, element.props, prevThenableState); // Successfully finished this component. We're going to keep rendering
|
2435
|
+
// using the same task, but we reset its thenable state before continuing.
|
2602
2436
|
|
2437
|
+
task.thenableState = null; // Keep rendering and reuse the same task. This inner loop is separate
|
2438
|
+
// from the render above because we don't need to reset the thenable state
|
2439
|
+
// until the next time something suspends and retries.
|
2603
2440
|
|
2604
|
-
|
2441
|
+
while (typeof value === 'object' && value !== null && value.$$typeof === REACT_ELEMENT_TYPE) {
|
2442
|
+
request.writtenObjects.set(value, task.id); // TODO: Concatenate keys of parents onto children.
|
2605
2443
|
|
2606
|
-
|
2607
|
-
|
2608
|
-
|
2444
|
+
var nextElement = value;
|
2445
|
+
task.model = value;
|
2446
|
+
value = attemptResolveElement(request, nextElement.type, nextElement.key, nextElement.ref, nextElement.props, null);
|
2447
|
+
}
|
2448
|
+
} // Track that this object is outlined and has an id.
|
2609
2449
|
|
2610
|
-
|
2611
|
-
|
2612
|
-
|
2613
|
-
// $FlowFixMe[incompatible-type] stringify can return null for undefined but we never do
|
2614
|
-
json = stringify(resolvedModel, task.toJSON);
|
2615
|
-
} else {
|
2616
|
-
// If the value is a string, it means it's a terminal value and we already escaped it
|
2617
|
-
// We don't need to escape it again so it's not passed the toJSON replacer.
|
2618
|
-
// $FlowFixMe[incompatible-type] stringify can return null for undefined but we never do
|
2619
|
-
json = stringify(resolvedModel);
|
2450
|
+
|
2451
|
+
if (typeof value === 'object' && value !== null) {
|
2452
|
+
request.writtenObjects.set(value, task.id);
|
2620
2453
|
}
|
2621
2454
|
|
2622
|
-
emitModelChunk(request, task.id,
|
2455
|
+
emitModelChunk(request, task.id, value);
|
2623
2456
|
request.abortableTasks.delete(task);
|
2624
2457
|
task.status = COMPLETED;
|
2625
2458
|
} catch (thrownValue) {
|
@@ -2645,10 +2478,6 @@ function retryTask(request, task) {
|
|
2645
2478
|
task.status = ERRORED$1;
|
2646
2479
|
var digest = logRecoverableError(request, x);
|
2647
2480
|
emitErrorChunk(request, task.id, digest, x);
|
2648
|
-
} finally {
|
2649
|
-
{
|
2650
|
-
debugID = prevDebugID;
|
2651
|
-
}
|
2652
2481
|
}
|
2653
2482
|
}
|
2654
2483
|
|
@@ -2865,6 +2694,11 @@ function abort(request, reason) {
|
|
2865
2694
|
}
|
2866
2695
|
}
|
2867
2696
|
|
2697
|
+
function importServerContexts(contexts) {
|
2698
|
+
|
2699
|
+
return rootContextSnapshot;
|
2700
|
+
}
|
2701
|
+
|
2868
2702
|
// This is the parsed shape of the wire format which is why it is
|
2869
2703
|
// condensed to only the essentialy information
|
2870
2704
|
var ID = 0;
|
@@ -3568,7 +3402,7 @@ function decodeFormState(actionResult, body, serverManifest) {
|
|
3568
3402
|
}
|
3569
3403
|
|
3570
3404
|
function renderToReadableStream(model, webpackMap, options) {
|
3571
|
-
var request = createRequest(model, webpackMap, options ? options.onError : undefined, options ? options.
|
3405
|
+
var request = createRequest(model, webpackMap, options ? options.onError : undefined, options ? options.context : undefined, options ? options.identifierPrefix : undefined, options ? options.onPostpone : undefined);
|
3572
3406
|
|
3573
3407
|
if (options && options.signal) {
|
3574
3408
|
var signal = options.signal;
|