@yakocloud/state-vocab 2.5.1 → 3.0.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.
package/README.md CHANGED
@@ -52,7 +52,7 @@ function ThemeToggle() {
52
52
  }
53
53
  ```
54
54
 
55
- **Initialize once at the root, read anywhere in the tree.** Call `.useState()` with a `defaultValue` at a parent component to seed the state — then call `.useState()` without arguments in any descendant to consume it. No context wiring, no prop passing. Convenient in NextJs
55
+ **Initialize once at the root, read anywhere in the tree.** Call `.useState()` with a `defaultValue` at a parent component to seed the state — then call `.useState()` without arguments in any descendant to consume it. No context wiring, no prop passing.
56
56
 
57
57
  ```tsx
58
58
  // Root component — initializes the state
@@ -82,8 +82,6 @@ function DeepChild() {
82
82
  }
83
83
  ```
84
84
 
85
- The `defaultValue` at the root acts as the initializer — subsequent `.useState()` calls in children pick up the shared value automatically without re-specifying defaults.
86
-
87
85
  **Dot-notation access with full TypeScript inference.** The state tree is navigated like a plain object — autocomplete guides you to the right node, and types flow from `defineState<T>` all the way to the hook return value without any manual annotations.
88
86
 
89
87
  ```ts
@@ -105,7 +103,7 @@ defineState({
105
103
  })
106
104
  ```
107
105
 
108
- **Minimal API surface.** Three exports: `defineState`, `setupStorage`, `StorageProvider`. No actions, reducers, selectors, or stores to configure.
106
+ **Minimal API surface.** Two exports: `defineState`, `setupStorage`. No actions, reducers, selectors, or stores to configure.
109
107
 
110
108
  ## Installation
111
109
 
@@ -118,7 +116,7 @@ npm install @yakocloud/state-vocab react react-dom
118
116
  ## Quick Start
119
117
 
120
118
  ```tsx
121
- import { setupStorage, defineState, StorageProvider } from '@yakocloud/state-vocab'
119
+ import { setupStorage, defineState } from '@yakocloud/state-vocab'
122
120
 
123
121
  type Theme = 'Dark' | 'White' | 'System'
124
122
 
@@ -133,14 +131,6 @@ const storage = setupStorage({
133
131
  },
134
132
  })
135
133
 
136
- function App() {
137
- return (
138
- <StorageProvider>
139
- <Settings />
140
- </StorageProvider>
141
- )
142
- }
143
-
144
134
  function Settings() {
145
135
  const [theme, setTheme] = storage.path.to.theme.useState()
146
136
 
@@ -197,7 +187,7 @@ Wraps a nested object of `defineState()` nodes and injects dot-separated paths i
197
187
 
198
188
  | Option | Type | Description | Default |
199
189
  |---|---|---|---|
200
- | `ssr` | `boolean \| undefined` | Defer storage reads until after mount (SSR support) | `false` |
190
+ | `verbose` | `boolean \| undefined` | Log current state to the browser console on every change | `false` |
201
191
 
202
192
  ```ts
203
193
  const storage = setupStorage({
@@ -211,24 +201,10 @@ storage.user.name // → path: "user.name"
211
201
  storage.user.age // → path: "user.age"
212
202
  ```
213
203
 
214
- ### `StorageProvider`
215
-
216
- A React context provider that must wrap all components using `.useState()` from any state node. Place it once near the top of your tree.
217
-
218
- ```tsx
219
- createRoot(document.getElementById('root')!).render(
220
- <StorageProvider>
221
- <App />
222
- </StorageProvider>
223
- )
224
- ```
225
-
226
- Accepts an optional `verbose` prop that logs the current state vocab to the browser console on every change — useful during development.
204
+ Enable verbose logging during development:
227
205
 
228
- ```tsx
229
- <StorageProvider verbose>
230
- <App />
231
- </StorageProvider>
206
+ ```ts
207
+ const storage = setupStorage({ ... }, { verbose: true })
232
208
  ```
233
209
 
234
210
  ## `useState` Hook
@@ -309,7 +285,7 @@ const storage = setupStorage({
309
285
  ## Full Example
310
286
 
311
287
  ```tsx
312
- import { setupStorage, defineState, StorageProvider } from '@yakocloud/state-vocab'
288
+ import { setupStorage, defineState } from '@yakocloud/state-vocab'
313
289
 
314
290
  type Theme = 'Dark' | 'White' | 'System'
315
291
 
@@ -393,11 +369,7 @@ function Dashboard() {
393
369
  )
394
370
  }
395
371
 
396
- createRoot(document.getElementById('root')!).render(
397
- <StorageProvider>
398
- <Page />
399
- </StorageProvider>
400
- )
372
+ createRoot(document.getElementById('root')!).render(<Page />)
401
373
  ```
402
374
 
403
375
  ## API Reference
@@ -416,18 +388,10 @@ createRoot(document.getElementById('root')!).render(
416
388
 
417
389
  | Option | Type | Default |
418
390
  |---|---|---|
419
- | `ssr` | `boolean \| undefined` | `false` |
391
+ | `verbose` | `boolean \| undefined` | `false` |
420
392
 
421
393
  Returns a proxied copy of `tree` with paths injected into all leaf nodes.
422
394
 
423
- ### `StorageProvider`
424
-
425
- React context provider. Must be an ancestor of any component using `.useState()`.
426
-
427
- | Prop | Type | Description |
428
- |---|---|---|
429
- | `verbose` | `boolean \| undefined` | Log state vocab to console on every change |
430
-
431
395
  ### `node.useState(options?)`
432
396
 
433
397
  | Option | Type | Description |
@@ -1,8 +1,3 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("react"),re=Symbol("state-def"),$=Symbol("state-path"),W=Symbol("state-ssr");function ie(t,s,r){if(!s)return t;const a=s.split(".");let n=t;for(const c of a)if(n!==null&&typeof n=="object"&&c in n)n=n[c];else return r;return n===void 0?r:n}function fe(t,s,r){const a=s.replace(/\[(\d+)\]/g,".$1").split(".");let n=t;for(let c=0;c<a.length-1;c++){const m=a[c],v=a[c+1];(n[m]===void 0||n[m]===null)&&(n[m]=/^\d+$/.test(v)?[]:{}),n=n[m]}return n[a[a.length-1]]=r,t}function de(t,s=0){let r;return function(...a){r!==void 0&&clearTimeout(r),r=setTimeout(()=>{r=void 0,t.apply(this,a)},s)}}function me(t,s,r=[]){return p.useMemo(()=>de(t,s),r)}function be(t){const s=JSON.stringify(t,null,2).split(`
2
- `),r=[],a=[];for(const n of s){const c=n.match(/^(\s*)"([^"]+)"(\s*:\s*)(.+)$/);if(c){const[,m,v,S,l]=c;r.push(`${m}%c"${v}"%c${S}%c${l}`),a.push("color: #9cdcfe; font-weight: bold","color: #cccccc","color: #ce9178")}else r.push(`%c${n}`),a.push("color: #cccccc")}console.log(r.join(`
3
- `),...a,t)}var V={exports:{}},x={};var Z;function ve(){if(Z)return x;Z=1;var t=Symbol.for("react.transitional.element"),s=Symbol.for("react.fragment");function r(a,n,c){var m=null;if(c!==void 0&&(m=""+c),n.key!==void 0&&(m=""+n.key),"key"in n){c={};for(var v in n)v!=="key"&&(c[v]=n[v])}else c=n;return n=c.ref,{$$typeof:t,type:a,key:m,ref:n!==void 0?n:null,props:c}}return x.Fragment=s,x.jsx=r,x.jsxs=r,x}var O={};var Q;function Ee(){return Q||(Q=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 E:return"Fragment";case A:return"Profiler";case k:return"StrictMode";case J:return"Suspense";case w: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 T:return"Portal";case h:return e.displayName||"Context";case b:return(e._context.displayName||"Context")+".Consumer";case j:var o=e.render;return e=e.displayName,e||(e=o.displayName||o.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ae:return o=e.displayName||null,o!==null?o:t(e.type)||"Memo";case I:o=e._payload,e=e._init;try{return t(e(o))}catch{}}return null}function s(e){return""+e}function r(e){try{s(e);var o=!1}catch{o=!0}if(o){o=console;var u=o.error,f=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return u.call(o,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",f),s(e)}}function a(e){if(e===E)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===I)return"<...>";try{var o=t(e);return o?"<"+o+">":"<...>"}catch{return"<...>"}}function n(){var e=M.A;return e===null?null:e.getOwner()}function c(){return Error("react-stack-top-frame")}function m(e){if(U.call(e,"key")){var o=Object.getOwnPropertyDescriptor(e,"key").get;if(o&&o.isReactWarning)return!1}return e.key!==void 0}function v(e,o){function u(){q||(q=!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))}u.isReactWarning=!0,Object.defineProperty(e,"key",{get:u,configurable:!0})}function S(){var e=t(this.type);return G[e]||(G[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 l(e,o,u,f,N,D){var d=u.ref;return e={$$typeof:g,type:e,key:o,props:u,_owner:f},(d!==void 0?d:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:S}):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:N}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:D}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function i(e,o,u,f,N,D){var d=o.children;if(d!==void 0)if(f)if(ue(d)){for(f=0;f<d.length;f++)_(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 _(d);if(U.call(o,"key")){d=t(e);var P=Object.keys(o).filter(function(le){return le!=="key"});f=0<P.length?"{key: someKey, "+P.join(": ..., ")+": ...}":"{key: someKey}",H[d+f]||(P=0<P.length?"{"+P.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,P,d),H[d+f]=!0)}if(d=null,u!==void 0&&(r(u),d=""+u),m(o)&&(r(o.key),d=""+o.key),"key"in o){u={};for(var F in o)F!=="key"&&(u[F]=o[F])}else u=o;return d&&v(u,typeof e=="function"?e.displayName||e.name||"Unknown":e),l(e,d,u,n(),N,D)}function _(e){R(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===I&&(e._payload.status==="fulfilled"?R(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function R(e){return typeof e=="object"&&e!==null&&e.$$typeof===g}var y=p,g=Symbol.for("react.transitional.element"),T=Symbol.for("react.portal"),E=Symbol.for("react.fragment"),k=Symbol.for("react.strict_mode"),A=Symbol.for("react.profiler"),b=Symbol.for("react.consumer"),h=Symbol.for("react.context"),j=Symbol.for("react.forward_ref"),J=Symbol.for("react.suspense"),w=Symbol.for("react.suspense_list"),ae=Symbol.for("react.memo"),I=Symbol.for("react.lazy"),se=Symbol.for("react.activity"),ce=Symbol.for("react.client.reference"),M=y.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,U=Object.prototype.hasOwnProperty,ue=Array.isArray,Y=console.createTask?console.createTask:function(){return null};y={react_stack_bottom_frame:function(e){return e()}};var q,G={},X=y.react_stack_bottom_frame.bind(y,c)(),B=Y(a(c)),H={};O.Fragment=E,O.jsx=function(e,o,u){var f=1e4>M.recentlyCreatedOwnerStacks++;return i(e,o,u,!1,f?Error("react-stack-top-frame"):X,f?Y(a(e)):B)},O.jsxs=function(e,o,u){var f=1e4>M.recentlyCreatedOwnerStacks++;return i(e,o,u,!0,f?Error("react-stack-top-frame"):X,f?Y(a(e)):B)}})()),O}var K;function _e(){return K||(K=1,process.env.NODE_ENV==="production"?V.exports=ve():V.exports=Ee()),V.exports}var pe=_e();const ne=p.createContext({stateVocab:{},setStateVocab:()=>{}});function Se(){return p.useContext(ne)}const Re=t=>{const{children:s,verbose:r}=t,[a,n]=p.useState({});return r&&be(a),pe.jsx(ne.Provider,{value:{stateVocab:a,setStateVocab:n},children:s})},C=(t,s)=>r=>{const a={...r};return fe(a,t,s),a},Te=t=>typeof t=="function",ye=t=>typeof t=="function",z=t=>typeof t<"u",L=t=>ye(t)?t():t,ge=typeof window>"u";function he(t={}){return{[re]:!0,[W]:!1,[$]:"",useState(s){const r=ge?void 0:L(t.storage),a=t.serialize??JSON.stringify,n=t.deserialize??JSON.parse,c=L(t.defaultValue),m=t.bidirectional;s??={};const v=L(s.defaultValue),S=me(s.onSet??(()=>{}),s.delayedSet,[]),l=Se(),i=this[$],_=this[W],[R,y]=p.useState(!_);p.useEffect(()=>y(!0),[]);const g=p.useMemo(()=>{if(!R||!r)return;const b=r.getItem(i);return b===null?null:n(b)},[R]),T=p.useMemo(()=>ie(l.stateVocab,i,g??v??c),[l.stateVocab,g]),E=p.useRef(T);return p.useEffect(()=>{z(T)&&(l.setStateVocab(C(i,T)),r&&g===null&&r.setItem(i,a(T)),E.current=T)},[g]),p.useEffect(()=>{if(!s.bidirectional&&!m)return;const b=h=>{if(h.key!==i)return;const j=h.newValue,w=(j===null?null:n(j))??v??c;z(w)&&(l.setStateVocab(C(i,w)),S(w,E.current),E.current=w)};return window.addEventListener("storage",b),()=>window.removeEventListener("storage",b)},[s.bidirectional,m]),[T,b=>{const h=Te(b)?b(E.current):b;l.setStateVocab(C(i,h)),S(h,E.current),r&&r.setItem(i,a(h)),E.current=h},()=>{const b=v??c;if(!z(b)){r?.removeItem(i);return}l.setStateVocab(C(i,b)),S(b,E.current),E.current=b,r&&r.setItem(i,a(b))}]},toString(){return this[$]}}}const ee=new WeakMap,te=new WeakMap;function oe(t,s){s??={};const{path:r="",ssr:a}=s;let n=ee.get(t);n||(n=new Map,ee.set(t,n));const c=n.get(r);if(c)return c;const m=new Proxy(t,{get(v,S){const l=v[S],i=r?`${r}.${String(S)}`:String(S);if(l&&typeof l=="object"&&re in l){const _=l;let R=te.get(_);R||(R=new Map,te.set(_,R));const y=R.get(i);if(y)return y;const g=Reflect.ownKeys(_).filter(k=>typeof _[k]=="function"),T=Object.fromEntries(g.map(k=>[k,(...A)=>_[k].call({..._,[$]:i,[W]:a},...A)])),E={..._,...T};return R.set(i,E),E}return l&&typeof l=="object"?oe(l,{path:i,ssr:a}):l}});return n.set(r,m),m}function ke(t,s){return oe(t,s)}exports.StorageProvider=Re;exports.defineState=he;exports.setupStorage=ke;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("react"),M=Symbol("state-def"),w=Symbol("state-path"),$=Symbol("state-verbose");function z(e,t,s){if(!t)return e;const r=t.split(".");let n=e;for(const o of r)if(n!==null&&typeof n=="object"&&o in n)n=n[o];else return s;return n===void 0?s:n}function N(e,t,s){const r=t.replace(/\[(\d+)\]/g,".$1").split(".");let n=e;for(let o=0;o<r.length-1;o++){const a=r[o],g=r[o+1];(n[a]===void 0||n[a]===null)&&(n[a]=/^\d+$/.test(g)?[]:{}),n=n[a]}return n[r[r.length-1]]=s,e}function j(e,t=0){let s;return function(...r){s!==void 0&&clearTimeout(s),s=setTimeout(()=>{s=void 0,e.apply(this,r)},t)}}function A(e,t,s=[]){return S.useMemo(()=>j(e,t),s)}function D(e){const t=JSON.stringify(e,null,2).split(`
2
+ `),s=[],r=[];for(const n of t){const o=n.match(/^(\s*)"([^"]+)"(\s*:\s*)(.+)$/);if(o){const[,a,g,u,l]=o;s.push(`${a}%c"${g}"%c${u}%c${l}`),r.push("color: #9cdcfe; font-weight: bold","color: #cccccc","color: #ce9178")}else s.push(`%c${n}`),r.push("color: #cccccc")}console.log(s.join(`
3
+ `),...r,e)}const P=e=>typeof e=="function",O=e=>typeof e=="function",p=e=>typeof e<"u",k=e=>O(e)?e():e;class F{#e;#t;constructor(){this.#e={},this.#t=new Set}subscribe(t){return this.#t.add(t),()=>this.#t.delete(t)}getClientSnapshot(){return this.#e}getServerSnapshot(){return this.#e}set(t,s){const r=z(this.#e,t),n=P(s)?s(r):s,o={...this.#e};N(o,t,n),this.#e=o,this.#t.forEach(a=>a())}}function J(e={}){const t=new F;return{[M]:!0,[w]:"",[$]:!1,useState(s){const r=k(e.storage),n=e.serialize??JSON.stringify,o=e.deserialize??JSON.parse,a=k(e.defaultValue),g=e.bidirectional;s??={};const u=k(s.defaultValue)??a,l=s.bidirectional??g,f=A(s.onSet??(()=>{}),s.delayedSet,[]),c=this[w],y=this[$],h=S.useRef(void 0),m=S.useRef(!1);if(!m.current){m.current=!0;let i=z(t.getServerSnapshot(),c);if(!p(i)){if(i=u,r){const d=r.getItem(c);d===null?p(i)&&r.setItem(c,n(i)):i=o(d)}p(i)&&t.set(c,i)}}const V=S.useSyncExternalStore(t.subscribe.bind(t),()=>t.getClientSnapshot(),()=>t.getServerSnapshot());y&&D(V);const v=z(V,c);h.current=v;const b=S.useEffectEvent(i=>{if(i.key!==c)return;const d=i.newValue,T=(d===null?null:o(d))??u;p(T)&&(t.set(c,T),f(T,h.current))});S.useEffect(()=>{if(l)return window.addEventListener("storage",b),()=>window.removeEventListener("storage",b)},[l]);const E=S.useCallback(i=>{const d=P(i)?i(h.current):i;t.set(c,d),f(d,h.current),r&&r.setItem(c,n(d))},[c,r,n,f]),x=S.useCallback(()=>{const i=u;if(!p(i)){r?.removeItem(c);return}t.set(c,i),f(i,h.current),r&&r.setItem(c,n(i))},[c,u,r,n,f]);return[v,E,x]},toString(){return this[w]}}}const C=new WeakMap,I=new WeakMap;function R(e,t){t??={};const{path:s="",verbose:r}=t;let n=C.get(e);n||(n=new Map,C.set(e,n));const o=n.get(s);if(o)return o;const a=new Proxy(e,{get(g,u){const l=g[u],f=s?`${s}.${String(u)}`:String(u);if(l&&typeof l=="object"&&M in l){const c=l;let y=I.get(c);y||(y=new Map,I.set(c,y));const h=y.get(f);if(h)return h;const m=Reflect.ownKeys(c).filter(b=>typeof c[b]=="function"),V=Object.fromEntries(m.map(b=>[b,(...E)=>c[b].call({...c,[w]:f,[$]:r},...E)])),v={...c,...V};return y.set(f,v),v}return l&&typeof l=="object"?R(l,{path:f,verbose:r}):l}});return n.set(s,a),a}function L(e,t){return R(e,t)}exports.defineState=J;exports.setupStorage=L;
@@ -1,467 +1,212 @@
1
- import de, { useMemo as W, createContext as me, useState as ne, useContext as be, useEffect as M, useRef as ve } from "react";
2
- const oe = Symbol("state-def"), C = Symbol("state-path"), J = Symbol("state-ssr");
3
- function Ee(t, s, r) {
4
- if (!s)
5
- return t;
6
- const a = s.split(".");
7
- let n = t;
8
- for (const c of a)
9
- if (n !== null && typeof n == "object" && c in n)
10
- n = n[c];
1
+ import { useMemo as A, useRef as z, useSyncExternalStore as D, useEffectEvent as j, useEffect as F, useCallback as I } from "react";
2
+ const M = Symbol("state-def"), V = Symbol("state-path"), $ = Symbol("state-verbose");
3
+ function k(e, t, s) {
4
+ if (!t)
5
+ return e;
6
+ const r = t.split(".");
7
+ let n = e;
8
+ for (const o of r)
9
+ if (n !== null && typeof n == "object" && o in n)
10
+ n = n[o];
11
11
  else
12
- return r;
13
- return n === void 0 ? r : n;
12
+ return s;
13
+ return n === void 0 ? s : n;
14
14
  }
15
- function _e(t, s, r) {
16
- const a = s.replace(/\[(\d+)\]/g, ".$1").split(".");
17
- let n = t;
18
- for (let c = 0; c < a.length - 1; c++) {
19
- const m = a[c], v = a[c + 1];
20
- (n[m] === void 0 || n[m] === null) && (n[m] = /^\d+$/.test(v) ? [] : {}), n = n[m];
15
+ function J(e, t, s) {
16
+ const r = t.replace(/\[(\d+)\]/g, ".$1").split(".");
17
+ let n = e;
18
+ for (let o = 0; o < r.length - 1; o++) {
19
+ const l = r[o], S = r[o + 1];
20
+ (n[l] === void 0 || n[l] === null) && (n[l] = /^\d+$/.test(S) ? [] : {}), n = n[l];
21
21
  }
22
- return n[a[a.length - 1]] = r, t;
22
+ return n[r[r.length - 1]] = s, e;
23
23
  }
24
- function pe(t, s = 0) {
25
- let r;
26
- return function(...a) {
27
- r !== void 0 && clearTimeout(r), r = setTimeout(() => {
28
- r = void 0, t.apply(this, a);
29
- }, s);
24
+ function L(e, t = 0) {
25
+ let s;
26
+ return function(...r) {
27
+ s !== void 0 && clearTimeout(s), s = setTimeout(() => {
28
+ s = void 0, e.apply(this, r);
29
+ }, t);
30
30
  };
31
31
  }
32
- function Se(t, s, r = []) {
33
- return W(
34
- () => pe(t, s),
32
+ function O(e, t, s = []) {
33
+ return A(
34
+ () => L(e, t),
35
35
  // eslint-disable-next-line react-hooks/exhaustive-deps
36
- r
36
+ s
37
37
  );
38
38
  }
39
- function Re(t) {
40
- const s = JSON.stringify(t, null, 2).split(`
41
- `), r = [], a = [];
42
- for (const n of s) {
43
- const c = n.match(/^(\s*)"([^"]+)"(\s*:\s*)(.+)$/);
44
- if (c) {
45
- const [, m, v, p, l] = c;
46
- r.push(`${m}%c"${v}"%c${p}%c${l}`), a.push(
39
+ function _(e) {
40
+ const t = JSON.stringify(e, null, 2).split(`
41
+ `), s = [], r = [];
42
+ for (const n of t) {
43
+ const o = n.match(/^(\s*)"([^"]+)"(\s*:\s*)(.+)$/);
44
+ if (o) {
45
+ const [, l, S, u, a] = o;
46
+ s.push(`${l}%c"${S}"%c${u}%c${a}`), r.push(
47
47
  "color: #9cdcfe; font-weight: bold",
48
48
  "color: #cccccc",
49
49
  "color: #ce9178"
50
50
  );
51
51
  } else
52
- r.push(`%c${n}`), a.push("color: #cccccc");
52
+ s.push(`%c${n}`), r.push("color: #cccccc");
53
53
  }
54
- console.log(r.join(`
55
- `), ...a, t);
54
+ console.log(s.join(`
55
+ `), ...r, e);
56
56
  }
57
- var N = { exports: {} }, P = {};
58
- var Q;
59
- function Te() {
60
- if (Q) return P;
61
- Q = 1;
62
- var t = Symbol.for("react.transitional.element"), s = Symbol.for("react.fragment");
63
- function r(a, n, c) {
64
- var m = null;
65
- if (c !== void 0 && (m = "" + c), n.key !== void 0 && (m = "" + n.key), "key" in n) {
66
- c = {};
67
- for (var v in n)
68
- v !== "key" && (c[v] = n[v]);
69
- } else c = n;
70
- return n = c.ref, {
71
- $$typeof: t,
72
- type: a,
73
- key: m,
74
- ref: n !== void 0 ? n : null,
75
- props: c
76
- };
57
+ const N = (e) => typeof e == "function", B = (e) => typeof e == "function", v = (e) => typeof e < "u", T = (e) => B(e) ? e() : e;
58
+ class K {
59
+ #e;
60
+ #t;
61
+ constructor() {
62
+ this.#e = {}, this.#t = /* @__PURE__ */ new Set();
77
63
  }
78
- return P.Fragment = s, P.jsx = r, P.jsxs = r, P;
79
- }
80
- var x = {};
81
- var K;
82
- function ye() {
83
- return K || (K = 1, process.env.NODE_ENV !== "production" && (function() {
84
- function t(e) {
85
- if (e == null) return null;
86
- if (typeof e == "function")
87
- return e.$$typeof === le ? null : e.displayName || e.name || null;
88
- if (typeof e == "string") return e;
89
- switch (e) {
90
- case E:
91
- return "Fragment";
92
- case A:
93
- return "Profiler";
94
- case g:
95
- return "StrictMode";
96
- case U:
97
- return "Suspense";
98
- case k:
99
- return "SuspenseList";
100
- case ue:
101
- return "Activity";
102
- }
103
- if (typeof e == "object")
104
- switch (typeof e.tag == "number" && console.error(
105
- "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
106
- ), e.$$typeof) {
107
- case R:
108
- return "Portal";
109
- case h:
110
- return e.displayName || "Context";
111
- case b:
112
- return (e._context.displayName || "Context") + ".Consumer";
113
- case O:
114
- var o = e.render;
115
- return e = e.displayName, e || (e = o.displayName || o.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
116
- case ce:
117
- return o = e.displayName || null, o !== null ? o : t(e.type) || "Memo";
118
- case $:
119
- o = e._payload, e = e._init;
120
- try {
121
- return t(e(o));
122
- } catch {
123
- }
124
- }
125
- return null;
126
- }
127
- function s(e) {
128
- return "" + e;
129
- }
130
- function r(e) {
131
- try {
132
- s(e);
133
- var o = !1;
134
- } catch {
135
- o = !0;
136
- }
137
- if (o) {
138
- o = console;
139
- var u = o.error, f = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
140
- return u.call(
141
- o,
142
- "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
143
- f
144
- ), s(e);
145
- }
146
- }
147
- function a(e) {
148
- if (e === E) return "<>";
149
- if (typeof e == "object" && e !== null && e.$$typeof === $)
150
- return "<...>";
151
- try {
152
- var o = t(e);
153
- return o ? "<" + o + ">" : "<...>";
154
- } catch {
155
- return "<...>";
156
- }
157
- }
158
- function n() {
159
- var e = I.A;
160
- return e === null ? null : e.getOwner();
161
- }
162
- function c() {
163
- return Error("react-stack-top-frame");
164
- }
165
- function m(e) {
166
- if (q.call(e, "key")) {
167
- var o = Object.getOwnPropertyDescriptor(e, "key").get;
168
- if (o && o.isReactWarning) return !1;
169
- }
170
- return e.key !== void 0;
171
- }
172
- function v(e, o) {
173
- function u() {
174
- G || (G = !0, console.error(
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
- o
177
- ));
178
- }
179
- u.isReactWarning = !0, Object.defineProperty(e, "key", {
180
- get: u,
181
- configurable: !0
182
- });
183
- }
184
- function p() {
185
- var e = t(this.type);
186
- return X[e] || (X[e] = !0, console.error(
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
- )), e = this.props.ref, e !== void 0 ? e : null;
189
- }
190
- function l(e, o, u, f, j, D) {
191
- var d = u.ref;
192
- return e = {
193
- $$typeof: y,
194
- type: e,
195
- key: o,
196
- props: u,
197
- _owner: f
198
- }, (d !== void 0 ? d : null) !== null ? Object.defineProperty(e, "ref", {
199
- enumerable: !1,
200
- get: p
201
- }) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
202
- configurable: !1,
203
- enumerable: !1,
204
- writable: !0,
205
- value: 0
206
- }), Object.defineProperty(e, "_debugInfo", {
207
- configurable: !1,
208
- enumerable: !1,
209
- writable: !0,
210
- value: null
211
- }), Object.defineProperty(e, "_debugStack", {
212
- configurable: !1,
213
- enumerable: !1,
214
- writable: !0,
215
- value: j
216
- }), Object.defineProperty(e, "_debugTask", {
217
- configurable: !1,
218
- enumerable: !1,
219
- writable: !0,
220
- value: D
221
- }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
222
- }
223
- function i(e, o, u, f, j, D) {
224
- var d = o.children;
225
- if (d !== void 0)
226
- if (f)
227
- if (ie(d)) {
228
- for (f = 0; f < d.length; f++)
229
- _(d[f]);
230
- Object.freeze && Object.freeze(d);
231
- } else
232
- console.error(
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
- );
235
- else _(d);
236
- if (q.call(o, "key")) {
237
- d = t(e);
238
- var w = Object.keys(o).filter(function(fe) {
239
- return fe !== "key";
240
- });
241
- f = 0 < w.length ? "{key: someKey, " + w.join(": ..., ") + ": ...}" : "{key: someKey}", Z[d + f] || (w = 0 < w.length ? "{" + w.join(": ..., ") + ": ...}" : "{}", console.error(
242
- `A props object containing a "key" prop is being spread into JSX:
243
- let props = %s;
244
- <%s {...props} />
245
- React keys must be passed directly to JSX without using spread:
246
- let props = %s;
247
- <%s key={someKey} {...props} />`,
248
- f,
249
- d,
250
- w,
251
- d
252
- ), Z[d + f] = !0);
253
- }
254
- if (d = null, u !== void 0 && (r(u), d = "" + u), m(o) && (r(o.key), d = "" + o.key), "key" in o) {
255
- u = {};
256
- for (var F in o)
257
- F !== "key" && (u[F] = o[F]);
258
- } else u = o;
259
- return d && v(
260
- u,
261
- typeof e == "function" ? e.displayName || e.name || "Unknown" : e
262
- ), l(
263
- e,
264
- d,
265
- u,
266
- n(),
267
- j,
268
- D
269
- );
270
- }
271
- function _(e) {
272
- S(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === $ && (e._payload.status === "fulfilled" ? S(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
273
- }
274
- function S(e) {
275
- return typeof e == "object" && e !== null && e.$$typeof === y;
276
- }
277
- var T = de, y = Symbol.for("react.transitional.element"), R = Symbol.for("react.portal"), E = Symbol.for("react.fragment"), g = Symbol.for("react.strict_mode"), A = Symbol.for("react.profiler"), b = Symbol.for("react.consumer"), h = Symbol.for("react.context"), O = Symbol.for("react.forward_ref"), U = Symbol.for("react.suspense"), k = Symbol.for("react.suspense_list"), ce = Symbol.for("react.memo"), $ = Symbol.for("react.lazy"), ue = Symbol.for("react.activity"), le = Symbol.for("react.client.reference"), I = T.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, q = Object.prototype.hasOwnProperty, ie = Array.isArray, Y = console.createTask ? console.createTask : function() {
278
- return null;
279
- };
280
- T = {
281
- react_stack_bottom_frame: function(e) {
282
- return e();
283
- }
284
- };
285
- var G, X = {}, B = T.react_stack_bottom_frame.bind(
286
- T,
287
- c
288
- )(), H = Y(a(c)), Z = {};
289
- x.Fragment = E, x.jsx = function(e, o, u) {
290
- var f = 1e4 > I.recentlyCreatedOwnerStacks++;
291
- return i(
292
- e,
293
- o,
294
- u,
295
- !1,
296
- f ? Error("react-stack-top-frame") : B,
297
- f ? Y(a(e)) : H
298
- );
299
- }, x.jsxs = function(e, o, u) {
300
- var f = 1e4 > I.recentlyCreatedOwnerStacks++;
301
- return i(
302
- e,
303
- o,
304
- u,
305
- !0,
306
- f ? Error("react-stack-top-frame") : B,
307
- f ? Y(a(e)) : H
308
- );
309
- };
310
- })()), x;
311
- }
312
- var ee;
313
- function he() {
314
- return ee || (ee = 1, process.env.NODE_ENV === "production" ? N.exports = Te() : N.exports = ye()), N.exports;
315
- }
316
- var ge = he();
317
- const ae = me({
318
- stateVocab: {},
319
- setStateVocab: () => {
64
+ subscribe(t) {
65
+ return this.#t.add(t), () => this.#t.delete(t);
66
+ }
67
+ getClientSnapshot() {
68
+ return this.#e;
69
+ }
70
+ getServerSnapshot() {
71
+ return this.#e;
72
+ }
73
+ set(t, s) {
74
+ const r = k(this.#e, t), n = N(s) ? s(r) : s, o = { ...this.#e };
75
+ J(o, t, n), this.#e = o, this.#t.forEach((l) => l());
320
76
  }
321
- });
322
- function ke() {
323
- return be(ae);
324
77
  }
325
- const Oe = (t) => {
326
- const { children: s, verbose: r } = t, [a, n] = ne({});
327
- return r && Re(a), /* @__PURE__ */ ge.jsx(ae.Provider, { value: { stateVocab: a, setStateVocab: n }, children: s });
328
- }, V = (t, s) => (r) => {
329
- const a = { ...r };
330
- return _e(a, t, s), a;
331
- }, we = (t) => typeof t == "function", Pe = (t) => typeof t == "function", z = (t) => typeof t < "u", L = (t) => Pe(t) ? t() : t, xe = typeof window > "u";
332
- function je(t = {}) {
78
+ function q(e = {}) {
79
+ const t = new K();
333
80
  return {
334
- [oe]: !0,
81
+ [M]: !0,
335
82
  // marks this object as a leaf in the router tree
336
- [J]: !1,
337
- // placeholder; injected at runtime by injectPaths()
338
- [C]: "",
83
+ [V]: "",
339
84
  // placeholder; injected at runtime by injectPaths()
85
+ [$]: !1,
86
+ // placeholder
340
87
  useState(s) {
341
- const r = xe ? void 0 : L(t.storage), a = t.serialize ?? JSON.stringify, n = t.deserialize ?? JSON.parse, c = L(t.defaultValue), m = t.bidirectional;
88
+ const r = T(e.storage), n = e.serialize ?? JSON.stringify, o = e.deserialize ?? JSON.parse, l = T(e.defaultValue), S = e.bidirectional;
342
89
  s ??= {};
343
- const v = L(s.defaultValue), p = Se(
90
+ const u = T(s.defaultValue) ?? l, a = s.bidirectional ?? S, f = O(
344
91
  s.onSet ?? (() => {
345
92
  }),
346
93
  s.delayedSet,
347
94
  []
348
- ), l = ke(), i = this[C], _ = this[J], [S, T] = ne(!_);
349
- M(() => T(!0), []);
350
- const y = W(
351
- () => {
352
- if (!S || !r)
353
- return;
354
- const b = r.getItem(i);
355
- return b === null ? null : n(b);
356
- },
357
- // eslint-disable-next-line react-hooks/exhaustive-deps
358
- [S]
359
- ), R = W(
360
- () => Ee(
361
- l.stateVocab,
362
- i,
363
- // 3rd argument in order to avoid waiting for useEffect execution
364
- y ?? v ?? c
365
- ),
366
- // eslint-disable-next-line react-hooks/exhaustive-deps
367
- [
368
- l.stateVocab,
369
- y
370
- ]
371
- ), E = ve(R);
372
- return M(
373
- () => {
374
- z(R) && (l.setStateVocab(V(i, R)), r && y === null && r.setItem(i, a(R)), E.current = R);
375
- },
376
- // eslint-disable-next-line react-hooks/exhaustive-deps
377
- [y]
378
- ), M(() => {
379
- if (!s.bidirectional && !m)
95
+ ), c = this[V], g = this[$], h = z(void 0), b = z(!1);
96
+ if (!b.current) {
97
+ b.current = !0;
98
+ let i = k(t.getServerSnapshot(), c);
99
+ if (!v(i)) {
100
+ if (i = u, r) {
101
+ const d = r.getItem(c);
102
+ d === null ? v(i) && r.setItem(c, n(i)) : i = o(d);
103
+ }
104
+ v(i) && t.set(c, i);
105
+ }
106
+ }
107
+ const m = D(
108
+ t.subscribe.bind(t),
109
+ () => t.getClientSnapshot(),
110
+ () => t.getServerSnapshot()
111
+ );
112
+ g && _(m);
113
+ const p = k(m, c);
114
+ h.current = p;
115
+ const y = j((i) => {
116
+ if (i.key !== c)
380
117
  return;
381
- const b = (h) => {
382
- if (h.key !== i)
383
- return;
384
- const O = h.newValue, k = (O === null ? null : n(O)) ?? v ?? c;
385
- z(k) && (l.setStateVocab(V(i, k)), p(k, E.current), E.current = k);
386
- };
387
- return window.addEventListener("storage", b), () => window.removeEventListener("storage", b);
118
+ const d = i.newValue, E = (d === null ? null : o(d)) ?? u;
119
+ v(E) && (t.set(c, E), f(E, h.current));
120
+ });
121
+ F(() => {
122
+ if (a)
123
+ return window.addEventListener("storage", y), () => window.removeEventListener("storage", y);
124
+ }, [a]);
125
+ const w = I((i) => {
126
+ const d = N(i) ? i(h.current) : i;
127
+ t.set(c, d), f(d, h.current), r && r.setItem(c, n(d));
388
128
  }, [
389
- s.bidirectional,
390
- m
391
- ]), [
392
- R,
393
- (b) => {
394
- const h = we(b) ? b(E.current) : b;
395
- l.setStateVocab(V(i, h)), p(h, E.current), r && r.setItem(i, a(h)), E.current = h;
396
- },
397
- () => {
398
- const b = v ?? c;
399
- if (!z(b)) {
400
- r?.removeItem(i);
401
- return;
402
- }
403
- l.setStateVocab(V(i, b)), p(b, E.current), E.current = b, r && r.setItem(i, a(b));
129
+ c,
130
+ r,
131
+ n,
132
+ f
133
+ ]), R = I(() => {
134
+ const i = u;
135
+ if (!v(i)) {
136
+ r?.removeItem(c);
137
+ return;
404
138
  }
139
+ t.set(c, i), f(i, h.current), r && r.setItem(c, n(i));
140
+ }, [
141
+ c,
142
+ u,
143
+ r,
144
+ n,
145
+ f
146
+ ]);
147
+ return [
148
+ p,
149
+ w,
150
+ R
405
151
  ];
406
152
  },
407
153
  /** Returns the fully qualified job name (dot-separated path). */
408
154
  toString() {
409
- return this[C];
155
+ return this[V];
410
156
  }
411
157
  };
412
158
  }
413
- const te = /* @__PURE__ */ new WeakMap(), re = /* @__PURE__ */ new WeakMap();
414
- function se(t, s) {
415
- s ??= {};
159
+ const C = /* @__PURE__ */ new WeakMap(), x = /* @__PURE__ */ new WeakMap();
160
+ function P(e, t) {
161
+ t ??= {};
416
162
  const {
417
- path: r = "",
418
- ssr: a
419
- } = s;
420
- let n = te.get(t);
421
- n || (n = /* @__PURE__ */ new Map(), te.set(t, n));
422
- const c = n.get(r);
423
- if (c)
424
- return c;
425
- const m = new Proxy(t, {
426
- get(v, p) {
427
- const l = v[p], i = r ? `${r}.${String(p)}` : String(p);
428
- if (l && typeof l == "object" && oe in l) {
429
- const _ = l;
430
- let S = re.get(_);
431
- S || (S = /* @__PURE__ */ new Map(), re.set(_, S));
432
- const T = S.get(i);
433
- if (T)
434
- return T;
435
- const y = Reflect.ownKeys(_).filter(
436
- (g) => typeof _[g] == "function"
437
- ), R = Object.fromEntries(
438
- y.map((g) => [
439
- g,
440
- (...A) => _[g].call(
163
+ path: s = "",
164
+ verbose: r
165
+ } = t;
166
+ let n = C.get(e);
167
+ n || (n = /* @__PURE__ */ new Map(), C.set(e, n));
168
+ const o = n.get(s);
169
+ if (o)
170
+ return o;
171
+ const l = new Proxy(e, {
172
+ get(S, u) {
173
+ const a = S[u], f = s ? `${s}.${String(u)}` : String(u);
174
+ if (a && typeof a == "object" && M in a) {
175
+ const c = a;
176
+ let g = x.get(c);
177
+ g || (g = /* @__PURE__ */ new Map(), x.set(c, g));
178
+ const h = g.get(f);
179
+ if (h)
180
+ return h;
181
+ const b = Reflect.ownKeys(c).filter(
182
+ (y) => typeof c[y] == "function"
183
+ ), m = Object.fromEntries(
184
+ b.map((y) => [
185
+ y,
186
+ (...w) => c[y].call(
441
187
  {
442
- ..._,
443
- [C]: i,
444
- [J]: a
188
+ ...c,
189
+ [V]: f,
190
+ [$]: r
445
191
  },
446
- ...A
192
+ ...w
447
193
  )
448
194
  ])
449
- ), E = { ..._, ...R };
450
- return S.set(i, E), E;
195
+ ), p = { ...c, ...m };
196
+ return g.set(f, p), p;
451
197
  }
452
- return l && typeof l == "object" ? se(l, {
453
- path: i,
454
- ssr: a
455
- }) : l;
198
+ return a && typeof a == "object" ? P(a, {
199
+ path: f,
200
+ verbose: r
201
+ }) : a;
456
202
  }
457
203
  });
458
- return n.set(r, m), m;
204
+ return n.set(s, l), l;
459
205
  }
460
- function Ne(t, s) {
461
- return se(t, s);
206
+ function G(e, t) {
207
+ return P(e, t);
462
208
  }
463
209
  export {
464
- Oe as StorageProvider,
465
- je as defineState,
466
- Ne as setupStorage
210
+ q as defineState,
211
+ G as setupStorage
467
212
  };
@@ -1,3 +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: unique symbol;
3
+ export declare const STATE_VERBOSE: unique symbol;
@@ -1,3 +1,2 @@
1
1
  export { defineState } from "./state";
2
2
  export { setupStorage } from "./setup";
3
- export { StateVocabContextProvider as StorageProvider } from "./context";
@@ -1,3 +1,6 @@
1
- export declare function setupStorage<T extends object>(native: T, options?: Partial<{
2
- ssr: boolean;
3
- }>): T;
1
+ type InjectPathsOptions = {
2
+ path: string;
3
+ verbose: boolean;
4
+ };
5
+ export declare function setupStorage<T extends object>(native: T, options?: Partial<Omit<InjectPathsOptions, "path">>): T;
6
+ export {};
@@ -1,4 +1,4 @@
1
- import { STATE_DEFINITION, STATE_PATH, STATE_SSR } from "./constants";
1
+ import { STATE_DEFINITION, STATE_PATH, STATE_VERBOSE } from "./constants";
2
2
  import type { Deserialize, Serialize, ValueOrFactory, ValueOrTransformer } from "./state.types";
3
3
  export declare function defineState<D>(definitionOptions?: {
4
4
  storage?: ValueOrFactory<Storage>;
@@ -8,11 +8,11 @@ export declare function defineState<D>(definitionOptions?: {
8
8
  deserialize?: Deserialize<D>;
9
9
  }): {
10
10
  [STATE_DEFINITION]: boolean;
11
- [STATE_SSR]: boolean;
12
11
  [STATE_PATH]: string;
12
+ [STATE_VERBOSE]: boolean;
13
13
  useState(this: {
14
14
  [STATE_PATH]: string;
15
- [STATE_SSR]: boolean;
15
+ [STATE_VERBOSE]: boolean;
16
16
  }, options?: {
17
17
  defaultValue?: ValueOrFactory<D>;
18
18
  delayedSet?: number;
@@ -1,8 +1,4 @@
1
- import type { Vocab } from "./context";
2
1
  import type { ValueOrTransformer, Transformer, ValueOrFactory } from "./state.types";
3
- export declare const embed: <D>(statePath: string, value: D) => (vocab: Vocab<D>) => {
4
- [x: string]: D | null;
5
- };
6
2
  export declare const isTransformer: <V>(v: ValueOrTransformer<V>) => v is Transformer<V>;
7
3
  export declare const isValueDefined: <V>(v: V | undefined) => v is V;
8
4
  export declare const valueOrFactory: <V>(input: ValueOrFactory<V>) => V;
@@ -4,4 +4,4 @@ export declare function set(obj: Record<string, unknown>, path: string, value: u
4
4
  export declare function debounce<T extends (...args: never[]) => unknown>(func: T, wait?: number): (...args: Parameters<T>) => void;
5
5
  export declare function useDebounce<T extends (...args: never[]) => unknown>(effect: T, wait: number | undefined, deps?: DependencyList): (...args: Parameters<T>) => void;
6
6
  export declare const isJsonValid: (input: string) => boolean;
7
- export declare function logStyled(obj: object): void;
7
+ export declare function logStyled(obj: unknown): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yakocloud/state-vocab",
3
- "version": "2.5.1",
3
+ "version": "3.0.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",
@@ -1,11 +0,0 @@
1
- import { type SetStateAction, type PropsWithChildren, type Dispatch } from "react";
2
- export type Vocab<T = unknown> = Record<string, T | null>;
3
- type Context<V extends Vocab = Vocab> = {
4
- stateVocab: V;
5
- setStateVocab: Dispatch<SetStateAction<V>>;
6
- };
7
- export declare function useStateVocabContext<T>(): Context<Vocab<T>>;
8
- export declare const StateVocabContextProvider: (props: PropsWithChildren<{
9
- verbose?: boolean;
10
- }>) => import("react/jsx-runtime").JSX.Element;
11
- export {};