react-server-dom-webpack 18.3.0-next-8b9ac8175-20230131 → 18.3.0-next-2ef24145e-20230202

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.
@@ -281,11 +281,6 @@ function createErrorChunk(response, error) {
281
281
  return new Chunk(ERRORED, null, error, response);
282
282
  }
283
283
 
284
- function createInitializedChunk(response, value) {
285
- // $FlowFixMe Flow doesn't support functions as constructors
286
- return new Chunk(INITIALIZED, value, null, response);
287
- }
288
-
289
284
  function wakeChunk(listeners, value) {
290
285
  for (var i = 0; i < listeners.length; i++) {
291
286
  var listener = listeners[i];
@@ -546,55 +541,84 @@ function createModelReject(chunk) {
546
541
  }
547
542
 
548
543
  function parseModelString(response, parentObject, key, value) {
549
- switch (value[0]) {
550
- case '$':
551
- {
552
- if (value === '$') {
553
- return REACT_ELEMENT_TYPE;
554
- } else if (value[1] === '$' || value[1] === '@') {
544
+ if (value[0] === '$') {
545
+ if (value === '$') {
546
+ // A very common symbol.
547
+ return REACT_ELEMENT_TYPE;
548
+ }
549
+
550
+ switch (value[1]) {
551
+ case '$':
552
+ {
555
553
  // This was an escaped string value.
556
554
  return value.substring(1);
557
- } else {
558
- var id = parseInt(value.substring(1), 16);
559
- var chunk = getChunk(response, id);
555
+ }
556
+
557
+ case 'L':
558
+ {
559
+ // Lazy node
560
+ var id = parseInt(value.substring(2), 16);
561
+ var chunk = getChunk(response, id); // We create a React.lazy wrapper around any lazy values.
562
+ // When passed into React, we'll know how to suspend on this.
563
+
564
+ return createLazyChunkWrapper(chunk);
565
+ }
566
+
567
+ case '@':
568
+ {
569
+ // Promise
570
+ var _id = parseInt(value.substring(2), 16);
560
571
 
561
- switch (chunk.status) {
572
+ var _chunk = getChunk(response, _id);
573
+
574
+ return _chunk;
575
+ }
576
+
577
+ case 'S':
578
+ {
579
+ return Symbol.for(value.substring(2));
580
+ }
581
+
582
+ case 'P':
583
+ {
584
+ return getOrCreateServerContext(value.substring(2)).Provider;
585
+ }
586
+
587
+ default:
588
+ {
589
+ // We assume that anything else is a reference ID.
590
+ var _id2 = parseInt(value.substring(1), 16);
591
+
592
+ var _chunk2 = getChunk(response, _id2);
593
+
594
+ switch (_chunk2.status) {
562
595
  case RESOLVED_MODEL:
563
- initializeModelChunk(chunk);
596
+ initializeModelChunk(_chunk2);
564
597
  break;
565
598
 
566
599
  case RESOLVED_MODULE:
567
- initializeModuleChunk(chunk);
600
+ initializeModuleChunk(_chunk2);
568
601
  break;
569
602
  } // The status might have changed after initialization.
570
603
 
571
604
 
572
- switch (chunk.status) {
605
+ switch (_chunk2.status) {
573
606
  case INITIALIZED:
574
- return chunk.value;
607
+ return _chunk2.value;
575
608
 
576
609
  case PENDING:
577
610
  case BLOCKED:
578
611
  var parentChunk = initializingChunk;
579
- chunk.then(createModelResolver(parentChunk, parentObject, key), createModelReject(parentChunk));
612
+
613
+ _chunk2.then(createModelResolver(parentChunk, parentObject, key), createModelReject(parentChunk));
614
+
580
615
  return null;
581
616
 
582
617
  default:
583
- throw chunk.reason;
618
+ throw _chunk2.reason;
584
619
  }
585
620
  }
586
- }
587
-
588
- case '@':
589
- {
590
- var _id = parseInt(value.substring(1), 16);
591
-
592
- var _chunk = getChunk(response, _id); // We create a React.lazy wrapper around any lazy values.
593
- // When passed into React, we'll know how to suspend on this.
594
-
595
-
596
- return createLazyChunkWrapper(_chunk);
597
- }
621
+ }
598
622
  }
599
623
 
600
624
  return value;
@@ -628,10 +652,6 @@ function resolveModel(response, id, model) {
628
652
  resolveModelChunk(chunk, model);
629
653
  }
630
654
  }
631
- function resolveProvider(response, id, contextName) {
632
- var chunks = response._chunks;
633
- chunks.set(id, createInitializedChunk(response, getOrCreateServerContext(contextName).Provider));
634
- }
635
655
  function resolveModule(response, id, model) {
636
656
  var chunks = response._chunks;
637
657
  var chunk = chunks.get(id);
@@ -672,12 +692,6 @@ function resolveModule(response, id, model) {
672
692
  }
673
693
  }
674
694
  }
675
- function resolveSymbol(response, id, name) {
676
- var chunks = response._chunks; // We assume that we'll always emit the symbol before anything references it
677
- // to save a few bytes.
678
-
679
- chunks.set(id, createInitializedChunk(response, Symbol.for(name)));
680
- }
681
695
  function resolveErrorDev(response, id, digest, message, stack) {
682
696
 
683
697
 
@@ -707,43 +721,23 @@ function processFullRow(response, row) {
707
721
  return;
708
722
  }
709
723
 
710
- var tag = row[0]; // When tags that are not text are added, check them here before
724
+ var colon = row.indexOf(':', 0);
725
+ var id = parseInt(row.substring(0, colon), 16);
726
+ var tag = row[colon + 1]; // When tags that are not text are added, check them here before
711
727
  // parsing the row as text.
712
728
  // switch (tag) {
713
729
  // }
714
730
 
715
- var colon = row.indexOf(':', 1);
716
- var id = parseInt(row.substring(1, colon), 16);
717
- var text = row.substring(colon + 1);
718
-
719
731
  switch (tag) {
720
- case 'J':
732
+ case 'I':
721
733
  {
722
- resolveModel(response, id, text);
723
- return;
724
- }
725
-
726
- case 'M':
727
- {
728
- resolveModule(response, id, text);
729
- return;
730
- }
731
-
732
- case 'P':
733
- {
734
- resolveProvider(response, id, text);
735
- return;
736
- }
737
-
738
- case 'S':
739
- {
740
- resolveSymbol(response, id, JSON.parse(text));
734
+ resolveModule(response, id, row.substring(colon + 2));
741
735
  return;
742
736
  }
743
737
 
744
738
  case 'E':
745
739
  {
746
- var errorInfo = JSON.parse(text);
740
+ var errorInfo = JSON.parse(row.substring(colon + 2));
747
741
 
748
742
  {
749
743
  resolveErrorDev(response, id, errorInfo.digest, errorInfo.message, errorInfo.stack);
@@ -754,7 +748,9 @@ function processFullRow(response, row) {
754
748
 
755
749
  default:
756
750
  {
757
- throw new Error("Error parsing the data. It's probably an error code or network corruption.");
751
+ // We assume anything else is JSON.
752
+ resolveModel(response, id, row.substring(colon + 1));
753
+ return;
758
754
  }
759
755
  }
760
756
  }
@@ -7,20 +7,20 @@
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
9
  */
10
- 'use strict';var h=require("react"),k={stream:!0};function m(a,b){return a?(a=a[b.id][b.name],b.async?{id:a.id,chunks:a.chunks,name:a.name,async:!0}:a):b}var n=new Map,p=new Map;function q(){}
11
- function r(a){for(var b=a.chunks,c=[],d=0;d<b.length;d++){var e=b[d],f=n.get(e);if(void 0===f){f=__webpack_chunk_load__(e);c.push(f);var l=n.set.bind(n,e,null);f.then(l,q);n.set(e,f)}else null!==f&&c.push(f)}if(a.async){if(b=p.get(a.id))return"fulfilled"===b.status?null:b;var g=Promise.all(c).then(function(){return __webpack_require__(a.id)});g.then(function(a){g.status="fulfilled";g.value=a},function(a){g.status="rejected";g.reason=a});p.set(a.id,g);return g}return 0<c.length?Promise.all(c):null}
12
- var t=Symbol.for("react.element"),u=Symbol.for("react.lazy"),v=Symbol.for("react.default_value"),w=h.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ContextRegistry;function x(a){w[a]||(w[a]=h.createServerContext(a,v));return w[a]}function y(a,b,c,d){this.status=a;this.value=b;this.reason=c;this._response=d}y.prototype=Object.create(Promise.prototype);
13
- y.prototype.then=function(a,b){switch(this.status){case "resolved_model":z(this);break;case "resolved_module":B(this)}switch(this.status){case "fulfilled":a(this.value);break;case "pending":case "blocked":a&&(null===this.value&&(this.value=[]),this.value.push(a));b&&(null===this.reason&&(this.reason=[]),this.reason.push(b));break;default:b(this.reason)}};
14
- function C(a){switch(a.status){case "resolved_model":z(a);break;case "resolved_module":B(a)}switch(a.status){case "fulfilled":return a.value;case "pending":case "blocked":throw a;default:throw a.reason;}}function D(a,b){return new y("fulfilled",b,null,a)}function E(a,b){for(var c=0;c<a.length;c++)(0,a[c])(b)}function F(a,b,c){switch(a.status){case "fulfilled":E(b,a.value);break;case "pending":case "blocked":a.value=b;a.reason=c;break;case "rejected":c&&E(c,a.reason)}}
15
- function G(a,b){if("pending"===a.status||"blocked"===a.status){var c=a.reason;a.status="rejected";a.reason=b;null!==c&&E(c,b)}}function H(a,b){if("pending"===a.status||"blocked"===a.status){var c=a.value,d=a.reason;a.status="resolved_module";a.value=b;null!==c&&(B(a),F(a,c,d))}}var I=null,J=null;
16
- function z(a){var b=I,c=J;I=a;J=null;try{var d=JSON.parse(a.value,a._response._fromJSON);null!==J&&0<J.deps?(J.value=d,a.status="blocked",a.value=null,a.reason=null):(a.status="fulfilled",a.value=d)}catch(e){a.status="rejected",a.reason=e}finally{I=b,J=c}}
17
- function B(a){try{var b=a.value;if(b.async){var c=p.get(b.id);if("fulfilled"===c.status)var d=c.value;else throw c.reason;}else d=__webpack_require__(b.id);var e="*"===b.name?d:""===b.name?d.__esModule?d.default:d:d[b.name];a.status="fulfilled";a.value=e}catch(f){a.status="rejected",a.reason=f}}function K(a,b){a._chunks.forEach(function(a){"pending"===a.status&&G(a,b)})}function L(a,b){var c=a._chunks,d=c.get(b);d||(d=new y("pending",null,null,a),c.set(b,d));return d}
18
- function N(a,b,c){if(J){var d=J;d.deps++}else d=J={deps:1,value:null};return function(e){b[c]=e;d.deps--;0===d.deps&&"blocked"===a.status&&(e=a.value,a.status="fulfilled",a.value=d.value,null!==e&&E(e,d.value))}}function O(a){return function(b){return G(a,b)}}
19
- function P(a,b,c,d){switch(d[0]){case "$":if("$"===d)return t;if("$"===d[1]||"@"===d[1])return d.substring(1);d=parseInt(d.substring(1),16);a=L(a,d);switch(a.status){case "resolved_model":z(a);break;case "resolved_module":B(a)}switch(a.status){case "fulfilled":return a.value;case "pending":case "blocked":return d=I,a.then(N(d,b,c),O(d)),null;default:throw a.reason;}case "@":return b=parseInt(d.substring(1),16),b=L(a,b),{$$typeof:u,_payload:b,_init:C}}return d}
20
- function Q(a,b,c){var d=a._chunks,e=d.get(b);c=JSON.parse(c,a._fromJSON);var f=m(a._bundlerConfig,c);if(c=r(f)){if(e){var l=e;l.status="blocked"}else l=new y("blocked",null,null,a),d.set(b,l);c.then(function(){return H(l,f)},function(a){return G(l,a)})}else e?H(e,f):d.set(b,new y("resolved_module",f,null,a))}function R(a){K(a,Error("Connection closed."))}
21
- function S(a,b){if(""!==b){var c=b[0],d=b.indexOf(":",1),e=parseInt(b.substring(1,d),16);b=b.substring(d+1);switch(c){case "J":d=a._chunks;(c=d.get(e))?"pending"===c.status&&(a=c.value,e=c.reason,c.status="resolved_model",c.value=b,null!==a&&(z(c),F(c,a,e))):d.set(e,new y("resolved_model",b,null,a));break;case "M":Q(a,e,b);break;case "P":a._chunks.set(e,D(a,x(b).Provider));break;case "S":b=JSON.parse(b);a._chunks.set(e,D(a,Symbol.for(b)));break;case "E":c=JSON.parse(b).digest;b=Error("An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.");
22
- b.stack="Error: "+b.message;b.digest=c;c=a._chunks;(d=c.get(e))?G(d,b):c.set(e,new y("rejected",null,b,a));break;default:throw Error("Error parsing the data. It's probably an error code or network corruption.");}}}function T(a){return function(b,c){return"string"===typeof c?P(a,this,b,c):"object"===typeof c&&null!==c?(b=c[0]===t?{$$typeof:t,type:c[1],key:c[2],ref:null,props:c[3],_owner:null}:c,b):c}}
23
- function U(a){var b=new TextDecoder,c=new Map;a={_bundlerConfig:a,_chunks:c,_partialRow:"",_stringDecoder:b};a._fromJSON=T(a);return a}function V(a,b){function c(b){var f=b.value;if(b.done)R(a);else{b=f;f=a._stringDecoder;for(var g=b.indexOf(10);-1<g;){var M=a._partialRow;var A=b.subarray(0,g);A=f.decode(A);S(a,M+A);a._partialRow="";b=b.subarray(g+1);g=b.indexOf(10)}a._partialRow+=f.decode(b,k);return e.read().then(c).catch(d)}}function d(b){K(a,b)}var e=b.getReader();e.read().then(c).catch(d)}
24
- exports.createFromFetch=function(a,b){var c=U(b&&b.moduleMap?b.moduleMap:null);a.then(function(a){V(c,a.body)},function(a){K(c,a)});return L(c,0)};exports.createFromReadableStream=function(a,b){b=U(b&&b.moduleMap?b.moduleMap:null);V(b,a);return L(b,0)};
25
- exports.createFromXHR=function(a,b){function c(){for(var b=a.responseText,c=f,d=b.indexOf("\n",c);-1<d;)c=e._partialRow+b.substring(c,d),S(e,c),e._partialRow="",c=d+1,d=b.indexOf("\n",c);e._partialRow+=b.substring(c);f=b.length}function d(){K(e,new TypeError("Network error"))}var e=U(b&&b.moduleMap?b.moduleMap:null),f=0;a.addEventListener("progress",c);a.addEventListener("load",function(){c();R(e)});a.addEventListener("error",d);a.addEventListener("abort",d);a.addEventListener("timeout",d);return L(e,
10
+ 'use strict';var h=require("react"),l={stream:!0};function m(a,b){return a?(a=a[b.id][b.name],b.async?{id:a.id,chunks:a.chunks,name:a.name,async:!0}:a):b}var n=new Map,p=new Map;function q(){}
11
+ function r(a){for(var b=a.chunks,c=[],d=0;d<b.length;d++){var e=b[d],f=n.get(e);if(void 0===f){f=__webpack_chunk_load__(e);c.push(f);var k=n.set.bind(n,e,null);f.then(k,q);n.set(e,f)}else null!==f&&c.push(f)}if(a.async){if(b=p.get(a.id))return"fulfilled"===b.status?null:b;var g=Promise.all(c).then(function(){return __webpack_require__(a.id)});g.then(function(a){g.status="fulfilled";g.value=a},function(a){g.status="rejected";g.reason=a});p.set(a.id,g);return g}return 0<c.length?Promise.all(c):null}
12
+ var t=Symbol.for("react.element"),u=Symbol.for("react.lazy"),v=Symbol.for("react.default_value"),w=h.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ContextRegistry;function x(a,b,c,d){this.status=a;this.value=b;this.reason=c;this._response=d}x.prototype=Object.create(Promise.prototype);
13
+ x.prototype.then=function(a,b){switch(this.status){case "resolved_model":y(this);break;case "resolved_module":z(this)}switch(this.status){case "fulfilled":a(this.value);break;case "pending":case "blocked":a&&(null===this.value&&(this.value=[]),this.value.push(a));b&&(null===this.reason&&(this.reason=[]),this.reason.push(b));break;default:b(this.reason)}};
14
+ function B(a){switch(a.status){case "resolved_model":y(a);break;case "resolved_module":z(a)}switch(a.status){case "fulfilled":return a.value;case "pending":case "blocked":throw a;default:throw a.reason;}}function C(a,b){for(var c=0;c<a.length;c++)(0,a[c])(b)}function D(a,b,c){switch(a.status){case "fulfilled":C(b,a.value);break;case "pending":case "blocked":a.value=b;a.reason=c;break;case "rejected":c&&C(c,a.reason)}}
15
+ function E(a,b){if("pending"===a.status||"blocked"===a.status){var c=a.reason;a.status="rejected";a.reason=b;null!==c&&C(c,b)}}function F(a,b){if("pending"===a.status||"blocked"===a.status){var c=a.value,d=a.reason;a.status="resolved_module";a.value=b;null!==c&&(z(a),D(a,c,d))}}var G=null,H=null;
16
+ function y(a){var b=G,c=H;G=a;H=null;try{var d=JSON.parse(a.value,a._response._fromJSON);null!==H&&0<H.deps?(H.value=d,a.status="blocked",a.value=null,a.reason=null):(a.status="fulfilled",a.value=d)}catch(e){a.status="rejected",a.reason=e}finally{G=b,H=c}}
17
+ function z(a){try{var b=a.value;if(b.async){var c=p.get(b.id);if("fulfilled"===c.status)var d=c.value;else throw c.reason;}else d=__webpack_require__(b.id);var e="*"===b.name?d:""===b.name?d.__esModule?d.default:d:d[b.name];a.status="fulfilled";a.value=e}catch(f){a.status="rejected",a.reason=f}}function I(a,b){a._chunks.forEach(function(a){"pending"===a.status&&E(a,b)})}function J(a,b){var c=a._chunks,d=c.get(b);d||(d=new x("pending",null,null,a),c.set(b,d));return d}
18
+ function K(a,b,c){if(H){var d=H;d.deps++}else d=H={deps:1,value:null};return function(e){b[c]=e;d.deps--;0===d.deps&&"blocked"===a.status&&(e=a.value,a.status="fulfilled",a.value=d.value,null!==e&&C(e,d.value))}}function M(a){return function(b){return E(a,b)}}
19
+ function N(a,b,c,d){if("$"===d[0]){if("$"===d)return t;switch(d[1]){case "$":return d.substring(1);case "L":return b=parseInt(d.substring(2),16),a=J(a,b),{$$typeof:u,_payload:a,_init:B};case "@":return b=parseInt(d.substring(2),16),J(a,b);case "S":return Symbol.for(d.substring(2));case "P":return a=d.substring(2),w[a]||(w[a]=h.createServerContext(a,v)),w[a].Provider;default:d=parseInt(d.substring(1),16);a=J(a,d);switch(a.status){case "resolved_model":y(a);break;case "resolved_module":z(a)}switch(a.status){case "fulfilled":return a.value;
20
+ case "pending":case "blocked":return d=G,a.then(K(d,b,c),M(d)),null;default:throw a.reason;}}}return d}function O(a,b,c){var d=a._chunks,e=d.get(b);c=JSON.parse(c,a._fromJSON);var f=m(a._bundlerConfig,c);if(c=r(f)){if(e){var k=e;k.status="blocked"}else k=new x("blocked",null,null,a),d.set(b,k);c.then(function(){return F(k,f)},function(a){return E(k,a)})}else e?F(e,f):d.set(b,new x("resolved_module",f,null,a))}function P(a){I(a,Error("Connection closed."))}
21
+ function Q(a,b){if(""!==b){var c=b.indexOf(":",0),d=parseInt(b.substring(0,c),16);switch(b[c+1]){case "I":O(a,d,b.substring(c+2));break;case "E":c=JSON.parse(b.substring(c+2)).digest;b=Error("An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.");b.stack="Error: "+b.message;b.digest=c;c=a._chunks;
22
+ var e=c.get(d);e?E(e,b):c.set(d,new x("rejected",null,b,a));break;default:b=b.substring(c+1),e=a._chunks,(c=e.get(d))?"pending"===c.status&&(a=c.value,d=c.reason,c.status="resolved_model",c.value=b,null!==a&&(y(c),D(c,a,d))):e.set(d,new x("resolved_model",b,null,a))}}}function R(a){return function(b,c){return"string"===typeof c?N(a,this,b,c):"object"===typeof c&&null!==c?(b=c[0]===t?{$$typeof:t,type:c[1],key:c[2],ref:null,props:c[3],_owner:null}:c,b):c}}
23
+ function S(a){var b=new TextDecoder,c=new Map;a={_bundlerConfig:a,_chunks:c,_partialRow:"",_stringDecoder:b};a._fromJSON=R(a);return a}function T(a,b){function c(b){var f=b.value;if(b.done)P(a);else{b=f;f=a._stringDecoder;for(var g=b.indexOf(10);-1<g;){var L=a._partialRow;var A=b.subarray(0,g);A=f.decode(A);Q(a,L+A);a._partialRow="";b=b.subarray(g+1);g=b.indexOf(10)}a._partialRow+=f.decode(b,l);return e.read().then(c).catch(d)}}function d(b){I(a,b)}var e=b.getReader();e.read().then(c).catch(d)}
24
+ exports.createFromFetch=function(a,b){var c=S(b&&b.moduleMap?b.moduleMap:null);a.then(function(a){T(c,a.body)},function(a){I(c,a)});return J(c,0)};exports.createFromReadableStream=function(a,b){b=S(b&&b.moduleMap?b.moduleMap:null);T(b,a);return J(b,0)};
25
+ exports.createFromXHR=function(a,b){function c(){for(var b=a.responseText,c=f,d=b.indexOf("\n",c);-1<d;)c=e._partialRow+b.substring(c,d),Q(e,c),e._partialRow="",c=d+1,d=b.indexOf("\n",c);e._partialRow+=b.substring(c);f=b.length}function d(){I(e,new TypeError("Network error"))}var e=S(b&&b.moduleMap?b.moduleMap:null),f=0;a.addEventListener("progress",c);a.addEventListener("load",function(){c();P(e)});a.addEventListener("error",d);a.addEventListener("abort",d);a.addEventListener("timeout",d);return J(e,
26
26
  0)};
@@ -41,9 +41,6 @@ module.exports = function register() {
41
41
 
42
42
  case 'defaultProps':
43
43
  return undefined;
44
-
45
- case 'getDefaultProps':
46
- return undefined;
47
44
  // Avoid this attempting to be serialized.
48
45
 
49
46
  case 'toJSON':
@@ -103,9 +100,6 @@ module.exports = function register() {
103
100
 
104
101
  case 'defaultProps':
105
102
  return undefined;
106
-
107
- case 'getDefaultProps':
108
- return undefined;
109
103
  // Avoid this attempting to be serialized.
110
104
 
111
105
  case 'toJSON':
@@ -149,11 +143,8 @@ module.exports = function register() {
149
143
  // If this module is expected to return a Promise (such as an AsyncModule) then
150
144
  // we should resolve that with a client reference that unwraps the Promise on
151
145
  // the client.
152
- var innerModuleId = target.filepath;
153
- var clientReference = Object.defineProperties(function () {
154
- throw new Error("Attempted to call the module exports of " + innerModuleId + " 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.");
155
- }, {
156
- // Represents the whole object instead of a particular import.
146
+ var clientReference = Object.defineProperties({}, {
147
+ // Represents the whole Module object instead of a particular import.
157
148
  name: {
158
149
  value: '*'
159
150
  },
@@ -238,10 +229,8 @@ module.exports = function register() {
238
229
 
239
230
  Module._extensions['.client.js'] = function (module, path) {
240
231
  var moduleId = url.pathToFileURL(path).href;
241
- var clientReference = Object.defineProperties(function () {
242
- throw new Error("Attempted to call the module exports of " + moduleId + " 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.");
243
- }, {
244
- // Represents the whole object instead of a particular import.
232
+ var clientReference = Object.defineProperties({}, {
233
+ // Represents the whole Module object instead of a particular import.
245
234
  name: {
246
235
  value: '*'
247
236
  },
@@ -169,7 +169,7 @@ function closeWithError(destination, error) {
169
169
  var stringify = JSON.stringify;
170
170
 
171
171
  function serializeRowHeader(tag, id) {
172
- return tag + id.toString(16) + ':';
172
+ return id.toString(16) + ':' + tag;
173
173
  }
174
174
 
175
175
  function processErrorChunkProd(request, id, digest) {
@@ -196,26 +196,17 @@ function processErrorChunkDev(request, id, digest, message, stack) {
196
196
  }
197
197
  function processModelChunk(request, id, model) {
198
198
  var json = stringify(model, request.toJSON);
199
- var row = serializeRowHeader('J', id) + json + '\n';
199
+ var row = id.toString(16) + ':' + json + '\n';
200
200
  return stringToChunk(row);
201
201
  }
202
202
  function processReferenceChunk(request, id, reference) {
203
203
  var json = stringify(reference);
204
- var row = serializeRowHeader('J', id) + json + '\n';
204
+ var row = id.toString(16) + ':' + json + '\n';
205
205
  return stringToChunk(row);
206
206
  }
207
207
  function processModuleChunk(request, id, moduleMetaData) {
208
208
  var json = stringify(moduleMetaData);
209
- var row = serializeRowHeader('M', id) + json + '\n';
210
- return stringToChunk(row);
211
- }
212
- function processProviderChunk(request, id, contextName) {
213
- var row = serializeRowHeader('P', id) + contextName + '\n';
214
- return stringToChunk(row);
215
- }
216
- function processSymbolChunk(request, id, name) {
217
- var json = stringify(name);
218
- var row = serializeRowHeader('S', id) + json + '\n';
209
+ var row = serializeRowHeader('I', id) + json + '\n';
219
210
  return stringToChunk(row);
220
211
  }
221
212
 
@@ -228,7 +219,7 @@ function isClientReference(reference) {
228
219
  return reference.$$typeof === CLIENT_REFERENCE_TAG;
229
220
  }
230
221
  function resolveModuleMetaData(config, clientReference) {
231
- var resolvedModuleData = config[clientReference.filepath][clientReference.name];
222
+ var resolvedModuleData = config.clientManifest[clientReference.filepath][clientReference.name];
232
223
 
233
224
  if (clientReference.async) {
234
225
  return {
@@ -1231,6 +1222,81 @@ var POP = {}; // Used for DEV messages to keep track of which parent rendered so
1231
1222
  var jsxPropsParents = new WeakMap();
1232
1223
  var jsxChildrenParents = new WeakMap();
1233
1224
 
1225
+ function serializeThenable(request, thenable) {
1226
+ request.pendingChunks++;
1227
+ var newTask = createTask(request, null, getActiveContext(), request.abortableTasks);
1228
+
1229
+ switch (thenable.status) {
1230
+ case 'fulfilled':
1231
+ {
1232
+ // We have the resolved value, we can go ahead and schedule it for serialization.
1233
+ newTask.model = thenable.value;
1234
+ pingTask(request, newTask);
1235
+ return newTask.id;
1236
+ }
1237
+
1238
+ case 'rejected':
1239
+ {
1240
+ var x = thenable.reason;
1241
+ var digest = logRecoverableError(request, x);
1242
+
1243
+ {
1244
+ var _getErrorMessageAndSt = getErrorMessageAndStackDev(x),
1245
+ message = _getErrorMessageAndSt.message,
1246
+ stack = _getErrorMessageAndSt.stack;
1247
+
1248
+ emitErrorChunkDev(request, newTask.id, digest, message, stack);
1249
+ }
1250
+
1251
+ return newTask.id;
1252
+ }
1253
+
1254
+ default:
1255
+ {
1256
+ if (typeof thenable.status === 'string') {
1257
+ // Only instrument the thenable if the status if not defined. If
1258
+ // it's defined, but an unknown value, assume it's been instrumented by
1259
+ // some custom userspace implementation. We treat it as "pending".
1260
+ break;
1261
+ }
1262
+
1263
+ var pendingThenable = thenable;
1264
+ pendingThenable.status = 'pending';
1265
+ pendingThenable.then(function (fulfilledValue) {
1266
+ if (thenable.status === 'pending') {
1267
+ var fulfilledThenable = thenable;
1268
+ fulfilledThenable.status = 'fulfilled';
1269
+ fulfilledThenable.value = fulfilledValue;
1270
+ }
1271
+ }, function (error) {
1272
+ if (thenable.status === 'pending') {
1273
+ var rejectedThenable = thenable;
1274
+ rejectedThenable.status = 'rejected';
1275
+ rejectedThenable.reason = error;
1276
+ }
1277
+ });
1278
+ break;
1279
+ }
1280
+ }
1281
+
1282
+ thenable.then(function (value) {
1283
+ newTask.model = value;
1284
+ pingTask(request, newTask);
1285
+ }, function (reason) {
1286
+ // TODO: Is it safe to directly emit these without being inside a retry?
1287
+ var digest = logRecoverableError(request, reason);
1288
+
1289
+ {
1290
+ var _getErrorMessageAndSt2 = getErrorMessageAndStackDev(reason),
1291
+ _message = _getErrorMessageAndSt2.message,
1292
+ _stack = _getErrorMessageAndSt2.stack;
1293
+
1294
+ emitErrorChunkDev(request, newTask.id, digest, _message, _stack);
1295
+ }
1296
+ });
1297
+ return newTask.id;
1298
+ }
1299
+
1234
1300
  function readThenable(thenable) {
1235
1301
  if (thenable.status === 'fulfilled') {
1236
1302
  return thenable.value;
@@ -1287,7 +1353,7 @@ function createLazyWrapperAroundWakeable(wakeable) {
1287
1353
  return lazyType;
1288
1354
  }
1289
1355
 
1290
- function attemptResolveElement(type, key, ref, props, prevThenableState) {
1356
+ function attemptResolveElement(request, type, key, ref, props, prevThenableState) {
1291
1357
  if (ref !== null && ref !== undefined) {
1292
1358
  // When the ref moves to the regular props object this will implicitly
1293
1359
  // throw for functions. We could probably relax it to a DEV warning for other
@@ -1314,6 +1380,16 @@ function attemptResolveElement(type, key, ref, props, prevThenableState) {
1314
1380
  var result = type(props);
1315
1381
 
1316
1382
  if (typeof result === 'object' && result !== null && typeof result.then === 'function') {
1383
+ // When the return value is in children position we can resolve it immediately,
1384
+ // to its value without a wrapper if it's synchronously available.
1385
+ var thenable = result;
1386
+
1387
+ if (thenable.status === 'fulfilled') {
1388
+ return thenable.value;
1389
+ } // TODO: Once we accept Promises as children on the client, we can just return
1390
+ // the thenable here.
1391
+
1392
+
1317
1393
  return createLazyWrapperAroundWakeable(result);
1318
1394
  }
1319
1395
 
@@ -1345,7 +1421,7 @@ function attemptResolveElement(type, key, ref, props, prevThenableState) {
1345
1421
  var payload = type._payload;
1346
1422
  var init = type._init;
1347
1423
  var wrappedType = init(payload);
1348
- return attemptResolveElement(wrappedType, key, ref, props, prevThenableState);
1424
+ return attemptResolveElement(request, wrappedType, key, ref, props, prevThenableState);
1349
1425
  }
1350
1426
 
1351
1427
  case REACT_FORWARD_REF_TYPE:
@@ -1357,7 +1433,7 @@ function attemptResolveElement(type, key, ref, props, prevThenableState) {
1357
1433
 
1358
1434
  case REACT_MEMO_TYPE:
1359
1435
  {
1360
- return attemptResolveElement(type.type, key, ref, props, prevThenableState);
1436
+ return attemptResolveElement(request, type.type, key, ref, props, prevThenableState);
1361
1437
  }
1362
1438
 
1363
1439
  case REACT_PROVIDER_TYPE:
@@ -1422,8 +1498,20 @@ function serializeByValueID(id) {
1422
1498
  return '$' + id.toString(16);
1423
1499
  }
1424
1500
 
1425
- function serializeByRefID(id) {
1426
- return '@' + id.toString(16);
1501
+ function serializeLazyID(id) {
1502
+ return '$L' + id.toString(16);
1503
+ }
1504
+
1505
+ function serializePromiseID(id) {
1506
+ return '$@' + id.toString(16);
1507
+ }
1508
+
1509
+ function serializeSymbolReference(name) {
1510
+ return '$S' + name;
1511
+ }
1512
+
1513
+ function serializeProviderReference(name) {
1514
+ return '$P' + name;
1427
1515
  }
1428
1516
 
1429
1517
  function serializeClientReference(request, parent, key, moduleReference) {
@@ -1438,7 +1526,7 @@ function serializeClientReference(request, parent, key, moduleReference) {
1438
1526
  // knows how to deal with lazy values. This lets us suspend
1439
1527
  // on this component rather than its parent until the code has
1440
1528
  // loaded.
1441
- return serializeByRefID(existingId);
1529
+ return serializeLazyID(existingId);
1442
1530
  }
1443
1531
 
1444
1532
  return serializeByValueID(existingId);
@@ -1457,7 +1545,7 @@ function serializeClientReference(request, parent, key, moduleReference) {
1457
1545
  // knows how to deal with lazy values. This lets us suspend
1458
1546
  // on this component rather than its parent until the code has
1459
1547
  // loaded.
1460
- return serializeByRefID(moduleId);
1548
+ return serializeLazyID(moduleId);
1461
1549
  }
1462
1550
 
1463
1551
  return serializeByValueID(moduleId);
@@ -1467,9 +1555,9 @@ function serializeClientReference(request, parent, key, moduleReference) {
1467
1555
  var digest = logRecoverableError(request, x);
1468
1556
 
1469
1557
  {
1470
- var _getErrorMessageAndSt = getErrorMessageAndStackDev(x),
1471
- message = _getErrorMessageAndSt.message,
1472
- stack = _getErrorMessageAndSt.stack;
1558
+ var _getErrorMessageAndSt3 = getErrorMessageAndStackDev(x),
1559
+ message = _getErrorMessageAndSt3.message,
1560
+ stack = _getErrorMessageAndSt3.stack;
1473
1561
 
1474
1562
  emitErrorChunkDev(request, errorId, digest, message, stack);
1475
1563
  }
@@ -1479,7 +1567,7 @@ function serializeClientReference(request, parent, key, moduleReference) {
1479
1567
  }
1480
1568
 
1481
1569
  function escapeStringValue(value) {
1482
- if (value[0] === '$' || value[0] === '@') {
1570
+ if (value[0] === '$') {
1483
1571
  // We need to escape $ or @ prefixed strings since we use those to encode
1484
1572
  // references to IDs and as special symbol values.
1485
1573
  return '$' + value;
@@ -1851,7 +1939,7 @@ function resolveModelToJSON(request, parent, key, value) {
1851
1939
  // TODO: Concatenate keys of parents onto children.
1852
1940
  var element = value; // Attempt to render the Server Component.
1853
1941
 
1854
- value = attemptResolveElement(element.type, element.key, element.ref, element.props, null);
1942
+ value = attemptResolveElement(request, element.type, element.key, element.ref, element.props, null);
1855
1943
  break;
1856
1944
  }
1857
1945
 
@@ -1878,7 +1966,7 @@ function resolveModelToJSON(request, parent, key, value) {
1878
1966
  var ping = newTask.ping;
1879
1967
  x.then(ping, ping);
1880
1968
  newTask.thenableState = getThenableStateAfterSuspending();
1881
- return serializeByRefID(newTask.id);
1969
+ return serializeLazyID(newTask.id);
1882
1970
  } else {
1883
1971
  // Something errored. We'll still send everything we have up until this point.
1884
1972
  // We'll replace this element with a lazy reference that throws on the client
@@ -1888,14 +1976,14 @@ function resolveModelToJSON(request, parent, key, value) {
1888
1976
  var digest = logRecoverableError(request, x);
1889
1977
 
1890
1978
  {
1891
- var _getErrorMessageAndSt2 = getErrorMessageAndStackDev(x),
1892
- message = _getErrorMessageAndSt2.message,
1893
- stack = _getErrorMessageAndSt2.stack;
1979
+ var _getErrorMessageAndSt4 = getErrorMessageAndStackDev(x),
1980
+ message = _getErrorMessageAndSt4.message,
1981
+ stack = _getErrorMessageAndSt4.stack;
1894
1982
 
1895
1983
  emitErrorChunkDev(request, errorId, digest, message, stack);
1896
1984
  }
1897
1985
 
1898
- return serializeByRefID(errorId);
1986
+ return serializeLazyID(errorId);
1899
1987
  }
1900
1988
  }
1901
1989
  }
@@ -1907,6 +1995,11 @@ function resolveModelToJSON(request, parent, key, value) {
1907
1995
  if (typeof value === 'object') {
1908
1996
  if (isClientReference(value)) {
1909
1997
  return serializeClientReference(request, parent, key, value);
1998
+ } else if (typeof value.then === 'function') {
1999
+ // We assume that any object with a .then property is a "Thenable" type,
2000
+ // or a Promise type. Either of which can be represented by a Promise.
2001
+ var promiseId = serializeThenable(request, value);
2002
+ return serializePromiseID(promiseId);
1910
2003
  } else if (value.$$typeof === REACT_PROVIDER_TYPE) {
1911
2004
  var providerKey = value._context._globalName;
1912
2005
  var writtenProviders = request.writtenProviders;
@@ -2066,12 +2159,14 @@ function emitModuleChunk(request, id, moduleMetaData) {
2066
2159
  }
2067
2160
 
2068
2161
  function emitSymbolChunk(request, id, name) {
2069
- var processedChunk = processSymbolChunk(request, id, name);
2162
+ var symbolReference = serializeSymbolReference(name);
2163
+ var processedChunk = processReferenceChunk(request, id, symbolReference);
2070
2164
  request.completedModuleChunks.push(processedChunk);
2071
2165
  }
2072
2166
 
2073
2167
  function emitProviderChunk(request, id, contextName) {
2074
- var processedChunk = processProviderChunk(request, id, contextName);
2168
+ var contextReference = serializeProviderReference(contextName);
2169
+ var processedChunk = processReferenceChunk(request, id, contextReference);
2075
2170
  request.completedJSONChunks.push(processedChunk);
2076
2171
  }
2077
2172
 
@@ -2096,7 +2191,7 @@ function retryTask(request, task) {
2096
2191
  // also suspends.
2097
2192
 
2098
2193
  task.model = value;
2099
- value = attemptResolveElement(element.type, element.key, element.ref, element.props, prevThenableState); // Successfully finished this component. We're going to keep rendering
2194
+ value = attemptResolveElement(request, element.type, element.key, element.ref, element.props, prevThenableState); // Successfully finished this component. We're going to keep rendering
2100
2195
  // using the same task, but we reset its thenable state before continuing.
2101
2196
 
2102
2197
  task.thenableState = null; // Keep rendering and reuse the same task. This inner loop is separate
@@ -2107,7 +2202,7 @@ function retryTask(request, task) {
2107
2202
  // TODO: Concatenate keys of parents onto children.
2108
2203
  var nextElement = value;
2109
2204
  task.model = value;
2110
- value = attemptResolveElement(nextElement.type, nextElement.key, nextElement.ref, nextElement.props, null);
2205
+ value = attemptResolveElement(request, nextElement.type, nextElement.key, nextElement.ref, nextElement.props, null);
2111
2206
  }
2112
2207
  }
2113
2208
 
@@ -2135,9 +2230,9 @@ function retryTask(request, task) {
2135
2230
  var digest = logRecoverableError(request, x);
2136
2231
 
2137
2232
  {
2138
- var _getErrorMessageAndSt3 = getErrorMessageAndStackDev(x),
2139
- message = _getErrorMessageAndSt3.message,
2140
- stack = _getErrorMessageAndSt3.stack;
2233
+ var _getErrorMessageAndSt5 = getErrorMessageAndStackDev(x),
2234
+ message = _getErrorMessageAndSt5.message,
2235
+ stack = _getErrorMessageAndSt5.stack;
2141
2236
 
2142
2237
  emitErrorChunkDev(request, task.id, digest, message, stack);
2143
2238
  }
@@ -2303,9 +2398,9 @@ function abort(request, reason) {
2303
2398
  var errorId = request.nextChunkId++;
2304
2399
 
2305
2400
  if (true) {
2306
- var _getErrorMessageAndSt4 = getErrorMessageAndStackDev(error),
2307
- message = _getErrorMessageAndSt4.message,
2308
- stack = _getErrorMessageAndSt4.stack;
2401
+ var _getErrorMessageAndSt6 = getErrorMessageAndStackDev(error),
2402
+ message = _getErrorMessageAndSt6.message,
2403
+ stack = _getErrorMessageAndSt6.stack;
2309
2404
 
2310
2405
  emitErrorChunkDev(request, errorId, digest, message, stack);
2311
2406
  } else {
@@ -2348,8 +2443,8 @@ function importServerContexts(contexts) {
2348
2443
  return rootContextSnapshot;
2349
2444
  }
2350
2445
 
2351
- function renderToReadableStream(model, webpackMap, options) {
2352
- var request = createRequest(model, webpackMap, options ? options.onError : undefined, options ? options.context : undefined, options ? options.identifierPrefix : undefined);
2446
+ function renderToReadableStream(model, webpackMaps, options) {
2447
+ var request = createRequest(model, webpackMaps, options ? options.onError : undefined, options ? options.context : undefined, options ? options.identifierPrefix : undefined);
2353
2448
 
2354
2449
  if (options && options.signal) {
2355
2450
  var signal = options.signal;