@yakocloud/state-vocab 3.1.2 → 3.1.4
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 +69 -4
- package/dist/state-vocab.cjs.js +4 -4
- package/dist/state-vocab.es.js +252 -239
- package/dist/types/context.d.ts +6 -1
- package/dist/types/state.d.ts +10 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -103,7 +103,7 @@ defineState({
|
|
|
103
103
|
})
|
|
104
104
|
```
|
|
105
105
|
|
|
106
|
-
**Minimal API surface.**
|
|
106
|
+
**Minimal API surface.** Three exports: `defineState`, `setupStorage`, `VocabStateProvider`. No actions, reducers, selectors, or stores to configure.
|
|
107
107
|
|
|
108
108
|
## Installation
|
|
109
109
|
|
|
@@ -115,8 +115,13 @@ npm install @yakocloud/state-vocab react react-dom
|
|
|
115
115
|
|
|
116
116
|
## Quick Start
|
|
117
117
|
|
|
118
|
+
Wrap your app with `VocabStateProvider` at the root — this initializes an isolated store for the component tree. Then define and use state anywhere inside it.
|
|
119
|
+
Library SSR-requirements:
|
|
120
|
+
- `Per-request store`: A Next.js server can handle multiple requests simultaneously. This means that the store should be created per request and should not be shared across requests.
|
|
121
|
+
- `SSR friendly`: Next.js applications are rendered twice, first on the server and again on the client. Having different outputs on both the client and the server will result in "hydration errors." The store will have to be initialized on the server and then re-initialized on the client with the same data in order to avoid that.
|
|
122
|
+
|
|
118
123
|
```tsx
|
|
119
|
-
import { setupStorage, defineState } from '@yakocloud/state-vocab'
|
|
124
|
+
import { setupStorage, defineState, VocabStateProvider } from '@yakocloud/state-vocab'
|
|
120
125
|
|
|
121
126
|
type Theme = 'Dark' | 'White' | 'System'
|
|
122
127
|
|
|
@@ -131,6 +136,14 @@ const storage = setupStorage({
|
|
|
131
136
|
},
|
|
132
137
|
})
|
|
133
138
|
|
|
139
|
+
function App() {
|
|
140
|
+
return (
|
|
141
|
+
<VocabStateProvider>
|
|
142
|
+
<Settings />
|
|
143
|
+
</VocabStateProvider>
|
|
144
|
+
)
|
|
145
|
+
}
|
|
146
|
+
|
|
134
147
|
function Settings() {
|
|
135
148
|
const [theme, setTheme] = storage.path.to.theme.useState()
|
|
136
149
|
|
|
@@ -144,6 +157,38 @@ function Settings() {
|
|
|
144
157
|
}
|
|
145
158
|
```
|
|
146
159
|
|
|
160
|
+
## Setup
|
|
161
|
+
|
|
162
|
+
### `VocabStateProvider`
|
|
163
|
+
|
|
164
|
+
All components that call `.useState()` must be descendants of `VocabStateProvider`. It creates an isolated `VocabStore` instance for its subtree — multiple providers can coexist in the same app without sharing state.
|
|
165
|
+
|
|
166
|
+
```tsx
|
|
167
|
+
import { VocabStateProvider } from '@yakocloud/state-vocab'
|
|
168
|
+
|
|
169
|
+
// Wrap your app root
|
|
170
|
+
createRoot(document.getElementById('root')!).render(
|
|
171
|
+
<React.StrictMode>
|
|
172
|
+
<VocabStateProvider>
|
|
173
|
+
<App />
|
|
174
|
+
</VocabStateProvider>
|
|
175
|
+
</React.StrictMode>
|
|
176
|
+
)
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
You can mount multiple independent providers — each gets its own store:
|
|
180
|
+
|
|
181
|
+
```tsx
|
|
182
|
+
// Two isolated state trees — state does not bleed between them
|
|
183
|
+
<VocabStateProvider>
|
|
184
|
+
<WidgetA />
|
|
185
|
+
</VocabStateProvider>
|
|
186
|
+
|
|
187
|
+
<VocabStateProvider>
|
|
188
|
+
<WidgetB />
|
|
189
|
+
</VocabStateProvider>
|
|
190
|
+
```
|
|
191
|
+
|
|
147
192
|
## Core Concepts
|
|
148
193
|
|
|
149
194
|
### `defineState(options?)`
|
|
@@ -247,6 +292,8 @@ With `ssr: true`:
|
|
|
247
292
|
|
|
248
293
|
This guarantees the server and client produce identical markup, and the value from storage is applied without a visible flash.
|
|
249
294
|
|
|
295
|
+
Wrap your page or app root with `VocabStateProvider` as usual — it works correctly in both SSR and client environments.
|
|
296
|
+
|
|
250
297
|
## `useState` Hook
|
|
251
298
|
|
|
252
299
|
Each state node exposes a `.useState()` method that works like React's built-in `useState` but adds persistence and callbacks.
|
|
@@ -325,7 +372,9 @@ const storage = setupStorage({
|
|
|
325
372
|
## Full Example
|
|
326
373
|
|
|
327
374
|
```tsx
|
|
328
|
-
import
|
|
375
|
+
import React from 'react'
|
|
376
|
+
import { createRoot } from 'react-dom/client'
|
|
377
|
+
import { setupStorage, defineState, VocabStateProvider } from '@yakocloud/state-vocab'
|
|
329
378
|
|
|
330
379
|
type Theme = 'Dark' | 'White' | 'System'
|
|
331
380
|
|
|
@@ -409,7 +458,13 @@ function Dashboard() {
|
|
|
409
458
|
)
|
|
410
459
|
}
|
|
411
460
|
|
|
412
|
-
createRoot(document.getElementById('root')!).render(
|
|
461
|
+
createRoot(document.getElementById('root')!).render(
|
|
462
|
+
<React.StrictMode>
|
|
463
|
+
<VocabStateProvider>
|
|
464
|
+
<Page />
|
|
465
|
+
</VocabStateProvider>
|
|
466
|
+
</React.StrictMode>
|
|
467
|
+
)
|
|
413
468
|
```
|
|
414
469
|
|
|
415
470
|
## API Reference
|
|
@@ -434,6 +489,16 @@ createRoot(document.getElementById('root')!).render(<Page />)
|
|
|
434
489
|
|
|
435
490
|
Returns a proxied copy of `tree` with paths injected into all leaf nodes.
|
|
436
491
|
|
|
492
|
+
### `VocabStateProvider`
|
|
493
|
+
|
|
494
|
+
A React context provider that initializes a `VocabStore` for its subtree. Required — all components calling `.useState()` must be descendants of this provider.
|
|
495
|
+
|
|
496
|
+
```tsx
|
|
497
|
+
<VocabStateProvider>
|
|
498
|
+
<App />
|
|
499
|
+
</VocabStateProvider>
|
|
500
|
+
```
|
|
501
|
+
|
|
437
502
|
### `node.useState(options?)`
|
|
438
503
|
|
|
439
504
|
| Option | Type | Description |
|
package/dist/state-vocab.cjs.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("react");var M={exports:{}},I={};var re;function ve(){if(re)return I;re=1;var t=Symbol.for("react.transitional.element"),n=Symbol.for("react.fragment");function r(u,s,a){var i=null;if(a!==void 0&&(i=""+a),s.key!==void 0&&(i=""+s.key),"key"in s){a={};for(var c in s)c!=="key"&&(a[c]=s[c])}else a=s;return s=a.ref,{$$typeof:t,type:u,key:i,ref:s!==void 0?s:null,props:a}}return I.Fragment=n,I.jsx=r,I.jsxs=r,I}var $={};var ne;function Ee(){return ne||(ne=1,process.env.NODE_ENV!=="production"&&(function(){function t(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===de?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case p:return"Fragment";case O:return"Profiler";case k:return"StrictMode";case J:return"Suspense";case l:return"SuspenseList";case x:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case h:return"Portal";case w:return e.displayName||"Context";case P:return(e._context.displayName||"Context")+".Consumer";case V:var o=e.render;return e=e.displayName,e||(e=o.displayName||o.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case T:return o=e.displayName||null,o!==null?o:t(e.type)||"Memo";case j:o=e._payload,e=e._init;try{return t(e(o))}catch{}}return null}function n(e){return""+e}function r(e){try{n(e);var o=!1}catch{o=!0}if(o){o=console;var d=o.error,v=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return d.call(o,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",v),n(e)}}function u(e){if(e===p)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===j)return"<...>";try{var o=t(e);return o?"<"+o+">":"<...>"}catch{return"<...>"}}function s(){var e=W.A;return e===null?null:e.getOwner()}function a(){return Error("react-stack-top-frame")}function i(e){if(H.call(e,"key")){var o=Object.getOwnPropertyDescriptor(e,"key").get;if(o&&o.isReactWarning)return!1}return e.key!==void 0}function c(e,o){function d(){Z||(Z=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",o))}d.isReactWarning=!0,Object.defineProperty(e,"key",{get:d,configurable:!0})}function y(){var e=t(this.type);return Q[e]||(Q[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function R(e,o,d,v,Y,q){var E=d.ref;return e={$$typeof:S,type:e,key:o,props:d,_owner:v},(E!==void 0?E:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:y}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:Y}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:q}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function g(e,o,d,v,Y,q){var E=o.children;if(E!==void 0)if(v)if(be(E)){for(v=0;v<E.length;v++)f(E[v]);Object.freeze&&Object.freeze(E)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else f(E);if(H.call(o,"key")){E=t(e);var N=Object.keys(o).filter(function(me){return me!=="key"});v=0<N.length?"{key: someKey, "+N.join(": ..., ")+": ...}":"{key: someKey}",te[E+v]||(N=0<N.length?"{"+N.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
2
|
let props = %s;
|
|
3
3
|
<%s {...props} />
|
|
4
4
|
React keys must be passed directly to JSX without using spread:
|
|
5
5
|
let props = %s;
|
|
6
|
-
<%s key={someKey} {...props} />`,
|
|
7
|
-
`),r=[],
|
|
8
|
-
`),...
|
|
6
|
+
<%s key={someKey} {...props} />`,v,E,N,E),te[E+v]=!0)}if(E=null,d!==void 0&&(r(d),E=""+d),i(o)&&(r(o.key),E=""+o.key),"key"in o){d={};for(var G in o)G!=="key"&&(d[G]=o[G])}else d=o;return E&&c(d,typeof e=="function"?e.displayName||e.name||"Unknown":e),R(e,E,d,s(),Y,q)}function f(e){b(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===j&&(e._payload.status==="fulfilled"?b(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function b(e){return typeof e=="object"&&e!==null&&e.$$typeof===S}var m=_,S=Symbol.for("react.transitional.element"),h=Symbol.for("react.portal"),p=Symbol.for("react.fragment"),k=Symbol.for("react.strict_mode"),O=Symbol.for("react.profiler"),P=Symbol.for("react.consumer"),w=Symbol.for("react.context"),V=Symbol.for("react.forward_ref"),J=Symbol.for("react.suspense"),l=Symbol.for("react.suspense_list"),T=Symbol.for("react.memo"),j=Symbol.for("react.lazy"),x=Symbol.for("react.activity"),de=Symbol.for("react.client.reference"),W=m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,H=Object.prototype.hasOwnProperty,be=Array.isArray,U=console.createTask?console.createTask:function(){return null};m={react_stack_bottom_frame:function(e){return e()}};var Z,Q={},K=m.react_stack_bottom_frame.bind(m,a)(),ee=U(u(a)),te={};$.Fragment=p,$.jsx=function(e,o,d){var v=1e4>W.recentlyCreatedOwnerStacks++;return g(e,o,d,!1,v?Error("react-stack-top-frame"):K,v?U(u(e)):ee)},$.jsxs=function(e,o,d){var v=1e4>W.recentlyCreatedOwnerStacks++;return g(e,o,d,!0,v?Error("react-stack-top-frame"):K,v?U(u(e)):ee)}})()),$}var oe;function Se(){return oe||(oe=1,process.env.NODE_ENV==="production"?M.exports=ve():M.exports=Ee()),M.exports}var he=Se();function L(t,n,r){if(!n)return t;const u=n.split(".");let s=t;for(const a of u)if(s!==null&&typeof s=="object"&&a in s)s=s[a];else return r;return s===void 0?r:s}function pe(t,n,r){const u=n.replace(/\[(\d+)\]/g,".$1").split(".");let s=t;for(let a=0;a<u.length-1;a++){const i=u[a],c=u[a+1];(s[i]===void 0||s[i]===null)&&(s[i]=/^\d+$/.test(c)?[]:{}),s=s[i]}return s[u[u.length-1]]=r,t}function _e(t,n=0){let r;return function(...u){r!==void 0&&clearTimeout(r),r=setTimeout(()=>{r=void 0,t.apply(this,u)},n)}}function ye(t,n,r=[]){return _.useMemo(()=>_e(t,n),r)}function se(t){const n=JSON.stringify(t,null,2).split(`
|
|
7
|
+
`),r=[],u=[];for(const s of n){const a=s.match(/^(\s*)"([^"]+)"(\s*:\s*)(.+)$/);if(a){const[,i,c,y,R]=a;r.push(`${i}%c"${c}"%c${y}%c${R}`),u.push("color: #9cdcfe; font-weight: bold","color: #cccccc","color: #ce9178")}else r.push(`%c${s}`),u.push("color: #cccccc")}console.log(r.join(`
|
|
8
|
+
`),...u,t)}const ue=t=>typeof t=="function",Re=t=>typeof t=="function",A=t=>typeof t<"u",C=t=>Re(t)?t():t;class Te{#e;#t;constructor(){this.uid=Math.random().toString(36).slice(2),this.#e={},this.#t=new Set}subscribe(n){return this.#t.add(n),()=>this.#t.delete(n)}getClientSnapshot(){return this.#e}getServerSnapshot(){return this.#e}get(n){return L(this.#e,n)}set(n,r){const u=L(this.#e,n),s=ue(r)?r(u):r,a={...this.#e};pe(a,n,s),this.#e=a,this.#t.forEach(i=>i())}}const le=_.createContext({});function ae(t={}){const n=_.useContext(le);return t.verbose&&console.log(`[Store uid]: ${n.uid}`),n}function ge({children:t}){const n=_.useMemo(()=>new Te,[]);return he.jsx(le.Provider,{value:n,children:t})}const ie=Symbol("state-def"),z=Symbol("state-path"),D=Symbol("state-verbose"),B=Symbol("state-verbose-path"),F=Symbol("state-ssr"),X=typeof window>"u",ce=X?_.useEffect:_.useLayoutEffect;function ke(t={}){return{[ie]:!0,[z]:"",[D]:!1,[B]:"",[F]:!1,useState(n){const r=X?void 0:C(t.storage),u=C(t.defaultValue),s=t.bidirectional;n??={};const a=C(n.defaultValue)??u,i=n.bidirectional??s,c=this[z],y=this[D],R=this[B],g=this[F],f=ae({verbose:y}),b=t.serialize??JSON.stringify,m=t.deserialize??JSON.parse,S=(l,T,j)=>{const x=T.getItem(l);x===null?A(j)&&T.setItem(l,b(j)):f.set(l,m(x))},h=ye(n.onSet??(()=>{}),n.delayedSet,[]),p=_.useRef(void 0),k=_.useRef(!1);if(!k.current){k.current=!0;let l=f.get(c);A(l)||(l=a,A(l)&&f.set(c,l)),!g&&r&&S(c,r,l)}const O=_.useSyncExternalStore(f.subscribe.bind(f),f.getClientSnapshot.bind(f),f.getServerSnapshot.bind(f));if(y)if(R){const l=L(O,R);l&&se(l)}else se(O);const P=L(O,c,a);p.current=P,ce(()=>{!g||!r||S(c,r,P)},[]);const w=_.useEffectEvent(l=>{if(l.key!==c)return;const T=l.newValue,x=(T===null?null:m(T))??a;A(x)&&(f.set(c,x),h(x,p.current))});_.useEffect(()=>{if(i)return window.addEventListener("storage",w),()=>window.removeEventListener("storage",w)},[i]);const V=_.useCallback(l=>{const T=ue(l)?l(p.current):l;f.set(c,T),h(T,p.current),r&&r.setItem(c,b(T))},[f,c,h,r,b]),J=_.useCallback(()=>{const l=a;if(!A(l)){r?.removeItem(c);return}f.set(c,l),h(l,p.current),r&&r.setItem(c,b(l))},[a,f,c,h,r,b]);return[P,V,J]},useInitialState(n){const r=X?void 0:C(t.storage),u=C(t.defaultValue);n??={};const s=C(n.defaultValue)??u,a=this[z],i=this[D],c=this[F],y=ae({verbose:i}),R=t.serialize??JSON.stringify,g=t.deserialize??JSON.parse,f=(S,h,p)=>{const k=h.getItem(S);k===null?A(p)&&h.setItem(S,R(p)):y.set(S,g(k))},b=_.useRef(!1);let m;b.current||(b.current=!0,m=y.get(a),A(m)||(m=s,A(m)&&y.set(a,m)),!c&&r&&f(a,r,m)),ce(()=>{!c||!r||f(a,r,m)},[])},toString(){return this[z]}}}function fe(t,n){const{path:r="",verbose:u,verbosePath:s,ssr:a,cache:i}=n;let c=i.proxy.get(t);c||(c=new Map,i.proxy.set(t,c));const y=c.get(r);if(y)return y;const R=new Proxy(t,{get(g,f){const b=g[f],m=r?`${r}.${String(f)}`:String(f);if(b&&typeof b=="object"&&ie in b){const S=b;let h=i.leaf.get(S);h||(h=new Map,i.leaf.set(S,h));const p=h.get(m);if(p)return p;const k=Reflect.ownKeys(S).filter(w=>typeof S[w]=="function"),O=Object.fromEntries(k.map(w=>[w,(...V)=>S[w].call({...S,[z]:m,[D]:u,[B]:s,[F]:a},...V)])),P={...S,...O};return h.set(m,P),P}return b&&typeof b=="object"?fe(b,{...n,path:m}):b}});return c.set(r,R),R}function we(t,n){return fe(t,{...n,verbosePath:n?.verbosePath??"",cache:{proxy:new WeakMap,leaf:new WeakMap}})}exports.VocabStateProvider=ge;exports.defineState=ke;exports.setupStorage=we;
|
package/dist/state-vocab.es.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
function
|
|
5
|
-
if (
|
|
6
|
-
|
|
7
|
-
var t = Symbol.for("react.transitional.element"),
|
|
1
|
+
import he, { useMemo as ue, createContext as pe, useContext as _e, useRef as G, useEffect as ie, useLayoutEffect as ye, useSyncExternalStore as Re, useEffectEvent as Te, useCallback as re } from "react";
|
|
2
|
+
var Y = { exports: {} }, V = {};
|
|
3
|
+
var ne;
|
|
4
|
+
function ge() {
|
|
5
|
+
if (ne) return V;
|
|
6
|
+
ne = 1;
|
|
7
|
+
var t = Symbol.for("react.transitional.element"), n = Symbol.for("react.fragment");
|
|
8
8
|
function r(l, s, a) {
|
|
9
9
|
var i = null;
|
|
10
10
|
if (a !== void 0 && (i = "" + a), s.key !== void 0 && (i = "" + s.key), "key" in s) {
|
|
@@ -20,129 +20,129 @@ function Re() {
|
|
|
20
20
|
props: a
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
return
|
|
23
|
+
return V.Fragment = n, V.jsx = r, V.jsxs = r, V;
|
|
24
24
|
}
|
|
25
|
-
var
|
|
26
|
-
var
|
|
27
|
-
function
|
|
28
|
-
return
|
|
25
|
+
var I = {};
|
|
26
|
+
var oe;
|
|
27
|
+
function ke() {
|
|
28
|
+
return oe || (oe = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
29
29
|
function t(e) {
|
|
30
30
|
if (e == null) return null;
|
|
31
31
|
if (typeof e == "function")
|
|
32
|
-
return e.$$typeof ===
|
|
32
|
+
return e.$$typeof === ve ? null : e.displayName || e.name || null;
|
|
33
33
|
if (typeof e == "string") return e;
|
|
34
34
|
switch (e) {
|
|
35
|
-
case
|
|
35
|
+
case p:
|
|
36
36
|
return "Fragment";
|
|
37
|
-
case P:
|
|
38
|
-
return "Profiler";
|
|
39
37
|
case A:
|
|
38
|
+
return "Profiler";
|
|
39
|
+
case g:
|
|
40
40
|
return "StrictMode";
|
|
41
|
-
case
|
|
41
|
+
case L:
|
|
42
42
|
return "Suspense";
|
|
43
43
|
case u:
|
|
44
44
|
return "SuspenseList";
|
|
45
|
-
case
|
|
45
|
+
case x:
|
|
46
46
|
return "Activity";
|
|
47
47
|
}
|
|
48
48
|
if (typeof e == "object")
|
|
49
49
|
switch (typeof e.tag == "number" && console.error(
|
|
50
50
|
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
51
51
|
), e.$$typeof) {
|
|
52
|
-
case
|
|
52
|
+
case h:
|
|
53
53
|
return "Portal";
|
|
54
|
-
case
|
|
54
|
+
case k:
|
|
55
55
|
return e.displayName || "Context";
|
|
56
|
-
case
|
|
56
|
+
case w:
|
|
57
57
|
return (e._context.displayName || "Context") + ".Consumer";
|
|
58
|
-
case
|
|
59
|
-
var
|
|
60
|
-
return e = e.displayName, e || (e =
|
|
61
|
-
case
|
|
62
|
-
return
|
|
63
|
-
case
|
|
64
|
-
|
|
58
|
+
case C:
|
|
59
|
+
var o = e.render;
|
|
60
|
+
return e = e.displayName, e || (e = o.displayName || o.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
61
|
+
case R:
|
|
62
|
+
return o = e.displayName || null, o !== null ? o : t(e.type) || "Memo";
|
|
63
|
+
case O:
|
|
64
|
+
o = e._payload, e = e._init;
|
|
65
65
|
try {
|
|
66
|
-
return t(e(
|
|
66
|
+
return t(e(o));
|
|
67
67
|
} catch {
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
return null;
|
|
71
71
|
}
|
|
72
|
-
function
|
|
72
|
+
function n(e) {
|
|
73
73
|
return "" + e;
|
|
74
74
|
}
|
|
75
75
|
function r(e) {
|
|
76
76
|
try {
|
|
77
|
-
|
|
78
|
-
var
|
|
77
|
+
n(e);
|
|
78
|
+
var o = !1;
|
|
79
79
|
} catch {
|
|
80
|
-
|
|
80
|
+
o = !0;
|
|
81
81
|
}
|
|
82
|
-
if (
|
|
83
|
-
|
|
84
|
-
var
|
|
85
|
-
return
|
|
86
|
-
|
|
82
|
+
if (o) {
|
|
83
|
+
o = console;
|
|
84
|
+
var d = o.error, v = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
85
|
+
return d.call(
|
|
86
|
+
o,
|
|
87
87
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
88
|
-
|
|
89
|
-
),
|
|
88
|
+
v
|
|
89
|
+
), n(e);
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
function l(e) {
|
|
93
|
-
if (e ===
|
|
94
|
-
if (typeof e == "object" && e !== null && e.$$typeof ===
|
|
93
|
+
if (e === p) return "<>";
|
|
94
|
+
if (typeof e == "object" && e !== null && e.$$typeof === O)
|
|
95
95
|
return "<...>";
|
|
96
96
|
try {
|
|
97
|
-
var
|
|
98
|
-
return
|
|
97
|
+
var o = t(e);
|
|
98
|
+
return o ? "<" + o + ">" : "<...>";
|
|
99
99
|
} catch {
|
|
100
100
|
return "<...>";
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
function s() {
|
|
104
|
-
var e =
|
|
104
|
+
var e = J.A;
|
|
105
105
|
return e === null ? null : e.getOwner();
|
|
106
106
|
}
|
|
107
107
|
function a() {
|
|
108
108
|
return Error("react-stack-top-frame");
|
|
109
109
|
}
|
|
110
110
|
function i(e) {
|
|
111
|
-
if (
|
|
112
|
-
var
|
|
113
|
-
if (
|
|
111
|
+
if (H.call(e, "key")) {
|
|
112
|
+
var o = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
113
|
+
if (o && o.isReactWarning) return !1;
|
|
114
114
|
}
|
|
115
115
|
return e.key !== void 0;
|
|
116
116
|
}
|
|
117
|
-
function c(e,
|
|
118
|
-
function
|
|
119
|
-
|
|
117
|
+
function c(e, o) {
|
|
118
|
+
function d() {
|
|
119
|
+
Z || (Z = !0, console.error(
|
|
120
120
|
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
121
|
-
|
|
121
|
+
o
|
|
122
122
|
));
|
|
123
123
|
}
|
|
124
|
-
|
|
125
|
-
get:
|
|
124
|
+
d.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
125
|
+
get: d,
|
|
126
126
|
configurable: !0
|
|
127
127
|
});
|
|
128
128
|
}
|
|
129
|
-
function
|
|
129
|
+
function _() {
|
|
130
130
|
var e = t(this.type);
|
|
131
|
-
return
|
|
131
|
+
return Q[e] || (Q[e] = !0, console.error(
|
|
132
132
|
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
133
133
|
)), e = this.props.ref, e !== void 0 ? e : null;
|
|
134
134
|
}
|
|
135
|
-
function y(e,
|
|
136
|
-
var
|
|
135
|
+
function y(e, o, d, v, z, U) {
|
|
136
|
+
var E = d.ref;
|
|
137
137
|
return e = {
|
|
138
|
-
$$typeof:
|
|
138
|
+
$$typeof: S,
|
|
139
139
|
type: e,
|
|
140
|
-
key:
|
|
141
|
-
props:
|
|
142
|
-
_owner:
|
|
143
|
-
}, (
|
|
140
|
+
key: o,
|
|
141
|
+
props: d,
|
|
142
|
+
_owner: v
|
|
143
|
+
}, (E !== void 0 ? E : null) !== null ? Object.defineProperty(e, "ref", {
|
|
144
144
|
enumerable: !1,
|
|
145
|
-
get:
|
|
145
|
+
get: _
|
|
146
146
|
}) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
|
|
147
147
|
configurable: !1,
|
|
148
148
|
enumerable: !1,
|
|
@@ -157,112 +157,112 @@ function Te() {
|
|
|
157
157
|
configurable: !1,
|
|
158
158
|
enumerable: !1,
|
|
159
159
|
writable: !0,
|
|
160
|
-
value:
|
|
160
|
+
value: z
|
|
161
161
|
}), Object.defineProperty(e, "_debugTask", {
|
|
162
162
|
configurable: !1,
|
|
163
163
|
enumerable: !1,
|
|
164
164
|
writable: !0,
|
|
165
|
-
value:
|
|
165
|
+
value: U
|
|
166
166
|
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
167
167
|
}
|
|
168
|
-
function
|
|
169
|
-
var
|
|
170
|
-
if (
|
|
171
|
-
if (
|
|
172
|
-
if (
|
|
173
|
-
for (
|
|
174
|
-
|
|
175
|
-
Object.freeze && Object.freeze(
|
|
168
|
+
function T(e, o, d, v, z, U) {
|
|
169
|
+
var E = o.children;
|
|
170
|
+
if (E !== void 0)
|
|
171
|
+
if (v)
|
|
172
|
+
if (Ee(E)) {
|
|
173
|
+
for (v = 0; v < E.length; v++)
|
|
174
|
+
f(E[v]);
|
|
175
|
+
Object.freeze && Object.freeze(E);
|
|
176
176
|
} else
|
|
177
177
|
console.error(
|
|
178
178
|
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
179
179
|
);
|
|
180
|
-
else
|
|
181
|
-
if (
|
|
182
|
-
|
|
183
|
-
var
|
|
184
|
-
return
|
|
180
|
+
else f(E);
|
|
181
|
+
if (H.call(o, "key")) {
|
|
182
|
+
E = t(e);
|
|
183
|
+
var j = Object.keys(o).filter(function(Se) {
|
|
184
|
+
return Se !== "key";
|
|
185
185
|
});
|
|
186
|
-
|
|
186
|
+
v = 0 < j.length ? "{key: someKey, " + j.join(": ..., ") + ": ...}" : "{key: someKey}", te[E + v] || (j = 0 < j.length ? "{" + j.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
187
187
|
`A props object containing a "key" prop is being spread into JSX:
|
|
188
188
|
let props = %s;
|
|
189
189
|
<%s {...props} />
|
|
190
190
|
React keys must be passed directly to JSX without using spread:
|
|
191
191
|
let props = %s;
|
|
192
192
|
<%s key={someKey} {...props} />`,
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
),
|
|
193
|
+
v,
|
|
194
|
+
E,
|
|
195
|
+
j,
|
|
196
|
+
E
|
|
197
|
+
), te[E + v] = !0);
|
|
198
198
|
}
|
|
199
|
-
if (
|
|
200
|
-
|
|
201
|
-
for (var
|
|
202
|
-
|
|
203
|
-
} else
|
|
204
|
-
return
|
|
205
|
-
|
|
199
|
+
if (E = null, d !== void 0 && (r(d), E = "" + d), i(o) && (r(o.key), E = "" + o.key), "key" in o) {
|
|
200
|
+
d = {};
|
|
201
|
+
for (var q in o)
|
|
202
|
+
q !== "key" && (d[q] = o[q]);
|
|
203
|
+
} else d = o;
|
|
204
|
+
return E && c(
|
|
205
|
+
d,
|
|
206
206
|
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
207
207
|
), y(
|
|
208
208
|
e,
|
|
209
|
-
|
|
210
|
-
|
|
209
|
+
E,
|
|
210
|
+
d,
|
|
211
211
|
s(),
|
|
212
|
-
|
|
213
|
-
|
|
212
|
+
z,
|
|
213
|
+
U
|
|
214
214
|
);
|
|
215
215
|
}
|
|
216
|
-
function
|
|
217
|
-
|
|
216
|
+
function f(e) {
|
|
217
|
+
m(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === O && (e._payload.status === "fulfilled" ? m(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
|
|
218
218
|
}
|
|
219
|
-
function
|
|
220
|
-
return typeof e == "object" && e !== null && e.$$typeof ===
|
|
219
|
+
function m(e) {
|
|
220
|
+
return typeof e == "object" && e !== null && e.$$typeof === S;
|
|
221
221
|
}
|
|
222
|
-
var
|
|
222
|
+
var b = he, S = Symbol.for("react.transitional.element"), h = Symbol.for("react.portal"), p = Symbol.for("react.fragment"), g = Symbol.for("react.strict_mode"), A = Symbol.for("react.profiler"), w = Symbol.for("react.consumer"), k = Symbol.for("react.context"), C = Symbol.for("react.forward_ref"), L = Symbol.for("react.suspense"), u = Symbol.for("react.suspense_list"), R = Symbol.for("react.memo"), O = Symbol.for("react.lazy"), x = Symbol.for("react.activity"), ve = Symbol.for("react.client.reference"), J = b.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, H = Object.prototype.hasOwnProperty, Ee = Array.isArray, W = console.createTask ? console.createTask : function() {
|
|
223
223
|
return null;
|
|
224
224
|
};
|
|
225
|
-
|
|
225
|
+
b = {
|
|
226
226
|
react_stack_bottom_frame: function(e) {
|
|
227
227
|
return e();
|
|
228
228
|
}
|
|
229
229
|
};
|
|
230
|
-
var
|
|
231
|
-
|
|
230
|
+
var Z, Q = {}, K = b.react_stack_bottom_frame.bind(
|
|
231
|
+
b,
|
|
232
232
|
a
|
|
233
|
-
)(),
|
|
234
|
-
|
|
235
|
-
var
|
|
236
|
-
return
|
|
233
|
+
)(), ee = W(l(a)), te = {};
|
|
234
|
+
I.Fragment = p, I.jsx = function(e, o, d) {
|
|
235
|
+
var v = 1e4 > J.recentlyCreatedOwnerStacks++;
|
|
236
|
+
return T(
|
|
237
237
|
e,
|
|
238
|
-
|
|
239
|
-
|
|
238
|
+
o,
|
|
239
|
+
d,
|
|
240
240
|
!1,
|
|
241
|
-
|
|
242
|
-
|
|
241
|
+
v ? Error("react-stack-top-frame") : K,
|
|
242
|
+
v ? W(l(e)) : ee
|
|
243
243
|
);
|
|
244
|
-
},
|
|
245
|
-
var
|
|
246
|
-
return
|
|
244
|
+
}, I.jsxs = function(e, o, d) {
|
|
245
|
+
var v = 1e4 > J.recentlyCreatedOwnerStacks++;
|
|
246
|
+
return T(
|
|
247
247
|
e,
|
|
248
|
-
|
|
249
|
-
|
|
248
|
+
o,
|
|
249
|
+
d,
|
|
250
250
|
!0,
|
|
251
|
-
|
|
252
|
-
|
|
251
|
+
v ? Error("react-stack-top-frame") : K,
|
|
252
|
+
v ? W(l(e)) : ee
|
|
253
253
|
);
|
|
254
254
|
};
|
|
255
|
-
})()),
|
|
255
|
+
})()), I;
|
|
256
256
|
}
|
|
257
|
-
var
|
|
258
|
-
function
|
|
259
|
-
return
|
|
257
|
+
var se;
|
|
258
|
+
function we() {
|
|
259
|
+
return se || (se = 1, process.env.NODE_ENV === "production" ? Y.exports = ge() : Y.exports = ke()), Y.exports;
|
|
260
260
|
}
|
|
261
|
-
var
|
|
262
|
-
function
|
|
263
|
-
if (!
|
|
261
|
+
var xe = we();
|
|
262
|
+
function M(t, n, r) {
|
|
263
|
+
if (!n)
|
|
264
264
|
return t;
|
|
265
|
-
const l =
|
|
265
|
+
const l = n.split(".");
|
|
266
266
|
let s = t;
|
|
267
267
|
for (const a of l)
|
|
268
268
|
if (s !== null && typeof s == "object" && a in s)
|
|
@@ -271,8 +271,8 @@ function D(t, o, r) {
|
|
|
271
271
|
return r;
|
|
272
272
|
return s === void 0 ? r : s;
|
|
273
273
|
}
|
|
274
|
-
function
|
|
275
|
-
const l =
|
|
274
|
+
function Pe(t, n, r) {
|
|
275
|
+
const l = n.replace(/\[(\d+)\]/g, ".$1").split(".");
|
|
276
276
|
let s = t;
|
|
277
277
|
for (let a = 0; a < l.length - 1; a++) {
|
|
278
278
|
const i = l[a], c = l[a + 1];
|
|
@@ -280,29 +280,29 @@ function we(t, o, r) {
|
|
|
280
280
|
}
|
|
281
281
|
return s[l[l.length - 1]] = r, t;
|
|
282
282
|
}
|
|
283
|
-
function
|
|
283
|
+
function Ae(t, n = 0) {
|
|
284
284
|
let r;
|
|
285
285
|
return function(...l) {
|
|
286
286
|
r !== void 0 && clearTimeout(r), r = setTimeout(() => {
|
|
287
287
|
r = void 0, t.apply(this, l);
|
|
288
|
-
},
|
|
288
|
+
}, n);
|
|
289
289
|
};
|
|
290
290
|
}
|
|
291
|
-
function
|
|
292
|
-
return
|
|
293
|
-
() =>
|
|
291
|
+
function Oe(t, n, r = []) {
|
|
292
|
+
return ue(
|
|
293
|
+
() => Ae(t, n),
|
|
294
294
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
295
295
|
r
|
|
296
296
|
);
|
|
297
297
|
}
|
|
298
|
-
function
|
|
299
|
-
const
|
|
298
|
+
function ae(t) {
|
|
299
|
+
const n = JSON.stringify(t, null, 2).split(`
|
|
300
300
|
`), r = [], l = [];
|
|
301
|
-
for (const s of
|
|
301
|
+
for (const s of n) {
|
|
302
302
|
const a = s.match(/^(\s*)"([^"]+)"(\s*:\s*)(.+)$/);
|
|
303
303
|
if (a) {
|
|
304
|
-
const [, i, c,
|
|
305
|
-
r.push(`${i}%c"${c}"%c${
|
|
304
|
+
const [, i, c, _, y] = a;
|
|
305
|
+
r.push(`${i}%c"${c}"%c${_}%c${y}`), l.push(
|
|
306
306
|
"color: #9cdcfe; font-weight: bold",
|
|
307
307
|
"color: #cccccc",
|
|
308
308
|
"color: #ce9178"
|
|
@@ -313,15 +313,15 @@ function se(t) {
|
|
|
313
313
|
console.log(r.join(`
|
|
314
314
|
`), ...l, t);
|
|
315
315
|
}
|
|
316
|
-
const
|
|
317
|
-
class
|
|
316
|
+
const fe = (t) => typeof t == "function", je = (t) => typeof t == "function", P = (t) => typeof t < "u", N = (t) => je(t) ? t() : t;
|
|
317
|
+
class Ne {
|
|
318
318
|
#e;
|
|
319
319
|
#t;
|
|
320
320
|
constructor() {
|
|
321
321
|
this.uid = Math.random().toString(36).slice(2), this.#e = {}, this.#t = /* @__PURE__ */ new Set();
|
|
322
322
|
}
|
|
323
|
-
subscribe(
|
|
324
|
-
return this.#t.add(
|
|
323
|
+
subscribe(n) {
|
|
324
|
+
return this.#t.add(n), () => this.#t.delete(n);
|
|
325
325
|
}
|
|
326
326
|
getClientSnapshot() {
|
|
327
327
|
return this.#e;
|
|
@@ -329,154 +329,167 @@ class Oe {
|
|
|
329
329
|
getServerSnapshot() {
|
|
330
330
|
return this.#e;
|
|
331
331
|
}
|
|
332
|
-
get(
|
|
333
|
-
return
|
|
332
|
+
get(n) {
|
|
333
|
+
return M(this.#e, n);
|
|
334
334
|
}
|
|
335
|
-
set(
|
|
336
|
-
const l =
|
|
337
|
-
|
|
335
|
+
set(n, r) {
|
|
336
|
+
const l = M(this.#e, n), s = fe(r) ? r(l) : r, a = { ...this.#e };
|
|
337
|
+
Pe(a, n, s), this.#e = a, this.#t.forEach((i) => i());
|
|
338
338
|
}
|
|
339
339
|
}
|
|
340
|
-
const
|
|
341
|
-
function
|
|
342
|
-
|
|
340
|
+
const de = pe({});
|
|
341
|
+
function ce(t = {}) {
|
|
342
|
+
const n = _e(de);
|
|
343
|
+
return t.verbose && console.log(`[Store uid]: ${n.uid}`), n;
|
|
343
344
|
}
|
|
344
345
|
function Ve({ children: t }) {
|
|
345
|
-
const
|
|
346
|
-
return /* @__PURE__ */
|
|
346
|
+
const n = ue(() => new Ne(), []);
|
|
347
|
+
return /* @__PURE__ */ xe.jsx(de.Provider, { value: n, children: t });
|
|
347
348
|
}
|
|
348
|
-
const
|
|
349
|
-
function
|
|
349
|
+
const me = Symbol("state-def"), $ = Symbol("state-path"), D = Symbol("state-verbose"), B = Symbol("state-verbose-path"), F = Symbol("state-ssr"), X = typeof window > "u", le = X ? ie : ye;
|
|
350
|
+
function Ie(t = {}) {
|
|
350
351
|
return {
|
|
351
|
-
[
|
|
352
|
+
[me]: !0,
|
|
352
353
|
// marks this object as a leaf in the router tree
|
|
353
|
-
[
|
|
354
|
+
[$]: "",
|
|
354
355
|
// placeholder; injected at runtime by injectPaths()
|
|
355
|
-
[
|
|
356
|
+
[D]: !1,
|
|
356
357
|
// placeholder
|
|
357
|
-
[
|
|
358
|
+
[B]: "",
|
|
358
359
|
// placeholder
|
|
359
|
-
[
|
|
360
|
+
[F]: !1,
|
|
360
361
|
// placeholder
|
|
361
|
-
useState(
|
|
362
|
-
const r =
|
|
363
|
-
|
|
364
|
-
const a =
|
|
365
|
-
const
|
|
366
|
-
|
|
367
|
-
},
|
|
368
|
-
|
|
362
|
+
useState(n) {
|
|
363
|
+
const r = X ? void 0 : N(t.storage), l = N(t.defaultValue), s = t.bidirectional;
|
|
364
|
+
n ??= {};
|
|
365
|
+
const a = N(n.defaultValue) ?? l, i = n.bidirectional ?? s, c = this[$], _ = this[D], y = this[B], T = this[F], f = ce({ verbose: _ }), m = t.serialize ?? JSON.stringify, b = t.deserialize ?? JSON.parse, S = (u, R, O) => {
|
|
366
|
+
const x = R.getItem(u);
|
|
367
|
+
x === null ? P(O) && R.setItem(u, m(O)) : f.set(u, b(x));
|
|
368
|
+
}, h = Oe(
|
|
369
|
+
n.onSet ?? (() => {
|
|
369
370
|
}),
|
|
370
|
-
|
|
371
|
+
n.delayedSet,
|
|
371
372
|
[]
|
|
372
|
-
),
|
|
373
|
-
if (!
|
|
374
|
-
|
|
375
|
-
let u =
|
|
376
|
-
|
|
373
|
+
), p = G(void 0), g = G(!1);
|
|
374
|
+
if (!g.current) {
|
|
375
|
+
g.current = !0;
|
|
376
|
+
let u = f.get(c);
|
|
377
|
+
P(u) || (u = a, P(u) && f.set(c, u)), !T && r && S(c, r, u);
|
|
377
378
|
}
|
|
378
|
-
const
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
379
|
+
const A = Re(
|
|
380
|
+
f.subscribe.bind(f),
|
|
381
|
+
f.getClientSnapshot.bind(f),
|
|
382
|
+
f.getServerSnapshot.bind(f)
|
|
382
383
|
);
|
|
383
|
-
if (
|
|
384
|
+
if (_)
|
|
384
385
|
if (y) {
|
|
385
|
-
const u =
|
|
386
|
-
u &&
|
|
386
|
+
const u = M(A, y);
|
|
387
|
+
u && ae(u);
|
|
387
388
|
} else
|
|
388
|
-
|
|
389
|
-
const
|
|
390
|
-
|
|
391
|
-
!
|
|
389
|
+
ae(A);
|
|
390
|
+
const w = M(A, c, a);
|
|
391
|
+
p.current = w, le(() => {
|
|
392
|
+
!T || !r || S(c, r, w);
|
|
392
393
|
}, []);
|
|
393
|
-
const
|
|
394
|
+
const k = Te((u) => {
|
|
394
395
|
if (u.key !== c)
|
|
395
396
|
return;
|
|
396
|
-
const
|
|
397
|
-
|
|
397
|
+
const R = u.newValue, x = (R === null ? null : b(R)) ?? a;
|
|
398
|
+
P(x) && (f.set(c, x), h(x, p.current));
|
|
398
399
|
});
|
|
399
|
-
|
|
400
|
+
ie(() => {
|
|
400
401
|
if (i)
|
|
401
|
-
return window.addEventListener("storage",
|
|
402
|
+
return window.addEventListener("storage", k), () => window.removeEventListener("storage", k);
|
|
402
403
|
}, [i]);
|
|
403
|
-
const
|
|
404
|
-
const
|
|
405
|
-
|
|
406
|
-
}, [c, r,
|
|
404
|
+
const C = re((u) => {
|
|
405
|
+
const R = fe(u) ? u(p.current) : u;
|
|
406
|
+
f.set(c, R), h(R, p.current), r && r.setItem(c, m(R));
|
|
407
|
+
}, [f, c, h, r, m]), L = re(() => {
|
|
407
408
|
const u = a;
|
|
408
|
-
if (!
|
|
409
|
+
if (!P(u)) {
|
|
409
410
|
r?.removeItem(c);
|
|
410
411
|
return;
|
|
411
412
|
}
|
|
412
|
-
|
|
413
|
-
}, [c,
|
|
413
|
+
f.set(c, u), h(u, p.current), r && r.setItem(c, m(u));
|
|
414
|
+
}, [a, f, c, h, r, m]);
|
|
414
415
|
return [
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
416
|
+
w,
|
|
417
|
+
C,
|
|
418
|
+
L
|
|
418
419
|
];
|
|
419
420
|
},
|
|
421
|
+
useInitialState(n) {
|
|
422
|
+
const r = X ? void 0 : N(t.storage), l = N(t.defaultValue);
|
|
423
|
+
n ??= {};
|
|
424
|
+
const s = N(n.defaultValue) ?? l, a = this[$], i = this[D], c = this[F], _ = ce({ verbose: i }), y = t.serialize ?? JSON.stringify, T = t.deserialize ?? JSON.parse, f = (S, h, p) => {
|
|
425
|
+
const g = h.getItem(S);
|
|
426
|
+
g === null ? P(p) && h.setItem(S, y(p)) : _.set(S, T(g));
|
|
427
|
+
}, m = G(!1);
|
|
428
|
+
let b;
|
|
429
|
+
m.current || (m.current = !0, b = _.get(a), P(b) || (b = s, P(b) && _.set(a, b)), !c && r && f(a, r, b)), le(() => {
|
|
430
|
+
!c || !r || f(a, r, b);
|
|
431
|
+
}, []);
|
|
432
|
+
},
|
|
420
433
|
/** Returns the fully qualified job name (dot-separated path). */
|
|
421
434
|
toString() {
|
|
422
|
-
return this[
|
|
435
|
+
return this[$];
|
|
423
436
|
}
|
|
424
437
|
};
|
|
425
438
|
}
|
|
426
|
-
function
|
|
439
|
+
function be(t, n) {
|
|
427
440
|
const {
|
|
428
441
|
path: r = "",
|
|
429
442
|
verbose: l,
|
|
430
443
|
verbosePath: s,
|
|
431
444
|
ssr: a,
|
|
432
445
|
cache: i
|
|
433
|
-
} =
|
|
446
|
+
} = n;
|
|
434
447
|
let c = i.proxy.get(t);
|
|
435
448
|
c || (c = /* @__PURE__ */ new Map(), i.proxy.set(t, c));
|
|
436
|
-
const
|
|
437
|
-
if (
|
|
438
|
-
return
|
|
449
|
+
const _ = c.get(r);
|
|
450
|
+
if (_)
|
|
451
|
+
return _;
|
|
439
452
|
const y = new Proxy(t, {
|
|
440
|
-
get(
|
|
441
|
-
const
|
|
442
|
-
if (
|
|
443
|
-
const
|
|
444
|
-
let
|
|
445
|
-
|
|
446
|
-
const
|
|
447
|
-
if (
|
|
448
|
-
return
|
|
449
|
-
const
|
|
450
|
-
(
|
|
451
|
-
),
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
(...
|
|
453
|
+
get(T, f) {
|
|
454
|
+
const m = T[f], b = r ? `${r}.${String(f)}` : String(f);
|
|
455
|
+
if (m && typeof m == "object" && me in m) {
|
|
456
|
+
const S = m;
|
|
457
|
+
let h = i.leaf.get(S);
|
|
458
|
+
h || (h = /* @__PURE__ */ new Map(), i.leaf.set(S, h));
|
|
459
|
+
const p = h.get(b);
|
|
460
|
+
if (p)
|
|
461
|
+
return p;
|
|
462
|
+
const g = Reflect.ownKeys(S).filter(
|
|
463
|
+
(k) => typeof S[k] == "function"
|
|
464
|
+
), A = Object.fromEntries(
|
|
465
|
+
g.map((k) => [
|
|
466
|
+
k,
|
|
467
|
+
(...C) => S[k].call(
|
|
455
468
|
{
|
|
456
|
-
...
|
|
457
|
-
[
|
|
458
|
-
[
|
|
459
|
-
[
|
|
460
|
-
[
|
|
469
|
+
...S,
|
|
470
|
+
[$]: b,
|
|
471
|
+
[D]: l,
|
|
472
|
+
[B]: s,
|
|
473
|
+
[F]: a
|
|
461
474
|
},
|
|
462
|
-
...
|
|
475
|
+
...C
|
|
463
476
|
)
|
|
464
477
|
])
|
|
465
|
-
),
|
|
466
|
-
return
|
|
478
|
+
), w = { ...S, ...A };
|
|
479
|
+
return h.set(b, w), w;
|
|
467
480
|
}
|
|
468
|
-
return
|
|
469
|
-
...
|
|
470
|
-
path:
|
|
471
|
-
}) :
|
|
481
|
+
return m && typeof m == "object" ? be(m, {
|
|
482
|
+
...n,
|
|
483
|
+
path: b
|
|
484
|
+
}) : m;
|
|
472
485
|
}
|
|
473
486
|
});
|
|
474
487
|
return c.set(r, y), y;
|
|
475
488
|
}
|
|
476
|
-
function
|
|
477
|
-
return
|
|
478
|
-
...
|
|
479
|
-
verbosePath:
|
|
489
|
+
function $e(t, n) {
|
|
490
|
+
return be(t, {
|
|
491
|
+
...n,
|
|
492
|
+
verbosePath: n?.verbosePath ?? "",
|
|
480
493
|
cache: {
|
|
481
494
|
proxy: /* @__PURE__ */ new WeakMap(),
|
|
482
495
|
leaf: /* @__PURE__ */ new WeakMap()
|
|
@@ -485,6 +498,6 @@ function Ie(t, o) {
|
|
|
485
498
|
}
|
|
486
499
|
export {
|
|
487
500
|
Ve as VocabStateProvider,
|
|
488
|
-
|
|
489
|
-
|
|
501
|
+
Ie as defineState,
|
|
502
|
+
$e as setupStorage
|
|
490
503
|
};
|
package/dist/types/context.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { type PropsWithChildren } from "react";
|
|
2
2
|
import VocabStore from "./store";
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* @see method from from https://zustand.docs.pmnd.rs/learn/guides/nextjs
|
|
5
|
+
*/
|
|
6
|
+
export declare function useVocabStoreContext(options?: {
|
|
7
|
+
verbose?: boolean;
|
|
8
|
+
}): VocabStore;
|
|
4
9
|
export declare function VocabStoreContextProvider({ children }: PropsWithChildren): import("react/jsx-runtime").JSX.Element;
|
package/dist/types/state.d.ts
CHANGED
|
@@ -23,6 +23,16 @@ export declare function defineState<D>(definitionOptions?: {
|
|
|
23
23
|
bidirectional?: true;
|
|
24
24
|
onSet?(nextValue: NoInfer<D>, prevValue: NoInfer<D>): void;
|
|
25
25
|
}): readonly [D, (nextValue: ValueOrTransformer<D>) => void, () => void];
|
|
26
|
+
useInitialState(this: {
|
|
27
|
+
[STATE_PATH]: string;
|
|
28
|
+
[STATE_VERBOSE]: boolean;
|
|
29
|
+
[STATE_SSR]: boolean;
|
|
30
|
+
}, options?: {
|
|
31
|
+
defaultValue?: ValueOrFactory<D>;
|
|
32
|
+
delayedSet?: number;
|
|
33
|
+
bidirectional?: true;
|
|
34
|
+
onSet?(nextValue: NoInfer<D>, prevValue: NoInfer<D>): void;
|
|
35
|
+
}): void;
|
|
26
36
|
/** Returns the fully qualified job name (dot-separated path). */
|
|
27
37
|
toString(this: {
|
|
28
38
|
[STATE_PATH]: string;
|