Comparing version 0.5.2 to 0.5.3
@@ -0,1 +1,10 @@ | ||
## [0.5.3](https://github.com/posva/pinia/compare/v0.5.2...v0.5.3) (2021-08-02) | ||
### Bug Fixes | ||
- markRaw on pinia ([208e6c0](https://github.com/posva/pinia/commit/208e6c00d2d6077b818a7f99f000b177a1f96107)) | ||
- **patch:** avoid merging reactive objects ([581bd08](https://github.com/posva/pinia/commit/581bd08d978050fc5b9e8c6b32147cf3798b33cb)), closes [#528](https://github.com/posva/pinia/issues/528) | ||
- **types:** forbid non existent access in getters and actions ([29eee8a](https://github.com/posva/pinia/commit/29eee8a3eba5f426a05315dd05c1a7eaf69a6758)) | ||
- **types:** remove state properties from this ([7990adf](https://github.com/posva/pinia/commit/7990adfffa39d14a0d458e6d8a0f341e61441693)) | ||
## [0.5.2](https://github.com/posva/pinia/compare/v0.5.1...v0.5.2) (2021-06-03) | ||
@@ -2,0 +11,0 @@ |
/*! | ||
* pinia v0.5.2 | ||
* pinia v0.5.3 | ||
* (c) 2021 Eduardo San Martin Morote | ||
@@ -27,3 +27,3 @@ * @license MIT | ||
const _p = []; | ||
const pinia = { | ||
const pinia = compositionApi.markRaw({ | ||
use(plugin) { | ||
@@ -35,3 +35,3 @@ _p.push(plugin); | ||
state, | ||
}; | ||
}); | ||
// this allows calling useStore() outside of a component setup after | ||
@@ -112,3 +112,3 @@ // installing pinia's plugin | ||
: { __VUE_DEVTOOLS_GLOBAL_HOOK__: undefined }; | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
// @ts-ignore | ||
const devtoolHook = target.__VUE_DEVTOOLS_GLOBAL_HOOK__; | ||
@@ -174,3 +174,6 @@ let rootStore; | ||
const targetValue = target[key]; | ||
if (isPlainObject(targetValue) && isPlainObject(subPatch)) { | ||
if (isPlainObject(targetValue) && | ||
isPlainObject(subPatch) && | ||
!compositionApi.isRef(subPatch) && | ||
!compositionApi.isReactive(subPatch)) { | ||
target[key] = innerPatch(targetValue, subPatch); | ||
@@ -290,3 +293,3 @@ } | ||
$id, | ||
_p: compositionApi.markRaw(pinia), | ||
_p: pinia, | ||
_as: compositionApi.markRaw(actionSubscriptions), | ||
@@ -409,11 +412,10 @@ // $state is added underneath | ||
pinia = getActivePinia(); | ||
let stores = storesMap.get(pinia); | ||
if (!stores) | ||
storesMap.set(pinia, (stores = new Map())); | ||
// let store = stores.get(id) as Store<Id, S, G, A> | ||
let storeAndDescriptor = stores.get(id); | ||
let storeCache = storesMap.get(pinia); | ||
if (!storeCache) | ||
storesMap.set(pinia, (storeCache = new Map())); | ||
let storeAndDescriptor = storeCache.get(id); | ||
if (!storeAndDescriptor) { | ||
storeAndDescriptor = initStore(id, state, pinia.state.value[id]); | ||
// @ts-expect-error: annoying to type | ||
stores.set(id, storeAndDescriptor); | ||
storeCache.set(id, storeAndDescriptor); | ||
if ((process.env.NODE_ENV !== 'production') && isClient) { | ||
@@ -420,0 +422,0 @@ // @ts-expect-error: annoying to type |
/*! | ||
* pinia v0.5.2 | ||
* pinia v0.5.3 | ||
* (c) 2021 Eduardo San Martin Morote | ||
@@ -27,3 +27,3 @@ * @license MIT | ||
const _p = []; | ||
const pinia = { | ||
const pinia = compositionApi.markRaw({ | ||
use(plugin) { | ||
@@ -35,3 +35,3 @@ _p.push(plugin); | ||
state, | ||
}; | ||
}); | ||
// this allows calling useStore() outside of a component setup after | ||
@@ -103,3 +103,3 @@ // installing pinia's plugin | ||
: { __VUE_DEVTOOLS_GLOBAL_HOOK__: undefined }; | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
// @ts-ignore | ||
target.__VUE_DEVTOOLS_GLOBAL_HOOK__; | ||
@@ -114,3 +114,6 @@ | ||
const targetValue = target[key]; | ||
if (isPlainObject(targetValue) && isPlainObject(subPatch)) { | ||
if (isPlainObject(targetValue) && | ||
isPlainObject(subPatch) && | ||
!compositionApi.isRef(subPatch) && | ||
!compositionApi.isReactive(subPatch)) { | ||
target[key] = innerPatch(targetValue, subPatch); | ||
@@ -230,3 +233,3 @@ } | ||
$id, | ||
_p: compositionApi.markRaw(pinia), | ||
_p: pinia, | ||
_as: compositionApi.markRaw(actionSubscriptions), | ||
@@ -347,11 +350,10 @@ // $state is added underneath | ||
pinia = getActivePinia(); | ||
let stores = storesMap.get(pinia); | ||
if (!stores) | ||
storesMap.set(pinia, (stores = new Map())); | ||
// let store = stores.get(id) as Store<Id, S, G, A> | ||
let storeAndDescriptor = stores.get(id); | ||
let storeCache = storesMap.get(pinia); | ||
if (!storeCache) | ||
storesMap.set(pinia, (storeCache = new Map())); | ||
let storeAndDescriptor = storeCache.get(id); | ||
if (!storeAndDescriptor) { | ||
storeAndDescriptor = initStore(id, state, pinia.state.value[id]); | ||
// @ts-expect-error: annoying to type | ||
stores.set(id, storeAndDescriptor); | ||
storeCache.set(id, storeAndDescriptor); | ||
const store = buildStoreToUse(storeAndDescriptor[0], storeAndDescriptor[1], id, getters, actions, options); | ||
@@ -358,0 +360,0 @@ // allow children to reuse this store instance to avoid creating a new |
/*! | ||
* pinia v0.5.2 | ||
* pinia v0.5.3 | ||
* (c) 2021 Eduardo San Martin Morote | ||
* @license MIT | ||
*/ | ||
import { ref, getCurrentInstance, inject, provide, set, markRaw, computed, reactive, watch, onUnmounted } from '@vue/composition-api'; | ||
import { ref, markRaw, getCurrentInstance, inject, provide, set, computed, reactive, watch, onUnmounted, isRef, isReactive } from '@vue/composition-api'; | ||
@@ -23,3 +23,3 @@ /** | ||
const _p = []; | ||
const pinia = { | ||
const pinia = markRaw({ | ||
use(plugin) { | ||
@@ -31,3 +31,3 @@ _p.push(plugin); | ||
state, | ||
}; | ||
}); | ||
// this allows calling useStore() outside of a component setup after | ||
@@ -108,3 +108,3 @@ // installing pinia's plugin | ||
: { __VUE_DEVTOOLS_GLOBAL_HOOK__: undefined }; | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
// @ts-ignore | ||
const devtoolHook = target.__VUE_DEVTOOLS_GLOBAL_HOOK__; | ||
@@ -170,3 +170,6 @@ let rootStore; | ||
const targetValue = target[key]; | ||
if (isPlainObject(targetValue) && isPlainObject(subPatch)) { | ||
if (isPlainObject(targetValue) && | ||
isPlainObject(subPatch) && | ||
!isRef(subPatch) && | ||
!isReactive(subPatch)) { | ||
target[key] = innerPatch(targetValue, subPatch); | ||
@@ -286,3 +289,3 @@ } | ||
$id, | ||
_p: markRaw(pinia), | ||
_p: pinia, | ||
_as: markRaw(actionSubscriptions), | ||
@@ -403,11 +406,10 @@ // $state is added underneath | ||
pinia = getActivePinia(); | ||
let stores = storesMap.get(pinia); | ||
if (!stores) | ||
storesMap.set(pinia, (stores = new Map())); | ||
// let store = stores.get(id) as Store<Id, S, G, A> | ||
let storeAndDescriptor = stores.get(id); | ||
let storeCache = storesMap.get(pinia); | ||
if (!storeCache) | ||
storesMap.set(pinia, (storeCache = new Map())); | ||
let storeAndDescriptor = storeCache.get(id); | ||
if (!storeAndDescriptor) { | ||
storeAndDescriptor = initStore(id, state, pinia.state.value[id]); | ||
// @ts-expect-error: annoying to type | ||
stores.set(id, storeAndDescriptor); | ||
storeCache.set(id, storeAndDescriptor); | ||
if (isClient) { | ||
@@ -414,0 +416,0 @@ // @ts-expect-error: annoying to type |
/*! | ||
* pinia v0.5.2 | ||
* pinia v0.5.3 | ||
* (c) 2021 Eduardo San Martin Morote | ||
* @license MIT | ||
*/ | ||
import { ref, getCurrentInstance, inject, provide, set, markRaw, computed, reactive, watch, onUnmounted } from '@vue/composition-api'; | ||
import { ref, markRaw, getCurrentInstance, inject, provide, set, computed, reactive, watch, onUnmounted, isRef, isReactive } from '@vue/composition-api'; | ||
@@ -23,3 +23,3 @@ /** | ||
const _p = []; | ||
const pinia = { | ||
const pinia = markRaw({ | ||
use(plugin) { | ||
@@ -31,3 +31,3 @@ _p.push(plugin); | ||
state, | ||
}; | ||
}); | ||
// this allows calling useStore() outside of a component setup after | ||
@@ -108,3 +108,3 @@ // installing pinia's plugin | ||
: { __VUE_DEVTOOLS_GLOBAL_HOOK__: undefined }; | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
// @ts-ignore | ||
const devtoolHook = target.__VUE_DEVTOOLS_GLOBAL_HOOK__; | ||
@@ -170,3 +170,6 @@ let rootStore; | ||
const targetValue = target[key]; | ||
if (isPlainObject(targetValue) && isPlainObject(subPatch)) { | ||
if (isPlainObject(targetValue) && | ||
isPlainObject(subPatch) && | ||
!isRef(subPatch) && | ||
!isReactive(subPatch)) { | ||
target[key] = innerPatch(targetValue, subPatch); | ||
@@ -286,3 +289,3 @@ } | ||
$id, | ||
_p: markRaw(pinia), | ||
_p: pinia, | ||
_as: markRaw(actionSubscriptions), | ||
@@ -405,11 +408,10 @@ // $state is added underneath | ||
pinia = getActivePinia(); | ||
let stores = storesMap.get(pinia); | ||
if (!stores) | ||
storesMap.set(pinia, (stores = new Map())); | ||
// let store = stores.get(id) as Store<Id, S, G, A> | ||
let storeAndDescriptor = stores.get(id); | ||
let storeCache = storesMap.get(pinia); | ||
if (!storeCache) | ||
storesMap.set(pinia, (storeCache = new Map())); | ||
let storeAndDescriptor = storeCache.get(id); | ||
if (!storeAndDescriptor) { | ||
storeAndDescriptor = initStore(id, state, pinia.state.value[id]); | ||
// @ts-expect-error: annoying to type | ||
stores.set(id, storeAndDescriptor); | ||
storeCache.set(id, storeAndDescriptor); | ||
if ((process.env.NODE_ENV !== 'production') && isClient) { | ||
@@ -416,0 +418,0 @@ // @ts-expect-error: annoying to type |
/*! | ||
* pinia v0.5.2 | ||
* pinia v0.5.3 | ||
* (c) 2021 Eduardo San Martin Morote | ||
@@ -24,3 +24,3 @@ * @license MIT | ||
const _p = []; | ||
const pinia = { | ||
const pinia = compositionApi.markRaw({ | ||
use(plugin) { | ||
@@ -32,3 +32,3 @@ _p.push(plugin); | ||
state, | ||
}; | ||
}); | ||
// this allows calling useStore() outside of a component setup after | ||
@@ -109,3 +109,3 @@ // installing pinia's plugin | ||
: { __VUE_DEVTOOLS_GLOBAL_HOOK__: undefined }; | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
// @ts-ignore | ||
const devtoolHook = target.__VUE_DEVTOOLS_GLOBAL_HOOK__; | ||
@@ -171,3 +171,6 @@ let rootStore; | ||
const targetValue = target[key]; | ||
if (isPlainObject(targetValue) && isPlainObject(subPatch)) { | ||
if (isPlainObject(targetValue) && | ||
isPlainObject(subPatch) && | ||
!compositionApi.isRef(subPatch) && | ||
!compositionApi.isReactive(subPatch)) { | ||
target[key] = innerPatch(targetValue, subPatch); | ||
@@ -287,3 +290,3 @@ } | ||
$id, | ||
_p: compositionApi.markRaw(pinia), | ||
_p: pinia, | ||
_as: compositionApi.markRaw(actionSubscriptions), | ||
@@ -404,11 +407,10 @@ // $state is added underneath | ||
pinia = getActivePinia(); | ||
let stores = storesMap.get(pinia); | ||
if (!stores) | ||
storesMap.set(pinia, (stores = new Map())); | ||
// let store = stores.get(id) as Store<Id, S, G, A> | ||
let storeAndDescriptor = stores.get(id); | ||
let storeCache = storesMap.get(pinia); | ||
if (!storeCache) | ||
storesMap.set(pinia, (storeCache = new Map())); | ||
let storeAndDescriptor = storeCache.get(id); | ||
if (!storeAndDescriptor) { | ||
storeAndDescriptor = initStore(id, state, pinia.state.value[id]); | ||
// @ts-expect-error: annoying to type | ||
stores.set(id, storeAndDescriptor); | ||
storeCache.set(id, storeAndDescriptor); | ||
if (isClient) { | ||
@@ -415,0 +417,0 @@ // @ts-expect-error: annoying to type |
/*! | ||
* pinia v0.5.2 | ||
* pinia v0.5.3 | ||
* (c) 2021 Eduardo San Martin Morote | ||
* @license MIT | ||
*/ | ||
var Pinia=function(t,e){"use strict";const n=new WeakMap,r=Symbol();let o;const i=t=>o=t,s=()=>o;function c(t){return t&&"object"==typeof t&&"[object Object]"===Object.prototype.toString.call(t)&&"function"!=typeof t.toJSON}var a;t.MutationType=void 0,(a=t.MutationType||(t.MutationType={})).direct="direct",a.patchObject="patch object",a.patchFunction="patch function";"undefined"!=typeof window?window:"undefined"!=typeof global&&global;const u=Object.assign;function p(t,e){for(const n in e){const r=e[n],o=t[n];t[n]=c(o)&&c(r)?p(o,r):r}return t}function f(n,r=(()=>({})),o){const i=s();e.set(i.state.value,n,o||r());let c=!0;const a=[],u=[];return[{$id:n,_p:e.markRaw(i),_as:e.markRaw(u),$patch:function(e){let r;c=!1,"function"==typeof e?(e(i.state.value[n]),r={type:t.MutationType.patchFunction,storeName:n,storeId:n}):(p(i.state.value[n],e),r={type:t.MutationType.patchObject,payload:e,storeName:n,storeId:n}),c=!0,a.forEach((t=>{t(r,i.state.value[n])}))},$subscribe:function(r){a.push(r);const o=e.watch((()=>i.state.value[n]),(e=>{c&&r({storeName:n,storeId:n,type:t.MutationType.direct},e)}),{deep:!0,flush:"sync"}),s=()=>{const t=a.indexOf(r);t>-1&&(a.splice(t,1),o())};return e.getCurrentInstance()&&e.onUnmounted(s),s},$onAction:function(t){u.push(t);const n=()=>{const e=u.indexOf(t);e>-1&&u.splice(e,1)};return e.getCurrentInstance()&&e.onUnmounted(n),n},$reset:function(){i.state.value[n]=r()}},{get:()=>i.state.value[n],set:t=>{c=!1,i.state.value[n]=t,c=!0}},Symbol()]}const d=()=>{};function l(t,n,r,o={},c={},a){const p=s(),f={};for(const t in o)f[t]=e.computed((()=>(i(p),o[t].call(h,h))));const l={};for(const e in c)l[e]=function(){i(p);const n=Array.from(arguments),r=this||h;let o,s=d,a=d;function u(t){s=t}function f(t){a=t}t._as.forEach((t=>{t({args:n,name:e,store:r,after:u,onError:f})}));try{o=c[e].apply(r,n),Promise.resolve(o).then(s).catch(a)}catch(t){throw a(t),t}return o};const h=e.reactive(u({},t,function(t,n){const r={},o=t.value[n];for(const i in o)r[i]=e.computed({get:()=>t.value[n][i],set:e=>t.value[n][i]=e});return r}(p.state,r),f,l));return Object.defineProperty(h,"$state",n),p._p.forEach((t=>{u(h,t({store:h,pinia:p,options:a}))})),h}function h(t){const{id:o,state:c,getters:a,actions:u}=t;function p(p){const d=e.getCurrentInstance(),h=d&&!p;(p=p||d&&e.inject(r))&&i(p),p=s();let y=n.get(p);y||n.set(p,y=new Map);let b=y.get(o);if(!b){b=f(o,c,p.state.value[o]),y.set(o,b);const n=l(b[0],b[1],o,a,u,t);return h&&e.provide(b[2],n),n}return d&&e.inject(b[2],null)||l(b[0],b[1],o,a,u,t)}return p.$id=o,p}function y(t,e){const n="_pStores"in t?t._pStores:t._pStores={},r=e.$id;return n[r]||(n[r]=e(t.$pinia))}let b="Store";function v(t,e){return Array.isArray(e)?e.reduce(((e,n)=>(e[n]=function(){return y(this,t)[n]},e)),{}):Object.keys(e).reduce(((n,r)=>(n[r]=function(){const n=y(this,t),o=e[r];return"function"==typeof o?o.call(this,n):n[o]},n)),{})}const m=v;return t.PiniaPlugin=function(t){t.mixin({beforeCreate(){const t=this.$options;if(t.pinia){if(!this._provided){const t={};Object.defineProperty(this,"_provided",{get:()=>t,set:e=>Object.assign(t,e)})}this._provided[r]=t.pinia,this.$pinia||(this.$pinia=t.pinia)}else!this.$pinia&&t.parent&&t.parent.$pinia&&(this.$pinia=t.parent.$pinia)},destroyed(){delete this._pStores}})},t.createPinia=function(){const t=e.ref({}),n=[],r={use:t=>(n.push(t),r),_p:n,state:t};return i(r),r},t.createStore=t=>(console.warn('[🍍]: "createStore" has been deprecated and will be removed on the sable release, use "defineStore" instead.'),h(t)),t.defineStore=h,t.mapActions=function(t,e){return Array.isArray(e)?e.reduce(((e,n)=>(e[n]=function(...e){return y(this,t)[n](...e)},e)),{}):Object.keys(e).reduce(((n,r)=>(n[r]=function(...n){return y(this,t)[e[r]](...n)},n)),{})},t.mapGetters=m,t.mapState=v,t.mapStores=function(...t){return t.reduce(((t,e)=>(t[e.$id+b]=function(){return y(this,e)},t)),{})},t.mapWritableState=function(t,e){return Array.isArray(e)?e.reduce(((e,n)=>(e[n]={get(){return y(this,t)[n]},set(e){return y(this,t)[n]=e}},e)),{}):Object.keys(e).reduce(((n,r)=>(n[r]={get(){return y(this,t)[e[r]]},set(n){return y(this,t)[e[r]]=n}},n)),{})},t.setActivePinia=i,t.setMapStoreSuffix=function(t){b=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 o=t=>i=t,s=()=>i;function c(t){return t&&"object"==typeof t&&"[object Object]"===Object.prototype.toString.call(t)&&"function"!=typeof t.toJSON}var a;t.MutationType=void 0,(a=t.MutationType||(t.MutationType={})).direct="direct",a.patchObject="patch object",a.patchFunction="patch function";"undefined"!=typeof window?window:"undefined"!=typeof global&&global;const u=Object.assign;function p(t,n){for(const r in n){const i=n[r],o=t[r];t[r]=c(o)&&c(i)&&!e.isRef(i)&&!e.isReactive(i)?p(o,i):i}return t}function f(n,r=(()=>({})),i){const o=s();e.set(o.state.value,n,i||r());let c=!0;const a=[],u=[];return[{$id:n,_p:o,_as:e.markRaw(u),$patch:function(e){let r;c=!1,"function"==typeof e?(e(o.state.value[n]),r={type:t.MutationType.patchFunction,storeName:n,storeId:n}):(p(o.state.value[n],e),r={type:t.MutationType.patchObject,payload:e,storeName:n,storeId:n}),c=!0,a.forEach((t=>{t(r,o.state.value[n])}))},$subscribe:function(r){a.push(r);const i=e.watch((()=>o.state.value[n]),(e=>{c&&r({storeName:n,storeId:n,type:t.MutationType.direct},e)}),{deep:!0,flush:"sync"}),s=()=>{const t=a.indexOf(r);t>-1&&(a.splice(t,1),i())};return e.getCurrentInstance()&&e.onUnmounted(s),s},$onAction:function(t){u.push(t);const n=()=>{const e=u.indexOf(t);e>-1&&u.splice(e,1)};return e.getCurrentInstance()&&e.onUnmounted(n),n},$reset:function(){o.state.value[n]=r()}},{get:()=>o.state.value[n],set:t=>{c=!1,o.state.value[n]=t,c=!0}},Symbol()]}const d=()=>{};function l(t,n,r,i={},c={},a){const p=s(),f={};for(const t in i)f[t]=e.computed((()=>(o(p),i[t].call(h,h))));const l={};for(const e in c)l[e]=function(){o(p);const n=Array.from(arguments),r=this||h;let i,s=d,a=d;function u(t){s=t}function f(t){a=t}t._as.forEach((t=>{t({args:n,name:e,store:r,after:u,onError:f})}));try{i=c[e].apply(r,n),Promise.resolve(i).then(s).catch(a)}catch(t){throw a(t),t}return i};const h=e.reactive(u({},t,function(t,n){const r={},i=t.value[n];for(const o in i)r[o]=e.computed({get:()=>t.value[n][o],set:e=>t.value[n][o]=e});return r}(p.state,r),f,l));return Object.defineProperty(h,"$state",n),p._p.forEach((t=>{u(h,t({store:h,pinia:p,options:a}))})),h}function h(t){const{id:i,state:c,getters:a,actions:u}=t;function p(p){const d=e.getCurrentInstance(),h=d&&!p;(p=p||d&&e.inject(r))&&o(p),p=s();let y=n.get(p);y||n.set(p,y=new Map);let b=y.get(i);if(!b){b=f(i,c,p.state.value[i]),y.set(i,b);const n=l(b[0],b[1],i,a,u,t);return h&&e.provide(b[2],n),n}return d&&e.inject(b[2],null)||l(b[0],b[1],i,a,u,t)}return p.$id=i,p}function y(t,e){const n="_pStores"in t?t._pStores:t._pStores={},r=e.$id;return n[r]||(n[r]=e(t.$pinia))}let b="Store";function v(t,e){return Array.isArray(e)?e.reduce(((e,n)=>(e[n]=function(){return y(this,t)[n]},e)),{}):Object.keys(e).reduce(((n,r)=>(n[r]=function(){const n=y(this,t),i=e[r];return"function"==typeof i?i.call(this,n):n[i]},n)),{})}const m=v;return t.PiniaPlugin=function(t){t.mixin({beforeCreate(){const t=this.$options;if(t.pinia){if(!this._provided){const t={};Object.defineProperty(this,"_provided",{get:()=>t,set:e=>Object.assign(t,e)})}this._provided[r]=t.pinia,this.$pinia||(this.$pinia=t.pinia)}else!this.$pinia&&t.parent&&t.parent.$pinia&&(this.$pinia=t.parent.$pinia)},destroyed(){delete this._pStores}})},t.createPinia=function(){const t=e.ref({}),n=[],r=e.markRaw({use:t=>(n.push(t),r),_p:n,state:t});return o(r),r},t.createStore=t=>(console.warn('[🍍]: "createStore" has been deprecated and will be removed on the sable release, use "defineStore" instead.'),h(t)),t.defineStore=h,t.mapActions=function(t,e){return Array.isArray(e)?e.reduce(((e,n)=>(e[n]=function(...e){return y(this,t)[n](...e)},e)),{}):Object.keys(e).reduce(((n,r)=>(n[r]=function(...n){return y(this,t)[e[r]](...n)},n)),{})},t.mapGetters=m,t.mapState=v,t.mapStores=function(...t){return t.reduce(((t,e)=>(t[e.$id+b]=function(){return y(this,e)},t)),{})},t.mapWritableState=function(t,e){return Array.isArray(e)?e.reduce(((e,n)=>(e[n]={get(){return y(this,t)[n]},set(e){return y(this,t)[n]=e}},e)),{}):Object.keys(e).reduce(((n,r)=>(n[r]={get(){return y(this,t)[e[r]]},set(n){return y(this,t)[e[r]]=n}},n)),{})},t.setActivePinia=o,t.setMapStoreSuffix=function(t){b=t},Object.defineProperty(t,"__esModule",{value:!0}),t}({},vueCompositionApi); |
@@ -151,3 +151,3 @@ import { UnwrapRef } from '@vue/composition-api'; | ||
*/ | ||
$state: UnwrapRef<S> & PiniaCustomStateProperties<S>; | ||
$state: UnwrapRef<StateTree extends S ? {} : S> & PiniaCustomStateProperties<S>; | ||
/** | ||
@@ -260,3 +260,3 @@ * Private property defining the pinia the store is attached to. | ||
*/ | ||
export declare type GenericStore<Id extends string = string, S extends StateTree = StateTree, G extends GettersTree<S> = GettersTree<S>, A = ActionsTree> = StoreWithState<Id, S, G, A> & UnwrapRef<S> & StoreWithGetters<G> & StoreWithActions<A> & PiniaCustomProperties<Id, S, G, A> & PiniaCustomStateProperties<S>; | ||
export declare type GenericStore<Id extends string = string, S extends StateTree = any, G extends GettersTree<S> = GettersTree<S>, A = ActionsTree> = StoreWithState<Id, S, G, A> & UnwrapRef<S> & StoreWithGetters<G> & StoreWithActions<A> & PiniaCustomProperties<Id, S, G, A> & PiniaCustomStateProperties<S>; | ||
/** | ||
@@ -292,3 +292,3 @@ * Return type of `defineStore()`. Function that allows instantiating a store. | ||
*/ | ||
export declare type GettersTree<S extends StateTree> = Record<string, ((state: UnwrapRef<S & PiniaCustomStateProperties<S>>) => any) | (() => any)>; | ||
export declare type GettersTree<S extends StateTree> = Record<string, ((state: UnwrapRef<(StateTree extends S ? {} : S) & PiniaCustomStateProperties<S>>) => any) | (() => any)>; | ||
/** | ||
@@ -314,8 +314,8 @@ * @internal | ||
*/ | ||
getters?: G & ThisType<UnwrapRef<S> & StoreWithGetters<G> & PiniaCustomProperties & PiniaCustomStateProperties>; | ||
getters?: G & ThisType<UnwrapRef<StateTree extends S ? {} : S> & StoreWithGetters<G> & PiniaCustomProperties>; | ||
/** | ||
* Optional object of actions. | ||
*/ | ||
actions?: A & ThisType<A & UnwrapRef<S> & StoreWithState<Id, S, G, A> & StoreWithGetters<G> & PiniaCustomProperties & PiniaCustomStateProperties>; | ||
actions?: A & ThisType<A & UnwrapRef<StateTree extends S ? {} : S> & StoreWithState<Id, S, G, A> & StoreWithGetters<GettersTree<S> extends G ? {} : G> & PiniaCustomProperties>; | ||
} | ||
//# sourceMappingURL=types.d.ts.map |
{ | ||
"name": "pinia", | ||
"version": "0.5.2", | ||
"version": "0.5.3", | ||
"description": "Intuitive, type safe and flexible Store for Vue", | ||
@@ -26,2 +26,3 @@ "main": "dist/pinia.cjs.js", | ||
}, | ||
"funding": "https://github.com/sponsors/posva", | ||
"scripts": { | ||
@@ -68,5 +69,5 @@ "lint": "eslint --color --ext=js,html,vue,ts src __tests__ *.js", | ||
"@rollup/plugin-alias": "^3.1.1", | ||
"@rollup/plugin-commonjs": "^19.0.0", | ||
"@rollup/plugin-commonjs": "^20.0.0", | ||
"@rollup/plugin-node-resolve": "^13.0.0", | ||
"@rollup/plugin-replace": "^2.3.3", | ||
"@rollup/plugin-replace": "^3.0.0", | ||
"@sucrase/jest-plugin": "^2.1.0", | ||
@@ -73,0 +74,0 @@ "@types/jest": "^26.0.23", |
Sorry, the diff of this file is not supported yet
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
199454
4020