Comparing version 1.1.19 to 1.1.20
import { IActionPayloadType, IHerbxActionParams, IHerbxGetterParams, IHerbxMutationParams, IHerbxMutationPayloadType } from 'herb-core-include'; | ||
import { StoreInstanceType } from '../store'; | ||
export declare function buildGetterParams<State, Getters, K extends keyof Getters>(this: StoreInstanceType, key: K): IHerbxGetterParams<State, Getters, K>; | ||
export declare function buildMutationParams<Mutations, State, K extends keyof Mutations>(this: StoreInstanceType, mutation: K, payload: IHerbxMutationPayloadType<Mutations, K>): IHerbxMutationParams<State, Mutations, K>; | ||
export declare function buildActionParams<State, Getters, Mutations, Actions, K extends keyof Actions>(this: StoreInstanceType<State, Getters, Mutations, Actions>, action: K, payload?: IActionPayloadType<Actions, K>): IHerbxActionParams<State, Getters, Mutations, Actions, K>; | ||
export declare function buildMutationParams<Mutations, State, K extends keyof Mutations>(this: StoreInstanceType, mutation: K, ...payload: IHerbxMutationPayloadType<Mutations, K>[]): IHerbxMutationParams<State, Mutations, K>; | ||
export declare function buildActionParams<State, Getters, Mutations, Actions, K extends keyof Actions>(this: StoreInstanceType<State, Getters, Mutations, Actions>, action: K, ...payload: IActionPayloadType<Actions, K>[]): IHerbxActionParams<State, Getters, Mutations, Actions, K>; | ||
//# sourceMappingURL=builder.d.ts.map |
@@ -1,7 +0,4 @@ | ||
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'; | ||
declare type IProxyFunctionResponse<T> = T | void | never; | ||
export declare function proxyState<T>(state: T, notify?: NotifyFunction<T>): IProxyFunctionResponse<T>; | ||
export declare function proxyState<T>(state: T): IProxyFunctionResponse<T>; | ||
export declare function proxyGetters<T>(getters: T, buildParams: IFunction<[keyof T]>): IProxyFunctionResponse<T>; | ||
@@ -8,0 +5,0 @@ export declare function proxyMutations<T>(mutations: T): IProxyFunctionResponse<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=4)}([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(5),o=n(6),i=n(7);t.exports=function(t,e){return r(t)||o(t,e)||i()}},function(t,e,n){t.exports=n(8)},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(0),i=n.n(o),u=n(1),c=n.n(u),s=n(2),a=n.n(s);function f(t,e){return Object.prototype.toString.call(t)===r[e]}function l(t){return null==t}function m(t){return Array.isArray?Array.isArray(t):f(t,"array")}function d(t){return!!t&&"object"===a()(t)}function b(t){return f(t,"object")}function p(t){return f(t,"string")}function y(t){return f(t,"symbol")}function h(t){return!!t&&"function"==typeof t.then}function g(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 v=n(3),$=n.n(v);function j(t,e){for(var n=$()(e,2),r=n[0],o=n[1],i=0;i<t.length;i++)if(t[i][r]===o)return t[i]}function S(t,e){return t.indexOf(e)}function x(t,e){for(var n=Object.keys(t),r=0;r<n.length;r++){var o=n[r];e(t[o],o)}}function O(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){var n=S(t,e);n>-1&&t.splice(n,1)}function T(){}function w(t,e){if(!t)throw new Error("[Herbx] "+e)}function k(t,e,n){0}function E(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(null===t||"object"!==a()(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 A(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function C(t,e){if(d(t)){var n=Object.prototype.toString.call(t);n===r.object?x(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;C(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),C(o,r)))}})}(t,r,n,e)})):n===r.array&&t.forEach((function(t){C(t,e)}))}}function M(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 D(t,e){return[this.state,e]}function F(t,e){var n=this,r=!!n.root,o={};return Object.defineProperties(o,{commit:{get:function(){return n.commit},enumerable:!0},dispatch:{get:function(){return n.dispatch},enumerable:!0},state:{get:function(){return n.state},enumerable:!0},rootState:{get:function(){return r?n.root.state:void 0},enumerable:!0},getters:{get:function(){return n.getters},enumerable:!0},rootGetters:{get:function(){return r?n.root.getters:void 0},enumerable:!0},dispatchRoot:{get:function(){return r?n.root.dispatch:T},enumerable:!0},commitRoot:{get:function(){return r?n.root.commit:T},enumerable:!0}}),[o,e]}function H(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 H(t.substr(o+e.length),i.$namespaceSep,i.modules)}}function N(t,e,n){var r=function(t,e){var n=O(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:H(o,e,n),method:i}}}function _(t,e){if(m(t))try{t.forEach((function(t){e(null,t)}))}catch(t){e(t)}}var q={},I=function(){function t(e){i()(this,t),this.queue=[],this.flushing=!1;var n=e.uid;this.uid=n,this.afterCreate()}return c()(t,[{key:"afterCreate",value:function(){A(q,this.uid)||(q[this.uid]=this)}},{key:"beforeDestroy",value:function(){A(q,this.uid)&&delete q[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&&(_(e.queue.splice(0,n),(function(t,e){t?console.warn("[Herbx Flush Error] ",t):e()})),e.flushing=!1,g(t)&&t())}),0)}}]),t}(),G=0,J=function(){function t(e){var n=this;i()(this,t),this.$namespaceSep="/",this.$mutationFunctionContext=null,this.$actionFunctionContext=null,this.$uid=G++,this.$subscribers={mutation:[],action:[]},this.$modules={},this.afterCreate=function(){n.resetScheduler()},this.beforeDestory=function(){n.$scheduler.beforeDestroy()},this.resetScheduler=function(){n.$scheduler.addTask((function(){n.broadcast(),g(n.$listener)&&n.$listener(n)}))},this.broadcast=function(){x(n.$modules,(function(t,e){n&&t.notify()}))},this.notify=function(){n&&n.$scheduler.flush(n.resetScheduler)},this.subscribe=function(t,e){return n.$subscribers[t]?(S(n.$subscribers[t],e)<0&&n.$subscribers[t].push(e),function(){P(n.$subscribers[t],e)}):T},this.registerModule=function(e,r){A(n.$modules,e)&&w(!1,"namespace is exists: "+e),b(r)||w(!1,"options must be object: "+e);var o=new t(Object.assign({},r,{root:n,namespace:e}));return n.$modules[e]=o,o},this.unregisterModule=function(t){A(n.$modules,t)&&(n.$modules[t].beforeDestory(),delete n.$modules[t])},this.dispatch=function(t,e){var r=n.$actions[t];if("function"==typeof r){_(n.$subscribers.action,(function(r,o){if(r)return k(0,r.message);o(n,t,e)}));var o=F.call(n,t,e);return r.apply(n.$actionFunctionContext,"function"==typeof n.$actionParamsTransformer?n.$actionParamsTransformer.apply(null,o):o)}var i=N(t,n.$namespaceSep,n.$modules);if(i&&i.module)return i.module.dispatch(i.method,e);k()},this.commit=function(t,e){var r=n.$mutations[t];if("function"==typeof r){var o=D.call(n,t,e),i=r.apply(n.$mutationFunctionContext,"function"==typeof n.$mutationParamsTransformer?n.$mutationParamsTransformer.apply(null,o.concat(t)):o);return _(n.$subscribers.mutation,(function(r,o){if(r)return k(0,r.message);o(n,t,e)})),i}var u=N(t,n.$namespaceSep,n.$modules);if(u&&u.module)return u.module.commit(u.method,e);k()};var r=e.state,o=e.getters,u=e.mutations,c=e.actions,s=e.plugins,a=e.namespace,f=e.actionParamsTransformer,m=e.getterParamsTransformer,d=e.mutationParamsTransformer,p=e.root,y=e.listener,h=e.modules;this.$state=function(t,e){if(!l(t)){var n=b(t);if(n){var r=E(t);return C(r,e),r}k()}}(r,this.notify)||{},this.$getters=function(t,e){if(!l(t)){var n=b(t);if(n){var r={};return x(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)}})):k()})),r}k()}}(o,(function(t){var e=M.call(n,t);return"function"==typeof n.$getterParamsTransformer?n.$getterParamsTransformer.call(null,e):e}))||{},this.$mutations=function(t){if(!l(t)){var e=b(t);if(e)return t;k()}}(u)||{},this.$actions=function(t){if(!l(t)){var e=b(t);if(e)return t;k()}}(c)||{},this.$namespace=a,this.$getterParamsTransformer=m,this.$actionParamsTransformer=f,this.$mutationParamsTransformer=d,this.$scheduler=new I({uid:this.$uid}),this.$listener=y,p&&p instanceof t&&(this.$root=p),b(h)&&x(h,(function(t,e){n.registerModule(e,t)})),_(s,(function(t,e){if(t)return k(0,t.message);g(e)&&e(n)})),this.afterCreate()}return c()(t,[{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 R(){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,r){n("%c [Herbx] Action: ".concat(JSON.stringify(e),", Payload: "),"color: #9E9E9E; font-weight: bold",r)}));t.subscribe("mutation",(function(t,r,o){var i=E(t.state);n("%c [Herbx] Prev State: ","color: #9E9E9E; font-weight: bold",e),n("%c [Herbx] Mutation: ".concat(JSON.stringify(r),", Payload: "),"color: #03A9F4; font-weight: bold",o),n("%c [Herbx] Next State: ","color: #4CAF50; font-weight: bold",i),e=i}))}}function B(){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 f})),n.d(e,"isNil",(function(){return l})),n.d(e,"isArray",(function(){return m})),n.d(e,"isObject",(function(){return d})),n.d(e,"isPlainObject",(function(){return b})),n.d(e,"isString",(function(){return p})),n.d(e,"isSymbol",(function(){return y})),n.d(e,"isPromise",(function(){return h})),n.d(e,"isFunction",(function(){return g})),n.d(e,"findByKey",(function(){return j})),n.d(e,"findIndex",(function(){return S})),n.d(e,"eachObject",(function(){return x})),n.d(e,"lastIndexOf",(function(){return O})),n.d(e,"remove",(function(){return P})),n.d(e,"noop",(function(){return T})),n.d(e,"assert",(function(){return w})),n.d(e,"log",(function(){return k})),n.d(e,"deepCopy",(function(){return E})),n.d(e,"hasOwnProperty",(function(){return A})),n.d(e,"LoggerPlugin",(function(){return R})),n.d(e,"DevToolPlugin",(function(){return B})),n.d(e,"Store",(function(){return J}));e.default=J}])})); | ||
!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 d(t){return Array.isArray?Array.isArray(t):m(t,"array")}function y(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 x=n(4),S=n.n(x);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 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=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 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 F(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 D(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,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 H(t.substr(o+e.length),i.$namespaceSep,i.modules)}}function _(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:H(o,e,n),method:i}}}function q(t,e){if(d(t))try{t.forEach((function(t){e(null,t)}))}catch(t){e(t)}}var I={},G=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(I,this.uid)||(I[this.uid]=this)}},{key:"beforeDestroy",value:function(){M(I,this.uid)&&delete I[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&&(q(e.queue.splice(0,n),(function(t,e){t?console.warn("[Herbx Flush Error] ",t):e()})),e.flushing=!1,$(t)&&t())}),0)}}]),t}(),J=0,R=function(){function t(e){var n=this;c()(this,t),this.$namespaceSep="/",this.$namespaced=!1,this.$mutationFunctionContext=null,this.$actionFunctionContext=null,this.$uid=J++,this.$subscribers={mutation:[],action:[]},this.$modules={},this.afterCreate=function(){n.$namespaced||(n.$scheduler=new G({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=_(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=D.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=_(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,d=e.mutationParamsTransformer,y=e.root,h=e.listener,g=e.modules,v=e.namespaced,x=void 0!==v&&v;this.$state=function(t){if(!p(t)){var e=b(t);if(e)return C(t);E()}}(r)||{},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=F.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=!!x,this.$getterParamsTransformer=m,this.$actionParamsTransformer=l,this.$mutationParamsTransformer=d,this.$listener=h,y&&y instanceof t&&(this.$root=y),b(g)&&P(g,(function(t,e){n.registerModule(e,t)})),q(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;q(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 B(){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 K(){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 d})),n.d(e,"isObject",(function(){return y})),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 j})),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 B})),n.d(e,"DevToolPlugin",(function(){return K})),n.d(e,"Store",(function(){return R}));e.default=R}])})); |
@@ -1,2 +0,2 @@ | ||
import { IFunction, IHerbxStoreOptions } from 'herb-core-include'; | ||
import { IFunction, IHerbxStoreOptions, IHerbxSubscriber } from 'herb-core-include'; | ||
import { noop } from './utils'; | ||
@@ -8,2 +8,3 @@ export declare type StoreInstanceType<State = any, Getters = any, Mutations = any, Actions = any> = Store<State, Getters, Mutations, Actions>; | ||
readonly $namespaceSep: string; | ||
readonly $namespaced: boolean; | ||
$mutationFunctionContext: any; | ||
@@ -22,3 +23,3 @@ $actionFunctionContext: any; | ||
private readonly $mutationParamsTransformer?; | ||
private readonly $scheduler; | ||
private $scheduler; | ||
private readonly $listener; | ||
@@ -38,6 +39,7 @@ constructor(options: IHerbxStoreOptions<State, Getters, Mutations, Actions>); | ||
unregisterModule: (namespace: string) => void; | ||
dispatch: (action: string, payload?: any) => any; | ||
commit: (mutation: string, payload?: any) => any; | ||
dispatch: (...args: any[]) => any; | ||
commit: (...args: any[]) => any; | ||
execSubcribers(key: keyof IHerbxSubscriber<Mutations, Actions>, args: any[]): void; | ||
} | ||
export default Store; | ||
//# sourceMappingURL=store.d.ts.map |
@@ -11,10 +11,10 @@ export declare enum Types { | ||
export declare function is(input: any, str: keyof typeof Types): boolean; | ||
export declare function isNil(input: any): boolean; | ||
export declare function isArray(input: any): boolean; | ||
export declare function isNil(nil: any): boolean; | ||
export declare function isArray(arr: any): arr is any[]; | ||
export declare function isObject(input: any): boolean; | ||
export declare function isPlainObject(input: any): boolean; | ||
export declare function isString(input: any): boolean; | ||
export declare function isSymbol(input: any): boolean; | ||
export declare function isPromise(e: any): boolean; | ||
export declare function isFunction(input: any): boolean; | ||
export declare function isPlainObject(obj: any): obj is Record<any, any>; | ||
export declare function isString(str: any): str is string; | ||
export declare function isSymbol(sym: any): boolean; | ||
export declare function isPromise(e: any): e is Promise<any>; | ||
export declare function isFunction(fn: any): boolean; | ||
//# sourceMappingURL=is.d.ts.map |
{ | ||
"name": "herbx", | ||
"version": "1.1.19", | ||
"version": "1.1.20", | ||
"main": "lib/index.js", | ||
@@ -18,5 +18,5 @@ "files": [ | ||
"dependencies": { | ||
"herb-core-include": "^1.0.8" | ||
"herb-core-include": "^1.0.9" | ||
}, | ||
"gitHead": "6dd58e6f498acc4254391bd48ef2b6b104ef167a" | ||
"gitHead": "9a8d5c92614b05bf81bf76cdaeba9368b637206e" | ||
} |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
84014
140
Updatedherb-core-include@^1.0.9