vuejs 1.0.36 → 1.0.37

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,761 @@
1
+ /**
2
+ * vuex v2.1.1
3
+ * (c) 2016 Evan You
4
+ * @license MIT
5
+ */
6
+ (function (global, factory) {
7
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
8
+ typeof define === 'function' && define.amd ? define(factory) :
9
+ (global.Vuex = factory());
10
+ }(this, (function () { 'use strict';
11
+
12
+ var devtoolHook =
13
+ typeof window !== 'undefined' &&
14
+ window.__VUE_DEVTOOLS_GLOBAL_HOOK__
15
+
16
+ function devtoolPlugin (store) {
17
+ if (!devtoolHook) { return }
18
+
19
+ store._devtoolHook = devtoolHook
20
+
21
+ devtoolHook.emit('vuex:init', store)
22
+
23
+ devtoolHook.on('vuex:travel-to-state', function (targetState) {
24
+ store.replaceState(targetState)
25
+ })
26
+
27
+ store.subscribe(function (mutation, state) {
28
+ devtoolHook.emit('vuex:mutation', mutation, state)
29
+ })
30
+ }
31
+
32
+ function applyMixin (Vue) {
33
+ var version = Number(Vue.version.split('.')[0])
34
+
35
+ if (version >= 2) {
36
+ var usesInit = Vue.config._lifecycleHooks.indexOf('init') > -1
37
+ Vue.mixin(usesInit ? { init: vuexInit } : { beforeCreate: vuexInit })
38
+ } else {
39
+ // override init and inject vuex init procedure
40
+ // for 1.x backwards compatibility.
41
+ var _init = Vue.prototype._init
42
+ Vue.prototype._init = function (options) {
43
+ if ( options === void 0 ) options = {};
44
+
45
+ options.init = options.init
46
+ ? [vuexInit].concat(options.init)
47
+ : vuexInit
48
+ _init.call(this, options)
49
+ }
50
+ }
51
+
52
+ /**
53
+ * Vuex init hook, injected into each instances init hooks list.
54
+ */
55
+
56
+ function vuexInit () {
57
+ var options = this.$options
58
+ // store injection
59
+ if (options.store) {
60
+ this.$store = options.store
61
+ } else if (options.parent && options.parent.$store) {
62
+ this.$store = options.parent.$store
63
+ }
64
+ }
65
+ }
66
+
67
+ var mapState = normalizeNamespace(function (namespace, states) {
68
+ var res = {}
69
+ normalizeMap(states).forEach(function (ref) {
70
+ var key = ref.key;
71
+ var val = ref.val;
72
+
73
+ res[key] = function mappedState () {
74
+ var state = this.$store.state
75
+ var getters = this.$store.getters
76
+ if (namespace) {
77
+ var module = this.$store._modulesNamespaceMap[namespace]
78
+ if (!module) {
79
+ warnNamespace('mapState', namespace)
80
+ return
81
+ }
82
+ state = module.state
83
+ getters = module.context.getters
84
+ }
85
+ return typeof val === 'function'
86
+ ? val.call(this, state, getters)
87
+ : state[val]
88
+ }
89
+ })
90
+ return res
91
+ })
92
+
93
+ var mapMutations = normalizeNamespace(function (namespace, mutations) {
94
+ var res = {}
95
+ normalizeMap(mutations).forEach(function (ref) {
96
+ var key = ref.key;
97
+ var val = ref.val;
98
+
99
+ val = namespace + val
100
+ res[key] = function mappedMutation () {
101
+ var args = [], len = arguments.length;
102
+ while ( len-- ) args[ len ] = arguments[ len ];
103
+
104
+ return this.$store.commit.apply(this.$store, [val].concat(args))
105
+ }
106
+ })
107
+ return res
108
+ })
109
+
110
+ var mapGetters = normalizeNamespace(function (namespace, getters) {
111
+ var res = {}
112
+ normalizeMap(getters).forEach(function (ref) {
113
+ var key = ref.key;
114
+ var val = ref.val;
115
+
116
+ val = namespace + val
117
+ res[key] = function mappedGetter () {
118
+ if (!(val in this.$store.getters)) {
119
+ console.error(("[vuex] unknown getter: " + val))
120
+ }
121
+ return this.$store.getters[val]
122
+ }
123
+ })
124
+ return res
125
+ })
126
+
127
+ var mapActions = normalizeNamespace(function (namespace, actions) {
128
+ var res = {}
129
+ normalizeMap(actions).forEach(function (ref) {
130
+ var key = ref.key;
131
+ var val = ref.val;
132
+
133
+ val = namespace + val
134
+ res[key] = function mappedAction () {
135
+ var args = [], len = arguments.length;
136
+ while ( len-- ) args[ len ] = arguments[ len ];
137
+
138
+ return this.$store.dispatch.apply(this.$store, [val].concat(args))
139
+ }
140
+ })
141
+ return res
142
+ })
143
+
144
+ function normalizeMap (map) {
145
+ return Array.isArray(map)
146
+ ? map.map(function (key) { return ({ key: key, val: key }); })
147
+ : Object.keys(map).map(function (key) { return ({ key: key, val: map[key] }); })
148
+ }
149
+
150
+ function normalizeNamespace (fn) {
151
+ return function (namespace, map) {
152
+ if (typeof namespace !== 'string') {
153
+ map = namespace
154
+ namespace = ''
155
+ } else if (namespace.charAt(namespace.length - 1) !== '/') {
156
+ namespace += '/'
157
+ }
158
+ return fn(namespace, map)
159
+ }
160
+ }
161
+
162
+ function warnNamespace (helper, namespace) {
163
+ console.error(("[vuex] module namespace not found in " + helper + "(): " + namespace))
164
+ }
165
+
166
+ /**
167
+ * forEach for object
168
+ */
169
+ function forEachValue (obj, fn) {
170
+ Object.keys(obj).forEach(function (key) { return fn(obj[key], key); })
171
+ }
172
+
173
+ function isObject (obj) {
174
+ return obj !== null && typeof obj === 'object'
175
+ }
176
+
177
+ function isPromise (val) {
178
+ return val && typeof val.then === 'function'
179
+ }
180
+
181
+ function assert (condition, msg) {
182
+ if (!condition) { throw new Error(("[vuex] " + msg)) }
183
+ }
184
+
185
+ var Module = function Module (rawModule, runtime) {
186
+ this.runtime = runtime
187
+ this._children = Object.create(null)
188
+ this._rawModule = rawModule
189
+ };
190
+
191
+ var prototypeAccessors$1 = { state: {},namespaced: {} };
192
+
193
+ prototypeAccessors$1.state.get = function () {
194
+ return this._rawModule.state || {}
195
+ };
196
+
197
+ prototypeAccessors$1.namespaced.get = function () {
198
+ return !!this._rawModule.namespaced
199
+ };
200
+
201
+ Module.prototype.addChild = function addChild (key, module) {
202
+ this._children[key] = module
203
+ };
204
+
205
+ Module.prototype.removeChild = function removeChild (key) {
206
+ delete this._children[key]
207
+ };
208
+
209
+ Module.prototype.getChild = function getChild (key) {
210
+ return this._children[key]
211
+ };
212
+
213
+ Module.prototype.update = function update (rawModule) {
214
+ this._rawModule.namespaced = rawModule.namespaced
215
+ if (rawModule.actions) {
216
+ this._rawModule.actions = rawModule.actions
217
+ }
218
+ if (rawModule.mutations) {
219
+ this._rawModule.mutations = rawModule.mutations
220
+ }
221
+ if (rawModule.getters) {
222
+ this._rawModule.getters = rawModule.getters
223
+ }
224
+ };
225
+
226
+ Module.prototype.forEachChild = function forEachChild (fn) {
227
+ forEachValue(this._children, fn)
228
+ };
229
+
230
+ Module.prototype.forEachGetter = function forEachGetter (fn) {
231
+ if (this._rawModule.getters) {
232
+ forEachValue(this._rawModule.getters, fn)
233
+ }
234
+ };
235
+
236
+ Module.prototype.forEachAction = function forEachAction (fn) {
237
+ if (this._rawModule.actions) {
238
+ forEachValue(this._rawModule.actions, fn)
239
+ }
240
+ };
241
+
242
+ Module.prototype.forEachMutation = function forEachMutation (fn) {
243
+ if (this._rawModule.mutations) {
244
+ forEachValue(this._rawModule.mutations, fn)
245
+ }
246
+ };
247
+
248
+ Object.defineProperties( Module.prototype, prototypeAccessors$1 );
249
+
250
+ var ModuleCollection = function ModuleCollection (rawRootModule) {
251
+ var this$1 = this;
252
+
253
+ // register root module (Vuex.Store options)
254
+ this.root = new Module(rawRootModule, false)
255
+
256
+ // register all nested modules
257
+ if (rawRootModule.modules) {
258
+ forEachValue(rawRootModule.modules, function (rawModule, key) {
259
+ this$1.register([key], rawModule, false)
260
+ })
261
+ }
262
+ };
263
+
264
+ ModuleCollection.prototype.get = function get (path) {
265
+ return path.reduce(function (module, key) {
266
+ return module.getChild(key)
267
+ }, this.root)
268
+ };
269
+
270
+ ModuleCollection.prototype.getNamespace = function getNamespace (path) {
271
+ var module = this.root
272
+ return path.reduce(function (namespace, key) {
273
+ module = module.getChild(key)
274
+ return namespace + (module.namespaced ? key + '/' : '')
275
+ }, '')
276
+ };
277
+
278
+ ModuleCollection.prototype.update = function update$1 (rawRootModule) {
279
+ update(this.root, rawRootModule)
280
+ };
281
+
282
+ ModuleCollection.prototype.register = function register (path, rawModule, runtime) {
283
+ var this$1 = this;
284
+ if ( runtime === void 0 ) runtime = true;
285
+
286
+ var parent = this.get(path.slice(0, -1))
287
+ var newModule = new Module(rawModule, runtime)
288
+ parent.addChild(path[path.length - 1], newModule)
289
+
290
+ // register nested modules
291
+ if (rawModule.modules) {
292
+ forEachValue(rawModule.modules, function (rawChildModule, key) {
293
+ this$1.register(path.concat(key), rawChildModule, runtime)
294
+ })
295
+ }
296
+ };
297
+
298
+ ModuleCollection.prototype.unregister = function unregister (path) {
299
+ var parent = this.get(path.slice(0, -1))
300
+ var key = path[path.length - 1]
301
+ if (!parent.getChild(key).runtime) { return }
302
+
303
+ parent.removeChild(key)
304
+ };
305
+
306
+ function update (targetModule, newModule) {
307
+ // update target module
308
+ targetModule.update(newModule)
309
+
310
+ // update nested modules
311
+ if (newModule.modules) {
312
+ for (var key in newModule.modules) {
313
+ if (!targetModule.getChild(key)) {
314
+ console.warn(
315
+ "[vuex] trying to add a new module '" + key + "' on hot reloading, " +
316
+ 'manual reload is needed'
317
+ )
318
+ return
319
+ }
320
+ update(targetModule.getChild(key), newModule.modules[key])
321
+ }
322
+ }
323
+ }
324
+
325
+ var Vue // bind on install
326
+
327
+ var Store = function Store (options) {
328
+ var this$1 = this;
329
+ if ( options === void 0 ) options = {};
330
+
331
+ assert(Vue, "must call Vue.use(Vuex) before creating a store instance.")
332
+ assert(typeof Promise !== 'undefined', "vuex requires a Promise polyfill in this browser.")
333
+
334
+ var state = options.state; if ( state === void 0 ) state = {};
335
+ var plugins = options.plugins; if ( plugins === void 0 ) plugins = [];
336
+ var strict = options.strict; if ( strict === void 0 ) strict = false;
337
+
338
+ // store internal state
339
+ this._committing = false
340
+ this._actions = Object.create(null)
341
+ this._mutations = Object.create(null)
342
+ this._wrappedGetters = Object.create(null)
343
+ this._modules = new ModuleCollection(options)
344
+ this._modulesNamespaceMap = Object.create(null)
345
+ this._subscribers = []
346
+ this._watcherVM = new Vue()
347
+
348
+ // bind commit and dispatch to self
349
+ var store = this
350
+ var ref = this;
351
+ var dispatch = ref.dispatch;
352
+ var commit = ref.commit;
353
+ this.dispatch = function boundDispatch (type, payload) {
354
+ return dispatch.call(store, type, payload)
355
+ }
356
+ this.commit = function boundCommit (type, payload, options) {
357
+ return commit.call(store, type, payload, options)
358
+ }
359
+
360
+ // strict mode
361
+ this.strict = strict
362
+
363
+ // init root module.
364
+ // this also recursively registers all sub-modules
365
+ // and collects all module getters inside this._wrappedGetters
366
+ installModule(this, state, [], this._modules.root)
367
+
368
+ // initialize the store vm, which is responsible for the reactivity
369
+ // (also registers _wrappedGetters as computed properties)
370
+ resetStoreVM(this, state)
371
+
372
+ // apply plugins
373
+ plugins.concat(devtoolPlugin).forEach(function (plugin) { return plugin(this$1); })
374
+ };
375
+
376
+ var prototypeAccessors = { state: {} };
377
+
378
+ prototypeAccessors.state.get = function () {
379
+ return this._vm.$data.state
380
+ };
381
+
382
+ prototypeAccessors.state.set = function (v) {
383
+ assert(false, "Use store.replaceState() to explicit replace store state.")
384
+ };
385
+
386
+ Store.prototype.commit = function commit (_type, _payload, _options) {
387
+ var this$1 = this;
388
+
389
+ // check object-style commit
390
+ var ref = unifyObjectStyle(_type, _payload, _options);
391
+ var type = ref.type;
392
+ var payload = ref.payload;
393
+ var options = ref.options;
394
+
395
+ var mutation = { type: type, payload: payload }
396
+ var entry = this._mutations[type]
397
+ if (!entry) {
398
+ console.error(("[vuex] unknown mutation type: " + type))
399
+ return
400
+ }
401
+ this._withCommit(function () {
402
+ entry.forEach(function commitIterator (handler) {
403
+ handler(payload)
404
+ })
405
+ })
406
+ this._subscribers.forEach(function (sub) { return sub(mutation, this$1.state); })
407
+
408
+ if (options && options.silent) {
409
+ console.warn(
410
+ "[vuex] mutation type: " + type + ". Silent option has been removed. " +
411
+ 'Use the filter functionality in the vue-devtools'
412
+ )
413
+ }
414
+ };
415
+
416
+ Store.prototype.dispatch = function dispatch (_type, _payload) {
417
+ // check object-style dispatch
418
+ var ref = unifyObjectStyle(_type, _payload);
419
+ var type = ref.type;
420
+ var payload = ref.payload;
421
+
422
+ var entry = this._actions[type]
423
+ if (!entry) {
424
+ console.error(("[vuex] unknown action type: " + type))
425
+ return
426
+ }
427
+ return entry.length > 1
428
+ ? Promise.all(entry.map(function (handler) { return handler(payload); }))
429
+ : entry[0](payload)
430
+ };
431
+
432
+ Store.prototype.subscribe = function subscribe (fn) {
433
+ var subs = this._subscribers
434
+ if (subs.indexOf(fn) < 0) {
435
+ subs.push(fn)
436
+ }
437
+ return function () {
438
+ var i = subs.indexOf(fn)
439
+ if (i > -1) {
440
+ subs.splice(i, 1)
441
+ }
442
+ }
443
+ };
444
+
445
+ Store.prototype.watch = function watch (getter, cb, options) {
446
+ var this$1 = this;
447
+
448
+ assert(typeof getter === 'function', "store.watch only accepts a function.")
449
+ return this._watcherVM.$watch(function () { return getter(this$1.state, this$1.getters); }, cb, options)
450
+ };
451
+
452
+ Store.prototype.replaceState = function replaceState (state) {
453
+ var this$1 = this;
454
+
455
+ this._withCommit(function () {
456
+ this$1._vm.state = state
457
+ })
458
+ };
459
+
460
+ Store.prototype.registerModule = function registerModule (path, rawModule) {
461
+ if (typeof path === 'string') { path = [path] }
462
+ assert(Array.isArray(path), "module path must be a string or an Array.")
463
+ this._modules.register(path, rawModule)
464
+ installModule(this, this.state, path, this._modules.get(path))
465
+ // reset store to update getters...
466
+ resetStoreVM(this, this.state)
467
+ };
468
+
469
+ Store.prototype.unregisterModule = function unregisterModule (path) {
470
+ var this$1 = this;
471
+
472
+ if (typeof path === 'string') { path = [path] }
473
+ assert(Array.isArray(path), "module path must be a string or an Array.")
474
+ this._modules.unregister(path)
475
+ this._withCommit(function () {
476
+ var parentState = getNestedState(this$1.state, path.slice(0, -1))
477
+ Vue.delete(parentState, path[path.length - 1])
478
+ })
479
+ resetStore(this)
480
+ };
481
+
482
+ Store.prototype.hotUpdate = function hotUpdate (newOptions) {
483
+ this._modules.update(newOptions)
484
+ resetStore(this)
485
+ };
486
+
487
+ Store.prototype._withCommit = function _withCommit (fn) {
488
+ var committing = this._committing
489
+ this._committing = true
490
+ fn()
491
+ this._committing = committing
492
+ };
493
+
494
+ Object.defineProperties( Store.prototype, prototypeAccessors );
495
+
496
+ function resetStore (store) {
497
+ store._actions = Object.create(null)
498
+ store._mutations = Object.create(null)
499
+ store._wrappedGetters = Object.create(null)
500
+ store._modulesNamespaceMap = Object.create(null)
501
+ var state = store.state
502
+ // init all modules
503
+ installModule(store, state, [], store._modules.root, true)
504
+ // reset vm
505
+ resetStoreVM(store, state)
506
+ }
507
+
508
+ function resetStoreVM (store, state) {
509
+ var oldVm = store._vm
510
+
511
+ // bind store public getters
512
+ store.getters = {}
513
+ var wrappedGetters = store._wrappedGetters
514
+ var computed = {}
515
+ forEachValue(wrappedGetters, function (fn, key) {
516
+ // use computed to leverage its lazy-caching mechanism
517
+ computed[key] = function () { return fn(store); }
518
+ Object.defineProperty(store.getters, key, {
519
+ get: function () { return store._vm[key]; },
520
+ enumerable: true // for local getters
521
+ })
522
+ })
523
+
524
+ // use a Vue instance to store the state tree
525
+ // suppress warnings just in case the user has added
526
+ // some funky global mixins
527
+ var silent = Vue.config.silent
528
+ Vue.config.silent = true
529
+ store._vm = new Vue({
530
+ data: { state: state },
531
+ computed: computed
532
+ })
533
+ Vue.config.silent = silent
534
+
535
+ // enable strict mode for new vm
536
+ if (store.strict) {
537
+ enableStrictMode(store)
538
+ }
539
+
540
+ if (oldVm) {
541
+ // dispatch changes in all subscribed watchers
542
+ // to force getter re-evaluation.
543
+ store._withCommit(function () {
544
+ oldVm.state = null
545
+ })
546
+ Vue.nextTick(function () { return oldVm.$destroy(); })
547
+ }
548
+ }
549
+
550
+ function installModule (store, rootState, path, module, hot) {
551
+ var isRoot = !path.length
552
+ var namespace = store._modules.getNamespace(path)
553
+
554
+ // register in namespace map
555
+ if (namespace) {
556
+ store._modulesNamespaceMap[namespace] = module
557
+ }
558
+
559
+ // set state
560
+ if (!isRoot && !hot) {
561
+ var parentState = getNestedState(rootState, path.slice(0, -1))
562
+ var moduleName = path[path.length - 1]
563
+ store._withCommit(function () {
564
+ Vue.set(parentState, moduleName, module.state)
565
+ })
566
+ }
567
+
568
+ var local = module.context = makeLocalContext(store, namespace)
569
+
570
+ module.forEachMutation(function (mutation, key) {
571
+ var namespacedType = namespace + key
572
+ registerMutation(store, namespacedType, mutation, path)
573
+ })
574
+
575
+ module.forEachAction(function (action, key) {
576
+ var namespacedType = namespace + key
577
+ registerAction(store, namespacedType, action, local, path)
578
+ })
579
+
580
+ module.forEachGetter(function (getter, key) {
581
+ var namespacedType = namespace + key
582
+ registerGetter(store, namespacedType, getter, local, path)
583
+ })
584
+
585
+ module.forEachChild(function (child, key) {
586
+ installModule(store, rootState, path.concat(key), child, hot)
587
+ })
588
+ }
589
+
590
+ /**
591
+ * make localized dispatch, commit and getters
592
+ * if there is no namespace, just use root ones
593
+ */
594
+ function makeLocalContext (store, namespace) {
595
+ var noNamespace = namespace === ''
596
+
597
+ var local = {
598
+ dispatch: noNamespace ? store.dispatch : function (_type, _payload, _options) {
599
+ var args = unifyObjectStyle(_type, _payload, _options)
600
+ var payload = args.payload;
601
+ var options = args.options;
602
+ var type = args.type;
603
+
604
+ if (!options || !options.root) {
605
+ type = namespace + type
606
+ if (!store._actions[type]) {
607
+ console.error(("[vuex] unknown local action type: " + (args.type) + ", global type: " + type))
608
+ return
609
+ }
610
+ }
611
+
612
+ return store.dispatch(type, payload)
613
+ },
614
+
615
+ commit: noNamespace ? store.commit : function (_type, _payload, _options) {
616
+ var args = unifyObjectStyle(_type, _payload, _options)
617
+ var payload = args.payload;
618
+ var options = args.options;
619
+ var type = args.type;
620
+
621
+ if (!options || !options.root) {
622
+ type = namespace + type
623
+ if (!store._mutations[type]) {
624
+ console.error(("[vuex] unknown local mutation type: " + (args.type) + ", global type: " + type))
625
+ return
626
+ }
627
+ }
628
+
629
+ store.commit(type, payload, options)
630
+ }
631
+ }
632
+
633
+ // getters object must be gotten lazily
634
+ // because store.getters will be changed by vm update
635
+ Object.defineProperty(local, 'getters', {
636
+ get: noNamespace ? function () { return store.getters; } : function () { return makeLocalGetters(store, namespace); }
637
+ })
638
+
639
+ return local
640
+ }
641
+
642
+ function makeLocalGetters (store, namespace) {
643
+ var gettersProxy = {}
644
+
645
+ var splitPos = namespace.length
646
+ Object.keys(store.getters).forEach(function (type) {
647
+ // skip if the target getter is not match this namespace
648
+ if (type.slice(0, splitPos) !== namespace) { return }
649
+
650
+ // extract local getter type
651
+ var localType = type.slice(splitPos)
652
+
653
+ // Add a port to the getters proxy.
654
+ // Define as getter property because
655
+ // we do not want to evaluate the getters in this time.
656
+ Object.defineProperty(gettersProxy, localType, {
657
+ get: function () { return store.getters[type]; },
658
+ enumerable: true
659
+ })
660
+ })
661
+
662
+ return gettersProxy
663
+ }
664
+
665
+ function registerMutation (store, type, handler, path) {
666
+ var entry = store._mutations[type] || (store._mutations[type] = [])
667
+ entry.push(function wrappedMutationHandler (payload) {
668
+ handler(getNestedState(store.state, path), payload)
669
+ })
670
+ }
671
+
672
+ function registerAction (store, type, handler, local, path) {
673
+ var entry = store._actions[type] || (store._actions[type] = [])
674
+ entry.push(function wrappedActionHandler (payload, cb) {
675
+ var res = handler({
676
+ dispatch: local.dispatch,
677
+ commit: local.commit,
678
+ getters: local.getters,
679
+ state: getNestedState(store.state, path),
680
+ rootGetters: store.getters,
681
+ rootState: store.state
682
+ }, payload, cb)
683
+ if (!isPromise(res)) {
684
+ res = Promise.resolve(res)
685
+ }
686
+ if (store._devtoolHook) {
687
+ return res.catch(function (err) {
688
+ store._devtoolHook.emit('vuex:error', err)
689
+ throw err
690
+ })
691
+ } else {
692
+ return res
693
+ }
694
+ })
695
+ }
696
+
697
+ function registerGetter (store, type, rawGetter, local, path) {
698
+ if (store._wrappedGetters[type]) {
699
+ console.error(("[vuex] duplicate getter key: " + type))
700
+ return
701
+ }
702
+ store._wrappedGetters[type] = function wrappedGetter (store) {
703
+ return rawGetter(
704
+ getNestedState(store.state, path), // local state
705
+ local.getters, // local getters
706
+ store.state, // root state
707
+ store.getters // root getters
708
+ )
709
+ }
710
+ }
711
+
712
+ function enableStrictMode (store) {
713
+ store._vm.$watch('state', function () {
714
+ assert(store._committing, "Do not mutate vuex store state outside mutation handlers.")
715
+ }, { deep: true, sync: true })
716
+ }
717
+
718
+ function getNestedState (state, path) {
719
+ return path.length
720
+ ? path.reduce(function (state, key) { return state[key]; }, state)
721
+ : state
722
+ }
723
+
724
+ function unifyObjectStyle (type, payload, options) {
725
+ if (isObject(type) && type.type) {
726
+ options = payload
727
+ payload = type
728
+ type = type.type
729
+ }
730
+ return { type: type, payload: payload, options: options }
731
+ }
732
+
733
+ function install (_Vue) {
734
+ if (Vue) {
735
+ console.error(
736
+ '[vuex] already installed. Vue.use(Vuex) should be called only once.'
737
+ )
738
+ return
739
+ }
740
+ Vue = _Vue
741
+ applyMixin(Vue)
742
+ }
743
+
744
+ // auto install in dist mode
745
+ if (typeof window !== 'undefined' && window.Vue) {
746
+ install(window.Vue)
747
+ }
748
+
749
+ var index = {
750
+ Store: Store,
751
+ install: install,
752
+ version: '2.1.1',
753
+ mapState: mapState,
754
+ mapMutations: mapMutations,
755
+ mapGetters: mapGetters,
756
+ mapActions: mapActions
757
+ }
758
+
759
+ return index;
760
+
761
+ })));