react-server-dom-webpack 19.0.0-rc-a26e3f403e-20240611 → 19.0.0-rc-f3e09d6328-20240612

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.
@@ -488,7 +488,6 @@ Chunk.prototype.then = function (resolve, reject) {
488
488
  break;
489
489
  case "pending":
490
490
  case "blocked":
491
- case "cyclic":
492
491
  resolve &&
493
492
  (null === this.value && (this.value = []), this.value.push(resolve));
494
493
  reject &&
@@ -511,7 +510,6 @@ function readChunk(chunk) {
511
510
  return chunk.value;
512
511
  case "pending":
513
512
  case "blocked":
514
- case "cyclic":
515
513
  throw chunk;
516
514
  default:
517
515
  throw chunk.reason;
@@ -530,7 +528,6 @@ function wakeChunkIfInitialized(chunk, resolveListeners, rejectListeners) {
530
528
  break;
531
529
  case "pending":
532
530
  case "blocked":
533
- case "cyclic":
534
531
  if (chunk.value)
535
532
  for (var i = 0; i < resolveListeners.length; i++)
536
533
  chunk.value.push(resolveListeners[i]);
@@ -596,35 +593,35 @@ function resolveModuleChunk(chunk, value) {
596
593
  wakeChunkIfInitialized(chunk, resolveListeners, rejectListeners));
597
594
  }
598
595
  }
599
- var initializingChunk = null,
600
- initializingChunkBlockedModel = null;
596
+ var initializingHandler = null;
601
597
  function initializeModelChunk(chunk) {
602
- var prevChunk = initializingChunk,
603
- prevBlocked = initializingChunkBlockedModel;
604
- initializingChunk = chunk;
605
- initializingChunkBlockedModel = null;
598
+ var prevHandler = initializingHandler;
599
+ initializingHandler = null;
606
600
  var resolvedModel = chunk.value;
607
- chunk.status = "cyclic";
601
+ chunk.status = "blocked";
608
602
  chunk.value = null;
609
603
  chunk.reason = null;
610
604
  try {
611
- var value = JSON.parse(resolvedModel, chunk._response._fromJSON);
612
- if (
613
- null !== initializingChunkBlockedModel &&
614
- 0 < initializingChunkBlockedModel.deps
615
- )
616
- (initializingChunkBlockedModel.value = value), (chunk.status = "blocked");
617
- else {
618
- var resolveListeners = chunk.value;
619
- chunk.status = "fulfilled";
620
- chunk.value = value;
621
- null !== resolveListeners && wakeChunk(resolveListeners, value);
605
+ var value = JSON.parse(resolvedModel, chunk._response._fromJSON),
606
+ resolveListeners = chunk.value;
607
+ null !== resolveListeners &&
608
+ ((chunk.value = null),
609
+ (chunk.reason = null),
610
+ wakeChunk(resolveListeners, value));
611
+ if (null !== initializingHandler) {
612
+ if (initializingHandler.errored) throw initializingHandler.value;
613
+ if (0 < initializingHandler.deps) {
614
+ initializingHandler.value = value;
615
+ initializingHandler.chunk = chunk;
616
+ return;
617
+ }
622
618
  }
619
+ chunk.status = "fulfilled";
620
+ chunk.value = value;
623
621
  } catch (error) {
624
622
  (chunk.status = "rejected"), (chunk.reason = error);
625
623
  } finally {
626
- (initializingChunk = prevChunk),
627
- (initializingChunkBlockedModel = prevBlocked);
624
+ initializingHandler = prevHandler;
628
625
  }
629
626
  }
630
627
  function initializeModuleChunk(chunk) {
@@ -654,46 +651,71 @@ function reportGlobalError(response, error) {
654
651
  "pending" === chunk.status && triggerErrorOnChunk(chunk, error);
655
652
  });
656
653
  }
654
+ function createLazyChunkWrapper(chunk) {
655
+ return { $$typeof: REACT_LAZY_TYPE, _payload: chunk, _init: readChunk };
656
+ }
657
657
  function getChunk(response, id) {
658
658
  var chunks = response._chunks,
659
659
  chunk = chunks.get(id);
660
660
  chunk || ((chunk = createPendingChunk(response)), chunks.set(id, chunk));
661
661
  return chunk;
662
662
  }
663
- function createModelResolver(
664
- chunk,
663
+ function waitForReference(
664
+ referencedChunk,
665
665
  parentObject,
666
666
  key,
667
- cyclic,
668
667
  response,
669
668
  map,
670
669
  path
671
670
  ) {
672
- if (initializingChunkBlockedModel) {
673
- var blocked = initializingChunkBlockedModel;
674
- cyclic || blocked.deps++;
671
+ function fulfill(value) {
672
+ for (var i = 1; i < path.length; i++) {
673
+ for (; value.$$typeof === REACT_LAZY_TYPE; )
674
+ if (((value = value._payload), value === handler.chunk))
675
+ value = handler.value;
676
+ else if ("fulfilled" === value.status) value = value.value;
677
+ else {
678
+ path.splice(0, i - 1);
679
+ value.then(fulfill, reject);
680
+ return;
681
+ }
682
+ value = value[path[i]];
683
+ }
684
+ parentObject[key] = map(response, value);
685
+ "" === key && null === handler.value && (handler.value = parentObject[key]);
686
+ handler.deps--;
687
+ 0 === handler.deps &&
688
+ ((i = handler.chunk),
689
+ null !== i &&
690
+ "blocked" === i.status &&
691
+ ((value = i.value),
692
+ (i.status = "fulfilled"),
693
+ (i.value = handler.value),
694
+ null !== value && wakeChunk(value, handler.value)));
695
+ }
696
+ function reject(error) {
697
+ if (!handler.errored) {
698
+ handler.errored = !0;
699
+ handler.value = error;
700
+ var chunk = handler.chunk;
701
+ null !== chunk &&
702
+ "blocked" === chunk.status &&
703
+ triggerErrorOnChunk(chunk, error);
704
+ }
705
+ }
706
+ if (initializingHandler) {
707
+ var handler = initializingHandler;
708
+ handler.deps++;
675
709
  } else
676
- blocked = initializingChunkBlockedModel = {
677
- deps: cyclic ? 0 : 1,
678
- value: null
710
+ handler = initializingHandler = {
711
+ parent: null,
712
+ chunk: null,
713
+ value: null,
714
+ deps: 1,
715
+ errored: !1
679
716
  };
680
- return function (value) {
681
- for (var i = 1; i < path.length; i++) value = value[path[i]];
682
- parentObject[key] = map(response, value);
683
- "" === key && null === blocked.value && (blocked.value = parentObject[key]);
684
- blocked.deps--;
685
- 0 === blocked.deps &&
686
- "blocked" === chunk.status &&
687
- ((value = chunk.value),
688
- (chunk.status = "fulfilled"),
689
- (chunk.value = blocked.value),
690
- null !== value && wakeChunk(value, blocked.value));
691
- };
692
- }
693
- function createModelReject(chunk) {
694
- return function (error) {
695
- return triggerErrorOnChunk(chunk, error);
696
- };
717
+ referencedChunk.then(fulfill, reject);
718
+ return null;
697
719
  }
698
720
  function createServerReferenceProxy(response, metaData) {
699
721
  function proxy() {
@@ -730,23 +752,21 @@ function getOutlinedModel(response, reference, parentObject, key, map) {
730
752
  return map(response, parentObject);
731
753
  case "pending":
732
754
  case "blocked":
733
- case "cyclic":
734
- var parentChunk = initializingChunk;
735
- id.then(
736
- createModelResolver(
737
- parentChunk,
738
- parentObject,
739
- key,
740
- "cyclic" === id.status,
741
- response,
742
- map,
743
- reference
744
- ),
745
- createModelReject(parentChunk)
746
- );
747
- return null;
755
+ return waitForReference(id, parentObject, key, response, map, reference);
748
756
  default:
749
- throw id.reason;
757
+ return (
758
+ initializingHandler
759
+ ? ((initializingHandler.errored = !0),
760
+ (initializingHandler.value = id.reason))
761
+ : (initializingHandler = {
762
+ parent: null,
763
+ chunk: null,
764
+ value: id.reason,
765
+ deps: 0,
766
+ errored: !0
767
+ }),
768
+ null
769
+ );
750
770
  }
751
771
  }
752
772
  function createMap(response, model) {
@@ -772,7 +792,19 @@ function createModel(response, model) {
772
792
  }
773
793
  function parseModelString(response, parentObject, key, value) {
774
794
  if ("$" === value[0]) {
775
- if ("$" === value) return REACT_ELEMENT_TYPE;
795
+ if ("$" === value)
796
+ return (
797
+ null !== initializingHandler &&
798
+ "0" === key &&
799
+ (initializingHandler = {
800
+ parent: initializingHandler,
801
+ chunk: null,
802
+ value: null,
803
+ deps: 0,
804
+ errored: !1
805
+ }),
806
+ REACT_ELEMENT_TYPE
807
+ );
776
808
  switch (value[1]) {
777
809
  case "$":
778
810
  return value.slice(1);
@@ -780,7 +812,7 @@ function parseModelString(response, parentObject, key, value) {
780
812
  return (
781
813
  (parentObject = parseInt(value.slice(2), 16)),
782
814
  (response = getChunk(response, parentObject)),
783
- { $$typeof: REACT_LAZY_TYPE, _payload: response, _init: readChunk }
815
+ createLazyChunkWrapper(response)
784
816
  );
785
817
  case "@":
786
818
  if (2 === value.length) return new Promise(function () {});
@@ -961,8 +993,8 @@ function startReadableStream(response, id, type) {
961
993
  (previousBlockedChunk = chunk));
962
994
  } else {
963
995
  chunk = previousBlockedChunk;
964
- var chunk$51 = createPendingChunk(response);
965
- chunk$51.then(
996
+ var chunk$52 = createPendingChunk(response);
997
+ chunk$52.then(
966
998
  function (v) {
967
999
  return controller.enqueue(v);
968
1000
  },
@@ -970,10 +1002,10 @@ function startReadableStream(response, id, type) {
970
1002
  return controller.error(e);
971
1003
  }
972
1004
  );
973
- previousBlockedChunk = chunk$51;
1005
+ previousBlockedChunk = chunk$52;
974
1006
  chunk.then(function () {
975
- previousBlockedChunk === chunk$51 && (previousBlockedChunk = null);
976
- resolveModelChunk(chunk$51, json);
1007
+ previousBlockedChunk === chunk$52 && (previousBlockedChunk = null);
1008
+ resolveModelChunk(chunk$52, json);
977
1009
  });
978
1010
  }
979
1011
  },
@@ -1101,8 +1133,8 @@ function mergeBuffer(buffer, lastChunk) {
1101
1133
  for (var l = buffer.length, byteLength = lastChunk.length, i = 0; i < l; i++)
1102
1134
  byteLength += buffer[i].byteLength;
1103
1135
  byteLength = new Uint8Array(byteLength);
1104
- for (var i$52 = (i = 0); i$52 < l; i$52++) {
1105
- var chunk = buffer[i$52];
1136
+ for (var i$53 = (i = 0); i$53 < l; i$53++) {
1137
+ var chunk = buffer[i$53];
1106
1138
  byteLength.set(chunk, i);
1107
1139
  i += chunk.byteLength;
1108
1140
  }
@@ -1278,21 +1310,37 @@ function processFullRow(response, id, tag, buffer, chunk) {
1278
1310
  }
1279
1311
  function createFromJSONCallback(response) {
1280
1312
  return function (key, value) {
1281
- return "string" === typeof value
1282
- ? parseModelString(response, this, key, value)
1283
- : "object" === typeof value && null !== value
1284
- ? ((key =
1285
- value[0] === REACT_ELEMENT_TYPE
1286
- ? {
1287
- $$typeof: REACT_ELEMENT_TYPE,
1288
- type: value[1],
1289
- key: value[2],
1290
- ref: null,
1291
- props: value[3]
1292
- }
1293
- : value),
1294
- key)
1295
- : value;
1313
+ if ("string" === typeof value)
1314
+ return parseModelString(response, this, key, value);
1315
+ if ("object" === typeof value && null !== value) {
1316
+ if (value[0] === REACT_ELEMENT_TYPE) {
1317
+ if (
1318
+ ((key = {
1319
+ $$typeof: REACT_ELEMENT_TYPE,
1320
+ type: value[1],
1321
+ key: value[2],
1322
+ ref: null,
1323
+ props: value[3]
1324
+ }),
1325
+ null !== initializingHandler)
1326
+ )
1327
+ if (
1328
+ ((value = initializingHandler),
1329
+ (initializingHandler = value.parent),
1330
+ value.errored)
1331
+ )
1332
+ (key = new Chunk("rejected", null, value.value, response)),
1333
+ (key = createLazyChunkWrapper(key));
1334
+ else if (0 < value.deps) {
1335
+ var blockedChunk = new Chunk("blocked", null, null, response);
1336
+ value.value = key;
1337
+ value.chunk = blockedChunk;
1338
+ key = createLazyChunkWrapper(blockedChunk);
1339
+ }
1340
+ } else key = value;
1341
+ return key;
1342
+ }
1343
+ return value;
1296
1344
  };
1297
1345
  }
1298
1346
  function createResponseFromOptions(options) {