UNPKG

17 kBJavaScriptView Raw
1module.exports=function(e,r){"use strict";var t={};function __webpack_require__(r){if(t[r]){return t[r].exports}var n=t[r]={i:r,l:false,exports:{}};e[r].call(n.exports,n,n.exports,__webpack_require__);n.l=true;return n.exports}__webpack_require__.ab=__dirname+"/";function startup(){return __webpack_require__(325)}return startup()}({202:function(e,r){"use strict";Object.defineProperty(r,"__esModule",{value:true});var t=new WeakMap;var n=0;function hash(e){if(!e.length)return"";var r="arg";for(var a=0;a<e.length;++a){var i=void 0;if(e[a]===null||typeof e[a]!=="object"){if(typeof e[a]==="string"){i='"'+e[a]+'"'}else{i=String(e[a])}}else{if(!t.has(e[a])){i=n;t.set(e[a],n++)}else{i=t.get(e[a])}}r+="@"+i}return r}r.default=hash},205:function(e,r){"use strict";Object.defineProperty(r,"__esModule",{value:true});function isOnline(){if(typeof navigator.onLine!=="undefined"){return navigator.onLine}return true}r.default=isOnline},209:function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:true});var n=t(297);var a=n.createContext({});a.displayName="SWRConfigContext";r.default=a},297:function(e){e.exports=require("react")},325:function(e,r,t){"use strict";function __export(e){for(var t in e)if(!r.hasOwnProperty(t))r[t]=e[t]}var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:true});__export(t(516));var a=n(t(516));var i=t(926);r.useSWRPages=i.useSWRPages;var u=t(641);r.cache=u.cache;r.default=a.default},459:function(e,r){"use strict";Object.defineProperty(r,"__esModule",{value:true});function isDocumentVisible(){if(typeof document!=="undefined"&&typeof document.visibilityState!=="undefined"){return document.visibilityState!=="hidden"}return true}r.default=isDocumentVisible},516:function(e,r,t){"use strict";var n=this&&this.__awaiter||function(e,r,t,n){function adopt(e){return e instanceof t?e:new t(function(r){r(e)})}return new(t||(t=Promise))(function(t,a){function fulfilled(e){try{step(n.next(e))}catch(e){a(e)}}function rejected(e){try{step(n["throw"](e))}catch(e){a(e)}}function step(e){e.done?t(e.value):adopt(e.value).then(fulfilled,rejected)}step((n=n.apply(e,r||[])).next())})};var a=this&&this.__generator||function(e,r){var t={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},n,a,i,u;return u={next:verb(0),throw:verb(1),return:verb(2)},typeof Symbol==="function"&&(u[Symbol.iterator]=function(){return this}),u;function verb(e){return function(r){return step([e,r])}}function step(u){if(n)throw new TypeError("Generator is already executing.");while(t)try{if(n=1,a&&(i=u[0]&2?a["return"]:u[0]?a["throw"]||((i=a["return"])&&i.call(a),0):a.next)&&!(i=i.call(a,u[1])).done)return i;if(a=0,i)u=[u[0]&2,i.value];switch(u[0]){case 0:case 1:i=u;break;case 4:t.label++;return{value:u[1],done:false};case 5:t.label++;a=u[1];u=[0];continue;case 7:u=t.ops.pop();t.trys.pop();continue;default:if(!(i=t.trys,i=i.length>0&&i[i.length-1])&&(u[0]===6||u[0]===2)){t=0;continue}if(u[0]===3&&(!i||u[1]>i[0]&&u[1]<i[3])){t.label=u[1];break}if(u[0]===6&&t.label<i[1]){t.label=i[1];i=u;break}if(i&&t.label<i[2]){t.label=i[2];t.ops.push(u);break}if(i[2])t.ops.pop();t.trys.pop();continue}u=r.call(e,t)}catch(e){u=[6,e];a=0}finally{n=i=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:true}}};var i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var t in e)if(Object.hasOwnProperty.call(e,t))r[t]=e[t];r["default"]=e;return r};var u=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:true});var f=t(297);var o=i(t(641));var s=u(t(459));var l=u(t(205));var c=u(t(542));var d=u(t(209));var v=typeof window==="undefined";var h=v?f.useEffect:f.useLayoutEffect;var p=function(e,r){if(r===void 0){r=true}var t=o.cache.serializeKey(e),n=t[0],a=t[2];if(!n)return Promise.resolve();var i=o.CACHE_REVALIDATORS[n];if(n&&i){var u=o.cache.get(n);var f=o.cache.get(a);var s=[];for(var l=0;l<i.length;++l){s.push(i[l](r,u,f,l>0))}return Promise.all(s).then(function(){return o.cache.get(n)})}return Promise.resolve(o.cache.get(n))};r.trigger=p;var _=function(e,r,t){var n=o.CACHE_REVALIDATORS[e];if(e&&n){for(var a=0;a<n.length;++a){n[a](false,r,t)}}};var R=function(e,r,t){if(t===void 0){t=true}return n(void 0,void 0,void 0,function(){var n,i,u,f,s,l,c,d,v,h;return a(this,function(a){switch(a.label){case 0:n=o.cache.serializeKey(e)[0];if(!n)return[2];if(typeof r==="undefined")return[2,p(e,t)];o.MUTATION_TS[n]=Date.now()-1;f=o.MUTATION_TS[n];s=o.CONCURRENT_PROMISES_TS[n];if(!(r&&typeof r==="function"))return[3,5];a.label=1;case 1:a.trys.push([1,3,,4]);return[4,r(o.cache.get(n))];case 2:i=a.sent();return[3,4];case 3:l=a.sent();u=l;return[3,4];case 4:return[3,11];case 5:if(!(r&&typeof r.then==="function"))return[3,10];a.label=6;case 6:a.trys.push([6,8,,9]);return[4,r];case 7:i=a.sent();return[3,9];case 8:c=a.sent();u=c;return[3,9];case 9:return[3,11];case 10:i=r;a.label=11;case 11:if(f!==o.MUTATION_TS[n]||s!==o.CONCURRENT_PROMISES_TS[n]){if(u)throw u;return[2,i]}if(typeof i!=="undefined"){o.cache.set(n,i,false)}d=o.CACHE_REVALIDATORS[n];if(d){v=[];for(h=0;h<d.length;++h){v.push(d[h](!!t,i,u,h>0))}return[2,Promise.all(v).then(function(){return o.cache.get(n)})]}if(u)throw u;return[2,i]}})})};r.mutate=R;function useSWR(){var e=this;var r=[];for(var t=0;t<arguments.length;t++){r[t]=arguments[t]}var i,u,p={};if(r.length>=1){i=r[0]}if(r.length>2){u=r[1];p=r[2]}else{if(typeof r[1]==="function"){u=r[1]}else if(typeof r[1]==="object"){p=r[1]}}var O=o.cache.serializeKey(i),S=O[0],y=O[1],C=O[2];p=Object.assign({},o.default,f.useContext(d.default),p);if(typeof u==="undefined"){u=p.fetcher}var E=o.cache.get(S)||p.initialData;var T=o.cache.get(C);var g=f.useRef({data:false,error:false,isValidating:false});var b=f.useRef({data:E,error:T,isValidating:false});var w=f.useState(null)[1];var m=f.useCallback(function(e){var r=false;for(var t in e){b.current[t]=e[t];if(g.current[t]){r=true}}if(r||p.suspense){w({})}},[]);var I=f.useRef(false);var M=f.useRef(S);var A=f.useRef({emit:function(e){var r=[];for(var t=1;t<arguments.length;t++){r[t-1]=arguments[t]}if(I.current)return;p[e].apply(p,r)}});var N=f.useCallback(function(e,r){return R(S,e,r)},[S]);var P=f.useCallback(function(r){if(r===void 0){r={}}return n(e,void 0,void 0,function(){var e,t,n,i,f,s,l;return a(this,function(a){switch(a.label){case 0:if(!S||!u)return[2,false];if(I.current)return[2,false];r=Object.assign({dedupe:false},r);e=true;t=typeof o.CONCURRENT_PROMISES[S]!=="undefined"&&r.dedupe;a.label=1;case 1:a.trys.push([1,6,,7]);m({isValidating:true});n=void 0;i=void 0;if(!t)return[3,3];i=o.CONCURRENT_PROMISES_TS[S];return[4,o.CONCURRENT_PROMISES[S]];case 2:n=a.sent();return[3,5];case 3:if(o.CONCURRENT_PROMISES[S]){o.MUTATION_TS[S]=Date.now()-1}if(p.loadingTimeout&&!o.cache.get(S)){setTimeout(function(){if(e)A.current.emit("onLoadingSlow",S,p)},p.loadingTimeout)}if(y!==null){o.CONCURRENT_PROMISES[S]=u.apply(void 0,y)}else{o.CONCURRENT_PROMISES[S]=u(S)}o.CONCURRENT_PROMISES_TS[S]=i=Date.now();return[4,o.CONCURRENT_PROMISES[S]];case 4:n=a.sent();setTimeout(function(){delete o.CONCURRENT_PROMISES[S];delete o.CONCURRENT_PROMISES_TS[S]},p.dedupingInterval);A.current.emit("onSuccess",n,S,p);a.label=5;case 5:if(o.MUTATION_TS[S]&&i<=o.MUTATION_TS[S]){m({isValidating:false});return[2,false]}o.cache.set(S,n,false);o.cache.set(C,undefined,false);f={isValidating:false};if(typeof b.current.error!=="undefined"){f.error=undefined}if(!p.compare(b.current.data,n)){f.data=n}m(f);if(!t){_(S,n,undefined)}return[3,7];case 6:s=a.sent();delete o.CONCURRENT_PROMISES[S];delete o.CONCURRENT_PROMISES_TS[S];o.cache.set(C,s,false);if(b.current.error!==s){m({isValidating:false,error:s});if(!t){_(S,undefined,s)}}A.current.emit("onError",s,S,p);if(p.shouldRetryOnError){l=(r.retryCount||0)+1;A.current.emit("onErrorRetry",s,S,p,P,Object.assign({dedupe:true},r,{retryCount:l}))}return[3,7];case 7:e=false;return[2,true]}})})},[S]);h(function(){if(!S)return undefined;I.current=false;var e=b.current.data;var r=o.cache.get(S)||p.initialData;if(M.current!==S||!p.compare(e,r)){m({data:r});M.current=S}var t=function(){return P({dedupe:true})};if(p.revalidateOnMount||!p.initialData&&p.revalidateOnMount===undefined){if(typeof r!=="undefined"&&!v&&window["requestIdleCallback"]){window["requestIdleCallback"](t)}else{t()}}var n;if(p.revalidateOnFocus){n=c.default(t,p.focusThrottleInterval);if(!o.FOCUS_REVALIDATORS[S]){o.FOCUS_REVALIDATORS[S]=[n]}else{o.FOCUS_REVALIDATORS[S].push(n)}}var a=function(e,r,n,a){if(e===void 0){e=true}if(a===void 0){a=true}var i={};var u=false;if(typeof r!=="undefined"&&!p.compare(b.current.data,r)){i.data=r;u=true}if(b.current.error!==n){i.error=n;u=true}if(u){m(i)}if(e){if(a){return t()}else{return P()}}return false};if(!o.CACHE_REVALIDATORS[S]){o.CACHE_REVALIDATORS[S]=[a]}else{o.CACHE_REVALIDATORS[S].push(a)}var i=null;if(!v&&window.addEventListener&&p.revalidateOnReconnect){window.addEventListener("online",i=t)}return function(){m=function(){return null};I.current=true;if(n&&o.FOCUS_REVALIDATORS[S]){var e=o.FOCUS_REVALIDATORS[S];var r=e.indexOf(n);if(r>=0){e[r]=e[e.length-1];e.pop()}}if(o.CACHE_REVALIDATORS[S]){var e=o.CACHE_REVALIDATORS[S];var r=e.indexOf(a);if(r>=0){e[r]=e[e.length-1];e.pop()}}if(!v&&window.removeEventListener&&i!==null){window.removeEventListener("online",i)}}},[S,P]);h(function(){var r=null;var t=function(){return n(e,void 0,void 0,function(){return a(this,function(e){switch(e.label){case 0:if(!(!b.current.error&&(p.refreshWhenHidden||s.default())&&(p.refreshWhenOffline||l.default())))return[3,2];return[4,P({dedupe:true})];case 1:e.sent();e.label=2;case 2:if(p.refreshInterval){r=setTimeout(t,p.refreshInterval)}return[2]}})})};if(p.refreshInterval){r=setTimeout(t,p.refreshInterval)}return function(){if(r)clearTimeout(r)}},[p.refreshInterval,p.refreshWhenHidden,p.refreshWhenOffline,P]);if(p.suspense){var U=o.cache.get(S)||E;var V=o.cache.get(C)||T;if(typeof U==="undefined"&&typeof V==="undefined"){if(!o.CONCURRENT_PROMISES[S]){P()}if(o.CONCURRENT_PROMISES[S]&&typeof o.CONCURRENT_PROMISES[S].then==="function"){throw o.CONCURRENT_PROMISES[S]}U=o.CONCURRENT_PROMISES[S]}if(typeof U==="undefined"&&V){throw V}return{error:V,data:U,revalidate:P,mutate:N,isValidating:b.current.isValidating}}return f.useMemo(function(){var e={revalidate:P,mutate:N};Object.defineProperties(e,{error:{get:function(){g.current.error=true;return M.current===S?b.current.error:T},enumerable:true},data:{get:function(){g.current.data=true;return M.current===S?b.current.data:E},enumerable:true},isValidating:{get:function(){g.current.isValidating=true;return b.current.isValidating},enumerable:true}});return e},[P])}var O=d.default.Provider;r.SWRConfig=O;r.default=useSWR},542:function(e,r){"use strict";Object.defineProperty(r,"__esModule",{value:true});function throttle(e,r){var t=false;return function(){var n=[];for(var a=0;a<arguments.length;a++){n[a]=arguments[a]}if(t)return;t=true;e.apply(void 0,n);setTimeout(function(){return t=false},r)}}r.default=throttle},641:function(e,r,t){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:true});var a=n(t(832));var i=n(t(459));var u=n(t(205));var f=n(t(722));var o=new f.default;r.cache=o;var s={};r.CONCURRENT_PROMISES=s;var l={};r.CONCURRENT_PROMISES_TS=l;var c={};r.FOCUS_REVALIDATORS=c;var d={};r.CACHE_REVALIDATORS=d;var v={};r.MUTATION_TS=v;function onErrorRetry(e,r,t,n,a){if(!i.default()){return}if(t.errorRetryCount&&a.retryCount>t.errorRetryCount){return}var u=Math.min(a.retryCount||0,8);var f=~~((Math.random()+.5)*(1<<u))*t.errorRetryInterval;setTimeout(n,f,a)}var h=typeof window!=="undefined"&&navigator["connection"]&&["slow-2g","2g"].indexOf(navigator["connection"].effectiveType)!==-1;var p={onLoadingSlow:function(){},onSuccess:function(){},onError:function(){},onErrorRetry:onErrorRetry,errorRetryInterval:(h?10:5)*1e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:(h?5:3)*1e3,refreshInterval:0,revalidateOnFocus:true,revalidateOnReconnect:true,refreshWhenHidden:false,refreshWhenOffline:false,shouldRetryOnError:true,suspense:false,compare:a.default};var _=false;if(typeof window!=="undefined"&&window.addEventListener&&!_){var R=function(){if(!i.default()||!u.default())return;for(var e in c){if(c[e][0])c[e][0]()}};window.addEventListener("visibilitychange",R,false);window.addEventListener("focus",R,false);_=true}r.default=p},722:function(e,r,t){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:true});var a=t(516);var i=n(t(202));var u=function(){function Cache(e){if(e===void 0){e={}}this.__cache=new Map(Object.entries(e));this.__listeners=[]}Cache.prototype.get=function(e){var r=this.serializeKey(e)[0];return this.__cache.get(r)};Cache.prototype.set=function(e,r,t){if(t===void 0){t=true}var n=this.serializeKey(e)[0];this.__cache.set(n,r);if(t)a.mutate(e,r,false);this.notify()};Cache.prototype.keys=function(){return Array.from(this.__cache.keys())};Cache.prototype.has=function(e){var r=this.serializeKey(e)[0];return this.__cache.has(r)};Cache.prototype.clear=function(e){if(e===void 0){e=true}if(e)this.__cache.forEach(function(e){return a.mutate(e,null,false)});this.__cache.clear();this.notify()};Cache.prototype.delete=function(e,r){if(r===void 0){r=true}var t=this.serializeKey(e)[0];if(r)a.mutate(e,null,false);this.__cache.delete(t);this.notify()};Cache.prototype.serializeKey=function(e){var r=null;if(typeof e==="function"){try{e=e()}catch(r){e=""}}if(Array.isArray(e)){r=e;e=i.default(e)}else{e=String(e||"")}var t=e?"err@"+e:"";return[e,r,t]};Cache.prototype.subscribe=function(e){var r=this;if(typeof e!=="function"){throw new Error("Expected the listener to be a function.")}var t=true;this.__listeners.push(e);return function(){if(!t)return;t=false;var n=r.__listeners.indexOf(e);if(n>-1){r.__listeners[n]=r.__listeners[r.__listeners.length-1];r.__listeners.length--}}};Cache.prototype.notify=function(){for(var e=0,r=this.__listeners;e<r.length;e++){var t=r[e];t()}};return Cache}();r.default=u},832:function(e){"use strict";var r=Array.isArray;var t=Object.keys;var n=Object.prototype.hasOwnProperty;e.exports=function equal(e,a){if(e===a)return true;if(e&&a&&typeof e=="object"&&typeof a=="object"){var i=r(e),u=r(a),f,o,s;if(i&&u){o=e.length;if(o!=a.length)return false;for(f=o;f--!==0;)if(!equal(e[f],a[f]))return false;return true}if(i!=u)return false;var l=e instanceof Date,c=a instanceof Date;if(l!=c)return false;if(l&&c)return e.getTime()==a.getTime();var d=e instanceof RegExp,v=a instanceof RegExp;if(d!=v)return false;if(d&&v)return e.toString()==a.toString();var h=t(e);o=h.length;if(o!==t(a).length)return false;for(f=o;f--!==0;)if(!n.call(a,h[f]))return false;for(f=o;f--!==0;){s=h[f];if(!equal(e[s],a[s]))return false}return true}return e!==e&&a!==a}},926:function(e,r,t){"use strict";var n=this&&this.__spreadArrays||function(){for(var e=0,r=0,t=arguments.length;r<t;r++)e+=arguments[r].length;for(var n=Array(e),a=0,r=0;r<t;r++)for(var i=arguments[r],u=0,f=i.length;u<f;u++,a++)n[a]=i[u];return n};var a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var t in e)if(Object.hasOwnProperty.call(e,t))r[t]=e[t];r["default"]=e;return r};Object.defineProperty(r,"__esModule",{value:true});var i=a(t(297));var u=t(641);var f=new Map;function useSWRPages(e,r,t,a){if(a===void 0){a=[]}var o="_swr_page_count_"+e;var s="_swr_page_offset_"+e;var l=i.useState(u.cache.get(o)||1),c=l[0],d=l[1];var v=i.useState(u.cache.get(s)||[null]),h=v[0],p=v[1];var _=i.useState([]),R=_[0],O=_[1];var S=i.useRef(r);var y=i.useRef(false);var C=i.useCallback(function(e){var r=S.current(e);if(r&&!r.length){y.current=true}else{y.current=false}return r},[]);var E=h[c]===null;var T=c===h.length;var g=E&&c===1&&y.current;var b=i.useCallback(function(){if(T||E)return;d(function(e){u.cache.set(o,e+1);return e+1})},[T||E]);var w=i.useCallback(r,a);S.current=w;var m=i.useMemo(function(){var r=function(e){return function(r){if(!R[e]||R[e].data!==r.data||R[e].error!==r.error||R[e].revalidate!==r.revalidate){setTimeout(function(){O(function(t){var a=n(t);a[e]={data:r.data,error:r.error,revalidate:r.revalidate,isValidating:r.isValidating,mutate:r.mutate};return a});if(typeof r.data!=="undefined"){var a=t(r,e);if(h[e+1]!==a){p(function(r){var t=n(r);t[e+1]=a;u.cache.set(s,t);return t})}}})}return r}};var a=[];if(!f.has(e)){f.set(e,[])}var o=f.get(e);for(var l=0;l<c;++l){if(!o[l]||o[l].offset!==h[l]||o[l].pageFn!==w){o[l]={component:i.default.createElement(C,{key:"page-"+h[l]+"-"+l,offset:h[l],withSWR:r(l)}),pageFn:w,offset:h[l]}}a.push(o[l].component)}return a},[w,c,R,h,e]);return{pages:m,pageCount:c,pageSWRs:R,isLoadingMore:T,isReachingEnd:E,isEmpty:g,loadMore:b}}r.useSWRPages=useSWRPages}});
\No newline at end of file