Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vuex

Package Overview
Dependencies
Maintainers
4
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vuex - npm Package Compare versions

Comparing version 4.0.0-rc.2 to 4.0.0

108

CHANGELOG.md

@@ -0,1 +1,109 @@

# [4.0.0](https://github.com/vuejs/vuex/compare/v4.0.0-rc.2...v4.0.0) (2021-02-02)
This is the official Vuex 4 release.
The focus for Vuex 4 is compatibility. Vuex 4 supports Vue 3, and it provides the exact same API as Vuex 3, so users can reuse their existing Vuex code with Vue 3.
There are a few breaking changes described in a later section, so please check them out.
You can find basic usage with both Option and Composition API in the `example` directory.
It's still released under `next` tag in NPM package as same as Vue 3. We're planning to remove `next` tag once Vue 3 is ready to remove it.
There have been a lot of contribution to make Vuex 4 stable. Thank you all for your very much appreciated help. It wouldn't have been possible without this wonderful Vue community!
## Documentation
To check out docs, visit [next.vuex.vuejs.org](https://next.vuex.vuejs.org/).
## Breaking changes
### Installation process has changed
To align with the new Vue 3 initialization process, the installation process of Vuex has changed.
To create a new store instance, users are now encouraged to use the newly introduced `createStore` function.
```js
import { createStore } from 'vuex'
export const store = createStore({
state() {
return {
count: 1
}
}
})
```
> Whilst this is not technically a breaking change, you may still use the `new Store(...)` syntax, we recommend this approach to align with Vue 3 and Vue Router Next.
To install Vuex to a Vue instance, pass the store instance instead of Vuex.
```js
import { createApp } from 'vue'
import { store } from './store'
import App from './App.vue'
const app = createApp(App)
app.use(store)
app.mount('#app')
```
### Bundles are now aligned with Vue 3
The following bundles are generated to align with Vue 3 bundles:
- `vuex.global(.prod).js`
- For direct use with `<script src="...">` in the browser. Exposes the Vuex global.
- Global build is built as IIFE, and not UMD, and is only meant for direct use with `<script src="...">`.
- Contains hard-coded prod/dev branches and the prod build is pre-minified. Use the `.prod.js` files for production.
- `vuex.esm-browser(.prod).js`
- For use with native ES module imports (including module supporting browsers via `<script type="module">`.
- `vuex.esm-bundler.js`
- For use with bundlers such as `webpack`, `rollup` and `parcel`.
- Leaves prod/dev branches with `process.env.NODE_ENV` guards (must be replaced by bundler).
- Does not ship minified builds (to be done together with the rest of the code after bundling).
- `vuex.cjs.js`
- For use in Node.js server-side rendering with `require()`.
### Typings for `ComponentCustomProperties`
Vuex 4 removes its global typings for `this.$store` within Vue Component to solve [issue #994](https://github.com/vuejs/vuex/issues/994). When used with TypeScript, you must declare your own module augmentation.
Place the following code in your project to allow `this.$store` to be typed correctly:
```ts
// vuex-shim.d.ts
import { ComponentCustomProperties } from 'vue'
import { Store } from 'vuex'
declare module '@vue/runtime-core' {
// Declare your own store states.
interface State {
count: number
}
interface ComponentCustomProperties {
$store: Store<State>
}
}
```
### `createLogger` function is exported from the core module
In Vuex 3, `createLogger` function was exported from `vuex/dist/logger` but it's now included in the core package. You should import the function directly from `vuex` package.
```js
import { createLogger } from 'vuex'
```
### Bug Fixes Included Since 4.0.0-rc.2
* export missing `storeKey` ([4ab2947](https://github.com/vuejs/vuex/commit/4ab294793a2c20ea6040f01f316618682df61fff))
* fix tree shaking notworking in webpack bundle ([#1906](https://github.com/vuejs/vuex/issues/1906)) ([#1907](https://github.com/vuejs/vuex/issues/1907)) ([aeddf7a](https://github.com/vuejs/vuex/commit/aeddf7a7c618eda7f316f8a6ace8d21eb96c29ff))
# [4.0.0-rc.2](https://github.com/vuejs/vuex/compare/v4.0.0-rc.1...v4.0.0-rc.2) (2020-11-25)

@@ -2,0 +110,0 @@

11

dist/vuex.cjs.js
/*!
* vuex v4.0.0-rc.2
* (c) 2020 Evan You
* vuex v4.0.0
* (c) 2021 Evan You
* @license MIT

@@ -921,3 +921,3 @@ */

* @param {String} [namespace] - Module's namespace
* @param {Object|Array} mutations # Object's item can be a function which accept `commit` function as the first param, it can accept anthor params. You can commit mutation and do any other things in this function. specially, You need to pass anthor params from the mapped function.
* @param {Object|Array} mutations # Object's item can be a function which accept `commit` function as the first param, it can accept another params. You can commit mutation and do any other things in this function. specially, You need to pass anthor params from the mapped function.
* @return {Object}

@@ -1185,5 +1185,6 @@ */

var index_cjs = {
version: '4.0.0-rc.2',
version: '4.0.0',
Store: Store,
storeKey: storeKey,
createStore: createStore,
Store: Store,
useStore: useStore,

@@ -1190,0 +1191,0 @@ mapState: mapState,

/*!
* vuex v4.0.0-rc.2
* (c) 2020 Evan You
* vuex v4.0.0
* (c) 2021 Evan You
* @license MIT

@@ -919,3 +919,3 @@ */

* @param {String} [namespace] - Module's namespace
* @param {Object|Array} mutations # Object's item can be a function which accept `commit` function as the first param, it can accept anthor params. You can commit mutation and do any other things in this function. specially, You need to pass anthor params from the mapped function.
* @param {Object|Array} mutations # Object's item can be a function which accept `commit` function as the first param, it can accept another params. You can commit mutation and do any other things in this function. specially, You need to pass anthor params from the mapped function.
* @return {Object}

@@ -1183,5 +1183,6 @@ */

var index = {
version: '4.0.0-rc.2',
version: '4.0.0',
Store: Store,
storeKey: storeKey,
createStore: createStore,
Store: Store,
useStore: useStore,

@@ -1197,2 +1198,2 @@ mapState: mapState,

export default index;
export { Store, createLogger, createNamespacedHelpers, createStore, mapActions, mapGetters, mapMutations, mapState, useStore };
export { Store, createLogger, createNamespacedHelpers, createStore, mapActions, mapGetters, mapMutations, mapState, storeKey, useStore };
/*!
* vuex v4.0.0-rc.2
* (c) 2020 Evan You
* vuex v4.0.0
* (c) 2021 Evan You
* @license MIT

@@ -773,3 +773,3 @@ */

* @param {String} [namespace] - Module's namespace
* @param {Object|Array} mutations # Object's item can be a function which accept `commit` function as the first param, it can accept anthor params. You can commit mutation and do any other things in this function. specially, You need to pass anthor params from the mapped function.
* @param {Object|Array} mutations # Object's item can be a function which accept `commit` function as the first param, it can accept another params. You can commit mutation and do any other things in this function. specially, You need to pass anthor params from the mapped function.
* @return {Object}

@@ -1021,5 +1021,6 @@ */

var index = {
version: '4.0.0-rc.2',
version: '4.0.0',
Store: Store,
storeKey: storeKey,
createStore: createStore,
Store: Store,
useStore: useStore,

@@ -1035,2 +1036,2 @@ mapState: mapState,

export default index;
export { Store, createLogger, createNamespacedHelpers, createStore, mapActions, mapGetters, mapMutations, mapState, useStore };
export { Store, createLogger, createNamespacedHelpers, createStore, mapActions, mapGetters, mapMutations, mapState, storeKey, useStore };
/*!
* vuex v4.0.0-rc.2
* (c) 2020 Evan You
* vuex v4.0.0
* (c) 2021 Evan You
* @license MIT

@@ -919,3 +919,3 @@ */

* @param {String} [namespace] - Module's namespace
* @param {Object|Array} mutations # Object's item can be a function which accept `commit` function as the first param, it can accept anthor params. You can commit mutation and do any other things in this function. specially, You need to pass anthor params from the mapped function.
* @param {Object|Array} mutations # Object's item can be a function which accept `commit` function as the first param, it can accept another params. You can commit mutation and do any other things in this function. specially, You need to pass anthor params from the mapped function.
* @return {Object}

@@ -1183,5 +1183,6 @@ */

var index = {
version: '4.0.0-rc.2',
version: '4.0.0',
Store: Store,
storeKey: storeKey,
createStore: createStore,
Store: Store,
useStore: useStore,

@@ -1197,2 +1198,2 @@ mapState: mapState,

export default index;
export { Store, createLogger, createNamespacedHelpers, createStore, mapActions, mapGetters, mapMutations, mapState, useStore };
export { Store, createLogger, createNamespacedHelpers, createStore, mapActions, mapGetters, mapMutations, mapState, storeKey, useStore };
/*!
* vuex v4.0.0-rc.2
* (c) 2020 Evan You
* vuex v4.0.0
* (c) 2021 Evan You
* @license MIT

@@ -920,3 +920,3 @@ */

* @param {String} [namespace] - Module's namespace
* @param {Object|Array} mutations # Object's item can be a function which accept `commit` function as the first param, it can accept anthor params. You can commit mutation and do any other things in this function. specially, You need to pass anthor params from the mapped function.
* @param {Object|Array} mutations # Object's item can be a function which accept `commit` function as the first param, it can accept another params. You can commit mutation and do any other things in this function. specially, You need to pass anthor params from the mapped function.
* @return {Object}

@@ -1184,5 +1184,6 @@ */

var index_cjs = {
version: '4.0.0-rc.2',
version: '4.0.0',
Store: Store,
storeKey: storeKey,
createStore: createStore,
Store: Store,
useStore: useStore,

@@ -1189,0 +1190,0 @@ mapState: mapState,

/*!
* vuex v4.0.0-rc.2
* (c) 2020 Evan You
* vuex v4.0.0
* (c) 2021 Evan You
* @license MIT
*/
var Vuex=function(t){"use strict";var e="store";var n=("undefined"!=typeof window?window:"undefined"!=typeof global?global:{}).__VUE_DEVTOOLS_GLOBAL_HOOK__;function r(t,e){if(void 0===e&&(e=[]),null===t||"object"!=typeof t)return t;var n,o=(n=function(e){return e.original===t},e.filter(n)[0]);if(o)return o.copy;var i=Array.isArray(t)?[]:{};return e.push({original:t,copy:i}),Object.keys(t).forEach((function(n){i[n]=r(t[n],e)})),i}function o(t,e){Object.keys(t).forEach((function(n){return e(t[n],n)}))}function i(t){return null!==t&&"object"==typeof t}var a=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)||{}},c={namespaced:{configurable:!0}};c.namespaced.get=function(){return!!this._rawModule.namespaced},a.prototype.addChild=function(t,e){this._children[t]=e},a.prototype.removeChild=function(t){delete this._children[t]},a.prototype.getChild=function(t){return this._children[t]},a.prototype.hasChild=function(t){return t in this._children},a.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)},a.prototype.forEachChild=function(t){o(this._children,t)},a.prototype.forEachGetter=function(t){this._rawModule.getters&&o(this._rawModule.getters,t)},a.prototype.forEachAction=function(t){this._rawModule.actions&&o(this._rawModule.actions,t)},a.prototype.forEachMutation=function(t){this._rawModule.mutations&&o(this._rawModule.mutations,t)},Object.defineProperties(a.prototype,c);var s=function(t){this.register([],t,!1)};function u(t,e,n){if(e.update(n),n.modules)for(var r in n.modules){if(!e.getChild(r))return;u(t.concat(r),e.getChild(r),n.modules[r])}}s.prototype.get=function(t){return t.reduce((function(t,e){return t.getChild(e)}),this.root)},s.prototype.getNamespace=function(t){var e=this.root;return t.reduce((function(t,n){return t+((e=e.getChild(n)).namespaced?n+"/":"")}),"")},s.prototype.update=function(t){u([],this.root,t)},s.prototype.register=function(t,e,n){var r=this;void 0===n&&(n=!0);var i=new a(e,n);0===t.length?this.root=i:this.get(t.slice(0,-1)).addChild(t[t.length-1],i);e.modules&&o(e.modules,(function(e,o){r.register(t.concat(o),e,n)}))},s.prototype.unregister=function(t){var e=this.get(t.slice(0,-1)),n=t[t.length-1],r=e.getChild(n);r&&r.runtime&&e.removeChild(n)},s.prototype.isRegistered=function(t){var e=this.get(t.slice(0,-1)),n=t[t.length-1];return!!e&&e.hasChild(n)};var f=function(t){var e=this;void 0===t&&(t={});var r=t.plugins;void 0===r&&(r=[]);var o=t.strict;void 0===o&&(o=!1),this._committing=!1,this._actions=Object.create(null),this._actionSubscribers=[],this._mutations=Object.create(null),this._wrappedGetters=Object.create(null),this._modules=new s(t),this._modulesNamespaceMap=Object.create(null),this._subscribers=[],this._makeLocalGettersCache=Object.create(null);var i=this,a=this.dispatch,c=this.commit;this.dispatch=function(t,e){return a.call(i,t,e)},this.commit=function(t,e,n){return c.call(i,t,e,n)},this.strict=o;var u=this._modules.root.state;m(this,u,[],this._modules.root),d(this,u),r.forEach((function(t){return t(e)})),(void 0===t.devtools||t.devtools)&&function(t){n&&(t._devtoolHook=n,n.emit("vuex:init",t),n.on("vuex:travel-to-state",(function(e){t.replaceState(e)})),t.subscribe((function(t,e){n.emit("vuex:mutation",t,e)}),{prepend:!0}),t.subscribeAction((function(t,e){n.emit("vuex:action",t,e)}),{prepend:!0}))}(this)},l={state:{configurable:!0}};function h(t,e,n){return e.indexOf(t)<0&&(n&&n.prepend?e.unshift(t):e.push(t)),function(){var n=e.indexOf(t);n>-1&&e.splice(n,1)}}function p(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;m(t,n,[],t._modules.root,!0),d(t,n,e)}function d(e,n,r){var i=e._state;e.getters={},e._makeLocalGettersCache=Object.create(null);var a=e._wrappedGetters,c={};o(a,(function(t,n){c[n]=function(t,e){return function(){return t(e)}}(t,e),Object.defineProperty(e.getters,n,{get:function(){return c[n]()},enumerable:!0})})),e._state=t.reactive({data:n}),e.strict&&function(e){t.watch((function(){return e._state.data}),(function(){}),{deep:!0,flush:"sync"})}(e),i&&r&&e._withCommit((function(){i.data=null}))}function m(t,e,n,r,o){var i=!n.length,a=t._modules.getNamespace(n);if(r.namespaced&&(t._modulesNamespaceMap[a],t._modulesNamespaceMap[a]=r),!i&&!o){var c=v(e,n.slice(0,-1)),s=n[n.length-1];t._withCommit((function(){c[s]=r.state}))}var u=r.context=function(t,e,n){var r=""===e,o={dispatch:r?t.dispatch:function(n,r,o){var i=g(n,r,o),a=i.payload,c=i.options,s=i.type;return c&&c.root||(s=e+s),t.dispatch(s,a)},commit:r?t.commit:function(n,r,o){var i=g(n,r,o),a=i.payload,c=i.options,s=i.type;c&&c.root||(s=e+s),t.commit(s,a,c)}};return Object.defineProperties(o,{getters:{get:r?function(){return t.getters}:function(){return function(t,e){if(!t._makeLocalGettersCache[e]){var n={},r=e.length;Object.keys(t.getters).forEach((function(o){if(o.slice(0,r)===e){var i=o.slice(r);Object.defineProperty(n,i,{get:function(){return t.getters[o]},enumerable:!0})}})),t._makeLocalGettersCache[e]=n}return t._makeLocalGettersCache[e]}(t,e)}},state:{get:function(){return v(t.state,n)}}}),o}(t,a,n);r.forEachMutation((function(e,n){!function(t,e,n,r){(t._mutations[e]||(t._mutations[e]=[])).push((function(e){n.call(t,r.state,e)}))}(t,a+n,e,u)})),r.forEachAction((function(e,n){var r=e.root?n:a+n,o=e.handler||e;!function(t,e,n,r){(t._actions[e]||(t._actions[e]=[])).push((function(e){var o,i=n.call(t,{dispatch:r.dispatch,commit:r.commit,getters:r.getters,state:r.state,rootGetters:t.getters,rootState:t.state},e);return(o=i)&&"function"==typeof o.then||(i=Promise.resolve(i)),t._devtoolHook?i.catch((function(e){throw t._devtoolHook.emit("vuex:error",e),e})):i}))}(t,r,o,u)})),r.forEachGetter((function(e,n){!function(t,e,n,r){if(t._wrappedGetters[e])return;t._wrappedGetters[e]=function(t){return n(r.state,r.getters,t.state,t.getters)}}(t,a+n,e,u)})),r.forEachChild((function(r,i){m(t,e,n.concat(i),r,o)}))}function v(t,e){return e.reduce((function(t,e){return t[e]}),t)}function g(t,e,n){return i(t)&&t.type&&(n=e,e=t,t=t.type),{type:t,payload:e,options:n}}f.prototype.install=function(t,n){t.provide(n||e,this),t.config.globalProperties.$store=this},l.state.get=function(){return this._state.data},l.state.set=function(t){},f.prototype.commit=function(t,e,n){var r=this,o=g(t,e,n),i=o.type,a=o.payload,c={type:i,payload:a},s=this._mutations[i];s&&(this._withCommit((function(){s.forEach((function(t){t(a)}))})),this._subscribers.slice().forEach((function(t){return t(c,r.state)})))},f.prototype.dispatch=function(t,e){var n=this,r=g(t,e),o=r.type,i=r.payload,a={type:o,payload:i},c=this._actions[o];if(c){try{this._actionSubscribers.slice().filter((function(t){return t.before})).forEach((function(t){return t.before(a,n.state)}))}catch(t){}var s=c.length>1?Promise.all(c.map((function(t){return t(i)}))):c[0](i);return new Promise((function(t,e){s.then((function(e){try{n._actionSubscribers.filter((function(t){return t.after})).forEach((function(t){return t.after(a,n.state)}))}catch(t){}t(e)}),(function(t){try{n._actionSubscribers.filter((function(t){return t.error})).forEach((function(e){return e.error(a,n.state,t)}))}catch(t){}e(t)}))}))}},f.prototype.subscribe=function(t,e){return h(t,this._subscribers,e)},f.prototype.subscribeAction=function(t,e){return h("function"==typeof t?{before:t}:t,this._actionSubscribers,e)},f.prototype.watch=function(e,n,r){var o=this;return t.watch((function(){return e(o.state,o.getters)}),n,Object.assign({},r))},f.prototype.replaceState=function(t){var e=this;this._withCommit((function(){e._state.data=t}))},f.prototype.registerModule=function(t,e,n){void 0===n&&(n={}),"string"==typeof t&&(t=[t]),this._modules.register(t,e),m(this,this.state,t,this._modules.get(t),n.preserveState),d(this,this.state)},f.prototype.unregisterModule=function(t){var e=this;"string"==typeof t&&(t=[t]),this._modules.unregister(t),this._withCommit((function(){delete v(e.state,t.slice(0,-1))[t[t.length-1]]})),p(this)},f.prototype.hasModule=function(t){return"string"==typeof t&&(t=[t]),this._modules.isRegistered(t)},f.prototype.hotUpdate=function(t){this._modules.update(t),p(this,!0)},f.prototype._withCommit=function(t){var e=this._committing;this._committing=!0,t(),this._committing=e},Object.defineProperties(f.prototype,l);var y=O((function(t,e){var n={};return M(e).forEach((function(e){var r=e.key,o=e.val;n[r]=function(){var e=this.$store.state,n=this.$store.getters;if(t){var r=C(this.$store,"mapState",t);if(!r)return;e=r.context.state,n=r.context.getters}return"function"==typeof o?o.call(this,e,n):e[o]},n[r].vuex=!0})),n})),_=O((function(t,e){var n={};return M(e).forEach((function(e){var r=e.key,o=e.val;n[r]=function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];var r=this.$store.commit;if(t){var i=C(this.$store,"mapMutations",t);if(!i)return;r=i.context.commit}return"function"==typeof o?o.apply(this,[r].concat(e)):r.apply(this.$store,[o].concat(e))}})),n})),b=O((function(t,e){var n={};return M(e).forEach((function(e){var r=e.key,o=e.val;o=t+o,n[r]=function(){if(!t||C(this.$store,"mapGetters",t))return this.$store.getters[o]},n[r].vuex=!0})),n})),w=O((function(t,e){var n={};return M(e).forEach((function(e){var r=e.key,o=e.val;n[r]=function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];var r=this.$store.dispatch;if(t){var i=C(this.$store,"mapActions",t);if(!i)return;r=i.context.dispatch}return"function"==typeof o?o.apply(this,[r].concat(e)):r.apply(this.$store,[o].concat(e))}})),n}));function M(t){return function(t){return Array.isArray(t)||i(t)}(t)?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 O(t){return function(e,n){return"string"!=typeof e?(n=e,e=""):"/"!==e.charAt(e.length-1)&&(e+="/"),t(e,n)}}function C(t,e,n){return t._modulesNamespaceMap[n]}function E(t,e,n){var r=n?t.groupCollapsed:t.group;try{r.call(t,e)}catch(n){t.log(e)}}function j(t){try{t.groupEnd()}catch(e){t.log("—— log end ——")}}function A(){var t=new Date;return" @ "+k(t.getHours(),2)+":"+k(t.getMinutes(),2)+":"+k(t.getSeconds(),2)+"."+k(t.getMilliseconds(),3)}function k(t,e){return n="0",r=e-t.toString().length,new Array(r+1).join(n)+t;var n,r}return{version:"4.0.0-rc.2",createStore:function(t){return new f(t)},Store:f,useStore:function(n){return void 0===n&&(n=null),t.inject(null!==n?n:e)},mapState:y,mapMutations:_,mapGetters:b,mapActions:w,createNamespacedHelpers:function(t){return{mapState:y.bind(null,t),mapGetters:b.bind(null,t),mapMutations:_.bind(null,t),mapActions:w.bind(null,t)}},createLogger:function(t){void 0===t&&(t={});var e=t.collapsed;void 0===e&&(e=!0);var n=t.filter;void 0===n&&(n=function(t,e,n){return!0});var o=t.transformer;void 0===o&&(o=function(t){return t});var i=t.mutationTransformer;void 0===i&&(i=function(t){return t});var a=t.actionFilter;void 0===a&&(a=function(t,e){return!0});var c=t.actionTransformer;void 0===c&&(c=function(t){return t});var s=t.logMutations;void 0===s&&(s=!0);var u=t.logActions;void 0===u&&(u=!0);var f=t.logger;return void 0===f&&(f=console),function(t){var l=r(t.state);void 0!==f&&(s&&t.subscribe((function(t,a){var c=r(a);if(n(t,l,c)){var s=A(),u=i(t),h="mutation "+t.type+s;E(f,h,e),f.log("%c prev state","color: #9E9E9E; font-weight: bold",o(l)),f.log("%c mutation","color: #03A9F4; font-weight: bold",u),f.log("%c next state","color: #4CAF50; font-weight: bold",o(c)),j(f)}l=c})),u&&t.subscribeAction((function(t,n){if(a(t,n)){var r=A(),o=c(t),i="action "+t.type+r;E(f,i,e),f.log("%c action","color: #03A9F4; font-weight: bold",o),j(f)}})))}}}}(Vue);
var Vuex=function(t){"use strict";var e="store";var n=("undefined"!=typeof window?window:"undefined"!=typeof global?global:{}).__VUE_DEVTOOLS_GLOBAL_HOOK__;function r(t,e){if(void 0===e&&(e=[]),null===t||"object"!=typeof t)return t;var n,o=(n=function(e){return e.original===t},e.filter(n)[0]);if(o)return o.copy;var i=Array.isArray(t)?[]:{};return e.push({original:t,copy:i}),Object.keys(t).forEach((function(n){i[n]=r(t[n],e)})),i}function o(t,e){Object.keys(t).forEach((function(n){return e(t[n],n)}))}function i(t){return null!==t&&"object"==typeof t}var a=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)||{}},c={namespaced:{configurable:!0}};c.namespaced.get=function(){return!!this._rawModule.namespaced},a.prototype.addChild=function(t,e){this._children[t]=e},a.prototype.removeChild=function(t){delete this._children[t]},a.prototype.getChild=function(t){return this._children[t]},a.prototype.hasChild=function(t){return t in this._children},a.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)},a.prototype.forEachChild=function(t){o(this._children,t)},a.prototype.forEachGetter=function(t){this._rawModule.getters&&o(this._rawModule.getters,t)},a.prototype.forEachAction=function(t){this._rawModule.actions&&o(this._rawModule.actions,t)},a.prototype.forEachMutation=function(t){this._rawModule.mutations&&o(this._rawModule.mutations,t)},Object.defineProperties(a.prototype,c);var s=function(t){this.register([],t,!1)};function u(t,e,n){if(e.update(n),n.modules)for(var r in n.modules){if(!e.getChild(r))return;u(t.concat(r),e.getChild(r),n.modules[r])}}s.prototype.get=function(t){return t.reduce((function(t,e){return t.getChild(e)}),this.root)},s.prototype.getNamespace=function(t){var e=this.root;return t.reduce((function(t,n){return t+((e=e.getChild(n)).namespaced?n+"/":"")}),"")},s.prototype.update=function(t){u([],this.root,t)},s.prototype.register=function(t,e,n){var r=this;void 0===n&&(n=!0);var i=new a(e,n);0===t.length?this.root=i:this.get(t.slice(0,-1)).addChild(t[t.length-1],i);e.modules&&o(e.modules,(function(e,o){r.register(t.concat(o),e,n)}))},s.prototype.unregister=function(t){var e=this.get(t.slice(0,-1)),n=t[t.length-1],r=e.getChild(n);r&&r.runtime&&e.removeChild(n)},s.prototype.isRegistered=function(t){var e=this.get(t.slice(0,-1)),n=t[t.length-1];return!!e&&e.hasChild(n)};var f=function(t){var e=this;void 0===t&&(t={});var r=t.plugins;void 0===r&&(r=[]);var o=t.strict;void 0===o&&(o=!1),this._committing=!1,this._actions=Object.create(null),this._actionSubscribers=[],this._mutations=Object.create(null),this._wrappedGetters=Object.create(null),this._modules=new s(t),this._modulesNamespaceMap=Object.create(null),this._subscribers=[],this._makeLocalGettersCache=Object.create(null);var i=this,a=this.dispatch,c=this.commit;this.dispatch=function(t,e){return a.call(i,t,e)},this.commit=function(t,e,n){return c.call(i,t,e,n)},this.strict=o;var u=this._modules.root.state;m(this,u,[],this._modules.root),d(this,u),r.forEach((function(t){return t(e)})),(void 0===t.devtools||t.devtools)&&function(t){n&&(t._devtoolHook=n,n.emit("vuex:init",t),n.on("vuex:travel-to-state",(function(e){t.replaceState(e)})),t.subscribe((function(t,e){n.emit("vuex:mutation",t,e)}),{prepend:!0}),t.subscribeAction((function(t,e){n.emit("vuex:action",t,e)}),{prepend:!0}))}(this)},l={state:{configurable:!0}};function h(t,e,n){return e.indexOf(t)<0&&(n&&n.prepend?e.unshift(t):e.push(t)),function(){var n=e.indexOf(t);n>-1&&e.splice(n,1)}}function p(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;m(t,n,[],t._modules.root,!0),d(t,n,e)}function d(e,n,r){var i=e._state;e.getters={},e._makeLocalGettersCache=Object.create(null);var a=e._wrappedGetters,c={};o(a,(function(t,n){c[n]=function(t,e){return function(){return t(e)}}(t,e),Object.defineProperty(e.getters,n,{get:function(){return c[n]()},enumerable:!0})})),e._state=t.reactive({data:n}),e.strict&&function(e){t.watch((function(){return e._state.data}),(function(){}),{deep:!0,flush:"sync"})}(e),i&&r&&e._withCommit((function(){i.data=null}))}function m(t,e,n,r,o){var i=!n.length,a=t._modules.getNamespace(n);if(r.namespaced&&(t._modulesNamespaceMap[a],t._modulesNamespaceMap[a]=r),!i&&!o){var c=v(e,n.slice(0,-1)),s=n[n.length-1];t._withCommit((function(){c[s]=r.state}))}var u=r.context=function(t,e,n){var r=""===e,o={dispatch:r?t.dispatch:function(n,r,o){var i=g(n,r,o),a=i.payload,c=i.options,s=i.type;return c&&c.root||(s=e+s),t.dispatch(s,a)},commit:r?t.commit:function(n,r,o){var i=g(n,r,o),a=i.payload,c=i.options,s=i.type;c&&c.root||(s=e+s),t.commit(s,a,c)}};return Object.defineProperties(o,{getters:{get:r?function(){return t.getters}:function(){return function(t,e){if(!t._makeLocalGettersCache[e]){var n={},r=e.length;Object.keys(t.getters).forEach((function(o){if(o.slice(0,r)===e){var i=o.slice(r);Object.defineProperty(n,i,{get:function(){return t.getters[o]},enumerable:!0})}})),t._makeLocalGettersCache[e]=n}return t._makeLocalGettersCache[e]}(t,e)}},state:{get:function(){return v(t.state,n)}}}),o}(t,a,n);r.forEachMutation((function(e,n){!function(t,e,n,r){(t._mutations[e]||(t._mutations[e]=[])).push((function(e){n.call(t,r.state,e)}))}(t,a+n,e,u)})),r.forEachAction((function(e,n){var r=e.root?n:a+n,o=e.handler||e;!function(t,e,n,r){(t._actions[e]||(t._actions[e]=[])).push((function(e){var o,i=n.call(t,{dispatch:r.dispatch,commit:r.commit,getters:r.getters,state:r.state,rootGetters:t.getters,rootState:t.state},e);return(o=i)&&"function"==typeof o.then||(i=Promise.resolve(i)),t._devtoolHook?i.catch((function(e){throw t._devtoolHook.emit("vuex:error",e),e})):i}))}(t,r,o,u)})),r.forEachGetter((function(e,n){!function(t,e,n,r){if(t._wrappedGetters[e])return;t._wrappedGetters[e]=function(t){return n(r.state,r.getters,t.state,t.getters)}}(t,a+n,e,u)})),r.forEachChild((function(r,i){m(t,e,n.concat(i),r,o)}))}function v(t,e){return e.reduce((function(t,e){return t[e]}),t)}function g(t,e,n){return i(t)&&t.type&&(n=e,e=t,t=t.type),{type:t,payload:e,options:n}}f.prototype.install=function(t,n){t.provide(n||e,this),t.config.globalProperties.$store=this},l.state.get=function(){return this._state.data},l.state.set=function(t){},f.prototype.commit=function(t,e,n){var r=this,o=g(t,e,n),i=o.type,a=o.payload,c={type:i,payload:a},s=this._mutations[i];s&&(this._withCommit((function(){s.forEach((function(t){t(a)}))})),this._subscribers.slice().forEach((function(t){return t(c,r.state)})))},f.prototype.dispatch=function(t,e){var n=this,r=g(t,e),o=r.type,i=r.payload,a={type:o,payload:i},c=this._actions[o];if(c){try{this._actionSubscribers.slice().filter((function(t){return t.before})).forEach((function(t){return t.before(a,n.state)}))}catch(t){}var s=c.length>1?Promise.all(c.map((function(t){return t(i)}))):c[0](i);return new Promise((function(t,e){s.then((function(e){try{n._actionSubscribers.filter((function(t){return t.after})).forEach((function(t){return t.after(a,n.state)}))}catch(t){}t(e)}),(function(t){try{n._actionSubscribers.filter((function(t){return t.error})).forEach((function(e){return e.error(a,n.state,t)}))}catch(t){}e(t)}))}))}},f.prototype.subscribe=function(t,e){return h(t,this._subscribers,e)},f.prototype.subscribeAction=function(t,e){return h("function"==typeof t?{before:t}:t,this._actionSubscribers,e)},f.prototype.watch=function(e,n,r){var o=this;return t.watch((function(){return e(o.state,o.getters)}),n,Object.assign({},r))},f.prototype.replaceState=function(t){var e=this;this._withCommit((function(){e._state.data=t}))},f.prototype.registerModule=function(t,e,n){void 0===n&&(n={}),"string"==typeof t&&(t=[t]),this._modules.register(t,e),m(this,this.state,t,this._modules.get(t),n.preserveState),d(this,this.state)},f.prototype.unregisterModule=function(t){var e=this;"string"==typeof t&&(t=[t]),this._modules.unregister(t),this._withCommit((function(){delete v(e.state,t.slice(0,-1))[t[t.length-1]]})),p(this)},f.prototype.hasModule=function(t){return"string"==typeof t&&(t=[t]),this._modules.isRegistered(t)},f.prototype.hotUpdate=function(t){this._modules.update(t),p(this,!0)},f.prototype._withCommit=function(t){var e=this._committing;this._committing=!0,t(),this._committing=e},Object.defineProperties(f.prototype,l);var y=O((function(t,e){var n={};return M(e).forEach((function(e){var r=e.key,o=e.val;n[r]=function(){var e=this.$store.state,n=this.$store.getters;if(t){var r=C(this.$store,"mapState",t);if(!r)return;e=r.context.state,n=r.context.getters}return"function"==typeof o?o.call(this,e,n):e[o]},n[r].vuex=!0})),n})),_=O((function(t,e){var n={};return M(e).forEach((function(e){var r=e.key,o=e.val;n[r]=function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];var r=this.$store.commit;if(t){var i=C(this.$store,"mapMutations",t);if(!i)return;r=i.context.commit}return"function"==typeof o?o.apply(this,[r].concat(e)):r.apply(this.$store,[o].concat(e))}})),n})),b=O((function(t,e){var n={};return M(e).forEach((function(e){var r=e.key,o=e.val;o=t+o,n[r]=function(){if(!t||C(this.$store,"mapGetters",t))return this.$store.getters[o]},n[r].vuex=!0})),n})),w=O((function(t,e){var n={};return M(e).forEach((function(e){var r=e.key,o=e.val;n[r]=function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];var r=this.$store.dispatch;if(t){var i=C(this.$store,"mapActions",t);if(!i)return;r=i.context.dispatch}return"function"==typeof o?o.apply(this,[r].concat(e)):r.apply(this.$store,[o].concat(e))}})),n}));function M(t){return function(t){return Array.isArray(t)||i(t)}(t)?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 O(t){return function(e,n){return"string"!=typeof e?(n=e,e=""):"/"!==e.charAt(e.length-1)&&(e+="/"),t(e,n)}}function C(t,e,n){return t._modulesNamespaceMap[n]}function E(t,e,n){var r=n?t.groupCollapsed:t.group;try{r.call(t,e)}catch(n){t.log(e)}}function j(t){try{t.groupEnd()}catch(e){t.log("—— log end ——")}}function A(){var t=new Date;return" @ "+k(t.getHours(),2)+":"+k(t.getMinutes(),2)+":"+k(t.getSeconds(),2)+"."+k(t.getMilliseconds(),3)}function k(t,e){return n="0",r=e-t.toString().length,new Array(r+1).join(n)+t;var n,r}return{version:"4.0.0",Store:f,storeKey:e,createStore:function(t){return new f(t)},useStore:function(n){return void 0===n&&(n=null),t.inject(null!==n?n:e)},mapState:y,mapMutations:_,mapGetters:b,mapActions:w,createNamespacedHelpers:function(t){return{mapState:y.bind(null,t),mapGetters:b.bind(null,t),mapMutations:_.bind(null,t),mapActions:w.bind(null,t)}},createLogger:function(t){void 0===t&&(t={});var e=t.collapsed;void 0===e&&(e=!0);var n=t.filter;void 0===n&&(n=function(t,e,n){return!0});var o=t.transformer;void 0===o&&(o=function(t){return t});var i=t.mutationTransformer;void 0===i&&(i=function(t){return t});var a=t.actionFilter;void 0===a&&(a=function(t,e){return!0});var c=t.actionTransformer;void 0===c&&(c=function(t){return t});var s=t.logMutations;void 0===s&&(s=!0);var u=t.logActions;void 0===u&&(u=!0);var f=t.logger;return void 0===f&&(f=console),function(t){var l=r(t.state);void 0!==f&&(s&&t.subscribe((function(t,a){var c=r(a);if(n(t,l,c)){var s=A(),u=i(t),h="mutation "+t.type+s;E(f,h,e),f.log("%c prev state","color: #9E9E9E; font-weight: bold",o(l)),f.log("%c mutation","color: #03A9F4; font-weight: bold",u),f.log("%c next state","color: #4CAF50; font-weight: bold",o(c)),j(f)}l=c})),u&&t.subscribeAction((function(t,n){if(a(t,n)){var r=A(),o=c(t),i="action "+t.type+r;E(f,i,e),f.log("%c action","color: #03A9F4; font-weight: bold",o),j(f)}})))}}}}(Vue);
{
"name": "vuex",
"version": "4.0.0-rc.2",
"version": "4.0.0",
"description": "state management for Vue.js",

@@ -8,2 +8,3 @@ "main": "dist/vuex.cjs.js",

".": {
"module": "./dist/vuex.esm-bundler.js",
"require": "./dist/vuex.cjs.js",

@@ -33,3 +34,3 @@ "import": "./dist/vuex.mjs"

"test:unit": "jest --testPathIgnorePatterns test/e2e",
"test:e2e": "start-server-and-test dev http://localhost:8080 'jest --testPathIgnorePatterns test/unit'",
"test:e2e": "start-server-and-test dev http://localhost:8080 \"jest --testPathIgnorePatterns test/unit\"",
"test:ssr": "cross-env VUE_ENV=server jest --testPathIgnorePatterns test/e2e",

@@ -59,16 +60,16 @@ "test:types": "tsc -p types/test",

"devDependencies": {
"@babel/core": "^7.9.6",
"@babel/preset-env": "^7.9.6",
"@babel/core": "^7.12.10",
"@babel/preset-env": "^7.12.11",
"@rollup/plugin-buble": "^0.21.3",
"@rollup/plugin-commonjs": "^16.0.0",
"@rollup/plugin-node-resolve": "^10.0.0",
"@rollup/plugin-commonjs": "^17.1.0",
"@rollup/plugin-node-resolve": "^11.1.1",
"@rollup/plugin-replace": "^2.3.2",
"@types/node": "^14.14.6",
"@vue/compiler-sfc": "^3.0.2",
"babel-jest": "^26.0.1",
"babel-loader": "^8.1.0",
"@types/node": "^14.14.22",
"@vue/compiler-sfc": "^3.0.5",
"babel-jest": "^26.6.3",
"babel-loader": "^8.2.2",
"brotli": "^1.3.2",
"chalk": "^4.0.0",
"conventional-changelog-cli": "^2.0.31",
"cross-env": "^7.0.2",
"conventional-changelog-cli": "^2.1.1",
"cross-env": "^7.0.3",
"css-loader": "^2.1.0",

@@ -78,17 +79,17 @@ "enquirer": "^2.3.5",

"eslint-plugin-vue-libs": "^4.0.0",
"execa": "^4.0.0",
"execa": "^5.0.0",
"express": "^4.17.1",
"fs-extra": "^9.0.1",
"jest": "^26.0.1",
"puppeteer": "^5.4.1",
"fs-extra": "^9.1.0",
"jest": "^26.6.3",
"puppeteer": "^5.5.0",
"regenerator-runtime": "^0.13.5",
"rollup": "^2.33.0",
"rollup": "^2.38.4",
"rollup-plugin-terser": "^7.0.2",
"semver": "^7.3.2",
"start-server-and-test": "^1.11.0",
"todomvc-app-css": "2.1.0",
"typescript": "^4.0.5",
"vitepress": "^0.9.0",
"vue": "^3.0.2",
"vue-loader": "^16.0.0-beta.1",
"semver": "^7.3.4",
"start-server-and-test": "^1.12.0",
"todomvc-app-css": "^2.3.0",
"typescript": "^4.1.3",
"vitepress": "^0.11.5",
"vue": "^3.0.5",
"vue-loader": "^16.1.2",
"vue-style-loader": "^4.1.2",

@@ -95,0 +96,0 @@ "webpack": "^4.43.0",

@@ -46,2 +46,4 @@ import { App, WatchOptions, InjectionKey } from "vue";

export const storeKey: string;
export function createStore<S>(options: StoreOptions<S>): Store<S>;

@@ -48,0 +50,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc