@vitejs/plugin-rsc 0.4.34 → 0.5.1

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 (100) hide show
  1. package/dist/{browser-D8OPzpF5.js → browser-B4C0Zb4m.js} +1 -1
  2. package/dist/{browser-CQv7Z3J4.d.ts → browser-C8KlM-b7.d.ts} +2 -2
  3. package/dist/{browser-DwWQeoll.d.ts → browser-CDBRiZjk.d.ts} +1 -1
  4. package/dist/{browser-7NhxQxuk.js → browser-U86erGOy.js} +3 -3
  5. package/dist/browser.d.ts +3 -3
  6. package/dist/browser.js +23 -5
  7. package/dist/chunk-Cdb3zUqJ.js +30 -0
  8. package/dist/{cjs-BamOAUgw.js → cjs-zUv66MZg.js} +3 -3
  9. package/dist/core/browser.d.ts +1 -1
  10. package/dist/core/browser.js +3 -3
  11. package/dist/core/plugin.js +1 -1
  12. package/dist/core/rsc.d.ts +2 -2
  13. package/dist/core/rsc.js +3 -3
  14. package/dist/core/ssr.d.ts +2 -2
  15. package/dist/core/ssr.js +3 -3
  16. package/dist/{dist-DiJnRA1C.js → dist-CNbFy2EZ.js} +1 -1
  17. package/dist/{encryption-runtime-B8xcnJoN.d.ts → encryption-runtime-BDgc4dBr.d.ts} +1 -1
  18. package/dist/{encryption-runtime-DT6dtlC5.js → encryption-runtime-D5_PLt4C.js} +4 -4
  19. package/dist/{encryption-utils-BDwwcMVT.js → encryption-utils-DdqSKS_O.js} +1 -1
  20. package/dist/{index-CPkExgij.d.ts → index-BY8KUQhI.d.ts} +1 -1
  21. package/dist/{index-B04iFwO5.d.ts → index-DJ0AhQ9B.d.ts} +1 -1
  22. package/dist/index.d.ts +2 -2
  23. package/dist/index.js +8 -8
  24. package/dist/picocolors-BRKobevN.js +74 -0
  25. package/dist/{plugin-CZbI4rhS.js → plugin-4UFT-s0w.js} +1 -1
  26. package/dist/{plugin-BLedJFh7.js → plugin-DNwmUjn4.js} +32 -22
  27. package/dist/{plugin-DCLI7Wh8.d.ts → plugin-fbbM1muv.d.ts} +2 -6
  28. package/dist/plugin.d.ts +2 -2
  29. package/dist/plugin.js +8 -8
  30. package/dist/plugins/cjs.js +3 -3
  31. package/dist/react/browser.d.ts +3 -3
  32. package/dist/react/browser.js +4 -4
  33. package/dist/react/rsc.d.ts +3 -3
  34. package/dist/react/rsc.js +4 -4
  35. package/dist/react/ssr.d.ts +3 -3
  36. package/dist/react/ssr.js +4 -4
  37. package/dist/{rpc-CUvSZurk.js → rpc-nwJuNojy.js} +1 -1
  38. package/dist/{rsc-JJjz3Z0i.d.ts → rsc-03j1e3xp.d.ts} +4 -4
  39. package/dist/{rsc-BdCB3621.js → rsc-B_DQ_Sju.js} +2 -2
  40. package/dist/{rsc-3bkzqdsJ.d.ts → rsc-OCbFObYE.d.ts} +2 -2
  41. package/dist/{rsc-GFzFWyhT.js → rsc-bL1QvQCm.js} +3 -3
  42. package/dist/rsc.d.ts +4 -4
  43. package/dist/rsc.js +24 -7
  44. package/dist/{shared-CXg_u-4h.js → shared-C8PSRwR2.js} +1 -1
  45. package/dist/{shared-n-ykEs15.js → shared-DlspEItJ.js} +1 -1
  46. package/dist/{ssr-BrSGyrxe.d.ts → ssr-Dgbl_mOS.d.ts} +1 -1
  47. package/dist/{ssr-Cd4SbAaO.js → ssr-DzY6rnEv.js} +2 -2
  48. package/dist/{ssr-Cm2FP2zD.js → ssr-EH7rBPkK.js} +3 -3
  49. package/dist/{ssr-CMjeQ9AS.d.ts → ssr-fBV4xXen.d.ts} +2 -2
  50. package/dist/ssr.d.ts +3 -3
  51. package/dist/ssr.js +54 -6
  52. package/dist/transforms/index.d.ts +1 -1
  53. package/dist/transforms/index.js +2 -2
  54. package/dist/{transforms-CpF3zNE0.js → transforms-CSPqW3RX.js} +3 -2
  55. package/dist/utils/encryption-runtime.d.ts +1 -1
  56. package/dist/utils/encryption-runtime.js +6 -6
  57. package/dist/utils/rpc.js +1 -1
  58. package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-client.browser.development.js +2964 -774
  59. package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-client.browser.production.js +554 -312
  60. package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-client.edge.development.js +2721 -724
  61. package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-client.edge.production.js +541 -300
  62. package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-client.node.development.js +2955 -858
  63. package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-client.node.production.js +652 -332
  64. package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-client.node.unbundled.development.js +2956 -861
  65. package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-client.node.unbundled.production.js +652 -332
  66. package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-plugin.js +6 -2
  67. package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-server.browser.development.js +1931 -713
  68. package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-server.browser.production.js +544 -295
  69. package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-server.edge.development.js +1926 -715
  70. package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-server.edge.production.js +542 -299
  71. package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-server.node.development.js +2719 -743
  72. package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-server.node.production.js +725 -338
  73. package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-server.node.unbundled.development.js +2703 -727
  74. package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-server.node.unbundled.production.js +725 -338
  75. package/dist/vendor/react-server-dom/package.json +3 -3
  76. package/dist/vendor/react-server-dom/server.node.js +3 -1
  77. package/dist/vendor/react-server-dom/server.node.unbundled.js +3 -1
  78. package/dist/vendor/react-server-dom/static.browser.js +1 -3
  79. package/dist/vendor/react-server-dom/static.edge.js +1 -3
  80. package/dist/vendor/react-server-dom/static.node.js +2 -3
  81. package/dist/vendor/react-server-dom/static.node.unbundled.js +1 -3
  82. package/package.json +11 -10
  83. package/types/index.d.ts +0 -4
  84. package/dist/browser--ZREVnM9.js +0 -22
  85. package/dist/client-C7Eok9hc.js +0 -23
  86. package/dist/extra/browser.d.ts +0 -14
  87. package/dist/extra/browser.js +0 -88
  88. package/dist/extra/rsc.d.ts +0 -2
  89. package/dist/extra/rsc.js +0 -56
  90. package/dist/extra/ssr.d.ts +0 -14
  91. package/dist/extra/ssr.js +0 -37
  92. package/dist/rsc-CiAoLCx8.js +0 -21
  93. package/dist/rsc-c22DF1A7.d.ts +0 -16
  94. package/dist/rsc-html-stream/browser.d.ts +0 -5
  95. package/dist/rsc-html-stream/browser.js +0 -8
  96. package/dist/rsc-html-stream/ssr.d.ts +0 -7
  97. package/dist/rsc-html-stream/ssr.js +0 -8
  98. package/dist/server-DMhFuTz_.js +0 -72
  99. package/dist/ssr-BQwZitKq.js +0 -53
  100. package/types/virtual.d.ts +0 -5
@@ -117,6 +117,8 @@ var PROMISE_PROTOTYPE = Promise.prototype,
117
117
  return;
118
118
  case "defaultProps":
119
119
  return;
120
+ case "_debugInfo":
121
+ return;
120
122
  case "toJSON":
121
123
  return;
122
124
  case Symbol.toPrimitive:
@@ -154,6 +156,8 @@ function getReference(target, name) {
154
156
  return target.name;
155
157
  case "defaultProps":
156
158
  return;
159
+ case "_debugInfo":
160
+ return;
157
161
  case "toJSON":
158
162
  return;
159
163
  case Symbol.toPrimitive:
@@ -375,6 +379,105 @@ function trimOptions(options) {
375
379
  ((hasProperties = !0), (trimmed[key] = options[key]));
376
380
  return hasProperties ? trimmed : null;
377
381
  }
382
+ function getChildFormatContext(parentContext, type, props) {
383
+ switch (type) {
384
+ case "img":
385
+ type = props.src;
386
+ var srcSet = props.srcSet;
387
+ if (
388
+ !(
389
+ "lazy" === props.loading ||
390
+ (!type && !srcSet) ||
391
+ ("string" !== typeof type && null != type) ||
392
+ ("string" !== typeof srcSet && null != srcSet) ||
393
+ "low" === props.fetchPriority ||
394
+ parentContext & 3
395
+ ) &&
396
+ ("string" !== typeof type ||
397
+ ":" !== type[4] ||
398
+ ("d" !== type[0] && "D" !== type[0]) ||
399
+ ("a" !== type[1] && "A" !== type[1]) ||
400
+ ("t" !== type[2] && "T" !== type[2]) ||
401
+ ("a" !== type[3] && "A" !== type[3])) &&
402
+ ("string" !== typeof srcSet ||
403
+ ":" !== srcSet[4] ||
404
+ ("d" !== srcSet[0] && "D" !== srcSet[0]) ||
405
+ ("a" !== srcSet[1] && "A" !== srcSet[1]) ||
406
+ ("t" !== srcSet[2] && "T" !== srcSet[2]) ||
407
+ ("a" !== srcSet[3] && "A" !== srcSet[3]))
408
+ ) {
409
+ var sizes = "string" === typeof props.sizes ? props.sizes : void 0;
410
+ var input = props.crossOrigin;
411
+ preload(type || "", "image", {
412
+ imageSrcSet: srcSet,
413
+ imageSizes: sizes,
414
+ crossOrigin:
415
+ "string" === typeof input
416
+ ? "use-credentials" === input
417
+ ? input
418
+ : ""
419
+ : void 0,
420
+ integrity: props.integrity,
421
+ type: props.type,
422
+ fetchPriority: props.fetchPriority,
423
+ referrerPolicy: props.referrerPolicy
424
+ });
425
+ }
426
+ return parentContext;
427
+ case "link":
428
+ type = props.rel;
429
+ srcSet = props.href;
430
+ if (
431
+ !(
432
+ parentContext & 1 ||
433
+ null != props.itemProp ||
434
+ "string" !== typeof type ||
435
+ "string" !== typeof srcSet ||
436
+ "" === srcSet
437
+ )
438
+ )
439
+ switch (type) {
440
+ case "preload":
441
+ preload(srcSet, props.as, {
442
+ crossOrigin: props.crossOrigin,
443
+ integrity: props.integrity,
444
+ nonce: props.nonce,
445
+ type: props.type,
446
+ fetchPriority: props.fetchPriority,
447
+ referrerPolicy: props.referrerPolicy,
448
+ imageSrcSet: props.imageSrcSet,
449
+ imageSizes: props.imageSizes,
450
+ media: props.media
451
+ });
452
+ break;
453
+ case "modulepreload":
454
+ preloadModule$1(srcSet, {
455
+ as: props.as,
456
+ crossOrigin: props.crossOrigin,
457
+ integrity: props.integrity,
458
+ nonce: props.nonce
459
+ });
460
+ break;
461
+ case "stylesheet":
462
+ preload(srcSet, "stylesheet", {
463
+ crossOrigin: props.crossOrigin,
464
+ integrity: props.integrity,
465
+ nonce: props.nonce,
466
+ type: props.type,
467
+ fetchPriority: props.fetchPriority,
468
+ referrerPolicy: props.referrerPolicy,
469
+ media: props.media
470
+ });
471
+ }
472
+ return parentContext;
473
+ case "picture":
474
+ return parentContext | 2;
475
+ case "noscript":
476
+ return parentContext | 1;
477
+ default:
478
+ return parentContext;
479
+ }
480
+ }
378
481
  var TEMPORARY_REFERENCE_TAG = Symbol.for("react.temporary.reference"),
379
482
  proxyHandlers = {
380
483
  get: function (target, name) {
@@ -387,6 +490,8 @@ var TEMPORARY_REFERENCE_TAG = Symbol.for("react.temporary.reference"),
387
490
  return;
388
491
  case "defaultProps":
389
492
  return;
493
+ case "_debugInfo":
494
+ return;
390
495
  case "toJSON":
391
496
  return;
392
497
  case Symbol.toPrimitive:
@@ -397,6 +502,8 @@ var TEMPORARY_REFERENCE_TAG = Symbol.for("react.temporary.reference"),
397
502
  throw Error(
398
503
  "Cannot render a Client Context Provider on the Server. Instead, you can export a Client Component wrapper that itself renders a Client Context Provider."
399
504
  );
505
+ case "then":
506
+ return;
400
507
  }
401
508
  throw Error(
402
509
  "Cannot access " +
@@ -442,16 +549,16 @@ function getIteratorFn(maybeIterable) {
442
549
  maybeIterable["@@iterator"];
443
550
  return "function" === typeof maybeIterable ? maybeIterable : null;
444
551
  }
445
- var ASYNC_ITERATOR = Symbol.asyncIterator,
446
- SuspenseException = Error(
447
- "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\nTo handle async errors, wrap your component in an error boundary, or call the promise's `.catch` method and pass the result to `use`."
448
- );
449
- function noop$1() {}
552
+ var ASYNC_ITERATOR = Symbol.asyncIterator;
553
+ function noop() {}
554
+ var SuspenseException = Error(
555
+ "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\nTo handle async errors, wrap your component in an error boundary, or call the promise's `.catch` method and pass the result to `use`."
556
+ );
450
557
  function trackUsedThenable(thenableState, thenable, index) {
451
558
  index = thenableState[index];
452
559
  void 0 === index
453
560
  ? thenableState.push(thenable)
454
- : index !== thenable && (thenable.then(noop$1, noop$1), (thenable = index));
561
+ : index !== thenable && (thenable.then(noop, noop), (thenable = index));
455
562
  switch (thenable.status) {
456
563
  case "fulfilled":
457
564
  return thenable.value;
@@ -459,7 +566,7 @@ function trackUsedThenable(thenableState, thenable, index) {
459
566
  throw thenable.reason;
460
567
  default:
461
568
  "string" === typeof thenable.status
462
- ? thenable.then(noop$1, noop$1)
569
+ ? thenable.then(noop, noop)
463
570
  : ((thenableState = thenable),
464
571
  (thenableState.status = "pending"),
465
572
  thenableState.then(
@@ -541,6 +648,7 @@ var HooksDispatcher = {
541
648
  return unsupportedRefresh;
542
649
  }
543
650
  };
651
+ HooksDispatcher.useEffectEvent = unsupportedHook;
544
652
  function unsupportedHook() {
545
653
  throw Error("This Hook is not supported in Server Components.");
546
654
  }
@@ -554,7 +662,7 @@ function useId() {
554
662
  if (null === currentRequest$1)
555
663
  throw Error("useId can only be used while React is rendering");
556
664
  var id = currentRequest$1.identifierCount++;
557
- return ":" + currentRequest$1.identifierPrefix + "S" + id.toString(32) + ":";
665
+ return "_" + currentRequest$1.identifierPrefix + "S_" + id.toString(32) + "_";
558
666
  }
559
667
  function use(usable) {
560
668
  if (
@@ -588,6 +696,10 @@ var DefaultAsyncDispatcher = {
588
696
  ((entry = resourceType()),
589
697
  JSCompiler_inline_result.set(resourceType, entry));
590
698
  return entry;
699
+ },
700
+ cacheSignal: function () {
701
+ var request = currentRequest ? currentRequest : null;
702
+ return request ? request.cacheController.signal : null;
591
703
  }
592
704
  },
593
705
  ReactSharedInternalsServer =
@@ -599,11 +711,8 @@ if (!ReactSharedInternalsServer)
599
711
  var isArrayImpl = Array.isArray,
600
712
  getPrototypeOf = Object.getPrototypeOf;
601
713
  function objectName(object) {
602
- return Object.prototype.toString
603
- .call(object)
604
- .replace(/^\[object (.*)\]$/, function (m, p0) {
605
- return p0;
606
- });
714
+ object = Object.prototype.toString.call(object);
715
+ return object.slice(8, object.length - 1);
607
716
  }
608
717
  function describeValueForErrorMessage(value) {
609
718
  switch (typeof value) {
@@ -707,24 +816,22 @@ function describeObjectForErrorMessage(objectOrArray, expandedName) {
707
816
  "\n " + str + "\n " + objectOrArray)
708
817
  : "\n " + str;
709
818
  }
710
- var ObjectPrototype = Object.prototype,
819
+ var hasOwnProperty = Object.prototype.hasOwnProperty,
820
+ ObjectPrototype = Object.prototype,
711
821
  stringify = JSON.stringify;
712
822
  function defaultErrorHandler(error) {
713
823
  console.error(error);
714
824
  }
715
- function defaultPostponeHandler() {}
716
825
  function RequestInstance(
717
826
  type,
718
827
  model,
719
828
  bundlerConfig,
720
829
  onError,
721
- identifierPrefix,
722
830
  onPostpone,
723
- temporaryReferences,
724
- environmentName,
725
- filterStackFrame,
726
831
  onAllReady,
727
- onFatalError
832
+ onFatalError,
833
+ identifierPrefix,
834
+ temporaryReferences
728
835
  ) {
729
836
  if (
730
837
  null !== ReactSharedInternalsServer.A &&
@@ -732,20 +839,20 @@ function RequestInstance(
732
839
  )
733
840
  throw Error("Currently React only supports one RSC renderer at a time.");
734
841
  ReactSharedInternalsServer.A = DefaultAsyncDispatcher;
735
- filterStackFrame = new Set();
736
- environmentName = [];
737
- var hints = new Set();
842
+ var abortSet = new Set(),
843
+ pingedTasks = [],
844
+ hints = new Set();
738
845
  this.type = type;
739
846
  this.status = 10;
740
847
  this.flushScheduled = !1;
741
848
  this.destination = this.fatalError = null;
742
849
  this.bundlerConfig = bundlerConfig;
743
850
  this.cache = new Map();
851
+ this.cacheController = new AbortController();
744
852
  this.pendingChunks = this.nextChunkId = 0;
745
853
  this.hints = hints;
746
- this.abortListeners = new Set();
747
- this.abortableTasks = filterStackFrame;
748
- this.pingedTasks = environmentName;
854
+ this.abortableTasks = abortSet;
855
+ this.pingedTasks = pingedTasks;
749
856
  this.completedImportChunks = [];
750
857
  this.completedHintChunks = [];
751
858
  this.completedRegularChunks = [];
@@ -759,20 +866,20 @@ function RequestInstance(
759
866
  this.identifierCount = 1;
760
867
  this.taintCleanupQueue = [];
761
868
  this.onError = void 0 === onError ? defaultErrorHandler : onError;
762
- this.onPostpone = void 0 === onPostpone ? defaultPostponeHandler : onPostpone;
869
+ this.onPostpone = void 0 === onPostpone ? noop : onPostpone;
763
870
  this.onAllReady = onAllReady;
764
871
  this.onFatalError = onFatalError;
765
- type = createTask(this, model, null, !1, filterStackFrame);
766
- environmentName.push(type);
872
+ type = createTask(this, model, null, !1, 0, abortSet);
873
+ pingedTasks.push(type);
767
874
  }
768
- function noop() {}
769
875
  var currentRequest = null;
770
876
  function serializeThenable(request, task, thenable) {
771
877
  var newTask = createTask(
772
878
  request,
773
- null,
879
+ thenable,
774
880
  task.keyPath,
775
881
  task.implicitSlot,
882
+ task.formatContext,
776
883
  request.abortableTasks
777
884
  );
778
885
  switch (thenable.status) {
@@ -786,9 +893,11 @@ function serializeThenable(request, task, thenable) {
786
893
  if (12 === request.status)
787
894
  return (
788
895
  request.abortableTasks.delete(newTask),
789
- (newTask.status = 3),
790
- (task = stringify(serializeByValueID(request.fatalError))),
791
- emitModelChunk(request, newTask.id, task),
896
+ 21 === request.type
897
+ ? (haltTask(newTask), finishHaltedTask(newTask, request))
898
+ : ((task = request.fatalError),
899
+ abortTask(newTask),
900
+ finishAbortedTask(newTask, request, task)),
792
901
  newTask.id
793
902
  );
794
903
  "string" !== typeof thenable.status &&
@@ -819,39 +928,48 @@ function serializeThenable(request, task, thenable) {
819
928
  }
820
929
  function serializeReadableStream(request, task, stream) {
821
930
  function progress(entry) {
822
- if (!aborted)
931
+ if (0 === streamTask.status)
823
932
  if (entry.done)
824
- request.abortListeners.delete(abortStream),
933
+ (streamTask.status = 1),
825
934
  (entry = streamTask.id.toString(16) + ":C\n"),
826
935
  request.completedRegularChunks.push(stringToChunk(entry)),
936
+ request.abortableTasks.delete(streamTask),
937
+ request.cacheController.signal.removeEventListener(
938
+ "abort",
939
+ abortStream
940
+ ),
827
941
  enqueueFlush(request),
828
- (aborted = !0);
942
+ callOnAllReadyIfReady(request);
829
943
  else
830
944
  try {
831
945
  (streamTask.model = entry.value),
832
946
  request.pendingChunks++,
833
- emitChunk(request, streamTask, streamTask.model),
947
+ tryStreamTask(request, streamTask),
834
948
  enqueueFlush(request),
835
949
  reader.read().then(progress, error);
836
- } catch (x$7) {
837
- error(x$7);
950
+ } catch (x$8) {
951
+ error(x$8);
838
952
  }
839
953
  }
840
954
  function error(reason) {
841
- aborted ||
842
- ((aborted = !0),
843
- request.abortListeners.delete(abortStream),
955
+ 0 === streamTask.status &&
956
+ (request.cacheController.signal.removeEventListener("abort", abortStream),
844
957
  erroredTask(request, streamTask, reason),
845
958
  enqueueFlush(request),
846
959
  reader.cancel(reason).then(error, error));
847
960
  }
848
- function abortStream(reason) {
849
- aborted ||
850
- ((aborted = !0),
851
- request.abortListeners.delete(abortStream),
852
- erroredTask(request, streamTask, reason),
853
- enqueueFlush(request),
854
- reader.cancel(reason).then(error, error));
961
+ function abortStream() {
962
+ if (0 === streamTask.status) {
963
+ var signal = request.cacheController.signal;
964
+ signal.removeEventListener("abort", abortStream);
965
+ signal = signal.reason;
966
+ 21 === request.type
967
+ ? (request.abortableTasks.delete(streamTask),
968
+ haltTask(streamTask),
969
+ finishHaltedTask(streamTask, request))
970
+ : (erroredTask(request, streamTask, signal), enqueueFlush(request));
971
+ reader.cancel(signal).then(error, error);
972
+ }
855
973
  }
856
974
  var supportsBYOB = stream.supportsBYOB;
857
975
  if (void 0 === supportsBYOB)
@@ -866,27 +984,30 @@ function serializeReadableStream(request, task, stream) {
866
984
  task.model,
867
985
  task.keyPath,
868
986
  task.implicitSlot,
987
+ task.formatContext,
869
988
  request.abortableTasks
870
989
  );
871
- request.abortableTasks.delete(streamTask);
872
990
  request.pendingChunks++;
873
991
  task = streamTask.id.toString(16) + ":" + (supportsBYOB ? "r" : "R") + "\n";
874
992
  request.completedRegularChunks.push(stringToChunk(task));
875
- var aborted = !1;
876
- request.abortListeners.add(abortStream);
993
+ request.cacheController.signal.addEventListener("abort", abortStream);
877
994
  reader.read().then(progress, error);
878
995
  return serializeByValueID(streamTask.id);
879
996
  }
880
997
  function serializeAsyncIterable(request, task, iterable, iterator) {
881
998
  function progress(entry) {
882
- if (!aborted)
999
+ if (0 === streamTask.status)
883
1000
  if (entry.done) {
884
- request.abortListeners.delete(abortIterable);
1001
+ streamTask.status = 1;
885
1002
  if (void 0 === entry.value)
886
1003
  var endStreamRow = streamTask.id.toString(16) + ":C\n";
887
1004
  else
888
1005
  try {
889
- var chunkId = outlineModel(request, entry.value);
1006
+ var chunkId = outlineModelWithFormatContext(
1007
+ request,
1008
+ entry.value,
1009
+ 0
1010
+ );
890
1011
  endStreamRow =
891
1012
  streamTask.id.toString(16) +
892
1013
  ":C" +
@@ -897,36 +1018,49 @@ function serializeAsyncIterable(request, task, iterable, iterator) {
897
1018
  return;
898
1019
  }
899
1020
  request.completedRegularChunks.push(stringToChunk(endStreamRow));
1021
+ request.abortableTasks.delete(streamTask);
1022
+ request.cacheController.signal.removeEventListener(
1023
+ "abort",
1024
+ abortIterable
1025
+ );
900
1026
  enqueueFlush(request);
901
- aborted = !0;
1027
+ callOnAllReadyIfReady(request);
902
1028
  } else
903
1029
  try {
904
1030
  (streamTask.model = entry.value),
905
1031
  request.pendingChunks++,
906
- emitChunk(request, streamTask, streamTask.model),
1032
+ tryStreamTask(request, streamTask),
907
1033
  enqueueFlush(request),
908
1034
  iterator.next().then(progress, error);
909
- } catch (x$8) {
910
- error(x$8);
1035
+ } catch (x$9) {
1036
+ error(x$9);
911
1037
  }
912
1038
  }
913
1039
  function error(reason) {
914
- aborted ||
915
- ((aborted = !0),
916
- request.abortListeners.delete(abortIterable),
1040
+ 0 === streamTask.status &&
1041
+ (request.cacheController.signal.removeEventListener(
1042
+ "abort",
1043
+ abortIterable
1044
+ ),
917
1045
  erroredTask(request, streamTask, reason),
918
1046
  enqueueFlush(request),
919
1047
  "function" === typeof iterator.throw &&
920
1048
  iterator.throw(reason).then(error, error));
921
1049
  }
922
- function abortIterable(reason) {
923
- aborted ||
924
- ((aborted = !0),
925
- request.abortListeners.delete(abortIterable),
926
- erroredTask(request, streamTask, reason),
927
- enqueueFlush(request),
1050
+ function abortIterable() {
1051
+ if (0 === streamTask.status) {
1052
+ var signal = request.cacheController.signal;
1053
+ signal.removeEventListener("abort", abortIterable);
1054
+ var reason = signal.reason;
1055
+ 21 === request.type
1056
+ ? (request.abortableTasks.delete(streamTask),
1057
+ haltTask(streamTask),
1058
+ finishHaltedTask(streamTask, request))
1059
+ : (erroredTask(request, streamTask, signal.reason),
1060
+ enqueueFlush(request));
928
1061
  "function" === typeof iterator.throw &&
929
- iterator.throw(reason).then(error, error));
1062
+ iterator.throw(reason).then(error, error);
1063
+ }
930
1064
  }
931
1065
  iterable = iterable === iterator;
932
1066
  var streamTask = createTask(
@@ -934,14 +1068,13 @@ function serializeAsyncIterable(request, task, iterable, iterator) {
934
1068
  task.model,
935
1069
  task.keyPath,
936
1070
  task.implicitSlot,
1071
+ task.formatContext,
937
1072
  request.abortableTasks
938
1073
  );
939
- request.abortableTasks.delete(streamTask);
940
1074
  request.pendingChunks++;
941
1075
  task = streamTask.id.toString(16) + ":" + (iterable ? "x" : "X") + "\n";
942
1076
  request.completedRegularChunks.push(stringToChunk(task));
943
- var aborted = !1;
944
- request.abortListeners.add(abortIterable);
1077
+ request.cacheController.signal.addEventListener("abort", abortIterable);
945
1078
  iterator.next().then(progress, error);
946
1079
  return serializeByValueID(streamTask.id);
947
1080
  }
@@ -956,9 +1089,10 @@ function readThenable(thenable) {
956
1089
  if ("rejected" === thenable.status) throw thenable.reason;
957
1090
  throw thenable;
958
1091
  }
959
- function createLazyWrapperAroundWakeable(wakeable) {
1092
+ function createLazyWrapperAroundWakeable(request, task, wakeable) {
960
1093
  switch (wakeable.status) {
961
1094
  case "fulfilled":
1095
+ return wakeable.value;
962
1096
  case "rejected":
963
1097
  break;
964
1098
  default:
@@ -987,9 +1121,7 @@ function processServerComponentReturnValue(request, task, Component, result) {
987
1121
  )
988
1122
  return result;
989
1123
  if ("function" === typeof result.then)
990
- return "fulfilled" === result.status
991
- ? result.value
992
- : createLazyWrapperAroundWakeable(result);
1124
+ return createLazyWrapperAroundWakeable(request, task, result);
993
1125
  var iteratorFn = getIteratorFn(result);
994
1126
  return iteratorFn
995
1127
  ? ((request = {}),
@@ -1044,6 +1176,19 @@ function renderFragment(request, task, children) {
1044
1176
  task.implicitSlot ? [request] : request)
1045
1177
  : children;
1046
1178
  }
1179
+ var serializedSize = 0;
1180
+ function deferTask(request, task) {
1181
+ task = createTask(
1182
+ request,
1183
+ task.model,
1184
+ task.keyPath,
1185
+ task.implicitSlot,
1186
+ task.formatContext,
1187
+ request.abortableTasks
1188
+ );
1189
+ pingTask(request, task);
1190
+ return serializeLazyID(task.id);
1191
+ }
1047
1192
  function renderElement(request, task, type, key, ref, props) {
1048
1193
  if (null !== ref && void 0 !== ref)
1049
1194
  throw Error(
@@ -1085,6 +1230,13 @@ function renderElement(request, task, type, key, ref, props) {
1085
1230
  case REACT_MEMO_TYPE:
1086
1231
  return renderElement(request, task, type.type, key, ref, props);
1087
1232
  }
1233
+ else
1234
+ "string" === typeof type &&
1235
+ ((ref = task.formatContext),
1236
+ (init = getChildFormatContext(ref, type, props)),
1237
+ ref !== init &&
1238
+ null != props.children &&
1239
+ outlineModelWithFormatContext(request, props.children, init));
1088
1240
  request = key;
1089
1241
  key = task.keyPath;
1090
1242
  null === request
@@ -1107,7 +1259,14 @@ function pingTask(request, task) {
1107
1259
  return performWork(request);
1108
1260
  }));
1109
1261
  }
1110
- function createTask(request, model, keyPath, implicitSlot, abortSet) {
1262
+ function createTask(
1263
+ request,
1264
+ model,
1265
+ keyPath,
1266
+ implicitSlot,
1267
+ formatContext,
1268
+ abortSet
1269
+ ) {
1111
1270
  request.pendingChunks++;
1112
1271
  var id = request.nextChunkId++;
1113
1272
  "object" !== typeof model ||
@@ -1121,10 +1280,12 @@ function createTask(request, model, keyPath, implicitSlot, abortSet) {
1121
1280
  model: model,
1122
1281
  keyPath: keyPath,
1123
1282
  implicitSlot: implicitSlot,
1283
+ formatContext: formatContext,
1124
1284
  ping: function () {
1125
1285
  return pingTask(request, task);
1126
1286
  },
1127
1287
  toJSON: function (parentPropertyName, value) {
1288
+ serializedSize += parentPropertyName.length;
1128
1289
  var prevKeyPath = task.keyPath,
1129
1290
  prevImplicitSlot = task.implicitSlot;
1130
1291
  try {
@@ -1146,10 +1307,16 @@ function createTask(request, model, keyPath, implicitSlot, abortSet) {
1146
1307
  12 === request.status)
1147
1308
  )
1148
1309
  (task.status = 3),
1149
- (prevKeyPath = request.fatalError),
1150
- (JSCompiler_inline_result = parentPropertyName
1151
- ? "$L" + prevKeyPath.toString(16)
1152
- : serializeByValueID(prevKeyPath));
1310
+ 21 === request.type
1311
+ ? ((prevKeyPath = request.nextChunkId++),
1312
+ (prevKeyPath = parentPropertyName
1313
+ ? serializeLazyID(prevKeyPath)
1314
+ : serializeByValueID(prevKeyPath)),
1315
+ (JSCompiler_inline_result = prevKeyPath))
1316
+ : ((prevKeyPath = request.fatalError),
1317
+ (JSCompiler_inline_result = parentPropertyName
1318
+ ? serializeLazyID(prevKeyPath)
1319
+ : serializeByValueID(prevKeyPath)));
1153
1320
  else if (
1154
1321
  ((value =
1155
1322
  thrownValue === SuspenseException
@@ -1164,6 +1331,7 @@ function createTask(request, model, keyPath, implicitSlot, abortSet) {
1164
1331
  task.model,
1165
1332
  task.keyPath,
1166
1333
  task.implicitSlot,
1334
+ task.formatContext,
1167
1335
  request.abortableTasks
1168
1336
  );
1169
1337
  var ping = JSCompiler_inline_result.ping;
@@ -1173,7 +1341,7 @@ function createTask(request, model, keyPath, implicitSlot, abortSet) {
1173
1341
  task.keyPath = prevKeyPath;
1174
1342
  task.implicitSlot = prevImplicitSlot;
1175
1343
  JSCompiler_inline_result = parentPropertyName
1176
- ? "$L" + JSCompiler_inline_result.id.toString(16)
1344
+ ? serializeLazyID(JSCompiler_inline_result.id)
1177
1345
  : serializeByValueID(JSCompiler_inline_result.id);
1178
1346
  } else
1179
1347
  (task.keyPath = prevKeyPath),
@@ -1183,7 +1351,7 @@ function createTask(request, model, keyPath, implicitSlot, abortSet) {
1183
1351
  (prevImplicitSlot = logRecoverableError(request, value, task)),
1184
1352
  emitErrorChunk(request, prevKeyPath, prevImplicitSlot),
1185
1353
  (JSCompiler_inline_result = parentPropertyName
1186
- ? "$L" + prevKeyPath.toString(16)
1354
+ ? serializeLazyID(prevKeyPath)
1187
1355
  : serializeByValueID(prevKeyPath));
1188
1356
  }
1189
1357
  return JSCompiler_inline_result;
@@ -1196,6 +1364,9 @@ function createTask(request, model, keyPath, implicitSlot, abortSet) {
1196
1364
  function serializeByValueID(id) {
1197
1365
  return "$" + id.toString(16);
1198
1366
  }
1367
+ function serializeLazyID(id) {
1368
+ return "$L" + id.toString(16);
1369
+ }
1199
1370
  function encodeReferenceChunk(request, id, reference) {
1200
1371
  request = stringify(reference);
1201
1372
  id = id.toString(16) + ":" + request + "\n";
@@ -1214,7 +1385,7 @@ function serializeClientReference(
1214
1385
  existingId = writtenClientReferences.get(clientReferenceKey);
1215
1386
  if (void 0 !== existingId)
1216
1387
  return parent[0] === REACT_ELEMENT_TYPE && "1" === parentPropertyName
1217
- ? "$L" + existingId.toString(16)
1388
+ ? serializeLazyID(existingId)
1218
1389
  : serializeByValueID(existingId);
1219
1390
  try {
1220
1391
  var config = request.bundlerConfig,
@@ -1252,7 +1423,7 @@ function serializeClientReference(
1252
1423
  request.completedImportChunks.push(processedChunk);
1253
1424
  writtenClientReferences.set(clientReferenceKey, importId);
1254
1425
  return parent[0] === REACT_ELEMENT_TYPE && "1" === parentPropertyName
1255
- ? "$L" + importId.toString(16)
1426
+ ? serializeLazyID(importId)
1256
1427
  : serializeByValueID(importId);
1257
1428
  } catch (x) {
1258
1429
  return (
@@ -1264,23 +1435,29 @@ function serializeClientReference(
1264
1435
  );
1265
1436
  }
1266
1437
  }
1267
- function outlineModel(request, value) {
1268
- value = createTask(request, value, null, !1, request.abortableTasks);
1438
+ function outlineModelWithFormatContext(request, value, formatContext) {
1439
+ value = createTask(
1440
+ request,
1441
+ value,
1442
+ null,
1443
+ !1,
1444
+ formatContext,
1445
+ request.abortableTasks
1446
+ );
1269
1447
  retryTask(request, value);
1270
1448
  return value.id;
1271
1449
  }
1272
1450
  function serializeTypedArray(request, tag, typedArray) {
1273
1451
  request.pendingChunks++;
1274
1452
  var bufferId = request.nextChunkId++;
1275
- emitTypedArrayChunk(request, bufferId, tag, typedArray);
1453
+ emitTypedArrayChunk(request, bufferId, tag, typedArray, !1);
1276
1454
  return serializeByValueID(bufferId);
1277
1455
  }
1278
1456
  function serializeBlob(request, blob) {
1279
1457
  function progress(entry) {
1280
- if (!aborted)
1458
+ if (0 === newTask.status)
1281
1459
  if (entry.done)
1282
- request.abortListeners.delete(abortBlob),
1283
- (aborted = !0),
1460
+ request.cacheController.signal.removeEventListener("abort", abortBlob),
1284
1461
  pingTask(request, newTask);
1285
1462
  else
1286
1463
  return (
@@ -1288,26 +1465,29 @@ function serializeBlob(request, blob) {
1288
1465
  );
1289
1466
  }
1290
1467
  function error(reason) {
1291
- aborted ||
1292
- ((aborted = !0),
1293
- request.abortListeners.delete(abortBlob),
1468
+ 0 === newTask.status &&
1469
+ (request.cacheController.signal.removeEventListener("abort", abortBlob),
1294
1470
  erroredTask(request, newTask, reason),
1295
1471
  enqueueFlush(request),
1296
1472
  reader.cancel(reason).then(error, error));
1297
1473
  }
1298
- function abortBlob(reason) {
1299
- aborted ||
1300
- ((aborted = !0),
1301
- request.abortListeners.delete(abortBlob),
1302
- erroredTask(request, newTask, reason),
1303
- enqueueFlush(request),
1304
- reader.cancel(reason).then(error, error));
1474
+ function abortBlob() {
1475
+ if (0 === newTask.status) {
1476
+ var signal = request.cacheController.signal;
1477
+ signal.removeEventListener("abort", abortBlob);
1478
+ signal = signal.reason;
1479
+ 21 === request.type
1480
+ ? (request.abortableTasks.delete(newTask),
1481
+ haltTask(newTask),
1482
+ finishHaltedTask(newTask, request))
1483
+ : (erroredTask(request, newTask, signal), enqueueFlush(request));
1484
+ reader.cancel(signal).then(error, error);
1485
+ }
1305
1486
  }
1306
1487
  var model = [blob.type],
1307
- newTask = createTask(request, model, null, !1, request.abortableTasks),
1308
- reader = blob.stream().getReader(),
1309
- aborted = !1;
1310
- request.abortListeners.add(abortBlob);
1488
+ newTask = createTask(request, model, null, !1, 0, request.abortableTasks),
1489
+ reader = blob.stream().getReader();
1490
+ request.cacheController.signal.addEventListener("abort", abortBlob);
1311
1491
  reader.read().then(progress).catch(error);
1312
1492
  return "$B" + newTask.id.toString(16);
1313
1493
  }
@@ -1339,6 +1519,7 @@ function renderModelDestructive(
1339
1519
  ((elementReference = parent + ":" + parentPropertyName),
1340
1520
  writtenObjects.set(value, elementReference)));
1341
1521
  }
1522
+ if (3200 < serializedSize) return deferTask(request, task);
1342
1523
  parentPropertyName = value.props;
1343
1524
  parent = parentPropertyName.ref;
1344
1525
  request = renderElement(
@@ -1356,6 +1537,7 @@ function renderModelDestructive(
1356
1537
  writtenObjects.set(request, elementReference));
1357
1538
  return request;
1358
1539
  case REACT_LAZY_TYPE:
1540
+ if (3200 < serializedSize) return deferTask(request, task);
1359
1541
  task.thenableState = null;
1360
1542
  parentPropertyName = value._init;
1361
1543
  value = parentPropertyName(value._payload);
@@ -1393,8 +1575,11 @@ function renderModelDestructive(
1393
1575
  return request;
1394
1576
  }
1395
1577
  if (void 0 !== writtenObjects)
1396
- if (modelRoot === value) modelRoot = null;
1397
- else return writtenObjects;
1578
+ if (modelRoot === value) {
1579
+ if (writtenObjects !== serializeByValueID(task.id))
1580
+ return writtenObjects;
1581
+ modelRoot = null;
1582
+ } else return writtenObjects;
1398
1583
  else if (
1399
1584
  -1 === parentPropertyName.indexOf(":") &&
1400
1585
  ((writtenObjects = elementReference.get(parent)),
@@ -1421,17 +1606,17 @@ function renderModelDestructive(
1421
1606
  if (value instanceof Map)
1422
1607
  return (
1423
1608
  (value = Array.from(value)),
1424
- "$Q" + outlineModel(request, value).toString(16)
1609
+ "$Q" + outlineModelWithFormatContext(request, value, 0).toString(16)
1425
1610
  );
1426
1611
  if (value instanceof Set)
1427
1612
  return (
1428
1613
  (value = Array.from(value)),
1429
- "$W" + outlineModel(request, value).toString(16)
1614
+ "$W" + outlineModelWithFormatContext(request, value, 0).toString(16)
1430
1615
  );
1431
1616
  if ("function" === typeof FormData && value instanceof FormData)
1432
1617
  return (
1433
1618
  (value = Array.from(value.entries())),
1434
- "$K" + outlineModel(request, value).toString(16)
1619
+ "$K" + outlineModelWithFormatContext(request, value, 0).toString(16)
1435
1620
  );
1436
1621
  if (value instanceof Error) return "$Z";
1437
1622
  if (value instanceof ArrayBuffer)
@@ -1466,8 +1651,9 @@ function renderModelDestructive(
1466
1651
  return (
1467
1652
  (parentPropertyName = elementReference.call(value)),
1468
1653
  parentPropertyName === value
1469
- ? "$i" +
1470
- outlineModel(request, Array.from(parentPropertyName)).toString(16)
1654
+ ? ((value = Array.from(parentPropertyName)),
1655
+ "$i" +
1656
+ outlineModelWithFormatContext(request, value, 0).toString(16))
1471
1657
  : renderFragment(request, task, Array.from(parentPropertyName))
1472
1658
  );
1473
1659
  if ("function" === typeof ReadableStream && value instanceof ReadableStream)
@@ -1505,6 +1691,7 @@ function renderModelDestructive(
1505
1691
  return value;
1506
1692
  }
1507
1693
  if ("string" === typeof value) {
1694
+ serializedSize += value.length;
1508
1695
  if (
1509
1696
  "Z" === value[value.length - 1] &&
1510
1697
  parent[parentPropertyName] instanceof Date
@@ -1514,7 +1701,7 @@ function renderModelDestructive(
1514
1701
  return (
1515
1702
  request.pendingChunks++,
1516
1703
  (task = request.nextChunkId++),
1517
- emitTextChunk(request, task, value),
1704
+ emitTextChunk(request, task, value, !1),
1518
1705
  serializeByValueID(task)
1519
1706
  );
1520
1707
  request = "$" === value[0] ? "$" + value : value;
@@ -1551,10 +1738,11 @@ function renderModelDestructive(
1551
1738
  null === parentPropertyName
1552
1739
  ? null
1553
1740
  : Promise.resolve(parentPropertyName)),
1554
- (request = outlineModel(request, {
1555
- id: value.$$id,
1556
- bound: parentPropertyName
1557
- })),
1741
+ (request = outlineModelWithFormatContext(
1742
+ request,
1743
+ { id: value.$$id, bound: parentPropertyName },
1744
+ 0
1745
+ )),
1558
1746
  task.set(value, request),
1559
1747
  (request = "$F" + request.toString(16))),
1560
1748
  request
@@ -1633,6 +1821,9 @@ function fatalError(request, error) {
1633
1821
  null !== request.destination
1634
1822
  ? ((request.status = 14), closeWithError(request.destination, error))
1635
1823
  : ((request.status = 13), (request.fatalError = error));
1824
+ request.cacheController.abort(
1825
+ Error("The render was aborted due to a fatal error.", { cause: error })
1826
+ );
1636
1827
  }
1637
1828
  function emitErrorChunk(request, id, digest) {
1638
1829
  digest = { digest: digest };
@@ -1645,74 +1836,76 @@ function emitModelChunk(request, id, json) {
1645
1836
  id = stringToChunk(id);
1646
1837
  request.completedRegularChunks.push(id);
1647
1838
  }
1648
- function emitTypedArrayChunk(request, id, tag, typedArray) {
1649
- request.pendingChunks++;
1650
- var buffer = new Uint8Array(
1839
+ function emitTypedArrayChunk(request, id, tag, typedArray, debug) {
1840
+ debug ? request.pendingDebugChunks++ : request.pendingChunks++;
1841
+ debug = new Uint8Array(
1651
1842
  typedArray.buffer,
1652
1843
  typedArray.byteOffset,
1653
1844
  typedArray.byteLength
1654
1845
  );
1655
- typedArray = 2048 < typedArray.byteLength ? buffer.slice() : buffer;
1656
- buffer = typedArray.byteLength;
1657
- id = id.toString(16) + ":" + tag + buffer.toString(16) + ",";
1846
+ typedArray = 2048 < typedArray.byteLength ? debug.slice() : debug;
1847
+ debug = typedArray.byteLength;
1848
+ id = id.toString(16) + ":" + tag + debug.toString(16) + ",";
1658
1849
  id = stringToChunk(id);
1659
1850
  request.completedRegularChunks.push(id, typedArray);
1660
1851
  }
1661
- function emitTextChunk(request, id, text) {
1852
+ function emitTextChunk(request, id, text, debug) {
1662
1853
  if (null === byteLengthOfChunk)
1663
1854
  throw Error(
1664
1855
  "Existence of byteLengthOfChunk should have already been checked. This is a bug in React."
1665
1856
  );
1666
- request.pendingChunks++;
1857
+ debug ? request.pendingDebugChunks++ : request.pendingChunks++;
1667
1858
  text = stringToChunk(text);
1668
- var binaryLength = text.byteLength;
1669
- id = id.toString(16) + ":T" + binaryLength.toString(16) + ",";
1859
+ debug = text.byteLength;
1860
+ id = id.toString(16) + ":T" + debug.toString(16) + ",";
1670
1861
  id = stringToChunk(id);
1671
1862
  request.completedRegularChunks.push(id, text);
1672
1863
  }
1673
1864
  function emitChunk(request, task, value) {
1674
1865
  var id = task.id;
1675
1866
  "string" === typeof value && null !== byteLengthOfChunk
1676
- ? emitTextChunk(request, id, value)
1867
+ ? emitTextChunk(request, id, value, !1)
1677
1868
  : value instanceof ArrayBuffer
1678
- ? emitTypedArrayChunk(request, id, "A", new Uint8Array(value))
1869
+ ? emitTypedArrayChunk(request, id, "A", new Uint8Array(value), !1)
1679
1870
  : value instanceof Int8Array
1680
- ? emitTypedArrayChunk(request, id, "O", value)
1871
+ ? emitTypedArrayChunk(request, id, "O", value, !1)
1681
1872
  : value instanceof Uint8Array
1682
- ? emitTypedArrayChunk(request, id, "o", value)
1873
+ ? emitTypedArrayChunk(request, id, "o", value, !1)
1683
1874
  : value instanceof Uint8ClampedArray
1684
- ? emitTypedArrayChunk(request, id, "U", value)
1875
+ ? emitTypedArrayChunk(request, id, "U", value, !1)
1685
1876
  : value instanceof Int16Array
1686
- ? emitTypedArrayChunk(request, id, "S", value)
1877
+ ? emitTypedArrayChunk(request, id, "S", value, !1)
1687
1878
  : value instanceof Uint16Array
1688
- ? emitTypedArrayChunk(request, id, "s", value)
1879
+ ? emitTypedArrayChunk(request, id, "s", value, !1)
1689
1880
  : value instanceof Int32Array
1690
- ? emitTypedArrayChunk(request, id, "L", value)
1881
+ ? emitTypedArrayChunk(request, id, "L", value, !1)
1691
1882
  : value instanceof Uint32Array
1692
- ? emitTypedArrayChunk(request, id, "l", value)
1883
+ ? emitTypedArrayChunk(request, id, "l", value, !1)
1693
1884
  : value instanceof Float32Array
1694
- ? emitTypedArrayChunk(request, id, "G", value)
1885
+ ? emitTypedArrayChunk(request, id, "G", value, !1)
1695
1886
  : value instanceof Float64Array
1696
- ? emitTypedArrayChunk(request, id, "g", value)
1887
+ ? emitTypedArrayChunk(request, id, "g", value, !1)
1697
1888
  : value instanceof BigInt64Array
1698
- ? emitTypedArrayChunk(request, id, "M", value)
1889
+ ? emitTypedArrayChunk(request, id, "M", value, !1)
1699
1890
  : value instanceof BigUint64Array
1700
- ? emitTypedArrayChunk(request, id, "m", value)
1891
+ ? emitTypedArrayChunk(request, id, "m", value, !1)
1701
1892
  : value instanceof DataView
1702
- ? emitTypedArrayChunk(request, id, "V", value)
1893
+ ? emitTypedArrayChunk(request, id, "V", value, !1)
1703
1894
  : ((value = stringify(value, task.toJSON)),
1704
1895
  emitModelChunk(request, task.id, value));
1705
1896
  }
1706
1897
  function erroredTask(request, task, error) {
1707
- request.abortableTasks.delete(task);
1708
1898
  task.status = 4;
1709
1899
  error = logRecoverableError(request, error, task);
1710
1900
  emitErrorChunk(request, task.id, error);
1901
+ request.abortableTasks.delete(task);
1902
+ callOnAllReadyIfReady(request);
1711
1903
  }
1712
1904
  var emptyRoot = {};
1713
1905
  function retryTask(request, task) {
1714
1906
  if (0 === task.status) {
1715
1907
  task.status = 5;
1908
+ var parentSerializedSize = serializedSize;
1716
1909
  try {
1717
1910
  modelRoot = task.model;
1718
1911
  var resolvedModel = renderModelDestructive(
@@ -1732,15 +1925,23 @@ function retryTask(request, task) {
1732
1925
  var json = stringify(resolvedModel);
1733
1926
  emitModelChunk(request, task.id, json);
1734
1927
  }
1735
- request.abortableTasks.delete(task);
1736
1928
  task.status = 1;
1929
+ request.abortableTasks.delete(task);
1930
+ callOnAllReadyIfReady(request);
1737
1931
  } catch (thrownValue) {
1738
- if (12 === request.status) {
1739
- request.abortableTasks.delete(task);
1740
- task.status = 3;
1741
- var model = stringify(serializeByValueID(request.fatalError));
1742
- emitModelChunk(request, task.id, model);
1743
- } else {
1932
+ if (12 === request.status)
1933
+ if (
1934
+ (request.abortableTasks.delete(task),
1935
+ (task.status = 0),
1936
+ 21 === request.type)
1937
+ )
1938
+ haltTask(task), finishHaltedTask(task, request);
1939
+ else {
1940
+ var errorId = request.fatalError;
1941
+ abortTask(task);
1942
+ finishAbortedTask(task, request, errorId);
1943
+ }
1944
+ else {
1744
1945
  var x =
1745
1946
  thrownValue === SuspenseException
1746
1947
  ? getSuspendedThenable()
@@ -1757,26 +1958,29 @@ function retryTask(request, task) {
1757
1958
  } else erroredTask(request, task, x);
1758
1959
  }
1759
1960
  } finally {
1961
+ serializedSize = parentSerializedSize;
1760
1962
  }
1761
1963
  }
1762
1964
  }
1965
+ function tryStreamTask(request, task) {
1966
+ var parentSerializedSize = serializedSize;
1967
+ try {
1968
+ emitChunk(request, task, task.model);
1969
+ } finally {
1970
+ serializedSize = parentSerializedSize;
1971
+ }
1972
+ }
1763
1973
  function performWork(request) {
1764
1974
  var prevDispatcher = ReactSharedInternalsServer.H;
1765
1975
  ReactSharedInternalsServer.H = HooksDispatcher;
1766
1976
  var prevRequest = currentRequest;
1767
1977
  currentRequest$1 = currentRequest = request;
1768
- var hadAbortableTasks = 0 < request.abortableTasks.size;
1769
1978
  try {
1770
1979
  var pingedTasks = request.pingedTasks;
1771
1980
  request.pingedTasks = [];
1772
1981
  for (var i = 0; i < pingedTasks.length; i++)
1773
1982
  retryTask(request, pingedTasks[i]);
1774
- null !== request.destination &&
1775
- flushCompletedChunks(request, request.destination);
1776
- if (hadAbortableTasks && 0 === request.abortableTasks.size) {
1777
- var onAllReady = request.onAllReady;
1778
- onAllReady();
1779
- }
1983
+ flushCompletedChunks(request);
1780
1984
  } catch (error) {
1781
1985
  logRecoverableError(request, error, null), fatalError(request, error);
1782
1986
  } finally {
@@ -1785,43 +1989,71 @@ function performWork(request) {
1785
1989
  (currentRequest = prevRequest);
1786
1990
  }
1787
1991
  }
1788
- function flushCompletedChunks(request, destination) {
1789
- currentView = new Uint8Array(2048);
1790
- writtenBytes = 0;
1791
- try {
1792
- for (
1793
- var importsChunks = request.completedImportChunks, i = 0;
1794
- i < importsChunks.length;
1795
- i++
1796
- )
1797
- request.pendingChunks--,
1798
- writeChunkAndReturn(destination, importsChunks[i]);
1799
- importsChunks.splice(0, i);
1800
- var hintChunks = request.completedHintChunks;
1801
- for (i = 0; i < hintChunks.length; i++)
1802
- writeChunkAndReturn(destination, hintChunks[i]);
1803
- hintChunks.splice(0, i);
1804
- var regularChunks = request.completedRegularChunks;
1805
- for (i = 0; i < regularChunks.length; i++)
1806
- request.pendingChunks--,
1807
- writeChunkAndReturn(destination, regularChunks[i]);
1808
- regularChunks.splice(0, i);
1809
- var errorChunks = request.completedErrorChunks;
1810
- for (i = 0; i < errorChunks.length; i++)
1811
- request.pendingChunks--, writeChunkAndReturn(destination, errorChunks[i]);
1812
- errorChunks.splice(0, i);
1813
- } finally {
1814
- (request.flushScheduled = !1),
1815
- currentView &&
1816
- 0 < writtenBytes &&
1817
- (destination.enqueue(
1818
- new Uint8Array(currentView.buffer, 0, writtenBytes)
1819
- ),
1820
- (currentView = null),
1821
- (writtenBytes = 0));
1992
+ function abortTask(task) {
1993
+ 0 === task.status && (task.status = 3);
1994
+ }
1995
+ function finishAbortedTask(task, request, errorId) {
1996
+ 3 === task.status &&
1997
+ ((errorId = serializeByValueID(errorId)),
1998
+ (task = encodeReferenceChunk(request, task.id, errorId)),
1999
+ request.completedErrorChunks.push(task));
2000
+ }
2001
+ function haltTask(task) {
2002
+ 0 === task.status && (task.status = 3);
2003
+ }
2004
+ function finishHaltedTask(task, request) {
2005
+ 3 === task.status && request.pendingChunks--;
2006
+ }
2007
+ function flushCompletedChunks(request) {
2008
+ var destination = request.destination;
2009
+ if (null !== destination) {
2010
+ currentView = new Uint8Array(2048);
2011
+ writtenBytes = 0;
2012
+ try {
2013
+ for (
2014
+ var importsChunks = request.completedImportChunks, i = 0;
2015
+ i < importsChunks.length;
2016
+ i++
2017
+ )
2018
+ request.pendingChunks--,
2019
+ writeChunkAndReturn(destination, importsChunks[i]);
2020
+ importsChunks.splice(0, i);
2021
+ var hintChunks = request.completedHintChunks;
2022
+ for (i = 0; i < hintChunks.length; i++)
2023
+ writeChunkAndReturn(destination, hintChunks[i]);
2024
+ hintChunks.splice(0, i);
2025
+ var regularChunks = request.completedRegularChunks;
2026
+ for (i = 0; i < regularChunks.length; i++)
2027
+ request.pendingChunks--,
2028
+ writeChunkAndReturn(destination, regularChunks[i]);
2029
+ regularChunks.splice(0, i);
2030
+ var errorChunks = request.completedErrorChunks;
2031
+ for (i = 0; i < errorChunks.length; i++)
2032
+ request.pendingChunks--,
2033
+ writeChunkAndReturn(destination, errorChunks[i]);
2034
+ errorChunks.splice(0, i);
2035
+ } finally {
2036
+ (request.flushScheduled = !1),
2037
+ currentView &&
2038
+ 0 < writtenBytes &&
2039
+ (destination.enqueue(
2040
+ new Uint8Array(currentView.buffer, 0, writtenBytes)
2041
+ ),
2042
+ (currentView = null),
2043
+ (writtenBytes = 0));
2044
+ }
1822
2045
  }
1823
2046
  0 === request.pendingChunks &&
1824
- ((request.status = 14), destination.close(), (request.destination = null));
2047
+ (12 > request.status &&
2048
+ request.cacheController.abort(
2049
+ Error(
2050
+ "This render completed successfully. All cacheSignals are now aborted to allow clean up of any unused resources."
2051
+ )
2052
+ ),
2053
+ null !== request.destination &&
2054
+ ((request.status = 14),
2055
+ request.destination.close(),
2056
+ (request.destination = null)));
1825
2057
  }
1826
2058
  function startWork(request) {
1827
2059
  request.flushScheduled = null !== request.destination;
@@ -1839,72 +2071,97 @@ function enqueueFlush(request) {
1839
2071
  ((request.flushScheduled = !0),
1840
2072
  scheduleWork(function () {
1841
2073
  request.flushScheduled = !1;
1842
- var destination = request.destination;
1843
- destination && flushCompletedChunks(request, destination);
2074
+ flushCompletedChunks(request);
1844
2075
  }));
1845
2076
  }
2077
+ function callOnAllReadyIfReady(request) {
2078
+ 0 === request.abortableTasks.size &&
2079
+ ((request = request.onAllReady), request());
2080
+ }
1846
2081
  function startFlowing(request, destination) {
1847
2082
  if (13 === request.status)
1848
2083
  (request.status = 14), closeWithError(destination, request.fatalError);
1849
2084
  else if (14 !== request.status && null === request.destination) {
1850
2085
  request.destination = destination;
1851
2086
  try {
1852
- flushCompletedChunks(request, destination);
2087
+ flushCompletedChunks(request);
1853
2088
  } catch (error) {
1854
2089
  logRecoverableError(request, error, null), fatalError(request, error);
1855
2090
  }
1856
2091
  }
1857
2092
  }
1858
- function abort(request, reason) {
2093
+ function finishHalt(request, abortedTasks) {
2094
+ try {
2095
+ abortedTasks.forEach(function (task) {
2096
+ return finishHaltedTask(task, request);
2097
+ });
2098
+ var onAllReady = request.onAllReady;
2099
+ onAllReady();
2100
+ flushCompletedChunks(request);
2101
+ } catch (error) {
2102
+ logRecoverableError(request, error, null), fatalError(request, error);
2103
+ }
2104
+ }
2105
+ function finishAbort(request, abortedTasks, errorId) {
1859
2106
  try {
1860
- 11 >= request.status && (request.status = 12);
1861
- var abortableTasks = request.abortableTasks;
1862
- if (0 < abortableTasks.size) {
1863
- var error =
1864
- void 0 === reason
1865
- ? Error("The render was aborted by the server without a reason.")
1866
- : "object" === typeof reason &&
1867
- null !== reason &&
1868
- "function" === typeof reason.then
1869
- ? Error("The render was aborted by the server with a promise.")
1870
- : reason,
1871
- digest = logRecoverableError(request, error, null),
1872
- errorId = request.nextChunkId++;
1873
- request.fatalError = errorId;
1874
- request.pendingChunks++;
1875
- emitErrorChunk(request, errorId, digest, error);
1876
- abortableTasks.forEach(function (task) {
1877
- if (5 !== task.status) {
1878
- task.status = 3;
1879
- var ref = serializeByValueID(errorId);
1880
- task = encodeReferenceChunk(request, task.id, ref);
1881
- request.completedErrorChunks.push(task);
2107
+ abortedTasks.forEach(function (task) {
2108
+ return finishAbortedTask(task, request, errorId);
2109
+ });
2110
+ var onAllReady = request.onAllReady;
2111
+ onAllReady();
2112
+ flushCompletedChunks(request);
2113
+ } catch (error) {
2114
+ logRecoverableError(request, error, null), fatalError(request, error);
2115
+ }
2116
+ }
2117
+ function abort(request, reason) {
2118
+ if (!(11 < request.status))
2119
+ try {
2120
+ request.status = 12;
2121
+ request.cacheController.abort(reason);
2122
+ var abortableTasks = request.abortableTasks;
2123
+ if (0 < abortableTasks.size)
2124
+ if (21 === request.type)
2125
+ abortableTasks.forEach(function (task) {
2126
+ return haltTask(task, request);
2127
+ }),
2128
+ scheduleWork(function () {
2129
+ return finishHalt(request, abortableTasks);
2130
+ });
2131
+ else {
2132
+ var error =
2133
+ void 0 === reason
2134
+ ? Error(
2135
+ "The render was aborted by the server without a reason."
2136
+ )
2137
+ : "object" === typeof reason &&
2138
+ null !== reason &&
2139
+ "function" === typeof reason.then
2140
+ ? Error(
2141
+ "The render was aborted by the server with a promise."
2142
+ )
2143
+ : reason,
2144
+ digest = logRecoverableError(request, error, null),
2145
+ errorId = request.nextChunkId++;
2146
+ request.fatalError = errorId;
2147
+ request.pendingChunks++;
2148
+ emitErrorChunk(request, errorId, digest, error, !1, null);
2149
+ abortableTasks.forEach(function (task) {
2150
+ return abortTask(task, request, errorId);
2151
+ });
2152
+ scheduleWork(function () {
2153
+ return finishAbort(request, abortableTasks, errorId);
2154
+ });
1882
2155
  }
1883
- });
1884
- abortableTasks.clear();
1885
- var onAllReady = request.onAllReady;
1886
- onAllReady();
1887
- }
1888
- var abortListeners = request.abortListeners;
1889
- if (0 < abortListeners.size) {
1890
- var error$22 =
1891
- void 0 === reason
1892
- ? Error("The render was aborted by the server without a reason.")
1893
- : "object" === typeof reason &&
1894
- null !== reason &&
1895
- "function" === typeof reason.then
1896
- ? Error("The render was aborted by the server with a promise.")
1897
- : reason;
1898
- abortListeners.forEach(function (callback) {
1899
- return callback(error$22);
1900
- });
1901
- abortListeners.clear();
2156
+ else {
2157
+ var onAllReady = request.onAllReady;
2158
+ onAllReady();
2159
+ flushCompletedChunks(request);
2160
+ }
2161
+ } catch (error$23) {
2162
+ logRecoverableError(request, error$23, null),
2163
+ fatalError(request, error$23);
1902
2164
  }
1903
- null !== request.destination &&
1904
- flushCompletedChunks(request, request.destination);
1905
- } catch (error$23) {
1906
- logRecoverableError(request, error$23, null), fatalError(request, error$23);
1907
- }
1908
2165
  }
1909
2166
  function resolveServerReference(bundlerConfig, id) {
1910
2167
  var name = "",
@@ -1990,7 +2247,6 @@ __webpack_require__.u = function (chunkId) {
1990
2247
  ? flightChunk
1991
2248
  : webpackGetChunkFilename(chunkId);
1992
2249
  };
1993
- var hasOwnProperty = Object.prototype.hasOwnProperty;
1994
2250
  function Chunk(status, value, reason, response) {
1995
2251
  this.status = status;
1996
2252
  this.value = value;
@@ -2693,6 +2949,48 @@ exports.decodeReply = function (body, webpackMap, options) {
2693
2949
  close(body);
2694
2950
  return webpackMap;
2695
2951
  };
2952
+ exports.prerender = function (model, webpackMap, options) {
2953
+ return new Promise(function (resolve, reject) {
2954
+ var request = new RequestInstance(
2955
+ 21,
2956
+ model,
2957
+ webpackMap,
2958
+ options ? options.onError : void 0,
2959
+ options ? options.onPostpone : void 0,
2960
+ function () {
2961
+ var stream = new ReadableStream(
2962
+ {
2963
+ type: "bytes",
2964
+ pull: function (controller) {
2965
+ startFlowing(request, controller);
2966
+ },
2967
+ cancel: function (reason) {
2968
+ request.destination = null;
2969
+ abort(request, reason);
2970
+ }
2971
+ },
2972
+ { highWaterMark: 0 }
2973
+ );
2974
+ resolve({ prelude: stream });
2975
+ },
2976
+ reject,
2977
+ options ? options.identifierPrefix : void 0,
2978
+ options ? options.temporaryReferences : void 0
2979
+ );
2980
+ if (options && options.signal) {
2981
+ var signal = options.signal;
2982
+ if (signal.aborted) abort(request, signal.reason);
2983
+ else {
2984
+ var listener = function () {
2985
+ abort(request, signal.reason);
2986
+ signal.removeEventListener("abort", listener);
2987
+ };
2988
+ signal.addEventListener("abort", listener);
2989
+ }
2990
+ }
2991
+ startWork(request);
2992
+ });
2993
+ };
2696
2994
  exports.registerClientReference = function (
2697
2995
  proxyImplementation,
2698
2996
  id,
@@ -2721,13 +3019,11 @@ exports.renderToReadableStream = function (model, webpackMap, options) {
2721
3019
  model,
2722
3020
  webpackMap,
2723
3021
  options ? options.onError : void 0,
2724
- options ? options.identifierPrefix : void 0,
2725
3022
  options ? options.onPostpone : void 0,
2726
- options ? options.temporaryReferences : void 0,
2727
- void 0,
2728
- void 0,
2729
3023
  noop,
2730
- noop
3024
+ noop,
3025
+ options ? options.identifierPrefix : void 0,
3026
+ options ? options.temporaryReferences : void 0
2731
3027
  );
2732
3028
  if (options && options.signal) {
2733
3029
  var signal = options.signal;
@@ -2757,50 +3053,3 @@ exports.renderToReadableStream = function (model, webpackMap, options) {
2757
3053
  { highWaterMark: 0 }
2758
3054
  );
2759
3055
  };
2760
- exports.unstable_prerender = function (model, webpackMap, options) {
2761
- return new Promise(function (resolve, reject) {
2762
- var request = new RequestInstance(
2763
- 21,
2764
- model,
2765
- webpackMap,
2766
- options ? options.onError : void 0,
2767
- options ? options.identifierPrefix : void 0,
2768
- options ? options.onPostpone : void 0,
2769
- options ? options.temporaryReferences : void 0,
2770
- void 0,
2771
- void 0,
2772
- function () {
2773
- var stream = new ReadableStream(
2774
- {
2775
- type: "bytes",
2776
- start: function () {
2777
- startWork(request);
2778
- },
2779
- pull: function (controller) {
2780
- startFlowing(request, controller);
2781
- },
2782
- cancel: function (reason) {
2783
- request.destination = null;
2784
- abort(request, reason);
2785
- }
2786
- },
2787
- { highWaterMark: 0 }
2788
- );
2789
- resolve({ prelude: stream });
2790
- },
2791
- reject
2792
- );
2793
- if (options && options.signal) {
2794
- var signal = options.signal;
2795
- if (signal.aborted) abort(request, signal.reason);
2796
- else {
2797
- var listener = function () {
2798
- abort(request, signal.reason);
2799
- signal.removeEventListener("abort", listener);
2800
- };
2801
- signal.addEventListener("abort", listener);
2802
- }
2803
- }
2804
- startWork(request);
2805
- });
2806
- };