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 0.3.0 to 0.3.1

7

CHANGELOG.md

@@ -0,1 +1,8 @@

## [0.3.1](https://github.com/posva/pinia/compare/v0.3.0...v0.3.1) (2021-04-10)
### Bug Fixes
- **store:** avoid multiple subscriptions call ([60df4d5](https://github.com/posva/pinia/commit/60df4d51e3c1ca7980c452d4d38eeac88b948acf)), closes [#429](https://github.com/posva/pinia/issues/429) [#430](https://github.com/posva/pinia/issues/430)
- **subscribe:** remove subscription when unmounted ([455ad95](https://github.com/posva/pinia/commit/455ad955ea4220d8434c327c6e54521a1ca93141))
# [0.3.0](https://github.com/posva/pinia/compare/v0.2.5...v0.3.0) (2021-04-09)

@@ -2,0 +9,0 @@

15

dist/pinia.cjs.js
/*!
* pinia v0.3.0
* pinia v0.3.1
* (c) 2021 Eduardo San Martin Morote

@@ -191,3 +191,3 @@ * @license MIT

let isListening = true;
let subscriptions = [];
const subscriptions = [];
function $patch(partialStateOrMutator) {

@@ -218,5 +218,3 @@ let partialState = {};

if (isListening) {
subscriptions.forEach((callback) => {
callback({ storeName: $id, type: '🧩 in place', payload: {} }, state);
});
callback({ storeName: $id, type: '🧩 in place', payload: {} }, state);
}

@@ -227,3 +225,3 @@ }, {

});
return () => {
const removeSubscription = () => {
const idx = subscriptions.indexOf(callback);

@@ -235,5 +233,8 @@ if (idx > -1) {

};
if (compositionApi.getCurrentInstance()) {
compositionApi.onUnmounted(removeSubscription);
}
return removeSubscription;
}
function $reset() {
subscriptions = [];
pinia.state.value[$id] = buildState();

@@ -240,0 +241,0 @@ }

/*!
* pinia v0.3.0
* pinia v0.3.1
* (c) 2021 Eduardo San Martin Morote

@@ -118,3 +118,3 @@ * @license MIT

let isListening = true;
let subscriptions = [];
const subscriptions = [];
function $patch(partialStateOrMutator) {

@@ -145,5 +145,3 @@ let partialState = {};

if (isListening) {
subscriptions.forEach((callback) => {
callback({ storeName: $id, type: '🧩 in place', payload: {} }, state);
});
callback({ storeName: $id, type: '🧩 in place', payload: {} }, state);
}

@@ -154,3 +152,3 @@ }, {

});
return () => {
const removeSubscription = () => {
const idx = subscriptions.indexOf(callback);

@@ -162,5 +160,8 @@ if (idx > -1) {

};
if (compositionApi.getCurrentInstance()) {
compositionApi.onUnmounted(removeSubscription);
}
return removeSubscription;
}
function $reset() {
subscriptions = [];
pinia.state.value[$id] = buildState();

@@ -167,0 +168,0 @@ }

/*!
* pinia v0.3.0
* pinia v0.3.1
* (c) 2021 Eduardo San Martin Morote
* @license MIT
*/
import { ref, getCurrentInstance, inject, markRaw, computed, reactive, watch } from '@vue/composition-api';
import { ref, getCurrentInstance, inject, markRaw, computed, reactive, watch, onUnmounted } from '@vue/composition-api';

@@ -185,3 +185,3 @@ /**

let isListening = true;
let subscriptions = [];
const subscriptions = [];
function $patch(partialStateOrMutator) {

@@ -212,5 +212,3 @@ let partialState = {};

if (isListening) {
subscriptions.forEach((callback) => {
callback({ storeName: $id, type: '🧩 in place', payload: {} }, state);
});
callback({ storeName: $id, type: '🧩 in place', payload: {} }, state);
}

@@ -221,3 +219,3 @@ }, {

});
return () => {
const removeSubscription = () => {
const idx = subscriptions.indexOf(callback);

@@ -229,5 +227,8 @@ if (idx > -1) {

};
if (getCurrentInstance()) {
onUnmounted(removeSubscription);
}
return removeSubscription;
}
function $reset() {
subscriptions = [];
pinia.state.value[$id] = buildState();

@@ -234,0 +235,0 @@ }

/*!
* pinia v0.3.0
* pinia v0.3.1
* (c) 2021 Eduardo San Martin Morote
* @license MIT
*/
import { ref, getCurrentInstance, inject, markRaw, computed, reactive, watch } from '@vue/composition-api';
import { ref, getCurrentInstance, inject, markRaw, computed, reactive, watch, onUnmounted } from '@vue/composition-api';

@@ -187,3 +187,3 @@ /**

let isListening = true;
let subscriptions = [];
const subscriptions = [];
function $patch(partialStateOrMutator) {

@@ -214,5 +214,3 @@ let partialState = {};

if (isListening) {
subscriptions.forEach((callback) => {
callback({ storeName: $id, type: '🧩 in place', payload: {} }, state);
});
callback({ storeName: $id, type: '🧩 in place', payload: {} }, state);
}

@@ -223,3 +221,3 @@ }, {

});
return () => {
const removeSubscription = () => {
const idx = subscriptions.indexOf(callback);

@@ -231,5 +229,8 @@ if (idx > -1) {

};
if (getCurrentInstance()) {
onUnmounted(removeSubscription);
}
return removeSubscription;
}
function $reset() {
subscriptions = [];
pinia.state.value[$id] = buildState();

@@ -236,0 +237,0 @@ }

/*!
* pinia v0.3.0
* pinia v0.3.1
* (c) 2021 Eduardo San Martin Morote

@@ -186,3 +186,3 @@ * @license MIT

let isListening = true;
let subscriptions = [];
const subscriptions = [];
function $patch(partialStateOrMutator) {

@@ -213,5 +213,3 @@ let partialState = {};

if (isListening) {
subscriptions.forEach((callback) => {
callback({ storeName: $id, type: '🧩 in place', payload: {} }, state);
});
callback({ storeName: $id, type: '🧩 in place', payload: {} }, state);
}

@@ -222,3 +220,3 @@ }, {

});
return () => {
const removeSubscription = () => {
const idx = subscriptions.indexOf(callback);

@@ -230,5 +228,8 @@ if (idx > -1) {

};
if (compositionApi.getCurrentInstance()) {
compositionApi.onUnmounted(removeSubscription);
}
return removeSubscription;
}
function $reset() {
subscriptions = [];
pinia.state.value[$id] = buildState();

@@ -235,0 +236,0 @@ }

/*!
* pinia v0.3.0
* pinia v0.3.1
* (c) 2021 Eduardo San Martin Morote
* @license MIT
*/
var Pinia=function(t,e){"use strict";const n=new WeakMap,r=Symbol();let i;const s=t=>i=t,o=()=>i;function a(t){return t&&"object"==typeof t&&"[object Object]"===Object.prototype.toString.call(t)&&"function"!=typeof t.toJSON}const c=Object.assign;function u(t,n=(()=>({})),r){const i=o();i.Vue.set(i.state.value,t,r||n());let s=!0,c=[];return[{$id:t,_p:e.markRaw(i),$patch:function(e){let n,r={};s=!1,"function"==typeof e?(e(i.state.value[t]),n="🧩 patch"):(!function t(e,n){for(const r in n){const i=n[r],s=e[r];e[r]=a(s)&&a(i)?t(s,i):i}return e}(i.state.value[t],e),r=e,n="⤵️ patch"),s=!0,c.forEach(e=>{e({storeName:t,type:n,payload:r},i.state.value[t])})},$subscribe:function(n){c.push(n);const r=e.watch(()=>i.state.value[t],e=>{s&&c.forEach(n=>{n({storeName:t,type:"🧩 in place",payload:{}},e)})},{deep:!0,flush:"sync"});return()=>{const t=c.indexOf(n);t>-1&&(c.splice(t,1),r())}},$reset:function(){c=[],i.state.value[t]=n()}},{get:()=>i.state.value[t],set:e=>{s=!1,i.state.value[t]=e,s=!0}}]}function p(t,n,r,i={},a={}){const u=o(),p={};for(const t in i)p[t]=e.computed(()=>(s(u),i[t].call(d,d)));const f={};for(const t in a)f[t]=function(){return s(u),a[t].apply(d,arguments)};const l=u._p.reduce((t,e)=>c({},t,e()),{}),d=e.reactive(c({},l,t,function(t,n){const r={},i=t.value[n];for(const s in i)r[s]=e.computed({get:()=>t.value[n][s],set:e=>t.value[n][s]=e});return r}(u.state,r),p,f));return Object.defineProperty(d,"$state",n),d}function f(t){const{id:i,state:a,getters:c,actions:f}=t;function l(t){(t=t||e.getCurrentInstance()&&e.inject(r))&&s(t),t=o();let l=n.get(t);l||n.set(t,l=new Map);let d=l.get(i);if(!d){d=u(i,a,t.state.value[i]),l.set(i,d);return p(d[0],d[1],i,c,f)}return p(d[0],d[1],i,c,f)}return l.$id=i,l}function l(t,e){const n=t._pStores||(t._pStores={}),r=e.$id;return n[r]||(n[r]=e(t.$pinia))}let d="Store";function h(t,e){return Array.isArray(e)?e.reduce((e,n)=>(e[n]=function(){return l(this,t)[n]},e),{}):Object.keys(e).reduce((n,r)=>(n[r]=function(){const n=l(this,t),i=e[r];return"function"==typeof i?i.call(this,n):n[i]},n),{})}const y=h;return t.PiniaPlugin=function(t){t.mixin({beforeCreate(){const e=this.$options;if(e.pinia){if(e.pinia.Vue=t,!this._provided){const t={};Object.defineProperty(this,"_provided",{get:()=>t,set:e=>Object.assign(t,e)})}this._provided[r]=e.pinia,this.$pinia||(this.$pinia=e.pinia)}else!this.$pinia&&e.parent&&e.parent.$pinia&&(this.$pinia=e.parent.$pinia)},destroyed(){delete this._pStores}})},t.createPinia=function(){const t=e.ref({}),n=[],r={Vue:{},use(t){n.push(t.bind(null,r))},_p:n,state:t};return s(r),r},t.createStore=t=>(console.warn('[🍍]: "createStore" has been deprecated and will be removed on the sable release, use "defineStore" instead.'),f(t)),t.defineStore=f,t.mapActions=function(t,e){return Array.isArray(e)?e.reduce((e,n)=>(e[n]=function(...e){return l(this,t)[n](...e)},e),{}):Object.keys(e).reduce((n,r)=>(n[r]=function(...n){return l(this,t)[e[r]](...n)},n),{})},t.mapGetters=y,t.mapState=h,t.mapStores=function(...t){return t.reduce((t,e)=>(t[e.$id+d]=function(){return l(this,e)},t),{})},t.mapWritableState=function(t,e){return Array.isArray(e)?e.reduce((e,n)=>(e[n]={get(){return l(this,t)[n]},set(e){return l(this,t)[n]=e}},e),{}):Object.keys(e).reduce((n,r)=>(n[r]={get(){return l(this,t)[e[r]]},set(n){return l(this,t)[e[r]]=n}},n),{})},t.setActivePinia=s,t.setMapStoreSuffix=function(t){d=t},Object.defineProperty(t,"__esModule",{value:!0}),t}({},vueCompositionApi);
var Pinia=function(t,e){"use strict";const n=new WeakMap,r=Symbol();let i;const s=t=>i=t,o=()=>i;function a(t){return t&&"object"==typeof t&&"[object Object]"===Object.prototype.toString.call(t)&&"function"!=typeof t.toJSON}const c=Object.assign;function u(t,n=(()=>({})),r){const i=o();i.Vue.set(i.state.value,t,r||n());let s=!0;const c=[];return[{$id:t,_p:e.markRaw(i),$patch:function(e){let n,r={};s=!1,"function"==typeof e?(e(i.state.value[t]),n="🧩 patch"):(!function t(e,n){for(const r in n){const i=n[r],s=e[r];e[r]=a(s)&&a(i)?t(s,i):i}return e}(i.state.value[t],e),r=e,n="⤵️ patch"),s=!0,c.forEach(e=>{e({storeName:t,type:n,payload:r},i.state.value[t])})},$subscribe:function(n){c.push(n);const r=e.watch(()=>i.state.value[t],e=>{s&&n({storeName:t,type:"🧩 in place",payload:{}},e)},{deep:!0,flush:"sync"}),o=()=>{const t=c.indexOf(n);t>-1&&(c.splice(t,1),r())};return e.getCurrentInstance()&&e.onUnmounted(o),o},$reset:function(){i.state.value[t]=n()}},{get:()=>i.state.value[t],set:e=>{s=!1,i.state.value[t]=e,s=!0}}]}function p(t,n,r,i={},a={}){const u=o(),p={};for(const t in i)p[t]=e.computed(()=>(s(u),i[t].call(d,d)));const f={};for(const t in a)f[t]=function(){return s(u),a[t].apply(d,arguments)};const l=u._p.reduce((t,e)=>c({},t,e()),{}),d=e.reactive(c({},l,t,function(t,n){const r={},i=t.value[n];for(const s in i)r[s]=e.computed({get:()=>t.value[n][s],set:e=>t.value[n][s]=e});return r}(u.state,r),p,f));return Object.defineProperty(d,"$state",n),d}function f(t){const{id:i,state:a,getters:c,actions:f}=t;function l(t){(t=t||e.getCurrentInstance()&&e.inject(r))&&s(t),t=o();let l=n.get(t);l||n.set(t,l=new Map);let d=l.get(i);if(!d){d=u(i,a,t.state.value[i]),l.set(i,d);return p(d[0],d[1],i,c,f)}return p(d[0],d[1],i,c,f)}return l.$id=i,l}function l(t,e){const n=t._pStores||(t._pStores={}),r=e.$id;return n[r]||(n[r]=e(t.$pinia))}let d="Store";function h(t,e){return Array.isArray(e)?e.reduce((e,n)=>(e[n]=function(){return l(this,t)[n]},e),{}):Object.keys(e).reduce((n,r)=>(n[r]=function(){const n=l(this,t),i=e[r];return"function"==typeof i?i.call(this,n):n[i]},n),{})}const y=h;return t.PiniaPlugin=function(t){t.mixin({beforeCreate(){const e=this.$options;if(e.pinia){if(e.pinia.Vue=t,!this._provided){const t={};Object.defineProperty(this,"_provided",{get:()=>t,set:e=>Object.assign(t,e)})}this._provided[r]=e.pinia,this.$pinia||(this.$pinia=e.pinia)}else!this.$pinia&&e.parent&&e.parent.$pinia&&(this.$pinia=e.parent.$pinia)},destroyed(){delete this._pStores}})},t.createPinia=function(){const t=e.ref({}),n=[],r={Vue:{},use(t){n.push(t.bind(null,r))},_p:n,state:t};return s(r),r},t.createStore=t=>(console.warn('[🍍]: "createStore" has been deprecated and will be removed on the sable release, use "defineStore" instead.'),f(t)),t.defineStore=f,t.mapActions=function(t,e){return Array.isArray(e)?e.reduce((e,n)=>(e[n]=function(...e){return l(this,t)[n](...e)},e),{}):Object.keys(e).reduce((n,r)=>(n[r]=function(...n){return l(this,t)[e[r]](...n)},n),{})},t.mapGetters=y,t.mapState=h,t.mapStores=function(...t){return t.reduce((t,e)=>(t[e.$id+d]=function(){return l(this,e)},t),{})},t.mapWritableState=function(t,e){return Array.isArray(e)?e.reduce((e,n)=>(e[n]={get(){return l(this,t)[n]},set(e){return l(this,t)[n]=e}},e),{}):Object.keys(e).reduce((n,r)=>(n[r]={get(){return l(this,t)[e[r]]},set(n){return l(this,t)[e[r]]=n}},n),{})},t.setActivePinia=s,t.setMapStoreSuffix=function(t){d=t},Object.defineProperty(t,"__esModule",{value:!0}),t}({},vueCompositionApi);

@@ -49,4 +49,3 @@ import { Pinia } from './rootStore';

/**
* Resets the store to its initial state by removing all subscriptions and
* building a new state object
* Resets the store to its initial state by building a new state object.
*/

@@ -53,0 +52,0 @@ $reset(): void;

{
"name": "pinia",
"version": "0.3.0",
"version": "0.3.1",
"description": "Intuitive, type safe and flexible Store for Vue",

@@ -5,0 +5,0 @@ "main": "dist/pinia.cjs.js",

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