react-ssr-prepass
Advanced tools
Comparing version 1.0.4 to 1.0.5
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
var is = require('react-is'); | ||
var is$1 = _interopDefault(require('object-is')); | ||
var React = require('react'); | ||
var React__default = _interopDefault(React); | ||
var is$1 = _interopDefault(require('object-is')); | ||
@@ -551,4 +551,2 @@ // | ||
return null; | ||
} finally { | ||
setCurrentIdentity(null); | ||
} | ||
@@ -562,10 +560,7 @@ }; | ||
setCurrentIdentity(makeIdentity()); | ||
var promise = visitor(element); | ||
if (element !== undefined) { | ||
var p = visitor(element); | ||
if (typeof p === 'object' && p !== null && typeof p.then === 'function') { | ||
queue.push(makeFrame(type, props, p)); | ||
return null; | ||
} | ||
if (promise) { | ||
queue.push(makeFrame(type, props, promise)); | ||
return null; | ||
} | ||
@@ -705,10 +700,7 @@ | ||
var instance = createInstance(type, props); | ||
var promise = visitor(element, instance); | ||
if (element !== undefined) { | ||
var p = visitor(element, instance); | ||
if (typeof p === 'object' && p !== null && typeof p.then === 'function') { | ||
queue.push(makeFrame$1(type, instance, p)); | ||
return null; | ||
} | ||
if (promise) { | ||
queue.push(makeFrame$1(type, instance, promise)); | ||
return null; | ||
} | ||
@@ -727,2 +719,82 @@ | ||
// | ||
var styledComponents; | ||
try { | ||
styledComponents = require('styled-components'); | ||
if (styledComponents.__DO_NOT_USE_OR_YOU_WILL_BE_HAUNTED_BY_SPOOKY_GHOSTS === undefined || styledComponents.ThemeContext === undefined) { | ||
styledComponents = undefined; | ||
} | ||
} catch (_error) {} | ||
/** Determines a StyledComponent's theme taking defaults into account */ | ||
var computeTheme = function (props, defaultProps) { | ||
var defaultTheme = defaultProps ? defaultProps.theme : undefined; | ||
var isDefaultTheme = defaultTheme ? props.theme === defaultTheme : false; | ||
if (props.theme && !isDefaultTheme) { | ||
return props.theme; | ||
} else { | ||
var contextTheme = readContextValue(styledComponents.ThemeContext); | ||
return contextTheme || defaultTheme; | ||
} | ||
}; | ||
/** Computes a StyledComponent's props with attributes */ | ||
var computeAttrsProps = function (input, props, theme) { | ||
var executionContext = Object.assign({}, props, | ||
{theme: theme}); | ||
var attrs = input.reduce(function (acc, attr) { | ||
if (typeof attr === 'function') { | ||
return Object.assign(acc, attr(executionContext)); | ||
} else if (typeof attr !== 'object' || attr === null) { | ||
return acc; | ||
} | ||
for (var key in attr) { | ||
var attrProp = attr[key]; | ||
if (typeof attrProp === 'function') { | ||
acc[key] = attrProp(executionContext); | ||
} else if (attr.hasOwnProperty(key)) { | ||
acc[key] = attrProp; | ||
} | ||
} | ||
return acc; | ||
}, {}); | ||
var newProps = Object.assign(attrs, props); | ||
newProps.className = props.className || ''; | ||
newProps.style = props.style ? Object.assign({}, attrs.style, props.style) : attrs.style; | ||
return newProps; | ||
}; | ||
/** Checks whether a ForwardRefElement is a StyledComponent element */ | ||
var isStyledElement = function (element) { return styledComponents !== undefined && typeof element.type.target !== undefined && typeof element.type.styledComponentId === 'string'; }; | ||
/** This is an optimised faux mounting strategy for StyledComponents. | ||
It is only enabled when styled-components is installed and the component | ||
can safely be skipped */ | ||
var mount$3 = function (element) { | ||
// Imitate styled-components' attrs props without computing styles | ||
var type = element.type; | ||
var attrs = Array.isArray(type.attrs) ? type.attrs : [type.attrs]; | ||
var computedProps = computeProps(element.props, type.defaultProps); | ||
var theme = computeTheme(element.props, type); | ||
var props = computeAttrsProps(attrs, computedProps, theme); | ||
var as = props.as || type.target; | ||
var children = computedProps.children || null; // StyledComponents rendering DOM elements can safely be skipped like normal DOM elements | ||
if (typeof as === 'string') { | ||
return getChildrenArray(children); | ||
} else { | ||
delete props.as; | ||
return [React.createElement(as, props, children)]; | ||
} | ||
}; | ||
// | ||
@@ -791,3 +863,4 @@ | ||
var type$2 = memoElement.type.type; | ||
var child$1 = render$3(type$2, memoElement.props, queue, visitor); | ||
var fauxElement = React.createElement(type$2, memoElement.props); | ||
var child$1 = render$3(type$2, memoElement.props, queue, visitor, fauxElement); | ||
return getChildrenArray(child$1); | ||
@@ -798,14 +871,16 @@ } | ||
{ | ||
var refElement = element; | ||
var refElement = element; // If we find a StyledComponent, we trigger a specific optimisation | ||
// that allows quick rendering of them without computing styles | ||
if (typeof refElement.type.styledComponentId === 'string' && typeof refElement.type.target !== 'function') { | ||
// This is an optimization that's specific to styled-components | ||
// We can safely skip them if they're not wrapping a component | ||
return getChildrenArray(refElement.props.children); | ||
} else { | ||
var props = refElement.props; | ||
var render$1 = refElement.type.render; | ||
var child$2 = mount$1(render$1, props, queue, visitor); | ||
return getChildrenArray(child$2); | ||
if (isStyledElement(refElement)) { | ||
return mount$3(refElement); | ||
} | ||
var ref$2 = refElement.type; | ||
var type$3 = ref$2.render; | ||
var defaultProps = ref$2.defaultProps; | ||
var props = computeProps(refElement.props, defaultProps); | ||
var fauxElement$1 = React.createElement(render$3, props); | ||
var child$2 = render$3(type$3, props, queue, visitor, fauxElement$1); | ||
return getChildrenArray(child$2); | ||
} | ||
@@ -822,5 +897,5 @@ | ||
var userElement = element; | ||
var type$3 = userElement.type; | ||
var type$4 = userElement.type; | ||
var props$1 = userElement.props; | ||
var child$3 = render$3(type$3, props$1, queue, visitor, userElement); | ||
var child$3 = render$3(type$4, props$1, queue, visitor, userElement); | ||
return getChildrenArray(child$3); | ||
@@ -837,14 +912,11 @@ } | ||
var visitLoop = function (traversalChildren, traversalIndex, traversalMap, traversalStore, queue, visitor) { | ||
var visitLoop = function (traversalChildren, traversalMap, traversalStore, queue, visitor) { | ||
var start = Date.now(); | ||
while (traversalChildren.length > 0 && Date.now() - start <= YIELD_AFTER_MS) { | ||
var currChildren = traversalChildren[traversalChildren.length - 1]; | ||
var currIndex = traversalIndex[traversalIndex.length - 1]++; | ||
while (traversalChildren.length > 0) { | ||
var element = traversalChildren[traversalChildren.length - 1].shift(); | ||
if (currIndex < currChildren.length) { | ||
var element = currChildren[currIndex]; | ||
if (element !== undefined) { | ||
var children = visitElement(element, queue, visitor); | ||
traversalChildren.push(children); | ||
traversalIndex.push(0); | ||
traversalMap.push(flushPrevContextMap()); | ||
@@ -854,27 +926,32 @@ traversalStore.push(flushPrevContextStore()); | ||
traversalChildren.pop(); | ||
traversalIndex.pop(); | ||
restoreContextMap(traversalMap.pop()); | ||
restoreContextStore(traversalStore.pop()); | ||
} | ||
if (Date.now() - start > YIELD_AFTER_MS) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
}; | ||
var makeYieldFrame = function (traversalChildren, traversalMap, traversalStore) { return ({ | ||
contextMap: getCurrentContextMap(), | ||
contextStore: getCurrentContextStore(), | ||
thenable: Promise.resolve(), | ||
kind: 'frame.yield', | ||
children: traversalChildren, | ||
map: traversalMap, | ||
store: traversalStore | ||
}); }; | ||
var visitChildren = function (init, queue, visitor) { | ||
var traversalChildren = [init]; | ||
var traversalIndex = [0]; | ||
var traversalMap = [flushPrevContextMap()]; | ||
var traversalStore = [flushPrevContextStore()]; | ||
visitLoop(traversalChildren, traversalIndex, traversalMap, traversalStore, queue, visitor); | ||
var hasYielded = visitLoop(traversalChildren, traversalMap, traversalStore, queue, visitor); | ||
if (traversalChildren.length > 0) { | ||
queue.unshift({ | ||
contextMap: getCurrentContextMap(), | ||
contextStore: getCurrentContextStore(), | ||
thenable: Promise.resolve(), | ||
kind: 'frame.yield', | ||
children: traversalChildren, | ||
index: traversalIndex, | ||
map: traversalMap, | ||
store: traversalStore | ||
}); | ||
if (hasYielded) { | ||
queue.unshift(makeYieldFrame(traversalChildren, traversalMap, traversalStore)); | ||
} | ||
@@ -886,3 +963,7 @@ }; | ||
setCurrentContextStore(frame.contextStore); | ||
visitLoop(frame.children, frame.index, frame.map, frame.store, queue, visitor); | ||
var hasYielded = visitLoop(frame.children, frame.map, frame.store, queue, visitor); | ||
if (hasYielded) { | ||
queue.unshift(makeYieldFrame(frame.children, frame.map, frame.store)); | ||
} | ||
}; | ||
@@ -921,7 +1002,7 @@ | ||
if (frame.kind === 'frame.class') { | ||
children = getChildrenArray(update$2(queue, frame)); | ||
children = update$2(queue, frame); | ||
} else if (frame.kind === 'frame.hooks') { | ||
children = getChildrenArray(update$1(queue, frame)); | ||
children = update$1(queue, frame); | ||
} else if (frame.kind === 'frame.lazy') { | ||
children = getChildrenArray(update(queue, frame)); | ||
children = update(queue, frame); | ||
} // Now continue walking the previously suspended component's | ||
@@ -931,3 +1012,3 @@ // children (which might also suspend) | ||
visitChildren(children, queue, visitor); | ||
visitChildren(getChildrenArray(children), queue, visitor); | ||
ReactCurrentDispatcher.current = prevDispatcher; | ||
@@ -945,3 +1026,3 @@ }); | ||
var defaultVisitor = function () {}; | ||
var defaultVisitor = function () { return undefined; }; | ||
@@ -948,0 +1029,0 @@ var renderPrepass = function (element, visitor) { |
@@ -1,2 +0,2 @@ | ||
function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}var e=require("react-is"),n=require("react"),r=t(n),u=t(require("object-is")),o=e.Element,i=e.Portal,c=e.Fragment,a=e.StrictMode,l=e.Profiler,f=e.ContextProvider,s=e.ContextConsumer,p=e.ConcurrentMode,d=e.ForwardRef,v=e.Suspense,h=e.Memo,y=e.Lazy,m=n.Children.toArray,x=function(t){return null!==t&&"object"==typeof t},_=function(t){return m(t).filter(x)},S=function(t,e){return"object"==typeof e?Object.assign({},e,t):t},g=new Map,M={},b=void 0,w=void 0,C=function(){return Object.assign({},M)},j=function(){return new Map(g)},E=function(){var t=b;return b=void 0,t},k=function(){var t=w;return w=void 0,t},z=function(t){void 0!==t&&g.set(t[0],t[1])},q=function(t){b=void 0,M=t},P=function(t){w=void 0,g=t},O=function(t){var e=g.get(t);return void 0!==e?e:t._currentValue},D={},F=function(t){var e=t.contextType,n=t.contextTypes;if(e)return O(e);if(!n)return D;var r={};for(var u in n)r[u]=M[u];return r},R=null,W=function(t){R=t},N=function(){if(null===R)throw new Error("[react-ssr-prepass] Hooks can only be called inside the body of a function component. (https://fb.me/react-invalid-hook-call)");return R},U=null,I=null,T=!1,A=!1,L=null,$=0,V=function(t){U=t};function H(){return null===I?null===U?(T=!1,U=I={memoizedState:null,queue:null,next:null}):(T=!0,I=U):null===I.next?(T=!1,I=I.next={memoizedState:null,queue:null,next:null}):(T=!0,I=I.next),I}function B(t,e){return"function"==typeof e?e(t):e}function Y(t,e,n){var r,u=N();if(I=H(),T){var o=I.queue,i=o.dispatch;if(null!==L){var c=L.get(o);if(void 0!==c){L.delete(o);var a=I.memoizedState,l=c;do{a=t(a,l.action),l=l.next}while(null!==l);return I.memoizedState=a,[a,i]}}return[I.memoizedState,i]}r=t===B?"function"==typeof e?e():e:void 0!==n?n(e):e,I.memoizedState=r;var f=I.queue={last:null,dispatch:null},s=f.dispatch=function(t,e,n){if(t===N()){A=!0;var r={action:n,next:null};null===L&&(L=new Map);var u=L.get(e);if(void 0===u)L.set(e,r);else{for(var o=u;null!==o.next;)o=o.next;o.next=r}}}.bind(null,u,f);return[I.memoizedState,s]}function G(){}var J={readContext:function(t,e){return O(t)},useContext:function(t,e){return N(),O(t)},useMemo:function(t,e){N();var n=void 0===e?null:e;if(null!==(I=H())){var r=I.memoizedState;if(null!==r&&null!==n&&function(t,e){if(null===e)return!1;for(var n=0;n<e.length&&n<t.length;n++)if(!u(t[n],e[n]))return!1;return!0}(n,r[1]))return r[0]}var o=t();return I.memoizedState=[o,n],o},useReducer:Y,useRef:function(t){N();var e=(I=H()).memoizedState;if(null===e){var n={current:t};return I.memoizedState=n,n}return e},useState:function(t){return Y(B,t)},useCallback:function(t,e){return t},useLayoutEffect:G,useImperativeHandle:G,useEffect:G,useDebugValue:G},K=function(t){return t._status=0,t._ctor().then(function(e){"function"==typeof e?(t._result=e,t._status=1):null!==e&&"object"==typeof e&&"function"==typeof e.default?(t._result=e.default,t._status=1):t._status=2}).catch(function(){t._status=2})},Q=function(t,e,r){return 1===t._status?n.createElement(t._result,e):null},X=function(t,e,n){return{contextMap:C(),contextStore:j(),id:N(),hook:U,kind:"frame.hooks",thenable:n,props:e,type:t}},Z=function(t,e,n){try{return function(t,e,n){for(var r=t(e,n);$<25&&A;)A=!1,$+=1,I=null,r=t(e,n);return $=0,L=null,I=null,r}(t,S(e,t.defaultProps),F(t))}catch(r){if("function"!=typeof r.then)throw r;return n.push(X(t,e,r)),null}finally{W(null)}},tt=function(t,e,n,r,u){if(V(null),W({}),void 0!==u){var o=r(u);if("object"==typeof o&&null!==o&&"function"==typeof o.then)return n.push(X(t,e,o)),null}return Z(t,e,n)},et=function(t,e,n){return{contextMap:C(),contextStore:j(),thenable:n,kind:"frame.class",instance:e,type:t}},nt=function(t,e,n){!function(t){var e=t.updater.queue;if(e.length>0){for(var n=Object.assign({},t.state),r=0,u=e.length;r<u;r++){var o=e[r],i="function"==typeof o?o.call(t,n,t.props,t.context):o;null!==i&&Object.assign(n,i)}t.state=n,e.length=0}}(e);var r=null;try{r=e.render()}catch(r){if("function"!=typeof r.then)throw r;return n.push(et(t,e,r)),null}if(void 0!==t.childContextTypes&&"function"==typeof e.getChildContext){var u=e.getChildContext();null!==u&&"object"==typeof u&&function(t){for(var e in b={},t)b[e]=M[e],M[e]=t[e]}(u)}if("function"!=typeof e.getDerivedStateFromProps&&("function"==typeof e.componentWillMount||"function"==typeof e.UNSAFE_componentWillMount)&&"function"==typeof e.componentWillUnmount)try{e.componentWillUnmount()}catch(t){}return e._isMounted=!1,r},rt="production"!==process.env.NODE_ENV?20:5,ut=function(t,e,n,r,u){return(o=t).prototype&&o.prototype.isReactComponent?function(t,e,n,r,u){W(null);var o=function(t,e){var n,r={queue:n=[],isMounted:function(){return!1},enqueueForceUpdate:function(){return null},enqueueReplaceState:function(t,e){t._isMounted&&(n.length=0,n.push(e))},enqueueSetState:function(t,e){t._isMounted&&n.push(e)}},u=S(e,t.defaultProps),o=F(t),i=new t(u,o,r);if(i.props=u,i.context=o,i.updater=r,i._isMounted=!0,void 0===i.state&&(i.state=null),"function"==typeof t.getDerivedStateFromProps){var c=(0,t.getDerivedStateFromProps)(i.props,i.state);null!=c&&(i.state=Object.assign({},i.state,c))}else"function"==typeof i.componentWillMount?i.componentWillMount():"function"==typeof i.UNSAFE_componentWillMount&&i.UNSAFE_componentWillMount();return i}(t,e);if(void 0!==u){var i=r(u,o);if("object"==typeof i&&null!==i&&"function"==typeof i.then)return n.push(et(t,o,i)),null}return nt(t,o,n)}(t,e,n,r,u):tt(t,e,n,r,u);var o},ot=function(t,e,n){switch(function(t){switch(t.$$typeof){case i:return i;case o:switch(t.type){case p:return p;case c:return c;case l:return l;case a:return a;case v:return v;default:switch(t.type&&t.type.$$typeof){case y:return y;case h:return h;case s:return s;case f:return f;case d:return d;default:return o}}default:return}}(t)){case v:case a:case p:case l:case c:return _(t.props.children);case f:var r=t.props,u=r.children;return function(t,e){w=[t,g.get(t)],g.set(t,e)}(t.type._context,r.value),_(u);case s:var m=t.props.children;if("function"==typeof m){var x=t.type,S=O("object"==typeof x._context?x._context:x);return _(m(S))}return[];case y:var M=function(t,e,n){return 2!==t._status&&1!==t._status?(n.push({contextMap:C(),contextStore:j(),kind:"frame.lazy",thenable:K(t),props:e,type:t}),null):Q(t,e)}(t.type,t.props,e);return _(M);case h:var b=ut(t.type.type,t.props,e,n);return _(b);case d:var E=t;if("string"==typeof E.type.styledComponentId&&"function"!=typeof E.type.target)return _(E.props.children);var k=tt(E.type.render,E.props,e,n);return _(k);case o:if("string"==typeof t.type)return _(t.props.children);var z=ut(t.type,t.props,e,n,t);return _(z);case i:default:return[]}},it=function(t,e,n,r,u,o){for(var i,c=Date.now();t.length>0&&Date.now()-c<=rt;){var a=t[t.length-1],l=e[e.length-1]++;if(l<a.length){var f=ot(a[l],u,o);t.push(f),e.push(0),n.push(E()),r.push(k())}else t.pop(),e.pop(),void 0!==(i=n.pop())&&Object.assign(M,i),z(r.pop())}},ct=function(t,e,n){var r=[t],u=[0],o=[E()],i=[k()];it(r,u,o,i,e,n),r.length>0&&e.unshift({contextMap:C(),contextStore:j(),thenable:Promise.resolve(),kind:"frame.yield",children:r,index:u,map:o,store:i})},at=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentDispatcher,lt=at.current,ft=function(t,e){return 0===t.length?Promise.resolve():function(t,e,n){if("frame.yield"===t.kind){var r=t;return new Promise(function(t){setImmediate(function(){lt=at.current,at.current=J,function(t,e,n){W(null),q(t.contextMap),P(t.contextStore),it(t.children,t.index,t.map,t.store,e,n)}(r,e,n),at.current=lt,t()})})}return t.thenable.then(function(){lt=at.current,at.current=J;var r=[];"frame.class"===t.kind?r=_(function(t,e){return W(null),q(e.contextMap),P(e.contextStore),nt(e.type,e.instance,t)}(e,t)):"frame.hooks"===t.kind?r=_(function(t,e){return V(e.hook),W(e.id),q(e.contextMap),P(e.contextStore),Z(e.type,e.props,t)}(e,t)):"frame.lazy"===t.kind&&(r=_(function(t,e){return W(null),q(e.contextMap),P(e.contextStore),Q(e.type,e.props)}(0,t))),ct(r,e,n),at.current=lt})}(t.shift(),t,e).then(function(){return ft(t,e)})},st=function(){};module.exports=function(t,e){var n=[],r=void 0!==e?e:st;q({}),P(new Map);try{lt=at.current,at.current=J,ct(_(t),n,r)}catch(t){return Promise.reject(t)}finally{at.current=lt}return ft(n,r)}; | ||
function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}var e=require("react-is"),n=t(require("object-is")),r=require("react"),o=t(r),u=e.Element,i=e.Portal,c=e.Fragment,a=e.StrictMode,l=e.Profiler,s=e.ContextProvider,f=e.ContextConsumer,p=e.ConcurrentMode,d=e.ForwardRef,v=e.Suspense,y=e.Memo,h=e.Lazy,m=r.Children.toArray,_=function(t){return null!==t&&"object"==typeof t},x=function(t){return m(t).filter(_)},S=function(t,e){return"object"==typeof e?Object.assign({},e,t):t},g=new Map,b={},M=void 0,O=void 0,E=function(){return Object.assign({},b)},j=function(){return new Map(g)},w=function(){var t=M;return M=void 0,t},C=function(){var t=O;return O=void 0,t},P=function(t){void 0!==t&&g.set(t[0],t[1])},k=function(t){M=void 0,b=t},z=function(t){O=void 0,g=t},q=function(t){var e=g.get(t);return void 0!==e?e:t._currentValue},D={},N=function(t){var e=t.contextType,n=t.contextTypes;if(e)return q(e);if(!n)return D;var r={};for(var o in n)r[o]=b[o];return r},R=null,T=function(t){R=t},U=function(){if(null===R)throw new Error("[react-ssr-prepass] Hooks can only be called inside the body of a function component. (https://fb.me/react-invalid-hook-call)");return R},F=null,W=null,A=!1,I=!1,L=null,H=0,Y=function(t){F=t};function $(){return null===W?null===F?(A=!1,F=W={memoizedState:null,queue:null,next:null}):(A=!0,W=F):null===W.next?(A=!1,W=W.next={memoizedState:null,queue:null,next:null}):(A=!0,W=W.next),W}function B(t,e){return"function"==typeof e?e(t):e}function V(t,e,n){var r,o=U();if(W=$(),A){var u=W.queue,i=u.dispatch;if(null!==L){var c=L.get(u);if(void 0!==c){L.delete(u);var a=W.memoizedState,l=c;do{a=t(a,l.action),l=l.next}while(null!==l);return W.memoizedState=a,[a,i]}}return[W.memoizedState,i]}r=t===B?"function"==typeof e?e():e:void 0!==n?n(e):e,W.memoizedState=r;var s=W.queue={last:null,dispatch:null},f=s.dispatch=function(t,e,n){if(t===U()){I=!0;var r={action:n,next:null};null===L&&(L=new Map);var o=L.get(e);if(void 0===o)L.set(e,r);else{for(var u=o;null!==u.next;)u=u.next;u.next=r}}}.bind(null,o,s);return[W.memoizedState,f]}function G(){}var K,J={readContext:function(t,e){return q(t)},useContext:function(t,e){return U(),q(t)},useMemo:function(t,e){U();var r=void 0===e?null:e;if(null!==(W=$())){var o=W.memoizedState;if(null!==o&&null!==r&&function(t,e){if(null===e)return!1;for(var r=0;r<e.length&&r<t.length;r++)if(!n(t[r],e[r]))return!1;return!0}(r,o[1]))return o[0]}var u=t();return W.memoizedState=[u,r],u},useReducer:V,useRef:function(t){U();var e=(W=$()).memoizedState;if(null===e){var n={current:t};return W.memoizedState=n,n}return e},useState:function(t){return V(B,t)},useCallback:function(t,e){return t},useLayoutEffect:G,useImperativeHandle:G,useEffect:G,useDebugValue:G},Q=function(t){return t._status=0,t._ctor().then(function(e){"function"==typeof e?(t._result=e,t._status=1):null!==e&&"object"==typeof e&&"function"==typeof e.default?(t._result=e.default,t._status=1):t._status=2}).catch(function(){t._status=2})},X=function(t,e,n){return 1===t._status?r.createElement(t._result,e):null},Z=function(t,e,n){return{contextMap:E(),contextStore:j(),id:U(),hook:F,kind:"frame.hooks",thenable:n,props:e,type:t}},tt=function(t,e,n){try{return function(t,e,n){for(var r=t(e,n);H<25&&I;)I=!1,H+=1,W=null,r=t(e,n);return H=0,L=null,W=null,r}(t,S(e,t.defaultProps),N(t))}catch(r){if("function"!=typeof r.then)throw r;return n.push(Z(t,e,r)),null}},et=function(t,e,n){return{contextMap:E(),contextStore:j(),thenable:n,kind:"frame.class",instance:e,type:t}},nt=function(t,e,n){!function(t){var e=t.updater.queue;if(e.length>0){for(var n=Object.assign({},t.state),r=0,o=e.length;r<o;r++){var u=e[r],i="function"==typeof u?u.call(t,n,t.props,t.context):u;null!==i&&Object.assign(n,i)}t.state=n,e.length=0}}(e);var r=null;try{r=e.render()}catch(r){if("function"!=typeof r.then)throw r;return n.push(et(t,e,r)),null}if(void 0!==t.childContextTypes&&"function"==typeof e.getChildContext){var o=e.getChildContext();null!==o&&"object"==typeof o&&function(t){for(var e in M={},t)M[e]=b[e],b[e]=t[e]}(o)}if("function"!=typeof e.getDerivedStateFromProps&&("function"==typeof e.componentWillMount||"function"==typeof e.UNSAFE_componentWillMount)&&"function"==typeof e.componentWillUnmount)try{e.componentWillUnmount()}catch(t){}return e._isMounted=!1,r};try{void 0!==(K=require("styled-components")).__DO_NOT_USE_OR_YOU_WILL_BE_HAUNTED_BY_SPOOKY_GHOSTS&&void 0!==K.ThemeContext||(K=void 0)}catch(t){}var rt="production"!==process.env.NODE_ENV?20:5,ot=function(t,e,n,r,o){return(u=t).prototype&&u.prototype.isReactComponent?function(t,e,n,r,o){T(null);var u=function(t,e){var n,r={queue:n=[],isMounted:function(){return!1},enqueueForceUpdate:function(){return null},enqueueReplaceState:function(t,e){t._isMounted&&(n.length=0,n.push(e))},enqueueSetState:function(t,e){t._isMounted&&n.push(e)}},o=S(e,t.defaultProps),u=N(t),i=new t(o,u,r);if(i.props=o,i.context=u,i.updater=r,i._isMounted=!0,void 0===i.state&&(i.state=null),"function"==typeof t.getDerivedStateFromProps){var c=(0,t.getDerivedStateFromProps)(i.props,i.state);null!=c&&(i.state=Object.assign({},i.state,c))}else"function"==typeof i.componentWillMount?i.componentWillMount():"function"==typeof i.UNSAFE_componentWillMount&&i.UNSAFE_componentWillMount();return i}(t,e),i=r(o,u);return i?(n.push(et(t,u,i)),null):nt(t,u,n)}(t,e,n,r,o):function(t,e,n,r,o){Y(null),T({});var u=r(o);return u?(n.push(Z(t,e,u)),null):tt(t,e,n)}(t,e,n,r,o);var u},ut=function(t,e,n){switch(function(t){switch(t.$$typeof){case i:return i;case u:switch(t.type){case p:return p;case c:return c;case l:return l;case a:return a;case v:return v;default:switch(t.type&&t.type.$$typeof){case h:return h;case y:return y;case f:return f;case s:return s;case d:return d;default:return u}}default:return}}(t)){case v:case a:case p:case l:case c:return x(t.props.children);case s:var o=t.props,m=o.children;return function(t,e){O=[t,g.get(t)],g.set(t,e)}(t.type._context,o.value),x(m);case f:var _=t.props.children;if("function"==typeof _){var b=t.type,M=q("object"==typeof b._context?b._context:b);return x(_(M))}return[];case h:var w=function(t,e,n){return 2!==t._status&&1!==t._status?(n.push({contextMap:E(),contextStore:j(),kind:"frame.lazy",thenable:Q(t),props:e,type:t}),null):X(t,e)}(t.type,t.props,e);return x(w);case y:var C=t,P=C.type.type,k=r.createElement(P,C.props),z=ot(P,C.props,e,n,k);return x(z);case d:var D=t;if(void 0!==K&&void 0!==typeof D.type.target&&"string"==typeof D.type.styledComponentId)return function(t){var e=t.type,n=Array.isArray(e.attrs)?e.attrs:[e.attrs],o=S(t.props,e.defaultProps),u=function(t,e,n){var r=Object.assign({},e,{theme:n}),o=t.reduce(function(t,e){if("function"==typeof e)return Object.assign(t,e(r));if("object"!=typeof e||null===e)return t;for(var n in e){var o=e[n];"function"==typeof o?t[n]=o(r):e.hasOwnProperty(n)&&(t[n]=o)}return t},{}),u=Object.assign(o,e);return u.className=e.className||"",u.style=e.style?Object.assign({},o.style,e.style):o.style,u}(n,o,function(t,n){var r=e?e.theme:void 0;return!t.theme||r&&t.theme===r?q(K.ThemeContext)||r:t.theme}(t.props)),i=u.as||e.target,c=o.children||null;return"string"==typeof i?x(c):(delete u.as,[r.createElement(i,u,c)])}(D);var N=D.type,R=N.render,T=S(D.props,N.defaultProps),U=r.createElement(ot,T),F=ot(R,T,e,n,U);return x(F);case u:if("string"==typeof t.type)return x(t.props.children);var W=ot(t.type,t.props,e,n,t);return x(W);case i:default:return[]}},it=function(t,e,n,r,o){for(var u,i=Date.now();t.length>0;){var c=t[t.length-1].shift();if(void 0!==c){var a=ut(c,r,o);t.push(a),e.push(w()),n.push(C())}else t.pop(),void 0!==(u=e.pop())&&Object.assign(b,u),P(n.pop());if(Date.now()-i>rt)return!0}return!1},ct=function(t,e,n){return{contextMap:E(),contextStore:j(),thenable:Promise.resolve(),kind:"frame.yield",children:t,map:e,store:n}},at=function(t,e,n){var r=[t],o=[w()],u=[C()];it(r,o,u,e,n)&&e.unshift(ct(r,o,u))},lt=o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentDispatcher,st=lt.current,ft=function(t,e){return 0===t.length?Promise.resolve():function(t,e,n){if("frame.yield"===t.kind){var r=t;return new Promise(function(t){setImmediate(function(){st=lt.current,lt.current=J,function(t,e,n){T(null),k(t.contextMap),z(t.contextStore),it(t.children,t.map,t.store,e,n)&&e.unshift(ct(t.children,t.map,t.store))}(r,e,n),lt.current=st,t()})})}return t.thenable.then(function(){st=lt.current,lt.current=J;var r=[];"frame.class"===t.kind?r=function(t,e){return T(null),k(e.contextMap),z(e.contextStore),nt(e.type,e.instance,t)}(e,t):"frame.hooks"===t.kind?r=function(t,e){return Y(e.hook),T(e.id),k(e.contextMap),z(e.contextStore),tt(e.type,e.props,t)}(e,t):"frame.lazy"===t.kind&&(r=function(t,e){return T(null),k(e.contextMap),z(e.contextStore),X(e.type,e.props)}(0,t)),at(x(r),e,n),lt.current=st})}(t.shift(),t,e).then(function(){return ft(t,e)})},pt=function(){};module.exports=function(t,e){var n=[],r=void 0!==e?e:pt;k({}),z(new Map);try{st=lt.current,lt.current=J,at(x(t),n,r)}catch(t){return Promise.reject(t)}finally{lt.current=st}return ft(n,r)}; | ||
//# sourceMappingURL=react-ssr-prepass.production.min.js.map |
{ | ||
"name": "react-ssr-prepass", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "A custom partial React SSR renderer for prefetching and suspense", | ||
@@ -60,4 +60,4 @@ "main": "index.js", | ||
"peerDependencies": { | ||
"react": "^16.6.0", | ||
"react-is": "^16.6.0" | ||
"react": "^16.8.0", | ||
"react-is": "^16.8.0" | ||
}, | ||
@@ -64,0 +64,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
121544
903