🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

zenbox

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zenbox - npm Package Compare versions

Comparing version
0.0.1
to
1.0.0
+1
dist/hooks/useCleanup.cjs
'use strict';var chunkBCUBYE76_cjs=require('../chunk-BCUBYE76.cjs'),react=require('react');const u=typeof window<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&(__REACT_DEVTOOLS_GLOBAL_HOOK__.renderers?.get(1)?.bundleType===1||__REACT_DEVTOOLS_GLOBAL_HOOK__.renderers?.get(1)==null);function p(t){return u?s(t):react.useEffect(()=>t,[])}chunkBCUBYE76_cjs.a(p,"useCleanup");function s(t){const e=react.useRef({step1:0,step2:0});react.useEffect(()=>(e.current.step1++,()=>{e.current.step2++,setTimeout(()=>{e.current.step1===e.current.step2&&(t(),e.current.step2++);});}),[]);}chunkBCUBYE76_cjs.a(s,"_useCleanup");exports.kIsReactDev=u;exports.useCleanup=p;
declare const kIsReactDev: boolean;
declare function useCleanup(cleanup: () => void): void;
export { kIsReactDev, useCleanup };
declare const kIsReactDev: boolean;
declare function useCleanup(cleanup: () => void): void;
export { kIsReactDev, useCleanup };
import {a}from'../chunk-EI7MMDWY.js';import {useEffect,useRef}from'react';const u=typeof window<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&(__REACT_DEVTOOLS_GLOBAL_HOOK__.renderers?.get(1)?.bundleType===1||__REACT_DEVTOOLS_GLOBAL_HOOK__.renderers?.get(1)==null);function o(t){return u?s(t):useEffect(()=>t,[])}a(o,"useCleanup");function s(t){const e=useRef({step1:0,step2:0});useEffect(()=>(e.current.step1++,()=>{e.current.step2++,setTimeout(()=>{e.current.step1===e.current.step2&&(t(),e.current.step2++);});}),[]);}a(s,"_useCleanup");export{u as kIsReactDev,o as useCleanup};
+1
-1

@@ -1,1 +0,1 @@

'use strict';var chunkBCUBYE76_cjs=require('../chunk-BCUBYE76.cjs'),jsxRuntime=require('react/jsx-runtime'),reactUnstrict=require('@del-wang/react-unstrict'),react=require('react'),core_js=require('../core.js'),utils_js=require('../utils.js');function B(i){let n=null;const s=chunkBCUBYE76_cjs.a(()=>n,"getStore"),c=chunkBCUBYE76_cjs.a(()=>n?.value,"getState"),S=chunkBCUBYE76_cjs.a((t,e)=>{n?.setState(t,e);},"setState"),o=react.createContext(null);function a(t){const e=react.useRef({unsubscribe:null,store:core_js.createStore(utils_js.mergeState(i,t.initialState))});return reactUnstrict.useUnStrictRun(()=>{e.current.unsubscribe||(e.current.unsubscribe=core_js.ZenBox.subscribeRead(u=>{u===e.current.store&&(n=u);}));}),react.useEffect(()=>()=>{e.current.unsubscribe?.();},[]),jsxRuntime.jsx(o.Provider,{value:e.current.store,children:t.children})}chunkBCUBYE76_cjs.a(a,"StoreProvider");function l(){const t=react.useContext(o);if(!t)throw new Error("useFindStore must be used within StoreProvider");return t}return chunkBCUBYE76_cjs.a(l,"useFindStore"),[a,l,{getStore:s,getState:c,setState:S}]}chunkBCUBYE76_cjs.a(B,"createProvider");exports.createProvider=B;
'use strict';var chunkBCUBYE76_cjs=require('../chunk-BCUBYE76.cjs'),jsxRuntime=require('react/jsx-runtime'),react=require('react'),core_js=require('../core.js'),useCleanup_js=require('../hooks/useCleanup.js'),utils_js=require('../utils.js');function y(i){let n=null;const s=chunkBCUBYE76_cjs.a(()=>n,"getStore"),c=chunkBCUBYE76_cjs.a(()=>n?.value,"getState"),a=chunkBCUBYE76_cjs.a((t,e)=>{n?.setState(t,e);},"setState"),o=react.createContext(null);function l(t){const e=react.useRef({unsubscribe:null,store:core_js.createStore(utils_js.mergeState(i,t.initialState))});return e.current.unsubscribe?.(),e.current.unsubscribe=core_js.ZenBox.subscribeRead(u=>{u===e.current.store&&(n=u);}),useCleanup_js.useCleanup(()=>{e.current.unsubscribe?.();}),jsxRuntime.jsx(o.Provider,{value:e.current.store,children:t.children})}chunkBCUBYE76_cjs.a(l,"StoreProvider");function S(){const t=react.useContext(o);if(!t)throw new Error("useFindStore must be used within StoreProvider");return t}return chunkBCUBYE76_cjs.a(S,"useFindStore"),[l,S,{getStore:s,getState:c,setState:a}]}chunkBCUBYE76_cjs.a(y,"createProvider");exports.createProvider=y;

@@ -1,1 +0,1 @@

import {a}from'../chunk-EI7MMDWY.js';import {jsx}from'react/jsx-runtime';import {useUnStrictRun}from'@del-wang/react-unstrict';import {createContext,useRef,useEffect,useContext}from'react';import {createStore,ZenBox}from'../core.js';import {mergeState}from'../utils.js';function y(i){let n=null;const s=a(()=>n,"getStore"),c=a(()=>n?.value,"getState"),S=a((t,e)=>{n?.setState(t,e);},"setState"),o=createContext(null);function a$1(t){const e=useRef({unsubscribe:null,store:createStore(mergeState(i,t.initialState))});return useUnStrictRun(()=>{e.current.unsubscribe||(e.current.unsubscribe=ZenBox.subscribeRead(u=>{u===e.current.store&&(n=u);}));}),useEffect(()=>()=>{e.current.unsubscribe?.();},[]),jsx(o.Provider,{value:e.current.store,children:t.children})}a(a$1,"StoreProvider");function l(){const t=useContext(o);if(!t)throw new Error("useFindStore must be used within StoreProvider");return t}return a(l,"useFindStore"),[a$1,l,{getStore:s,getState:c,setState:S}]}a(y,"createProvider");export{y as createProvider};
import {a}from'../chunk-EI7MMDWY.js';import {jsx}from'react/jsx-runtime';import {createContext,useRef,useContext}from'react';import {createStore,ZenBox}from'../core.js';import {useCleanup}from'../hooks/useCleanup.js';import {mergeState}from'../utils.js';function w(i){let n=null;const s=a(()=>n,"getStore"),c=a(()=>n?.value,"getState"),a$1=a((t,e)=>{n?.setState(t,e);},"setState"),o=createContext(null);function l(t){const e=useRef({unsubscribe:null,store:createStore(mergeState(i,t.initialState))});return e.current.unsubscribe?.(),e.current.unsubscribe=ZenBox.subscribeRead(u=>{u===e.current.store&&(n=u);}),useCleanup(()=>{e.current.unsubscribe?.();}),jsx(o.Provider,{value:e.current.store,children:t.children})}a(l,"StoreProvider");function S(){const t=useContext(o);if(!t)throw new Error("useFindStore must be used within StoreProvider");return t}return a(S,"useFindStore"),[l,S,{getStore:s,getState:c,setState:a$1}]}a(w,"createProvider");export{w as createProvider};

@@ -1,1 +0,1 @@

'use strict';var chunkBCUBYE76_cjs=require('./chunk-BCUBYE76.cjs'),equals=require('@del-wang/equals'),immer=require('immer'),utils_js=require('./utils.js');class n{constructor(e){this._state=e;immer.enableMapSet();}static{chunkBCUBYE76_cjs.a(this,"ZenBox");}static _readListeners=new Set;_writeListeners=new Set;get value(){return n._readListeners.forEach(e=>e(this)),this._state}set value(e){this.setState(e);}setState=chunkBCUBYE76_cjs.a((e,r)=>{if(this._state=typeof e=="function"?immer.produce(this._state,e):utils_js.mergeState(this._state,e),!r?.silent)for(const t of this._writeListeners){const{select:i,equal:s,onChange:o,prev:S}=t,c=i(this._state);s(S,c)||(o(c,S),t.prev=c);}},"setState");subscribe=chunkBCUBYE76_cjs.a(e=>{const{onChange:r,select:t=chunkBCUBYE76_cjs.a(o=>o,"select"),equal:i=equals.shallowEqual}=e,s={onChange:r,select:t,equal:i,prev:t(this._state)};return this._writeListeners.add(s),()=>this._writeListeners.delete(s)},"subscribe");static subscribeRead(e){return n._readListeners.add(e),()=>n._readListeners.delete(e)}static track(e){const r=new Set,t=n.subscribeRead(s=>r.add(s)),i=e();return t(),[r,i]}}function f(d){return new n(d)}chunkBCUBYE76_cjs.a(f,"createStore");exports.ZenBox=n;exports.createStore=f;
'use strict';var chunkBCUBYE76_cjs=require('./chunk-BCUBYE76.cjs'),equals=require('@del-wang/equals'),immer=require('immer'),utils_js=require('./utils.js');class a{constructor(e){this._state=e;immer.enableMapSet();}static{chunkBCUBYE76_cjs.a(this,"ZenBox");}static _readListeners=new Set;_writeListeners=new Set;get value(){return a._readListeners.forEach(e=>e(this)),this._state}set value(e){this.setState(e);}setState=chunkBCUBYE76_cjs.a((e,r)=>{if(this._state=typeof e=="function"?immer.produce(this._state,e):utils_js.mergeState(this._state,e),!r?.silent)for(const t of this._writeListeners){const{select:n,equal:s,onChange:d,prev:c}=t,o=n(this._state);s(c,o)||(d(o,c),t.prev=o);}},"setState");subscribe=chunkBCUBYE76_cjs.a(e=>{const{onChange:r,select:t=utils_js.identity,equal:n=equals.shallowEqual}=e,s={onChange:r,select:t,equal:n,prev:t(this._state)};return this._writeListeners.add(s),()=>this._writeListeners.delete(s)},"subscribe");static subscribeRead(e){return a._readListeners.add(e),()=>a._readListeners.delete(e)}static track(e){const r=new Set,t=a.subscribeRead(s=>r.add(s)),n=e();return t(),[r,n]}}function _(S){return new a(S)}chunkBCUBYE76_cjs.a(_,"createStore");exports.ZenBox=a;exports.createStore=_;

@@ -1,1 +0,1 @@

import {a}from'./chunk-EI7MMDWY.js';import {shallowEqual}from'@del-wang/equals';import {enableMapSet,produce}from'immer';import {mergeState}from'./utils.js';class n{constructor(e){this._state=e;enableMapSet();}static{a(this,"ZenBox");}static _readListeners=new Set;_writeListeners=new Set;get value(){return n._readListeners.forEach(e=>e(this)),this._state}set value(e){this.setState(e);}setState=a((e,r)=>{if(this._state=typeof e=="function"?produce(this._state,e):mergeState(this._state,e),!r?.silent)for(const t of this._writeListeners){const{select:i,equal:s,onChange:o,prev:S}=t,c=i(this._state);s(S,c)||(o(c,S),t.prev=c);}},"setState");subscribe=a(e=>{const{onChange:r,select:t=a(o=>o,"select"),equal:i=shallowEqual}=e,s={onChange:r,select:t,equal:i,prev:t(this._state)};return this._writeListeners.add(s),()=>this._writeListeners.delete(s)},"subscribe");static subscribeRead(e){return n._readListeners.add(e),()=>n._readListeners.delete(e)}static track(e){const r=new Set,t=n.subscribeRead(s=>r.add(s)),i=e();return t(),[r,i]}}function V(d){return new n(d)}a(V,"createStore");export{n as ZenBox,V as createStore};
import {a as a$1}from'./chunk-EI7MMDWY.js';import {shallowEqual}from'@del-wang/equals';import {enableMapSet,produce}from'immer';import {mergeState,identity}from'./utils.js';class a{constructor(e){this._state=e;enableMapSet();}static{a$1(this,"ZenBox");}static _readListeners=new Set;_writeListeners=new Set;get value(){return a._readListeners.forEach(e=>e(this)),this._state}set value(e){this.setState(e);}setState=a$1((e,r)=>{if(this._state=typeof e=="function"?produce(this._state,e):mergeState(this._state,e),!r?.silent)for(const t of this._writeListeners){const{select:n,equal:s,onChange:d,prev:c}=t,o=n(this._state);s(c,o)||(d(o,c),t.prev=o);}},"setState");subscribe=a$1(e=>{const{onChange:r,select:t=identity,equal:n=shallowEqual}=e,s={onChange:r,select:t,equal:n,prev:t(this._state)};return this._writeListeners.add(s),()=>this._writeListeners.delete(s)},"subscribe");static subscribeRead(e){return a._readListeners.add(e),()=>a._readListeners.delete(e)}static track(e){const r=new Set,t=a.subscribeRead(s=>r.add(s)),n=e();return t(),[r,n]}}function f(S){return new a(S)}a$1(f,"createStore");export{a as ZenBox,f as createStore};

@@ -1,1 +0,1 @@

'use strict';var chunkBCUBYE76_cjs=require('../chunk-BCUBYE76.cjs'),equals=require('@del-wang/equals'),reactUnstrict=require('@del-wang/react-unstrict'),react=require('react'),core_js=require('../core.js'),utils_js=require('../utils.js');function U(n,u,o){const a=typeof n=="function"?n:()=>n,e=react.useRef({initialized:false,triggered:false,prev:utils_js.NULL,cleanupDeps:null,cleanupWatchEffect:null,watch:a,onChange:u,...o});e.current={...e.current,watch:a,onChange:u,...o};const l=react.useCallback(()=>{const{initialized:i,watch:d,deep:m,once:s,immediate:v}=e.current;if(s&&e.current.triggered)return;e.current.cleanupDeps?.();const[h,r]=core_js.ZenBox.track(()=>utils_js.resolveValue(d())),E=Array.from(h).map(t=>t.subscribe({onChange:chunkBCUBYE76_cjs.a(()=>l(),"onChange")}));e.current.cleanupDeps=()=>{E.forEach(t=>t());};const W=m?equals.deepEqual:equals.shallowEqual,p=e.current.prev===utils_js.NULL?r:e.current.prev;(!i&&v||i&&!W(p,r))&&(e.current.triggered=true,e.current.cleanupWatchEffect?.(),e.current.cleanupWatchEffect=e.current.onChange(r,p),s&&(e.current.cleanupDeps?.(),e.current.cleanupDeps=null,e.current.cleanupWatchEffect?.(),e.current.cleanupWatchEffect=null)),e.current.prev=r,e.current.initialized=true;},[]);return reactUnstrict.useUnStrictRun(l),reactUnstrict.useUnStrictEffect(()=>()=>{e.current.cleanupDeps?.(),e.current.cleanupWatchEffect?.(),e.current=null;},[]),e.current.prev}chunkBCUBYE76_cjs.a(U,"useWatch");exports.useWatch=U;
'use strict';var chunkBCUBYE76_cjs=require('../chunk-BCUBYE76.cjs'),equals=require('@del-wang/equals'),react=require('react'),core_js=require('../core.js'),utils_js=require('../utils.js'),useCleanup_js=require('./useCleanup.js');function C(n,u,o){const a=typeof n=="function"?n:()=>n,e=react.useRef({initialized:false,triggered:false,prev:utils_js.NULL,cleanupDeps:null,cleanupWatchEffect:null,watch:a,onChange:u,...o});e.current={...e.current,watch:a,onChange:u,...o};const l=react.useCallback(()=>{const{initialized:i,watch:d,deep:m,once:p,immediate:v}=e.current;if(p&&e.current.triggered)return;e.current.cleanupDeps?.();const[h,r]=core_js.ZenBox.track(()=>utils_js.resolveValue(d())),E=Array.from(h).map(t=>t.subscribe({onChange:chunkBCUBYE76_cjs.a(()=>l(),"onChange")}));e.current.cleanupDeps=()=>{E.forEach(t=>t());};const W=m?equals.deepEqual:equals.shallowEqual,s=e.current.prev===utils_js.NULL?r:e.current.prev;(!i&&v||i&&!W(s,r))&&(e.current.triggered=true,e.current.cleanupWatchEffect?.(),e.current.cleanupWatchEffect=e.current.onChange(r,s),p&&(e.current.cleanupDeps?.(),e.current.cleanupDeps=null,e.current.cleanupWatchEffect?.(),e.current.cleanupWatchEffect=null)),e.current.prev=r,e.current.initialized=true;},[]);return l(),useCleanup_js.useCleanup(()=>{e.current.cleanupDeps?.(),e.current.cleanupWatchEffect?.(),e.current=null;}),e.current.prev}chunkBCUBYE76_cjs.a(C,"useWatch");exports.useWatch=C;

@@ -1,1 +0,1 @@

import {a}from'../chunk-EI7MMDWY.js';import {deepEqual,shallowEqual}from'@del-wang/equals';import {useUnStrictRun,useUnStrictEffect}from'@del-wang/react-unstrict';import {useRef,useCallback}from'react';import {ZenBox}from'../core.js';import {NULL,resolveValue}from'../utils.js';function F(n,u,o){const a$1=typeof n=="function"?n:()=>n,e=useRef({initialized:false,triggered:false,prev:NULL,cleanupDeps:null,cleanupWatchEffect:null,watch:a$1,onChange:u,...o});e.current={...e.current,watch:a$1,onChange:u,...o};const l=useCallback(()=>{const{initialized:i,watch:d,deep:m,once:s,immediate:v}=e.current;if(s&&e.current.triggered)return;e.current.cleanupDeps?.();const[h,r]=ZenBox.track(()=>resolveValue(d())),E=Array.from(h).map(t=>t.subscribe({onChange:a(()=>l(),"onChange")}));e.current.cleanupDeps=()=>{E.forEach(t=>t());};const W=m?deepEqual:shallowEqual,p=e.current.prev===NULL?r:e.current.prev;(!i&&v||i&&!W(p,r))&&(e.current.triggered=true,e.current.cleanupWatchEffect?.(),e.current.cleanupWatchEffect=e.current.onChange(r,p),s&&(e.current.cleanupDeps?.(),e.current.cleanupDeps=null,e.current.cleanupWatchEffect?.(),e.current.cleanupWatchEffect=null)),e.current.prev=r,e.current.initialized=true;},[]);return useUnStrictRun(l),useUnStrictEffect(()=>()=>{e.current.cleanupDeps?.(),e.current.cleanupWatchEffect?.(),e.current=null;},[]),e.current.prev}a(F,"useWatch");export{F as useWatch};
import {a}from'../chunk-EI7MMDWY.js';import {deepEqual,shallowEqual}from'@del-wang/equals';import {useRef,useCallback}from'react';import {ZenBox}from'../core.js';import {NULL,resolveValue}from'../utils.js';import {useCleanup}from'./useCleanup.js';function z(n,u,o){const a$1=typeof n=="function"?n:()=>n,e=useRef({initialized:false,triggered:false,prev:NULL,cleanupDeps:null,cleanupWatchEffect:null,watch:a$1,onChange:u,...o});e.current={...e.current,watch:a$1,onChange:u,...o};const l=useCallback(()=>{const{initialized:i,watch:d,deep:m,once:p,immediate:v}=e.current;if(p&&e.current.triggered)return;e.current.cleanupDeps?.();const[h,r]=ZenBox.track(()=>resolveValue(d())),E=Array.from(h).map(t=>t.subscribe({onChange:a(()=>l(),"onChange")}));e.current.cleanupDeps=()=>{E.forEach(t=>t());};const W=m?deepEqual:shallowEqual,s=e.current.prev===NULL?r:e.current.prev;(!i&&v||i&&!W(s,r))&&(e.current.triggered=true,e.current.cleanupWatchEffect?.(),e.current.cleanupWatchEffect=e.current.onChange(r,s),p&&(e.current.cleanupDeps?.(),e.current.cleanupDeps=null,e.current.cleanupWatchEffect?.(),e.current.cleanupWatchEffect=null)),e.current.prev=r,e.current.initialized=true;},[]);return l(),useCleanup(()=>{e.current.cleanupDeps?.(),e.current.cleanupWatchEffect?.(),e.current=null;}),e.current.prev}a(z,"useWatch");export{z as useWatch};

@@ -1,1 +0,1 @@

'use strict';var chunkBCUBYE76_cjs=require('../chunk-BCUBYE76.cjs'),reactUnstrict=require('@del-wang/react-unstrict'),react=require('react'),core_js=require('../core.js');function k(t){const c=react.useRef({watch:t,cleanupDeps:null,cleanupWatchEffect:null});c.current={...c.current,watch:t};const r=react.useCallback(()=>{const{watch:u,cleanupDeps:o,cleanupWatchEffect:a}=c.current;a?.(),o?.();const[s,d]=core_js.ZenBox.track(()=>{c.current.cleanupWatchEffect=u();}),f=Array.from(s).map(n=>n.subscribe({onChange:chunkBCUBYE76_cjs.a(()=>r(),"onChange")}));c.current.cleanupDeps=()=>{f.forEach(n=>n());};},[]);reactUnstrict.useUnStrictRun(r),reactUnstrict.useUnStrictEffect(()=>()=>{c.current.cleanupDeps?.(),c.current.cleanupWatchEffect?.(),c.current=null;},[]);}chunkBCUBYE76_cjs.a(k,"useWatchEffect");exports.useWatchEffect=k;
'use strict';var chunkBCUBYE76_cjs=require('../chunk-BCUBYE76.cjs'),react=require('react'),core_js=require('../core.js'),useCleanup_js=require('./useCleanup.js');function D(u){const c=react.useRef({watch:u,cleanupDeps:null,cleanupWatchEffect:null});c.current={...c.current,watch:u};const r=react.useCallback(()=>{const{watch:t,cleanupDeps:o,cleanupWatchEffect:a}=c.current;a?.(),o?.();const[s,m]=core_js.ZenBox.track(()=>{c.current.cleanupWatchEffect=t();}),l=Array.from(s).map(n=>n.subscribe({onChange:chunkBCUBYE76_cjs.a(()=>r(),"onChange")}));c.current.cleanupDeps=()=>{l.forEach(n=>n());};},[]);r(),useCleanup_js.useCleanup(()=>{c.current.cleanupDeps?.(),c.current.cleanupWatchEffect?.(),c.current=null;});}chunkBCUBYE76_cjs.a(D,"useWatchEffect");exports.useWatchEffect=D;

@@ -1,1 +0,1 @@

import {a}from'../chunk-EI7MMDWY.js';import {useUnStrictRun,useUnStrictEffect}from'@del-wang/react-unstrict';import {useRef,useCallback}from'react';import {ZenBox}from'../core.js';function D(t){const c=useRef({watch:t,cleanupDeps:null,cleanupWatchEffect:null});c.current={...c.current,watch:t};const r=useCallback(()=>{const{watch:u,cleanupDeps:o,cleanupWatchEffect:a$1}=c.current;a$1?.(),o?.();const[s,d]=ZenBox.track(()=>{c.current.cleanupWatchEffect=u();}),f=Array.from(s).map(n=>n.subscribe({onChange:a(()=>r(),"onChange")}));c.current.cleanupDeps=()=>{f.forEach(n=>n());};},[]);useUnStrictRun(r),useUnStrictEffect(()=>()=>{c.current.cleanupDeps?.(),c.current.cleanupWatchEffect?.(),c.current=null;},[]);}a(D,"useWatchEffect");export{D as useWatchEffect};
import {a}from'../chunk-EI7MMDWY.js';import {useRef,useCallback}from'react';import {ZenBox}from'../core.js';import {useCleanup}from'./useCleanup.js';function W(u){const c=useRef({watch:u,cleanupDeps:null,cleanupWatchEffect:null});c.current={...c.current,watch:u};const r=useCallback(()=>{const{watch:t,cleanupDeps:o,cleanupWatchEffect:a$1}=c.current;a$1?.(),o?.();const[s,m]=ZenBox.track(()=>{c.current.cleanupWatchEffect=t();}),l=Array.from(s).map(n=>n.subscribe({onChange:a(()=>r(),"onChange")}));c.current.cleanupDeps=()=>{l.forEach(n=>n());};},[]);r(),useCleanup(()=>{c.current.cleanupDeps?.(),c.current.cleanupWatchEffect?.(),c.current=null;});}a(W,"useWatchEffect");export{W as useWatchEffect};

@@ -10,5 +10,5 @@ export { Memo } from './components/Memo.cjs';

export { useWatchEffect } from './hooks/useWatchEffect.cjs';
export { NULL, Prettify, ResolveZenBox, mergeState, resolveValue } from './utils.cjs';
export { NULL, Prettify, ResolveZenBox, identity, mergeState, resolveValue } from './utils.cjs';
export { deepEqual, shallowEqual } from '@del-wang/equals';
import 'react';
import 'react/jsx-runtime';

@@ -10,5 +10,5 @@ export { Memo } from './components/Memo.js';

export { useWatchEffect } from './hooks/useWatchEffect.js';
export { NULL, Prettify, ResolveZenBox, mergeState, resolveValue } from './utils.js';
export { NULL, Prettify, ResolveZenBox, identity, mergeState, resolveValue } from './utils.js';
export { deepEqual, shallowEqual } from '@del-wang/equals';
import 'react';
import 'react/jsx-runtime';

@@ -1,1 +0,1 @@

'use strict';var chunkBCUBYE76_cjs=require('./chunk-BCUBYE76.cjs'),core_js=require('./core.js'),equals=require('@del-wang/equals');const T=Symbol("NULL");function l(e,n={}){const t={...e};for(const o in n)Object.hasOwn(e,o)&&(t[o]=n[o]);return t}chunkBCUBYE76_cjs.a(l,"mergeState");function i(e){return e instanceof core_js.ZenBox?e.value:Array.isArray(e)&&e.length>0?e.map(n=>n instanceof core_js.ZenBox?n.value:n):e}chunkBCUBYE76_cjs.a(i,"resolveValue");Object.defineProperty(exports,"deepEqual",{enumerable:true,get:function(){return equals.deepEqual}});Object.defineProperty(exports,"shallowEqual",{enumerable:true,get:function(){return equals.shallowEqual}});exports.NULL=T;exports.mergeState=l;exports.resolveValue=i;
'use strict';var chunkBCUBYE76_cjs=require('./chunk-BCUBYE76.cjs'),core_js=require('./core.js'),equals=require('@del-wang/equals');const T=Symbol("NULL"),i=chunkBCUBYE76_cjs.a(e=>e,"identity");function l(e,n={}){const t={...e};for(const r in n)Object.hasOwn(e,r)&&(t[r]=n[r]);return t}chunkBCUBYE76_cjs.a(l,"mergeState");function y(e){return e instanceof core_js.ZenBox?e.value:Array.isArray(e)&&e.length>0?e.map(n=>n instanceof core_js.ZenBox?n.value:n):e}chunkBCUBYE76_cjs.a(y,"resolveValue");Object.defineProperty(exports,"deepEqual",{enumerable:true,get:function(){return equals.deepEqual}});Object.defineProperty(exports,"shallowEqual",{enumerable:true,get:function(){return equals.shallowEqual}});exports.NULL=T;exports.identity=i;exports.mergeState=l;exports.resolveValue=y;

@@ -9,5 +9,6 @@ import { ZenBox, State } from './core.cjs';

declare const NULL: unique symbol;
declare const identity: <T>(state: T) => T;
declare function mergeState<T extends State>(initialState: T, partialState?: Partial<T>): T;
declare function resolveValue<T>(value: T): T;
export { NULL, type Prettify, type ResolveZenBox, mergeState, resolveValue };
export { NULL, type Prettify, type ResolveZenBox, identity, mergeState, resolveValue };

@@ -9,5 +9,6 @@ import { ZenBox, State } from './core.js';

declare const NULL: unique symbol;
declare const identity: <T>(state: T) => T;
declare function mergeState<T extends State>(initialState: T, partialState?: Partial<T>): T;
declare function resolveValue<T>(value: T): T;
export { NULL, type Prettify, type ResolveZenBox, mergeState, resolveValue };
export { NULL, type Prettify, type ResolveZenBox, identity, mergeState, resolveValue };

@@ -1,1 +0,1 @@

import {a}from'./chunk-EI7MMDWY.js';import {ZenBox}from'./core.js';export{deepEqual,shallowEqual}from'@del-wang/equals';const f=Symbol("NULL");function T(e,n={}){const t={...e};for(const o in n)Object.hasOwn(e,o)&&(t[o]=n[o]);return t}a(T,"mergeState");function l(e){return e instanceof ZenBox?e.value:Array.isArray(e)&&e.length>0?e.map(n=>n instanceof ZenBox?n.value:n):e}a(l,"resolveValue");export{f as NULL,T as mergeState,l as resolveValue};
import {a}from'./chunk-EI7MMDWY.js';import {ZenBox}from'./core.js';export{deepEqual,shallowEqual}from'@del-wang/equals';const f=Symbol("NULL"),T=a(e=>e,"identity");function i(e,n={}){const t={...e};for(const r in n)Object.hasOwn(e,r)&&(t[r]=n[r]);return t}a(i,"mergeState");function l(e){return e instanceof ZenBox?e.value:Array.isArray(e)&&e.length>0?e.map(n=>n instanceof ZenBox?n.value:n):e}a(l,"resolveValue");export{f as NULL,T as identity,i as mergeState,l as resolveValue};
{
"name": "zenbox",
"version": "0.0.1",
"version": "1.0.0",
"type": "module",

@@ -19,7 +19,2 @@ "description": "Code React like Vue 💚, manage state like Zustand 🐻.",

],
"scripts": {
"prepublish": "npm run build",
"build": "del build",
"test": "vitest run"
},
"files": [

@@ -61,7 +56,6 @@ "dist",

"@del-wang/equals": "^1.1.0",
"@del-wang/react-unstrict": "^1.1.0",
"immer": "^10.1.1"
},
"devDependencies": {
"@biomejs/biome": "^2.0.5",
"@biomejs/biome": "^2.0.6",
"@del-wang/config": "^1.2.0",

@@ -72,3 +66,3 @@ "@testing-library/dom": "^10.4.0",

"jsdom": "^26.1.0",
"lefthook": "^1.11.14",
"lefthook": "^1.11.15",
"tsup": "^8.5.0",

@@ -81,3 +75,2 @@ "typescript": "^5",

},
"packageManager": "pnpm@10.0.0",
"homepage": "https://github.com/idootop/ZenBox",

@@ -90,3 +83,9 @@ "bugs": {

"url": "git+https://github.com/idootop/ZenBox.git"
},
"scripts": {
"prepublish": "npm run build",
"build": "del build",
"test": "vitest run",
"lint": "biome check --write --no-errors-on-unmatched --diagnostic-level=error ."
}
}
}
+34
-35

@@ -0,30 +1,37 @@

![ZenBox](/website/public/banners/top.png)
## What is ZenBox?
<img alt="ZenBox" src="./assets/zenbox.webp" height='256' />
ZenBox is a modern React state management library that combines the simplicity of Zustand with the reactive patterns of Vue. It provides an intuitive API that feels natural to developers familiar with either framework.
## What's ZenBox?
Love Zustand & Vue? Meet ZenBox ❤️
A lightweight, intuitive state management library that combines the reactivity of Vue with the simplicity of Zustand for React applications.
### 🐻 Zustand's Simplicity
```ts
const counter = createStore({ count: 0 }); // Full TypeScript inference
const counter = createStore({ count: 0 }); // Auto-type inference
```
### ⚡ Vue-like DX
### 💚 Vue-like Developer Experience
```ts
const doubled = useComputed(() => 2 * counter.value.count);
const doubled = useComputed(() => counter.value.count * 2);
useWatch(
() => counter.value.count,
(current, prev) => console.log("Changed!", current, prev)
(current, prev) => console.log("Count changed from", prev, "to", current)
);
```
## Why Choose ZenBox?
- 🚀 **Easy to Use** - Intuitive API for immediate productivity
- ⚡ **High Performance** - Only re-renders what actually changed
- 💪 **TypeScript First** - Full type inference out of the box, zero boilerplate
- 🎯 **Flexible Architecture** - Works for both global and component-level state
- 📦 **Lightweight** - [100 lines of core code](https://zenbox.del.wang/en/blog/react-state-management-in-100-lines), under 3KB gzipped (without Immer)
## Getting Started
> [!TIP]
> ✨ Launching soon - stay tuned!
We believe ZenBox will transform how you think about React state management.

@@ -35,34 +42,26 @@ ```shell

## Documentation
**Ready to experience state management that feels like magic?** ✨
- [Core](./docs/core/) - Core API documentation
- [Hooks](./docs/hooks/) - Detailed hook documentation
- [Components](./docs/components/) - Component documentation
## Community & Support
## Why Choose ZenBox?
- 📚 **Documentation**: [https://zenbox.del.wang](https://zenbox.del.wang)
- 🐙 **GitHub**: [idootop/ZenBox](https://github.com/idootop/ZenBox)
- 💬 **Discussions**: [GitHub Discussions](https://github.com/idootop/ZenBox/discussions)
- 🐛 **Issues**: [GitHub Issues](https://github.com/idootop/ZenBox/issues)
**The state management library that feels like magic** ✨
## ZenBox vs Zustand
- 🎯 **Simple API** - Love Zustand & Vue? You’ll ❤️ ZenBox! Combines the best of both worlds in an API that feels natural and intuitive
- ⚡ **Lightning Fast** - Smart selective subscriptions + efficient change detection = blazing performance with minimal re-renders
- 🔮 **Vue-like Magic in React** - Get `useComputed` and `useWatch` reactivity that just works, no manual dependency tracking needed
- 📦 **TypeScript Superpowers** - Full auto-inference out of the box. No interfaces, no generics, no headaches - just pure type safety
- 🏗️ **Mutate Like a Human** - Write `state.count++` instead of `setState(prev => ({...prev, count: prev.count + 1}))`. Immer built-in!
- 🪶 **Featherweight** - Under 100 lines of core code, < 10KB gzipped. Big power, tiny footprint
| Feature | ZenBox | Zustand |
| ------------------------ | ---------------------------------- | ------------------------------ |
| **Learning Curve** | ✅ Minimal (Vue-friendly) | ✅ Low |
| **Vue-like Reactivity** | ✅ `useComputed`/`useWatch` | ❌ Manual handling |
| **TypeScript Support** | ✅ Complete auto-inference | ⚠️ Manual interface definition |
| **State Access** | ✅ Unified `store.value` interface | ❌ Manual `get()`/`set()` |
| **Cross-Store Computed** | ✅ Automatic dependency tracking | ⚠️ Requires pre-combination |
| **Store Scoping** | ✅ Built-in Provider for isolation | ❌ Global by default |
| **Immer Integration** | ✅ Built-in support | ⚠️ Middleware required |
| **Bundle Size** | **< 3KB** gzipped (without Immer) | **< 1KB** gzipped |
### ZenBox vs Zustand
| Feature | ZenBox | Zustand |
| ---------------------- | ------------------------------------ | ---------------------------- |
| **Simple API** | ✅ One-line store creation | ✅ Simple |
| **Vue-like DX** | ✅ `useComputed`/`useWatch` | ❌ Manual handling |
| **TypeScript Support** | ✅ Full auto-inference | ⚠️ Manual interface required |
| **State Mutation** | ✅ Direct mutation (Vue-like) | ❌ Manual `.get()`/`.set()` |
| **Computed Values** | ✅ Cross-store, auto-tracked | ⚠️ Pre-combined |
| **Store Scoping** | ✅ Built-in Provider for local store | ❌ Global default |
| **Immer Support** | ✅ Out of the box | ⚠️ Middleware required |
| **Learning Curve** | ✅ Minimal (Vue-friendly) | ✅ Low |
## License
MIT License © 2025-PRESENT [Del Wang](https://del.wang)