@codescouts/vue-store-beta
Advanced tools
Comparing version 1.0.11 to 1.0.12
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("pinia"),w=(e,r)=>(Object.entries(r).forEach(t=>{if(typeof t[1]=="object"&&e[t[0]]){const c=e[t[0]];e[t[0]]=w(c,t[1])}else e[t[0]]=t[1]}),e),S=(e,r)=>{const t=new e;return w(t,r),t},h=(e,r)=>typeof e=="string"?r:Array.isArray(r)?r.map(t=>S(e,t)):S(e,r),j=(e,r,t)=>(t?()=>t(e,h):()=>h(r,e))(),y=(e,r)=>{const t={withPersist:!1,entityType:void 0,factory:void 0,merge:void 0},c=o=>o?typeof o=="string"?o:o.name:e,a=()=>{const{withPersist:o,entityType:n,factory:f,merge:g}=t;let m=s=>r(s);if(o){const s=c(n),i=localStorage.getItem(s);if(i){let u;try{u=JSON.parse(i)}catch{u={}}const P=f&&n?j(u,n,f):g(u,h);m=O=>({...r(O),...P})}}const l={set(s){if(this.$patch(s),o){const i=c(n);localStorage.setItem(i,JSON.stringify(s))}},get(){return this.$state}},v=d.defineStore(e,{state:()=>m(l),actions:l});return()=>{const s=v();return Object.assign(l,s),s}};function p(o,n){return t.withPersist=!0,t.entityType=o,t.factory=n,{andRestore:g=>(t.merge=g,{build:a}),build:a}}return{build:a,withPersist:p}},I=e=>d.defineStore(e.name,{state:()=>new e,actions:{save(t){this.$patch(t)},get(){return S(e,this.$state)}}});exports.create=y;exports.useStoreFor=I; | ||
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("pinia"),w=(e,r)=>(Object.entries(r).forEach(t=>{if(typeof t[1]=="object"&&e[t[0]]){const c=e[t[0]];e[t[0]]=w(c,t[1])}else e[t[0]]=t[1]}),e),S=(e,r)=>{const t=new e;return w(t,r),t},h=(e,r)=>typeof e=="string"?r:Array.isArray(r)?r.map(t=>S(e,t)):S(e,r),j=(e,r,t)=>(t?()=>t(e,h):()=>h(r,e))(),y=(e,r)=>{const t={withPersist:!1,entityType:void 0,factory:void 0,merge:void 0},c=o=>o?typeof o=="string"?o:o.name:e,a=()=>{const{withPersist:o,entityType:n,factory:f,merge:g}=t;let m=s=>r(s);if(o){const s=c(n),i=localStorage.getItem(s);if(i){let u;try{u=JSON.parse(i)}catch{u={}}const v=f&&n?j(u,n,f):g(u,h);m=O=>({...r(O),...v})}}const l={set(s){if(this.$patch(s),o){const i=c(n);localStorage.setItem(i,JSON.stringify(s))}},get(){return this.$state}},P=d.defineStore(e,{state:()=>m(l),actions:l});return()=>{const s=P();return Object.assign(l,s),s}};function p(o,n){return t.withPersist=!0,t.entityType=o,t.factory=n,{andRestore:g=>(t.merge=g,{build:a}),build:a}}return{build:a,withPersist:p}},I=e=>d.defineStore(e.name,{state:()=>({state:new e}),actions:{set(t){this.$patch({state:t})},get(){return S(e,this.$state.state)}}});exports.create=y;exports.useStoreFor=I; |
@@ -29,6 +29,6 @@ import { defineStore as d } from "pinia"; | ||
} | ||
const P = f && n ? O(u, n, f) : g(u, m); | ||
const v = f && n ? O(u, n, f) : g(u, m); | ||
S = (I) => ({ | ||
...r(I), | ||
...P | ||
...v | ||
}); | ||
@@ -47,3 +47,3 @@ } | ||
} | ||
}, v = d(e, { | ||
}, P = d(e, { | ||
state: () => S(h), | ||
@@ -53,3 +53,3 @@ actions: h | ||
return () => { | ||
const s = v(); | ||
const s = P(); | ||
return Object.assign(h, s), s; | ||
@@ -63,9 +63,11 @@ }; | ||
}, K = (e) => d(e.name, { | ||
state: () => new e(), | ||
state: () => ({ | ||
state: new e() | ||
}), | ||
actions: { | ||
save(t) { | ||
this.$patch(t); | ||
set(t) { | ||
this.$patch({ state: t }); | ||
}, | ||
get() { | ||
return l(e, this.$state); | ||
return l(e, this.$state.state); | ||
} | ||
@@ -72,0 +74,0 @@ } |
@@ -6,3 +6,5 @@ interface ImplicitStorage<S> { | ||
export type Store<S> = () => S; | ||
export type StoreWithService<T, S> = () => Store<T> & S & ImplicitStorage<T>; | ||
export type StoreWithService<T, S> = () => { | ||
state: T; | ||
} & S & ImplicitStorage<T>; | ||
export type StateCreator<S> = (store: ImplicitStorage<S>) => S; | ||
@@ -9,0 +11,0 @@ export type Newly<T> = { |
{ | ||
"name": "@codescouts/vue-store-beta", | ||
"version": "1.0.11", | ||
"version": "1.0.12", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.cjs.js", |
@@ -110,9 +110,11 @@ import { StateTree, _ActionsTree, defineStore } from "pinia"; | ||
const store = defineStore(Ctor.name, { | ||
state: () => new Ctor() as any, | ||
state: () => ({ | ||
state: new Ctor() as T, | ||
}), | ||
actions: { | ||
save(state: T) { | ||
this.$patch(state); | ||
set(state: T) { | ||
this.$patch({ state }); | ||
}, | ||
get(): T { | ||
return autoCreate(Ctor, this.$state); | ||
return autoCreate(Ctor, this.$state.state); | ||
}, | ||
@@ -119,0 +121,0 @@ }, |
@@ -7,3 +7,6 @@ interface ImplicitStorage<S> { | ||
export type Store<S> = () => S; | ||
export type StoreWithService<T, S> = () => Store<T> & S & ImplicitStorage<T>; | ||
export type StoreWithService<T, S> = () => { | ||
state: T; | ||
} & S & | ||
ImplicitStorage<T>; | ||
export type StateCreator<S> = (store: ImplicitStorage<S>) => S; | ||
@@ -10,0 +13,0 @@ |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
11240
291
0