@yakocloud/state-vocab 2.1.2 → 2.1.3

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
@@ -149,10 +149,14 @@ const birthday = defineState({
149
149
  })
150
150
  ```
151
151
 
152
- ### `setupStorage(tree)`
152
+ ### `setupStorage(tree, options)`
153
153
 
154
154
  Wraps a nested object of `defineState()` nodes and injects dot-separated paths into each leaf. The returned object mirrors your tree structure.
155
155
 
156
+ | Parameter | Type | Description | Default
157
+ |---|---|---|
158
+ | `ssr` | `boolean \| undefined` | SSR support | false
159
+
156
160
  ```ts
157
161
  const storage = setupStorage({
158
162
  user: {
@@ -1,8 +1,8 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("react"),B=Symbol("state-def"),A=Symbol("state-path");function ie(t,c,o){if(!c)return t;const a=c.split(".");let r=t;for(const s of a)if(r!==null&&typeof r=="object"&&s in r)r=r[s];else return o;return r===void 0?o:r}function fe(t,c,o){const a=c.replace(/\[(\d+)\]/g,".$1").split(".");let r=t;for(let s=0;s<a.length-1;s++){const f=a[s],u=a[s+1];(r[f]===void 0||r[f]===null)&&(r[f]=/^\d+$/.test(u)?[]:{}),r=r[f]}return r[a[a.length-1]]=o,t}function de(t,c=0){let o;return function(...a){o!==void 0&&clearTimeout(o),o=setTimeout(()=>{o=void 0,t.apply(this,a)},c)}}function me(t,c,o=[]){return y.useMemo(()=>de(t,c),o)}function be(t){const c=JSON.stringify(t,null,2).split(`
2
- `),o=[],a=[];for(const r of c){const s=r.match(/^(\s*)"([^"]+)"(\s*:\s*)(.+)$/);if(s){const[,f,u,p,v]=s;o.push(`${f}%c"${u}"%c${p}%c${v}`),a.push("color: #9cdcfe; font-weight: bold","color: #cccccc","color: #ce9178")}else o.push(`%c${r}`),a.push("color: #cccccc")}console.log(o.join(`
3
- `),...a,t)}var x={exports:{}},k={};var W;function ve(){if(W)return k;W=1;var t=Symbol.for("react.transitional.element"),c=Symbol.for("react.fragment");function o(a,r,s){var f=null;if(s!==void 0&&(f=""+s),r.key!==void 0&&(f=""+r.key),"key"in r){s={};for(var u in r)u!=="key"&&(s[u]=r[u])}else s=r;return r=s.ref,{$$typeof:t,type:a,key:f,ref:r!==void 0?r:null,props:s}}return k.Fragment=c,k.jsx=o,k.jsxs=o,k}var w={};var J;function Ee(){return J||(J=1,process.env.NODE_ENV!=="production"&&(function(){function t(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===ce?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case S:return"Fragment";case K:return"Profiler";case h:return"StrictMode";case ne:return"Suspense";case oe:return"SuspenseList";case se: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 d:return"Portal";case te:return e.displayName||"Context";case ee:return(e._context.displayName||"Context")+".Consumer";case re:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ae:return n=e.displayName||null,n!==null?n:t(e.type)||"Memo";case j:n=e._payload,e=e._init;try{return t(e(n))}catch{}}return null}function c(e){return""+e}function o(e){try{c(e);var n=!1}catch{n=!0}if(n){n=console;var i=n.error,m=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return i.call(n,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",m),c(e)}}function a(e){if(e===S)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===j)return"<...>";try{var n=t(e);return n?"<"+n+">":"<...>"}catch{return"<...>"}}function r(){var e=N.A;return e===null?null:e.getOwner()}function s(){return Error("react-stack-top-frame")}function f(e){if(Y.call(e,"key")){var n=Object.getOwnPropertyDescriptor(e,"key").get;if(n&&n.isReactWarning)return!1}return e.key!==void 0}function u(e,n){function i(){M||(M=!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)",n))}i.isReactWarning=!0,Object.defineProperty(e,"key",{get:i,configurable:!0})}function p(){var e=t(this.type);return D[e]||(D[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 v(e,n,i,m,P,V){var b=i.ref;return e={$$typeof:_,type:e,key:n,props:i,_owner:m},(b!==void 0?b:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:p}):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:P}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:V}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function l(e,n,i,m,P,V){var b=n.children;if(b!==void 0)if(m)if(ue(b)){for(m=0;m<b.length;m++)R(b[m]);Object.freeze&&Object.freeze(b)}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 R(b);if(Y.call(n,"key")){b=t(e);var g=Object.keys(n).filter(function(le){return le!=="key"});m=0<g.length?"{key: someKey, "+g.join(": ..., ")+": ...}":"{key: someKey}",z[b+m]||(g=0<g.length?"{"+g.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"),K=Symbol("state-def"),C=Symbol("state-path"),D=Symbol("state-ssr-support");function fe(t,c,a){if(!c)return t;const s=c.split(".");let r=t;for(const o of s)if(r!==null&&typeof r=="object"&&o in r)r=r[o];else return a;return r===void 0?a:r}function de(t,c,a){const s=c.replace(/\[(\d+)\]/g,".$1").split(".");let r=t;for(let o=0;o<s.length-1;o++){const i=s[o],b=s[o+1];(r[i]===void 0||r[i]===null)&&(r[i]=/^\d+$/.test(b)?[]:{}),r=r[i]}return r[s[s.length-1]]=a,t}function me(t,c=0){let a;return function(...s){a!==void 0&&clearTimeout(a),a=setTimeout(()=>{a=void 0,t.apply(this,s)},c)}}function be(t,c,a=[]){return _.useMemo(()=>me(t,c),a)}function ve(t){const c=JSON.stringify(t,null,2).split(`
2
+ `),a=[],s=[];for(const r of c){const o=r.match(/^(\s*)"([^"]+)"(\s*:\s*)(.+)$/);if(o){const[,i,b,R,f]=o;a.push(`${i}%c"${b}"%c${R}%c${f}`),s.push("color: #9cdcfe; font-weight: bold","color: #cccccc","color: #ce9178")}else a.push(`%c${r}`),s.push("color: #cccccc")}console.log(a.join(`
3
+ `),...s,t)}var j={exports:{}},O={};var G;function pe(){if(G)return O;G=1;var t=Symbol.for("react.transitional.element"),c=Symbol.for("react.fragment");function a(s,r,o){var i=null;if(o!==void 0&&(i=""+o),r.key!==void 0&&(i=""+r.key),"key"in r){o={};for(var b in r)b!=="key"&&(o[b]=r[b])}else o=r;return r=o.ref,{$$typeof:t,type:s,key:i,ref:r!==void 0?r:null,props:o}}return O.Fragment=c,O.jsx=a,O.jsxs=a,O}var x={};var X;function Ee(){return X||(X=1,process.env.NODE_ENV!=="production"&&(function(){function t(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===ue?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case p:return"Fragment";case v:return"Profiler";case E:return"StrictMode";case oe:return"Suspense";case ae:return"SuspenseList";case ce: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 k:return"Portal";case P:return e.displayName||"Context";case h:return(e._context.displayName||"Context")+".Consumer";case ne:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case se:return n=e.displayName||null,n!==null?n:t(e.type)||"Memo";case V:n=e._payload,e=e._init;try{return t(e(n))}catch{}}return null}function c(e){return""+e}function a(e){try{c(e);var n=!1}catch{n=!0}if(n){n=console;var u=n.error,d=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return u.call(n,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",d),c(e)}}function s(e){if(e===p)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===V)return"<...>";try{var n=t(e);return n?"<"+n+">":"<...>"}catch{return"<...>"}}function r(){var e=$.A;return e===null?null:e.getOwner()}function o(){return Error("react-stack-top-frame")}function i(e){if(L.call(e,"key")){var n=Object.getOwnPropertyDescriptor(e,"key").get;if(n&&n.isReactWarning)return!1}return e.key!==void 0}function b(e,n){function u(){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)",n))}u.isReactWarning=!0,Object.defineProperty(e,"key",{get:u,configurable:!0})}function R(){var e=t(this.type);return W[e]||(W[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 f(e,n,u,d,A,M){var m=u.ref;return e={$$typeof:y,type:e,key:n,props:u,_owner:d},(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:A}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:M}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function l(e,n,u,d,A,M){var m=n.children;if(m!==void 0)if(d)if(le(m)){for(d=0;d<m.length;d++)S(m[d]);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 S(m);if(L.call(n,"key")){m=t(e);var w=Object.keys(n).filter(function(ie){return ie!=="key"});d=0<w.length?"{key: someKey, "+w.join(": ..., ")+": ...}":"{key: someKey}",q[m+d]||(w=0<w.length?"{"+w.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
4
4
  let props = %s;
5
5
  <%s {...props} />
6
6
  React keys must be passed directly to JSX without using spread:
7
7
  let props = %s;
8
- <%s key={someKey} {...props} />`,m,b,g,b),z[b+m]=!0)}if(b=null,i!==void 0&&(o(i),b=""+i),f(n)&&(o(n.key),b=""+n.key),"key"in n){i={};for(var $ in n)$!=="key"&&(i[$]=n[$])}else i=n;return b&&u(i,typeof e=="function"?e.displayName||e.name||"Unknown":e),v(e,b,i,r(),P,V)}function R(e){T(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===j&&(e._payload.status==="fulfilled"?T(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function T(e){return typeof e=="object"&&e!==null&&e.$$typeof===_}var E=y,_=Symbol.for("react.transitional.element"),d=Symbol.for("react.portal"),S=Symbol.for("react.fragment"),h=Symbol.for("react.strict_mode"),K=Symbol.for("react.profiler"),ee=Symbol.for("react.consumer"),te=Symbol.for("react.context"),re=Symbol.for("react.forward_ref"),ne=Symbol.for("react.suspense"),oe=Symbol.for("react.suspense_list"),ae=Symbol.for("react.memo"),j=Symbol.for("react.lazy"),se=Symbol.for("react.activity"),ce=Symbol.for("react.client.reference"),N=E.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Y=Object.prototype.hasOwnProperty,ue=Array.isArray,C=console.createTask?console.createTask:function(){return null};E={react_stack_bottom_frame:function(e){return e()}};var M,D={},F=E.react_stack_bottom_frame.bind(E,s)(),L=C(a(s)),z={};w.Fragment=S,w.jsx=function(e,n,i){var m=1e4>N.recentlyCreatedOwnerStacks++;return l(e,n,i,!1,m?Error("react-stack-top-frame"):F,m?C(a(e)):L)},w.jsxs=function(e,n,i){var m=1e4>N.recentlyCreatedOwnerStacks++;return l(e,n,i,!0,m?Error("react-stack-top-frame"):F,m?C(a(e)):L)}})()),w}var U;function pe(){return U||(U=1,process.env.NODE_ENV==="production"?x.exports=ve():x.exports=Ee()),x.exports}var _e=pe();const H=y.createContext({stateVocab:{},setStateVocab:()=>{}});function Se(){return y.useContext(H)}const Re=t=>{const{children:c,verbose:o}=t,[a,r]=y.useState({});return o&&be(a),_e.jsx(H.Provider,{value:{stateVocab:a,setStateVocab:r},children:c})},O=(t,c)=>o=>{const a={...o};return fe(a,t,c),a},I=(t,c)=>Z(t)??c,q=t=>{const{serialized:c,defaultValue:o,superDefaultValue:a,deserialize:r}=t;if(c===null){const s=I(o,a);return typeof s>"u"?void 0:s}return r(c)},ye=t=>typeof t=="function",Te=t=>typeof t=="function",Z=t=>Te(t)?t():t;function ge(t={}){const{serialize:c=JSON.stringify,deserialize:o=JSON.parse}=t,a=t.defaultValue,r=t.bidirectional,s=typeof window>"u"?void 0:Z(t.storage);return{[B]:!0,[A]:"",useState(f,u){u??={};const p=me(u.onSet??(()=>{}),u.delayedSet,[]),v=Se(),l=this[A],R=y.useMemo(()=>{if(!s)return;const _=s.getItem(l);return q({serialized:_,defaultValue:f,superDefaultValue:a,deserialize:o})},[l]),T=y.useMemo(()=>ie(v.stateVocab,l,R??I(f,a)),[v.stateVocab,R,l]);y.useEffect(()=>{!s||typeof R>"u"||v.setStateVocab(O(l,R))},[R]),y.useEffect(()=>{if(!u.bidirectional&&!r)return;const _=d=>{if(d.key!==l)return;const S=d.newValue,h=q({serialized:S,defaultValue:f,superDefaultValue:a,deserialize:o});v.setStateVocab(O(l,h)),p(h,E.current),E.current=h};return window.addEventListener("storage",_),()=>window.removeEventListener("storage",_)},[l,u.bidirectional,r]);const E=y.useRef(T);return[T,function(d){const S=ye(d)?d(E.current):d;v.setStateVocab(O(l,S)),p(S,E.current),s&&s.setItem(l,c(S)),E.current=S},function(){const d=I(f,a);if(typeof d>"u"){s?.removeItem(l);return}v.setStateVocab(O(l,d)),p(d,E.current),E.current=d,s&&s.setItem(l,c(d))}]},toString(){return this[A]}}}const G=new WeakMap,X=new WeakMap;function Q(t,c=""){let o=G.get(t);o||(o=new Map,G.set(t,o));const a=o.get(c);if(a)return a;const r=new Proxy(t,{get(s,f){const u=s[f],p=c?`${c}.${String(f)}`:String(f);if(u&&typeof u=="object"&&B in u){const v=u;let l=X.get(v);l||(l=new Map,X.set(v,l));const R=l.get(p);if(R)return R;const T=Reflect.ownKeys(v).filter(d=>typeof v[d]=="function"),E=Object.fromEntries(T.map(d=>[d,(...S)=>v[d].call({...v,[A]:p},...S)])),_={...v,...E};return l.set(p,_),_}return u&&typeof u=="object"?Q(u,p):u}});return o.set(c,r),r}function he(t){return Q(t)}exports.StorageProvider=Re;exports.defineState=ge;exports.setupStorage=he;
8
+ <%s key={someKey} {...props} />`,d,m,w,m),q[m+d]=!0)}if(m=null,u!==void 0&&(a(u),m=""+u),i(n)&&(a(n.key),m=""+n.key),"key"in n){u={};for(var Y in n)Y!=="key"&&(u[Y]=n[Y])}else u=n;return m&&b(u,typeof e=="function"?e.displayName||e.name||"Unknown":e),f(e,m,u,r(),A,M)}function S(e){T(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===V&&(e._payload.status==="fulfilled"?T(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function T(e){return typeof e=="object"&&e!==null&&e.$$typeof===y}var g=_,y=Symbol.for("react.transitional.element"),k=Symbol.for("react.portal"),p=Symbol.for("react.fragment"),E=Symbol.for("react.strict_mode"),v=Symbol.for("react.profiler"),h=Symbol.for("react.consumer"),P=Symbol.for("react.context"),ne=Symbol.for("react.forward_ref"),oe=Symbol.for("react.suspense"),ae=Symbol.for("react.suspense_list"),se=Symbol.for("react.memo"),V=Symbol.for("react.lazy"),ce=Symbol.for("react.activity"),ue=Symbol.for("react.client.reference"),$=g.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,L=Object.prototype.hasOwnProperty,le=Array.isArray,I=console.createTask?console.createTask:function(){return null};g={react_stack_bottom_frame:function(e){return e()}};var z,W={},J=g.react_stack_bottom_frame.bind(g,o)(),U=I(s(o)),q={};x.Fragment=p,x.jsx=function(e,n,u){var d=1e4>$.recentlyCreatedOwnerStacks++;return l(e,n,u,!1,d?Error("react-stack-top-frame"):J,d?I(s(e)):U)},x.jsxs=function(e,n,u){var d=1e4>$.recentlyCreatedOwnerStacks++;return l(e,n,u,!0,d?Error("react-stack-top-frame"):J,d?I(s(e)):U)}})()),x}var B;function Se(){return B||(B=1,process.env.NODE_ENV==="production"?j.exports=pe():j.exports=Ee()),j.exports}var _e=Se();const ee=_.createContext({stateVocab:{},setStateVocab:()=>{}});function Re(){return _.useContext(ee)}const Te=t=>{const{children:c,verbose:a}=t,[s,r]=_.useState({});return a&&ve(s),_e.jsx(ee.Provider,{value:{stateVocab:s,setStateVocab:r},children:c})},N=(t,c)=>a=>{const s={...a};return de(s,t,c),s},F=(t,c)=>te(t)??c,H=t=>{const{serialized:c,defaultValue:a,superDefaultValue:s,deserialize:r}=t;if(c===null){const o=F(a,s);return typeof o>"u"?void 0:o}return r(c)},ye=t=>typeof t=="function",ge=t=>typeof t=="function",te=t=>ge(t)?t():t,he=typeof window>"u";function ke(t={}){const{serialize:c=JSON.stringify,deserialize:a=JSON.parse}=t,s=t.defaultValue,r=t.bidirectional,o=he?void 0:te(t.storage);return{[K]:!0,[D]:!1,[C]:"",useState(i,b){b??={};const R=be(b.onSet??(()=>{}),b.delayedSet,[]),f=Re(),l=this[C],S=this[D],[T,g]=_.useState(!S);_.useEffect(()=>g(!0),[]);const y=_.useMemo(()=>{if(!T||!o)return;const E=o.getItem(l);return H({serialized:E,defaultValue:i,superDefaultValue:s,deserialize:a})},[l,T]),k=_.useMemo(()=>fe(f.stateVocab,l,y??F(i,s)),[f.stateVocab,y,l]);_.useEffect(()=>{!o||typeof y>"u"||f.setStateVocab(N(l,y))},[y]),_.useEffect(()=>{if(!b.bidirectional&&!r)return;const E=v=>{if(v.key!==l)return;const h=v.newValue,P=H({serialized:h,defaultValue:i,superDefaultValue:s,deserialize:a});f.setStateVocab(N(l,P)),R(P,p.current),p.current=P};return window.addEventListener("storage",E),()=>window.removeEventListener("storage",E)},[l,b.bidirectional,r]);const p=_.useRef(k);return[k,function(v){const h=ye(v)?v(p.current):v;f.setStateVocab(N(l,h)),R(h,p.current),o&&o.setItem(l,c(h)),p.current=h},function(){const v=F(i,s);if(typeof v>"u"){o?.removeItem(l);return}f.setStateVocab(N(l,v)),R(v,p.current),p.current=v,o&&o.setItem(l,c(v))}]},toString(){return this[C]}}}const Z=new WeakMap,Q=new WeakMap;function re(t,c){c??={};const{path:a="",ssr:s}=c;let r=Z.get(t);r||(r=new Map,Z.set(t,r));const o=r.get(a);if(o)return o;const i=new Proxy(t,{get(b,R){const f=b[R],l=a?`${a}.${String(R)}`:String(R);if(f&&typeof f=="object"&&K in f){const S=f;let T=Q.get(S);T||(T=new Map,Q.set(S,T));const g=T.get(l);if(g)return g;const y=Reflect.ownKeys(S).filter(E=>typeof S[E]=="function"),k=Object.fromEntries(y.map(E=>[E,(...v)=>S[E].call({...S,[C]:l,[D]:s},...v)])),p={...S,...k};return T.set(l,p),p}return f&&typeof f=="object"?re(f,{path:l,ssr:s}):f}});return r.set(a,i),i}function we(t,c){return re(t,c)}exports.StorageProvider=Te;exports.defineState=ke;exports.setupStorage=we;
@@ -1,121 +1,121 @@
1
- import fe, { useMemo as $, createContext as de, useState as me, useContext as be, useEffect as W, useRef as ve } from "react";
2
- const H = Symbol("state-def"), O = Symbol("state-path");
3
- function Ee(t, c, o) {
1
+ import me, { useMemo as F, createContext as be, useState as ee, useContext as ve, useEffect as D, useRef as pe } from "react";
2
+ const te = Symbol("state-def"), N = Symbol("state-path"), M = Symbol("state-ssr-support");
3
+ function Ee(t, c, a) {
4
4
  if (!c)
5
5
  return t;
6
- const a = c.split(".");
6
+ const s = c.split(".");
7
7
  let r = t;
8
- for (const s of a)
9
- if (r !== null && typeof r == "object" && s in r)
10
- r = r[s];
8
+ for (const o of s)
9
+ if (r !== null && typeof r == "object" && o in r)
10
+ r = r[o];
11
11
  else
12
- return o;
13
- return r === void 0 ? o : r;
12
+ return a;
13
+ return r === void 0 ? a : r;
14
14
  }
15
- function pe(t, c, o) {
16
- const a = c.replace(/\[(\d+)\]/g, ".$1").split(".");
15
+ function _e(t, c, a) {
16
+ const s = c.replace(/\[(\d+)\]/g, ".$1").split(".");
17
17
  let r = t;
18
- for (let s = 0; s < a.length - 1; s++) {
19
- const f = a[s], u = a[s + 1];
20
- (r[f] === void 0 || r[f] === null) && (r[f] = /^\d+$/.test(u) ? [] : {}), r = r[f];
18
+ for (let o = 0; o < s.length - 1; o++) {
19
+ const i = s[o], b = s[o + 1];
20
+ (r[i] === void 0 || r[i] === null) && (r[i] = /^\d+$/.test(b) ? [] : {}), r = r[i];
21
21
  }
22
- return r[a[a.length - 1]] = o, t;
22
+ return r[s[s.length - 1]] = a, t;
23
23
  }
24
- function _e(t, c = 0) {
25
- let o;
26
- return function(...a) {
27
- o !== void 0 && clearTimeout(o), o = setTimeout(() => {
28
- o = void 0, t.apply(this, a);
24
+ function Se(t, c = 0) {
25
+ let a;
26
+ return function(...s) {
27
+ a !== void 0 && clearTimeout(a), a = setTimeout(() => {
28
+ a = void 0, t.apply(this, s);
29
29
  }, c);
30
30
  };
31
31
  }
32
- function Se(t, c, o = []) {
33
- return $(
34
- () => _e(t, c),
32
+ function Re(t, c, a = []) {
33
+ return F(
34
+ () => Se(t, c),
35
35
  // eslint-disable-next-line react-hooks/exhaustive-deps
36
- o
36
+ a
37
37
  );
38
38
  }
39
- function Re(t) {
39
+ function Te(t) {
40
40
  const c = JSON.stringify(t, null, 2).split(`
41
- `), o = [], a = [];
41
+ `), a = [], s = [];
42
42
  for (const r of c) {
43
- const s = r.match(/^(\s*)"([^"]+)"(\s*:\s*)(.+)$/);
44
- if (s) {
45
- const [, f, u, p, v] = s;
46
- o.push(`${f}%c"${u}"%c${p}%c${v}`), a.push(
43
+ const o = r.match(/^(\s*)"([^"]+)"(\s*:\s*)(.+)$/);
44
+ if (o) {
45
+ const [, i, b, S, f] = o;
46
+ a.push(`${i}%c"${b}"%c${S}%c${f}`), s.push(
47
47
  "color: #9cdcfe; font-weight: bold",
48
48
  "color: #cccccc",
49
49
  "color: #ce9178"
50
50
  );
51
51
  } else
52
- o.push(`%c${r}`), a.push("color: #cccccc");
52
+ a.push(`%c${r}`), s.push("color: #cccccc");
53
53
  }
54
- console.log(o.join(`
55
- `), ...a, t);
54
+ console.log(a.join(`
55
+ `), ...s, t);
56
56
  }
57
- var x = { exports: {} }, h = {};
58
- var J;
57
+ var A = { exports: {} }, P = {};
58
+ var X;
59
59
  function ye() {
60
- if (J) return h;
61
- J = 1;
60
+ if (X) return P;
61
+ X = 1;
62
62
  var t = Symbol.for("react.transitional.element"), c = Symbol.for("react.fragment");
63
- function o(a, r, s) {
64
- var f = null;
65
- if (s !== void 0 && (f = "" + s), r.key !== void 0 && (f = "" + r.key), "key" in r) {
66
- s = {};
67
- for (var u in r)
68
- u !== "key" && (s[u] = r[u]);
69
- } else s = r;
70
- return r = s.ref, {
63
+ function a(s, r, o) {
64
+ var i = null;
65
+ if (o !== void 0 && (i = "" + o), r.key !== void 0 && (i = "" + r.key), "key" in r) {
66
+ o = {};
67
+ for (var b in r)
68
+ b !== "key" && (o[b] = r[b]);
69
+ } else o = r;
70
+ return r = o.ref, {
71
71
  $$typeof: t,
72
- type: a,
73
- key: f,
72
+ type: s,
73
+ key: i,
74
74
  ref: r !== void 0 ? r : null,
75
- props: s
75
+ props: o
76
76
  };
77
77
  }
78
- return h.Fragment = c, h.jsx = o, h.jsxs = o, h;
78
+ return P.Fragment = c, P.jsx = a, P.jsxs = a, P;
79
79
  }
80
- var k = {};
81
- var U;
82
- function Te() {
83
- return U || (U = 1, process.env.NODE_ENV !== "production" && (function() {
80
+ var x = {};
81
+ var B;
82
+ function ge() {
83
+ return B || (B = 1, process.env.NODE_ENV !== "production" && (function() {
84
84
  function t(e) {
85
85
  if (e == null) return null;
86
86
  if (typeof e == "function")
87
- return e.$$typeof === ue ? null : e.displayName || e.name || null;
87
+ return e.$$typeof === ie ? null : e.displayName || e.name || null;
88
88
  if (typeof e == "string") return e;
89
89
  switch (e) {
90
- case S:
90
+ case p:
91
91
  return "Fragment";
92
- case ee:
92
+ case v:
93
93
  return "Profiler";
94
- case g:
94
+ case E:
95
95
  return "StrictMode";
96
- case oe:
96
+ case se:
97
97
  return "Suspense";
98
- case ae:
99
- return "SuspenseList";
100
98
  case ce:
99
+ return "SuspenseList";
100
+ case le:
101
101
  return "Activity";
102
102
  }
103
103
  if (typeof e == "object")
104
104
  switch (typeof e.tag == "number" && console.error(
105
105
  "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
106
106
  ), e.$$typeof) {
107
- case d:
107
+ case h:
108
108
  return "Portal";
109
- case re:
109
+ case w:
110
110
  return e.displayName || "Context";
111
- case te:
111
+ case g:
112
112
  return (e._context.displayName || "Context") + ".Consumer";
113
- case ne:
113
+ case ae:
114
114
  var n = e.render;
115
115
  return e = e.displayName, e || (e = n.displayName || n.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
116
- case se:
116
+ case ue:
117
117
  return n = e.displayName || null, n !== null ? n : t(e.type) || "Memo";
118
- case A:
118
+ case C:
119
119
  n = e._payload, e = e._init;
120
120
  try {
121
121
  return t(e(n));
@@ -127,7 +127,7 @@ function Te() {
127
127
  function c(e) {
128
128
  return "" + e;
129
129
  }
130
- function o(e) {
130
+ function a(e) {
131
131
  try {
132
132
  c(e);
133
133
  var n = !1;
@@ -136,17 +136,17 @@ function Te() {
136
136
  }
137
137
  if (n) {
138
138
  n = console;
139
- var i = n.error, m = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
140
- return i.call(
139
+ var u = n.error, d = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
140
+ return u.call(
141
141
  n,
142
142
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
143
- m
143
+ d
144
144
  ), c(e);
145
145
  }
146
146
  }
147
- function a(e) {
148
- if (e === S) return "<>";
149
- if (typeof e == "object" && e !== null && e.$$typeof === A)
147
+ function s(e) {
148
+ if (e === p) return "<>";
149
+ if (typeof e == "object" && e !== null && e.$$typeof === C)
150
150
  return "<...>";
151
151
  try {
152
152
  var n = t(e);
@@ -156,48 +156,48 @@ function Te() {
156
156
  }
157
157
  }
158
158
  function r() {
159
- var e = j.A;
159
+ var e = V.A;
160
160
  return e === null ? null : e.getOwner();
161
161
  }
162
- function s() {
162
+ function o() {
163
163
  return Error("react-stack-top-frame");
164
164
  }
165
- function f(e) {
166
- if (Y.call(e, "key")) {
165
+ function i(e) {
166
+ if (z.call(e, "key")) {
167
167
  var n = Object.getOwnPropertyDescriptor(e, "key").get;
168
168
  if (n && n.isReactWarning) return !1;
169
169
  }
170
170
  return e.key !== void 0;
171
171
  }
172
- function u(e, n) {
173
- function i() {
174
- D || (D = !0, console.error(
172
+ function b(e, n) {
173
+ function u() {
174
+ W || (W = !0, console.error(
175
175
  "%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)",
176
176
  n
177
177
  ));
178
178
  }
179
- i.isReactWarning = !0, Object.defineProperty(e, "key", {
180
- get: i,
179
+ u.isReactWarning = !0, Object.defineProperty(e, "key", {
180
+ get: u,
181
181
  configurable: !0
182
182
  });
183
183
  }
184
- function p() {
184
+ function S() {
185
185
  var e = t(this.type);
186
- return F[e] || (F[e] = !0, console.error(
186
+ return J[e] || (J[e] = !0, console.error(
187
187
  "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."
188
188
  )), e = this.props.ref, e !== void 0 ? e : null;
189
189
  }
190
- function v(e, n, i, m, w, C) {
191
- var b = i.ref;
190
+ function f(e, n, u, d, O, I) {
191
+ var m = u.ref;
192
192
  return e = {
193
- $$typeof: _,
193
+ $$typeof: T,
194
194
  type: e,
195
195
  key: n,
196
- props: i,
197
- _owner: m
198
- }, (b !== void 0 ? b : null) !== null ? Object.defineProperty(e, "ref", {
196
+ props: u,
197
+ _owner: d
198
+ }, (m !== void 0 ? m : null) !== null ? Object.defineProperty(e, "ref", {
199
199
  enumerable: !1,
200
- get: p
200
+ get: S
201
201
  }) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
202
202
  configurable: !1,
203
203
  enumerable: !1,
@@ -212,263 +212,279 @@ function Te() {
212
212
  configurable: !1,
213
213
  enumerable: !1,
214
214
  writable: !0,
215
- value: w
215
+ value: O
216
216
  }), Object.defineProperty(e, "_debugTask", {
217
217
  configurable: !1,
218
218
  enumerable: !1,
219
219
  writable: !0,
220
- value: C
220
+ value: I
221
221
  }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
222
222
  }
223
- function l(e, n, i, m, w, C) {
224
- var b = n.children;
225
- if (b !== void 0)
226
- if (m)
227
- if (le(b)) {
228
- for (m = 0; m < b.length; m++)
229
- R(b[m]);
230
- Object.freeze && Object.freeze(b);
223
+ function l(e, n, u, d, O, I) {
224
+ var m = n.children;
225
+ if (m !== void 0)
226
+ if (d)
227
+ if (fe(m)) {
228
+ for (d = 0; d < m.length; d++)
229
+ _(m[d]);
230
+ Object.freeze && Object.freeze(m);
231
231
  } else
232
232
  console.error(
233
233
  "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
234
234
  );
235
- else R(b);
236
- if (Y.call(n, "key")) {
237
- b = t(e);
238
- var T = Object.keys(n).filter(function(ie) {
239
- return ie !== "key";
235
+ else _(m);
236
+ if (z.call(n, "key")) {
237
+ m = t(e);
238
+ var k = Object.keys(n).filter(function(de) {
239
+ return de !== "key";
240
240
  });
241
- m = 0 < T.length ? "{key: someKey, " + T.join(": ..., ") + ": ...}" : "{key: someKey}", z[b + m] || (T = 0 < T.length ? "{" + T.join(": ..., ") + ": ...}" : "{}", console.error(
241
+ d = 0 < k.length ? "{key: someKey, " + k.join(": ..., ") + ": ...}" : "{key: someKey}", G[m + d] || (k = 0 < k.length ? "{" + k.join(": ..., ") + ": ...}" : "{}", console.error(
242
242
  `A props object containing a "key" prop is being spread into JSX:
243
243
  let props = %s;
244
244
  <%s {...props} />
245
245
  React keys must be passed directly to JSX without using spread:
246
246
  let props = %s;
247
247
  <%s key={someKey} {...props} />`,
248
+ d,
248
249
  m,
249
- b,
250
- T,
251
- b
252
- ), z[b + m] = !0);
250
+ k,
251
+ m
252
+ ), G[m + d] = !0);
253
253
  }
254
- if (b = null, i !== void 0 && (o(i), b = "" + i), f(n) && (o(n.key), b = "" + n.key), "key" in n) {
255
- i = {};
256
- for (var V in n)
257
- V !== "key" && (i[V] = n[V]);
258
- } else i = n;
259
- return b && u(
260
- i,
254
+ if (m = null, u !== void 0 && (a(u), m = "" + u), i(n) && (a(n.key), m = "" + n.key), "key" in n) {
255
+ u = {};
256
+ for (var Y in n)
257
+ Y !== "key" && (u[Y] = n[Y]);
258
+ } else u = n;
259
+ return m && b(
260
+ u,
261
261
  typeof e == "function" ? e.displayName || e.name || "Unknown" : e
262
- ), v(
262
+ ), f(
263
263
  e,
264
- b,
265
- i,
264
+ m,
265
+ u,
266
266
  r(),
267
- w,
268
- C
267
+ O,
268
+ I
269
269
  );
270
270
  }
271
- function R(e) {
272
- y(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === A && (e._payload.status === "fulfilled" ? y(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
271
+ function _(e) {
272
+ R(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === C && (e._payload.status === "fulfilled" ? R(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
273
273
  }
274
- function y(e) {
275
- return typeof e == "object" && e !== null && e.$$typeof === _;
274
+ function R(e) {
275
+ return typeof e == "object" && e !== null && e.$$typeof === T;
276
276
  }
277
- var E = fe, _ = Symbol.for("react.transitional.element"), d = Symbol.for("react.portal"), S = Symbol.for("react.fragment"), g = Symbol.for("react.strict_mode"), ee = Symbol.for("react.profiler"), te = Symbol.for("react.consumer"), re = Symbol.for("react.context"), ne = Symbol.for("react.forward_ref"), oe = Symbol.for("react.suspense"), ae = Symbol.for("react.suspense_list"), se = Symbol.for("react.memo"), A = Symbol.for("react.lazy"), ce = Symbol.for("react.activity"), ue = Symbol.for("react.client.reference"), j = E.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, Y = Object.prototype.hasOwnProperty, le = Array.isArray, N = console.createTask ? console.createTask : function() {
277
+ var y = me, T = Symbol.for("react.transitional.element"), h = Symbol.for("react.portal"), p = Symbol.for("react.fragment"), E = Symbol.for("react.strict_mode"), v = Symbol.for("react.profiler"), g = Symbol.for("react.consumer"), w = Symbol.for("react.context"), ae = Symbol.for("react.forward_ref"), se = Symbol.for("react.suspense"), ce = Symbol.for("react.suspense_list"), ue = Symbol.for("react.memo"), C = Symbol.for("react.lazy"), le = Symbol.for("react.activity"), ie = Symbol.for("react.client.reference"), V = y.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, z = Object.prototype.hasOwnProperty, fe = Array.isArray, $ = console.createTask ? console.createTask : function() {
278
278
  return null;
279
279
  };
280
- E = {
280
+ y = {
281
281
  react_stack_bottom_frame: function(e) {
282
282
  return e();
283
283
  }
284
284
  };
285
- var D, F = {}, M = E.react_stack_bottom_frame.bind(
286
- E,
287
- s
288
- )(), L = N(a(s)), z = {};
289
- k.Fragment = S, k.jsx = function(e, n, i) {
290
- var m = 1e4 > j.recentlyCreatedOwnerStacks++;
285
+ var W, J = {}, U = y.react_stack_bottom_frame.bind(
286
+ y,
287
+ o
288
+ )(), q = $(s(o)), G = {};
289
+ x.Fragment = p, x.jsx = function(e, n, u) {
290
+ var d = 1e4 > V.recentlyCreatedOwnerStacks++;
291
291
  return l(
292
292
  e,
293
293
  n,
294
- i,
294
+ u,
295
295
  !1,
296
- m ? Error("react-stack-top-frame") : M,
297
- m ? N(a(e)) : L
296
+ d ? Error("react-stack-top-frame") : U,
297
+ d ? $(s(e)) : q
298
298
  );
299
- }, k.jsxs = function(e, n, i) {
300
- var m = 1e4 > j.recentlyCreatedOwnerStacks++;
299
+ }, x.jsxs = function(e, n, u) {
300
+ var d = 1e4 > V.recentlyCreatedOwnerStacks++;
301
301
  return l(
302
302
  e,
303
303
  n,
304
- i,
304
+ u,
305
305
  !0,
306
- m ? Error("react-stack-top-frame") : M,
307
- m ? N(a(e)) : L
306
+ d ? Error("react-stack-top-frame") : U,
307
+ d ? $(s(e)) : q
308
308
  );
309
309
  };
310
- })()), k;
310
+ })()), x;
311
311
  }
312
- var q;
313
- function ge() {
314
- return q || (q = 1, process.env.NODE_ENV === "production" ? x.exports = ye() : x.exports = Te()), x.exports;
312
+ var H;
313
+ function he() {
314
+ return H || (H = 1, process.env.NODE_ENV === "production" ? A.exports = ye() : A.exports = ge()), A.exports;
315
315
  }
316
- var he = ge();
317
- const Z = de({
316
+ var ke = he();
317
+ const re = be({
318
318
  stateVocab: {},
319
319
  setStateVocab: () => {
320
320
  }
321
321
  });
322
- function ke() {
323
- return be(Z);
322
+ function we() {
323
+ return ve(re);
324
324
  }
325
- const Oe = (t) => {
326
- const { children: c, verbose: o } = t, [a, r] = me({});
327
- return o && Re(a), /* @__PURE__ */ he.jsx(Z.Provider, { value: { stateVocab: a, setStateVocab: r }, children: c });
328
- }, P = (t, c) => (o) => {
329
- const a = { ...o };
330
- return pe(a, t, c), a;
331
- }, I = (t, c) => Q(t) ?? c, G = (t) => {
332
- const { serialized: c, defaultValue: o, superDefaultValue: a, deserialize: r } = t;
325
+ const je = (t) => {
326
+ const { children: c, verbose: a } = t, [s, r] = ee({});
327
+ return a && Te(s), /* @__PURE__ */ ke.jsx(re.Provider, { value: { stateVocab: s, setStateVocab: r }, children: c });
328
+ }, j = (t, c) => (a) => {
329
+ const s = { ...a };
330
+ return _e(s, t, c), s;
331
+ }, L = (t, c) => ne(t) ?? c, Z = (t) => {
332
+ const { serialized: c, defaultValue: a, superDefaultValue: s, deserialize: r } = t;
333
333
  if (c === null) {
334
- const s = I(o, a);
335
- return typeof s > "u" ? void 0 : s;
334
+ const o = L(a, s);
335
+ return typeof o > "u" ? void 0 : o;
336
336
  }
337
337
  return r(c);
338
- }, we = (t) => typeof t == "function", xe = (t) => typeof t == "function", Q = (t) => xe(t) ? t() : t;
339
- function Ae(t = {}) {
338
+ }, Pe = (t) => typeof t == "function", xe = (t) => typeof t == "function", ne = (t) => xe(t) ? t() : t, Oe = typeof window > "u";
339
+ function Ne(t = {}) {
340
340
  const {
341
341
  serialize: c = JSON.stringify,
342
- deserialize: o = JSON.parse
343
- } = t, a = t.defaultValue, r = t.bidirectional, s = typeof window > "u" ? void 0 : Q(t.storage);
342
+ deserialize: a = JSON.parse
343
+ } = t, s = t.defaultValue, r = t.bidirectional, o = Oe ? void 0 : ne(t.storage);
344
344
  return {
345
- [H]: !0,
345
+ [te]: !0,
346
346
  // marks this object as a leaf in the router tree
347
- [O]: "",
347
+ [M]: !1,
348
348
  // placeholder; injected at runtime by injectPaths()
349
- useState(f, u) {
350
- u ??= {};
351
- const p = Se(
352
- u.onSet ?? (() => {
349
+ [N]: "",
350
+ // placeholder; injected at runtime by injectPaths()
351
+ useState(i, b) {
352
+ b ??= {};
353
+ const S = Re(
354
+ b.onSet ?? (() => {
353
355
  }),
354
- u.delayedSet,
356
+ b.delayedSet,
355
357
  []
356
- ), v = ke(), l = this[O], R = $(
358
+ ), f = we(), l = this[N], _ = this[M], [R, y] = ee(!_);
359
+ D(() => y(!0), []);
360
+ const T = F(
357
361
  () => {
358
- if (!s)
362
+ if (!R || !o)
359
363
  return;
360
- const _ = s.getItem(l);
361
- return G({
362
- serialized: _,
363
- defaultValue: f,
364
- superDefaultValue: a,
365
- deserialize: o
364
+ const E = o.getItem(l);
365
+ return Z({
366
+ serialized: E,
367
+ defaultValue: i,
368
+ superDefaultValue: s,
369
+ deserialize: a
366
370
  });
367
371
  },
368
372
  // eslint-disable-next-line react-hooks/exhaustive-deps
369
- [l]
370
- ), y = $(
373
+ [l, R]
374
+ ), h = F(
371
375
  () => Ee(
372
- v.stateVocab,
376
+ f.stateVocab,
373
377
  l,
374
- R ?? I(f, a)
378
+ T ?? L(i, s)
375
379
  ),
376
380
  // eslint-disable-next-line react-hooks/exhaustive-deps
377
381
  [
378
- v.stateVocab,
379
- R,
382
+ f.stateVocab,
383
+ T,
380
384
  l
381
385
  ]
382
386
  );
383
- W(
387
+ D(
384
388
  () => {
385
- !s || typeof R > "u" || v.setStateVocab(P(l, R));
389
+ !o || typeof T > "u" || f.setStateVocab(j(l, T));
386
390
  },
387
391
  // eslint-disable-next-line react-hooks/exhaustive-deps
388
- [R]
389
- ), W(() => {
390
- if (!u.bidirectional && !r)
392
+ [T]
393
+ ), D(() => {
394
+ if (!b.bidirectional && !r)
391
395
  return;
392
- const _ = (d) => {
393
- if (d.key !== l)
396
+ const E = (v) => {
397
+ if (v.key !== l)
394
398
  return;
395
- const S = d.newValue, g = G({
396
- serialized: S,
397
- defaultValue: f,
398
- superDefaultValue: a,
399
- deserialize: o
399
+ const g = v.newValue, w = Z({
400
+ serialized: g,
401
+ defaultValue: i,
402
+ superDefaultValue: s,
403
+ deserialize: a
400
404
  });
401
- v.setStateVocab(P(l, g)), p(g, E.current), E.current = g;
405
+ f.setStateVocab(j(l, w)), S(w, p.current), p.current = w;
402
406
  };
403
- return window.addEventListener("storage", _), () => window.removeEventListener("storage", _);
407
+ return window.addEventListener("storage", E), () => window.removeEventListener("storage", E);
404
408
  }, [
405
409
  l,
406
- u.bidirectional,
410
+ b.bidirectional,
407
411
  r
408
412
  ]);
409
- const E = ve(y);
413
+ const p = pe(h);
410
414
  return [
411
- y,
412
- function(d) {
413
- const S = we(d) ? d(E.current) : d;
414
- v.setStateVocab(P(l, S)), p(S, E.current), s && s.setItem(l, c(S)), E.current = S;
415
+ h,
416
+ function(v) {
417
+ const g = Pe(v) ? v(p.current) : v;
418
+ f.setStateVocab(j(l, g)), S(g, p.current), o && o.setItem(l, c(g)), p.current = g;
415
419
  },
416
420
  function() {
417
- const d = I(f, a);
418
- if (typeof d > "u") {
419
- s?.removeItem(l);
421
+ const v = L(i, s);
422
+ if (typeof v > "u") {
423
+ o?.removeItem(l);
420
424
  return;
421
425
  }
422
- v.setStateVocab(P(l, d)), p(d, E.current), E.current = d, s && s.setItem(l, c(d));
426
+ f.setStateVocab(j(l, v)), S(v, p.current), p.current = v, o && o.setItem(l, c(v));
423
427
  }
424
428
  ];
425
429
  },
426
430
  /** Returns the fully qualified job name (dot-separated path). */
427
431
  toString() {
428
- return this[O];
432
+ return this[N];
429
433
  }
430
434
  };
431
435
  }
432
- const X = /* @__PURE__ */ new WeakMap(), B = /* @__PURE__ */ new WeakMap();
433
- function K(t, c = "") {
434
- let o = X.get(t);
435
- o || (o = /* @__PURE__ */ new Map(), X.set(t, o));
436
- const a = o.get(c);
437
- if (a)
438
- return a;
439
- const r = new Proxy(t, {
440
- get(s, f) {
441
- const u = s[f], p = c ? `${c}.${String(f)}` : String(f);
442
- if (u && typeof u == "object" && H in u) {
443
- const v = u;
444
- let l = B.get(v);
445
- l || (l = /* @__PURE__ */ new Map(), B.set(v, l));
446
- const R = l.get(p);
447
- if (R)
448
- return R;
449
- const y = Reflect.ownKeys(v).filter(
450
- (d) => typeof v[d] == "function"
451
- ), E = Object.fromEntries(
452
- y.map((d) => [
453
- d,
454
- (...S) => v[d].call(
455
- { ...v, [O]: p },
456
- ...S
436
+ const Q = /* @__PURE__ */ new WeakMap(), K = /* @__PURE__ */ new WeakMap();
437
+ function oe(t, c) {
438
+ c ??= {};
439
+ const {
440
+ path: a = "",
441
+ ssr: s
442
+ } = c;
443
+ let r = Q.get(t);
444
+ r || (r = /* @__PURE__ */ new Map(), Q.set(t, r));
445
+ const o = r.get(a);
446
+ if (o)
447
+ return o;
448
+ const i = new Proxy(t, {
449
+ get(b, S) {
450
+ const f = b[S], l = a ? `${a}.${String(S)}` : String(S);
451
+ if (f && typeof f == "object" && te in f) {
452
+ const _ = f;
453
+ let R = K.get(_);
454
+ R || (R = /* @__PURE__ */ new Map(), K.set(_, R));
455
+ const y = R.get(l);
456
+ if (y)
457
+ return y;
458
+ const T = Reflect.ownKeys(_).filter(
459
+ (E) => typeof _[E] == "function"
460
+ ), h = Object.fromEntries(
461
+ T.map((E) => [
462
+ E,
463
+ (...v) => _[E].call(
464
+ {
465
+ ..._,
466
+ [N]: l,
467
+ [M]: s
468
+ },
469
+ ...v
457
470
  )
458
471
  ])
459
- ), _ = { ...v, ...E };
460
- return l.set(p, _), _;
472
+ ), p = { ..._, ...h };
473
+ return R.set(l, p), p;
461
474
  }
462
- return u && typeof u == "object" ? K(u, p) : u;
475
+ return f && typeof f == "object" ? oe(f, {
476
+ path: l,
477
+ ssr: s
478
+ }) : f;
463
479
  }
464
480
  });
465
- return o.set(c, r), r;
481
+ return r.set(a, i), i;
466
482
  }
467
- function je(t) {
468
- return K(t);
483
+ function Ce(t, c) {
484
+ return oe(t, c);
469
485
  }
470
486
  export {
471
- Oe as StorageProvider,
472
- Ae as defineState,
473
- je as setupStorage
487
+ je as StorageProvider,
488
+ Ne as defineState,
489
+ Ce as setupStorage
474
490
  };
@@ -1,2 +1,3 @@
1
1
  export declare const STATE_DEFINITION: unique symbol;
2
2
  export declare const STATE_PATH: unique symbol;
3
+ export declare const STATE_SSR_SUPPORT: unique symbol;
@@ -1 +1,3 @@
1
- export declare function setupStorage<T extends object>(nativeRouter: T): T;
1
+ export declare function setupStorage<T extends object>(native: T, options?: Partial<{
2
+ ssr: boolean;
3
+ }>): T;
@@ -1,4 +1,4 @@
1
- import { STATE_DEFINITION, STATE_PATH } from "./constants";
1
+ import { STATE_DEFINITION, STATE_PATH, STATE_SSR_SUPPORT } from "./constants";
2
2
  import type { ValueOrFactory, ValueOrTransformer } from "./types";
3
3
  export declare function defineState<T>(definitionOptions?: {
4
4
  storage?: ValueOrFactory<Storage>;
@@ -8,9 +8,11 @@ export declare function defineState<T>(definitionOptions?: {
8
8
  deserialize?: (v: string) => T;
9
9
  }): {
10
10
  [STATE_DEFINITION]: boolean;
11
+ [STATE_SSR_SUPPORT]: boolean;
11
12
  [STATE_PATH]: string;
12
13
  useState<D = T>(this: {
13
14
  [STATE_PATH]: string;
15
+ [STATE_SSR_SUPPORT]: boolean;
14
16
  }, defaultValue?: ValueOrFactory<D>, options?: {
15
17
  delayedSet?: number;
16
18
  bidirectional?: true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yakocloud/state-vocab",
3
- "version": "2.1.2",
3
+ "version": "2.1.3",
4
4
  "main": "dist/state-vocab.cjs.js",
5
5
  "module": "dist/state-vocab.es.js",
6
6
  "types": "dist/types/index.d.ts",