@airma/react-effect
Advanced tools
Comparing version 15.0.0 to 15.1.0
@@ -1,1 +0,1 @@ | ||
!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n(require("react")):"function"==typeof define&&define.amd?define(["react"],n):"object"==typeof exports?exports["@airma/react-effect"]=n(require("react")):t["@airma/react-effect"]=n(t.react)}(self,(function(t){return function(){var n={4933:function(t,n,r){var e=r(6291),o=r(7073),i=TypeError;t.exports=function(t){if(e(t))return t;throw i(o(t)+" is not a function")}},8209:function(t,n,r){var e=r(1814),o=r(7073),i=TypeError;t.exports=function(t){if(e(t))return t;throw i(o(t)+" is not a constructor")}},9076:function(t,n,r){var e=r(6291),o=String,i=TypeError;t.exports=function(t){if("object"==typeof t||e(t))return t;throw i("Can't set "+o(t)+" as a prototype")}},2814:function(t,n,r){var e=r(6282),o=TypeError;t.exports=function(t,n){if(e(n,t))return t;throw o("Incorrect invocation")}},4905:function(t,n,r){var e=r(2366),o=String,i=TypeError;t.exports=function(t){if(e(t))return t;throw i(o(t)+" is not an object")}},5029:function(t,n,r){var e=r(678),o=r(6971),i=r(4821),u=function(t){return function(n,r,u){var c,a=e(n),f=i(a),s=o(u,f);if(t&&r!=r){for(;f>s;)if((c=a[s++])!=c)return!0}else for(;f>s;s++)if((t||s in a)&&a[s]===r)return t||s||0;return!t&&-1}};t.exports={includes:u(!0),indexOf:u(!1)}},650:function(t,n,r){var e=r(936);t.exports=e([].slice)},3165:function(t,n,r){var e=r(6802)("iterator"),o=!1;try{var i=0,u={next:function(){return{done:!!i++}},return:function(){o=!0}};u[e]=function(){return this},Array.from(u,(function(){throw 2}))}catch(t){}t.exports=function(t,n){if(!n&&!o)return!1;var r=!1;try{var i={};i[e]=function(){return{next:function(){return{done:r=!0}}}},t(i)}catch(t){}return r}},5489:function(t,n,r){var e=r(936),o=e({}.toString),i=e("".slice);t.exports=function(t){return i(o(t),8,-1)}},486:function(t,n,r){var e=r(8171),o=r(6291),i=r(5489),u=r(6802)("toStringTag"),c=Object,a="Arguments"==i(function(){return arguments}());t.exports=e?i:function(t){var n,r,e;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(r=function(t,n){try{return t[n]}catch(t){}}(n=c(t),u))?r:a?i(n):"Object"==(e=i(n))&&o(n.callee)?"Arguments":e}},6810:function(t,n,r){var e=r(8382),o=r(2466),i=r(8117),u=r(6462);t.exports=function(t,n,r){for(var c=o(n),a=u.f,f=i.f,s=0;s<c.length;s++){var p=c[s];e(t,p)||r&&e(r,p)||a(t,p,f(n,p))}}},430:function(t,n,r){var e=r(1502),o=r(6462),i=r(6034);t.exports=e?function(t,n,r){return o.f(t,n,i(1,r))}:function(t,n,r){return t[n]=r,t}},6034:function(t){t.exports=function(t,n){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:n}}},5850:function(t,n,r){var e=r(6291),o=r(6462),i=r(7192),u=r(1756);t.exports=function(t,n,r,c){c||(c={});var a=c.enumerable,f=void 0!==c.name?c.name:n;if(e(r)&&i(r,f,c),c.global)a?t[n]=r:u(n,r);else{try{c.unsafe?t[n]&&(a=!0):delete t[n]}catch(t){}a?t[n]=r:o.f(t,n,{value:r,enumerable:!1,configurable:!c.nonConfigurable,writable:!c.nonWritable})}return t}},1756:function(t,n,r){var e=r(5001),o=Object.defineProperty;t.exports=function(t,n){try{o(e,t,{value:n,configurable:!0,writable:!0})}catch(r){e[t]=n}return n}},1502:function(t,n,r){var e=r(5061);t.exports=!e((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}))},5178:function(t){var n="object"==typeof document&&document.all,r=void 0===n&&void 0!==n;t.exports={all:n,IS_HTMLDDA:r}},6009:function(t,n,r){var e=r(5001),o=r(2366),i=e.document,u=o(i)&&o(i.createElement);t.exports=function(t){return u?i.createElement(t):{}}},6837:function(t,n,r){var e=r(5065),o=r(566);t.exports=!e&&!o&&"object"==typeof window&&"object"==typeof document},5065:function(t){t.exports="object"==typeof Deno&&Deno&&"object"==typeof Deno.version},1368:function(t,n,r){var e=r(9966),o=r(5001);t.exports=/ipad|iphone|ipod/i.test(e)&&void 0!==o.Pebble},311:function(t,n,r){var e=r(9966);t.exports=/(?:ipad|iphone|ipod).*applewebkit/i.test(e)},566:function(t,n,r){var e=r(5489),o=r(5001);t.exports="process"==e(o.process)},4832:function(t,n,r){var e=r(9966);t.exports=/web0s(?!.*chrome)/i.test(e)},9966:function(t,n,r){var e=r(3425);t.exports=e("navigator","userAgent")||""},2821:function(t,n,r){var e,o,i=r(5001),u=r(9966),c=i.process,a=i.Deno,f=c&&c.versions||a&&a.version,s=f&&f.v8;s&&(o=(e=s.split("."))[0]>0&&e[0]<4?1:+(e[0]+e[1])),!o&&u&&(!(e=u.match(/Edge\/(\d+)/))||e[1]>=74)&&(e=u.match(/Chrome\/(\d+)/))&&(o=+e[1]),t.exports=o},2089:function(t){t.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},9638:function(t,n,r){var e=r(5001),o=r(8117).f,i=r(430),u=r(5850),c=r(1756),a=r(6810),f=r(1092);t.exports=function(t,n){var r,s,p,l,v,h=t.target,d=t.global,y=t.stat;if(r=d?e:y?e[h]||c(h,{}):(e[h]||{}).prototype)for(s in n){if(l=n[s],p=t.dontCallGetSet?(v=o(r,s))&&v.value:r[s],!f(d?s:h+(y?".":"#")+s,t.forced)&&void 0!==p){if(typeof l==typeof p)continue;a(l,p)}(t.sham||p&&p.sham)&&i(l,"sham",!0),u(r,s,l,t)}}},5061:function(t){t.exports=function(t){try{return!!t()}catch(t){return!0}}},5494:function(t,n,r){var e=r(8483),o=Function.prototype,i=o.apply,u=o.call;t.exports="object"==typeof Reflect&&Reflect.apply||(e?u.bind(i):function(){return u.apply(i,arguments)})},9918:function(t,n,r){var e=r(1017),o=r(4933),i=r(8483),u=e(e.bind);t.exports=function(t,n){return o(t),void 0===n?t:i?u(t,n):function(){return t.apply(n,arguments)}}},8483:function(t,n,r){var e=r(5061);t.exports=!e((function(){var t=function(){}.bind();return"function"!=typeof t||t.hasOwnProperty("prototype")}))},3927:function(t,n,r){var e=r(8483),o=Function.prototype.call;t.exports=e?o.bind(o):function(){return o.apply(o,arguments)}},9873:function(t,n,r){var e=r(1502),o=r(8382),i=Function.prototype,u=e&&Object.getOwnPropertyDescriptor,c=o(i,"name"),a=c&&"something"===function(){}.name,f=c&&(!e||e&&u(i,"name").configurable);t.exports={EXISTS:c,PROPER:a,CONFIGURABLE:f}},1017:function(t,n,r){var e=r(5489),o=r(936);t.exports=function(t){if("Function"===e(t))return o(t)}},936:function(t,n,r){var e=r(8483),o=Function.prototype,i=o.call,u=e&&o.bind.bind(i,i);t.exports=e?u:function(t){return function(){return i.apply(t,arguments)}}},3425:function(t,n,r){var e=r(5001),o=r(6291),i=function(t){return o(t)?t:void 0};t.exports=function(t,n){return arguments.length<2?i(e[t]):e[t]&&e[t][n]}},6354:function(t,n,r){var e=r(486),o=r(3815),i=r(860),u=r(501),c=r(6802)("iterator");t.exports=function(t){if(!i(t))return o(t,c)||o(t,"@@iterator")||u[e(t)]}},8437:function(t,n,r){var e=r(3927),o=r(4933),i=r(4905),u=r(7073),c=r(6354),a=TypeError;t.exports=function(t,n){var r=arguments.length<2?c(t):n;if(o(r))return i(e(r,t));throw a(u(t)+" is not iterable")}},3815:function(t,n,r){var e=r(4933),o=r(860);t.exports=function(t,n){var r=t[n];return o(r)?void 0:e(r)}},5001:function(t,n,r){var e=function(t){return t&&t.Math==Math&&t};t.exports=e("object"==typeof globalThis&&globalThis)||e("object"==typeof window&&window)||e("object"==typeof self&&self)||e("object"==typeof r.g&&r.g)||function(){return this}()||Function("return this")()},8382:function(t,n,r){var e=r(936),o=r(7615),i=e({}.hasOwnProperty);t.exports=Object.hasOwn||function(t,n){return i(o(t),n)}},2499:function(t){t.exports={}},3455:function(t,n,r){var e=r(5001);t.exports=function(t,n){var r=e.console;r&&r.error&&(1==arguments.length?r.error(t):r.error(t,n))}},2118:function(t,n,r){var e=r(3425);t.exports=e("document","documentElement")},7788:function(t,n,r){var e=r(1502),o=r(5061),i=r(6009);t.exports=!e&&!o((function(){return 7!=Object.defineProperty(i("div"),"a",{get:function(){return 7}}).a}))},2901:function(t,n,r){var e=r(936),o=r(5061),i=r(5489),u=Object,c=e("".split);t.exports=o((function(){return!u("z").propertyIsEnumerable(0)}))?function(t){return"String"==i(t)?c(t,""):u(t)}:u},685:function(t,n,r){var e=r(936),o=r(6291),i=r(9982),u=e(Function.toString);o(i.inspectSource)||(i.inspectSource=function(t){return u(t)}),t.exports=i.inspectSource},684:function(t,n,r){var e,o,i,u=r(1899),c=r(5001),a=r(2366),f=r(430),s=r(8382),p=r(9982),l=r(1695),v=r(2499),h="Object already initialized",d=c.TypeError,y=c.WeakMap;if(u||p.state){var b=p.state||(p.state=new y);b.get=b.get,b.has=b.has,b.set=b.set,e=function(t,n){if(b.has(t))throw d(h);return n.facade=t,b.set(t,n),n},o=function(t){return b.get(t)||{}},i=function(t){return b.has(t)}}else{var m=l("state");v[m]=!0,e=function(t,n){if(s(t,m))throw d(h);return n.facade=t,f(t,m,n),n},o=function(t){return s(t,m)?t[m]:{}},i=function(t){return s(t,m)}}t.exports={set:e,get:o,has:i,enforce:function(t){return i(t)?o(t):e(t,{})},getterFor:function(t){return function(n){var r;if(!a(n)||(r=o(n)).type!==t)throw d("Incompatible receiver, "+t+" required");return r}}}},5557:function(t,n,r){var e=r(6802),o=r(501),i=e("iterator"),u=Array.prototype;t.exports=function(t){return void 0!==t&&(o.Array===t||u[i]===t)}},6291:function(t,n,r){var e=r(5178),o=e.all;t.exports=e.IS_HTMLDDA?function(t){return"function"==typeof t||t===o}:function(t){return"function"==typeof t}},1814:function(t,n,r){var e=r(936),o=r(5061),i=r(6291),u=r(486),c=r(3425),a=r(685),f=function(){},s=[],p=c("Reflect","construct"),l=/^\s*(?:class|function)\b/,v=e(l.exec),h=!l.exec(f),d=function(t){if(!i(t))return!1;try{return p(f,s,t),!0}catch(t){return!1}},y=function(t){if(!i(t))return!1;switch(u(t)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return h||!!v(l,a(t))}catch(t){return!0}};y.sham=!0,t.exports=!p||o((function(){var t;return d(d.call)||!d(Object)||!d((function(){t=!0}))||t}))?y:d},1092:function(t,n,r){var e=r(5061),o=r(6291),i=/#|\.prototype\./,u=function(t,n){var r=a[c(t)];return r==s||r!=f&&(o(n)?e(n):!!n)},c=u.normalize=function(t){return String(t).replace(i,".").toLowerCase()},a=u.data={},f=u.NATIVE="N",s=u.POLYFILL="P";t.exports=u},860:function(t){t.exports=function(t){return null==t}},2366:function(t,n,r){var e=r(6291),o=r(5178),i=o.all;t.exports=o.IS_HTMLDDA?function(t){return"object"==typeof t?null!==t:e(t)||t===i}:function(t){return"object"==typeof t?null!==t:e(t)}},13:function(t){t.exports=!1},6448:function(t,n,r){var e=r(3425),o=r(6291),i=r(6282),u=r(7558),c=Object;t.exports=u?function(t){return"symbol"==typeof t}:function(t){var n=e("Symbol");return o(n)&&i(n.prototype,c(t))}},8971:function(t,n,r){var e=r(9918),o=r(3927),i=r(4905),u=r(7073),c=r(5557),a=r(4821),f=r(6282),s=r(8437),p=r(6354),l=r(9200),v=TypeError,h=function(t,n){this.stopped=t,this.result=n},d=h.prototype;t.exports=function(t,n,r){var y,b,m,g,x,w,j,O=r&&r.that,S=!(!r||!r.AS_ENTRIES),E=!(!r||!r.IS_RECORD),P=!(!r||!r.IS_ITERATOR),T=!(!r||!r.INTERRUPTED),C=e(n,O),R=function(t){return y&&l(y,"normal",t),new h(!0,t)},A=function(t){return S?(i(t),T?C(t[0],t[1],R):C(t[0],t[1])):T?C(t,R):C(t)};if(E)y=t.iterator;else if(P)y=t;else{if(!(b=p(t)))throw v(u(t)+" is not iterable");if(c(b)){for(m=0,g=a(t);g>m;m++)if((x=A(t[m]))&&f(d,x))return x;return new h(!1)}y=s(t,b)}for(w=E?t.next:y.next;!(j=o(w,y)).done;){try{x=A(j.value)}catch(t){l(y,"throw",t)}if("object"==typeof x&&x&&f(d,x))return x}return new h(!1)}},9200:function(t,n,r){var e=r(3927),o=r(4905),i=r(3815);t.exports=function(t,n,r){var u,c;o(t);try{if(!(u=i(t,"return"))){if("throw"===n)throw r;return r}u=e(u,t)}catch(t){c=!0,u=t}if("throw"===n)throw r;if(c)throw u;return o(u),r}},501:function(t){t.exports={}},4821:function(t,n,r){var e=r(4479);t.exports=function(t){return e(t.length)}},7192:function(t,n,r){var e=r(5061),o=r(6291),i=r(8382),u=r(1502),c=r(9873).CONFIGURABLE,a=r(685),f=r(684),s=f.enforce,p=f.get,l=Object.defineProperty,v=u&&!e((function(){return 8!==l((function(){}),"length",{value:8}).length})),h=String(String).split("String"),d=t.exports=function(t,n,r){"Symbol("===String(n).slice(0,7)&&(n="["+String(n).replace(/^Symbol\(([^)]*)\)/,"$1")+"]"),r&&r.getter&&(n="get "+n),r&&r.setter&&(n="set "+n),(!i(t,"name")||c&&t.name!==n)&&(u?l(t,"name",{value:n,configurable:!0}):t.name=n),v&&r&&i(r,"arity")&&t.length!==r.arity&&l(t,"length",{value:r.arity});try{r&&i(r,"constructor")&&r.constructor?u&&l(t,"prototype",{writable:!1}):t.prototype&&(t.prototype=void 0)}catch(t){}var e=s(t);return i(e,"source")||(e.source=h.join("string"==typeof n?n:"")),t};Function.prototype.toString=d((function(){return o(this)&&p(this).source||a(this)}),"toString")},1367:function(t){var n=Math.ceil,r=Math.floor;t.exports=Math.trunc||function(t){var e=+t;return(e>0?r:n)(e)}},3690:function(t,n,r){var e,o,i,u,c,a,f,s,p=r(5001),l=r(9918),v=r(8117).f,h=r(8680).set,d=r(311),y=r(1368),b=r(4832),m=r(566),g=p.MutationObserver||p.WebKitMutationObserver,x=p.document,w=p.process,j=p.Promise,O=v(p,"queueMicrotask"),S=O&&O.value;S||(e=function(){var t,n;for(m&&(t=w.domain)&&t.exit();o;){n=o.fn,o=o.next;try{n()}catch(t){throw o?u():i=void 0,t}}i=void 0,t&&t.enter()},d||m||b||!g||!x?!y&&j&&j.resolve?((f=j.resolve(void 0)).constructor=j,s=l(f.then,f),u=function(){s(e)}):m?u=function(){w.nextTick(e)}:(h=l(h,p),u=function(){h(e)}):(c=!0,a=x.createTextNode(""),new g(e).observe(a,{characterData:!0}),u=function(){a.data=c=!c})),t.exports=S||function(t){var n={fn:t,next:void 0};i&&(i.next=n),o||(o=n,u()),i=n}},7714:function(t,n,r){"use strict";var e=r(4933),o=TypeError,i=function(t){var n,r;this.promise=new t((function(t,e){if(void 0!==n||void 0!==r)throw o("Bad Promise constructor");n=t,r=e})),this.resolve=e(n),this.reject=e(r)};t.exports.f=function(t){return new i(t)}},6462:function(t,n,r){var e=r(1502),o=r(7788),i=r(5780),u=r(4905),c=r(1030),a=TypeError,f=Object.defineProperty,s=Object.getOwnPropertyDescriptor,p="enumerable",l="configurable",v="writable";n.f=e?i?function(t,n,r){if(u(t),n=c(n),u(r),"function"==typeof t&&"prototype"===n&&"value"in r&&v in r&&!r.writable){var e=s(t,n);e&&e.writable&&(t[n]=r.value,r={configurable:l in r?r.configurable:e.configurable,enumerable:p in r?r.enumerable:e.enumerable,writable:!1})}return f(t,n,r)}:f:function(t,n,r){if(u(t),n=c(n),u(r),o)try{return f(t,n,r)}catch(t){}if("get"in r||"set"in r)throw a("Accessors not supported");return"value"in r&&(t[n]=r.value),t}},8117:function(t,n,r){var e=r(1502),o=r(3927),i=r(9265),u=r(6034),c=r(678),a=r(1030),f=r(8382),s=r(7788),p=Object.getOwnPropertyDescriptor;n.f=e?p:function(t,n){if(t=c(t),n=a(n),s)try{return p(t,n)}catch(t){}if(f(t,n))return u(!o(i.f,t,n),t[n])}},9219:function(t,n,r){var e=r(3855),o=r(2089).concat("length","prototype");n.f=Object.getOwnPropertyNames||function(t){return e(t,o)}},2822:function(t,n){n.f=Object.getOwnPropertySymbols},6282:function(t,n,r){var e=r(936);t.exports=e({}.isPrototypeOf)},3855:function(t,n,r){var e=r(936),o=r(8382),i=r(678),u=r(5029).indexOf,c=r(2499),a=e([].push);t.exports=function(t,n){var r,e=i(t),f=0,s=[];for(r in e)!o(c,r)&&o(e,r)&&a(s,r);for(;n.length>f;)o(e,r=n[f++])&&(~u(s,r)||a(s,r));return s}},9265:function(t,n){"use strict";var r={}.propertyIsEnumerable,e=Object.getOwnPropertyDescriptor,o=e&&!r.call({1:2},1);n.f=o?function(t){var n=e(this,t);return!!n&&n.enumerable}:r},2848:function(t,n,r){var e=r(936),o=r(4905),i=r(9076);t.exports=Object.setPrototypeOf||("__proto__"in{}?function(){var t,n=!1,r={};try{(t=e(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set))(r,[]),n=r instanceof Array}catch(t){}return function(r,e){return o(r),i(e),n?t(r,e):r.__proto__=e,r}}():void 0)},379:function(t,n,r){var e=r(3927),o=r(6291),i=r(2366),u=TypeError;t.exports=function(t,n){var r,c;if("string"===n&&o(r=t.toString)&&!i(c=e(r,t)))return c;if(o(r=t.valueOf)&&!i(c=e(r,t)))return c;if("string"!==n&&o(r=t.toString)&&!i(c=e(r,t)))return c;throw u("Can't convert object to primitive value")}},2466:function(t,n,r){var e=r(3425),o=r(936),i=r(9219),u=r(2822),c=r(4905),a=o([].concat);t.exports=e("Reflect","ownKeys")||function(t){var n=i.f(c(t)),r=u.f;return r?a(n,r(t)):n}},7040:function(t){t.exports=function(t){try{return{error:!1,value:t()}}catch(t){return{error:!0,value:t}}}},8410:function(t,n,r){var e=r(5001),o=r(7883),i=r(6291),u=r(1092),c=r(685),a=r(6802),f=r(6837),s=r(5065),p=r(13),l=r(2821),v=o&&o.prototype,h=a("species"),d=!1,y=i(e.PromiseRejectionEvent),b=u("Promise",(function(){var t=c(o),n=t!==String(o);if(!n&&66===l)return!0;if(p&&(!v.catch||!v.finally))return!0;if(!l||l<51||!/native code/.test(t)){var r=new o((function(t){t(1)})),e=function(t){t((function(){}),(function(){}))};if((r.constructor={})[h]=e,!(d=r.then((function(){}))instanceof e))return!0}return!n&&(f||s)&&!y}));t.exports={CONSTRUCTOR:b,REJECTION_EVENT:y,SUBCLASSING:d}},7883:function(t,n,r){var e=r(5001);t.exports=e.Promise},7504:function(t,n,r){var e=r(4905),o=r(2366),i=r(7714);t.exports=function(t,n){if(e(t),o(n)&&n.constructor===t)return n;var r=i.f(t);return(0,r.resolve)(n),r.promise}},3653:function(t,n,r){var e=r(7883),o=r(3165),i=r(8410).CONSTRUCTOR;t.exports=i||!o((function(t){e.all(t).then(void 0,(function(){}))}))},8791:function(t){var n=function(){this.head=null,this.tail=null};n.prototype={add:function(t){var n={item:t,next:null};this.head?this.tail.next=n:this.head=n,this.tail=n},get:function(){var t=this.head;if(t)return this.head=t.next,this.tail===t&&(this.tail=null),t.item}},t.exports=n},4475:function(t,n,r){var e=r(860),o=TypeError;t.exports=function(t){if(e(t))throw o("Can't call method on "+t);return t}},3126:function(t,n,r){"use strict";var e=r(3425),o=r(6462),i=r(6802),u=r(1502),c=i("species");t.exports=function(t){var n=e(t),r=o.f;u&&n&&!n[c]&&r(n,c,{configurable:!0,get:function(){return this}})}},606:function(t,n,r){var e=r(6462).f,o=r(8382),i=r(6802)("toStringTag");t.exports=function(t,n,r){t&&!r&&(t=t.prototype),t&&!o(t,i)&&e(t,i,{configurable:!0,value:n})}},1695:function(t,n,r){var e=r(6809),o=r(1050),i=e("keys");t.exports=function(t){return i[t]||(i[t]=o(t))}},9982:function(t,n,r){var e=r(5001),o=r(1756),i="__core-js_shared__",u=e[i]||o(i,{});t.exports=u},6809:function(t,n,r){var e=r(13),o=r(9982);(t.exports=function(t,n){return o[t]||(o[t]=void 0!==n?n:{})})("versions",[]).push({version:"3.26.1",mode:e?"pure":"global",copyright:"© 2014-2022 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.26.1/LICENSE",source:"https://github.com/zloirock/core-js"})},3571:function(t,n,r){var e=r(4905),o=r(8209),i=r(860),u=r(6802)("species");t.exports=function(t,n){var r,c=e(t).constructor;return void 0===c||i(r=e(c)[u])?n:o(r)}},5947:function(t,n,r){var e=r(2821),o=r(5061);t.exports=!!Object.getOwnPropertySymbols&&!o((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&e&&e<41}))},8680:function(t,n,r){var e,o,i,u,c=r(5001),a=r(5494),f=r(9918),s=r(6291),p=r(8382),l=r(5061),v=r(2118),h=r(650),d=r(6009),y=r(7427),b=r(311),m=r(566),g=c.setImmediate,x=c.clearImmediate,w=c.process,j=c.Dispatch,O=c.Function,S=c.MessageChannel,E=c.String,P=0,T={},C="onreadystatechange";try{e=c.location}catch(t){}var R=function(t){if(p(T,t)){var n=T[t];delete T[t],n()}},A=function(t){return function(){R(t)}},I=function(t){R(t.data)},_=function(t){c.postMessage(E(t),e.protocol+"//"+e.host)};g&&x||(g=function(t){y(arguments.length,1);var n=s(t)?t:O(t),r=h(arguments,1);return T[++P]=function(){a(n,void 0,r)},o(P),P},x=function(t){delete T[t]},m?o=function(t){w.nextTick(A(t))}:j&&j.now?o=function(t){j.now(A(t))}:S&&!b?(u=(i=new S).port2,i.port1.onmessage=I,o=f(u.postMessage,u)):c.addEventListener&&s(c.postMessage)&&!c.importScripts&&e&&"file:"!==e.protocol&&!l(_)?(o=_,c.addEventListener("message",I,!1)):o=C in d("script")?function(t){v.appendChild(d("script")).onreadystatechange=function(){v.removeChild(this),R(t)}}:function(t){setTimeout(A(t),0)}),t.exports={set:g,clear:x}},6971:function(t,n,r){var e=r(9398),o=Math.max,i=Math.min;t.exports=function(t,n){var r=e(t);return r<0?o(r+n,0):i(r,n)}},678:function(t,n,r){var e=r(2901),o=r(4475);t.exports=function(t){return e(o(t))}},9398:function(t,n,r){var e=r(1367);t.exports=function(t){var n=+t;return n!=n||0===n?0:e(n)}},4479:function(t,n,r){var e=r(9398),o=Math.min;t.exports=function(t){return t>0?o(e(t),9007199254740991):0}},7615:function(t,n,r){var e=r(4475),o=Object;t.exports=function(t){return o(e(t))}},6973:function(t,n,r){var e=r(3927),o=r(2366),i=r(6448),u=r(3815),c=r(379),a=r(6802),f=TypeError,s=a("toPrimitive");t.exports=function(t,n){if(!o(t)||i(t))return t;var r,a=u(t,s);if(a){if(void 0===n&&(n="default"),r=e(a,t,n),!o(r)||i(r))return r;throw f("Can't convert object to primitive value")}return void 0===n&&(n="number"),c(t,n)}},1030:function(t,n,r){var e=r(6973),o=r(6448);t.exports=function(t){var n=e(t,"string");return o(n)?n:n+""}},8171:function(t,n,r){var e={};e[r(6802)("toStringTag")]="z",t.exports="[object z]"===String(e)},7073:function(t){var n=String;t.exports=function(t){try{return n(t)}catch(t){return"Object"}}},1050:function(t,n,r){var e=r(936),o=0,i=Math.random(),u=e(1..toString);t.exports=function(t){return"Symbol("+(void 0===t?"":t)+")_"+u(++o+i,36)}},7558:function(t,n,r){var e=r(5947);t.exports=e&&!Symbol.sham&&"symbol"==typeof Symbol.iterator},5780:function(t,n,r){var e=r(1502),o=r(5061);t.exports=e&&o((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype}))},7427:function(t){var n=TypeError;t.exports=function(t,r){if(t<r)throw n("Not enough arguments");return t}},1899:function(t,n,r){var e=r(5001),o=r(6291),i=e.WeakMap;t.exports=o(i)&&/native code/.test(String(i))},6802:function(t,n,r){var e=r(5001),o=r(6809),i=r(8382),u=r(1050),c=r(5947),a=r(7558),f=o("wks"),s=e.Symbol,p=s&&s.for,l=a?s:s&&s.withoutSetter||u;t.exports=function(t){if(!i(f,t)||!c&&"string"!=typeof f[t]){var n="Symbol."+t;c&&i(s,t)?f[t]=s[t]:f[t]=a&&p?p(n):l(n)}return f[t]}},5370:function(t,n,r){"use strict";var e=r(9638),o=r(3927),i=r(4933),u=r(7714),c=r(7040),a=r(8971);e({target:"Promise",stat:!0,forced:r(3653)},{all:function(t){var n=this,r=u.f(n),e=r.resolve,f=r.reject,s=c((function(){var r=i(n.resolve),u=[],c=0,s=1;a(t,(function(t){var i=c++,a=!1;s++,o(r,n,t).then((function(t){a||(a=!0,u[i]=t,--s||e(u))}),f)})),--s||e(u)}));return s.error&&f(s.value),r.promise}})},4139:function(t,n,r){"use strict";var e=r(9638),o=r(13),i=r(8410).CONSTRUCTOR,u=r(7883),c=r(3425),a=r(6291),f=r(5850),s=u&&u.prototype;if(e({target:"Promise",proto:!0,forced:i,real:!0},{catch:function(t){return this.then(void 0,t)}}),!o&&a(u)){var p=c("Promise").prototype.catch;s.catch!==p&&f(s,"catch",p,{unsafe:!0})}},9688:function(t,n,r){"use strict";var e,o,i,u=r(9638),c=r(13),a=r(566),f=r(5001),s=r(3927),p=r(5850),l=r(2848),v=r(606),h=r(3126),d=r(4933),y=r(6291),b=r(2366),m=r(2814),g=r(3571),x=r(8680).set,w=r(3690),j=r(3455),O=r(7040),S=r(8791),E=r(684),P=r(7883),T=r(8410),C=r(7714),R="Promise",A=T.CONSTRUCTOR,I=T.REJECTION_EVENT,_=T.SUBCLASSING,M=E.getterFor(R),F=E.set,D=P&&P.prototype,N=P,k=D,L=f.TypeError,U=f.document,z=f.process,G=C.f,B=G,q=!!(U&&U.createEvent&&f.dispatchEvent),H="unhandledrejection",W=function(t){var n;return!(!b(t)||!y(n=t.then))&&n},V=function(t,n){var r,e,o,i=n.value,u=1==n.state,c=u?t.ok:t.fail,a=t.resolve,f=t.reject,p=t.domain;try{c?(u||(2===n.rejection&&X(n),n.rejection=1),!0===c?r=i:(p&&p.enter(),r=c(i),p&&(p.exit(),o=!0)),r===t.promise?f(L("Promise-chain cycle")):(e=W(r))?s(e,r,a,f):a(r)):f(i)}catch(t){p&&!o&&p.exit(),f(t)}},J=function(t,n){t.notified||(t.notified=!0,w((function(){for(var r,e=t.reactions;r=e.get();)V(r,t);t.notified=!1,n&&!t.rejection&&$(t)})))},K=function(t,n,r){var e,o;q?((e=U.createEvent("Event")).promise=n,e.reason=r,e.initEvent(t,!1,!0),f.dispatchEvent(e)):e={promise:n,reason:r},!I&&(o=f["on"+t])?o(e):t===H&&j("Unhandled promise rejection",r)},$=function(t){s(x,f,(function(){var n,r=t.facade,e=t.value;if(Q(t)&&(n=O((function(){a?z.emit("unhandledRejection",e,r):K(H,r,e)})),t.rejection=a||Q(t)?2:1,n.error))throw n.value}))},Q=function(t){return 1!==t.rejection&&!t.parent},X=function(t){s(x,f,(function(){var n=t.facade;a?z.emit("rejectionHandled",n):K("rejectionhandled",n,t.value)}))},Y=function(t,n,r){return function(e){t(n,e,r)}},Z=function(t,n,r){t.done||(t.done=!0,r&&(t=r),t.value=n,t.state=2,J(t,!0))},tt=function(t,n,r){if(!t.done){t.done=!0,r&&(t=r);try{if(t.facade===n)throw L("Promise can't be resolved itself");var e=W(n);e?w((function(){var r={done:!1};try{s(e,n,Y(tt,r,t),Y(Z,r,t))}catch(n){Z(r,n,t)}})):(t.value=n,t.state=1,J(t,!1))}catch(n){Z({done:!1},n,t)}}};if(A&&(k=(N=function(t){m(this,k),d(t),s(e,this);var n=M(this);try{t(Y(tt,n),Y(Z,n))}catch(t){Z(n,t)}}).prototype,(e=function(t){F(this,{type:R,done:!1,notified:!1,parent:!1,reactions:new S,rejection:!1,state:0,value:void 0})}).prototype=p(k,"then",(function(t,n){var r=M(this),e=G(g(this,N));return r.parent=!0,e.ok=!y(t)||t,e.fail=y(n)&&n,e.domain=a?z.domain:void 0,0==r.state?r.reactions.add(e):w((function(){V(e,r)})),e.promise})),o=function(){var t=new e,n=M(t);this.promise=t,this.resolve=Y(tt,n),this.reject=Y(Z,n)},C.f=G=function(t){return t===N||undefined===t?new o(t):B(t)},!c&&y(P)&&D!==Object.prototype)){i=D.then,_||p(D,"then",(function(t,n){var r=this;return new N((function(t,n){s(i,r,t,n)})).then(t,n)}),{unsafe:!0});try{delete D.constructor}catch(t){}l&&l(D,k)}u({global:!0,constructor:!0,wrap:!0,forced:A},{Promise:N}),v(N,R,!1,!0),h(R)},3045:function(t,n,r){r(9688),r(5370),r(4139),r(7508),r(5858),r(1856)},7508:function(t,n,r){"use strict";var e=r(9638),o=r(3927),i=r(4933),u=r(7714),c=r(7040),a=r(8971);e({target:"Promise",stat:!0,forced:r(3653)},{race:function(t){var n=this,r=u.f(n),e=r.reject,f=c((function(){var u=i(n.resolve);a(t,(function(t){o(u,n,t).then(r.resolve,e)}))}));return f.error&&e(f.value),r.promise}})},5858:function(t,n,r){"use strict";var e=r(9638),o=r(3927),i=r(7714);e({target:"Promise",stat:!0,forced:r(8410).CONSTRUCTOR},{reject:function(t){var n=i.f(this);return o(n.reject,void 0,t),n.promise}})},1856:function(t,n,r){"use strict";var e=r(9638),o=r(3425),i=r(13),u=r(7883),c=r(8410).CONSTRUCTOR,a=r(7504),f=o("Promise"),s=i&&!c;e({target:"Promise",stat:!0,forced:i||c},{resolve:function(t){return a(s&&this===f?u:this,t)}})},8156:function(n){"use strict";n.exports=t}},r={};function e(t){var o=r[t];if(void 0!==o)return o.exports;var i=r[t]={exports:{}};return n[t](i,i.exports,e),i.exports}e.d=function(t,n){for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},e.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),e.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};return function(){"use strict";function t(t,n,r){return n in t?Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[n]=r,t}function n(t,n){(null==n||n>t.length)&&(n=t.length);for(var r=0,e=new Array(n);r<n;r++)e[r]=t[r];return e}function r(t,r){return function(t){if(Array.isArray(t))return t}(t)||function(t,n){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var e,o,i=[],u=!0,c=!1;try{for(r=r.call(t);!(u=(e=r.next()).done)&&(i.push(e.value),!n||i.length!==n);u=!0);}catch(t){c=!0,o=t}finally{try{u||null==r.return||r.return()}finally{if(c)throw o}}return i}}(t,r)||function(t,r){if(t){if("string"==typeof t)return n(t,r);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?n(t,r):void 0}}(t,r)||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.")}()}e.r(o),e.d(o,{useMutation:function(){return p},useQuery:function(){return s},useSideEffect:function(){return f}});e(3045);var i=e(8156);function u(t,n){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(t);n&&(e=e.filter((function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable}))),r.push.apply(r,e)}return r}function c(n){for(var r=1;r<arguments.length;r++){var e=null!=arguments[r]?arguments[r]:{};r%2?u(Object(e),!0).forEach((function(r){t(n,r,e[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):u(Object(e)).forEach((function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(e,t))}))}return n}function a(t){var n=r((0,i.useState)(t),2),e=n[0],o=n[1],u=(0,i.useRef)(!0),c=(0,i.useCallback)((function(t){u.current&&o(t)}),[o]);return(0,i.useEffect)((function(){return function(){u.current=!1}}),[]),[e,c]}function f(t,n,e){var o=e||{},u=Array.isArray(o),c=u?o:o.deps||[],f=!u&&o.manual,s=r(a(n),2),p=s[0],l=s[1],v=function(){return t(l)},h=(0,i.useRef)(null),d=(0,i.useRef)(v);d.current=v;var y=(0,i.useCallback)((function(){null!=h.current&&h.current()}),[]),b=(0,i.useCallback)((function(){null!=h.current&&h.current();var t=d.current();return h.current="function"==typeof t?t:null,t}),[]);return(0,i.useEffect)((function(){f||b()}),c),(0,i.useEffect)((function(){return function(){var t=h.current;null!=t&&t()}}),[]),[p,b,{destroy:y}]}function s(t,n){var e=(0,i.useMemo)((function(){return{data:void 0,isError:!1,isFetching:!1,abandon:!1}}),[]),o=(0,i.useRef)(0),u=r(f((function(n){n((function(t){return c(c({},t||e),{},{isFetching:!0})}));var r=t();if(!r||"function"!=typeof r.then)throw new Error("The callback have to return a promise object.");var i=o.current+1;return o.current=i,r.then((function(t){var r={data:t,isError:!1,isFetching:!1,abandon:i!==o.current};return r.abandon||n(r),r}),(function(t){var r={error:t,isError:!0,isFetching:!1,abandon:i!==o.current};return r.abandon||n((function(t){return c(c({},t||e),r)})),c(c({},r),{},{data:void 0})}))}),e,n),2);return[u[0],u[1]]}function p(t,n){var e=(0,i.useMemo)((function(){return{data:void 0,isError:!1,isFetching:!1,abandon:!1}}),[]),o=n||{},u=o.after,f=void 0===u?function(){}:u,s=o.repeatable,p=void 0===s||s,l=(0,i.useRef)(!1),v=r(a(e),2),h=v[0],d=v[1],y=(0,i.useCallback)((function(){if(l.current)return Promise.resolve(c(c({},h),{},{abandon:!0}));l.current=!0,d((function(t){return c(c({},t),{},{isFetching:!0})}));var n=t.apply(void 0,arguments).then();return n.then((function(t){var n={data:t,isError:!1,isFetching:!1,abandon:!1};return n.abandon||(d(n),f(n)),l.current=!p,n}),(function(t){var n={error:t,isError:!0,isFetching:!1,abandon:!1};return n.abandon||(d((function(t){return c(c({},t||e),n)})),f(c(c({},n),{},{data:void 0}))),l.current=!1,c(c({},n),{},{data:void 0})}))}),[]);return[h,y]}}(),o}()})); | ||
!function(t,r){"object"==typeof exports&&"object"==typeof module?module.exports=r(require("react"),require("@airma/react-state")):"function"==typeof define&&define.amd?define(["react","@airma/react-state"],r):"object"==typeof exports?exports["@airma/react-effect"]=r(require("react"),require("@airma/react-state")):t["@airma/react-effect"]=r(t.react,t["@airma/react-state"])}(self,(function(t,r){return function(){var n={4933:function(t,r,n){var e=n(6291),o=n(7073),i=TypeError;t.exports=function(t){if(e(t))return t;throw i(o(t)+" is not a function")}},8209:function(t,r,n){var e=n(1814),o=n(7073),i=TypeError;t.exports=function(t){if(e(t))return t;throw i(o(t)+" is not a constructor")}},9076:function(t,r,n){var e=n(6291),o=String,i=TypeError;t.exports=function(t){if("object"==typeof t||e(t))return t;throw i("Can't set "+o(t)+" as a prototype")}},2814:function(t,r,n){var e=n(6282),o=TypeError;t.exports=function(t,r){if(e(r,t))return t;throw o("Incorrect invocation")}},4905:function(t,r,n){var e=n(2366),o=String,i=TypeError;t.exports=function(t){if(e(t))return t;throw i(o(t)+" is not an object")}},5029:function(t,r,n){var e=n(678),o=n(6971),i=n(4821),c=function(t){return function(r,n,c){var u,a=e(r),f=i(a),s=o(c,f);if(t&&n!=n){for(;f>s;)if((u=a[s++])!=u)return!0}else for(;f>s;s++)if((t||s in a)&&a[s]===n)return t||s||0;return!t&&-1}};t.exports={includes:c(!0),indexOf:c(!1)}},650:function(t,r,n){var e=n(936);t.exports=e([].slice)},3165:function(t,r,n){var e=n(6802)("iterator"),o=!1;try{var i=0,c={next:function(){return{done:!!i++}},return:function(){o=!0}};c[e]=function(){return this},Array.from(c,(function(){throw 2}))}catch(t){}t.exports=function(t,r){if(!r&&!o)return!1;var n=!1;try{var i={};i[e]=function(){return{next:function(){return{done:n=!0}}}},t(i)}catch(t){}return n}},5489:function(t,r,n){var e=n(936),o=e({}.toString),i=e("".slice);t.exports=function(t){return i(o(t),8,-1)}},486:function(t,r,n){var e=n(8171),o=n(6291),i=n(5489),c=n(6802)("toStringTag"),u=Object,a="Arguments"==i(function(){return arguments}());t.exports=e?i:function(t){var r,n,e;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(n=function(t,r){try{return t[r]}catch(t){}}(r=u(t),c))?n:a?i(r):"Object"==(e=i(r))&&o(r.callee)?"Arguments":e}},6810:function(t,r,n){var e=n(8382),o=n(2466),i=n(8117),c=n(6462);t.exports=function(t,r,n){for(var u=o(r),a=c.f,f=i.f,s=0;s<u.length;s++){var p=u[s];e(t,p)||n&&e(n,p)||a(t,p,f(r,p))}}},430:function(t,r,n){var e=n(1502),o=n(6462),i=n(6034);t.exports=e?function(t,r,n){return o.f(t,r,i(1,n))}:function(t,r,n){return t[r]=n,t}},6034:function(t){t.exports=function(t,r){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:r}}},5850:function(t,r,n){var e=n(6291),o=n(6462),i=n(7192),c=n(1756);t.exports=function(t,r,n,u){u||(u={});var a=u.enumerable,f=void 0!==u.name?u.name:r;if(e(n)&&i(n,f,u),u.global)a?t[r]=n:c(r,n);else{try{u.unsafe?t[r]&&(a=!0):delete t[r]}catch(t){}a?t[r]=n:o.f(t,r,{value:n,enumerable:!1,configurable:!u.nonConfigurable,writable:!u.nonWritable})}return t}},1756:function(t,r,n){var e=n(5001),o=Object.defineProperty;t.exports=function(t,r){try{o(e,t,{value:r,configurable:!0,writable:!0})}catch(n){e[t]=r}return r}},1502:function(t,r,n){var e=n(5061);t.exports=!e((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}))},5178:function(t){var r="object"==typeof document&&document.all,n=void 0===r&&void 0!==r;t.exports={all:r,IS_HTMLDDA:n}},6009:function(t,r,n){var e=n(5001),o=n(2366),i=e.document,c=o(i)&&o(i.createElement);t.exports=function(t){return c?i.createElement(t):{}}},6837:function(t,r,n){var e=n(5065),o=n(566);t.exports=!e&&!o&&"object"==typeof window&&"object"==typeof document},5065:function(t){t.exports="object"==typeof Deno&&Deno&&"object"==typeof Deno.version},1368:function(t,r,n){var e=n(9966),o=n(5001);t.exports=/ipad|iphone|ipod/i.test(e)&&void 0!==o.Pebble},311:function(t,r,n){var e=n(9966);t.exports=/(?:ipad|iphone|ipod).*applewebkit/i.test(e)},566:function(t,r,n){var e=n(5489),o=n(5001);t.exports="process"==e(o.process)},4832:function(t,r,n){var e=n(9966);t.exports=/web0s(?!.*chrome)/i.test(e)},9966:function(t,r,n){var e=n(3425);t.exports=e("navigator","userAgent")||""},2821:function(t,r,n){var e,o,i=n(5001),c=n(9966),u=i.process,a=i.Deno,f=u&&u.versions||a&&a.version,s=f&&f.v8;s&&(o=(e=s.split("."))[0]>0&&e[0]<4?1:+(e[0]+e[1])),!o&&c&&(!(e=c.match(/Edge\/(\d+)/))||e[1]>=74)&&(e=c.match(/Chrome\/(\d+)/))&&(o=+e[1]),t.exports=o},2089:function(t){t.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},9638:function(t,r,n){var e=n(5001),o=n(8117).f,i=n(430),c=n(5850),u=n(1756),a=n(6810),f=n(1092);t.exports=function(t,r){var n,s,p,v,l,y=t.target,d=t.global,h=t.stat;if(n=d?e:h?e[y]||u(y,{}):(e[y]||{}).prototype)for(s in r){if(v=r[s],p=t.dontCallGetSet?(l=o(n,s))&&l.value:n[s],!f(d?s:y+(h?".":"#")+s,t.forced)&&void 0!==p){if(typeof v==typeof p)continue;a(v,p)}(t.sham||p&&p.sham)&&i(v,"sham",!0),c(n,s,v,t)}}},5061:function(t){t.exports=function(t){try{return!!t()}catch(t){return!0}}},5494:function(t,r,n){var e=n(8483),o=Function.prototype,i=o.apply,c=o.call;t.exports="object"==typeof Reflect&&Reflect.apply||(e?c.bind(i):function(){return c.apply(i,arguments)})},9918:function(t,r,n){var e=n(1017),o=n(4933),i=n(8483),c=e(e.bind);t.exports=function(t,r){return o(t),void 0===r?t:i?c(t,r):function(){return t.apply(r,arguments)}}},8483:function(t,r,n){var e=n(5061);t.exports=!e((function(){var t=function(){}.bind();return"function"!=typeof t||t.hasOwnProperty("prototype")}))},3927:function(t,r,n){var e=n(8483),o=Function.prototype.call;t.exports=e?o.bind(o):function(){return o.apply(o,arguments)}},9873:function(t,r,n){var e=n(1502),o=n(8382),i=Function.prototype,c=e&&Object.getOwnPropertyDescriptor,u=o(i,"name"),a=u&&"something"===function(){}.name,f=u&&(!e||e&&c(i,"name").configurable);t.exports={EXISTS:u,PROPER:a,CONFIGURABLE:f}},1017:function(t,r,n){var e=n(5489),o=n(936);t.exports=function(t){if("Function"===e(t))return o(t)}},936:function(t,r,n){var e=n(8483),o=Function.prototype,i=o.call,c=e&&o.bind.bind(i,i);t.exports=e?c:function(t){return function(){return i.apply(t,arguments)}}},3425:function(t,r,n){var e=n(5001),o=n(6291),i=function(t){return o(t)?t:void 0};t.exports=function(t,r){return arguments.length<2?i(e[t]):e[t]&&e[t][r]}},6354:function(t,r,n){var e=n(486),o=n(3815),i=n(860),c=n(501),u=n(6802)("iterator");t.exports=function(t){if(!i(t))return o(t,u)||o(t,"@@iterator")||c[e(t)]}},8437:function(t,r,n){var e=n(3927),o=n(4933),i=n(4905),c=n(7073),u=n(6354),a=TypeError;t.exports=function(t,r){var n=arguments.length<2?u(t):r;if(o(n))return i(e(n,t));throw a(c(t)+" is not iterable")}},3815:function(t,r,n){var e=n(4933),o=n(860);t.exports=function(t,r){var n=t[r];return o(n)?void 0:e(n)}},5001:function(t,r,n){var e=function(t){return t&&t.Math==Math&&t};t.exports=e("object"==typeof globalThis&&globalThis)||e("object"==typeof window&&window)||e("object"==typeof self&&self)||e("object"==typeof n.g&&n.g)||function(){return this}()||Function("return this")()},8382:function(t,r,n){var e=n(936),o=n(7615),i=e({}.hasOwnProperty);t.exports=Object.hasOwn||function(t,r){return i(o(t),r)}},2499:function(t){t.exports={}},3455:function(t,r,n){var e=n(5001);t.exports=function(t,r){var n=e.console;n&&n.error&&(1==arguments.length?n.error(t):n.error(t,r))}},2118:function(t,r,n){var e=n(3425);t.exports=e("document","documentElement")},7788:function(t,r,n){var e=n(1502),o=n(5061),i=n(6009);t.exports=!e&&!o((function(){return 7!=Object.defineProperty(i("div"),"a",{get:function(){return 7}}).a}))},2901:function(t,r,n){var e=n(936),o=n(5061),i=n(5489),c=Object,u=e("".split);t.exports=o((function(){return!c("z").propertyIsEnumerable(0)}))?function(t){return"String"==i(t)?u(t,""):c(t)}:c},685:function(t,r,n){var e=n(936),o=n(6291),i=n(9982),c=e(Function.toString);o(i.inspectSource)||(i.inspectSource=function(t){return c(t)}),t.exports=i.inspectSource},684:function(t,r,n){var e,o,i,c=n(1899),u=n(5001),a=n(2366),f=n(430),s=n(8382),p=n(9982),v=n(1695),l=n(2499),y="Object already initialized",d=u.TypeError,h=u.WeakMap;if(c||p.state){var b=p.state||(p.state=new h);b.get=b.get,b.has=b.has,b.set=b.set,e=function(t,r){if(b.has(t))throw d(y);return r.facade=t,b.set(t,r),r},o=function(t){return b.get(t)||{}},i=function(t){return b.has(t)}}else{var g=v("state");l[g]=!0,e=function(t,r){if(s(t,g))throw d(y);return r.facade=t,f(t,g,r),r},o=function(t){return s(t,g)?t[g]:{}},i=function(t){return s(t,g)}}t.exports={set:e,get:o,has:i,enforce:function(t){return i(t)?o(t):e(t,{})},getterFor:function(t){return function(r){var n;if(!a(r)||(n=o(r)).type!==t)throw d("Incompatible receiver, "+t+" required");return n}}}},5557:function(t,r,n){var e=n(6802),o=n(501),i=e("iterator"),c=Array.prototype;t.exports=function(t){return void 0!==t&&(o.Array===t||c[i]===t)}},6291:function(t,r,n){var e=n(5178),o=e.all;t.exports=e.IS_HTMLDDA?function(t){return"function"==typeof t||t===o}:function(t){return"function"==typeof t}},1814:function(t,r,n){var e=n(936),o=n(5061),i=n(6291),c=n(486),u=n(3425),a=n(685),f=function(){},s=[],p=u("Reflect","construct"),v=/^\s*(?:class|function)\b/,l=e(v.exec),y=!v.exec(f),d=function(t){if(!i(t))return!1;try{return p(f,s,t),!0}catch(t){return!1}},h=function(t){if(!i(t))return!1;switch(c(t)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return y||!!l(v,a(t))}catch(t){return!0}};h.sham=!0,t.exports=!p||o((function(){var t;return d(d.call)||!d(Object)||!d((function(){t=!0}))||t}))?h:d},1092:function(t,r,n){var e=n(5061),o=n(6291),i=/#|\.prototype\./,c=function(t,r){var n=a[u(t)];return n==s||n!=f&&(o(r)?e(r):!!r)},u=c.normalize=function(t){return String(t).replace(i,".").toLowerCase()},a=c.data={},f=c.NATIVE="N",s=c.POLYFILL="P";t.exports=c},860:function(t){t.exports=function(t){return null==t}},2366:function(t,r,n){var e=n(6291),o=n(5178),i=o.all;t.exports=o.IS_HTMLDDA?function(t){return"object"==typeof t?null!==t:e(t)||t===i}:function(t){return"object"==typeof t?null!==t:e(t)}},13:function(t){t.exports=!1},6448:function(t,r,n){var e=n(3425),o=n(6291),i=n(6282),c=n(7558),u=Object;t.exports=c?function(t){return"symbol"==typeof t}:function(t){var r=e("Symbol");return o(r)&&i(r.prototype,u(t))}},8971:function(t,r,n){var e=n(9918),o=n(3927),i=n(4905),c=n(7073),u=n(5557),a=n(4821),f=n(6282),s=n(8437),p=n(6354),v=n(9200),l=TypeError,y=function(t,r){this.stopped=t,this.result=r},d=y.prototype;t.exports=function(t,r,n){var h,b,g,m,O,x,j,w=n&&n.that,S=!(!n||!n.AS_ENTRIES),P=!(!n||!n.IS_RECORD),E=!(!n||!n.IS_ITERATOR),T=!(!n||!n.INTERRUPTED),R=e(r,w),A=function(t){return h&&v(h,"normal",t),new y(!0,t)},C=function(t){return S?(i(t),T?R(t[0],t[1],A):R(t[0],t[1])):T?R(t,A):R(t)};if(P)h=t.iterator;else if(E)h=t;else{if(!(b=p(t)))throw l(c(t)+" is not iterable");if(u(b)){for(g=0,m=a(t);m>g;g++)if((O=C(t[g]))&&f(d,O))return O;return new y(!1)}h=s(t,b)}for(x=P?t.next:h.next;!(j=o(x,h)).done;){try{O=C(j.value)}catch(t){v(h,"throw",t)}if("object"==typeof O&&O&&f(d,O))return O}return new y(!1)}},9200:function(t,r,n){var e=n(3927),o=n(4905),i=n(3815);t.exports=function(t,r,n){var c,u;o(t);try{if(!(c=i(t,"return"))){if("throw"===r)throw n;return n}c=e(c,t)}catch(t){u=!0,c=t}if("throw"===r)throw n;if(u)throw c;return o(c),n}},501:function(t){t.exports={}},4821:function(t,r,n){var e=n(4479);t.exports=function(t){return e(t.length)}},7192:function(t,r,n){var e=n(5061),o=n(6291),i=n(8382),c=n(1502),u=n(9873).CONFIGURABLE,a=n(685),f=n(684),s=f.enforce,p=f.get,v=Object.defineProperty,l=c&&!e((function(){return 8!==v((function(){}),"length",{value:8}).length})),y=String(String).split("String"),d=t.exports=function(t,r,n){"Symbol("===String(r).slice(0,7)&&(r="["+String(r).replace(/^Symbol\(([^)]*)\)/,"$1")+"]"),n&&n.getter&&(r="get "+r),n&&n.setter&&(r="set "+r),(!i(t,"name")||u&&t.name!==r)&&(c?v(t,"name",{value:r,configurable:!0}):t.name=r),l&&n&&i(n,"arity")&&t.length!==n.arity&&v(t,"length",{value:n.arity});try{n&&i(n,"constructor")&&n.constructor?c&&v(t,"prototype",{writable:!1}):t.prototype&&(t.prototype=void 0)}catch(t){}var e=s(t);return i(e,"source")||(e.source=y.join("string"==typeof r?r:"")),t};Function.prototype.toString=d((function(){return o(this)&&p(this).source||a(this)}),"toString")},1367:function(t){var r=Math.ceil,n=Math.floor;t.exports=Math.trunc||function(t){var e=+t;return(e>0?n:r)(e)}},3690:function(t,r,n){var e,o,i,c,u,a,f,s,p=n(5001),v=n(9918),l=n(8117).f,y=n(8680).set,d=n(311),h=n(1368),b=n(4832),g=n(566),m=p.MutationObserver||p.WebKitMutationObserver,O=p.document,x=p.process,j=p.Promise,w=l(p,"queueMicrotask"),S=w&&w.value;S||(e=function(){var t,r;for(g&&(t=x.domain)&&t.exit();o;){r=o.fn,o=o.next;try{r()}catch(t){throw o?c():i=void 0,t}}i=void 0,t&&t.enter()},d||g||b||!m||!O?!h&&j&&j.resolve?((f=j.resolve(void 0)).constructor=j,s=v(f.then,f),c=function(){s(e)}):g?c=function(){x.nextTick(e)}:(y=v(y,p),c=function(){y(e)}):(u=!0,a=O.createTextNode(""),new m(e).observe(a,{characterData:!0}),c=function(){a.data=u=!u})),t.exports=S||function(t){var r={fn:t,next:void 0};i&&(i.next=r),o||(o=r,c()),i=r}},7714:function(t,r,n){"use strict";var e=n(4933),o=TypeError,i=function(t){var r,n;this.promise=new t((function(t,e){if(void 0!==r||void 0!==n)throw o("Bad Promise constructor");r=t,n=e})),this.resolve=e(r),this.reject=e(n)};t.exports.f=function(t){return new i(t)}},6462:function(t,r,n){var e=n(1502),o=n(7788),i=n(5780),c=n(4905),u=n(1030),a=TypeError,f=Object.defineProperty,s=Object.getOwnPropertyDescriptor,p="enumerable",v="configurable",l="writable";r.f=e?i?function(t,r,n){if(c(t),r=u(r),c(n),"function"==typeof t&&"prototype"===r&&"value"in n&&l in n&&!n.writable){var e=s(t,r);e&&e.writable&&(t[r]=n.value,n={configurable:v in n?n.configurable:e.configurable,enumerable:p in n?n.enumerable:e.enumerable,writable:!1})}return f(t,r,n)}:f:function(t,r,n){if(c(t),r=u(r),c(n),o)try{return f(t,r,n)}catch(t){}if("get"in n||"set"in n)throw a("Accessors not supported");return"value"in n&&(t[r]=n.value),t}},8117:function(t,r,n){var e=n(1502),o=n(3927),i=n(9265),c=n(6034),u=n(678),a=n(1030),f=n(8382),s=n(7788),p=Object.getOwnPropertyDescriptor;r.f=e?p:function(t,r){if(t=u(t),r=a(r),s)try{return p(t,r)}catch(t){}if(f(t,r))return c(!o(i.f,t,r),t[r])}},9219:function(t,r,n){var e=n(3855),o=n(2089).concat("length","prototype");r.f=Object.getOwnPropertyNames||function(t){return e(t,o)}},2822:function(t,r){r.f=Object.getOwnPropertySymbols},6282:function(t,r,n){var e=n(936);t.exports=e({}.isPrototypeOf)},3855:function(t,r,n){var e=n(936),o=n(8382),i=n(678),c=n(5029).indexOf,u=n(2499),a=e([].push);t.exports=function(t,r){var n,e=i(t),f=0,s=[];for(n in e)!o(u,n)&&o(e,n)&&a(s,n);for(;r.length>f;)o(e,n=r[f++])&&(~c(s,n)||a(s,n));return s}},9265:function(t,r){"use strict";var n={}.propertyIsEnumerable,e=Object.getOwnPropertyDescriptor,o=e&&!n.call({1:2},1);r.f=o?function(t){var r=e(this,t);return!!r&&r.enumerable}:n},2848:function(t,r,n){var e=n(936),o=n(4905),i=n(9076);t.exports=Object.setPrototypeOf||("__proto__"in{}?function(){var t,r=!1,n={};try{(t=e(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set))(n,[]),r=n instanceof Array}catch(t){}return function(n,e){return o(n),i(e),r?t(n,e):n.__proto__=e,n}}():void 0)},379:function(t,r,n){var e=n(3927),o=n(6291),i=n(2366),c=TypeError;t.exports=function(t,r){var n,u;if("string"===r&&o(n=t.toString)&&!i(u=e(n,t)))return u;if(o(n=t.valueOf)&&!i(u=e(n,t)))return u;if("string"!==r&&o(n=t.toString)&&!i(u=e(n,t)))return u;throw c("Can't convert object to primitive value")}},2466:function(t,r,n){var e=n(3425),o=n(936),i=n(9219),c=n(2822),u=n(4905),a=o([].concat);t.exports=e("Reflect","ownKeys")||function(t){var r=i.f(u(t)),n=c.f;return n?a(r,n(t)):r}},7040:function(t){t.exports=function(t){try{return{error:!1,value:t()}}catch(t){return{error:!0,value:t}}}},8410:function(t,r,n){var e=n(5001),o=n(7883),i=n(6291),c=n(1092),u=n(685),a=n(6802),f=n(6837),s=n(5065),p=n(13),v=n(2821),l=o&&o.prototype,y=a("species"),d=!1,h=i(e.PromiseRejectionEvent),b=c("Promise",(function(){var t=u(o),r=t!==String(o);if(!r&&66===v)return!0;if(p&&(!l.catch||!l.finally))return!0;if(!v||v<51||!/native code/.test(t)){var n=new o((function(t){t(1)})),e=function(t){t((function(){}),(function(){}))};if((n.constructor={})[y]=e,!(d=n.then((function(){}))instanceof e))return!0}return!r&&(f||s)&&!h}));t.exports={CONSTRUCTOR:b,REJECTION_EVENT:h,SUBCLASSING:d}},7883:function(t,r,n){var e=n(5001);t.exports=e.Promise},7504:function(t,r,n){var e=n(4905),o=n(2366),i=n(7714);t.exports=function(t,r){if(e(t),o(r)&&r.constructor===t)return r;var n=i.f(t);return(0,n.resolve)(r),n.promise}},3653:function(t,r,n){var e=n(7883),o=n(3165),i=n(8410).CONSTRUCTOR;t.exports=i||!o((function(t){e.all(t).then(void 0,(function(){}))}))},8791:function(t){var r=function(){this.head=null,this.tail=null};r.prototype={add:function(t){var r={item:t,next:null};this.head?this.tail.next=r:this.head=r,this.tail=r},get:function(){var t=this.head;if(t)return this.head=t.next,this.tail===t&&(this.tail=null),t.item}},t.exports=r},4475:function(t,r,n){var e=n(860),o=TypeError;t.exports=function(t){if(e(t))throw o("Can't call method on "+t);return t}},3126:function(t,r,n){"use strict";var e=n(3425),o=n(6462),i=n(6802),c=n(1502),u=i("species");t.exports=function(t){var r=e(t),n=o.f;c&&r&&!r[u]&&n(r,u,{configurable:!0,get:function(){return this}})}},606:function(t,r,n){var e=n(6462).f,o=n(8382),i=n(6802)("toStringTag");t.exports=function(t,r,n){t&&!n&&(t=t.prototype),t&&!o(t,i)&&e(t,i,{configurable:!0,value:r})}},1695:function(t,r,n){var e=n(6809),o=n(1050),i=e("keys");t.exports=function(t){return i[t]||(i[t]=o(t))}},9982:function(t,r,n){var e=n(5001),o=n(1756),i="__core-js_shared__",c=e[i]||o(i,{});t.exports=c},6809:function(t,r,n){var e=n(13),o=n(9982);(t.exports=function(t,r){return o[t]||(o[t]=void 0!==r?r:{})})("versions",[]).push({version:"3.26.1",mode:e?"pure":"global",copyright:"© 2014-2022 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.26.1/LICENSE",source:"https://github.com/zloirock/core-js"})},3571:function(t,r,n){var e=n(4905),o=n(8209),i=n(860),c=n(6802)("species");t.exports=function(t,r){var n,u=e(t).constructor;return void 0===u||i(n=e(u)[c])?r:o(n)}},5947:function(t,r,n){var e=n(2821),o=n(5061);t.exports=!!Object.getOwnPropertySymbols&&!o((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&e&&e<41}))},8680:function(t,r,n){var e,o,i,c,u=n(5001),a=n(5494),f=n(9918),s=n(6291),p=n(8382),v=n(5061),l=n(2118),y=n(650),d=n(6009),h=n(7427),b=n(311),g=n(566),m=u.setImmediate,O=u.clearImmediate,x=u.process,j=u.Dispatch,w=u.Function,S=u.MessageChannel,P=u.String,E=0,T={},R="onreadystatechange";try{e=u.location}catch(t){}var A=function(t){if(p(T,t)){var r=T[t];delete T[t],r()}},C=function(t){return function(){A(t)}},D=function(t){A(t.data)},I=function(t){u.postMessage(P(t),e.protocol+"//"+e.host)};m&&O||(m=function(t){h(arguments.length,1);var r=s(t)?t:w(t),n=y(arguments,1);return T[++E]=function(){a(r,void 0,n)},o(E),E},O=function(t){delete T[t]},g?o=function(t){x.nextTick(C(t))}:j&&j.now?o=function(t){j.now(C(t))}:S&&!b?(c=(i=new S).port2,i.port1.onmessage=D,o=f(c.postMessage,c)):u.addEventListener&&s(u.postMessage)&&!u.importScripts&&e&&"file:"!==e.protocol&&!v(I)?(o=I,u.addEventListener("message",D,!1)):o=R in d("script")?function(t){l.appendChild(d("script")).onreadystatechange=function(){l.removeChild(this),A(t)}}:function(t){setTimeout(C(t),0)}),t.exports={set:m,clear:O}},6971:function(t,r,n){var e=n(9398),o=Math.max,i=Math.min;t.exports=function(t,r){var n=e(t);return n<0?o(n+r,0):i(n,r)}},678:function(t,r,n){var e=n(2901),o=n(4475);t.exports=function(t){return e(o(t))}},9398:function(t,r,n){var e=n(1367);t.exports=function(t){var r=+t;return r!=r||0===r?0:e(r)}},4479:function(t,r,n){var e=n(9398),o=Math.min;t.exports=function(t){return t>0?o(e(t),9007199254740991):0}},7615:function(t,r,n){var e=n(4475),o=Object;t.exports=function(t){return o(e(t))}},6973:function(t,r,n){var e=n(3927),o=n(2366),i=n(6448),c=n(3815),u=n(379),a=n(6802),f=TypeError,s=a("toPrimitive");t.exports=function(t,r){if(!o(t)||i(t))return t;var n,a=c(t,s);if(a){if(void 0===r&&(r="default"),n=e(a,t,r),!o(n)||i(n))return n;throw f("Can't convert object to primitive value")}return void 0===r&&(r="number"),u(t,r)}},1030:function(t,r,n){var e=n(6973),o=n(6448);t.exports=function(t){var r=e(t,"string");return o(r)?r:r+""}},8171:function(t,r,n){var e={};e[n(6802)("toStringTag")]="z",t.exports="[object z]"===String(e)},7073:function(t){var r=String;t.exports=function(t){try{return r(t)}catch(t){return"Object"}}},1050:function(t,r,n){var e=n(936),o=0,i=Math.random(),c=e(1..toString);t.exports=function(t){return"Symbol("+(void 0===t?"":t)+")_"+c(++o+i,36)}},7558:function(t,r,n){var e=n(5947);t.exports=e&&!Symbol.sham&&"symbol"==typeof Symbol.iterator},5780:function(t,r,n){var e=n(1502),o=n(5061);t.exports=e&&o((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype}))},7427:function(t){var r=TypeError;t.exports=function(t,n){if(t<n)throw r("Not enough arguments");return t}},1899:function(t,r,n){var e=n(5001),o=n(6291),i=e.WeakMap;t.exports=o(i)&&/native code/.test(String(i))},6802:function(t,r,n){var e=n(5001),o=n(6809),i=n(8382),c=n(1050),u=n(5947),a=n(7558),f=o("wks"),s=e.Symbol,p=s&&s.for,v=a?s:s&&s.withoutSetter||c;t.exports=function(t){if(!i(f,t)||!u&&"string"!=typeof f[t]){var r="Symbol."+t;u&&i(s,t)?f[t]=s[t]:f[t]=a&&p?p(r):v(r)}return f[t]}},5370:function(t,r,n){"use strict";var e=n(9638),o=n(3927),i=n(4933),c=n(7714),u=n(7040),a=n(8971);e({target:"Promise",stat:!0,forced:n(3653)},{all:function(t){var r=this,n=c.f(r),e=n.resolve,f=n.reject,s=u((function(){var n=i(r.resolve),c=[],u=0,s=1;a(t,(function(t){var i=u++,a=!1;s++,o(n,r,t).then((function(t){a||(a=!0,c[i]=t,--s||e(c))}),f)})),--s||e(c)}));return s.error&&f(s.value),n.promise}})},4139:function(t,r,n){"use strict";var e=n(9638),o=n(13),i=n(8410).CONSTRUCTOR,c=n(7883),u=n(3425),a=n(6291),f=n(5850),s=c&&c.prototype;if(e({target:"Promise",proto:!0,forced:i,real:!0},{catch:function(t){return this.then(void 0,t)}}),!o&&a(c)){var p=u("Promise").prototype.catch;s.catch!==p&&f(s,"catch",p,{unsafe:!0})}},9688:function(t,r,n){"use strict";var e,o,i,c=n(9638),u=n(13),a=n(566),f=n(5001),s=n(3927),p=n(5850),v=n(2848),l=n(606),y=n(3126),d=n(4933),h=n(6291),b=n(2366),g=n(2814),m=n(3571),O=n(8680).set,x=n(3690),j=n(3455),w=n(7040),S=n(8791),P=n(684),E=n(7883),T=n(8410),R=n(7714),A="Promise",C=T.CONSTRUCTOR,D=T.REJECTION_EVENT,I=T.SUBCLASSING,M=P.getterFor(A),_=P.set,F=E&&E.prototype,N=E,k=F,L=f.TypeError,U=f.document,K=f.process,z=R.f,G=z,q=!!(U&&U.createEvent&&f.dispatchEvent),B="unhandledrejection",H=function(t){var r;return!(!b(t)||!h(r=t.then))&&r},W=function(t,r){var n,e,o,i=r.value,c=1==r.state,u=c?t.ok:t.fail,a=t.resolve,f=t.reject,p=t.domain;try{u?(c||(2===r.rejection&&X(r),r.rejection=1),!0===u?n=i:(p&&p.enter(),n=u(i),p&&(p.exit(),o=!0)),n===t.promise?f(L("Promise-chain cycle")):(e=H(n))?s(e,n,a,f):a(n)):f(i)}catch(t){p&&!o&&p.exit(),f(t)}},V=function(t,r){t.notified||(t.notified=!0,x((function(){for(var n,e=t.reactions;n=e.get();)W(n,t);t.notified=!1,r&&!t.rejection&&$(t)})))},J=function(t,r,n){var e,o;q?((e=U.createEvent("Event")).promise=r,e.reason=n,e.initEvent(t,!1,!0),f.dispatchEvent(e)):e={promise:r,reason:n},!D&&(o=f["on"+t])?o(e):t===B&&j("Unhandled promise rejection",n)},$=function(t){s(O,f,(function(){var r,n=t.facade,e=t.value;if(Q(t)&&(r=w((function(){a?K.emit("unhandledRejection",e,n):J(B,n,e)})),t.rejection=a||Q(t)?2:1,r.error))throw r.value}))},Q=function(t){return 1!==t.rejection&&!t.parent},X=function(t){s(O,f,(function(){var r=t.facade;a?K.emit("rejectionHandled",r):J("rejectionhandled",r,t.value)}))},Y=function(t,r,n){return function(e){t(r,e,n)}},Z=function(t,r,n){t.done||(t.done=!0,n&&(t=n),t.value=r,t.state=2,V(t,!0))},tt=function(t,r,n){if(!t.done){t.done=!0,n&&(t=n);try{if(t.facade===r)throw L("Promise can't be resolved itself");var e=H(r);e?x((function(){var n={done:!1};try{s(e,r,Y(tt,n,t),Y(Z,n,t))}catch(r){Z(n,r,t)}})):(t.value=r,t.state=1,V(t,!1))}catch(r){Z({done:!1},r,t)}}};if(C&&(k=(N=function(t){g(this,k),d(t),s(e,this);var r=M(this);try{t(Y(tt,r),Y(Z,r))}catch(t){Z(r,t)}}).prototype,(e=function(t){_(this,{type:A,done:!1,notified:!1,parent:!1,reactions:new S,rejection:!1,state:0,value:void 0})}).prototype=p(k,"then",(function(t,r){var n=M(this),e=z(m(this,N));return n.parent=!0,e.ok=!h(t)||t,e.fail=h(r)&&r,e.domain=a?K.domain:void 0,0==n.state?n.reactions.add(e):x((function(){W(e,n)})),e.promise})),o=function(){var t=new e,r=M(t);this.promise=t,this.resolve=Y(tt,r),this.reject=Y(Z,r)},R.f=z=function(t){return t===N||undefined===t?new o(t):G(t)},!u&&h(E)&&F!==Object.prototype)){i=F.then,I||p(F,"then",(function(t,r){var n=this;return new N((function(t,r){s(i,n,t,r)})).then(t,r)}),{unsafe:!0});try{delete F.constructor}catch(t){}v&&v(F,k)}c({global:!0,constructor:!0,wrap:!0,forced:C},{Promise:N}),l(N,A,!1,!0),y(A)},3045:function(t,r,n){n(9688),n(5370),n(4139),n(7508),n(5858),n(1856)},7508:function(t,r,n){"use strict";var e=n(9638),o=n(3927),i=n(4933),c=n(7714),u=n(7040),a=n(8971);e({target:"Promise",stat:!0,forced:n(3653)},{race:function(t){var r=this,n=c.f(r),e=n.reject,f=u((function(){var c=i(r.resolve);a(t,(function(t){o(c,r,t).then(n.resolve,e)}))}));return f.error&&e(f.value),n.promise}})},5858:function(t,r,n){"use strict";var e=n(9638),o=n(3927),i=n(7714);e({target:"Promise",stat:!0,forced:n(8410).CONSTRUCTOR},{reject:function(t){var r=i.f(this);return o(r.reject,void 0,t),r.promise}})},1856:function(t,r,n){"use strict";var e=n(9638),o=n(3425),i=n(13),c=n(7883),u=n(8410).CONSTRUCTOR,a=n(7504),f=o("Promise"),s=i&&!u;e({target:"Promise",stat:!0,forced:i||u},{resolve:function(t){return a(s&&this===f?c:this,t)}})},7400:function(t){"use strict";t.exports=r},8156:function(r){"use strict";r.exports=t}},e={};function o(t){var r=e[t];if(void 0!==r)return r.exports;var i=e[t]={exports:{}};return n[t](i,i.exports,o),i.exports}o.d=function(t,r){for(var n in r)o.o(r,n)&&!o.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),o.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};return function(){"use strict";function t(t,r){(null==r||r>t.length)&&(r=t.length);for(var n=0,e=new Array(r);n<r;n++)e[n]=t[n];return e}function r(r,n){if(r){if("string"==typeof r)return t(r,n);var e=Object.prototype.toString.call(r).slice(8,-1);return"Object"===e&&r.constructor&&(e=r.constructor.name),"Map"===e||"Set"===e?Array.from(r):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?t(r,n):void 0}}function n(n){return function(r){if(Array.isArray(r))return t(r)}(n)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(n)||r(n)||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 e(t,r,n){return r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function c(t,n){return function(t){if(Array.isArray(t))return t}(t)||function(t,r){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var e,o,i=[],c=!0,u=!1;try{for(n=n.call(t);!(c=(e=n.next()).done)&&(i.push(e.value),!r||i.length!==r);c=!0);}catch(t){u=!0,o=t}finally{try{c||null==n.return||n.return()}finally{if(u)throw o}}return i}}(t,n)||r(t,n)||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.")}()}o.r(i),o.d(i,{EffectProvider:function(){return P},Strategy:function(){return b},asyncEffect:function(){return y},useAsyncEffect:function(){return S},useMutation:function(){return w},useQuery:function(){return j},withEffectProvider:function(){return E}});o(3045);var u=o(8156),a=o(7400);function f(t,r){if(null==t)return{};var n,e,o=function(t,r){if(null==t)return{};var n,e,o={},i=Object.keys(t);for(e=0;e<i.length;e++)n=i[e],r.indexOf(n)>=0||(o[n]=t[n]);return o}(t,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(e=0;e<i.length;e++)n=i[e],r.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(o[n]=t[n])}return o}var s=["version"];function p(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(t);r&&(e=e.filter((function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),n.push.apply(n,e)}return n}function v(t){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?p(Object(n),!0).forEach((function(r){e(t,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):p(Object(n)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))}))}return t}function l(t){var r=t.version,n=f(t,s),e=function(t){return v(v({},t),{},{version:r})};return{state:n,version:r||0,setState:function(r){return e("function"!=typeof r?r:r(t))},trigger:function(){return v(v({},t),{},{version:(r||0)+1})}}}function y(t){var r=(0,a.factory)(l,{data:void 0,isError:!1,isFetching:!1,abandon:!1});return r.effect=[function(){return t.apply(void 0,arguments)}],r}function d(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(t);r&&(e=e.filter((function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),n.push.apply(n,e)}return n}function h(t){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?d(Object(n),!0).forEach((function(r){e(t,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):d(Object(n)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))}))}return t}var b={debounce:function(t){var r=t.time;return function(t,n,e){if(e.current){var o=e.current,i=o.id,c=o.resolve;e.current=void 0,clearTimeout(i),c(h(h({},t()),{},{abandon:!0}))}return new Promise((function(t){var o=setTimeout((function(){t(n())}),r);e.current={id:o,resolve:t}}))}},once:function(){return function(t,r,n){return n.current?new Promise((function(r){r(h(h({},t()),{},{abandon:!0}))})):(n.current=!0,r().then((function(t){return t.isError&&(n.current=!1),t})))}}};function g(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(t);r&&(e=e.filter((function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),n.push.apply(n,e)}return n}function m(t){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?g(Object(n),!0).forEach((function(r){e(t,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):g(Object(n)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))}))}return t}function O(t,r){if(!("function"==typeof t.pipe))return[l,t,r];var n=c(t.effect,2);return[t,n[0],n[1]||r]}function x(t){return function(r){var n=t();if(!n||"function"!=typeof n.then)throw new Error("The callback have to return a promise object.");return r(m(m({},{data:void 0,isError:!1,isFetching:!1,abandon:!1}),{},{isFetching:!0})),n.then((function(t){return r({data:t,isError:!1,isFetching:!1,abandon:!1})}),(function(t){return r({data:void 0,error:t,isError:!0,isFetching:!1,abandon:!1})}))}}function j(t,r){var e=c(O(t,Array.isArray(r)?{variables:r}:r),3),o=e[0],i=e[1],f=e[2],s=o===l?[o,{data:void 0,isError:!1,isFetching:!1,abandon:!1}]:[o],p=a.useModel.apply(void 0,n(s)),v=f||{},y=v.variables,d=v.deps,h=v.manual,b=v.strategy,g=!d&&!y||h,j=x((function(){return i.apply(void 0,n(y||[]))})),w=(0,u.useRef)({}),S=(0,u.useRef)(),P=(0,u.useRef)(0),E=function(){var t=P.current+1;P.current=t;return j((function(r){var n=p.state,e=p.setState,o=t!==P.current,i=function(t){return o||e(t),t};return r.isFetching?i(m(m({},r),{},{data:n.data,abandon:o,fetchingKey:w.current})):r.isError?i(m(m(m({},n),r),{},{data:n.data,abandon:o,fetchingKey:void 0})):i(m(m({},r),{},{abandon:o,fetchingKey:void 0}))}))},T=function(t){if(!b)return t();return b((function(){return p.state}),t,S)},R=function(){return T(E)};(0,u.useLayoutEffect)((function(){if(!g){var t=p.state.fetchingKey;t&&t!==w.current||function(){var t=p.state.fetchingKey;t&&t!==w.current||T(E)}()}}),d||y||[]);var A=(0,u.useRef)(p.version);return(0,u.useEffect)((function(){A.current!==p.version&&(A.current=p.version,R())}),[p.version]),[p.state,R]}function w(t,r){var e=c(O(t,Array.isArray(r)?{variables:r}:r),3),o=e[0],i=e[1],f=e[2],s=o===l?[o,{data:void 0,isError:!1,isFetching:!1,abandon:!1}]:[o],p=a.useModel.apply(void 0,n(s)),v=f||{},y=v.variables,d=v.strategy,h=x((function(){return i.apply(void 0,n(y||[]))})),b=(0,u.useRef)(),g=(0,u.useRef)({}),j=(0,u.useRef)(!1),w=function(){if(j.current)return new Promise((function(t){t(p.state)}));j.current=!0;return h((function(t){var r=p.state,n=p.setState;return t.isFetching?n(m(m({},t),{},{data:r.data,fetchingKey:g.current})):(j.current=!1,t.isError?n(m(m(m({},r),t),{},{data:r.data,fetchingKey:void 0})):n(m(m({},t),{},{fetchingKey:void 0})))}))},S=function(){return t=w,d?d((function(){return p.state}),t,b):t();var t},P=(0,u.useRef)(p.version);return(0,u.useEffect)((function(){P.current!==p.version&&(P.current=p.version,S())}),[p.version]),[p.state,S]}function S(t){return(0,a.useSelector)(t,(function(t){return[t.state,t.trigger]}))}var P=a.ModelProvider,E=a.withModelProvider}(),i}()})); |
105
index.d.ts
@@ -1,7 +0,4 @@ | ||
export declare type ResponseParam<T> = T | ((d: T) => T); | ||
import { FactoryCollection, FactoryModel } from '@airma/react-state'; | ||
import { ComponentType, FC, ReactNode } from 'react'; | ||
export declare type ResponseType<T> = (data: ResponseParam<T>) => void; | ||
export declare type SideEffectCallback<T> = (response: ResponseType<T>) => any; | ||
export declare type PromiseResult<T> = { | ||
@@ -15,22 +12,86 @@ data: T | undefined; | ||
export declare function useSideEffect<T, C extends SideEffectCallback<T>>( | ||
callback: C, | ||
defaultState: T, | ||
config?: { deps?: any[]; manual?: boolean } | any[] | ||
): [T, () => ReturnType<C>, { destroy: () => any }]; | ||
export declare type StrategyType<T = any> = ( | ||
getCurrentState: () => PromiseResult<T>, | ||
runner: () => Promise<PromiseResult<T>>, | ||
storeRef: { current: any } | ||
) => Promise<PromiseResult<T>>; | ||
export declare function useQuery<T>( | ||
callback: () => Promise<T>, | ||
config?: { deps?: any[]; manual?: boolean } | any[] | ||
): [PromiseResult<T>, () => Promise<PromiseResult<T>>]; | ||
export declare type PromiseEffectCallback<T> = (...params: any[]) => Promise<T>; | ||
export declare type ModelPromiseEffectCallback< | ||
E extends PromiseEffectCallback<any> | ||
> = FactoryModel< | ||
(st: PromiseResult & { version?: number }) => { | ||
state: PromiseResult; | ||
version: number; | ||
setState: (s: PromiseResult) => PromiseResult & { version?: number }; | ||
trigger: () => PromiseResult & { version?: number }; | ||
} | ||
> & { | ||
effect: [E]; | ||
}; | ||
export declare type QueryConfig<T, C extends PromiseEffectCallback<T>> = { | ||
deps?: any[]; | ||
variables?: Parameters<C>; | ||
strategy?: StrategyType; | ||
manual?: boolean; | ||
}; | ||
export declare type MutationConfig<T, C extends PromiseEffectCallback<T>> = { | ||
variables?: Parameters<C>; | ||
strategy?: StrategyType; | ||
}; | ||
declare type PCR< | ||
T extends PromiseEffectCallback<any> | ModelPromiseEffectCallback<any> | ||
> = T extends PromiseEffectCallback<infer R> | ||
? R | ||
: T extends ModelPromiseEffectCallback<infer C> | ||
? PCR<C> | ||
: never; | ||
declare type MCC< | ||
T extends PromiseEffectCallback<any> | ModelPromiseEffectCallback<any> | ||
> = T extends PromiseEffectCallback<any> | ||
? T | ||
: T extends ModelPromiseEffectCallback<infer C> | ||
? C | ||
: never; | ||
export declare function useQuery< | ||
D extends PromiseEffectCallback<any> | ModelPromiseEffectCallback<any> | ||
>( | ||
callback: D, | ||
config?: QueryConfig<PCR<D>, MCC<D>> | Parameters<MCC<D>> | ||
): [PromiseResult<PCR<D>>, () => Promise<PromiseResult<PCR<D>>>]; | ||
export declare function useMutation< | ||
T, | ||
C extends (...params: any[]) => Promise<T> | ||
D extends PromiseEffectCallback<any> | ModelPromiseEffectCallback<any> | ||
>( | ||
callback: C, | ||
config?: { after?: (r: PromiseResult<T>) => any; repeatable?: boolean } | ||
): [ | ||
PromiseResult<T>, | ||
(...params: Parameters<typeof callback>) => Promise<PromiseResult<T>> | ||
]; | ||
callback: D, | ||
config?: MutationConfig<PCR<D>, MCC<D>> | Parameters<MCC<D>> | ||
): [PromiseResult<PCR<D>>, () => Promise<PromiseResult<PCR<D>>>]; | ||
export declare function useAsyncEffect< | ||
D extends ModelPromiseEffectCallback<any> | ||
>(factory: D): [PromiseResult<PCR<D>>, () => void]; | ||
export declare function asyncEffect< | ||
E extends (...params: any[]) => Promise<any>, | ||
T = E extends (...params: any[]) => Promise<infer R> ? R : never | ||
>(effectCallback: E): ModelPromiseEffectCallback<E>; | ||
export declare const EffectProvider: FC<{ | ||
value: FactoryCollection; | ||
children?: ReactNode; | ||
}>; | ||
export declare function withEffectProvider( | ||
models: FactoryCollection | ||
): <P extends object>(component: ComponentType<P>) => typeof component; | ||
export declare const Strategy = { | ||
debounce: (op: { time: number }) => StrategyType, | ||
once: () => StrategyType | ||
}; |
{ | ||
"private": false, | ||
"name": "@airma/react-effect", | ||
"version": "15.0.0", | ||
"version": "15.1.0", | ||
"description": "This is a react async state management tool", | ||
"main": "dist/index.js", | ||
"license": "MIT", | ||
"author": "Jimmy.Harding", | ||
"typings": "index.d.ts", | ||
"scripts": { | ||
"lint": "eslint src --fix --ext .ts,.tsx ", | ||
"lint-init": "eslint --init", | ||
"build": "webpack", | ||
"analyze": "webpack --config webpack.analyze.js", | ||
"test": "jest --coverage", | ||
"docs": "docsify serve ./docs" | ||
}, | ||
"homepage": "https://filefoxper.github.io/airma/#/react-effect/index", | ||
"repository": { | ||
@@ -21,3 +13,3 @@ "type": "git", | ||
}, | ||
"homepage": "https://filefoxper.github.io/airma/#/react-effect/index", | ||
"main": "dist/index.js", | ||
"files": [ | ||
@@ -27,16 +19,13 @@ "dist", | ||
], | ||
"keywords": [ | ||
"react", | ||
"hook", | ||
"side-effects", | ||
"state-management", | ||
"async", | ||
"async-state", | ||
"closures", | ||
"state", | ||
"typescript", | ||
"browser" | ||
], | ||
"license": "MIT", | ||
"scripts": { | ||
"analyze": "webpack --config webpack.analyze.js", | ||
"build": "webpack", | ||
"docs": "docsify serve ./docs", | ||
"lint": "eslint src --fix --ext .ts,.tsx ", | ||
"lint-init": "eslint --init", | ||
"test": "jest --coverage" | ||
}, | ||
"typings": "index.d.ts", | ||
"dependencies": { | ||
"@airma/react-state": "^17.0.8", | ||
"react": ">=16.8.0", | ||
@@ -46,4 +35,2 @@ "react-dom": ">=16.8.0" | ||
"devDependencies": { | ||
"prettier": "2.3.2", | ||
"typescript": "4.9.4", | ||
"esbuild": "^0.16.6", | ||
@@ -58,7 +45,21 @@ "eslint": "^8.27.0", | ||
"pre-commit": "^1.2.2", | ||
"prettier": "2.3.2", | ||
"prettier-eslint": "^12.0.0", | ||
"prettier-eslint-cli": "^5.0.1", | ||
"regenerator-runtime": "0.13.5", | ||
"rewire": "5.0.0" | ||
} | ||
"rewire": "5.0.0", | ||
"typescript": "4.9.4" | ||
}, | ||
"keywords": [ | ||
"async", | ||
"async-state", | ||
"browser", | ||
"closures", | ||
"hook", | ||
"react", | ||
"side-effects", | ||
"state", | ||
"state-management", | ||
"typescript" | ||
] | ||
} |
541
README.md
@@ -13,13 +13,95 @@ [![npm][npm-image]][npm-url] | ||
This tool is used for managing the side effect state of react app. | ||
`@airma/react-effect` is designed for managing the asynchronous effect state for react components. | ||
## async effect | ||
## Why effects | ||
There are two async effects currently, `useQuery` and `useMutation`. They can accept a Promise callback, and returns the execution result of the Promise. | ||
React hook system is designed for synchronous render usage. But asynchronous operations are often used in components, so, take the asynchronous code out of render is a good choice. That's why `useEffect` is useful in hook system, we can set the asynchronous in it, and run it out of the render time. | ||
### useQuery | ||
Good example: | ||
We can wrap a promise return callback to `useQuery`, when the dependecies changes, it querys data for you. | ||
```ts | ||
import {useEffect, useState} from 'react'; | ||
import {query} from './service'; | ||
const useQueryEffect = (variables)=>{ | ||
const [data, setData] = useState(undefined); | ||
const [isFetching, setFetching] = useState(false); | ||
const [error, setError] = useState(undefined); | ||
useEffect(()=>{ | ||
setFetching(true); | ||
// limit the asynchronous only in useEffect | ||
query(variables).then((d)=>{ | ||
// set the query result into state | ||
setData(d); | ||
setError(undefined); | ||
setFetching(false); | ||
},(e)=>{ | ||
setError(e); | ||
setFetching(false); | ||
}); | ||
},[variables]); // when variables change, run query | ||
// return state information out for render usage | ||
return {data, isFetching, error}; | ||
}; | ||
const App = memo(()=>{ | ||
...... | ||
const {data, isFetching, error} = useQueryEffect(variables); | ||
return ......; | ||
}); | ||
``` | ||
Not so good example: | ||
```ts | ||
import {memo, useState} from 'react'; | ||
import {query} from './service'; | ||
const App = memo(()=>{ | ||
const [data, setData] = useState(undefined); | ||
const [isFetching, setFetching] = useState(false); | ||
const [error, setError] = useState(undefined); | ||
// Use asynchronous callback directly | ||
// may affect the other operation codes, | ||
// and make asynchronous operations spread out in component | ||
const handleQuery = async (variables)=>{ | ||
setFetching(true); | ||
try { | ||
const d = await query(variables); | ||
setData(d); | ||
setError(undefined); | ||
} catch(e) { | ||
setError(e); | ||
} finally { | ||
setFetching(false); | ||
} | ||
}; | ||
// affected by asynchronous callback `handleQuery` | ||
const handleReset = async ()=>{ | ||
await handleQuery(defaultVariables); | ||
doSomething(); | ||
}; | ||
useEffect(()=>{ | ||
handleQuery(); | ||
},[]); | ||
return ......; | ||
}) | ||
``` | ||
Use asynchronous callback all over in component is not a good idea, we need concentrative controllers for limit asynchronous operations in less effects. Then we can have a simple synchronously render component. | ||
Now, Let's take some simple, but more powerful API to replace the code of good example above. | ||
## useQuery | ||
We can wrap a promise return callback to `useQuery`, when the dependecy varaibles change, it fetches data for you. | ||
```ts | ||
import React from 'react'; | ||
@@ -29,2 +111,7 @@ import {useQuery} from '@airma/react-effect'; | ||
type UserQuery = { | ||
name: string; | ||
username: string; | ||
} | ||
const cli = client(); | ||
@@ -36,13 +123,12 @@ | ||
// query method | ||
()=> | ||
(q: UserQuery)=> | ||
cli.rest('/api/user/list'). | ||
setParams(query). | ||
setParams(q). | ||
get<User[]>(), | ||
// when the elements of dependencies `[query]` changes, | ||
// or the first time of the hook `useQuery` is loaded, | ||
// it execute the query method. | ||
// dependency vairables change, | ||
// the query method runs with the newest variables. | ||
[query] | ||
); | ||
const { | ||
// User[] | ||
// User[] | undefined | ||
data, | ||
@@ -83,3 +169,3 @@ // boolean | ||
const { | ||
// User[] | ||
// User[] | undefined | ||
data, | ||
@@ -96,3 +182,3 @@ // boolean | ||
const { | ||
// User[] | ||
// User[] | undefined | ||
data, | ||
@@ -116,3 +202,3 @@ // boolean | ||
The manual execution is not recommend, you may accept an abandoned result, if the execution is not the newest one, in that case, you may have a different result with the hook `useQuery` result. | ||
The manual execution is not recommend, you may accept an abandoned result, if the execution is not the newest one, in that case, you may have a different result with the hook `useQuery` result. And we have talked the problem about asynchronous code spread out in component. | ||
@@ -137,6 +223,8 @@ ### useMutation | ||
setBody(u). | ||
post<User>() | ||
post<User>(), | ||
// set variables | ||
[user] | ||
); | ||
const { | ||
// User | ||
// User | undefined | ||
data, | ||
@@ -151,15 +239,6 @@ // boolean | ||
const handleClick = async ()=>{ | ||
const { | ||
// User[] | ||
data, | ||
// boolean | ||
isFetching, | ||
// any | ||
error, | ||
// boolean | ||
isError, | ||
// boolean | ||
abandon | ||
} = await execute(); | ||
const handleClick = ()=>{ | ||
// it returns a promise result, | ||
// but we recommoned you using it as a void returning callback | ||
execute(); | ||
} | ||
@@ -173,7 +252,7 @@ | ||
Sometimes we need an mutation to be inexecutable when the last execution is finished successly, we can use config `repeatable:false` to do this. | ||
Sometimes we need an mutation only can be executed once. We can take a `Strategy` like `Strategy.once`. | ||
```ts | ||
import React from 'react'; | ||
import {useMutation} from '@airma/react-effect'; | ||
import {useMutation, Strategy} from '@airma/react-effect'; | ||
import {client} from '@airma/restful'; | ||
@@ -191,10 +270,10 @@ | ||
post<User>(), | ||
// set repeatable false, | ||
// makes the mutation only one shot | ||
// set strategy | ||
{ | ||
repeatable:false | ||
variables: [user], | ||
strategy: Strategy.once() | ||
} | ||
); | ||
const { | ||
// User | ||
// User | undefined | ||
data, | ||
@@ -211,3 +290,3 @@ // boolean | ||
const { | ||
// User[] | ||
// User | undefined | ||
data, | ||
@@ -229,67 +308,104 @@ // boolean | ||
We often execute a query after a mutation is finished, we can set `after` callback into the config, and after the mutation is finished, it will execute the query. | ||
## state sharing | ||
We have provides a `EffectProvider` for sharing the state changes of `useQuery` and `useMutation`. | ||
```ts | ||
import React from 'react'; | ||
import {useMutation, useQuery} from '@airma/react-effect'; | ||
import {client} from '@airma/restful'; | ||
import React, {memo} from 'react'; | ||
import { client } from '@airma/restful'; | ||
import { useModel, useSelector, factory } from '@airma/react-state'; | ||
import { EffectProvider, asyncEffect, useAsyncEffect } from '@airma/react-effect'; | ||
type UserQuery = {name: string, username: string}; | ||
const cli = client(); | ||
const App = ()=>{ | ||
...... | ||
const userQueryModel = (state: UserQuery)=>{ | ||
const {name, username} = state; | ||
return { | ||
name, | ||
username, | ||
state, | ||
changeName(e: ChangeEvent){ | ||
return {username, name: e.target.value}; | ||
}, | ||
changeUsername(e: ChangeEvent){ | ||
return {name, username: e.target.value}; | ||
} | ||
} | ||
} | ||
const [queryResult, executeQuery] = useQuery(()=>..., [...]); | ||
const [user, setUser] = useState({name:'', username:''}); | ||
const [result, execute] = useMutation( | ||
// mutation method | ||
(u:User)=> | ||
cli.rest('/api/user'). | ||
setBody(u). | ||
post<User>(), | ||
// set after callback, | ||
// it accepts the async execution result of mutation, | ||
// and runs after the mutation is finished. | ||
const queryUsers = (query:UserQuery)=> cli.rest('/api/user/list'). | ||
setParams(query). | ||
get<User[]>(); | ||
const models = { | ||
userQuery: factory(userQueryModel), // make a customized model key | ||
queryUsers: asyncEffect(queryUsers) // make an effect model key | ||
}; | ||
const Condition = memo(()=>{ | ||
const { | ||
name, | ||
username, | ||
changeName, | ||
changeUsername | ||
} = useModel(models.userQuery); | ||
// useAsyncEffect can accept the query state changes | ||
// from `models.queryUsers`, | ||
// it also can trigger it query again by `trigger`. | ||
const [{isFetching}, trigger] = useAsyncEffect(models.queryUsers); | ||
return ( | ||
<div> | ||
<input type="text" value={name} onChange={changeName}/> | ||
<input | ||
type="text" | ||
value={username} | ||
onChange={changeUsername} | ||
/> | ||
{/* we disable query button, */} | ||
{/* when the query is fetching */} | ||
<button | ||
disabled={isFetching} | ||
onClick={trigger} | ||
> | ||
query | ||
</button> | ||
</div> | ||
) | ||
}); | ||
const Datasource = memo(()=>{ | ||
const q = useSelector(models.userQuery,s =>s.state); | ||
const [ | ||
{ | ||
repeatable:false, | ||
after:({isError})=>{ | ||
if ( !isError ) { | ||
executeQuery(); | ||
} | ||
} | ||
data, | ||
isFetching, | ||
error, | ||
isError | ||
} | ||
] = useQuery(models.queryUsers, [q]); | ||
return ......; | ||
}); | ||
const App = memo(()=>{ | ||
// yes, | ||
// EffectProvider is just the `ModelProvider` in | ||
// `@airma/react-state`, | ||
// you can choose any of them as you wish. | ||
return ( | ||
<EffectProvider value={models}> | ||
<Condition/> | ||
<Datasource/> | ||
</EffectProvider> | ||
); | ||
const { | ||
// User | ||
data, | ||
// boolean | ||
isFetching, | ||
// any | ||
error, | ||
// boolean | ||
isError | ||
} = result; | ||
const handleClick = async ()=>{ | ||
const { | ||
// User[] | ||
data, | ||
// boolean | ||
isFetching, | ||
// any | ||
error, | ||
// boolean | ||
isError, | ||
// boolean | ||
abandon | ||
} = await execute(user); | ||
} | ||
...... | ||
} | ||
}) | ||
``` | ||
The `after` callback can accepts a async execution result. | ||
Now, you can share the query or mutation state any where in a `EffectProvider`. Because the `EffectProvider` is `ModelProvider`, so, they have same features, for example, the useQuery or useAsynEffect find the key in parent Providers, the middle Provider will not block them. You can refer to [ModelProvider](https://filefoxper.github.io/airma/#/react-state/feature?id=scope-state) in [@airma/react-state](https://filefoxper.github.io/airma/#/react-state/index). | ||
### async execution result | ||
## async execution result | ||
@@ -315,89 +431,49 @@ The promise result is a unitary result format for both useQuery and useMutation. | ||
``` | ||
## API | ||
## useSideEffect | ||
### useQuery | ||
If you want to make a side effect state management without promise, you can use this API. | ||
To execute a query promise callback. | ||
```ts | ||
import React from 'react'; | ||
import {useSideEffect} from '@airma/react-effect'; | ||
const App = ()=>{ | ||
const [second, execute] = useSideEffect(response => { | ||
const id = window.setInterval(() => { | ||
response(s => s + 1); | ||
}, 1000); | ||
return () => clearInterval(id); | ||
}, 0); // 0 is the default state | ||
} | ||
function useQuery< | ||
D extends PromiseEffectCallback<any> | ModelPromiseEffectCallback<any> | ||
>( | ||
callback: D, | ||
config?: QueryConfig<PCR<D>, MCC<D>> | Parameters<MCC<D>> | ||
): [PromiseResult<PCR<D>>, () => Promise<PromiseResult<PCR<D>>>]; | ||
``` | ||
As the proto hook of `useQuery`, you can also use the config and dependencies like `useQuery`. | ||
parameters: | ||
```ts | ||
import React from 'react'; | ||
import {useSideEffect} from '@airma/react-effect'; | ||
* callback - a callback returns a promise, or a effect model. When it is a `effect model`, the query result will be shared out to any place in a EffectProvider. | ||
* config - it is optional. If you set nothing, it means you want to execute it manually. It can be an tuple array as parameters for callback. It can be a config object to set features of this query. | ||
const App = ()=>{ | ||
const [state, setState] = useState(...); | ||
const [second, execute] = useSideEffect(response => { | ||
const id = window.setInterval(() => { | ||
response(s => s + 1); | ||
}, 1000); | ||
return () => clearInterval(id); | ||
}, 0, [state]); | ||
// when state change, it will clear last interval, | ||
// then setInterval again. | ||
} | ||
``` | ||
config: | ||
You can start it manually. | ||
* variables - you can set an array as parameters for query, when the elements change, the query callback runs. | ||
* deps - you can set an array as dependencies, sometimes you may want to drive query callback running by the different dependencies with variables. | ||
* manual - set manual `true`, means you want to execute the query manually, then the deps and variables change will not affect the query callback running. | ||
* strategy - you can set a strategy function to make query callback running with the strategy you want, for example: `debounce`, `once`. | ||
```ts | ||
import React from 'react'; | ||
import {useSideEffect} from '@airma/react-effect'; | ||
returns: | ||
const App = ()=>{ | ||
const [state, setState] = useState(...); | ||
const [second, execute] = useSideEffect(response => { | ||
const id = window.setInterval(() => { | ||
response(s => s + 1); | ||
}, 1000); | ||
return () => clearInterval(id); | ||
}, 0, {manual:true}); | ||
// use manual execution | ||
} | ||
``` | ||
You can destroy it manualy. Yes, the destroy function is not exist in `useQuery` result. | ||
```ts | ||
import React from 'react'; | ||
import {useSideEffect} from '@airma/react-effect'; | ||
const App = ()=>{ | ||
const [state, setState] = useState(...); | ||
const [second, execute, destroy] = useSideEffect(response => { | ||
const id = window.setInterval(() => { | ||
response(s => s + 1); | ||
}, 1000); | ||
return () => clearInterval(id); | ||
}, 0); | ||
// destroy the side effect will clear interval forcely, | ||
// if it has been created. | ||
const handleDestroy=()=>destroy(); | ||
} | ||
[ | ||
result, | ||
execute | ||
] | ||
``` | ||
## API | ||
### useMutation | ||
### useQuery | ||
To execute a mutation promise callback, it can only be drived manually by calling the returning method `execute`. | ||
To execute a query promise callback. | ||
```ts | ||
export declare function useQuery<T>( | ||
callback: () => Promise<T>, | ||
config?: { deps?: any[]; manual?: boolean } | any[] | ||
): [PromiseResult<T>, () => Promise<PromiseResult<T>>]; | ||
function useMutation< | ||
D extends PromiseEffectCallback<any> | ModelPromiseEffectCallback<any> | ||
>( | ||
callback: D, | ||
config?: MutationConfig<PCR<D>, MCC<D>> | Parameters<MCC<D>> | ||
): [PromiseResult<PCR<D>>, () => Promise<PromiseResult<PCR<D>>>]; | ||
``` | ||
@@ -407,5 +483,10 @@ | ||
* callback - a callback returns a promise, and it should has no parameters. | ||
* config - it is optional, if you set nothing, the query will be executed once when the hook is mounted, if you set an array dependencies for it, it querys when the hook is mounted or the dependencies element changes. Set `{ manual:true }` allows you execute it manually. | ||
* callback - a callback returns a promise, or a effect model. When it is a `effect model`, the query result will be shared out to any place in a EffectProvider. | ||
* config - it is optional. It can be an tuple array as parameters for callback. It can be a config object to set features of this mutation. | ||
config: | ||
* variables - you can set an array as parameters for query, when the elements change, the mutation callback runs. | ||
* strategy - you can set a strategy function to make query callback running with the strategy you want, for example: `debounce`, `once`. | ||
returns: | ||
@@ -420,17 +501,11 @@ | ||
### useMutation | ||
### asyncEffect | ||
To execute a mutation promise callback. | ||
It is used to generate a `effect model` with effect( promise ) callback. We can provide it as a key to `EffectProvider` or [ModelProvider](https://filefoxper.github.io/airma/#/react-state/api?id=modelprovider) in `@airma/react-state` for state sharing. And use `useQuery` or `useMutation` to link it, and fetching the query state. | ||
```ts | ||
export declare function useMutation< | ||
T, | ||
C extends (...params: any[]) => Promise<T> | ||
>( | ||
callback: C, | ||
config?: { after?: () => any; repeatable?: boolean } | ||
): [ | ||
PromiseResult<T>, | ||
(...params: Parameters<typeof callback>) => Promise<PromiseResult<T>> | ||
]; | ||
function asyncEffect< | ||
E extends (...params: any[]) => Promise<any>, | ||
T = E extends (...params: any[]) => Promise<infer R> ? R : never | ||
>(effectCallback: E): ModelPromiseEffectCallback<E>; | ||
``` | ||
@@ -440,5 +515,22 @@ | ||
* callback - a callback returns a promise, it can accept parameters, when execute it, you need to pass paramters for it. | ||
* config - it is optional. Set `repeatable: true` limits the execution only can work once, if the execution is successed. the `after` callback will be called, when the execution is finished. | ||
* effectCallback - a callback returns a promise. | ||
returns | ||
A [react-state factory model](https://filefoxper.github.io/airma/#/react-state/api?id=factory) with effect( promise ) callback. | ||
### useAsyncEffect | ||
It is used to accept the state change from `useQuery` or `useMutation` with a same `effect model`. | ||
```ts | ||
function useAsyncEffect< | ||
D extends ModelPromiseEffectCallback<any> | ||
>(effectModel: D): [PromiseResult<PCR<D>>, () => void]; | ||
``` | ||
parameters: | ||
* effectModel - an `effect model` created by `asyncEffect` API. | ||
returns: | ||
@@ -449,39 +541,96 @@ | ||
result, | ||
execute | ||
trigger | ||
] | ||
``` | ||
### useSideEffect | ||
The trigger method is different with `execute` method returned by `useQuery` and `useMutation`. It returns void, that means it can not be `await`. | ||
To make a side effect state management. | ||
### EffectProvider | ||
You can refer it to [ModelProvider](https://filefoxper.github.io/airma/#/react-state/api?id=modelprovider) in `@airma/react-state`. | ||
### withEffectProvider | ||
You can refer it to [withModelProvider](https://filefoxper.github.io/airma/#/react-state/api?id=withmodelprovider) in `@airma/react-state`. | ||
### Strategy | ||
It provides some useful effect running `Strategy` for you. | ||
```ts | ||
export declare type ResponseParam<T> = T | ((d: T) => T); | ||
const Strategy = { | ||
debounce: (op: { time: number }) => StrategyType, | ||
once: () => StrategyType | ||
}; | ||
``` | ||
export declare type ResponseType<T> = (data: ResponseParam<T>) => void; | ||
You can use it to the config `strategy` in `useQuery` and `useMutation`. | ||
export declare type SideEffectCallback<T> = (response: ResponseType<T>) => any; | ||
#### debounce | ||
export declare function useSideEffect<T, C extends SideEffectCallback<T>>( | ||
callback: C, | ||
defaultState: T, | ||
config?: { deps?: any[]; manual?: boolean } | any[] | ||
): [T, () => ReturnType<C>, { destroy: () => any }]; | ||
you can set a debounce time to it. like: | ||
```ts | ||
useQuery(callback,{ | ||
variables:[...], | ||
strategy: Strategy.debounce({time:300}) | ||
}) | ||
``` | ||
parameters: | ||
Then the query callback runs with this debounce strategy. | ||
* callback - a callback accept a response callback as a parameter. | ||
* defaultState - you need to give it a defaultState. | ||
* config - it is optional, if you set nothing, the query will be executed once when the hook is mounted, if you set an array dependencies for it, it querys when the hook is mounted or the dependencies element changes. Set `{ manual:true }` allows you execute it manually. | ||
#### once | ||
The response callback is like a setState from `useState`. You can use it to set the side effect state. | ||
It is used to force the query or mutation callback only runs once, if no error comes out. | ||
returns: | ||
## Write Strategy | ||
You can write Strategy yourself, it is a simple work. | ||
```ts | ||
[ | ||
result, | ||
execute | ||
] | ||
export type StrategyType<T = any> = ( | ||
getCurrentState: () => PromiseResult<T>, | ||
runner: () => Promise<PromiseResult<T>>, | ||
storeRef: { current: any } | ||
) => Promise<PromiseResult<T>>; | ||
``` | ||
A Strategy function accepts 3 parameters: | ||
* getCurrentState - A function returns a current promise result. | ||
* runner - the wrapped effect callback, returns a promise. | ||
* storeRef - a store for your Strategy, you can store any thing which is helpful for your Strategy. | ||
For example: | ||
```ts | ||
function once(): StrategyType { | ||
// this inner function is a Strategy | ||
return function oc(getCurrentState, runner, storeRef) { | ||
// It store a boolean value to tell | ||
// if the effect callback is started. | ||
// If this value is true, | ||
// it returns a current state promise, | ||
// and mark it to abandoned. | ||
if (storeRef.current) { | ||
return new Promise(resolve => { | ||
const currentState = getCurrentState(); | ||
resolve({ ...currentState, abandon: true }); | ||
}); | ||
} | ||
// If the store value is false, | ||
// it marks it as started, | ||
// then truely start it. | ||
storeRef.current = true; | ||
return runner().then(d => { | ||
if (d.isError) { | ||
// if the promise is error, | ||
// mark it to false again, | ||
// the the effect callback can be started again. | ||
storeRef.current = false; | ||
} | ||
return d; | ||
}); | ||
}; | ||
} | ||
``` |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
55559
81
619
3
3
+ Added@airma/react-state@^17.0.8
+ Added@airma/core@17.2.5(transitive)
+ Added@airma/react-state@17.3.6(transitive)