UNPKG

next

Version:

The React Framework

39 lines (38 loc) • 12.3 kB
/** * @license React * react-server-dom-webpack-client.edge.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. */ 'use strict';var p=require("react-dom"),q=require("react"),r={stream:!0};function u(a,b){if(a){var c=a[b.id];if(a=c[b.name])c=a.name;else{a=c["*"];if(!a)throw Error('Could not find the module "'+b.id+'" in the React SSR Manifest. This is probably a bug in the React Server Components bundler.');c=b.name}return{id:a.id,chunks:a.chunks,name:c,async:!!b.async}}return b}var w=new Map; function x(a){var b=globalThis.__next_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 y(){} function z(a){for(var b=a.chunks,c=[],d=0;d<b.length;d++){var e=b[d],k=w.get(e);if(void 0===k){k=globalThis.__next_chunk_load__(e);c.push(k);var f=w.set.bind(w,e,null);k.then(f,y);w.set(e,k)}else null!==k&&c.push(k)}return a.async?0===c.length?x(a.id):Promise.all(c).then(function(){return x(a.id)}):0<c.length?Promise.all(c):null}var A=p.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Dispatcher,B=Symbol.for("react.element"),aa=Symbol.for("react.lazy"),ba=Symbol.for("react.default_value"),C=Symbol.iterator; function ca(a){if(null===a||"object"!==typeof a)return null;a=C&&a[C]||a["@@iterator"];return"function"===typeof a?a:null}var da=Array.isArray,D=new WeakMap;function ea(a){return Number.isFinite(a)?0===a&&-Infinity===1/a?"$-0":a:Infinity===a?"$Infinity":-Infinity===a?"$-Infinity":"$NaN"} function fa(a,b,c,d){function e(g,h){if(null===h)return null;if("object"===typeof h){if("function"===typeof h.then){null===l&&(l=new FormData);f++;var n=k++;h.then(function(m){m=JSON.stringify(m,e);var t=l;t.append(b+n,m);f--;0===f&&c(t)},function(m){d(m)});return"$@"+n.toString(16)}if(h instanceof FormData){null===l&&(l=new FormData);var v=l;g=k++;var E=b+g+"_";h.forEach(function(m,t){v.append(E+t,m)});return"$K"+g.toString(16)}return h instanceof Map?(h=JSON.stringify(Array.from(h),e),null===l&& (l=new FormData),g=k++,l.append(b+g,h),"$Q"+g.toString(16)):h instanceof Set?(h=JSON.stringify(Array.from(h),e),null===l&&(l=new FormData),g=k++,l.append(b+g,h),"$W"+g.toString(16)):!da(h)&&ca(h)?Array.from(h):h}if("string"===typeof h){if("Z"===h[h.length-1]&&this[g]instanceof Date)return"$D"+h;h="$"===h[0]?"$"+h:h;return h}if("boolean"===typeof h)return h;if("number"===typeof h)return ea(h);if("undefined"===typeof h)return"$undefined";if("function"===typeof h){h=D.get(h);if(void 0!==h)return h=JSON.stringify(h, e),null===l&&(l=new FormData),g=k++,l.set(b+g,h),"$F"+g.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 h){g=h.description;if(Symbol.for(g)!==h)throw Error("Only global symbols received from Symbol.for(...) can be passed to Server Functions. The symbol Symbol.for("+(h.description+") cannot be found among global symbols."));return"$S"+g}if("bigint"===typeof h)return"$n"+ h.toString(10);throw Error("Type "+typeof h+" is not supported as an argument to a Server Function.");}var k=1,f=0,l=null;a=JSON.stringify(a,e);null===l?c(a):(l.set(b+"0",a),0===f&&c(l))}var F=new WeakMap;function ha(a){var b,c,d=new Promise(function(e,k){b=e;c=k});fa(a,"",function(e){if("string"===typeof e){var k=new FormData;k.append("0",e);e=k}d.status="fulfilled";d.value=e;b(e)},function(e){d.status="rejected";d.reason=e;c(e)});return d} function G(a){var b=D.get(this);if(!b)throw Error("Tried to encode a Server Action from a different instance than the encoder is from. This is a bug in React.");var c=null;if(null!==b.bound){c=F.get(b);c||(c=ha(b),F.set(b,c));if("rejected"===c.status)throw c.reason;if("fulfilled"!==c.status)throw c;b=c.value;var d=new FormData;b.forEach(function(e,k){d.append("$ACTION_"+a+":"+k,e)});c=d;b="$ACTION_REF_"+a}else b="$ACTION_ID_"+b.id;return{name:b,method:"POST",encType:"multipart/form-data",data:c}} function ia(a,b){function c(){var d=Array.prototype.slice.call(arguments);return b(a,d)}c.$$FORM_ACTION=G;D.set(c,{id:a,bound:null});return c}var H=q.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ContextRegistry;function I(a,b,c,d){this.status=a;this.value=b;this.reason=c;this._response=d}I.prototype=Object.create(Promise.prototype); I.prototype.then=function(a,b){switch(this.status){case "resolved_model":J(this);break;case "resolved_module":K(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)}}; function ja(a){switch(a.status){case "resolved_model":J(a);break;case "resolved_module":K(a)}switch(a.status){case "fulfilled":return a.value;case "pending":case "blocked":throw a;default:throw a.reason;}}function L(a,b){for(var c=0;c<a.length;c++)(0,a[c])(b)}function M(a,b,c){switch(a.status){case "fulfilled":L(b,a.value);break;case "pending":case "blocked":a.value=b;a.reason=c;break;case "rejected":c&&L(c,a.reason)}} function N(a,b){if("pending"===a.status||"blocked"===a.status){var c=a.reason;a.status="rejected";a.reason=b;null!==c&&L(c,b)}}function O(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&&(K(a),M(a,c,d))}}var P=null,Q=null; function J(a){var b=P,c=Q;P=a;Q=null;try{var d=JSON.parse(a.value,a._response._fromJSON);null!==Q&&0<Q.deps?(Q.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{P=b,Q=c}} function K(a){try{var b=a.value,c=globalThis.__next_require__(b.id);if(b.async&&"function"===typeof c.then)if("fulfilled"===c.status)c=c.value;else throw c.reason;var d="*"===b.name?c:""===b.name?c.__esModule?c.default:c:c[b.name];a.status="fulfilled";a.value=d}catch(e){a.status="rejected",a.reason=e}}function R(a,b){a._chunks.forEach(function(c){"pending"===c.status&&N(c,b)})}function S(a,b){var c=a._chunks,d=c.get(b);d||(d=new I("pending",null,null,a),c.set(b,d));return d} function ka(a,b,c){if(Q){var d=Q;d.deps++}else d=Q={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&&L(e,d.value))}}function la(a){return function(b){return N(a,b)}} function ma(a,b){function c(){var e=Array.prototype.slice.call(arguments),k=b.bound;return k?"fulfilled"===k.status?d(b.id,k.value.concat(e)):Promise.resolve(k).then(function(f){return d(b.id,f.concat(e))}):d(b.id,e)}var d=a._callServer;c.$$FORM_ACTION=G;D.set(c,b);return c}function T(a,b){a=S(a,b);switch(a.status){case "resolved_model":J(a)}switch(a.status){case "fulfilled":return a.value;default:throw a.reason;}} function na(a,b,c,d){if("$"===d[0]){if("$"===d)return B;switch(d[1]){case "$":return d.slice(1);case "L":return b=parseInt(d.slice(2),16),a=S(a,b),{$$typeof:aa,_payload:a,_init:ja};case "@":return b=parseInt(d.slice(2),16),S(a,b);case "S":return Symbol.for(d.slice(2));case "P":return a=d.slice(2),H[a]||(H[a]=q.createServerContext(a,ba)),H[a].Provider;case "F":return b=parseInt(d.slice(2),16),b=T(a,b),ma(a,b);case "Q":return b=parseInt(d.slice(2),16),a=T(a,b),new Map(a);case "W":return b=parseInt(d.slice(2), 16),a=T(a,b),new Set(a);case "I":return Infinity;case "-":return"$-0"===d?-0:-Infinity;case "N":return NaN;case "u":return;case "D":return new Date(Date.parse(d.slice(2)));case "n":return BigInt(d.slice(2));default:d=parseInt(d.slice(1),16);a=S(a,d);switch(a.status){case "resolved_model":J(a);break;case "resolved_module":K(a)}switch(a.status){case "fulfilled":return a.value;case "pending":case "blocked":return d=P,a.then(ka(d,b,c),la(d)),null;default:throw a.reason;}}}return d} function oa(){throw Error('Trying to call a function from "use server" but the callServer option was not implemented in your router runtime.');}function U(a,b){var c=new Map;a={_bundlerConfig:a,_callServer:void 0!==b?b:oa,_chunks:c,_stringDecoder:new TextDecoder,_fromJSON:null,_rowState:0,_rowID:0,_rowTag:0,_rowLength:0,_buffer:[]};a._fromJSON=pa(a);return a}function V(a,b,c){a._chunks.set(b,new I("fulfilled",c,null,a))} function qa(a,b,c){var d=a._chunks,e=d.get(b);c=JSON.parse(c,a._fromJSON);var k=u(a._bundlerConfig,c);if(c=z(k)){if(e){var f=e;f.status="blocked"}else f=new I("blocked",null,null,a),d.set(b,f);c.then(function(){return O(f,k)},function(l){return N(f,l)})}else e?O(e,k):d.set(b,new I("resolved_module",k,null,a))}function W(a,b){for(var c=a.length,d=b.length,e=0;e<c;e++)d+=a[e].byteLength;d=new Uint8Array(d);for(var k=e=0;k<c;k++){var f=a[k];d.set(f,e);e+=f.byteLength}d.set(b,e);return d} function X(a,b,c,d,e,k){c=0===c.length&&0===d.byteOffset%k?d:W(c,d);e=new e(c.buffer,c.byteOffset,c.byteLength/k);V(a,b,e)} function ra(a,b,c,d,e){switch(c){case 65:V(a,b,W(d,e).buffer);return;case 67:X(a,b,d,e,Int8Array,1);return;case 99:V(a,b,0===d.length?e:W(d,e));return;case 85:X(a,b,d,e,Uint8ClampedArray,1);return;case 83:X(a,b,d,e,Int16Array,2);return;case 115:X(a,b,d,e,Uint16Array,2);return;case 76:X(a,b,d,e,Int32Array,4);return;case 108:X(a,b,d,e,Uint32Array,4);return;case 70:X(a,b,d,e,Float32Array,4);return;case 68:X(a,b,d,e,Float64Array,8);return;case 78:X(a,b,d,e,BigInt64Array,8);return;case 109:X(a,b,d,e,BigUint64Array, 8);return;case 86:X(a,b,d,e,DataView,1);return}for(var k=a._stringDecoder,f="",l=0;l<d.length;l++)f+=k.decode(d[l],r);f+=k.decode(e);switch(c){case 73:qa(a,b,f);break;case 72:b=f[0];f=f.slice(1);a=JSON.parse(f,a._fromJSON);if(f=A.current){if("string"===typeof a)c=a;else{c=a[0];var g=a[1]}switch(b){case "D":f.prefetchDNS(c,g);break;case "C":f.preconnect(c,g);break;case "L":f.preload(c,g);break;case "I":f.preinit(c,g)}}break;case 69:f=JSON.parse(f).digest;g=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."); g.stack="Error: "+g.message;g.digest=f;f=a._chunks;(c=f.get(b))?N(c,g):f.set(b,new I("rejected",null,g,a));break;case 84:a._chunks.set(b,new I("fulfilled",f,null,a));break;default:g=f,c=a._chunks,(f=c.get(b))?"pending"===f.status&&(a=f.value,b=f.reason,f.status="resolved_model",f.value=g,null!==a&&(J(f),M(f,a,b))):c.set(b,new I("resolved_model",g,null,a))}} function pa(a){return function(b,c){return"string"===typeof c?na(a,this,b,c):"object"===typeof c&&null!==c?(b=c[0]===B?{$$typeof:B,type:c[1],key:c[2],ref:null,props:c[3],_owner:null}:c,b):c}}function Y(){throw Error("Server Functions cannot be called during initial render. This would create a fetch waterfall. Try to use a Server Component to pass data to Client Components instead.");} function Z(a,b){function c(k){var f=k.value;if(k.done)R(a,Error("Connection closed."));else{var l=0,g=a._rowState;k=a._rowID;for(var h=a._rowTag,n=a._rowLength,v=a._buffer,E=f.length;l<E;){var m=-1;switch(g){case 0:m=f[l++];58===m?g=1:k=k<<4|(96<m?m-87:m-48);continue;case 1:g=f[l];84===g||65===g||67===g||99===g||85===g||83===g||115===g||76===g||108===g||70===g||68===g||78===g||109===g||86===g?(h=g,g=2,l++):64<g&&91>g?(h=g,g=3,l++):(h=0,g=3);continue;case 2:m=f[l++];44===m?g=4:n=n<<4|(96<m?m-87:m- 48);continue;case 3:m=f.indexOf(10,l);break;case 4:m=l+n,m>f.length&&(m=-1)}var t=f.byteOffset+l;if(-1<m)n=new Uint8Array(f.buffer,t,m-l),ra(a,k,h,v,n),l=m,3===g&&l++,n=k=h=g=0,v.length=0;else{f=new Uint8Array(f.buffer,t,f.byteLength-l);v.push(f);n-=f.byteLength;break}}a._rowState=g;a._rowID=k;a._rowTag=h;a._rowLength=n;return e.read().then(c).catch(d)}}function d(k){R(a,k)}var e=b.getReader();e.read().then(c).catch(d)} exports.createFromFetch=function(a,b){var c=U(b&&b.moduleMap?b.moduleMap:null,Y);a.then(function(d){Z(c,d.body)},function(d){R(c,d)});return S(c,0)};exports.createFromReadableStream=function(a,b){b=U(b&&b.moduleMap?b.moduleMap:null,Y);Z(b,a);return S(b,0)};exports.createServerReference=function(a){return ia(a,Y)};