chrono-state-z 2.2.1-iz → 2.2.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
@@ -25,13 +25,13 @@ It provides **atoms, computed values, async state, effects, scheduling**, with a
25
25
 
26
26
  ## 🧠 Mental Model
27
27
 
28
- - **Atom** small reactive state unit
29
- - **Computed** derived, cached reactive value
30
- - **AsyncAtom** async resource with invalidate + priority
31
- - **Effect** reactive side-effect runner
32
- - **Transaction** batch updates
33
- - **Store / Intent** event-driven orchestration
34
- - **React hooks** thin bindings over the headless core
28
+ - Atom small reactive state unit
29
+ - Computed derived value, cached and reactive
30
+ - AsyncAtom async state with suspense-style read
31
+ - Effect reactive side-effect runner
32
+ - Scheduler priority-based execution control
33
+ - Store / Intent intent-driven state orchestration
34
+ - React hooks thin bindings over the headless core
35
35
 
36
36
  ---
37
37
 
@@ -281,11 +281,16 @@ function StoreView({ store }: { store: Store<any> }) {
281
281
 
282
282
  ```tsx
283
283
  // Only re-renders when saving changes, not the whole store.
284
- import { useStoreSelector } from "chrono-state-z"
284
+ import { useStoreSelector } from 'chrono-state-z'
285
285
 
286
286
  function SavingBadge({ store }) {
287
287
  const saving = useStoreSelector(store, s => s.saving)
288
- return saving ? "Saving..." : "Idle"
288
+ // const saving = useStoreSelector(
289
+ // store,
290
+ // s => s.meta,
291
+ // shallowEqual
292
+ // )
293
+ return saving ? 'Saving...' : 'Idle'
289
294
  }
290
295
 
291
296
  ```
@@ -0,0 +1,10 @@
1
+ import { CommonResource } from "./asyncResource";
2
+ export type AsyncAtom<T> = {
3
+ (): T | undefined;
4
+ } & CommonResource<T>;
5
+ export declare function asyncAtom<T>(fetcher: (signal?: AbortSignal) => Promise<T>, options?: {
6
+ suspense?: boolean;
7
+ }): AsyncAtom<T>;
8
+ export declare function asyncAtomFamily<K, T>(factory: (key: K) => (signal?: AbortSignal) => Promise<T>, options?: {
9
+ suspense?: boolean;
10
+ }): (key: K) => AsyncAtom<T>;
@@ -0,0 +1,8 @@
1
+ import type { Priority } from "intentx-core-z";
2
+ export type AsyncComputed<T> = {
3
+ (): T | undefined;
4
+ invalidate(priority?: Priority): void;
5
+ status(): string;
6
+ error(): any;
7
+ };
8
+ export declare function asyncComputed<T>(getter: (signal?: AbortSignal) => Promise<T>, priority?: Priority): AsyncComputed<T>;
@@ -0,0 +1,28 @@
1
+ import { Priority } from "intentx-core-z";
2
+ export type CommonResource<T> = {
3
+ load(): Promise<T>;
4
+ cancel(): void;
5
+ invalidate(priority?: Priority): void;
6
+ status(): AsyncState<T>["status"];
7
+ error(): any;
8
+ setSuccess(value: T, priority?: Priority): void;
9
+ };
10
+ export type AsyncState<T> = {
11
+ status: "idle";
12
+ } | {
13
+ status: "loading";
14
+ promise: Promise<T>;
15
+ } | {
16
+ status: "success";
17
+ data: T;
18
+ } | {
19
+ status: "error";
20
+ error: any;
21
+ };
22
+ export type AsyncResource<T> = {
23
+ read(): T | undefined;
24
+ } & CommonResource<T>;
25
+ export declare function createAsyncResource<T>(fetcher: (signal?: AbortSignal) => Promise<T>, options?: {
26
+ suspense?: boolean;
27
+ priority?: Priority;
28
+ }): AsyncResource<T>;
@@ -0,0 +1,6 @@
1
+ export type ReadonlyAtom<T> = () => T;
2
+ export declare const atom: <T>(initial: T, options?: import("./createAtomFactory").AtomOptions<T>) => import("./createBaseAtom").Atom<T>;
3
+ export declare const atomMiddleware: <T>(initial: T, middleware?: import("./createAtomFactory").AtomMiddleware<T>) => import("./createBaseAtom").Atom<T>;
4
+ export declare function readonlyAtom<T>(atom: {
5
+ (): T;
6
+ }): ReadonlyAtom<T>;
@@ -0,0 +1,7 @@
1
+ import type { Signal } from "intentx-core-z";
2
+ export type AtomOptions<T> = {
3
+ equals?: (a: T, b: T) => boolean;
4
+ };
5
+ export type AtomMiddleware<T> = (next: T, prev: T) => T;
6
+ export declare function createAtomFactory(signal: <T>(v: T) => Signal<T>): <T>(initial: T, options?: AtomOptions<T>) => import("./createBaseAtom").Atom<T>;
7
+ export declare function createAtomWithMiddlewareFactory(signal: <T>(v: T) => Signal<T>): <T>(initial: T, middleware?: AtomMiddleware<T>) => import("./createBaseAtom").Atom<T>;
@@ -0,0 +1,6 @@
1
+ import type { Priority, Signal } from "intentx-core-z";
2
+ export type Atom<T> = Signal<T> & {
3
+ update(fn: (prev: T) => T, priority?: Priority): void;
4
+ };
5
+ export type AtomTransform<T> = (next: T, prev: T) => T;
6
+ export declare function createBaseAtomFactory(signal: <T>(v: T) => Signal<T>): <T>(initial: T, transform?: AtomTransform<T>) => Atom<T>;
@@ -0,0 +1,3 @@
1
+ import type { Scope } from "intentx-core-z";
2
+ import { Store } from "./types";
3
+ export declare function createStore<S extends object>(initial: S, scope?: Scope): Store<S>;
@@ -0,0 +1,7 @@
1
+ export declare function factoryAtom<K, A>(factory: (key: K) => A, options?: {
2
+ weak?: boolean;
3
+ }): {
4
+ (key: K): A;
5
+ delete(key: K): void;
6
+ clear(): void;
7
+ };
@@ -0,0 +1,13 @@
1
+ export * from "./atom";
2
+ export * from "./asyncComputed";
3
+ export * from "./createAtomFactory";
4
+ export * from "./createBaseAtom";
5
+ export { asyncAtom } from "./asyncAtom";
6
+ export { computed } from "intentx-core-z";
7
+ export { effect } from "intentx-core-z";
8
+ export * from "./watch";
9
+ export { createStore } from "./createStore";
10
+ export * from "./selector";
11
+ export type { Store, Subscriber } from "./types";
12
+ export { factoryAtom } from "./factoryAtom";
13
+ export { transaction } from "./transaction";
@@ -0,0 +1,7 @@
1
+ export type EqualityFn<T> = (a: T, b: T) => boolean;
2
+ export declare function createSelector<S, R>(select: (state: S) => R, isEqual?: EqualityFn<R>): (state: S) => R;
3
+ export declare function selectAtom<T, R>(atom: () => T, selector: (value: T) => R, onChange: (value: R) => void, options?: {
4
+ isEqual?: (a: R, b: R) => boolean;
5
+ immediate?: boolean;
6
+ }): () => void;
7
+ export declare function watchSelector<S, R>(getState: () => S, subscribe: (fn: () => void) => () => void, selector: (state: S) => R, onChange: (value: R) => void, isEqual?: EqualityFn<R>): () => void;
@@ -0,0 +1 @@
1
+ export { batch as transaction } from "intentx-core-z";
@@ -0,0 +1,12 @@
1
+ import type { IntentHandler, Scope } from "intentx-core-z";
2
+ import { EqualityFn } from "./selector";
3
+ export type Subscriber = () => void;
4
+ export type Store<S extends object> = {
5
+ scope: Scope;
6
+ state(): S;
7
+ setState(fn: (s: S) => void): void;
8
+ subscribe(fn: Subscriber): () => void;
9
+ emit(type: string, payload?: any): Promise<void>;
10
+ on(type: string, handler: IntentHandler<S>): () => void;
11
+ watch<R>(selector: (state: S) => R, onChange: (value: R) => void, isEqual?: EqualityFn<R>): () => void;
12
+ };
@@ -0,0 +1,7 @@
1
+ import type { Priority } from "intentx-core-z";
2
+ export type WatchOptions<T> = {
3
+ immediate?: boolean;
4
+ equals?: (a: T, b: T) => boolean;
5
+ priority?: Priority;
6
+ };
7
+ export declare function watch<T>(getter: () => T, fn: (value: T, prev: T | undefined, onCleanup: (callback: () => void) => void) => void, options?: WatchOptions<T>): () => void;
@@ -1 +1 @@
1
- "use strict";var e=require("react"),t=require("intentx-state-z");function r(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,Object.freeze(t)}var n=r(e);function c(e){return n.useSyncExternalStore(r=>t.effect(()=>{e(),r()}),e,e)}Object.defineProperty(exports,"asyncAtom",{enumerable:!0,get:function(){return t.asyncAtom}}),Object.defineProperty(exports,"asyncAtomFamily",{enumerable:!0,get:function(){return t.asyncAtomFamily}}),Object.defineProperty(exports,"asyncComputed",{enumerable:!0,get:function(){return t.asyncComputed}}),Object.defineProperty(exports,"atom",{enumerable:!0,get:function(){return t.atom}}),Object.defineProperty(exports,"atomMiddleware",{enumerable:!0,get:function(){return t.atomMiddleware}}),Object.defineProperty(exports,"batch",{enumerable:!0,get:function(){return t.batch}}),Object.defineProperty(exports,"computed",{enumerable:!0,get:function(){return t.computed}}),Object.defineProperty(exports,"createAppScope",{enumerable:!0,get:function(){return t.createAppScope}}),Object.defineProperty(exports,"createSelector",{enumerable:!0,get:function(){return t.createSelector}}),Object.defineProperty(exports,"createSharedIntentBus",{enumerable:!0,get:function(){return t.createSharedIntentBus}}),Object.defineProperty(exports,"createStore",{enumerable:!0,get:function(){return t.createStore}}),Object.defineProperty(exports,"effect",{enumerable:!0,get:function(){return t.effect}}),Object.defineProperty(exports,"factoryAtom",{enumerable:!0,get:function(){return t.factoryAtom}}),Object.defineProperty(exports,"readonlyAtom",{enumerable:!0,get:function(){return t.readonlyAtom}}),Object.defineProperty(exports,"selectAtom",{enumerable:!0,get:function(){return t.selectAtom}}),Object.defineProperty(exports,"transaction",{enumerable:!0,get:function(){return t.transaction}}),Object.defineProperty(exports,"watch",{enumerable:!0,get:function(){return t.watch}}),Object.defineProperty(exports,"watchSelector",{enumerable:!0,get:function(){return t.watchSelector}}),exports.scheduleReactJob=function(t,r="normal"){"low"===r?e.startTransition(t):t()},exports.useAtom=c,exports.useAtomSelector=function(r,n,c=Object.is){const o=e.useRef(t.createSelector(n,c)),u=()=>o.current(r());return e.useSyncExternalStore(e=>t.effect(()=>{r(),e()}),u,u)},exports.useBatch=function(){return t.batch},exports.useComputed=function(e,r=[]){return c(n.useMemo(()=>t.computed(e),r))},exports.useEffectReact=function(e,r="normal"){const c=n.useRef(e);c.current=e,n.useEffect(()=>{const e=t.effect(()=>{c.current()},r);return()=>e()},[r])},exports.useFactoryAtom=function(e,t){const r=n.useRef(e);r.current=e;const o=n.useRef(null),u=n.useRef(null);return null!==o.current&&u.current===t||(o.current=r.current(t),u.current=t),c(o.current)},exports.useStore=function(t){return e.useSyncExternalStore(t.subscribe,t.state,t.state)},exports.useStoreSelector=function(e,r,c=Object.is){const o=n.useRef(r);o.current=r;const u=n.useRef(t.createSelector(e=>o.current(e),c)),s=n.useCallback(()=>u.current(e.state()),[e]);return n.useSyncExternalStore(e.subscribe,s,s)},exports.useWatch=function(e,r,c){const o=n.useRef(r);o.current=r;const u=n.useRef(c);u.current=c,n.useEffect(()=>{const r=t.watch(e,e=>{o.current(e)},u.current);return()=>null==r?void 0:r()},[e])};
1
+ "use strict";var e=require("intentx-core-z"),t=require("react");function r(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,Object.freeze(t)}var n=r(t);function o(e){return function(t,r){const n=e(t),o=n.set;return n.set=(e,t="normal")=>{const s=n(),c=r?r(e,s):e;o(c,t)},n.update=(e,t="normal")=>{n.set(e(n()),t)},n}}function s(e){const t=o(e);return function(e,r){var n;const o=null!==(n=null==r?void 0:r.equals)&&void 0!==n?n:Object.is;return t(e,(e,t)=>o(e,t)?t:e)}}function c(e){const t=o(e);return function(e,r){return t(e,r)}}const u=s(e.signal),a=c(e.signal);function i(t,r){var n,o;const s=null!==(n=null==r?void 0:r.suspense)&&void 0!==n&&n,c=null!==(o=null==r?void 0:r.priority)&&void 0!==o?o:"normal",a=u({status:"idle"});let i=null;const l=()=>{const e=a();if("loading"===e.status)return e.promise;null==i||i.abort(),i=new AbortController;const r=t(i.signal).then(e=>(a.set({status:"success",data:e},c),e)).catch(e=>{if("AbortError"===(null==e?void 0:e.name))return Promise.resolve(void 0);throw a.set({status:"error",error:e}),e});return a.set({status:"loading",promise:r},c),r},f=()=>{null==i||i.abort()};return{read:()=>{const e=a();switch(e.status){case"success":return e.data;case"error":if(s)throw e.error;return;case"loading":if(s)throw e.promise;return;case"idle":const t=l();if(s)throw t;return}},load:l,cancel:f,invalidate:(t=c)=>{f(),a.set({status:"idle"},t),e.schedule(l,t)},status:()=>a().status,error:()=>"error"===a().status?a().error:void 0,setSuccess:(e,t=c)=>{a.set({status:"success",data:e},t)}}}function l(t,r,n){const{immediate:o=!1,equals:s=Object.is,priority:c="normal"}=null!=n?n:{};let u,a,i=!1;const l=e.effect(()=>{const e=t();if(!i)return i=!0,o&&f(e,u),void(u=e);s(e,u)||(f(e,u),u=e)},c);function f(e,t){const n=a;a=void 0,null==n||n(),r(e,t,e=>{a=e})}return()=>{null==a||a(),l()}}function f(e,t=Object.is){let r,n=!1;return o=>{const s=e(o);return n&&t(r,s)?r:(n=!0,r=s,s)}}function d(e,t,r,n,o=Object.is){const s=f(r,o);let c=!1;const u=()=>{c||n(s(e()))};u();const a=t(u);return()=>{c=!0,a()}}const p=e.createScope("default");function m(t){return n.useSyncExternalStore(r=>e.effect(()=>{t(),r()}),t,t)}Object.defineProperty(exports,"computed",{enumerable:!0,get:function(){return e.computed}}),Object.defineProperty(exports,"createScope",{enumerable:!0,get:function(){return e.createScope}}),Object.defineProperty(exports,"effect",{enumerable:!0,get:function(){return e.effect}}),Object.defineProperty(exports,"transaction",{enumerable:!0,get:function(){return e.batch}}),exports.asyncAtom=function(e,t){const r=i(e,t),n=()=>r.read();return n.load=r.load,n.cancel=r.cancel,n.invalidate=r.invalidate,n.status=r.status,n.error=r.error,n.setSuccess=e=>r.setSuccess(e),n},exports.asyncComputed=function(e,t="normal"){const r=i(e,{suspense:!0,priority:t}),n=()=>r.read();return n.invalidate=r.invalidate,n.status=r.status,n.error=r.error,n},exports.atom=u,exports.atomMiddleware=a,exports.createAtomFactory=s,exports.createAtomWithMiddlewareFactory=c,exports.createBaseAtomFactory=o,exports.createSelector=f,exports.createStore=function(t,r=p){let n=t;const o=new Set,s=e.createIntentBus((e,t)=>{const r=new AbortController;return{payload:e,scope:t,state:n,signal:r.signal,setState(e){e(n),o.forEach(e=>e())},emit:(e,r)=>s.emit(e,r,t)}});return{scope:r,state:()=>n,setState(e){e(n),o.forEach(e=>e())},subscribe:e=>(o.add(e),()=>o.delete(e)),emit:(e,t)=>s.emit(e,t,r),on:(e,t)=>s.on(e,t,r),watch:(e,t,r)=>d(()=>n,e=>(o.add(e),()=>o.delete(e)),e,t,r)}},exports.factoryAtom=function(e,t){var r;const n=null!==(r=null==t?void 0:t.weak)&&void 0!==r&&r,o=n?new WeakMap:new Map,s=t=>{const r=o.get(t);if(void 0!==r)return r;const n=e(t);return o.set(t,n),n};return s.delete=e=>{n||o.delete(e)},s.clear=()=>{n||o.clear()},s},exports.readonlyAtom=function(e){return()=>e()},exports.scheduleReactJob=function(e,r="normal"){"low"===r?t.startTransition(e):e()},exports.selectAtom=function(t,r,n,o){var s;const c=null!==(s=null==o?void 0:o.isEqual)&&void 0!==s?s:Object.is;let u;return e.effect(()=>{const e=r(t());void 0!==u&&c(u,e)||(u=e,((null==o?void 0:o.immediate)||void 0!==u)&&n(e))})},exports.useAtom=m,exports.useAtomSelector=function(r,n,o=Object.is){const s=t.useRef(f(n,o)),c=()=>s.current(r());return t.useSyncExternalStore(t=>e.effect(()=>{r(),t()}),c,c)},exports.useBatch=function(){return e.batch},exports.useComputed=function(t,r=[]){return m(n.useMemo(()=>e.computed(t),r))},exports.useEffectReact=function(t,r="normal"){const o=n.useRef(t);o.current=t,n.useEffect(()=>{const t=e.effect(()=>{o.current()},r);return()=>t()},[r])},exports.useFactoryAtom=function(e,t){const r=n.useRef(e);r.current=e;const o=n.useRef(null),s=n.useRef(null);return null!==o.current&&s.current===t||(o.current=r.current(t),s.current=t),m(o.current)},exports.useStore=function(e){return t.useSyncExternalStore(e.subscribe,e.state,e.state)},exports.useStoreSelector=function(e,t,r=Object.is){const o=n.useRef(t);o.current=t;const s=n.useRef(f(e=>o.current(e),r)),c=n.useCallback(()=>s.current(e.state()),[e]);return n.useSyncExternalStore(e.subscribe,c,c)},exports.useWatch=function(e,t,r){const o=n.useRef(t);o.current=t;const s=n.useRef(r);s.current=r,n.useEffect(()=>{const t=l(e,e=>{o.current(e)},s.current);return()=>null==t?void 0:t()},[e])},exports.watch=l,exports.watchSelector=d;
package/build/index.d.ts CHANGED
@@ -1,9 +1,4 @@
1
- export * from "./react";
2
- export { atom, readonlyAtom, atomMiddleware, } from "intentx-state-z";
3
- export { asyncAtom, asyncAtomFamily, } from "intentx-state-z";
4
- export { asyncComputed } from "intentx-state-z";
5
- export { computed, effect, batch, transaction, } from "intentx-state-z";
6
- export { createStore, createAppScope, createSharedIntentBus } from "intentx-state-z";
7
- export type { Atom, Priority, Store, Subscriber } from "intentx-state-z";
8
- export { createSelector, selectAtom, watchSelector, watch } from "intentx-state-z";
9
- export { factoryAtom } from "intentx-state-z";
1
+ export { createScope } from "intentx-core-z";
2
+ export type { Scope } from "intentx-core-z";
3
+ export * from './core';
4
+ export * from './react';
@@ -1 +1 @@
1
- import*as t from"react";import e,{startTransition as r}from"react";import{effect as n,createSelector as c,batch as u,computed as o,watch as s}from"intentx-state-z";export{asyncAtom,asyncAtomFamily,asyncComputed,atom,atomMiddleware,batch,computed,createAppScope,createSelector,createSharedIntentBus,createStore,effect,factoryAtom,readonlyAtom,selectAtom,transaction,watch,watchSelector}from"intentx-state-z";function a(e){return t.useSyncExternalStore(t=>n(()=>{e(),t()}),e,e)}function f(t,r,u=Object.is){const o=e.useRef(c(r,u)),s=()=>o.current(t());return e.useSyncExternalStore(e=>n(()=>{t(),e()}),s,s)}function i(){return u}function l(e,r=[]){return a(t.useMemo(()=>o(e),r))}function m(e,r="normal"){const c=t.useRef(e);c.current=e,t.useEffect(()=>{const t=n(()=>{c.current()},r);return()=>t()},[r])}function S(e,r){const n=t.useRef(e);n.current=e;const c=t.useRef(null),u=t.useRef(null);return null!==c.current&&u.current===r||(c.current=n.current(r),u.current=r),a(c.current)}function p(t){return e.useSyncExternalStore(t.subscribe,t.state,t.state)}function y(e,r,n=Object.is){const u=t.useRef(r);u.current=r;const o=t.useRef(c(t=>u.current(t),n)),s=t.useCallback(()=>o.current(e.state()),[e]);return t.useSyncExternalStore(e.subscribe,s,s)}function R(e,r,n){const c=t.useRef(r);c.current=r;const u=t.useRef(n);u.current=n,t.useEffect(()=>{const t=s(e,t=>{c.current(t)},u.current);return()=>null==t?void 0:t()},[e])}function b(t,e="normal"){"low"===e?r(t):t()}export{b as scheduleReactJob,a as useAtom,f as useAtomSelector,i as useBatch,l as useComputed,m as useEffectReact,S as useFactoryAtom,p as useStore,y as useStoreSelector,R as useWatch};
1
+ import{signal as t,schedule as e,effect as n,createScope as r,createIntentBus as s,batch as o,computed as u}from"intentx-core-z";export{computed,createScope,effect,batch as transaction}from"intentx-core-z";import*as c from"react";import i,{startTransition as a}from"react";function l(t){return function(e,n){const r=t(e),s=r.set;return r.set=(t,e="normal")=>{const o=r(),u=n?n(t,o):t;s(u,e)},r.update=(t,e="normal")=>{r.set(t(r()),e)},r}}function f(t){const e=l(t);return function(t,n){var r;const s=null!==(r=null==n?void 0:n.equals)&&void 0!==r?r:Object.is;return e(t,(t,e)=>s(t,e)?e:t)}}function d(t){const e=l(t);return function(t,n){return e(t,n)}}const v=f(t),m=d(t);function p(t){return()=>t()}function b(t,n){var r,s;const o=null!==(r=null==n?void 0:n.suspense)&&void 0!==r&&r,u=null!==(s=null==n?void 0:n.priority)&&void 0!==s?s:"normal",c=v({status:"idle"});let i=null;const a=()=>{const e=c();if("loading"===e.status)return e.promise;null==i||i.abort(),i=new AbortController;const n=t(i.signal).then(t=>(c.set({status:"success",data:t},u),t)).catch(t=>{if("AbortError"===(null==t?void 0:t.name))return Promise.resolve(void 0);throw c.set({status:"error",error:t}),t});return c.set({status:"loading",promise:n},u),n},l=()=>{null==i||i.abort()};return{read:()=>{const t=c();switch(t.status){case"success":return t.data;case"error":if(o)throw t.error;return;case"loading":if(o)throw t.promise;return;case"idle":const e=a();if(o)throw e;return}},load:a,cancel:l,invalidate:(t=u)=>{l(),c.set({status:"idle"},t),e(a,t)},status:()=>c().status,error:()=>"error"===c().status?c().error:void 0,setSuccess:(t,e=u)=>{c.set({status:"success",data:t},e)}}}function S(t,e="normal"){const n=b(t,{suspense:!0,priority:e}),r=()=>n.read();return r.invalidate=n.invalidate,r.status=n.status,r.error=n.error,r}function w(t,e){const n=b(t,e),r=()=>n.read();return r.load=n.load,r.cancel=n.cancel,r.invalidate=n.invalidate,r.status=n.status,r.error=n.error,r.setSuccess=t=>n.setSuccess(t),r}function h(t,e,r){const{immediate:s=!1,equals:o=Object.is,priority:u="normal"}=null!=r?r:{};let c,i,a=!1;const l=n(()=>{const e=t();if(!a)return a=!0,s&&f(e,c),void(c=e);o(e,c)||(f(e,c),c=e)},u);function f(t,n){const r=i;i=void 0,null==r||r(),e(t,n,t=>{i=t})}return()=>{null==i||i(),l()}}function E(t,e=Object.is){let n,r=!1;return s=>{const o=t(s);return r&&e(n,o)?n:(r=!0,n=o,o)}}function R(t,e,r,s){var o;const u=null!==(o=null==s?void 0:s.isEqual)&&void 0!==o?o:Object.is;let c;return n(()=>{const n=e(t());void 0!==c&&u(c,n)||(c=n,((null==s?void 0:s.immediate)||void 0!==c)&&r(n))})}function x(t,e,n,r,s=Object.is){const o=E(n,s);let u=!1;const c=()=>{u||r(o(t()))};c();const i=e(c);return()=>{u=!0,i()}}const y=r("default");function g(t,e=y){let n=t;const r=new Set,o=s((t,e)=>{const s=new AbortController;return{payload:t,scope:e,state:n,signal:s.signal,setState(t){t(n),r.forEach(t=>t())},emit:(t,n)=>o.emit(t,n,e)}});return{scope:e,state:()=>n,setState(t){t(n),r.forEach(t=>t())},subscribe:t=>(r.add(t),()=>r.delete(t)),emit:(t,n)=>o.emit(t,n,e),on:(t,n)=>o.on(t,n,e),watch:(t,e,s)=>x(()=>n,t=>(r.add(t),()=>r.delete(t)),t,e,s)}}function j(t,e){var n;const r=null!==(n=null==e?void 0:e.weak)&&void 0!==n&&n,s=r?new WeakMap:new Map,o=e=>{const n=s.get(e);if(void 0!==n)return n;const r=t(e);return s.set(e,r),r};return o.delete=t=>{r||s.delete(t)},o.clear=()=>{r||s.clear()},o}function O(t){return c.useSyncExternalStore(e=>n(()=>{t(),e()}),t,t)}function k(t,e,r=Object.is){const s=i.useRef(E(e,r)),o=()=>s.current(t());return i.useSyncExternalStore(e=>n(()=>{t(),e()}),o,o)}function q(){return o}function A(t,e=[]){return O(c.useMemo(()=>u(t),e))}function C(t,e="normal"){const r=c.useRef(t);r.current=t,c.useEffect(()=>{const t=n(()=>{r.current()},e);return()=>t()},[e])}function M(t,e){const n=c.useRef(t);n.current=t;const r=c.useRef(null),s=c.useRef(null);return null!==r.current&&s.current===e||(r.current=n.current(e),s.current=e),O(r.current)}function z(t){return i.useSyncExternalStore(t.subscribe,t.state,t.state)}function P(t,e,n=Object.is){const r=c.useRef(e);r.current=e;const s=c.useRef(E(t=>r.current(t),n)),o=c.useCallback(()=>s.current(t.state()),[t]);return c.useSyncExternalStore(t.subscribe,o,o)}function W(t,e,n){const r=c.useRef(e);r.current=e;const s=c.useRef(n);s.current=n,c.useEffect(()=>{const e=h(t,t=>{r.current(t)},s.current);return()=>null==e?void 0:e()},[t])}function B(t,e="normal"){"low"===e?a(t):t()}export{w as asyncAtom,S as asyncComputed,v as atom,m as atomMiddleware,f as createAtomFactory,d as createAtomWithMiddlewareFactory,l as createBaseAtomFactory,E as createSelector,g as createStore,j as factoryAtom,p as readonlyAtom,B as scheduleReactJob,R as selectAtom,O as useAtom,k as useAtomSelector,q as useBatch,A as useComputed,C as useEffectReact,M as useFactoryAtom,z as useStore,P as useStoreSelector,W as useWatch,h as watch,x as watchSelector};
@@ -1,2 +1,2 @@
1
- import type { Priority } from 'intentx-state-z';
1
+ import type { Priority } from 'intentx-core-z';
2
2
  export declare function scheduleReactJob(job: () => void, priority?: Priority): void;
@@ -1,2 +1,2 @@
1
- import { batch } from 'intentx-state-z';
1
+ import { batch } from 'intentx-core-z';
2
2
  export declare function useBatch(): typeof batch;
@@ -1,2 +1,2 @@
1
- import { Priority } from 'intentx-state-z';
1
+ import { Priority } from 'intentx-core-z';
2
2
  export declare function useEffectReact(fn: () => void, priority?: Priority): void;
@@ -1,2 +1,2 @@
1
- import type { WatchOptions } from "intentx-state-z";
1
+ import type { WatchOptions } from "../core/watch";
2
2
  export declare function useWatch<T>(getter: () => T, fn: (val: T) => void, options?: WatchOptions<T>): void;
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "chrono-state-z",
3
- "version": "2.2.1-iz",
3
+ "version": "2.2.1",
4
4
  "description": "A fine-grained, intent-driven reactive state runtime for building complex React logic outside components.",
5
5
  "license": "MIT",
6
6
  "author": "Delpi.Kye",
7
7
  "sideEffects": false,
8
+
8
9
  "main": "build/index.cjs.js",
9
10
  "module": "build/index.esm.js",
10
11
  "types": "build/index.d.ts",
@@ -18,12 +19,14 @@
18
19
  "files": [
19
20
  "build"
20
21
  ],
22
+
21
23
  "scripts": {
22
24
  "clean": "rimraf build",
23
25
  "build": "rollup -c",
24
26
  "cb": "npm run clean && npm run build",
25
27
  "prepublishOnly": "npm run cb"
26
28
  },
29
+
27
30
  "repository": {
28
31
  "type": "git",
29
32
  "url": "https://github.com/delpikye-v/chrono-state.git"
@@ -53,7 +56,7 @@
53
56
  "react": ">=18"
54
57
  },
55
58
  "dependencies": {
56
- "intentx-state-z": "^0.1.1"
59
+ "intentx-core-z": "^2.2.1"
57
60
  },
58
61
  "devDependencies": {
59
62
  "@rollup/plugin-commonjs": "^25.0.0",