react-server-dom-webpack 19.0.0-rc.0 → 19.0.0

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 (28) hide show
  1. package/cjs/react-server-dom-webpack-client.browser.development.js +2483 -3269
  2. package/cjs/react-server-dom-webpack-client.browser.production.js +420 -215
  3. package/cjs/react-server-dom-webpack-client.edge.development.js +2656 -3546
  4. package/cjs/react-server-dom-webpack-client.edge.production.js +424 -218
  5. package/cjs/react-server-dom-webpack-client.node.development.js +2693 -3498
  6. package/cjs/react-server-dom-webpack-client.node.production.js +546 -263
  7. package/cjs/react-server-dom-webpack-client.node.unbundled.development.js +2638 -3434
  8. package/cjs/react-server-dom-webpack-client.node.unbundled.production.js +526 -257
  9. package/cjs/react-server-dom-webpack-plugin.js +11 -11
  10. package/cjs/react-server-dom-webpack-server.browser.development.js +3700 -5229
  11. package/cjs/react-server-dom-webpack-server.browser.production.js +447 -276
  12. package/cjs/react-server-dom-webpack-server.edge.development.js +3730 -5241
  13. package/cjs/react-server-dom-webpack-server.edge.production.js +435 -283
  14. package/cjs/react-server-dom-webpack-server.node.development.js +3794 -5384
  15. package/cjs/react-server-dom-webpack-server.node.production.js +428 -289
  16. package/cjs/react-server-dom-webpack-server.node.unbundled.development.js +3756 -5310
  17. package/cjs/react-server-dom-webpack-server.node.unbundled.production.js +421 -284
  18. package/esm/react-server-dom-webpack-node-loader.production.js +238 -44
  19. package/package.json +27 -4
  20. package/server.browser.js +12 -2
  21. package/server.edge.js +12 -2
  22. package/server.node.js +13 -2
  23. package/server.node.unbundled.js +13 -2
  24. package/static.browser.js +12 -0
  25. package/static.edge.js +12 -0
  26. package/static.js +6 -0
  27. package/static.node.js +12 -0
  28. package/static.node.unbundled.js +12 -0
@@ -11,6 +11,30 @@
11
11
  "use strict";
12
12
  var ReactDOM = require("react-dom"),
13
13
  React = require("react"),
14
+ channel = new MessageChannel(),
15
+ taskQueue = [];
16
+ channel.port1.onmessage = function () {
17
+ var task = taskQueue.shift();
18
+ task && task();
19
+ };
20
+ function scheduleWork(callback) {
21
+ taskQueue.push(callback);
22
+ channel.port2.postMessage(null);
23
+ }
24
+ function handleErrorInNextTick(error) {
25
+ setTimeout(function () {
26
+ throw error;
27
+ });
28
+ }
29
+ var LocalPromise = Promise,
30
+ scheduleMicrotask =
31
+ "function" === typeof queueMicrotask
32
+ ? queueMicrotask
33
+ : function (callback) {
34
+ LocalPromise.resolve(null)
35
+ .then(callback)
36
+ .catch(handleErrorInNextTick);
37
+ },
14
38
  currentView = null,
15
39
  writtenBytes = 0;
16
40
  function writeChunkAndReturn(destination, chunk) {
@@ -42,6 +66,9 @@ var textEncoder = new TextEncoder();
42
66
  function stringToChunk(content) {
43
67
  return textEncoder.encode(content);
44
68
  }
69
+ function byteLengthOfChunk(chunk) {
70
+ return chunk.byteLength;
71
+ }
45
72
  function closeWithError(destination, error) {
46
73
  "function" === typeof destination.error
47
74
  ? destination.error(error)
@@ -61,12 +88,15 @@ var FunctionBind = Function.prototype.bind,
61
88
  function bind() {
62
89
  var newFn = FunctionBind.apply(this, arguments);
63
90
  if (this.$$typeof === SERVER_REFERENCE_TAG) {
64
- var args = ArraySlice.call(arguments, 1);
91
+ var args = ArraySlice.call(arguments, 1),
92
+ $$typeof = { value: SERVER_REFERENCE_TAG },
93
+ $$id = { value: this.$$id };
94
+ args = { value: this.$$bound ? this.$$bound.concat(args) : args };
65
95
  return Object.defineProperties(newFn, {
66
- $$typeof: { value: SERVER_REFERENCE_TAG },
67
- $$id: { value: this.$$id },
68
- $$bound: { value: this.$$bound ? this.$$bound.concat(args) : args },
69
- bind: { value: bind }
96
+ $$typeof: $$typeof,
97
+ $$id: $$id,
98
+ $$bound: args,
99
+ bind: { value: bind, configurable: !0 }
70
100
  });
71
101
  }
72
102
  return newFn;
@@ -97,6 +127,10 @@ var PROMISE_PROTOTYPE = Promise.prototype,
97
127
  throw Error(
98
128
  "Cannot render a Client Context Provider on the Server. Instead, you can export a Client Component wrapper that itself renders a Client Context Provider."
99
129
  );
130
+ case "then":
131
+ throw Error(
132
+ "Cannot await or return from a thenable. You cannot await a client module from a server component."
133
+ );
100
134
  }
101
135
  throw Error(
102
136
  "Cannot access " +
@@ -295,8 +329,8 @@ function preinitStyle(href, precedence, options) {
295
329
  options
296
330
  ])
297
331
  : "string" === typeof precedence
298
- ? emitHint(request, "S", [href, precedence])
299
- : emitHint(request, "S", href);
332
+ ? emitHint(request, "S", [href, precedence])
333
+ : emitHint(request, "S", href);
300
334
  }
301
335
  previousDispatcher.S(href, precedence, options);
302
336
  }
@@ -412,12 +446,12 @@ var ASYNC_ITERATOR = Symbol.asyncIterator,
412
446
  SuspenseException = Error(
413
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`"
414
448
  );
415
- function noop() {}
449
+ function noop$1() {}
416
450
  function trackUsedThenable(thenableState, thenable, index) {
417
451
  index = thenableState[index];
418
452
  void 0 === index
419
453
  ? thenableState.push(thenable)
420
- : index !== thenable && (thenable.then(noop, noop), (thenable = index));
454
+ : index !== thenable && (thenable.then(noop$1, noop$1), (thenable = index));
421
455
  switch (thenable.status) {
422
456
  case "fulfilled":
423
457
  return thenable.value;
@@ -425,7 +459,7 @@ function trackUsedThenable(thenableState, thenable, index) {
425
459
  throw thenable.reason;
426
460
  default:
427
461
  "string" === typeof thenable.status
428
- ? thenable.then(noop, noop)
462
+ ? thenable.then(noop$1, noop$1)
429
463
  : ((thenableState = thenable),
430
464
  (thenableState.status = "pending"),
431
465
  thenableState.then(
@@ -552,7 +586,13 @@ var DefaultAsyncDispatcher = {
552
586
  return entry;
553
587
  }
554
588
  },
555
- isArrayImpl = Array.isArray,
589
+ ReactSharedInternalsServer =
590
+ React.__SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
591
+ if (!ReactSharedInternalsServer)
592
+ throw Error(
593
+ '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.'
594
+ );
595
+ var isArrayImpl = Array.isArray,
556
596
  getPrototypeOf = Object.getPrototypeOf;
557
597
  function objectName(object) {
558
598
  return Object.prototype.toString
@@ -577,8 +617,8 @@ function describeValueForErrorMessage(value) {
577
617
  return value.$$typeof === CLIENT_REFERENCE_TAG
578
618
  ? "client"
579
619
  : (value = value.displayName || value.name)
580
- ? "function " + value
581
- : "function";
620
+ ? "function " + value
621
+ : "function";
582
622
  default:
583
623
  return String(value);
584
624
  }
@@ -659,30 +699,28 @@ function describeObjectForErrorMessage(objectOrArray, expandedName) {
659
699
  return void 0 === expandedName
660
700
  ? str
661
701
  : -1 < objKind && 0 < length
662
- ? ((objectOrArray = " ".repeat(objKind) + "^".repeat(length)),
663
- "\n " + str + "\n " + objectOrArray)
664
- : "\n " + str;
702
+ ? ((objectOrArray = " ".repeat(objKind) + "^".repeat(length)),
703
+ "\n " + str + "\n " + objectOrArray)
704
+ : "\n " + str;
665
705
  }
666
- var ReactSharedInternalsServer =
667
- React.__SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
668
- if (!ReactSharedInternalsServer)
669
- throw Error(
670
- '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.'
671
- );
672
706
  var ObjectPrototype = Object.prototype,
673
707
  stringify = JSON.stringify;
674
708
  function defaultErrorHandler(error) {
675
709
  console.error(error);
676
710
  }
677
711
  function defaultPostponeHandler() {}
678
- function createRequest(
712
+ function RequestInstance(
713
+ type,
679
714
  model,
680
715
  bundlerConfig,
681
716
  onError,
682
717
  identifierPrefix,
683
718
  onPostpone,
719
+ temporaryReferences,
684
720
  environmentName,
685
- temporaryReferences
721
+ filterStackFrame,
722
+ onAllReady,
723
+ onFatalError
686
724
  ) {
687
725
  if (
688
726
  null !== ReactSharedInternalsServer.A &&
@@ -690,41 +728,40 @@ function createRequest(
690
728
  )
691
729
  throw Error("Currently React only supports one RSC renderer at a time.");
692
730
  ReactSharedInternalsServer.A = DefaultAsyncDispatcher;
693
- var abortSet = new Set();
731
+ filterStackFrame = new Set();
694
732
  environmentName = [];
695
733
  var hints = new Set();
696
- bundlerConfig = {
697
- status: 0,
698
- flushScheduled: !1,
699
- fatalError: null,
700
- destination: null,
701
- bundlerConfig: bundlerConfig,
702
- cache: new Map(),
703
- nextChunkId: 0,
704
- pendingChunks: 0,
705
- hints: hints,
706
- abortListeners: new Set(),
707
- abortableTasks: abortSet,
708
- pingedTasks: environmentName,
709
- completedImportChunks: [],
710
- completedHintChunks: [],
711
- completedRegularChunks: [],
712
- completedErrorChunks: [],
713
- writtenSymbols: new Map(),
714
- writtenClientReferences: new Map(),
715
- writtenServerReferences: new Map(),
716
- writtenObjects: new WeakMap(),
717
- temporaryReferences: temporaryReferences,
718
- identifierPrefix: identifierPrefix || "",
719
- identifierCount: 1,
720
- taintCleanupQueue: [],
721
- onError: void 0 === onError ? defaultErrorHandler : onError,
722
- onPostpone: void 0 === onPostpone ? defaultPostponeHandler : onPostpone
723
- };
724
- model = createTask(bundlerConfig, model, null, !1, abortSet);
725
- environmentName.push(model);
726
- return bundlerConfig;
734
+ this.type = type;
735
+ this.status = 10;
736
+ this.flushScheduled = !1;
737
+ this.destination = this.fatalError = null;
738
+ this.bundlerConfig = bundlerConfig;
739
+ this.cache = new Map();
740
+ this.pendingChunks = this.nextChunkId = 0;
741
+ this.hints = hints;
742
+ this.abortListeners = new Set();
743
+ this.abortableTasks = filterStackFrame;
744
+ this.pingedTasks = environmentName;
745
+ this.completedImportChunks = [];
746
+ this.completedHintChunks = [];
747
+ this.completedRegularChunks = [];
748
+ this.completedErrorChunks = [];
749
+ this.writtenSymbols = new Map();
750
+ this.writtenClientReferences = new Map();
751
+ this.writtenServerReferences = new Map();
752
+ this.writtenObjects = new WeakMap();
753
+ this.temporaryReferences = temporaryReferences;
754
+ this.identifierPrefix = identifierPrefix || "";
755
+ this.identifierCount = 1;
756
+ this.taintCleanupQueue = [];
757
+ this.onError = void 0 === onError ? defaultErrorHandler : onError;
758
+ this.onPostpone = void 0 === onPostpone ? defaultPostponeHandler : onPostpone;
759
+ this.onAllReady = onAllReady;
760
+ this.onFatalError = onFatalError;
761
+ type = createTask(this, model, null, !1, filterStackFrame);
762
+ environmentName.push(type);
727
763
  }
764
+ function noop() {}
728
765
  var currentRequest = null;
729
766
  function serializeThenable(request, task, thenable) {
730
767
  var newTask = createTask(
@@ -741,11 +778,21 @@ function serializeThenable(request, task, thenable) {
741
778
  );
742
779
  case "rejected":
743
780
  return (
744
- (task = logRecoverableError(request, thenable.reason)),
781
+ (task = logRecoverableError(request, thenable.reason, null)),
745
782
  emitErrorChunk(request, newTask.id, task),
783
+ (newTask.status = 4),
784
+ request.abortableTasks.delete(newTask),
746
785
  newTask.id
747
786
  );
748
787
  default:
788
+ if (12 === request.status)
789
+ return (
790
+ request.abortableTasks.delete(newTask),
791
+ (newTask.status = 3),
792
+ (task = stringify(serializeByValueID(request.fatalError))),
793
+ emitModelChunk(request, newTask.id, task),
794
+ newTask.id
795
+ );
749
796
  "string" !== typeof thenable.status &&
750
797
  ((thenable.status = "pending"),
751
798
  thenable.then(
@@ -766,11 +813,12 @@ function serializeThenable(request, task, thenable) {
766
813
  pingTask(request, newTask);
767
814
  },
768
815
  function (reason) {
769
- newTask.status = 4;
770
- reason = logRecoverableError(request, reason);
771
- emitErrorChunk(request, newTask.id, reason);
772
- request.abortableTasks.delete(newTask);
773
- enqueueFlush(request);
816
+ 0 === newTask.status &&
817
+ ((reason = logRecoverableError(request, reason, newTask)),
818
+ emitErrorChunk(request, newTask.id, reason),
819
+ (newTask.status = 4),
820
+ request.abortableTasks.delete(newTask),
821
+ enqueueFlush(request));
774
822
  }
775
823
  );
776
824
  return newTask.id;
@@ -779,7 +827,7 @@ function serializeReadableStream(request, task, stream) {
779
827
  function progress(entry) {
780
828
  if (!aborted)
781
829
  if (entry.done)
782
- request.abortListeners.delete(error),
830
+ request.abortListeners.delete(abortStream),
783
831
  (entry = streamTask.id.toString(16) + ":C\n"),
784
832
  request.completedRegularChunks.push(stringToChunk(entry)),
785
833
  enqueueFlush(request),
@@ -798,8 +846,18 @@ function serializeReadableStream(request, task, stream) {
798
846
  function error(reason) {
799
847
  if (!aborted) {
800
848
  aborted = !0;
801
- request.abortListeners.delete(error);
802
- var digest = logRecoverableError(request, reason);
849
+ request.abortListeners.delete(abortStream);
850
+ var digest = logRecoverableError(request, reason, streamTask);
851
+ emitErrorChunk(request, streamTask.id, digest);
852
+ enqueueFlush(request);
853
+ reader.cancel(reason).then(error, error);
854
+ }
855
+ }
856
+ function abortStream(reason) {
857
+ if (!aborted) {
858
+ aborted = !0;
859
+ request.abortListeners.delete(abortStream);
860
+ var digest = logRecoverableError(request, reason, streamTask);
803
861
  emitErrorChunk(request, streamTask.id, digest);
804
862
  enqueueFlush(request);
805
863
  reader.cancel(reason).then(error, error);
@@ -825,7 +883,7 @@ function serializeReadableStream(request, task, stream) {
825
883
  task = streamTask.id.toString(16) + ":" + (supportsBYOB ? "r" : "R") + "\n";
826
884
  request.completedRegularChunks.push(stringToChunk(task));
827
885
  var aborted = !1;
828
- request.abortListeners.add(error);
886
+ request.abortListeners.add(abortStream);
829
887
  reader.read().then(progress, error);
830
888
  return serializeByValueID(streamTask.id);
831
889
  }
@@ -833,7 +891,7 @@ function serializeAsyncIterable(request, task, iterable, iterator) {
833
891
  function progress(entry) {
834
892
  if (!aborted)
835
893
  if (entry.done) {
836
- request.abortListeners.delete(error);
894
+ request.abortListeners.delete(abortIterable);
837
895
  if (void 0 === entry.value)
838
896
  var endStreamRow = streamTask.id.toString(16) + ":C\n";
839
897
  else
@@ -865,8 +923,19 @@ function serializeAsyncIterable(request, task, iterable, iterator) {
865
923
  function error(reason) {
866
924
  if (!aborted) {
867
925
  aborted = !0;
868
- request.abortListeners.delete(error);
869
- var digest = logRecoverableError(request, reason);
926
+ request.abortListeners.delete(abortIterable);
927
+ var digest = logRecoverableError(request, reason, streamTask);
928
+ emitErrorChunk(request, streamTask.id, digest);
929
+ enqueueFlush(request);
930
+ "function" === typeof iterator.throw &&
931
+ iterator.throw(reason).then(error, error);
932
+ }
933
+ }
934
+ function abortIterable(reason) {
935
+ if (!aborted) {
936
+ aborted = !0;
937
+ request.abortListeners.delete(abortIterable);
938
+ var digest = logRecoverableError(request, reason, streamTask);
870
939
  emitErrorChunk(request, streamTask.id, digest);
871
940
  enqueueFlush(request);
872
941
  "function" === typeof iterator.throw &&
@@ -886,7 +955,7 @@ function serializeAsyncIterable(request, task, iterable, iterator) {
886
955
  task = streamTask.id.toString(16) + ":" + (iterable ? "x" : "X") + "\n";
887
956
  request.completedRegularChunks.push(stringToChunk(task));
888
957
  var aborted = !1;
889
- request.abortListeners.add(error);
958
+ request.abortListeners.add(abortIterable);
890
959
  iterator.next().then(progress, error);
891
960
  return serializeByValueID(streamTask.id);
892
961
  }
@@ -926,12 +995,22 @@ function createLazyWrapperAroundWakeable(wakeable) {
926
995
  }
927
996
  return { $$typeof: REACT_LAZY_TYPE, _payload: wakeable, _init: readThenable };
928
997
  }
998
+ function voidHandler() {}
929
999
  function renderFunctionComponent(request, task, key, Component, props) {
930
1000
  var prevThenableState = task.thenableState;
931
1001
  task.thenableState = null;
932
1002
  thenableIndexCounter = 0;
933
1003
  thenableState = prevThenableState;
934
1004
  Component = Component(props, void 0);
1005
+ if (12 === request.status)
1006
+ throw (
1007
+ ("object" === typeof Component &&
1008
+ null !== Component &&
1009
+ "function" === typeof Component.then &&
1010
+ Component.$$typeof !== CLIENT_REFERENCE_TAG$1 &&
1011
+ Component.then(voidHandler, voidHandler),
1012
+ null)
1013
+ );
935
1014
  if (
936
1015
  "object" === typeof Component &&
937
1016
  null !== Component &&
@@ -988,64 +1067,68 @@ function renderFragment(request, task, children) {
988
1067
  task.implicitSlot ? [request] : request)
989
1068
  : children;
990
1069
  }
991
- function renderClientElement(task, type, key, props) {
992
- var keyPath = task.keyPath;
993
- null === key
994
- ? (key = keyPath)
995
- : null !== keyPath && (key = keyPath + "," + key);
996
- type = [REACT_ELEMENT_TYPE, type, key, props];
997
- return task.implicitSlot && null !== key ? [type] : type;
998
- }
999
1070
  function renderElement(request, task, type, key, ref, props) {
1000
1071
  if (null !== ref && void 0 !== ref)
1001
1072
  throw Error(
1002
1073
  "Refs cannot be used in Server Components, nor passed to Client Components."
1003
1074
  );
1004
- if ("function" === typeof type)
1005
- return type.$$typeof === CLIENT_REFERENCE_TAG$1 ||
1006
- type.$$typeof === TEMPORARY_REFERENCE_TAG
1007
- ? renderClientElement(task, type, key, props)
1008
- : renderFunctionComponent(request, task, key, type, props);
1009
- if ("string" === typeof type)
1010
- return renderClientElement(task, type, key, props);
1011
- if ("symbol" === typeof type)
1012
- return type === REACT_FRAGMENT_TYPE && null === key
1013
- ? ((key = task.implicitSlot),
1014
- null === task.keyPath && (task.implicitSlot = !0),
1015
- (request = renderModelDestructive(
1016
- request,
1017
- task,
1018
- emptyRoot,
1019
- "",
1020
- props.children
1021
- )),
1022
- (task.implicitSlot = key),
1023
- request)
1024
- : renderClientElement(task, type, key, props);
1025
- if (null != type && "object" === typeof type) {
1026
- if (type.$$typeof === CLIENT_REFERENCE_TAG$1)
1027
- return renderClientElement(task, type, key, props);
1075
+ if (
1076
+ "function" === typeof type &&
1077
+ type.$$typeof !== CLIENT_REFERENCE_TAG$1 &&
1078
+ type.$$typeof !== TEMPORARY_REFERENCE_TAG
1079
+ )
1080
+ return renderFunctionComponent(request, task, key, type, props);
1081
+ if (type === REACT_FRAGMENT_TYPE && null === key)
1082
+ return (
1083
+ (type = task.implicitSlot),
1084
+ null === task.keyPath && (task.implicitSlot = !0),
1085
+ (props = renderModelDestructive(
1086
+ request,
1087
+ task,
1088
+ emptyRoot,
1089
+ "",
1090
+ props.children
1091
+ )),
1092
+ (task.implicitSlot = type),
1093
+ props
1094
+ );
1095
+ if (
1096
+ null != type &&
1097
+ "object" === typeof type &&
1098
+ type.$$typeof !== CLIENT_REFERENCE_TAG$1
1099
+ )
1028
1100
  switch (type.$$typeof) {
1029
1101
  case REACT_LAZY_TYPE:
1030
1102
  var init = type._init;
1031
1103
  type = init(type._payload);
1104
+ if (12 === request.status) throw null;
1032
1105
  return renderElement(request, task, type, key, ref, props);
1033
1106
  case REACT_FORWARD_REF_TYPE:
1034
1107
  return renderFunctionComponent(request, task, key, type.render, props);
1035
1108
  case REACT_MEMO_TYPE:
1036
1109
  return renderElement(request, task, type.type, key, ref, props);
1037
1110
  }
1038
- }
1039
- throw Error(
1040
- "Unsupported Server Component type: " + describeValueForErrorMessage(type)
1041
- );
1111
+ request = key;
1112
+ key = task.keyPath;
1113
+ null === request
1114
+ ? (request = key)
1115
+ : null !== key && (request = key + "," + request);
1116
+ props = [REACT_ELEMENT_TYPE, type, request, props];
1117
+ task = task.implicitSlot && null !== request ? [props] : props;
1118
+ return task;
1042
1119
  }
1043
1120
  function pingTask(request, task) {
1044
1121
  var pingedTasks = request.pingedTasks;
1045
1122
  pingedTasks.push(task);
1046
1123
  1 === pingedTasks.length &&
1047
1124
  ((request.flushScheduled = null !== request.destination),
1048
- performWork(request));
1125
+ 21 === request.type || 10 === request.status
1126
+ ? scheduleMicrotask(function () {
1127
+ return performWork(request);
1128
+ })
1129
+ : scheduleWork(function () {
1130
+ return performWork(request);
1131
+ }));
1049
1132
  }
1050
1133
  function createTask(request, model, keyPath, implicitSlot, abortSet) {
1051
1134
  request.pendingChunks++;
@@ -1077,19 +1160,27 @@ function createTask(request, model, keyPath, implicitSlot, abortSet) {
1077
1160
  );
1078
1161
  } catch (thrownValue) {
1079
1162
  if (
1080
- ((parentPropertyName =
1163
+ ((parentPropertyName = task.model),
1164
+ (parentPropertyName =
1165
+ "object" === typeof parentPropertyName &&
1166
+ null !== parentPropertyName &&
1167
+ (parentPropertyName.$$typeof === REACT_ELEMENT_TYPE ||
1168
+ parentPropertyName.$$typeof === REACT_LAZY_TYPE)),
1169
+ 12 === request.status)
1170
+ )
1171
+ (task.status = 3),
1172
+ (prevKeyPath = request.fatalError),
1173
+ (JSCompiler_inline_result = parentPropertyName
1174
+ ? "$L" + prevKeyPath.toString(16)
1175
+ : serializeByValueID(prevKeyPath));
1176
+ else if (
1177
+ ((value =
1081
1178
  thrownValue === SuspenseException
1082
1179
  ? getSuspendedThenable()
1083
1180
  : thrownValue),
1084
- (value = task.model),
1085
- (value =
1086
- "object" === typeof value &&
1181
+ "object" === typeof value &&
1087
1182
  null !== value &&
1088
- (value.$$typeof === REACT_ELEMENT_TYPE ||
1089
- value.$$typeof === REACT_LAZY_TYPE)),
1090
- "object" === typeof parentPropertyName &&
1091
- null !== parentPropertyName &&
1092
- "function" === typeof parentPropertyName.then)
1183
+ "function" === typeof value.then)
1093
1184
  ) {
1094
1185
  JSCompiler_inline_result = createTask(
1095
1186
  request,
@@ -1099,28 +1190,24 @@ function createTask(request, model, keyPath, implicitSlot, abortSet) {
1099
1190
  request.abortableTasks
1100
1191
  );
1101
1192
  var ping = JSCompiler_inline_result.ping;
1102
- parentPropertyName.then(ping, ping);
1193
+ value.then(ping, ping);
1103
1194
  JSCompiler_inline_result.thenableState =
1104
1195
  getThenableStateAfterSuspending();
1105
1196
  task.keyPath = prevKeyPath;
1106
1197
  task.implicitSlot = prevImplicitSlot;
1107
- JSCompiler_inline_result = value
1198
+ JSCompiler_inline_result = parentPropertyName
1108
1199
  ? "$L" + JSCompiler_inline_result.id.toString(16)
1109
1200
  : serializeByValueID(JSCompiler_inline_result.id);
1110
- } else if (
1111
- ((task.keyPath = prevKeyPath),
1112
- (task.implicitSlot = prevImplicitSlot),
1113
- value)
1114
- )
1115
- request.pendingChunks++,
1201
+ } else
1202
+ (task.keyPath = prevKeyPath),
1203
+ (task.implicitSlot = prevImplicitSlot),
1204
+ request.pendingChunks++,
1116
1205
  (prevKeyPath = request.nextChunkId++),
1117
- (prevImplicitSlot = logRecoverableError(
1118
- request,
1119
- parentPropertyName
1120
- )),
1206
+ (prevImplicitSlot = logRecoverableError(request, value, task)),
1121
1207
  emitErrorChunk(request, prevKeyPath, prevImplicitSlot),
1122
- (JSCompiler_inline_result = "$L" + prevKeyPath.toString(16));
1123
- else throw parentPropertyName;
1208
+ (JSCompiler_inline_result = parentPropertyName
1209
+ ? "$L" + prevKeyPath.toString(16)
1210
+ : serializeByValueID(prevKeyPath));
1124
1211
  }
1125
1212
  return JSCompiler_inline_result;
1126
1213
  },
@@ -1170,8 +1257,14 @@ function serializeClientReference(
1170
1257
  '" in the React Client Manifest. This is probably a bug in the React Server Components bundler.'
1171
1258
  );
1172
1259
  }
1260
+ if (!0 === resolvedModuleData.async && !0 === clientReference.$$async)
1261
+ throw Error(
1262
+ 'The module "' +
1263
+ modulePath +
1264
+ '" 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.'
1265
+ );
1173
1266
  var JSCompiler_inline_result =
1174
- !0 === clientReference.$$async
1267
+ !0 === resolvedModuleData.async || !0 === clientReference.$$async
1175
1268
  ? [resolvedModuleData.id, resolvedModuleData.chunks, existingId, 1]
1176
1269
  : [resolvedModuleData.id, resolvedModuleData.chunks, existingId];
1177
1270
  request.pendingChunks++;
@@ -1188,7 +1281,7 @@ function serializeClientReference(
1188
1281
  return (
1189
1282
  request.pendingChunks++,
1190
1283
  (parent = request.nextChunkId++),
1191
- (parentPropertyName = logRecoverableError(request, x)),
1284
+ (parentPropertyName = logRecoverableError(request, x, null)),
1192
1285
  emitErrorChunk(request, parent, parentPropertyName),
1193
1286
  serializeByValueID(parent)
1194
1287
  );
@@ -1209,7 +1302,7 @@ function serializeBlob(request, blob) {
1209
1302
  function progress(entry) {
1210
1303
  if (!aborted)
1211
1304
  if (entry.done)
1212
- request.abortListeners.delete(error),
1305
+ request.abortListeners.delete(abortBlob),
1213
1306
  (aborted = !0),
1214
1307
  pingTask(request, newTask);
1215
1308
  else
@@ -1220,10 +1313,19 @@ function serializeBlob(request, blob) {
1220
1313
  function error(reason) {
1221
1314
  if (!aborted) {
1222
1315
  aborted = !0;
1223
- request.abortListeners.delete(error);
1224
- var digest = logRecoverableError(request, reason);
1316
+ request.abortListeners.delete(abortBlob);
1317
+ var digest = logRecoverableError(request, reason, newTask);
1318
+ emitErrorChunk(request, newTask.id, digest);
1319
+ enqueueFlush(request);
1320
+ reader.cancel(reason).then(error, error);
1321
+ }
1322
+ }
1323
+ function abortBlob(reason) {
1324
+ if (!aborted) {
1325
+ aborted = !0;
1326
+ request.abortListeners.delete(abortBlob);
1327
+ var digest = logRecoverableError(request, reason, newTask);
1225
1328
  emitErrorChunk(request, newTask.id, digest);
1226
- request.abortableTasks.delete(newTask);
1227
1329
  enqueueFlush(request);
1228
1330
  reader.cancel(reason).then(error, error);
1229
1331
  }
@@ -1232,7 +1334,7 @@ function serializeBlob(request, blob) {
1232
1334
  newTask = createTask(request, model, null, !1, request.abortableTasks),
1233
1335
  reader = blob.stream().getReader(),
1234
1336
  aborted = !1;
1235
- request.abortListeners.add(error);
1337
+ request.abortListeners.add(abortBlob);
1236
1338
  reader.read().then(progress).catch(error);
1237
1339
  return "$B" + newTask.id.toString(16);
1238
1340
  }
@@ -1250,7 +1352,8 @@ function renderModelDestructive(
1250
1352
  if ("object" === typeof value) {
1251
1353
  switch (value.$$typeof) {
1252
1354
  case REACT_ELEMENT_TYPE:
1253
- var writtenObjects = request.writtenObjects;
1355
+ var elementReference = null,
1356
+ writtenObjects = request.writtenObjects;
1254
1357
  if (null === task.keyPath && !task.implicitSlot) {
1255
1358
  var existingReference = writtenObjects.get(value);
1256
1359
  if (void 0 !== existingReference)
@@ -1260,11 +1363,12 @@ function renderModelDestructive(
1260
1363
  -1 === parentPropertyName.indexOf(":") &&
1261
1364
  ((parent = writtenObjects.get(parent)),
1262
1365
  void 0 !== parent &&
1263
- writtenObjects.set(value, parent + ":" + parentPropertyName));
1366
+ ((elementReference = parent + ":" + parentPropertyName),
1367
+ writtenObjects.set(value, elementReference)));
1264
1368
  }
1265
1369
  parentPropertyName = value.props;
1266
1370
  parent = parentPropertyName.ref;
1267
- return renderElement(
1371
+ request = renderElement(
1268
1372
  request,
1269
1373
  task,
1270
1374
  value.type,
@@ -1272,13 +1376,18 @@ function renderModelDestructive(
1272
1376
  void 0 !== parent ? parent : null,
1273
1377
  parentPropertyName
1274
1378
  );
1379
+ "object" === typeof request &&
1380
+ null !== request &&
1381
+ null !== elementReference &&
1382
+ (writtenObjects.has(request) ||
1383
+ writtenObjects.set(request, elementReference));
1384
+ return request;
1275
1385
  case REACT_LAZY_TYPE:
1276
- return (
1277
- (task.thenableState = null),
1278
- (parentPropertyName = value._init),
1279
- (value = parentPropertyName(value._payload)),
1280
- renderModelDestructive(request, task, emptyRoot, "", value)
1281
- );
1386
+ task.thenableState = null;
1387
+ parentPropertyName = value._init;
1388
+ value = parentPropertyName(value._payload);
1389
+ if (12 === request.status) throw null;
1390
+ return renderModelDestructive(request, task, emptyRoot, "", value);
1282
1391
  case REACT_LEGACY_ELEMENT_TYPE:
1283
1392
  throw Error(
1284
1393
  '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.'
@@ -1293,44 +1402,47 @@ function renderModelDestructive(
1293
1402
  );
1294
1403
  if (
1295
1404
  void 0 !== request.temporaryReferences &&
1296
- ((writtenObjects = request.temporaryReferences.get(value)),
1297
- void 0 !== writtenObjects)
1405
+ ((elementReference = request.temporaryReferences.get(value)),
1406
+ void 0 !== elementReference)
1298
1407
  )
1299
- return "$T" + writtenObjects;
1300
- writtenObjects = request.writtenObjects;
1301
- existingReference = writtenObjects.get(value);
1408
+ return "$T" + elementReference;
1409
+ elementReference = request.writtenObjects;
1410
+ writtenObjects = elementReference.get(value);
1302
1411
  if ("function" === typeof value.then) {
1303
- if (void 0 !== existingReference) {
1412
+ if (void 0 !== writtenObjects) {
1304
1413
  if (null !== task.keyPath || task.implicitSlot)
1305
1414
  return "$@" + serializeThenable(request, task, value).toString(16);
1306
1415
  if (modelRoot === value) modelRoot = null;
1307
- else return existingReference;
1416
+ else return writtenObjects;
1308
1417
  }
1309
1418
  request = "$@" + serializeThenable(request, task, value).toString(16);
1310
- writtenObjects.set(value, request);
1419
+ elementReference.set(value, request);
1311
1420
  return request;
1312
1421
  }
1313
- if (void 0 !== existingReference)
1422
+ if (void 0 !== writtenObjects)
1314
1423
  if (modelRoot === value) modelRoot = null;
1315
- else return existingReference;
1424
+ else return writtenObjects;
1316
1425
  else if (
1317
1426
  -1 === parentPropertyName.indexOf(":") &&
1318
- ((existingReference = writtenObjects.get(parent)),
1319
- void 0 !== existingReference)
1427
+ ((writtenObjects = elementReference.get(parent)),
1428
+ void 0 !== writtenObjects)
1320
1429
  ) {
1321
- var propertyName = parentPropertyName;
1430
+ existingReference = parentPropertyName;
1322
1431
  if (isArrayImpl(parent) && parent[0] === REACT_ELEMENT_TYPE)
1323
1432
  switch (parentPropertyName) {
1324
1433
  case "1":
1325
- propertyName = "type";
1434
+ existingReference = "type";
1326
1435
  break;
1327
1436
  case "2":
1328
- propertyName = "key";
1437
+ existingReference = "key";
1329
1438
  break;
1330
1439
  case "3":
1331
- propertyName = "props";
1440
+ existingReference = "props";
1441
+ break;
1442
+ case "4":
1443
+ existingReference = "_owner";
1332
1444
  }
1333
- writtenObjects.set(value, existingReference + ":" + propertyName);
1445
+ elementReference.set(value, writtenObjects + ":" + existingReference);
1334
1446
  }
1335
1447
  if (isArrayImpl(value)) return renderFragment(request, task, value);
1336
1448
  if (value instanceof Map)
@@ -1348,6 +1460,7 @@ function renderModelDestructive(
1348
1460
  (value = Array.from(value.entries())),
1349
1461
  "$K" + outlineModel(request, value).toString(16)
1350
1462
  );
1463
+ if (value instanceof Error) return "$Z";
1351
1464
  if (value instanceof ArrayBuffer)
1352
1465
  return serializeTypedArray(request, "A", new Uint8Array(value));
1353
1466
  if (value instanceof Int8Array)
@@ -1376,9 +1489,9 @@ function renderModelDestructive(
1376
1489
  return serializeTypedArray(request, "V", value);
1377
1490
  if ("function" === typeof Blob && value instanceof Blob)
1378
1491
  return serializeBlob(request, value);
1379
- if ((parentPropertyName = getIteratorFn(value)))
1492
+ if ((elementReference = getIteratorFn(value)))
1380
1493
  return (
1381
- (parentPropertyName = parentPropertyName.call(value)),
1494
+ (parentPropertyName = elementReference.call(value)),
1382
1495
  parentPropertyName === value
1383
1496
  ? "$i" +
1384
1497
  outlineModel(request, Array.from(parentPropertyName)).toString(16)
@@ -1386,8 +1499,8 @@ function renderModelDestructive(
1386
1499
  );
1387
1500
  if ("function" === typeof ReadableStream && value instanceof ReadableStream)
1388
1501
  return serializeReadableStream(request, task, value);
1389
- parentPropertyName = value[ASYNC_ITERATOR];
1390
- if ("function" === typeof parentPropertyName)
1502
+ elementReference = value[ASYNC_ITERATOR];
1503
+ if ("function" === typeof elementReference)
1391
1504
  return (
1392
1505
  null !== task.keyPath
1393
1506
  ? ((request = [
@@ -1397,7 +1510,7 @@ function renderModelDestructive(
1397
1510
  { children: value }
1398
1511
  ]),
1399
1512
  (request = task.implicitSlot ? [request] : request))
1400
- : ((parentPropertyName = parentPropertyName.call(value)),
1513
+ : ((parentPropertyName = elementReference.call(value)),
1401
1514
  (request = serializeAsyncIterable(
1402
1515
  request,
1403
1516
  task,
@@ -1406,13 +1519,15 @@ function renderModelDestructive(
1406
1519
  ))),
1407
1520
  request
1408
1521
  );
1522
+ if (value instanceof Date) return "$D" + value.toJSON();
1409
1523
  request = getPrototypeOf(value);
1410
1524
  if (
1411
1525
  request !== ObjectPrototype &&
1412
1526
  (null === request || null !== getPrototypeOf(request))
1413
1527
  )
1414
1528
  throw Error(
1415
- "Only plain objects, and a few built-ins, can be passed to Client Components from Server Components. Classes or null prototypes are not supported."
1529
+ "Only plain objects, and a few built-ins, can be passed to Client Components from Server Components. Classes or null prototypes are not supported." +
1530
+ describeObjectForErrorMessage(parent, parentPropertyName)
1416
1531
  );
1417
1532
  return value;
1418
1533
  }
@@ -1422,7 +1537,7 @@ function renderModelDestructive(
1422
1537
  parent[parentPropertyName] instanceof Date
1423
1538
  )
1424
1539
  return "$D" + value;
1425
- if (1024 <= value.length)
1540
+ if (1024 <= value.length && null !== byteLengthOfChunk)
1426
1541
  return (
1427
1542
  request.pendingChunks++,
1428
1543
  (task = request.nextChunkId++),
@@ -1439,10 +1554,10 @@ function renderModelDestructive(
1439
1554
  ? "$-0"
1440
1555
  : value
1441
1556
  : Infinity === value
1442
- ? "$Infinity"
1443
- : -Infinity === value
1444
- ? "$-Infinity"
1445
- : "$NaN";
1557
+ ? "$Infinity"
1558
+ : -Infinity === value
1559
+ ? "$-Infinity"
1560
+ : "$NaN";
1446
1561
  if ("undefined" === typeof value) return "$undefined";
1447
1562
  if ("function" === typeof value) {
1448
1563
  if (value.$$typeof === CLIENT_REFERENCE_TAG$1)
@@ -1459,13 +1574,14 @@ function renderModelDestructive(
1459
1574
  void 0 !== parentPropertyName
1460
1575
  ? (request = "$F" + parentPropertyName.toString(16))
1461
1576
  : ((parentPropertyName = value.$$bound),
1462
- (parentPropertyName = {
1577
+ (parentPropertyName =
1578
+ null === parentPropertyName
1579
+ ? null
1580
+ : Promise.resolve(parentPropertyName)),
1581
+ (request = outlineModel(request, {
1463
1582
  id: value.$$id,
1464
1583
  bound: parentPropertyName
1465
- ? Promise.resolve(parentPropertyName)
1466
- : null
1467
- }),
1468
- (request = outlineModel(request, parentPropertyName)),
1584
+ })),
1469
1585
  task.set(value, request),
1470
1586
  (request = "$F" + request.toString(16))),
1471
1587
  request
@@ -1492,10 +1608,11 @@ function renderModelDestructive(
1492
1608
  }
1493
1609
  if ("symbol" === typeof value) {
1494
1610
  task = request.writtenSymbols;
1495
- writtenObjects = task.get(value);
1496
- if (void 0 !== writtenObjects) return serializeByValueID(writtenObjects);
1497
- writtenObjects = value.description;
1498
- if (Symbol.for(writtenObjects) !== value)
1611
+ elementReference = task.get(value);
1612
+ if (void 0 !== elementReference)
1613
+ return serializeByValueID(elementReference);
1614
+ elementReference = value.description;
1615
+ if (Symbol.for(elementReference) !== value)
1499
1616
  throw Error(
1500
1617
  "Only global symbols received from Symbol.for(...) can be passed to Client Components. The symbol Symbol.for(" +
1501
1618
  (value.description + ") cannot be found among global symbols.") +
@@ -1506,7 +1623,7 @@ function renderModelDestructive(
1506
1623
  parent = encodeReferenceChunk(
1507
1624
  request,
1508
1625
  parentPropertyName,
1509
- "$S" + writtenObjects
1626
+ "$S" + elementReference
1510
1627
  );
1511
1628
  request.completedImportChunks.push(parent);
1512
1629
  task.set(value, parentPropertyName);
@@ -1538,9 +1655,11 @@ function logRecoverableError(request, error) {
1538
1655
  return errorDigest || "";
1539
1656
  }
1540
1657
  function fatalError(request, error) {
1658
+ var onFatalError = request.onFatalError;
1659
+ onFatalError(error);
1541
1660
  null !== request.destination
1542
- ? ((request.status = 2), closeWithError(request.destination, error))
1543
- : ((request.status = 1), (request.fatalError = error));
1661
+ ? ((request.status = 14), closeWithError(request.destination, error))
1662
+ : ((request.status = 13), (request.fatalError = error));
1544
1663
  }
1545
1664
  function emitErrorChunk(request, id, digest) {
1546
1665
  digest = { digest: digest };
@@ -1567,6 +1686,10 @@ function emitTypedArrayChunk(request, id, tag, typedArray) {
1567
1686
  request.completedRegularChunks.push(id, typedArray);
1568
1687
  }
1569
1688
  function emitTextChunk(request, id, text) {
1689
+ if (null === byteLengthOfChunk)
1690
+ throw Error(
1691
+ "Existence of byteLengthOfChunk should have already been checked. This is a bug in React."
1692
+ );
1570
1693
  request.pendingChunks++;
1571
1694
  text = stringToChunk(text);
1572
1695
  var binaryLength = text.byteLength;
@@ -1576,40 +1699,41 @@ function emitTextChunk(request, id, text) {
1576
1699
  }
1577
1700
  function emitChunk(request, task, value) {
1578
1701
  var id = task.id;
1579
- "string" === typeof value
1702
+ "string" === typeof value && null !== byteLengthOfChunk
1580
1703
  ? emitTextChunk(request, id, value)
1581
1704
  : value instanceof ArrayBuffer
1582
- ? emitTypedArrayChunk(request, id, "A", new Uint8Array(value))
1583
- : value instanceof Int8Array
1584
- ? emitTypedArrayChunk(request, id, "O", value)
1585
- : value instanceof Uint8Array
1586
- ? emitTypedArrayChunk(request, id, "o", value)
1587
- : value instanceof Uint8ClampedArray
1588
- ? emitTypedArrayChunk(request, id, "U", value)
1589
- : value instanceof Int16Array
1590
- ? emitTypedArrayChunk(request, id, "S", value)
1591
- : value instanceof Uint16Array
1592
- ? emitTypedArrayChunk(request, id, "s", value)
1593
- : value instanceof Int32Array
1594
- ? emitTypedArrayChunk(request, id, "L", value)
1595
- : value instanceof Uint32Array
1596
- ? emitTypedArrayChunk(request, id, "l", value)
1597
- : value instanceof Float32Array
1598
- ? emitTypedArrayChunk(request, id, "G", value)
1599
- : value instanceof Float64Array
1600
- ? emitTypedArrayChunk(request, id, "g", value)
1601
- : value instanceof BigInt64Array
1602
- ? emitTypedArrayChunk(request, id, "M", value)
1603
- : value instanceof BigUint64Array
1604
- ? emitTypedArrayChunk(request, id, "m", value)
1605
- : value instanceof DataView
1606
- ? emitTypedArrayChunk(request, id, "V", value)
1607
- : ((value = stringify(value, task.toJSON)),
1608
- emitModelChunk(request, task.id, value));
1705
+ ? emitTypedArrayChunk(request, id, "A", new Uint8Array(value))
1706
+ : value instanceof Int8Array
1707
+ ? emitTypedArrayChunk(request, id, "O", value)
1708
+ : value instanceof Uint8Array
1709
+ ? emitTypedArrayChunk(request, id, "o", value)
1710
+ : value instanceof Uint8ClampedArray
1711
+ ? emitTypedArrayChunk(request, id, "U", value)
1712
+ : value instanceof Int16Array
1713
+ ? emitTypedArrayChunk(request, id, "S", value)
1714
+ : value instanceof Uint16Array
1715
+ ? emitTypedArrayChunk(request, id, "s", value)
1716
+ : value instanceof Int32Array
1717
+ ? emitTypedArrayChunk(request, id, "L", value)
1718
+ : value instanceof Uint32Array
1719
+ ? emitTypedArrayChunk(request, id, "l", value)
1720
+ : value instanceof Float32Array
1721
+ ? emitTypedArrayChunk(request, id, "G", value)
1722
+ : value instanceof Float64Array
1723
+ ? emitTypedArrayChunk(request, id, "g", value)
1724
+ : value instanceof BigInt64Array
1725
+ ? emitTypedArrayChunk(request, id, "M", value)
1726
+ : value instanceof BigUint64Array
1727
+ ? emitTypedArrayChunk(request, id, "m", value)
1728
+ : value instanceof DataView
1729
+ ? emitTypedArrayChunk(request, id, "V", value)
1730
+ : ((value = stringify(value, task.toJSON)),
1731
+ emitModelChunk(request, task.id, value));
1609
1732
  }
1610
1733
  var emptyRoot = {};
1611
1734
  function retryTask(request, task) {
1612
- if (0 === task.status)
1735
+ if (0 === task.status) {
1736
+ task.status = 5;
1613
1737
  try {
1614
1738
  modelRoot = task.model;
1615
1739
  var resolvedModel = renderModelDestructive(
@@ -1632,28 +1756,42 @@ function retryTask(request, task) {
1632
1756
  request.abortableTasks.delete(task);
1633
1757
  task.status = 1;
1634
1758
  } catch (thrownValue) {
1635
- var x =
1636
- thrownValue === SuspenseException
1637
- ? getSuspendedThenable()
1638
- : thrownValue;
1639
- if ("object" === typeof x && null !== x && "function" === typeof x.then) {
1640
- var ping = task.ping;
1641
- x.then(ping, ping);
1642
- task.thenableState = getThenableStateAfterSuspending();
1643
- } else {
1759
+ if (12 === request.status) {
1644
1760
  request.abortableTasks.delete(task);
1645
- task.status = 4;
1646
- var digest = logRecoverableError(request, x);
1647
- emitErrorChunk(request, task.id, digest);
1761
+ task.status = 3;
1762
+ var model = stringify(serializeByValueID(request.fatalError));
1763
+ emitModelChunk(request, task.id, model);
1764
+ } else {
1765
+ var x =
1766
+ thrownValue === SuspenseException
1767
+ ? getSuspendedThenable()
1768
+ : thrownValue;
1769
+ if (
1770
+ "object" === typeof x &&
1771
+ null !== x &&
1772
+ "function" === typeof x.then
1773
+ ) {
1774
+ task.status = 0;
1775
+ task.thenableState = getThenableStateAfterSuspending();
1776
+ var ping = task.ping;
1777
+ x.then(ping, ping);
1778
+ } else {
1779
+ request.abortableTasks.delete(task);
1780
+ task.status = 4;
1781
+ var digest = logRecoverableError(request, x, task);
1782
+ emitErrorChunk(request, task.id, digest);
1783
+ }
1648
1784
  }
1649
1785
  } finally {
1650
1786
  }
1787
+ }
1651
1788
  }
1652
1789
  function performWork(request) {
1653
1790
  var prevDispatcher = ReactSharedInternalsServer.H;
1654
1791
  ReactSharedInternalsServer.H = HooksDispatcher;
1655
1792
  var prevRequest = currentRequest;
1656
1793
  currentRequest$1 = currentRequest = request;
1794
+ var hadAbortableTasks = 0 < request.abortableTasks.size;
1657
1795
  try {
1658
1796
  var pingedTasks = request.pingedTasks;
1659
1797
  request.pingedTasks = [];
@@ -1661,8 +1799,12 @@ function performWork(request) {
1661
1799
  retryTask(request, pingedTasks[i]);
1662
1800
  null !== request.destination &&
1663
1801
  flushCompletedChunks(request, request.destination);
1802
+ if (hadAbortableTasks && 0 === request.abortableTasks.size) {
1803
+ var onAllReady = request.onAllReady;
1804
+ onAllReady();
1805
+ }
1664
1806
  } catch (error) {
1665
- logRecoverableError(request, error), fatalError(request, error);
1807
+ logRecoverableError(request, error, null), fatalError(request, error);
1666
1808
  } finally {
1667
1809
  (ReactSharedInternalsServer.H = prevDispatcher),
1668
1810
  (currentRequest$1 = null),
@@ -1705,54 +1847,77 @@ function flushCompletedChunks(request, destination) {
1705
1847
  (writtenBytes = 0));
1706
1848
  }
1707
1849
  0 === request.pendingChunks &&
1708
- (destination.close(), (request.destination = null));
1850
+ ((request.status = 14), destination.close(), (request.destination = null));
1851
+ }
1852
+ function startWork(request) {
1853
+ request.flushScheduled = null !== request.destination;
1854
+ scheduleMicrotask(function () {
1855
+ return performWork(request);
1856
+ });
1857
+ scheduleWork(function () {
1858
+ 10 === request.status && (request.status = 11);
1859
+ });
1709
1860
  }
1710
1861
  function enqueueFlush(request) {
1711
- if (
1712
- !1 === request.flushScheduled &&
1862
+ !1 === request.flushScheduled &&
1713
1863
  0 === request.pingedTasks.length &&
1714
- null !== request.destination
1715
- ) {
1716
- var destination = request.destination;
1717
- request.flushScheduled = !0;
1718
- flushCompletedChunks(request, destination);
1719
- }
1864
+ null !== request.destination &&
1865
+ ((request.flushScheduled = !0),
1866
+ scheduleWork(function () {
1867
+ request.flushScheduled = !1;
1868
+ var destination = request.destination;
1869
+ destination && flushCompletedChunks(request, destination);
1870
+ }));
1720
1871
  }
1721
1872
  function abort(request, reason) {
1722
1873
  try {
1874
+ 11 >= request.status && (request.status = 12);
1723
1875
  var abortableTasks = request.abortableTasks;
1724
1876
  if (0 < abortableTasks.size) {
1725
- request.pendingChunks++;
1726
- var errorId = request.nextChunkId++,
1727
- error =
1877
+ var error =
1728
1878
  void 0 === reason
1729
1879
  ? Error("The render was aborted by the server without a reason.")
1730
- : reason,
1731
- digest = logRecoverableError(request, error);
1880
+ : "object" === typeof reason &&
1881
+ null !== reason &&
1882
+ "function" === typeof reason.then
1883
+ ? Error("The render was aborted by the server with a promise.")
1884
+ : reason,
1885
+ digest = logRecoverableError(request, error, null),
1886
+ errorId = request.nextChunkId++;
1887
+ request.fatalError = errorId;
1888
+ request.pendingChunks++;
1732
1889
  emitErrorChunk(request, errorId, digest, error);
1733
1890
  abortableTasks.forEach(function (task) {
1734
- task.status = 3;
1735
- var ref = serializeByValueID(errorId);
1736
- task = encodeReferenceChunk(request, task.id, ref);
1737
- request.completedErrorChunks.push(task);
1891
+ if (5 !== task.status) {
1892
+ task.status = 3;
1893
+ var ref = serializeByValueID(errorId);
1894
+ task = encodeReferenceChunk(request, task.id, ref);
1895
+ request.completedErrorChunks.push(task);
1896
+ }
1738
1897
  });
1739
1898
  abortableTasks.clear();
1899
+ var onAllReady = request.onAllReady;
1900
+ onAllReady();
1740
1901
  }
1741
1902
  var abortListeners = request.abortListeners;
1742
1903
  if (0 < abortListeners.size) {
1743
- var error$22 =
1904
+ var error$23 =
1744
1905
  void 0 === reason
1745
1906
  ? Error("The render was aborted by the server without a reason.")
1746
- : reason;
1907
+ : "object" === typeof reason &&
1908
+ null !== reason &&
1909
+ "function" === typeof reason.then
1910
+ ? Error("The render was aborted by the server with a promise.")
1911
+ : reason;
1747
1912
  abortListeners.forEach(function (callback) {
1748
- return callback(error$22);
1913
+ return callback(error$23);
1749
1914
  });
1750
1915
  abortListeners.clear();
1751
1916
  }
1752
1917
  null !== request.destination &&
1753
1918
  flushCompletedChunks(request, request.destination);
1754
- } catch (error$23) {
1755
- logRecoverableError(request, error$23), fatalError(request, error$23);
1919
+ } catch (error$24) {
1920
+ logRecoverableError(request, error$24, null), fatalError(request, error$24);
1756
1921
  }
1757
1922
  }
1758
1923
  function resolveServerReference(bundlerConfig, id) {
@@ -1771,7 +1936,9 @@ function resolveServerReference(bundlerConfig, id) {
1771
1936
  '" in the React Server Manifest. This is probably a bug in the React Server Components bundler.'
1772
1937
  );
1773
1938
  }
1774
- return [resolvedModuleData.id, resolvedModuleData.chunks, name];
1939
+ return resolvedModuleData.async
1940
+ ? [resolvedModuleData.id, resolvedModuleData.chunks, name, 1]
1941
+ : [resolvedModuleData.id, resolvedModuleData.chunks, name];
1775
1942
  }
1776
1943
  var chunkCache = new Map();
1777
1944
  function requireAsyncModule(id) {
@@ -1812,8 +1979,8 @@ function preloadModule(metadata) {
1812
1979
  return requireAsyncModule(metadata[0]);
1813
1980
  })
1814
1981
  : 0 < promises.length
1815
- ? Promise.all(promises)
1816
- : null;
1982
+ ? Promise.all(promises)
1983
+ : null;
1817
1984
  }
1818
1985
  function requireModule(metadata) {
1819
1986
  var moduleExports = __webpack_require__(metadata[0]);
@@ -1824,10 +1991,10 @@ function requireModule(metadata) {
1824
1991
  return "*" === metadata[2]
1825
1992
  ? moduleExports
1826
1993
  : "" === metadata[2]
1827
- ? moduleExports.__esModule
1828
- ? moduleExports.default
1829
- : moduleExports
1830
- : moduleExports[metadata[2]];
1994
+ ? moduleExports.__esModule
1995
+ ? moduleExports.default
1996
+ : moduleExports
1997
+ : moduleExports[metadata[2]];
1831
1998
  }
1832
1999
  var chunkMap = new Map(),
1833
2000
  webpackGetChunkFilename = __webpack_require__.u;
@@ -2204,8 +2371,8 @@ function parseReadableStream(response, reference, type) {
2204
2371
  (previousBlockedChunk = chunk));
2205
2372
  } else {
2206
2373
  chunk = previousBlockedChunk;
2207
- var chunk$26 = createPendingChunk(response);
2208
- chunk$26.then(
2374
+ var chunk$27 = createPendingChunk(response);
2375
+ chunk$27.then(
2209
2376
  function (v) {
2210
2377
  return controller.enqueue(v);
2211
2378
  },
@@ -2213,10 +2380,10 @@ function parseReadableStream(response, reference, type) {
2213
2380
  return controller.error(e);
2214
2381
  }
2215
2382
  );
2216
- previousBlockedChunk = chunk$26;
2383
+ previousBlockedChunk = chunk$27;
2217
2384
  chunk.then(function () {
2218
- previousBlockedChunk === chunk$26 && (previousBlockedChunk = null);
2219
- resolveModelChunk(chunk$26, json, -1);
2385
+ previousBlockedChunk === chunk$27 && (previousBlockedChunk = null);
2386
+ resolveModelChunk(chunk$27, json, -1);
2220
2387
  });
2221
2388
  }
2222
2389
  },
@@ -2461,10 +2628,10 @@ function loadServerReference(bundlerConfig, id, bound) {
2461
2628
  return fn.bind.apply(fn, [null].concat(_ref));
2462
2629
  })
2463
2630
  : bundlerConfig
2464
- ? Promise.resolve(bundlerConfig).then(function () {
2465
- return requireModule(serverReference);
2466
- })
2467
- : Promise.resolve(requireModule(serverReference));
2631
+ ? Promise.resolve(bundlerConfig).then(function () {
2632
+ return requireModule(serverReference);
2633
+ })
2634
+ : Promise.resolve(requireModule(serverReference));
2468
2635
  }
2469
2636
  function decodeBoundActionMetaData(body, serverManifest, formFieldPrefix) {
2470
2637
  body = createResponse(serverManifest, formFieldPrefix, void 0, body);
@@ -2557,14 +2724,18 @@ exports.registerServerReference = function (reference, id, exportName) {
2557
2724
  });
2558
2725
  };
2559
2726
  exports.renderToReadableStream = function (model, webpackMap, options) {
2560
- var request = createRequest(
2727
+ var request = new RequestInstance(
2728
+ 20,
2561
2729
  model,
2562
2730
  webpackMap,
2563
2731
  options ? options.onError : void 0,
2564
2732
  options ? options.identifierPrefix : void 0,
2565
2733
  options ? options.onPostpone : void 0,
2566
- options ? options.environmentName : void 0,
2567
- options ? options.temporaryReferences : void 0
2734
+ options ? options.temporaryReferences : void 0,
2735
+ void 0,
2736
+ void 0,
2737
+ noop,
2738
+ noop
2568
2739
  );
2569
2740
  if (options && options.signal) {
2570
2741
  var signal = options.signal;
@@ -2581,18 +2752,18 @@ exports.renderToReadableStream = function (model, webpackMap, options) {
2581
2752
  {
2582
2753
  type: "bytes",
2583
2754
  start: function () {
2584
- request.flushScheduled = null !== request.destination;
2585
- performWork(request);
2755
+ startWork(request);
2586
2756
  },
2587
2757
  pull: function (controller) {
2588
- if (1 === request.status)
2589
- (request.status = 2), closeWithError(controller, request.fatalError);
2590
- else if (2 !== request.status && null === request.destination) {
2758
+ if (13 === request.status)
2759
+ (request.status = 14), closeWithError(controller, request.fatalError);
2760
+ else if (14 !== request.status && null === request.destination) {
2591
2761
  request.destination = controller;
2592
2762
  try {
2593
2763
  flushCompletedChunks(request, controller);
2594
2764
  } catch (error) {
2595
- logRecoverableError(request, error), fatalError(request, error);
2765
+ logRecoverableError(request, error, null),
2766
+ fatalError(request, error);
2596
2767
  }
2597
2768
  }
2598
2769
  },