@yakocloud/state-vocab 3.1.3 → 3.1.5

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 CHANGED
@@ -508,4 +508,23 @@ A React context provider that initializes a `VocabStore` for its subtree. Requir
508
508
  | `onSet` | `(next: T, prev: T) => void \| undefined` | Callback after state change |
509
509
  | `bidirectional` | `true \| undefined` | Sync state across browser tabs |
510
510
 
511
- Returns `[value, setValue, resetValue]`
511
+ Returns `[value, setValue, resetValue]`
512
+
513
+ ### `node.useInitialState(options)`
514
+
515
+ Initializes state without subscribing the caller component to re-renders. Use at layout or root components that only need to seed a value — not react to its changes.
516
+
517
+ | Option | Type | Description |
518
+ |---|---|---|
519
+ | `defaultValue` | `T \| (() => T)` | Value to seed. Required. |
520
+
521
+ ```tsx
522
+ function Page() {
523
+ // Seeds the value — this component will NOT re-render when pageProps changes
524
+ storage.demo.pageProps.useInitialState({
525
+ defaultValue: { title: 'Hello', count: 42 },
526
+ })
527
+
528
+ return <Dashboard />
529
+ }
530
+ ```
@@ -1,8 +1,8 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("react");var Y={exports:{}},N={};var te;function me(){if(te)return N;te=1;var t=Symbol.for("react.transitional.element"),n=Symbol.for("react.fragment");function r(l,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:l,key:i,ref:s!==void 0?s:null,props:a}}return N.Fragment=n,N.jsx=r,N.jsxs=r,N}var V={};var re;function ve(){return re||(re=1,process.env.NODE_ENV!=="production"&&(function(){function t(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===fe?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case _:return"Fragment";case x:return"Profiler";case O:return"StrictMode";case F:return"Suspense";case u:return"SuspenseList";case w: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 p:return"Portal";case g:return e.displayName||"Context";case k:return(e._context.displayName||"Context")+".Consumer";case C:var o=e.render;return e=e.displayName,e||(e=o.displayName||o.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case y:return o=e.displayName||null,o!==null?o:t(e.type)||"Memo";case A: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 f=o.error,b=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return f.call(o,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",b),n(e)}}function l(e){if(e===_)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===A)return"<...>";try{var o=t(e);return o?"<"+o+">":"<...>"}catch{return"<...>"}}function s(){var e=z.A;return e===null?null:e.getOwner()}function a(){return Error("react-stack-top-frame")}function i(e){if(X.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 f(){H||(H=!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))}f.isReactWarning=!0,Object.defineProperty(e,"key",{get:f,configurable:!0})}function R(){var e=t(this.type);return Z[e]||(Z[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 T(e,o,f,b,I,W){var m=f.ref;return e={$$typeof:S,type:e,key:o,props:f,_owner:b},(m!==void 0?m:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:R}):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:I}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:W}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function P(e,o,f,b,I,W){var m=o.children;if(m!==void 0)if(b)if(de(m)){for(b=0;b<m.length;b++)d(m[b]);Object.freeze&&Object.freeze(m)}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 d(m);if(X.call(o,"key")){m=t(e);var j=Object.keys(o).filter(function(be){return be!=="key"});b=0<j.length?"{key: someKey, "+j.join(": ..., ")+": ...}":"{key: someKey}",ee[m+b]||(j=0<j.length?"{"+j.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("react");var Y={exports:{}},V={};var re;function Ee(){if(re)return V;re=1;var t=Symbol.for("react.transitional.element"),n=Symbol.for("react.fragment");function r(u,o,a){var l=null;if(a!==void 0&&(l=""+a),o.key!==void 0&&(l=""+o.key),"key"in o){a={};for(var c in o)c!=="key"&&(a[c]=o[c])}else a=o;return o=a.ref,{$$typeof:t,type:u,key:l,ref:o!==void 0?o:null,props:a}}return V.Fragment=n,V.jsx=r,V.jsxs=r,V}var I={};var ne;function Se(){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===be?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case h:return"Fragment";case A:return"Profiler";case j:return"StrictMode";case J:return"Suspense";case i:return"SuspenseList";case P: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 p:return"Portal";case k:return e.displayName||"Context";case w:return(e._context.displayName||"Context")+".Consumer";case C:var s=e.render;return e=e.displayName,e||(e=s.displayName||s.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case T:return s=e.displayName||null,s!==null?s:t(e.type)||"Memo";case O:s=e._payload,e=e._init;try{return t(e(s))}catch{}}return null}function n(e){return""+e}function r(e){try{n(e);var s=!1}catch{s=!0}if(s){s=console;var b=s.error,m=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return b.call(s,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",m),n(e)}}function u(e){if(e===h)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===O)return"<...>";try{var s=t(e);return s?"<"+s+">":"<...>"}catch{return"<...>"}}function o(){var e=W.A;return e===null?null:e.getOwner()}function a(){return Error("react-stack-top-frame")}function l(e){if(H.call(e,"key")){var s=Object.getOwnPropertyDescriptor(e,"key").get;if(s&&s.isReactWarning)return!1}return e.key!==void 0}function c(e,s){function b(){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)",s))}b.isReactWarning=!0,Object.defineProperty(e,"key",{get:b,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,s,b,m,M,q){var v=b.ref;return e={$$typeof:S,type:e,key:s,props:b,_owner:m},(v!==void 0?v: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:M}),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,s,b,m,M,q){var v=s.children;if(v!==void 0)if(m)if(me(v)){for(m=0;m<v.length;m++)f(v[m]);Object.freeze&&Object.freeze(v)}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(v);if(H.call(s,"key")){v=t(e);var N=Object.keys(s).filter(function(ve){return ve!=="key"});m=0<N.length?"{key: someKey, "+N.join(": ..., ")+": ...}":"{key: someKey}",te[v+m]||(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} />`,b,m,j,m),ee[m+b]=!0)}if(m=null,f!==void 0&&(r(f),m=""+f),i(o)&&(r(o.key),m=""+o.key),"key"in o){f={};for(var J in o)J!=="key"&&(f[J]=o[J])}else f=o;return m&&c(f,typeof e=="function"?e.displayName||e.name||"Unknown":e),T(e,m,f,s(),I,W)}function d(e){v(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===A&&(e._payload.status==="fulfilled"?v(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function v(e){return typeof e=="object"&&e!==null&&e.$$typeof===S}var h=E,S=Symbol.for("react.transitional.element"),p=Symbol.for("react.portal"),_=Symbol.for("react.fragment"),O=Symbol.for("react.strict_mode"),x=Symbol.for("react.profiler"),k=Symbol.for("react.consumer"),g=Symbol.for("react.context"),C=Symbol.for("react.forward_ref"),F=Symbol.for("react.suspense"),u=Symbol.for("react.suspense_list"),y=Symbol.for("react.memo"),A=Symbol.for("react.lazy"),w=Symbol.for("react.activity"),fe=Symbol.for("react.client.reference"),z=h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,X=Object.prototype.hasOwnProperty,de=Array.isArray,L=console.createTask?console.createTask:function(){return null};h={react_stack_bottom_frame:function(e){return e()}};var H,Z={},Q=h.react_stack_bottom_frame.bind(h,a)(),K=L(l(a)),ee={};V.Fragment=_,V.jsx=function(e,o,f){var b=1e4>z.recentlyCreatedOwnerStacks++;return P(e,o,f,!1,b?Error("react-stack-top-frame"):Q,b?L(l(e)):K)},V.jsxs=function(e,o,f){var b=1e4>z.recentlyCreatedOwnerStacks++;return P(e,o,f,!0,b?Error("react-stack-top-frame"):Q,b?L(l(e)):K)}})()),V}var ne;function Ee(){return ne||(ne=1,process.env.NODE_ENV==="production"?Y.exports=me():Y.exports=ve()),Y.exports}var Se=Ee();function D(t,n,r){if(!n)return t;const l=n.split(".");let s=t;for(const a of l)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 l=n.replace(/\[(\d+)\]/g,".$1").split(".");let s=t;for(let a=0;a<l.length-1;a++){const i=l[a],c=l[a+1];(s[i]===void 0||s[i]===null)&&(s[i]=/^\d+$/.test(c)?[]:{}),s=s[i]}return s[l[l.length-1]]=r,t}function he(t,n=0){let r;return function(...l){r!==void 0&&clearTimeout(r),r=setTimeout(()=>{r=void 0,t.apply(this,l)},n)}}function _e(t,n,r=[]){return E.useMemo(()=>he(t,n),r)}function oe(t){const n=JSON.stringify(t,null,2).split(`
7
- `),r=[],l=[];for(const s of n){const a=s.match(/^(\s*)"([^"]+)"(\s*:\s*)(.+)$/);if(a){const[,i,c,R,T]=a;r.push(`${i}%c"${c}"%c${R}%c${T}`),l.push("color: #9cdcfe; font-weight: bold","color: #cccccc","color: #ce9178")}else r.push(`%c${s}`),l.push("color: #cccccc")}console.log(r.join(`
8
- `),...l,t)}const se=t=>typeof t=="function",ye=t=>typeof t=="function",$=t=>typeof t<"u",U=t=>ye(t)?t():t;class Re{#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 D(this.#e,n)}set(n,r){const l=D(this.#e,n),s=se(r)?r(l):r,a={...this.#e};pe(a,n,s),this.#e=a,this.#t.forEach(i=>i())}}const ae=E.createContext({});function ce(t={}){const n=E.useContext(ae);return t.verbose&&console.log(`[${ce.name}]: `,n.uid),n}function Te({children:t}){const n=E.useMemo(()=>new Re,[]);return Se.jsx(ae.Provider,{value:n,children:t})}const ue=Symbol("state-def"),M=Symbol("state-path"),q=Symbol("state-verbose"),G=Symbol("state-verbose-path"),B=Symbol("state-ssr"),le=typeof window>"u",ge=le?E.useEffect:E.useLayoutEffect;function ke(t={}){return{[ue]:!0,[M]:"",[q]:!1,[G]:"",[B]:!1,useState(n){const r=le?void 0:U(t.storage),l=U(t.defaultValue),s=t.bidirectional;n??={};const a=U(n.defaultValue)??l,i=n.bidirectional??s,c=this[M],R=this[q],T=this[G],P=this[B],d=ce({verbose:R}),v=t.serialize??JSON.stringify,h=t.deserialize??JSON.parse,S=(u,y,A)=>{const w=y.getItem(u);w===null?$(A)&&y.setItem(u,v(A)):d.set(u,h(w))},p=_e(n.onSet??(()=>{}),n.delayedSet,[]),_=E.useRef(void 0),O=E.useRef(!1);if(!O.current){O.current=!0;let u=d.get(c);$(u)||(u=a,$(u)&&d.set(c,u)),!P&&r&&S(c,r,u)}const x=E.useSyncExternalStore(d.subscribe.bind(d),d.getClientSnapshot.bind(d),d.getServerSnapshot.bind(d));if(R)if(T){const u=D(x,T);u&&oe(u)}else oe(x);const k=D(x,c,a);_.current=k,ge(()=>{!P||!r||S(c,r,k)},[]);const g=E.useEffectEvent(u=>{if(u.key!==c)return;const y=u.newValue,w=(y===null?null:h(y))??a;$(w)&&(d.set(c,w),p(w,_.current))});E.useEffect(()=>{if(i)return window.addEventListener("storage",g),()=>window.removeEventListener("storage",g)},[i]);const C=E.useCallback(u=>{const y=se(u)?u(_.current):u;d.set(c,y),p(y,_.current),r&&r.setItem(c,v(y))},[c,r,p]),F=E.useCallback(()=>{const u=a;if(!$(u)){r?.removeItem(c);return}d.set(c,u),p(u,_.current),r&&r.setItem(c,v(u))},[c,a,r,p]);return[k,C,F]},toString(){return this[M]}}}function ie(t,n){const{path:r="",verbose:l,verbosePath:s,ssr:a,cache:i}=n;let c=i.proxy.get(t);c||(c=new Map,i.proxy.set(t,c));const R=c.get(r);if(R)return R;const T=new Proxy(t,{get(P,d){const v=P[d],h=r?`${r}.${String(d)}`:String(d);if(v&&typeof v=="object"&&ue in v){const S=v;let p=i.leaf.get(S);p||(p=new Map,i.leaf.set(S,p));const _=p.get(h);if(_)return _;const O=Reflect.ownKeys(S).filter(g=>typeof S[g]=="function"),x=Object.fromEntries(O.map(g=>[g,(...C)=>S[g].call({...S,[M]:h,[q]:l,[G]:s,[B]:a},...C)])),k={...S,...x};return p.set(h,k),k}return v&&typeof v=="object"?ie(v,{...n,path:h}):v}});return c.set(r,T),T}function we(t,n){return ie(t,{...n,verbosePath:n?.verbosePath??"",cache:{proxy:new WeakMap,leaf:new WeakMap}})}exports.VocabStateProvider=Te;exports.defineState=ke;exports.setupStorage=we;
6
+ <%s key={someKey} {...props} />`,m,v,N,v),te[v+m]=!0)}if(v=null,b!==void 0&&(r(b),v=""+b),l(s)&&(r(s.key),v=""+s.key),"key"in s){b={};for(var G in s)G!=="key"&&(b[G]=s[G])}else b=s;return v&&c(b,typeof e=="function"?e.displayName||e.name||"Unknown":e),R(e,v,b,o(),M,q)}function f(e){d(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===O&&(e._payload.status==="fulfilled"?d(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function d(e){return typeof e=="object"&&e!==null&&e.$$typeof===S}var E=_,S=Symbol.for("react.transitional.element"),p=Symbol.for("react.portal"),h=Symbol.for("react.fragment"),j=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"),J=Symbol.for("react.suspense"),i=Symbol.for("react.suspense_list"),T=Symbol.for("react.memo"),O=Symbol.for("react.lazy"),P=Symbol.for("react.activity"),be=Symbol.for("react.client.reference"),W=E.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,H=Object.prototype.hasOwnProperty,me=Array.isArray,U=console.createTask?console.createTask:function(){return null};E={react_stack_bottom_frame:function(e){return e()}};var Z,Q={},K=E.react_stack_bottom_frame.bind(E,a)(),ee=U(u(a)),te={};I.Fragment=h,I.jsx=function(e,s,b){var m=1e4>W.recentlyCreatedOwnerStacks++;return g(e,s,b,!1,m?Error("react-stack-top-frame"):K,m?U(u(e)):ee)},I.jsxs=function(e,s,b){var m=1e4>W.recentlyCreatedOwnerStacks++;return g(e,s,b,!0,m?Error("react-stack-top-frame"):K,m?U(u(e)):ee)}})()),I}var oe;function pe(){return oe||(oe=1,process.env.NODE_ENV==="production"?Y.exports=Ee():Y.exports=Se()),Y.exports}var he=pe();function L(t,n,r){if(!n)return t;const u=n.split(".");let o=t;for(const a of u)if(o!==null&&typeof o=="object"&&a in o)o=o[a];else return r;return o===void 0?r:o}function _e(t,n,r){const u=n.replace(/\[(\d+)\]/g,".$1").split(".");let o=t;for(let a=0;a<u.length-1;a++){const l=u[a],c=u[a+1];(o[l]===void 0||o[l]===null)&&(o[l]=/^\d+$/.test(c)?[]:{}),o=o[l]}return o[u[u.length-1]]=r,t}function ye(t,n=0){let r;return function(...u){r!==void 0&&clearTimeout(r),r=setTimeout(()=>{r=void 0,t.apply(this,u)},n)}}function Re(t,n,r=[]){return _.useMemo(()=>ye(t,n),r)}function se(t){const n=JSON.stringify(t,null,2).split(`
7
+ `),r=[],u=[];for(const o of n){const a=o.match(/^(\s*)"([^"]+)"(\s*:\s*)(.+)$/);if(a){const[,l,c,y,R]=a;r.push(`${l}%c"${c}"%c${y}%c${R}`),u.push("color: #9cdcfe; font-weight: bold","color: #cccccc","color: #ce9178")}else r.push(`%c${o}`),u.push("color: #cccccc")}console.log(r.join(`
8
+ `),...u,t)}const ue=t=>typeof t=="function",Te=t=>typeof t=="function",x=t=>typeof t<"u",$=t=>Te(t)?t():t;class ie{#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),o=ue(r)?r(u):r,a={...this.#e};_e(a,n,o),this.#e=a,this.#t.forEach(l=>l())}}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 ie,[]);return he.jsx(le.Provider,{value:n,children:t})}const fe=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{[fe]:!0,[z]:"",[D]:!1,[B]:"",[F]:!1,useState(n){const r=X?void 0:$(t.storage),u=$(t.defaultValue),o=t.bidirectional;n??={};const a=$(n.defaultValue)??u,l=n.bidirectional??o,c=this[z],y=this[D],R=this[B],g=this[F],f=ae({verbose:y});if(!(f instanceof ie))throw new Error("Make sure your component is wrapped in VocabStateProvider");const d=t.serialize??JSON.stringify,E=t.deserialize??JSON.parse,S=(i,T,O)=>{const P=T.getItem(i);P===null?x(O)&&T.setItem(i,d(O)):f.set(i,E(P))},p=Re(n.onSet??(()=>{}),n.delayedSet,[]),h=_.useRef(void 0),j=_.useRef(!1);if(!j.current){j.current=!0;let i=f.get(c);x(i)||(i=a,x(i)&&f.set(c,i)),!g&&r&&S(c,r,i)}const A=_.useSyncExternalStore(f.subscribe.bind(f),f.getClientSnapshot.bind(f),f.getServerSnapshot.bind(f));if(y)if(R){const i=L(A,R);i&&se(i)}else se(A);const w=L(A,c,a);h.current=w,ce(()=>{!g||!r||S(c,r,w)},[]);const k=_.useEffectEvent(i=>{if(i.key!==c)return;const T=i.newValue,P=(T===null?null:E(T))??a;x(P)&&(f.set(c,P),p(P,h.current))});_.useEffect(()=>{if(l)return window.addEventListener("storage",k),()=>window.removeEventListener("storage",k)},[l]);const C=_.useCallback(i=>{const T=ue(i)?i(h.current):i;f.set(c,T),p(T,h.current),r&&r.setItem(c,d(T))},[f,c,p,r,d]),J=_.useCallback(()=>{const i=a;if(!x(i)){r?.removeItem(c);return}f.set(c,i),p(i,h.current),r&&r.setItem(c,d(i))},[a,f,c,p,r,d]);return[w,C,J]},useInitialState(n){const r=X?void 0:$(t.storage),u=$(n.defaultValue),o=this[z],a=this[D],l=this[F],c=ae({verbose:a}),y=t.serialize??JSON.stringify,R=t.deserialize??JSON.parse,g=(E,S,p)=>{const h=S.getItem(E);h===null?x(p)&&S.setItem(E,y(p)):c.set(E,R(h))},f=_.useRef(!1);let d;f.current||(f.current=!0,d=c.get(o),x(d)||(d=u,x(d)&&c.set(o,d)),!l&&r&&g(o,r,d)),ce(()=>{!l||!r||g(o,r,d)},[])},toString(){return this[z]}}}function de(t,n){const{path:r="",verbose:u,verbosePath:o,ssr:a,cache:l}=n;let c=l.proxy.get(t);c||(c=new Map,l.proxy.set(t,c));const y=c.get(r);if(y)return y;const R=new Proxy(t,{get(g,f){const d=g[f],E=r?`${r}.${String(f)}`:String(f);if(d&&typeof d=="object"&&fe in d){const S=d;let p=l.leaf.get(S);p||(p=new Map,l.leaf.set(S,p));const h=p.get(E);if(h)return h;const j=Reflect.ownKeys(S).filter(k=>typeof S[k]=="function"),A=Object.fromEntries(j.map(k=>[k,(...C)=>S[k].call({...S,[z]:E,[D]:u,[B]:o,[F]:a},...C)])),w={...S,...A};return p.set(E,w),w}return d&&typeof d=="object"?de(d,{...n,path:E}):d}});return c.set(r,R),R}function we(t,n){return de(t,{...n,verbosePath:n?.verbosePath??"",cache:{proxy:new WeakMap,leaf:new WeakMap}})}exports.VocabStateProvider=ge;exports.defineState=ke;exports.setupStorage=we;
@@ -1,48 +1,48 @@
1
- import pe, { useMemo as ae, createContext as Se, useContext as he, useRef as ee, useSyncExternalStore as _e, useEffect as ce, useLayoutEffect as ye, useEffectEvent as Re, useCallback as te } from "react";
2
- var I = { exports: {} }, C = {};
3
- var re;
4
- function Te() {
5
- if (re) return C;
6
- re = 1;
1
+ import he, { useMemo as le, createContext as _e, useContext as ye, useRef as G, useEffect as ue, useLayoutEffect as Re, useSyncExternalStore as Te, useEffectEvent as ge, useCallback as re } from "react";
2
+ var Y = { exports: {} }, C = {};
3
+ var ne;
4
+ function ke() {
5
+ if (ne) return C;
6
+ ne = 1;
7
7
  var t = Symbol.for("react.transitional.element"), n = Symbol.for("react.fragment");
8
- function r(l, s, a) {
9
- var i = null;
10
- if (a !== void 0 && (i = "" + a), s.key !== void 0 && (i = "" + s.key), "key" in s) {
8
+ function r(i, o, a) {
9
+ var u = null;
10
+ if (a !== void 0 && (u = "" + a), o.key !== void 0 && (u = "" + o.key), "key" in o) {
11
11
  a = {};
12
- for (var c in s)
13
- c !== "key" && (a[c] = s[c]);
14
- } else a = s;
15
- return s = a.ref, {
12
+ for (var c in o)
13
+ c !== "key" && (a[c] = o[c]);
14
+ } else a = o;
15
+ return o = a.ref, {
16
16
  $$typeof: t,
17
- type: l,
18
- key: i,
19
- ref: s !== void 0 ? s : null,
17
+ type: i,
18
+ key: u,
19
+ ref: o !== void 0 ? o : null,
20
20
  props: a
21
21
  };
22
22
  }
23
23
  return C.Fragment = n, C.jsx = r, C.jsxs = r, C;
24
24
  }
25
- var N = {};
26
- var ne;
27
- function ge() {
28
- return ne || (ne = 1, process.env.NODE_ENV !== "production" && (function() {
25
+ var V = {};
26
+ var oe;
27
+ function we() {
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 === be ? null : e.displayName || e.name || null;
32
+ return e.$$typeof === Ee ? null : e.displayName || e.name || null;
33
33
  if (typeof e == "string") return e;
34
34
  switch (e) {
35
35
  case h:
36
36
  return "Fragment";
37
- case x:
37
+ case P:
38
38
  return "Profiler";
39
- case A:
39
+ case O:
40
40
  return "StrictMode";
41
- case F:
41
+ case L:
42
42
  return "Suspense";
43
- case u:
43
+ case l:
44
44
  return "SuspenseList";
45
- case k:
45
+ case w:
46
46
  return "Activity";
47
47
  }
48
48
  if (typeof e == "object")
@@ -51,19 +51,19 @@ function ge() {
51
51
  ), e.$$typeof) {
52
52
  case p:
53
53
  return "Portal";
54
- case T:
55
- return e.displayName || "Context";
56
54
  case g:
55
+ return e.displayName || "Context";
56
+ case k:
57
57
  return (e._context.displayName || "Context") + ".Consumer";
58
- case j:
59
- var o = e.render;
60
- return e = e.displayName, e || (e = o.displayName || o.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
61
- case _:
62
- return o = e.displayName || null, o !== null ? o : t(e.type) || "Memo";
63
- case P:
64
- o = e._payload, e = e._init;
58
+ case N:
59
+ var s = e.render;
60
+ return e = e.displayName, e || (e = s.displayName || s.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
61
+ case R:
62
+ return s = e.displayName || null, s !== null ? s : t(e.type) || "Memo";
63
+ case A:
64
+ s = e._payload, e = e._init;
65
65
  try {
66
- return t(e(o));
66
+ return t(e(s));
67
67
  } catch {
68
68
  }
69
69
  }
@@ -75,74 +75,74 @@ function ge() {
75
75
  function r(e) {
76
76
  try {
77
77
  n(e);
78
- var o = !1;
78
+ var s = !1;
79
79
  } catch {
80
- o = !0;
80
+ s = !0;
81
81
  }
82
- if (o) {
83
- o = console;
84
- var f = o.error, m = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
85
- return f.call(
86
- o,
82
+ if (s) {
83
+ s = console;
84
+ var m = s.error, b = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
85
+ return m.call(
86
+ s,
87
87
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
88
- m
88
+ b
89
89
  ), n(e);
90
90
  }
91
91
  }
92
- function l(e) {
92
+ function i(e) {
93
93
  if (e === h) return "<>";
94
- if (typeof e == "object" && e !== null && e.$$typeof === P)
94
+ if (typeof e == "object" && e !== null && e.$$typeof === A)
95
95
  return "<...>";
96
96
  try {
97
- var o = t(e);
98
- return o ? "<" + o + ">" : "<...>";
97
+ var s = t(e);
98
+ return s ? "<" + s + ">" : "<...>";
99
99
  } catch {
100
100
  return "<...>";
101
101
  }
102
102
  }
103
- function s() {
104
- var e = M.A;
103
+ function o() {
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
- function i(e) {
111
- if (B.call(e, "key")) {
112
- var o = Object.getOwnPropertyDescriptor(e, "key").get;
113
- if (o && o.isReactWarning) return !1;
110
+ function u(e) {
111
+ if (H.call(e, "key")) {
112
+ var s = Object.getOwnPropertyDescriptor(e, "key").get;
113
+ if (s && s.isReactWarning) return !1;
114
114
  }
115
115
  return e.key !== void 0;
116
116
  }
117
- function c(e, o) {
118
- function f() {
119
- X || (X = !0, console.error(
117
+ function c(e, s) {
118
+ function m() {
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
- o
121
+ s
122
122
  ));
123
123
  }
124
- f.isReactWarning = !0, Object.defineProperty(e, "key", {
125
- get: f,
124
+ m.isReactWarning = !0, Object.defineProperty(e, "key", {
125
+ get: m,
126
126
  configurable: !0
127
127
  });
128
128
  }
129
- function y() {
129
+ function _() {
130
130
  var e = t(this.type);
131
- return H[e] || (H[e] = !0, console.error(
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 R(e, o, f, m, $, L) {
136
- var b = f.ref;
135
+ function y(e, s, m, b, z, U) {
136
+ var v = m.ref;
137
137
  return e = {
138
- $$typeof: E,
138
+ $$typeof: S,
139
139
  type: e,
140
- key: o,
141
- props: f,
142
- _owner: m
143
- }, (b !== void 0 ? b : null) !== null ? Object.defineProperty(e, "ref", {
140
+ key: s,
141
+ props: m,
142
+ _owner: b
143
+ }, (v !== void 0 ? v : null) !== null ? Object.defineProperty(e, "ref", {
144
144
  enumerable: !1,
145
- get: y
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,164 +157,164 @@ function ge() {
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: L
165
+ value: U
166
166
  }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
167
167
  }
168
- function w(e, o, f, m, $, L) {
169
- var b = o.children;
170
- if (b !== void 0)
171
- if (m)
172
- if (ve(b)) {
173
- for (m = 0; m < b.length; m++)
174
- d(b[m]);
175
- Object.freeze && Object.freeze(b);
168
+ function T(e, s, m, b, z, U) {
169
+ var v = s.children;
170
+ if (v !== void 0)
171
+ if (b)
172
+ if (Se(v)) {
173
+ for (b = 0; b < v.length; b++)
174
+ f(v[b]);
175
+ Object.freeze && Object.freeze(v);
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 d(b);
181
- if (B.call(o, "key")) {
182
- b = t(e);
183
- var O = Object.keys(o).filter(function(Ee) {
184
- return Ee !== "key";
180
+ else f(v);
181
+ if (H.call(s, "key")) {
182
+ v = t(e);
183
+ var j = Object.keys(s).filter(function(pe) {
184
+ return pe !== "key";
185
185
  });
186
- m = 0 < O.length ? "{key: someKey, " + O.join(": ..., ") + ": ...}" : "{key: someKey}", K[b + m] || (O = 0 < O.length ? "{" + O.join(": ..., ") + ": ...}" : "{}", console.error(
186
+ b = 0 < j.length ? "{key: someKey, " + j.join(": ..., ") + ": ...}" : "{key: someKey}", te[v + b] || (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
- m,
194
193
  b,
195
- O,
196
- b
197
- ), K[b + m] = !0);
194
+ v,
195
+ j,
196
+ v
197
+ ), te[v + b] = !0);
198
198
  }
199
- if (b = null, f !== void 0 && (r(f), b = "" + f), i(o) && (r(o.key), b = "" + o.key), "key" in o) {
200
- f = {};
201
- for (var W in o)
202
- W !== "key" && (f[W] = o[W]);
203
- } else f = o;
204
- return b && c(
205
- f,
199
+ if (v = null, m !== void 0 && (r(m), v = "" + m), u(s) && (r(s.key), v = "" + s.key), "key" in s) {
200
+ m = {};
201
+ for (var q in s)
202
+ q !== "key" && (m[q] = s[q]);
203
+ } else m = s;
204
+ return v && c(
205
+ m,
206
206
  typeof e == "function" ? e.displayName || e.name || "Unknown" : e
207
- ), R(
207
+ ), y(
208
208
  e,
209
- b,
210
- f,
211
- s(),
212
- $,
213
- L
209
+ v,
210
+ m,
211
+ o(),
212
+ z,
213
+ U
214
214
  );
215
215
  }
216
- function d(e) {
217
- v(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === P && (e._payload.status === "fulfilled" ? v(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
216
+ function f(e) {
217
+ d(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === A && (e._payload.status === "fulfilled" ? d(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
218
218
  }
219
- function v(e) {
220
- return typeof e == "object" && e !== null && e.$$typeof === E;
219
+ function d(e) {
220
+ return typeof e == "object" && e !== null && e.$$typeof === S;
221
221
  }
222
- var S = pe, E = Symbol.for("react.transitional.element"), p = Symbol.for("react.portal"), h = Symbol.for("react.fragment"), A = Symbol.for("react.strict_mode"), x = Symbol.for("react.profiler"), g = Symbol.for("react.consumer"), T = Symbol.for("react.context"), j = Symbol.for("react.forward_ref"), F = Symbol.for("react.suspense"), u = Symbol.for("react.suspense_list"), _ = Symbol.for("react.memo"), P = Symbol.for("react.lazy"), k = Symbol.for("react.activity"), be = Symbol.for("react.client.reference"), M = S.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, B = Object.prototype.hasOwnProperty, ve = Array.isArray, z = console.createTask ? console.createTask : function() {
222
+ var E = he, S = Symbol.for("react.transitional.element"), p = Symbol.for("react.portal"), h = Symbol.for("react.fragment"), O = Symbol.for("react.strict_mode"), P = Symbol.for("react.profiler"), k = Symbol.for("react.consumer"), g = Symbol.for("react.context"), N = Symbol.for("react.forward_ref"), L = Symbol.for("react.suspense"), l = Symbol.for("react.suspense_list"), R = Symbol.for("react.memo"), A = Symbol.for("react.lazy"), w = Symbol.for("react.activity"), Ee = Symbol.for("react.client.reference"), J = E.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, H = Object.prototype.hasOwnProperty, Se = Array.isArray, W = console.createTask ? console.createTask : function() {
223
223
  return null;
224
224
  };
225
- S = {
225
+ E = {
226
226
  react_stack_bottom_frame: function(e) {
227
227
  return e();
228
228
  }
229
229
  };
230
- var X, H = {}, Z = S.react_stack_bottom_frame.bind(
231
- S,
230
+ var Z, Q = {}, K = E.react_stack_bottom_frame.bind(
231
+ E,
232
232
  a
233
- )(), Q = z(l(a)), K = {};
234
- N.Fragment = h, N.jsx = function(e, o, f) {
235
- var m = 1e4 > M.recentlyCreatedOwnerStacks++;
236
- return w(
233
+ )(), ee = W(i(a)), te = {};
234
+ V.Fragment = h, V.jsx = function(e, s, m) {
235
+ var b = 1e4 > J.recentlyCreatedOwnerStacks++;
236
+ return T(
237
237
  e,
238
- o,
239
- f,
238
+ s,
239
+ m,
240
240
  !1,
241
- m ? Error("react-stack-top-frame") : Z,
242
- m ? z(l(e)) : Q
241
+ b ? Error("react-stack-top-frame") : K,
242
+ b ? W(i(e)) : ee
243
243
  );
244
- }, N.jsxs = function(e, o, f) {
245
- var m = 1e4 > M.recentlyCreatedOwnerStacks++;
246
- return w(
244
+ }, V.jsxs = function(e, s, m) {
245
+ var b = 1e4 > J.recentlyCreatedOwnerStacks++;
246
+ return T(
247
247
  e,
248
- o,
249
- f,
248
+ s,
249
+ m,
250
250
  !0,
251
- m ? Error("react-stack-top-frame") : Z,
252
- m ? z(l(e)) : Q
251
+ b ? Error("react-stack-top-frame") : K,
252
+ b ? W(i(e)) : ee
253
253
  );
254
254
  };
255
- })()), N;
255
+ })()), V;
256
256
  }
257
- var oe;
258
- function ke() {
259
- return oe || (oe = 1, process.env.NODE_ENV === "production" ? I.exports = Te() : I.exports = ge()), I.exports;
257
+ var se;
258
+ function xe() {
259
+ return se || (se = 1, process.env.NODE_ENV === "production" ? Y.exports = ke() : Y.exports = we()), Y.exports;
260
260
  }
261
- var we = ke();
262
- function D(t, n, r) {
261
+ var Pe = xe();
262
+ function F(t, n, r) {
263
263
  if (!n)
264
264
  return t;
265
- const l = n.split(".");
266
- let s = t;
267
- for (const a of l)
268
- if (s !== null && typeof s == "object" && a in s)
269
- s = s[a];
265
+ const i = n.split(".");
266
+ let o = t;
267
+ for (const a of i)
268
+ if (o !== null && typeof o == "object" && a in o)
269
+ o = o[a];
270
270
  else
271
271
  return r;
272
- return s === void 0 ? r : s;
272
+ return o === void 0 ? r : o;
273
273
  }
274
- function xe(t, n, r) {
275
- const l = n.replace(/\[(\d+)\]/g, ".$1").split(".");
276
- let s = t;
277
- for (let a = 0; a < l.length - 1; a++) {
278
- const i = l[a], c = l[a + 1];
279
- (s[i] === void 0 || s[i] === null) && (s[i] = /^\d+$/.test(c) ? [] : {}), s = s[i];
274
+ function Ae(t, n, r) {
275
+ const i = n.replace(/\[(\d+)\]/g, ".$1").split(".");
276
+ let o = t;
277
+ for (let a = 0; a < i.length - 1; a++) {
278
+ const u = i[a], c = i[a + 1];
279
+ (o[u] === void 0 || o[u] === null) && (o[u] = /^\d+$/.test(c) ? [] : {}), o = o[u];
280
280
  }
281
- return s[l[l.length - 1]] = r, t;
281
+ return o[i[i.length - 1]] = r, t;
282
282
  }
283
- function Pe(t, n = 0) {
283
+ function Oe(t, n = 0) {
284
284
  let r;
285
- return function(...l) {
285
+ return function(...i) {
286
286
  r !== void 0 && clearTimeout(r), r = setTimeout(() => {
287
- r = void 0, t.apply(this, l);
287
+ r = void 0, t.apply(this, i);
288
288
  }, n);
289
289
  };
290
290
  }
291
- function Ae(t, n, r = []) {
292
- return ae(
293
- () => Pe(t, n),
291
+ function je(t, n, r = []) {
292
+ return le(
293
+ () => Oe(t, n),
294
294
  // eslint-disable-next-line react-hooks/exhaustive-deps
295
295
  r
296
296
  );
297
297
  }
298
- function se(t) {
298
+ function ae(t) {
299
299
  const n = JSON.stringify(t, null, 2).split(`
300
- `), r = [], l = [];
301
- for (const s of n) {
302
- const a = s.match(/^(\s*)"([^"]+)"(\s*:\s*)(.+)$/);
300
+ `), r = [], i = [];
301
+ for (const o of n) {
302
+ const a = o.match(/^(\s*)"([^"]+)"(\s*:\s*)(.+)$/);
303
303
  if (a) {
304
- const [, i, c, y, R] = a;
305
- r.push(`${i}%c"${c}"%c${y}%c${R}`), l.push(
304
+ const [, u, c, _, y] = a;
305
+ r.push(`${u}%c"${c}"%c${_}%c${y}`), i.push(
306
306
  "color: #9cdcfe; font-weight: bold",
307
307
  "color: #cccccc",
308
308
  "color: #ce9178"
309
309
  );
310
310
  } else
311
- r.push(`%c${s}`), l.push("color: #cccccc");
311
+ r.push(`%c${o}`), i.push("color: #cccccc");
312
312
  }
313
313
  console.log(r.join(`
314
- `), ...l, t);
314
+ `), ...i, t);
315
315
  }
316
- const ue = (t) => typeof t == "function", Oe = (t) => typeof t == "function", V = (t) => typeof t < "u", J = (t) => Oe(t) ? t() : t;
317
- class je {
316
+ const fe = (t) => typeof t == "function", Ne = (t) => typeof t == "function", x = (t) => typeof t < "u", I = (t) => Ne(t) ? t() : t;
317
+ class de {
318
318
  #e;
319
319
  #t;
320
320
  constructor() {
@@ -330,152 +330,165 @@ class je {
330
330
  return this.#e;
331
331
  }
332
332
  get(n) {
333
- return D(this.#e, n);
333
+ return F(this.#e, n);
334
334
  }
335
335
  set(n, r) {
336
- const l = D(this.#e, n), s = ue(r) ? r(l) : r, a = { ...this.#e };
337
- xe(a, n, s), this.#e = a, this.#t.forEach((i) => i());
336
+ const i = F(this.#e, n), o = fe(r) ? r(i) : r, a = { ...this.#e };
337
+ Ae(a, n, o), this.#e = a, this.#t.forEach((u) => u());
338
338
  }
339
339
  }
340
- const le = Se({});
341
- function ie(t = {}) {
342
- const n = he(le);
343
- return t.verbose && console.log(`[${ie.name}]: `, n.uid), n;
340
+ const me = _e({});
341
+ function ce(t = {}) {
342
+ const n = ye(me);
343
+ return t.verbose && console.log(`[Store uid]: ${n.uid}`), n;
344
344
  }
345
345
  function Ve({ children: t }) {
346
- const n = ae(() => new je(), []);
347
- return /* @__PURE__ */ we.jsx(le.Provider, { value: n, children: t });
346
+ const n = le(() => new de(), []);
347
+ return /* @__PURE__ */ Pe.jsx(me.Provider, { value: n, children: t });
348
348
  }
349
- const fe = Symbol("state-def"), Y = Symbol("state-path"), U = Symbol("state-verbose"), q = Symbol("state-verbose-path"), G = Symbol("state-ssr"), de = typeof window > "u", Ce = de ? ce : ye;
350
- function $e(t = {}) {
349
+ const be = Symbol("state-def"), $ = Symbol("state-path"), M = Symbol("state-verbose"), B = Symbol("state-verbose-path"), D = Symbol("state-ssr"), X = typeof window > "u", ie = X ? ue : Re;
350
+ function Ie(t = {}) {
351
351
  return {
352
- [fe]: !0,
352
+ [be]: !0,
353
353
  // marks this object as a leaf in the router tree
354
- [Y]: "",
354
+ [$]: "",
355
355
  // placeholder; injected at runtime by injectPaths()
356
- [U]: !1,
356
+ [M]: !1,
357
357
  // placeholder
358
- [q]: "",
358
+ [B]: "",
359
359
  // placeholder
360
- [G]: !1,
360
+ [D]: !1,
361
361
  // placeholder
362
362
  useState(n) {
363
- const r = de ? void 0 : J(t.storage), l = J(t.defaultValue), s = t.bidirectional;
363
+ const r = X ? void 0 : I(t.storage), i = I(t.defaultValue), o = t.bidirectional;
364
364
  n ??= {};
365
- const a = J(n.defaultValue) ?? l, i = n.bidirectional ?? s, c = this[Y], y = this[U], R = this[q], w = this[G], d = ie({ verbose: y }), v = t.serialize ?? JSON.stringify, S = t.deserialize ?? JSON.parse, E = (u, _, P) => {
366
- const k = _.getItem(u);
367
- k === null ? V(P) && _.setItem(u, v(P)) : d.set(u, S(k));
368
- }, p = Ae(
365
+ const a = I(n.defaultValue) ?? i, u = n.bidirectional ?? o, c = this[$], _ = this[M], y = this[B], T = this[D], f = ce({ verbose: _ });
366
+ if (!(f instanceof de))
367
+ throw new Error("Make sure your component is wrapped in VocabStateProvider");
368
+ const d = t.serialize ?? JSON.stringify, E = t.deserialize ?? JSON.parse, S = (l, R, A) => {
369
+ const w = R.getItem(l);
370
+ w === null ? x(A) && R.setItem(l, d(A)) : f.set(l, E(w));
371
+ }, p = je(
369
372
  n.onSet ?? (() => {
370
373
  }),
371
374
  n.delayedSet,
372
375
  []
373
- ), h = ee(void 0), A = ee(!1);
374
- if (!A.current) {
375
- A.current = !0;
376
- let u = d.get(c);
377
- V(u) || (u = a, V(u) && d.set(c, u)), !w && r && E(c, r, u);
376
+ ), h = G(void 0), O = G(!1);
377
+ if (!O.current) {
378
+ O.current = !0;
379
+ let l = f.get(c);
380
+ x(l) || (l = a, x(l) && f.set(c, l)), !T && r && S(c, r, l);
378
381
  }
379
- const x = _e(
380
- d.subscribe.bind(d),
381
- d.getClientSnapshot.bind(d),
382
- d.getServerSnapshot.bind(d)
382
+ const P = Te(
383
+ f.subscribe.bind(f),
384
+ f.getClientSnapshot.bind(f),
385
+ f.getServerSnapshot.bind(f)
383
386
  );
384
- if (y)
385
- if (R) {
386
- const u = D(x, R);
387
- u && se(u);
387
+ if (_)
388
+ if (y) {
389
+ const l = F(P, y);
390
+ l && ae(l);
388
391
  } else
389
- se(x);
390
- const g = D(x, c, a);
391
- h.current = g, Ce(() => {
392
- !w || !r || E(c, r, g);
392
+ ae(P);
393
+ const k = F(P, c, a);
394
+ h.current = k, ie(() => {
395
+ !T || !r || S(c, r, k);
393
396
  }, []);
394
- const T = Re((u) => {
395
- if (u.key !== c)
397
+ const g = ge((l) => {
398
+ if (l.key !== c)
396
399
  return;
397
- const _ = u.newValue, k = (_ === null ? null : S(_)) ?? a;
398
- V(k) && (d.set(c, k), p(k, h.current));
400
+ const R = l.newValue, w = (R === null ? null : E(R)) ?? a;
401
+ x(w) && (f.set(c, w), p(w, h.current));
399
402
  });
400
- ce(() => {
401
- if (i)
402
- return window.addEventListener("storage", T), () => window.removeEventListener("storage", T);
403
- }, [i]);
404
- const j = te((u) => {
405
- const _ = ue(u) ? u(h.current) : u;
406
- d.set(c, _), p(_, h.current), r && r.setItem(c, v(_));
407
- }, [c, r, p]), F = te(() => {
408
- const u = a;
409
- if (!V(u)) {
403
+ ue(() => {
404
+ if (u)
405
+ return window.addEventListener("storage", g), () => window.removeEventListener("storage", g);
406
+ }, [u]);
407
+ const N = re((l) => {
408
+ const R = fe(l) ? l(h.current) : l;
409
+ f.set(c, R), p(R, h.current), r && r.setItem(c, d(R));
410
+ }, [f, c, p, r, d]), L = re(() => {
411
+ const l = a;
412
+ if (!x(l)) {
410
413
  r?.removeItem(c);
411
414
  return;
412
415
  }
413
- d.set(c, u), p(u, h.current), r && r.setItem(c, v(u));
414
- }, [c, a, r, p]);
416
+ f.set(c, l), p(l, h.current), r && r.setItem(c, d(l));
417
+ }, [a, f, c, p, r, d]);
415
418
  return [
416
- g,
417
- j,
418
- F
419
+ k,
420
+ N,
421
+ L
419
422
  ];
420
423
  },
424
+ useInitialState(n) {
425
+ const r = X ? void 0 : I(t.storage), i = I(n.defaultValue), o = this[$], a = this[M], u = this[D], c = ce({ verbose: a }), _ = t.serialize ?? JSON.stringify, y = t.deserialize ?? JSON.parse, T = (E, S, p) => {
426
+ const h = S.getItem(E);
427
+ h === null ? x(p) && S.setItem(E, _(p)) : c.set(E, y(h));
428
+ }, f = G(!1);
429
+ let d;
430
+ f.current || (f.current = !0, d = c.get(o), x(d) || (d = i, x(d) && c.set(o, d)), !u && r && T(o, r, d)), ie(() => {
431
+ !u || !r || T(o, r, d);
432
+ }, []);
433
+ },
421
434
  /** Returns the fully qualified job name (dot-separated path). */
422
435
  toString() {
423
- return this[Y];
436
+ return this[$];
424
437
  }
425
438
  };
426
439
  }
427
- function me(t, n) {
440
+ function ve(t, n) {
428
441
  const {
429
442
  path: r = "",
430
- verbose: l,
431
- verbosePath: s,
443
+ verbose: i,
444
+ verbosePath: o,
432
445
  ssr: a,
433
- cache: i
446
+ cache: u
434
447
  } = n;
435
- let c = i.proxy.get(t);
436
- c || (c = /* @__PURE__ */ new Map(), i.proxy.set(t, c));
437
- const y = c.get(r);
438
- if (y)
439
- return y;
440
- const R = new Proxy(t, {
441
- get(w, d) {
442
- const v = w[d], S = r ? `${r}.${String(d)}` : String(d);
443
- if (v && typeof v == "object" && fe in v) {
444
- const E = v;
445
- let p = i.leaf.get(E);
446
- p || (p = /* @__PURE__ */ new Map(), i.leaf.set(E, p));
447
- const h = p.get(S);
448
+ let c = u.proxy.get(t);
449
+ c || (c = /* @__PURE__ */ new Map(), u.proxy.set(t, c));
450
+ const _ = c.get(r);
451
+ if (_)
452
+ return _;
453
+ const y = new Proxy(t, {
454
+ get(T, f) {
455
+ const d = T[f], E = r ? `${r}.${String(f)}` : String(f);
456
+ if (d && typeof d == "object" && be in d) {
457
+ const S = d;
458
+ let p = u.leaf.get(S);
459
+ p || (p = /* @__PURE__ */ new Map(), u.leaf.set(S, p));
460
+ const h = p.get(E);
448
461
  if (h)
449
462
  return h;
450
- const A = Reflect.ownKeys(E).filter(
451
- (T) => typeof E[T] == "function"
452
- ), x = Object.fromEntries(
453
- A.map((T) => [
454
- T,
455
- (...j) => E[T].call(
463
+ const O = Reflect.ownKeys(S).filter(
464
+ (g) => typeof S[g] == "function"
465
+ ), P = Object.fromEntries(
466
+ O.map((g) => [
467
+ g,
468
+ (...N) => S[g].call(
456
469
  {
457
- ...E,
458
- [Y]: S,
459
- [U]: l,
460
- [q]: s,
461
- [G]: a
470
+ ...S,
471
+ [$]: E,
472
+ [M]: i,
473
+ [B]: o,
474
+ [D]: a
462
475
  },
463
- ...j
476
+ ...N
464
477
  )
465
478
  ])
466
- ), g = { ...E, ...x };
467
- return p.set(S, g), g;
479
+ ), k = { ...S, ...P };
480
+ return p.set(E, k), k;
468
481
  }
469
- return v && typeof v == "object" ? me(v, {
482
+ return d && typeof d == "object" ? ve(d, {
470
483
  ...n,
471
- path: S
472
- }) : v;
484
+ path: E
485
+ }) : d;
473
486
  }
474
487
  });
475
- return c.set(r, R), R;
488
+ return c.set(r, y), y;
476
489
  }
477
- function Ie(t, n) {
478
- return me(t, {
490
+ function $e(t, n) {
491
+ return ve(t, {
479
492
  ...n,
480
493
  verbosePath: n?.verbosePath ?? "",
481
494
  cache: {
@@ -486,6 +499,6 @@ function Ie(t, n) {
486
499
  }
487
500
  export {
488
501
  Ve as VocabStateProvider,
489
- $e as defineState,
490
- Ie as setupStorage
502
+ Ie as defineState,
503
+ $e as setupStorage
491
504
  };
@@ -1,5 +1,8 @@
1
1
  import { type PropsWithChildren } from "react";
2
2
  import VocabStore from "./store";
3
+ /**
4
+ * @see method from from https://zustand.docs.pmnd.rs/learn/guides/nextjs
5
+ */
3
6
  export declare function useVocabStoreContext(options?: {
4
7
  verbose?: boolean;
5
8
  }): VocabStore;
@@ -23,6 +23,13 @@ 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
+ }): void;
26
33
  /** Returns the fully qualified job name (dot-separated path). */
27
34
  toString(this: {
28
35
  [STATE_PATH]: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yakocloud/state-vocab",
3
- "version": "3.1.3",
3
+ "version": "3.1.5",
4
4
  "main": "dist/state-vocab.cjs.js",
5
5
  "module": "dist/state-vocab.es.js",
6
6
  "types": "dist/types/index.d.ts",