react-server-dom-webpack 19.0.0-canary-e3ebcd54b-20240405 → 19.0.0-canary-adb717393-20240411
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 +136 -97
- package/cjs/react-server-dom-webpack-client.browser.production.js +106 -65
- package/cjs/react-server-dom-webpack-client.browser.production.min.js +24 -23
- package/cjs/react-server-dom-webpack-client.browser.production.min.js.map +1 -1
- package/cjs/react-server-dom-webpack-client.edge.development.js +144 -105
- package/cjs/react-server-dom-webpack-client.edge.production.js +114 -73
- package/cjs/react-server-dom-webpack-client.edge.production.min.js +24 -23
- package/cjs/react-server-dom-webpack-client.edge.production.min.js.map +1 -1
- package/cjs/react-server-dom-webpack-client.node.development.js +144 -105
- package/cjs/react-server-dom-webpack-client.node.production.js +114 -73
- package/cjs/react-server-dom-webpack-client.node.production.min.js +26 -25
- 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 +144 -105
- package/cjs/react-server-dom-webpack-client.node.unbundled.production.js +114 -73
- package/cjs/react-server-dom-webpack-client.node.unbundled.production.min.js +33 -32
- 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-server.browser.development.js +349 -56
- package/cjs/react-server-dom-webpack-server.browser.production.js +93 -36
- package/cjs/react-server-dom-webpack-server.browser.production.min.js +68 -68
- package/cjs/react-server-dom-webpack-server.browser.production.min.js.map +1 -1
- package/cjs/react-server-dom-webpack-server.edge.development.js +349 -56
- package/cjs/react-server-dom-webpack-server.edge.production.js +93 -36
- package/cjs/react-server-dom-webpack-server.edge.production.min.js +58 -58
- package/cjs/react-server-dom-webpack-server.edge.production.min.js.map +1 -1
- package/cjs/react-server-dom-webpack-server.node.development.js +349 -56
- package/cjs/react-server-dom-webpack-server.node.production.js +93 -36
- package/cjs/react-server-dom-webpack-server.node.production.min.js +56 -56
- 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 +349 -56
- package/cjs/react-server-dom-webpack-server.node.unbundled.production.js +93 -36
- package/cjs/react-server-dom-webpack-server.node.unbundled.production.min.js +53 -53
- package/cjs/react-server-dom-webpack-server.node.unbundled.production.min.js.map +1 -1
- package/package.json +3 -3
- package/umd/react-server-dom-webpack-client.browser.development.js +136 -97
- package/umd/react-server-dom-webpack-client.browser.production.min.js +25 -25
- package/umd/react-server-dom-webpack-server.browser.development.js +349 -56
- package/umd/react-server-dom-webpack-server.browser.production.min.js +54 -54
@@ -17,7 +17,12 @@ if (process.env.NODE_ENV !== "production") {
|
|
17
17
|
var React = require('react');
|
18
18
|
var ReactDOM = require('react-dom');
|
19
19
|
|
20
|
-
var
|
20
|
+
var ReactSharedInternalsServer = // $FlowFixMe: It's defined in the one we resolve to.
|
21
|
+
React.__SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
|
22
|
+
|
23
|
+
if (!ReactSharedInternalsServer) {
|
24
|
+
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.');
|
25
|
+
}
|
21
26
|
|
22
27
|
function error(format) {
|
23
28
|
{
|
@@ -35,8 +40,7 @@ function printWarning(level, format, args) {
|
|
35
40
|
// When changing this logic, you might want to also
|
36
41
|
// update consoleWithStackDev.www.js as well.
|
37
42
|
{
|
38
|
-
var
|
39
|
-
var stack = ReactDebugCurrentFrame.getStackAddendum();
|
43
|
+
var stack = ReactSharedInternalsServer.getStackAddendum();
|
40
44
|
|
41
45
|
if (stack !== '') {
|
42
46
|
format += '%s';
|
@@ -453,18 +457,45 @@ function getServerReferenceBoundArguments(config, serverReference) {
|
|
453
457
|
return serverReference.$$bound;
|
454
458
|
}
|
455
459
|
|
456
|
-
var ReactDOMSharedInternals = ReactDOM.
|
457
|
-
|
458
|
-
var
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
460
|
+
var ReactDOMSharedInternals = ReactDOM.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
|
461
|
+
|
462
|
+
var previousDispatcher = ReactDOMSharedInternals.d;
|
463
|
+
/* ReactDOMCurrentDispatcher */
|
464
|
+
|
465
|
+
ReactDOMSharedInternals.d
|
466
|
+
/* ReactDOMCurrentDispatcher */
|
467
|
+
= {
|
468
|
+
f
|
469
|
+
/* flushSyncWork */
|
470
|
+
: previousDispatcher.f
|
471
|
+
/* flushSyncWork */
|
472
|
+
,
|
473
|
+
r
|
474
|
+
/* requestFormReset */
|
475
|
+
: previousDispatcher.r
|
476
|
+
/* requestFormReset */
|
477
|
+
,
|
478
|
+
D
|
479
|
+
/* prefetchDNS */
|
480
|
+
: prefetchDNS,
|
481
|
+
C
|
482
|
+
/* preconnect */
|
483
|
+
: preconnect,
|
484
|
+
L
|
485
|
+
/* preload */
|
486
|
+
: preload,
|
487
|
+
m
|
488
|
+
/* preloadModule */
|
489
|
+
: preloadModule$1,
|
490
|
+
X
|
491
|
+
/* preinitScript */
|
492
|
+
: preinitScript,
|
493
|
+
S
|
494
|
+
/* preinitStyle */
|
495
|
+
: preinitStyle,
|
496
|
+
M
|
497
|
+
/* preinitModuleScript */
|
498
|
+
: preinitModuleScript
|
468
499
|
};
|
469
500
|
|
470
501
|
function prefetchDNS(href) {
|
@@ -483,7 +514,9 @@ function prefetchDNS(href) {
|
|
483
514
|
hints.add(key);
|
484
515
|
emitHint(request, 'D', href);
|
485
516
|
} else {
|
486
|
-
previousDispatcher.
|
517
|
+
previousDispatcher.D(
|
518
|
+
/* prefetchDNS */
|
519
|
+
href);
|
487
520
|
}
|
488
521
|
}
|
489
522
|
}
|
@@ -509,7 +542,9 @@ function preconnect(href, crossOrigin) {
|
|
509
542
|
emitHint(request, 'C', href);
|
510
543
|
}
|
511
544
|
} else {
|
512
|
-
previousDispatcher.
|
545
|
+
previousDispatcher.C(
|
546
|
+
/* preconnect */
|
547
|
+
href, crossOrigin);
|
513
548
|
}
|
514
549
|
}
|
515
550
|
}
|
@@ -542,7 +577,9 @@ function preload(href, as, options) {
|
|
542
577
|
emitHint(request, 'L', [href, as]);
|
543
578
|
}
|
544
579
|
} else {
|
545
|
-
previousDispatcher.
|
580
|
+
previousDispatcher.L(
|
581
|
+
/* preload */
|
582
|
+
href, as, options);
|
546
583
|
}
|
547
584
|
}
|
548
585
|
}
|
@@ -569,7 +606,9 @@ function preloadModule$1(href, options) {
|
|
569
606
|
return emitHint(request, 'm', href);
|
570
607
|
}
|
571
608
|
} else {
|
572
|
-
previousDispatcher.
|
609
|
+
previousDispatcher.m(
|
610
|
+
/* preloadModule */
|
611
|
+
href, options);
|
573
612
|
}
|
574
613
|
}
|
575
614
|
}
|
@@ -598,7 +637,9 @@ function preinitStyle(href, precedence, options) {
|
|
598
637
|
return emitHint(request, 'S', href);
|
599
638
|
}
|
600
639
|
} else {
|
601
|
-
previousDispatcher.
|
640
|
+
previousDispatcher.S(
|
641
|
+
/* preinitStyle */
|
642
|
+
href, precedence, options);
|
602
643
|
}
|
603
644
|
}
|
604
645
|
}
|
@@ -625,7 +666,9 @@ function preinitScript(src, options) {
|
|
625
666
|
return emitHint(request, 'X', src);
|
626
667
|
}
|
627
668
|
} else {
|
628
|
-
previousDispatcher.
|
669
|
+
previousDispatcher.X(
|
670
|
+
/* preinitScript */
|
671
|
+
src, options);
|
629
672
|
}
|
630
673
|
}
|
631
674
|
}
|
@@ -652,7 +695,9 @@ function preinitModuleScript(src, options) {
|
|
652
695
|
return emitHint(request, 'M', src);
|
653
696
|
}
|
654
697
|
} else {
|
655
|
-
previousDispatcher.
|
698
|
+
previousDispatcher.M(
|
699
|
+
/* preinitModuleScript */
|
700
|
+
src, options);
|
656
701
|
}
|
657
702
|
}
|
658
703
|
} // Flight normally encodes undefined as a special character however for directive option
|
@@ -933,21 +978,34 @@ function getSuspendedThenable() {
|
|
933
978
|
var currentRequest$1 = null;
|
934
979
|
var thenableIndexCounter = 0;
|
935
980
|
var thenableState = null;
|
981
|
+
var currentComponentDebugInfo = null;
|
936
982
|
function prepareToUseHooksForRequest(request) {
|
937
983
|
currentRequest$1 = request;
|
938
984
|
}
|
939
985
|
function resetHooksForRequest() {
|
940
986
|
currentRequest$1 = null;
|
941
987
|
}
|
942
|
-
function prepareToUseHooksForComponent(prevThenableState) {
|
988
|
+
function prepareToUseHooksForComponent(prevThenableState, componentDebugInfo) {
|
943
989
|
thenableIndexCounter = 0;
|
944
990
|
thenableState = prevThenableState;
|
991
|
+
|
992
|
+
{
|
993
|
+
currentComponentDebugInfo = componentDebugInfo;
|
994
|
+
}
|
945
995
|
}
|
946
996
|
function getThenableStateAfterSuspending() {
|
947
997
|
// If you use() to Suspend this should always exist but if you throw a Promise instead,
|
948
998
|
// which is not really supported anymore, it will be empty. We use the empty set as a
|
949
999
|
// marker to know if this was a replay of the same component or first attempt.
|
950
1000
|
var state = thenableState || createThenableState();
|
1001
|
+
|
1002
|
+
{
|
1003
|
+
// This is a hack but we stash the debug info here so that we don't need a completely
|
1004
|
+
// different data structure just for this in DEV. Not too happy about it.
|
1005
|
+
state._componentDebugInfo = currentComponentDebugInfo;
|
1006
|
+
currentComponentDebugInfo = null;
|
1007
|
+
}
|
1008
|
+
|
951
1009
|
thenableState = null;
|
952
1010
|
return state;
|
953
1011
|
}
|
@@ -1405,12 +1463,7 @@ function describeObjectForErrorMessage(objectOrArray, expandedName) {
|
|
1405
1463
|
return '\n ' + str;
|
1406
1464
|
}
|
1407
1465
|
|
1408
|
-
var
|
1409
|
-
React.__SECRET_SERVER_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
1410
|
-
|
1411
|
-
if (!ReactSharedServerInternals) {
|
1412
|
-
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.');
|
1413
|
-
}
|
1466
|
+
var ReactSharedInternals = ReactSharedInternalsServer;
|
1414
1467
|
|
1415
1468
|
var ObjectPrototype = Object.prototype;
|
1416
1469
|
var stringify = JSON.stringify; // Serializable values
|
@@ -1424,8 +1477,6 @@ var ERRORED$1 = 4; // object reference status
|
|
1424
1477
|
|
1425
1478
|
var SEEN_BUT_NOT_YET_OUTLINED = -1;
|
1426
1479
|
var NEVER_OUTLINED = -2;
|
1427
|
-
var ReactCurrentCache = ReactSharedServerInternals.ReactCurrentCache;
|
1428
|
-
var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
|
1429
1480
|
|
1430
1481
|
function defaultErrorHandler(error) {
|
1431
1482
|
console['error'](error); // Don't transform to our wrapper
|
@@ -1438,11 +1489,11 @@ var OPEN = 0;
|
|
1438
1489
|
var CLOSING = 1;
|
1439
1490
|
var CLOSED = 2;
|
1440
1491
|
function createRequest(model, bundlerConfig, onError, identifierPrefix, onPostpone, environmentName) {
|
1441
|
-
if (
|
1492
|
+
if (ReactSharedInternals.C !== null && ReactSharedInternals.C !== DefaultCacheDispatcher) {
|
1442
1493
|
throw new Error('Currently React only supports one RSC renderer at a time.');
|
1443
1494
|
}
|
1444
1495
|
|
1445
|
-
|
1496
|
+
ReactSharedInternals.C = DefaultCacheDispatcher;
|
1446
1497
|
var abortSet = new Set();
|
1447
1498
|
var pingedTasks = [];
|
1448
1499
|
var cleanupQueue = [];
|
@@ -1651,33 +1702,56 @@ function createLazyWrapperAroundWakeable(wakeable) {
|
|
1651
1702
|
return lazyType;
|
1652
1703
|
}
|
1653
1704
|
|
1654
|
-
function renderFunctionComponent(request, task, key, Component, props) {
|
1705
|
+
function renderFunctionComponent(request, task, key, Component, props, owner) {
|
1655
1706
|
// Reset the task's thenable state before continuing, so that if a later
|
1656
1707
|
// component suspends we can reuse the same task object. If the same
|
1657
1708
|
// component suspends again, the thenable state will be restored.
|
1658
1709
|
var prevThenableState = task.thenableState;
|
1659
1710
|
task.thenableState = null;
|
1711
|
+
var componentDebugInfo = null;
|
1660
1712
|
|
1661
1713
|
{
|
1662
1714
|
if (debugID === null) {
|
1663
1715
|
// We don't have a chunk to assign debug info. We need to outline this
|
1664
1716
|
// component to assign it an ID.
|
1665
1717
|
return outlineTask(request, task);
|
1666
|
-
} else if (prevThenableState !== null)
|
1718
|
+
} else if (prevThenableState !== null) {
|
1719
|
+
// This is a replay and we've already emitted the debug info of this component
|
1720
|
+
// in the first pass. We skip emitting a duplicate line.
|
1721
|
+
// As a hack we stashed the previous component debug info on this object in DEV.
|
1722
|
+
componentDebugInfo = prevThenableState._componentDebugInfo;
|
1723
|
+
} else {
|
1667
1724
|
// This is a new component in the same task so we can emit more debug info.
|
1668
1725
|
var componentName = Component.displayName || Component.name || '';
|
1669
1726
|
request.pendingChunks++;
|
1670
|
-
|
1727
|
+
var componentDebugID = debugID;
|
1728
|
+
componentDebugInfo = {
|
1671
1729
|
name: componentName,
|
1672
|
-
env: request.environmentName
|
1673
|
-
|
1730
|
+
env: request.environmentName,
|
1731
|
+
owner: owner
|
1732
|
+
}; // We outline this model eagerly so that we can refer to by reference as an owner.
|
1733
|
+
// If we had a smarter way to dedupe we might not have to do this if there ends up
|
1734
|
+
// being no references to this as an owner.
|
1735
|
+
|
1736
|
+
outlineModel(request, componentDebugInfo);
|
1737
|
+
emitDebugChunk(request, componentDebugID, componentDebugInfo);
|
1674
1738
|
}
|
1675
1739
|
}
|
1676
1740
|
|
1677
|
-
prepareToUseHooksForComponent(prevThenableState); // The secondArg is always undefined in Server Components since refs error early.
|
1741
|
+
prepareToUseHooksForComponent(prevThenableState, componentDebugInfo); // The secondArg is always undefined in Server Components since refs error early.
|
1678
1742
|
|
1679
1743
|
var secondArg = undefined;
|
1680
|
-
var result
|
1744
|
+
var result;
|
1745
|
+
|
1746
|
+
{
|
1747
|
+
ReactSharedInternals.owner = componentDebugInfo;
|
1748
|
+
|
1749
|
+
try {
|
1750
|
+
result = Component(props, secondArg);
|
1751
|
+
} finally {
|
1752
|
+
ReactSharedInternals.owner = null;
|
1753
|
+
}
|
1754
|
+
}
|
1681
1755
|
|
1682
1756
|
if (typeof result === 'object' && result !== null && typeof result.then === 'function') {
|
1683
1757
|
// When the return value is in children position we can resolve it immediately,
|
@@ -1768,7 +1842,8 @@ function renderFragment(request, task, children) {
|
|
1768
1842
|
return children;
|
1769
1843
|
}
|
1770
1844
|
|
1771
|
-
function renderClientElement(task, type, key, props)
|
1845
|
+
function renderClientElement(task, type, key, props, owner) // DEV-only
|
1846
|
+
{
|
1772
1847
|
// the keys of any Server Components which are not serialized.
|
1773
1848
|
|
1774
1849
|
|
@@ -1780,7 +1855,7 @@ function renderClientElement(task, type, key, props) {
|
|
1780
1855
|
key = keyPath + ',' + key;
|
1781
1856
|
}
|
1782
1857
|
|
1783
|
-
var element = [REACT_ELEMENT_TYPE, type, key, props];
|
1858
|
+
var element = [REACT_ELEMENT_TYPE, type, key, props, owner] ;
|
1784
1859
|
|
1785
1860
|
if (task.implicitSlot && key !== null) {
|
1786
1861
|
// The root Server Component had no key so it was in an implicit slot.
|
@@ -1818,7 +1893,8 @@ function outlineTask(request, task) {
|
|
1818
1893
|
return serializeLazyID(newTask.id);
|
1819
1894
|
}
|
1820
1895
|
|
1821
|
-
function renderElement(request, task, type, key, ref, props)
|
1896
|
+
function renderElement(request, task, type, key, ref, props, owner) // DEV only
|
1897
|
+
{
|
1822
1898
|
if (ref !== null && ref !== undefined) {
|
1823
1899
|
// When the ref moves to the regular props object this will implicitly
|
1824
1900
|
// throw for functions. We could probably relax it to a DEV warning for other
|
@@ -1839,14 +1915,14 @@ function renderElement(request, task, type, key, ref, props) {
|
|
1839
1915
|
if (typeof type === 'function') {
|
1840
1916
|
if (isClientReference(type) || isTemporaryReference(type)) {
|
1841
1917
|
// This is a reference to a Client Component.
|
1842
|
-
return renderClientElement(task, type, key, props);
|
1918
|
+
return renderClientElement(task, type, key, props, owner);
|
1843
1919
|
} // This is a Server Component.
|
1844
1920
|
|
1845
1921
|
|
1846
|
-
return renderFunctionComponent(request, task, key, type, props);
|
1922
|
+
return renderFunctionComponent(request, task, key, type, props, owner);
|
1847
1923
|
} else if (typeof type === 'string') {
|
1848
1924
|
// This is a host element. E.g. HTML.
|
1849
|
-
return renderClientElement(task, type, key, props);
|
1925
|
+
return renderClientElement(task, type, key, props, owner);
|
1850
1926
|
} else if (typeof type === 'symbol') {
|
1851
1927
|
if (type === REACT_FRAGMENT_TYPE && key === null) {
|
1852
1928
|
// For key-less fragments, we add a small optimization to avoid serializing
|
@@ -1864,11 +1940,11 @@ function renderElement(request, task, type, key, ref, props) {
|
|
1864
1940
|
// Any built-in works as long as its props are serializable.
|
1865
1941
|
|
1866
1942
|
|
1867
|
-
return renderClientElement(task, type, key, props);
|
1943
|
+
return renderClientElement(task, type, key, props, owner);
|
1868
1944
|
} else if (type != null && typeof type === 'object') {
|
1869
1945
|
if (isClientReference(type)) {
|
1870
1946
|
// This is a reference to a Client Component.
|
1871
|
-
return renderClientElement(task, type, key, props);
|
1947
|
+
return renderClientElement(task, type, key, props, owner);
|
1872
1948
|
}
|
1873
1949
|
|
1874
1950
|
switch (type.$$typeof) {
|
@@ -1877,17 +1953,17 @@ function renderElement(request, task, type, key, ref, props) {
|
|
1877
1953
|
var payload = type._payload;
|
1878
1954
|
var init = type._init;
|
1879
1955
|
var wrappedType = init(payload);
|
1880
|
-
return renderElement(request, task, wrappedType, key, ref, props);
|
1956
|
+
return renderElement(request, task, wrappedType, key, ref, props, owner);
|
1881
1957
|
}
|
1882
1958
|
|
1883
1959
|
case REACT_FORWARD_REF_TYPE:
|
1884
1960
|
{
|
1885
|
-
return renderFunctionComponent(request, task, key, type.render, props);
|
1961
|
+
return renderFunctionComponent(request, task, key, type.render, props, owner);
|
1886
1962
|
}
|
1887
1963
|
|
1888
1964
|
case REACT_MEMO_TYPE:
|
1889
1965
|
{
|
1890
|
-
return renderElement(request, task, type.type, key, ref, props);
|
1966
|
+
return renderElement(request, task, type.type, key, ref, props, owner);
|
1891
1967
|
}
|
1892
1968
|
}
|
1893
1969
|
}
|
@@ -1966,6 +2042,10 @@ function serializeLazyID(id) {
|
|
1966
2042
|
return '$L' + id.toString(16);
|
1967
2043
|
}
|
1968
2044
|
|
2045
|
+
function serializeInfinitePromise() {
|
2046
|
+
return '$@';
|
2047
|
+
}
|
2048
|
+
|
1969
2049
|
function serializePromiseID(id) {
|
1970
2050
|
return '$@' + id.toString(16);
|
1971
2051
|
}
|
@@ -2130,6 +2210,12 @@ function serializeMap(request, map) {
|
|
2130
2210
|
return '$Q' + id.toString(16);
|
2131
2211
|
}
|
2132
2212
|
|
2213
|
+
function serializeFormData(request, formData) {
|
2214
|
+
var entries = Array.from(formData.entries());
|
2215
|
+
var id = outlineModel(request, entries);
|
2216
|
+
return '$K' + id.toString(16);
|
2217
|
+
}
|
2218
|
+
|
2133
2219
|
function serializeSet(request, set) {
|
2134
2220
|
var entries = Array.from(set);
|
2135
2221
|
|
@@ -2306,7 +2392,7 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
|
|
2306
2392
|
|
2307
2393
|
|
2308
2394
|
return renderElement(request, task, element.type, // $FlowFixMe[incompatible-call] the key of an element is null | string
|
2309
|
-
element.key, ref, props);
|
2395
|
+
element.key, ref, props, element._owner );
|
2310
2396
|
}
|
2311
2397
|
|
2312
2398
|
case REACT_LAZY_TYPE:
|
@@ -2404,6 +2490,11 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
|
|
2404
2490
|
|
2405
2491
|
if (value instanceof Set) {
|
2406
2492
|
return serializeSet(request, value);
|
2493
|
+
} // TODO: FormData is not available in old Node. Remove the typeof later.
|
2494
|
+
|
2495
|
+
|
2496
|
+
if (typeof FormData === 'function' && value instanceof FormData) {
|
2497
|
+
return serializeFormData(request, value);
|
2407
2498
|
}
|
2408
2499
|
|
2409
2500
|
var iteratorFn = getIteratorFn(value);
|
@@ -2671,14 +2762,216 @@ function emitModelChunk(request, id, json) {
|
|
2671
2762
|
}
|
2672
2763
|
|
2673
2764
|
function emitDebugChunk(request, id, debugInfo) {
|
2765
|
+
// use the full serialization that requires a task.
|
2674
2766
|
|
2675
2767
|
|
2676
|
-
var
|
2768
|
+
var counter = {
|
2769
|
+
objectCount: 0
|
2770
|
+
};
|
2771
|
+
|
2772
|
+
function replacer(parentPropertyName, value) {
|
2773
|
+
return renderConsoleValue(request, counter, this, parentPropertyName, value);
|
2774
|
+
} // $FlowFixMe[incompatible-type] stringify can return null
|
2775
|
+
|
2776
|
+
|
2777
|
+
var json = stringify(debugInfo, replacer);
|
2677
2778
|
var row = serializeRowHeader('D', id) + json + '\n';
|
2678
2779
|
var processedChunk = stringToChunk(row);
|
2679
2780
|
request.completedRegularChunks.push(processedChunk);
|
2680
2781
|
}
|
2681
2782
|
|
2783
|
+
function serializeEval(source) {
|
2784
|
+
|
2785
|
+
return '$E' + source;
|
2786
|
+
} // This is a forked version of renderModel which should never error, never suspend and is limited
|
2787
|
+
// in the depth it can encode.
|
2788
|
+
|
2789
|
+
|
2790
|
+
function renderConsoleValue(request, counter, parent, parentPropertyName, value) {
|
2791
|
+
// Make sure that `parent[parentPropertyName]` wasn't JSONified before `value` was passed to us
|
2792
|
+
// $FlowFixMe[incompatible-use]
|
2793
|
+
var originalValue = parent[parentPropertyName];
|
2794
|
+
|
2795
|
+
if (value === null) {
|
2796
|
+
return null;
|
2797
|
+
}
|
2798
|
+
|
2799
|
+
if (typeof value === 'object') {
|
2800
|
+
if (isClientReference(value)) {
|
2801
|
+
// We actually have this value on the client so we could import it.
|
2802
|
+
// This might be confusing though because on the Server it won't actually
|
2803
|
+
// be this value, so if you're debugging client references maybe you'd be
|
2804
|
+
// better with a place holder.
|
2805
|
+
return serializeClientReference(request, parent, parentPropertyName, value);
|
2806
|
+
}
|
2807
|
+
|
2808
|
+
if (counter.objectCount > 20) {
|
2809
|
+
// We've reached our max number of objects to serialize across the wire so we serialize this
|
2810
|
+
// object but no properties inside of it, as a place holder.
|
2811
|
+
return Array.isArray(value) ? [] : {};
|
2812
|
+
}
|
2813
|
+
|
2814
|
+
counter.objectCount++;
|
2815
|
+
var writtenObjects = request.writtenObjects;
|
2816
|
+
var existingId = writtenObjects.get(value); // $FlowFixMe[method-unbinding]
|
2817
|
+
|
2818
|
+
if (typeof value.then === 'function') {
|
2819
|
+
if (existingId !== undefined) {
|
2820
|
+
// We've seen this promise before, so we can just refer to the same result.
|
2821
|
+
return serializePromiseID(existingId);
|
2822
|
+
}
|
2823
|
+
|
2824
|
+
var thenable = value;
|
2825
|
+
|
2826
|
+
switch (thenable.status) {
|
2827
|
+
case 'fulfilled':
|
2828
|
+
{
|
2829
|
+
return serializePromiseID(outlineConsoleValue(request, counter, thenable.value));
|
2830
|
+
}
|
2831
|
+
|
2832
|
+
case 'rejected':
|
2833
|
+
{
|
2834
|
+
var x = thenable.reason;
|
2835
|
+
request.pendingChunks++;
|
2836
|
+
var errorId = request.nextChunkId++;
|
2837
|
+
|
2838
|
+
{
|
2839
|
+
// We don't log these errors since they didn't actually throw into Flight.
|
2840
|
+
var digest = '';
|
2841
|
+
emitErrorChunk(request, errorId, digest, x);
|
2842
|
+
}
|
2843
|
+
|
2844
|
+
return serializePromiseID(errorId);
|
2845
|
+
}
|
2846
|
+
} // If it hasn't already resolved (and been instrumented) we just encode an infinite
|
2847
|
+
// promise that will never resolve.
|
2848
|
+
|
2849
|
+
|
2850
|
+
return serializeInfinitePromise();
|
2851
|
+
}
|
2852
|
+
|
2853
|
+
if (existingId !== undefined && existingId >= 0) {
|
2854
|
+
// We've already emitted this as a real object, so we can
|
2855
|
+
// just refer to that by its existing ID.
|
2856
|
+
return serializeByValueID(existingId);
|
2857
|
+
}
|
2858
|
+
|
2859
|
+
if (isArray(value)) {
|
2860
|
+
return value;
|
2861
|
+
}
|
2862
|
+
|
2863
|
+
if (value instanceof Map) {
|
2864
|
+
return serializeMap(request, value);
|
2865
|
+
}
|
2866
|
+
|
2867
|
+
if (value instanceof Set) {
|
2868
|
+
return serializeSet(request, value);
|
2869
|
+
} // TODO: FormData is not available in old Node. Remove the typeof later.
|
2870
|
+
|
2871
|
+
|
2872
|
+
if (typeof FormData === 'function' && value instanceof FormData) {
|
2873
|
+
return serializeFormData(request, value);
|
2874
|
+
}
|
2875
|
+
|
2876
|
+
var iteratorFn = getIteratorFn(value);
|
2877
|
+
|
2878
|
+
if (iteratorFn) {
|
2879
|
+
return Array.from(value);
|
2880
|
+
} // $FlowFixMe[incompatible-return]
|
2881
|
+
|
2882
|
+
|
2883
|
+
return value;
|
2884
|
+
}
|
2885
|
+
|
2886
|
+
if (typeof value === 'string') {
|
2887
|
+
if (value[value.length - 1] === 'Z') {
|
2888
|
+
// Possibly a Date, whose toJSON automatically calls toISOString
|
2889
|
+
if (originalValue instanceof Date) {
|
2890
|
+
return serializeDateFromDateJSON(value);
|
2891
|
+
}
|
2892
|
+
}
|
2893
|
+
|
2894
|
+
if (value.length >= 1024) {
|
2895
|
+
// For large strings, we encode them outside the JSON payload so that we
|
2896
|
+
// don't have to double encode and double parse the strings. This can also
|
2897
|
+
// be more compact in case the string has a lot of escaped characters.
|
2898
|
+
return serializeLargeTextString(request, value);
|
2899
|
+
}
|
2900
|
+
|
2901
|
+
return escapeStringValue(value);
|
2902
|
+
}
|
2903
|
+
|
2904
|
+
if (typeof value === 'boolean') {
|
2905
|
+
return value;
|
2906
|
+
}
|
2907
|
+
|
2908
|
+
if (typeof value === 'number') {
|
2909
|
+
return serializeNumber(value);
|
2910
|
+
}
|
2911
|
+
|
2912
|
+
if (typeof value === 'undefined') {
|
2913
|
+
return serializeUndefined();
|
2914
|
+
}
|
2915
|
+
|
2916
|
+
if (typeof value === 'function') {
|
2917
|
+
if (isClientReference(value)) {
|
2918
|
+
return serializeClientReference(request, parent, parentPropertyName, value);
|
2919
|
+
}
|
2920
|
+
|
2921
|
+
if (isTemporaryReference(value)) {
|
2922
|
+
return serializeTemporaryReference(request, value);
|
2923
|
+
} // Serialize the body of the function as an eval so it can be printed.
|
2924
|
+
// $FlowFixMe[method-unbinding]
|
2925
|
+
|
2926
|
+
|
2927
|
+
return serializeEval('(' + Function.prototype.toString.call(value) + ')');
|
2928
|
+
}
|
2929
|
+
|
2930
|
+
if (typeof value === 'symbol') {
|
2931
|
+
var writtenSymbols = request.writtenSymbols;
|
2932
|
+
|
2933
|
+
var _existingId3 = writtenSymbols.get(value);
|
2934
|
+
|
2935
|
+
if (_existingId3 !== undefined) {
|
2936
|
+
return serializeByValueID(_existingId3);
|
2937
|
+
} // $FlowFixMe[incompatible-type] `description` might be undefined
|
2938
|
+
|
2939
|
+
|
2940
|
+
var name = value.description; // We use the Symbol.for version if it's not a global symbol. Close enough.
|
2941
|
+
|
2942
|
+
request.pendingChunks++;
|
2943
|
+
var symbolId = request.nextChunkId++;
|
2944
|
+
emitSymbolChunk(request, symbolId, name);
|
2945
|
+
return serializeByValueID(symbolId);
|
2946
|
+
}
|
2947
|
+
|
2948
|
+
if (typeof value === 'bigint') {
|
2949
|
+
return serializeBigInt(value);
|
2950
|
+
}
|
2951
|
+
|
2952
|
+
return 'unknown type ' + typeof value;
|
2953
|
+
}
|
2954
|
+
|
2955
|
+
function outlineConsoleValue(request, counter, model) {
|
2956
|
+
|
2957
|
+
function replacer(parentPropertyName, value) {
|
2958
|
+
try {
|
2959
|
+
return renderConsoleValue(request, counter, this, parentPropertyName, value);
|
2960
|
+
} catch (x) {
|
2961
|
+
return 'unknown value';
|
2962
|
+
}
|
2963
|
+
} // $FlowFixMe[incompatible-type] stringify can return null
|
2964
|
+
|
2965
|
+
|
2966
|
+
var json = stringify(model, replacer);
|
2967
|
+
request.pendingChunks++;
|
2968
|
+
var id = request.nextChunkId++;
|
2969
|
+
var row = id.toString(16) + ':' + json + '\n';
|
2970
|
+
var processedChunk = stringToChunk(row);
|
2971
|
+
request.completedRegularChunks.push(processedChunk);
|
2972
|
+
return id;
|
2973
|
+
}
|
2974
|
+
|
2682
2975
|
function forwardDebugInfo(request, id, debugInfo) {
|
2683
2976
|
for (var i = 0; i < debugInfo.length; i++) {
|
2684
2977
|
request.pendingChunks++;
|
@@ -2770,8 +3063,8 @@ function retryTask(request, task) {
|
|
2770
3063
|
}
|
2771
3064
|
|
2772
3065
|
function performWork(request) {
|
2773
|
-
var prevDispatcher =
|
2774
|
-
|
3066
|
+
var prevDispatcher = ReactSharedInternals.H;
|
3067
|
+
ReactSharedInternals.H = HooksDispatcher;
|
2775
3068
|
var prevRequest = currentRequest;
|
2776
3069
|
currentRequest = request;
|
2777
3070
|
prepareToUseHooksForRequest(request);
|
@@ -2792,7 +3085,7 @@ function performWork(request) {
|
|
2792
3085
|
logRecoverableError(request, error);
|
2793
3086
|
fatalError(request, error);
|
2794
3087
|
} finally {
|
2795
|
-
|
3088
|
+
ReactSharedInternals.H = prevDispatcher;
|
2796
3089
|
resetHooksForRequest();
|
2797
3090
|
currentRequest = prevRequest;
|
2798
3091
|
}
|