atomirx 0.0.8 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +198 -2234
- package/bin/cli.js +90 -0
- package/dist/core/derived.d.ts +2 -2
- package/dist/core/effect.d.ts +3 -2
- package/dist/core/onCreateHook.d.ts +15 -2
- package/dist/core/onErrorHook.d.ts +4 -1
- package/dist/core/pool.d.ts +78 -0
- package/dist/core/pool.test.d.ts +1 -0
- package/dist/core/select-boolean.test.d.ts +1 -0
- package/dist/core/select-pool.test.d.ts +1 -0
- package/dist/core/select.d.ts +278 -86
- package/dist/core/types.d.ts +233 -1
- package/dist/core/withAbort.d.ts +95 -0
- package/dist/core/withReady.d.ts +3 -3
- package/dist/devtools/constants.d.ts +41 -0
- package/dist/devtools/index.cjs +1 -0
- package/dist/devtools/index.d.ts +29 -0
- package/dist/devtools/index.js +429 -0
- package/dist/devtools/registry.d.ts +98 -0
- package/dist/devtools/registry.test.d.ts +1 -0
- package/dist/devtools/setup.d.ts +61 -0
- package/dist/devtools/types.d.ts +311 -0
- package/dist/index-BZEnfIcB.cjs +1 -0
- package/dist/index-BbPZhsDl.js +1653 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +18 -14
- package/dist/onDispatchHook-C8yLzr-o.cjs +1 -0
- package/dist/onDispatchHook-SKbiIUaJ.js +5 -0
- package/dist/onErrorHook-BGGy3tqK.js +38 -0
- package/dist/onErrorHook-DHBASmYw.cjs +1 -0
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.js +191 -151
- package/dist/react/onDispatchHook.d.ts +106 -0
- package/dist/react/useAction.d.ts +4 -1
- package/dist/react-devtools/DevToolsPanel.d.ts +93 -0
- package/dist/react-devtools/EntityDetails.d.ts +10 -0
- package/dist/react-devtools/EntityList.d.ts +15 -0
- package/dist/react-devtools/LogList.d.ts +12 -0
- package/dist/react-devtools/hooks.d.ts +50 -0
- package/dist/react-devtools/index.cjs +1 -0
- package/dist/react-devtools/index.d.ts +31 -0
- package/dist/react-devtools/index.js +1589 -0
- package/dist/react-devtools/styles.d.ts +148 -0
- package/package.json +26 -2
- package/skills/atomirx/SKILL.md +456 -0
- package/skills/atomirx/references/async-patterns.md +188 -0
- package/skills/atomirx/references/atom-patterns.md +238 -0
- package/skills/atomirx/references/deferred-loading.md +191 -0
- package/skills/atomirx/references/derived-patterns.md +428 -0
- package/skills/atomirx/references/effect-patterns.md +426 -0
- package/skills/atomirx/references/error-handling.md +140 -0
- package/skills/atomirx/references/hooks.md +322 -0
- package/skills/atomirx/references/pool-patterns.md +229 -0
- package/skills/atomirx/references/react-integration.md +411 -0
- package/skills/atomirx/references/rules.md +407 -0
- package/skills/atomirx/references/select-context.md +309 -0
- package/skills/atomirx/references/service-template.md +172 -0
- package/skills/atomirx/references/store-template.md +205 -0
- package/skills/atomirx/references/testing-patterns.md +431 -0
- package/coverage/base.css +0 -224
- package/coverage/block-navigation.js +0 -87
- package/coverage/clover.xml +0 -1440
- package/coverage/coverage-final.json +0 -14
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +0 -131
- package/coverage/prettify.css +0 -1
- package/coverage/prettify.js +0 -2
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +0 -210
- package/coverage/src/core/atom.ts.html +0 -889
- package/coverage/src/core/batch.ts.html +0 -223
- package/coverage/src/core/define.ts.html +0 -805
- package/coverage/src/core/emitter.ts.html +0 -919
- package/coverage/src/core/equality.ts.html +0 -631
- package/coverage/src/core/hook.ts.html +0 -460
- package/coverage/src/core/index.html +0 -281
- package/coverage/src/core/isAtom.ts.html +0 -100
- package/coverage/src/core/isPromiseLike.ts.html +0 -133
- package/coverage/src/core/onCreateHook.ts.html +0 -138
- package/coverage/src/core/scheduleNotifyHook.ts.html +0 -94
- package/coverage/src/core/types.ts.html +0 -523
- package/coverage/src/core/withUse.ts.html +0 -253
- package/coverage/src/index.html +0 -116
- package/coverage/src/index.ts.html +0 -106
- package/dist/index-CBVj1kSj.js +0 -1350
- package/dist/index-Cxk9v0um.cjs +0 -1
- package/scripts/publish.js +0 -198
- package/src/core/atom.test.ts +0 -633
- package/src/core/atom.ts +0 -311
- package/src/core/atomState.test.ts +0 -342
- package/src/core/atomState.ts +0 -256
- package/src/core/batch.test.ts +0 -257
- package/src/core/batch.ts +0 -172
- package/src/core/define.test.ts +0 -343
- package/src/core/define.ts +0 -243
- package/src/core/derived.test.ts +0 -1215
- package/src/core/derived.ts +0 -450
- package/src/core/effect.test.ts +0 -802
- package/src/core/effect.ts +0 -188
- package/src/core/emitter.test.ts +0 -364
- package/src/core/emitter.ts +0 -392
- package/src/core/equality.test.ts +0 -392
- package/src/core/equality.ts +0 -182
- package/src/core/getAtomState.ts +0 -69
- package/src/core/hook.test.ts +0 -227
- package/src/core/hook.ts +0 -177
- package/src/core/isAtom.ts +0 -27
- package/src/core/isPromiseLike.test.ts +0 -72
- package/src/core/isPromiseLike.ts +0 -16
- package/src/core/onCreateHook.ts +0 -107
- package/src/core/onErrorHook.test.ts +0 -350
- package/src/core/onErrorHook.ts +0 -52
- package/src/core/promiseCache.test.ts +0 -241
- package/src/core/promiseCache.ts +0 -284
- package/src/core/scheduleNotifyHook.ts +0 -53
- package/src/core/select.ts +0 -729
- package/src/core/selector.test.ts +0 -799
- package/src/core/types.ts +0 -389
- package/src/core/withReady.test.ts +0 -534
- package/src/core/withReady.ts +0 -191
- package/src/core/withUse.test.ts +0 -249
- package/src/core/withUse.ts +0 -56
- package/src/index.test.ts +0 -80
- package/src/index.ts +0 -65
- package/src/react/index.ts +0 -21
- package/src/react/rx.test.tsx +0 -571
- package/src/react/rx.tsx +0 -531
- package/src/react/strictModeTest.tsx +0 -71
- package/src/react/useAction.test.ts +0 -987
- package/src/react/useAction.ts +0 -607
- package/src/react/useSelector.test.ts +0 -182
- package/src/react/useSelector.ts +0 -292
- package/src/react/useStable.test.ts +0 -553
- package/src/react/useStable.ts +0 -288
- package/tsconfig.json +0 -9
- package/v2.md +0 -725
- package/vite.config.ts +0 -42
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-BZEnfIcB.cjs"),o=require("./onErrorHook-DHBASmYw.cjs");exports.AllAtomsRejectedError=e.AllAtomsRejectedError;exports.atom=e.atom;exports.batch=e.batch;exports.define=e.define;exports.derived=e.derived;exports.effect=e.effect;exports.emitter=e.emitter;exports.getAtomState=e.getAtomState;exports.isAtom=e.isAtom;exports.isDerived=e.isDerived;exports.isFulfilled=e.isFulfilled;exports.isPending=e.isPending;exports.isPool=e.isPool;exports.isRejected=e.isRejected;exports.isScopedAtom=e.isScopedAtom;exports.pool=e.pool;exports.promisesEqual=e.promisesEqual;exports.readonly=e.readonly;exports.select=e.select;exports.trackPromise=e.trackPromise;exports.unwrap=e.unwrap;exports.onCreateHook=o.onCreateHook;exports.onErrorHook=o.onErrorHook;
|
package/dist/index.d.ts
CHANGED
|
@@ -5,14 +5,15 @@ export { derived, type DerivedContext } from './core/derived';
|
|
|
5
5
|
export { effect, type EffectContext } from './core/effect';
|
|
6
6
|
export { emitter } from './core/emitter';
|
|
7
7
|
export { isAtom, isDerived } from './core/isAtom';
|
|
8
|
-
export {
|
|
8
|
+
export { pool, isPool } from './core/pool';
|
|
9
|
+
export { select, AllAtomsRejectedError, isScopedAtom, type Condition, } from './core/select';
|
|
9
10
|
export { getAtomState } from './core/getAtomState';
|
|
10
11
|
export { isPending, isFulfilled, isRejected, trackPromise, unwrap, } from './core/promiseCache';
|
|
11
|
-
export type { Atom, AtomMeta, AtomOptions, AtomState, AtomValue, AnyAtom, DerivedAtom, DerivedAtomMeta, DerivedOptions, EffectOptions, Equality, EqualityShorthand, Getter, KeyedResult, MutableAtom, MutableAtomMeta, Pipeable, SelectStateResult, SettledResult, } from './core/types';
|
|
12
|
+
export type { Atom, AtomMeta, AtomOptions, AtomState, AtomValue, AnyAtom, DerivedAtom, DerivedAtomMeta, DerivedOptions, EffectOptions, Equality, EqualityShorthand, Getter, KeyedResult, MutableAtom, MutableAtomMeta, Pipeable, Pool, PoolEvent, PoolMeta, PoolOptions, SelectStateResult, SettledResult, ScopedAtom, } from './core/types';
|
|
12
13
|
export { onCreateHook } from './core/onCreateHook';
|
|
13
14
|
export type { CreateInfo, MutableInfo, DerivedInfo, EffectInfo, ModuleInfo, } from './core/onCreateHook';
|
|
14
15
|
export { onErrorHook } from './core/onErrorHook';
|
|
15
16
|
export type { ErrorInfo } from './core/onErrorHook';
|
|
16
|
-
export type { SelectContext, SelectResult, ReactiveSelector as ContextSelectorFn, SafeResult, } from './core/select';
|
|
17
|
+
export type { SelectContext, SelectOutput, SelectResult, ReactiveSelector as ContextSelectorFn, SafeResult, } from './core/select';
|
|
17
18
|
export type { PromiseState, CombinedPromiseMeta } from './core/promiseCache';
|
|
18
19
|
export { promisesEqual } from './core/promiseCache';
|
package/dist/index.js
CHANGED
|
@@ -1,23 +1,27 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as e, c as o, f as r, g as t, h as i, j as l, k as m, o as d, i as c, l as n, u as f, q as p, m as A, v as k, n as u, p as g, z as j, e as v, s as x, x as E, y as P } from "./index-BbPZhsDl.js";
|
|
2
|
+
import { o as q, a as y } from "./onErrorHook-BGGy3tqK.js";
|
|
2
3
|
export {
|
|
3
|
-
|
|
4
|
+
e as AllAtomsRejectedError,
|
|
4
5
|
o as atom,
|
|
5
6
|
r as batch,
|
|
6
7
|
t as define,
|
|
7
8
|
i as derived,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
l as effect,
|
|
10
|
+
m as emitter,
|
|
11
|
+
d as getAtomState,
|
|
12
|
+
c as isAtom,
|
|
13
|
+
n as isDerived,
|
|
13
14
|
f as isFulfilled,
|
|
14
|
-
|
|
15
|
+
p as isPending,
|
|
16
|
+
A as isPool,
|
|
15
17
|
k as isRejected,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
u as isScopedAtom,
|
|
19
|
+
q as onCreateHook,
|
|
20
|
+
y as onErrorHook,
|
|
21
|
+
g as pool,
|
|
22
|
+
j as promisesEqual,
|
|
23
|
+
v as readonly,
|
|
24
|
+
x as select,
|
|
21
25
|
E as trackPromise,
|
|
22
|
-
|
|
26
|
+
P as unwrap
|
|
23
27
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const o=require("./onErrorHook-DHBASmYw.cjs"),r=o.hook();exports.onDispatchHook=r;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
function s(t) {
|
|
2
|
+
const r = Object.assign(
|
|
3
|
+
(e) => () => {
|
|
4
|
+
const o = r.current;
|
|
5
|
+
return r.current = e(o), () => {
|
|
6
|
+
r.current = o;
|
|
7
|
+
};
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
current: t,
|
|
11
|
+
// Override method for direct mutation using reducer
|
|
12
|
+
override: (e) => {
|
|
13
|
+
r.current = e(r.current);
|
|
14
|
+
},
|
|
15
|
+
reset: () => {
|
|
16
|
+
r.current = t;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
return r;
|
|
21
|
+
}
|
|
22
|
+
function c(t, r) {
|
|
23
|
+
const e = [];
|
|
24
|
+
for (const o of t)
|
|
25
|
+
e.push(o());
|
|
26
|
+
try {
|
|
27
|
+
return r();
|
|
28
|
+
} finally {
|
|
29
|
+
for (const o of e.reverse())
|
|
30
|
+
o();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const n = Object.assign(s, { use: c }), u = n(), a = n();
|
|
34
|
+
export {
|
|
35
|
+
a,
|
|
36
|
+
n as h,
|
|
37
|
+
u as o
|
|
38
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function s(t){const r=Object.assign(e=>()=>{const o=r.current;return r.current=e(o),()=>{r.current=o}},{current:t,override:e=>{r.current=e(r.current)},reset:()=>{r.current=t}});return r}function c(t,r){const e=[];for(const o of t)e.push(o());try{return r()}finally{for(const o of e.reverse())o()}}const n=Object.assign(s,{use:c}),u=n(),a=n();exports.hook=n;exports.onCreateHook=u;exports.onErrorHook=a;
|
package/dist/react/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var F=Object.defineProperty;var z=(r,e,n)=>e in r?F(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n;var w=(r,e,n)=>z(r,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react"),t=require("../index-BZEnfIcB.cjs"),y=require("../onDispatchHook-C8yLzr-o.cjs"),d=require("react/jsx-runtime"),H=require("../onErrorHook-DHBASmYw.cjs");function C(r,e){const n=t.isAtom(r)?({read:p})=>p(r):r,m=t.resolveEquality(e??"shallow"),s=o.useRef(n),R=o.useRef(m);s.current=n,R.current=m;const a=o.useRef(new Map),u=o.useRef(new Set),c=o.useRef([]),b=o.useRef(new Map),l=o.useRef({value:void 0,initialized:!1}),A=o.useCallback(()=>{const{result:p}=t.select(s.current);if(u.current=p._atomDeps,b.current=p._poolDeps,p.promise!==void 0)throw p.promise;if(p.error!==void 0)throw p.error;const E=p.value;return(!l.current.initialized||!R.current(E,l.current.value))&&(l.current={value:E,initialized:!0}),l.current.value},[]),k=o.useCallback(p=>{const E=a.current,g=()=>{const{result:f}=t.select(s.current);u.current=f._atomDeps,b.current=f._poolDeps,i(),p()},i=()=>{const f=u.current,v=b.current;for(const[h,D]of E)f.has(h)||(D(),E.delete(h));for(const h of f)E.has(h)||E.set(h,h.on(g));for(const h of c.current)h();c.current=[];for(const[h,D]of v)for(const x of D)c.current.push(h._onRemove(x,g))};return i(),()=>{for(const f of E.values())f();E.clear();for(const f of c.current)f();c.current=[]}},[]);return o.useSyncExternalStore(k,A,A)}function _(r){return r==null?Object.is:Array.isArray(r)?"shallow":r instanceof Date?t.deepEqual:typeof r=="object"?t.shallowEqual:Object.is}function I(r,e){const n=o.useRef({}),m=o.useRef(null);m.current===null&&(m.current={});const s=n.current,R=m.current;for(const a of Object.keys(r)){const u=r[a],c=s[a];if(typeof u=="function"){const[k]=t.tryStabilize(c,u,()=>!1);s[a]={value:k},R[a]=k;continue}const b=e==null?void 0:e[a],l=b?t.resolveEquality(b):t.resolveEquality(_(u)),[A]=t.tryStabilize(c,u,l);s[a]={value:A},R[a]=A}for(const a of Object.keys(s))a in r||(delete s[a],delete R[a]);return R}const P={status:"idle",result:void 0,error:void 0},T={status:"loading",result:void 0,error:void 0};function L(r,e){switch(e.type){case"START":return T;case"SUCCESS":return{status:"success",result:e.result,error:void 0};case"ERROR":return{status:"error",result:void 0,error:e.error};case"RESET":return P;default:return r}}function M(r,e={}){const{lazy:n=!0,exclusive:m=!0,deps:s=[]}=e,R=n?P:T,[a,u]=o.useReducer(L,R),c=o.useRef(null),b=o.useRef(r);b.current=r;const l=o.useCallback(()=>{const i=c.current;return i?(i.abort(),c.current=null,!0):!1},[]),A=(n?[]:s??[]).filter(t.isAtom),k=C(({read:i})=>A.map(f=>i(f))),p=o.useCallback(()=>{var v,h,D,x,q,O;m&&l();const i=new AbortController;c.current=i,u({type:"START"}),(h=(v=y.onDispatchHook).current)==null||h.call(v,{type:"start",meta:e.meta,deps:s});let f;try{f=b.current(t.withUse({signal:i.signal}))}catch(j){return u({type:"ERROR",error:j}),(x=(D=y.onDispatchHook).current)==null||x.call(D,{type:"error",meta:e.meta,deps:s,error:j}),Object.assign(Promise.reject(j),{abort:()=>i.abort()})}if(t.isPromiseLike(f)){const j=f;return(O=(q=y.onDispatchHook).current)==null||O.call(q,{type:"loading",meta:e.meta,deps:s}),j.then(S=>{c.current===i&&(u({type:"SUCCESS",result:S}),y.onDispatchHook.current&&y.onDispatchHook.current({type:"resolved",meta:e.meta,deps:s}))},S=>{if(S instanceof DOMException&&S.name==="AbortError"){(c.current===null||c.current===i)&&(u({type:"ERROR",error:S}),y.onDispatchHook.current&&y.onDispatchHook.current({type:"abort",meta:e.meta,deps:s,error:S}));return}c.current===i&&(u({type:"ERROR",error:S}),y.onDispatchHook.current&&y.onDispatchHook.current({type:"rejected",meta:e.meta,deps:s,error:S}))}),Object.assign(j,{abort:()=>{i.abort(),c.current===i&&(c.current=null)}})}else y.onDispatchHook.current&&y.onDispatchHook.current({type:"success",meta:e.meta,deps:s});return u({type:"SUCCESS",result:f}),Object.assign(Promise.resolve(f),{abort:()=>i.abort()})},[m,l]),E=(s??[]).filter(i=>!t.isAtom(i));o.useEffect(()=>{n||p()},[n,...k,...E]),o.useEffect(()=>()=>{m&&l()},[m,l]);const g=o.useCallback(()=>{m&&l(),u({type:"RESET"})},[m,l]);return Object.assign(p,{...a,abort:l,reset:g})}function U(r,e){const n=e===void 0?void 0:typeof e=="object"&&e!==null&&!Array.isArray(e)&&("equals"in e||"loading"in e||"error"in e)?e:{equals:e};return d.jsx(J,{selectorOrAtom:r,options:n})}class V extends o.Component{constructor(){super(...arguments);w(this,"state",{error:null})}static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n,m){}render(){if(this.state.error!==null&&this.props.onError)return d.jsx(d.Fragment,{children:this.props.onError({error:this.state.error})});if(this.state.error!==null)throw this.state.error;return this.props.children}}function W(r){const e=C(r.selector,r.equals);return d.jsx(d.Fragment,{children:e??null})}function B(r){return d.jsx(d.Fragment,{children:r.render()})}function G(r){return r.fallback?d.jsx(o.Suspense,{fallback:d.jsx(B,{render:r.fallback}),children:r.children}):d.jsx(d.Fragment,{children:r.children})}function N(r){return r.onError?d.jsx(V,{onError:r.onError,children:r.children}):d.jsx(d.Fragment,{children:r.children})}const J=o.memo(function(e){var u,c,b,l;const n=o.useRef(e.selectorOrAtom);n.current=e.selectorOrAtom;const m=t.isAtom(e.selectorOrAtom),s=(u=e.options)==null?void 0:u.deps,R=m?[e.selectorOrAtom,...s??[]]:s??[{}],a=o.useCallback(A=>t.isAtom(n.current)?A.read(n.current):n.current(A),R);return d.jsx(N,{onError:(c=e.options)==null?void 0:c.error,children:d.jsx(G,{fallback:(b=e.options)==null?void 0:b.loading,children:d.jsx(W,{selector:a,equals:(l=e.options)==null?void 0:l.equals})})})},(r,e)=>t.shallowEqual(r.selectorOrAtom,e.selectorOrAtom)&&t.shallowEqual(r.options,e.options));exports.AllAtomsRejectedError=t.AllAtomsRejectedError;exports.atom=t.atom;exports.batch=t.batch;exports.define=t.define;exports.derived=t.derived;exports.effect=t.effect;exports.emitter=t.emitter;exports.getAtomState=t.getAtomState;exports.isAtom=t.isAtom;exports.isDerived=t.isDerived;exports.isFulfilled=t.isFulfilled;exports.isPending=t.isPending;exports.isPool=t.isPool;exports.isRejected=t.isRejected;exports.isScopedAtom=t.isScopedAtom;exports.pool=t.pool;exports.promisesEqual=t.promisesEqual;exports.readonly=t.readonly;exports.select=t.select;exports.trackPromise=t.trackPromise;exports.unwrap=t.unwrap;exports.onCreateHook=H.onCreateHook;exports.onErrorHook=H.onErrorHook;exports.rx=U;exports.useAction=M;exports.useSelector=C;exports.useStable=I;
|
package/dist/react/index.js
CHANGED
|
@@ -1,89 +1,97 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { useRef as
|
|
5
|
-
import { i as
|
|
6
|
-
import { A as
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
1
|
+
var M = Object.defineProperty;
|
|
2
|
+
var V = (r, e, t) => e in r ? M(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
|
+
var _ = (r, e, t) => V(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { useRef as p, useCallback as D, useSyncExternalStore as W, useReducer as B, useEffect as P, memo as G, Suspense as N, Component as J } from "react";
|
|
5
|
+
import { i as O, r as w, s as F, t as I, d as K, a as q, w as Q, b as X } from "../index-BbPZhsDl.js";
|
|
6
|
+
import { A as he, c as Re, f as Ee, g as ye, h as Se, j as Ae, k as ve, o as ge, l as De, u as Oe, q as je, m as ke, v as xe, n as Ce, p as we, z as qe, e as Te, x as ze, y as _e } from "../index-BbPZhsDl.js";
|
|
7
|
+
import { o as E } from "../onDispatchHook-SKbiIUaJ.js";
|
|
8
|
+
import { jsx as b, Fragment as j } from "react/jsx-runtime";
|
|
9
|
+
import { o as Fe, a as Ie } from "../onErrorHook-BGGy3tqK.js";
|
|
10
|
+
function L(r, e) {
|
|
11
|
+
const t = O(r) ? ({ read: f }) => f(r) : r, l = w(e ?? "shallow"), n = p(t), h = p(l);
|
|
12
|
+
n.current = t, h.current = l;
|
|
13
|
+
const u = p(/* @__PURE__ */ new Map()), s = p(/* @__PURE__ */ new Set()), o = p([]), m = p(/* @__PURE__ */ new Map()), a = p({
|
|
12
14
|
value: void 0,
|
|
13
15
|
initialized: !1
|
|
14
|
-
}),
|
|
15
|
-
const
|
|
16
|
-
if (
|
|
17
|
-
throw
|
|
18
|
-
if (
|
|
19
|
-
throw
|
|
20
|
-
const
|
|
21
|
-
return (!
|
|
22
|
-
}, []),
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
16
|
+
}), y = D(() => {
|
|
17
|
+
const { result: f } = F(n.current);
|
|
18
|
+
if (s.current = f._atomDeps, m.current = f._poolDeps, f.promise !== void 0)
|
|
19
|
+
throw f.promise;
|
|
20
|
+
if (f.error !== void 0)
|
|
21
|
+
throw f.error;
|
|
22
|
+
const R = f.value;
|
|
23
|
+
return (!a.current.initialized || !h.current(R, a.current.value)) && (a.current = { value: R, initialized: !0 }), a.current.value;
|
|
24
|
+
}, []), A = D((f) => {
|
|
25
|
+
const R = u.current, k = () => {
|
|
26
|
+
const { result: i } = F(n.current);
|
|
27
|
+
s.current = i._atomDeps, m.current = i._poolDeps, c(), f();
|
|
28
|
+
}, c = () => {
|
|
29
|
+
const i = s.current, x = m.current;
|
|
30
|
+
for (const [d, v] of R)
|
|
31
|
+
i.has(d) || (v(), R.delete(d));
|
|
32
|
+
for (const d of i)
|
|
33
|
+
R.has(d) || R.set(d, d.on(k));
|
|
34
|
+
for (const d of o.current)
|
|
35
|
+
d();
|
|
36
|
+
o.current = [];
|
|
37
|
+
for (const [d, v] of x)
|
|
38
|
+
for (const C of v)
|
|
39
|
+
o.current.push(d._onRemove(C, k));
|
|
35
40
|
};
|
|
36
|
-
return
|
|
37
|
-
for (const
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
return c(), () => {
|
|
42
|
+
for (const i of R.values())
|
|
43
|
+
i();
|
|
44
|
+
R.clear();
|
|
45
|
+
for (const i of o.current)
|
|
46
|
+
i();
|
|
47
|
+
o.current = [];
|
|
40
48
|
};
|
|
41
49
|
}, []);
|
|
42
|
-
return
|
|
50
|
+
return W(A, y, y);
|
|
43
51
|
}
|
|
44
|
-
function
|
|
45
|
-
return r == null ?
|
|
52
|
+
function Y(r) {
|
|
53
|
+
return r == null ? Object.is : Array.isArray(r) ? "shallow" : r instanceof Date ? K : typeof r == "object" ? q : Object.is;
|
|
46
54
|
}
|
|
47
|
-
function
|
|
48
|
-
const t =
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
for (const
|
|
52
|
-
const
|
|
53
|
-
if (typeof
|
|
54
|
-
const [
|
|
55
|
-
n,
|
|
55
|
+
function fe(r, e) {
|
|
56
|
+
const t = p({}), l = p(null);
|
|
57
|
+
l.current === null && (l.current = {});
|
|
58
|
+
const n = t.current, h = l.current;
|
|
59
|
+
for (const u of Object.keys(r)) {
|
|
60
|
+
const s = r[u], o = n[u];
|
|
61
|
+
if (typeof s == "function") {
|
|
62
|
+
const [A] = I(
|
|
56
63
|
o,
|
|
64
|
+
s,
|
|
57
65
|
() => !1
|
|
58
66
|
// Equality doesn't matter for functions
|
|
59
67
|
);
|
|
60
|
-
|
|
68
|
+
n[u] = { value: A }, h[u] = A;
|
|
61
69
|
continue;
|
|
62
70
|
}
|
|
63
|
-
const
|
|
64
|
-
n,
|
|
71
|
+
const m = e == null ? void 0 : e[u], a = m ? w(m) : w(Y(s)), [y] = I(
|
|
65
72
|
o,
|
|
66
|
-
|
|
73
|
+
s,
|
|
74
|
+
a
|
|
67
75
|
);
|
|
68
|
-
|
|
76
|
+
n[u] = { value: y }, h[u] = y;
|
|
69
77
|
}
|
|
70
|
-
for (const
|
|
71
|
-
|
|
72
|
-
return
|
|
78
|
+
for (const u of Object.keys(n))
|
|
79
|
+
u in r || (delete n[u], delete h[u]);
|
|
80
|
+
return h;
|
|
73
81
|
}
|
|
74
|
-
const
|
|
82
|
+
const U = {
|
|
75
83
|
status: "idle",
|
|
76
84
|
result: void 0,
|
|
77
85
|
error: void 0
|
|
78
|
-
},
|
|
86
|
+
}, H = {
|
|
79
87
|
status: "loading",
|
|
80
88
|
result: void 0,
|
|
81
89
|
error: void 0
|
|
82
90
|
};
|
|
83
|
-
function
|
|
91
|
+
function Z(r, e) {
|
|
84
92
|
switch (e.type) {
|
|
85
93
|
case "START":
|
|
86
|
-
return
|
|
94
|
+
return H;
|
|
87
95
|
case "SUCCESS":
|
|
88
96
|
return {
|
|
89
97
|
status: "success",
|
|
@@ -97,147 +105,179 @@ function B(r, e) {
|
|
|
97
105
|
error: e.error
|
|
98
106
|
};
|
|
99
107
|
case "RESET":
|
|
100
|
-
return
|
|
108
|
+
return U;
|
|
101
109
|
default:
|
|
102
110
|
return r;
|
|
103
111
|
}
|
|
104
112
|
}
|
|
105
|
-
function
|
|
106
|
-
const { lazy: t = !0, exclusive:
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
),
|
|
110
|
-
|
|
111
|
-
const
|
|
112
|
-
const
|
|
113
|
-
return
|
|
114
|
-
}, []),
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
113
|
+
function de(r, e = {}) {
|
|
114
|
+
const { lazy: t = !0, exclusive: l = !0, deps: n = [] } = e, h = t ? U : H, [u, s] = B(
|
|
115
|
+
Z,
|
|
116
|
+
h
|
|
117
|
+
), o = p(null), m = p(r);
|
|
118
|
+
m.current = r;
|
|
119
|
+
const a = D(() => {
|
|
120
|
+
const c = o.current;
|
|
121
|
+
return c ? (c.abort(), o.current = null, !0) : !1;
|
|
122
|
+
}, []), y = (t ? [] : n ?? []).filter(O), A = L(({ read: c }) => y.map((i) => c(i))), f = D(() => {
|
|
123
|
+
var x, d, v, C, T, z;
|
|
124
|
+
l && a();
|
|
125
|
+
const c = new AbortController();
|
|
126
|
+
o.current = c, s({ type: "START" }), (d = (x = E).current) == null || d.call(x, { type: "start", meta: e.meta, deps: n });
|
|
127
|
+
let i;
|
|
119
128
|
try {
|
|
120
|
-
|
|
121
|
-
} catch (
|
|
122
|
-
return
|
|
123
|
-
|
|
129
|
+
i = m.current(Q({ signal: c.signal }));
|
|
130
|
+
} catch (g) {
|
|
131
|
+
return s({ type: "ERROR", error: g }), (C = (v = E).current) == null || C.call(v, {
|
|
132
|
+
type: "error",
|
|
133
|
+
meta: e.meta,
|
|
134
|
+
deps: n,
|
|
135
|
+
error: g
|
|
136
|
+
}), Object.assign(Promise.reject(g), {
|
|
137
|
+
abort: () => c.abort()
|
|
124
138
|
});
|
|
125
139
|
}
|
|
126
|
-
if (
|
|
127
|
-
const
|
|
128
|
-
return
|
|
140
|
+
if (X(i)) {
|
|
141
|
+
const g = i;
|
|
142
|
+
return (z = (T = E).current) == null || z.call(T, {
|
|
143
|
+
type: "loading",
|
|
144
|
+
meta: e.meta,
|
|
145
|
+
deps: n
|
|
146
|
+
}), g.then(
|
|
129
147
|
(S) => {
|
|
130
|
-
|
|
148
|
+
o.current === c && (s({ type: "SUCCESS", result: S }), E.current && E.current({
|
|
149
|
+
type: "resolved",
|
|
150
|
+
meta: e.meta,
|
|
151
|
+
deps: n
|
|
152
|
+
}));
|
|
131
153
|
},
|
|
132
154
|
(S) => {
|
|
133
155
|
if (S instanceof DOMException && S.name === "AbortError") {
|
|
134
|
-
(
|
|
156
|
+
(o.current === null || o.current === c) && (s({ type: "ERROR", error: S }), E.current && E.current({
|
|
157
|
+
type: "abort",
|
|
158
|
+
meta: e.meta,
|
|
159
|
+
deps: n,
|
|
160
|
+
error: S
|
|
161
|
+
}));
|
|
135
162
|
return;
|
|
136
163
|
}
|
|
137
|
-
|
|
164
|
+
o.current === c && (s({ type: "ERROR", error: S }), E.current && E.current({
|
|
165
|
+
type: "rejected",
|
|
166
|
+
meta: e.meta,
|
|
167
|
+
deps: n,
|
|
168
|
+
error: S
|
|
169
|
+
}));
|
|
138
170
|
}
|
|
139
|
-
), Object.assign(
|
|
171
|
+
), Object.assign(g, {
|
|
140
172
|
abort: () => {
|
|
141
|
-
|
|
173
|
+
c.abort(), o.current === c && (o.current = null);
|
|
142
174
|
}
|
|
143
175
|
});
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
|
|
176
|
+
} else
|
|
177
|
+
E.current && E.current({
|
|
178
|
+
type: "success",
|
|
179
|
+
meta: e.meta,
|
|
180
|
+
deps: n
|
|
181
|
+
});
|
|
182
|
+
return s({ type: "SUCCESS", result: i }), Object.assign(Promise.resolve(i), {
|
|
183
|
+
abort: () => c.abort()
|
|
147
184
|
});
|
|
148
|
-
}, [
|
|
149
|
-
|
|
150
|
-
t ||
|
|
151
|
-
}, [t, ...
|
|
152
|
-
|
|
153
|
-
}, [
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
}, [
|
|
157
|
-
return Object.assign(
|
|
158
|
-
...
|
|
159
|
-
abort:
|
|
160
|
-
reset:
|
|
185
|
+
}, [l, a]), R = (n ?? []).filter((c) => !O(c));
|
|
186
|
+
P(() => {
|
|
187
|
+
t || f();
|
|
188
|
+
}, [t, ...A, ...R]), P(() => () => {
|
|
189
|
+
l && a();
|
|
190
|
+
}, [l, a]);
|
|
191
|
+
const k = D(() => {
|
|
192
|
+
l && a(), s({ type: "RESET" });
|
|
193
|
+
}, [l, a]);
|
|
194
|
+
return Object.assign(f, {
|
|
195
|
+
...u,
|
|
196
|
+
abort: a,
|
|
197
|
+
reset: k
|
|
161
198
|
});
|
|
162
199
|
}
|
|
163
|
-
function
|
|
200
|
+
function me(r, e) {
|
|
164
201
|
const t = e === void 0 ? void 0 : typeof e == "object" && e !== null && !Array.isArray(e) && ("equals" in e || "loading" in e || "error" in e) ? e : { equals: e };
|
|
165
|
-
return /* @__PURE__ */
|
|
166
|
-
|
|
202
|
+
return /* @__PURE__ */ b(
|
|
203
|
+
oe,
|
|
167
204
|
{
|
|
168
205
|
selectorOrAtom: r,
|
|
169
206
|
options: t
|
|
170
207
|
}
|
|
171
208
|
);
|
|
172
209
|
}
|
|
173
|
-
class
|
|
210
|
+
class $ extends J {
|
|
174
211
|
constructor() {
|
|
175
212
|
super(...arguments);
|
|
176
|
-
|
|
213
|
+
_(this, "state", { error: null });
|
|
177
214
|
}
|
|
178
215
|
static getDerivedStateFromError(t) {
|
|
179
216
|
return { error: t };
|
|
180
217
|
}
|
|
181
218
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
182
|
-
componentDidCatch(t,
|
|
219
|
+
componentDidCatch(t, l) {
|
|
183
220
|
}
|
|
184
221
|
render() {
|
|
185
222
|
if (this.state.error !== null && this.props.onError)
|
|
186
|
-
return /* @__PURE__ */
|
|
223
|
+
return /* @__PURE__ */ b(j, { children: this.props.onError({ error: this.state.error }) });
|
|
187
224
|
if (this.state.error !== null)
|
|
188
225
|
throw this.state.error;
|
|
189
226
|
return this.props.children;
|
|
190
227
|
}
|
|
191
228
|
}
|
|
192
|
-
function
|
|
193
|
-
const e =
|
|
194
|
-
return /* @__PURE__ */
|
|
229
|
+
function ee(r) {
|
|
230
|
+
const e = L(r.selector, r.equals);
|
|
231
|
+
return /* @__PURE__ */ b(j, { children: e ?? null });
|
|
195
232
|
}
|
|
196
|
-
function
|
|
197
|
-
return /* @__PURE__ */
|
|
233
|
+
function re(r) {
|
|
234
|
+
return /* @__PURE__ */ b(j, { children: r.render() });
|
|
198
235
|
}
|
|
199
|
-
function
|
|
200
|
-
return r.fallback ? /* @__PURE__ */
|
|
236
|
+
function te(r) {
|
|
237
|
+
return r.fallback ? /* @__PURE__ */ b(N, { fallback: /* @__PURE__ */ b(re, { render: r.fallback }), children: r.children }) : /* @__PURE__ */ b(j, { children: r.children });
|
|
201
238
|
}
|
|
202
|
-
function
|
|
203
|
-
return r.onError ? /* @__PURE__ */
|
|
239
|
+
function ne(r) {
|
|
240
|
+
return r.onError ? /* @__PURE__ */ b($, { onError: r.onError, children: r.children }) : /* @__PURE__ */ b(j, { children: r.children });
|
|
204
241
|
}
|
|
205
|
-
const
|
|
242
|
+
const oe = G(
|
|
206
243
|
function(e) {
|
|
207
|
-
var
|
|
208
|
-
const t =
|
|
244
|
+
var s, o, m, a;
|
|
245
|
+
const t = p(e.selectorOrAtom);
|
|
209
246
|
t.current = e.selectorOrAtom;
|
|
210
|
-
const
|
|
211
|
-
(
|
|
212
|
-
|
|
247
|
+
const l = O(e.selectorOrAtom), n = (s = e.options) == null ? void 0 : s.deps, h = l ? [e.selectorOrAtom, ...n ?? []] : n ?? [{}], u = D(
|
|
248
|
+
(y) => O(t.current) ? y.read(t.current) : t.current(y),
|
|
249
|
+
h
|
|
213
250
|
);
|
|
214
|
-
return /* @__PURE__ */
|
|
251
|
+
return /* @__PURE__ */ b(ne, { onError: (o = e.options) == null ? void 0 : o.error, children: /* @__PURE__ */ b(te, { fallback: (m = e.options) == null ? void 0 : m.loading, children: /* @__PURE__ */ b(ee, { selector: u, equals: (a = e.options) == null ? void 0 : a.equals }) }) });
|
|
215
252
|
},
|
|
216
|
-
(r, e) =>
|
|
253
|
+
(r, e) => q(r.selectorOrAtom, e.selectorOrAtom) && q(r.options, e.options)
|
|
217
254
|
);
|
|
218
255
|
export {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
256
|
+
he as AllAtomsRejectedError,
|
|
257
|
+
Re as atom,
|
|
258
|
+
Ee as batch,
|
|
259
|
+
ye as define,
|
|
260
|
+
Se as derived,
|
|
261
|
+
Ae as effect,
|
|
262
|
+
ve as emitter,
|
|
263
|
+
ge as getAtomState,
|
|
264
|
+
O as isAtom,
|
|
265
|
+
De as isDerived,
|
|
266
|
+
Oe as isFulfilled,
|
|
267
|
+
je as isPending,
|
|
268
|
+
ke as isPool,
|
|
269
|
+
xe as isRejected,
|
|
270
|
+
Ce as isScopedAtom,
|
|
271
|
+
Fe as onCreateHook,
|
|
272
|
+
Ie as onErrorHook,
|
|
273
|
+
we as pool,
|
|
274
|
+
qe as promisesEqual,
|
|
275
|
+
Te as readonly,
|
|
276
|
+
me as rx,
|
|
277
|
+
F as select,
|
|
278
|
+
ze as trackPromise,
|
|
279
|
+
_e as unwrap,
|
|
280
|
+
de as useAction,
|
|
281
|
+
L as useSelector,
|
|
282
|
+
fe as useStable
|
|
243
283
|
};
|