@yakocloud/state-vocab 3.0.9 → 3.1.1

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