react-server-dom-webpack 19.0.0-canary-96c584661-20240412 → 19.0.0-canary-657428a9e-20240416
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 +40 -7
- package/cjs/react-server-dom-webpack-client.browser.production.js +37 -6
- package/cjs/react-server-dom-webpack-client.browser.production.min.js +7 -7
- package/cjs/react-server-dom-webpack-client.browser.production.min.js.map +1 -1
- package/cjs/react-server-dom-webpack-client.edge.development.js +40 -7
- package/cjs/react-server-dom-webpack-client.edge.production.js +37 -6
- package/cjs/react-server-dom-webpack-client.edge.production.min.js +18 -18
- package/cjs/react-server-dom-webpack-client.edge.production.min.js.map +1 -1
- package/cjs/react-server-dom-webpack-client.node.development.js +40 -7
- package/cjs/react-server-dom-webpack-client.node.production.js +37 -6
- package/cjs/react-server-dom-webpack-client.node.production.min.js +4 -4
- 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 +40 -7
- package/cjs/react-server-dom-webpack-client.node.unbundled.production.js +37 -6
- package/cjs/react-server-dom-webpack-client.node.unbundled.production.min.js +16 -16
- package/cjs/react-server-dom-webpack-client.node.unbundled.production.min.js.map +1 -1
- package/cjs/react-server-dom-webpack-server.browser.development.js +127 -86
- package/cjs/react-server-dom-webpack-server.browser.production.js +95 -64
- package/cjs/react-server-dom-webpack-server.browser.production.min.js +59 -58
- package/cjs/react-server-dom-webpack-server.browser.production.min.js.map +1 -1
- package/cjs/react-server-dom-webpack-server.edge.development.js +127 -86
- package/cjs/react-server-dom-webpack-server.edge.production.js +95 -64
- package/cjs/react-server-dom-webpack-server.edge.production.min.js +60 -60
- package/cjs/react-server-dom-webpack-server.edge.production.min.js.map +1 -1
- package/cjs/react-server-dom-webpack-server.node.development.js +127 -86
- package/cjs/react-server-dom-webpack-server.node.production.js +95 -64
- package/cjs/react-server-dom-webpack-server.node.production.min.js +60 -61
- 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 +127 -86
- package/cjs/react-server-dom-webpack-server.node.unbundled.production.js +95 -64
- package/cjs/react-server-dom-webpack-server.node.unbundled.production.min.js +58 -58
- 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 +40 -7
- package/umd/react-server-dom-webpack-client.browser.production.min.js +19 -19
- package/umd/react-server-dom-webpack-server.browser.development.js +127 -86
- package/umd/react-server-dom-webpack-server.browser.production.min.js +55 -54
@@ -972,7 +972,14 @@ function trackUsedThenable(thenableState, thenable, index) {
|
|
972
972
|
|
973
973
|
default:
|
974
974
|
{
|
975
|
-
if (typeof thenable.status === 'string')
|
975
|
+
if (typeof thenable.status === 'string') {
|
976
|
+
// Only instrument the thenable if the status if not defined. If
|
977
|
+
// it's defined, but an unknown value, assume it's been instrumented by
|
978
|
+
// some custom userspace implementation. We treat it as "pending".
|
979
|
+
// Attach a dummy listener, to ensure that any lazy initialization can
|
980
|
+
// happen. Flight lazily parses JSON when the value is actually awaited.
|
981
|
+
thenable.then(noop, noop);
|
982
|
+
} else {
|
976
983
|
var pendingThenable = thenable;
|
977
984
|
pendingThenable.status = 'pending';
|
978
985
|
pendingThenable.then(function (fulfilledValue) {
|
@@ -987,21 +994,22 @@ function trackUsedThenable(thenableState, thenable, index) {
|
|
987
994
|
rejectedThenable.status = 'rejected';
|
988
995
|
rejectedThenable.reason = error;
|
989
996
|
}
|
990
|
-
});
|
997
|
+
});
|
998
|
+
} // Check one more time in case the thenable resolved synchronously
|
991
999
|
|
992
|
-
switch (thenable.status) {
|
993
|
-
case 'fulfilled':
|
994
|
-
{
|
995
|
-
var fulfilledThenable = thenable;
|
996
|
-
return fulfilledThenable.value;
|
997
|
-
}
|
998
1000
|
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1001
|
+
switch (thenable.status) {
|
1002
|
+
case 'fulfilled':
|
1003
|
+
{
|
1004
|
+
var fulfilledThenable = thenable;
|
1005
|
+
return fulfilledThenable.value;
|
1006
|
+
}
|
1007
|
+
|
1008
|
+
case 'rejected':
|
1009
|
+
{
|
1010
|
+
var rejectedThenable = thenable;
|
1011
|
+
throw rejectedThenable.reason;
|
1012
|
+
}
|
1005
1013
|
} // Suspend.
|
1006
1014
|
//
|
1007
1015
|
// Throwing here is an implementation detail that allows us to unwind the
|
@@ -1568,6 +1576,7 @@ function createRequest(model, bundlerConfig, onError, identifierPrefix, onPostpo
|
|
1568
1576
|
nextChunkId: 0,
|
1569
1577
|
pendingChunks: 0,
|
1570
1578
|
hints: hints,
|
1579
|
+
abortListeners: new Set(),
|
1571
1580
|
abortableTasks: abortSet,
|
1572
1581
|
pingedTasks: pingedTasks,
|
1573
1582
|
completedImportChunks: [],
|
@@ -1680,10 +1689,7 @@ function serializeThenable(request, task, thenable) {
|
|
1680
1689
|
}
|
1681
1690
|
|
1682
1691
|
request.abortableTasks.delete(newTask);
|
1683
|
-
|
1684
|
-
if (request.destination !== null) {
|
1685
|
-
flushCompletedChunks(request, request.destination);
|
1686
|
-
}
|
1692
|
+
enqueueFlush(request);
|
1687
1693
|
});
|
1688
1694
|
return newTask.id;
|
1689
1695
|
}
|
@@ -1849,24 +1855,6 @@ function renderFunctionComponent(request, task, key, Component, props, owner) {
|
|
1849
1855
|
}
|
1850
1856
|
|
1851
1857
|
function renderFragment(request, task, children) {
|
1852
|
-
{
|
1853
|
-
var debugInfo = children._debugInfo;
|
1854
|
-
|
1855
|
-
if (debugInfo) {
|
1856
|
-
// If this came from Flight, forward any debug info into this new row.
|
1857
|
-
if (debugID === null) {
|
1858
|
-
// We don't have a chunk to assign debug info. We need to outline this
|
1859
|
-
// component to assign it an ID.
|
1860
|
-
return outlineTask(request, task);
|
1861
|
-
} else {
|
1862
|
-
// Forward any debug info we have the first time we see it.
|
1863
|
-
// We do this after init so that we have received all the debug info
|
1864
|
-
// from the server by the time we emit it.
|
1865
|
-
forwardDebugInfo(request, debugID, debugInfo);
|
1866
|
-
}
|
1867
|
-
}
|
1868
|
-
}
|
1869
|
-
|
1870
1858
|
if (task.keyPath !== null) {
|
1871
1859
|
// We have a Server Component that specifies a key but we're now splitting
|
1872
1860
|
// the tree using a fragment.
|
@@ -1898,6 +1886,28 @@ function renderFragment(request, task, children) {
|
|
1898
1886
|
// before recursing here.
|
1899
1887
|
|
1900
1888
|
|
1889
|
+
{
|
1890
|
+
var debugInfo = children._debugInfo;
|
1891
|
+
|
1892
|
+
if (debugInfo) {
|
1893
|
+
// If this came from Flight, forward any debug info into this new row.
|
1894
|
+
if (debugID === null) {
|
1895
|
+
// We don't have a chunk to assign debug info. We need to outline this
|
1896
|
+
// component to assign it an ID.
|
1897
|
+
return outlineTask(request, task);
|
1898
|
+
} else {
|
1899
|
+
// Forward any debug info we have the first time we see it.
|
1900
|
+
// We do this after init so that we have received all the debug info
|
1901
|
+
// from the server by the time we emit it.
|
1902
|
+
forwardDebugInfo(request, debugID, debugInfo);
|
1903
|
+
} // Since we're rendering this array again, create a copy that doesn't
|
1904
|
+
// have the debug info so we avoid outlining or emitting debug info again.
|
1905
|
+
|
1906
|
+
|
1907
|
+
children = Array.from(children);
|
1908
|
+
}
|
1909
|
+
}
|
1910
|
+
|
1901
1911
|
return children;
|
1902
1912
|
}
|
1903
1913
|
|
@@ -2239,13 +2249,9 @@ function serializeTemporaryReference(request, temporaryReference) {
|
|
2239
2249
|
}
|
2240
2250
|
|
2241
2251
|
function serializeLargeTextString(request, text) {
|
2242
|
-
request.pendingChunks
|
2252
|
+
request.pendingChunks++;
|
2243
2253
|
var textId = request.nextChunkId++;
|
2244
|
-
|
2245
|
-
var binaryLength = byteLengthOfChunk(textChunk);
|
2246
|
-
var row = textId.toString(16) + ':T' + binaryLength.toString(16) + ',';
|
2247
|
-
var headerChunk = stringToChunk(row);
|
2248
|
-
request.completedRegularChunks.push(headerChunk, textChunk);
|
2254
|
+
emitTextChunk(request, textId, text);
|
2249
2255
|
return serializeByValueID(textId);
|
2250
2256
|
}
|
2251
2257
|
|
@@ -2560,7 +2566,7 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
|
|
2560
2566
|
|
2561
2567
|
if (iteratorFn) {
|
2562
2568
|
return renderFragment(request, task, Array.from(value));
|
2563
|
-
}
|
2569
|
+
}
|
2564
2570
|
|
2565
2571
|
|
2566
2572
|
var proto = getPrototypeOf(value);
|
@@ -2835,6 +2841,16 @@ function emitDebugChunk(request, id, debugInfo) {
|
|
2835
2841
|
request.completedRegularChunks.push(processedChunk);
|
2836
2842
|
}
|
2837
2843
|
|
2844
|
+
function emitTextChunk(request, id, text) {
|
2845
|
+
request.pendingChunks++; // Extra chunk for the header.
|
2846
|
+
|
2847
|
+
var textChunk = stringToChunk(text);
|
2848
|
+
var binaryLength = byteLengthOfChunk(textChunk);
|
2849
|
+
var row = id.toString(16) + ':T' + binaryLength.toString(16) + ',';
|
2850
|
+
var headerChunk = stringToChunk(row);
|
2851
|
+
request.completedRegularChunks.push(headerChunk, textChunk);
|
2852
|
+
}
|
2853
|
+
|
2838
2854
|
function serializeEval(source) {
|
2839
2855
|
|
2840
2856
|
return '$E' + source;
|
@@ -3034,6 +3050,22 @@ function forwardDebugInfo(request, id, debugInfo) {
|
|
3034
3050
|
}
|
3035
3051
|
}
|
3036
3052
|
|
3053
|
+
function emitChunk(request, task, value) {
|
3054
|
+
var id = task.id; // For certain types we have special types, we typically outlined them but
|
3055
|
+
// we can emit them directly for this row instead of through an indirection.
|
3056
|
+
|
3057
|
+
if (typeof value === 'string') {
|
3058
|
+
|
3059
|
+
emitTextChunk(request, id, value);
|
3060
|
+
return;
|
3061
|
+
}
|
3062
|
+
// $FlowFixMe[incompatible-type] stringify can return null for undefined but we never do
|
3063
|
+
|
3064
|
+
|
3065
|
+
var json = stringify(value, task.toJSON);
|
3066
|
+
emitModelChunk(request, task.id, json);
|
3067
|
+
}
|
3068
|
+
|
3037
3069
|
var emptyRoot = {};
|
3038
3070
|
|
3039
3071
|
function retryTask(request, task) {
|
@@ -3070,21 +3102,19 @@ function retryTask(request, task) {
|
|
3070
3102
|
|
3071
3103
|
task.keyPath = null;
|
3072
3104
|
task.implicitSlot = false;
|
3073
|
-
var json;
|
3074
3105
|
|
3075
3106
|
if (typeof resolvedModel === 'object' && resolvedModel !== null) {
|
3076
3107
|
// Object might contain unresolved values like additional elements.
|
3077
3108
|
// This is simulating what the JSON loop would do if this was part of it.
|
3078
|
-
|
3079
|
-
json = stringify(resolvedModel, task.toJSON);
|
3109
|
+
emitChunk(request, task, resolvedModel);
|
3080
3110
|
} else {
|
3081
3111
|
// If the value is a string, it means it's a terminal value and we already escaped it
|
3082
3112
|
// We don't need to escape it again so it's not passed the toJSON replacer.
|
3083
3113
|
// $FlowFixMe[incompatible-type] stringify can return null for undefined but we never do
|
3084
|
-
json = stringify(resolvedModel);
|
3114
|
+
var json = stringify(resolvedModel);
|
3115
|
+
emitModelChunk(request, task.id, json);
|
3085
3116
|
}
|
3086
3117
|
|
3087
|
-
emitModelChunk(request, task.id, json);
|
3088
3118
|
request.abortableTasks.delete(task);
|
3089
3119
|
task.status = COMPLETED;
|
3090
3120
|
} catch (thrownValue) {
|
@@ -3242,6 +3272,7 @@ function flushCompletedChunks(request, destination) {
|
|
3242
3272
|
if (request.pendingChunks === 0) {
|
3243
3273
|
|
3244
3274
|
close$1(destination);
|
3275
|
+
request.destination = null;
|
3245
3276
|
}
|
3246
3277
|
}
|
3247
3278
|
|
@@ -3299,11 +3330,10 @@ function stopFlowing(request) {
|
|
3299
3330
|
|
3300
3331
|
function abort(request, reason) {
|
3301
3332
|
try {
|
3302
|
-
var abortableTasks = request.abortableTasks;
|
3333
|
+
var abortableTasks = request.abortableTasks; // We have tasks to abort. We'll emit one error row and then emit a reference
|
3334
|
+
// to that row from every row that's still remaining.
|
3303
3335
|
|
3304
3336
|
if (abortableTasks.size > 0) {
|
3305
|
-
// We have tasks to abort. We'll emit one error row and then emit a reference
|
3306
|
-
// to that row from every row that's still remaining.
|
3307
3337
|
request.pendingChunks++;
|
3308
3338
|
var errorId = request.nextChunkId++;
|
3309
3339
|
|
@@ -3319,6 +3349,21 @@ function abort(request, reason) {
|
|
3319
3349
|
abortableTasks.clear();
|
3320
3350
|
}
|
3321
3351
|
|
3352
|
+
var abortListeners = request.abortListeners;
|
3353
|
+
|
3354
|
+
if (abortListeners.size > 0) {
|
3355
|
+
var _error;
|
3356
|
+
|
3357
|
+
if (enablePostpone && typeof reason === 'object' && reason !== null && reason.$$typeof === REACT_POSTPONE_TYPE) ; else {
|
3358
|
+
_error = reason === undefined ? new Error('The render was aborted by the server without a reason.') : reason;
|
3359
|
+
}
|
3360
|
+
|
3361
|
+
abortListeners.forEach(function (callback) {
|
3362
|
+
return callback(_error);
|
3363
|
+
});
|
3364
|
+
abortListeners.clear();
|
3365
|
+
}
|
3366
|
+
|
3322
3367
|
if (request.destination !== null) {
|
3323
3368
|
flushCompletedChunks(request, request.destination);
|
3324
3369
|
}
|
@@ -3701,7 +3746,7 @@ function getOutlinedModel(response, id) {
|
|
3701
3746
|
return chunk.value;
|
3702
3747
|
}
|
3703
3748
|
|
3704
|
-
function parseModelString(response,
|
3749
|
+
function parseModelString(response, obj, key, value) {
|
3705
3750
|
if (value[0] === '$') {
|
3706
3751
|
switch (value[1]) {
|
3707
3752
|
case '$':
|
@@ -3713,19 +3758,21 @@ function parseModelString(response, parentObject, key, value) {
|
|
3713
3758
|
case '@':
|
3714
3759
|
{
|
3715
3760
|
// Promise
|
3716
|
-
var
|
3717
|
-
|
3718
|
-
|
3761
|
+
var _id = parseInt(value.slice(2), 16);
|
3762
|
+
|
3763
|
+
var _chunk = getChunk(response, _id);
|
3764
|
+
|
3765
|
+
return _chunk;
|
3719
3766
|
}
|
3720
3767
|
|
3721
3768
|
case 'F':
|
3722
3769
|
{
|
3723
3770
|
// Server Reference
|
3724
|
-
var
|
3771
|
+
var _id2 = parseInt(value.slice(2), 16); // TODO: Just encode this in the reference inline instead of as a model.
|
3725
3772
|
|
3726
3773
|
|
3727
|
-
var metaData = getOutlinedModel(response,
|
3728
|
-
return loadServerReference$1(response, metaData.id, metaData.bound, initializingChunk,
|
3774
|
+
var metaData = getOutlinedModel(response, _id2);
|
3775
|
+
return loadServerReference$1(response, metaData.id, metaData.bound, initializingChunk, obj, key);
|
3729
3776
|
}
|
3730
3777
|
|
3731
3778
|
case 'T':
|
@@ -3737,18 +3784,18 @@ function parseModelString(response, parentObject, key, value) {
|
|
3737
3784
|
case 'Q':
|
3738
3785
|
{
|
3739
3786
|
// Map
|
3740
|
-
var
|
3787
|
+
var _id3 = parseInt(value.slice(2), 16);
|
3741
3788
|
|
3742
|
-
var data = getOutlinedModel(response,
|
3789
|
+
var data = getOutlinedModel(response, _id3);
|
3743
3790
|
return new Map(data);
|
3744
3791
|
}
|
3745
3792
|
|
3746
3793
|
case 'W':
|
3747
3794
|
{
|
3748
3795
|
// Set
|
3749
|
-
var
|
3796
|
+
var _id4 = parseInt(value.slice(2), 16);
|
3750
3797
|
|
3751
|
-
var _data = getOutlinedModel(response,
|
3798
|
+
var _data = getOutlinedModel(response, _id4);
|
3752
3799
|
|
3753
3800
|
return new Set(_data);
|
3754
3801
|
}
|
@@ -3814,37 +3861,31 @@ function parseModelString(response, parentObject, key, value) {
|
|
3814
3861
|
// BigInt
|
3815
3862
|
return BigInt(value.slice(2));
|
3816
3863
|
}
|
3864
|
+
}
|
3817
3865
|
|
3818
|
-
default:
|
3819
|
-
{
|
3820
|
-
// We assume that anything else is a reference ID.
|
3821
|
-
var _id4 = parseInt(value.slice(1), 16);
|
3822
|
-
|
3823
|
-
var _chunk = getChunk(response, _id4);
|
3824
|
-
|
3825
|
-
switch (_chunk.status) {
|
3826
|
-
case RESOLVED_MODEL:
|
3827
|
-
initializeModelChunk(_chunk);
|
3828
|
-
break;
|
3829
|
-
} // The status might have changed after initialization.
|
3830
3866
|
|
3867
|
+
var id = parseInt(value.slice(1), 16);
|
3868
|
+
var chunk = getChunk(response, id);
|
3831
3869
|
|
3832
|
-
|
3833
|
-
|
3834
|
-
|
3870
|
+
switch (chunk.status) {
|
3871
|
+
case RESOLVED_MODEL:
|
3872
|
+
initializeModelChunk(chunk);
|
3873
|
+
break;
|
3874
|
+
} // The status might have changed after initialization.
|
3835
3875
|
|
3836
|
-
case PENDING:
|
3837
|
-
case BLOCKED:
|
3838
|
-
var parentChunk = initializingChunk;
|
3839
3876
|
|
3840
|
-
|
3877
|
+
switch (chunk.status) {
|
3878
|
+
case INITIALIZED:
|
3879
|
+
return chunk.value;
|
3841
3880
|
|
3842
|
-
|
3881
|
+
case PENDING:
|
3882
|
+
case BLOCKED:
|
3883
|
+
var parentChunk = initializingChunk;
|
3884
|
+
chunk.then(createModelResolver(parentChunk, obj, key), createModelReject(parentChunk));
|
3885
|
+
return null;
|
3843
3886
|
|
3844
|
-
|
3845
|
-
|
3846
|
-
}
|
3847
|
-
}
|
3887
|
+
default:
|
3888
|
+
throw chunk.reason;
|
3848
3889
|
}
|
3849
3890
|
}
|
3850
3891
|
|
@@ -920,7 +920,14 @@ function trackUsedThenable(thenableState, thenable, index) {
|
|
920
920
|
|
921
921
|
default:
|
922
922
|
{
|
923
|
-
if (typeof thenable.status === 'string')
|
923
|
+
if (typeof thenable.status === 'string') {
|
924
|
+
// Only instrument the thenable if the status if not defined. If
|
925
|
+
// it's defined, but an unknown value, assume it's been instrumented by
|
926
|
+
// some custom userspace implementation. We treat it as "pending".
|
927
|
+
// Attach a dummy listener, to ensure that any lazy initialization can
|
928
|
+
// happen. Flight lazily parses JSON when the value is actually awaited.
|
929
|
+
thenable.then(noop, noop);
|
930
|
+
} else {
|
924
931
|
const pendingThenable = thenable;
|
925
932
|
pendingThenable.status = 'pending';
|
926
933
|
pendingThenable.then(fulfilledValue => {
|
@@ -935,21 +942,22 @@ function trackUsedThenable(thenableState, thenable, index) {
|
|
935
942
|
rejectedThenable.status = 'rejected';
|
936
943
|
rejectedThenable.reason = error;
|
937
944
|
}
|
938
|
-
});
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
945
|
+
});
|
946
|
+
} // Check one more time in case the thenable resolved synchronously
|
947
|
+
|
948
|
+
|
949
|
+
switch (thenable.status) {
|
950
|
+
case 'fulfilled':
|
951
|
+
{
|
952
|
+
const fulfilledThenable = thenable;
|
953
|
+
return fulfilledThenable.value;
|
954
|
+
}
|
955
|
+
|
956
|
+
case 'rejected':
|
957
|
+
{
|
958
|
+
const rejectedThenable = thenable;
|
959
|
+
throw rejectedThenable.reason;
|
960
|
+
}
|
953
961
|
} // Suspend.
|
954
962
|
//
|
955
963
|
// Throwing here is an implementation detail that allows us to unwind the
|
@@ -1385,6 +1393,7 @@ function createRequest(model, bundlerConfig, onError, identifierPrefix, onPostpo
|
|
1385
1393
|
nextChunkId: 0,
|
1386
1394
|
pendingChunks: 0,
|
1387
1395
|
hints,
|
1396
|
+
abortListeners: new Set(),
|
1388
1397
|
abortableTasks: abortSet,
|
1389
1398
|
pingedTasks: pingedTasks,
|
1390
1399
|
completedImportChunks: [],
|
@@ -1482,10 +1491,7 @@ function serializeThenable(request, task, thenable) {
|
|
1482
1491
|
}
|
1483
1492
|
|
1484
1493
|
request.abortableTasks.delete(newTask);
|
1485
|
-
|
1486
|
-
if (request.destination !== null) {
|
1487
|
-
flushCompletedChunks(request, request.destination);
|
1488
|
-
}
|
1494
|
+
enqueueFlush(request);
|
1489
1495
|
});
|
1490
1496
|
return newTask.id;
|
1491
1497
|
}
|
@@ -1611,7 +1617,6 @@ function renderFunctionComponent(request, task, key, Component, props, owner) {
|
|
1611
1617
|
}
|
1612
1618
|
|
1613
1619
|
function renderFragment(request, task, children) {
|
1614
|
-
|
1615
1620
|
if (task.keyPath !== null) {
|
1616
1621
|
// We have a Server Component that specifies a key but we're now splitting
|
1617
1622
|
// the tree using a fragment.
|
@@ -1638,10 +1643,6 @@ function renderFragment(request, task, children) {
|
|
1638
1643
|
|
1639
1644
|
return [fragment];
|
1640
1645
|
} // Since we're yielding here, that implicitly resets the keyPath context on the
|
1641
|
-
// way up. Which is what we want since we've consumed it. If this changes to
|
1642
|
-
// be recursive serialization, we need to reset the keyPath and implicitSlot,
|
1643
|
-
// before recursing here.
|
1644
|
-
|
1645
1646
|
|
1646
1647
|
return children;
|
1647
1648
|
}
|
@@ -1932,13 +1933,9 @@ function serializeTemporaryReference(request, temporaryReference) {
|
|
1932
1933
|
}
|
1933
1934
|
|
1934
1935
|
function serializeLargeTextString(request, text) {
|
1935
|
-
request.pendingChunks
|
1936
|
+
request.pendingChunks++;
|
1936
1937
|
const textId = request.nextChunkId++;
|
1937
|
-
|
1938
|
-
const binaryLength = byteLengthOfChunk(textChunk);
|
1939
|
-
const row = textId.toString(16) + ':T' + binaryLength.toString(16) + ',';
|
1940
|
-
const headerChunk = stringToChunk(row);
|
1941
|
-
request.completedRegularChunks.push(headerChunk, textChunk);
|
1938
|
+
emitTextChunk(request, textId, text);
|
1942
1939
|
return serializeByValueID(textId);
|
1943
1940
|
}
|
1944
1941
|
|
@@ -2215,7 +2212,7 @@ function renderModelDestructive(request, task, parent, parentPropertyName, value
|
|
2215
2212
|
|
2216
2213
|
if (iteratorFn) {
|
2217
2214
|
return renderFragment(request, task, Array.from(value));
|
2218
|
-
}
|
2215
|
+
}
|
2219
2216
|
|
2220
2217
|
|
2221
2218
|
const proto = getPrototypeOf(value);
|
@@ -2420,6 +2417,32 @@ function emitModelChunk(request, id, json) {
|
|
2420
2417
|
request.completedRegularChunks.push(processedChunk);
|
2421
2418
|
}
|
2422
2419
|
|
2420
|
+
function emitTextChunk(request, id, text) {
|
2421
|
+
request.pendingChunks++; // Extra chunk for the header.
|
2422
|
+
|
2423
|
+
const textChunk = stringToChunk(text);
|
2424
|
+
const binaryLength = byteLengthOfChunk(textChunk);
|
2425
|
+
const row = id.toString(16) + ':T' + binaryLength.toString(16) + ',';
|
2426
|
+
const headerChunk = stringToChunk(row);
|
2427
|
+
request.completedRegularChunks.push(headerChunk, textChunk);
|
2428
|
+
}
|
2429
|
+
|
2430
|
+
function emitChunk(request, task, value) {
|
2431
|
+
const id = task.id; // For certain types we have special types, we typically outlined them but
|
2432
|
+
// we can emit them directly for this row instead of through an indirection.
|
2433
|
+
|
2434
|
+
if (typeof value === 'string') {
|
2435
|
+
|
2436
|
+
emitTextChunk(request, id, value);
|
2437
|
+
return;
|
2438
|
+
}
|
2439
|
+
// $FlowFixMe[incompatible-type] stringify can return null for undefined but we never do
|
2440
|
+
|
2441
|
+
|
2442
|
+
const json = stringify(value, task.toJSON);
|
2443
|
+
emitModelChunk(request, task.id, json);
|
2444
|
+
}
|
2445
|
+
|
2423
2446
|
const emptyRoot = {};
|
2424
2447
|
|
2425
2448
|
function retryTask(request, task) {
|
@@ -2447,21 +2470,19 @@ function retryTask(request, task) {
|
|
2447
2470
|
|
2448
2471
|
task.keyPath = null;
|
2449
2472
|
task.implicitSlot = false;
|
2450
|
-
let json;
|
2451
2473
|
|
2452
2474
|
if (typeof resolvedModel === 'object' && resolvedModel !== null) {
|
2453
2475
|
// Object might contain unresolved values like additional elements.
|
2454
2476
|
// This is simulating what the JSON loop would do if this was part of it.
|
2455
|
-
|
2456
|
-
json = stringify(resolvedModel, task.toJSON);
|
2477
|
+
emitChunk(request, task, resolvedModel);
|
2457
2478
|
} else {
|
2458
2479
|
// If the value is a string, it means it's a terminal value and we already escaped it
|
2459
2480
|
// We don't need to escape it again so it's not passed the toJSON replacer.
|
2460
2481
|
// $FlowFixMe[incompatible-type] stringify can return null for undefined but we never do
|
2461
|
-
json = stringify(resolvedModel);
|
2482
|
+
const json = stringify(resolvedModel);
|
2483
|
+
emitModelChunk(request, task.id, json);
|
2462
2484
|
}
|
2463
2485
|
|
2464
|
-
emitModelChunk(request, task.id, json);
|
2465
2486
|
request.abortableTasks.delete(task);
|
2466
2487
|
task.status = COMPLETED;
|
2467
2488
|
} catch (thrownValue) {
|
@@ -2613,6 +2634,7 @@ function flushCompletedChunks(request, destination) {
|
|
2613
2634
|
if (request.pendingChunks === 0) {
|
2614
2635
|
|
2615
2636
|
close$1(destination);
|
2637
|
+
request.destination = null;
|
2616
2638
|
}
|
2617
2639
|
}
|
2618
2640
|
|
@@ -2666,11 +2688,10 @@ function stopFlowing(request) {
|
|
2666
2688
|
|
2667
2689
|
function abort(request, reason) {
|
2668
2690
|
try {
|
2669
|
-
const abortableTasks = request.abortableTasks;
|
2691
|
+
const abortableTasks = request.abortableTasks; // We have tasks to abort. We'll emit one error row and then emit a reference
|
2692
|
+
// to that row from every row that's still remaining.
|
2670
2693
|
|
2671
2694
|
if (abortableTasks.size > 0) {
|
2672
|
-
// We have tasks to abort. We'll emit one error row and then emit a reference
|
2673
|
-
// to that row from every row that's still remaining.
|
2674
2695
|
request.pendingChunks++;
|
2675
2696
|
const errorId = request.nextChunkId++;
|
2676
2697
|
|
@@ -2684,6 +2705,19 @@ function abort(request, reason) {
|
|
2684
2705
|
abortableTasks.clear();
|
2685
2706
|
}
|
2686
2707
|
|
2708
|
+
const abortListeners = request.abortListeners;
|
2709
|
+
|
2710
|
+
if (abortListeners.size > 0) {
|
2711
|
+
let error;
|
2712
|
+
|
2713
|
+
if (enablePostpone && typeof reason === 'object' && reason !== null && reason.$$typeof === REACT_POSTPONE_TYPE) ; else {
|
2714
|
+
error = reason === undefined ? new Error('The render was aborted by the server without a reason.') : reason;
|
2715
|
+
}
|
2716
|
+
|
2717
|
+
abortListeners.forEach(callback => callback(error));
|
2718
|
+
abortListeners.clear();
|
2719
|
+
}
|
2720
|
+
|
2687
2721
|
if (request.destination !== null) {
|
2688
2722
|
flushCompletedChunks(request, request.destination);
|
2689
2723
|
}
|
@@ -3062,7 +3096,7 @@ function getOutlinedModel(response, id) {
|
|
3062
3096
|
return chunk.value;
|
3063
3097
|
}
|
3064
3098
|
|
3065
|
-
function parseModelString(response,
|
3099
|
+
function parseModelString(response, obj, key, value) {
|
3066
3100
|
if (value[0] === '$') {
|
3067
3101
|
switch (value[1]) {
|
3068
3102
|
case '$':
|
@@ -3085,7 +3119,7 @@ function parseModelString(response, parentObject, key, value) {
|
|
3085
3119
|
const id = parseInt(value.slice(2), 16); // TODO: Just encode this in the reference inline instead of as a model.
|
3086
3120
|
|
3087
3121
|
const metaData = getOutlinedModel(response, id);
|
3088
|
-
return loadServerReference$1(response, metaData.id, metaData.bound, initializingChunk,
|
3122
|
+
return loadServerReference$1(response, metaData.id, metaData.bound, initializingChunk, obj, key);
|
3089
3123
|
}
|
3090
3124
|
|
3091
3125
|
case 'T':
|
@@ -3169,34 +3203,31 @@ function parseModelString(response, parentObject, key, value) {
|
|
3169
3203
|
// BigInt
|
3170
3204
|
return BigInt(value.slice(2));
|
3171
3205
|
}
|
3206
|
+
}
|
3172
3207
|
|
3173
|
-
default:
|
3174
|
-
{
|
3175
|
-
// We assume that anything else is a reference ID.
|
3176
|
-
const id = parseInt(value.slice(1), 16);
|
3177
|
-
const chunk = getChunk(response, id);
|
3178
3208
|
|
3179
|
-
|
3180
|
-
|
3181
|
-
initializeModelChunk(chunk);
|
3182
|
-
break;
|
3183
|
-
} // The status might have changed after initialization.
|
3209
|
+
const id = parseInt(value.slice(1), 16);
|
3210
|
+
const chunk = getChunk(response, id);
|
3184
3211
|
|
3212
|
+
switch (chunk.status) {
|
3213
|
+
case RESOLVED_MODEL:
|
3214
|
+
initializeModelChunk(chunk);
|
3215
|
+
break;
|
3216
|
+
} // The status might have changed after initialization.
|
3185
3217
|
|
3186
|
-
switch (chunk.status) {
|
3187
|
-
case INITIALIZED:
|
3188
|
-
return chunk.value;
|
3189
3218
|
|
3190
|
-
|
3191
|
-
|
3192
|
-
|
3193
|
-
chunk.then(createModelResolver(parentChunk, parentObject, key), createModelReject(parentChunk));
|
3194
|
-
return null;
|
3219
|
+
switch (chunk.status) {
|
3220
|
+
case INITIALIZED:
|
3221
|
+
return chunk.value;
|
3195
3222
|
|
3196
|
-
|
3197
|
-
|
3198
|
-
|
3199
|
-
|
3223
|
+
case PENDING:
|
3224
|
+
case BLOCKED:
|
3225
|
+
const parentChunk = initializingChunk;
|
3226
|
+
chunk.then(createModelResolver(parentChunk, obj, key), createModelReject(parentChunk));
|
3227
|
+
return null;
|
3228
|
+
|
3229
|
+
default:
|
3230
|
+
throw chunk.reason;
|
3200
3231
|
}
|
3201
3232
|
}
|
3202
3233
|
|