Comparing version 0.3.4 to 0.3.5
@@ -1,1 +0,1 @@ | ||
module.exports=function(e,t){"use strict";var r={};function __webpack_require__(t){if(r[t]){return r[t].exports}var n=r[t]={i:t,l:false,exports:{}};e[t].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()}({48:function(e,t){var r=Object.prototype.hasOwnProperty;function dequal(e,t){var n,i;if(e===t)return true;if(e&&t&&(n=e.constructor)===t.constructor){if(n===Date)return e.getTime()===t.getTime();if(n===RegExp)return e.toString()===t.toString();if(n===Array){if((i=e.length)===t.length){while(i--&&dequal(e[i],t[i]));}return i===-1}if(!n||typeof e==="object"){i=0;for(n in e){if(r.call(e,n)&&++i&&!r.call(t,n))return false;if(!(n in t)||!dequal(e[n],t[n]))return false}return Object.keys(t).length===i}}return e!==e&&t!==t}t.dequal=dequal},202:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=new WeakMap;var n=0;function hash(e){if(!e.length)return"";var t="arg";for(var i=0;i<e.length;++i){var u=void 0;if(e[i]===null||typeof e[i]!=="object"&&typeof e[i]!=="function"){if(typeof e[i]==="string"){u='"'+e[i]+'"'}else{u=String(e[i])}}else{if(!r.has(e[i])){u=n;r.set(e[i],n++)}else{u=r.get(e[i])}}t+="@"+u}return t}t.default=hash},205:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});function isOnline(){if(typeof navigator.onLine!=="undefined"){return navigator.onLine}return true}t.default=isOnline},209:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:true});var n=r(297);var i=n.createContext({});i.displayName="SWRConfigContext";t.default=i},297:function(e){e.exports=require("react")},325:function(e,t,r){"use strict";function __export(e){for(var r in e)if(!t.hasOwnProperty(r))t[r]=e[r]}var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});__export(r(516));var i=n(r(516));var u=r(942);t.useSWRInfinite=u.useSWRInfinite;var a=r(641);t.cache=a.cache;t.default=i.default},459:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});function isDocumentVisible(){if(typeof document!=="undefined"&&typeof document.visibilityState!=="undefined"){return document.visibilityState!=="hidden"}return true}t.default=isDocumentVisible},516:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){function adopt(e){return e instanceof r?e:new r(function(t){t(e)})}return new(r||(r=Promise))(function(r,i){function fulfilled(e){try{step(n.next(e))}catch(e){i(e)}}function rejected(e){try{step(n["throw"](e))}catch(e){i(e)}}function step(e){e.done?r(e.value):adopt(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())})};var i=this&&this.__generator||function(e,t){var r={label:0,sent:function(){if(u[0]&1)throw u[1];return u[1]},trys:[],ops:[]},n,i,u,a;return a={next:verb(0),throw:verb(1),return:verb(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function verb(e){return function(t){return step([e,t])}}function step(a){if(n)throw new TypeError("Generator is already executing.");while(r)try{if(n=1,i&&(u=a[0]&2?i["return"]:a[0]?i["throw"]||((u=i["return"])&&u.call(i),0):i.next)&&!(u=u.call(i,a[1])).done)return u;if(i=0,u)a=[a[0]&2,u.value];switch(a[0]){case 0:case 1:u=a;break;case 4:r.label++;return{value:a[1],done:false};case 5:r.label++;i=a[1];a=[0];continue;case 7:a=r.ops.pop();r.trys.pop();continue;default:if(!(u=r.trys,u=u.length>0&&u[u.length-1])&&(a[0]===6||a[0]===2)){r=0;continue}if(a[0]===3&&(!u||a[1]>u[0]&&a[1]<u[3])){r.label=a[1];break}if(a[0]===6&&r.label<u[1]){r.label=u[1];u=a;break}if(u&&r.label<u[2]){r.label=u[2];r.ops.push(a);break}if(u[2])r.ops.pop();r.trys.pop();continue}a=t.call(e,r)}catch(e){a=[6,e];i=0}finally{n=u=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};var u=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)if(Object.hasOwnProperty.call(e,r))t[r]=e[r];t["default"]=e;return t};var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});var f=r(297);var o=u(r(641));var c=a(r(459));var l=a(r(205));var s=a(r(209));var d=typeof window==="undefined";var v=d?null:window["requestIdleCallback"]||function(e){return setTimeout(e,1)};var h=d?f.useEffect:f.useLayoutEffect;var p={};var y={};var b={};var _={};var m={};var w={};var g={};if(!d&&window.addEventListener){var O=function(e){if(!c.default()||!l.default())return;for(var t in e){if(e[t][0])e[t][0]()}};window.addEventListener("visibilitychange",function(){return O(b)},false);window.addEventListener("focus",function(){return O(b)},false);window.addEventListener("online",function(){return O(_)},false)}var j=function(e,t){if(t===void 0){t=true}var r=o.cache.serializeKey(e),n=r[0],i=r[2],u=r[3];if(!n)return Promise.resolve();var a=m[n];if(n&&a){var f=o.cache.get(n);var c=o.cache.get(i);var l=o.cache.get(u);var s=[];for(var d=0;d<a.length;++d){s.push(a[d](t,f,c,l,d>0))}return Promise.all(s).then(function(){return o.cache.get(n)})}return Promise.resolve(o.cache.get(n))};t.trigger=j;var x=function(e,t,r,n){var i=m[e];if(e&&i){for(var u=0;u<i.length;++u){i[u](false,t,r,n)}}};var S=function(e,t,r){if(r===void 0){r=true}return n(void 0,void 0,void 0,function(){var n,u,a,f,c,l,s,d,v,h,p,b;return i(this,function(i){switch(i.label){case 0:n=o.cache.serializeKey(e),u=n[0],a=n[2];if(!u)return[2];if(typeof t==="undefined")return[2,j(e,r)];w[u]=Date.now()-1;g[u]=0;f=w[u];c=y[u];if(!(t&&typeof t==="function"))return[3,5];i.label=1;case 1:i.trys.push([1,3,,4]);return[4,t(o.cache.get(u))];case 2:l=i.sent();return[3,4];case 3:d=i.sent();s=d;return[3,4];case 4:return[3,11];case 5:if(!(t&&typeof t.then==="function"))return[3,10];i.label=6;case 6:i.trys.push([6,8,,9]);return[4,t];case 7:l=i.sent();return[3,9];case 8:v=i.sent();s=v;return[3,9];case 9:return[3,11];case 10:l=t;i.label=11;case 11:if(f!==w[u]||c!==y[u]){if(s)throw s;return[2,l]}if(typeof l!=="undefined"){o.cache.set(u,l)}o.cache.set(a,s);g[u]=Date.now()-1;h=m[u];if(h){p=[];for(b=0;b<h.length;++b){p.push(h[b](!!r,l,s,undefined,b>0))}return[2,Promise.all(p).then(function(){if(s)throw s;return o.cache.get(u)})]}if(s)throw s;return[2,l]}})})};t.mutate=S;function useSWR(){var e=this;var t=[];for(var r=0;r<arguments.length;r++){t[r]=arguments[r]}var u,a,d={};if(t.length>=1){u=t[0]}if(t.length>2){a=t[1];d=t[2]}else{if(typeof t[1]==="function"){a=t[1]}else if(typeof t[1]==="object"){d=t[1]}}var O=o.cache.serializeKey(u),j=O[0],P=O[1],M=O[2],E=O[3];d=Object.assign({},o.default,f.useContext(s.default),d);var T=f.useRef(d);h(function(){T.current=d});if(typeof a==="undefined"){a=d.fetcher}var V=function(){var e=o.cache.get(j);return typeof e==="undefined"?d.initialData:e};var W=V();var C=o.cache.get(M);var R=!!o.cache.get(E);var z=f.useRef({data:false,error:false,isValidating:false});var I=f.useRef({data:W,error:C,isValidating:R});f.useDebugValue(I.current.data);var q=f.useState(null)[1];var D=f.useCallback(function(e){var t=false;for(var r in e){if(I.current[r]===e[r]){continue}I.current[r]=e[r];if(z.current[r]){t=true}}if(t||d.suspense){if(k.current)return;q({})}},[]);var k=f.useRef(false);var L=f.useRef(j);var K=f.useRef({emit:function(e){var t;var r=[];for(var n=1;n<arguments.length;n++){r[n-1]=arguments[n]}if(k.current)return;(t=T.current)[e].apply(t,r)}});var A=f.useCallback(function(e,t){return S(j,e,t)},[j]);var H=function(e,t){if(!t)return;if(!e[j]){e[j]=[t]}else{e[j].push(t)}};var F=function(e,t){if(e[j]){var r=e[j];var n=r.indexOf(t);if(n>=0){r[n]=r[r.length-1];r.pop()}}};var G=f.useCallback(function(t){if(t===void 0){t={}}return n(e,void 0,void 0,function(){var e,r,n,u,f,c,l,s;return i(this,function(i){switch(i.label){case 0:if(!j||!a)return[2,false];if(k.current)return[2,false];t=Object.assign({dedupe:false},t);e=true;r=typeof p[j]!=="undefined"&&t.dedupe;i.label=1;case 1:i.trys.push([1,6,,7]);D({isValidating:true});o.cache.set(E,true);if(!r){x(j,undefined,undefined,true)}n=void 0;u=void 0;if(!r)return[3,3];u=y[j];return[4,p[j]];case 2:n=i.sent();return[3,5];case 3:if(d.loadingTimeout&&!o.cache.get(j)){setTimeout(function(){if(e)K.current.emit("onLoadingSlow",j,d)},d.loadingTimeout)}if(P!==null){p[j]=a.apply(void 0,P)}else{p[j]=a(j)}y[j]=u=Date.now();return[4,p[j]];case 4:n=i.sent();setTimeout(function(){delete p[j];delete y[j]},d.dedupingInterval);K.current.emit("onSuccess",n,j,d);i.label=5;case 5:f=y[j]>u||w[j]&&(u<=w[j]||u<=g[j]||g[j]===0);if(f){D({isValidating:false});return[2,false]}o.cache.set(j,n);o.cache.set(M,undefined);o.cache.set(E,false);c={isValidating:false};if(typeof I.current.error!=="undefined"){c.error=undefined}if(!d.compare(I.current.data,n)){c.data=n}D(c);if(!r){x(j,n,undefined,false)}return[3,7];case 6:l=i.sent();delete p[j];delete y[j];o.cache.set(M,l);if(I.current.error!==l){D({isValidating:false,error:l});if(!r){x(j,undefined,l,false)}}K.current.emit("onError",l,j,d);if(d.shouldRetryOnError){s=(t.retryCount||0)+1;K.current.emit("onErrorRetry",l,j,d,G,Object.assign({dedupe:true},t,{retryCount:s}))}return[3,7];case 7:e=false;return[2,true]}})})},[j]);h(function(){if(!j)return undefined;k.current=false;var e=I.current.data;var t=V();if(L.current!==j){L.current=j}if(!d.compare(e,t)){D({data:t})}var r=function(){return G({dedupe:true})};if(d.revalidateOnMount||!d.initialData&&d.revalidateOnMount===undefined){if(typeof t!=="undefined"){v(r)}else{r()}}var n=false;var i=function(){if(n||!T.current.revalidateOnFocus)return;n=true;r();setTimeout(function(){return n=false},T.current.focusThrottleInterval)};var u=function(){if(T.current.revalidateOnReconnect){r()}};var a=function(e,t,n,i,u){if(e===void 0){e=true}if(u===void 0){u=true}var a={};var f=false;if(typeof t!=="undefined"&&!d.compare(I.current.data,t)){a.data=t;f=true}if(I.current.error!==n){a.error=n;f=true}if(typeof i!=="undefined"&&I.current.isValidating!==i){a.isValidating=i;f=true}if(f){D(a)}if(e){if(u){return r()}else{return G()}}return false};H(b,i);H(_,u);H(m,a);return function(){D=function(){return null};k.current=true;F(b,i);F(_,u);F(m,a)}},[j,G]);h(function(){var t=null;var r=function(){return n(e,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:if(!(!I.current.error&&(T.current.refreshWhenHidden||c.default())&&(T.current.refreshWhenOffline||l.default())))return[3,2];return[4,G({dedupe:true})];case 1:e.sent();e.label=2;case 2:if(T.current.refreshInterval&&!I.current.error){t=setTimeout(r,T.current.refreshInterval)}return[2]}})})};if(T.current.refreshInterval){t=setTimeout(r,T.current.refreshInterval)}return function(){if(t)clearTimeout(t)}},[d.refreshInterval,d.refreshWhenHidden,d.refreshWhenOffline,G]);var B=f.useMemo(function(){var e={revalidate:G,mutate:A};Object.defineProperties(e,{error:{get:function(){z.current.error=true;return L.current===j?I.current.error:C},enumerable:true},data:{get:function(){z.current.data=true;return L.current===j?I.current.data:W},enumerable:true},isValidating:{get:function(){z.current.isValidating=true;return I.current.isValidating},enumerable:true}});return e},[G]);if(d.suspense){var J=o.cache.get(j);var Q=o.cache.get(M);if(typeof J==="undefined"){J=W}if(typeof Q==="undefined"){Q=C}if(typeof J==="undefined"&&typeof Q==="undefined"){if(!p[j]){G()}if(p[j]&&typeof p[j].then==="function"){throw p[j]}J=p[j]}if(typeof J==="undefined"&&Q){throw Q}return{error:Q,data:J,revalidate:G,mutate:A,isValidating:I.current.isValidating}}return B}var P=s.default.Provider;t.SWRConfig=P;t.default=useSWR},641:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});var i=r(48);var u=n(r(459));var a=n(r(722));var f=new a.default;t.cache=f;function onErrorRetry(e,t,r,n,i){if(!u.default()){return}if(typeof r.errorRetryCount==="number"&&i.retryCount>r.errorRetryCount){return}var a=Math.min(i.retryCount||0,8);var f=~~((Math.random()+.5)*(1<<a))*r.errorRetryInterval;setTimeout(n,f,i)}var o=typeof window!=="undefined"&&navigator["connection"]&&["slow-2g","2g"].indexOf(navigator["connection"].effectiveType)!==-1;var c={onLoadingSlow:function(){},onSuccess:function(){},onError:function(){},onErrorRetry:onErrorRetry,errorRetryInterval:(o?10:5)*1e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:(o?5:3)*1e3,refreshInterval:0,revalidateOnFocus:true,revalidateOnReconnect:true,refreshWhenHidden:false,refreshWhenOffline:false,shouldRetryOnError:true,suspense:false,compare:i.dequal,fetcher:function(e){return fetch(e).then(function(e){return e.json()})}};t.default=c},722:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});var i=n(r(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 t=this.serializeKey(e)[0];return this.__cache.get(t)};Cache.prototype.set=function(e,t){var r=this.serializeKey(e)[0];this.__cache.set(r,t);this.notify()};Cache.prototype.keys=function(){return Array.from(this.__cache.keys())};Cache.prototype.has=function(e){var t=this.serializeKey(e)[0];return this.__cache.has(t)};Cache.prototype.clear=function(){this.__cache.clear();this.notify()};Cache.prototype.delete=function(e){var t=this.serializeKey(e)[0];this.__cache.delete(t);this.notify()};Cache.prototype.serializeKey=function(e){var t=null;if(typeof e==="function"){try{e=e()}catch(t){e=""}}if(Array.isArray(e)){t=e;e=i.default(e)}else{e=String(e||"")}var r=e?"err@"+e:"";var n=e?"validating@"+e:"";return[e,t,r,n]};Cache.prototype.subscribe=function(e){var t=this;if(typeof e!=="function"){throw new Error("Expected the listener to be a function.")}var r=true;this.__listeners.push(e);return function(){if(!r)return;r=false;var n=t.__listeners.indexOf(e);if(n>-1){t.__listeners[n]=t.__listeners[t.__listeners.length-1];t.__listeners.length--}}};Cache.prototype.notify=function(){for(var e=0,t=this.__listeners;e<t.length;e++){var r=t[e];r()}};return Cache}();t.default=u},942:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){function adopt(e){return e instanceof r?e:new r(function(t){t(e)})}return new(r||(r=Promise))(function(r,i){function fulfilled(e){try{step(n.next(e))}catch(e){i(e)}}function rejected(e){try{step(n["throw"](e))}catch(e){i(e)}}function step(e){e.done?r(e.value):adopt(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())})};var i=this&&this.__generator||function(e,t){var r={label:0,sent:function(){if(u[0]&1)throw u[1];return u[1]},trys:[],ops:[]},n,i,u,a;return a={next:verb(0),throw:verb(1),return:verb(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function verb(e){return function(t){return step([e,t])}}function step(a){if(n)throw new TypeError("Generator is already executing.");while(r)try{if(n=1,i&&(u=a[0]&2?i["return"]:a[0]?i["throw"]||((u=i["return"])&&u.call(i),0):i.next)&&!(u=u.call(i,a[1])).done)return u;if(i=0,u)a=[a[0]&2,u.value];switch(a[0]){case 0:case 1:u=a;break;case 4:r.label++;return{value:a[1],done:false};case 5:r.label++;i=a[1];a=[0];continue;case 7:a=r.ops.pop();r.trys.pop();continue;default:if(!(u=r.trys,u=u.length>0&&u[u.length-1])&&(a[0]===6||a[0]===2)){r=0;continue}if(a[0]===3&&(!u||a[1]>u[0]&&a[1]<u[3])){r.label=a[1];break}if(a[0]===6&&r.label<u[1]){r.label=u[1];u=a;break}if(u&&r.label<u[2]){r.label=u[2];r.ops.push(a);break}if(u[2])r.ops.pop();r.trys.pop();continue}a=t.call(e,r)}catch(e){a=[6,e];i=0}finally{n=u=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};var u=this&&this.__rest||function(e,t){var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0)r[n]=e[n];if(e!=null&&typeof Object.getOwnPropertySymbols==="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++){if(t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i]))r[n[i]]=e[n[i]]}return r};var a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)if(Object.hasOwnProperty.call(e,r))t[r]=e[r];t["default"]=e;return t};var f=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});var o=r(297);var c=a(r(641));var l=f(r(209));var s=f(r(516));function useSWRInfinite(){var e=this;var t=[];for(var r=0;r<arguments.length;r++){t[r]=arguments[r]}var a,f,d={};if(t.length>=1){a=t[0]}if(t.length>2){f=t[1];d=t[2]}else{if(typeof t[1]==="function"){f=t[1]}else if(typeof t[1]==="object"){d=t[1]}}d=Object.assign({},c.default,o.useContext(l.default),d);var v=d.initialSize,h=v===void 0?1:v,p=d.revalidateAll,y=p===void 0?false:p,b=d.persistSize,_=b===void 0?false:b,m=d.fetcher,w=u(d,["initialSize","revalidateAll","persistSize","fetcher"]);if(typeof f==="undefined"){f=m}var g=null;try{g=c.cache.serializeKey(a(0,null))[0]}catch(e){}var O=o.useState(false)[1];var j=null;if(g){j="context@"+g}var x=null;var S;if(g){x="size@"+g;S=c.cache.get(x)}var P=o.useRef(S||h);var M=o.useRef(false);o.useEffect(function(){if(M.current){if(!_){P.current=h}}else{M.current=true}},[g]);var E=s.default(g?["many",g]:null,function(){return n(e,void 0,void 0,function(){var e,t,r,n,u,o,l,s,v,h,p;return i(this,function(i){switch(i.label){case 0:e=c.cache.get(j)||{},t=e.originalData,r=e.force;n=[];u=null;o=0;i.label=1;case 1:if(!(o<P.current))return[3,8];l=c.cache.serializeKey(a(o,u)),s=l[0],v=l[1];if(!s){return[3,8]}h=c.cache.get(s);p=y||r||typeof r==="undefined"&&o===0||t&&!d.compare(t[o],h)||typeof h==="undefined";if(!p)return[3,6];if(!(v!==null))return[3,3];return[4,f.apply(void 0,v)];case 2:h=i.sent();return[3,5];case 3:return[4,f(s)];case 4:h=i.sent();i.label=5;case 5:c.cache.set(s,h);i.label=6;case 6:n.push(h);u=h;i.label=7;case 7:++o;return[3,1];case 8:c.cache.delete(j);return[2,n]}})})},w);var T=E;var V=T.mutate;T.size=P.current;T.mutate=o.useCallback(function(e,t){if(t===void 0){t=true}if(t&&typeof e!=="undefined"){var r=T.data;c.cache.set(j,{originalData:r,force:false})}else if(t){c.cache.set(j,{force:true})}return V(e,t)},[V,T.data,j]);T.setSize=o.useCallback(function(e){if(typeof e==="function"){P.current=e(P.current)}else if(typeof e==="number"){P.current=e}c.cache.set(x,P.current);O(function(e){return!e});return T.mutate(function(e){return e})},[T.mutate,x]);return T}t.useSWRInfinite=useSWRInfinite}}); | ||
module.exports=function(e,t){"use strict";var r={};function __webpack_require__(t){if(r[t]){return r[t].exports}var n=r[t]={i:t,l:false,exports:{}};e[t].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()}({48:function(e,t){var r=Object.prototype.hasOwnProperty;function dequal(e,t){var n,i;if(e===t)return true;if(e&&t&&(n=e.constructor)===t.constructor){if(n===Date)return e.getTime()===t.getTime();if(n===RegExp)return e.toString()===t.toString();if(n===Array){if((i=e.length)===t.length){while(i--&&dequal(e[i],t[i]));}return i===-1}if(!n||typeof e==="object"){i=0;for(n in e){if(r.call(e,n)&&++i&&!r.call(t,n))return false;if(!(n in t)||!dequal(e[n],t[n]))return false}return Object.keys(t).length===i}}return e!==e&&t!==t}t.dequal=dequal},202:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});var r=new WeakMap;var n=0;function hash(e){if(!e.length)return"";var t="arg";for(var i=0;i<e.length;++i){var u=void 0;if(e[i]===null||typeof e[i]!=="object"&&typeof e[i]!=="function"){if(typeof e[i]==="string"){u='"'+e[i]+'"'}else{u=String(e[i])}}else{if(!r.has(e[i])){u=n;r.set(e[i],n++)}else{u=r.get(e[i])}}t+="@"+u}return t}t.default=hash},205:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});function isOnline(){if(typeof navigator.onLine!=="undefined"){return navigator.onLine}return true}t.default=isOnline},209:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:true});var n=r(297);var i=n.createContext({});i.displayName="SWRConfigContext";t.default=i},297:function(e){e.exports=require("react")},325:function(e,t,r){"use strict";function __export(e){for(var r in e)if(!t.hasOwnProperty(r))t[r]=e[r]}var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});__export(r(516));var i=n(r(516));var u=r(942);t.useSWRInfinite=u.useSWRInfinite;var a=r(641);t.cache=a.cache;t.default=i.default},459:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});function isDocumentVisible(){if(typeof document!=="undefined"&&typeof document.visibilityState!=="undefined"){return document.visibilityState!=="hidden"}return true}t.default=isDocumentVisible},516:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){function adopt(e){return e instanceof r?e:new r(function(t){t(e)})}return new(r||(r=Promise))(function(r,i){function fulfilled(e){try{step(n.next(e))}catch(e){i(e)}}function rejected(e){try{step(n["throw"](e))}catch(e){i(e)}}function step(e){e.done?r(e.value):adopt(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())})};var i=this&&this.__generator||function(e,t){var r={label:0,sent:function(){if(u[0]&1)throw u[1];return u[1]},trys:[],ops:[]},n,i,u,a;return a={next:verb(0),throw:verb(1),return:verb(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function verb(e){return function(t){return step([e,t])}}function step(a){if(n)throw new TypeError("Generator is already executing.");while(r)try{if(n=1,i&&(u=a[0]&2?i["return"]:a[0]?i["throw"]||((u=i["return"])&&u.call(i),0):i.next)&&!(u=u.call(i,a[1])).done)return u;if(i=0,u)a=[a[0]&2,u.value];switch(a[0]){case 0:case 1:u=a;break;case 4:r.label++;return{value:a[1],done:false};case 5:r.label++;i=a[1];a=[0];continue;case 7:a=r.ops.pop();r.trys.pop();continue;default:if(!(u=r.trys,u=u.length>0&&u[u.length-1])&&(a[0]===6||a[0]===2)){r=0;continue}if(a[0]===3&&(!u||a[1]>u[0]&&a[1]<u[3])){r.label=a[1];break}if(a[0]===6&&r.label<u[1]){r.label=u[1];u=a;break}if(u&&r.label<u[2]){r.label=u[2];r.ops.push(a);break}if(u[2])r.ops.pop();r.trys.pop();continue}a=t.call(e,r)}catch(e){a=[6,e];i=0}finally{n=u=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};var u=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)if(Object.hasOwnProperty.call(e,r))t[r]=e[r];t["default"]=e;return t};var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});var f=r(297);var o=u(r(641));var c=a(r(459));var l=a(r(205));var s=a(r(209));var d=typeof window==="undefined";var v=d?null:window["requestIdleCallback"]||function(e){return setTimeout(e,1)};var h=d?f.useEffect:f.useLayoutEffect;var p={};var y={};var b={};var _={};var w={};var m={};var g={};if(!d&&window.addEventListener){var O=function(e){if(!c.default()||!l.default())return;for(var t in e){if(e[t][0])e[t][0]()}};window.addEventListener("visibilitychange",function(){return O(b)},false);window.addEventListener("focus",function(){return O(b)},false);window.addEventListener("online",function(){return O(_)},false)}var j=function(e,t){if(t===void 0){t=true}var r=o.cache.serializeKey(e),n=r[0],i=r[2],u=r[3];if(!n)return Promise.resolve();var a=w[n];if(n&&a){var f=o.cache.get(n);var c=o.cache.get(i);var l=o.cache.get(u);var s=[];for(var d=0;d<a.length;++d){s.push(a[d](t,f,c,l,d>0))}return Promise.all(s).then(function(){return o.cache.get(n)})}return Promise.resolve(o.cache.get(n))};t.trigger=j;var x=function(e,t,r,n){var i=w[e];if(e&&i){for(var u=0;u<i.length;++u){i[u](false,t,r,n)}}};var S=function(e,t,r){if(r===void 0){r=true}return n(void 0,void 0,void 0,function(){var n,u,a,f,c,l,s,d,v,h,p,b;return i(this,function(i){switch(i.label){case 0:n=o.cache.serializeKey(e),u=n[0],a=n[2];if(!u)return[2];if(typeof t==="undefined")return[2,j(e,r)];m[u]=Date.now()-1;g[u]=0;f=m[u];c=y[u];if(!(t&&typeof t==="function"))return[3,5];i.label=1;case 1:i.trys.push([1,3,,4]);return[4,t(o.cache.get(u))];case 2:l=i.sent();return[3,4];case 3:d=i.sent();s=d;return[3,4];case 4:return[3,11];case 5:if(!(t&&typeof t.then==="function"))return[3,10];i.label=6;case 6:i.trys.push([6,8,,9]);return[4,t];case 7:l=i.sent();return[3,9];case 8:v=i.sent();s=v;return[3,9];case 9:return[3,11];case 10:l=t;i.label=11;case 11:if(f!==m[u]||c!==y[u]){if(s)throw s;return[2,l]}if(typeof l!=="undefined"){o.cache.set(u,l)}o.cache.set(a,s);g[u]=Date.now()-1;h=w[u];if(h){p=[];for(b=0;b<h.length;++b){p.push(h[b](!!r,l,s,undefined,b>0))}return[2,Promise.all(p).then(function(){if(s)throw s;return o.cache.get(u)})]}if(s)throw s;return[2,l]}})})};t.mutate=S;function useSWR(){var e=this;var t=[];for(var r=0;r<arguments.length;r++){t[r]=arguments[r]}var u,a,d={};if(t.length>=1){u=t[0]}if(t.length>2){a=t[1];d=t[2]}else{if(typeof t[1]==="function"){a=t[1]}else if(typeof t[1]==="object"){d=t[1]}}var O=o.cache.serializeKey(u),j=O[0],P=O[1],M=O[2],E=O[3];d=Object.assign({},o.default,f.useContext(s.default),d);var T=f.useRef(d);h(function(){T.current=d});if(typeof a==="undefined"){a=d.fetcher}var V=function(){var e=o.cache.get(j);return typeof e==="undefined"?d.initialData:e};var W=V();var C=o.cache.get(M);var I=!!o.cache.get(E);var z=f.useRef({data:false,error:false,isValidating:false});var R=f.useRef({data:W,error:C,isValidating:I});f.useDebugValue(R.current.data);var q=f.useState(null)[1];var D=f.useCallback(function(e){var t=false;for(var r in e){if(R.current[r]===e[r]){continue}R.current[r]=e[r];if(z.current[r]){t=true}}if(t||d.suspense){if(k.current)return;q({})}},[]);var k=f.useRef(false);var L=f.useRef(j);var K=f.useRef({emit:function(e){var t;var r=[];for(var n=1;n<arguments.length;n++){r[n-1]=arguments[n]}if(k.current)return;(t=T.current)[e].apply(t,r)}});var A=f.useCallback(function(e,t){return S(L.current,e,t)},[]);var H=function(e,t){if(!t)return;if(!e[j]){e[j]=[t]}else{e[j].push(t)}};var F=function(e,t){if(e[j]){var r=e[j];var n=r.indexOf(t);if(n>=0){r[n]=r[r.length-1];r.pop()}}};var G=f.useCallback(function(t){if(t===void 0){t={}}return n(e,void 0,void 0,function(){var e,r,n,u,f,c,l,s;return i(this,function(i){switch(i.label){case 0:if(!j||!a)return[2,false];if(k.current)return[2,false];t=Object.assign({dedupe:false},t);e=true;r=typeof p[j]!=="undefined"&&t.dedupe;i.label=1;case 1:i.trys.push([1,6,,7]);D({isValidating:true});o.cache.set(E,true);if(!r){x(j,undefined,undefined,true)}n=void 0;u=void 0;if(!r)return[3,3];u=y[j];return[4,p[j]];case 2:n=i.sent();return[3,5];case 3:if(d.loadingTimeout&&!o.cache.get(j)){setTimeout(function(){if(e)K.current.emit("onLoadingSlow",j,d)},d.loadingTimeout)}if(P!==null){p[j]=a.apply(void 0,P)}else{p[j]=a(j)}y[j]=u=Date.now();return[4,p[j]];case 4:n=i.sent();setTimeout(function(){delete p[j];delete y[j]},d.dedupingInterval);K.current.emit("onSuccess",n,j,d);i.label=5;case 5:f=y[j]>u||m[j]&&(u<=m[j]||u<=g[j]||g[j]===0);if(f){D({isValidating:false});return[2,false]}o.cache.set(j,n);o.cache.set(M,undefined);o.cache.set(E,false);c={isValidating:false};if(typeof R.current.error!=="undefined"){c.error=undefined}if(!d.compare(R.current.data,n)){c.data=n}D(c);if(!r){x(j,n,undefined,false)}return[3,7];case 6:l=i.sent();delete p[j];delete y[j];o.cache.set(M,l);if(R.current.error!==l){D({isValidating:false,error:l});if(!r){x(j,undefined,l,false)}}K.current.emit("onError",l,j,d);if(d.shouldRetryOnError){s=(t.retryCount||0)+1;K.current.emit("onErrorRetry",l,j,d,G,Object.assign({dedupe:true},t,{retryCount:s}))}return[3,7];case 7:e=false;return[2,true]}})})},[j]);h(function(){if(!j)return undefined;k.current=false;var e=R.current.data;var t=V();if(L.current!==j){L.current=j}if(!d.compare(e,t)){D({data:t})}var r=function(){return G({dedupe:true})};if(d.revalidateOnMount||!d.initialData&&d.revalidateOnMount===undefined){if(typeof t!=="undefined"){v(r)}else{r()}}var n=false;var i=function(){if(n||!T.current.revalidateOnFocus)return;n=true;r();setTimeout(function(){return n=false},T.current.focusThrottleInterval)};var u=function(){if(T.current.revalidateOnReconnect){r()}};var a=function(e,t,n,i,u){if(e===void 0){e=true}if(u===void 0){u=true}var a={};var f=false;if(typeof t!=="undefined"&&!d.compare(R.current.data,t)){a.data=t;f=true}if(R.current.error!==n){a.error=n;f=true}if(typeof i!=="undefined"&&R.current.isValidating!==i){a.isValidating=i;f=true}if(f){D(a)}if(e){if(u){return r()}else{return G()}}return false};H(b,i);H(_,u);H(w,a);return function(){D=function(){return null};k.current=true;F(b,i);F(_,u);F(w,a)}},[j,G]);h(function(){var t=null;var r=function(){return n(e,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:if(!(!R.current.error&&(T.current.refreshWhenHidden||c.default())&&(T.current.refreshWhenOffline||l.default())))return[3,2];return[4,G({dedupe:true})];case 1:e.sent();e.label=2;case 2:if(T.current.refreshInterval&&!R.current.error){t=setTimeout(r,T.current.refreshInterval)}return[2]}})})};if(T.current.refreshInterval){t=setTimeout(r,T.current.refreshInterval)}return function(){if(t)clearTimeout(t)}},[d.refreshInterval,d.refreshWhenHidden,d.refreshWhenOffline,G]);var B=f.useMemo(function(){var e={revalidate:G,mutate:A};Object.defineProperties(e,{error:{get:function(){z.current.error=true;return L.current===j?R.current.error:C},enumerable:true},data:{get:function(){z.current.data=true;return L.current===j?R.current.data:W},enumerable:true},isValidating:{get:function(){z.current.isValidating=true;return R.current.isValidating},enumerable:true}});return e},[G]);if(d.suspense){var J=o.cache.get(j);var Q=o.cache.get(M);if(typeof J==="undefined"){J=W}if(typeof Q==="undefined"){Q=C}if(typeof J==="undefined"&&typeof Q==="undefined"){if(!p[j]){G()}if(p[j]&&typeof p[j].then==="function"){throw p[j]}J=p[j]}if(typeof J==="undefined"&&Q){throw Q}return{error:Q,data:J,revalidate:G,mutate:A,isValidating:R.current.isValidating}}return B}var P=s.default.Provider;t.SWRConfig=P;t.default=useSWR},641:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});var i=r(48);var u=n(r(459));var a=n(r(722));var f=new a.default;t.cache=f;function onErrorRetry(e,t,r,n,i){if(!u.default()){return}if(typeof r.errorRetryCount==="number"&&i.retryCount>r.errorRetryCount){return}var a=Math.min(i.retryCount||0,8);var f=~~((Math.random()+.5)*(1<<a))*r.errorRetryInterval;setTimeout(n,f,i)}var o=typeof window!=="undefined"&&navigator["connection"]&&["slow-2g","2g"].indexOf(navigator["connection"].effectiveType)!==-1;var c={onLoadingSlow:function(){},onSuccess:function(){},onError:function(){},onErrorRetry:onErrorRetry,errorRetryInterval:(o?10:5)*1e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:(o?5:3)*1e3,refreshInterval:0,revalidateOnFocus:true,revalidateOnReconnect:true,refreshWhenHidden:false,refreshWhenOffline:false,shouldRetryOnError:true,suspense:false,compare:i.dequal,fetcher:function(e){return fetch(e).then(function(e){return e.json()})}};t.default=c},722:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});var i=n(r(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 t=this.serializeKey(e)[0];return this.__cache.get(t)};Cache.prototype.set=function(e,t){var r=this.serializeKey(e)[0];this.__cache.set(r,t);this.notify()};Cache.prototype.keys=function(){return Array.from(this.__cache.keys())};Cache.prototype.has=function(e){var t=this.serializeKey(e)[0];return this.__cache.has(t)};Cache.prototype.clear=function(){this.__cache.clear();this.notify()};Cache.prototype.delete=function(e){var t=this.serializeKey(e)[0];this.__cache.delete(t);this.notify()};Cache.prototype.serializeKey=function(e){var t=null;if(typeof e==="function"){try{e=e()}catch(t){e=""}}if(Array.isArray(e)){t=e;e=i.default(e)}else{e=String(e||"")}var r=e?"err@"+e:"";var n=e?"validating@"+e:"";return[e,t,r,n]};Cache.prototype.subscribe=function(e){var t=this;if(typeof e!=="function"){throw new Error("Expected the listener to be a function.")}var r=true;this.__listeners.push(e);return function(){if(!r)return;r=false;var n=t.__listeners.indexOf(e);if(n>-1){t.__listeners[n]=t.__listeners[t.__listeners.length-1];t.__listeners.length--}}};Cache.prototype.notify=function(){for(var e=0,t=this.__listeners;e<t.length;e++){var r=t[e];r()}};return Cache}();t.default=u},942:function(e,t,r){"use strict";var n=this&&this.__assign||function(){n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i))e[i]=t[i]}return e};return n.apply(this,arguments)};var i=this&&this.__awaiter||function(e,t,r,n){function adopt(e){return e instanceof r?e:new r(function(t){t(e)})}return new(r||(r=Promise))(function(r,i){function fulfilled(e){try{step(n.next(e))}catch(e){i(e)}}function rejected(e){try{step(n["throw"](e))}catch(e){i(e)}}function step(e){e.done?r(e.value):adopt(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())})};var u=this&&this.__generator||function(e,t){var r={label:0,sent:function(){if(u[0]&1)throw u[1];return u[1]},trys:[],ops:[]},n,i,u,a;return a={next:verb(0),throw:verb(1),return:verb(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function verb(e){return function(t){return step([e,t])}}function step(a){if(n)throw new TypeError("Generator is already executing.");while(r)try{if(n=1,i&&(u=a[0]&2?i["return"]:a[0]?i["throw"]||((u=i["return"])&&u.call(i),0):i.next)&&!(u=u.call(i,a[1])).done)return u;if(i=0,u)a=[a[0]&2,u.value];switch(a[0]){case 0:case 1:u=a;break;case 4:r.label++;return{value:a[1],done:false};case 5:r.label++;i=a[1];a=[0];continue;case 7:a=r.ops.pop();r.trys.pop();continue;default:if(!(u=r.trys,u=u.length>0&&u[u.length-1])&&(a[0]===6||a[0]===2)){r=0;continue}if(a[0]===3&&(!u||a[1]>u[0]&&a[1]<u[3])){r.label=a[1];break}if(a[0]===6&&r.label<u[1]){r.label=u[1];u=a;break}if(u&&r.label<u[2]){r.label=u[2];r.ops.push(a);break}if(u[2])r.ops.pop();r.trys.pop();continue}a=t.call(e,r)}catch(e){a=[6,e];i=0}finally{n=u=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};var a=this&&this.__rest||function(e,t){var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0)r[n]=e[n];if(e!=null&&typeof Object.getOwnPropertySymbols==="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++){if(t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i]))r[n[i]]=e[n[i]]}return r};var f=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)if(Object.hasOwnProperty.call(e,r))t[r]=e[r];t["default"]=e;return t};var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});var c=r(297);var l=f(r(641));var s=o(r(209));var d=o(r(516));function useSWRInfinite(){var e=this;var t=[];for(var r=0;r<arguments.length;r++){t[r]=arguments[r]}var f,o,v={};if(t.length>=1){f=t[0]}if(t.length>2){o=t[1];v=t[2]}else{if(typeof t[1]==="function"){o=t[1]}else if(typeof t[1]==="object"){v=t[1]}}v=Object.assign({},l.default,c.useContext(s.default),v);var h=v.initialSize,p=h===void 0?1:h,y=v.revalidateAll,b=y===void 0?false:y,_=v.persistSize,w=_===void 0?false:_,m=v.fetcher,g=a(v,["initialSize","revalidateAll","persistSize","fetcher"]);if(typeof o==="undefined"){o=m}var O=null;try{O=l.cache.serializeKey(f(0,null))[0]}catch(e){}var j=c.useState(false)[1];var x=null;if(O){x="context@"+O}var S=null;var P;if(O){S="size@"+O;P=l.cache.get(S)}var M=c.useRef(P||p);var E=c.useRef(false);c.useEffect(function(){if(E.current){if(!w){M.current=p}}else{E.current=true}},[O]);var T=d.default(O?["many",O]:null,function(){return i(e,void 0,void 0,function(){var e,t,r,n,i,a,c,s,d,h,p;return u(this,function(u){switch(u.label){case 0:e=l.cache.get(x)||{},t=e.originalData,r=e.force;n=[];i=null;a=0;u.label=1;case 1:if(!(a<M.current))return[3,8];c=l.cache.serializeKey(f(a,i)),s=c[0],d=c[1];if(!s){return[3,8]}h=l.cache.get(s);p=b||r||typeof r==="undefined"&&a===0||t&&!v.compare(t[a],h)||typeof h==="undefined";if(!p)return[3,6];if(!(d!==null))return[3,3];return[4,o.apply(void 0,d)];case 2:h=u.sent();return[3,5];case 3:return[4,o(s)];case 4:h=u.sent();u.label=5;case 5:l.cache.set(s,h);u.label=6;case 6:n.push(h);i=h;u.label=7;case 7:++a;return[3,1];case 8:l.cache.delete(x);return[2,n]}})})},g);var V=c.useRef(T.data);c.useEffect(function(){V.current=T.data},[T.data]);var W=c.useCallback(function(e,t){if(t===void 0){t=true}if(t&&typeof e!=="undefined"){var r=V.current;l.cache.set(x,{originalData:r,force:false})}else if(t){l.cache.set(x,{force:true})}return T.mutate(e,t)},[T.mutate,x]);var C=M.current;var I=c.useCallback(function(e){if(typeof e==="function"){M.current=e(M.current)}else if(typeof e==="number"){M.current=e}l.cache.set(S,M.current);j(function(e){return!e});return W(function(e){return e})},[W,S]);return n(n({},T),{mutate:W,size:C,setSize:I})}t.useSWRInfinite=useSWRInfinite}}); |
@@ -15,3 +15,4 @@ // use WeakMap to store the object->key mapping | ||
var _hash = void 0; | ||
if (args[i] === null || (typeof args[i] !== 'object' && typeof args[i] !== 'function')) { | ||
if (args[i] === null || | ||
(typeof args[i] !== 'object' && typeof args[i] !== 'function')) { | ||
// need to consider the case that args[i] is a string: | ||
@@ -18,0 +19,0 @@ // args[i] _hash |
@@ -0,1 +1,12 @@ | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -169,11 +180,12 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
}); }, extraConfig); | ||
var swrInfinite = swr; | ||
// extend the SWR API | ||
var mutate = swrInfinite.mutate; | ||
swrInfinite.size = pageCountRef.current; | ||
swrInfinite.mutate = useCallback(function (data, shouldRevalidate) { | ||
// keep the data inside a ref | ||
var dataRef = useRef(swr.data); | ||
useEffect(function () { | ||
dataRef.current = swr.data; | ||
}, [swr.data]); | ||
var mutate = useCallback(function (data, shouldRevalidate) { | ||
if (shouldRevalidate === void 0) { shouldRevalidate = true; } | ||
if (shouldRevalidate && typeof data !== 'undefined') { | ||
// we only revalidate the pages that are changed | ||
var originalData = swrInfinite.data; | ||
var originalData = dataRef.current; | ||
cache.set(contextCacheKey, { originalData: originalData, force: false }); | ||
@@ -185,5 +197,7 @@ } | ||
} | ||
return mutate(data, shouldRevalidate); | ||
}, [mutate, swrInfinite.data, contextCacheKey]); | ||
swrInfinite.setSize = useCallback(function (arg) { | ||
return swr.mutate(data, shouldRevalidate); | ||
}, [swr.mutate, contextCacheKey]); | ||
// extend the SWR API | ||
var size = pageCountRef.current; | ||
var setSize = useCallback(function (arg) { | ||
if (typeof arg === 'function') { | ||
@@ -197,6 +211,8 @@ pageCountRef.current = arg(pageCountRef.current); | ||
rerender(function (v) { return !v; }); | ||
return swrInfinite.mutate(function (v) { return v; }); | ||
}, [swrInfinite.mutate, pageCountCacheKey]); | ||
return swrInfinite; | ||
return mutate(function (v) { return v; }); | ||
}, [mutate, pageCountCacheKey]); | ||
return __assign(__assign({}, swr), { mutate: mutate, | ||
size: size, | ||
setSize: setSize }); | ||
} | ||
export { useSWRInfinite }; |
@@ -283,4 +283,4 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
var boundMutate = useCallback(function (data, shouldRevalidate) { | ||
return mutate(key, data, shouldRevalidate); | ||
}, [key]); | ||
return mutate(keyRef.current, data, shouldRevalidate); | ||
}, []); | ||
var addRevalidator = function (revalidators, callback) { | ||
@@ -287,0 +287,0 @@ if (!callback) |
{ | ||
"name": "swr", | ||
"version": "0.3.4", | ||
"version": "0.3.5", | ||
"description": "React Hooks library for remote data fetching", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
101990
1353