Comparing version 2.0.4 to 2.0.5
@@ -0,1 +1,8 @@ | ||
## [2.0.5](https://github.com/posva/pinia/compare/pinia@2.0.4...pinia@2.0.5) (2021-12-01) | ||
### Bug Fixes | ||
- accept reactive with storeToRefs ([3a2a334](https://github.com/posva/pinia/commit/3a2a334110dadb94cc1dddc10bd7673aa79b358f)), closes [#799](https://github.com/posva/pinia/issues/799) | ||
- shouldHydrate if not in skipHydrateMap ([#846](https://github.com/posva/pinia/issues/846)) ([bcc44bc](https://github.com/posva/pinia/commit/bcc44bcedf2f127cf0218db4a89bb16b028a4ffc)) | ||
## [2.0.4](https://github.com/posva/pinia/compare/pinia@2.0.3...pinia@2.0.4) (2021-11-19) | ||
@@ -2,0 +9,0 @@ |
/*! | ||
* pinia v2.0.4 | ||
* pinia v2.0.5 | ||
* (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,_=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); | ||
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([]),R=e.markRaw([]);const O=a.state.value[n];function w(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])}$||O||(e.isVue2?e.set(a.state.value,n,{}):a.state.value[n]={}),e.ref({});const P=l;function S(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(R,{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 V={_p:a,$id:n,$onAction:c.bind(null,R),$patch:w,$reset:P,$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=[],R=[],a._s.delete(n)}};e.isVue2&&(V._r=!1);const k=e.reactive(h({},V));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))$||(!O||(M=i,e.isVue2?d.has(M):r(M)&&M.hasOwnProperty(p))||(e.isRef(i)?i.value=O[t]:f(i,O[t])),e.isVue2?e.set(a.state.value[n],t,i):a.state.value[n][t]=i);else if("function"==typeof i){const n=S(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),h(e.toRaw(k),A)),Object.defineProperty(k,"$state",{get:()=>a.state.value[n],set:t=>{w((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:_}))))})),O&&$&&o.hydrate&&o.hydrate(k.$state,O),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.4", | ||
"version": "2.0.5", | ||
"description": "Intuitive, type safe and flexible Store for Vue", | ||
@@ -72,6 +72,6 @@ "main": "index.js", | ||
"@microsoft/api-extractor": "7.18.19", | ||
"@vue/compiler-sfc": "^3.2.22", | ||
"@vue/server-renderer": "^3.2.22", | ||
"@vue/test-utils": "^2.0.0-rc.16", | ||
"vue": "^3.2.22", | ||
"@vue/compiler-sfc": "^3.2.23", | ||
"@vue/server-renderer": "^3.2.23", | ||
"@vue/test-utils": "^2.0.0-rc.17", | ||
"vue": "^3.2.23", | ||
"vue2": "npm:vue@2" | ||
@@ -85,3 +85,3 @@ }, | ||
"@vue/composition-api": "^1.4.0", | ||
"typescript": "^4.4.4", | ||
"typescript": "^4.5.2", | ||
"vue": "^2.6.14 || ^3.2.0" | ||
@@ -88,0 +88,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
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
439209
10553