-
Notifications
You must be signed in to change notification settings - Fork 28.2k
/
Copy pathreact-server-dom-turbopack-server.node.development.js
5399 lines (4412 loc) · 166 KB
/
react-server-dom-turbopack-server.node.development.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* @license React
* react-server-dom-turbopack-server.node.development.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';
if (process.env.NODE_ENV !== "production") {
(function() {
'use strict';
var React = require('react');
var util = require('util');
require('crypto');
var async_hooks = require('async_hooks');
var ReactDOM = require('react-dom');
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
var ReactSharedInternalsServer = // $FlowFixMe: It's defined in the one we resolve to.
React.__SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
if (!ReactSharedInternalsServer) {
throw new Error('The "react" package in this environment is not configured correctly. ' + 'The "react-server" condition must be enabled in any environment that ' + 'runs React Server Components.');
}
function error(format) {
{
{
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
args[_key2 - 1] = arguments[_key2];
}
printWarning('error', format, args);
}
}
}
function printWarning(level, format, args) {
// When changing this logic, you might want to also
// update consoleWithStackDev.www.js as well.
{
var stack = ReactSharedInternalsServer.getStackAddendum();
if (stack !== '') {
format += '%s';
args = args.concat([stack]);
} // eslint-disable-next-line react-internal/safe-string-coercion
var argsWithFormat = args.map(function (item) {
return String(item);
}); // Careful: RN currently depends on this prefix
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
// breaks IE9: https://github.com/facebook/react/issues/13610
// eslint-disable-next-line react-internal/no-production-logging
Function.prototype.apply.call(console[level], console, argsWithFormat);
}
}
// -----------------------------------------------------------------------------
var enablePostpone = false;
function scheduleWork(callback) {
setImmediate(callback);
}
function flushBuffered(destination) {
// If we don't have any more data to send right now.
// Flush whatever is in the buffer to the wire.
if (typeof destination.flush === 'function') {
// By convention the Zlib streams provide a flush function for this purpose.
// For Express, compression middleware adds this method.
destination.flush();
}
}
var VIEW_SIZE = 2048;
var currentView = null;
var writtenBytes = 0;
var destinationHasCapacity = true;
function beginWriting(destination) {
currentView = new Uint8Array(VIEW_SIZE);
writtenBytes = 0;
destinationHasCapacity = true;
}
function writeStringChunk(destination, stringChunk) {
if (stringChunk.length === 0) {
return;
} // maximum possible view needed to encode entire string
if (stringChunk.length * 3 > VIEW_SIZE) {
if (writtenBytes > 0) {
writeToDestination(destination, currentView.subarray(0, writtenBytes));
currentView = new Uint8Array(VIEW_SIZE);
writtenBytes = 0;
}
writeToDestination(destination, textEncoder.encode(stringChunk));
return;
}
var target = currentView;
if (writtenBytes > 0) {
target = currentView.subarray(writtenBytes);
}
var _textEncoder$encodeIn = textEncoder.encodeInto(stringChunk, target),
read = _textEncoder$encodeIn.read,
written = _textEncoder$encodeIn.written;
writtenBytes += written;
if (read < stringChunk.length) {
writeToDestination(destination, currentView.subarray(0, writtenBytes));
currentView = new Uint8Array(VIEW_SIZE);
writtenBytes = textEncoder.encodeInto(stringChunk.slice(read), currentView).written;
}
if (writtenBytes === VIEW_SIZE) {
writeToDestination(destination, currentView);
currentView = new Uint8Array(VIEW_SIZE);
writtenBytes = 0;
}
}
function writeViewChunk(destination, chunk) {
if (chunk.byteLength === 0) {
return;
}
if (chunk.byteLength > VIEW_SIZE) {
// this chunk may overflow a single view which implies it was not
// one that is cached by the streaming renderer. We will enqueu
// it directly and expect it is not re-used
if (writtenBytes > 0) {
writeToDestination(destination, currentView.subarray(0, writtenBytes));
currentView = new Uint8Array(VIEW_SIZE);
writtenBytes = 0;
}
writeToDestination(destination, chunk);
return;
}
var bytesToWrite = chunk;
var allowableBytes = currentView.length - writtenBytes;
if (allowableBytes < bytesToWrite.byteLength) {
// this chunk would overflow the current view. We enqueue a full view
// and start a new view with the remaining chunk
if (allowableBytes === 0) {
// the current view is already full, send it
writeToDestination(destination, currentView);
} else {
// fill up the current view and apply the remaining chunk bytes
// to a new view.
currentView.set(bytesToWrite.subarray(0, allowableBytes), writtenBytes);
writtenBytes += allowableBytes;
writeToDestination(destination, currentView);
bytesToWrite = bytesToWrite.subarray(allowableBytes);
}
currentView = new Uint8Array(VIEW_SIZE);
writtenBytes = 0;
}
currentView.set(bytesToWrite, writtenBytes);
writtenBytes += bytesToWrite.byteLength;
if (writtenBytes === VIEW_SIZE) {
writeToDestination(destination, currentView);
currentView = new Uint8Array(VIEW_SIZE);
writtenBytes = 0;
}
}
function writeChunk(destination, chunk) {
if (typeof chunk === 'string') {
writeStringChunk(destination, chunk);
} else {
writeViewChunk(destination, chunk);
}
}
function writeToDestination(destination, view) {
var currentHasCapacity = destination.write(view);
destinationHasCapacity = destinationHasCapacity && currentHasCapacity;
}
function writeChunkAndReturn(destination, chunk) {
writeChunk(destination, chunk);
return destinationHasCapacity;
}
function completeWriting(destination) {
if (currentView && writtenBytes > 0) {
destination.write(currentView.subarray(0, writtenBytes));
}
currentView = null;
writtenBytes = 0;
destinationHasCapacity = true;
}
function close$1(destination) {
destination.end();
}
var textEncoder = new util.TextEncoder();
function stringToChunk(content) {
return content;
}
function typedArrayToBinaryChunk(content) {
// Convert any non-Uint8Array array to Uint8Array. We could avoid this for Uint8Arrays.
return new Uint8Array(content.buffer, content.byteOffset, content.byteLength);
}
function byteLengthOfChunk(chunk) {
return typeof chunk === 'string' ? Buffer.byteLength(chunk, 'utf8') : chunk.byteLength;
}
function byteLengthOfBinaryChunk(chunk) {
return chunk.byteLength;
}
function closeWithError(destination, error) {
// $FlowFixMe[incompatible-call]: This is an Error object or the destination accepts other types.
destination.destroy(error);
}
// eslint-disable-next-line no-unused-vars
var CLIENT_REFERENCE_TAG$1 = Symbol.for('react.client.reference');
var SERVER_REFERENCE_TAG = Symbol.for('react.server.reference');
function isClientReference(reference) {
return reference.$$typeof === CLIENT_REFERENCE_TAG$1;
}
function isServerReference(reference) {
return reference.$$typeof === SERVER_REFERENCE_TAG;
}
function registerClientReference(proxyImplementation, id, exportName) {
return registerClientReferenceImpl(proxyImplementation, id + '#' + exportName, false);
}
function registerClientReferenceImpl(proxyImplementation, id, async) {
return Object.defineProperties(proxyImplementation, {
$$typeof: {
value: CLIENT_REFERENCE_TAG$1
},
$$id: {
value: id
},
$$async: {
value: async
}
});
} // $FlowFixMe[method-unbinding]
var FunctionBind = Function.prototype.bind; // $FlowFixMe[method-unbinding]
var ArraySlice = Array.prototype.slice;
function bind() {
// $FlowFixMe[unsupported-syntax]
var newFn = FunctionBind.apply(this, arguments);
if (this.$$typeof === SERVER_REFERENCE_TAG) {
var args = ArraySlice.call(arguments, 1);
return Object.defineProperties(newFn, {
$$typeof: {
value: SERVER_REFERENCE_TAG
},
$$id: {
value: this.$$id
},
$$bound: {
value: this.$$bound ? this.$$bound.concat(args) : args
},
bind: {
value: bind
}
});
}
return newFn;
}
function registerServerReference(reference, id, exportName) {
return Object.defineProperties(reference, {
$$typeof: {
value: SERVER_REFERENCE_TAG
},
$$id: {
value: exportName === null ? id : id + '#' + exportName,
configurable: true
},
$$bound: {
value: null,
configurable: true
},
bind: {
value: bind,
configurable: true
}
});
}
var PROMISE_PROTOTYPE = Promise.prototype;
var deepProxyHandlers = {
get: function (target, name, receiver) {
switch (name) {
// These names are read by the Flight runtime if you end up using the exports object.
case '$$typeof':
// These names are a little too common. We should probably have a way to
// have the Flight runtime extract the inner target instead.
return target.$$typeof;
case '$$id':
return target.$$id;
case '$$async':
return target.$$async;
case 'name':
return target.name;
case 'displayName':
return undefined;
// We need to special case this because createElement reads it if we pass this
// reference.
case 'defaultProps':
return undefined;
// Avoid this attempting to be serialized.
case 'toJSON':
return undefined;
case Symbol.toPrimitive:
// $FlowFixMe[prop-missing]
return Object.prototype[Symbol.toPrimitive];
case Symbol.toStringTag:
// $FlowFixMe[prop-missing]
return Object.prototype[Symbol.toStringTag];
case 'Provider':
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.");
} // eslint-disable-next-line react-internal/safe-string-coercion
var expression = String(target.name) + '.' + String(name);
throw new Error("Cannot access " + expression + " on the server. " + 'You cannot dot into a client module from a server component. ' + 'You can only pass the imported name through.');
},
set: function () {
throw new Error('Cannot assign to a client module from a server module.');
}
};
function getReference(target, name) {
switch (name) {
// These names are read by the Flight runtime if you end up using the exports object.
case '$$typeof':
return target.$$typeof;
case '$$id':
return target.$$id;
case '$$async':
return target.$$async;
case 'name':
return target.name;
// We need to special case this because createElement reads it if we pass this
// reference.
case 'defaultProps':
return undefined;
// Avoid this attempting to be serialized.
case 'toJSON':
return undefined;
case Symbol.toPrimitive:
// $FlowFixMe[prop-missing]
return Object.prototype[Symbol.toPrimitive];
case Symbol.toStringTag:
// $FlowFixMe[prop-missing]
return Object.prototype[Symbol.toStringTag];
case '__esModule':
// Something is conditionally checking which export to use. We'll pretend to be
// an ESM compat module but then we'll check again on the client.
var moduleId = target.$$id;
target.default = registerClientReferenceImpl(function () {
throw new Error("Attempted to call the default export of " + moduleId + " from the server " + "but it's on the client. It's not possible to invoke a client function from " + "the server, it can only be rendered as a Component or passed to props of a " + "Client Component.");
}, target.$$id + '#', target.$$async);
return true;
case 'then':
if (target.then) {
// Use a cached value
return target.then;
}
if (!target.$$async) {
// If this module is expected to return a Promise (such as an AsyncModule) then
// we should resolve that with a client reference that unwraps the Promise on
// the client.
var clientReference = registerClientReferenceImpl({}, target.$$id, true);
var proxy = new Proxy(clientReference, proxyHandlers$1); // Treat this as a resolved Promise for React's use()
target.status = 'fulfilled';
target.value = proxy;
var then = target.then = registerClientReferenceImpl(function then(resolve, reject) {
// Expose to React.
return Promise.resolve(resolve(proxy));
}, // If this is not used as a Promise but is treated as a reference to a `.then`
// export then we should treat it as a reference to that name.
target.$$id + '#then', false);
return then;
} else {
// Since typeof .then === 'function' is a feature test we'd continue recursing
// indefinitely if we return a function. Instead, we return an object reference
// if we check further.
return undefined;
}
}
if (typeof name === 'symbol') {
throw new Error('Cannot read Symbol exports. Only named exports are supported on a client module ' + 'imported on the server.');
}
var cachedReference = target[name];
if (!cachedReference) {
var reference = registerClientReferenceImpl(function () {
throw new Error( // eslint-disable-next-line react-internal/safe-string-coercion
"Attempted to call " + String(name) + "() from the server but " + String(name) + " is on the client. " + "It's not possible to invoke a client function from the server, it can " + "only be rendered as a Component or passed to props of a Client Component.");
}, target.$$id + '#' + name, target.$$async);
Object.defineProperty(reference, 'name', {
value: name
});
cachedReference = target[name] = new Proxy(reference, deepProxyHandlers);
}
return cachedReference;
}
var proxyHandlers$1 = {
get: function (target, name, receiver) {
return getReference(target, name);
},
getOwnPropertyDescriptor: function (target, name) {
var descriptor = Object.getOwnPropertyDescriptor(target, name);
if (!descriptor) {
descriptor = {
value: getReference(target, name),
writable: false,
configurable: false,
enumerable: false
};
Object.defineProperty(target, name, descriptor);
}
return descriptor;
},
getPrototypeOf: function (target) {
// Pretend to be a Promise in case anyone asks.
return PROMISE_PROTOTYPE;
},
set: function () {
throw new Error('Cannot assign to a client module from a server module.');
}
};
function createClientModuleProxy(moduleId) {
var clientReference = registerClientReferenceImpl({}, // Represents the whole Module object instead of a particular import.
moduleId, false);
return new Proxy(clientReference, proxyHandlers$1);
}
function getClientReferenceKey(reference) {
return reference.$$async ? reference.$$id + '#async' : reference.$$id;
}
function resolveClientReferenceMetadata(config, clientReference) {
var modulePath = clientReference.$$id;
var name = '';
var resolvedModuleData = config[modulePath];
if (resolvedModuleData) {
// The potentially aliased name.
name = resolvedModuleData.name;
} else {
// We didn't find this specific export name but we might have the * export
// which contains this name as well.
// TODO: It's unfortunate that we now have to parse this string. We should
// probably go back to encoding path and name separately on the client reference.
var idx = modulePath.lastIndexOf('#');
if (idx !== -1) {
name = modulePath.slice(idx + 1);
resolvedModuleData = config[modulePath.slice(0, idx)];
}
if (!resolvedModuleData) {
throw new Error('Could not find the module "' + modulePath + '" in the React Client Manifest. ' + 'This is probably a bug in the React Server Components bundler.');
}
}
if (clientReference.$$async === true) {
return [resolvedModuleData.id, resolvedModuleData.chunks, name, 1];
} else {
return [resolvedModuleData.id, resolvedModuleData.chunks, name];
}
}
function getServerReferenceId(config, serverReference) {
return serverReference.$$id;
}
function getServerReferenceBoundArguments(config, serverReference) {
return serverReference.$$bound;
}
var ReactDOMSharedInternals = ReactDOM.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
var previousDispatcher = ReactDOMSharedInternals.d;
/* ReactDOMCurrentDispatcher */
ReactDOMSharedInternals.d
/* ReactDOMCurrentDispatcher */
= {
f
/* flushSyncWork */
: previousDispatcher.f
/* flushSyncWork */
,
r
/* requestFormReset */
: previousDispatcher.r
/* requestFormReset */
,
D
/* prefetchDNS */
: prefetchDNS,
C
/* preconnect */
: preconnect,
L
/* preload */
: preload,
m
/* preloadModule */
: preloadModule$1,
X
/* preinitScript */
: preinitScript,
S
/* preinitStyle */
: preinitStyle,
M
/* preinitModuleScript */
: preinitModuleScript
};
function prefetchDNS(href) {
if (typeof href === 'string' && href) {
var request = resolveRequest();
if (request) {
var hints = getHints(request);
var key = 'D|' + href;
if (hints.has(key)) {
// duplicate hint
return;
}
hints.add(key);
emitHint(request, 'D', href);
} else {
previousDispatcher.D(
/* prefetchDNS */
href);
}
}
}
function preconnect(href, crossOrigin) {
if (typeof href === 'string') {
var request = resolveRequest();
if (request) {
var hints = getHints(request);
var key = "C|" + (crossOrigin == null ? 'null' : crossOrigin) + "|" + href;
if (hints.has(key)) {
// duplicate hint
return;
}
hints.add(key);
if (typeof crossOrigin === 'string') {
emitHint(request, 'C', [href, crossOrigin]);
} else {
emitHint(request, 'C', href);
}
} else {
previousDispatcher.C(
/* preconnect */
href, crossOrigin);
}
}
}
function preload(href, as, options) {
if (typeof href === 'string') {
var request = resolveRequest();
if (request) {
var hints = getHints(request);
var key = 'L';
if (as === 'image' && options) {
key += getImagePreloadKey(href, options.imageSrcSet, options.imageSizes);
} else {
key += "[" + as + "]" + href;
}
if (hints.has(key)) {
// duplicate hint
return;
}
hints.add(key);
var trimmed = trimOptions(options);
if (trimmed) {
emitHint(request, 'L', [href, as, trimmed]);
} else {
emitHint(request, 'L', [href, as]);
}
} else {
previousDispatcher.L(
/* preload */
href, as, options);
}
}
}
function preloadModule$1(href, options) {
if (typeof href === 'string') {
var request = resolveRequest();
if (request) {
var hints = getHints(request);
var key = 'm|' + href;
if (hints.has(key)) {
// duplicate hint
return;
}
hints.add(key);
var trimmed = trimOptions(options);
if (trimmed) {
return emitHint(request, 'm', [href, trimmed]);
} else {
return emitHint(request, 'm', href);
}
} else {
previousDispatcher.m(
/* preloadModule */
href, options);
}
}
}
function preinitStyle(href, precedence, options) {
if (typeof href === 'string') {
var request = resolveRequest();
if (request) {
var hints = getHints(request);
var key = 'S|' + href;
if (hints.has(key)) {
// duplicate hint
return;
}
hints.add(key);
var trimmed = trimOptions(options);
if (trimmed) {
return emitHint(request, 'S', [href, typeof precedence === 'string' ? precedence : 0, trimmed]);
} else if (typeof precedence === 'string') {
return emitHint(request, 'S', [href, precedence]);
} else {
return emitHint(request, 'S', href);
}
} else {
previousDispatcher.S(
/* preinitStyle */
href, precedence, options);
}
}
}
function preinitScript(src, options) {
if (typeof src === 'string') {
var request = resolveRequest();
if (request) {
var hints = getHints(request);
var key = 'X|' + src;
if (hints.has(key)) {
// duplicate hint
return;
}
hints.add(key);
var trimmed = trimOptions(options);
if (trimmed) {
return emitHint(request, 'X', [src, trimmed]);
} else {
return emitHint(request, 'X', src);
}
} else {
previousDispatcher.X(
/* preinitScript */
src, options);
}
}
}
function preinitModuleScript(src, options) {
if (typeof src === 'string') {
var request = resolveRequest();
if (request) {
var hints = getHints(request);
var key = 'M|' + src;
if (hints.has(key)) {
// duplicate hint
return;
}
hints.add(key);
var trimmed = trimOptions(options);
if (trimmed) {
return emitHint(request, 'M', [src, trimmed]);
} else {
return emitHint(request, 'M', src);
}
} else {
previousDispatcher.M(
/* preinitModuleScript */
src, options);
}
}
} // Flight normally encodes undefined as a special character however for directive option
// arguments we don't want to send unnecessary keys and bloat the payload so we create a
// trimmed object which omits any keys with null or undefined values.
// This is only typesafe because these option objects have entirely optional fields where
// null and undefined represent the same thing as no property.
function trimOptions(options) {
if (options == null) return null;
var hasProperties = false;
var trimmed = {};
for (var key in options) {
if (options[key] != null) {
hasProperties = true;
trimmed[key] = options[key];
}
}
return hasProperties ? trimmed : null;
}
function getImagePreloadKey(href, imageSrcSet, imageSizes) {
var uniquePart = '';
if (typeof imageSrcSet === 'string' && imageSrcSet !== '') {
uniquePart += '[' + imageSrcSet + ']';
if (typeof imageSizes === 'string') {
uniquePart += '[' + imageSizes + ']';
}
} else {
uniquePart += '[][]' + href;
}
return "[image]" + uniquePart;
}
// This module registers the host dispatcher so it needs to be imported
// small, smaller than how we encode undefined, and is unambiguous. We could use
// a different tuple structure to encode this instead but this makes the runtime
// cost cheaper by eliminating a type checks in more positions.
// prettier-ignore
function createHints() {
return new Set();
}
var supportsRequestStorage = true;
var requestStorage = new async_hooks.AsyncLocalStorage();
var supportsComponentStorage = true;
var componentStorage = new async_hooks.AsyncLocalStorage() ;
var TEMPORARY_REFERENCE_TAG = Symbol.for('react.temporary.reference'); // eslint-disable-next-line no-unused-vars
function createTemporaryReferenceSet() {
return new WeakMap();
}
function isOpaqueTemporaryReference(reference) {
return reference.$$typeof === TEMPORARY_REFERENCE_TAG;
}
function resolveTemporaryReference(temporaryReferences, temporaryReference) {
return temporaryReferences.get(temporaryReference);
}
var proxyHandlers = {
get: function (target, name, receiver) {
switch (name) {
// These names are read by the Flight runtime if you end up using the exports object.
case '$$typeof':
// These names are a little too common. We should probably have a way to
// have the Flight runtime extract the inner target instead.
return target.$$typeof;
case 'name':
return undefined;
case 'displayName':
return undefined;
// We need to special case this because createElement reads it if we pass this
// reference.
case 'defaultProps':
return undefined;
// Avoid this attempting to be serialized.
case 'toJSON':
return undefined;
case Symbol.toPrimitive:
// $FlowFixMe[prop-missing]
return Object.prototype[Symbol.toPrimitive];
case Symbol.toStringTag:
// $FlowFixMe[prop-missing]
return Object.prototype[Symbol.toStringTag];
case 'Provider':
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.");
}
throw new Error( // eslint-disable-next-line react-internal/safe-string-coercion
"Cannot access " + String(name) + " on the server. " + 'You cannot dot into a temporary client reference from a server component. ' + 'You can only pass the value through to the client.');
},
set: function () {
throw new Error('Cannot assign to a temporary client reference from a server module.');
}
};
function createTemporaryReference(temporaryReferences, id) {
var reference = Object.defineProperties(function () {
throw new Error( // eslint-disable-next-line react-internal/safe-string-coercion
"Attempted to call a temporary Client Reference from the server but it is on the client. " + "It's not possible to invoke a client function from the server, it can " + "only be rendered as a Component or passed to props of a Client Component.");
}, {
$$typeof: {
value: TEMPORARY_REFERENCE_TAG
}
});
var wrapper = new Proxy(reference, proxyHandlers);
registerTemporaryReference(temporaryReferences, wrapper, id);
return wrapper;
}
function registerTemporaryReference(temporaryReferences, object, id) {
temporaryReferences.set(object, id);
}
// When adding new symbols to this file,
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
// The Symbol used to tag the ReactElement-like types.
var REACT_LEGACY_ELEMENT_TYPE = Symbol.for('react.element');
var REACT_ELEMENT_TYPE = Symbol.for('react.transitional.element') ;
var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
var REACT_CONTEXT_TYPE = Symbol.for('react.context');
var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');
var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');
var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');
var REACT_MEMO_TYPE = Symbol.for('react.memo');
var REACT_LAZY_TYPE = Symbol.for('react.lazy');
var REACT_MEMO_CACHE_SENTINEL = Symbol.for('react.memo_cache_sentinel');
var REACT_POSTPONE_TYPE = Symbol.for('react.postpone');
var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
var FAUX_ITERATOR_SYMBOL = '@@iterator';
function getIteratorFn(maybeIterable) {
if (maybeIterable === null || typeof maybeIterable !== 'object') {
return null;
}
var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
if (typeof maybeIterator === 'function') {
return maybeIterator;
}
return null;
}
var ASYNC_ITERATOR = Symbol.asyncIterator;
// Corresponds to ReactFiberWakeable and ReactFizzWakeable modules. Generally,
// changes to one module should be reflected in the others.
// TODO: Rename this module and the corresponding Fiber one to "Thenable"
// instead of "Wakeable". Or some other more appropriate name.
// An error that is thrown (e.g. by `use`) to trigger Suspense. If we
// detect this is caught by userspace, we'll log a warning in development.
var SuspenseException = new Error("Suspense Exception: This is not a real error! It's an implementation " + 'detail of `use` to interrupt the current render. You must either ' + 'rethrow it immediately, or move the `use` call outside of the ' + '`try/catch` block. Capturing without rethrowing will lead to ' + 'unexpected behavior.\n\n' + 'To handle async errors, wrap your component in an error boundary, or ' + "call the promise's `.catch` method and pass the result to `use`");
function createThenableState() {
// The ThenableState is created the first time a component suspends. If it
// suspends again, we'll reuse the same state.
return [];
}
function noop() {}
function trackUsedThenable(thenableState, thenable, index) {
var previous = thenableState[index];
if (previous === undefined) {
thenableState.push(thenable);
} else {
if (previous !== thenable) {
// Reuse the previous thenable, and drop the new one. We can assume
// they represent the same value, because components are idempotent.
// Avoid an unhandled rejection errors for the Promises that we'll
// intentionally ignore.
thenable.then(noop, noop);
thenable = previous;
}
} // We use an expando to track the status and result of a thenable so that we
// can synchronously unwrap the value. Think of this as an extension of the
// Promise API, or a custom interface that is a superset of Thenable.
//
// If the thenable doesn't have a status, set it to "pending" and attach
// a listener that will update its status and result when it resolves.
switch (thenable.status) {
case 'fulfilled':
{
var fulfilledValue = thenable.value;
return fulfilledValue;
}
case 'rejected':
{
var rejectedError = thenable.reason;
throw rejectedError;
}
default:
{
if (typeof thenable.status === 'string') {
// Only instrument the thenable if the status if not defined. If
// it's defined, but an unknown value, assume it's been instrumented by
// some custom userspace implementation. We treat it as "pending".
// Attach a dummy listener, to ensure that any lazy initialization can
// happen. Flight lazily parses JSON when the value is actually awaited.
thenable.then(noop, noop);
} else {
var pendingThenable = thenable;