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.
Files changed (37) hide show
  1. package/cjs/react-server-dom-webpack-client.browser.development.js +40 -7
  2. package/cjs/react-server-dom-webpack-client.browser.production.js +37 -6
  3. package/cjs/react-server-dom-webpack-client.browser.production.min.js +7 -7
  4. package/cjs/react-server-dom-webpack-client.browser.production.min.js.map +1 -1
  5. package/cjs/react-server-dom-webpack-client.edge.development.js +40 -7
  6. package/cjs/react-server-dom-webpack-client.edge.production.js +37 -6
  7. package/cjs/react-server-dom-webpack-client.edge.production.min.js +18 -18
  8. package/cjs/react-server-dom-webpack-client.edge.production.min.js.map +1 -1
  9. package/cjs/react-server-dom-webpack-client.node.development.js +40 -7
  10. package/cjs/react-server-dom-webpack-client.node.production.js +37 -6
  11. package/cjs/react-server-dom-webpack-client.node.production.min.js +4 -4
  12. package/cjs/react-server-dom-webpack-client.node.production.min.js.map +1 -1
  13. package/cjs/react-server-dom-webpack-client.node.unbundled.development.js +40 -7
  14. package/cjs/react-server-dom-webpack-client.node.unbundled.production.js +37 -6
  15. package/cjs/react-server-dom-webpack-client.node.unbundled.production.min.js +16 -16
  16. package/cjs/react-server-dom-webpack-client.node.unbundled.production.min.js.map +1 -1
  17. package/cjs/react-server-dom-webpack-server.browser.development.js +127 -86
  18. package/cjs/react-server-dom-webpack-server.browser.production.js +95 -64
  19. package/cjs/react-server-dom-webpack-server.browser.production.min.js +59 -58
  20. package/cjs/react-server-dom-webpack-server.browser.production.min.js.map +1 -1
  21. package/cjs/react-server-dom-webpack-server.edge.development.js +127 -86
  22. package/cjs/react-server-dom-webpack-server.edge.production.js +95 -64
  23. package/cjs/react-server-dom-webpack-server.edge.production.min.js +60 -60
  24. package/cjs/react-server-dom-webpack-server.edge.production.min.js.map +1 -1
  25. package/cjs/react-server-dom-webpack-server.node.development.js +127 -86
  26. package/cjs/react-server-dom-webpack-server.node.production.js +95 -64
  27. package/cjs/react-server-dom-webpack-server.node.production.min.js +60 -61
  28. package/cjs/react-server-dom-webpack-server.node.production.min.js.map +1 -1
  29. package/cjs/react-server-dom-webpack-server.node.unbundled.development.js +127 -86
  30. package/cjs/react-server-dom-webpack-server.node.unbundled.production.js +95 -64
  31. package/cjs/react-server-dom-webpack-server.node.unbundled.production.min.js +58 -58
  32. package/cjs/react-server-dom-webpack-server.node.unbundled.production.min.js.map +1 -1
  33. package/package.json +3 -3
  34. package/umd/react-server-dom-webpack-client.browser.development.js +40 -7
  35. package/umd/react-server-dom-webpack-client.browser.production.min.js +19 -19
  36. package/umd/react-server-dom-webpack-server.browser.development.js +127 -86
  37. package/umd/react-server-dom-webpack-server.browser.production.min.js +55 -54
@@ -902,7 +902,14 @@
902
902
 
903
903
  default:
904
904
  {
905
- if (typeof thenable.status === 'string') ; else {
905
+ if (typeof thenable.status === 'string') {
906
+ // Only instrument the thenable if the status if not defined. If
907
+ // it's defined, but an unknown value, assume it's been instrumented by
908
+ // some custom userspace implementation. We treat it as "pending".
909
+ // Attach a dummy listener, to ensure that any lazy initialization can
910
+ // happen. Flight lazily parses JSON when the value is actually awaited.
911
+ thenable.then(noop, noop);
912
+ } else {
906
913
  var pendingThenable = thenable;
907
914
  pendingThenable.status = 'pending';
908
915
  pendingThenable.then(function (fulfilledValue) {
@@ -917,21 +924,22 @@
917
924
  rejectedThenable.status = 'rejected';
918
925
  rejectedThenable.reason = error;
919
926
  }
920
- }); // Check one more time in case the thenable resolved synchronously
927
+ });
928
+ } // Check one more time in case the thenable resolved synchronously
921
929
 
922
- switch (thenable.status) {
923
- case 'fulfilled':
924
- {
925
- var fulfilledThenable = thenable;
926
- return fulfilledThenable.value;
927
- }
928
930
 
929
- case 'rejected':
930
- {
931
- var rejectedThenable = thenable;
932
- throw rejectedThenable.reason;
933
- }
934
- }
931
+ switch (thenable.status) {
932
+ case 'fulfilled':
933
+ {
934
+ var fulfilledThenable = thenable;
935
+ return fulfilledThenable.value;
936
+ }
937
+
938
+ case 'rejected':
939
+ {
940
+ var rejectedThenable = thenable;
941
+ throw rejectedThenable.reason;
942
+ }
935
943
  } // Suspend.
936
944
  //
937
945
  // Throwing here is an implementation detail that allows us to unwind the
@@ -1498,6 +1506,7 @@
1498
1506
  nextChunkId: 0,
1499
1507
  pendingChunks: 0,
1500
1508
  hints: hints,
1509
+ abortListeners: new Set(),
1501
1510
  abortableTasks: abortSet,
1502
1511
  pingedTasks: pingedTasks,
1503
1512
  completedImportChunks: [],
@@ -1605,10 +1614,7 @@
1605
1614
  }
1606
1615
 
1607
1616
  request.abortableTasks.delete(newTask);
1608
-
1609
- if (request.destination !== null) {
1610
- flushCompletedChunks(request, request.destination);
1611
- }
1617
+ enqueueFlush(request);
1612
1618
  });
1613
1619
  return newTask.id;
1614
1620
  }
@@ -1774,24 +1780,6 @@
1774
1780
  }
1775
1781
 
1776
1782
  function renderFragment(request, task, children) {
1777
- {
1778
- var debugInfo = children._debugInfo;
1779
-
1780
- if (debugInfo) {
1781
- // If this came from Flight, forward any debug info into this new row.
1782
- if (debugID === null) {
1783
- // We don't have a chunk to assign debug info. We need to outline this
1784
- // component to assign it an ID.
1785
- return outlineTask(request, task);
1786
- } else {
1787
- // Forward any debug info we have the first time we see it.
1788
- // We do this after init so that we have received all the debug info
1789
- // from the server by the time we emit it.
1790
- forwardDebugInfo(request, debugID, debugInfo);
1791
- }
1792
- }
1793
- }
1794
-
1795
1783
  if (task.keyPath !== null) {
1796
1784
  // We have a Server Component that specifies a key but we're now splitting
1797
1785
  // the tree using a fragment.
@@ -1823,6 +1811,28 @@
1823
1811
  // before recursing here.
1824
1812
 
1825
1813
 
1814
+ {
1815
+ var debugInfo = children._debugInfo;
1816
+
1817
+ if (debugInfo) {
1818
+ // If this came from Flight, forward any debug info into this new row.
1819
+ if (debugID === null) {
1820
+ // We don't have a chunk to assign debug info. We need to outline this
1821
+ // component to assign it an ID.
1822
+ return outlineTask(request, task);
1823
+ } else {
1824
+ // Forward any debug info we have the first time we see it.
1825
+ // We do this after init so that we have received all the debug info
1826
+ // from the server by the time we emit it.
1827
+ forwardDebugInfo(request, debugID, debugInfo);
1828
+ } // Since we're rendering this array again, create a copy that doesn't
1829
+ // have the debug info so we avoid outlining or emitting debug info again.
1830
+
1831
+
1832
+ children = Array.from(children);
1833
+ }
1834
+ }
1835
+
1826
1836
  return children;
1827
1837
  }
1828
1838
 
@@ -2164,13 +2174,9 @@
2164
2174
  }
2165
2175
 
2166
2176
  function serializeLargeTextString(request, text) {
2167
- request.pendingChunks += 2;
2177
+ request.pendingChunks++;
2168
2178
  var textId = request.nextChunkId++;
2169
- var textChunk = stringToChunk(text);
2170
- var binaryLength = byteLengthOfChunk(textChunk);
2171
- var row = textId.toString(16) + ':T' + binaryLength.toString(16) + ',';
2172
- var headerChunk = stringToChunk(row);
2173
- request.completedRegularChunks.push(headerChunk, textChunk);
2179
+ emitTextChunk(request, textId, text);
2174
2180
  return serializeByValueID(textId);
2175
2181
  }
2176
2182
 
@@ -2485,7 +2491,7 @@
2485
2491
 
2486
2492
  if (iteratorFn) {
2487
2493
  return renderFragment(request, task, Array.from(value));
2488
- } // Verify that this is a simple plain object.
2494
+ }
2489
2495
 
2490
2496
 
2491
2497
  var proto = getPrototypeOf(value);
@@ -2758,6 +2764,16 @@
2758
2764
  request.completedRegularChunks.push(processedChunk);
2759
2765
  }
2760
2766
 
2767
+ function emitTextChunk(request, id, text) {
2768
+ request.pendingChunks++; // Extra chunk for the header.
2769
+
2770
+ var textChunk = stringToChunk(text);
2771
+ var binaryLength = byteLengthOfChunk(textChunk);
2772
+ var row = id.toString(16) + ':T' + binaryLength.toString(16) + ',';
2773
+ var headerChunk = stringToChunk(row);
2774
+ request.completedRegularChunks.push(headerChunk, textChunk);
2775
+ }
2776
+
2761
2777
  function serializeEval(source) {
2762
2778
 
2763
2779
  return '$E' + source;
@@ -2957,6 +2973,22 @@
2957
2973
  }
2958
2974
  }
2959
2975
 
2976
+ function emitChunk(request, task, value) {
2977
+ var id = task.id; // For certain types we have special types, we typically outlined them but
2978
+ // we can emit them directly for this row instead of through an indirection.
2979
+
2980
+ if (typeof value === 'string') {
2981
+
2982
+ emitTextChunk(request, id, value);
2983
+ return;
2984
+ }
2985
+ // $FlowFixMe[incompatible-type] stringify can return null for undefined but we never do
2986
+
2987
+
2988
+ var json = stringify(value, task.toJSON);
2989
+ emitModelChunk(request, task.id, json);
2990
+ }
2991
+
2960
2992
  var emptyRoot = {};
2961
2993
 
2962
2994
  function retryTask(request, task) {
@@ -2993,21 +3025,19 @@
2993
3025
 
2994
3026
  task.keyPath = null;
2995
3027
  task.implicitSlot = false;
2996
- var json;
2997
3028
 
2998
3029
  if (typeof resolvedModel === 'object' && resolvedModel !== null) {
2999
3030
  // Object might contain unresolved values like additional elements.
3000
3031
  // This is simulating what the JSON loop would do if this was part of it.
3001
- // $FlowFixMe[incompatible-type] stringify can return null for undefined but we never do
3002
- json = stringify(resolvedModel, task.toJSON);
3032
+ emitChunk(request, task, resolvedModel);
3003
3033
  } else {
3004
3034
  // If the value is a string, it means it's a terminal value and we already escaped it
3005
3035
  // We don't need to escape it again so it's not passed the toJSON replacer.
3006
3036
  // $FlowFixMe[incompatible-type] stringify can return null for undefined but we never do
3007
- json = stringify(resolvedModel);
3037
+ var json = stringify(resolvedModel);
3038
+ emitModelChunk(request, task.id, json);
3008
3039
  }
3009
3040
 
3010
- emitModelChunk(request, task.id, json);
3011
3041
  request.abortableTasks.delete(task);
3012
3042
  task.status = COMPLETED;
3013
3043
  } catch (thrownValue) {
@@ -3163,6 +3193,7 @@
3163
3193
  if (request.pendingChunks === 0) {
3164
3194
 
3165
3195
  close$1(destination);
3196
+ request.destination = null;
3166
3197
  }
3167
3198
  }
3168
3199
 
@@ -3220,11 +3251,10 @@
3220
3251
 
3221
3252
  function abort(request, reason) {
3222
3253
  try {
3223
- var abortableTasks = request.abortableTasks;
3254
+ var abortableTasks = request.abortableTasks; // We have tasks to abort. We'll emit one error row and then emit a reference
3255
+ // to that row from every row that's still remaining.
3224
3256
 
3225
3257
  if (abortableTasks.size > 0) {
3226
- // We have tasks to abort. We'll emit one error row and then emit a reference
3227
- // to that row from every row that's still remaining.
3228
3258
  request.pendingChunks++;
3229
3259
  var errorId = request.nextChunkId++;
3230
3260
 
@@ -3240,6 +3270,21 @@
3240
3270
  abortableTasks.clear();
3241
3271
  }
3242
3272
 
3273
+ var abortListeners = request.abortListeners;
3274
+
3275
+ if (abortListeners.size > 0) {
3276
+ var _error;
3277
+
3278
+ if (enablePostpone && typeof reason === 'object' && reason !== null && reason.$$typeof === REACT_POSTPONE_TYPE) ; else {
3279
+ _error = reason === undefined ? new Error('The render was aborted by the server without a reason.') : reason;
3280
+ }
3281
+
3282
+ abortListeners.forEach(function (callback) {
3283
+ return callback(_error);
3284
+ });
3285
+ abortListeners.clear();
3286
+ }
3287
+
3243
3288
  if (request.destination !== null) {
3244
3289
  flushCompletedChunks(request, request.destination);
3245
3290
  }
@@ -3671,7 +3716,7 @@
3671
3716
  return chunk.value;
3672
3717
  }
3673
3718
 
3674
- function parseModelString(response, parentObject, key, value) {
3719
+ function parseModelString(response, obj, key, value) {
3675
3720
  if (value[0] === '$') {
3676
3721
  switch (value[1]) {
3677
3722
  case '$':
@@ -3683,19 +3728,21 @@
3683
3728
  case '@':
3684
3729
  {
3685
3730
  // Promise
3686
- var id = parseInt(value.slice(2), 16);
3687
- var chunk = getChunk(response, id);
3688
- return chunk;
3731
+ var _id = parseInt(value.slice(2), 16);
3732
+
3733
+ var _chunk = getChunk(response, _id);
3734
+
3735
+ return _chunk;
3689
3736
  }
3690
3737
 
3691
3738
  case 'F':
3692
3739
  {
3693
3740
  // Server Reference
3694
- var _id = parseInt(value.slice(2), 16); // TODO: Just encode this in the reference inline instead of as a model.
3741
+ var _id2 = parseInt(value.slice(2), 16); // TODO: Just encode this in the reference inline instead of as a model.
3695
3742
 
3696
3743
 
3697
- var metaData = getOutlinedModel(response, _id);
3698
- return loadServerReference$1(response, metaData.id, metaData.bound, initializingChunk, parentObject, key);
3744
+ var metaData = getOutlinedModel(response, _id2);
3745
+ return loadServerReference$1(response, metaData.id, metaData.bound, initializingChunk, obj, key);
3699
3746
  }
3700
3747
 
3701
3748
  case 'T':
@@ -3707,18 +3754,18 @@
3707
3754
  case 'Q':
3708
3755
  {
3709
3756
  // Map
3710
- var _id2 = parseInt(value.slice(2), 16);
3757
+ var _id3 = parseInt(value.slice(2), 16);
3711
3758
 
3712
- var data = getOutlinedModel(response, _id2);
3759
+ var data = getOutlinedModel(response, _id3);
3713
3760
  return new Map(data);
3714
3761
  }
3715
3762
 
3716
3763
  case 'W':
3717
3764
  {
3718
3765
  // Set
3719
- var _id3 = parseInt(value.slice(2), 16);
3766
+ var _id4 = parseInt(value.slice(2), 16);
3720
3767
 
3721
- var _data = getOutlinedModel(response, _id3);
3768
+ var _data = getOutlinedModel(response, _id4);
3722
3769
 
3723
3770
  return new Set(_data);
3724
3771
  }
@@ -3784,37 +3831,31 @@
3784
3831
  // BigInt
3785
3832
  return BigInt(value.slice(2));
3786
3833
  }
3834
+ }
3787
3835
 
3788
- default:
3789
- {
3790
- // We assume that anything else is a reference ID.
3791
- var _id4 = parseInt(value.slice(1), 16);
3792
-
3793
- var _chunk = getChunk(response, _id4);
3794
-
3795
- switch (_chunk.status) {
3796
- case RESOLVED_MODEL:
3797
- initializeModelChunk(_chunk);
3798
- break;
3799
- } // The status might have changed after initialization.
3800
3836
 
3837
+ var id = parseInt(value.slice(1), 16);
3838
+ var chunk = getChunk(response, id);
3801
3839
 
3802
- switch (_chunk.status) {
3803
- case INITIALIZED:
3804
- return _chunk.value;
3840
+ switch (chunk.status) {
3841
+ case RESOLVED_MODEL:
3842
+ initializeModelChunk(chunk);
3843
+ break;
3844
+ } // The status might have changed after initialization.
3805
3845
 
3806
- case PENDING:
3807
- case BLOCKED:
3808
- var parentChunk = initializingChunk;
3809
3846
 
3810
- _chunk.then(createModelResolver(parentChunk, parentObject, key), createModelReject(parentChunk));
3847
+ switch (chunk.status) {
3848
+ case INITIALIZED:
3849
+ return chunk.value;
3811
3850
 
3812
- return null;
3851
+ case PENDING:
3852
+ case BLOCKED:
3853
+ var parentChunk = initializingChunk;
3854
+ chunk.then(createModelResolver(parentChunk, obj, key), createModelReject(parentChunk));
3855
+ return null;
3813
3856
 
3814
- default:
3815
- throw _chunk.reason;
3816
- }
3817
- }
3857
+ default:
3858
+ throw chunk.reason;
3818
3859
  }
3819
3860
  }
3820
3861