@yakocloud/state-vocab 3.0.1 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -0
- package/dist/state-vocab.cjs.js +3 -3
- package/dist/state-vocab.es.js +154 -143
- package/dist/types/constants.d.ts +1 -0
- package/dist/types/main.utils.d.ts +1 -1
- package/dist/types/setup.d.ts +1 -0
- package/dist/types/state.d.ts +3 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -188,6 +188,7 @@ Wraps a nested object of `defineState()` nodes and injects dot-separated paths i
|
|
|
188
188
|
| Option | Type | Description | Default |
|
|
189
189
|
|---|---|---|---|
|
|
190
190
|
| `verbose` | `boolean \| undefined` | Log current state to the browser console on every change | `false` |
|
|
191
|
+
| `ssr` | `boolean \| undefined` | Defer storage reads until after hydration (Next.js / SSR) | `false` |
|
|
191
192
|
|
|
192
193
|
```ts
|
|
193
194
|
const storage = setupStorage({
|
|
@@ -207,6 +208,25 @@ Enable verbose logging during development:
|
|
|
207
208
|
const storage = setupStorage({ ... }, { verbose: true })
|
|
208
209
|
```
|
|
209
210
|
|
|
211
|
+
### SSR / Next.js
|
|
212
|
+
|
|
213
|
+
When using localStorage or sessionStorage in a Next.js app, the server renders with `defaultValue` while the client reads the persisted value — causing a hydration mismatch. Pass `ssr: true` to fix this:
|
|
214
|
+
|
|
215
|
+
```ts
|
|
216
|
+
// lib/storage.ts
|
|
217
|
+
const storage = setupStorage({
|
|
218
|
+
preference: {
|
|
219
|
+
theme: defineState<Theme>({ storage: localStorage, defaultValue: 'Dark' }),
|
|
220
|
+
},
|
|
221
|
+
}, { ssr: true })
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
With `ssr: true`:
|
|
225
|
+
- **Server & first client render** — always use `defaultValue`, storage is not read
|
|
226
|
+
- **After hydration** — `useLayoutEffect` fires synchronously before paint, reads storage and updates state
|
|
227
|
+
|
|
228
|
+
This guarantees the server and client produce identical markup, and the value from storage is applied without a visible flash.
|
|
229
|
+
|
|
210
230
|
## `useState` Hook
|
|
211
231
|
|
|
212
232
|
Each state node exposes a `.useState()` method that works like React's built-in `useState` but adds persistence and callbacks.
|
|
@@ -389,6 +409,7 @@ createRoot(document.getElementById('root')!).render(<Page />)
|
|
|
389
409
|
| Option | Type | Default |
|
|
390
410
|
|---|---|---|
|
|
391
411
|
| `verbose` | `boolean \| undefined` | `false` |
|
|
412
|
+
| `ssr` | `boolean \| undefined` | `false` |
|
|
392
413
|
|
|
393
414
|
Returns a proxied copy of `tree` with paths injected into all leaf nodes.
|
|
394
415
|
|
package/dist/state-vocab.cjs.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
`),s=[],
|
|
3
|
-
`),...
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("react"),R=Symbol("state-def"),T=Symbol("state-path"),z=Symbol("state-verbose"),x=Symbol("state-ssr");function C(t,e,s){if(!e)return t;const o=e.split(".");let c=t;for(const r of o)if(c!==null&&typeof c=="object"&&r in c)c=c[r];else return s;return c===void 0?s:c}function j(t,e,s){const o=e.replace(/\[(\d+)\]/g,".$1").split(".");let c=t;for(let r=0;r<o.length-1;r++){const n=o[r],a=o[r+1];(c[n]===void 0||c[n]===null)&&(c[n]=/^\d+$/.test(a)?[]:{}),c=c[n]}return c[o[o.length-1]]=s,t}function D(t,e=0){let s;return function(...o){s!==void 0&&clearTimeout(s),s=setTimeout(()=>{s=void 0,t.apply(this,o)},e)}}function O(t,e,s=[]){return f.useMemo(()=>D(t,e),s)}function P(t){const e=JSON.stringify(t,null,2).split(`
|
|
2
|
+
`),s=[],o=[];for(const c of e){const r=c.match(/^(\s*)"([^"]+)"(\s*:\s*)(.+)$/);if(r){const[,n,a,d,h]=r;s.push(`${n}%c"${a}"%c${d}%c${h}`),o.push("color: #9cdcfe; font-weight: bold","color: #cccccc","color: #ce9178")}else s.push(`%c${c}`),o.push("color: #cccccc")}console.log(s.join(`
|
|
3
|
+
`),...o,t)}const M=t=>typeof t=="function",_=t=>typeof t=="function",E=t=>typeof t<"u",$=t=>_(t)?t():t,A=typeof window>"u",F=A?f.useEffect:f.useLayoutEffect;class J{#e;#t;constructor(){this.#e={},this.#t=new Set}subscribe(e){return this.#t.add(e),()=>this.#t.delete(e)}getClientSnapshot(){return this.#e}getServerSnapshot(){return this.#e}get(e){return C(this.#e,e)}set(e,s){const o=C(this.#e,e),c=M(s)?s(o):s,r={...this.#e};j(r,e,c),this.#e=r,this.#t.forEach(n=>n())}}function B(t={}){const e=new J,s=t.serialize??JSON.stringify,o=t.deserialize??JSON.parse,c=(r,n,a)=>{const d=n.getItem(r);d===null?E(a)&&n.setItem(r,s(a)):e.set(r,o(d))};return{[R]:!0,[T]:"",[z]:!1,[x]:!1,useState(r){const n=A?void 0:$(t.storage),a=$(t.defaultValue),d=t.bidirectional;r??={};const h=$(r.defaultValue)??a,p=r.bidirectional??d,u=O(r.onSet??(()=>{}),r.delayedSet,[]),i=this[T],S=this[z],y=this[x],g=f.useRef(void 0),w=f.useRef(!1);if(!w.current){w.current=!0;let l=e.get(i);E(l)||(l=h,E(l)&&e.set(i,l)),!y&&n&&c(i,n,l)}const V=f.useSyncExternalStore(e.subscribe.bind(e),e.getClientSnapshot.bind(e),e.getServerSnapshot.bind(e));S&&P(V);const v=C(V,i,h);g.current=v,F(()=>{!y||!n||c(i,n,v)},[]);const b=f.useEffectEvent(l=>{if(l.key!==i)return;const m=l.newValue,I=(m===null?null:o(m))??h;E(I)&&(e.set(i,I),u(I,g.current))});f.useEffect(()=>{if(p)return window.addEventListener("storage",b),()=>window.removeEventListener("storage",b)},[p]);const k=f.useCallback(l=>{const m=M(l)?l(g.current):l;e.set(i,m),u(m,g.current),n&&n.setItem(i,s(m))},[i,n,s,u]),N=f.useCallback(()=>{const l=h;if(!E(l)){n?.removeItem(i);return}e.set(i,l),u(l,g.current),n&&n.setItem(i,s(l))},[i,h,n,s,u]);return[v,k,N]},toString(){return this[T]}}}function L(t,e){const{path:s="",verbose:o,ssr:c,cache:r}=e;let n=r.proxy.get(t);n||(n=new Map,r.proxy.set(t,n));const a=n.get(s);if(a)return a;const d=new Proxy(t,{get(h,p){const u=h[p],i=s?`${s}.${String(p)}`:String(p);if(u&&typeof u=="object"&&R in u){const S=u;let y=r.leaf.get(S);y||(y=new Map,r.leaf.set(S,y));const g=y.get(i);if(g)return g;const w=Reflect.ownKeys(S).filter(b=>typeof S[b]=="function"),V=Object.fromEntries(w.map(b=>[b,(...k)=>S[b].call({...S,[T]:i,[z]:o,[x]:c},...k)])),v={...S,...V};return y.set(i,v),v}return u&&typeof u=="object"?L(u,{...e,path:i}):u}});return n.set(s,d),d}function K(t,e){return L(t,{...e,cache:{proxy:new WeakMap,leaf:new WeakMap}})}exports.defineState=B;exports.setupStorage=K;
|
package/dist/state-vocab.es.js
CHANGED
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
import { useMemo as
|
|
2
|
-
const
|
|
3
|
-
function
|
|
4
|
-
if (!
|
|
5
|
-
return
|
|
6
|
-
const
|
|
7
|
-
let
|
|
8
|
-
for (const
|
|
9
|
-
if (
|
|
10
|
-
|
|
1
|
+
import { useMemo as j, useRef as C, useSyncExternalStore as F, useEffect as A, useLayoutEffect as J, useEffectEvent as O, useCallback as R } from "react";
|
|
2
|
+
const L = Symbol("state-def"), V = Symbol("state-path"), k = Symbol("state-verbose"), z = Symbol("state-ssr");
|
|
3
|
+
function x(t, e, n) {
|
|
4
|
+
if (!e)
|
|
5
|
+
return t;
|
|
6
|
+
const o = e.split(".");
|
|
7
|
+
let c = t;
|
|
8
|
+
for (const r of o)
|
|
9
|
+
if (c !== null && typeof c == "object" && r in c)
|
|
10
|
+
c = c[r];
|
|
11
11
|
else
|
|
12
|
-
return
|
|
13
|
-
return
|
|
12
|
+
return n;
|
|
13
|
+
return c === void 0 ? n : c;
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
const
|
|
17
|
-
let
|
|
18
|
-
for (let
|
|
19
|
-
const
|
|
20
|
-
(
|
|
15
|
+
function P(t, e, n) {
|
|
16
|
+
const o = e.replace(/\[(\d+)\]/g, ".$1").split(".");
|
|
17
|
+
let c = t;
|
|
18
|
+
for (let r = 0; r < o.length - 1; r++) {
|
|
19
|
+
const s = o[r], a = o[r + 1];
|
|
20
|
+
(c[s] === void 0 || c[s] === null) && (c[s] = /^\d+$/.test(a) ? [] : {}), c = c[s];
|
|
21
21
|
}
|
|
22
|
-
return
|
|
22
|
+
return c[o[o.length - 1]] = n, t;
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
let
|
|
26
|
-
return function(...
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
},
|
|
24
|
+
function B(t, e = 0) {
|
|
25
|
+
let n;
|
|
26
|
+
return function(...o) {
|
|
27
|
+
n !== void 0 && clearTimeout(n), n = setTimeout(() => {
|
|
28
|
+
n = void 0, t.apply(this, o);
|
|
29
|
+
}, e);
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
function
|
|
33
|
-
return
|
|
34
|
-
() =>
|
|
32
|
+
function K(t, e, n = []) {
|
|
33
|
+
return j(
|
|
34
|
+
() => B(t, e),
|
|
35
35
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
36
|
-
|
|
36
|
+
n
|
|
37
37
|
);
|
|
38
38
|
}
|
|
39
|
-
function
|
|
40
|
-
const
|
|
41
|
-
`),
|
|
42
|
-
for (const
|
|
43
|
-
const
|
|
44
|
-
if (
|
|
45
|
-
const [,
|
|
46
|
-
|
|
39
|
+
function W(t) {
|
|
40
|
+
const e = JSON.stringify(t, null, 2).split(`
|
|
41
|
+
`), n = [], o = [];
|
|
42
|
+
for (const c of e) {
|
|
43
|
+
const r = c.match(/^(\s*)"([^"]+)"(\s*:\s*)(.+)$/);
|
|
44
|
+
if (r) {
|
|
45
|
+
const [, s, a, f, d] = r;
|
|
46
|
+
n.push(`${s}%c"${a}"%c${f}%c${d}`), o.push(
|
|
47
47
|
"color: #9cdcfe; font-weight: bold",
|
|
48
48
|
"color: #cccccc",
|
|
49
49
|
"color: #ce9178"
|
|
50
50
|
);
|
|
51
51
|
} else
|
|
52
|
-
|
|
52
|
+
n.push(`%c${c}`), o.push("color: #cccccc");
|
|
53
53
|
}
|
|
54
|
-
console.log(
|
|
55
|
-
`), ...
|
|
54
|
+
console.log(n.join(`
|
|
55
|
+
`), ...o, t);
|
|
56
56
|
}
|
|
57
|
-
const
|
|
58
|
-
class
|
|
57
|
+
const M = (t) => typeof t == "function", H = (t) => typeof t == "function", m = (t) => typeof t < "u", $ = (t) => H(t) ? t() : t, N = typeof window > "u", q = N ? A : J;
|
|
58
|
+
class G {
|
|
59
59
|
#e;
|
|
60
60
|
#t;
|
|
61
61
|
constructor() {
|
|
62
62
|
this.#e = {}, this.#t = /* @__PURE__ */ new Set();
|
|
63
63
|
}
|
|
64
|
-
subscribe(
|
|
65
|
-
return this.#t.add(
|
|
64
|
+
subscribe(e) {
|
|
65
|
+
return this.#t.add(e), () => this.#t.delete(e);
|
|
66
66
|
}
|
|
67
67
|
getClientSnapshot() {
|
|
68
68
|
return this.#e;
|
|
@@ -70,84 +70,88 @@ class K {
|
|
|
70
70
|
getServerSnapshot() {
|
|
71
71
|
return this.#e;
|
|
72
72
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
get(e) {
|
|
74
|
+
return x(this.#e, e);
|
|
75
|
+
}
|
|
76
|
+
set(e, n) {
|
|
77
|
+
const o = x(this.#e, e), c = M(n) ? n(o) : n, r = { ...this.#e };
|
|
78
|
+
P(r, e, c), this.#e = r, this.#t.forEach((s) => s());
|
|
76
79
|
}
|
|
77
80
|
}
|
|
78
|
-
function
|
|
79
|
-
const
|
|
81
|
+
function X(t = {}) {
|
|
82
|
+
const e = new G(), n = t.serialize ?? JSON.stringify, o = t.deserialize ?? JSON.parse, c = (r, s, a) => {
|
|
83
|
+
const f = s.getItem(r);
|
|
84
|
+
f === null ? m(a) && s.setItem(r, n(a)) : e.set(r, o(f));
|
|
85
|
+
};
|
|
80
86
|
return {
|
|
81
|
-
[
|
|
87
|
+
[L]: !0,
|
|
82
88
|
// marks this object as a leaf in the router tree
|
|
83
89
|
[V]: "",
|
|
84
90
|
// placeholder; injected at runtime by injectPaths()
|
|
85
|
-
[
|
|
91
|
+
[k]: !1,
|
|
92
|
+
// placeholder
|
|
93
|
+
[z]: !1,
|
|
86
94
|
// placeholder
|
|
87
|
-
useState(
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
const
|
|
91
|
-
|
|
95
|
+
useState(r) {
|
|
96
|
+
const s = N ? void 0 : $(t.storage), a = $(t.defaultValue), f = t.bidirectional;
|
|
97
|
+
r ??= {};
|
|
98
|
+
const d = $(r.defaultValue) ?? a, p = r.bidirectional ?? f, u = K(
|
|
99
|
+
r.onSet ?? (() => {
|
|
92
100
|
}),
|
|
93
|
-
|
|
101
|
+
r.delayedSet,
|
|
94
102
|
[]
|
|
95
|
-
),
|
|
96
|
-
if (!
|
|
97
|
-
|
|
98
|
-
let
|
|
99
|
-
|
|
100
|
-
if (i = u, r) {
|
|
101
|
-
const d = r.getItem(c);
|
|
102
|
-
d === null ? v(i) && r.setItem(c, n(i)) : i = o(d);
|
|
103
|
-
}
|
|
104
|
-
v(i) && t.set(c, i);
|
|
105
|
-
}
|
|
103
|
+
), i = this[V], h = this[k], y = this[z], S = C(void 0), E = C(!1);
|
|
104
|
+
if (!E.current) {
|
|
105
|
+
E.current = !0;
|
|
106
|
+
let l = e.get(i);
|
|
107
|
+
m(l) || (l = d, m(l) && e.set(i, l)), !y && s && c(i, s, l);
|
|
106
108
|
}
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
const w = F(
|
|
110
|
+
e.subscribe.bind(e),
|
|
111
|
+
e.getClientSnapshot.bind(e),
|
|
112
|
+
e.getServerSnapshot.bind(e)
|
|
111
113
|
);
|
|
112
|
-
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
h && W(w);
|
|
115
|
+
const b = x(w, i, d);
|
|
116
|
+
S.current = b, q(() => {
|
|
117
|
+
!y || !s || c(i, s, b);
|
|
118
|
+
}, []);
|
|
119
|
+
const g = O((l) => {
|
|
120
|
+
if (l.key !== i)
|
|
117
121
|
return;
|
|
118
|
-
const
|
|
119
|
-
|
|
122
|
+
const v = l.newValue, I = (v === null ? null : o(v)) ?? d;
|
|
123
|
+
m(I) && (e.set(i, I), u(I, S.current));
|
|
120
124
|
});
|
|
121
|
-
|
|
122
|
-
if (
|
|
123
|
-
return window.addEventListener("storage",
|
|
124
|
-
}, [
|
|
125
|
-
const
|
|
126
|
-
const
|
|
127
|
-
|
|
125
|
+
A(() => {
|
|
126
|
+
if (p)
|
|
127
|
+
return window.addEventListener("storage", g), () => window.removeEventListener("storage", g);
|
|
128
|
+
}, [p]);
|
|
129
|
+
const T = R((l) => {
|
|
130
|
+
const v = M(l) ? l(S.current) : l;
|
|
131
|
+
e.set(i, v), u(v, S.current), s && s.setItem(i, n(v));
|
|
128
132
|
}, [
|
|
129
|
-
|
|
130
|
-
|
|
133
|
+
i,
|
|
134
|
+
s,
|
|
131
135
|
n,
|
|
132
|
-
|
|
133
|
-
]),
|
|
134
|
-
const
|
|
135
|
-
if (!
|
|
136
|
-
|
|
136
|
+
u
|
|
137
|
+
]), _ = R(() => {
|
|
138
|
+
const l = d;
|
|
139
|
+
if (!m(l)) {
|
|
140
|
+
s?.removeItem(i);
|
|
137
141
|
return;
|
|
138
142
|
}
|
|
139
|
-
|
|
143
|
+
e.set(i, l), u(l, S.current), s && s.setItem(i, n(l));
|
|
140
144
|
}, [
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
145
|
+
i,
|
|
146
|
+
d,
|
|
147
|
+
s,
|
|
144
148
|
n,
|
|
145
|
-
|
|
149
|
+
u
|
|
146
150
|
]);
|
|
147
151
|
return [
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
152
|
+
b,
|
|
153
|
+
T,
|
|
154
|
+
_
|
|
151
155
|
];
|
|
152
156
|
},
|
|
153
157
|
/** Returns the fully qualified job name (dot-separated path). */
|
|
@@ -156,57 +160,64 @@ function q(e = {}) {
|
|
|
156
160
|
}
|
|
157
161
|
};
|
|
158
162
|
}
|
|
159
|
-
|
|
160
|
-
function P(e, t) {
|
|
161
|
-
t ??= {};
|
|
163
|
+
function D(t, e) {
|
|
162
164
|
const {
|
|
163
|
-
path:
|
|
164
|
-
verbose:
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
165
|
+
path: n = "",
|
|
166
|
+
verbose: o,
|
|
167
|
+
ssr: c,
|
|
168
|
+
cache: r
|
|
169
|
+
} = e;
|
|
170
|
+
let s = r.proxy.get(t);
|
|
171
|
+
s || (s = /* @__PURE__ */ new Map(), r.proxy.set(t, s));
|
|
172
|
+
const a = s.get(n);
|
|
173
|
+
if (a)
|
|
174
|
+
return a;
|
|
175
|
+
const f = new Proxy(t, {
|
|
176
|
+
get(d, p) {
|
|
177
|
+
const u = d[p], i = n ? `${n}.${String(p)}` : String(p);
|
|
178
|
+
if (u && typeof u == "object" && L in u) {
|
|
179
|
+
const h = u;
|
|
180
|
+
let y = r.leaf.get(h);
|
|
181
|
+
y || (y = /* @__PURE__ */ new Map(), r.leaf.set(h, y));
|
|
182
|
+
const S = y.get(i);
|
|
183
|
+
if (S)
|
|
184
|
+
return S;
|
|
185
|
+
const E = Reflect.ownKeys(h).filter(
|
|
186
|
+
(g) => typeof h[g] == "function"
|
|
187
|
+
), w = Object.fromEntries(
|
|
188
|
+
E.map((g) => [
|
|
189
|
+
g,
|
|
190
|
+
(...T) => h[g].call(
|
|
187
191
|
{
|
|
188
|
-
...
|
|
189
|
-
[V]:
|
|
190
|
-
[
|
|
192
|
+
...h,
|
|
193
|
+
[V]: i,
|
|
194
|
+
[k]: o,
|
|
195
|
+
[z]: c
|
|
191
196
|
},
|
|
192
|
-
...
|
|
197
|
+
...T
|
|
193
198
|
)
|
|
194
199
|
])
|
|
195
|
-
),
|
|
196
|
-
return
|
|
200
|
+
), b = { ...h, ...w };
|
|
201
|
+
return y.set(i, b), b;
|
|
197
202
|
}
|
|
198
|
-
return
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}) :
|
|
203
|
+
return u && typeof u == "object" ? D(u, {
|
|
204
|
+
...e,
|
|
205
|
+
path: i
|
|
206
|
+
}) : u;
|
|
202
207
|
}
|
|
203
208
|
});
|
|
204
|
-
return
|
|
209
|
+
return s.set(n, f), f;
|
|
205
210
|
}
|
|
206
|
-
function
|
|
207
|
-
return
|
|
211
|
+
function Y(t, e) {
|
|
212
|
+
return D(t, {
|
|
213
|
+
...e,
|
|
214
|
+
cache: {
|
|
215
|
+
proxy: /* @__PURE__ */ new WeakMap(),
|
|
216
|
+
leaf: /* @__PURE__ */ new WeakMap()
|
|
217
|
+
}
|
|
218
|
+
});
|
|
208
219
|
}
|
|
209
220
|
export {
|
|
210
|
-
|
|
211
|
-
|
|
221
|
+
X as defineState,
|
|
222
|
+
Y as setupStorage
|
|
212
223
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const toLocalDatetimeString: (date: Date | null) => string;
|
|
2
|
-
export declare const toDateString: (date: Date | null) => string
|
|
2
|
+
export declare const toDateString: (date: Date | null) => string;
|
package/dist/types/setup.d.ts
CHANGED
package/dist/types/state.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { STATE_DEFINITION, STATE_PATH, STATE_VERBOSE } from "./constants";
|
|
1
|
+
import { STATE_DEFINITION, STATE_PATH, STATE_SSR, STATE_VERBOSE } from "./constants";
|
|
2
2
|
import type { Deserialize, Serialize, ValueOrFactory, ValueOrTransformer } from "./state.types";
|
|
3
3
|
export declare function defineState<D>(definitionOptions?: {
|
|
4
4
|
storage?: ValueOrFactory<Storage>;
|
|
@@ -10,9 +10,11 @@ export declare function defineState<D>(definitionOptions?: {
|
|
|
10
10
|
[STATE_DEFINITION]: boolean;
|
|
11
11
|
[STATE_PATH]: string;
|
|
12
12
|
[STATE_VERBOSE]: boolean;
|
|
13
|
+
[STATE_SSR]: boolean;
|
|
13
14
|
useState(this: {
|
|
14
15
|
[STATE_PATH]: string;
|
|
15
16
|
[STATE_VERBOSE]: boolean;
|
|
17
|
+
[STATE_SSR]: boolean;
|
|
16
18
|
}, options?: {
|
|
17
19
|
defaultValue?: ValueOrFactory<D>;
|
|
18
20
|
delayedSet?: number;
|