@depup/jotai 2.18.0-depup.0

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.
Files changed (215) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +25 -0
  3. package/babel/plugin-debug-label.d.ts +5 -0
  4. package/babel/plugin-debug-label.js +54 -0
  5. package/babel/plugin-react-refresh.d.ts +5 -0
  6. package/babel/plugin-react-refresh.js +72 -0
  7. package/babel/preset.d.ts +6 -0
  8. package/babel/preset.js +110 -0
  9. package/babel/utils.d.ts +5 -0
  10. package/benchmarks/simple-read.d.ts +2 -0
  11. package/benchmarks/simple-write.d.ts +2 -0
  12. package/benchmarks/subscribe-write.d.ts +2 -0
  13. package/changes.json +5 -0
  14. package/esm/babel/plugin-debug-label.d.mts +5 -0
  15. package/esm/babel/plugin-debug-label.mjs +103 -0
  16. package/esm/babel/plugin-react-refresh.d.mts +5 -0
  17. package/esm/babel/plugin-react-refresh.mjs +121 -0
  18. package/esm/babel/preset.d.mts +6 -0
  19. package/esm/babel/preset.mjs +179 -0
  20. package/esm/babel/utils.d.mts +5 -0
  21. package/esm/index.d.mts +2 -0
  22. package/esm/index.mjs +2 -0
  23. package/esm/react/Provider.d.mts +16 -0
  24. package/esm/react/useAtom.d.mts +13 -0
  25. package/esm/react/useAtomValue.d.mts +9 -0
  26. package/esm/react/useSetAtom.d.mts +7 -0
  27. package/esm/react/utils/useAtomCallback.d.mts +5 -0
  28. package/esm/react/utils/useHydrateAtoms.d.mts +14 -0
  29. package/esm/react/utils/useReducerAtom.d.mts +14 -0
  30. package/esm/react/utils/useResetAtom.d.mts +6 -0
  31. package/esm/react/utils.d.mts +4 -0
  32. package/esm/react/utils.mjs +57 -0
  33. package/esm/react.d.mts +4 -0
  34. package/esm/react.mjs +182 -0
  35. package/esm/utils.d.mts +2 -0
  36. package/esm/utils.mjs +2 -0
  37. package/esm/vanilla/atom.d.mts +47 -0
  38. package/esm/vanilla/internals.d.mts +164 -0
  39. package/esm/vanilla/internals.mjs +715 -0
  40. package/esm/vanilla/store.d.mts +5 -0
  41. package/esm/vanilla/typeUtils.d.mts +7 -0
  42. package/esm/vanilla/utils/atomFamily.d.mts +55 -0
  43. package/esm/vanilla/utils/atomWithDefault.d.mts +6 -0
  44. package/esm/vanilla/utils/atomWithLazy.d.mts +2 -0
  45. package/esm/vanilla/utils/atomWithObservable.d.mts +32 -0
  46. package/esm/vanilla/utils/atomWithReducer.d.mts +3 -0
  47. package/esm/vanilla/utils/atomWithRefresh.d.mts +6 -0
  48. package/esm/vanilla/utils/atomWithReset.d.mts +8 -0
  49. package/esm/vanilla/utils/atomWithStorage.d.mts +50 -0
  50. package/esm/vanilla/utils/constants.d.mts +1 -0
  51. package/esm/vanilla/utils/freezeAtom.d.mts +6 -0
  52. package/esm/vanilla/utils/loadable.d.mts +33 -0
  53. package/esm/vanilla/utils/selectAtom.d.mts +2 -0
  54. package/esm/vanilla/utils/splitAtom.d.mts +16 -0
  55. package/esm/vanilla/utils/unwrap.d.mts +5 -0
  56. package/esm/vanilla/utils.d.mts +14 -0
  57. package/esm/vanilla/utils.mjs +736 -0
  58. package/esm/vanilla.d.mts +4 -0
  59. package/esm/vanilla.mjs +59 -0
  60. package/index.d.ts +2 -0
  61. package/index.js +19 -0
  62. package/package.json +125 -0
  63. package/react/Provider.d.ts +16 -0
  64. package/react/useAtom.d.ts +13 -0
  65. package/react/useAtomValue.d.ts +9 -0
  66. package/react/useSetAtom.d.ts +7 -0
  67. package/react/utils/useAtomCallback.d.ts +5 -0
  68. package/react/utils/useHydrateAtoms.d.ts +14 -0
  69. package/react/utils/useReducerAtom.d.ts +14 -0
  70. package/react/utils/useResetAtom.d.ts +6 -0
  71. package/react/utils.d.ts +4 -0
  72. package/react/utils.js +100 -0
  73. package/react.d.ts +4 -0
  74. package/react.js +182 -0
  75. package/system/babel/plugin-debug-label.development.js +113 -0
  76. package/system/babel/plugin-debug-label.production.js +4 -0
  77. package/system/babel/plugin-react-refresh.development.js +131 -0
  78. package/system/babel/plugin-react-refresh.production.js +11 -0
  79. package/system/babel/preset.development.js +189 -0
  80. package/system/babel/preset.production.js +14 -0
  81. package/system/index.development.js +27 -0
  82. package/system/index.production.js +1 -0
  83. package/system/react/utils.development.js +79 -0
  84. package/system/react/utils.production.js +2 -0
  85. package/system/react.development.js +210 -0
  86. package/system/react.production.js +2 -0
  87. package/system/utils.development.js +27 -0
  88. package/system/utils.production.js +1 -0
  89. package/system/vanilla/internals.development.js +735 -0
  90. package/system/vanilla/internals.production.js +1 -0
  91. package/system/vanilla/utils.development.js +764 -0
  92. package/system/vanilla/utils.production.js +1 -0
  93. package/system/vanilla.development.js +75 -0
  94. package/system/vanilla.production.js +1 -0
  95. package/ts3.8/babel/plugin-debug-label.d.ts +6 -0
  96. package/ts3.8/babel/plugin-react-refresh.d.ts +6 -0
  97. package/ts3.8/babel/preset.d.ts +7 -0
  98. package/ts3.8/babel/utils.d.ts +6 -0
  99. package/ts3.8/benchmarks/simple-read.d.ts +3 -0
  100. package/ts3.8/benchmarks/simple-write.d.ts +3 -0
  101. package/ts3.8/benchmarks/subscribe-write.d.ts +3 -0
  102. package/ts3.8/esm/babel/plugin-debug-label.d.ts +6 -0
  103. package/ts3.8/esm/babel/plugin-react-refresh.d.ts +6 -0
  104. package/ts3.8/esm/babel/preset.d.ts +7 -0
  105. package/ts3.8/esm/babel/utils.d.ts +6 -0
  106. package/ts3.8/esm/index.d.ts +3 -0
  107. package/ts3.8/esm/react/Provider.d.ts +17 -0
  108. package/ts3.8/esm/react/useAtom.d.ts +28 -0
  109. package/ts3.8/esm/react/useAtomValue.d.ts +10 -0
  110. package/ts3.8/esm/react/useSetAtom.d.ts +8 -0
  111. package/ts3.8/esm/react/utils/useAtomCallback.d.ts +6 -0
  112. package/ts3.8/esm/react/utils/useHydrateAtoms.d.ts +27 -0
  113. package/ts3.8/esm/react/utils/useReducerAtom.d.ts +21 -0
  114. package/ts3.8/esm/react/utils/useResetAtom.d.ts +9 -0
  115. package/ts3.8/esm/react/utils.d.ts +5 -0
  116. package/ts3.8/esm/react.d.ts +5 -0
  117. package/ts3.8/esm/utils.d.ts +3 -0
  118. package/ts3.8/esm/vanilla/atom.d.ts +48 -0
  119. package/ts3.8/esm/vanilla/internals.d.ts +165 -0
  120. package/ts3.8/esm/vanilla/store.d.ts +6 -0
  121. package/ts3.8/esm/vanilla/typeUtils.d.ts +8 -0
  122. package/ts3.8/esm/vanilla/utils/atomFamily.d.ts +56 -0
  123. package/ts3.8/esm/vanilla/utils/atomWithDefault.d.ts +11 -0
  124. package/ts3.8/esm/vanilla/utils/atomWithLazy.d.ts +3 -0
  125. package/ts3.8/esm/vanilla/utils/atomWithObservable.d.ts +37 -0
  126. package/ts3.8/esm/vanilla/utils/atomWithReducer.d.ts +8 -0
  127. package/ts3.8/esm/vanilla/utils/atomWithRefresh.d.ts +10 -0
  128. package/ts3.8/esm/vanilla/utils/atomWithReset.d.ts +11 -0
  129. package/ts3.8/esm/vanilla/utils/atomWithStorage.d.ts +53 -0
  130. package/ts3.8/esm/vanilla/utils/constants.d.ts +2 -0
  131. package/ts3.8/esm/vanilla/utils/freezeAtom.d.ts +7 -0
  132. package/ts3.8/esm/vanilla/utils/loadable.d.ts +34 -0
  133. package/ts3.8/esm/vanilla/utils/selectAtom.d.ts +3 -0
  134. package/ts3.8/esm/vanilla/utils/splitAtom.d.ts +21 -0
  135. package/ts3.8/esm/vanilla/utils/unwrap.d.ts +6 -0
  136. package/ts3.8/esm/vanilla/utils.d.ts +15 -0
  137. package/ts3.8/esm/vanilla.d.ts +5 -0
  138. package/ts3.8/index.d.ts +3 -0
  139. package/ts3.8/react/Provider.d.ts +17 -0
  140. package/ts3.8/react/useAtom.d.ts +28 -0
  141. package/ts3.8/react/useAtomValue.d.ts +10 -0
  142. package/ts3.8/react/useSetAtom.d.ts +8 -0
  143. package/ts3.8/react/utils/useAtomCallback.d.ts +6 -0
  144. package/ts3.8/react/utils/useHydrateAtoms.d.ts +27 -0
  145. package/ts3.8/react/utils/useReducerAtom.d.ts +21 -0
  146. package/ts3.8/react/utils/useResetAtom.d.ts +9 -0
  147. package/ts3.8/react/utils.d.ts +5 -0
  148. package/ts3.8/react.d.ts +5 -0
  149. package/ts3.8/utils.d.ts +3 -0
  150. package/ts3.8/vanilla/atom.d.ts +48 -0
  151. package/ts3.8/vanilla/internals.d.ts +165 -0
  152. package/ts3.8/vanilla/store.d.ts +6 -0
  153. package/ts3.8/vanilla/typeUtils.d.ts +8 -0
  154. package/ts3.8/vanilla/utils/atomFamily.d.ts +56 -0
  155. package/ts3.8/vanilla/utils/atomWithDefault.d.ts +11 -0
  156. package/ts3.8/vanilla/utils/atomWithLazy.d.ts +3 -0
  157. package/ts3.8/vanilla/utils/atomWithObservable.d.ts +37 -0
  158. package/ts3.8/vanilla/utils/atomWithReducer.d.ts +8 -0
  159. package/ts3.8/vanilla/utils/atomWithRefresh.d.ts +10 -0
  160. package/ts3.8/vanilla/utils/atomWithReset.d.ts +11 -0
  161. package/ts3.8/vanilla/utils/atomWithStorage.d.ts +53 -0
  162. package/ts3.8/vanilla/utils/constants.d.ts +2 -0
  163. package/ts3.8/vanilla/utils/freezeAtom.d.ts +7 -0
  164. package/ts3.8/vanilla/utils/loadable.d.ts +34 -0
  165. package/ts3.8/vanilla/utils/selectAtom.d.ts +3 -0
  166. package/ts3.8/vanilla/utils/splitAtom.d.ts +21 -0
  167. package/ts3.8/vanilla/utils/unwrap.d.ts +6 -0
  168. package/ts3.8/vanilla/utils.d.ts +15 -0
  169. package/ts3.8/vanilla.d.ts +5 -0
  170. package/ts_version_3.8_and_above_is_required.d.ts +0 -0
  171. package/umd/babel/plugin-debug-label.development.js +58 -0
  172. package/umd/babel/plugin-debug-label.production.js +1 -0
  173. package/umd/babel/plugin-react-refresh.development.js +76 -0
  174. package/umd/babel/plugin-react-refresh.production.js +1 -0
  175. package/umd/babel/preset.development.js +114 -0
  176. package/umd/babel/preset.production.js +1 -0
  177. package/umd/index.development.js +20 -0
  178. package/umd/index.production.js +1 -0
  179. package/umd/react/utils.development.js +101 -0
  180. package/umd/react/utils.production.js +1 -0
  181. package/umd/react.development.js +184 -0
  182. package/umd/react.production.js +1 -0
  183. package/umd/utils.development.js +20 -0
  184. package/umd/utils.production.js +1 -0
  185. package/umd/vanilla/internals.development.js +785 -0
  186. package/umd/vanilla/internals.production.js +1 -0
  187. package/umd/vanilla/utils.development.js +858 -0
  188. package/umd/vanilla/utils.production.js +1 -0
  189. package/umd/vanilla.development.js +64 -0
  190. package/umd/vanilla.production.js +1 -0
  191. package/utils.d.ts +2 -0
  192. package/utils.js +19 -0
  193. package/vanilla/atom.d.ts +47 -0
  194. package/vanilla/internals.d.ts +164 -0
  195. package/vanilla/internals.js +779 -0
  196. package/vanilla/store.d.ts +5 -0
  197. package/vanilla/typeUtils.d.ts +7 -0
  198. package/vanilla/utils/atomFamily.d.ts +55 -0
  199. package/vanilla/utils/atomWithDefault.d.ts +6 -0
  200. package/vanilla/utils/atomWithLazy.d.ts +2 -0
  201. package/vanilla/utils/atomWithObservable.d.ts +32 -0
  202. package/vanilla/utils/atomWithReducer.d.ts +3 -0
  203. package/vanilla/utils/atomWithRefresh.d.ts +6 -0
  204. package/vanilla/utils/atomWithReset.d.ts +8 -0
  205. package/vanilla/utils/atomWithStorage.d.ts +50 -0
  206. package/vanilla/utils/constants.d.ts +1 -0
  207. package/vanilla/utils/freezeAtom.d.ts +6 -0
  208. package/vanilla/utils/loadable.d.ts +33 -0
  209. package/vanilla/utils/selectAtom.d.ts +2 -0
  210. package/vanilla/utils/splitAtom.d.ts +16 -0
  211. package/vanilla/utils/unwrap.d.ts +5 -0
  212. package/vanilla/utils.d.ts +14 -0
  213. package/vanilla/utils.js +854 -0
  214. package/vanilla.d.ts +4 -0
  215. package/vanilla.js +60 -0
@@ -0,0 +1,11 @@
1
+ import type { WritableAtom } from 'jotai/vanilla';
2
+ import { RESET } from './constants';
3
+ type Read<Value, Args extends unknown[], Result> = WritableAtom<Value, Args, Result>['read'];
4
+ type DefaultSetStateAction<Value> = Value | typeof RESET | ((prev: Value) => Value | typeof RESET);
5
+ export declare function atomWithDefault<Value>(getDefault: Read<Value, [
6
+ DefaultSetStateAction<Value>
7
+ ], void>): WritableAtom<Value, [
8
+ DefaultSetStateAction<Value>
9
+ ], void>;
10
+ export {};
11
+ declare type Awaited<T> = T extends Promise<infer V> ? V : T;
@@ -0,0 +1,3 @@
1
+ import type { PrimitiveAtom } from 'jotai/vanilla';
2
+ export declare function atomWithLazy<Value>(makeInitial: () => Value): PrimitiveAtom<Value>;
3
+ declare type Awaited<T> = T extends Promise<infer V> ? V : T;
@@ -0,0 +1,37 @@
1
+ import type { Atom, Getter, WritableAtom } from 'jotai/vanilla';
2
+ type AnyError = unknown;
3
+ type Subscription = {
4
+ unsubscribe: () => void;
5
+ };
6
+ type Observer<T> = {
7
+ next: (value: T) => void;
8
+ error: (error: AnyError) => void;
9
+ complete: () => void;
10
+ };
11
+ type ObservableLike<T> = {
12
+ subscribe(observer: Observer<T>): Subscription;
13
+ } | {
14
+ subscribe(observer: Partial<Observer<T>>): Subscription;
15
+ } | {
16
+ subscribe(observer: Partial<Observer<T>>): Subscription;
17
+ subscribe(next: (value: T) => void): Subscription;
18
+ };
19
+ type SubjectLike<T> = ObservableLike<T> & Observer<T>;
20
+ type Options<Data> = {
21
+ initialValue?: Data | (() => Data);
22
+ unstable_timeout?: number;
23
+ };
24
+ type OptionsWithInitialValue<Data> = {
25
+ initialValue: Data | (() => Data);
26
+ unstable_timeout?: number;
27
+ };
28
+ export declare function atomWithObservable<Data>(getObservable: (get: Getter) => SubjectLike<Data>, options: OptionsWithInitialValue<Data>): WritableAtom<Data, [
29
+ Data
30
+ ], void>;
31
+ export declare function atomWithObservable<Data>(getObservable: (get: Getter) => SubjectLike<Data>, options?: Options<Data>): WritableAtom<Data | Promise<Data>, [
32
+ Data
33
+ ], void>;
34
+ export declare function atomWithObservable<Data>(getObservable: (get: Getter) => ObservableLike<Data>, options: OptionsWithInitialValue<Data>): Atom<Data>;
35
+ export declare function atomWithObservable<Data>(getObservable: (get: Getter) => ObservableLike<Data>, options?: Options<Data>): Atom<Data | Promise<Data>>;
36
+ export {};
37
+ declare type Awaited<T> = T extends Promise<infer V> ? V : T;
@@ -0,0 +1,8 @@
1
+ import type { WritableAtom } from 'jotai/vanilla';
2
+ export declare function atomWithReducer<Value, Action>(initialValue: Value, reducer: (value: Value, action?: Action) => Value): WritableAtom<Value, [
3
+ Action?
4
+ ], void>;
5
+ export declare function atomWithReducer<Value, Action>(initialValue: Value, reducer: (value: Value, action: Action) => Value): WritableAtom<Value, [
6
+ Action
7
+ ], void>;
8
+ declare type Awaited<T> = T extends Promise<infer V> ? V : T;
@@ -0,0 +1,10 @@
1
+ import type { WritableAtom } from 'jotai/vanilla';
2
+ type Read<Value, Args extends unknown[], Result> = WritableAtom<Value, Args, Result>['read'];
3
+ type Write<Value, Args extends unknown[], Result> = WritableAtom<Value, Args, Result>['write'];
4
+ export declare function atomWithRefresh<Value, Args extends unknown[], Result>(read: Read<Value, Args, Result>, write: Write<Value, Args, Result>): WritableAtom<Value, Args | [
5
+ ], Result | void>;
6
+ export declare function atomWithRefresh<Value>(read: Read<Value, [
7
+ ], void>): WritableAtom<Value, [
8
+ ], void>;
9
+ export {};
10
+ declare type Awaited<T> = T extends Promise<infer V> ? V : T;
@@ -0,0 +1,11 @@
1
+ import type { WritableAtom } from 'jotai/vanilla';
2
+ import { RESET } from './constants';
3
+ type SetStateActionWithReset<Value> = Value | typeof RESET | ((prev: Value) => Value | typeof RESET);
4
+ type WithInitialValue<Value> = {
5
+ init: Value;
6
+ };
7
+ export declare function atomWithReset<Value>(initialValue: Value): WritableAtom<Value, [
8
+ SetStateActionWithReset<Value>
9
+ ], void> & WithInitialValue<Value>;
10
+ export {};
11
+ declare type Awaited<T> = T extends Promise<infer V> ? V : T;
@@ -0,0 +1,53 @@
1
+ import type { WritableAtom } from 'jotai/vanilla';
2
+ import { RESET } from './constants';
3
+ type Unsubscribe = () => void;
4
+ type Subscribe<Value> = (key: string, callback: (value: Value) => void, initialValue: Value) => Unsubscribe | undefined;
5
+ type StringSubscribe = (key: string, callback: (value: string | null) => void) => Unsubscribe | undefined;
6
+ type SetStateActionWithReset<Value> = Value | typeof RESET | ((prev: Value) => Value | typeof RESET);
7
+ export interface AsyncStorage<Value> {
8
+ getItem: (key: string, initialValue: Value) => PromiseLike<Value>;
9
+ setItem: (key: string, newValue: Value) => PromiseLike<void>;
10
+ removeItem: (key: string) => PromiseLike<void>;
11
+ subscribe?: Subscribe<Value>;
12
+ }
13
+ export interface SyncStorage<Value> {
14
+ getItem: (key: string, initialValue: Value) => Value;
15
+ setItem: (key: string, newValue: Value) => void;
16
+ removeItem: (key: string) => void;
17
+ subscribe?: Subscribe<Value>;
18
+ }
19
+ export interface AsyncStringStorage {
20
+ getItem: (key: string) => PromiseLike<string | null>;
21
+ setItem: (key: string, newValue: string) => PromiseLike<void>;
22
+ removeItem: (key: string) => PromiseLike<void>;
23
+ subscribe?: StringSubscribe;
24
+ }
25
+ export interface SyncStringStorage {
26
+ getItem: (key: string) => string | null;
27
+ setItem: (key: string, newValue: string) => void;
28
+ removeItem: (key: string) => void;
29
+ subscribe?: StringSubscribe;
30
+ }
31
+ export declare function withStorageValidator<Value>(validator: (value: unknown) => value is Value): {
32
+ (storage: AsyncStorage<unknown>): AsyncStorage<Value>;
33
+ (storage: SyncStorage<unknown>): SyncStorage<Value>;
34
+ };
35
+ type JsonStorageOptions = {
36
+ reviver?: (key: string, value: unknown) => unknown;
37
+ replacer?: (key: string, value: unknown) => unknown;
38
+ };
39
+ export declare function createJSONStorage<Value>(): SyncStorage<Value>;
40
+ export declare function createJSONStorage<Value>(getStringStorage: () => AsyncStringStorage, options?: JsonStorageOptions): AsyncStorage<Value>;
41
+ export declare function createJSONStorage<Value>(getStringStorage: () => SyncStringStorage, options?: JsonStorageOptions): SyncStorage<Value>;
42
+ export declare function atomWithStorage<Value>(key: string, initialValue: Value, storage: AsyncStorage<Value>, options?: {
43
+ getOnInit?: boolean;
44
+ }): WritableAtom<Value | Promise<Value>, [
45
+ SetStateActionWithReset<Value | Promise<Value>>
46
+ ], Promise<void>>;
47
+ export declare function atomWithStorage<Value>(key: string, initialValue: Value, storage?: SyncStorage<Value>, options?: {
48
+ getOnInit?: boolean;
49
+ }): WritableAtom<Value, [
50
+ SetStateActionWithReset<Value>
51
+ ], void>;
52
+ export {};
53
+ declare type Awaited<T> = T extends Promise<infer V> ? V : T;
@@ -0,0 +1,2 @@
1
+ export declare const RESET: unique symbol;
2
+ declare type Awaited<T> = T extends Promise<infer V> ? V : T;
@@ -0,0 +1,7 @@
1
+ import type { Atom } from 'jotai/vanilla';
2
+ export declare function freezeAtom<AtomType extends Atom<unknown>>(anAtom: AtomType): AtomType;
3
+ /**
4
+ * @deprecated Define it on users end
5
+ */
6
+ export declare function freezeAtomCreator<CreateAtom extends (...args: unknown[]) => Atom<unknown>>(createAtom: CreateAtom): CreateAtom;
7
+ declare type Awaited<T> = T extends Promise<infer V> ? V : T;
@@ -0,0 +1,34 @@
1
+ import type { Atom } from 'jotai/vanilla';
2
+ export type Loadable<Value> = {
3
+ state: 'loading';
4
+ } | {
5
+ state: 'hasError';
6
+ error: unknown;
7
+ } | {
8
+ state: 'hasData';
9
+ data: Awaited<Value>;
10
+ };
11
+ /**
12
+ * @deprecated `loadable` is deprecated infavor of `unwrap`.
13
+ *
14
+ * Userland implementation of loadable:
15
+ * ```js
16
+ * function loadable(anAtom) {
17
+ * const LOADING = { state: 'loading' }
18
+ * const unwrappedAtom = unwrap(anAtom, () => LOADING)
19
+ * return atom((get) => {
20
+ * try {
21
+ * const data = get(unwrappedAtom)
22
+ * if (data === LOADING) {
23
+ * return LOADING
24
+ * }
25
+ * return { state: 'hasData', data }
26
+ * } catch (error) {
27
+ * return { state: 'hasError', error }
28
+ * }
29
+ * })
30
+ * }
31
+ * ```
32
+ */
33
+ export declare function loadable<Value>(anAtom: Atom<Value>): Atom<Loadable<Value>>;
34
+ declare type Awaited<T> = T extends Promise<infer V> ? V : T;
@@ -0,0 +1,3 @@
1
+ import type { Atom } from 'jotai/vanilla';
2
+ export declare function selectAtom<Value, Slice>(anAtom: Atom<Value>, selector: (v: Value, prevSlice?: Slice) => Slice, equalityFn?: (a: Slice, b: Slice) => boolean): Atom<Slice>;
3
+ declare type Awaited<T> = T extends Promise<infer V> ? V : T;
@@ -0,0 +1,21 @@
1
+ import type { Atom, PrimitiveAtom, WritableAtom } from 'jotai/vanilla';
2
+ type SplitAtomAction<Item> = {
3
+ type: 'remove';
4
+ atom: PrimitiveAtom<Item>;
5
+ } | {
6
+ type: 'insert';
7
+ value: Item;
8
+ before?: PrimitiveAtom<Item>;
9
+ } | {
10
+ type: 'move';
11
+ atom: PrimitiveAtom<Item>;
12
+ before?: PrimitiveAtom<Item>;
13
+ };
14
+ export declare function splitAtom<Item, Key>(arrAtom: WritableAtom<Item[], [
15
+ Item[]
16
+ ], void>, keyExtractor?: (item: Item) => Key): WritableAtom<PrimitiveAtom<Item>[], [
17
+ SplitAtomAction<Item>
18
+ ], void>;
19
+ export declare function splitAtom<Item, Key>(arrAtom: Atom<Item[]>, keyExtractor?: (item: Item) => Key): Atom<Atom<Item>[]>;
20
+ export {};
21
+ declare type Awaited<T> = T extends Promise<infer V> ? V : T;
@@ -0,0 +1,6 @@
1
+ import type { Atom, WritableAtom } from 'jotai/vanilla';
2
+ export declare function unwrap<Value, Args extends unknown[], Result>(anAtom: WritableAtom<Value, Args, Result>): WritableAtom<Awaited<Value> | undefined, Args, Result>;
3
+ export declare function unwrap<Value, Args extends unknown[], Result, PendingValue>(anAtom: WritableAtom<Value, Args, Result>, fallback: (prev?: Awaited<Value>) => PendingValue): WritableAtom<Awaited<Value> | PendingValue, Args, Result>;
4
+ export declare function unwrap<Value>(anAtom: Atom<Value>): Atom<Awaited<Value> | undefined>;
5
+ export declare function unwrap<Value, PendingValue>(anAtom: Atom<Value>, fallback: (prev?: Awaited<Value>) => PendingValue): Atom<Awaited<Value> | PendingValue>;
6
+ declare type Awaited<T> = T extends Promise<infer V> ? V : T;
@@ -0,0 +1,15 @@
1
+ export { RESET } from './utils/constants';
2
+ export { atomWithReset } from './utils/atomWithReset';
3
+ export { atomWithReducer } from './utils/atomWithReducer';
4
+ export { atomFamily } from './utils/atomFamily';
5
+ export { selectAtom } from './utils/selectAtom';
6
+ export { freezeAtom, freezeAtomCreator } from './utils/freezeAtom';
7
+ export { splitAtom } from './utils/splitAtom';
8
+ export { atomWithDefault } from './utils/atomWithDefault';
9
+ export { atomWithStorage, createJSONStorage, withStorageValidator as unstable_withStorageValidator, } from './utils/atomWithStorage';
10
+ export { atomWithObservable } from './utils/atomWithObservable';
11
+ export { loadable } from './utils/loadable';
12
+ export { unwrap } from './utils/unwrap';
13
+ export { atomWithRefresh } from './utils/atomWithRefresh';
14
+ export { atomWithLazy } from './utils/atomWithLazy';
15
+ declare type Awaited<T> = T extends Promise<infer V> ? V : T;
@@ -0,0 +1,5 @@
1
+ export { atom } from './vanilla/atom';
2
+ export type { Atom, WritableAtom, PrimitiveAtom } from './vanilla/atom';
3
+ export { createStore, getDefaultStore, INTERNAL_overrideCreateStore, } from './vanilla/store';
4
+ export type { Getter, Setter, ExtractAtomValue, ExtractAtomArgs, ExtractAtomResult, SetStateAction, } from './vanilla/typeUtils';
5
+ declare type Awaited<T> = T extends Promise<infer V> ? V : T;
@@ -0,0 +1,3 @@
1
+ export * from 'jotai/vanilla';
2
+ export * from 'jotai/react';
3
+ declare type Awaited<T> = T extends Promise<infer V> ? V : T;
@@ -0,0 +1,17 @@
1
+ import type { FunctionComponent, ReactElement, ReactNode } from 'react';
2
+ import { createStore } from 'jotai/vanilla';
3
+ type Store = ReturnType<typeof createStore>;
4
+ type Options = {
5
+ store?: Store;
6
+ };
7
+ export declare function useStore(options?: Options): Store;
8
+ export declare function Provider({ children, store, }: {
9
+ children?: ReactNode;
10
+ store?: Store;
11
+ }): ReactElement<{
12
+ value: Store | undefined;
13
+ }, FunctionComponent<{
14
+ value: Store;
15
+ }>>;
16
+ export {};
17
+ declare type Awaited<T> = T extends Promise<infer V> ? V : T;
@@ -0,0 +1,28 @@
1
+ import type { Atom, ExtractAtomArgs, ExtractAtomResult, ExtractAtomValue, PrimitiveAtom, SetStateAction, WritableAtom } from 'jotai/vanilla';
2
+ import { useAtomValue } from './useAtomValue';
3
+ type SetAtom<Args extends unknown[], Result> = (...args: Args) => Result;
4
+ type Options = Parameters<typeof useAtomValue>[1];
5
+ export declare function useAtom<Value, Args extends unknown[], Result>(atom: WritableAtom<Value, Args, Result>, options?: Options): [
6
+ Awaited<Value>,
7
+ SetAtom<Args, Result>
8
+ ];
9
+ export declare function useAtom<Value>(atom: PrimitiveAtom<Value>, options?: Options): [
10
+ Awaited<Value>,
11
+ SetAtom<[
12
+ SetStateAction<Value>
13
+ ], void>
14
+ ];
15
+ export declare function useAtom<Value>(atom: Atom<Value>, options?: Options): [
16
+ Awaited<Value>,
17
+ never
18
+ ];
19
+ export declare function useAtom<AtomType extends WritableAtom<unknown, never[], unknown>>(atom: AtomType, options?: Options): [
20
+ Awaited<ExtractAtomValue<AtomType>>,
21
+ SetAtom<ExtractAtomArgs<AtomType>, ExtractAtomResult<AtomType>>
22
+ ];
23
+ export declare function useAtom<AtomType extends Atom<unknown>>(atom: AtomType, options?: Options): [
24
+ Awaited<ExtractAtomValue<AtomType>>,
25
+ never
26
+ ];
27
+ export {};
28
+ declare type Awaited<T> = T extends Promise<infer V> ? V : T;
@@ -0,0 +1,10 @@
1
+ import type { Atom, ExtractAtomValue } from 'jotai/vanilla';
2
+ import { useStore } from './Provider';
3
+ type Options = Parameters<typeof useStore>[0] & {
4
+ delay?: number;
5
+ unstable_promiseStatus?: boolean;
6
+ };
7
+ export declare function useAtomValue<Value>(atom: Atom<Value>, options?: Options): Awaited<Value>;
8
+ export declare function useAtomValue<AtomType extends Atom<unknown>>(atom: AtomType, options?: Options): Awaited<ExtractAtomValue<AtomType>>;
9
+ export {};
10
+ declare type Awaited<T> = T extends Promise<infer V> ? V : T;
@@ -0,0 +1,8 @@
1
+ import type { ExtractAtomArgs, ExtractAtomResult, WritableAtom } from 'jotai/vanilla';
2
+ import { useStore } from './Provider';
3
+ type SetAtom<Args extends unknown[], Result> = (...args: Args) => Result;
4
+ type Options = Parameters<typeof useStore>[0];
5
+ export declare function useSetAtom<Value, Args extends unknown[], Result>(atom: WritableAtom<Value, Args, Result>, options?: Options): SetAtom<Args, Result>;
6
+ export declare function useSetAtom<AtomType extends WritableAtom<unknown, never[], unknown>>(atom: AtomType, options?: Options): SetAtom<ExtractAtomArgs<AtomType>, ExtractAtomResult<AtomType>>;
7
+ export {};
8
+ declare type Awaited<T> = T extends Promise<infer V> ? V : T;
@@ -0,0 +1,6 @@
1
+ import { useSetAtom } from 'jotai/react';
2
+ import type { Getter, Setter } from 'jotai/vanilla';
3
+ type Options = Parameters<typeof useSetAtom>[1];
4
+ export declare function useAtomCallback<Result, Args extends unknown[]>(callback: (get: Getter, set: Setter, ...arg: Args) => Result, options?: Options): (...args: Args) => Result;
5
+ export {};
6
+ declare type Awaited<T> = T extends Promise<infer V> ? V : T;
@@ -0,0 +1,27 @@
1
+ import { useStore } from 'jotai/react';
2
+ import type { WritableAtom } from 'jotai/vanilla';
3
+ type Options = Parameters<typeof useStore>[0] & {
4
+ dangerouslyForceHydrate?: boolean;
5
+ };
6
+ type AnyWritableAtom = WritableAtom<any, any[], any>;
7
+ type InferAtomTuples<T> = {
8
+ [K in keyof T]: T[K] extends readonly [
9
+ infer A,
10
+ ...infer Rest
11
+ ] ? A extends WritableAtom<unknown, infer Args, unknown> ? Rest extends Args ? readonly [
12
+ A,
13
+ ...Rest
14
+ ] : never : T[K] : never;
15
+ };
16
+ export type INTERNAL_InferAtomTuples<T> = InferAtomTuples<T>;
17
+ export declare function useHydrateAtoms<T extends (readonly [
18
+ AnyWritableAtom,
19
+ ...unknown[]
20
+ ])[]>(values: InferAtomTuples<T>, options?: Options): void;
21
+ export declare function useHydrateAtoms<T extends Map<AnyWritableAtom, unknown>>(values: T, options?: Options): void;
22
+ export declare function useHydrateAtoms<T extends Iterable<readonly [
23
+ AnyWritableAtom,
24
+ ...unknown[]
25
+ ]>>(values: InferAtomTuples<T>, options?: Options): void;
26
+ export {};
27
+ declare type Awaited<T> = T extends Promise<infer V> ? V : T;
@@ -0,0 +1,21 @@
1
+ import { useAtom } from 'jotai/react';
2
+ import type { PrimitiveAtom } from 'jotai/vanilla';
3
+ type Options = Parameters<typeof useAtom>[1];
4
+ /**
5
+ * @deprecated please use a recipe instead
6
+ * https://github.com/pmndrs/jotai/pull/2467
7
+ */
8
+ export declare function useReducerAtom<Value, Action>(anAtom: PrimitiveAtom<Value>, reducer: (v: Value, a?: Action) => Value, options?: Options): [
9
+ Value,
10
+ (action?: Action) => void
11
+ ];
12
+ /**
13
+ * @deprecated please use a recipe instead
14
+ * https://github.com/pmndrs/jotai/pull/2467
15
+ */
16
+ export declare function useReducerAtom<Value, Action>(anAtom: PrimitiveAtom<Value>, reducer: (v: Value, a: Action) => Value, options?: Options): [
17
+ Value,
18
+ (action: Action) => void
19
+ ];
20
+ export {};
21
+ declare type Awaited<T> = T extends Promise<infer V> ? V : T;
@@ -0,0 +1,9 @@
1
+ import { useSetAtom } from 'jotai/react';
2
+ import { RESET } from 'jotai/vanilla/utils';
3
+ import type { WritableAtom } from 'jotai/vanilla';
4
+ type Options = Parameters<typeof useSetAtom>[1];
5
+ export declare function useResetAtom<T>(anAtom: WritableAtom<unknown, [
6
+ typeof RESET
7
+ ], T>, options?: Options): () => T;
8
+ export {};
9
+ declare type Awaited<T> = T extends Promise<infer V> ? V : T;
@@ -0,0 +1,5 @@
1
+ export { useResetAtom } from './utils/useResetAtom';
2
+ export { useReducerAtom } from './utils/useReducerAtom';
3
+ export { useAtomCallback } from './utils/useAtomCallback';
4
+ export { useHydrateAtoms } from './utils/useHydrateAtoms';
5
+ declare type Awaited<T> = T extends Promise<infer V> ? V : T;
@@ -0,0 +1,5 @@
1
+ export { Provider, useStore } from './react/Provider';
2
+ export { useAtomValue } from './react/useAtomValue';
3
+ export { useSetAtom } from './react/useSetAtom';
4
+ export { useAtom } from './react/useAtom';
5
+ declare type Awaited<T> = T extends Promise<infer V> ? V : T;
@@ -0,0 +1,3 @@
1
+ export * from 'jotai/vanilla/utils';
2
+ export * from 'jotai/react/utils';
3
+ declare type Awaited<T> = T extends Promise<infer V> ? V : T;
@@ -0,0 +1,48 @@
1
+ import type { Store } from './store';
2
+ type Getter = <Value>(atom: Atom<Value>) => Value;
3
+ type Setter = <Value, Args extends unknown[], Result>(atom: WritableAtom<Value, Args, Result>, ...args: Args) => Result;
4
+ type SetAtom<Args extends unknown[], Result> = <A extends Args>(...args: A) => Result;
5
+ /**
6
+ * setSelf is for internal use only and subject to change without notice.
7
+ */
8
+ type Read<Value, SetSelf = never> = (get: Getter, options: {
9
+ readonly signal: AbortSignal;
10
+ readonly setSelf: SetSelf;
11
+ }) => Value;
12
+ type Write<Args extends unknown[], Result> = (get: Getter, set: Setter, ...args: Args) => Result;
13
+ type WithInitialValue<Value> = {
14
+ init: Value;
15
+ };
16
+ type OnUnmount = () => void;
17
+ type OnMount<Args extends unknown[], Result> = <S extends SetAtom<Args, Result>>(setAtom: S) => OnUnmount | void;
18
+ export interface Atom<Value> {
19
+ toString: () => string;
20
+ read: Read<Value>;
21
+ debugLabel?: string;
22
+ /**
23
+ * To ONLY be used by Jotai libraries to mark atoms as private. Subject to change.
24
+ * @private
25
+ */
26
+ debugPrivate?: boolean;
27
+ /**
28
+ * Fires after atom is referenced by the store for the first time
29
+ * This is an internal API and subject to change without notice.
30
+ */
31
+ INTERNAL_onInit?: (store: Store) => void;
32
+ }
33
+ export interface WritableAtom<Value, Args extends unknown[], Result> extends Atom<Value> {
34
+ read: Read<Value, SetAtom<Args, unknown>>;
35
+ write: Write<Args, Result>;
36
+ onMount?: OnMount<Args, Result>;
37
+ }
38
+ type SetStateAction<Value> = Value | ((prev: Value) => Value);
39
+ export type PrimitiveAtom<Value> = WritableAtom<Value, [
40
+ SetStateAction<Value>
41
+ ], void>;
42
+ export declare function atom<Value, Args extends unknown[], Result>(read: Read<Value, SetAtom<Args, unknown>>, write: Write<Args, Result>): WritableAtom<Value, Args, Result>;
43
+ export declare function atom<Value>(read: Read<Value>): Atom<Value>;
44
+ export declare function atom<Value, Args extends unknown[], Result>(initialValue: Value, write: Write<Args, Result>): WritableAtom<Value, Args, Result> & WithInitialValue<Value>;
45
+ export declare function atom<Value>(): PrimitiveAtom<Value | undefined> & WithInitialValue<Value | undefined>;
46
+ export declare function atom<Value>(initialValue: Value): PrimitiveAtom<Value> & WithInitialValue<Value>;
47
+ export {};
48
+ declare type Awaited<T> = T extends Promise<infer V> ? V : T;
@@ -0,0 +1,165 @@
1
+ import type { Atom, WritableAtom } from './atom';
2
+ type AnyValue = unknown;
3
+ type AnyError = unknown;
4
+ type AnyAtom = Atom<AnyValue>;
5
+ type AnyWritableAtom = WritableAtom<AnyValue, unknown[], unknown>;
6
+ type OnUnmount = () => void;
7
+ type EpochNumber = number;
8
+ /**
9
+ * Mutable atom state,
10
+ * tracked for both mounted and unmounted atoms in a store.
11
+ *
12
+ * This should be garbage collectable.
13
+ * We can mutate it during atom read. (except for fields with TODO)
14
+ */
15
+ type AtomState<Value = AnyValue> = {
16
+ /**
17
+ * Map of atoms that the atom depends on.
18
+ * The map value is the epoch number of the dependency.
19
+ */
20
+ readonly d: Map<AnyAtom, EpochNumber>;
21
+ /**
22
+ * Set of atoms with pending promise that depend on the atom.
23
+ *
24
+ * This may cause memory leaks, but it's for the capability to continue promises
25
+ * TODO(daishi): revisit how to handle this
26
+ */
27
+ readonly p: Set<AnyAtom>;
28
+ /** The epoch number of the atom. */
29
+ n: EpochNumber;
30
+ /** Atom value */
31
+ v?: Value;
32
+ /** Atom error */
33
+ e?: AnyError;
34
+ };
35
+ /**
36
+ * State tracked for mounted atoms. An atom is considered "mounted" if it has a
37
+ * subscriber, or is a transitive dependency of another atom that has a
38
+ * subscriber.
39
+ * The mounted state of an atom is freed once it is no longer mounted.
40
+ */
41
+ type Mounted = {
42
+ /** Set of listeners to notify when the atom value changes. */
43
+ readonly l: Set<() => void>;
44
+ /** Set of mounted atoms that the atom depends on. */
45
+ readonly d: Set<AnyAtom>;
46
+ /** Set of mounted atoms that depends on the atom. */
47
+ readonly t: Set<AnyAtom>;
48
+ /** Function to run when the atom is unmounted. */
49
+ u?: () => void;
50
+ };
51
+ type WeakMapLike<K extends object, V> = {
52
+ get(key: K): V | undefined;
53
+ set(key: K, value: V): void;
54
+ has(key: K): boolean;
55
+ delete(key: K): boolean;
56
+ };
57
+ type SetLike<T> = {
58
+ readonly size: number;
59
+ add(value: T): void;
60
+ has(value: T): boolean;
61
+ delete(value: T): boolean;
62
+ clear(): void;
63
+ forEach(callback: (value: T) => void): void;
64
+ [Symbol.iterator](): IterableIterator<T>;
65
+ };
66
+ type AtomStateMap = WeakMapLike<AnyAtom, AtomState>;
67
+ type MountedMap = WeakMapLike<AnyAtom, Mounted>;
68
+ type InvalidatedAtoms = WeakMapLike<AnyAtom, EpochNumber>;
69
+ type ChangedAtoms = SetLike<AnyAtom>;
70
+ type Callbacks = SetLike<() => void>;
71
+ type AtomRead = <Value>(store: Store, atom: Atom<Value>, ...params: Parameters<Atom<Value>['read']>) => Value;
72
+ type AtomWrite = <Value, Args extends unknown[], Result>(store: Store, atom: WritableAtom<Value, Args, Result>, ...params: Parameters<WritableAtom<Value, Args, Result>['write']>) => Result;
73
+ type AtomOnInit = <Value>(store: Store, atom: Atom<Value>) => void;
74
+ type AtomOnMount = <Value, Args extends unknown[], Result>(store: Store, atom: WritableAtom<Value, Args, Result>, setAtom: (...args: Args) => Result) => OnUnmount | void;
75
+ type EnsureAtomState = <Value>(store: Store, atom: Atom<Value>) => AtomState<Value>;
76
+ type FlushCallbacks = (store: Store) => void;
77
+ type RecomputeInvalidatedAtoms = (store: Store) => void;
78
+ type ReadAtomState = <Value>(store: Store, atom: Atom<Value>) => AtomState<Value>;
79
+ type InvalidateDependents = (store: Store, atom: AnyAtom) => void;
80
+ type WriteAtomState = <Value, Args extends unknown[], Result>(store: Store, atom: WritableAtom<Value, Args, Result>, ...args: Args) => Result;
81
+ type MountDependencies = (store: Store, atom: AnyAtom) => void;
82
+ type MountAtom = <Value>(store: Store, atom: Atom<Value>) => Mounted;
83
+ type UnmountAtom = <Value>(store: Store, atom: Atom<Value>) => Mounted | undefined;
84
+ type SetAtomStateValueOrPromise = <Value>(store: Store, atom: Atom<Value>, valueOrPromise: Value) => void;
85
+ type StoreGet = <Value>(store: Store, atom: Atom<Value>) => Value;
86
+ type StoreSet = <Value, Args extends unknown[], Result>(store: Store, atom: WritableAtom<Value, Args, Result>, ...args: Args) => Result;
87
+ type StoreSub = (store: Store, atom: AnyAtom, listener: () => void) => () => void;
88
+ type EnhanceBuildingBlocks = (buildingBlocks: Readonly<BuildingBlocks>) => Readonly<BuildingBlocks>;
89
+ type AbortHandlersMap = WeakMapLike<PromiseLike<unknown>, Set<() => void>>;
90
+ type RegisterAbortHandler = <T>(store: Store, promise: PromiseLike<T>, abortHandler: () => void) => void;
91
+ type AbortPromise = <T>(store: Store, promise: PromiseLike<T>) => void;
92
+ type Store = {
93
+ get: <Value>(atom: Atom<Value>) => Value;
94
+ set: <Value, Args extends unknown[], Result>(atom: WritableAtom<Value, Args, Result>, ...args: Args) => Result;
95
+ sub: (atom: AnyAtom, listener: () => void) => () => void;
96
+ };
97
+ type BuildingBlocks = [
98
+ /*atomStateMap*/ AtomStateMap,
99
+ /*mountedMap*/ MountedMap,
100
+ /*invalidatedAtoms*/ InvalidatedAtoms,
101
+ /*changedAtoms*/ ChangedAtoms,
102
+ /*mountCallbacks*/ Callbacks,
103
+ /*unmountCallbacks*/ Callbacks,
104
+ /*storeHooks*/ StoreHooks,
105
+ /*atomRead*/ AtomRead,
106
+ /*atomWrite*/ AtomWrite,
107
+ /*atomOnInit*/ AtomOnInit,
108
+ /*atomOnMount*/ AtomOnMount,
109
+ /*ensureAtomState*/ EnsureAtomState,
110
+ /*flushCallbacks*/ FlushCallbacks,
111
+ /*recomputeInvalidatedAtoms*/ RecomputeInvalidatedAtoms,
112
+ /*readAtomState*/ ReadAtomState,
113
+ /*invalidateDependents*/ InvalidateDependents,
114
+ /*writeAtomState*/ WriteAtomState,
115
+ /*mountDependencies*/ MountDependencies,
116
+ /*mountAtom*/ MountAtom,
117
+ /*unmountAtom*/ UnmountAtom,
118
+ /*setAtomStateValueOrPromise*/ SetAtomStateValueOrPromise,
119
+ /*storeGet*/ StoreGet,
120
+ /*storeSet*/ StoreSet,
121
+ /*storeSub*/ StoreSub,
122
+ /*enhanceBuildingBlocks*/ EnhanceBuildingBlocks | undefined,
123
+ /*abortHandlersMap*/ AbortHandlersMap,
124
+ /*registerAbortHandler*/ RegisterAbortHandler,
125
+ /*abortPromise*/ AbortPromise
126
+ ];
127
+ export type { AtomState as INTERNAL_AtomState, Mounted as INTERNAL_Mounted, AtomStateMap as INTERNAL_AtomStateMap, MountedMap as INTERNAL_MountedMap, InvalidatedAtoms as INTERNAL_InvalidatedAtoms, ChangedAtoms as INTERNAL_ChangedAtoms, Callbacks as INTERNAL_Callbacks, AtomRead as INTERNAL_AtomRead, AtomWrite as INTERNAL_AtomWrite, AtomOnInit as INTERNAL_AtomOnInit, AtomOnMount as INTERNAL_AtomOnMount, EnsureAtomState as INTERNAL_EnsureAtomState, FlushCallbacks as INTERNAL_FlushCallbacks, RecomputeInvalidatedAtoms as INTERNAL_RecomputeInvalidatedAtoms, ReadAtomState as INTERNAL_ReadAtomState, InvalidateDependents as INTERNAL_InvalidateDependents, WriteAtomState as INTERNAL_WriteAtomState, MountDependencies as INTERNAL_MountDependencies, MountAtom as INTERNAL_MountAtom, UnmountAtom as INTERNAL_UnmountAtom, Store as INTERNAL_Store, BuildingBlocks as INTERNAL_BuildingBlocks, StoreHooks as INTERNAL_StoreHooks, };
128
+ declare function hasInitialValue<T extends Atom<AnyValue>>(atom: T): atom is T & (T extends Atom<infer Value> ? {
129
+ init: Value;
130
+ } : never);
131
+ declare function isActuallyWritableAtom(atom: AnyAtom): atom is AnyWritableAtom;
132
+ declare function isAtomStateInitialized<Value>(atomState: AtomState<Value>): boolean;
133
+ declare function returnAtomValue<Value>(atomState: AtomState<Value>): Value;
134
+ declare function isPromiseLike(p: unknown): p is PromiseLike<unknown>;
135
+ declare function addPendingPromiseToDependency(atom: AnyAtom, promise: PromiseLike<AnyValue>, dependencyAtomState: AtomState): void;
136
+ declare function getMountedOrPendingDependents(atom: AnyAtom, atomState: AtomState, mountedMap: MountedMap): Iterable<AnyAtom>;
137
+ type StoreHook = {
138
+ (): void;
139
+ add(callback: () => void): () => void;
140
+ };
141
+ type StoreHookForAtoms = {
142
+ (atom: AnyAtom): void;
143
+ add(atom: AnyAtom, callback: () => void): () => void;
144
+ add(atom: undefined, callback: (atom: AnyAtom) => void): () => void;
145
+ };
146
+ /** StoreHooks are an experimental API. */
147
+ type StoreHooks = {
148
+ /** Listener to notify when the atom state is created. */
149
+ readonly i?: StoreHookForAtoms;
150
+ /** Listener to notify when the atom is read. */
151
+ readonly r?: StoreHookForAtoms;
152
+ /** Listener to notify when the atom value is changed. */
153
+ readonly c?: StoreHookForAtoms;
154
+ /** Listener to notify when the atom is mounted. */
155
+ readonly m?: StoreHookForAtoms;
156
+ /** Listener to notify when the atom is unmounted. */
157
+ readonly u?: StoreHookForAtoms;
158
+ /** Listener to notify when callbacks are being flushed. */
159
+ readonly f?: StoreHook;
160
+ };
161
+ declare function initializeStoreHooks(storeHooks: StoreHooks): Required<StoreHooks>;
162
+ declare function getBuildingBlocks(store: Store): Readonly<BuildingBlocks>;
163
+ declare function buildStore(...buildArgs: Partial<BuildingBlocks>): Store;
164
+ export { buildStore as INTERNAL_buildStoreRev2, getBuildingBlocks as INTERNAL_getBuildingBlocksRev2, initializeStoreHooks as INTERNAL_initializeStoreHooksRev2, hasInitialValue as INTERNAL_hasInitialValue, isActuallyWritableAtom as INTERNAL_isActuallyWritableAtom, isAtomStateInitialized as INTERNAL_isAtomStateInitialized, returnAtomValue as INTERNAL_returnAtomValue, isPromiseLike as INTERNAL_isPromiseLike, addPendingPromiseToDependency as INTERNAL_addPendingPromiseToDependency, getMountedOrPendingDependents as INTERNAL_getMountedOrPendingDependents, };
165
+ declare type Awaited<T> = T extends Promise<infer V> ? V : T;
@@ -0,0 +1,6 @@
1
+ import type { INTERNAL_Store } from 'jotai/vanilla/internals';
2
+ export type Store = INTERNAL_Store;
3
+ export declare function INTERNAL_overrideCreateStore(fn: (prev: typeof createStore | undefined) => typeof createStore): void;
4
+ export declare function createStore(): Store;
5
+ export declare function getDefaultStore(): Store;
6
+ declare type Awaited<T> = T extends Promise<infer V> ? V : T;