react-server-dom-webpack
Version:
React Server Components bindings for DOM using Webpack. This is intended to be integrated into meta-frameworks. It is not intended to be imported directly.
33 lines (31 loc) • 11.6 kB
JavaScript
/**
* @license React
* react-server-dom-webpack-client.browser.production.min.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
;(function(){(function(r,w){"object"===typeof exports&&"undefined"!==typeof module?w(exports,require("react-dom")):"function"===typeof define&&define.amd?define(["exports","react-dom"],w):(r="undefined"!==typeof globalThis?globalThis:r||self,w(r.ReactServerDOMClient={},r.ReactDOM))})(this,function(r,w){function S(a,b){if(a){var c=a[b[0]];if(a=c[b[2]])c=a.name;else{a=c["*"];if(!a)throw Error('Could not find the module "'+b[0]+'" in the React SSR Manifest. This is probably a bug in the React Server Components bundler.');
c=b[2]}return 4===b.length?[a.id,a.chunks,c,1]:[a.id,a.chunks,c]}return b}function J(a){var b=__webpack_require__(a);if("function"!==typeof b.then||"fulfilled"===b.status)return null;b.then(function(c){b.status="fulfilled";b.value=c},function(c){b.status="rejected";b.reason=c});return b}function T(){}function U(a){for(var b=a[1],c=[],e=0;e<b.length;){var k=b[e++],l=b[e++],n=z.get(k);void 0===n?(K.set(k,l),l=__webpack_chunk_load__(k),c.push(l),n=z.set.bind(z,k,null),l.then(n,T),z.set(k,l)):null!==
n&&c.push(n)}return 4===a.length?0===c.length?J(a[0]):Promise.all(c).then(function(){return J(a[0])}):0<c.length?Promise.all(c):null}function V(a){if(null===a||"object"!==typeof a)return null;a=L&&a[L]||a["@@iterator"];return"function"===typeof a?a:null}function W(a){return Number.isFinite(a)?0===a&&-Infinity===1/a?"$-0":a:Infinity===a?"$Infinity":-Infinity===a?"$-Infinity":"$NaN"}function X(a,b,c,e){function k(m,d){if(null===d)return null;if("object"===typeof d){if("function"===typeof d.then){null===
g&&(g=new FormData);n++;var h=l++;d.then(function(p){p=JSON.stringify(p,k);var q=g;q.append(b+h,p);n--;0===n&&c(q)},function(p){e(p)});return"$@"+h.toString(16)}if(Y(d))return d;if(d instanceof FormData){null===g&&(g=new FormData);var f=g;m=l++;var D=b+m+"_";d.forEach(function(p,q){f.append(D+q,p)});return"$K"+m.toString(16)}if(d instanceof Map)return d=JSON.stringify(Array.from(d),k),null===g&&(g=new FormData),m=l++,g.append(b+m,d),"$Q"+m.toString(16);if(d instanceof Set)return d=JSON.stringify(Array.from(d),
k),null===g&&(g=new FormData),m=l++,g.append(b+m,d),"$W"+m.toString(16);if(V(d))return Array.from(d);m=M(d);if(m!==Z&&(null===m||null!==M(m)))throw Error("Only plain objects, and a few built-ins, can be passed to Server Actions. Classes or null prototypes are not supported.");return d}if("string"===typeof d){if("Z"===d[d.length-1]&&this[m]instanceof Date)return"$D"+d;d="$"===d[0]?"$"+d:d;return d}if("boolean"===typeof d)return d;if("number"===typeof d)return W(d);if("undefined"===typeof d)return"$undefined";
if("function"===typeof d){d=E.get(d);if(void 0!==d)return d=JSON.stringify(d,k),null===g&&(g=new FormData),m=l++,g.set(b+m,d),"$F"+m.toString(16);throw Error("Client Functions cannot be passed directly to Server Functions. Only Functions passed from the Server can be passed back again.");}if("symbol"===typeof d){m=d.description;if(Symbol.for(m)!==d)throw Error("Only global symbols received from Symbol.for(...) can be passed to Server Functions. The symbol Symbol.for("+(d.description+") cannot be found among global symbols."));
return"$S"+m}if("bigint"===typeof d)return"$n"+d.toString(10);throw Error("Type "+typeof d+" is not supported as an argument to a Server Function.");}var l=1,n=0,g=null;a=JSON.stringify(a,k);null===g?c(a):(g.set(b+"0",a),0===n&&c(g))}function aa(a,b,c){E.set(a,b)}function u(a,b,c,e){this.status=a;this.value=b;this.reason=c;this._response=e}function ba(a){switch(a.status){case "resolved_model":x(a);break;case "resolved_module":A(a)}switch(a.status){case "fulfilled":return a.value;case "pending":case "blocked":case "cyclic":throw a;
default:throw a.reason;}}function y(a,b){for(var c=0;c<a.length;c++)(0,a[c])(b)}function N(a,b,c){switch(a.status){case "fulfilled":y(b,a.value);break;case "pending":case "blocked":case "cyclic":a.value=b;a.reason=c;break;case "rejected":c&&y(c,a.reason)}}function B(a,b){if("pending"===a.status||"blocked"===a.status){var c=a.reason;a.status="rejected";a.reason=b;null!==c&&y(c,b)}}function O(a,b){if("pending"===a.status||"blocked"===a.status){var c=a.value,e=a.reason;a.status="resolved_module";a.value=
b;null!==c&&(A(a),N(a,c,e))}}function x(a){var b=C,c=t;C=a;t=null;var e=a.value;a.status="cyclic";a.value=null;a.reason=null;try{var k=JSON.parse(e,a._response._fromJSON);if(null!==t&&0<t.deps)t.value=k,a.status="blocked",a.value=null,a.reason=null;else{var l=a.value;a.status="fulfilled";a.value=k;null!==l&&y(l,k)}}catch(n){a.status="rejected",a.reason=n}finally{C=b,t=c}}function A(a){try{var b=a.value,c=__webpack_require__(b[0]);if(4===b.length&&"function"===typeof c.then)if("fulfilled"===c.status)c=
c.value;else throw c.reason;var e="*"===b[2]?c:""===b[2]?c.__esModule?c.default:c:c[b[2]];a.status="fulfilled";a.value=e}catch(k){a.status="rejected",a.reason=k}}function F(a,b){a._chunks.forEach(function(c){"pending"===c.status&&B(c,b)})}function v(a,b){var c=a._chunks,e=c.get(b);e||(e=new u("pending",null,null,a),c.set(b,e));return e}function ca(a,b,c,e){if(t){var k=t;e||k.deps++}else k=t={deps:e?0:1,value:null};return function(l){b[c]=l;k.deps--;0===k.deps&&"blocked"===a.status&&(l=a.value,a.status=
"fulfilled",a.value=k.value,null!==l&&y(l,k.value))}}function da(a){return function(b){return B(a,b)}}function ea(a,b){var c=a._callServer;a=function(){var e=Array.prototype.slice.call(arguments),k=b.bound;return k?"fulfilled"===k.status?c(b.id,k.value.concat(e)):Promise.resolve(k).then(function(l){return c(b.id,l.concat(e))}):c(b.id,e)};E.set(a,b);return a}function G(a,b){a=v(a,b);switch(a.status){case "resolved_model":x(a)}switch(a.status){case "fulfilled":return a.value;default:throw a.reason;
}}function fa(a,b,c,e){if("$"===e[0]){if("$"===e)return H;switch(e[1]){case "$":return e.slice(1);case "L":return b=parseInt(e.slice(2),16),a=v(a,b),{$$typeof:ha,_payload:a,_init:ba};case "@":return b=parseInt(e.slice(2),16),v(a,b);case "S":return Symbol.for(e.slice(2));case "F":return b=parseInt(e.slice(2),16),b=G(a,b),ea(a,b);case "Q":return b=parseInt(e.slice(2),16),a=G(a,b),new Map(a);case "W":return b=parseInt(e.slice(2),16),a=G(a,b),new Set(a);case "I":return Infinity;case "-":return"$-0"===
e?-0:-Infinity;case "N":return NaN;case "u":return;case "D":return new Date(Date.parse(e.slice(2)));case "n":return BigInt(e.slice(2));default:e=parseInt(e.slice(1),16);a=v(a,e);switch(a.status){case "resolved_model":x(a);break;case "resolved_module":A(a)}switch(a.status){case "fulfilled":return a.value;case "pending":case "blocked":case "cyclic":return e=C,a.then(ca(e,b,c,"cyclic"===a.status),da(e)),null;default:throw a.reason;}}}return e}function ia(){throw Error('Trying to call a function from "use server" but the callServer option was not implemented in your router runtime.');
}function P(a,b,c,e,k){var l=new Map;a={_bundlerConfig:a,_moduleLoading:b,_callServer:void 0!==c?c:ia,_encodeFormAction:e,_nonce:k,_chunks:l,_stringDecoder:new TextDecoder,_fromJSON:null,_rowState:0,_rowID:0,_rowTag:0,_rowLength:0,_buffer:[]};a._fromJSON=ja(a);return a}function ka(a,b,c){var e=a._chunks,k=e.get(b);c=JSON.parse(c,a._fromJSON);var l=S(a._bundlerConfig,c);if(c=U(l)){if(k){var n=k;n.status="blocked"}else n=new u("blocked",null,null,a),e.set(b,n);c.then(function(){return O(n,l)},function(g){return B(n,
g)})}else k?O(k,l):e.set(b,new u("resolved_module",l,null,a))}function ja(a){return function(b,c){return"string"===typeof c?fa(a,this,b,c):"object"===typeof c&&null!==c?(b=c[0]===H?{$$typeof:H,type:c[1],key:c[2],ref:null,props:c[3],_owner:null}:c,b):c}}function Q(a,b){function c(l){var n=l.value;if(l.done)F(a,Error("Connection closed."));else{var g=0,m=a._rowState,d=a._rowID,h=a._rowTag,f=a._rowLength;l=a._buffer;for(var D=n.length;g<D;){var p=-1;switch(m){case 0:p=n[g++];58===p?m=1:d=d<<4|(96<p?
p-87:p-48);continue;case 1:m=n[g];84===m?(h=m,m=2,g++):64<m&&91>m?(h=m,m=3,g++):(h=0,m=3);continue;case 2:p=n[g++];44===p?m=4:f=f<<4|(96<p?p-87:p-48);continue;case 3:p=n.indexOf(10,g);break;case 4:p=g+f,p>n.length&&(p=-1)}var q=n.byteOffset+g;if(-1<p){g=new Uint8Array(n.buffer,q,p-g);f=a;q=h;var R=f._stringDecoder;h="";for(var I=0;I<l.length;I++)h+=R.decode(l[I],la);h+=R.decode(g);switch(q){case 73:ka(f,d,h);break;case 72:d=h[0];h=h.slice(1);f=JSON.parse(h,f._fromJSON);if(h=ma.current)switch(d){case "D":h.prefetchDNS(f);
break;case "C":"string"===typeof f?h.preconnect(f):h.preconnect(f[0],f[1]);break;case "L":d=f[0];g=f[1];3===f.length?h.preload(d,g,f[2]):h.preload(d,g);break;case "m":"string"===typeof f?h.preloadModule(f):h.preloadModule(f[0],f[1]);break;case "S":"string"===typeof f?h.preinitStyle(f):h.preinitStyle(f[0],0===f[1]?void 0:f[1],3===f.length?f[2]:void 0);break;case "X":"string"===typeof f?h.preinitScript(f):h.preinitScript(f[0],f[1]);break;case "M":"string"===typeof f?h.preinitModuleScript(f):h.preinitModuleScript(f[0],
f[1])}break;case 69:h=JSON.parse(h);g=h.digest;h=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.");h.stack="Error: "+h.message;h.digest=g;g=f._chunks;(q=g.get(d))?B(q,h):g.set(d,new u("rejected",null,h,f));break;case 84:f._chunks.set(d,new u("fulfilled",h,null,f));break;case 68:throw Error("Failed to read a RSC payload created by a development version of React on the server while using a production version on the client. Always use matching versions on the server and the client.");
default:g=f._chunks,(q=g.get(d))?(f=q,d=h,"pending"===f.status&&(h=f.value,g=f.reason,f.status="resolved_model",f.value=d,null!==h&&(x(f),N(f,h,g)))):g.set(d,new u("resolved_model",h,null,f))}g=p;3===m&&g++;f=d=h=m=0;l.length=0}else{n=new Uint8Array(n.buffer,q,n.byteLength-g);l.push(n);f-=n.byteLength;break}}a._rowState=m;a._rowID=d;a._rowTag=h;a._rowLength=f;return k.read().then(c).catch(e)}}function e(l){F(a,l)}var k=b.getReader();k.read().then(c).catch(e)}var la={stream:!0},z=new Map,K=new Map,
na=__webpack_require__.u;__webpack_require__.u=function(a){var b=K.get(a);return void 0!==b?b:na(a)};var ma=w.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Dispatcher,H=Symbol.for("react.element"),ha=Symbol.for("react.lazy"),L=Symbol.iterator,Y=Array.isArray,M=Object.getPrototypeOf,Z=Object.prototype,E=new WeakMap;u.prototype=Object.create(Promise.prototype);u.prototype.then=function(a,b){switch(this.status){case "resolved_model":x(this);break;case "resolved_module":A(this)}switch(this.status){case "fulfilled":a(this.value);
break;case "pending":case "blocked":case "cyclic":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)}};var C=null,t=null;r.createFromFetch=function(a,b){var c=P(null,null,b&&b.callServer?b.callServer:void 0,void 0,void 0);a.then(function(e){Q(c,e.body)},function(e){F(c,e)});return v(c,0)};r.createFromReadableStream=function(a,b){b=P(null,null,b&&b.callServer?b.callServer:void 0,void 0,void 0);Q(b,a);
return v(b,0)};r.createServerReference=function(a,b,c){c=function(){var e=Array.prototype.slice.call(arguments);return b(a,e)};aa(c,{id:a,bound:null});return c};r.encodeReply=function(a){return new Promise(function(b,c){X(a,"",b,c)})}})})();