react-server-dom-webpack
Advanced tools
Comparing version 0.0.0-experimental-9209c30ff to 0.0.0-experimental-9212d994b
@@ -22,2 +22,8 @@ /** @license React vundefined | ||
var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare | ||
function isArray(a) { | ||
return isArrayImpl(a); | ||
} | ||
class ClientReferenceDependency extends ModuleDependency { | ||
@@ -58,3 +64,3 @@ constructor(request) { | ||
}]; | ||
} else if (typeof options.clientReferences === 'string' || !Array.isArray(options.clientReferences)) { | ||
} else if (typeof options.clientReferences === 'string' || !isArray(options.clientReferences)) { | ||
this.clientReferences = [options.clientReferences]; | ||
@@ -61,0 +67,0 @@ } else { |
@@ -57,4 +57,4 @@ /** @license React vundefined | ||
} | ||
function writeChunk(destination, buffer) { | ||
destination.enqueue(buffer); | ||
function writeChunk(destination, chunk) { | ||
destination.enqueue(chunk); | ||
return destination.desiredSize > 0; | ||
@@ -66,5 +66,19 @@ } | ||
var textEncoder = new TextEncoder(); | ||
function convertStringToBuffer(content) { | ||
function stringToChunk(content) { | ||
return textEncoder.encode(content); | ||
} | ||
function closeWithError(destination, error) { | ||
if (typeof destination.error === 'function') { | ||
// $FlowFixMe: This is an Error object or the destination accepts other types. | ||
destination.error(error); | ||
} else { | ||
// Earlier implementations doesn't support this method. In that environment you're | ||
// supposed to throw from a promise returned but we don't return a promise in our | ||
// approach. We could fork this implementation but this is environment is an edge | ||
// case to begin with. It's even less common to run this in an older environment. | ||
// Even then, this is not where errors are supposed to happen and they get reported | ||
// to a global callback in addition to this anyway. So it's fine just to close this. | ||
destination.close(); | ||
} | ||
} | ||
@@ -84,3 +98,3 @@ // This file is an intermediate layer to translate between Flight | ||
var row = serializeRowHeader('E', id) + stringify(errorInfo) + '\n'; | ||
return convertStringToBuffer(row); | ||
return stringToChunk(row); | ||
} | ||
@@ -90,3 +104,3 @@ function processModelChunk(request, id, model) { | ||
var row = serializeRowHeader('J', id) + json + '\n'; | ||
return convertStringToBuffer(row); | ||
return stringToChunk(row); | ||
} | ||
@@ -96,3 +110,3 @@ function processModuleChunk(request, id, moduleMetaData) { | ||
var row = serializeRowHeader('M', id) + json + '\n'; | ||
return convertStringToBuffer(row); | ||
return stringToChunk(row); | ||
} | ||
@@ -102,3 +116,3 @@ function processSymbolChunk(request, id, name) { | ||
var row = serializeRowHeader('S', id) + json + '\n'; | ||
return convertStringToBuffer(row); | ||
return stringToChunk(row); | ||
} | ||
@@ -164,5 +178,15 @@ | ||
var isArray = Array.isArray; | ||
var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare | ||
function isArray(a) { | ||
return isArrayImpl(a); | ||
} | ||
var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher; | ||
function createRequest(model, destination, bundlerConfig) { | ||
function defaultErrorHandler(error) { | ||
console['error'](error); // Don't transform to our wrapper | ||
} | ||
function createRequest(model, destination, bundlerConfig, onError) { | ||
var pingedSegments = []; | ||
@@ -181,2 +205,3 @@ var request = { | ||
writtenModules: new Map(), | ||
onError: onError === undefined ? defaultErrorHandler : onError, | ||
flowing: false, | ||
@@ -492,5 +517,6 @@ toJSON: function (key, value) { | ||
} else { | ||
// Something errored. We'll still send everything we have up until this point. | ||
reportError(request, x); // Something errored. We'll still send everything we have up until this point. | ||
// We'll replace this element with a lazy reference that throws on the client | ||
// once it gets rendered. | ||
request.pendingChunks++; | ||
@@ -639,2 +665,12 @@ var errorId = request.nextChunkId++; | ||
function reportError(request, error) { | ||
var onError = request.onError; | ||
onError(error); | ||
} | ||
function fatalError(request, error) { | ||
// This is called outside error handling code such as if an error happens in React internals. | ||
closeWithError(request.destination, error); | ||
} | ||
function emitErrorChunk(request, id, error) { | ||
@@ -695,3 +731,4 @@ // TODO: We should not leak error messages to the client in prod. | ||
} else { | ||
// This errored, we need to serialize this error to the | ||
reportError(request, x); // This errored, we need to serialize this error to the | ||
emitErrorChunk(request, segment.id, x); | ||
@@ -707,16 +744,22 @@ } | ||
currentCache = request.cache; | ||
var pingedSegments = request.pingedSegments; | ||
request.pingedSegments = []; | ||
for (var i = 0; i < pingedSegments.length; i++) { | ||
var segment = pingedSegments[i]; | ||
retrySegment(request, segment); | ||
} | ||
try { | ||
var pingedSegments = request.pingedSegments; | ||
request.pingedSegments = []; | ||
if (request.flowing) { | ||
flushCompletedChunks(request); | ||
for (var i = 0; i < pingedSegments.length; i++) { | ||
var segment = pingedSegments[i]; | ||
retrySegment(request, segment); | ||
} | ||
if (request.flowing) { | ||
flushCompletedChunks(request); | ||
} | ||
} catch (error) { | ||
reportError(request, error); | ||
fatalError(request, error); | ||
} finally { | ||
ReactCurrentDispatcher.current = prevDispatcher; | ||
currentCache = prevCache; | ||
} | ||
ReactCurrentDispatcher.current = prevDispatcher; | ||
currentCache = prevCache; | ||
} | ||
@@ -804,3 +847,9 @@ | ||
request.flowing = true; | ||
flushCompletedChunks(request); | ||
try { | ||
flushCompletedChunks(request); | ||
} catch (error) { | ||
reportError(request, error); | ||
fatalError(request, error); | ||
} | ||
} | ||
@@ -867,7 +916,7 @@ | ||
function renderToReadableStream(model, webpackMap) { | ||
function renderToReadableStream(model, webpackMap, options) { | ||
var request; | ||
return new ReadableStream({ | ||
start: function (controller) { | ||
request = createRequest(model, controller, webpackMap); | ||
request = createRequest(model, controller, webpackMap, options ? options.onError : undefined); | ||
startWork(request); | ||
@@ -874,0 +923,0 @@ }, |
@@ -9,16 +9,17 @@ /** @license React vundefined | ||
*/ | ||
'use strict';var l=require("react");function m(a){for(var c="https://reactjs.org/docs/error-decoder.html?invariant="+a,d=1;d<arguments.length;d++)c+="&args[]="+encodeURIComponent(arguments[d]);return"Minified React error #"+a+"; visit "+c+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(a,c){a.enqueue(c);return 0<a.desiredSize} | ||
var q=new TextEncoder,r=JSON.stringify,t=Symbol.for("react.module.reference"),u=60103,w=60107,x=60112,y=60115,z=60116;if("function"===typeof Symbol&&Symbol.for){var A=Symbol.for;u=A("react.element");w=A("react.fragment");x=A("react.forward_ref");y=A("react.memo");z=A("react.lazy")}var B=Array.isArray,C=l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentDispatcher; | ||
function G(a,c,d){var b=[],e={destination:c,bundlerConfig:d,cache:new Map,nextChunkId:0,pendingChunks:0,pingedSegments:b,completedModuleChunks:[],completedJSONChunks:[],completedErrorChunks:[],writtenSymbols:new Map,writtenModules:new Map,flowing:!1,toJSON:function(a,b){return H(e,this,a,b)}};e.pendingChunks++;a=I(e,a);b.push(a);return e} | ||
function J(a,c,d,b){if(null!==d&&void 0!==d)throw Error(m(379));if("function"===typeof a)return a(b);if("string"===typeof a)return[u,a,c,b];if("symbol"===typeof a)return a===w?b.children:[u,a,c,b];if(null!=a&&"object"===typeof a){if(a.$$typeof===t)return[u,a,c,b];switch(a.$$typeof){case x:return a=a.render,a(b,void 0);case y:return J(a.type,c,d,b)}}throw Error(m(351,K(a)));} | ||
function I(a,c){var d={id:a.nextChunkId++,model:c,ping:function(){var b=a.pingedSegments;b.push(d);1===b.length&&L(a)}};return d}function M(a){return Object.prototype.toString.call(a).replace(/^\[object (.*)\]$/,function(a,d){return d})}function N(a){var c=JSON.stringify(a);return'"'+a+'"'===c?a:c} | ||
function K(a){switch(typeof a){case "string":return JSON.stringify(10>=a.length?a:a.substr(0,10)+"...");case "object":if(B(a))return"[...]";a=M(a);return"Object"===a?"{...}":a;case "function":return"function";default:return String(a)}} | ||
function O(a,c){if(B(a)){for(var d="[",b=0;b<a.length;b++){0<b&&(d+=", ");if(6<b){d+="...";break}var e=a[b];d=""+b===c&&"object"===typeof e&&null!==e?d+O(e):d+K(e)}return d+"]"}d="{";b=Object.keys(a);for(e=0;e<b.length;e++){0<e&&(d+=", ");if(6<e){d+="...";break}var f=b[e];d+=N(f)+": ";var h=a[f];d=f===c&&"object"===typeof h&&null!==h?d+O(h):d+K(h)}return d+"}"} | ||
function H(a,c,d,b){switch(b){case u:return"$";case z:throw Error(m(352));}for(;"object"===typeof b&&null!==b&&b.$$typeof===u;){var e=b;try{b=J(e.type,e.key,e.ref,e.props)}catch(p){if("object"===typeof p&&null!==p&&"function"===typeof p.then)return a.pendingChunks++,a=I(a,b),c=a.ping,p.then(c,c),"@"+a.id.toString(16);a.pendingChunks++;c=a.nextChunkId++;P(a,c,p);return"@"+c.toString(16)}}if(null===b)return null;if("object"===typeof b){if(b.$$typeof===t){e=b.filepath+"#"+b.name;var f=a.writtenModules, | ||
h=f.get(e);if(void 0!==h)return c[0]===u&&"1"===d?"@"+h.toString(16):"$"+h.toString(16);try{var k=a.bundlerConfig[b.filepath][b.name];a.pendingChunks++;var g=a.nextChunkId++,D=r(k),E="M"+g.toString(16)+":"+D+"\n";var F=q.encode(E);a.completedModuleChunks.push(F);f.set(e,g);return c[0]===u&&"1"===d?"@"+g.toString(16):"$"+g.toString(16)}catch(p){return a.pendingChunks++,c=a.nextChunkId++,P(a,c,p),"$"+c.toString(16)}}return b}if("string"===typeof b)return a="$"===b[0]||"@"===b[0]?"$"+b:b,a;if("boolean"=== | ||
typeof b||"number"===typeof b||"undefined"===typeof b)return b;if("function"===typeof b){if(/^on[A-Z]/.test(d))throw Error(m(374,N(d),O(c)));throw Error(m(375,N(d),b.displayName||b.name||"function",O(c)));}if("symbol"===typeof b){k=a.writtenSymbols;g=k.get(b);if(void 0!==g)return"$"+g.toString(16);g=b.description;if(Symbol.for(g)!==b)throw Error(m(376,b.description,N(d),O(c)));a.pendingChunks++;c=a.nextChunkId++;d=r(g);d="S"+c.toString(16)+":"+d+"\n";d=q.encode(d);a.completedModuleChunks.push(d); | ||
k.set(b,c);return"$"+c.toString(16)}if("bigint"===typeof b)throw Error(m(377,b,N(d),O(c)));throw Error(m(378,typeof b,N(d),O(c)));}function P(a,c,d){var b="";try{if(d instanceof Error){var e=""+d.message;b=""+d.stack}else e="Error: "+d}catch(f){e="An error occurred but serializing the error message failed."}d={message:e,stack:b};c="E"+c.toString(16)+":"+r(d)+"\n";c=q.encode(c);a.completedErrorChunks.push(c)} | ||
function L(a){var c=C.current,d=Q;C.current=R;Q=a.cache;var b=a.pingedSegments;a.pingedSegments=[];for(var e=0;e<b.length;e++){var f=b[e];var h=a;try{for(var k=f.model;"object"===typeof k&&null!==k&&k.$$typeof===u;){var g=k;f.model=k;k=J(g.type,g.key,g.ref,g.props)}var D=f.id,E=r(k,h.toJSON),F="J"+D.toString(16)+":"+E+"\n";var p=q.encode(F);h.completedJSONChunks.push(p)}catch(v){"object"===typeof v&&null!==v&&"function"===typeof v.then?(f=f.ping,v.then(f,f)):P(h,f.id,v)}}a.flowing&&S(a);C.current= | ||
c;Q=d}var T=!1;function S(a){if(!T){T=!0;var c=a.destination;try{for(var d=a.completedModuleChunks,b=0;b<d.length;b++)if(a.pendingChunks--,!n(c,d[b])){a.flowing=!1;b++;break}d.splice(0,b);var e=a.completedJSONChunks;for(b=0;b<e.length;b++)if(a.pendingChunks--,!n(c,e[b])){a.flowing=!1;b++;break}e.splice(0,b);var f=a.completedErrorChunks;for(b=0;b<f.length;b++)if(a.pendingChunks--,!n(c,f[b])){a.flowing=!1;b++;break}f.splice(0,b)}finally{T=!1}0===a.pendingChunks&&c.close()}} | ||
function U(){throw Error(m(373));}function V(){if(!Q)throw Error(m(384));}var Q=null,R={useMemo:function(a){return a()},useCallback:function(a){return a},useDebugValue:function(){},useDeferredValue:U,useTransition:U,getCacheForType:function(a){if(!Q)throw Error(m(380));var c=Q.get(a);void 0===c&&(c=a(),Q.set(a,c));return c},readContext:U,useContext:U,useReducer:U,useRef:U,useState:U,useLayoutEffect:U,useImperativeHandle:U,useEffect:U,useOpaqueIdentifier:U,useMutableSource:U,useCacheRefresh:function(){return V}}; | ||
exports.renderToReadableStream=function(a,c){var d;return new ReadableStream({start:function(b){b=d=G(a,b,c);b.flowing=!0;L(b)},pull:function(){var a=d;a.flowing=!0;S(a)},cancel:function(){}})}; | ||
'use strict';var l=require("react");function m(a){for(var c="https://reactjs.org/docs/error-decoder.html?invariant="+a,d=1;d<arguments.length;d++)c+="&args[]="+encodeURIComponent(arguments[d]);return"Minified React error #"+a+"; visit "+c+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function p(a,c){a.enqueue(c);return 0<a.desiredSize}var r=new TextEncoder;function t(a,c){"function"===typeof a.error?a.error(c):a.close()} | ||
var u=JSON.stringify,v=Symbol.for("react.module.reference"),w=60103,x=60107,y=60112,z=60115,A=60116;if("function"===typeof Symbol&&Symbol.for){var B=Symbol.for;w=B("react.element");x=B("react.fragment");y=B("react.forward_ref");z=B("react.memo");A=B("react.lazy")}var C=Array.isArray,D=l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentDispatcher;function H(a){console.error(a)} | ||
function I(a,c,d,b){var e=[],f={destination:c,bundlerConfig:d,cache:new Map,nextChunkId:0,pendingChunks:0,pingedSegments:e,completedModuleChunks:[],completedJSONChunks:[],completedErrorChunks:[],writtenSymbols:new Map,writtenModules:new Map,onError:void 0===b?H:b,flowing:!1,toJSON:function(a,b){return J(f,this,a,b)}};f.pendingChunks++;a=K(f,a);e.push(a);return f} | ||
function L(a,c,d,b){if(null!==d&&void 0!==d)throw Error(m(379));if("function"===typeof a)return a(b);if("string"===typeof a)return[w,a,c,b];if("symbol"===typeof a)return a===x?b.children:[w,a,c,b];if(null!=a&&"object"===typeof a){if(a.$$typeof===v)return[w,a,c,b];switch(a.$$typeof){case y:return a=a.render,a(b,void 0);case z:return L(a.type,c,d,b)}}throw Error(m(351,M(a)));} | ||
function K(a,c){var d={id:a.nextChunkId++,model:c,ping:function(){var b=a.pingedSegments;b.push(d);1===b.length&&N(a)}};return d}function O(a){return Object.prototype.toString.call(a).replace(/^\[object (.*)\]$/,function(a,d){return d})}function P(a){var c=JSON.stringify(a);return'"'+a+'"'===c?a:c} | ||
function M(a){switch(typeof a){case "string":return JSON.stringify(10>=a.length?a:a.substr(0,10)+"...");case "object":if(C(a))return"[...]";a=O(a);return"Object"===a?"{...}":a;case "function":return"function";default:return String(a)}} | ||
function Q(a,c){if(C(a)){for(var d="[",b=0;b<a.length;b++){0<b&&(d+=", ");if(6<b){d+="...";break}var e=a[b];d=""+b===c&&"object"===typeof e&&null!==e?d+Q(e):d+M(e)}return d+"]"}d="{";b=Object.keys(a);for(e=0;e<b.length;e++){0<e&&(d+=", ");if(6<e){d+="...";break}var f=b[e];d+=P(f)+": ";var h=a[f];d=f===c&&"object"===typeof h&&null!==h?d+Q(h):d+M(h)}return d+"}"} | ||
function J(a,c,d,b){switch(b){case w:return"$";case A:throw Error(m(352));}for(;"object"===typeof b&&null!==b&&b.$$typeof===w;){var e=b;try{b=L(e.type,e.key,e.ref,e.props)}catch(n){if("object"===typeof n&&null!==n&&"function"===typeof n.then)return a.pendingChunks++,a=K(a,b),c=a.ping,n.then(c,c),"@"+a.id.toString(16);S(a,n);a.pendingChunks++;c=a.nextChunkId++;T(a,c,n);return"@"+c.toString(16)}}if(null===b)return null;if("object"===typeof b){if(b.$$typeof===v){e=b.filepath+"#"+b.name;var f=a.writtenModules, | ||
h=f.get(e);if(void 0!==h)return c[0]===w&&"1"===d?"@"+h.toString(16):"$"+h.toString(16);try{var k=a.bundlerConfig[b.filepath][b.name];a.pendingChunks++;var g=a.nextChunkId++,E=u(k),F="M"+g.toString(16)+":"+E+"\n";var G=r.encode(F);a.completedModuleChunks.push(G);f.set(e,g);return c[0]===w&&"1"===d?"@"+g.toString(16):"$"+g.toString(16)}catch(n){return a.pendingChunks++,c=a.nextChunkId++,T(a,c,n),"$"+c.toString(16)}}return b}if("string"===typeof b)return a="$"===b[0]||"@"===b[0]?"$"+b:b,a;if("boolean"=== | ||
typeof b||"number"===typeof b||"undefined"===typeof b)return b;if("function"===typeof b){if(/^on[A-Z]/.test(d))throw Error(m(374,P(d),Q(c)));throw Error(m(375,P(d),b.displayName||b.name||"function",Q(c)));}if("symbol"===typeof b){k=a.writtenSymbols;g=k.get(b);if(void 0!==g)return"$"+g.toString(16);g=b.description;if(Symbol.for(g)!==b)throw Error(m(376,b.description,P(d),Q(c)));a.pendingChunks++;c=a.nextChunkId++;d=u(g);d="S"+c.toString(16)+":"+d+"\n";d=r.encode(d);a.completedModuleChunks.push(d); | ||
k.set(b,c);return"$"+c.toString(16)}if("bigint"===typeof b)throw Error(m(377,b,P(d),Q(c)));throw Error(m(378,typeof b,P(d),Q(c)));}function S(a,c){a=a.onError;a(c)}function T(a,c,d){var b="";try{if(d instanceof Error){var e=""+d.message;b=""+d.stack}else e="Error: "+d}catch(f){e="An error occurred but serializing the error message failed."}d={message:e,stack:b};c="E"+c.toString(16)+":"+u(d)+"\n";c=r.encode(c);a.completedErrorChunks.push(c)} | ||
function N(a){var c=D.current,d=U;D.current=V;U=a.cache;try{var b=a.pingedSegments;a.pingedSegments=[];for(var e=0;e<b.length;e++){var f=b[e];var h=a;try{for(var k=f.model;"object"===typeof k&&null!==k&&k.$$typeof===w;){var g=k;f.model=k;k=L(g.type,g.key,g.ref,g.props)}var E=f.id,F=u(k,h.toJSON),G="J"+E.toString(16)+":"+F+"\n";var n=r.encode(G);h.completedJSONChunks.push(n)}catch(q){if("object"===typeof q&&null!==q&&"function"===typeof q.then){var R=f.ping;q.then(R,R)}else S(h,q),T(h,f.id,q)}}a.flowing&& | ||
W(a)}catch(q){S(a,q),t(a.destination,q)}finally{D.current=c,U=d}}var X=!1; | ||
function W(a){if(!X){X=!0;var c=a.destination;try{for(var d=a.completedModuleChunks,b=0;b<d.length;b++)if(a.pendingChunks--,!p(c,d[b])){a.flowing=!1;b++;break}d.splice(0,b);var e=a.completedJSONChunks;for(b=0;b<e.length;b++)if(a.pendingChunks--,!p(c,e[b])){a.flowing=!1;b++;break}e.splice(0,b);var f=a.completedErrorChunks;for(b=0;b<f.length;b++)if(a.pendingChunks--,!p(c,f[b])){a.flowing=!1;b++;break}f.splice(0,b)}finally{X=!1}0===a.pendingChunks&&c.close()}}function Y(){throw Error(m(373));} | ||
function Z(){if(!U)throw Error(m(384));}var U=null,V={useMemo:function(a){return a()},useCallback:function(a){return a},useDebugValue:function(){},useDeferredValue:Y,useTransition:Y,getCacheForType:function(a){if(!U)throw Error(m(380));var c=U.get(a);void 0===c&&(c=a(),U.set(a,c));return c},readContext:Y,useContext:Y,useReducer:Y,useRef:Y,useState:Y,useLayoutEffect:Y,useImperativeHandle:Y,useEffect:Y,useOpaqueIdentifier:Y,useMutableSource:Y,useCacheRefresh:function(){return Z}}; | ||
exports.renderToReadableStream=function(a,c,d){var b;return new ReadableStream({start:function(e){e=b=I(a,e,c,d?d.onError:void 0);e.flowing=!0;N(e)},pull:function(){var a=b;a.flowing=!0;try{W(a)}catch(f){S(a,f),t(a.destination,f)}},cancel:function(){}})}; |
@@ -61,8 +61,5 @@ /** @license React vundefined | ||
if (typeof destination.flush === 'function') { | ||
// http.createServer response have flush(), but it has a different meaning and | ||
// is deprecated in favor of flushHeaders(). Detect to avoid a warning. | ||
if (typeof destination.flushHeaders !== 'function') { | ||
// By convention the Zlib streams provide a flush function for this purpose. | ||
destination.flush(); | ||
} | ||
// By convention the Zlib streams provide a flush function for this purpose. | ||
// For Express, compression middleware adds this method. | ||
destination.flush(); | ||
} | ||
@@ -76,4 +73,4 @@ } | ||
} | ||
function writeChunk(destination, buffer) { | ||
var nodeBuffer = buffer; // close enough | ||
function writeChunk(destination, chunk) { | ||
var nodeBuffer = chunk; // close enough | ||
@@ -91,5 +88,9 @@ return destination.write(nodeBuffer); | ||
} | ||
function convertStringToBuffer(content) { | ||
return Buffer.from(content, 'utf8'); | ||
function stringToChunk(content) { | ||
return content; | ||
} | ||
function closeWithError(destination, error) { | ||
// $FlowFixMe: This is an Error object or the destination accepts other types. | ||
destination.destroy(error); | ||
} | ||
@@ -109,3 +110,3 @@ // This file is an intermediate layer to translate between Flight | ||
var row = serializeRowHeader('E', id) + stringify(errorInfo) + '\n'; | ||
return convertStringToBuffer(row); | ||
return stringToChunk(row); | ||
} | ||
@@ -115,3 +116,3 @@ function processModelChunk(request, id, model) { | ||
var row = serializeRowHeader('J', id) + json + '\n'; | ||
return convertStringToBuffer(row); | ||
return stringToChunk(row); | ||
} | ||
@@ -121,3 +122,3 @@ function processModuleChunk(request, id, moduleMetaData) { | ||
var row = serializeRowHeader('M', id) + json + '\n'; | ||
return convertStringToBuffer(row); | ||
return stringToChunk(row); | ||
} | ||
@@ -127,3 +128,3 @@ function processSymbolChunk(request, id, name) { | ||
var row = serializeRowHeader('S', id) + json + '\n'; | ||
return convertStringToBuffer(row); | ||
return stringToChunk(row); | ||
} | ||
@@ -189,5 +190,15 @@ | ||
var isArray = Array.isArray; | ||
var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare | ||
function isArray(a) { | ||
return isArrayImpl(a); | ||
} | ||
var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher; | ||
function createRequest(model, destination, bundlerConfig) { | ||
function defaultErrorHandler(error) { | ||
console['error'](error); // Don't transform to our wrapper | ||
} | ||
function createRequest(model, destination, bundlerConfig, onError) { | ||
var pingedSegments = []; | ||
@@ -206,2 +217,3 @@ var request = { | ||
writtenModules: new Map(), | ||
onError: onError === undefined ? defaultErrorHandler : onError, | ||
flowing: false, | ||
@@ -517,5 +529,6 @@ toJSON: function (key, value) { | ||
} else { | ||
// Something errored. We'll still send everything we have up until this point. | ||
reportError(request, x); // Something errored. We'll still send everything we have up until this point. | ||
// We'll replace this element with a lazy reference that throws on the client | ||
// once it gets rendered. | ||
request.pendingChunks++; | ||
@@ -664,2 +677,12 @@ var errorId = request.nextChunkId++; | ||
function reportError(request, error) { | ||
var onError = request.onError; | ||
onError(error); | ||
} | ||
function fatalError(request, error) { | ||
// This is called outside error handling code such as if an error happens in React internals. | ||
closeWithError(request.destination, error); | ||
} | ||
function emitErrorChunk(request, id, error) { | ||
@@ -720,3 +743,4 @@ // TODO: We should not leak error messages to the client in prod. | ||
} else { | ||
// This errored, we need to serialize this error to the | ||
reportError(request, x); // This errored, we need to serialize this error to the | ||
emitErrorChunk(request, segment.id, x); | ||
@@ -732,16 +756,22 @@ } | ||
currentCache = request.cache; | ||
var pingedSegments = request.pingedSegments; | ||
request.pingedSegments = []; | ||
for (var i = 0; i < pingedSegments.length; i++) { | ||
var segment = pingedSegments[i]; | ||
retrySegment(request, segment); | ||
} | ||
try { | ||
var pingedSegments = request.pingedSegments; | ||
request.pingedSegments = []; | ||
if (request.flowing) { | ||
flushCompletedChunks(request); | ||
for (var i = 0; i < pingedSegments.length; i++) { | ||
var segment = pingedSegments[i]; | ||
retrySegment(request, segment); | ||
} | ||
if (request.flowing) { | ||
flushCompletedChunks(request); | ||
} | ||
} catch (error) { | ||
reportError(request, error); | ||
fatalError(request, error); | ||
} finally { | ||
ReactCurrentDispatcher.current = prevDispatcher; | ||
currentCache = prevCache; | ||
} | ||
ReactCurrentDispatcher.current = prevDispatcher; | ||
currentCache = prevCache; | ||
} | ||
@@ -833,3 +863,9 @@ | ||
request.flowing = true; | ||
flushCompletedChunks(request); | ||
try { | ||
flushCompletedChunks(request); | ||
} catch (error) { | ||
reportError(request, error); | ||
fatalError(request, error); | ||
} | ||
} | ||
@@ -902,4 +938,4 @@ | ||
function pipeToNodeWritable(model, destination, webpackMap) { | ||
var request = createRequest(model, destination, webpackMap); | ||
function pipeToNodeWritable(model, destination, webpackMap, options) { | ||
var request = createRequest(model, destination, webpackMap, options ? options.onError : undefined); | ||
destination.on('drain', createDrainHandler(destination, request)); | ||
@@ -906,0 +942,0 @@ startWork(request); |
@@ -9,17 +9,17 @@ /** @license React vundefined | ||
*/ | ||
'use strict';var l=require("react");function m(a){for(var c="https://reactjs.org/docs/error-decoder.html?invariant="+a,d=1;d<arguments.length;d++)c+="&args[]="+encodeURIComponent(arguments[d]);return"Minified React error #"+a+"; visit "+c+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var n=JSON.stringify,q=Symbol.for("react.module.reference"),r=60103,t=60107,u=60112,w=60115,x=60116; | ||
if("function"===typeof Symbol&&Symbol.for){var y=Symbol.for;r=y("react.element");t=y("react.fragment");u=y("react.forward_ref");w=y("react.memo");x=y("react.lazy")}var z=Array.isArray,A=l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentDispatcher; | ||
function E(a,c,d){var b=[],e={destination:c,bundlerConfig:d,cache:new Map,nextChunkId:0,pendingChunks:0,pingedSegments:b,completedModuleChunks:[],completedJSONChunks:[],completedErrorChunks:[],writtenSymbols:new Map,writtenModules:new Map,flowing:!1,toJSON:function(a,b){return F(e,this,a,b)}};e.pendingChunks++;a=G(e,a);b.push(a);return e} | ||
function H(a,c,d,b){if(null!==d&&void 0!==d)throw Error(m(379));if("function"===typeof a)return a(b);if("string"===typeof a)return[r,a,c,b];if("symbol"===typeof a)return a===t?b.children:[r,a,c,b];if(null!=a&&"object"===typeof a){if(a.$$typeof===q)return[r,a,c,b];switch(a.$$typeof){case u:return a=a.render,a(b,void 0);case w:return H(a.type,c,d,b)}}throw Error(m(351,I(a)));}function J(a,c){var d=a.pingedSegments;d.push(c);1===d.length&&setImmediate(function(){return K(a)})} | ||
'use strict';var l=require("react");function m(a){for(var c="https://reactjs.org/docs/error-decoder.html?invariant="+a,d=1;d<arguments.length;d++)c+="&args[]="+encodeURIComponent(arguments[d]);return"Minified React error #"+a+"; visit "+c+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var p=JSON.stringify,r=Symbol.for("react.module.reference"),t=60103,u=60107,v=60112,w=60115,x=60116; | ||
if("function"===typeof Symbol&&Symbol.for){var y=Symbol.for;t=y("react.element");u=y("react.fragment");v=y("react.forward_ref");w=y("react.memo");x=y("react.lazy")}var z=Array.isArray,A=l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentDispatcher;function B(a){console.error(a)} | ||
function E(a,c,d,b){var e=[],f={destination:c,bundlerConfig:d,cache:new Map,nextChunkId:0,pendingChunks:0,pingedSegments:e,completedModuleChunks:[],completedJSONChunks:[],completedErrorChunks:[],writtenSymbols:new Map,writtenModules:new Map,onError:void 0===b?B:b,flowing:!1,toJSON:function(a,b){return F(f,this,a,b)}};f.pendingChunks++;a=G(f,a);e.push(a);return f} | ||
function H(a,c,d,b){if(null!==d&&void 0!==d)throw Error(m(379));if("function"===typeof a)return a(b);if("string"===typeof a)return[t,a,c,b];if("symbol"===typeof a)return a===u?b.children:[t,a,c,b];if(null!=a&&"object"===typeof a){if(a.$$typeof===r)return[t,a,c,b];switch(a.$$typeof){case v:return a=a.render,a(b,void 0);case w:return H(a.type,c,d,b)}}throw Error(m(351,I(a)));}function J(a,c){var d=a.pingedSegments;d.push(c);1===d.length&&setImmediate(function(){return K(a)})} | ||
function G(a,c){var d={id:a.nextChunkId++,model:c,ping:function(){return J(a,d)}};return d}function L(a){return Object.prototype.toString.call(a).replace(/^\[object (.*)\]$/,function(a,d){return d})}function M(a){var c=JSON.stringify(a);return'"'+a+'"'===c?a:c}function I(a){switch(typeof a){case "string":return JSON.stringify(10>=a.length?a:a.substr(0,10)+"...");case "object":if(z(a))return"[...]";a=L(a);return"Object"===a?"{...}":a;case "function":return"function";default:return String(a)}} | ||
function N(a,c){if(z(a)){for(var d="[",b=0;b<a.length;b++){0<b&&(d+=", ");if(6<b){d+="...";break}var e=a[b];d=""+b===c&&"object"===typeof e&&null!==e?d+N(e):d+I(e)}return d+"]"}d="{";b=Object.keys(a);for(e=0;e<b.length;e++){0<e&&(d+=", ");if(6<e){d+="...";break}var f=b[e];d+=M(f)+": ";var h=a[f];d=f===c&&"object"===typeof h&&null!==h?d+N(h):d+I(h)}return d+"}"} | ||
function F(a,c,d,b){switch(b){case r:return"$";case x:throw Error(m(352));}for(;"object"===typeof b&&null!==b&&b.$$typeof===r;){var e=b;try{b=H(e.type,e.key,e.ref,e.props)}catch(p){if("object"===typeof p&&null!==p&&"function"===typeof p.then)return a.pendingChunks++,a=G(a,b),c=a.ping,p.then(c,c),"@"+a.id.toString(16);a.pendingChunks++;c=a.nextChunkId++;O(a,c,p);return"@"+c.toString(16)}}if(null===b)return null;if("object"===typeof b){if(b.$$typeof===q){e=b.filepath+"#"+b.name;var f=a.writtenModules, | ||
h=f.get(e);if(void 0!==h)return c[0]===r&&"1"===d?"@"+h.toString(16):"$"+h.toString(16);try{var k=a.bundlerConfig[b.filepath][b.name];a.pendingChunks++;var g=a.nextChunkId++,B=n(k),C="M"+g.toString(16)+":"+B+"\n";var D=Buffer.from(C,"utf8");a.completedModuleChunks.push(D);f.set(e,g);return c[0]===r&&"1"===d?"@"+g.toString(16):"$"+g.toString(16)}catch(p){return a.pendingChunks++,c=a.nextChunkId++,O(a,c,p),"$"+c.toString(16)}}return b}if("string"===typeof b)return a="$"===b[0]||"@"===b[0]?"$"+b:b,a; | ||
if("boolean"===typeof b||"number"===typeof b||"undefined"===typeof b)return b;if("function"===typeof b){if(/^on[A-Z]/.test(d))throw Error(m(374,M(d),N(c)));throw Error(m(375,M(d),b.displayName||b.name||"function",N(c)));}if("symbol"===typeof b){k=a.writtenSymbols;g=k.get(b);if(void 0!==g)return"$"+g.toString(16);g=b.description;if(Symbol.for(g)!==b)throw Error(m(376,b.description,M(d),N(c)));a.pendingChunks++;c=a.nextChunkId++;d=n(g);d="S"+c.toString(16)+":"+d+"\n";d=Buffer.from(d,"utf8");a.completedModuleChunks.push(d); | ||
k.set(b,c);return"$"+c.toString(16)}if("bigint"===typeof b)throw Error(m(377,b,M(d),N(c)));throw Error(m(378,typeof b,M(d),N(c)));}function O(a,c,d){var b="";try{if(d instanceof Error){var e=""+d.message;b=""+d.stack}else e="Error: "+d}catch(f){e="An error occurred but serializing the error message failed."}d={message:e,stack:b};c="E"+c.toString(16)+":"+n(d)+"\n";c=Buffer.from(c,"utf8");a.completedErrorChunks.push(c)} | ||
function K(a){var c=A.current,d=P;A.current=Q;P=a.cache;var b=a.pingedSegments;a.pingedSegments=[];for(var e=0;e<b.length;e++){var f=b[e];var h=a;try{for(var k=f.model;"object"===typeof k&&null!==k&&k.$$typeof===r;){var g=k;f.model=k;k=H(g.type,g.key,g.ref,g.props)}var B=f.id,C=n(k,h.toJSON),D="J"+B.toString(16)+":"+C+"\n";var p=Buffer.from(D,"utf8");h.completedJSONChunks.push(p)}catch(v){"object"===typeof v&&null!==v&&"function"===typeof v.then?(f=f.ping,v.then(f,f)):O(h,f.id,v)}}a.flowing&&R(a); | ||
A.current=c;P=d}var S=!1; | ||
function R(a){if(!S){S=!0;var c=a.destination;"function"===typeof c.cork&&c.cork();try{for(var d=a.completedModuleChunks,b=0;b<d.length;b++)if(a.pendingChunks--,!c.write(d[b])){a.flowing=!1;b++;break}d.splice(0,b);var e=a.completedJSONChunks;for(b=0;b<e.length;b++)if(a.pendingChunks--,!c.write(e[b])){a.flowing=!1;b++;break}e.splice(0,b);var f=a.completedErrorChunks;for(b=0;b<f.length;b++)if(a.pendingChunks--,!c.write(f[b])){a.flowing=!1;b++;break}f.splice(0,b)}finally{S=!1,"function"===typeof c.uncork&& | ||
c.uncork()}"function"===typeof c.flush&&"function"!==typeof c.flushHeaders&&c.flush();0===a.pendingChunks&&c.end()}}function T(a){a.flowing=!0;setImmediate(function(){return K(a)})}function U(){throw Error(m(373));}function V(){if(!P)throw Error(m(384));} | ||
var P=null,Q={useMemo:function(a){return a()},useCallback:function(a){return a},useDebugValue:function(){},useDeferredValue:U,useTransition:U,getCacheForType:function(a){if(!P)throw Error(m(380));var c=P.get(a);void 0===c&&(c=a(),P.set(a,c));return c},readContext:U,useContext:U,useReducer:U,useRef:U,useState:U,useLayoutEffect:U,useImperativeHandle:U,useEffect:U,useOpaqueIdentifier:U,useMutableSource:U,useCacheRefresh:function(){return V}};function W(a,c){return function(){c.flowing=!0;R(c)}} | ||
exports.pipeToNodeWritable=function(a,c,d){a=E(a,c,d);c.on("drain",W(c,a));T(a)}; | ||
function O(a,c){if(z(a)){for(var d="[",b=0;b<a.length;b++){0<b&&(d+=", ");if(6<b){d+="...";break}var e=a[b];d=""+b===c&&"object"===typeof e&&null!==e?d+O(e):d+I(e)}return d+"]"}d="{";b=Object.keys(a);for(e=0;e<b.length;e++){0<e&&(d+=", ");if(6<e){d+="...";break}var f=b[e];d+=M(f)+": ";var h=a[f];d=f===c&&"object"===typeof h&&null!==h?d+O(h):d+I(h)}return d+"}"} | ||
function F(a,c,d,b){switch(b){case t:return"$";case x:throw Error(m(352));}for(;"object"===typeof b&&null!==b&&b.$$typeof===t;){var e=b;try{b=H(e.type,e.key,e.ref,e.props)}catch(n){if("object"===typeof n&&null!==n&&"function"===typeof n.then)return a.pendingChunks++,a=G(a,b),c=a.ping,n.then(c,c),"@"+a.id.toString(16);P(a,n);a.pendingChunks++;c=a.nextChunkId++;Q(a,c,n);return"@"+c.toString(16)}}if(null===b)return null;if("object"===typeof b){if(b.$$typeof===r){e=b.filepath+"#"+b.name;var f=a.writtenModules, | ||
h=f.get(e);if(void 0!==h)return c[0]===t&&"1"===d?"@"+h.toString(16):"$"+h.toString(16);try{var k=a.bundlerConfig[b.filepath][b.name];a.pendingChunks++;var g=a.nextChunkId++,C=p(k);var D="M"+g.toString(16)+":"+C+"\n";a.completedModuleChunks.push(D);f.set(e,g);return c[0]===t&&"1"===d?"@"+g.toString(16):"$"+g.toString(16)}catch(n){return a.pendingChunks++,c=a.nextChunkId++,Q(a,c,n),"$"+c.toString(16)}}return b}if("string"===typeof b)return a="$"===b[0]||"@"===b[0]?"$"+b:b,a;if("boolean"===typeof b|| | ||
"number"===typeof b||"undefined"===typeof b)return b;if("function"===typeof b){if(/^on[A-Z]/.test(d))throw Error(m(374,M(d),O(c)));throw Error(m(375,M(d),b.displayName||b.name||"function",O(c)));}if("symbol"===typeof b){k=a.writtenSymbols;g=k.get(b);if(void 0!==g)return"$"+g.toString(16);g=b.description;if(Symbol.for(g)!==b)throw Error(m(376,b.description,M(d),O(c)));a.pendingChunks++;c=a.nextChunkId++;d=p(g);d="S"+c.toString(16)+":"+d+"\n";a.completedModuleChunks.push(d);k.set(b,c);return"$"+c.toString(16)}if("bigint"=== | ||
typeof b)throw Error(m(377,b,M(d),O(c)));throw Error(m(378,typeof b,M(d),O(c)));}function P(a,c){a=a.onError;a(c)}function Q(a,c,d){var b="";try{if(d instanceof Error){var e=""+d.message;b=""+d.stack}else e="Error: "+d}catch(f){e="An error occurred but serializing the error message failed."}d={message:e,stack:b};c="E"+c.toString(16)+":"+p(d)+"\n";a.completedErrorChunks.push(c)} | ||
function K(a){var c=A.current,d=R;A.current=S;R=a.cache;try{var b=a.pingedSegments;a.pingedSegments=[];for(var e=0;e<b.length;e++){var f=b[e];var h=a;try{for(var k=f.model;"object"===typeof k&&null!==k&&k.$$typeof===t;){var g=k;f.model=k;k=H(g.type,g.key,g.ref,g.props)}var C=f.id,D=p(k,h.toJSON);var n="J"+C.toString(16)+":"+D+"\n";h.completedJSONChunks.push(n)}catch(q){if("object"===typeof q&&null!==q&&"function"===typeof q.then){var N=f.ping;q.then(N,N)}else P(h,q),Q(h,f.id,q)}}a.flowing&&T(a)}catch(q){P(a, | ||
q),a.destination.destroy(q)}finally{A.current=c,R=d}}var U=!1; | ||
function T(a){if(!U){U=!0;var c=a.destination;"function"===typeof c.cork&&c.cork();try{for(var d=a.completedModuleChunks,b=0;b<d.length;b++)if(a.pendingChunks--,!c.write(d[b])){a.flowing=!1;b++;break}d.splice(0,b);var e=a.completedJSONChunks;for(b=0;b<e.length;b++)if(a.pendingChunks--,!c.write(e[b])){a.flowing=!1;b++;break}e.splice(0,b);var f=a.completedErrorChunks;for(b=0;b<f.length;b++)if(a.pendingChunks--,!c.write(f[b])){a.flowing=!1;b++;break}f.splice(0,b)}finally{U=!1,"function"===typeof c.uncork&& | ||
c.uncork()}"function"===typeof c.flush&&c.flush();0===a.pendingChunks&&c.end()}}function V(a){a.flowing=!0;setImmediate(function(){return K(a)})}function W(){throw Error(m(373));}function X(){if(!R)throw Error(m(384));} | ||
var R=null,S={useMemo:function(a){return a()},useCallback:function(a){return a},useDebugValue:function(){},useDeferredValue:W,useTransition:W,getCacheForType:function(a){if(!R)throw Error(m(380));var c=R.get(a);void 0===c&&(c=a(),R.set(a,c));return c},readContext:W,useContext:W,useReducer:W,useRef:W,useState:W,useLayoutEffect:W,useImperativeHandle:W,useEffect:W,useOpaqueIdentifier:W,useMutableSource:W,useCacheRefresh:function(){return X}}; | ||
function Y(a,c){return function(){c.flowing=!0;try{T(c)}catch(d){P(c,d),c.destination.destroy(d)}}}exports.pipeToNodeWritable=function(a,c,d,b){a=E(a,c,d,b?b.onError:void 0);c.on("drain",Y(c,a));V(a)}; |
{ | ||
"name": "react-server-dom-webpack", | ||
"description": "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.", | ||
"version": "0.0.0-experimental-9209c30ff", | ||
"version": "0.0.0-experimental-9212d994b", | ||
"keywords": [ | ||
@@ -51,4 +51,4 @@ "react" | ||
"peerDependencies": { | ||
"react": "0.0.0-experimental-9209c30ff", | ||
"react-dom": "0.0.0-experimental-9209c30ff", | ||
"react": "0.0.0-experimental-9212d994b", | ||
"react-dom": "0.0.0-experimental-9212d994b", | ||
"webpack": "^4.43.0" | ||
@@ -55,0 +55,0 @@ }, |
@@ -54,4 +54,4 @@ /** @license React vundefined | ||
} | ||
function writeChunk(destination, buffer) { | ||
destination.enqueue(buffer); | ||
function writeChunk(destination, chunk) { | ||
destination.enqueue(chunk); | ||
return destination.desiredSize > 0; | ||
@@ -63,5 +63,19 @@ } | ||
var textEncoder = new TextEncoder(); | ||
function convertStringToBuffer(content) { | ||
function stringToChunk(content) { | ||
return textEncoder.encode(content); | ||
} | ||
function closeWithError(destination, error) { | ||
if (typeof destination.error === 'function') { | ||
// $FlowFixMe: This is an Error object or the destination accepts other types. | ||
destination.error(error); | ||
} else { | ||
// Earlier implementations doesn't support this method. In that environment you're | ||
// supposed to throw from a promise returned but we don't return a promise in our | ||
// approach. We could fork this implementation but this is environment is an edge | ||
// case to begin with. It's even less common to run this in an older environment. | ||
// Even then, this is not where errors are supposed to happen and they get reported | ||
// to a global callback in addition to this anyway. So it's fine just to close this. | ||
destination.close(); | ||
} | ||
} | ||
@@ -81,3 +95,3 @@ // This file is an intermediate layer to translate between Flight | ||
var row = serializeRowHeader('E', id) + stringify(errorInfo) + '\n'; | ||
return convertStringToBuffer(row); | ||
return stringToChunk(row); | ||
} | ||
@@ -87,3 +101,3 @@ function processModelChunk(request, id, model) { | ||
var row = serializeRowHeader('J', id) + json + '\n'; | ||
return convertStringToBuffer(row); | ||
return stringToChunk(row); | ||
} | ||
@@ -93,3 +107,3 @@ function processModuleChunk(request, id, moduleMetaData) { | ||
var row = serializeRowHeader('M', id) + json + '\n'; | ||
return convertStringToBuffer(row); | ||
return stringToChunk(row); | ||
} | ||
@@ -99,3 +113,3 @@ function processSymbolChunk(request, id, name) { | ||
var row = serializeRowHeader('S', id) + json + '\n'; | ||
return convertStringToBuffer(row); | ||
return stringToChunk(row); | ||
} | ||
@@ -161,5 +175,15 @@ | ||
var isArray = Array.isArray; | ||
var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare | ||
function isArray(a) { | ||
return isArrayImpl(a); | ||
} | ||
var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher; | ||
function createRequest(model, destination, bundlerConfig) { | ||
function defaultErrorHandler(error) { | ||
console['error'](error); // Don't transform to our wrapper | ||
} | ||
function createRequest(model, destination, bundlerConfig, onError) { | ||
var pingedSegments = []; | ||
@@ -178,2 +202,3 @@ var request = { | ||
writtenModules: new Map(), | ||
onError: onError === undefined ? defaultErrorHandler : onError, | ||
flowing: false, | ||
@@ -489,5 +514,6 @@ toJSON: function (key, value) { | ||
} else { | ||
// Something errored. We'll still send everything we have up until this point. | ||
reportError(request, x); // Something errored. We'll still send everything we have up until this point. | ||
// We'll replace this element with a lazy reference that throws on the client | ||
// once it gets rendered. | ||
request.pendingChunks++; | ||
@@ -636,2 +662,12 @@ var errorId = request.nextChunkId++; | ||
function reportError(request, error) { | ||
var onError = request.onError; | ||
onError(error); | ||
} | ||
function fatalError(request, error) { | ||
// This is called outside error handling code such as if an error happens in React internals. | ||
closeWithError(request.destination, error); | ||
} | ||
function emitErrorChunk(request, id, error) { | ||
@@ -692,3 +728,4 @@ // TODO: We should not leak error messages to the client in prod. | ||
} else { | ||
// This errored, we need to serialize this error to the | ||
reportError(request, x); // This errored, we need to serialize this error to the | ||
emitErrorChunk(request, segment.id, x); | ||
@@ -704,16 +741,22 @@ } | ||
currentCache = request.cache; | ||
var pingedSegments = request.pingedSegments; | ||
request.pingedSegments = []; | ||
for (var i = 0; i < pingedSegments.length; i++) { | ||
var segment = pingedSegments[i]; | ||
retrySegment(request, segment); | ||
} | ||
try { | ||
var pingedSegments = request.pingedSegments; | ||
request.pingedSegments = []; | ||
if (request.flowing) { | ||
flushCompletedChunks(request); | ||
for (var i = 0; i < pingedSegments.length; i++) { | ||
var segment = pingedSegments[i]; | ||
retrySegment(request, segment); | ||
} | ||
if (request.flowing) { | ||
flushCompletedChunks(request); | ||
} | ||
} catch (error) { | ||
reportError(request, error); | ||
fatalError(request, error); | ||
} finally { | ||
ReactCurrentDispatcher.current = prevDispatcher; | ||
currentCache = prevCache; | ||
} | ||
ReactCurrentDispatcher.current = prevDispatcher; | ||
currentCache = prevCache; | ||
} | ||
@@ -801,3 +844,9 @@ | ||
request.flowing = true; | ||
flushCompletedChunks(request); | ||
try { | ||
flushCompletedChunks(request); | ||
} catch (error) { | ||
reportError(request, error); | ||
fatalError(request, error); | ||
} | ||
} | ||
@@ -864,7 +913,7 @@ | ||
function renderToReadableStream(model, webpackMap) { | ||
function renderToReadableStream(model, webpackMap, options) { | ||
var request; | ||
return new ReadableStream({ | ||
start: function (controller) { | ||
request = createRequest(model, controller, webpackMap); | ||
request = createRequest(model, controller, webpackMap, options ? options.onError : undefined); | ||
startWork(request); | ||
@@ -871,0 +920,0 @@ }, |
@@ -9,15 +9,15 @@ /** @license React vundefined | ||
*/ | ||
(function(){'use strict';(function(l,m){"object"===typeof exports&&"undefined"!==typeof module?m(exports,require("react")):"function"===typeof define&&define.amd?define(["exports","react"],m):(l=l||self,m(l.ReactServerDOMWriter={},l.React))})(this,function(l,m){function g(a){for(var c="https://reactjs.org/docs/error-decoder.html?invariant="+a,d=1;d<arguments.length;d++)c+="&args[]="+encodeURIComponent(arguments[d]);return"Minified React error #"+a+"; visit "+c+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."} | ||
function z(a,c){a.enqueue(c);return 0<a.desiredSize}function O(a,c,d){var b=[],e={destination:c,bundlerConfig:d,cache:new Map,nextChunkId:0,pendingChunks:0,pingedSegments:b,completedModuleChunks:[],completedJSONChunks:[],completedErrorChunks:[],writtenSymbols:new Map,writtenModules:new Map,flowing:!1,toJSON:function(a,b){return P(e,this,a,b)}};e.pendingChunks++;a=F(e,a);b.push(a);return e}function A(a,c,d,b){if(null!==d&&void 0!==d)throw Error(g(379));if("function"===typeof a)return a(b);if("string"=== | ||
typeof a)return[n,a,c,b];if("symbol"===typeof a)return a===G?b.children:[n,a,c,b];if(null!=a&&"object"===typeof a){if(a.$$typeof===H)return[n,a,c,b];switch(a.$$typeof){case I:return a=a.render,a(b,void 0);case J:return A(a.type,c,d,b)}}throw Error(g(351,B(a)));}function F(a,c){var d={id:a.nextChunkId++,model:c,ping:function(){var b=a.pingedSegments;b.push(d);1===b.length&&K(a)}};return d}function Q(a){return Object.prototype.toString.call(a).replace(/^\[object (.*)\]$/,function(a,d){return d})}function u(a){var c= | ||
JSON.stringify(a);return'"'+a+'"'===c?a:c}function B(a){switch(typeof a){case "string":return JSON.stringify(10>=a.length?a:a.substr(0,10)+"...");case "object":if(L(a))return"[...]";a=Q(a);return"Object"===a?"{...}":a;case "function":return"function";default:return String(a)}}function p(a,c){if(L(a)){for(var d="[",b=0;b<a.length;b++){0<b&&(d+=", ");if(6<b){d+="...";break}var e=a[b];d=""+b===c&&"object"===typeof e&&null!==e?d+p(e):d+B(e)}return d+"]"}d="{";b=Object.keys(a);for(e=0;e<b.length;e++){0< | ||
e&&(d+=", ");if(6<e){d+="...";break}var t=b[e];d+=u(t)+": ";var f=a[t];d=t===c&&"object"===typeof f&&null!==f?d+p(f):d+B(f)}return d+"}"}function P(a,c,d,b){switch(b){case n:return"$";case M:throw Error(g(352));}for(;"object"===typeof b&&null!==b&&b.$$typeof===n;){var e=b;try{b=A(e.type,e.key,e.ref,e.props)}catch(q){if("object"===typeof q&&null!==q&&"function"===typeof q.then)return a.pendingChunks++,a=F(a,b),c=a.ping,q.then(c,c),"@"+a.id.toString(16);a.pendingChunks++;c=a.nextChunkId++;C(a,c,q); | ||
return"@"+c.toString(16)}}if(null===b)return null;if("object"===typeof b){if(b.$$typeof===H){e=b.filepath+"#"+b.name;var t=a.writtenModules,f=t.get(e);if(void 0!==f)return c[0]===n&&"1"===d?"@"+f.toString(16):"$"+f.toString(16);try{var k=a.bundlerConfig[b.filepath][b.name];a.pendingChunks++;var h=a.nextChunkId++,r=x(k),l="M"+h.toString(16)+":"+r+"\n";var m=y.encode(l);a.completedModuleChunks.push(m);t.set(e,h);return c[0]===n&&"1"===d?"@"+h.toString(16):"$"+h.toString(16)}catch(q){return a.pendingChunks++, | ||
c=a.nextChunkId++,C(a,c,q),"$"+c.toString(16)}}return b}if("string"===typeof b)return a="$"===b[0]||"@"===b[0]?"$"+b:b,a;if("boolean"===typeof b||"number"===typeof b||"undefined"===typeof b)return b;if("function"===typeof b){if(/^on[A-Z]/.test(d))throw Error(g(374,u(d),p(c)));throw Error(g(375,u(d),b.displayName||b.name||"function",p(c)));}if("symbol"===typeof b){k=a.writtenSymbols;h=k.get(b);if(void 0!==h)return"$"+h.toString(16);h=b.description;if(Symbol.for(h)!==b)throw Error(g(376,b.description, | ||
u(d),p(c)));a.pendingChunks++;c=a.nextChunkId++;d=x(h);d="S"+c.toString(16)+":"+d+"\n";d=y.encode(d);a.completedModuleChunks.push(d);k.set(b,c);return"$"+c.toString(16)}if("bigint"===typeof b)throw Error(g(377,b,u(d),p(c)));throw Error(g(378,typeof b,u(d),p(c)));}function C(a,c,d){var b="";try{if(d instanceof Error){var e=""+d.message;b=""+d.stack}else e="Error: "+d}catch(t){e="An error occurred but serializing the error message failed."}d={message:e,stack:b};c="E"+c.toString(16)+":"+x(d)+"\n";c= | ||
y.encode(c);a.completedErrorChunks.push(c)}function K(a){var c=D.current,d=r;D.current=R;r=a.cache;var b=a.pingedSegments;a.pingedSegments=[];for(var e=0;e<b.length;e++){var f=b[e];var g=a;try{for(var k=f.model;"object"===typeof k&&null!==k&&k.$$typeof===n;){var h=k;f.model=k;k=A(h.type,h.key,h.ref,h.props)}var l=f.id,m=x(k,g.toJSON),p="J"+l.toString(16)+":"+m+"\n";var q=y.encode(p);g.completedJSONChunks.push(q)}catch(v){"object"===typeof v&&null!==v&&"function"===typeof v.then?(f=f.ping,v.then(f, | ||
f)):C(g,f.id,v)}}a.flowing&&N(a);D.current=c;r=d}function N(a){if(!E){E=!0;var c=a.destination;try{for(var d=a.completedModuleChunks,b=0;b<d.length;b++)if(a.pendingChunks--,!z(c,d[b])){a.flowing=!1;b++;break}d.splice(0,b);var e=a.completedJSONChunks;for(b=0;b<e.length;b++)if(a.pendingChunks--,!z(c,e[b])){a.flowing=!1;b++;break}e.splice(0,b);var f=a.completedErrorChunks;for(b=0;b<f.length;b++)if(a.pendingChunks--,!z(c,f[b])){a.flowing=!1;b++;break}f.splice(0,b)}finally{E=!1}0===a.pendingChunks&&c.close()}} | ||
function f(){throw Error(g(373));}function S(){if(!r)throw Error(g(384));}var y=new TextEncoder,x=JSON.stringify,H=Symbol.for("react.module.reference"),n=60103,G=60107,I=60112,J=60115,M=60116;if("function"===typeof Symbol&&Symbol.for){var w=Symbol.for;n=w("react.element");G=w("react.fragment");I=w("react.forward_ref");J=w("react.memo");M=w("react.lazy")}var L=Array.isArray,D=m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentDispatcher,E=!1,r=null,R={useMemo:function(a){return a()}, | ||
useCallback:function(a){return a},useDebugValue:function(){},useDeferredValue:f,useTransition:f,getCacheForType:function(a){if(!r)throw Error(g(380));var c=r.get(a);void 0===c&&(c=a(),r.set(a,c));return c},readContext:f,useContext:f,useReducer:f,useRef:f,useState:f,useLayoutEffect:f,useImperativeHandle:f,useEffect:f,useOpaqueIdentifier:f,useMutableSource:f,useCacheRefresh:function(){return S}};l.renderToReadableStream=function(a,c){var d;return new ReadableStream({start:function(b){b=d=O(a,b,c);b.flowing= | ||
!0;K(b)},pull:function(a){a=d;a.flowing=!0;N(a)},cancel:function(a){}})}}); | ||
(function(){'use strict';(function(l,n){"object"===typeof exports&&"undefined"!==typeof module?n(exports,require("react")):"function"===typeof define&&define.amd?define(["exports","react"],n):(l=l||self,n(l.ReactServerDOMWriter={},l.React))})(this,function(l,n){function h(a){for(var c="https://reactjs.org/docs/error-decoder.html?invariant="+a,d=1;d<arguments.length;d++)c+="&args[]="+encodeURIComponent(arguments[d]);return"Minified React error #"+a+"; visit "+c+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."} | ||
function A(a,c){a.enqueue(c);return 0<a.desiredSize}function G(a,c){"function"===typeof a.error?a.error(c):a.close()}function Q(a){console.error(a)}function R(a,c,d,b){var e=[],f={destination:c,bundlerConfig:d,cache:new Map,nextChunkId:0,pendingChunks:0,pingedSegments:e,completedModuleChunks:[],completedJSONChunks:[],completedErrorChunks:[],writtenSymbols:new Map,writtenModules:new Map,onError:void 0===b?Q:b,flowing:!1,toJSON:function(a,b){return S(f,this,a,b)}};f.pendingChunks++;a=H(f,a);e.push(a); | ||
return f}function B(a,c,d,b){if(null!==d&&void 0!==d)throw Error(h(379));if("function"===typeof a)return a(b);if("string"===typeof a)return[p,a,c,b];if("symbol"===typeof a)return a===I?b.children:[p,a,c,b];if(null!=a&&"object"===typeof a){if(a.$$typeof===J)return[p,a,c,b];switch(a.$$typeof){case K:return a=a.render,a(b,void 0);case L:return B(a.type,c,d,b)}}throw Error(h(351,C(a)));}function H(a,c){var d={id:a.nextChunkId++,model:c,ping:function(){var b=a.pingedSegments;b.push(d);1===b.length&&M(a)}}; | ||
return d}function T(a){return Object.prototype.toString.call(a).replace(/^\[object (.*)\]$/,function(a,d){return d})}function q(a){var c=JSON.stringify(a);return'"'+a+'"'===c?a:c}function C(a){switch(typeof a){case "string":return JSON.stringify(10>=a.length?a:a.substr(0,10)+"...");case "object":if(N(a))return"[...]";a=T(a);return"Object"===a?"{...}":a;case "function":return"function";default:return String(a)}}function r(a,c){if(N(a)){for(var d="[",b=0;b<a.length;b++){0<b&&(d+=", ");if(6<b){d+="..."; | ||
break}var e=a[b];d=""+b===c&&"object"===typeof e&&null!==e?d+r(e):d+C(e)}return d+"]"}d="{";b=Object.keys(a);for(e=0;e<b.length;e++){0<e&&(d+=", ");if(6<e){d+="...";break}var f=b[e];d+=q(f)+": ";var v=a[f];d=f===c&&"object"===typeof v&&null!==v?d+r(v):d+C(v)}return d+"}"}function S(a,c,d,b){switch(b){case p:return"$";case O:throw Error(h(352));}for(;"object"===typeof b&&null!==b&&b.$$typeof===p;){var e=b;try{b=B(e.type,e.key,e.ref,e.props)}catch(m){if("object"===typeof m&&null!==m&&"function"===typeof m.then)return a.pendingChunks++, | ||
a=H(a,b),c=a.ping,m.then(c,c),"@"+a.id.toString(16);x(a,m);a.pendingChunks++;c=a.nextChunkId++;D(a,c,m);return"@"+c.toString(16)}}if(null===b)return null;if("object"===typeof b){if(b.$$typeof===J){e=b.filepath+"#"+b.name;var f=a.writtenModules,v=f.get(e);if(void 0!==v)return c[0]===p&&"1"===d?"@"+v.toString(16):"$"+v.toString(16);try{var g=a.bundlerConfig[b.filepath][b.name];a.pendingChunks++;var k=a.nextChunkId++,t=y(g),l="M"+k.toString(16)+":"+t+"\n";var n=z.encode(l);a.completedModuleChunks.push(n); | ||
f.set(e,k);return c[0]===p&&"1"===d?"@"+k.toString(16):"$"+k.toString(16)}catch(m){return a.pendingChunks++,c=a.nextChunkId++,D(a,c,m),"$"+c.toString(16)}}return b}if("string"===typeof b)return a="$"===b[0]||"@"===b[0]?"$"+b:b,a;if("boolean"===typeof b||"number"===typeof b||"undefined"===typeof b)return b;if("function"===typeof b){if(/^on[A-Z]/.test(d))throw Error(h(374,q(d),r(c)));throw Error(h(375,q(d),b.displayName||b.name||"function",r(c)));}if("symbol"===typeof b){g=a.writtenSymbols;k=g.get(b); | ||
if(void 0!==k)return"$"+k.toString(16);k=b.description;if(Symbol.for(k)!==b)throw Error(h(376,b.description,q(d),r(c)));a.pendingChunks++;c=a.nextChunkId++;d=y(k);d="S"+c.toString(16)+":"+d+"\n";d=z.encode(d);a.completedModuleChunks.push(d);g.set(b,c);return"$"+c.toString(16)}if("bigint"===typeof b)throw Error(h(377,b,q(d),r(c)));throw Error(h(378,typeof b,q(d),r(c)));}function x(a,c){a=a.onError;a(c)}function D(a,c,d){var b="";try{if(d instanceof Error){var e=""+d.message;b=""+d.stack}else e="Error: "+ | ||
d}catch(f){e="An error occurred but serializing the error message failed."}d={message:e,stack:b};c="E"+c.toString(16)+":"+y(d)+"\n";c=z.encode(c);a.completedErrorChunks.push(c)}function M(a){var c=E.current,d=t;E.current=U;t=a.cache;try{var b=a.pingedSegments;a.pingedSegments=[];for(var e=0;e<b.length;e++){var f=b[e];var g=a;try{for(var h=f.model;"object"===typeof h&&null!==h&&h.$$typeof===p;){var k=h;f.model=h;h=B(k.type,k.key,k.ref,k.props)}var l=f.id,n=y(h,g.toJSON),r="J"+l.toString(16)+":"+n+ | ||
"\n";var m=z.encode(r);g.completedJSONChunks.push(m)}catch(u){if("object"===typeof u&&null!==u&&"function"===typeof u.then){var q=f.ping;u.then(q,q)}else x(g,u),D(g,f.id,u)}}a.flowing&&P(a)}catch(u){x(a,u),G(a.destination,u)}finally{E.current=c,t=d}}function P(a){if(!F){F=!0;var c=a.destination;try{for(var d=a.completedModuleChunks,b=0;b<d.length;b++)if(a.pendingChunks--,!A(c,d[b])){a.flowing=!1;b++;break}d.splice(0,b);var e=a.completedJSONChunks;for(b=0;b<e.length;b++)if(a.pendingChunks--,!A(c,e[b])){a.flowing= | ||
!1;b++;break}e.splice(0,b);var f=a.completedErrorChunks;for(b=0;b<f.length;b++)if(a.pendingChunks--,!A(c,f[b])){a.flowing=!1;b++;break}f.splice(0,b)}finally{F=!1}0===a.pendingChunks&&c.close()}}function g(){throw Error(h(373));}function V(){if(!t)throw Error(h(384));}var z=new TextEncoder,y=JSON.stringify,J=Symbol.for("react.module.reference"),p=60103,I=60107,K=60112,L=60115,O=60116;if("function"===typeof Symbol&&Symbol.for){var w=Symbol.for;p=w("react.element");I=w("react.fragment");K=w("react.forward_ref"); | ||
L=w("react.memo");O=w("react.lazy")}var N=Array.isArray,E=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentDispatcher,F=!1,t=null,U={useMemo:function(a){return a()},useCallback:function(a){return a},useDebugValue:function(){},useDeferredValue:g,useTransition:g,getCacheForType:function(a){if(!t)throw Error(h(380));var c=t.get(a);void 0===c&&(c=a(),t.set(a,c));return c},readContext:g,useContext:g,useReducer:g,useRef:g,useState:g,useLayoutEffect:g,useImperativeHandle:g,useEffect:g,useOpaqueIdentifier:g, | ||
useMutableSource:g,useCacheRefresh:function(){return V}};l.renderToReadableStream=function(a,c,d){var b;return new ReadableStream({start:function(e){e=b=R(a,e,c,d?d.onError:void 0);e.flowing=!0;M(e)},pull:function(a){a=b;a.flowing=!0;try{P(a)}catch(f){x(a,f),G(a.destination,f)}},cancel:function(a){}})}}); | ||
})(); |
171682
4064