New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@airma/react-effect

Package Overview
Dependencies
Maintainers
1
Versions
89
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@airma/react-effect - npm Package Compare versions

Comparing version 18.3.0-alpha.10 to 18.3.0-alpha.11

2

dist/index.js

@@ -1,1 +0,1 @@

!function(r,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react"),require("@airma/react-state"),require("@airma/react-hooks-core")):"function"==typeof define&&define.amd?define(["react","@airma/react-state","@airma/react-hooks-core"],e):"object"==typeof exports?exports["@airma/react-effect"]=e(require("react"),require("@airma/react-state"),require("@airma/react-hooks-core")):r["@airma/react-effect"]=e(r.react,r["@airma/react-state"],r["@airma/react-hooks-core"])}(self,(function(r,e,n){return function(){"use strict";var t={309:function(r){r.exports=n},719:function(r){r.exports=e},156:function(e){e.exports=r}},o={};function u(r){var e=o[r];if(void 0!==e)return e.exports;var n=o[r]={exports:{}};return t[r](n,n.exports,u),n.exports}u.d=function(r,e){for(var n in e)u.o(e,n)&&!u.o(r,n)&&Object.defineProperty(r,n,{enumerable:!0,get:e[n]})},u.o=function(r,e){return Object.prototype.hasOwnProperty.call(r,e)},u.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})};var i={};return function(){function r(r,e,n){return e in r?Object.defineProperty(r,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):r[e]=n,r}function e(r,e){(null==e||e>r.length)&&(e=r.length);for(var n=0,t=new Array(e);n<e;n++)t[n]=r[n];return t}function n(r,n){if(r){if("string"==typeof r)return e(r,n);var t=Object.prototype.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?e(r,n):void 0}}function t(r){return function(r){if(Array.isArray(r))return e(r)}(r)||function(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}(r)||n(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(r,e){return function(r){if(Array.isArray(r))return r}(r)||function(r,e){var n=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=n){var t,o,u=[],i=!0,c=!1;try{for(n=n.call(r);!(i=(t=n.next()).done)&&(u.push(t.value),!e||u.length!==e);i=!0);}catch(r){c=!0,o=r}finally{try{i||null==n.return||n.return()}finally{if(c)throw o}}return u}}(r,e)||n(r,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}u.r(i),u.d(i,{ConfigProvider:function(){return w},Provider:function(){return Y},SessionProvider:function(){return _},Strategy:function(){return C},createSessionKey:function(){return b},provide:function(){return $},session:function(){return B},useIsFetching:function(){return U},useLazyComponent:function(){return J},useLoadedSession:function(){return N},useMutation:function(){return R},useQuery:function(){return G},useResponse:function(){return z},useSession:function(){return Q}});var c=u(156),a=u(719),s=u(309);function f(r,e){if(null==r)return{};var n,t,o=function(r,e){if(null==r)return{};var n,t,o={},u=Object.keys(r);for(t=0;t<u.length;t++)n=u[t],e.indexOf(n)>=0||(o[n]=r[n]);return o}(r,e);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(r);for(t=0;t<u.length;t++)n=u[t],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(r,n)&&(o[n]=r[n])}return o}var l=["version"];function d(r,e){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(r);e&&(t=t.filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.push.apply(n,t)}return n}function v(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?d(Object(t),!0).forEach((function(n){r(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):d(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function y(r){var e=r.version,n=f(r,l),t=function(n){return v(v({},n),{},{version:e,uniqueKey:r.uniqueKey})},o=function(e){return e.isFetching?e:v(v({},e),{},{fetchVersion:(r.fetchVersion||0)+1})};return{state:n,version:e||0,setState:function(e){return o(t("function"!=typeof e?e:e(r)))},setFetchingKey:function(e){return t(v(v({},r),{},{fetchingKey:e,finalFetchingKey:null!=e?e:r.finalFetchingKey}))},removeFetchingKey:function(e){return r.fetchingKey!==e?r:t(v(v({},r),{},{fetchingKey:void 0}))},trigger:function(){return v(v({},r),{},{version:(e||0)+1})}}}var p=function(r){return v({data:void 0,variables:void 0,isError:!1,isFetching:!1,abandon:!1,triggerType:void 0,loaded:!1,sessionLoaded:!1,cache:[]},r)};function h(r,e,n){if(!("function"==typeof r.pipe))return[y,r,n,!1];var t=o(r.effect,2),u=t[0],i=t[1].sessionType;if(null!=i&&i!==e)throw new Error("The sessionType is not matched, can not use '".concat(i," type' sessionKey with '").concat("query"===e?"useQuery":"useMutation","'"));return[r,u,n,!0]}function g(r,e){return o(h(r,"query",Array.isArray(e)?{variables:e}:e),3)[2]||{}}function b(r,e){var n=(0,a.createKey)(y,p()),t=function(){return r.apply(void 0,arguments)};return t.sessionConfig=r.sessionConfig,n.effect=[t,e?{sessionType:e}:{}],n}var m=[],O=(0,a.createKey)((function(r){return{isFetching:r.length>0,setGlobalFetchingKey:function(e){return r.some((function(r){return r===e}))?r:r.concat(e)},removeGlobalFetchingKey:function(e){return r.some((function(r){return r===e}))?r.filter((function(r){return r!==e})):r}}}),m),j=(0,c.createContext)(null);function w(r){var e=r.value,n=r.children,t=(0,c.useMemo)((function(){return e.useGlobalFetching?O:void 0}),[]);return(0,c.createElement)(j.Provider,{value:e},t?(0,c.createElement)(a.Provider,{value:t},n):n)}function P(){return(0,c.useContext)(j)}function E(r,e){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(r);e&&(t=t.filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.push.apply(n,t)}return n}function S(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?E(Object(t),!0).forEach((function(n){r(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):E(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function F(r){return Array.isArray(r)?r:[r]}function T(r,e){var n=null==e?1:e;function u(r,e){var n=r.find((function(r){return o(r,1)[0]===e}))||[void 0,void 0];return o(n,2)[1]}return{get:function(e){if(!(n<1))return u(r,e)},set:function(e,i){if(n<1)return[];var c={data:i,lastUpdateTime:A()};if(null!=u(r,e))return r.map((function(r){var n=o(r,2),t=n[0],u=n[1];return e!==t?[t,u]:[e,c]}));var a=[].concat(t(r),[[e,c]]);return a.length>n?a.slice(a.length-n):a}}}function A(){return(new Date).getTime()}function K(r,e,n){var u=n.strategy,i=(e.sessionConfig||{}).cache,a=F(u),s=(0,c.useRef)(a.map((function(){return{current:void 0}}))),f=a.map((function(r){if(r)return r.effect})).filter((function(r){return!!r})),l=a.map((function(r){if(r)return r.response})).filter((function(r){return!!r})),d=function(){var r=function(r){return JSON.stringify(r)};if(null!=i){if("default"===i)return{key:r};if("function"==typeof i)return{key:i};var e=i.key;return{key:null==e||"default"===e?r:e,staleTime:i.staleTime,capacity:i.capacity}}}();return[function(n,u){var i,c,f=u||[],l={current:function(){return r.state},variables:f,runner:function(){var t=r.state,o=r.setState;if(!d)return o(S(S({},t),{},{isFetching:!0,triggerType:n})),e(n,f);var u=t.cache,i=d.key,c=d.staleTime,a=d.capacity,s=i(f||[]),l=T(u,a).get(s);return l&&c&&A()>c+l.lastUpdateTime?Promise.resolve(S(S({},t),{},{data:l.data,isFetching:!1})):(o(S(S({},t),{},l?{isFetching:!0,data:l.data,triggerType:n}:{isFetching:!0,triggerType:n})),e(n,f))},store:s,runtimeCache:(i=[],c=function(r){var e=i.find((function(e){return o(e,1)[0]===r}));if(Array.isArray(e))return e},{set:function(r,e){var n=c(r);n?n[1]=e:i.push([r,e])},get:function(r){var e=c(r);if(e)return e[1]}})};return function(r){var e=function(r){return r.runner()};return function(n){var o=n.store.current;return t(r).reverse().reduce((function(r,e,n){var t=o[n]||{current:void 0};return function(n){return null==e?r(n):e(S(S({},n),{},{store:t,runner:function(){return r(n)}}))}}),e)(n).then((function(r){var e=n.current(),t=e.loaded,o=e.sessionLoaded,u=r.abandon,i=r.isError,c=r.isFetching,a=t||!u&&!i&&!c,s=o||!u&&!i&&!c;return S(S({},r),{},{loaded:a,sessionLoaded:s})}))}}(a)(l).then((function(e){var n=r.state;if(e.abandon)return e;if(!d||null!=d.capacity&&d.capacity<1)return r.setState(e),e;var t=d.key,o=d.capacity,u=t(e.variables||[]),i=T(n.cache,o).set(u,e.data),c=S(S({},e),{},{cache:i});return r.setState(c),c}))},f,l]}function k(r,e){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(r);e&&(t=t.filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.push.apply(n,t)}return n}function D(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?k(Object(t),!0).forEach((function(n){r(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):k(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}var M=function(r,e){return!!Object.is(r,e)||null!=r&&null!=e&&JSON.stringify(r)===JSON.stringify(e)};function q(r,e){var n=(e||{}).withAbandoned;return function(e){var t=e.runner,o=e.runtimeCache,u=e.store,i=o.get(q);return o.set(q,!0),u.current=r,t().then((function(r){var e=u.current;return!r.isError||i||!e||r.abandon&&!n||e(r.error,r),r}))}}function x(r){var e=function(r){return(0,r.runner)()};return e.response=r,e}x.success=function(r){var e=function(r){return(0,r.runner)()};return e.response=function(e){e.isError||e.isFetching||!e.sessionLoaded||r(e.data,e)},e},x.error=function(r){var e=function(r){var e=r.runner;return r.runtimeCache.set(q,!0),e()};return e.response=function(e){e.isError&&!e.isFetching&&r(e.error,e)},e},x.failure=function(r){var e=function(r){var e=r.runner;return r.runtimeCache.set(q,!0),e()};return e.response=function(e){e.isError&&!e.isFetching&&r(e.error,e)},e};var C={debounce:function(r){var e="number"==typeof r?r:r.duration,n="number"!=typeof r&&!!r.lead;return function(r){return n?function(){var n=r.current,t=r.runner,o=r.store;o.current&&o.current.id&&(clearTimeout(o.current.id),o.current.id=void 0);var u=setTimeout((function(){o.current=void 0}),e);if(null!=o.current)return o.current.id=u,o.current.promise.then((function(r){return D(D({},r),{},{abandon:!0})}));var i={id:u,version:0,resolve:function(){},promise:new Promise((function(r){r(D(D({},n()),{},{abandon:!0}))}))},c=new Promise((function(r){r(t()),i.resolve=r}));return i.promise=c,o.current=i,c}():function(){var n=r.current,t=r.runner,o=r.store;if(o.current){var u=o.current,i=u.id,c=u.resolve;clearTimeout(i),o.current.id=setTimeout((function(){o.current=void 0,c(t())}),e),o.current.version+=1;var a=o.current.version;return o.current.promise.then((function(r){var e;return a===(null===(e=o.current)||void 0===e?void 0:e.version)?r:D(D({},r),{},{abandon:!0})}))}var s={id:null,version:0,resolve:function(){},promise:new Promise((function(r){r(D(D({},n()),{},{abandon:!0}))}))},f=new Promise((function(r){s.id=setTimeout((function(){o.current=void 0,r(t())}),e),s.resolve=r}));s.promise=f,o.current=s;var l=s.version;return f.then((function(r){var e;return null!==(e=o.current)&&void 0!==e&&e.version||0===l?r:D(D({},r),{},{abandon:!0})}))}()}},throttle:function(r){var e=function(){if(null!=r)return"number"==typeof r?r:r.duration}();return function(r){var n=r.current,t=r.runner,o=r.store,u=r.variables,i=void 0===u?[]:u;o.current=o.current||{timeoutId:null,variables:void 0};var c=o.current.variables,a=o.current.timeoutId;return function(r,e){return null==r||!M(r,e)}(c,i)||null==a&&null!=e?(o.current.variables=i,null==e||(null!=a&&clearTimeout(a),o.current.timeoutId=setTimeout((function(){o.current=o.current||{},o.current.timeoutId=null}),e)),t()):new Promise((function(r){r(n())}))}},once:function(){return function(r){var e=r.runner,n=r.store;return n.current?n.current.then((function(r){return D(D({},r),{},{abandon:!0})})):(n.current=e().then((function(r){return r.isError&&(n.current=void 0),r})),n.current)}},error:q,failure:function(r,e){var n=(e||{}).withAbandoned;return function(e){var t=e.runner,o=e.runtimeCache,u=e.store,i=o.get(q);return o.set(q,!0),u.current=r,t().then((function(r){var e=u.current;return!r.isError||i||!e||r.abandon&&!n||e(r.error,r),r}))}},success:function(r,e){var n=(e||{}).withAbandoned;return function(e){var t=e.runner,o=e.store;return o.current=r,t().then((function(r){var e=o.current;return r.isError||!e||r.abandon&&!n||e(r.data,r),r}))}},validate:function(r){return function(e){var n=e.runner,t=e.current;if(!r()){var o=t();return new Promise((function(r){r(D(D({},o),{},{abandon:!0}))}))}return n()}},memo:function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:M;return function(e){var n=e.runner,t=e.current;return n().then((function(e){var n=t();return("function"==typeof r?r(n.data,e.data):n.data===e.data)?D(D({},e),{},{data:n.data}):e}))}},reduce:function(r){return function(e){var n=e.runner,t=e.current;return n().then((function(e){if(e.isError||e.abandon)return e;var n=t(),o=r(n.data,e.data,[n,e]);return D(D({},e),{},{data:o})}))}},response:x};function I(r,e){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(r);e&&(t=t.filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.push.apply(n,t)}return n}function L(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?I(Object(t),!0).forEach((function(n){r(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):I(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function V(r,e){var n=(0,c.useRef)({}),u=function(r,e,n){var u=Array.isArray(n)?{variables:n}:n,i=o(h(r,"query",u),4),c=i[0],s=i[1],f=i[2],l=i[3],d=f||{},v=d.defaultData,y=d.loaded,g=Object.prototype.hasOwnProperty.call(d,"defaultData"),b=l?g?[c,p({data:v,uniqueKey:r,loaded:!0})]:[c]:[c,p(g?{data:v,uniqueKey:e,loaded:!0}:void 0)],m=a.useModel.apply(void 0,t(b));if(y&&!m.state.loaded)throw new Error('This session is not loaded, you should remove "config.loaded" option.');return[m,d,s]}(r,n.current,e),i=o(u,3),f=i[0],l=i[1],d=i[2],v=l.variables,y=l.deps,g=l.triggerOn,b=void 0===g?["mount","update","manual"]:g,j=(0,a.useRealtimeInstance)(f),w=(0,a.useModel)(O,m,{autoLink:!0}),P=w.setGlobalFetchingKey,E=w.removeGlobalFetchingKey,S=function(r,e){var o=function(r){return function(e){var n=r(e);if(!n||"function"!=typeof n.then)throw new Error("The callback have to return a promise object.");return n.then((function(r){return{data:r,variables:e,error:void 0,isError:!1}}),(function(r){return{variables:e,error:r,isError:!0}}))}}((function(r){return d.apply(void 0,t(r))}));return o(e).then((function(e){var t=null!=j.state.finalFetchingKey&&n.current!==j.state.finalFetchingKey;return L(L(L({},j.state),e),{},{abandon:t,isFetching:!1,triggerType:r})}))};S.sessionConfig=d.sessionConfig;var F=o(K(j,S,l),3),T=F[0],A=F[1],k=F[2],D=function(r,e){var t=j.state.fetchingKey;return b.indexOf(r)<0||t&&t!==n.current?new Promise((function(r){r(L(L({},j.state),{},{abandon:!0}))})):(j.setFetchingKey(n.current),Promise.resolve(void 0).then((function(){j.removeFetchingKey(n.current)})),T(r,e||v))},M=(0,s.usePersistFn)((function(){return D("manual")})),q=(0,s.usePersistFn)((function(){for(var r=arguments.length,e=new Array(r),n=0;n<r;n++)e[n]=arguments[n];return D("manual",e)})),x=y||v||[];(0,s.useMount)((function(){D("mount")})),(0,s.useUpdate)((function(){D("update")}),x);var C=(0,c.useRef)(f.version);return(0,c.useEffect)((function(){if(C.current!==f.version){C.current=f.version;var r=j.state.fetchingKey;r&&r!==n.current||M()}}),[f.version]),(0,c.useEffect)((function(){f.state.isFetching?P(n.current):E(n.current)}),[f.state.isFetching]),(0,s.useUnmount)((function(){E(n.current),j.removeFetchingKey(n.current)})),(0,c.useEffect)((function(){A.forEach((function(r){r(f.state)}))}),[f.state]),(0,c.useEffect)((function(){null!=f.state.fetchVersion&&k.forEach((function(r){r(f.state)}))}),[f.state.fetchVersion]),[f.state,M,q]}function G(r,e){var n=g(r,e),t=n.variables,o=n.deps,u=n.manual,i=n.triggerOn,c=void 0===i?["mount","update","manual"]:i,a=n.strategy,s=!o&&!t||u?["manual"]:c,f=(P()||{}).strategy,l=F(a),d=f?f(l,"query"):l;return V(r,L(L({},n),{},{triggerOn:s,strategy:d.concat((function(r){var e=r.runner,n=r.store;n.current=n.current||0;var t=n.current+1;return n.current=t,e().then((function(r){return n.current!==t?S(S({},r),{},{abandon:!0}):r}))}))}))}function R(r,e){var n=g(r,e),t=n.triggerOn,o=void 0===t?["manual"]:t,u=n.strategy,i=(P()||{}).strategy,c=F(u),a=i?i(c,"mutation"):c;return V(r,L(L({},n),{},{triggerOn:o,strategy:a.concat((function(r){var e=r.runner,n=r.store;if(n.current)return n.current.then((function(r){return S(S({},r),{},{abandon:!0})}));var t=e();return n.current=t.then((function(r){return n.current=void 0,r})),t}))}))}function Q(r,e){var n=o(r.effect,2)[1].sessionType,t=(0,a.useSelector)(r,(function(r){return[r.state,r.trigger]})),u="string"==typeof e?{sessionType:e,loaded:void 0}:e||{},i=u.loaded,c=u.sessionType,s=o(t,1)[0].loaded;if(c&&n&&c!==n)throw new Error("The sessionType is not matched, can not use '".concat(n," type' sessionKey with '").concat(c," type' useSession."));if(i&&!s)throw new Error("The session is not loaded yet, check config, and set {loaded: undefined}.");return t}function U(){for(var r=arguments.length,e=new Array(r),n=0;n<r;n++)e[n]=arguments[n];var t=(0,c.useMemo)((function(){return e.map((function(r){return Array.isArray(r)?o(r,1)[0]:r})).some((function(r){return r.isFetching}))}),e),u=(0,a.useIsModelMatchedInStore)(O),i=(0,a.useModel)(O,m,{autoLink:!0}).isFetching;if(!u&&!e.length)throw new Error("You should provide a `GlobalRefreshProvider` to support a global `isFetching` detect.");return u&&!e.length?i:t}function J(r){for(var e=arguments.length,n=new Array(e>1?e-1:0),u=1;u<e;u++)n[u-1]=arguments[u];var i=(0,c.useMemo)((function(){return n.map((function(r){var e={loaded:!1};return e.promise=new Promise((function(r,n){e.resolve=r,e.reject=n})),e}))}),[]),a=(0,c.useRef)(i);function s(r){return r.default?r:{default:r}}return(0,c.useEffect)((function(){var r=a.current;n.forEach((function(e,n){var t=Array.isArray(e)?e[0]:e,o=r[n];if(t.isError&&!o.loaded)return o.loaded=!0,void o.reject(t);t.loaded&&!o.loaded&&(o.loaded=!0,o.resolve(!0))}))}),[].concat(n)),(0,c.useMemo)((function(){var e=a.current.map((function(r){return r.promise}));return(0,c.lazy)((function(){var n=r();return Promise.all([n].concat(t(e))).then((function(r){return s(o(r,1)[0])}),(function(r){return n.then((function(e){var n=function(r){var e=r;return e.default&&"function"==typeof e.default?e.default:r}(e),t=function(r,e){return function(n){return(0,c.createElement)(r,L(L({},n),{},{error:e}))}}(n,r);return s(t)}))}))}))}),[])}function N(r,e){return Q(r,"string"==typeof e?{sessionType:e,loaded:!0}:L(L({},e),{},{loaded:!0}))}function z(r,e){(0,c.useEffect)((function(){if(null!=e.fetchVersion){var n=!e.isFetching&&e.isError,t=!e.isFetching&&e.sessionLoaded&&!e.isError;(n||t)&&r(e)}}),[e.fetchVersion])}z.useSuccess=function(r,e){(0,c.useEffect)((function(){null!=e.fetchVersion&&(!e.isFetching&&e.sessionLoaded&&!e.isError&&r(e.data,e))}),[e.fetchVersion])},z.useFailure=function(r,e){(0,c.useEffect)((function(){null!=e.fetchVersion&&(!e.isFetching&&e.isError&&r(e.error,e))}),[e.fetchVersion])},z.success=z.useSuccess,z.error=z.useFailure;var _=a.Provider,Y=a.Provider,$=a.provide,B=function(r,e){var n="string"==typeof e?{sessionType:e,cache:void 0}:e,o=n.sessionType,u=n.cache,i=function(){return r.apply(void 0,arguments)};i.sessionConfig={sessionType:o,cache:u};var a=function r(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],u=null!=e?e:b(i,o),a={key:u,with:function(){for(var e=arguments.length,t=new Array(e),o=0;o<e;o++)t[o]=arguments[o];var i=n.concat(t.map((function(r){return"function"==typeof r?r:r.key})));return r(u,i)},asGlobal:function(){var r=u.global(),e={useSession:function(){return Q(r,o)},useLoadedSession:function(){return N(r,o)}};return L(L({},e),{},"query"===o?{useQuery:function(e){return G(r,e)}}:{useMutation:function(e){return R(r,e)}})},useSession:function(){return Q(u,o)},useLoadedSession:function(){return N(u,o)},provide:function(){return $([u].concat(t(n)))},provideTo:function(r){return $([u].concat(t(n)))(r)},Provider:function(r){var e=r.children;return(0,c.createElement)(Y,{value:[u].concat(t(n))},e)}};return L(L({},a),{},"query"===o?{useQuery:function(r){return G(u,r)}}:{useMutation:function(r){return R(u,r)}})},s={store:a,createStore:a},f=L(L({},s),{},{useQuery:function(r){return G(i,r)}}),l=L(L({},s),{},{useMutation:function(r){return R(i,r)}}),d="query"===o?f:l;return Object.assign(i,d)}}(),i}()}));
!function(r,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react"),require("@airma/react-state"),require("@airma/react-hooks-core")):"function"==typeof define&&define.amd?define(["react","@airma/react-state","@airma/react-hooks-core"],e):"object"==typeof exports?exports["@airma/react-effect"]=e(require("react"),require("@airma/react-state"),require("@airma/react-hooks-core")):r["@airma/react-effect"]=e(r.react,r["@airma/react-state"],r["@airma/react-hooks-core"])}(self,(function(r,e,n){return function(){"use strict";var t={309:function(r){r.exports=n},719:function(r){r.exports=e},156:function(e){e.exports=r}},o={};function u(r){var e=o[r];if(void 0!==e)return e.exports;var n=o[r]={exports:{}};return t[r](n,n.exports,u),n.exports}u.d=function(r,e){for(var n in e)u.o(e,n)&&!u.o(r,n)&&Object.defineProperty(r,n,{enumerable:!0,get:e[n]})},u.o=function(r,e){return Object.prototype.hasOwnProperty.call(r,e)},u.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})};var i={};return function(){function r(r,e,n){return e in r?Object.defineProperty(r,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):r[e]=n,r}function e(r,e){(null==e||e>r.length)&&(e=r.length);for(var n=0,t=new Array(e);n<e;n++)t[n]=r[n];return t}function n(r,n){if(r){if("string"==typeof r)return e(r,n);var t=Object.prototype.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?e(r,n):void 0}}function t(r){return function(r){if(Array.isArray(r))return e(r)}(r)||function(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}(r)||n(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(r,e){return function(r){if(Array.isArray(r))return r}(r)||function(r,e){var n=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=n){var t,o,u=[],i=!0,c=!1;try{for(n=n.call(r);!(i=(t=n.next()).done)&&(u.push(t.value),!e||u.length!==e);i=!0);}catch(r){c=!0,o=r}finally{try{i||null==n.return||n.return()}finally{if(c)throw o}}return u}}(r,e)||n(r,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}u.r(i),u.d(i,{ConfigProvider:function(){return w},Provider:function(){return $},SessionProvider:function(){return Y},Strategy:function(){return L},createSessionKey:function(){return g},provide:function(){return B},session:function(){return H},useIsFetching:function(){return J},useLazyComponent:function(){return N},useLoadedSession:function(){return z},useMutation:function(){return Q},useQuery:function(){return R},useResponse:function(){return _},useSession:function(){return U}});var c=u(156),a=u(719),s=u(309);function f(r,e){if(null==r)return{};var n,t,o=function(r,e){if(null==r)return{};var n,t,o={},u=Object.keys(r);for(t=0;t<u.length;t++)n=u[t],e.indexOf(n)>=0||(o[n]=r[n]);return o}(r,e);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(r);for(t=0;t<u.length;t++)n=u[t],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(r,n)&&(o[n]=r[n])}return o}var l=["version"];function d(r,e){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(r);e&&(t=t.filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.push.apply(n,t)}return n}function v(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?d(Object(t),!0).forEach((function(n){r(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):d(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function y(r){var e=r.version,n=f(r,l),t=function(n){return v(v({},n),{},{version:e,uniqueKey:r.uniqueKey})},o=function(e){return e.isFetching?e:v(v({},e),{},{fetchVersion:(r.fetchVersion||0)+1})};return{state:n,version:e||0,setState:function(e){return o(t("function"!=typeof e?e:e(r)))},setFetchingKey:function(e){return t(v(v({},r),{},{fetchingKey:e,finalFetchingKey:null!=e?e:r.finalFetchingKey}))},removeFetchingKey:function(e){return r.fetchingKey!==e?r:t(v(v({},r),{},{fetchingKey:void 0}))},trigger:function(){return v(v({},r),{},{version:(e||0)+1})}}}var p=function(r){return v({data:void 0,variables:void 0,isError:!1,isFetching:!1,abandon:!1,triggerType:void 0,loaded:!1,sessionLoaded:!1,cache:[]},r)};function h(r,e,n){if(!("function"==typeof r.pipe))return[y,r,n,!1];var t=o(r.effect,2),u=t[0],i=t[1].sessionType;if(null!=i&&i!==e)throw new Error("The sessionType is not matched, can not use '".concat(i," type' sessionKey with '").concat("query"===e?"useQuery":"useMutation","'"));return[r,u,n,!0]}function b(r,e){return o(h(r,"query",Array.isArray(e)?{variables:e}:e),3)[2]||{}}function g(r,e){var n=(0,a.createKey)(y,p());return n.effect=[function(){return r.apply(void 0,arguments)},e?{sessionType:e}:{}],n}var m=[],O=(0,a.createKey)((function(r){return{isFetching:r.length>0,setGlobalFetchingKey:function(e){return r.some((function(r){return r===e}))?r:r.concat(e)},removeGlobalFetchingKey:function(e){return r.some((function(r){return r===e}))?r.filter((function(r){return r!==e})):r}}}),m),j=(0,c.createContext)(null);function w(r){var e=r.value,n=r.children,t=(0,c.useMemo)((function(){return e.useGlobalFetching?O:void 0}),[]);return(0,c.createElement)(j.Provider,{value:e},t?(0,c.createElement)(a.Provider,{value:t},n):n)}function P(){return(0,c.useContext)(j)}function E(r,e){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(r);e&&(t=t.filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.push.apply(n,t)}return n}function S(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?E(Object(t),!0).forEach((function(n){r(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):E(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function F(r){return Array.isArray(r)?r:[r]}function T(r,e,n){var u=F(n.strategy),i=(0,c.useRef)(u.map((function(){return{current:void 0}})));return[function(c,a){var s,f,l=a||[],d={current:function(){return r.state},variables:l,runner:function(n){var t=r.state,o=r.setState,u=S(S({},t),{},{isFetching:!0}),i=n?n(u):u;return i.abandon||o(S(S({},i),{},{triggerType:c})),e(c,l)},triggerType:c,config:n,store:i,runtimeCache:(s=[],f=function(r){var e=s.find((function(e){return o(e,1)[0]===r}));if(Array.isArray(e))return e},{set:function(r,e){var n=f(r);n?n[1]=e:s.push([r,e])},get:function(r){var e=f(r);if(e)return e[1]}})};return function(r){return function(e){var n=[],o=e.store.current;return t(r).reverse().reduce((function(r,e,t){var u=o[t]||{current:void 0};return function(t){var o=S(S({},t),{},{store:u});return null==e?r(o):e(S(S({},o),{},{runner:function(e){return null!=e&&n.push(e),r(o)}}))}}),(function(r){return r.runner((function(r){return n.reduce((function(r,e){return r.abandon?r:e(r)}),r)}))}))(e).then((function(r){var n=e.current(),t=n.loaded,o=n.sessionLoaded,u=r.abandon,i=r.isError,c=r.isFetching,a=t||!u&&!i&&!c,s=o||!u&&!i&&!c;return S(S({},r),{},{loaded:a,sessionLoaded:s})}))}}(u)(d).then((function(e){return e.abandon||r.setState(e),e}))},u.map((function(r){if(r)return r.effect})).filter((function(r){return!!r})),u.map((function(r){if(r)return r.response})).filter((function(r){return!!r}))]}var A=["cache"];function K(r,e){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(r);e&&(t=t.filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.push.apply(n,t)}return n}function D(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?K(Object(t),!0).forEach((function(n){r(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):K(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}var M=function(r,e){return!!Object.is(r,e)||null!=r&&null!=e&&JSON.stringify(r)===JSON.stringify(e)};function q(r,e){var n=(e||{}).withAbandoned;return function(e){var t=e.runner,o=e.runtimeCache,u=e.store,i=o.get(q);return o.set(q,!0),u.current=r,t().then((function(r){var e=u.current;return!r.isError||i||!e||r.abandon&&!n||e(r.error,r),r}))}}function x(r){var e=function(r){return(0,r.runner)()};return e.response=r,e}function k(){return(new Date).getTime()}function I(r,e){var n=null==e?1:e;function u(r,e){var n=r.find((function(r){return o(r,1)[0]===e}))||[void 0,void 0];return o(n,2)[1]}return{get:function(e){if(!(n<1))return u(r,e)},set:function(e,i){if(n<1)return[];var c={data:i,lastUpdateTime:k()};if(null!=u(r,e))return r.map((function(r){var n=o(r,2),t=n[0],u=n[1];return e!==t?[t,u]:[e,c]}));var a=[].concat(t(r),[[e,c]]);return a.length>n?a.slice(a.length-n):a}}}x.success=function(r){var e=function(r){return(0,r.runner)()};return e.response=function(e){e.isError||e.isFetching||!e.sessionLoaded||r(e.data,e)},e},x.error=function(r){var e=function(r){var e=r.runner;return r.runtimeCache.set(q,!0),e()};return e.response=function(e){e.isError&&!e.isFetching&&r(e.error,e)},e},x.failure=function(r){var e=function(r){var e=r.runner;return r.runtimeCache.set(q,!0),e()};return e.response=function(e){e.isError&&!e.isFetching&&r(e.error,e)},e};var L={cache:function(r){var e=r||{},n=e.key,t=void 0===n?function(r){return JSON.stringify(r)}:n,o=e.staleTime,u=e.capacity,i=void 0===u?1:u;return function(r){var e=r.current,n=r.runner,u=r.variables,c=e(),a=c.cache,s=(f(c,A),t(u)),l=I(a,i).get(s);if(l&&o&&k()>o+l.lastUpdateTime){var d=D(D({},c),{},{data:l.data,variables:u});return Promise.resolve(d)}return n((function(r){return l&&(!o||o<0)?D(D({},r),{},{data:l.data}):r})).then((function(r){if(r.isError)return r;var e=t(r.variables||[]),n=I(r.cache,i).set(e,r.data);return D(D({},r),{},{cache:n})}))}},debounce:function(r){var e="number"==typeof r?r:r.duration,n="number"!=typeof r&&!!r.lead;return function(r){return n?function(){var n=r.current,t=r.runner,o=r.store;o.current&&o.current.id&&(clearTimeout(o.current.id),o.current.id=void 0);var u=setTimeout((function(){o.current=void 0}),e);if(null!=o.current)return o.current.id=u,o.current.promise.then((function(r){return D(D({},r),{},{abandon:!0})}));var i={id:u,version:0,resolve:function(){},promise:new Promise((function(r){r(D(D({},n()),{},{abandon:!0}))}))},c=new Promise((function(r){r(t()),i.resolve=r}));return i.promise=c,o.current=i,c}():function(){var n=r.current,t=r.runner,o=r.store;if(o.current){var u=o.current,i=u.id,c=u.resolve;clearTimeout(i),o.current.id=setTimeout((function(){o.current=void 0,c(t())}),e),o.current.version+=1;var a=o.current.version;return o.current.promise.then((function(r){var e;return a===(null===(e=o.current)||void 0===e?void 0:e.version)?r:D(D({},r),{},{abandon:!0})}))}var s={id:null,version:0,resolve:function(){},promise:new Promise((function(r){r(D(D({},n()),{},{abandon:!0}))}))},f=new Promise((function(r){s.id=setTimeout((function(){o.current=void 0,r(t())}),e),s.resolve=r}));s.promise=f,o.current=s;var l=s.version;return f.then((function(r){var e;return null!==(e=o.current)&&void 0!==e&&e.version||0===l?r:D(D({},r),{},{abandon:!0})}))}()}},throttle:function(r){var e=function(){if(null!=r)return"number"==typeof r?r:r.duration}();return function(r){var n=r.current,t=r.runner,o=r.store,u=r.variables,i=void 0===u?[]:u;o.current=o.current||{timeoutId:null,variables:void 0};var c=o.current.variables,a=o.current.timeoutId;return function(r,e){return null==r||!M(r,e)}(c,i)||null==a&&null!=e?(o.current.variables=i,null==e||(null!=a&&clearTimeout(a),o.current.timeoutId=setTimeout((function(){o.current=o.current||{},o.current.timeoutId=null}),e)),t()):new Promise((function(r){r(n())}))}},once:function(){return function(r){var e=r.runner,n=r.store;return n.current?n.current.then((function(r){return D(D({},r),{},{abandon:!0})})):(n.current=e().then((function(r){return r.isError&&(n.current=void 0),r})),n.current)}},error:q,failure:function(r,e){var n=(e||{}).withAbandoned;return function(e){var t=e.runner,o=e.runtimeCache,u=e.store,i=o.get(q);return o.set(q,!0),u.current=r,t().then((function(r){var e=u.current;return!r.isError||i||!e||r.abandon&&!n||e(r.error,r),r}))}},success:function(r,e){var n=(e||{}).withAbandoned;return function(e){var t=e.runner,o=e.store;return o.current=r,t().then((function(r){var e=o.current;return r.isError||!e||r.abandon&&!n||e(r.data,r),r}))}},validate:function(r){return function(e){var n=e.runner,t=e.current;if(!r()){var o=t();return new Promise((function(r){r(D(D({},o),{},{abandon:!0}))}))}return n()}},memo:function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:M;return function(e){var n=e.runner,t=e.current;return n().then((function(e){var n=t();return("function"==typeof r?r(n.data,e.data):n.data===e.data)?D(D({},e),{},{data:n.data}):e}))}},reduce:function(r){return function(e){var n=e.runner,t=e.current;return n().then((function(e){if(e.isError||e.abandon)return e;var n=t(),o=r(n.data,e.data,[n,e]);return D(D({},e),{},{data:o})}))}},response:x};function C(r,e){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(r);e&&(t=t.filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.push.apply(n,t)}return n}function V(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?C(Object(t),!0).forEach((function(n){r(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):C(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function G(r,e){var n=(0,c.useRef)({}),u=function(r,e,n){var u=Array.isArray(n)?{variables:n}:n,i=o(h(r,"query",u),4),c=i[0],s=i[1],f=i[2],l=i[3],d=f||{},v=d.defaultData,y=d.loaded,b=Object.prototype.hasOwnProperty.call(d,"defaultData"),g=l?b?[c,p({data:v,uniqueKey:r,loaded:!0})]:[c]:[c,p(b?{data:v,uniqueKey:e,loaded:!0}:void 0)],m=a.useModel.apply(void 0,t(g));if(y&&!m.state.loaded)throw new Error('This session is not loaded, you should remove "config.loaded" option.');return[m,d,s]}(r,n.current,e),i=o(u,3),f=i[0],l=i[1],d=i[2],v=l.variables,y=l.deps,b=l.triggerOn,g=void 0===b?["mount","update","manual"]:b,j=(0,a.useRealtimeInstance)(f),w=(0,a.useModel)(O,m,{autoLink:!0}),P=w.setGlobalFetchingKey,E=w.removeGlobalFetchingKey,S=T(j,(function(r,e){var o=function(r){return function(e){var n=r(e);if(!n||"function"!=typeof n.then)throw new Error("The callback have to return a promise object.");return n.then((function(r){return{data:r,variables:e,error:void 0,isError:!1}}),(function(r){return{variables:e,error:r,isError:!0}}))}}((function(r){return d.apply(void 0,t(r))}));return o(e).then((function(e){var t=null!=j.state.finalFetchingKey&&n.current!==j.state.finalFetchingKey;return V(V(V({},j.state),e),{},{abandon:t,isFetching:!1,triggerType:r})}))}),l),F=o(S,3),A=F[0],K=F[1],D=F[2],M=function(r,e){var t=j.state.fetchingKey;return g.indexOf(r)<0||t&&t!==n.current?new Promise((function(r){r(V(V({},j.state),{},{abandon:!0}))})):(j.setFetchingKey(n.current),Promise.resolve(void 0).then((function(){j.removeFetchingKey(n.current)})),A(r,e||v))},q=(0,s.usePersistFn)((function(){return M("manual")})),x=(0,s.usePersistFn)((function(){for(var r=arguments.length,e=new Array(r),n=0;n<r;n++)e[n]=arguments[n];return M("manual",e)})),k=y||v||[];(0,s.useMount)((function(){M("mount")})),(0,s.useUpdate)((function(){M("update")}),k);var I=(0,c.useRef)(f.version);return(0,c.useEffect)((function(){if(I.current!==f.version){I.current=f.version;var r=j.state.fetchingKey;r&&r!==n.current||q()}}),[f.version]),(0,c.useEffect)((function(){f.state.isFetching?P(n.current):E(n.current)}),[f.state.isFetching]),(0,s.useUnmount)((function(){E(n.current),j.removeFetchingKey(n.current)})),(0,c.useEffect)((function(){K.forEach((function(r){r(f.state)}))}),[f.state]),(0,c.useEffect)((function(){null!=f.state.fetchVersion&&D.forEach((function(r){r(f.state)}))}),[f.state.fetchVersion]),[f.state,q,x]}function R(r,e){var n=b(r,e),t=n.variables,o=n.deps,u=n.manual,i=n.triggerOn,c=void 0===i?["mount","update","manual"]:i,a=n.strategy,s=!o&&!t||u?["manual"]:c,f=(P()||{}).strategy,l=F(a),d=f?f(l,"query"):l;return G(r,V(V({},n),{},{triggerOn:s,strategy:d.concat((function(r){var e=r.runner,n=r.store;n.current=n.current||0;var t=n.current+1;return n.current=t,e().then((function(r){return n.current!==t?S(S({},r),{},{abandon:!0}):r}))}))}))}function Q(r,e){var n=b(r,e),t=n.triggerOn,o=void 0===t?["manual"]:t,u=n.strategy,i=(P()||{}).strategy,c=F(u),a=i?i(c,"mutation"):c;return G(r,V(V({},n),{},{triggerOn:o,strategy:a.concat((function(r){var e=r.runner,n=r.store;if("manual"!==r.triggerType)return e();if(n.current)return n.current.then((function(r){return S(S({},r),{},{abandon:!0})}));var t=e();return n.current=t.then((function(r){return n.current=void 0,r})),t}))}))}function U(r,e){var n=o(r.effect,2)[1].sessionType,t=(0,a.useSelector)(r,(function(r){return[r.state,r.trigger]})),u="string"==typeof e?{sessionType:e,loaded:void 0}:e||{},i=u.loaded,c=u.sessionType,s=o(t,1)[0].loaded;if(c&&n&&c!==n)throw new Error("The sessionType is not matched, can not use '".concat(n," type' sessionKey with '").concat(c," type' useSession."));if(i&&!s)throw new Error("The session is not loaded yet, check config, and set {loaded: undefined}.");return t}function J(){for(var r=arguments.length,e=new Array(r),n=0;n<r;n++)e[n]=arguments[n];var t=(0,c.useMemo)((function(){return e.map((function(r){return Array.isArray(r)?o(r,1)[0]:r})).some((function(r){return r.isFetching}))}),e),u=(0,a.useIsModelMatchedInStore)(O),i=(0,a.useModel)(O,m,{autoLink:!0}).isFetching;if(!u&&!e.length)throw new Error("You should provide a `GlobalRefreshProvider` to support a global `isFetching` detect.");return u&&!e.length?i:t}function N(r){for(var e=arguments.length,n=new Array(e>1?e-1:0),u=1;u<e;u++)n[u-1]=arguments[u];var i=(0,c.useMemo)((function(){return n.map((function(r){var e={loaded:!1};return e.promise=new Promise((function(r,n){e.resolve=r,e.reject=n})),e}))}),[]),a=(0,c.useRef)(i);function s(r){return r.default?r:{default:r}}return(0,c.useEffect)((function(){var r=a.current;n.forEach((function(e,n){var t=Array.isArray(e)?e[0]:e,o=r[n];if(t.isError&&!o.loaded)return o.loaded=!0,void o.reject(t);t.loaded&&!o.loaded&&(o.loaded=!0,o.resolve(!0))}))}),[].concat(n)),(0,c.useMemo)((function(){var e=a.current.map((function(r){return r.promise}));return(0,c.lazy)((function(){var n=r();return Promise.all([n].concat(t(e))).then((function(r){return s(o(r,1)[0])}),(function(r){return n.then((function(e){var n=function(r){var e=r;return e.default&&"function"==typeof e.default?e.default:r}(e),t=function(r,e){return function(n){return(0,c.createElement)(r,V(V({},n),{},{error:e}))}}(n,r);return s(t)}))}))}))}),[])}function z(r,e){return U(r,"string"==typeof e?{sessionType:e,loaded:!0}:V(V({},e),{},{loaded:!0}))}function _(r,e){(0,c.useEffect)((function(){if(null!=e.fetchVersion){var n=!e.isFetching&&e.isError,t=!e.isFetching&&e.sessionLoaded&&!e.isError;(n||t)&&r(e)}}),[e.fetchVersion])}_.useSuccess=function(r,e){(0,c.useEffect)((function(){null!=e.fetchVersion&&(!e.isFetching&&e.sessionLoaded&&!e.isError&&r(e.data,e))}),[e.fetchVersion])},_.useFailure=function(r,e){(0,c.useEffect)((function(){null!=e.fetchVersion&&(!e.isFetching&&e.isError&&r(e.error,e))}),[e.fetchVersion])},_.success=_.useSuccess,_.error=_.useFailure;var Y=a.Provider,$=a.Provider,B=a.provide,H=function(r,e){var n=e,o=function(){return r.apply(void 0,arguments)},u=function r(e){var u=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=null!=e?e:g(o,n),a={key:i,with:function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];var o=u.concat(n.map((function(r){return"function"==typeof r?r:r.key})));return r(i,o)},asGlobal:function(){var r=i.global(),e={useSession:function(){return U(r,n)},useLoadedSession:function(){return z(r,n)}};return V(V({},e),{},"query"===n?{useQuery:function(e){return R(r,e)}}:{useMutation:function(e){return Q(r,e)}})},useSession:function(){return U(i,n)},useLoadedSession:function(){return z(i,n)},provide:function(){return B([i].concat(t(u)))},provideTo:function(r){return B([i].concat(t(u)))(r)},Provider:function(r){var e=r.children;return(0,c.createElement)($,{value:[i].concat(t(u))},e)}};return V(V({},a),{},"query"===n?{useQuery:function(r){return R(i,r)}}:{useMutation:function(r){return Q(i,r)}})},i={store:u,createStore:u},a=V(V({},i),{},{useQuery:function(r){return R(o,r)}}),s=V(V({},i),{},{useMutation:function(r){return Q(o,r)}}),f="query"===n?a:s;return Object.assign(o,f)}}(),i}()}));

@@ -11,3 +11,2 @@ import { ModelKeys, ModelKey, AirReducer } from '@airma/react-state';

} from 'react';
import { KeyBy } from './src/libs/type';

@@ -97,11 +96,2 @@ declare type TriggerType = 'mount' | 'update' | 'manual';

export type KeyBy<C extends PromiseCallback<any>> = (
variables: Parameters<C>
) => string;
export type CacheType<C extends PromiseCallback<any>> =
| { key?: KeyBy<C> | 'default'; staleTime?: number; capacity?: number }
| KeyBy<C>
| 'default';
declare type QueryConfig<T, C extends PromiseCallback<T>> = {

@@ -374,2 +364,7 @@ deps?: any[];

export declare const Strategy: {
cache: <T = any, V extends any[] = any[]>(op?: {
key?: (vars: V) => string;
staleTime?: number;
capacity?: number;
}) => StrategyType<T, V>;
debounce: <T = any, V extends any[] = any[]>(

@@ -532,3 +527,3 @@ op: { duration: number; lead?: boolean } | number

sessionCallback: D,
sessionType: 'query' | { sessionType: 'query'; cache?: CacheType<D> }
sessionType: 'query'
): {

@@ -545,3 +540,3 @@ (...p: Parameters<D>): ReturnType<D>;

sessionCallback: D,
sessionType: 'mutation' | { sessionType: 'mutation'; cache?: CacheType<D> }
sessionType: 'mutation'
): {

@@ -548,0 +543,0 @@ (...p: Parameters<D>): ReturnType<D>;

{
"private": false,
"name": "@airma/react-effect",
"version": "18.3.0-alpha.10",
"version": "18.3.0-alpha.11",
"description": "This is a react async state management tool",

@@ -28,4 +28,4 @@ "license": "MIT",

"dependencies": {
"@airma/react-hooks-core": "^18.3.0-alpha.10",
"@airma/react-state": "^18.3.0-alpha.10",
"@airma/react-hooks-core": "^18.3.0-alpha.11",
"@airma/react-state": "^18.3.0-alpha.11",
"react": ">=16.8.0"

@@ -32,0 +32,0 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc