UNPKG

redux-router-preload

Version:

Universal preloading for [redux-router](https://github.com/acdlite/redux-router)

1 lines 14.9 kB
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react"),require("react-redux")):"function"==typeof define&&define.amd?define(["react","react-redux"],e):"object"==typeof exports?exports.ReduxRouterPreload=e(require("react"),require("react-redux")):t.ReduxRouterPreload=e(t.React,t.ReactRedux)}(this,function(t,e){return function(t){function e(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return t[n].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0});var o=r(3);Object.defineProperty(e,"preload",{enumerable:!0,get:function(){return n(o)["default"]}});var a=r(2);Object.defineProperty(e,"reducer",{enumerable:!0,get:function(){return n(a)["default"]}})},function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.LOADER_FIELD="@@reduxReactRouterPreload/loaderField",e.SERVER_LOAD="@@reduxReactRouterPreload/serverLoad"},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.initialState=void 0;var n=Object.assign||function(t){for(var e=1;arguments.length>e;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},o=r(1),a=e.initialState={loadedOnServer:!1,shouldReloadAfterServerPreload:!1,initialDidChangeDispatched:!1},i=function(t){return function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:a,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};switch(r.type){case t:return e.loadedOnServer?e.initialDidChangeDispatched?n({},e,{shouldReloadAfterServerPreload:!0}):n({},e,{initialDidChangeDispatched:!0}):e;case o.SERVER_LOAD:return n({},e,{loadedOnServer:!0});default:return e}}};e["default"]=i},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){var r={};for(var n in t)e.indexOf(n)<0&&Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=t[n]);return r}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function u(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0}),e.createPreload=void 0;var c=Object.assign||function(t){for(var e=1;arguments.length>e;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},f=function(){function t(t,e){for(var r=0;e.length>r;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),l=r(10),s=n(l),p=r(1),d=r(11),h=r(4),v=n(h),y=r(5),_=n(y),b=r(7),g=n(b),j=function(t){return{preloadState:t.preload,state:t}},O=function(t){return{dispatch:t}},w=function(t){return t.routeParams},m=e.createPreload=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){return!0},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:w;return function(l){function p(){a(this,p);var t=i(this,Object.getPrototypeOf(p).call(this));return t.state={loading:!1},t}return u(p,l),f(p,[{key:"componentWillReceiveProps",value:function(t){var e=n(t),r=n(this.props);(0,g["default"])(e,r)||this.preloadData(t)}},{key:"componentWillMount",value:function(){this.preloadData()}},{key:"shouldComponentUpdate",value:function(t,e){var n=this.props,o={prevProps:n,nextProps:t},a=this.state,i={prevState:a,nextState:e};return r(o,i)}},{key:"preloadData",value:function(e){var r=this,n=e||this.props,a=n.preloadState,i=n.dispatch,u=n.state,c=o(n,["preloadState","dispatch","state"]);if(!a.loadedOnServer||a.shouldReloadAfterServerPreload){this.setState({loading:!0});var f=t(i,u,c);(0,_["default"])(f&&f.then,"first argument of the preload decorator should return a promise"),f.then(function(){return r.setState({loading:!1})})}}},{key:"render",value:function(){var t=this.state.loading,r=c({loading:t},this.props);return s["default"].createElement(e,r)}}]),p}(l.Component)},P=function(t,e){return function(r){var n=m(t,r,e);n[p.LOADER_FIELD]=t;var o=(0,v["default"])(n,r);return(0,d.connect)(j,O)(o)}};e["default"]=P},function(t,e){"use strict";var r={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,mixins:!0,propTypes:!0,type:!0},n={name:!0,length:!0,prototype:!0,caller:!0,arguments:!0,arity:!0};t.exports=function(t,e){if("string"!=typeof e)for(var o=Object.getOwnPropertyNames(e),a=0;o.length>a;++a)if(!r[o[a]]&&!n[o[a]])try{t[o[a]]=e[o[a]]}catch(i){}return t}},function(t,e,r){"use strict";var n=function(t,e,r,n,o,a,i,u){if(!t){var c;if(void 0===e)c=Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var f=[r,n,o,a,i,u],l=0;c=Error(e.replace(/%s/g,function(){return f[l++]})),c.name="Invariant Violation"}throw c.framesToPop=1,c}};t.exports=n},function(t,e,r){(function(t,r){function n(t){return t&&t.Object===Object?t:null}var o={"function":!0,object:!0},a=o[typeof e]&&e&&!e.nodeType?e:void 0,i=o[typeof t]&&t&&!t.nodeType?t:void 0,u=n(a&&i&&"object"==typeof r&&r),c=n(o[typeof self]&&self),f=n(o[typeof window]&&window),l=n(o[typeof this]&&this),s=u||f!==(l&&l.window)&&f||c||l||Function("return this")();t.exports=s}).call(e,r(9)(t),function(){return this}()||Function("return this")())},function(t,e,r){function n(t,e){for(var r=-1,n=t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}function o(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(r){}return e}function a(t){var e=-1,r=Array(t.size);return t.forEach(function(t,n){r[++e]=[n,t]}),r}function i(t){var e=-1,r=Array(t.size);return t.forEach(function(t){r[++e]=t}),r}function u(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function c(){this.__data__=Zt?Zt(null):{}}function f(t){return this.has(t)&&delete this.__data__[t]}function l(t){var e=this.__data__;if(Zt){var r=e[t];return r===ot?void 0:r}return qt.call(e,t)?e[t]:void 0}function s(t){var e=this.__data__;return Zt?void 0!==e[t]:qt.call(e,t)}function p(t,e){var r=this.__data__;return r[t]=Zt&&void 0===e?ot:e,this}function d(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function h(){this.__data__=[]}function v(t){var e=this.__data__,r=L(e,t);if(0>r)return!1;var n=e.length-1;return r==n?e.pop():Gt.call(e,r,1),!0}function y(t){var e=this.__data__,r=L(e,t);return 0>r?void 0:e[r][1]}function _(t){return L(this.__data__,t)>-1}function b(t,e){var r=this.__data__,n=L(r,t);return 0>n?r.push([t,e]):r[n][1]=e,this}function g(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function j(){this.__data__={hash:new u,map:new(Kt||d),string:new u}}function O(t){return q(this,t)["delete"](t)}function w(t){return q(this,t).get(t)}function m(t){return q(this,t).has(t)}function P(t,e){return q(this,t).set(t,e),this}function x(t){var e=-1,r=t?t.length:0;for(this.__data__=new g;++e<r;)this.add(t[e])}function A(t){return this.__data__.set(t,ot),this}function S(t){return this.__data__.has(t)}function R(t){this.__data__=new d(t)}function E(){this.__data__=new d}function D(t){return this.__data__["delete"](t)}function k(t){return this.__data__.get(t)}function F(t){return this.__data__.has(t)}function M(t,e){var r=this.__data__;return r instanceof d&&r.__data__.length==nt&&(r=this.__data__=new g(r.__data__)),r.set(t,e),this}function L(t,e){for(var r=t.length;r--;)if(H(t[r][0],e))return r;return-1}function C(t,e){return qt.call(t,e)||"object"==typeof t&&e in t&&null===W(t)}function T(t,e,r,n,o){return t===e?!0:null==t||null==e||!X(t)&&!Y(e)?t!==t&&e!==e:I(t,e,T,r,n,o)}function I(t,e,r,n,a,i){var u=ue(t),c=ue(e),f=ft,l=ft;u||(f=B(t),f=f==ct?_t:f),c||(l=B(e),l=l==ct?_t:l);var s=f==_t&&!o(t),p=l==_t&&!o(e),d=f==l;if(d&&!s)return i||(i=new R),u||tt(t)?U(t,e,r,n,a,i):$(t,e,f,r,n,a,i);if(!(a&it)){var h=s&&qt.call(t,"__wrapped__"),v=p&&qt.call(e,"__wrapped__");if(h||v){var y=h?t.value():t,_=v?e.value():e;return i||(i=new R),r(y,_,n,a,i)}}return d?(i||(i=new R),V(t,e,r,n,a,i)):!1}function U(t,e,r,o,a,i){var u=a&it,c=t.length,f=e.length;if(!(c==f||u&&f>c))return!1;var l=i.get(t);if(l)return l==e;var s=-1,p=!0,d=a&at?new x:void 0;for(i.set(t,e);++s<c;){var h=t[s],v=e[s];if(o)var y=u?o(v,h,s,e,t,i):o(h,v,s,t,e,i);if(void 0!==y){if(y)continue;p=!1;break}if(d){if(!n(e,function(t,e){return d.has(e)||h!==t&&!r(h,t,o,a,i)?void 0:d.add(e)})){p=!1;break}}else if(h!==v&&!r(h,v,o,a,i)){p=!1;break}}return i["delete"](t),p}function $(t,e,r,n,o,u,c){switch(r){case xt:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case Pt:return!(t.byteLength!=e.byteLength||!n(new Nt(t),new Nt(e)));case lt:case st:return+t==+e;case pt:return t.name==e.name&&t.message==e.message;case yt:return t!=+t?e!=+e:t==+e;case gt:case Ot:return t==e+"";case vt:var f=a;case jt:var l=u&it;if(f||(f=i),t.size!=e.size&&!l)return!1;var s=c.get(t);return s?s==e:(u|=at,c.set(t,e),U(f(t),f(e),n,o,u,c));case wt:if(ie)return ie.call(t)==ie.call(e)}return!1}function V(t,e,r,n,o,a){var i=o&it,u=et(t),c=u.length,f=et(e),l=f.length;if(c!=l&&!i)return!1;for(var s=c;s--;){var p=u[s];if(!(i?p in e:C(e,p)))return!1}var d=a.get(t);if(d)return d==e;var h=!0;a.set(t,e);for(var v=i;++s<c;){p=u[s];var y=t[p],_=e[p];if(n)var b=i?n(_,y,p,e,t,a):n(y,_,p,t,e,a);if(!(void 0===b?y===_||r(y,_,n,o,a):b)){h=!1;break}v||(v="constructor"==p)}if(h&&!v){var g=t.constructor,j=e.constructor;g!=j&&"constructor"in t&&"constructor"in e&&!("function"==typeof g&&g instanceof g&&"function"==typeof j&&j instanceof j)&&(h=!1)}return a["delete"](t),h}function q(t,e){var r=t.__data__;return N(e)?r["string"==typeof e?"string":"hash"]:r.map}function z(t,e){var r=t[e];return Z(r)?r:void 0}function W(t){return Ht(Object(t))}function B(t){return zt.call(t)}function N(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}function G(t){if(null!=t){try{return Vt.call(t)}catch(e){}try{return t+""}catch(e){}}return""}function H(t,e){return t===e||t!==t&&e!==e}function J(t,e){return T(t,e)}function K(t){var e=X(t)?zt.call(t):"";return e==dt||e==ht}function Q(t){return"number"==typeof t&&t>-1&&t%1==0&&ut>=t}function X(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Y(t){return!!t&&"object"==typeof t}function Z(t){if(!X(t))return!1;var e=K(t)||o(t)?Wt:Tt;return e.test(G(t))}function tt(t){return Y(t)&&Q(t.length)&&!!It[zt.call(t)]}var et=r(8),rt=r(6),nt=200,ot="__lodash_hash_undefined__",at=1,it=2,ut=9007199254740991,ct="[object Arguments]",ft="[object Array]",lt="[object Boolean]",st="[object Date]",pt="[object Error]",dt="[object Function]",ht="[object GeneratorFunction]",vt="[object Map]",yt="[object Number]",_t="[object Object]",bt="[object Promise]",gt="[object RegExp]",jt="[object Set]",Ot="[object String]",wt="[object Symbol]",mt="[object WeakMap]",Pt="[object ArrayBuffer]",xt="[object DataView]",At="[object Float32Array]",St="[object Float64Array]",Rt="[object Int8Array]",Et="[object Int16Array]",Dt="[object Int32Array]",kt="[object Uint8Array]",Ft="[object Uint8ClampedArray]",Mt="[object Uint16Array]",Lt="[object Uint32Array]",Ct=/[\\^$.*+?()[\]{}|]/g,Tt=/^\[object .+?Constructor\]$/,It={};It[At]=It[St]=It[Rt]=It[Et]=It[Dt]=It[kt]=It[Ft]=It[Mt]=It[Lt]=!0,It[ct]=It[ft]=It[Pt]=It[lt]=It[xt]=It[st]=It[pt]=It[dt]=It[vt]=It[yt]=It[_t]=It[gt]=It[jt]=It[Ot]=It[mt]=!1;var Ut=Array.prototype,$t=Object.prototype,Vt=Function.prototype.toString,qt=$t.hasOwnProperty,zt=$t.toString,Wt=RegExp("^"+Vt.call(qt).replace(Ct,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Bt=rt.Symbol,Nt=rt.Uint8Array,Gt=Ut.splice,Ht=Object.getPrototypeOf,Jt=z(rt,"DataView"),Kt=z(rt,"Map"),Qt=z(rt,"Promise"),Xt=z(rt,"Set"),Yt=z(rt,"WeakMap"),Zt=z(Object,"create"),te=G(Jt),ee=G(Kt),re=G(Qt),ne=G(Xt),oe=G(Yt),ae=Bt?Bt.prototype:void 0,ie=ae?ae.valueOf:void 0;u.prototype.clear=c,u.prototype["delete"]=f,u.prototype.get=l,u.prototype.has=s,u.prototype.set=p,d.prototype.clear=h,d.prototype["delete"]=v,d.prototype.get=y,d.prototype.has=_,d.prototype.set=b,g.prototype.clear=j,g.prototype["delete"]=O,g.prototype.get=w,g.prototype.has=m,g.prototype.set=P,x.prototype.add=x.prototype.push=A,x.prototype.has=S,R.prototype.clear=E,R.prototype["delete"]=D,R.prototype.get=k,R.prototype.has=F,R.prototype.set=M,(Jt&&B(new Jt(new ArrayBuffer(1)))!=xt||Kt&&B(new Kt)!=vt||Qt&&B(Qt.resolve())!=bt||Xt&&B(new Xt)!=jt||Yt&&B(new Yt)!=mt)&&(B=function(t){var e=zt.call(t),r=e==_t?t.constructor:void 0,n=r?G(r):void 0;if(n)switch(n){case te:return xt;case ee:return vt;case re:return bt;case ne:return jt;case oe:return mt}return e});var ue=Array.isArray;t.exports=J},function(t,e){function r(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}function n(t,e){return A.call(t,e)||"object"==typeof t&&e in t&&null===i(t)}function o(t){return D(Object(t))}function a(t){return function(e){return null==e?void 0:e[t]}}function i(t){return E(Object(t))}function u(t){var e=t?t.length:void 0;return h(e)&&(F(t)||_(t)||l(t))?r(e,String):null}function c(t,e){return e=null==e?g:e,!!e&&("number"==typeof t||P.test(t))&&t>-1&&t%1==0&&e>t}function f(t){var e=t&&t.constructor,r="function"==typeof e&&e.prototype||x;return t===r}function l(t){return p(t)&&A.call(t,"callee")&&(!R.call(t,"callee")||S.call(t)==j)}function s(t){return null!=t&&h(k(t))&&!d(t)}function p(t){return y(t)&&s(t)}function d(t){var e=v(t)?S.call(t):"";return e==O||e==w}function h(t){return"number"==typeof t&&t>-1&&t%1==0&&g>=t}function v(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function y(t){return!!t&&"object"==typeof t}function _(t){return"string"==typeof t||!F(t)&&y(t)&&S.call(t)==m}function b(t){var e=f(t);if(!e&&!s(t))return o(t);var r=u(t),a=!!r,i=r||[],l=i.length;for(var p in t)!n(t,p)||a&&("length"==p||c(p,l))||e&&"constructor"==p||i.push(p);return i}var g=9007199254740991,j="[object Arguments]",O="[object Function]",w="[object GeneratorFunction]",m="[object String]",P=/^(?:0|[1-9]\d*)$/,x=Object.prototype,A=x.hasOwnProperty,S=x.toString,R=x.propertyIsEnumerable,E=Object.getPrototypeOf,D=Object.keys,k=a("length"),F=Array.isArray;t.exports=b},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children=[],t.webpackPolyfill=1),t}},function(e,r){e.exports=t},function(t,r){t.exports=e}])});