@airma/react-state
Advanced tools
Comparing version 18.5.4 to 18.5.5
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react"),require("@airma/react-hooks-core")):"function"==typeof define&&define.amd?define(["react","@airma/react-hooks-core"],e):"object"==typeof exports?exports["@airma/react-state"]=e(require("react"),require("@airma/react-hooks-core")):t["@airma/react-state"]=e(t.react,t["@airma/react-hooks-core"])}(self,(function(t,e){return function(){"use strict";var r={309:function(t){t.exports=e},156:function(e){e.exports=t}},n={};function o(t){var e=n[t];if(void 0!==e)return e.exports;var c=n[t]={exports:{}};return r[t](c,c.exports,o),c.exports}o.d=function(t,e){for(var r in e)o.o(e,r)&&!o.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var c={};return function(){function t(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function e(e,r){if(e){if("string"==typeof e)return t(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?t(e,r):void 0}}function r(r){return function(e){if(Array.isArray(e))return t(e)}(r)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(r)||e(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function u(t,r){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,c=[],u=!0,i=!1;try{for(r=r.call(t);!(u=(n=r.next()).done)&&(c.push(n.value),!e||c.length!==e);u=!0);}catch(t){i=!0,o=t}finally{try{u||null==r.return||r.return()}finally{if(i)throw o}}return c}}(t,r)||e(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.")}()}o.r(c),o.d(c,{ConfigProvider:function(){return X},Provider:function(){return z},createKey:function(){return Q},model:function(){return Z},provide:function(){return J},shallowEqual:function(){return N},useControlledModel:function(){return F},useModel:function(){return Y},useSelector:function(){return H},useSignal:function(){return $}});var i=o(156),a=o(309);function f(t){return f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},f(t)}function s(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function l(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?s(Object(r),!0).forEach((function(e){n(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):s(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function d(t,e,r,n){var o=Object.keys(r),c={};return o.forEach((function(r){c[r]={get:function(){return n.get?n.get(t,r,e):t[r]},set:function(o){if(n.set){if(!n.set(t,r,o,e))throw new Error("".concat(r," in proxy target is not mutable"))}else t[r]=o}}})),c}var p=function(t,e){return"function"!=typeof Proxy?function(t,e){var r={},n=d(t,r,t,e),o=d(t,r,Object.getPrototypeOf(t),e);return Object.defineProperties(r,l(l({},o),n)),r}(t,e):new Proxy(t,e)};function v(t){return t&&"object"===f(t)}function h(t,e){if(Object.is(t,e))return!0;if(!v(t)||!v(e))return!1;var r=Object.keys(t),n=Object.keys(e);if(r.length!==n.length)return!1;var o=t,c=e;return!r.some((function(t){return!Object.prototype.hasOwnProperty.call(c,t)}))&&!n.some((function(t){var e=c[t],r=o[t];return!Object.is(e,r)}))}function y(){}function g(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function b(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?g(Object(r),!0).forEach((function(e){n(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):g(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}var m={},O="@@lazyIdentify";function w(t,e){t.forEach((function(t){t(e)}))}function j(t,e){return t(e)}function S(t,e){return function(n){if(null!=n){var o=t.dispatching;if(function(e){var r=t.dispatching;if(!r){var n={value:e};return n.tail=n,void(t.dispatching=n)}var o=r.tail;if(o){var c={prev:o,value:e};o.next=c,r.tail=c}}(n),!o){for(var c=function(){var n=t.dispatching;if(n){var o=r(t.dispatches);try{"function"==typeof e.batchUpdate&&o.length?e.batchUpdate((function(){w(o,n.value)})):w(o,n.value)}catch(e){throw t.dispatching=void 0,e}!function(){var e=t.dispatching;if(e){var r=e.next,n=e.tail;if(n===e||!r)return e.tail=void 0,t.dispatching=void 0,e;r.prev=void 0;var o=r;o.tail=n,t.dispatching=o}}()}else t.dispatching=void 0};t.dispatching;)c();!function(){var e=t.temporaryDispatches;e.length||(t.dispatches=t.dispatches.concat(e),t.temporaryDispatches=[]);var r={state:t.state,prevState:t.state,instance:t.current,prevInstance:t.current,type:"",method:null};e.forEach((function(t){t(r)}))}()}}}}function E(t,e,r){var n=t.current[e];if(n.noActionMethod&&n.noActionMethod===m)return n;if(r.methodsCache[e])return r.methodsCache[e];var o=function n(){for(var o=arguments.length,c=new Array(o),u=0;u<o;u++)c[u]=arguments[u];var i=t.current[e].apply(void 0,c),a=t.reducer,f=t.controlled;if(t.isDestroyed)return i;var s={type:e,state:i,prevState:i,instance:t.current,prevInstance:t.current,method:n};if(f)return t.notify(s),i;var l=t.state,d=t.current;t.current=j(a,i),t.state=i,t.version+=1,t.cacheState={state:i};var p={type:e,state:i,prevState:l,instance:t.current,prevInstance:d,method:n},v=r.middleWare?r.middleWare(p):p;return t.notify(v),i};return o.dispatchType=e,o.dispatchId=r.sourceTo,r.methodsCache[e]=o,o}function P(t,e){t.cacheGenerators[e]&&(t.cacheGenerators[e]=null)}function D(t,e){var r=t.current[e];if(!r||r.cacheGenerator!==D)return P(t,e),r;if(null==r.deps)return P(t,e),{get:function(){var r=t.current[e];if(null==r)throw new Error("This field is not exist now.");if(!C(r))throw new Error("This field is changed to be a normal object");return r.callback()}};var n=t.cacheGenerators[e];if(n&&h(n.deps,r.deps))return n.out;var o={get:function(){var r=t.current[e];if(null==r)throw new Error("This field is not exist now.");if(!C(r))throw new Error("This field is changed to be a normal object");var n=t.cacheGenerators[e];if(!n){var c=r.callback();return t.cacheGenerators[e]={value:c,deps:r.deps,out:o},c}var u=n.value;if(h(n.deps,r.deps))return u;t.cacheGenerators[e]=null;var i=r.callback();return t.cacheGenerators[e]={value:i,deps:r.deps,out:o},i}};return o}function C(t){return!!t&&"object"===f(t)&&t.cacheGenerator===D}function k(t,e,n){var o=j(t,e),c=n||{},u=c.controlled,i={batchUpdate:c.batchUpdate},a={version:0,isDestroyed:!1,current:o,reducer:t,dispatch:null,dispatches:[],temporaryDispatches:[],cacheMethods:{},cacheGenerators:{},state:e,cacheState:null,controlled:!!u,notify:y,isSubscribing:!1};function f(t,e){var r=a.state;if(!a.isDestroyed){var n=!(!e||!e.isDefault),o=!(!e||!e.ignoreDispatch);if(!n||!a.cacheState){var c=e?e.state:r;c===r||a.controlled||(a.version+=1);var u=r,i=a.current;a.reducer=t,a.state=c,a.cacheState=e&&e.cache?{state:e.state}:a.cacheState,a.current=j(t,a.state),r===a.state||n||o||a.notify({state:a.state,prevState:u,instance:a.current,prevInstance:i,type:"",method:null})}}}function s(){if(!a.isDestroyed){for(var t={state:a.state,prevState:a.state,instance:a.current,prevInstance:a.current,type:"",method:null},e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];r.forEach((function(e){e(t)}))}}function l(t){var e=a.dispatches,n=a.temporaryDispatches,o=a.controlled;a.isDestroyed||([].concat(r(e),r(n)).indexOf(t)>=0||(o?a.dispatches=[t]:(a.temporaryDispatches.push(t),a.dispatching||(a.dispatches=[].concat(r(a.dispatches),r(a.temporaryDispatches)),a.temporaryDispatches=[],s.apply(void 0,r(n))))))}function d(t){if(!t)return a.dispatches=[],void(a.temporaryDispatches=[]);var e=a.dispatches,r=a.temporaryDispatches;a.dispatches=e.filter((function(e){return e!==t})),a.temporaryDispatches=r.filter((function(e){return e!==t}))}a.notify=S(a,i);var v=p(o,{get:function(t,e){var r=a.current[e];return C(r)?r.cacheGenerator(a,e):Object.prototype.hasOwnProperty.call(a.current,e)&&"function"==typeof r?E(a,e,{methodsCache:a.cacheMethods}):r}});return{agent:v,getReducer:function(){return a.reducer},getCacheState:function(){return a.cacheState},getState:function(){return a.state},getVersion:function(){return a.version},getCurrent:function(t){if(a.isDestroyed)return a.current;if(Array.isArray(a.current))return a.current.map((function(e,r){return C(e)?e.cacheGenerator(a,r.toString()):"function"==typeof e?t?E(a,r.toString(),b(b({},t),{},{sourceTo:v[r]})):v[r]:e}));var e=Object.keys(a.current),r=b({},a.current);return e.forEach((function(e){var n=r[e];C(n)?r[e]=n.cacheGenerator(a,e):"function"==typeof n&&(r[e]=t?E(a,e,b(b({},t),{},{sourceTo:v[e]})):v[e])})),r},getStoreInstance:function(){return a.current},getListeners:function(){return a.dispatches},update:f,updateState:function(t){f(a.reducer,{state:t,cache:!0})},notice:function(){s(a.notify)},tunnel:function(t){return{connect:function(){l(t)},disconnect:function(){d(t)}}},destroy:function(){a.dispatch=null,a.dispatches=[],function(t){var e=t.dispatching;if(e){for(var r=e;r;){var n=r.next;r.next=void 0,r.prev=void 0,n&&(n.prev=void 0),r=n}e.tail=void 0,t.dispatching=void 0}}(a),a.temporaryDispatches=[],a.notify=y,a.isDestroyed=!0,a.cacheMethods={},a.cacheGenerators={},i.batchUpdate=void 0},renew:function(t){if(a.isDestroyed=!1,a.notify=S(a,i),t){var e=t.getState,r=t.getReducer;a.cacheState=null,f(r(),{state:e(),ignoreDispatch:!0})}},connect:function(t){l(t)},disconnect:d,optimize:function(t){i.batchUpdate!==t&&(i.batchUpdate=void 0,i.batchUpdate=t)}}}function x(t){if(t.agent[O])throw new Error("A stateless connection should be initialized before it is accessed.")}function A(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];if("function"==typeof t&&"function"==typeof t.creation)return[{key:n.join("."),keys:n,factory:t,connection:t.creation(e)}];if(!t||"object"!==f(t))return[];var o=[],c=t;return Object.keys(c).forEach((function(t){var u=A(c[t],e,n.concat(t));o.push.apply(o,r(u))})),o}function M(t){return{get:function(e){var r=t.find((function(t){return t.factory===e||t.sourceFactory===e}));return r?r.connection:void 0}}}function R(t,e){var r=t;var n,o,c=A(t,e),u=(o=(n=c).map((function(t){return t.connection})),{collections:n,connections:o,instances:M(n)}),i={destroyed:!1,parent:null==e?void 0:e.parent,update:function(r,n){return r!==t||(null==n?void 0:n.parent)!==(null==e?void 0:e.parent)||i.destroyed?(i.parent=n?n.parent:void 0,function(t,e){var r=A(t,e),n=u.collections,o=M(r);n.forEach((function(t){null!=o.get(t.factory)&&t.connection.renew()}))}(r),i.destroyed=!1,i):i},get:function(t){return u.instances.get(t)},equal:function(t){return t===r},destroy:function(){u.connections.forEach((function(t){return t.destroy()})),i.destroyed=!0}};return i}function G(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function T(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?G(Object(r),!0).forEach((function(e){n(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):G(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}var I=(0,i.createContext)(void 0);function U(t){var e=(0,i.useRef)(null);return null==e.current?(e.current={result:t()},e.current.result):e.current.result}function F(t,e,r){return function(t,e,r,n){var o=(n||{}).disabled,c=k(t,e,{controlled:!0}),u=(0,a.usePersistFn)((function(t){var n=t.state;e!==n&&(o||r(n))})),f=c.tunnel(u);return(0,i.useEffect)((function(){return f.connect(),function(){f.disconnect()}})),(0,i.useEffect)((function(){return c.renew(),function(){c.destroy()}}),[]),c.getCurrent()}(t,e,r)}var W=(0,i.createContext)(null);function q(){var t=((0,i.useContext)(I)||{}).batchUpdate;return(0,i.useMemo)((function(){return{batchUpdate:t}}),[t])}var z=function(t){var e=t.keys,r=t.value,n=t.children,o=null!=e?e:r;if(null==o)throw new Error("You need to provide keys to `Provider`");var c=q().batchUpdate,u=(0,i.useContext)(W),a=U((function(){return R(o,{batchUpdate:c,parent:u||void 0})}));return(0,i.useEffect)((function(){return a.update(o,u||void 0),function(){a.destroy()}}),[a,o,u]),(0,i.createElement)(W.Provider,{value:a},n)};function V(t,e){if(e.connection)return e.connection;if(null!=t){var r=t.get(e);return!r&&t.parent?V(t.parent,e):r}}function L(){var t=(0,i.useRef)({}),e=(0,a.usePersistFn)((function(t){return t}));return{methodsCache:t.current,middleWare:e}}function _(t,e,r){var n=T(T({},{required:!1}),r),o=n.useDefaultState,c=n.signal,f=(0,i.useRef)(!1),s=(0,i.useRef)(!1),l=(0,i.useRef)(!1);s.current=!1,f.current=!1;var d=q().batchUpdate,v=(0,i.useRef)(!1),g=(0,i.useContext)(W),b=t.isFactory,m="function"==typeof b&&b(),O=m?V(g,t):void 0;if(m&&!O)throw new Error("The model in usage is a `store key`, it should match with a store created by `StoreProvider`.");var w=null!=O&&!!o&&null==O.getCacheState();w&&O.update(t,{state:e,cache:!0,ignoreDispatch:!0}),null!=O&&x(O);var j=L(),S=(0,i.useRef)(t),E=U((function(){return O||k(t,e)}));E.optimize(d);var P=O||E;S.current===t||O||(S.current=t,P.update(t));var D=u((0,i.useState)({agent:P.getCurrent(j),action:null}),2),C=D[0],A=D[1],M=(0,i.useRef)(P.getVersion()),R=(0,i.useRef)(null),G=C.agent,I={selection:[]};R.current=I.selection;var F=(0,a.usePersistFn)((function(t){var e=t;if(!v.current){var r,n,o,u,i=P.getVersion(),a=P.getCurrent(j);if(M.current!==i||e.payload)if(e.payload||(M.current=i),!c||s.current)if(!(c&&R.current&&(r=a,n=G,o=R.current,u=!0,o.forEach((function(t){r[t]!==n[t]&&(u=!1)})),u)))A({agent:a,action:e})}}));(0,i.useLayoutEffect)((function(){f.current=!0,l.current=s.current}));var z=P.tunnel(F);(0,i.useEffect)((function(){return z.connect(),function(){z.disconnect()}})),(0,i.useEffect)((function(){return v.current=!1,P.renew(),function(){v.current=!0,R.current=null,null==O&&P.destroy()}}),[]),(0,i.useEffect)((function(){w&&P.notice()}),[w]);var _=function(){s.current=!0,I.selection!==R.current&&(I.selection=null);var t=P.getCurrent(j);return p(t,{get:function(t,e,r){var n=t[e];if(null!=I.selection&&I.selection===R.current&&!v.current&&!f.current){var o={};I.selection.forEach((function(t){o[t]=!0})),o[e]||I.selection.push(e)}return n}})},K=(0,a.usePersistFn)(_),Y=l.current?_:K,$=function(t,e){function r(t){return null==t?null:t.dispatchId||t}return{useEffectWrap:function(n){var o=(0,i.useRef)(null),c=(0,i.useRef)(null),f=(0,i.useRef)(null),s=u((0,i.useState)(null),2),l=s[0],d=s[1],p=L(),v=(0,a.usePersistFn)((function(e){if(l!==e&&e.type){var n=t.getCurrent(p),u=o.current,i=f.current;if(null!=u||null!=i){var a=c.current,s=i?i(n):null;c.current=s,u&&u.length&&u.map(r).indexOf(r(e.method))<0||null!=s&&null!=a&&h(s,a)||d(e)}}})),g=t.tunnel(v);(0,i.useEffect)((function(){if(null==o.current&&null==f.current)return y;if(null!=o.current&&null==l)return y;var e=t.getCurrent(p);return n(e,l)}),[l]),(0,i.useEffect)((function(){if(null!=o.current||null!=f.current)return y;var r=t.getCurrent(p);return n(r,e)}),[e]),(0,i.useEffect)((function(){return g.connect(),function(){g.disconnect()}}),[]);var b={onActions:function(e){var r=e(t.getCurrent(p));if(!Array.isArray(r))throw new Error("The `filter callback` for method `on` should return an action method array.");return o.current=r.filter((function(t){return"function"==typeof t})),b},onChanges:function(t){return f.current=t,b}};return b},useWatchtWrap:function(e){var n=(0,i.useRef)(null),o=(0,i.useRef)(null),c=(0,i.useRef)(null),u=L(),f=(0,a.usePersistFn)((function(i){if(!i.type)return y;var a=t.getCurrent(u),f=n.current,s=c.current,l=o.current,d=s?s(a):null;return o.current=d,f&&f.length&&f.map(r).indexOf(r(i.method))<0||null!=d&&null!=l&&h(d,l)?y:e(a,i)})),s=t.tunnel(f);(0,i.useEffect)((function(){return s.connect(),function(){s.disconnect()}}),[]);var l={onActions:function(e){var r=e(t.getCurrent(u));if(!Array.isArray(r))throw new Error("The `filter callback` for method `on` should return an action method array.");return n.current=r.filter((function(t){return"function"==typeof t})),l},onChanges:function(t){return c.current=t,l}};return l}}}(P,C.action),B=$.useEffectWrap,H=$.useWatchtWrap;Y.useEffect=B,Y.useWatch=H;var J=G;if(c)return[P.getState(),J,P.updateState,Y];return[P.getState(),J,P.updateState,function(){return J}]}function K(t,e,r){var n=u(_(t,e,r),4),o=n[0],c=n[1];n[2];return[o,c,n[3]]}function Y(t,e){return u(K(t,e,{useDefaultState:arguments.length>1}),2)[1]}function $(t,e){return u(K(t,e,{useDefaultState:arguments.length>1,signal:!0}),3)[2]}var B=function(t){return'API "'.concat(t,'" can not work, there is no matched Provider with its store key.')};function H(t,e,r){var n=q().batchUpdate,o=(0,i.useContext)(W),c=L(),f=V(o,t);if(!f)throw new Error(B("useSelector"));x(f),f.optimize(n);var s=e(f.getCurrent(c)),l=(0,i.useRef)(!1),d=(0,i.useRef)(f.getVersion()),p=u((0,i.useState)({data:s}),2),v=p[0],h=p[1],y=(0,a.usePersistFn)((function(){if(!l.current){var t=f.getVersion();if(d.current!==t){d.current=t;var n=e(f.getCurrent(c));(function(t,e){return r?r(t,e):Object.is(t,e)})(v.data,n)||h({data:n})}}})),g=f.tunnel(y);return(0,i.useEffect)((function(){return g.connect(),function(){g.disconnect()}})),(0,i.useEffect)((function(){return l.current=!1,function(){l.current=!0}}),[]),v.data}function J(t){return function(e){return function(r){return(0,i.createElement)(z,{value:t},(0,i.createElement)(e,r))}}}var N=h,Q=function(t,e){return function(t,e,r){var o=function(e){return t(e)};return o.creation=function(t){return r?k((function(t){return n({},O,m)}),void 0,t):k(o,e,t)},o.static=function(){return function(t){var e=function(e){return t(e)};return e.payload=t.payload,e.connection=t.creation(),e.static=function(){return e},e.isFactory=t.isFactory,e}(o)},o.isFactory=function(){return!0},o}(t,e,arguments.length<2)},X=function(t){var e=t.value,r=t.children;return(0,i.createElement)(I.Provider,{value:e},r)},Z=function(t){var e=function(e){return t(e)};e.meta={};var n=function t(n,o){var c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],u=null!=o?o:arguments.length>0?Q(e,n):Q(e);var a={key:u,keys:c,useModel:function(t){var e=arguments.length?[u,t]:[u];return Y.apply(void 0,e)},useSignal:function(t){var e=arguments.length?[u,t]:[u];return $.apply(void 0,e)},useSelector:function(t,e){return H(u,t,e)},static:function(){var t=u.static();return{useModel:function(e){var r=arguments.length?[t,e]:[t];return Y.apply(void 0,r)},useSignal:function(e){var r=arguments.length?[t,e]:[t];return $.apply(void 0,r)},useSelector:function(e,r){return H(t,e,r)}}},provide:function(){return J([u].concat(r(c)))},provideTo:function(t){return J([u].concat(r(c)))(t)},Provider:function(t){var e=t.children;return(0,i.createElement)(z,{value:[u].concat(r(c))},e)}};return T(T({},a),{},{with:function(){for(var e=arguments.length,r=new Array(e),o=0;o<e;o++)r[o]=arguments[o];var i=c.concat(r.map((function(t){return"function"==typeof t?t:t.key})));return t(n,u,i)}})};return Object.assign(e,{useModel:function(t){var r=arguments.length?[e,t]:[e];return Y.apply(void 0,r)},useSignal:function(t){var r=arguments.length?[e,t]:[e];return $.apply(void 0,r)},useControlledModel:function(t,r){return F(e,t,r)},createStore:function(t){return arguments.length?n(t):n()}})};Z.create=Z,Z.createCacheField=function(t,e){var r=null==e?e:e.some((function(t){return C(t)&&null==t.deps}))?void 0:e.flatMap((function(t){return C(t)?t.deps:t}));return{callback:t,deps:r,cacheGenerator:D,get:function(){return t()}}},Z.createField=function(t,e){var r=null==e?e:e.some((function(t){return C(t)&&null==t.deps}))?void 0:e.flatMap((function(t){return C(t)?t.deps:t}));return{callback:t,deps:r,cacheGenerator:D,get:function(){return t()}}},Z.createMethod=function(t){var e=function(){return t.apply(void 0,arguments)};return Object.assign(e,t),e.noActionMethod=m,e}}(),c}()})); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react"),require("@airma/react-hooks-core")):"function"==typeof define&&define.amd?define(["react","@airma/react-hooks-core"],e):"object"==typeof exports?exports["@airma/react-state"]=e(require("react"),require("@airma/react-hooks-core")):t["@airma/react-state"]=e(t.react,t["@airma/react-hooks-core"])}(self,(function(t,e){return function(){"use strict";var r={309:function(t){t.exports=e},156:function(e){e.exports=t}},n={};function o(t){var e=n[t];if(void 0!==e)return e.exports;var c=n[t]={exports:{}};return r[t](c,c.exports,o),c.exports}o.d=function(t,e){for(var r in e)o.o(e,r)&&!o.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var c={};return function(){function t(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function e(e,r){if(e){if("string"==typeof e)return t(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?t(e,r):void 0}}function r(r){return function(e){if(Array.isArray(e))return t(e)}(r)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(r)||e(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function u(t,r){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,c=[],u=!0,i=!1;try{for(r=r.call(t);!(u=(n=r.next()).done)&&(c.push(n.value),!e||c.length!==e);u=!0);}catch(t){i=!0,o=t}finally{try{u||null==r.return||r.return()}finally{if(i)throw o}}return c}}(t,r)||e(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.")}()}o.r(c),o.d(c,{ConfigProvider:function(){return Q},Provider:function(){return q},createKey:function(){return N},model:function(){return X},provide:function(){return H},shallowEqual:function(){return J},useControlledModel:function(){return G},useModel:function(){return K},useSelector:function(){return B},useSignal:function(){return Y}});var i=o(156),a=o(309);function f(t){return f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},f(t)}function s(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function l(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?s(Object(r),!0).forEach((function(e){n(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):s(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function p(t,e,r,n){var o=Object.keys(r),c={};return o.forEach((function(r){c[r]={get:function(){return n.get?n.get(t,r,e):t[r]},set:function(o){if(n.set){if(!n.set(t,r,o,e))throw new Error("".concat(r," in proxy target is not mutable"))}else t[r]=o}}})),c}var d=function(t,e){return"function"!=typeof Proxy?function(t,e){var r={},n=p(t,r,t,e),o=p(t,r,Object.getPrototypeOf(t),e);return Object.defineProperties(r,l(l({},o),n)),r}(t,e):new Proxy(t,e)};function v(t){return t&&"object"===f(t)}function h(t,e){if(Object.is(t,e))return!0;if(!v(t)||!v(e))return!1;var r=Object.keys(t),n=Object.keys(e);if(r.length!==n.length)return!1;var o=t,c=e;return!r.some((function(t){return!Object.prototype.hasOwnProperty.call(c,t)}))&&!n.some((function(t){var e=c[t],r=o[t];return!Object.is(e,r)}))}function y(){}function g(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function b(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?g(Object(r),!0).forEach((function(e){n(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):g(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}var m={},O="@@lazyIdentify";function S(t,e){t.forEach((function(t){t(e)}))}function j(t,e){return t(e)}function w(t,e){return function(n){if(null!=n){var o=t.dispatching;if(function(e){var r=t.dispatching;if(!r){var n={value:e};return n.tail=n,void(t.dispatching=n)}var o=r.tail;if(o){var c={prev:o,value:e};o.next=c,r.tail=c}}(n),!o){for(var c=function(){var n=t.dispatching;if(n){var o=r(t.dispatches);try{"function"==typeof e.batchUpdate&&o.length?e.batchUpdate((function(){S(o,n.value)})):S(o,n.value)}catch(e){throw t.dispatching=void 0,e}!function(){var e=t.dispatching;if(e){var r=e.next,n=e.tail;if(n===e||!r)return e.tail=void 0,t.dispatching=void 0,e;r.prev=void 0;var o=r;o.tail=n,t.dispatching=o}}()}else t.dispatching=void 0};t.dispatching;)c();!function(){var e=t.temporaryDispatches;e.length||(t.dispatches=t.dispatches.concat(e),t.temporaryDispatches=[]);var r={state:t.state,prevState:t.state,instance:t.current,prevInstance:t.current,type:"",method:null};e.forEach((function(t){t(r)}))}()}}}}function P(t,e,r){var n=t.current[e];if(n.noActionMethod&&n.noActionMethod===m)return n;if(r.methodsCache[e])return r.methodsCache[e];var o=function n(){for(var o=arguments.length,c=new Array(o),u=0;u<o;u++)c[u]=arguments[u];var i=t.current[e].apply(void 0,c),a=t.reducer,f=t.controlled;if(t.isDestroyed)return i;var s={type:e,state:i,prevState:i,instance:t.current,prevInstance:t.current,method:n};if(f)return t.notify(s),i;var l=t.state,p=t.current;t.current=j(a,i),t.state=i,t.version+=1,t.cacheState={state:i};var d={type:e,state:i,prevState:l,instance:t.current,prevInstance:p,method:n},v=r.middleWare?r.middleWare(d):d;return t.notify(v),i};return o.dispatchType=e,o.dispatchId=r.sourceTo,r.methodsCache[e]=o,o}function E(t,e){var r=t.current[e];if(!r||r.cacheGenerator!==E)return function(t,e){t.cacheGenerators[e]&&(t.cacheGenerators[e]=null)}(t,e),r;var n=t.cacheGenerators[e];if(n&&(r.deps&&h(n.deps,r.deps)||!r.deps&&n.value===r.value))return n.out;var o={get:function(){var r=t.current[e];if(null==r)throw new Error("This field is not exist now.");if(!D(r))throw new Error("This field is changed to be a normal object");var n=t.cacheGenerators[e];if(!n)return r.value;var o=n.value,c=n.deps;return r.deps&&h(c,r.deps)||!r.deps&&o===r.value?o:r.value}};return t.cacheGenerators[e]={value:r.value,deps:r.deps,out:o},o}function D(t){return!!t&&"object"===f(t)&&t.cacheGenerator===E}function C(t,e,n){var o=j(t,e),c=n||{},u=c.controlled,i={batchUpdate:c.batchUpdate},a={version:0,isDestroyed:!1,current:o,reducer:t,dispatch:null,dispatches:[],temporaryDispatches:[],cacheMethods:{},cacheGenerators:{},state:e,cacheState:null,controlled:!!u,notify:y,isSubscribing:!1};function f(t,e){var r=a.state;if(!a.isDestroyed){var n=!(!e||!e.isDefault),o=!(!e||!e.ignoreDispatch);if(!n||!a.cacheState){var c=e?e.state:r;c===r||a.controlled||(a.version+=1);var u=r,i=a.current;a.reducer=t,a.state=c,a.cacheState=e&&e.cache?{state:e.state}:a.cacheState,a.current=j(t,a.state),r===a.state||n||o||a.notify({state:a.state,prevState:u,instance:a.current,prevInstance:i,type:"",method:null})}}}function s(){if(!a.isDestroyed){for(var t={state:a.state,prevState:a.state,instance:a.current,prevInstance:a.current,type:"",method:null},e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];r.forEach((function(e){e(t)}))}}function l(t){var e=a.dispatches,n=a.temporaryDispatches,o=a.controlled;a.isDestroyed||([].concat(r(e),r(n)).indexOf(t)>=0||(o?a.dispatches=[t]:(a.temporaryDispatches.push(t),a.dispatching||(a.dispatches=[].concat(r(a.dispatches),r(a.temporaryDispatches)),a.temporaryDispatches=[],s.apply(void 0,r(n))))))}function p(t){if(!t)return a.dispatches=[],void(a.temporaryDispatches=[]);var e=a.dispatches,r=a.temporaryDispatches;a.dispatches=e.filter((function(e){return e!==t})),a.temporaryDispatches=r.filter((function(e){return e!==t}))}a.notify=w(a,i);var v=d(o,{get:function(t,e){var r=a.current[e];return D(r)?r.cacheGenerator(a,e):Object.prototype.hasOwnProperty.call(a.current,e)&&"function"==typeof r?P(a,e,{methodsCache:a.cacheMethods}):r}});return{agent:v,getReducer:function(){return a.reducer},getCacheState:function(){return a.cacheState},getState:function(){return a.state},getVersion:function(){return a.version},getCurrent:function(t){if(a.isDestroyed)return a.current;if(Array.isArray(a.current))return a.current.map((function(e,r){return D(e)?e.cacheGenerator(a,r.toString()):"function"==typeof e?t?P(a,r.toString(),b(b({},t),{},{sourceTo:v[r]})):v[r]:e}));var e=Object.keys(a.current),r=b({},a.current);return e.forEach((function(e){var n=r[e];D(n)?r[e]=n.cacheGenerator(a,e):"function"==typeof n&&(r[e]=t?P(a,e,b(b({},t),{},{sourceTo:v[e]})):v[e])})),r},getStoreInstance:function(){return a.current},getListeners:function(){return a.dispatches},update:f,updateState:function(t){f(a.reducer,{state:t,cache:!0})},notice:function(){s(a.notify)},tunnel:function(t){return{connect:function(){l(t)},disconnect:function(){p(t)}}},destroy:function(){a.dispatch=null,a.dispatches=[],function(t){var e=t.dispatching;if(e){for(var r=e;r;){var n=r.next;r.next=void 0,r.prev=void 0,n&&(n.prev=void 0),r=n}e.tail=void 0,t.dispatching=void 0}}(a),a.temporaryDispatches=[],a.notify=y,a.isDestroyed=!0,a.cacheMethods={},a.cacheGenerators={},i.batchUpdate=void 0},renew:function(t){if(a.isDestroyed=!1,a.notify=w(a,i),t){var e=t.getState,r=t.getReducer;a.cacheState=null,f(r(),{state:e(),ignoreDispatch:!0})}},connect:function(t){l(t)},disconnect:p,optimize:function(t){i.batchUpdate!==t&&(i.batchUpdate=void 0,i.batchUpdate=t)}}}function x(t){if(t.agent[O])throw new Error("A stateless connection should be initialized before it is accessed.")}function k(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];if("function"==typeof t&&"function"==typeof t.creation)return[{key:n.join("."),keys:n,factory:t,connection:t.creation(e)}];if(!t||"object"!==f(t))return[];var o=[],c=t;return Object.keys(c).forEach((function(t){var u=k(c[t],e,n.concat(t));o.push.apply(o,r(u))})),o}function A(t){return{get:function(e){var r=t.find((function(t){return t.factory===e||t.sourceFactory===e}));return r?r.connection:void 0}}}function M(t,e){var r=t;var n,o,c=k(t,e),u=(o=(n=c).map((function(t){return t.connection})),{collections:n,connections:o,instances:A(n)}),i={destroyed:!1,parent:null==e?void 0:e.parent,update:function(r,n){return r!==t||(null==n?void 0:n.parent)!==(null==e?void 0:e.parent)||i.destroyed?(i.parent=n?n.parent:void 0,function(t,e){var r=k(t,e),n=u.collections,o=A(r);n.forEach((function(t){null!=o.get(t.factory)&&t.connection.renew()}))}(r),i.destroyed=!1,i):i},get:function(t){return u.instances.get(t)},equal:function(t){return t===r},destroy:function(){u.connections.forEach((function(t){return t.destroy()})),i.destroyed=!0}};return i}function R(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function I(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?R(Object(r),!0).forEach((function(e){n(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):R(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}var U=(0,i.createContext)(void 0);function F(t){var e=(0,i.useRef)(null);return null==e.current?(e.current={result:t()},e.current.result):e.current.result}function G(t,e,r){return function(t,e,r,n){var o=(n||{}).disabled,c=C(t,e,{controlled:!0}),u=(0,a.usePersistFn)((function(t){var n=t.state;e!==n&&(o||r(n))})),f=c.tunnel(u);return(0,i.useEffect)((function(){return f.connect(),function(){f.disconnect()}})),(0,i.useEffect)((function(){return c.renew(),function(){c.destroy()}}),[]),c.getCurrent()}(t,e,r)}var T=(0,i.createContext)(null);function W(){var t=((0,i.useContext)(U)||{}).batchUpdate;return(0,i.useMemo)((function(){return{batchUpdate:t}}),[t])}var q=function(t){var e=t.keys,r=t.value,n=t.children,o=null!=e?e:r;if(null==o)throw new Error("You need to provide keys to `Provider`");var c=W().batchUpdate,u=(0,i.useContext)(T),a=F((function(){return M(o,{batchUpdate:c,parent:u||void 0})}));return(0,i.useEffect)((function(){return a.update(o,u||void 0),function(){a.destroy()}}),[a,o,u]),(0,i.createElement)(T.Provider,{value:a},n)};function z(t,e){if(e.connection)return e.connection;if(null!=t){var r=t.get(e);return!r&&t.parent?z(t.parent,e):r}}function V(){var t=(0,i.useRef)({}),e=(0,a.usePersistFn)((function(t){return t}));return{methodsCache:t.current,middleWare:e}}function L(t,e,r){var n=I(I({},{required:!1}),r),o=n.useDefaultState,c=n.signal,f=(0,i.useRef)(!1),s=(0,i.useRef)(!1),l=(0,i.useRef)(!1);s.current=!1,f.current=!1;var p=W().batchUpdate,v=(0,i.useRef)(!1),g=(0,i.useContext)(T),b=t.isFactory,m="function"==typeof b&&b(),O=m?z(g,t):void 0;if(m&&!O)throw new Error("The model in usage is a `store key`, it should match with a store created by `StoreProvider`.");var S=null!=O&&!!o&&null==O.getCacheState();S&&O.update(t,{state:e,cache:!0,ignoreDispatch:!0}),null!=O&&x(O);var j=V(),w=(0,i.useRef)(t),P=F((function(){return O||C(t,e)}));P.optimize(p);var E=O||P;w.current===t||O||(w.current=t,E.update(t));var D=u((0,i.useState)({agent:E.getCurrent(j),action:null}),2),k=D[0],A=D[1],M=(0,i.useRef)(E.getVersion()),R=(0,i.useRef)(null),U=k.agent,G={selection:[]};R.current=G.selection;var q=(0,a.usePersistFn)((function(t){var e=t;if(!v.current){var r,n,o,u,i=E.getVersion(),a=E.getCurrent(j);if(M.current!==i||e.payload)if(e.payload||(M.current=i),!c||s.current)if(!(c&&R.current&&(r=a,n=U,o=R.current,u=!0,o.forEach((function(t){r[t]!==n[t]&&(u=!1)})),u)))A({agent:a,action:e})}}));(0,i.useLayoutEffect)((function(){f.current=!0,l.current=s.current}));var L=E.tunnel(q);(0,i.useEffect)((function(){return L.connect(),function(){L.disconnect()}})),(0,i.useEffect)((function(){return v.current=!1,E.renew(),function(){v.current=!0,R.current=null,null==O&&E.destroy()}}),[]),(0,i.useEffect)((function(){S&&E.notice()}),[S]);var _=function(){s.current=!0,G.selection!==R.current&&(G.selection=null);var t=E.getCurrent(j);return d(t,{get:function(t,e,r){var n=t[e];if(null!=G.selection&&G.selection===R.current&&!v.current&&!f.current){var o={};G.selection.forEach((function(t){o[t]=!0})),o[e]||G.selection.push(e)}return n}})},K=(0,a.usePersistFn)(_),Y=l.current?_:K,$=function(t,e){function r(t){return null==t?null:t.dispatchId||t}return{useEffectWrap:function(n){var o=(0,i.useRef)(null),c=(0,i.useRef)(null),f=(0,i.useRef)(null),s=u((0,i.useState)(null),2),l=s[0],p=s[1],d=V(),v=(0,a.usePersistFn)((function(e){if(l!==e&&e.type){var n=t.getCurrent(d),u=o.current,i=f.current;if(null!=u||null!=i){var a=c.current,s=i?i(n):null;c.current=s,u&&u.length&&u.map(r).indexOf(r(e.method))<0||null!=s&&null!=a&&h(s,a)||p(e)}}})),g=t.tunnel(v);(0,i.useEffect)((function(){if(null==o.current&&null==f.current)return y;if(null!=o.current&&null==l)return y;var e=t.getCurrent(d);return n(e,l)}),[l]),(0,i.useEffect)((function(){if(null!=o.current||null!=f.current)return y;var r=t.getCurrent(d);return n(r,e)}),[e]),(0,i.useEffect)((function(){return g.connect(),function(){g.disconnect()}}),[]);var b={onActions:function(e){var r=e(t.getCurrent(d));if(!Array.isArray(r))throw new Error("The `filter callback` for method `on` should return an action method array.");return o.current=r.filter((function(t){return"function"==typeof t})),b},onChanges:function(t){return f.current=t,b}};return b},useWatchtWrap:function(e){var n=(0,i.useRef)(null),o=(0,i.useRef)(null),c=(0,i.useRef)(null),u=V(),f=(0,a.usePersistFn)((function(i){if(!i.type)return y;var a=t.getCurrent(u),f=n.current,s=c.current,l=o.current,p=s?s(a):null;return o.current=p,f&&f.length&&f.map(r).indexOf(r(i.method))<0||null!=p&&null!=l&&h(p,l)?y:e(a,i)})),s=t.tunnel(f);(0,i.useEffect)((function(){return s.connect(),function(){s.disconnect()}}),[]);var l={onActions:function(e){var r=e(t.getCurrent(u));if(!Array.isArray(r))throw new Error("The `filter callback` for method `on` should return an action method array.");return n.current=r.filter((function(t){return"function"==typeof t})),l},onChanges:function(t){return c.current=t,l}};return l}}}(E,k.action),B=$.useEffectWrap,H=$.useWatchtWrap;Y.useEffect=B,Y.useWatch=H;var J=U;if(c)return[E.getState(),J,E.updateState,Y];return[E.getState(),J,E.updateState,function(){return J}]}function _(t,e,r){var n=u(L(t,e,r),4),o=n[0],c=n[1];n[2];return[o,c,n[3]]}function K(t,e){return u(_(t,e,{useDefaultState:arguments.length>1}),2)[1]}function Y(t,e){return u(_(t,e,{useDefaultState:arguments.length>1,signal:!0}),3)[2]}var $=function(t){return'API "'.concat(t,'" can not work, there is no matched Provider with its store key.')};function B(t,e,r){var n=W().batchUpdate,o=(0,i.useContext)(T),c=V(),f=z(o,t);if(!f)throw new Error($("useSelector"));x(f),f.optimize(n);var s=e(f.getCurrent(c)),l=(0,i.useRef)(!1),p=(0,i.useRef)(f.getVersion()),d=u((0,i.useState)({data:s}),2),v=d[0],h=d[1],y=(0,a.usePersistFn)((function(){if(!l.current){var t=f.getVersion();if(p.current!==t){p.current=t;var n=e(f.getCurrent(c));(function(t,e){return r?r(t,e):Object.is(t,e)})(v.data,n)||h({data:n})}}})),g=f.tunnel(y);return(0,i.useEffect)((function(){return g.connect(),function(){g.disconnect()}})),(0,i.useEffect)((function(){return l.current=!1,function(){l.current=!0}}),[]),v.data}function H(t){return function(e){return function(r){return(0,i.createElement)(q,{value:t},(0,i.createElement)(e,r))}}}var J=h,N=function(t,e){return function(t,e,r){var o=function(e){return t(e)};return o.creation=function(t){return r?C((function(t){return n({},O,m)}),void 0,t):C(o,e,t)},o.static=function(){return function(t){var e=function(e){return t(e)};return e.payload=t.payload,e.connection=t.creation(),e.static=function(){return e},e.isFactory=t.isFactory,e}(o)},o.isFactory=function(){return!0},o}(t,e,arguments.length<2)},Q=function(t){var e=t.value,r=t.children;return(0,i.createElement)(U.Provider,{value:e},r)},X=function(t){var e=function(e){return t(e)};e.meta={};var n=function t(n,o){var c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],u=null!=o?o:arguments.length>0?N(e,n):N(e);var a={key:u,keys:c,useModel:function(t){var e=arguments.length?[u,t]:[u];return K.apply(void 0,e)},useSignal:function(t){var e=arguments.length?[u,t]:[u];return Y.apply(void 0,e)},useSelector:function(t,e){return B(u,t,e)},static:function(){var t=u.static();return{useModel:function(e){var r=arguments.length?[t,e]:[t];return K.apply(void 0,r)},useSignal:function(e){var r=arguments.length?[t,e]:[t];return Y.apply(void 0,r)},useSelector:function(e,r){return B(t,e,r)}}},provide:function(){return H([u].concat(r(c)))},provideTo:function(t){return H([u].concat(r(c)))(t)},Provider:function(t){var e=t.children;return(0,i.createElement)(q,{value:[u].concat(r(c))},e)}};return I(I({},a),{},{with:function(){for(var e=arguments.length,r=new Array(e),o=0;o<e;o++)r[o]=arguments[o];var i=c.concat(r.map((function(t){return"function"==typeof t?t:t.key})));return t(n,u,i)}})};return Object.assign(e,{useModel:function(t){var r=arguments.length?[e,t]:[e];return K.apply(void 0,r)},useSignal:function(t){var r=arguments.length?[e,t]:[e];return Y.apply(void 0,r)},useControlledModel:function(t,r){return G(e,t,r)},createStore:function(t){return arguments.length?n(t):n()}})};X.create=X,X.createCacheField=function(t,e){var r=null==e?e:e.some((function(t){return D(t)&&null==t.deps}))?void 0:e.flatMap((function(t){return D(t)?t.deps:t})),n=t();return{callback:t,deps:r,cacheGenerator:E,value:n,get:function(){return n}}},X.createField=function(t,e){var r=null==e?e:e.some((function(t){return D(t)&&null==t.deps}))?void 0:e.flatMap((function(t){return D(t)?t.deps:t})),n=t();return{callback:t,deps:r,cacheGenerator:E,value:n,get:function(){return n}}},X.createMethod=function(t){var e=function(){return t.apply(void 0,arguments)};return Object.assign(e,t),e.noActionMethod=m,e}}(),c}()})); |
{ | ||
"name": "@airma/react-state", | ||
"version": "18.5.4", | ||
"version": "18.5.5", | ||
"description": "the purpose of this project is make useReducer more simplify", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
39163