Comparing version 1.2.6 to 1.2.7
@@ -1,8 +0,10 @@ | ||
import { IFunction, IObject } from 'herb-core-include'; | ||
declare type NotifyFunction<T extends IObject, K extends keyof T = keyof T> = IFunction<[K, any, T]>; | ||
export declare function proxyObject<T = any>(obj: T, notify?: NotifyFunction<T>): void; | ||
export declare function proxy<T, K extends keyof T = keyof T>(obj: T, key: K, value: K extends keyof T ? T[K] : any, notify?: NotifyFunction<T>): void; | ||
import { IFunction } from 'herb-core-include'; | ||
import { Watcher } from '../observer/watcher'; | ||
declare const GetterWatchersKey = "__GW__"; | ||
declare type IInitFunctionResponse<T> = T | void | never; | ||
export declare function initState<T>(state: T, notify: IFunction): IInitFunctionResponse<T>; | ||
export declare function initGetters<T>(getters: T, buildParams: IFunction<[keyof T]>): IInitFunctionResponse<T>; | ||
export declare function cacheGetter(key: string): (this: { | ||
__GW__: Record<any, Watcher>; | ||
}) => any; | ||
export declare function initMutations<T>(mutations: T): IInitFunctionResponse<T>; | ||
@@ -9,0 +11,0 @@ export declare function initActions<T>(actions: T): IInitFunctionResponse<T>; |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("herbx",[],e):"object"==typeof exports?exports.herbx=e():t.herbx=e()}(this,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=5)}([function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}},function(t,e){function n(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}t.exports=function(t,e,r){return e&&n(t.prototype,e),r&&n(t,r),t}},function(t,e){function n(t){return(n="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})(t)}function r(e){return"function"==typeof Symbol&&"symbol"===n(Symbol.iterator)?t.exports=r=function(t){return n(t)}:t.exports=r=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":n(t)},r(e)}t.exports=r},function(t,e,n){var r=n(6),o=n(7),i=n(8);t.exports=function(t){return r(t)||o(t)||i()}},function(t,e,n){var r=n(9),o=n(10),i=n(11);t.exports=function(t,e){return r(t)||o(t,e)||i()}},function(t,e,n){t.exports=n(12)},function(t,e){t.exports=function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e<t.length;e++)n[e]=t[e];return n}}},function(t,e){t.exports=function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}},function(t,e){t.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}},function(t,e){t.exports=function(t){if(Array.isArray(t))return t}},function(t,e){t.exports=function(t,e){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t)){var n=[],r=!0,o=!1,i=void 0;try{for(var u,c=t[Symbol.iterator]();!(r=(u=c.next()).done)&&(n.push(u.value),!e||n.length!==e);r=!0);}catch(t){o=!0,i=t}finally{try{r||null==c.return||c.return()}finally{if(o)throw i}}return n}}},function(t,e){t.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}},function(t,e,n){"use strict";n.r(e);var r,o=n(3),i=n.n(o),u=n(0),c=n.n(u),a=n(1),s=n.n(a),f=n(2),l=n.n(f);function m(t,e){return Object.prototype.toString.call(t)===r[e]}function p(t){return null==t}function y(t){return Array.isArray?Array.isArray(t):m(t,"array")}function d(t){return!!t&&"object"===l()(t)}function b(t){return m(t,"object")}function h(t){return m(t,"string")}function g(t){return m(t,"symbol")}function v(t){return!!t&&"function"==typeof t.then}function $(t){return"function"==typeof t}!function(t){t.array="[object Array]",t.date="[object Date]",t.set="[object Set]",t.map="[object Map]",t.object="[object Object]",t.string="[object String]",t.symbol="[object Symbol]"}(r||(r={}));var j=n(4),x=n.n(j);function S(t,e){for(var n=x()(e,2),r=n[0],o=n[1],i=0;i<t.length;i++)if(t[i][r]===o)return t[i]}function O(t,e){return t.indexOf(e)}function P(t,e){for(var n=Object.keys(t),r=0;r<n.length;r++){var o=n[r];e(t[o],o)}}function w(t,e){if("string"==typeof t){for(var n=t.length;n>=0;){var r=n-e.length;if(r<0)return-1;if(t.substr(r,e.length)===e)return r;n-=1}return-1}return-1}function T(t,e){var n=O(t,e);n>-1&&t.splice(n,1)}function A(){}function k(t,e){if(!t)throw new Error("[Herbx] "+e)}function E(t,e,n){0}function C(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(null===t||"object"!==l()(t))return t;var n=S(e,["origin",t]);if(n)return n.copy;var o=Object.prototype.toString.call(t),i={origin:t,copy:void 0};return e.push(i),o===r.array?(i.copy=[],i.copy=t.map((function(t){return C(t,e)}))):o===r.set?(i.copy=new Set,t.forEach((function(t){i.copy.add(C(t,e))}))):o===r.map?(i.copy=new Map,t.forEach((function(t,n){i.copy.set(n,C(t,e))}))):o===r.date?i.copy=new Date(t):(i.copy={},Object.keys(t).forEach((function(n){i.copy[n]=C(t[n],e)}))),i.copy}function M(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function D(t){var e=this,n=!!e.root,r={};return Object.defineProperties(r,{state:{get:function(){return e.state},enumerable:!0},getters:{get:function(){return e.getters},enumerable:!0},rootState:{get:function(){return n?e.root.state:void 0},enumerable:!0},rootGetters:{get:function(){return n?e.root.getters:void 0},enumerable:!0}}),r}function F(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return[this.state].concat(n)}function N(t){var e=this,n=!!e.root,r={};Object.defineProperties(r,{commit:{get:function(){return e.commit},enumerable:!0},dispatch:{get:function(){return e.dispatch},enumerable:!0},state:{get:function(){return e.state},enumerable:!0},rootState:{get:function(){return n?e.root.state:void 0},enumerable:!0},getters:{get:function(){return e.getters},enumerable:!0},rootGetters:{get:function(){return n?e.root.getters:void 0},enumerable:!0},dispatchRoot:{get:function(){return n?e.root.dispatch:A},enumerable:!0},commitRoot:{get:function(){return n?e.root.commit:A},enumerable:!0}});for(var o=arguments.length,i=new Array(o>1?o-1:0),u=1;u<o;u++)i[u-1]=arguments[u];return[r].concat(i)}function H(t,e){if(d(t)){var n=Object.prototype.toString.call(t);n===r.object?P(t,(function(n,r){!function(t,e,n,r){var o=Object.getOwnPropertyDescriptor(t,e);if(o&&!1===o.configurable)return;var i=o&&o.get,u=o&&o.set;H(n,r),Object.defineProperty(t,e,{configurable:!0,enumerable:!0,get:function(){return i?i.call(t):n},set:function(o){o!==(i?i.call(t):n)&&(i&&!u||(u?u.call(t,o):n=o,r(e,o,t),H(o,r)))}})}(t,r,n,e)})):n===r.array&&t.forEach((function(t){H(t,e)}))}}function _(t,e,n){var r=n[t];if(r)return r;var o=t.indexOf(e);if(o>-1){var i=n[t.substr(0,o)];if(i)return _(t.substr(o+e.length),i.$namespaceSep,i.modules)}}function q(t,e,n){var r=function(t,e){var n=w(t,e);if(!(n<0))return{moduleName:t.substr(0,n),method:t.substr(n+e.length)}}(t,e);if(r){var o=r.moduleName,i=r.method;return{module:_(o,e,n),method:i}}}function I(t,e){if(y(t))try{t.forEach((function(t){e(null,t)}))}catch(t){e(t)}}var G={},J=function(){function t(e){c()(this,t),this.queue=[],this.flushing=!1;var n=e.uid;this.uid=n,this.afterCreate()}return s()(t,[{key:"afterCreate",value:function(){M(G,this.uid)||(G[this.uid]=this)}},{key:"beforeDestroy",value:function(){M(G,this.uid)&&delete G[this.uid]}},{key:"setTimer",value:function(t,e){return setTimeout(t,e)}},{key:"clearTimer",value:function(t){return clearTimeout(t)}},{key:"addTask",value:function(t){this.queue.push(t)}},{key:"removeTask",value:function(t){T(this.queue,t)}},{key:"flush",value:function(t){var e=this;this.flushing=!0,this.clearTimer(this.timer);var n=this.queue.length;this.timer=this.setTimer((function(){e&&(I(e.queue.splice(0,n),(function(t,e){t?console.warn("[Herbx Flush Error] ",t):e()})),e.flushing=!1,$(t)&&t())}),0)}}]),t}(),R=0,B=function(){function t(e){var n=this;c()(this,t),this.$namespaceSep="/",this.$namespaced=!1,this.$mutationFunctionContext=null,this.$actionFunctionContext=null,this.$uid=R++,this.$subscribers={mutation:[],action:[]},this.$modules={},this.afterCreate=function(){n.$namespaced||(n.$scheduler=new J({uid:n.$uid}),n.resetScheduler())},this.beforeDestory=function(){n.$scheduler&&n.$scheduler.beforeDestroy()},this.resetScheduler=function(){n.$scheduler.addTask((function(){n.broadcast(),$(n.$listener)&&n.$listener(n)}))},this.broadcast=function(){P(n.$modules,(function(t,e){n&&!t.$namespaced&&t.notify()}))},this.notify=function(){n&&(n.$namespaced?n.root.notify():n.$scheduler.flush(n.resetScheduler))},this.subscribe=function(t,e){return n.$subscribers[t]?(O(n.$subscribers[t],e)<0&&n.$subscribers[t].push(e),function(){T(n.$subscribers[t],e)}):A},this.registerModule=function(e,r){M(n.$modules,e)&&k(!1,"namespace is exists: "+e),b(r)||k(!1,"options must be object: "+e);var o=Object.assign({},r,{root:n,namespace:e}),i=new t(o);return n.$modules[e]=i,o.namespaced&&(M(n.$state,e)&&k(!1,"module state namespace is exists: "+e),M(n.$getters,e)&&k(!1,"module getters namespace is exists: "+e),Object.defineProperty(n.state,e,{get:function(){return i.$state},enumerable:!0}),Object.defineProperty(n.getters,e,{get:function(){return i.$getters},enumerable:!0})),i},this.unregisterModule=function(t){M(n.$modules,t)&&(n.$modules[t].beforeDestory(),delete n.$modules[t])},this.dispatch=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];var o=e[0],u=n.$actions[o];if("function"==typeof u){n.execSubcribers("action",e);var c=N.apply(n,e),a=u.apply(n.$actionFunctionContext,"function"==typeof n.$actionParamsTransformer?n.$actionParamsTransformer.apply(null,c):c);return a}var s,f=q(o,n.$namespaceSep,n.$modules);if(f&&f.module)return(s=f.module).dispatch.apply(s,[f.method].concat(i()(e.slice(1))));E()},this.commit=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];var o=e[0];if(b(o)){var u=Object.assign(n.state,o);return n.execSubcribers("mutation",e),n.notify(),u}var c=n.$mutations[o];if("function"==typeof c){var a=F.apply(n,e),s=c.apply(n.$mutationFunctionContext,"function"==typeof n.$mutationParamsTransformer?n.$mutationParamsTransformer.apply(null,a.concat(o)):a);return n.execSubcribers("mutation",e),n.notify(),s}var f,l=q(o,n.$namespaceSep,n.$modules);if(l&&l.module)return(f=l.module).commit.apply(f,[l.method].concat(i()(e.slice(1))));E()};var r=e.state,o=e.getters,u=e.mutations,a=e.actions,s=e.plugins,f=e.namespace,l=e.actionParamsTransformer,m=e.getterParamsTransformer,y=e.mutationParamsTransformer,d=e.root,h=e.listener,g=e.modules,v=e.namespaced,j=void 0!==v&&v;this.$state=function(t,e){if(!p(t)){var n=b(t);if(n){var r=C(t);return H(r,e),r}E()}}(r,this.notify)||{},this.$getters=function(t,e){if(!p(t)){var n=b(t);if(n){var r={};return P(t,(function(t,n){"function"==typeof t?(r[n]=t,Object.defineProperty(r,n,{enumerable:!0,get:function(){var r=e(n);return t.call(null,r)}})):E()})),r}E()}}(o,(function(t){var e=D.call(n,t);return"function"==typeof n.$getterParamsTransformer?n.$getterParamsTransformer.call(null,e):e}))||{},this.$mutations=function(t){if(!p(t)){var e=b(t);if(e)return t;E()}}(u)||{},this.$actions=function(t){if(!p(t)){var e=b(t);if(e)return t;E()}}(a)||{},this.$namespace=f,this.$namespaced=!!j,this.$getterParamsTransformer=m,this.$actionParamsTransformer=l,this.$mutationParamsTransformer=y,this.$listener=h,d&&d instanceof t&&(this.$root=d),b(g)&&P(g,(function(t,e){n.registerModule(e,t)})),I(s,(function(t,e){if(t)return E(0,t.message);$(e)&&e(n)})),this.afterCreate()}return s()(t,[{key:"execSubcribers",value:function(t,e){var n=this;I(this.$subscribers[t],(function(t,r){if(t)return E(0,t.message);$(r)&&r.apply(void 0,[n].concat(i()(e)))}))}},{key:"state",get:function(){return this.$state}},{key:"getters",get:function(){return this.$getters}},{key:"root",get:function(){return this.$root}},{key:"modules",get:function(){return this.$modules}}]),t}();function K(){arguments.length>0&&void 0!==arguments[0]&&arguments[0];return function(t){var e=C(t.state),n=console.info;t.subscribe("action",(function(t,e){for(var r=arguments.length,o=new Array(r>2?r-2:0),i=2;i<r;i++)o[i-2]=arguments[i];n("%c [Herbx] Action: ".concat(JSON.stringify(e),", Payload: "),"color: #9E9E9E; font-weight: bold",o)}));t.subscribe("mutation",(function(t,r){for(var o=r,i=arguments.length,u=new Array(i>2?i-2:0),c=2;c<i;c++)u[c-2]=arguments[c];var a=u;"string"!=typeof r&&(o="Empty Mutation Name",a.unshift(r));var s=C(t.state);n("%c [Herbx] Prev State: ","color: #9E9E9E; font-weight: bold",e),n("%c [Herbx] Mutation: ".concat(JSON.stringify(o),", Payload: "),"color: #03A9F4; font-weight: bold",a),n("%c [Herbx] Next State: ","color: #4CAF50; font-weight: bold",s),e=s}))}}function L(){arguments.length>0&&void 0!==arguments[0]&&arguments[0];return function(t){}}n.d(e,"Types",(function(){return r})),n.d(e,"is",(function(){return m})),n.d(e,"isNil",(function(){return p})),n.d(e,"isArray",(function(){return y})),n.d(e,"isObject",(function(){return d})),n.d(e,"isPlainObject",(function(){return b})),n.d(e,"isString",(function(){return h})),n.d(e,"isSymbol",(function(){return g})),n.d(e,"isPromise",(function(){return v})),n.d(e,"isFunction",(function(){return $})),n.d(e,"findByKey",(function(){return S})),n.d(e,"findIndex",(function(){return O})),n.d(e,"eachObject",(function(){return P})),n.d(e,"lastIndexOf",(function(){return w})),n.d(e,"remove",(function(){return T})),n.d(e,"noop",(function(){return A})),n.d(e,"assert",(function(){return k})),n.d(e,"log",(function(){return E})),n.d(e,"deepCopy",(function(){return C})),n.d(e,"hasOwnProperty",(function(){return M})),n.d(e,"LoggerPlugin",(function(){return K})),n.d(e,"DevToolPlugin",(function(){return L})),n.d(e,"Store",(function(){return B}));e.default=B}])})); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("herbx",[],e):"object"==typeof exports?exports.herbx=e():t.herbx=e()}(this,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=5)}([function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}},function(t,e){function n(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}t.exports=function(t,e,r){return e&&n(t.prototype,e),r&&n(t,r),t}},function(t,e){function n(t){return(n="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})(t)}function r(e){return"function"==typeof Symbol&&"symbol"===n(Symbol.iterator)?t.exports=r=function(t){return n(t)}:t.exports=r=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":n(t)},r(e)}t.exports=r},function(t,e,n){var r=n(6),o=n(7),i=n(8);t.exports=function(t){return r(t)||o(t)||i()}},function(t,e,n){var r=n(9),o=n(10),i=n(11);t.exports=function(t,e){return r(t)||o(t,e)||i()}},function(t,e,n){t.exports=n(12)},function(t,e){t.exports=function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e<t.length;e++)n[e]=t[e];return n}}},function(t,e){t.exports=function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}},function(t,e){t.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}},function(t,e){t.exports=function(t){if(Array.isArray(t))return t}},function(t,e){t.exports=function(t,e){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t)){var n=[],r=!0,o=!1,i=void 0;try{for(var u,s=t[Symbol.iterator]();!(r=(u=s.next()).done)&&(n.push(u.value),!e||n.length!==e);r=!0);}catch(t){o=!0,i=t}finally{try{r||null==s.return||s.return()}finally{if(o)throw i}}return n}}},function(t,e){t.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}},function(t,e,n){"use strict";n.r(e);var r,o=n(3),i=n.n(o),u=n(0),s=n.n(u),a=n(1),c=n.n(a),f=n(2),l=n.n(f);function d(t,e){return Object.prototype.toString.call(t)===r[e]}function h(t){return null==t}function p(t){return Array.isArray?Array.isArray(t):d(t,"array")}function y(t){return null!==t&&"object"===l()(t)}function m(t){return d(t,"object")}function b(t){return d(t,"string")}function v(t){return d(t,"symbol")}function g(t){return!!t&&"function"==typeof t.then}function $(t){return"function"==typeof t}!function(t){t.array="[object Array]",t.date="[object Date]",t.set="[object Set]",t.map="[object Map]",t.object="[object Object]",t.string="[object String]",t.symbol="[object Symbol]"}(r||(r={}));var w=n(4),S=n.n(w);function j(t,e){for(var n=S()(e,2),r=n[0],o=n[1],i=0;i<t.length;i++)if(t[i][r]===o)return t[i]}function x(t,e){return t.indexOf(e)}function O(t,e){for(var n=Object.keys(t),r=0;r<n.length;r++){var o=n[r];e(t[o],o)}}function k(t,e){if("string"==typeof t){for(var n=t.length;n>=0;){var r=n-e.length;if(r<0)return-1;if(t.substr(r,e.length)===e)return r;n-=1}return-1}return-1}function P(t,e){if(t.length){var n=x(t,e);n>-1&&t.splice(n,1)}}function T(){}function A(t,e){if(!t)throw new Error("[Herbx] "+e)}function D(t,e,n){0}function E(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(null===t||"object"!==l()(t))return t;var n=j(e,["origin",t]);if(n)return n.copy;var o=Object.prototype.toString.call(t),i={origin:t,copy:void 0};return e.push(i),o===r.array?(i.copy=[],i.copy=t.map((function(t){return E(t,e)}))):o===r.set?(i.copy=new Set,t.forEach((function(t){i.copy.add(E(t,e))}))):o===r.map?(i.copy=new Map,t.forEach((function(t,n){i.copy.set(n,E(t,e))}))):o===r.date?i.copy=new Date(t):(i.copy={},Object.keys(t).forEach((function(n){i.copy[n]=E(t[n],e)}))),i.copy}function I(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function _(t,e,n,r){Object.defineProperty(t,e,{value:n,enumerable:!!r,writable:!0,configurable:!0})}function C(t){var e=this,n=!!e.root,r={};return Object.defineProperties(r,{state:{get:function(){return e.state},enumerable:!0},getters:{get:function(){return e.getters},enumerable:!0},rootState:{get:function(){return n?e.root.state:void 0},enumerable:!0},rootGetters:{get:function(){return n?e.root.getters:void 0},enumerable:!0}}),r}function M(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return[this.state].concat(n)}function F(t){var e=this,n=!!e.root,r={};Object.defineProperties(r,{commit:{get:function(){return e.commit},enumerable:!0},dispatch:{get:function(){return e.dispatch},enumerable:!0},state:{get:function(){return e.state},enumerable:!0},rootState:{get:function(){return n?e.root.state:void 0},enumerable:!0},getters:{get:function(){return e.getters},enumerable:!0},rootGetters:{get:function(){return n?e.root.getters:void 0},enumerable:!0},dispatchRoot:{get:function(){return n?e.root.dispatch:T},enumerable:!0},commitRoot:{get:function(){return n?e.root.commit:T},enumerable:!0}});for(var o=arguments.length,i=new Array(o>1?o-1:0),u=1;u<o;u++)i[u-1]=arguments[u];return[r].concat(i)}var N=0,H=function(){function t(){s()(this,t),this.id=N++,this.subs=[]}return c()(t,[{key:"addSub",value:function(t){this.subs.push(t)}},{key:"removeSub",value:function(t){P(this.subs,t)}},{key:"depend",value:function(){t.target&&t.target.addDep(this)}},{key:"notify",value:function(){for(var t=this.subs.slice(),e=0,n=t.length;e<n;e++)t[e].update()}}]),t}();H.target=null;var q=[];var G="__OB__";function B(t,e,n,r){var o=Object.getOwnPropertyDescriptor(t,e);if(!o||!1!==o.configurable){var i=new H,u=o&&o.get,s=o&&o.set,a=J(n,r);Object.defineProperty(t,e,{configurable:!0,enumerable:!0,get:function(){var e=u?u.call(t):n;return H.target&&(i.depend(),a&&(a.dep.depend(),p(e)&&function t(e){for(var n,r=0,o=e.length;r<o;r++)(n=e[r])&&n[G]&&n[G].dep.depend(),p(n)&&t(n)}(e))),e},set:function(e){e!==(u?u.call(t):n)&&(u&&!s||(s?s.call(t,e):n=e,a=J(e,r),i.notify(),r&&r()))}})}}function J(t,e){var n;if(y(t))return I(t,G)&&t[G]instanceof R?n=t[G]:(p(t)||m(t))&&Object.isExtensible(t)&&(n=new R(t,e)),n}var R=function(){function t(e,n){s()(this,t),this.value=e,this.dep=new H,this.cb=n,_(e,G,this,!1),p(e)?this.observeArray(e):this.walk(e)}return c()(t,[{key:"walk",value:function(t,e){for(var n=Object.keys(t),r=0;r<n.length;r++)B(t,n[r],t[n[r]],e)}},{key:"observeArray",value:function(t,e){for(var n=0,r=t.length;n<r;n++)J(t[n],e)}}]),t}(),U=function(){function t(e){s()(this,t),this.active=!0,this.dirty=!0,this.deps=[],this.depIds=new Set,this.newDeps=[],this.newDepIds=new Set;var n=e.getter,r=e.notify;this.notify=r,this.getter="function"==typeof n?n:T}return c()(t,[{key:"get",value:function(){var t,e;t=this,q.push(t),H.target=t;try{e=this.getter()}catch(t){throw t}finally{q.pop(),H.target=q[q.length-1],this.cleanUpDeps()}return e}},{key:"evaluate",value:function(){this.value=this.get(),this.dirty=!1}},{key:"addDep",value:function(t){var e=t.id;this.newDepIds.has(e)||(this.newDepIds.add(e),this.newDeps.push(t),this.depIds.has(e)||t.addSub(this))}},{key:"cleanUpDeps",value:function(){for(var t=this.deps.length;t--;){var e=this.deps[t];this.newDepIds.has(e.id)||e.removeSub(this)}var n=this.depIds;this.depIds=this.newDepIds,this.newDepIds=n,this.newDepIds.clear(),n=this.deps,this.deps=this.newDeps,this.newDeps=n,this.newDeps.length=0}},{key:"update",value:function(){this.dirty=!0}},{key:"run",value:function(){if(this.active){var t=this.get();if(t!==this.value||y(t)){var e=this.value;this.value=t,this.notify&&this.notify(t,e)}}}},{key:"depend",value:function(){for(var t=this.deps.length;t--;)this.deps[t].depend()}},{key:"teardown",value:function(){if(this.active){for(var t=this.deps.length;t--;)this.deps[t].removeSub(this);this.active=!1}}}]),t}(),K="__GW__";function L(t){return function(){var e=this[K]&&this[K][t];if(e)return e.dirty&&e.evaluate(),H.target&&e.depend(),e.value}}function W(t,e,n){var r=n[t];if(r)return r;var o=t.indexOf(e);if(o>-1){var i=n[t.substr(0,o)];if(i)return W(t.substr(o+e.length),i.$namespaceSep,i.modules)}}function z(t,e,n){var r=function(t,e){var n=k(t,e);if(!(n<0))return{moduleName:t.substr(0,n),method:t.substr(n+e.length)}}(t,e);if(r){var o=r.moduleName,i=r.method;return{module:W(o,e,n),method:i}}}function Q(t,e){if(p(t))try{t.forEach((function(t){e(null,t)}))}catch(t){e(t)}}var V={},X=function(){function t(e){s()(this,t),this.queue=[],this.flushing=!1;var n=e.uid;this.uid=n,this.afterCreate()}return c()(t,[{key:"afterCreate",value:function(){I(V,this.uid)||(V[this.uid]=this)}},{key:"beforeDestroy",value:function(){I(V,this.uid)&&delete V[this.uid]}},{key:"setTimer",value:function(t,e){return setTimeout(t,e)}},{key:"clearTimer",value:function(t){return clearTimeout(t)}},{key:"addTask",value:function(t){this.queue.push(t)}},{key:"removeTask",value:function(t){P(this.queue,t)}},{key:"flush",value:function(t){var e=this;this.flushing=!0,this.clearTimer(this.timer);var n=this.queue.length;this.timer=this.setTimer((function(){e&&(Q(e.queue.splice(0,n),(function(t,e){t?console.warn("[Herbx Flush Error] ",t):e()})),e.flushing=!1,$(t)&&t())}),0)}}]),t}(),Y=0,Z=function(){function t(e){var n=this;s()(this,t),this.$namespaceSep="/",this.$namespaced=!1,this.$mutationFunctionContext=null,this.$actionFunctionContext=null,this.$uid=Y++,this.$subscribers={mutation:[],action:[]},this.$modules={},this.afterCreate=function(){n.$namespaced||(n.$scheduler=new X({uid:n.$uid}),n.resetScheduler())},this.beforeDestory=function(){n.$scheduler&&n.$scheduler.beforeDestroy()},this.resetScheduler=function(){n.$scheduler.addTask((function(){n.broadcast(),$(n.$listener)&&n.$listener(n)}))},this.broadcast=function(){O(n.$modules,(function(t,e){n&&!t.$namespaced&&t.notify()}))},this.notify=function(){n&&(n.$namespaced?n.root.notify():n.$scheduler.flush(n.resetScheduler))},this.subscribe=function(t,e){return n.$subscribers[t]?(x(n.$subscribers[t],e)<0&&n.$subscribers[t].push(e),function(){P(n.$subscribers[t],e)}):T},this.registerModule=function(e,r){I(n.$modules,e)&&A(!1,"namespace is exists: "+e),m(r)||A(!1,"options must be object: "+e);var o=Object.assign({},r,{root:n,namespace:e}),i=new t(o);return n.$modules[e]=i,o.namespaced&&(I(n.$state,e)&&A(!1,"module state namespace is exists: "+e),I(n.$getters,e)&&A(!1,"module getters namespace is exists: "+e),Object.defineProperty(n.state,e,{get:function(){return i.$state},enumerable:!0}),Object.defineProperty(n.getters,e,{get:function(){return i.$getters},enumerable:!0})),i},this.unregisterModule=function(t){I(n.$modules,t)&&(n.$modules[t].beforeDestory(),delete n.$modules[t])},this.dispatch=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];var o=e[0],u=n.$actions[o];if("function"==typeof u){n.execSubcribers("action",e);var s=F.apply(n,e),a=u.apply(n.$actionFunctionContext,"function"==typeof n.$actionParamsTransformer?n.$actionParamsTransformer.apply(null,s):s);return a}var c,f=z(o,n.$namespaceSep,n.$modules);if(f&&f.module)return(c=f.module).dispatch.apply(c,[f.method].concat(i()(e.slice(1))));D()},this.commit=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];var o=e[0];if(m(o)){var u=Object.assign(n.state,o);return n.execSubcribers("mutation",e),n.notify(),u}var s=n.$mutations[o];if("function"==typeof s){var a=M.apply(n,e),c=s.apply(n.$mutationFunctionContext,"function"==typeof n.$mutationParamsTransformer?n.$mutationParamsTransformer.apply(null,a.concat(o)):a);return n.execSubcribers("mutation",e),n.notify(),c}var f,l=z(o,n.$namespaceSep,n.$modules);if(l&&l.module)return(f=l.module).commit.apply(f,[l.method].concat(i()(e.slice(1))));D()};var r=e.state,o=e.getters,u=e.mutations,a=e.actions,c=e.plugins,f=e.namespace,l=e.actionParamsTransformer,d=e.getterParamsTransformer,p=e.mutationParamsTransformer,y=e.root,b=e.listener,v=e.modules,g=e.namespaced,w=void 0!==g&&g;this.$state=function(t,e){if(!h(t)){var n=m(t);if(n)return J(t,e).value;D()}}(r,this.notify)||{},this.$getters=function(t,e){if(!h(t)){var n=m(t);if(n){var r={},o={};return _(r,K,o,!1),O(t,(function(t,n){"function"==typeof t?(o[n]=new U({getter:function(){var r=e(n);return t.call(null,r)}}),Object.defineProperty(r,n,{enumerable:!0,get:L(n)})):D()})),r}D()}}(o,(function(t){var e=C.call(n,t);return"function"==typeof n.$getterParamsTransformer?n.$getterParamsTransformer.call(null,e):e}))||{},this.$mutations=function(t){if(!h(t)){var e=m(t);if(e)return t;D()}}(u)||{},this.$actions=function(t){if(!h(t)){var e=m(t);if(e)return t;D()}}(a)||{},this.$namespace=f,this.$namespaced=!!w,this.$getterParamsTransformer=d,this.$actionParamsTransformer=l,this.$mutationParamsTransformer=p,this.$listener=b,y&&y instanceof t&&(this.$root=y),m(v)&&O(v,(function(t,e){n.registerModule(e,t)})),Q(c,(function(t,e){if(t)return D(0,t.message);$(e)&&e(n)})),this.afterCreate()}return c()(t,[{key:"execSubcribers",value:function(t,e){var n=this;Q(this.$subscribers[t],(function(t,r){if(t)return D(0,t.message);$(r)&&r.apply(void 0,[n].concat(i()(e)))}))}},{key:"state",get:function(){return this.$state}},{key:"getters",get:function(){return this.$getters}},{key:"root",get:function(){return this.$root}},{key:"modules",get:function(){return this.$modules}}]),t}();function tt(){arguments.length>0&&void 0!==arguments[0]&&arguments[0];return function(t){var e=E(t.state),n=console.info;t.subscribe("action",(function(t,e){for(var r=arguments.length,o=new Array(r>2?r-2:0),i=2;i<r;i++)o[i-2]=arguments[i];n("%c [Herbx] Action: ".concat(JSON.stringify(e),", Payload: "),"color: #9E9E9E; font-weight: bold",o)}));t.subscribe("mutation",(function(t,r){for(var o=r,i=arguments.length,u=new Array(i>2?i-2:0),s=2;s<i;s++)u[s-2]=arguments[s];var a=u;"string"!=typeof r&&(o="Empty Mutation Name",a.unshift(r));var c=E(t.state);n("%c [Herbx] Prev State: ","color: #9E9E9E; font-weight: bold",e),n("%c [Herbx] Mutation: ".concat(JSON.stringify(o),", Payload: "),"color: #03A9F4; font-weight: bold",a),n("%c [Herbx] Next State: ","color: #4CAF50; font-weight: bold",c),e=c}))}}function et(){arguments.length>0&&void 0!==arguments[0]&&arguments[0];return function(t){}}n.d(e,"Types",(function(){return r})),n.d(e,"is",(function(){return d})),n.d(e,"isNil",(function(){return h})),n.d(e,"isArray",(function(){return p})),n.d(e,"isObject",(function(){return y})),n.d(e,"isPlainObject",(function(){return m})),n.d(e,"isString",(function(){return b})),n.d(e,"isSymbol",(function(){return v})),n.d(e,"isPromise",(function(){return g})),n.d(e,"isFunction",(function(){return $})),n.d(e,"findByKey",(function(){return j})),n.d(e,"findIndex",(function(){return x})),n.d(e,"eachObject",(function(){return O})),n.d(e,"lastIndexOf",(function(){return k})),n.d(e,"remove",(function(){return P})),n.d(e,"noop",(function(){return T})),n.d(e,"assert",(function(){return A})),n.d(e,"log",(function(){return D})),n.d(e,"deepCopy",(function(){return E})),n.d(e,"hasOwnProperty",(function(){return I})),n.d(e,"def",(function(){return _})),n.d(e,"LoggerPlugin",(function(){return tt})),n.d(e,"DevToolPlugin",(function(){return et})),n.d(e,"Store",(function(){return Z}));e.default=Z}])})); |
@@ -11,3 +11,4 @@ import { IObject } from 'herb-core-include'; | ||
export declare function hasOwnProperty(obj: IObject, key: any): any; | ||
export declare function def(obj: IObject, key: string, val: any, enumerable?: boolean): void; | ||
export {}; | ||
//# sourceMappingURL=function.d.ts.map |
{ | ||
"name": "herbx", | ||
"version": "1.2.6", | ||
"version": "1.2.7", | ||
"main": "lib/index.js", | ||
@@ -20,3 +20,3 @@ "files": [ | ||
}, | ||
"gitHead": "dd332724f0e8bd9a0bc7254ce65f2320e03d56e8" | ||
"gitHead": "8cdb207f567a98458203b6f37e4c2a02fede613e" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
106307
42
230
1