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.2.4 to 2.2.5

10

dist/pinia.d.ts

@@ -637,2 +637,10 @@ import { App } from 'vue-demi';

/**
* Returns whether a value should be hydrated
*
* @param obj - target variable
* @returns true if `obj` should be hydrated
*/
export declare function shouldHydrate(obj: any): boolean;
/**
* Tells Pinia to skip the hydration process of a given object. This is useful in setup stores (only) when you return a

@@ -780,3 +788,3 @@ * stateful object in the store but it isn't really state. e.g. returning a router instance in a setup store.

*/
declare type StoreToRefs<SS extends StoreGeneric> = _ToStateRefs<SS> & ToRefs<PiniaCustomStateProperties<StoreState<SS>>> & _ToComputedRefs<StoreGetters<SS>>;
declare type StoreToRefs<SS extends StoreGeneric> = SS extends unknown ? _ToStateRefs<SS> & ToRefs<PiniaCustomStateProperties<StoreState<SS>>> & _ToComputedRefs<StoreGetters<SS>> : never;

@@ -783,0 +791,0 @@ /**

5

dist/pinia.iife.prod.js
/*!
* pinia v2.2.4
* pinia v2.2.5
* (c) 2024 Eduardo San Martin Morote
* @license MIT
*/
var Pinia=function(t,e){"use strict";let n;const i=t=>n=t,s=Symbol();function o(t){return t&&"object"==typeof t&&"[object Object]"===Object.prototype.toString.call(t)&&"function"!=typeof t.toJSON}var r;t.MutationType=void 0,(r=t.MutationType||(t.MutationType={})).direct="direct",r.patchObject="patch object",r.patchFunction="patch function";const c="undefined"!=typeof window;const a=()=>{};function u(t,n,i,s=a){t.push(n);const o=()=>{const e=t.indexOf(n);e>-1&&(t.splice(e,1),s())};return!i&&e.getCurrentScope()&&e.onScopeDispose(o),o}function p(t,...e){t.slice().forEach((t=>{t(...e)}))}const f=t=>t(),h=Symbol(),l=Symbol();function d(t,n){t instanceof Map&&n instanceof Map?n.forEach(((e,n)=>t.set(n,e))):t instanceof Set&&n instanceof Set&&n.forEach(t.add,t);for(const i in n){if(!n.hasOwnProperty(i))continue;const s=n[i],r=t[i];t[i]=o(r)&&o(s)&&t.hasOwnProperty(i)&&!e.isRef(s)&&!e.isReactive(s)?d(r,s):s}return t}const y=Symbol(),v=new WeakMap;const{assign:$}=Object;function _(n,s,r={},c,_,b){let j;const S=$({actions:{}},r),m={deep:!0};let O,g,R,P=[],V=[];const w=c.state.value[n];let M;function A(i){let s;O=g=!1,"function"==typeof i?(i(c.state.value[n]),s={type:t.MutationType.patchFunction,storeId:n,events:R}):(d(c.state.value[n],i),s={type:t.MutationType.patchObject,payload:i,storeId:n,events:R});const o=M=Symbol();e.nextTick().then((()=>{M===o&&(O=!0)})),g=!0,p(P,s,c.state.value[n])}b||w||(e.isVue2?e.set(c.state.value,n,{}):c.state.value[n]={}),e.ref({});const k=b?function(){const{state:t}=r,e=t?t():{};this.$patch((t=>{$(t,e)}))}:a;const T=(t,e="")=>{if(h in t)return t[l]=e,t;const s=function(){i(c);const e=Array.from(arguments),o=[],r=[];let a;p(V,{args:e,name:s[l],store:E,after:function(t){o.push(t)},onError:function(t){r.push(t)}});try{a=t.apply(this&&this.$id===n?this:E,e)}catch(t){throw p(r,t),t}return a instanceof Promise?a.then((t=>(p(o,t),t))).catch((t=>(p(r,t),Promise.reject(t)))):(p(o,a),a)};return s[h]=!0,s[l]=e,s},x={_p:c,$id:n,$onAction:u.bind(null,V),$patch:A,$reset:k,$subscribe(i,s={}){const o=u(P,i,s.detached,(()=>r())),r=j.run((()=>e.watch((()=>c.state.value[n]),(e=>{("sync"===s.flush?g:O)&&i({storeId:n,type:t.MutationType.direct,events:R},e)}),$({},m,s))));return o},$dispose:function(){j.stop(),P=[],V=[],c._s.delete(n)}};e.isVue2&&(x._r=!1);const E=e.reactive(x);c._s.set(n,E);const C=(c._a&&c._a.runWithContext||f)((()=>c._e.run((()=>(j=e.effectScope()).run((()=>s({action:T})))))));for(const t in C){const i=C[t];if(e.isRef(i)&&(!e.isRef(W=i)||!W.effect)||e.isReactive(i))b||(!w||(I=i,e.isVue2?v.has(I):o(I)&&I.hasOwnProperty(y))||(e.isRef(i)?i.value=w[t]:d(i,w[t])),e.isVue2?e.set(c.state.value[n],t,i):c.state.value[n][t]=i);else if("function"==typeof i){const n=T(i,t);e.isVue2?e.set(C,t,n):C[t]=n,S.actions[t]=i}}var I,W;return e.isVue2?Object.keys(C).forEach((t=>{e.set(E,t,C[t])})):($(E,C),$(e.toRaw(E),C)),Object.defineProperty(E,"$state",{get:()=>c.state.value[n],set:t=>{A((e=>{$(e,t)}))}}),e.isVue2&&(E._r=!0),c._p.forEach((t=>{$(E,j.run((()=>t({store:E,app:c._a,pinia:c,options:S}))))})),w&&b&&r.hydrate&&r.hydrate(E.$state,w),O=!0,g=!0,E}let b="Store";function j(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 S=j;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,c&&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()=>{}},t.createPinia=function(){const t=e.effectScope(!0),n=t.run((()=>e.ref({})));let o=[],r=[];const c=e.markRaw({install(t){i(c),e.isVue2||(c._a=t,t.provide(s,c),t.config.globalProperties.$pinia=c,r.forEach((t=>o.push(t))),r=[])},use(t){return this._a||e.isVue2?o.push(t):r.push(t),this},_p:o,_a:null,_e:t,_s:new Map,state:n});return c},t.defineStore=function(t,o,r){let c,a;const u="function"==typeof o;function p(t,r){const p=e.hasInjectionContext();(t=t||(p?e.inject(s,null):null))&&i(t),(t=n)._s.has(c)||(u?_(c,o,a,t):function(t,n,s){const{state:o,actions:r,getters:c}=n,a=s.state.value[t];let u;u=_(t,(function(){a||(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 $(n,r,Object.keys(c||{}).reduce(((n,o)=>(n[o]=e.markRaw(e.computed((()=>{i(s);const n=s._s.get(t);if(!e.isVue2||n._r)return c[o].call(n,n)}))),n)),{}))}),n,s,0,!0)}(c,a,t));return t._s.get(c)}return"string"==typeof t?(c=t,a=u?r:o):(a=t,c=t.id),p.$id=c,p},t.disposePinia=function(t){t._e.stop(),t._s.clear(),t._p.splice(0),t.state.value={},t._a=null},t.getActivePinia=()=>e.hasInjectionContext()&&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=S,t.mapState=j,t.mapStores=function(...t){return t.reduce(((t,e)=>(t[e.$id+b]=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){b=t},t.skipHydrate=function(t){return e.isVue2?v.set(t,1)&&t:Object.defineProperty(t,y,{})},t.storeToRefs=function(t){if(e.isVue2)return e.toRefs(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}},t}({},VueDemi);
var Pinia=function(t,e){"use strict";let n;const i=t=>n=t,s=Symbol();function o(t){return t&&"object"==typeof t&&"[object Object]"===Object.prototype.toString.call(t)&&"function"!=typeof t.toJSON}var r;t.MutationType=void 0,(r=t.MutationType||(t.MutationType={})).direct="direct",r.patchObject="patch object",r.patchFunction="patch function";const c="undefined"!=typeof window;const a=()=>{};function u(t,n,i,s=a){t.push(n);const o=()=>{const e=t.indexOf(n);e>-1&&(t.splice(e,1),s())};return!i&&e.getCurrentScope()&&e.onScopeDispose(o),o}function p(t,...e){t.slice().forEach((t=>{t(...e)}))}const f=t=>t(),h=Symbol(),l=Symbol();function d(t,n){t instanceof Map&&n instanceof Map?n.forEach(((e,n)=>t.set(n,e))):t instanceof Set&&n instanceof Set&&n.forEach(t.add,t);for(const i in n){if(!n.hasOwnProperty(i))continue;const s=n[i],r=t[i];t[i]=o(r)&&o(s)&&t.hasOwnProperty(i)&&!e.isRef(s)&&!e.isReactive(s)?d(r,s):s}return t}const y=Symbol(),v=new WeakMap;function $(t){return e.isVue2?!v.has(t):!o(t)||!t.hasOwnProperty(y)}const{assign:_}=Object;function b(n,s,o={},r,c,y){let v;const b=_({actions:{}},o),j={deep:!0};let S,m,O,g=[],R=[];const P=r.state.value[n];let V;function w(i){let s;S=m=!1,"function"==typeof i?(i(r.state.value[n]),s={type:t.MutationType.patchFunction,storeId:n,events:O}):(d(r.state.value[n],i),s={type:t.MutationType.patchObject,payload:i,storeId:n,events:O});const o=V=Symbol();e.nextTick().then((()=>{V===o&&(S=!0)})),m=!0,p(g,s,r.state.value[n])}y||P||(e.isVue2?e.set(r.state.value,n,{}):r.state.value[n]={}),e.ref({});const M=y?function(){const{state:t}=o,e=t?t():{};this.$patch((t=>{_(t,e)}))}:a;const A=(t,e="")=>{if(h in t)return t[l]=e,t;const s=function(){i(r);const e=Array.from(arguments),o=[],c=[];let a;p(R,{args:e,name:s[l],store:T,after:function(t){o.push(t)},onError:function(t){c.push(t)}});try{a=t.apply(this&&this.$id===n?this:T,e)}catch(t){throw p(c,t),t}return a instanceof Promise?a.then((t=>(p(o,t),t))).catch((t=>(p(c,t),Promise.reject(t)))):(p(o,a),a)};return s[h]=!0,s[l]=e,s},k={_p:r,$id:n,$onAction:u.bind(null,R),$patch:w,$reset:M,$subscribe(i,s={}){const o=u(g,i,s.detached,(()=>c())),c=v.run((()=>e.watch((()=>r.state.value[n]),(e=>{("sync"===s.flush?m:S)&&i({storeId:n,type:t.MutationType.direct,events:O},e)}),_({},j,s))));return o},$dispose:function(){v.stop(),g=[],R=[],r._s.delete(n)}};e.isVue2&&(k._r=!1);const T=e.reactive(k);r._s.set(n,T);const x=(r._a&&r._a.runWithContext||f)((()=>r._e.run((()=>(v=e.effectScope()).run((()=>s({action:A})))))));for(const t in x){const i=x[t];if(e.isRef(i)&&(!e.isRef(E=i)||!E.effect)||e.isReactive(i))y||(P&&$(i)&&(e.isRef(i)?i.value=P[t]:d(i,P[t])),e.isVue2?e.set(r.state.value[n],t,i):r.state.value[n][t]=i);else if("function"==typeof i){const n=A(i,t);e.isVue2?e.set(x,t,n):x[t]=n,b.actions[t]=i}}var E;return e.isVue2?Object.keys(x).forEach((t=>{e.set(T,t,x[t])})):(_(T,x),_(e.toRaw(T),x)),Object.defineProperty(T,"$state",{get:()=>r.state.value[n],set:t=>{w((e=>{_(e,t)}))}}),e.isVue2&&(T._r=!0),r._p.forEach((t=>{_(T,v.run((()=>t({store:T,app:r._a,pinia:r,options:b}))))})),P&&y&&o.hydrate&&o.hydrate(T.$state,P),S=!0,m=!0,T}
/*! #__NO_SIDE_EFFECTS__ */let j="Store";function S(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 m=S;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,c&&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()=>{}},t.createPinia=function(){const t=e.effectScope(!0),n=t.run((()=>e.ref({})));let o=[],r=[];const c=e.markRaw({install(t){i(c),e.isVue2||(c._a=t,t.provide(s,c),t.config.globalProperties.$pinia=c,r.forEach((t=>o.push(t))),r=[])},use(t){return this._a||e.isVue2?o.push(t):r.push(t),this},_p:o,_a:null,_e:t,_s:new Map,state:n});return c},t.defineStore=function(t,o,r){let c,a;const u="function"==typeof o;function p(t,r){const p=e.hasInjectionContext();(t=t||(p?e.inject(s,null):null))&&i(t),(t=n)._s.has(c)||(u?b(c,o,a,t):function(t,n,s){const{state:o,actions:r,getters:c}=n,a=s.state.value[t];let u;u=b(t,(function(){a||(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 _(n,r,Object.keys(c||{}).reduce(((n,o)=>(n[o]=e.markRaw(e.computed((()=>{i(s);const n=s._s.get(t);if(!e.isVue2||n._r)return c[o].call(n,n)}))),n)),{}))}),n,s,0,!0)}(c,a,t));return t._s.get(c)}return"string"==typeof t?(c=t,a=u?r:o):(a=t,c=t.id),p.$id=c,p},t.disposePinia=function(t){t._e.stop(),t._s.clear(),t._p.splice(0),t.state.value={},t._a=null},t.getActivePinia=()=>e.hasInjectionContext()&&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=m,t.mapState=S,t.mapStores=function(...t){return t.reduce(((t,e)=>(t[e.$id+j]=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){j=t},t.shouldHydrate=$,t.skipHydrate=function(t){return e.isVue2?v.set(t,1)&&t:Object.defineProperty(t,y,{})},t.storeToRefs=function(t){if(e.isVue2)return e.toRefs(t);{const n=e.toRaw(t),i={};for(const s in n){const o=n[s];(e.isRef(o)||e.isReactive(o))&&(i[s]=e.toRef(t,s))}return i}},t}({},VueDemi);
{
"name": "pinia",
"version": "2.2.4",
"version": "2.2.5",
"description": "Intuitive, type safe and flexible Store for Vue",

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

"typescript": ">=4.4.4",
"vue": "^2.6.14 || ^3.3.0"
"vue": "^2.6.14 || ^3.5.11"
},

@@ -78,0 +78,0 @@ "peerDependenciesMeta": {

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