@vitejs/plugin-rsc 0.5.33 → 0.5.35

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 (81) hide show
  1. package/README.md +18 -2
  2. package/dist/browser.d.ts +1 -1
  3. package/dist/{cjs-AWVWfddx.js → cjs-DhDj_zQT.js} +2 -2
  4. package/dist/client-Dq3oGLRS.d.ts +8 -0
  5. package/dist/{client-reference-DEZtXTv1.d.ts → client-reference-Bk5pzNGN.d.ts} +1 -1
  6. package/dist/client.node-BEQT2PT-.d.ts +9 -0
  7. package/dist/client.shared-D1HxyClg.js +10 -0
  8. package/dist/client.shared-VT232QCM.d.ts +16 -0
  9. package/dist/core/browser.js +1 -1
  10. package/dist/core/plugin.d.ts +2 -3
  11. package/dist/core/rsc.d.ts +1 -1
  12. package/dist/core/rsc.js +1 -1
  13. package/dist/core/ssr.d.ts +1 -7
  14. package/dist/core/ssr.js +1 -1
  15. package/dist/{index-C5IY2S-e.d.ts → index-CROaL0MT.d.ts} +34 -8
  16. package/dist/index.js +1 -1
  17. package/dist/{picocolors-D28_L_A0.js → picocolors-DCTC64Zv.js} +1 -1
  18. package/dist/{plugin-DarRieDr.js → plugin-CLvIS10V.js} +38 -32
  19. package/dist/plugin.js +1 -1
  20. package/dist/plugins/cjs.d.ts +2 -3
  21. package/dist/plugins/cjs.js +1 -1
  22. package/dist/react/browser.d.ts +10 -10
  23. package/dist/react/rsc/client.d.ts +1 -1
  24. package/dist/react/rsc/client.js +2 -5
  25. package/dist/react/rsc/client.node.d.ts +2 -0
  26. package/dist/react/rsc/client.node.js +16 -0
  27. package/dist/react/rsc/server.d.ts +2 -2
  28. package/dist/react/rsc/server.node.d.ts +3 -0
  29. package/dist/react/rsc/server.node.js +24 -0
  30. package/dist/react/rsc/static.d.ts +4 -5
  31. package/dist/react/rsc/static.node.d.ts +6 -0
  32. package/dist/react/rsc/static.node.js +11 -0
  33. package/dist/react/rsc.d.ts +3 -3
  34. package/dist/react/ssr.d.ts +9 -9
  35. package/dist/react/ssr.node.d.ts +12 -0
  36. package/dist/react/ssr.node.js +21 -0
  37. package/dist/rsc/client.d.ts +1 -1
  38. package/dist/rsc/client.node.d.ts +2 -0
  39. package/dist/rsc/client.node.js +3 -0
  40. package/dist/rsc/server.d.ts +5 -5
  41. package/dist/rsc/server.node.d.ts +19 -0
  42. package/dist/rsc/server.node.js +13 -0
  43. package/dist/rsc/static.d.ts +4 -5
  44. package/dist/rsc/static.node.d.ts +16 -0
  45. package/dist/rsc/static.node.js +12 -0
  46. package/dist/{rsc-C3UdJLOW.d.ts → rsc-D8UlANI2.d.ts} +1 -1
  47. package/dist/rsc.d.ts +3 -3
  48. package/dist/rsc.node.d.ts +6 -0
  49. package/dist/rsc.node.js +7 -0
  50. package/dist/{scope-Bdx33sQv.js → scope-Ck0n25my.js} +2 -4
  51. package/dist/{server-ZBjqNTqU.d.ts → server-YwgjVtsE.d.ts} +2 -2
  52. package/dist/server.node-DU77AeKU.d.ts +15 -0
  53. package/dist/shared-BWJvctW6.js +34 -0
  54. package/dist/shared-CXQb6hk9.js +89 -0
  55. package/dist/shared-DJBuYpZL.d.ts +20 -0
  56. package/dist/ssr-C-U7jY5S.d.ts +8 -0
  57. package/dist/ssr.d.ts +3 -21
  58. package/dist/ssr.js +1 -87
  59. package/dist/ssr.node.d.ts +5 -0
  60. package/dist/ssr.node.js +4 -0
  61. package/dist/transforms/index.js +91 -62
  62. package/dist/utils/encryption-runtime.d.ts +3 -4
  63. package/dist/utils/encryption-runtime.js +4 -2
  64. package/dist/utils/rpc.d.ts +3 -4
  65. package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-client.browser.development.js +909 -495
  66. package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-client.browser.production.js +399 -265
  67. package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-client.edge.development.js +901 -477
  68. package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-client.edge.production.js +380 -219
  69. package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-client.node.development.js +925 -484
  70. package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-client.node.production.js +385 -221
  71. package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-server.browser.development.js +726 -388
  72. package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-server.browser.production.js +566 -397
  73. package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-server.edge.development.js +734 -397
  74. package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-server.edge.production.js +477 -238
  75. package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-server.node.development.js +1029 -620
  76. package/dist/vendor/react-server-dom/cjs/react-server-dom-webpack-server.node.production.js +481 -261
  77. package/dist/vendor/react-server-dom/esm/react-server-dom-webpack-node-loader.production.js +2 -2
  78. package/dist/vendor/react-server-dom/package.json +3 -3
  79. package/package.json +15 -15
  80. package/dist/client-Bhch3O41.d.ts +0 -19
  81. package/dist/dist-uqdtSkzK.js +0 -64
@@ -10,8 +10,23 @@
10
10
 
11
11
  "use strict";
12
12
  var ReactDOM = require("react-dom"),
13
- React = require("react"),
14
- channel = new MessageChannel(),
13
+ React = require("react");
14
+ function formatProdErrorMessage(code) {
15
+ var url = "https://react.dev/errors/" + code;
16
+ if (1 < arguments.length) {
17
+ url += "?args[]=" + encodeURIComponent(arguments[1]);
18
+ for (var i = 2; i < arguments.length; i++)
19
+ url += "&args[]=" + encodeURIComponent(arguments[i]);
20
+ }
21
+ return (
22
+ "Minified React error #" +
23
+ code +
24
+ "; visit " +
25
+ url +
26
+ " for the full message or use the non-minified dev environment for full errors and additional helpful warnings."
27
+ );
28
+ }
29
+ var channel = new MessageChannel(),
15
30
  taskQueue = [];
16
31
  channel.port1.onmessage = function () {
17
32
  var task = taskQueue.shift();
@@ -37,7 +52,7 @@ var LocalPromise = Promise,
37
52
  },
38
53
  currentView = null,
39
54
  writtenBytes = 0;
40
- function writeChunkAndReturn(destination, chunk) {
55
+ function writeChunk(destination, chunk) {
41
56
  if (0 !== chunk.byteLength)
42
57
  if (2048 < chunk.byteLength)
43
58
  0 < writtenBytes &&
@@ -60,6 +75,9 @@ function writeChunkAndReturn(destination, chunk) {
60
75
  currentView.set(chunk, writtenBytes);
61
76
  writtenBytes += chunk.byteLength;
62
77
  }
78
+ }
79
+ function writeChunkAndReturn(destination, chunk) {
80
+ writeChunk(destination, chunk);
63
81
  return !0;
64
82
  }
65
83
  var textEncoder = new TextEncoder();
@@ -110,7 +128,7 @@ var serverReferenceToString = {
110
128
  },
111
129
  PROMISE_PROTOTYPE = Promise.prototype,
112
130
  deepProxyHandlers = {
113
- get: function (target, name) {
131
+ get: function (target, name, receiver) {
114
132
  switch (name) {
115
133
  case "$$typeof":
116
134
  return target.$$typeof;
@@ -133,22 +151,16 @@ var serverReferenceToString = {
133
151
  case Symbol.toStringTag:
134
152
  return Object.prototype[Symbol.toStringTag];
135
153
  case "Provider":
136
- throw Error(
137
- "Cannot render a Client Context Provider on the Server. Instead, you can export a Client Component wrapper that itself renders a Client Context Provider."
138
- );
154
+ return receiver;
139
155
  case "then":
140
- throw Error(
141
- "Cannot await or return from a thenable. You cannot await a client module from a server component."
142
- );
156
+ throw Error(formatProdErrorMessage(590));
143
157
  }
144
158
  throw Error(
145
- "Cannot access " +
146
- (String(target.name) + "." + String(name)) +
147
- " on the server. You cannot dot into a client module from a server component. You can only pass the imported name through."
159
+ formatProdErrorMessage(591, String(target.name) + "." + String(name))
148
160
  );
149
161
  },
150
162
  set: function () {
151
- throw Error("Cannot assign to a client module from a server module.");
163
+ throw Error(formatProdErrorMessage(592));
152
164
  }
153
165
  };
154
166
  function getReference(target, name) {
@@ -175,11 +187,7 @@ function getReference(target, name) {
175
187
  var moduleId = target.$$id;
176
188
  target.default = registerClientReferenceImpl(
177
189
  function () {
178
- throw Error(
179
- "Attempted to call the default export of " +
180
- moduleId +
181
- " from the server but it's on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component."
182
- );
190
+ throw Error(formatProdErrorMessage(593, moduleId));
183
191
  },
184
192
  target.$$id + "#",
185
193
  target.$$async
@@ -200,21 +208,12 @@ function getReference(target, name) {
200
208
  !1
201
209
  ));
202
210
  }
203
- if ("symbol" === typeof name)
204
- throw Error(
205
- "Cannot read Symbol exports. Only named exports are supported on a client module imported on the server."
206
- );
211
+ if ("symbol" === typeof name) throw Error(formatProdErrorMessage(594));
207
212
  clientReference = target[name];
208
213
  clientReference ||
209
214
  ((clientReference = registerClientReferenceImpl(
210
215
  function () {
211
- throw Error(
212
- "Attempted to call " +
213
- String(name) +
214
- "() from the server but " +
215
- String(name) +
216
- " is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component."
217
- );
216
+ throw Error(formatProdErrorMessage(595, String(name), String(name)));
218
217
  },
219
218
  target.$$id + "#" + name,
220
219
  target.$$async
@@ -244,7 +243,7 @@ var proxyHandlers$1 = {
244
243
  return PROMISE_PROTOTYPE;
245
244
  },
246
245
  set: function () {
247
- throw Error("Cannot assign to a client module from a server module.");
246
+ throw Error(formatProdErrorMessage(592));
248
247
  }
249
248
  },
250
249
  ReactDOMSharedInternals =
@@ -466,7 +465,7 @@ function getChildFormatContext(parentContext, type, props) {
466
465
  });
467
466
  break;
468
467
  case "stylesheet":
469
- preload(srcSet, "stylesheet", {
468
+ preload(srcSet, "style", {
470
469
  crossOrigin: props.crossOrigin,
471
470
  integrity: props.integrity,
472
471
  nonce: props.nonce,
@@ -487,7 +486,7 @@ function getChildFormatContext(parentContext, type, props) {
487
486
  }
488
487
  var TEMPORARY_REFERENCE_TAG = Symbol.for("react.temporary.reference"),
489
488
  proxyHandlers = {
490
- get: function (target, name) {
489
+ get: function (target, name, receiver) {
491
490
  switch (name) {
492
491
  case "$$typeof":
493
492
  return target.$$typeof;
@@ -506,30 +505,20 @@ var TEMPORARY_REFERENCE_TAG = Symbol.for("react.temporary.reference"),
506
505
  case Symbol.toStringTag:
507
506
  return Object.prototype[Symbol.toStringTag];
508
507
  case "Provider":
509
- throw Error(
510
- "Cannot render a Client Context Provider on the Server. Instead, you can export a Client Component wrapper that itself renders a Client Context Provider."
511
- );
508
+ return receiver;
512
509
  case "then":
513
510
  return;
514
511
  }
515
- throw Error(
516
- "Cannot access " +
517
- String(name) +
518
- " on the server. You cannot dot into a temporary client reference from a server component. You can only pass the value through to the client."
519
- );
512
+ throw Error(formatProdErrorMessage(514, String(name)));
520
513
  },
521
514
  set: function () {
522
- throw Error(
523
- "Cannot assign to a temporary client reference from a server module."
524
- );
515
+ throw Error(formatProdErrorMessage(515));
525
516
  }
526
517
  };
527
518
  function createTemporaryReference(temporaryReferences, id) {
528
519
  var reference = Object.defineProperties(
529
520
  function () {
530
- throw Error(
531
- "Attempted to call a temporary Client Reference from the server but it is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component."
532
- );
521
+ throw Error(formatProdErrorMessage(516));
533
522
  },
534
523
  { $$typeof: { value: TEMPORARY_REFERENCE_TAG } }
535
524
  );
@@ -546,9 +535,9 @@ var REACT_LEGACY_ELEMENT_TYPE = Symbol.for("react.element"),
546
535
  REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"),
547
536
  REACT_MEMO_TYPE = Symbol.for("react.memo"),
548
537
  REACT_LAZY_TYPE = Symbol.for("react.lazy"),
549
- REACT_MEMO_CACHE_SENTINEL = Symbol.for("react.memo_cache_sentinel");
550
- Symbol.for("react.postpone");
551
- var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
538
+ REACT_MEMO_CACHE_SENTINEL = Symbol.for("react.memo_cache_sentinel"),
539
+ REACT_VIEW_TRANSITION_TYPE = Symbol.for("react.view_transition"),
540
+ MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
552
541
  function getIteratorFn(maybeIterable) {
553
542
  if (null === maybeIterable || "object" !== typeof maybeIterable) return null;
554
543
  maybeIterable =
@@ -556,11 +545,10 @@ function getIteratorFn(maybeIterable) {
556
545
  maybeIterable["@@iterator"];
557
546
  return "function" === typeof maybeIterable ? maybeIterable : null;
558
547
  }
559
- var ASYNC_ITERATOR = Symbol.asyncIterator;
548
+ var ASYNC_ITERATOR = Symbol.asyncIterator,
549
+ REACT_OPTIMISTIC_KEY = Symbol.for("react.optimistic_key");
560
550
  function noop() {}
561
- var SuspenseException = Error(
562
- "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`."
563
- );
551
+ var SuspenseException = Error(formatProdErrorMessage(460));
564
552
  function trackUsedThenable(thenableState, thenable, index) {
565
553
  index = thenableState[index];
566
554
  void 0 === index
@@ -570,7 +558,10 @@ function trackUsedThenable(thenableState, thenable, index) {
570
558
  case "fulfilled":
571
559
  return thenable.value;
572
560
  case "rejected":
573
- throw thenable.reason;
561
+ thenableState = thenable.reason;
562
+ if (void 0 === thenableState && !("reason" in thenable))
563
+ throw Error(formatProdErrorMessage(600));
564
+ throw thenableState;
574
565
  default:
575
566
  "string" === typeof thenable.status
576
567
  ? thenable.then(noop, noop)
@@ -604,10 +595,7 @@ function trackUsedThenable(thenableState, thenable, index) {
604
595
  }
605
596
  var suspendedThenable = null;
606
597
  function getSuspendedThenable() {
607
- if (null === suspendedThenable)
608
- throw Error(
609
- "Expected a suspended thenable. This is a bug in React. Please file an issue."
610
- );
598
+ if (null === suspendedThenable) throw Error(formatProdErrorMessage(459));
611
599
  var thenable = suspendedThenable;
612
600
  suspendedThenable = null;
613
601
  return thenable;
@@ -653,21 +641,20 @@ var HooksDispatcher = {
653
641
  },
654
642
  useCacheRefresh: function () {
655
643
  return unsupportedRefresh;
656
- }
644
+ },
645
+ useEffectEvent: unsupportedHook
657
646
  };
658
- HooksDispatcher.useEffectEvent = unsupportedHook;
659
647
  function unsupportedHook() {
660
- throw Error("This Hook is not supported in Server Components.");
648
+ throw Error(formatProdErrorMessage(373));
661
649
  }
662
650
  function unsupportedRefresh() {
663
- throw Error("Refreshing the cache is not supported in Server Components.");
651
+ throw Error(formatProdErrorMessage(384));
664
652
  }
665
653
  function unsupportedContext() {
666
- throw Error("Cannot read a Client Context from a Server Component.");
654
+ throw Error(formatProdErrorMessage(502));
667
655
  }
668
656
  function useId() {
669
- if (null === currentRequest$1)
670
- throw Error("useId can only be used while React is rendering");
657
+ if (null === currentRequest$1) throw Error(formatProdErrorMessage(433));
671
658
  var id = currentRequest$1.identifierCount++;
672
659
  return "_" + currentRequest$1.identifierPrefix + "S_" + id.toString(32) + "_";
673
660
  }
@@ -686,10 +673,10 @@ function use(usable) {
686
673
  }
687
674
  if (usable.$$typeof === CLIENT_REFERENCE_TAG$1) {
688
675
  if (null != usable.value && usable.value.$$typeof === REACT_CONTEXT_TYPE)
689
- throw Error("Cannot read a Client Context from a Server Component.");
690
- throw Error("Cannot use() an already resolved Client Reference.");
676
+ throw Error(formatProdErrorMessage(502));
677
+ throw Error(formatProdErrorMessage(503));
691
678
  }
692
- throw Error("An unsupported type was passed to use(): " + String(usable));
679
+ throw Error(formatProdErrorMessage(438, String(usable)));
693
680
  }
694
681
  var DefaultAsyncDispatcher = {
695
682
  getCacheForType: function (resourceType) {
@@ -711,10 +698,7 @@ var DefaultAsyncDispatcher = {
711
698
  },
712
699
  ReactSharedInternalsServer =
713
700
  React.__SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
714
- if (!ReactSharedInternalsServer)
715
- throw Error(
716
- 'The "react" package in this environment is not configured correctly. The "react-server" condition must be enabled in any environment that runs React Server Components.'
717
- );
701
+ if (!ReactSharedInternalsServer) throw Error(formatProdErrorMessage(492));
718
702
  var isArrayImpl = Array.isArray,
719
703
  getPrototypeOf = Object.getPrototypeOf;
720
704
  function objectName(object) {
@@ -750,6 +734,8 @@ function describeElementType(type) {
750
734
  return "Suspense";
751
735
  case REACT_SUSPENSE_LIST_TYPE:
752
736
  return "SuspenseList";
737
+ case REACT_VIEW_TRANSITION_TYPE:
738
+ return "ViewTransition";
753
739
  }
754
740
  if ("object" === typeof type)
755
741
  switch (type.$$typeof) {
@@ -825,7 +811,8 @@ function describeObjectForErrorMessage(objectOrArray, expandedName) {
825
811
  }
826
812
  var hasOwnProperty = Object.prototype.hasOwnProperty,
827
813
  ObjectPrototype$1 = Object.prototype,
828
- stringify = JSON.stringify;
814
+ stringify = JSON.stringify,
815
+ NEXT_TWO_CHUNKS_ARE_ATOMIC = Symbol();
829
816
  function defaultErrorHandler(error) {
830
817
  console.error(error);
831
818
  }
@@ -834,7 +821,6 @@ function RequestInstance(
834
821
  model,
835
822
  bundlerConfig,
836
823
  onError,
837
- onPostpone,
838
824
  onAllReady,
839
825
  onFatalError,
840
826
  identifierPrefix,
@@ -844,7 +830,7 @@ function RequestInstance(
844
830
  null !== ReactSharedInternalsServer.A &&
845
831
  ReactSharedInternalsServer.A !== DefaultAsyncDispatcher
846
832
  )
847
- throw Error("Currently React only supports one RSC renderer at a time.");
833
+ throw Error(formatProdErrorMessage(458));
848
834
  ReactSharedInternalsServer.A = DefaultAsyncDispatcher;
849
835
  var abortSet = new Set(),
850
836
  pingedTasks = [],
@@ -868,12 +854,13 @@ function RequestInstance(
868
854
  this.writtenClientReferences = new Map();
869
855
  this.writtenServerReferences = new Map();
870
856
  this.writtenObjects = new WeakMap();
857
+ this.writtenImportStrings = new Map();
858
+ this.writtenImportStringsSize = 0;
871
859
  this.temporaryReferences = temporaryReferences;
872
860
  this.identifierPrefix = identifierPrefix || "";
873
861
  this.identifierCount = 1;
874
862
  this.taintCleanupQueue = [];
875
863
  this.onError = void 0 === onError ? defaultErrorHandler : onError;
876
- this.onPostpone = void 0 === onPostpone ? noop : onPostpone;
877
864
  this.onAllReady = onAllReady;
878
865
  this.onFatalError = onFatalError;
879
866
  type = createTask(this, model, null, !1, 0, abortSet);
@@ -881,31 +868,52 @@ function RequestInstance(
881
868
  }
882
869
  var currentRequest = null;
883
870
  function serializeThenable(request, task, thenable) {
884
- var newTask = createTask(
885
- request,
886
- thenable,
887
- task.keyPath,
888
- task.implicitSlot,
889
- task.formatContext,
890
- request.abortableTasks
891
- );
892
871
  switch (thenable.status) {
893
872
  case "fulfilled":
894
873
  return (
895
- (newTask.model = thenable.value), pingTask(request, newTask), newTask.id
874
+ (task = createTask(
875
+ request,
876
+ thenable,
877
+ task.keyPath,
878
+ task.implicitSlot,
879
+ task.formatContext,
880
+ request.abortableTasks
881
+ )),
882
+ (task.model = thenable.value),
883
+ pingTask(request, task),
884
+ task.id
896
885
  );
897
886
  case "rejected":
898
- return erroredTask(request, newTask, thenable.reason), newTask.id;
887
+ return (
888
+ (task = createTask(
889
+ request,
890
+ thenable,
891
+ task.keyPath,
892
+ task.implicitSlot,
893
+ task.formatContext,
894
+ request.abortableTasks
895
+ )),
896
+ erroredTask(request, task, thenable.reason),
897
+ task.id
898
+ );
899
899
  default:
900
+ var newTask$12 = createTask(
901
+ request,
902
+ thenable,
903
+ task.keyPath,
904
+ task.implicitSlot,
905
+ task.formatContext,
906
+ request.abortableTasks
907
+ );
900
908
  if (12 === request.status)
901
909
  return (
902
- request.abortableTasks.delete(newTask),
910
+ request.abortableTasks.delete(newTask$12),
903
911
  21 === request.type
904
- ? (haltTask(newTask), finishHaltedTask(newTask, request))
912
+ ? (haltTask(newTask$12), finishHaltedTask(newTask$12, request))
905
913
  : ((task = request.fatalError),
906
- abortTask(newTask),
907
- finishAbortedTask(newTask, request, task)),
908
- newTask.id
914
+ abortTask(newTask$12),
915
+ finishAbortedTask(newTask$12, request, task)),
916
+ newTask$12.id
909
917
  );
910
918
  "string" !== typeof thenable.status &&
911
919
  ((thenable.status = "pending"),
@@ -920,18 +928,18 @@ function serializeThenable(request, task, thenable) {
920
928
  ((thenable.status = "rejected"), (thenable.reason = error));
921
929
  }
922
930
  ));
931
+ thenable.then(
932
+ function (value) {
933
+ newTask$12.model = value;
934
+ pingTask(request, newTask$12);
935
+ },
936
+ function (reason) {
937
+ 0 === newTask$12.status &&
938
+ (erroredTask(request, newTask$12, reason), enqueueFlush(request));
939
+ }
940
+ );
941
+ return newTask$12.id;
923
942
  }
924
- thenable.then(
925
- function (value) {
926
- newTask.model = value;
927
- pingTask(request, newTask);
928
- },
929
- function (reason) {
930
- 0 === newTask.status &&
931
- (erroredTask(request, newTask, reason), enqueueFlush(request));
932
- }
933
- );
934
- return newTask.id;
935
943
  }
936
944
  function serializeReadableStream(request, task, stream) {
937
945
  function progress(entry) {
@@ -949,13 +957,21 @@ function serializeReadableStream(request, task, stream) {
949
957
  callOnAllReadyIfReady(request);
950
958
  else
951
959
  try {
952
- (streamTask.model = entry.value),
953
- request.pendingChunks++,
954
- tryStreamTask(request, streamTask),
960
+ request.pendingChunks++,
961
+ (streamTask.model = entry.value),
962
+ isByteStream
963
+ ? emitTypedArrayChunk(
964
+ request,
965
+ streamTask.id,
966
+ "b",
967
+ streamTask.model,
968
+ !1
969
+ )
970
+ : tryStreamTask(request, streamTask),
955
971
  enqueueFlush(request),
956
972
  reader.read().then(progress, error);
957
- } catch (x$11) {
958
- error(x$11);
973
+ } catch (x$13) {
974
+ error(x$13);
959
975
  }
960
976
  }
961
977
  function error(reason) {
@@ -985,7 +1001,8 @@ function serializeReadableStream(request, task, stream) {
985
1001
  } catch (x) {
986
1002
  supportsBYOB = !1;
987
1003
  }
988
- var reader = stream.getReader(),
1004
+ var isByteStream = supportsBYOB,
1005
+ reader = stream.getReader(),
989
1006
  streamTask = createTask(
990
1007
  request,
991
1008
  task.model,
@@ -995,7 +1012,7 @@ function serializeReadableStream(request, task, stream) {
995
1012
  request.abortableTasks
996
1013
  );
997
1014
  request.pendingChunks++;
998
- task = streamTask.id.toString(16) + ":" + (supportsBYOB ? "r" : "R") + "\n";
1015
+ task = streamTask.id.toString(16) + ":" + (isByteStream ? "r" : "R") + "\n";
999
1016
  request.completedRegularChunks.push(stringToChunk(task));
1000
1017
  request.cacheController.signal.addEventListener("abort", abortStream);
1001
1018
  reader.read().then(progress, error);
@@ -1039,8 +1056,8 @@ function serializeAsyncIterable(request, task, iterable, iterator) {
1039
1056
  tryStreamTask(request, streamTask),
1040
1057
  enqueueFlush(request),
1041
1058
  iterator.next().then(progress, error);
1042
- } catch (x$12) {
1043
- error(x$12);
1059
+ } catch (x$14) {
1060
+ error(x$14);
1044
1061
  }
1045
1062
  }
1046
1063
  function error(reason) {
@@ -1165,7 +1182,12 @@ function renderFunctionComponent(request, task, key, Component, props) {
1165
1182
  Component = task.keyPath;
1166
1183
  prevThenableState = task.implicitSlot;
1167
1184
  null !== key
1168
- ? (task.keyPath = null === Component ? key : Component + "," + key)
1185
+ ? (task.keyPath =
1186
+ key === REACT_OPTIMISTIC_KEY || Component === REACT_OPTIMISTIC_KEY
1187
+ ? REACT_OPTIMISTIC_KEY
1188
+ : null === Component
1189
+ ? key
1190
+ : Component + "," + key)
1169
1191
  : null === Component && (task.implicitSlot = !0);
1170
1192
  request = renderModelDestructive(request, task, emptyRoot, "", props);
1171
1193
  task.keyPath = Component;
@@ -1197,10 +1219,7 @@ function deferTask(request, task) {
1197
1219
  return serializeLazyID(task.id);
1198
1220
  }
1199
1221
  function renderElement(request, task, type, key, ref, props) {
1200
- if (null !== ref && void 0 !== ref)
1201
- throw Error(
1202
- "Refs cannot be used in Server Components, nor passed to Client Components."
1203
- );
1222
+ if (null !== ref && void 0 !== ref) throw Error(formatProdErrorMessage(379));
1204
1223
  if (
1205
1224
  "function" === typeof type &&
1206
1225
  type.$$typeof !== CLIENT_REFERENCE_TAG$1 &&
@@ -1248,7 +1267,11 @@ function renderElement(request, task, type, key, ref, props) {
1248
1267
  key = task.keyPath;
1249
1268
  null === request
1250
1269
  ? (request = key)
1251
- : null !== key && (request = key + "," + request);
1270
+ : null !== key &&
1271
+ (request =
1272
+ key === REACT_OPTIMISTIC_KEY || request === REACT_OPTIMISTIC_KEY
1273
+ ? REACT_OPTIMISTIC_KEY
1274
+ : key + "," + request);
1252
1275
  props = [REACT_ELEMENT_TYPE, type, request, props];
1253
1276
  task = task.implicitSlot && null !== request ? [props] : props;
1254
1277
  return task;
@@ -1273,9 +1296,27 @@ function createTask(
1273
1296
  implicitSlot,
1274
1297
  formatContext,
1275
1298
  abortSet
1299
+ ) {
1300
+ return createTaskWithID(
1301
+ request,
1302
+ request.nextChunkId++,
1303
+ model,
1304
+ keyPath,
1305
+ implicitSlot,
1306
+ formatContext,
1307
+ abortSet
1308
+ );
1309
+ }
1310
+ function createTaskWithID(
1311
+ request,
1312
+ id,
1313
+ model,
1314
+ keyPath,
1315
+ implicitSlot,
1316
+ formatContext,
1317
+ abortSet
1276
1318
  ) {
1277
1319
  request.pendingChunks++;
1278
- var id = request.nextChunkId++;
1279
1320
  "object" !== typeof model ||
1280
1321
  null === model ||
1281
1322
  null !== keyPath ||
@@ -1291,83 +1332,125 @@ function createTask(
1291
1332
  ping: function () {
1292
1333
  return pingTask(request, task);
1293
1334
  },
1294
- toJSON: function (parentPropertyName, value) {
1295
- serializedSize += parentPropertyName.length;
1296
- var prevKeyPath = task.keyPath,
1297
- prevImplicitSlot = task.implicitSlot;
1298
- try {
1299
- var JSCompiler_inline_result = renderModelDestructive(
1300
- request,
1301
- task,
1302
- this,
1303
- parentPropertyName,
1304
- value
1305
- );
1306
- } catch (thrownValue) {
1307
- if (
1308
- ((parentPropertyName = task.model),
1309
- (parentPropertyName =
1310
- "object" === typeof parentPropertyName &&
1311
- null !== parentPropertyName &&
1312
- (parentPropertyName.$$typeof === REACT_ELEMENT_TYPE ||
1313
- parentPropertyName.$$typeof === REACT_LAZY_TYPE)),
1314
- 12 === request.status)
1315
- )
1316
- (task.status = 3),
1317
- 21 === request.type
1318
- ? ((prevKeyPath = request.nextChunkId++),
1319
- (prevKeyPath = parentPropertyName
1320
- ? serializeLazyID(prevKeyPath)
1321
- : serializeByValueID(prevKeyPath)),
1322
- (JSCompiler_inline_result = prevKeyPath))
1323
- : ((prevKeyPath = request.fatalError),
1324
- (JSCompiler_inline_result = parentPropertyName
1325
- ? serializeLazyID(prevKeyPath)
1326
- : serializeByValueID(prevKeyPath)));
1327
- else if (
1328
- ((value =
1329
- thrownValue === SuspenseException
1330
- ? getSuspendedThenable()
1331
- : thrownValue),
1332
- "object" === typeof value &&
1333
- null !== value &&
1334
- "function" === typeof value.then)
1335
- ) {
1336
- JSCompiler_inline_result = createTask(
1337
- request,
1338
- task.model,
1339
- task.keyPath,
1340
- task.implicitSlot,
1341
- task.formatContext,
1342
- request.abortableTasks
1343
- );
1344
- var ping = JSCompiler_inline_result.ping;
1345
- value.then(ping, ping);
1346
- JSCompiler_inline_result.thenableState =
1347
- getThenableStateAfterSuspending();
1348
- task.keyPath = prevKeyPath;
1349
- task.implicitSlot = prevImplicitSlot;
1350
- JSCompiler_inline_result = parentPropertyName
1351
- ? serializeLazyID(JSCompiler_inline_result.id)
1352
- : serializeByValueID(JSCompiler_inline_result.id);
1353
- } else
1354
- (task.keyPath = prevKeyPath),
1355
- (task.implicitSlot = prevImplicitSlot),
1356
- request.pendingChunks++,
1357
- (prevKeyPath = request.nextChunkId++),
1358
- (prevImplicitSlot = logRecoverableError(request, value, task)),
1359
- emitErrorChunk(request, prevKeyPath, prevImplicitSlot),
1360
- (JSCompiler_inline_result = parentPropertyName
1361
- ? serializeLazyID(prevKeyPath)
1362
- : serializeByValueID(prevKeyPath));
1363
- }
1364
- return JSCompiler_inline_result;
1365
- },
1366
1335
  thenableState: null
1367
1336
  };
1368
1337
  abortSet.add(task);
1369
1338
  return task;
1370
1339
  }
1340
+ function resolveModel(request, task, parent, parentPropertyName, value) {
1341
+ var jsonValue = value;
1342
+ null !== value &&
1343
+ "object" === typeof value &&
1344
+ "function" === typeof value.toJSON &&
1345
+ (jsonValue = value.toJSON(parentPropertyName));
1346
+ serializedSize += parentPropertyName.length;
1347
+ value = task.keyPath;
1348
+ var prevImplicitSlot = task.implicitSlot;
1349
+ try {
1350
+ var JSCompiler_inline_result = renderModelDestructive(
1351
+ request,
1352
+ task,
1353
+ parent,
1354
+ parentPropertyName,
1355
+ jsonValue
1356
+ );
1357
+ } catch (thrownValue) {
1358
+ (parent = task.model),
1359
+ (parent =
1360
+ "object" === typeof parent &&
1361
+ null !== parent &&
1362
+ (parent.$$typeof === REACT_ELEMENT_TYPE ||
1363
+ parent.$$typeof === REACT_LAZY_TYPE)),
1364
+ 12 === request.status
1365
+ ? ((task.status = 3),
1366
+ 21 === request.type
1367
+ ? ((value = request.nextChunkId++),
1368
+ (value = parent
1369
+ ? serializeLazyID(value)
1370
+ : serializeByValueID(value)),
1371
+ (JSCompiler_inline_result = value))
1372
+ : ((value = request.fatalError),
1373
+ (JSCompiler_inline_result = parent
1374
+ ? serializeLazyID(value)
1375
+ : serializeByValueID(value))))
1376
+ : ((parentPropertyName =
1377
+ thrownValue === SuspenseException
1378
+ ? getSuspendedThenable()
1379
+ : thrownValue),
1380
+ "object" === typeof parentPropertyName &&
1381
+ null !== parentPropertyName &&
1382
+ "function" === typeof parentPropertyName.then
1383
+ ? ((jsonValue = createTask(
1384
+ request,
1385
+ task.model,
1386
+ task.keyPath,
1387
+ task.implicitSlot,
1388
+ task.formatContext,
1389
+ request.abortableTasks
1390
+ )),
1391
+ (JSCompiler_inline_result = jsonValue.ping),
1392
+ parentPropertyName.then(
1393
+ JSCompiler_inline_result,
1394
+ JSCompiler_inline_result
1395
+ ),
1396
+ (jsonValue.thenableState = getThenableStateAfterSuspending()),
1397
+ (task.keyPath = value),
1398
+ (task.implicitSlot = prevImplicitSlot),
1399
+ (JSCompiler_inline_result = parent
1400
+ ? serializeLazyID(jsonValue.id)
1401
+ : serializeByValueID(jsonValue.id)))
1402
+ : ((task.keyPath = value),
1403
+ (task.implicitSlot = prevImplicitSlot),
1404
+ request.pendingChunks++,
1405
+ (value = request.nextChunkId++),
1406
+ (prevImplicitSlot = logRecoverableError(
1407
+ request,
1408
+ parentPropertyName,
1409
+ task
1410
+ )),
1411
+ emitErrorChunk(request, value, prevImplicitSlot),
1412
+ (JSCompiler_inline_result = parent
1413
+ ? serializeLazyID(value)
1414
+ : serializeByValueID(value))));
1415
+ }
1416
+ value = JSCompiler_inline_result;
1417
+ if (null === value || "object" !== typeof value) return value;
1418
+ if (isArrayImpl(value)) {
1419
+ var resolved$16 = [];
1420
+ for (
1421
+ prevImplicitSlot = 0;
1422
+ prevImplicitSlot < value.length;
1423
+ prevImplicitSlot++
1424
+ )
1425
+ resolved$16[prevImplicitSlot] = resolveModel(
1426
+ request,
1427
+ task,
1428
+ value,
1429
+ "" + prevImplicitSlot,
1430
+ value[prevImplicitSlot]
1431
+ );
1432
+ return resolved$16;
1433
+ }
1434
+ prevImplicitSlot = {};
1435
+ for (resolved$16 in value)
1436
+ hasOwnProperty.call(value, resolved$16) &&
1437
+ ((parent = resolveModel(
1438
+ request,
1439
+ task,
1440
+ value,
1441
+ resolved$16,
1442
+ value[resolved$16]
1443
+ )),
1444
+ "__proto__" === resolved$16
1445
+ ? Object.defineProperty(prevImplicitSlot, resolved$16, {
1446
+ value: parent,
1447
+ enumerable: !0,
1448
+ writable: !0,
1449
+ configurable: !0
1450
+ })
1451
+ : (prevImplicitSlot[resolved$16] = parent));
1452
+ return prevImplicitSlot;
1453
+ }
1371
1454
  function serializeByValueID(id) {
1372
1455
  return "$" + id.toString(16);
1373
1456
  }
@@ -1406,26 +1489,37 @@ function serializeClientReference(
1406
1489
  ((existingId = modulePath.slice(idx + 1)),
1407
1490
  (resolvedModuleData = config[modulePath.slice(0, idx)]));
1408
1491
  if (!resolvedModuleData)
1409
- throw Error(
1410
- 'Could not find the module "' +
1411
- modulePath +
1412
- '" in the React Client Manifest. This is probably a bug in the React Server Components bundler.'
1413
- );
1492
+ throw Error(formatProdErrorMessage(596, modulePath));
1414
1493
  }
1415
1494
  if (!0 === resolvedModuleData.async && !0 === clientReference.$$async)
1416
- throw Error(
1417
- 'The module "' +
1418
- modulePath +
1419
- '" is marked as an async ESM module but was loaded as a CJS proxy. This is probably a bug in the React Server Components bundler.'
1420
- );
1495
+ throw Error(formatProdErrorMessage(597, modulePath));
1421
1496
  var JSCompiler_inline_result =
1422
1497
  !0 === resolvedModuleData.async || !0 === clientReference.$$async
1423
1498
  ? [resolvedModuleData.id, resolvedModuleData.chunks, existingId, 1]
1424
1499
  : [resolvedModuleData.id, resolvedModuleData.chunks, existingId];
1500
+ var copy = transformImportMetadata(request, JSCompiler_inline_result, 0);
1501
+ if (copy !== NOT_PLAIN_IMPORT_METADATA)
1502
+ var JSCompiler_temp = stringify(copy);
1503
+ else
1504
+ b: {
1505
+ clientReference = importStringRequest;
1506
+ importStringRequest = request;
1507
+ try {
1508
+ JSCompiler_temp = stringify(
1509
+ JSCompiler_inline_result,
1510
+ importMetadataReplacer
1511
+ );
1512
+ break b;
1513
+ } finally {
1514
+ importStringRequest = clientReference;
1515
+ }
1516
+ JSCompiler_temp = void 0;
1517
+ }
1518
+ var JSCompiler_inline_result$jscomp$0 = JSCompiler_temp;
1425
1519
  request.pendingChunks++;
1426
1520
  var importId = request.nextChunkId++,
1427
- json = stringify(JSCompiler_inline_result),
1428
- row = importId.toString(16) + ":I" + json + "\n",
1521
+ row =
1522
+ importId.toString(16) + ":I" + JSCompiler_inline_result$jscomp$0 + "\n",
1429
1523
  processedChunk = stringToChunk(row);
1430
1524
  request.completedImportChunks.push(processedChunk);
1431
1525
  writtenClientReferences.set(clientReferenceKey, importId);
@@ -1498,6 +1592,27 @@ function serializeBlob(request, blob) {
1498
1592
  reader.read().then(progress).catch(error);
1499
1593
  return "$B" + newTask.id.toString(16);
1500
1594
  }
1595
+ function escapeStringValue(value) {
1596
+ return "$" === value[0] ? "$" + value : value;
1597
+ }
1598
+ function serializeImportString(request, value) {
1599
+ if (16 > value.length) return escapeStringValue(value);
1600
+ var writtenStrings = request.writtenImportStrings,
1601
+ existing = writtenStrings.get(value);
1602
+ if (void 0 !== existing) return existing;
1603
+ existing = request.writtenImportStringsSize + value.length;
1604
+ if (32768 < existing) return escapeStringValue(value);
1605
+ request.writtenImportStringsSize = existing;
1606
+ request.pendingChunks++;
1607
+ existing = request.nextChunkId++;
1608
+ var json = stringify(escapeStringValue(value));
1609
+ request.completedImportChunks.push(
1610
+ stringToChunk(existing.toString(16) + ":" + json + "\n")
1611
+ );
1612
+ request = serializeByValueID(existing);
1613
+ writtenStrings.set(value, request);
1614
+ return request;
1615
+ }
1501
1616
  var modelRoot = !1;
1502
1617
  function renderModelDestructive(
1503
1618
  request,
@@ -1546,14 +1661,18 @@ function renderModelDestructive(
1546
1661
  case REACT_LAZY_TYPE:
1547
1662
  if (3200 < serializedSize) return deferTask(request, task);
1548
1663
  task.thenableState = null;
1549
- parentPropertyName = value._init;
1550
- value = parentPropertyName(value._payload);
1664
+ elementReference = value._init;
1665
+ value = elementReference(value._payload);
1551
1666
  if (12 === request.status) throw null;
1552
- return renderModelDestructive(request, task, emptyRoot, "", value);
1553
- case REACT_LEGACY_ELEMENT_TYPE:
1554
- throw Error(
1555
- 'A React Element from an older version of React was rendered. This is not supported. It can happen if:\n- Multiple copies of the "react" package is used.\n- A library pre-bundled an old copy of "react" or "react/jsx-runtime".\n- A compiler tries to "inline" JSX instead of using the runtime.'
1667
+ return renderModelDestructive(
1668
+ request,
1669
+ task,
1670
+ parent,
1671
+ parentPropertyName,
1672
+ value
1556
1673
  );
1674
+ case REACT_LEGACY_ELEMENT_TYPE:
1675
+ throw Error(formatProdErrorMessage(525));
1557
1676
  }
1558
1677
  if (value.$$typeof === CLIENT_REFERENCE_TAG$1)
1559
1678
  return serializeClientReference(
@@ -1692,28 +1811,26 @@ function renderModelDestructive(
1692
1811
  (null === request || null !== getPrototypeOf(request))
1693
1812
  )
1694
1813
  throw Error(
1695
- "Only plain objects, and a few built-ins, can be passed to Client Components from Server Components. Classes or null prototypes are not supported." +
1814
+ formatProdErrorMessage(
1815
+ 498,
1696
1816
  describeObjectForErrorMessage(parent, parentPropertyName)
1817
+ )
1697
1818
  );
1698
1819
  return value;
1699
1820
  }
1700
- if ("string" === typeof value) {
1701
- serializedSize += value.length;
1702
- if (
1821
+ if ("string" === typeof value)
1822
+ return (
1823
+ (serializedSize += value.length),
1703
1824
  "Z" === value[value.length - 1] &&
1704
1825
  parent[parentPropertyName] instanceof Date
1705
- )
1706
- return "$D" + value;
1707
- if (1024 <= value.length && null !== byteLengthOfChunk)
1708
- return (
1709
- request.pendingChunks++,
1710
- (task = request.nextChunkId++),
1711
- emitTextChunk(request, task, value, !1),
1712
- serializeByValueID(task)
1713
- );
1714
- request = "$" === value[0] ? "$" + value : value;
1715
- return request;
1716
- }
1826
+ ? "$D" + value
1827
+ : 1024 <= value.length && null !== byteLengthOfChunk
1828
+ ? (request.pendingChunks++,
1829
+ (task = request.nextChunkId++),
1830
+ emitTextChunk(request, task, value, !1),
1831
+ serializeByValueID(task))
1832
+ : escapeStringValue(value)
1833
+ );
1717
1834
  if ("boolean" === typeof value) return value;
1718
1835
  if ("number" === typeof value)
1719
1836
  return Number.isFinite(value)
@@ -1760,18 +1877,19 @@ function renderModelDestructive(
1760
1877
  )
1761
1878
  return "$T" + request;
1762
1879
  if (value.$$typeof === TEMPORARY_REFERENCE_TAG)
1763
- throw Error(
1764
- "Could not reference an opaque temporary reference. This is likely due to misconfiguring the temporaryReferences options on the server."
1765
- );
1880
+ throw Error(formatProdErrorMessage(526));
1766
1881
  if (/^on[A-Z]/.test(parentPropertyName))
1767
1882
  throw Error(
1768
- "Event handlers cannot be passed to Client Component props." +
1769
- describeObjectForErrorMessage(parent, parentPropertyName) +
1770
- "\nIf you need interactivity, consider converting part of this to a Client Component."
1883
+ formatProdErrorMessage(
1884
+ 374,
1885
+ describeObjectForErrorMessage(parent, parentPropertyName)
1886
+ )
1771
1887
  );
1772
1888
  throw Error(
1773
- 'Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with "use server". Or maybe you meant to call this function rather than return it.' +
1889
+ formatProdErrorMessage(
1890
+ 375,
1774
1891
  describeObjectForErrorMessage(parent, parentPropertyName)
1892
+ )
1775
1893
  );
1776
1894
  }
1777
1895
  if ("symbol" === typeof value) {
@@ -1782,9 +1900,11 @@ function renderModelDestructive(
1782
1900
  elementReference = value.description;
1783
1901
  if (Symbol.for(elementReference) !== value)
1784
1902
  throw Error(
1785
- "Only global symbols received from Symbol.for(...) can be passed to Client Components. The symbol Symbol.for(" +
1786
- (value.description + ") cannot be found among global symbols.") +
1903
+ formatProdErrorMessage(
1904
+ 376,
1905
+ value.description,
1787
1906
  describeObjectForErrorMessage(parent, parentPropertyName)
1907
+ )
1788
1908
  );
1789
1909
  request.pendingChunks++;
1790
1910
  parentPropertyName = request.nextChunkId++;
@@ -1799,10 +1919,11 @@ function renderModelDestructive(
1799
1919
  }
1800
1920
  if ("bigint" === typeof value) return "$n" + value.toString(10);
1801
1921
  throw Error(
1802
- "Type " +
1803
- typeof value +
1804
- " is not supported in Client Component props." +
1922
+ formatProdErrorMessage(
1923
+ 378,
1924
+ typeof value,
1805
1925
  describeObjectForErrorMessage(parent, parentPropertyName)
1926
+ )
1806
1927
  );
1807
1928
  }
1808
1929
  function logRecoverableError(request, error) {
@@ -1828,9 +1949,8 @@ function fatalError(request, error) {
1828
1949
  null !== request.destination
1829
1950
  ? ((request.status = 14), closeWithError(request.destination, error))
1830
1951
  : ((request.status = 13), (request.fatalError = error));
1831
- request.cacheController.abort(
1832
- Error("The render was aborted due to a fatal error.", { cause: error })
1833
- );
1952
+ error = Error(formatProdErrorMessage(562), { cause: error });
1953
+ request.cacheController.abort(error);
1834
1954
  }
1835
1955
  function emitErrorChunk(request, id, digest) {
1836
1956
  digest = { digest: digest };
@@ -1838,6 +1958,69 @@ function emitErrorChunk(request, id, digest) {
1838
1958
  id = stringToChunk(id);
1839
1959
  request.completedErrorChunks.push(id);
1840
1960
  }
1961
+ var importStringRequest = null;
1962
+ function importMetadataReplacer(key, value) {
1963
+ return "string" === typeof value
1964
+ ? ((key = importStringRequest),
1965
+ null === key
1966
+ ? escapeStringValue(value)
1967
+ : serializeImportString(key, value))
1968
+ : value;
1969
+ }
1970
+ var NOT_PLAIN_IMPORT_METADATA = {};
1971
+ function transformImportMetadata(request, value, depth) {
1972
+ switch (typeof value) {
1973
+ case "string":
1974
+ return serializeImportString(request, value);
1975
+ case "number":
1976
+ case "boolean":
1977
+ case "undefined":
1978
+ return value;
1979
+ case "object":
1980
+ if (null === value) return null;
1981
+ if (16 < depth || "function" === typeof value.toJSON)
1982
+ return NOT_PLAIN_IMPORT_METADATA;
1983
+ if (isArrayImpl(value)) {
1984
+ for (
1985
+ var length = value.length, copy = Array(length), i = 0;
1986
+ i < length;
1987
+ i++
1988
+ ) {
1989
+ var element = value[i];
1990
+ if ("string" === typeof element)
1991
+ copy[i] = serializeImportString(request, element);
1992
+ else {
1993
+ element = transformImportMetadata(request, element, depth + 1);
1994
+ if (element === NOT_PLAIN_IMPORT_METADATA)
1995
+ return NOT_PLAIN_IMPORT_METADATA;
1996
+ copy[i] = element;
1997
+ }
1998
+ }
1999
+ return copy;
2000
+ }
2001
+ length = getPrototypeOf(value);
2002
+ if (length !== ObjectPrototype$1 && null !== length)
2003
+ return NOT_PLAIN_IMPORT_METADATA;
2004
+ length = Object.keys(value);
2005
+ copy = {};
2006
+ for (i = 0; i < length.length; i++) {
2007
+ element = length[i];
2008
+ if (element in ObjectPrototype$1) return NOT_PLAIN_IMPORT_METADATA;
2009
+ var element$25 = value[element];
2010
+ if ("string" === typeof element$25)
2011
+ copy[element] = serializeImportString(request, element$25);
2012
+ else {
2013
+ element$25 = transformImportMetadata(request, element$25, depth + 1);
2014
+ if (element$25 === NOT_PLAIN_IMPORT_METADATA)
2015
+ return NOT_PLAIN_IMPORT_METADATA;
2016
+ copy[element] = element$25;
2017
+ }
2018
+ }
2019
+ return copy;
2020
+ default:
2021
+ return NOT_PLAIN_IMPORT_METADATA;
2022
+ }
2023
+ }
1841
2024
  function emitModelChunk(request, id, json) {
1842
2025
  id = id.toString(16) + ":" + json + "\n";
1843
2026
  id = stringToChunk(id);
@@ -1854,7 +2037,11 @@ function emitTypedArrayChunk(request, id, tag, typedArray, debug) {
1854
2037
  debug = typedArray.byteLength;
1855
2038
  id = id.toString(16) + ":" + tag + debug.toString(16) + ",";
1856
2039
  id = stringToChunk(id);
1857
- request.completedRegularChunks.push(id, typedArray);
2040
+ request.completedRegularChunks.push(
2041
+ NEXT_TWO_CHUNKS_ARE_ATOMIC,
2042
+ id,
2043
+ typedArray
2044
+ );
1858
2045
  }
1859
2046
  function emitTextChunk(request, id, text, debug) {
1860
2047
  if (null === byteLengthOfChunk)
@@ -1866,7 +2053,7 @@ function emitTextChunk(request, id, text, debug) {
1866
2053
  debug = text.byteLength;
1867
2054
  id = id.toString(16) + ":T" + debug.toString(16) + ",";
1868
2055
  id = stringToChunk(id);
1869
- request.completedRegularChunks.push(id, text);
2056
+ request.completedRegularChunks.push(NEXT_TWO_CHUNKS_ARE_ATOMIC, id, text);
1870
2057
  }
1871
2058
  function emitChunk(request, task, value) {
1872
2059
  var id = task.id;
@@ -1898,7 +2085,14 @@ function emitChunk(request, task, value) {
1898
2085
  ? emitTypedArrayChunk(request, id, "m", value, !1)
1899
2086
  : value instanceof DataView
1900
2087
  ? emitTypedArrayChunk(request, id, "V", value, !1)
1901
- : ((value = stringify(value, task.toJSON)),
2088
+ : ((value = resolveModel(
2089
+ request,
2090
+ task,
2091
+ { "": value },
2092
+ "",
2093
+ value
2094
+ )),
2095
+ (value = stringify(value)),
1902
2096
  emitModelChunk(request, task.id, value));
1903
2097
  }
1904
2098
  function erroredTask(request, task, error) {
@@ -2030,9 +2224,28 @@ function flushCompletedChunks(request) {
2030
2224
  writeChunkAndReturn(destination, hintChunks[i]);
2031
2225
  hintChunks.splice(0, i);
2032
2226
  var regularChunks = request.completedRegularChunks;
2033
- for (i = 0; i < regularChunks.length; i++)
2034
- request.pendingChunks--,
2035
- writeChunkAndReturn(destination, regularChunks[i]);
2227
+ for (i = 0; i < regularChunks.length; i++) {
2228
+ var item = regularChunks[i];
2229
+ importsChunks = void 0;
2230
+ if (item === NEXT_TWO_CHUNKS_ARE_ATOMIC) {
2231
+ if (i + 2 >= regularChunks.length)
2232
+ throw Error(formatProdErrorMessage(601));
2233
+ request.pendingChunks -= 2;
2234
+ writeChunk(destination, regularChunks[i + 1]);
2235
+ importsChunks = writeChunkAndReturn(
2236
+ destination,
2237
+ regularChunks[i + 2]
2238
+ );
2239
+ i += 2;
2240
+ } else
2241
+ request.pendingChunks--,
2242
+ (importsChunks = writeChunkAndReturn(destination, item));
2243
+ if (!importsChunks) {
2244
+ request.destination = null;
2245
+ i++;
2246
+ break;
2247
+ }
2248
+ }
2036
2249
  regularChunks.splice(0, i);
2037
2250
  var errorChunks = request.completedErrorChunks;
2038
2251
  for (i = 0; i < errorChunks.length; i++)
@@ -2052,11 +2265,8 @@ function flushCompletedChunks(request) {
2052
2265
  }
2053
2266
  0 === request.pendingChunks &&
2054
2267
  (12 > request.status &&
2055
- request.cacheController.abort(
2056
- Error(
2057
- "This render completed successfully. All cacheSignals are now aborted to allow clean up of any unused resources."
2058
- )
2059
- ),
2268
+ ((destination = Error(formatProdErrorMessage(563))),
2269
+ request.cacheController.abort(destination)),
2060
2270
  null !== request.destination &&
2061
2271
  ((request.status = 14),
2062
2272
  request.destination.close(),
@@ -2121,6 +2331,17 @@ function finishAbort(request, abortedTasks, errorId) {
2121
2331
  logRecoverableError(request, error, null), fatalError(request, error);
2122
2332
  }
2123
2333
  }
2334
+ function attachAbortSignal(request, signal) {
2335
+ signal.aborted
2336
+ ? abort(request, signal.reason)
2337
+ : signal.addEventListener(
2338
+ "abort",
2339
+ function () {
2340
+ abort(request, signal.reason);
2341
+ },
2342
+ { signal: request.cacheController.signal }
2343
+ );
2344
+ }
2124
2345
  function abort(request, reason) {
2125
2346
  if (!(11 < request.status))
2126
2347
  try {
@@ -2138,15 +2359,11 @@ function abort(request, reason) {
2138
2359
  else {
2139
2360
  var error =
2140
2361
  void 0 === reason
2141
- ? Error(
2142
- "The render was aborted by the server without a reason."
2143
- )
2362
+ ? Error(formatProdErrorMessage(432))
2144
2363
  : "object" === typeof reason &&
2145
2364
  null !== reason &&
2146
2365
  "function" === typeof reason.then
2147
- ? Error(
2148
- "The render was aborted by the server with a promise."
2149
- )
2366
+ ? Error(formatProdErrorMessage(530))
2150
2367
  : reason,
2151
2368
  digest = logRecoverableError(request, error, null),
2152
2369
  errorId = request.nextChunkId++;
@@ -2165,9 +2382,9 @@ function abort(request, reason) {
2165
2382
  onAllReady();
2166
2383
  flushCompletedChunks(request);
2167
2384
  }
2168
- } catch (error$26) {
2169
- logRecoverableError(request, error$26, null),
2170
- fatalError(request, error$26);
2385
+ } catch (error$32) {
2386
+ logRecoverableError(request, error$32, null),
2387
+ fatalError(request, error$32);
2171
2388
  }
2172
2389
  }
2173
2390
  function resolveServerReference(bundlerConfig, id) {
@@ -2179,12 +2396,7 @@ function resolveServerReference(bundlerConfig, id) {
2179
2396
  -1 !== idx &&
2180
2397
  ((name = id.slice(idx + 1)),
2181
2398
  (resolvedModuleData = bundlerConfig[id.slice(0, idx)]));
2182
- if (!resolvedModuleData)
2183
- throw Error(
2184
- 'Could not find the module "' +
2185
- id +
2186
- '" in the React Server Manifest. This is probably a bug in the React Server Components bundler.'
2187
- );
2399
+ if (!resolvedModuleData) throw Error(formatProdErrorMessage(589, id));
2188
2400
  }
2189
2401
  return resolvedModuleData.async
2190
2402
  ? [resolvedModuleData.id, resolvedModuleData.chunks, name, 1]
@@ -2259,50 +2471,56 @@ function ReactPromise(status, value, reason) {
2259
2471
  this.reason = reason;
2260
2472
  }
2261
2473
  ReactPromise.prototype = Object.create(Promise.prototype);
2262
- ReactPromise.prototype.then = function (resolve, reject) {
2263
- switch (this.status) {
2264
- case "resolved_model":
2265
- initializeModelChunk(this);
2266
- }
2267
- switch (this.status) {
2268
- case "fulfilled":
2269
- if ("function" === typeof resolve) {
2270
- for (
2271
- var inspectedValue = this.value,
2272
- cycleProtection = 0,
2273
- visited = new Set();
2274
- inspectedValue instanceof ReactPromise;
2474
+ Object.defineProperty(ReactPromise.prototype, "then", {
2475
+ writable: !0,
2476
+ enumerable: !0,
2477
+ configurable: !0,
2478
+ value: function (resolve, reject) {
2479
+ switch (this.status) {
2480
+ case "resolved_model":
2481
+ initializeModelChunk(this);
2482
+ }
2483
+ switch (this.status) {
2484
+ case "fulfilled":
2485
+ if ("function" === typeof resolve) {
2486
+ for (
2487
+ var inspectedValue = this.value,
2488
+ cycleProtection = 0,
2489
+ visited = new Set();
2490
+ inspectedValue instanceof ReactPromise;
2275
2491
 
2276
- ) {
2277
- cycleProtection++;
2278
- if (
2279
- inspectedValue === this ||
2280
- visited.has(inspectedValue) ||
2281
- 1e3 < cycleProtection
2282
2492
  ) {
2283
- "function" === typeof reject &&
2284
- reject(Error("Cannot have cyclic thenables."));
2285
- return;
2493
+ cycleProtection++;
2494
+ if (
2495
+ inspectedValue === this ||
2496
+ visited.has(inspectedValue) ||
2497
+ 1e3 < cycleProtection
2498
+ ) {
2499
+ "function" === typeof reject &&
2500
+ reject(Error(formatProdErrorMessage(569)));
2501
+ return;
2502
+ }
2503
+ visited.add(inspectedValue);
2504
+ if ("fulfilled" === inspectedValue.status)
2505
+ inspectedValue = inspectedValue.value;
2506
+ else break;
2286
2507
  }
2287
- visited.add(inspectedValue);
2288
- if ("fulfilled" === inspectedValue.status)
2289
- inspectedValue = inspectedValue.value;
2290
- else break;
2508
+ resolve(this.value);
2291
2509
  }
2292
- resolve(this.value);
2293
- }
2294
- break;
2295
- case "pending":
2296
- case "blocked":
2297
- "function" === typeof resolve &&
2298
- (null === this.value && (this.value = []), this.value.push(resolve));
2299
- "function" === typeof reject &&
2300
- (null === this.reason && (this.reason = []), this.reason.push(reject));
2301
- break;
2302
- default:
2303
- "function" === typeof reject && reject(this.reason);
2510
+ break;
2511
+ case "pending":
2512
+ case "blocked":
2513
+ "function" === typeof resolve &&
2514
+ (null === this.value && (this.value = []), this.value.push(resolve));
2515
+ "function" === typeof reject &&
2516
+ (null === this.reason && (this.reason = []),
2517
+ this.reason.push(reject));
2518
+ break;
2519
+ default:
2520
+ "function" === typeof reject && reject(this.reason);
2521
+ }
2304
2522
  }
2305
- };
2523
+ });
2306
2524
  var ObjectPrototype = Object.prototype,
2307
2525
  ArrayPrototype = Array.prototype;
2308
2526
  function wakeChunk(response, listeners, value, chunk) {
@@ -2341,6 +2559,9 @@ function createResolvedModelChunk(response, value, id) {
2341
2559
  $jscomp$compprop2)
2342
2560
  );
2343
2561
  }
2562
+ function createErroredChunk(response, reason) {
2563
+ return new ReactPromise("rejected", null, reason);
2564
+ }
2344
2565
  function resolveModelChunk(response, chunk, value, id) {
2345
2566
  if ("pending" !== chunk.status)
2346
2567
  (chunk = chunk.reason),
@@ -2443,7 +2664,9 @@ function loadServerReference$1(response, metaData, parentObject, key) {
2443
2664
  (cachedPromise = requireModule(serverReference)),
2444
2665
  (id = blockedPromise),
2445
2666
  (id.status = "fulfilled"),
2446
- (id.value = cachedPromise)
2667
+ (id.value = cachedPromise),
2668
+ (id.reason = null),
2669
+ cachedPromise
2447
2670
  );
2448
2671
  if (initializingHandler) {
2449
2672
  var handler = initializingHandler;
@@ -2462,13 +2685,7 @@ function loadServerReference$1(response, metaData, parentObject, key) {
2462
2685
  var promiseValue = metaData.bound.value;
2463
2686
  promiseValue = isArrayImpl(promiseValue) ? promiseValue.slice(0) : [];
2464
2687
  if (1e3 < promiseValue.length) {
2465
- reject(
2466
- Error(
2467
- "Server Function has too many bound arguments. Received " +
2468
- promiseValue.length +
2469
- " but the limit is 1000."
2470
- )
2471
- );
2688
+ reject(Error(formatProdErrorMessage(580, promiseValue.length, 1e3)));
2472
2689
  return;
2473
2690
  }
2474
2691
  promiseValue.unshift(null);
@@ -2551,9 +2768,7 @@ function bumpArrayCount(arrayContext, slots, response) {
2551
2768
  (arrayContext.count += slots) > response._arraySizeLimit &&
2552
2769
  arrayContext.fork
2553
2770
  )
2554
- throw Error(
2555
- "Maximum array nesting exceeded. Large nested arrays can be dangerous. Try adding intermediate objects."
2556
- );
2771
+ throw Error(formatProdErrorMessage(571));
2557
2772
  }
2558
2773
  var initializingHandler = null;
2559
2774
  function initializeModelChunk(chunk) {
@@ -2629,7 +2844,7 @@ function getChunk(response, id) {
2629
2844
  "string" === typeof chunk
2630
2845
  ? createResolvedModelChunk(response, chunk, id)
2631
2846
  : response._closed
2632
- ? new ReactPromise("rejected", null, response._closedReason)
2847
+ ? createErroredChunk(response, response._closedReason)
2633
2848
  : new ReactPromise("pending", null, null)),
2634
2849
  chunks.set(id, chunk));
2635
2850
  return chunk;
@@ -2656,7 +2871,7 @@ function fulfillReference(response, reference, value, arrayRoot) {
2656
2871
  getPrototypeOf(value) !== ArrayPrototype) ||
2657
2872
  !hasOwnProperty.call(value, name)
2658
2873
  )
2659
- throw Error("Invalid reference.");
2874
+ throw Error(formatProdErrorMessage(570));
2660
2875
  value = value[name];
2661
2876
  if (isArrayImpl(value))
2662
2877
  (localLength = 0),
@@ -2726,9 +2941,7 @@ function getOutlinedModel(
2726
2941
  id = chunk.value;
2727
2942
  chunk = chunk.reason;
2728
2943
  if (null !== chunk && "error" in chunk)
2729
- throw Error(
2730
- "Expected an initialized chunk but got an initialized stream chunk instead. This payload may have been submitted by an older version of React."
2731
- );
2944
+ throw Error(formatProdErrorMessage(599));
2732
2945
  for (
2733
2946
  var localLength = 0,
2734
2947
  rootArrayContexts = response._rootArrayContexts,
@@ -2744,7 +2957,7 @@ function getOutlinedModel(
2744
2957
  getPrototypeOf(id) !== ArrayPrototype) ||
2745
2958
  !hasOwnProperty.call(id, localLength)
2746
2959
  )
2747
- throw Error("Invalid reference.");
2960
+ throw Error(formatProdErrorMessage(570));
2748
2961
  id = id[localLength];
2749
2962
  isArrayImpl(id)
2750
2963
  ? ((localLength = 0), (chunk = rootArrayContexts.get(id) || chunk))
@@ -2790,7 +3003,7 @@ function getOutlinedModel(
2790
3003
  null
2791
3004
  );
2792
3005
  case "pending":
2793
- throw Error("Invalid forward reference.");
3006
+ throw Error(formatProdErrorMessage(574));
2794
3007
  default:
2795
3008
  return (
2796
3009
  initializingHandler
@@ -2809,20 +3022,20 @@ function getOutlinedModel(
2809
3022
  }
2810
3023
  }
2811
3024
  function createMap(response, model) {
2812
- if (!isArrayImpl(model)) throw Error("Invalid Map initializer.");
2813
- if (!0 === model.$$consumed) throw Error("Already initialized Map.");
3025
+ if (!isArrayImpl(model)) throw Error(formatProdErrorMessage(575));
3026
+ if (!0 === model.$$consumed) throw Error(formatProdErrorMessage(572));
2814
3027
  model.$$consumed = !0;
2815
3028
  return new Map(model);
2816
3029
  }
2817
3030
  function createSet(response, model) {
2818
- if (!isArrayImpl(model)) throw Error("Invalid Set initializer.");
2819
- if (!0 === model.$$consumed) throw Error("Already initialized Set.");
3031
+ if (!isArrayImpl(model)) throw Error(formatProdErrorMessage(576));
3032
+ if (!0 === model.$$consumed) throw Error(formatProdErrorMessage(573));
2820
3033
  model.$$consumed = !0;
2821
3034
  return new Set(model);
2822
3035
  }
2823
3036
  function extractIterator(response, model) {
2824
- if (!isArrayImpl(model)) throw Error("Invalid Iterator initializer.");
2825
- if (!0 === model.$$consumed) throw Error("Already initialized Iterator.");
3037
+ if (!isArrayImpl(model)) throw Error(formatProdErrorMessage(577));
3038
+ if (!0 === model.$$consumed) throw Error(formatProdErrorMessage(578));
2826
3039
  model.$$consumed = !0;
2827
3040
  return model[Symbol.iterator]();
2828
3041
  }
@@ -2852,15 +3065,10 @@ function parseTypedArray(
2852
3065
  reference = parseInt(reference.slice(2), 16);
2853
3066
  var key = response._prefix + reference;
2854
3067
  bytesPerElement = response._chunks;
2855
- if (bytesPerElement.has(reference))
2856
- throw Error("Already initialized typed array.");
3068
+ if (bytesPerElement.has(reference)) throw Error(formatProdErrorMessage(568));
2857
3069
  bytesPerElement.set(
2858
3070
  reference,
2859
- new ReactPromise(
2860
- "rejected",
2861
- null,
2862
- Error("Already initialized typed array.")
2863
- )
3071
+ createErroredChunk(response, Error(formatProdErrorMessage(568)))
2864
3072
  );
2865
3073
  reference = response._formData.data.get(key).arrayBuffer();
2866
3074
  if (initializingHandler) {
@@ -2918,11 +3126,10 @@ function parseReadableStream(response, reference, type) {
2918
3126
  function enqueue(value) {
2919
3127
  "bytes" !== type || ArrayBuffer.isView(value)
2920
3128
  ? controller.enqueue(value)
2921
- : flightController.error(Error("Invalid data for bytes stream."));
3129
+ : flightController.error(Error(formatProdErrorMessage(579)));
2922
3130
  }
2923
3131
  reference = parseInt(reference.slice(2), 16);
2924
- if (response._chunks.has(reference))
2925
- throw Error("Already initialized stream.");
3132
+ if (response._chunks.has(reference)) throw Error(formatProdErrorMessage(567));
2926
3133
  var controller = null,
2927
3134
  closed = !1,
2928
3135
  stream = new ReadableStream({
@@ -2943,12 +3150,12 @@ function parseReadableStream(response, reference, type) {
2943
3150
  (previousBlockedChunk = chunk));
2944
3151
  } else {
2945
3152
  chunk = previousBlockedChunk;
2946
- var chunk$31 = new ReactPromise("pending", null, null);
2947
- chunk$31.then(enqueue, flightController.error);
2948
- previousBlockedChunk = chunk$31;
3153
+ var chunk$37 = new ReactPromise("pending", null, null);
3154
+ chunk$37.then(enqueue, flightController.error);
3155
+ previousBlockedChunk = chunk$37;
2949
3156
  chunk.then(function () {
2950
- previousBlockedChunk === chunk$31 && (previousBlockedChunk = null);
2951
- resolveModelChunk(response, chunk$31, json, -1);
3157
+ previousBlockedChunk === chunk$37 && (previousBlockedChunk = null);
3158
+ resolveModelChunk(response, chunk$37, json, -1);
2952
3159
  });
2953
3160
  }
2954
3161
  },
@@ -2989,8 +3196,7 @@ FlightIterator.prototype[ASYNC_ITERATOR] = function () {
2989
3196
  };
2990
3197
  function parseAsyncIterable(response, reference, iterator) {
2991
3198
  reference = parseInt(reference.slice(2), 16);
2992
- if (response._chunks.has(reference))
2993
- throw Error("Already initialized stream.");
3199
+ if (response._chunks.has(reference)) throw Error(formatProdErrorMessage(567));
2994
3200
  var buffer = [],
2995
3201
  closed = !1,
2996
3202
  nextWriteIndex = 0,
@@ -2999,10 +3205,7 @@ function parseAsyncIterable(response, reference, iterator) {
2999
3205
  (($jscomp$compprop5[ASYNC_ITERATOR] = function () {
3000
3206
  var nextReadIndex = 0;
3001
3207
  return new FlightIterator(function (arg) {
3002
- if (void 0 !== arg)
3003
- throw Error(
3004
- "Values cannot be passed to next() of AsyncIterables passed to Client Components."
3005
- );
3208
+ if (void 0 !== arg) throw Error(formatProdErrorMessage(524));
3006
3209
  if (nextReadIndex === buffer.length) {
3007
3210
  if (closed)
3008
3211
  return new ReactPromise(
@@ -3103,9 +3306,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3103
3306
  );
3104
3307
  case "T":
3105
3308
  if (void 0 === reference || void 0 === response._temporaryReferences)
3106
- throw Error(
3107
- "Could not reference an opaque temporary reference. This is likely due to misconfiguring the temporaryReferences options on the server."
3108
- );
3309
+ throw Error(formatProdErrorMessage(526));
3109
3310
  return createTemporaryReference(
3110
3311
  response._temporaryReferences,
3111
3312
  reference
@@ -3164,11 +3365,7 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3164
3365
  case "n":
3165
3366
  obj = value.slice(2);
3166
3367
  if (300 < obj.length)
3167
- throw Error(
3168
- "BigInt is too large. Received " +
3169
- obj.length +
3170
- " digits but the limit is 300."
3171
- );
3368
+ throw Error(formatProdErrorMessage(581, obj.length, 300));
3172
3369
  null !== arrayRoot && bumpArrayCount(arrayRoot, obj.length, response);
3173
3370
  return BigInt(obj);
3174
3371
  case "A":
@@ -3302,10 +3499,11 @@ function parseModelString(response, obj, key, value, reference, arrayRoot) {
3302
3499
  arrayRoot
3303
3500
  );
3304
3501
  case "B":
3305
- return (
3306
- (obj = parseInt(value.slice(2), 16)),
3307
- response._formData.data.get(response._prefix + obj)
3308
- );
3502
+ obj = parseInt(value.slice(2), 16);
3503
+ response = response._formData.data.get(response._prefix + obj);
3504
+ if (!(response instanceof Blob))
3505
+ throw Error(formatProdErrorMessage(582));
3506
+ return response;
3309
3507
  case "R":
3310
3508
  return parseReadableStream(response, value, void 0);
3311
3509
  case "r":
@@ -3341,9 +3539,6 @@ function createResponse(bundlerConfig, formFieldPrefix, temporaryReferences) {
3341
3539
  _arraySizeLimit: arraySizeLimit
3342
3540
  };
3343
3541
  }
3344
- function close(response) {
3345
- reportGlobalError(response, Error("Connection closed."));
3346
- }
3347
3542
  function loadServerReference(bundlerConfig, metaData) {
3348
3543
  var id = metaData.id;
3349
3544
  if ("string" !== typeof id) return null;
@@ -3355,11 +3550,7 @@ function loadServerReference(bundlerConfig, metaData) {
3355
3550
  _ref = _ref[0];
3356
3551
  var fn = requireModule(serverReference);
3357
3552
  if (1e3 < _ref.length)
3358
- throw Error(
3359
- "Server Function has too many bound arguments. Received " +
3360
- _ref.length +
3361
- " but the limit is 1000."
3362
- );
3553
+ throw Error(formatProdErrorMessage(580, _ref.length, 1e3));
3363
3554
  return fn.bind.apply(fn, [null].concat(_ref));
3364
3555
  })
3365
3556
  : bundlerConfig
@@ -3381,7 +3572,7 @@ function decodeBoundActionMetaData(
3381
3572
  body,
3382
3573
  arraySizeLimit
3383
3574
  );
3384
- close(body);
3575
+ reportGlobalError(body, Error(formatProdErrorMessage(412)));
3385
3576
  body = getChunk(body, 0);
3386
3577
  body.then(function () {});
3387
3578
  if ("fulfilled" !== body.status) throw body.reason;
@@ -3414,7 +3605,7 @@ exports.decodeAction = function (body, serverManifest) {
3414
3605
  else if (actionKey.startsWith("$ACTION_ID_"))
3415
3606
  (body = actionKey.slice(11)),
3416
3607
  (action = loadServerReference(serverManifest, { id: body, bound: null }));
3417
- else throw Error("Cannot handle action key. This is a bug in React.");
3608
+ else throw Error(formatProdErrorMessage(602));
3418
3609
  return action.then(function (fn) {
3419
3610
  return fn.bind(null, formData);
3420
3611
  });
@@ -3450,7 +3641,7 @@ exports.decodeReply = function (body, webpackMap, options) {
3450
3641
  options ? options.arraySizeLimit : void 0
3451
3642
  );
3452
3643
  webpackMap = getChunk(body, 0);
3453
- close(body);
3644
+ reportGlobalError(body, Error(formatProdErrorMessage(412)));
3454
3645
  return webpackMap;
3455
3646
  };
3456
3647
  exports.prerender = function (model, webpackMap, options) {
@@ -3460,7 +3651,6 @@ exports.prerender = function (model, webpackMap, options) {
3460
3651
  model,
3461
3652
  webpackMap,
3462
3653
  options ? options.onError : void 0,
3463
- options ? options.onPostpone : void 0,
3464
3654
  function () {
3465
3655
  var stream = new ReadableStream(
3466
3656
  {
@@ -3481,17 +3671,7 @@ exports.prerender = function (model, webpackMap, options) {
3481
3671
  options ? options.identifierPrefix : void 0,
3482
3672
  options ? options.temporaryReferences : void 0
3483
3673
  );
3484
- if (options && options.signal) {
3485
- var signal = options.signal;
3486
- if (signal.aborted) abort(request, signal.reason);
3487
- else {
3488
- var listener = function () {
3489
- abort(request, signal.reason);
3490
- signal.removeEventListener("abort", listener);
3491
- };
3492
- signal.addEventListener("abort", listener);
3493
- }
3494
- }
3674
+ options && options.signal && attachAbortSignal(request, options.signal);
3495
3675
  startWork(request);
3496
3676
  });
3497
3677
  };
@@ -3524,23 +3704,12 @@ exports.renderToReadableStream = function (model, webpackMap, options) {
3524
3704
  model,
3525
3705
  webpackMap,
3526
3706
  options ? options.onError : void 0,
3527
- options ? options.onPostpone : void 0,
3528
3707
  noop,
3529
3708
  noop,
3530
3709
  options ? options.identifierPrefix : void 0,
3531
3710
  options ? options.temporaryReferences : void 0
3532
3711
  );
3533
- if (options && options.signal) {
3534
- var signal = options.signal;
3535
- if (signal.aborted) abort(request, signal.reason);
3536
- else {
3537
- var listener = function () {
3538
- abort(request, signal.reason);
3539
- signal.removeEventListener("abort", listener);
3540
- };
3541
- signal.addEventListener("abort", listener);
3542
- }
3543
- }
3712
+ options && options.signal && attachAbortSignal(request, options.signal);
3544
3713
  return new ReadableStream(
3545
3714
  {
3546
3715
  type: "bytes",