vueonrails 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE.md +21 -0
- data/README.md +7 -7
- data/lib/generators/generator_templates/forms/index.vue.erb +45 -0
- data/lib/generators/generator_templates/packs/index.js +13 -13
- data/lib/generators/generator_templates/packs/index.vue +3 -3
- data/lib/generators/generator_templates/packs/pack.js.erb +3 -3
- data/lib/generators/generator_templates/sfc/single-file-component.vue +3 -3
- data/lib/generators/generator_templates/tests/unit.test.js.erb +2 -2
- data/lib/generators/generator_templates/turbolinks/turbolinks-pack.js.erb +3 -3
- data/lib/generators/options/child.rb +6 -0
- data/lib/generators/options/click.rb +0 -1
- data/lib/generators/options/form.rb +1 -19
- data/lib/generators/options/list.rb +0 -1
- data/lib/generators/options/modal.rb +0 -1
- data/lib/generators/options/parent.rb +3 -0
- data/lib/generators/options/seperate.rb +0 -1
- data/lib/generators/options/single.rb +0 -1
- data/lib/generators/options/table.rb +0 -1
- data/lib/generators/options/test.rb +1 -2
- data/lib/generators/options/turbolinks-seperate.rb +0 -1
- data/lib/generators/options/turbolinks-single.rb +0 -1
- data/lib/generators/options/vuex.rb +0 -1
- data/lib/generators/vue/vue_generator.rb +76 -18
- data/lib/install/setup.rb +4 -5
- data/lib/install/spv.rb +0 -1
- data/lib/install/test.rb +0 -3
- data/lib/install/ui.rb +0 -3
- data/lib/vueonrails/post_message.rb +1 -1
- data/lib/vueonrails/version.rb +1 -1
- metadata +10 -23
- data/vendor/assets/javascripts/axios.js +0 -1545
- data/vendor/assets/javascripts/axios.map +0 -1
- data/vendor/assets/javascripts/element-ui.js +0 -12
- data/vendor/assets/javascripts/vue-resource.js +0 -1531
- data/vendor/assets/javascripts/vue-router.js +0 -2709
- data/vendor/assets/javascripts/vue-router2.js +0 -2284
- data/vendor/assets/javascripts/vue-validator.js +0 -910
- data/vendor/assets/javascripts/vue-validator2.js +0 -2615
- data/vendor/assets/javascripts/vue-validator3.js +0 -2054
- data/vendor/assets/javascripts/vue.js +0 -10237
- data/vendor/assets/javascripts/vue.min.js +0 -9
- data/vendor/assets/javascripts/vue2.js +0 -8568
- data/vendor/assets/javascripts/vue2.min.js +0 -8
- data/vendor/assets/javascripts/vueonrails.js +0 -39
- data/vendor/assets/javascripts/vuex.js +0 -722
- data/vendor/assets/javascripts/vuex2.js +0 -805
- data/vendor/assets/stylesheets/element-ui.css +0 -1
@@ -1,722 +0,0 @@
|
|
1
|
-
/*!
|
2
|
-
* Vuex v1.0.1
|
3
|
-
* (c) 2017 Evan You
|
4
|
-
* Released under the MIT License.
|
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 _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
|
13
|
-
return typeof obj;
|
14
|
-
} : function (obj) {
|
15
|
-
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
16
|
-
};
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
var classCallCheck = function (instance, Constructor) {
|
29
|
-
if (!(instance instanceof Constructor)) {
|
30
|
-
throw new TypeError("Cannot call a class as a function");
|
31
|
-
}
|
32
|
-
};
|
33
|
-
|
34
|
-
var createClass = function () {
|
35
|
-
function defineProperties(target, props) {
|
36
|
-
for (var i = 0; i < props.length; i++) {
|
37
|
-
var descriptor = props[i];
|
38
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
39
|
-
descriptor.configurable = true;
|
40
|
-
if ("value" in descriptor) descriptor.writable = true;
|
41
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
42
|
-
}
|
43
|
-
}
|
44
|
-
|
45
|
-
return function (Constructor, protoProps, staticProps) {
|
46
|
-
if (protoProps) defineProperties(Constructor.prototype, protoProps);
|
47
|
-
if (staticProps) defineProperties(Constructor, staticProps);
|
48
|
-
return Constructor;
|
49
|
-
};
|
50
|
-
}();
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
var toConsumableArray = function (arr) {
|
93
|
-
if (Array.isArray(arr)) {
|
94
|
-
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
|
95
|
-
|
96
|
-
return arr2;
|
97
|
-
} else {
|
98
|
-
return Array.from(arr);
|
99
|
-
}
|
100
|
-
};
|
101
|
-
|
102
|
-
/**
|
103
|
-
* Merge an array of objects into one.
|
104
|
-
*
|
105
|
-
* @param {Array<Object>} arr
|
106
|
-
* @return {Object}
|
107
|
-
*/
|
108
|
-
|
109
|
-
function mergeObjects(arr) {
|
110
|
-
return arr.reduce(function (prev, obj) {
|
111
|
-
Object.keys(obj).forEach(function (key) {
|
112
|
-
var existing = prev[key];
|
113
|
-
if (existing) {
|
114
|
-
// allow multiple mutation objects to contain duplicate
|
115
|
-
// handlers for the same mutation type
|
116
|
-
if (Array.isArray(existing)) {
|
117
|
-
prev[key] = existing.concat(obj[key]);
|
118
|
-
} else {
|
119
|
-
prev[key] = [existing].concat(obj[key]);
|
120
|
-
}
|
121
|
-
} else {
|
122
|
-
prev[key] = obj[key];
|
123
|
-
}
|
124
|
-
});
|
125
|
-
return prev;
|
126
|
-
}, {});
|
127
|
-
}
|
128
|
-
|
129
|
-
/**
|
130
|
-
* Deep copy the given object considering circular structure.
|
131
|
-
* This function caches all nested objects and its copies.
|
132
|
-
* If it detects circular structure, use cached copy to avoid infinite loop.
|
133
|
-
*
|
134
|
-
* @param {*} obj
|
135
|
-
* @param {Array<Object>} cache
|
136
|
-
* @return {*}
|
137
|
-
*/
|
138
|
-
|
139
|
-
|
140
|
-
/**
|
141
|
-
* Check whether the given value is Object or not
|
142
|
-
*
|
143
|
-
* @param {*} obj
|
144
|
-
* @return {Boolean}
|
145
|
-
*/
|
146
|
-
|
147
|
-
function isObject(obj) {
|
148
|
-
return obj !== null && (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object';
|
149
|
-
}
|
150
|
-
|
151
|
-
/**
|
152
|
-
* Get state sub tree by given keys.
|
153
|
-
*
|
154
|
-
* @param {Object} state
|
155
|
-
* @param {Array<String>} nestedKeys
|
156
|
-
* @return {Object}
|
157
|
-
*/
|
158
|
-
function getNestedState(state, nestedKeys) {
|
159
|
-
return nestedKeys.reduce(function (state, key) {
|
160
|
-
return state[key];
|
161
|
-
}, state);
|
162
|
-
}
|
163
|
-
|
164
|
-
/**
|
165
|
-
* Hacks to get access to Vue internals.
|
166
|
-
* Maybe we should expose these...
|
167
|
-
*/
|
168
|
-
|
169
|
-
var Watcher = void 0;
|
170
|
-
function getWatcher(vm) {
|
171
|
-
if (!Watcher) {
|
172
|
-
var noop = function noop() {};
|
173
|
-
var unwatch = vm.$watch(noop, noop);
|
174
|
-
Watcher = vm._watchers[0].constructor;
|
175
|
-
unwatch();
|
176
|
-
}
|
177
|
-
return Watcher;
|
178
|
-
}
|
179
|
-
|
180
|
-
var Dep = void 0;
|
181
|
-
function getDep(vm) {
|
182
|
-
if (!Dep) {
|
183
|
-
Dep = vm._data.__ob__.dep.constructor;
|
184
|
-
}
|
185
|
-
return Dep;
|
186
|
-
}
|
187
|
-
|
188
|
-
var hook = typeof window !== 'undefined' && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
|
189
|
-
|
190
|
-
function devtoolPlugin(store) {
|
191
|
-
if (!hook) return;
|
192
|
-
|
193
|
-
hook.emit('vuex:init', store);
|
194
|
-
|
195
|
-
hook.on('vuex:travel-to-state', function (targetState) {
|
196
|
-
store.replaceState(targetState);
|
197
|
-
});
|
198
|
-
|
199
|
-
store.subscribe(function (mutation, state) {
|
200
|
-
hook.emit('vuex:mutation', mutation, state);
|
201
|
-
});
|
202
|
-
}
|
203
|
-
|
204
|
-
var override = function (Vue) {
|
205
|
-
var version = Number(Vue.version.split('.')[0]);
|
206
|
-
|
207
|
-
if (version >= 2) {
|
208
|
-
var usesInit = Vue.config._lifecycleHooks.indexOf('init') > -1;
|
209
|
-
Vue.mixin(usesInit ? { init: vuexInit } : { beforeCreate: vuexInit });
|
210
|
-
} else {
|
211
|
-
(function () {
|
212
|
-
// override init and inject vuex init procedure
|
213
|
-
// for 1.x backwards compatibility.
|
214
|
-
var _init = Vue.prototype._init;
|
215
|
-
Vue.prototype._init = function () {
|
216
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
217
|
-
|
218
|
-
options.init = options.init ? [vuexInit].concat(options.init) : vuexInit;
|
219
|
-
_init.call(this, options);
|
220
|
-
};
|
221
|
-
})();
|
222
|
-
}
|
223
|
-
|
224
|
-
/**
|
225
|
-
* Vuex init hook, injected into each instances init hooks list.
|
226
|
-
*/
|
227
|
-
|
228
|
-
function vuexInit() {
|
229
|
-
var options = this.$options;
|
230
|
-
var store = options.store,
|
231
|
-
vuex = options.vuex;
|
232
|
-
// store injection
|
233
|
-
|
234
|
-
if (store) {
|
235
|
-
this.$store = store;
|
236
|
-
} else if (options.parent && options.parent.$store) {
|
237
|
-
this.$store = options.parent.$store;
|
238
|
-
}
|
239
|
-
// vuex option handling
|
240
|
-
if (vuex) {
|
241
|
-
if (!this.$store) {
|
242
|
-
console.warn('[vuex] store not injected. make sure to ' + 'provide the store option in your root component.');
|
243
|
-
}
|
244
|
-
var state = vuex.state,
|
245
|
-
actions = vuex.actions;
|
246
|
-
var getters = vuex.getters;
|
247
|
-
// handle deprecated state option
|
248
|
-
|
249
|
-
if (state && !getters) {
|
250
|
-
console.warn('[vuex] vuex.state option will been deprecated in 1.0. ' + 'Use vuex.getters instead.');
|
251
|
-
getters = state;
|
252
|
-
}
|
253
|
-
// getters
|
254
|
-
if (getters) {
|
255
|
-
options.computed = options.computed || {};
|
256
|
-
for (var key in getters) {
|
257
|
-
defineVuexGetter(this, key, getters[key]);
|
258
|
-
}
|
259
|
-
}
|
260
|
-
// actions
|
261
|
-
if (actions) {
|
262
|
-
options.methods = options.methods || {};
|
263
|
-
for (var _key in actions) {
|
264
|
-
options.methods[_key] = makeBoundAction(this.$store, actions[_key], _key);
|
265
|
-
}
|
266
|
-
}
|
267
|
-
}
|
268
|
-
}
|
269
|
-
|
270
|
-
/**
|
271
|
-
* Setter for all getter properties.
|
272
|
-
*/
|
273
|
-
|
274
|
-
function setter() {
|
275
|
-
throw new Error('vuex getter properties are read-only.');
|
276
|
-
}
|
277
|
-
|
278
|
-
/**
|
279
|
-
* Define a Vuex getter on an instance.
|
280
|
-
*
|
281
|
-
* @param {Vue} vm
|
282
|
-
* @param {String} key
|
283
|
-
* @param {Function} getter
|
284
|
-
*/
|
285
|
-
|
286
|
-
function defineVuexGetter(vm, key, getter) {
|
287
|
-
if (typeof getter !== 'function') {
|
288
|
-
console.warn('[vuex] Getter bound to key \'vuex.getters.' + key + '\' is not a function.');
|
289
|
-
} else {
|
290
|
-
Object.defineProperty(vm, key, {
|
291
|
-
enumerable: true,
|
292
|
-
configurable: true,
|
293
|
-
get: makeComputedGetter(vm.$store, getter),
|
294
|
-
set: setter
|
295
|
-
});
|
296
|
-
}
|
297
|
-
}
|
298
|
-
|
299
|
-
/**
|
300
|
-
* Make a computed getter, using the same caching mechanism of computed
|
301
|
-
* properties. In addition, it is cached on the raw getter function using
|
302
|
-
* the store's unique cache id. This makes the same getter shared
|
303
|
-
* across all components use the same underlying watcher, and makes
|
304
|
-
* the getter evaluated only once during every flush.
|
305
|
-
*
|
306
|
-
* @param {Store} store
|
307
|
-
* @param {Function} getter
|
308
|
-
*/
|
309
|
-
|
310
|
-
function makeComputedGetter(store, getter) {
|
311
|
-
var id = store._getterCacheId;
|
312
|
-
|
313
|
-
// cached
|
314
|
-
if (getter[id]) {
|
315
|
-
return getter[id];
|
316
|
-
}
|
317
|
-
var vm = store._vm;
|
318
|
-
var Watcher = getWatcher(vm);
|
319
|
-
var Dep = getDep(vm);
|
320
|
-
var watcher = new Watcher(vm, function (vm) {
|
321
|
-
return getter(vm.state);
|
322
|
-
}, null, { lazy: true });
|
323
|
-
var computedGetter = function computedGetter() {
|
324
|
-
if (watcher.dirty) {
|
325
|
-
watcher.evaluate();
|
326
|
-
}
|
327
|
-
if (Dep.target) {
|
328
|
-
watcher.depend();
|
329
|
-
}
|
330
|
-
return watcher.value;
|
331
|
-
};
|
332
|
-
getter[id] = computedGetter;
|
333
|
-
return computedGetter;
|
334
|
-
}
|
335
|
-
|
336
|
-
/**
|
337
|
-
* Make a bound-to-store version of a raw action function.
|
338
|
-
*
|
339
|
-
* @param {Store} store
|
340
|
-
* @param {Function} action
|
341
|
-
* @param {String} key
|
342
|
-
*/
|
343
|
-
|
344
|
-
function makeBoundAction(store, action, key) {
|
345
|
-
if (typeof action !== 'function') {
|
346
|
-
console.warn('[vuex] Action bound to key \'vuex.actions.' + key + '\' is not a function.');
|
347
|
-
}
|
348
|
-
return function vuexBoundAction() {
|
349
|
-
for (var _len = arguments.length, args = Array(_len), _key2 = 0; _key2 < _len; _key2++) {
|
350
|
-
args[_key2] = arguments[_key2];
|
351
|
-
}
|
352
|
-
|
353
|
-
return action.call.apply(action, [this, store].concat(args));
|
354
|
-
};
|
355
|
-
}
|
356
|
-
|
357
|
-
// option merging
|
358
|
-
var merge = Vue.config.optionMergeStrategies.computed;
|
359
|
-
Vue.config.optionMergeStrategies.vuex = function (toVal, fromVal) {
|
360
|
-
if (!toVal) return fromVal;
|
361
|
-
if (!fromVal) return toVal;
|
362
|
-
return {
|
363
|
-
getters: merge(toVal.getters, fromVal.getters),
|
364
|
-
state: merge(toVal.state, fromVal.state),
|
365
|
-
actions: merge(toVal.actions, fromVal.actions)
|
366
|
-
};
|
367
|
-
};
|
368
|
-
};
|
369
|
-
|
370
|
-
var Vue = void 0;
|
371
|
-
var uid = 0;
|
372
|
-
|
373
|
-
var Store = function () {
|
374
|
-
|
375
|
-
/**
|
376
|
-
* @param {Object} options
|
377
|
-
* - {Object} state
|
378
|
-
* - {Object} actions
|
379
|
-
* - {Object} mutations
|
380
|
-
* - {Array} plugins
|
381
|
-
* - {Boolean} strict
|
382
|
-
*/
|
383
|
-
|
384
|
-
function Store() {
|
385
|
-
var _this = this;
|
386
|
-
|
387
|
-
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
388
|
-
_ref$state = _ref.state,
|
389
|
-
state = _ref$state === undefined ? {} : _ref$state,
|
390
|
-
_ref$mutations = _ref.mutations,
|
391
|
-
mutations = _ref$mutations === undefined ? {} : _ref$mutations,
|
392
|
-
_ref$modules = _ref.modules,
|
393
|
-
modules = _ref$modules === undefined ? {} : _ref$modules,
|
394
|
-
_ref$plugins = _ref.plugins,
|
395
|
-
plugins = _ref$plugins === undefined ? [] : _ref$plugins,
|
396
|
-
_ref$strict = _ref.strict,
|
397
|
-
strict = _ref$strict === undefined ? false : _ref$strict;
|
398
|
-
|
399
|
-
classCallCheck(this, Store);
|
400
|
-
|
401
|
-
this._getterCacheId = 'vuex_store_' + uid++;
|
402
|
-
this._dispatching = false;
|
403
|
-
this._rootMutations = this._mutations = mutations;
|
404
|
-
this._modules = modules;
|
405
|
-
this._subscribers = [];
|
406
|
-
// bind dispatch to self
|
407
|
-
var dispatch = this.dispatch;
|
408
|
-
this.dispatch = function () {
|
409
|
-
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
410
|
-
args[_key] = arguments[_key];
|
411
|
-
}
|
412
|
-
|
413
|
-
dispatch.apply(_this, args);
|
414
|
-
};
|
415
|
-
// use a Vue instance to store the state tree
|
416
|
-
// suppress warnings just in case the user has added
|
417
|
-
// some funky global mixins
|
418
|
-
if (!Vue) {
|
419
|
-
throw new Error('[vuex] must call Vue.use(Vuex) before creating a store instance.');
|
420
|
-
}
|
421
|
-
var silent = Vue.config.silent;
|
422
|
-
Vue.config.silent = true;
|
423
|
-
this._vm = new Vue({
|
424
|
-
data: {
|
425
|
-
state: state
|
426
|
-
}
|
427
|
-
});
|
428
|
-
Vue.config.silent = silent;
|
429
|
-
this._setupModuleState(state, modules);
|
430
|
-
this._setupModuleMutations(modules);
|
431
|
-
// add extra warnings in strict mode
|
432
|
-
if (strict) {
|
433
|
-
this._setupMutationCheck();
|
434
|
-
}
|
435
|
-
// apply plugins
|
436
|
-
devtoolPlugin(this);
|
437
|
-
plugins.forEach(function (plugin) {
|
438
|
-
return plugin(_this);
|
439
|
-
});
|
440
|
-
}
|
441
|
-
|
442
|
-
/**
|
443
|
-
* Getter for the entire state tree.
|
444
|
-
* Read only.
|
445
|
-
*
|
446
|
-
* @return {Object}
|
447
|
-
*/
|
448
|
-
|
449
|
-
createClass(Store, [{
|
450
|
-
key: 'replaceState',
|
451
|
-
|
452
|
-
|
453
|
-
/**
|
454
|
-
* Replace root state.
|
455
|
-
*
|
456
|
-
* @param {Object} state
|
457
|
-
*/
|
458
|
-
|
459
|
-
value: function replaceState(state) {
|
460
|
-
this._dispatching = true;
|
461
|
-
this._vm.state = state;
|
462
|
-
this._dispatching = false;
|
463
|
-
}
|
464
|
-
|
465
|
-
/**
|
466
|
-
* Dispatch an action.
|
467
|
-
*
|
468
|
-
* @param {String} type
|
469
|
-
*/
|
470
|
-
|
471
|
-
}, {
|
472
|
-
key: 'dispatch',
|
473
|
-
value: function dispatch(type) {
|
474
|
-
var _this2 = this;
|
475
|
-
|
476
|
-
for (var _len2 = arguments.length, payload = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
477
|
-
payload[_key2 - 1] = arguments[_key2];
|
478
|
-
}
|
479
|
-
|
480
|
-
var silent = false;
|
481
|
-
var isObjectStyleDispatch = false;
|
482
|
-
// compatibility for object actions, e.g. FSA
|
483
|
-
if ((typeof type === 'undefined' ? 'undefined' : _typeof(type)) === 'object' && type.type && arguments.length === 1) {
|
484
|
-
isObjectStyleDispatch = true;
|
485
|
-
payload = type;
|
486
|
-
if (type.silent) silent = true;
|
487
|
-
type = type.type;
|
488
|
-
}
|
489
|
-
var handler = this._mutations[type];
|
490
|
-
var state = this.state;
|
491
|
-
if (handler) {
|
492
|
-
this._dispatching = true;
|
493
|
-
// apply the mutation
|
494
|
-
if (Array.isArray(handler)) {
|
495
|
-
handler.forEach(function (h) {
|
496
|
-
isObjectStyleDispatch ? h(state, payload) : h.apply(undefined, [state].concat(toConsumableArray(payload)));
|
497
|
-
});
|
498
|
-
} else {
|
499
|
-
isObjectStyleDispatch ? handler(state, payload) : handler.apply(undefined, [state].concat(toConsumableArray(payload)));
|
500
|
-
}
|
501
|
-
this._dispatching = false;
|
502
|
-
if (!silent) {
|
503
|
-
(function () {
|
504
|
-
var mutation = isObjectStyleDispatch ? payload : { type: type, payload: payload };
|
505
|
-
_this2._subscribers.forEach(function (sub) {
|
506
|
-
return sub(mutation, state);
|
507
|
-
});
|
508
|
-
})();
|
509
|
-
}
|
510
|
-
} else {
|
511
|
-
console.warn('[vuex] Unknown mutation: ' + type);
|
512
|
-
}
|
513
|
-
}
|
514
|
-
|
515
|
-
/**
|
516
|
-
* Watch state changes on the store.
|
517
|
-
* Same API as Vue's $watch, except when watching a function,
|
518
|
-
* the function gets the state as the first argument.
|
519
|
-
*
|
520
|
-
* @param {Function} fn
|
521
|
-
* @param {Function} cb
|
522
|
-
* @param {Object} [options]
|
523
|
-
*/
|
524
|
-
|
525
|
-
}, {
|
526
|
-
key: 'watch',
|
527
|
-
value: function watch(fn, cb, options) {
|
528
|
-
var _this3 = this;
|
529
|
-
|
530
|
-
if (typeof fn !== 'function') {
|
531
|
-
console.error('Vuex store.watch only accepts function.');
|
532
|
-
return;
|
533
|
-
}
|
534
|
-
return this._vm.$watch(function () {
|
535
|
-
return fn(_this3.state);
|
536
|
-
}, cb, options);
|
537
|
-
}
|
538
|
-
|
539
|
-
/**
|
540
|
-
* Subscribe to state changes. Fires after every mutation.
|
541
|
-
*/
|
542
|
-
|
543
|
-
}, {
|
544
|
-
key: 'subscribe',
|
545
|
-
value: function subscribe(fn) {
|
546
|
-
var subs = this._subscribers;
|
547
|
-
if (subs.indexOf(fn) < 0) {
|
548
|
-
subs.push(fn);
|
549
|
-
}
|
550
|
-
return function () {
|
551
|
-
var i = subs.indexOf(fn);
|
552
|
-
if (i > -1) {
|
553
|
-
subs.splice(i, 1);
|
554
|
-
}
|
555
|
-
};
|
556
|
-
}
|
557
|
-
|
558
|
-
/**
|
559
|
-
* Hot update mutations & modules.
|
560
|
-
*
|
561
|
-
* @param {Object} options
|
562
|
-
* - {Object} [mutations]
|
563
|
-
* - {Object} [modules]
|
564
|
-
*/
|
565
|
-
|
566
|
-
}, {
|
567
|
-
key: 'hotUpdate',
|
568
|
-
value: function hotUpdate() {
|
569
|
-
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
570
|
-
mutations = _ref2.mutations,
|
571
|
-
modules = _ref2.modules;
|
572
|
-
|
573
|
-
this._rootMutations = this._mutations = mutations || this._rootMutations;
|
574
|
-
this._setupModuleMutations(modules || this._modules);
|
575
|
-
}
|
576
|
-
|
577
|
-
/**
|
578
|
-
* Attach sub state tree of each module to the root tree.
|
579
|
-
*
|
580
|
-
* @param {Object} state
|
581
|
-
* @param {Object} modules
|
582
|
-
*/
|
583
|
-
|
584
|
-
}, {
|
585
|
-
key: '_setupModuleState',
|
586
|
-
value: function _setupModuleState(state, modules) {
|
587
|
-
var _this4 = this;
|
588
|
-
|
589
|
-
if (!isObject(modules)) return;
|
590
|
-
|
591
|
-
Object.keys(modules).forEach(function (key) {
|
592
|
-
var module = modules[key];
|
593
|
-
|
594
|
-
// set this module's state
|
595
|
-
Vue.set(state, key, module.state || {});
|
596
|
-
|
597
|
-
// retrieve nested modules
|
598
|
-
_this4._setupModuleState(state[key], module.modules);
|
599
|
-
});
|
600
|
-
}
|
601
|
-
|
602
|
-
/**
|
603
|
-
* Bind mutations for each module to its sub tree and
|
604
|
-
* merge them all into one final mutations map.
|
605
|
-
*
|
606
|
-
* @param {Object} updatedModules
|
607
|
-
*/
|
608
|
-
|
609
|
-
}, {
|
610
|
-
key: '_setupModuleMutations',
|
611
|
-
value: function _setupModuleMutations(updatedModules) {
|
612
|
-
var modules = this._modules;
|
613
|
-
Object.keys(updatedModules).forEach(function (key) {
|
614
|
-
modules[key] = updatedModules[key];
|
615
|
-
});
|
616
|
-
var updatedMutations = this._createModuleMutations(modules, []);
|
617
|
-
this._mutations = mergeObjects([this._rootMutations].concat(toConsumableArray(updatedMutations)));
|
618
|
-
}
|
619
|
-
|
620
|
-
/**
|
621
|
-
* Helper method for _setupModuleMutations.
|
622
|
-
* The method retrieve nested sub modules and
|
623
|
-
* bind each mutations to its sub tree recursively.
|
624
|
-
*
|
625
|
-
* @param {Object} modules
|
626
|
-
* @param {Array<String>} nestedKeys
|
627
|
-
* @return {Array<Object>}
|
628
|
-
*/
|
629
|
-
|
630
|
-
}, {
|
631
|
-
key: '_createModuleMutations',
|
632
|
-
value: function _createModuleMutations(modules, nestedKeys) {
|
633
|
-
var _this5 = this;
|
634
|
-
|
635
|
-
if (!isObject(modules)) return [];
|
636
|
-
|
637
|
-
return Object.keys(modules).map(function (key) {
|
638
|
-
var module = modules[key];
|
639
|
-
var newNestedKeys = nestedKeys.concat(key);
|
640
|
-
|
641
|
-
// retrieve nested modules
|
642
|
-
var nestedMutations = _this5._createModuleMutations(module.modules, newNestedKeys);
|
643
|
-
|
644
|
-
if (!module || !module.mutations) {
|
645
|
-
return mergeObjects(nestedMutations);
|
646
|
-
}
|
647
|
-
|
648
|
-
// bind mutations to sub state tree
|
649
|
-
var mutations = {};
|
650
|
-
Object.keys(module.mutations).forEach(function (name) {
|
651
|
-
var original = module.mutations[name];
|
652
|
-
mutations[name] = function (state) {
|
653
|
-
for (var _len3 = arguments.length, args = Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
|
654
|
-
args[_key3 - 1] = arguments[_key3];
|
655
|
-
}
|
656
|
-
|
657
|
-
original.apply(undefined, [getNestedState(state, newNestedKeys)].concat(args));
|
658
|
-
};
|
659
|
-
});
|
660
|
-
|
661
|
-
// merge mutations of this module and nested modules
|
662
|
-
return mergeObjects([mutations].concat(toConsumableArray(nestedMutations)));
|
663
|
-
});
|
664
|
-
}
|
665
|
-
|
666
|
-
/**
|
667
|
-
* Setup mutation check: if the Vuex instance's state is mutated
|
668
|
-
* outside of a mutation handler, we throw en error. This effectively
|
669
|
-
* enforces all mutations to the state to be trackable and hot-reloadable.
|
670
|
-
* However, this comes at a run time cost since we are doing a deep
|
671
|
-
* watch on the entire state tree, so it is only enabled if the
|
672
|
-
* strict option is set to true.
|
673
|
-
*/
|
674
|
-
|
675
|
-
}, {
|
676
|
-
key: '_setupMutationCheck',
|
677
|
-
value: function _setupMutationCheck() {
|
678
|
-
var _this6 = this;
|
679
|
-
|
680
|
-
var Watcher = getWatcher(this._vm);
|
681
|
-
/* eslint-disable no-new */
|
682
|
-
new Watcher(this._vm, 'state', function () {
|
683
|
-
if (!_this6._dispatching) {
|
684
|
-
throw new Error('[vuex] Do not mutate vuex store state outside mutation handlers.');
|
685
|
-
}
|
686
|
-
}, { deep: true, sync: true });
|
687
|
-
/* eslint-enable no-new */
|
688
|
-
}
|
689
|
-
}, {
|
690
|
-
key: 'state',
|
691
|
-
get: function get$$1() {
|
692
|
-
return this._vm.state;
|
693
|
-
},
|
694
|
-
set: function set$$1(v) {
|
695
|
-
throw new Error('[vuex] Use store.replaceState() to explicit replace store state.');
|
696
|
-
}
|
697
|
-
}]);
|
698
|
-
return Store;
|
699
|
-
}();
|
700
|
-
|
701
|
-
function install(_Vue) {
|
702
|
-
if (Vue) {
|
703
|
-
console.warn('[vuex] already installed. Vue.use(Vuex) should be called only once.');
|
704
|
-
return;
|
705
|
-
}
|
706
|
-
Vue = _Vue;
|
707
|
-
override(Vue);
|
708
|
-
}
|
709
|
-
|
710
|
-
// auto install in dist mode
|
711
|
-
if (typeof window !== 'undefined' && window.Vue) {
|
712
|
-
install(window.Vue);
|
713
|
-
}
|
714
|
-
|
715
|
-
var index = {
|
716
|
-
Store: Store,
|
717
|
-
install: install
|
718
|
-
};
|
719
|
-
|
720
|
-
return index;
|
721
|
-
|
722
|
-
})));
|