@liqueflies/vuex-async-module
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -5,4 +5,2 @@ 'use strict'; | ||
var _vuex = require('vuex'); | ||
var _lodash = require('lodash.camelcase'); | ||
@@ -20,10 +18,18 @@ | ||
beforeCreate: function beforeCreate() { | ||
var _mapState, _mapActions; | ||
var _Object$assign, _Object$assign2; | ||
var name = this.$options.name; | ||
this.$options.computed = Object.assign({}, this.$options.computed, (0, _vuex.mapState)(name, (_mapState = {}, _mapState[name] = 'data', _mapState[name + 'RequestIsPending'] = 'isPending', _mapState))); | ||
this.$options.methods = Object.assign({}, this.$options.methods, (0, _vuex.mapActions)(name, (_mapActions = {}, _mapActions['getAsync' + (0, _lodash4.default)((0, _lodash2.default)(name))] = 'getAsync', _mapActions))); | ||
this.$options.computed = Object.assign({}, this.$options.computed, (_Object$assign = {}, _Object$assign[name] = function () { | ||
return this.$store.state[name].data; | ||
}, _Object$assign[name + 'RequestIsPending'] = function undefined() { | ||
return this.$store.state[name].isPending; | ||
}, _Object$assign)); | ||
this.$options.methods = Object.assign({}, this.$options.methods, (_Object$assign2 = {}, _Object$assign2['getAsync' + (0, _lodash4.default)((0, _lodash2.default)(name))] = function undefined() { | ||
var _$store; | ||
(_$store = this.$store).dispatch.apply(_$store, [name + '/getAsync'].concat(Array.prototype.slice.call(arguments))); | ||
}, _Object$assign2)); | ||
} | ||
}; | ||
module.exports = exports['default']; |
@@ -1,2 +0,1 @@ | ||
import { mapState, mapActions } from 'vuex'; | ||
import camelCase from 'lodash.camelcase'; | ||
@@ -7,9 +6,17 @@ import upperFirst from 'lodash.upperfirst'; | ||
beforeCreate: function beforeCreate() { | ||
var _mapState, _mapActions; | ||
var _Object$assign, _Object$assign2; | ||
var name = this.$options.name; | ||
this.$options.computed = Object.assign({}, this.$options.computed, mapState(name, (_mapState = {}, _mapState[name] = 'data', _mapState[name + 'RequestIsPending'] = 'isPending', _mapState))); | ||
this.$options.methods = Object.assign({}, this.$options.methods, mapActions(name, (_mapActions = {}, _mapActions['getAsync' + upperFirst(camelCase(name))] = 'getAsync', _mapActions))); | ||
this.$options.computed = Object.assign({}, this.$options.computed, (_Object$assign = {}, _Object$assign[name] = function () { | ||
return this.$store.state[name].data; | ||
}, _Object$assign[name + 'RequestIsPending'] = function undefined() { | ||
return this.$store.state[name].isPending; | ||
}, _Object$assign)); | ||
this.$options.methods = Object.assign({}, this.$options.methods, (_Object$assign2 = {}, _Object$assign2['getAsync' + upperFirst(camelCase(name))] = function undefined() { | ||
var _$store; | ||
(_$store = this.$store).dispatch.apply(_$store, [name + '/getAsync'].concat(Array.prototype.slice.call(arguments))); | ||
}, _Object$assign2)); | ||
} | ||
}; |
{ | ||
"name": "@liqueflies/vuex-async-module", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "vuex async module generator.", | ||
@@ -66,5 +66,3 @@ "main": "dist/index.js", | ||
"rollup-plugin-replace": "2.0.0", | ||
"rollup-plugin-uglify": "2.0.1", | ||
"vue": "2.5.6", | ||
"vuex": "3.0.1" | ||
"rollup-plugin-uglify": "2.0.1" | ||
}, | ||
@@ -74,6 +72,3 @@ "dependencies": { | ||
"lodash.upperfirst": "4.3.1" | ||
}, | ||
"peerDependencies": { | ||
"vuex": "^3.0.1" | ||
} | ||
} |
@@ -1,2 +0,1 @@ | ||
import { mapState, mapActions } from 'vuex' | ||
import camelCase from 'lodash.camelcase' | ||
@@ -11,6 +10,10 @@ import upperFirst from 'lodash.upperfirst' | ||
this.$options.computed, | ||
mapState(name, { | ||
[name]: 'data', | ||
[`${name}RequestIsPending`]: 'isPending' | ||
}) | ||
{ | ||
[name]: function () { | ||
return this.$store.state[name].data | ||
}, | ||
[`${name}RequestIsPending`]: function () { | ||
return this.$store.state[name].isPending | ||
} | ||
} | ||
) | ||
@@ -20,7 +23,9 @@ this.$options.methods = Object.assign( | ||
this.$options.methods, | ||
mapActions(name, { | ||
[`getAsync${upperFirst(camelCase(name))}`]: 'getAsync' | ||
}) | ||
{ | ||
[`getAsync${upperFirst(camelCase(name))}`]: function () { | ||
this.$store.dispatch(`${name}/getAsync`, ...arguments) | ||
} | ||
} | ||
) | ||
} | ||
} |
/*! @liqueflies/vuex-async-module - v0.0.3 | ||
/*! @liqueflies/vuex-async-module - v0.0.4 | ||
* https://github.com/liqueflies/vuex-async-module | ||
@@ -98,864 +98,2 @@ * Copyright (c) 2017 - [object Object]; | ||
/** | ||
* vuex v3.0.1 | ||
* (c) 2017 Evan You | ||
* @license MIT | ||
*/ | ||
var applyMixin = function (Vue) { | ||
var version = Number(Vue.version.split('.')[0]); | ||
if (version >= 2) { | ||
Vue.mixin({ beforeCreate: vuexInit }); | ||
} else { | ||
// override init and inject vuex init procedure | ||
// for 1.x backwards compatibility. | ||
var _init = Vue.prototype._init; | ||
Vue.prototype._init = function (options) { | ||
if ( options === void 0 ) options = {}; | ||
options.init = options.init | ||
? [vuexInit].concat(options.init) | ||
: vuexInit; | ||
_init.call(this, options); | ||
}; | ||
} | ||
/** | ||
* Vuex init hook, injected into each instances init hooks list. | ||
*/ | ||
function vuexInit () { | ||
var options = this.$options; | ||
// store injection | ||
if (options.store) { | ||
this.$store = typeof options.store === 'function' | ||
? options.store() | ||
: options.store; | ||
} else if (options.parent && options.parent.$store) { | ||
this.$store = options.parent.$store; | ||
} | ||
} | ||
}; | ||
var devtoolHook = | ||
typeof window !== 'undefined' && | ||
window.__VUE_DEVTOOLS_GLOBAL_HOOK__; | ||
function devtoolPlugin (store) { | ||
if (!devtoolHook) { return } | ||
store._devtoolHook = devtoolHook; | ||
devtoolHook.emit('vuex:init', store); | ||
devtoolHook.on('vuex:travel-to-state', function (targetState) { | ||
store.replaceState(targetState); | ||
}); | ||
store.subscribe(function (mutation, state) { | ||
devtoolHook.emit('vuex:mutation', mutation, state); | ||
}); | ||
} | ||
/** | ||
* Get the first item that pass the test | ||
* by second argument function | ||
* | ||
* @param {Array} list | ||
* @param {Function} f | ||
* @return {*} | ||
*/ | ||
/** | ||
* Deep copy the given object considering circular structure. | ||
* This function caches all nested objects and its copies. | ||
* If it detects circular structure, use cached copy to avoid infinite loop. | ||
* | ||
* @param {*} obj | ||
* @param {Array<Object>} cache | ||
* @return {*} | ||
*/ | ||
/** | ||
* forEach for object | ||
*/ | ||
function forEachValue (obj, fn) { | ||
Object.keys(obj).forEach(function (key) { return fn(obj[key], key); }); | ||
} | ||
function isObject (obj) { | ||
return obj !== null && typeof obj === 'object' | ||
} | ||
function isPromise (val) { | ||
return val && typeof val.then === 'function' | ||
} | ||
function assert (condition, msg) { | ||
if (!condition) { throw new Error(("[vuex] " + msg)) } | ||
} | ||
var Module = function Module (rawModule, runtime) { | ||
this.runtime = runtime; | ||
this._children = Object.create(null); | ||
this._rawModule = rawModule; | ||
var rawState = rawModule.state; | ||
this.state = (typeof rawState === 'function' ? rawState() : rawState) || {}; | ||
}; | ||
var prototypeAccessors$1 = { namespaced: { configurable: true } }; | ||
prototypeAccessors$1.namespaced.get = function () { | ||
return !!this._rawModule.namespaced | ||
}; | ||
Module.prototype.addChild = function addChild (key, module) { | ||
this._children[key] = module; | ||
}; | ||
Module.prototype.removeChild = function removeChild (key) { | ||
delete this._children[key]; | ||
}; | ||
Module.prototype.getChild = function getChild (key) { | ||
return this._children[key] | ||
}; | ||
Module.prototype.update = function update (rawModule) { | ||
this._rawModule.namespaced = rawModule.namespaced; | ||
if (rawModule.actions) { | ||
this._rawModule.actions = rawModule.actions; | ||
} | ||
if (rawModule.mutations) { | ||
this._rawModule.mutations = rawModule.mutations; | ||
} | ||
if (rawModule.getters) { | ||
this._rawModule.getters = rawModule.getters; | ||
} | ||
}; | ||
Module.prototype.forEachChild = function forEachChild (fn) { | ||
forEachValue(this._children, fn); | ||
}; | ||
Module.prototype.forEachGetter = function forEachGetter (fn) { | ||
if (this._rawModule.getters) { | ||
forEachValue(this._rawModule.getters, fn); | ||
} | ||
}; | ||
Module.prototype.forEachAction = function forEachAction (fn) { | ||
if (this._rawModule.actions) { | ||
forEachValue(this._rawModule.actions, fn); | ||
} | ||
}; | ||
Module.prototype.forEachMutation = function forEachMutation (fn) { | ||
if (this._rawModule.mutations) { | ||
forEachValue(this._rawModule.mutations, fn); | ||
} | ||
}; | ||
Object.defineProperties( Module.prototype, prototypeAccessors$1 ); | ||
var ModuleCollection = function ModuleCollection (rawRootModule) { | ||
// register root module (Vuex.Store options) | ||
this.register([], rawRootModule, false); | ||
}; | ||
ModuleCollection.prototype.get = function get (path) { | ||
return path.reduce(function (module, key) { | ||
return module.getChild(key) | ||
}, this.root) | ||
}; | ||
ModuleCollection.prototype.getNamespace = function getNamespace (path) { | ||
var module = this.root; | ||
return path.reduce(function (namespace, key) { | ||
module = module.getChild(key); | ||
return namespace + (module.namespaced ? key + '/' : '') | ||
}, '') | ||
}; | ||
ModuleCollection.prototype.update = function update$1 (rawRootModule) { | ||
update([], this.root, rawRootModule); | ||
}; | ||
ModuleCollection.prototype.register = function register (path, rawModule, runtime) { | ||
var this$1 = this; | ||
if ( runtime === void 0 ) runtime = true; | ||
{ | ||
assertRawModule(path, rawModule); | ||
} | ||
var newModule = new Module(rawModule, runtime); | ||
if (path.length === 0) { | ||
this.root = newModule; | ||
} else { | ||
var parent = this.get(path.slice(0, -1)); | ||
parent.addChild(path[path.length - 1], newModule); | ||
} | ||
// register nested modules | ||
if (rawModule.modules) { | ||
forEachValue(rawModule.modules, function (rawChildModule, key) { | ||
this$1.register(path.concat(key), rawChildModule, runtime); | ||
}); | ||
} | ||
}; | ||
ModuleCollection.prototype.unregister = function unregister (path) { | ||
var parent = this.get(path.slice(0, -1)); | ||
var key = path[path.length - 1]; | ||
if (!parent.getChild(key).runtime) { return } | ||
parent.removeChild(key); | ||
}; | ||
function update (path, targetModule, newModule) { | ||
{ | ||
assertRawModule(path, newModule); | ||
} | ||
// update target module | ||
targetModule.update(newModule); | ||
// update nested modules | ||
if (newModule.modules) { | ||
for (var key in newModule.modules) { | ||
if (!targetModule.getChild(key)) { | ||
{ | ||
console.warn( | ||
"[vuex] trying to add a new module '" + key + "' on hot reloading, " + | ||
'manual reload is needed' | ||
); | ||
} | ||
return | ||
} | ||
update( | ||
path.concat(key), | ||
targetModule.getChild(key), | ||
newModule.modules[key] | ||
); | ||
} | ||
} | ||
} | ||
var functionAssert = { | ||
assert: function (value) { return typeof value === 'function'; }, | ||
expected: 'function' | ||
}; | ||
var objectAssert = { | ||
assert: function (value) { return typeof value === 'function' || | ||
(typeof value === 'object' && typeof value.handler === 'function'); }, | ||
expected: 'function or object with "handler" function' | ||
}; | ||
var assertTypes = { | ||
getters: functionAssert, | ||
mutations: functionAssert, | ||
actions: objectAssert | ||
}; | ||
function assertRawModule (path, rawModule) { | ||
Object.keys(assertTypes).forEach(function (key) { | ||
if (!rawModule[key]) { return } | ||
var assertOptions = assertTypes[key]; | ||
forEachValue(rawModule[key], function (value, type) { | ||
assert( | ||
assertOptions.assert(value), | ||
makeAssertionMessage(path, key, type, value, assertOptions.expected) | ||
); | ||
}); | ||
}); | ||
} | ||
function makeAssertionMessage (path, key, type, value, expected) { | ||
var buf = key + " should be " + expected + " but \"" + key + "." + type + "\""; | ||
if (path.length > 0) { | ||
buf += " in module \"" + (path.join('.')) + "\""; | ||
} | ||
buf += " is " + (JSON.stringify(value)) + "."; | ||
return buf | ||
} | ||
var Vue; // bind on install | ||
var Store = function Store (options) { | ||
var this$1 = this; | ||
if ( options === void 0 ) options = {}; | ||
// Auto install if it is not done yet and `window` has `Vue`. | ||
// To allow users to avoid auto-installation in some cases, | ||
// this code should be placed here. See #731 | ||
if (!Vue && typeof window !== 'undefined' && window.Vue) { | ||
install(window.Vue); | ||
} | ||
{ | ||
assert(Vue, "must call Vue.use(Vuex) before creating a store instance."); | ||
assert(typeof Promise !== 'undefined', "vuex requires a Promise polyfill in this browser."); | ||
assert(this instanceof Store, "Store must be called with the new operator."); | ||
} | ||
var plugins = options.plugins; if ( plugins === void 0 ) plugins = []; | ||
var strict = options.strict; if ( strict === void 0 ) strict = false; | ||
var state = options.state; if ( state === void 0 ) state = {}; | ||
if (typeof state === 'function') { | ||
state = state() || {}; | ||
} | ||
// store internal state | ||
this._committing = false; | ||
this._actions = Object.create(null); | ||
this._actionSubscribers = []; | ||
this._mutations = Object.create(null); | ||
this._wrappedGetters = Object.create(null); | ||
this._modules = new ModuleCollection(options); | ||
this._modulesNamespaceMap = Object.create(null); | ||
this._subscribers = []; | ||
this._watcherVM = new Vue(); | ||
// bind commit and dispatch to self | ||
var store = this; | ||
var ref = this; | ||
var dispatch = ref.dispatch; | ||
var commit = ref.commit; | ||
this.dispatch = function boundDispatch (type, payload) { | ||
return dispatch.call(store, type, payload) | ||
}; | ||
this.commit = function boundCommit (type, payload, options) { | ||
return commit.call(store, type, payload, options) | ||
}; | ||
// strict mode | ||
this.strict = strict; | ||
// init root module. | ||
// this also recursively registers all sub-modules | ||
// and collects all module getters inside this._wrappedGetters | ||
installModule(this, state, [], this._modules.root); | ||
// initialize the store vm, which is responsible for the reactivity | ||
// (also registers _wrappedGetters as computed properties) | ||
resetStoreVM(this, state); | ||
// apply plugins | ||
plugins.forEach(function (plugin) { return plugin(this$1); }); | ||
if (Vue.config.devtools) { | ||
devtoolPlugin(this); | ||
} | ||
}; | ||
var prototypeAccessors = { state: { configurable: true } }; | ||
prototypeAccessors.state.get = function () { | ||
return this._vm._data.$$state | ||
}; | ||
prototypeAccessors.state.set = function (v) { | ||
{ | ||
assert(false, "Use store.replaceState() to explicit replace store state."); | ||
} | ||
}; | ||
Store.prototype.commit = function commit (_type, _payload, _options) { | ||
var this$1 = this; | ||
// check object-style commit | ||
var ref = unifyObjectStyle(_type, _payload, _options); | ||
var type = ref.type; | ||
var payload = ref.payload; | ||
var options = ref.options; | ||
var mutation = { type: type, payload: payload }; | ||
var entry = this._mutations[type]; | ||
if (!entry) { | ||
{ | ||
console.error(("[vuex] unknown mutation type: " + type)); | ||
} | ||
return | ||
} | ||
this._withCommit(function () { | ||
entry.forEach(function commitIterator (handler) { | ||
handler(payload); | ||
}); | ||
}); | ||
this._subscribers.forEach(function (sub) { return sub(mutation, this$1.state); }); | ||
if ( | ||
"development" !== 'production' && | ||
options && options.silent | ||
) { | ||
console.warn( | ||
"[vuex] mutation type: " + type + ". Silent option has been removed. " + | ||
'Use the filter functionality in the vue-devtools' | ||
); | ||
} | ||
}; | ||
Store.prototype.dispatch = function dispatch (_type, _payload) { | ||
var this$1 = this; | ||
// check object-style dispatch | ||
var ref = unifyObjectStyle(_type, _payload); | ||
var type = ref.type; | ||
var payload = ref.payload; | ||
var action = { type: type, payload: payload }; | ||
var entry = this._actions[type]; | ||
if (!entry) { | ||
{ | ||
console.error(("[vuex] unknown action type: " + type)); | ||
} | ||
return | ||
} | ||
this._actionSubscribers.forEach(function (sub) { return sub(action, this$1.state); }); | ||
return entry.length > 1 | ||
? Promise.all(entry.map(function (handler) { return handler(payload); })) | ||
: entry[0](payload) | ||
}; | ||
Store.prototype.subscribe = function subscribe (fn) { | ||
return genericSubscribe(fn, this._subscribers) | ||
}; | ||
Store.prototype.subscribeAction = function subscribeAction (fn) { | ||
return genericSubscribe(fn, this._actionSubscribers) | ||
}; | ||
Store.prototype.watch = function watch (getter, cb, options) { | ||
var this$1 = this; | ||
{ | ||
assert(typeof getter === 'function', "store.watch only accepts a function."); | ||
} | ||
return this._watcherVM.$watch(function () { return getter(this$1.state, this$1.getters); }, cb, options) | ||
}; | ||
Store.prototype.replaceState = function replaceState (state) { | ||
var this$1 = this; | ||
this._withCommit(function () { | ||
this$1._vm._data.$$state = state; | ||
}); | ||
}; | ||
Store.prototype.registerModule = function registerModule (path, rawModule, options) { | ||
if ( options === void 0 ) options = {}; | ||
if (typeof path === 'string') { path = [path]; } | ||
{ | ||
assert(Array.isArray(path), "module path must be a string or an Array."); | ||
assert(path.length > 0, 'cannot register the root module by using registerModule.'); | ||
} | ||
this._modules.register(path, rawModule); | ||
installModule(this, this.state, path, this._modules.get(path), options.preserveState); | ||
// reset store to update getters... | ||
resetStoreVM(this, this.state); | ||
}; | ||
Store.prototype.unregisterModule = function unregisterModule (path) { | ||
var this$1 = this; | ||
if (typeof path === 'string') { path = [path]; } | ||
{ | ||
assert(Array.isArray(path), "module path must be a string or an Array."); | ||
} | ||
this._modules.unregister(path); | ||
this._withCommit(function () { | ||
var parentState = getNestedState(this$1.state, path.slice(0, -1)); | ||
Vue.delete(parentState, path[path.length - 1]); | ||
}); | ||
resetStore(this); | ||
}; | ||
Store.prototype.hotUpdate = function hotUpdate (newOptions) { | ||
this._modules.update(newOptions); | ||
resetStore(this, true); | ||
}; | ||
Store.prototype._withCommit = function _withCommit (fn) { | ||
var committing = this._committing; | ||
this._committing = true; | ||
fn(); | ||
this._committing = committing; | ||
}; | ||
Object.defineProperties( Store.prototype, prototypeAccessors ); | ||
function genericSubscribe (fn, subs) { | ||
if (subs.indexOf(fn) < 0) { | ||
subs.push(fn); | ||
} | ||
return function () { | ||
var i = subs.indexOf(fn); | ||
if (i > -1) { | ||
subs.splice(i, 1); | ||
} | ||
} | ||
} | ||
function resetStore (store, hot) { | ||
store._actions = Object.create(null); | ||
store._mutations = Object.create(null); | ||
store._wrappedGetters = Object.create(null); | ||
store._modulesNamespaceMap = Object.create(null); | ||
var state = store.state; | ||
// init all modules | ||
installModule(store, state, [], store._modules.root, true); | ||
// reset vm | ||
resetStoreVM(store, state, hot); | ||
} | ||
function resetStoreVM (store, state, hot) { | ||
var oldVm = store._vm; | ||
// bind store public getters | ||
store.getters = {}; | ||
var wrappedGetters = store._wrappedGetters; | ||
var computed = {}; | ||
forEachValue(wrappedGetters, function (fn, key) { | ||
// use computed to leverage its lazy-caching mechanism | ||
computed[key] = function () { return fn(store); }; | ||
Object.defineProperty(store.getters, key, { | ||
get: function () { return store._vm[key]; }, | ||
enumerable: true // for local getters | ||
}); | ||
}); | ||
// use a Vue instance to store the state tree | ||
// suppress warnings just in case the user has added | ||
// some funky global mixins | ||
var silent = Vue.config.silent; | ||
Vue.config.silent = true; | ||
store._vm = new Vue({ | ||
data: { | ||
$$state: state | ||
}, | ||
computed: computed | ||
}); | ||
Vue.config.silent = silent; | ||
// enable strict mode for new vm | ||
if (store.strict) { | ||
enableStrictMode(store); | ||
} | ||
if (oldVm) { | ||
if (hot) { | ||
// dispatch changes in all subscribed watchers | ||
// to force getter re-evaluation for hot reloading. | ||
store._withCommit(function () { | ||
oldVm._data.$$state = null; | ||
}); | ||
} | ||
Vue.nextTick(function () { return oldVm.$destroy(); }); | ||
} | ||
} | ||
function installModule (store, rootState, path, module, hot) { | ||
var isRoot = !path.length; | ||
var namespace = store._modules.getNamespace(path); | ||
// register in namespace map | ||
if (module.namespaced) { | ||
store._modulesNamespaceMap[namespace] = module; | ||
} | ||
// set state | ||
if (!isRoot && !hot) { | ||
var parentState = getNestedState(rootState, path.slice(0, -1)); | ||
var moduleName = path[path.length - 1]; | ||
store._withCommit(function () { | ||
Vue.set(parentState, moduleName, module.state); | ||
}); | ||
} | ||
var local = module.context = makeLocalContext(store, namespace, path); | ||
module.forEachMutation(function (mutation, key) { | ||
var namespacedType = namespace + key; | ||
registerMutation(store, namespacedType, mutation, local); | ||
}); | ||
module.forEachAction(function (action, key) { | ||
var type = action.root ? key : namespace + key; | ||
var handler = action.handler || action; | ||
registerAction(store, type, handler, local); | ||
}); | ||
module.forEachGetter(function (getter, key) { | ||
var namespacedType = namespace + key; | ||
registerGetter(store, namespacedType, getter, local); | ||
}); | ||
module.forEachChild(function (child, key) { | ||
installModule(store, rootState, path.concat(key), child, hot); | ||
}); | ||
} | ||
/** | ||
* make localized dispatch, commit, getters and state | ||
* if there is no namespace, just use root ones | ||
*/ | ||
function makeLocalContext (store, namespace, path) { | ||
var noNamespace = namespace === ''; | ||
var local = { | ||
dispatch: noNamespace ? store.dispatch : function (_type, _payload, _options) { | ||
var args = unifyObjectStyle(_type, _payload, _options); | ||
var payload = args.payload; | ||
var options = args.options; | ||
var type = args.type; | ||
if (!options || !options.root) { | ||
type = namespace + type; | ||
if ("development" !== 'production' && !store._actions[type]) { | ||
console.error(("[vuex] unknown local action type: " + (args.type) + ", global type: " + type)); | ||
return | ||
} | ||
} | ||
return store.dispatch(type, payload) | ||
}, | ||
commit: noNamespace ? store.commit : function (_type, _payload, _options) { | ||
var args = unifyObjectStyle(_type, _payload, _options); | ||
var payload = args.payload; | ||
var options = args.options; | ||
var type = args.type; | ||
if (!options || !options.root) { | ||
type = namespace + type; | ||
if ("development" !== 'production' && !store._mutations[type]) { | ||
console.error(("[vuex] unknown local mutation type: " + (args.type) + ", global type: " + type)); | ||
return | ||
} | ||
} | ||
store.commit(type, payload, options); | ||
} | ||
}; | ||
// getters and state object must be gotten lazily | ||
// because they will be changed by vm update | ||
Object.defineProperties(local, { | ||
getters: { | ||
get: noNamespace | ||
? function () { return store.getters; } | ||
: function () { return makeLocalGetters(store, namespace); } | ||
}, | ||
state: { | ||
get: function () { return getNestedState(store.state, path); } | ||
} | ||
}); | ||
return local | ||
} | ||
function makeLocalGetters (store, namespace) { | ||
var gettersProxy = {}; | ||
var splitPos = namespace.length; | ||
Object.keys(store.getters).forEach(function (type) { | ||
// skip if the target getter is not match this namespace | ||
if (type.slice(0, splitPos) !== namespace) { return } | ||
// extract local getter type | ||
var localType = type.slice(splitPos); | ||
// Add a port to the getters proxy. | ||
// Define as getter property because | ||
// we do not want to evaluate the getters in this time. | ||
Object.defineProperty(gettersProxy, localType, { | ||
get: function () { return store.getters[type]; }, | ||
enumerable: true | ||
}); | ||
}); | ||
return gettersProxy | ||
} | ||
function registerMutation (store, type, handler, local) { | ||
var entry = store._mutations[type] || (store._mutations[type] = []); | ||
entry.push(function wrappedMutationHandler (payload) { | ||
handler.call(store, local.state, payload); | ||
}); | ||
} | ||
function registerAction (store, type, handler, local) { | ||
var entry = store._actions[type] || (store._actions[type] = []); | ||
entry.push(function wrappedActionHandler (payload, cb) { | ||
var res = handler.call(store, { | ||
dispatch: local.dispatch, | ||
commit: local.commit, | ||
getters: local.getters, | ||
state: local.state, | ||
rootGetters: store.getters, | ||
rootState: store.state | ||
}, payload, cb); | ||
if (!isPromise(res)) { | ||
res = Promise.resolve(res); | ||
} | ||
if (store._devtoolHook) { | ||
return res.catch(function (err) { | ||
store._devtoolHook.emit('vuex:error', err); | ||
throw err | ||
}) | ||
} else { | ||
return res | ||
} | ||
}); | ||
} | ||
function registerGetter (store, type, rawGetter, local) { | ||
if (store._wrappedGetters[type]) { | ||
{ | ||
console.error(("[vuex] duplicate getter key: " + type)); | ||
} | ||
return | ||
} | ||
store._wrappedGetters[type] = function wrappedGetter (store) { | ||
return rawGetter( | ||
local.state, // local state | ||
local.getters, // local getters | ||
store.state, // root state | ||
store.getters // root getters | ||
) | ||
}; | ||
} | ||
function enableStrictMode (store) { | ||
store._vm.$watch(function () { return this._data.$$state }, function () { | ||
{ | ||
assert(store._committing, "Do not mutate vuex store state outside mutation handlers."); | ||
} | ||
}, { deep: true, sync: true }); | ||
} | ||
function getNestedState (state, path) { | ||
return path.length | ||
? path.reduce(function (state, key) { return state[key]; }, state) | ||
: state | ||
} | ||
function unifyObjectStyle (type, payload, options) { | ||
if (isObject(type) && type.type) { | ||
options = payload; | ||
payload = type; | ||
type = type.type; | ||
} | ||
{ | ||
assert(typeof type === 'string', ("Expects string as the type, but found " + (typeof type) + ".")); | ||
} | ||
return { type: type, payload: payload, options: options } | ||
} | ||
function install (_Vue) { | ||
if (Vue && _Vue === Vue) { | ||
{ | ||
console.error( | ||
'[vuex] already installed. Vue.use(Vuex) should be called only once.' | ||
); | ||
} | ||
return | ||
} | ||
Vue = _Vue; | ||
applyMixin(Vue); | ||
} | ||
var mapState = normalizeNamespace(function (namespace, states) { | ||
var res = {}; | ||
normalizeMap(states).forEach(function (ref) { | ||
var key = ref.key; | ||
var val = ref.val; | ||
res[key] = function mappedState () { | ||
var state = this.$store.state; | ||
var getters = this.$store.getters; | ||
if (namespace) { | ||
var module = getModuleByNamespace(this.$store, 'mapState', namespace); | ||
if (!module) { | ||
return | ||
} | ||
state = module.context.state; | ||
getters = module.context.getters; | ||
} | ||
return typeof val === 'function' | ||
? val.call(this, state, getters) | ||
: state[val] | ||
}; | ||
// mark vuex getter for devtools | ||
res[key].vuex = true; | ||
}); | ||
return res | ||
}); | ||
var mapActions = normalizeNamespace(function (namespace, actions) { | ||
var res = {}; | ||
normalizeMap(actions).forEach(function (ref) { | ||
var key = ref.key; | ||
var val = ref.val; | ||
res[key] = function mappedAction () { | ||
var args = [], len = arguments.length; | ||
while ( len-- ) args[ len ] = arguments[ len ]; | ||
var dispatch = this.$store.dispatch; | ||
if (namespace) { | ||
var module = getModuleByNamespace(this.$store, 'mapActions', namespace); | ||
if (!module) { | ||
return | ||
} | ||
dispatch = module.context.dispatch; | ||
} | ||
return typeof val === 'function' | ||
? val.apply(this, [dispatch].concat(args)) | ||
: dispatch.apply(this.$store, [val].concat(args)) | ||
}; | ||
}); | ||
return res | ||
}); | ||
function normalizeMap (map) { | ||
return Array.isArray(map) | ||
? map.map(function (key) { return ({ key: key, val: key }); }) | ||
: Object.keys(map).map(function (key) { return ({ key: key, val: map[key] }); }) | ||
} | ||
function normalizeNamespace (fn) { | ||
return function (namespace, map) { | ||
if (typeof namespace !== 'string') { | ||
map = namespace; | ||
namespace = ''; | ||
} else if (namespace.charAt(namespace.length - 1) !== '/') { | ||
namespace += '/'; | ||
} | ||
return fn(namespace, map) | ||
} | ||
} | ||
function getModuleByNamespace (store, helper, namespace) { | ||
var module = store._modulesNamespaceMap[namespace]; | ||
if ("development" !== 'production' && !module) { | ||
console.error(("[vuex] module namespace not found in " + helper + "(): " + namespace)); | ||
} | ||
return module | ||
} | ||
var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; | ||
@@ -1869,8 +1007,16 @@ | ||
beforeCreate: function beforeCreate() { | ||
var _mapState, _mapActions; | ||
var _Object$assign, _Object$assign2; | ||
var name = this.$options.name; | ||
this.$options.computed = Object.assign({}, this.$options.computed, mapState(name, (_mapState = {}, _mapState[name] = 'data', _mapState[name + 'RequestIsPending'] = 'isPending', _mapState))); | ||
this.$options.methods = Object.assign({}, this.$options.methods, mapActions(name, (_mapActions = {}, _mapActions['getAsync' + lodash_upperfirst(lodash_camelcase(name))] = 'getAsync', _mapActions))); | ||
this.$options.computed = Object.assign({}, this.$options.computed, (_Object$assign = {}, _Object$assign[name] = function () { | ||
return this.$store.state[name].data; | ||
}, _Object$assign[name + 'RequestIsPending'] = function undefined() { | ||
return this.$store.state[name].isPending; | ||
}, _Object$assign)); | ||
this.$options.methods = Object.assign({}, this.$options.methods, (_Object$assign2 = {}, _Object$assign2['getAsync' + lodash_upperfirst(lodash_camelcase(name))] = function undefined() { | ||
var _$store; | ||
(_$store = this.$store).dispatch.apply(_$store, [name + '/getAsync'].concat(Array.prototype.slice.call(arguments))); | ||
}, _Object$assign2)); | ||
} | ||
@@ -1877,0 +1023,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
/*! @liqueflies/vuex-async-module - v0.0.3 | ||
/*! @liqueflies/vuex-async-module - v0.0.4 | ||
* https://github.com/liqueflies/vuex-async-module | ||
@@ -6,3 +6,3 @@ * Copyright (c) 2017 - [object Object]; | ||
*/ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.VuexAsyncModule={})}(this,function(t){"use strict";function e(t,e){Object.keys(t).forEach(function(n){return e(t[n],n)})}function n(t,e,o){if(e.update(o),o.modules)for(var r in o.modules){if(!e.getChild(r))return;n(t.concat(r),e.getChild(r),o.modules[r])}}function o(t,e){return e.indexOf(t)<0&&e.push(t),function(){var n=e.indexOf(t);n>-1&&e.splice(n,1)}}function r(t,e){t._actions=Object.create(null),t._mutations=Object.create(null),t._wrappedGetters=Object.create(null),t._modulesNamespaceMap=Object.create(null);var n=t.state;u(t,n,[],t._modules.root,!0),i(t,n,e)}function i(t,n,o){var r=t._vm;t.getters={};var i={};e(t._wrappedGetters,function(e,n){i[n]=function(){return e(t)},Object.defineProperty(t.getters,n,{get:function(){return t._vm[n]},enumerable:!0})});var u=w.config.silent;w.config.silent=!0,t._vm=new w({data:{$$state:n},computed:i}),w.config.silent=u,t.strict&&function(t){t._vm.$watch(function(){return this._data.$$state},function(){},{deep:!0,sync:!0})}(t),r&&(o&&t._withCommit(function(){r._data.$$state=null}),w.nextTick(function(){return r.$destroy()}))}function u(t,e,n,o,r){var i=!n.length,f=t._modules.getNamespace(n);if(o.namespaced&&(t._modulesNamespaceMap[f]=o),!i&&!r){var a=c(e,n.slice(0,-1)),d=n[n.length-1];t._withCommit(function(){w.set(a,d,o.state)})}var l=o.context=function(t,e,n){var o=""===e,r={dispatch:o?t.dispatch:function(n,o,r){var i=s(n,o,r),u=i.payload,c=i.options,f=i.type;return c&&c.root||(f=e+f),t.dispatch(f,u)},commit:o?t.commit:function(n,o,r){var i=s(n,o,r),u=i.payload,c=i.options,f=i.type;c&&c.root||(f=e+f),t.commit(f,u,c)}};return Object.defineProperties(r,{getters:{get:o?function(){return t.getters}:function(){return function(t,e){var n={},o=e.length;return Object.keys(t.getters).forEach(function(r){if(r.slice(0,o)===e){var i=r.slice(o);Object.defineProperty(n,i,{get:function(){return t.getters[r]},enumerable:!0})}}),n}(t,e)}},state:{get:function(){return c(t.state,n)}}}),r}(t,f,n);o.forEachMutation(function(e,n){!function(t,e,n,o){(t._mutations[e]||(t._mutations[e]=[])).push(function(e){n.call(t,o.state,e)})}(t,f+n,e,l)}),o.forEachAction(function(e,n){var o=e.root?n:f+n,r=e.handler||e;!function(t,e,n,o){(t._actions[e]||(t._actions[e]=[])).push(function(e,r){var i=n.call(t,{dispatch:o.dispatch,commit:o.commit,getters:o.getters,state:o.state,rootGetters:t.getters,rootState:t.state},e,r);return function(t){return t&&"function"==typeof t.then}(i)||(i=Promise.resolve(i)),t._devtoolHook?i.catch(function(e){throw t._devtoolHook.emit("vuex:error",e),e}):i})}(t,o,r,l)}),o.forEachGetter(function(e,n){!function(t,e,n,o){if(t._wrappedGetters[e])return;t._wrappedGetters[e]=function(t){return n(o.state,o.getters,t.state,t.getters)}}(t,f+n,e,l)}),o.forEachChild(function(o,i){u(t,e,n.concat(i),o,r)})}function c(t,e){return e.length?e.reduce(function(t,e){return t[e]},t):t}function s(t,e,n){return function(t){return null!==t&&"object"==typeof t}(t)&&t.type&&(n=e,e=t,t=t.type),{type:t,payload:e,options:n}}function f(t){return Array.isArray(t)?t.map(function(t){return{key:t,val:t}}):Object.keys(t).map(function(e){return{key:e,val:t[e]}})}function a(t){return function(e,n){return"string"!=typeof e?(n=e,e=""):"/"!==e.charAt(e.length-1)&&(e+="/"),t(e,n)}}function d(t,e,n){return t._modulesNamespaceMap[n]}function l(t){return it.test(t)}function p(t){return l(t)?function(t){return t.match(ot)||[]}(t):function(t){return t.split("")}(t)}function h(t){if("string"==typeof t)return t;if(function(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&dt.call(t)==M}(t))return ht?ht.call(t):"";var e=t+"";return"0"==e&&1/t==-N?"-0":e}function _(t,e,n){var o=t.length;return n=void 0===n?o:n,!e&&n>=o?t:function(t,e,n){var o=-1,r=t.length;e<0&&(e=-e>r?0:r+e),(n=n>r?r:n)<0&&(n+=r),r=e>n?0:n-e>>>0,e>>>=0;for(var i=Array(r);++o<r;)i[o]=t[o+e];return i}(t,e,n)}function m(t){return null==t?"":h(t)}function v(t){return Rt.test(t)}function g(t){return v(t)?function(t){return t.match(Ct)||[]}(t):function(t){return t.split("")}(t)}function y(t){if("string"==typeof t)return t;if(function(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&Pt.call(t)==yt}(t))return Ut?Ut.call(t):"";var e=t+"";return"0"==e&&1/t==-gt?"-0":e}function E(t,e,n){var o=t.length;return n=void 0===n?o:n,!e&&n>=o?t:function(t,e,n){var o=-1,r=t.length;e<0&&(e=-e>r?0:r+e),(n=n>r?r:n)<0&&(n+=r),r=e>n?0:n-e>>>0,e>>>=0;for(var i=Array(r);++o<r;)i[o]=t[o+e];return i}(t,e,n)}var b=function(t){function e(){var t=this.$options;t.store?this.$store="function"==typeof t.store?t.store():t.store:t.parent&&t.parent.$store&&(this.$store=t.parent.$store)}if(Number(t.version.split(".")[0])>=2)t.mixin({beforeCreate:e});else{var n=t.prototype._init;t.prototype._init=function(t){void 0===t&&(t={}),t.init=t.init?[e].concat(t.init):e,n.call(this,t)}}},S="undefined"!=typeof window&&window.__VUE_DEVTOOLS_GLOBAL_HOOK__,x=function(t,e){this.runtime=e,this._children=Object.create(null),this._rawModule=t;var n=t.state;this.state=("function"==typeof n?n():n)||{}},O={namespaced:{configurable:!0}};O.namespaced.get=function(){return!!this._rawModule.namespaced},x.prototype.addChild=function(t,e){this._children[t]=e},x.prototype.removeChild=function(t){delete this._children[t]},x.prototype.getChild=function(t){return this._children[t]},x.prototype.update=function(t){this._rawModule.namespaced=t.namespaced,t.actions&&(this._rawModule.actions=t.actions),t.mutations&&(this._rawModule.mutations=t.mutations),t.getters&&(this._rawModule.getters=t.getters)},x.prototype.forEachChild=function(t){e(this._children,t)},x.prototype.forEachGetter=function(t){this._rawModule.getters&&e(this._rawModule.getters,t)},x.prototype.forEachAction=function(t){this._rawModule.actions&&e(this._rawModule.actions,t)},x.prototype.forEachMutation=function(t){this._rawModule.mutations&&e(this._rawModule.mutations,t)},Object.defineProperties(x.prototype,O);var j=function(t){this.register([],t,!1)};j.prototype.get=function(t){return t.reduce(function(t,e){return t.getChild(e)},this.root)},j.prototype.getNamespace=function(t){var e=this.root;return t.reduce(function(t,n){return e=e.getChild(n),t+(e.namespaced?n+"/":"")},"")},j.prototype.update=function(t){n([],this.root,t)},j.prototype.register=function(t,n,o){var r=this;void 0===o&&(o=!0);var i=new x(n,o);if(0===t.length)this.root=i;else{this.get(t.slice(0,-1)).addChild(t[t.length-1],i)}n.modules&&e(n.modules,function(e,n){r.register(t.concat(n),e,o)})},j.prototype.unregister=function(t){var e=this.get(t.slice(0,-1)),n=t[t.length-1];e.getChild(n).runtime&&e.removeChild(n)};var w,T=function(t){var e=this;void 0===t&&(t={}),!w&&"undefined"!=typeof window&&window.Vue&&function(t){w&&t===w||b(w=t)}(window.Vue);var n=t.plugins;void 0===n&&(n=[]);var o=t.strict;void 0===o&&(o=!1);var r=t.state;void 0===r&&(r={}),"function"==typeof r&&(r=r()||{}),this._committing=!1,this._actions=Object.create(null),this._actionSubscribers=[],this._mutations=Object.create(null),this._wrappedGetters=Object.create(null),this._modules=new j(t),this._modulesNamespaceMap=Object.create(null),this._subscribers=[],this._watcherVM=new w;var c=this,s=this.dispatch,f=this.commit;this.dispatch=function(t,e){return s.call(c,t,e)},this.commit=function(t,e,n){return f.call(c,t,e,n)},this.strict=o,u(this,r,[],this._modules.root),i(this,r),n.forEach(function(t){return t(e)}),w.config.devtools&&function(t){S&&(t._devtoolHook=S,S.emit("vuex:init",t),S.on("vuex:travel-to-state",function(e){t.replaceState(e)}),t.subscribe(function(t,e){S.emit("vuex:mutation",t,e)}))}(this)},A={state:{configurable:!0}};A.state.get=function(){return this._vm._data.$$state},A.state.set=function(t){},T.prototype.commit=function(t,e,n){var o=this,r=s(t,e,n),i=r.type,u=r.payload,c={type:i,payload:u},f=this._mutations[i];f&&(this._withCommit(function(){f.forEach(function(t){t(u)})}),this._subscribers.forEach(function(t){return t(c,o.state)}))},T.prototype.dispatch=function(t,e){var n=this,o=s(t,e),r=o.type,i=o.payload,u={type:r,payload:i},c=this._actions[r];if(c)return this._actionSubscribers.forEach(function(t){return t(u,n.state)}),c.length>1?Promise.all(c.map(function(t){return t(i)})):c[0](i)},T.prototype.subscribe=function(t){return o(t,this._subscribers)},T.prototype.subscribeAction=function(t){return o(t,this._actionSubscribers)},T.prototype.watch=function(t,e,n){var o=this;return this._watcherVM.$watch(function(){return t(o.state,o.getters)},e,n)},T.prototype.replaceState=function(t){var e=this;this._withCommit(function(){e._vm._data.$$state=t})},T.prototype.registerModule=function(t,e,n){void 0===n&&(n={}),"string"==typeof t&&(t=[t]),this._modules.register(t,e),u(this,this.state,t,this._modules.get(t),n.preserveState),i(this,this.state)},T.prototype.unregisterModule=function(t){var e=this;"string"==typeof t&&(t=[t]),this._modules.unregister(t),this._withCommit(function(){var n=c(e.state,t.slice(0,-1));w.delete(n,t[t.length-1])}),r(this)},T.prototype.hotUpdate=function(t){this._modules.update(t),r(this,!0)},T.prototype._withCommit=function(t){var e=this._committing;this._committing=!0,t(),this._committing=e},Object.defineProperties(T.prototype,A);var C=a(function(t,e){var n={};return f(e).forEach(function(e){var o=e.key,r=e.val;n[o]=function(){var e=this.$store.state,n=this.$store.getters;if(t){var o=d(this.$store,0,t);if(!o)return;e=o.context.state,n=o.context.getters}return"function"==typeof r?r.call(this,e,n):e[r]},n[o].vuex=!0}),n}),R=a(function(t,e){var n={};return f(e).forEach(function(e){var o=e.key,r=e.val;n[o]=function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];var o=this.$store.dispatch;if(t){var i=d(this.$store,0,t);if(!i)return;o=i.context.dispatch}return"function"==typeof r?r.apply(this,[o].concat(e)):o.apply(this.$store,[r].concat(e))}}),n}),$="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},N=1/0,M="[object Symbol]",P=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,D=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,I="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",U="[\\ud800-\\udfff]",G="["+I+"]",L="[\\u0300-\\u036f\\ufe20-\\ufe23\\u20d0-\\u20f0]",k="\\d+",z="[\\u2700-\\u27bf]",Z="[a-z\\xdf-\\xf6\\xf8-\\xff]",V="[^\\ud800-\\udfff"+I+k+"\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde]",H="\\ud83c[\\udffb-\\udfff]",Y="[^\\ud800-\\udfff]",F="(?:\\ud83c[\\udde6-\\uddff]){2}",J="[\\ud800-\\udbff][\\udc00-\\udfff]",K="[A-Z\\xc0-\\xd6\\xd8-\\xde]",q="(?:"+Z+"|"+V+")",B="(?:"+K+"|"+V+")",W="(?:"+L+"|"+H+")"+"?",X="[\\ufe0e\\ufe0f]?"+W+("(?:\\u200d(?:"+[Y,F,J].join("|")+")[\\ufe0e\\ufe0f]?"+W+")*"),Q="(?:"+[z,F,J].join("|")+")"+X,tt="(?:"+[Y+L+"?",L,F,J,U].join("|")+")",et=RegExp("['’]","g"),nt=RegExp(L,"g"),ot=RegExp(H+"(?="+H+")|"+tt+X,"g"),rt=RegExp([K+"?"+Z+"+(?:['’](?:d|ll|m|re|s|t|ve))?(?="+[G,K,"$"].join("|")+")",B+"+(?:['’](?:D|LL|M|RE|S|T|VE))?(?="+[G,K+q,"$"].join("|")+")",K+"?"+q+"+(?:['’](?:d|ll|m|re|s|t|ve))?",K+"+(?:['’](?:D|LL|M|RE|S|T|VE))?",k,Q].join("|"),"g"),it=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe23\\u20d0-\\u20f0\\ufe0e\\ufe0f]"),ut=/[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,ct="object"==typeof $&&$&&$.Object===Object&&$,st="object"==typeof self&&self&&self.Object===Object&&self,ft=ct||st||Function("return this")(),at=function(t){return function(e){return null==t?void 0:t[e]}}({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"ss"}),dt=Object.prototype.toString,lt=ft.Symbol,pt=lt?lt.prototype:void 0,ht=pt?pt.toString:void 0,_t=function(t){return function(e){return function(t,e,n,o){var r=-1,i=t?t.length:0;for(o&&i&&(n=t[++r]);++r<i;)n=e(n,t[r],r,t);return n}(function(t,e,n){return t=m(t),void 0===(e=n?void 0:e)?function(t){return ut.test(t)}(t)?function(t){return t.match(rt)||[]}(t):function(t){return t.match(P)||[]}(t):t.match(e)||[]}(function(t){return(t=m(t))&&t.replace(D,at).replace(nt,"")}(e).replace(et,"")),t,"")}}(function(t,e,n){return e=e.toLowerCase(),t+(n?function(t){return mt(m(t).toLowerCase())}(e):e)}),mt=function(t){return function(e){var n=l(e=m(e))?p(e):void 0,o=n?n[0]:e.charAt(0),r=n?_(n,1).join(""):e.slice(1);return o[t]()+r}}("toUpperCase"),vt=_t,gt=1/0,yt="[object Symbol]",Et="[\\ud800-\\udfff]",bt="[\\u0300-\\u036f\\ufe20-\\ufe23\\u20d0-\\u20f0]",St="\\ud83c[\\udffb-\\udfff]",xt="[^\\ud800-\\udfff]",Ot="(?:\\ud83c[\\udde6-\\uddff]){2}",jt="[\\ud800-\\udbff][\\udc00-\\udfff]",wt="(?:"+bt+"|"+St+")"+"?",Tt="[\\ufe0e\\ufe0f]?"+wt+("(?:\\u200d(?:"+[xt,Ot,jt].join("|")+")[\\ufe0e\\ufe0f]?"+wt+")*"),At="(?:"+[xt+bt+"?",bt,Ot,jt,Et].join("|")+")",Ct=RegExp(St+"(?="+St+")|"+At+Tt,"g"),Rt=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe23\\u20d0-\\u20f0\\ufe0e\\ufe0f]"),$t="object"==typeof $&&$&&$.Object===Object&&$,Nt="object"==typeof self&&self&&self.Object===Object&&self,Mt=$t||Nt||Function("return this")(),Pt=Object.prototype.toString,Dt=Mt.Symbol,It=Dt?Dt.prototype:void 0,Ut=It?It.toString:void 0,Gt=function(t){return function(e){var n=v(e=null==e?"":y(e))?g(e):void 0,o=n?n[0]:e.charAt(0),r=n?E(n,1).join(""):e.slice(1);return o[t]()+r}}("toUpperCase"),Lt={beforeCreate:function(){var t,e,n=this.$options.name;this.$options.computed=Object.assign({},this.$options.computed,C(n,(t={},t[n]="data",t[n+"RequestIsPending"]="isPending",t))),this.$options.methods=Object.assign({},this.$options.methods,R(n,(e={},e["getAsync"+Gt(vt(n))]="getAsync",e)))}};t.asyncModuleMixin=Lt,t.default=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=Object.assign({},t);if(void 0===e.xhr)throw new TypeError("You must provide a valid XHR transport library in `options.xhr`");return{namespaced:!0,state:{isPending:!0,statusCode:null,data:null,errors:null},mutations:function(){var t,e={SET_RESPONSE_DATA:"SET_RESPONSE_DATA",SET_IS_PENDING:"SET_IS_PENDING",SET_STATUS_CODE:"SET_STATUS_CODE",SET_ERRORS:"SET_ERRORS"};return t={},t[e.SET_RESPONSE_DATA]=function(t,e){return t.data=e,t.data},t[e.SET_IS_PENDING]=function(t,e){return t.isPending=e,t.isPending},t[e.SET_STATUS_CODE]=function(t,e){return t.statusCode=e,t.statusCode},t[e.SET_ERRORS]=function(t,e){return t.errors=e,t.errors},t}(),actions:function(t){var e={SET_RESPONSE_DATA:"SET_RESPONSE_DATA",SET_IS_PENDING:"SET_IS_PENDING",SET_STATUS_CODE:"SET_STATUS_CODE",SET_ERRORS:"SET_ERRORS"},n=e.SET_RESPONSE_DATA,o=e.SET_IS_PENDING,r=e.SET_STATUS_CODE,i=e.SET_ERRORS;return{getAsync:function(e,u){var c=e.state,s=e.commit,f=u.url,a=u.forceUpdate,d=void 0!==a&&a;return c.isPending||d?t(f).then(function(t){s(n,t.data),s(r,t.status),s(o,!1)}).catch(function(t){s(i,t.errors),s(r,t.status),s(o,!1)}):Promise.resolve(null)}}}(e.xhr)}},Object.defineProperty(t,"__esModule",{value:!0})}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.VuexAsyncModule={})}(this,function(t){"use strict";function e(t){return Z.test(t)}function u(t){return e(t)?function(t){return t.match(z)||[]}(t):function(t){return t.split("")}(t)}function n(t){if("string"==typeof t)return t;if(function(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&V.call(t)==l}(t))return J?J.call(t):"";var e=t+"";return"0"==e&&1/t==-a?"-0":e}function f(t,e,u){var n=t.length;return u=void 0===u?n:u,!e&&u>=n?t:function(t,e,u){var n=-1,f=t.length;e<0&&(e=-e>f?0:f+e),(u=u>f?f:u)<0&&(u+=f),f=e>u?0:u-e>>>0,e>>>=0;for(var r=Array(f);++n<f;)r[n]=t[n+e];return r}(t,e,u)}function r(t){return null==t?"":n(t)}function o(t){return dt.test(t)}function i(t){return o(t)?function(t){return t.match(ct)||[]}(t):function(t){return t.split("")}(t)}function c(t){if("string"==typeof t)return t;if(function(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&Et.call(t)==B}(t))return xt?xt.call(t):"";var e=t+"";return"0"==e&&1/t==-X?"-0":e}function d(t,e,u){var n=t.length;return u=void 0===u?n:u,!e&&u>=n?t:function(t,e,u){var n=-1,f=t.length;e<0&&(e=-e>f?0:f+e),(u=u>f?f:u)<0&&(u+=f),f=e>u?0:u-e>>>0,e>>>=0;for(var r=Array(f);++n<f;)r[n]=t[n+e];return r}(t,e,u)}var s="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},a=1/0,l="[object Symbol]",E=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,S=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,p="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",x="[\\ud800-\\udfff]",T="["+p+"]",b="[\\u0300-\\u036f\\ufe20-\\ufe23\\u20d0-\\u20f0]",g="\\d+",A="[\\u2700-\\u27bf]",_="[a-z\\xdf-\\xf6\\xf8-\\xff]",y="[^\\ud800-\\udfff"+p+g+"\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde]",O="\\ud83c[\\udffb-\\udfff]",v="[^\\ud800-\\udfff]",R="(?:\\ud83c[\\udde6-\\uddff]){2}",h="[\\ud800-\\udbff][\\udc00-\\udfff]",j="[A-Z\\xc0-\\xd6\\xd8-\\xde]",m="(?:"+_+"|"+y+")",D="(?:"+j+"|"+y+")",I="(?:"+b+"|"+O+")"+"?",N="[\\ufe0e\\ufe0f]?"+I+("(?:\\u200d(?:"+[v,R,h].join("|")+")[\\ufe0e\\ufe0f]?"+I+")*"),P="(?:"+[A,R,h].join("|")+")"+N,C="(?:"+[v+b+"?",b,R,h,x].join("|")+")",U=RegExp("['’]","g"),L=RegExp(b,"g"),z=RegExp(O+"(?="+O+")|"+C+N,"g"),G=RegExp([j+"?"+_+"+(?:['’](?:d|ll|m|re|s|t|ve))?(?="+[T,j,"$"].join("|")+")",D+"+(?:['’](?:D|LL|M|RE|S|T|VE))?(?="+[T,j+m,"$"].join("|")+")",j+"?"+m+"+(?:['’](?:d|ll|m|re|s|t|ve))?",j+"+(?:['’](?:D|LL|M|RE|S|T|VE))?",g,P].join("|"),"g"),Z=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe23\\u20d0-\\u20f0\\ufe0e\\ufe0f]"),$=/[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,w="object"==typeof s&&s&&s.Object===Object&&s,M="object"==typeof self&&self&&self.Object===Object&&self,Y=w||M||Function("return this")(),H=function(t){return function(e){return null==t?void 0:t[e]}}({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"ss"}),V=Object.prototype.toString,k=Y.Symbol,F=k?k.prototype:void 0,J=F?F.toString:void 0,q=function(t){return function(e){return function(t,e,u,n){var f=-1,r=t?t.length:0;for(n&&r&&(u=t[++f]);++f<r;)u=e(u,t[f],f,t);return u}(function(t,e,u){return t=r(t),void 0===(e=u?void 0:e)?function(t){return $.test(t)}(t)?function(t){return t.match(G)||[]}(t):function(t){return t.match(E)||[]}(t):t.match(e)||[]}(function(t){return(t=r(t))&&t.replace(S,H).replace(L,"")}(e).replace(U,"")),t,"")}}(function(t,e,u){return e=e.toLowerCase(),t+(u?function(t){return K(r(t).toLowerCase())}(e):e)}),K=function(t){return function(n){var o=e(n=r(n))?u(n):void 0,i=o?o[0]:n.charAt(0),c=o?f(o,1).join(""):n.slice(1);return i[t]()+c}}("toUpperCase"),W=q,X=1/0,B="[object Symbol]",Q="[\\ud800-\\udfff]",tt="[\\u0300-\\u036f\\ufe20-\\ufe23\\u20d0-\\u20f0]",et="\\ud83c[\\udffb-\\udfff]",ut="[^\\ud800-\\udfff]",nt="(?:\\ud83c[\\udde6-\\uddff]){2}",ft="[\\ud800-\\udbff][\\udc00-\\udfff]",rt="(?:"+tt+"|"+et+")"+"?",ot="[\\ufe0e\\ufe0f]?"+rt+("(?:\\u200d(?:"+[ut,nt,ft].join("|")+")[\\ufe0e\\ufe0f]?"+rt+")*"),it="(?:"+[ut+tt+"?",tt,nt,ft,Q].join("|")+")",ct=RegExp(et+"(?="+et+")|"+it+ot,"g"),dt=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe23\\u20d0-\\u20f0\\ufe0e\\ufe0f]"),st="object"==typeof s&&s&&s.Object===Object&&s,at="object"==typeof self&&self&&self.Object===Object&&self,lt=st||at||Function("return this")(),Et=Object.prototype.toString,St=lt.Symbol,pt=St?St.prototype:void 0,xt=pt?pt.toString:void 0,Tt=function(t){return function(e){var u=o(e=null==e?"":c(e))?i(e):void 0,n=u?u[0]:e.charAt(0),f=u?d(u,1).join(""):e.slice(1);return n[t]()+f}}("toUpperCase"),bt={beforeCreate:function(){var t,e,u=this.$options.name;this.$options.computed=Object.assign({},this.$options.computed,(t={},t[u]=function(){return this.$store.state[u].data},t[u+"RequestIsPending"]=function(){return this.$store.state[u].isPending},t)),this.$options.methods=Object.assign({},this.$options.methods,(e={},e["getAsync"+Tt(W(u))]=function(){var t;(t=this.$store).dispatch.apply(t,[u+"/getAsync"].concat(Array.prototype.slice.call(arguments)))},e))}};t.asyncModuleMixin=bt,t.default=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=Object.assign({},t);if(void 0===e.xhr)throw new TypeError("You must provide a valid XHR transport library in `options.xhr`");return{namespaced:!0,state:{isPending:!0,statusCode:null,data:null,errors:null},mutations:function(){var t,e={SET_RESPONSE_DATA:"SET_RESPONSE_DATA",SET_IS_PENDING:"SET_IS_PENDING",SET_STATUS_CODE:"SET_STATUS_CODE",SET_ERRORS:"SET_ERRORS"};return t={},t[e.SET_RESPONSE_DATA]=function(t,e){return t.data=e,t.data},t[e.SET_IS_PENDING]=function(t,e){return t.isPending=e,t.isPending},t[e.SET_STATUS_CODE]=function(t,e){return t.statusCode=e,t.statusCode},t[e.SET_ERRORS]=function(t,e){return t.errors=e,t.errors},t}(),actions:function(t){var e={SET_RESPONSE_DATA:"SET_RESPONSE_DATA",SET_IS_PENDING:"SET_IS_PENDING",SET_STATUS_CODE:"SET_STATUS_CODE",SET_ERRORS:"SET_ERRORS"},u=e.SET_RESPONSE_DATA,n=e.SET_IS_PENDING,f=e.SET_STATUS_CODE,r=e.SET_ERRORS;return{getAsync:function(e,o){var i=e.state,c=e.commit,d=o.url,s=o.forceUpdate,a=void 0!==s&&s;return i.isPending||a?t(d).then(function(t){c(u,t.data),c(f,t.status),c(n,!1)}).catch(function(t){c(r,t.errors),c(f,t.status),c(n,!1)}):Promise.resolve(null)}}}(e.xhr)}},Object.defineProperty(t,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=vuex-async-module.min.js.map |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2
19
148860
1260