From ddcc6dbf2e40768101f47d5dbad922a218277190 Mon Sep 17 00:00:00 2001 From: Evan You Date: Fri, 4 Mar 2016 07:36:34 -0500 Subject: [PATCH] 0.5.1 --- dist/vuex.js | 11 +++++++++-- dist/vuex.min.js | 4 ++-- package.json | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/dist/vuex.js b/dist/vuex.js index 61825199f..e8e66bb2f 100644 --- a/dist/vuex.js +++ b/dist/vuex.js @@ -1,5 +1,5 @@ /*! - * Vuex v0.5.0 + * Vuex v0.5.1 * (c) 2016 Evan You * Released under the MIT License. */ @@ -100,9 +100,11 @@ hook.emit('vuex:init', store); hook.on('vuex:travel-to-state', function (targetState) { var currentState = store._vm._data; + store._dispatching = true; Object.keys(targetState).forEach(function (key) { currentState[key] = targetState[key]; }); + store._dispatching = false; }); }, onMutation: function onMutation(mutation, state) { @@ -455,9 +457,14 @@ override(Vue); } + function createLogger() { + console.warn('[vuex] Vuex.createLogger has been deprecated.' + 'Use `import createLogger from \'vuex/logger\' instead.'); + } + var index = { Store: Store, - install: install + install: install, + createLogger: createLogger }; return index; diff --git a/dist/vuex.min.js b/dist/vuex.min.js index 339e5f905..b6583de8f 100644 --- a/dist/vuex.min.js +++ b/dist/vuex.min.js @@ -1,6 +1,6 @@ /*! - * Vuex v0.5.0 + * Vuex v0.5.1 * (c) 2016 Evan You * Released under the MIT License. */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.Vuex=e()}(this,function(){"use strict";function t(t){return t.reduce(function(t,e){return Object.keys(e).forEach(function(n){var o=t[n];o?Array.isArray(o)?o.push(e[n]):t[n]=[t[n],e[n]]:t[n]=e[n]}),t},{})}function e(t){if(Array.isArray(t))return t.map(e);if(t&&"object"===("undefined"==typeof t?"undefined":i["typeof"](t))){for(var n={},o=Object.keys(t),s=0,a=o.length;a>s;s++){var r=o[s];n[r]=e(t[r])}return n}return t}function n(t){var e=t.prototype._init;t.prototype._init=function(t){var n=this;t=t||{};var o=this.constructor.options,i=t.store||o.store;i?this.$store=i:t.parent&&t.parent.$store&&(this.$store=t.parent.$store);var s=t.vuex||o.vuex;s&&!function(){n.$store||console.warn("[vuex] store not injected. make sure to provide the store option in your root component.");var e=s.state,o=s.actions;e&&(t.computed=t.computed||{},Object.keys(e).forEach(function(n){t.computed[n]=function(){return e[n].call(this,this.$store.state)}})),o&&(t.methods=t.methods||{},Object.keys(o).forEach(function(e){t.methods[e]=function(){for(var t,n=arguments.length,i=Array(n),s=0;n>s;s++)i[s]=arguments[s];return(t=o[e]).call.apply(t,[this,this.$store].concat(i))}}))}(),e.call(this,t)}}function o(t){r=t,n(r)}var i={};i["typeof"]="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},i.classCallCheck=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},i.createClass=function(){function t(t,e){for(var n=0;no;o++)n[o]=arguments[o];v.apply(t,n)};var y=r.config.silent;r.config.silent=!0,this._vm=new r({data:s}),r.config.silent=y,this._setupModuleState(s,h),this._setupModuleMutations(h),this._setupMiddlewares(d,s),l&&this._setupMutationCheck()}return i.createClass(n,[{key:"dispatch",value:function(t){for(var n=this,o=arguments.length,i=Array(o>1?o-1:0),s=1;o>s;s++)i[s-1]=arguments[s];var a=this._mutations[t],r=this._prevSnapshot,u=this.state,c=void 0,h=void 0;a?(this._dispatching=!0,Array.isArray(a)?a.forEach(function(t){return t.apply(void 0,[u].concat(i))}):a.apply(void 0,[u].concat(i)),this._dispatching=!1,this._needSnapshots&&(c=this._prevSnapshot=e(u),h=e(i)),this._middlewares.forEach(function(e){e.onMutation&&(e.snapshot?e.onMutation({type:t,payload:h},c,r,n):e.onMutation({type:t,payload:i},u,n))})):console.warn("[vuex] Unknown mutation: "+t)}},{key:"watch",value:function(t,e,n){var o=this;return this._vm.$watch(function(){return"function"==typeof t?t(o.state):o._vm.$get(t)},e,n)}},{key:"hotUpdate",value:function(){var t=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],e=t.mutations,n=t.modules;this._rootMutations=this._mutations=e||this._rootMutations,this._setupModuleMutations(n||this._modules)}},{key:"_setupModuleState",value:function(t,e){var n=r.parsers.path.setPath;Object.keys(e).forEach(function(o){n(t,o,e[o].state||{})})}},{key:"_setupModuleMutations",value:function(e){this._modules=e;var n=r.parsers.path.getPath,o=[this._rootMutations];Object.keys(e).forEach(function(t){var i=e[t];if(i&&i.mutations){var s={};Object.keys(i.mutations).forEach(function(e){var o=i.mutations[e];s[e]=function(e){for(var i=arguments.length,s=Array(i>1?i-1:0),a=1;i>a;a++)s[a-1]=arguments[a];o.apply(void 0,[n(e,t)].concat(s))}}),o.push(s)}}),this._mutations=t(o)}},{key:"_setupMutationCheck",value:function(){var t=this,e=this._vm.$watch("__vuex__",function(t){return t}),n=this._vm._watchers[0].constructor;e(),new n(this._vm,"$data",function(){if(!t._dispatching)throw new Error("[vuex] Do not mutate vuex store state outside mutation handlers.")},{deep:!0,sync:!0})}},{key:"_setupMiddlewares",value:function(t,n){var o=this;this._middlewares=[a].concat(t),this._needSnapshots=t.some(function(t){return t.snapshot}),this._needSnapshots&&console.log("[vuex] One or more of your middlewares are taking state snapshots for each mutation. Make sure to use them only during development.");var i=this._prevSnapshot=this._needSnapshots?e(n):null;this._middlewares.forEach(function(t){t.onInit&&t.onInit(t.snapshot?i:n,o)})}},{key:"state",get:function(){return this._vm._data},set:function(t){throw new Error("[vuex] Vuex root state is read only.")}}]),n}(),c={Store:u,install:o};return c}); \ No newline at end of file +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.Vuex=e()}(this,function(){"use strict";function t(t){return t.reduce(function(t,e){return Object.keys(e).forEach(function(o){var n=t[o];n?Array.isArray(n)?n.push(e[o]):t[o]=[t[o],e[o]]:t[o]=e[o]}),t},{})}function e(t){if(Array.isArray(t))return t.map(e);if(t&&"object"===("undefined"==typeof t?"undefined":s["typeof"](t))){for(var o={},n=Object.keys(t),i=0,a=n.length;a>i;i++){var r=n[i];o[r]=e(t[r])}return o}return t}function o(t){var e=t.prototype._init;t.prototype._init=function(t){var o=this;t=t||{};var n=this.constructor.options,i=t.store||n.store;i?this.$store=i:t.parent&&t.parent.$store&&(this.$store=t.parent.$store);var s=t.vuex||n.vuex;s&&!function(){o.$store||console.warn("[vuex] store not injected. make sure to provide the store option in your root component.");var e=s.state,n=s.actions;e&&(t.computed=t.computed||{},Object.keys(e).forEach(function(o){t.computed[o]=function(){return e[o].call(this,this.$store.state)}})),n&&(t.methods=t.methods||{},Object.keys(n).forEach(function(e){t.methods[e]=function(){for(var t,o=arguments.length,i=Array(o),s=0;o>s;s++)i[s]=arguments[s];return(t=n[e]).call.apply(t,[this,this.$store].concat(i))}}))}(),e.call(this,t)}}function n(t){u=t,o(u)}function i(){console.warn("[vuex] Vuex.createLogger has been deprecated.Use `import createLogger from 'vuex/logger' instead.")}var s={};s["typeof"]="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},s.classCallCheck=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},s.createClass=function(){function t(t,e){for(var o=0;on;n++)o[n]=arguments[n];v.apply(t,o)};var y=u.config.silent;u.config.silent=!0,this._vm=new u({data:i}),u.config.silent=y,this._setupModuleState(i,h),this._setupModuleMutations(h),this._setupMiddlewares(d,i),l&&this._setupMutationCheck()}return s.createClass(o,[{key:"dispatch",value:function(t){for(var o=this,n=arguments.length,i=Array(n>1?n-1:0),s=1;n>s;s++)i[s-1]=arguments[s];var a=this._mutations[t],r=this._prevSnapshot,u=this.state,c=void 0,h=void 0;a?(this._dispatching=!0,Array.isArray(a)?a.forEach(function(t){return t.apply(void 0,[u].concat(i))}):a.apply(void 0,[u].concat(i)),this._dispatching=!1,this._needSnapshots&&(c=this._prevSnapshot=e(u),h=e(i)),this._middlewares.forEach(function(e){e.onMutation&&(e.snapshot?e.onMutation({type:t,payload:h},c,r,o):e.onMutation({type:t,payload:i},u,o))})):console.warn("[vuex] Unknown mutation: "+t)}},{key:"watch",value:function(t,e,o){var n=this;return this._vm.$watch(function(){return"function"==typeof t?t(n.state):n._vm.$get(t)},e,o)}},{key:"hotUpdate",value:function(){var t=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],e=t.mutations,o=t.modules;this._rootMutations=this._mutations=e||this._rootMutations,this._setupModuleMutations(o||this._modules)}},{key:"_setupModuleState",value:function(t,e){var o=u.parsers.path.setPath;Object.keys(e).forEach(function(n){o(t,n,e[n].state||{})})}},{key:"_setupModuleMutations",value:function(e){this._modules=e;var o=u.parsers.path.getPath,n=[this._rootMutations];Object.keys(e).forEach(function(t){var i=e[t];if(i&&i.mutations){var s={};Object.keys(i.mutations).forEach(function(e){var n=i.mutations[e];s[e]=function(e){for(var i=arguments.length,s=Array(i>1?i-1:0),a=1;i>a;a++)s[a-1]=arguments[a];n.apply(void 0,[o(e,t)].concat(s))}}),n.push(s)}}),this._mutations=t(n)}},{key:"_setupMutationCheck",value:function(){var t=this,e=this._vm.$watch("__vuex__",function(t){return t}),o=this._vm._watchers[0].constructor;e(),new o(this._vm,"$data",function(){if(!t._dispatching)throw new Error("[vuex] Do not mutate vuex store state outside mutation handlers.")},{deep:!0,sync:!0})}},{key:"_setupMiddlewares",value:function(t,o){var n=this;this._middlewares=[r].concat(t),this._needSnapshots=t.some(function(t){return t.snapshot}),this._needSnapshots&&console.log("[vuex] One or more of your middlewares are taking state snapshots for each mutation. Make sure to use them only during development.");var i=this._prevSnapshot=this._needSnapshots?e(o):null;this._middlewares.forEach(function(t){t.onInit&&t.onInit(t.snapshot?i:o,n)})}},{key:"state",get:function(){return this._vm._data},set:function(t){throw new Error("[vuex] Vuex root state is read only.")}}]),o}(),h={Store:c,install:n,createLogger:i};return h}); \ No newline at end of file diff --git a/package.json b/package.json index 54e64c3e3..16525eed7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vuex", - "version": "0.5.0", + "version": "0.5.1", "description": "state management for Vue.js", "main": "dist/vuex.js", "files": [