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

pinia

Package Overview
Dependencies
Maintainers
1
Versions
119
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pinia - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

16

CHANGELOG.md

@@ -0,1 +1,13 @@

## [2.0.1](https://github.com/posva/pinia/compare/pinia@2.0.0...pinia@2.0.1) (2021-11-03)
This release correctly removes the deprecated APIs as advertised in v2. The [documentation](https://pinia.esm.dev/cookbook/migration-v1-v2.html) contains a list of all the deprecations compared to v0.x.
### Bug Fixes
- use assign instead of spread for older browsers ([51cf9b6](https://github.com/posva/pinia/commit/51cf9b6e5a61d668a5e27b5e02833607ad0b5907))
### Features
- **warn:** improve getActivePinia warn ([6a0a209](https://github.com/posva/pinia/commit/6a0a209faf42b149bcda1dd373e0b1e5bf426ce4))
# [2.0.0](https://github.com/posva/pinia/compare/pinia@2.0.0-rc.15...pinia@2.0.0) (2021-10-27)

@@ -11,2 +23,6 @@

### BREAKING CHANGES
All deprecated API have been removed.
# [2.0.0-rc.15](https://github.com/posva/pinia/compare/pinia@2.0.0-rc.14...pinia@2.0.0-rc.15) (2021-10-25)

@@ -13,0 +29,0 @@

57

dist/pinia.d.ts

@@ -151,8 +151,2 @@ import { App } from 'vue-demi';

actions: A;
/**
* Id of the store. Only available when the options API is used.
*
* @deprecated Use `store.$id` instead.
*/
id?: Id;
}

@@ -182,10 +176,2 @@

/**
* Generic and type-unsafe version of Store. Doesn't fail on access with
* strings, making it much easier to write generic functions that do not care
* about the kind of store that is passed.
* @deprecated Use `StoreGeneric` instead
*/
export declare type GenericStore<Id extends string = string, S extends StateTree = StateTree, G = _GettersTree<S>, A = _ActionsTree> = _StoreWithState<Id, S, G, A> & UnwrapRef<S> & _StoreWithGetters<G> & A & PiniaCustomProperties<Id, S, G, A> & PiniaCustomStateProperties<S>;
/**
* Get the currently active pinia if there is any.

@@ -516,7 +502,13 @@ */

/**
* @deprecated use `PiniaVuePlugin` instead.
* Plugin to extend every store.
*/
export declare const PiniaPlugin: ((app: App<any>, ...options: any[]) => any) & {
install?: ((app: App<any>, ...options: any[]) => any) | undefined;
};
export declare interface PiniaPlugin {
/**
* Plugin to extend every store. Returns an object to extend the store or
* nothing.
*
* @param context - Context
*/
(context: PiniaPluginContext): Partial<PiniaCustomProperties & PiniaCustomStateProperties> | void;
}

@@ -546,13 +538,6 @@ /**

/**
* Plugin to extend every store
* Plugin to extend every store.
* @deprecated use PiniaPlugin instead
*/
export declare interface PiniaStorePlugin {
/**
* Plugin to extend every store. Returns an object to extend the store or
* nothing.
*
* @param context - Context
*/
(context: PiniaPluginContext): Partial<PiniaCustomProperties & PiniaCustomStateProperties> | void;
}
export declare type PiniaStorePlugin = PiniaPlugin;

@@ -838,18 +823,2 @@ /**

/**
* Setups a callback to be called whenever the state changes. It also returns
* a function to remove the callback. Note than when calling
* `store.$subscribe()` inside of a component, it will be automatically
* cleanup up when the component gets unmounted unless `detached` is set to
* true.
*
* @deprecated use `store.$subscribe(fn, { detached: true })` instead.
*
* @param callback - callback passed to the watcher
* @param detached - detach the subscription from the context this is called
* from
* @returns function that removes the watcher
*/
$subscribe(callback: SubscriptionCallback<S>, detached?: boolean): () => void;
/**
* @alpha Please send feedback at https://github.com/posva/pinia/issues/240
* Setups a callback to be called every time an action is about to get

@@ -856,0 +825,0 @@ * invoked. The callback receives an object with all the relevant information

/*!
* pinia v2.0.0
* pinia v2.0.1
* (c) 2021 Eduardo San Martin Morote
* @license MIT
*/
var Pinia=function(t,e){"use strict";let n;const i=t=>n=t,s=Symbol();function r(t){return t&&"object"==typeof t&&"[object Object]"===Object.prototype.toString.call(t)&&"function"!=typeof t.toJSON}var o;t.MutationType=void 0,(o=t.MutationType||(t.MutationType={})).direct="direct",o.patchObject="patch object",o.patchFunction="patch function";const a="undefined"!=typeof window;function c(t,n,i){t.push(n);const s=()=>{const e=t.indexOf(n);e>-1&&t.splice(e,1)};return!i&&e.getCurrentInstance()&&e.onUnmounted(s),s}function u(t,...e){t.forEach((t=>{t(...e)}))}function f(t,n){for(const i in n){const s=n[i],o=t[i];t[i]=r(o)&&r(s)&&!e.isRef(s)&&!e.isReactive(s)?f(o,s):s}return t}const p=Symbol(),d=new WeakMap;const{assign:h}=Object;const l=()=>{};function y(n,s,o={},a,y){let v;const $=o.state,_={actions:{},...o},b={deep:!0};let g,j,m=e.markRaw([]),O=e.markRaw([]);const R=a.state.value[n];function P(e){let i;g=!1,"function"==typeof e?(e(a.state.value[n]),i={type:t.MutationType.patchFunction,storeId:n,events:j}):(f(a.state.value[n],e),i={type:t.MutationType.patchObject,payload:e,storeId:n,events:j}),g=!0,u(m,i,a.state.value[n])}$||R||(e.isVue2?e.set(a.state.value,n,{}):a.state.value[n]={}),e.ref({});const S=l;function V(t,e){return function(){i(a);const s=Array.from(arguments);let r,o=l,c=l;function f(t){o=t}function p(t){c=t}u(O,{args:s,name:t,store:k,after:f,onError:p});try{r=e.apply(this&&this.$id===n?this:k,s)}catch(t){if(!1!==c(t))throw t}if(r instanceof Promise)return r.then((t=>{const e=o(t);return void 0===e?t:e})).catch((t=>{if(!1!==c(t))return Promise.reject(t)}));const d=o(r);return void 0===d?r:d}}const w={_p:a,$id:n,$onAction:c.bind(null,O),$patch:P,$reset:S,$subscribe(i,s={}){const r=c(m,i,s.detached),o=v.run((()=>e.watch((()=>a.state.value[n]),((e,s)=>{g&&i({storeId:n,type:t.MutationType.direct,events:j},e)}),h({},b,s))));return()=>{o(),r()}},$dispose:function(){v.stop(),m=[],O=[],a._s.delete(n)}};e.isVue2&&(w._r=!1);const k=e.reactive(h({},w));a._s.set(n,k);const A=a._e.run((()=>(v=e.effectScope(),v.run((()=>s())))));for(const t in A){const i=A[t];if(e.isRef(i)&&(!e.isRef(T=i)||!T.effect)||e.isReactive(i))$||(R&&(M=i,e.isVue2?d.has(M):!r(M)||!M.hasOwnProperty(p))&&(e.isRef(i)?i.value=R[t]:f(i,R[t])),e.isVue2?e.set(a.state.value[n],t,i):a.state.value[n][t]=i);else if("function"==typeof i){const n=V(t,i);e.isVue2?e.set(A,t,n):A[t]=n,_.actions[t]=i}}var M,T;return e.isVue2?Object.keys(A).forEach((t=>{e.set(k,t,A[t])})):h(k,A),Object.defineProperty(k,"$state",{get:()=>a.state.value[n],set:t=>{P((e=>{h(e,t)}))}}),e.isVue2&&(k._r=!0),a._p.forEach((t=>{h(k,v.run((()=>t({store:k,app:a._a,pinia:a,options:_}))))})),R&&$&&o.hydrate&&o.hydrate(k.$state,R),g=!0,k}let v="Store";function $(t,e){return Array.isArray(e)?e.reduce(((e,n)=>(e[n]=function(){return t(this.$pinia)[n]},e)),{}):Object.keys(e).reduce(((n,i)=>(n[i]=function(){const n=t(this.$pinia),s=e[i];return"function"==typeof s?s.call(this,n):n[s]},n)),{})}const _=$;const b=function(t){t.mixin({beforeCreate(){const t=this.$options;if(t.pinia){const e=t.pinia;if(!this._provided){const t={};Object.defineProperty(this,"_provided",{get:()=>t,set:e=>Object.assign(t,e)})}this._provided[s]=e,this.$pinia||(this.$pinia=e),e._a=this,a&&i(e)}else!this.$pinia&&t.parent&&t.parent.$pinia&&(this.$pinia=t.parent.$pinia)},destroyed(){delete this._pStores}})};return t.PiniaPlugin=b,t.PiniaVuePlugin=b,t.acceptHMRUpdate=function(t,e){return n=>{const i=e.data.pinia||t._pinia;if(i){e.data.pinia=i;for(const r in n){const o=n[r];if("function"==typeof(s=o)&&"string"==typeof s.$id&&i._s.has(o.$id)){const n=o.$id;if(n!==t.$id)return console.warn(`The id of the store changed from "${t.$id}" to "${n}". Reloading.`),e.invalidate();const s=i._s.get(n);if(!s)return void console.log("skipping hmr because store doesn't exist yet");o(i,s)}}var s}}},t.createPinia=function(){const t=e.effectScope(!0),n=t.run((()=>e.ref({})));let r=[],o=[];const a=e.markRaw({install(t){i(a),e.isVue2||(a._a=t,t.provide(s,a),t.config.globalProperties.$pinia=a,o.forEach((t=>r.push(t))),o=[])},use(t){return this._a||e.isVue2?r.push(t):o.push(t),this},_p:r,_a:null,_e:t,_s:new Map,state:n});return a},t.defineStore=function(t,r,o){let a,c;const u="function"==typeof r;function f(t,o){const f=e.getCurrentInstance();(t=t||f&&e.inject(s))&&i(t),(t=n)._s.has(a)||(u?y(a,r,c,t):function(t,n,s,r){const{state:o,actions:a,getters:c}=n,u=s.state.value[t];let f;f=y(t,(function(){u||(e.isVue2?e.set(s.state.value,t,o?o():{}):s.state.value[t]=o?o():{});const n=e.toRefs(s.state.value[t]);return h(n,a,Object.keys(c||{}).reduce(((n,r)=>(n[r]=e.markRaw(e.computed((()=>{i(s);const n=s._s.get(t);if(!e.isVue2||n._r)return c[r].call(n,n)}))),n)),{}))}),n,s),f.$reset=function(){const t=o?o():{};this.$patch((e=>{h(e,t)}))}}(a,c,t));return t._s.get(a)}return"string"==typeof t?(a=t,c=u?o:r):(c=t,a=t.id),f.$id=a,f},t.getActivePinia=()=>e.getCurrentInstance()&&e.inject(s)||n,t.mapActions=function(t,e){return Array.isArray(e)?e.reduce(((e,n)=>(e[n]=function(...e){return t(this.$pinia)[n](...e)},e)),{}):Object.keys(e).reduce(((n,i)=>(n[i]=function(...n){return t(this.$pinia)[e[i]](...n)},n)),{})},t.mapGetters=_,t.mapState=$,t.mapStores=function(...t){return t.reduce(((t,e)=>(t[e.$id+v]=function(){return e(this.$pinia)},t)),{})},t.mapWritableState=function(t,e){return Array.isArray(e)?e.reduce(((e,n)=>(e[n]={get(){return t(this.$pinia)[n]},set(e){return t(this.$pinia)[n]=e}},e)),{}):Object.keys(e).reduce(((n,i)=>(n[i]={get(){return t(this.$pinia)[e[i]]},set(n){return t(this.$pinia)[e[i]]=n}},n)),{})},t.setActivePinia=i,t.setMapStoreSuffix=function(t){v=t},t.skipHydrate=function(t){return e.isVue2?d.set(t,1)&&t:Object.defineProperty(t,p,{})},t.storeToRefs=function(t){t=e.toRaw(t);const n={};for(const i in t){const s=t[i];(e.isRef(s)||e.isReactive(s))&&(n[i]=e.toRef(t,i))}return n},Object.defineProperty(t,"__esModule",{value:!0}),t}({},VueDemi);
var Pinia=function(t,e){"use strict";let n;const i=t=>n=t,s=Symbol();function r(t){return t&&"object"==typeof t&&"[object Object]"===Object.prototype.toString.call(t)&&"function"!=typeof t.toJSON}var o;t.MutationType=void 0,(o=t.MutationType||(t.MutationType={})).direct="direct",o.patchObject="patch object",o.patchFunction="patch function";const a="undefined"!=typeof window;function c(t,n,i){t.push(n);const s=()=>{const e=t.indexOf(n);e>-1&&t.splice(e,1)};return!i&&e.getCurrentInstance()&&e.onUnmounted(s),s}function u(t,...e){t.forEach((t=>{t(...e)}))}function f(t,n){for(const i in n){const s=n[i],o=t[i];t[i]=r(o)&&r(s)&&!e.isRef(s)&&!e.isReactive(s)?f(o,s):s}return t}const p=Symbol(),d=new WeakMap;const{assign:h}=Object;const l=()=>{};function y(n,s,o={},a,y){let v;const $=o.state,_=h({actions:{}},o),b={deep:!0};let g,j,m=e.markRaw([]),O=e.markRaw([]);const R=a.state.value[n];function P(e){let i;g=!1,"function"==typeof e?(e(a.state.value[n]),i={type:t.MutationType.patchFunction,storeId:n,events:j}):(f(a.state.value[n],e),i={type:t.MutationType.patchObject,payload:e,storeId:n,events:j}),g=!0,u(m,i,a.state.value[n])}$||R||(e.isVue2?e.set(a.state.value,n,{}):a.state.value[n]={}),e.ref({});const S=l;function V(t,e){return function(){i(a);const s=Array.from(arguments);let r,o=l,c=l;function f(t){o=t}function p(t){c=t}u(O,{args:s,name:t,store:k,after:f,onError:p});try{r=e.apply(this&&this.$id===n?this:k,s)}catch(t){if(!1!==c(t))throw t}if(r instanceof Promise)return r.then((t=>{const e=o(t);return void 0===e?t:e})).catch((t=>{if(!1!==c(t))return Promise.reject(t)}));const d=o(r);return void 0===d?r:d}}const w={_p:a,$id:n,$onAction:c.bind(null,O),$patch:P,$reset:S,$subscribe(i,s={}){const r=c(m,i,s.detached),o=v.run((()=>e.watch((()=>a.state.value[n]),(e=>{g&&i({storeId:n,type:t.MutationType.direct,events:j},e)}),h({},b,s))));return()=>{o(),r()}},$dispose:function(){v.stop(),m=[],O=[],a._s.delete(n)}};e.isVue2&&(w._r=!1);const k=e.reactive(h({},w));a._s.set(n,k);const A=a._e.run((()=>(v=e.effectScope(),v.run((()=>s())))));for(const t in A){const i=A[t];if(e.isRef(i)&&(!e.isRef(T=i)||!T.effect)||e.isReactive(i))$||(R&&(M=i,e.isVue2?d.has(M):!r(M)||!M.hasOwnProperty(p))&&(e.isRef(i)?i.value=R[t]:f(i,R[t])),e.isVue2?e.set(a.state.value[n],t,i):a.state.value[n][t]=i);else if("function"==typeof i){const n=V(t,i);e.isVue2?e.set(A,t,n):A[t]=n,_.actions[t]=i}}var M,T;return e.isVue2?Object.keys(A).forEach((t=>{e.set(k,t,A[t])})):h(k,A),Object.defineProperty(k,"$state",{get:()=>a.state.value[n],set:t=>{P((e=>{h(e,t)}))}}),e.isVue2&&(k._r=!0),a._p.forEach((t=>{h(k,v.run((()=>t({store:k,app:a._a,pinia:a,options:_}))))})),R&&$&&o.hydrate&&o.hydrate(k.$state,R),g=!0,k}let v="Store";function $(t,e){return Array.isArray(e)?e.reduce(((e,n)=>(e[n]=function(){return t(this.$pinia)[n]},e)),{}):Object.keys(e).reduce(((n,i)=>(n[i]=function(){const n=t(this.$pinia),s=e[i];return"function"==typeof s?s.call(this,n):n[s]},n)),{})}const _=$;return t.PiniaVuePlugin=function(t){t.mixin({beforeCreate(){const t=this.$options;if(t.pinia){const e=t.pinia;if(!this._provided){const t={};Object.defineProperty(this,"_provided",{get:()=>t,set:e=>Object.assign(t,e)})}this._provided[s]=e,this.$pinia||(this.$pinia=e),e._a=this,a&&i(e)}else!this.$pinia&&t.parent&&t.parent.$pinia&&(this.$pinia=t.parent.$pinia)},destroyed(){delete this._pStores}})},t.acceptHMRUpdate=function(t,e){return n=>{const i=e.data.pinia||t._pinia;if(i){e.data.pinia=i;for(const r in n){const o=n[r];if("function"==typeof(s=o)&&"string"==typeof s.$id&&i._s.has(o.$id)){const n=o.$id;if(n!==t.$id)return console.warn(`The id of the store changed from "${t.$id}" to "${n}". Reloading.`),e.invalidate();const s=i._s.get(n);if(!s)return void console.log("skipping hmr because store doesn't exist yet");o(i,s)}}var s}}},t.createPinia=function(){const t=e.effectScope(!0),n=t.run((()=>e.ref({})));let r=[],o=[];const a=e.markRaw({install(t){i(a),e.isVue2||(a._a=t,t.provide(s,a),t.config.globalProperties.$pinia=a,o.forEach((t=>r.push(t))),o=[])},use(t){return this._a||e.isVue2?r.push(t):o.push(t),this},_p:r,_a:null,_e:t,_s:new Map,state:n});return a},t.defineStore=function(t,r,o){let a,c;const u="function"==typeof r;function f(t,o){const f=e.getCurrentInstance();(t=t||f&&e.inject(s))&&i(t),(t=n)._s.has(a)||(u?y(a,r,c,t):function(t,n,s,r){const{state:o,actions:a,getters:c}=n,u=s.state.value[t];let f;f=y(t,(function(){u||(e.isVue2?e.set(s.state.value,t,o?o():{}):s.state.value[t]=o?o():{});const n=e.toRefs(s.state.value[t]);return h(n,a,Object.keys(c||{}).reduce(((n,r)=>(n[r]=e.markRaw(e.computed((()=>{i(s);const n=s._s.get(t);if(!e.isVue2||n._r)return c[r].call(n,n)}))),n)),{}))}),n,s),f.$reset=function(){const t=o?o():{};this.$patch((e=>{h(e,t)}))}}(a,c,t));return t._s.get(a)}return"string"==typeof t?(a=t,c=u?o:r):(c=t,a=t.id),f.$id=a,f},t.getActivePinia=()=>e.getCurrentInstance()&&e.inject(s)||n,t.mapActions=function(t,e){return Array.isArray(e)?e.reduce(((e,n)=>(e[n]=function(...e){return t(this.$pinia)[n](...e)},e)),{}):Object.keys(e).reduce(((n,i)=>(n[i]=function(...n){return t(this.$pinia)[e[i]](...n)},n)),{})},t.mapGetters=_,t.mapState=$,t.mapStores=function(...t){return t.reduce(((t,e)=>(t[e.$id+v]=function(){return e(this.$pinia)},t)),{})},t.mapWritableState=function(t,e){return Array.isArray(e)?e.reduce(((e,n)=>(e[n]={get(){return t(this.$pinia)[n]},set(e){return t(this.$pinia)[n]=e}},e)),{}):Object.keys(e).reduce(((n,i)=>(n[i]={get(){return t(this.$pinia)[e[i]]},set(n){return t(this.$pinia)[e[i]]=n}},n)),{})},t.setActivePinia=i,t.setMapStoreSuffix=function(t){v=t},t.skipHydrate=function(t){return e.isVue2?d.set(t,1)&&t:Object.defineProperty(t,p,{})},t.storeToRefs=function(t){t=e.toRaw(t);const n={};for(const i in t){const s=t[i];(e.isRef(s)||e.isReactive(s))&&(n[i]=e.toRef(t,i))}return n},Object.defineProperty(t,"__esModule",{value:!0}),t}({},VueDemi);
{
"name": "pinia",
"version": "2.0.0",
"version": "2.0.1",
"description": "Intuitive, type safe and flexible Store for Vue",

@@ -71,3 +71,3 @@ "main": "index.js",

"devDependencies": {
"@microsoft/api-extractor": "7.18.16",
"@microsoft/api-extractor": "7.18.17",
"@vue/compiler-sfc": "^3.2.20",

@@ -84,3 +84,3 @@ "@vue/server-renderer": "^3.2.20",

"peerDependencies": {
"@vue/composition-api": "^1.2.4",
"@vue/composition-api": "^1.3.0",
"typescript": "^4.4.4",

@@ -87,0 +87,0 @@ "vue": "^2.6.14 || ^3.2.0"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

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