@depup/jotai 2.19.1-depup.0 → 2.20.2-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.
- package/README.md +2 -2
- package/changes.json +1 -1
- package/esm/react.mjs +4 -4
- package/esm/vanilla/internals.d.mts +33 -29
- package/esm/vanilla/internals.mjs +121 -114
- package/esm/vanilla/utils.mjs +1 -1
- package/esm/vanilla.mjs +2 -2
- package/package.json +3 -4
- package/react.js +3 -3
- package/system/react.development.js +5 -5
- package/system/react.production.js +2 -2
- package/system/vanilla/internals.development.js +125 -117
- package/system/vanilla/internals.production.js +1 -1
- package/system/vanilla/utils.development.js +1 -1
- package/system/vanilla/utils.production.js +1 -1
- package/system/vanilla.development.js +3 -3
- package/system/vanilla.production.js +1 -1
- package/ts3.8/esm/vanilla/internals.d.ts +32 -28
- package/ts3.8/vanilla/internals.d.ts +32 -28
- package/umd/react.development.js +3 -3
- package/umd/react.production.js +1 -1
- package/umd/vanilla/internals.development.js +127 -131
- package/umd/vanilla/internals.production.js +1 -1
- package/umd/vanilla/utils.development.js +1 -1
- package/umd/vanilla/utils.production.js +1 -1
- package/umd/vanilla.development.js +1 -1
- package/umd/vanilla.production.js +1 -1
- package/vanilla/internals.d.ts +33 -29
- package/vanilla/internals.js +127 -131
- package/vanilla/utils.js +1 -1
- package/vanilla.js +1 -1
package/README.md
CHANGED
|
@@ -13,8 +13,8 @@ npm install @depup/jotai
|
|
|
13
13
|
|
|
14
14
|
| Field | Value |
|
|
15
15
|
|-------|-------|
|
|
16
|
-
| Original | [jotai](https://www.npmjs.com/package/jotai) @ 2.
|
|
17
|
-
| Processed | 2026-
|
|
16
|
+
| Original | [jotai](https://www.npmjs.com/package/jotai) @ 2.20.2 |
|
|
17
|
+
| Processed | 2026-07-21 |
|
|
18
18
|
| Smoke test | failed |
|
|
19
19
|
| Deps updated | 0 |
|
|
20
20
|
|
package/changes.json
CHANGED
package/esm/react.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import React, { createContext, useContext, useRef, createElement, useReducer, useEffect, useDebugValue, useCallback } from 'react';
|
|
3
3
|
import { getDefaultStore, createStore } from 'jotai/vanilla';
|
|
4
|
-
import {
|
|
4
|
+
import { INTERNAL_getBuildingBlocksRev3 } from 'jotai/vanilla/internals';
|
|
5
5
|
|
|
6
6
|
const StoreContext = createContext(
|
|
7
7
|
void 0
|
|
@@ -63,7 +63,7 @@ const use = React.use || // A shim for older React versions
|
|
|
63
63
|
});
|
|
64
64
|
const continuablePromiseMap = /* @__PURE__ */ new WeakMap();
|
|
65
65
|
const createContinuablePromise = (store, promise, getValue) => {
|
|
66
|
-
const buildingBlocks =
|
|
66
|
+
const buildingBlocks = INTERNAL_getBuildingBlocksRev3(store);
|
|
67
67
|
const registerAbortHandler = buildingBlocks[26];
|
|
68
68
|
let continuablePromise = continuablePromiseMap.get(promise);
|
|
69
69
|
if (!continuablePromise) {
|
|
@@ -86,7 +86,7 @@ const createContinuablePromise = (store, promise, getValue) => {
|
|
|
86
86
|
continuablePromiseMap.set(nextValue, continuablePromise);
|
|
87
87
|
curr = nextValue;
|
|
88
88
|
nextValue.then(onFulfilled(nextValue), onRejected(nextValue));
|
|
89
|
-
registerAbortHandler(store, nextValue, onAbort);
|
|
89
|
+
registerAbortHandler(buildingBlocks, store, nextValue, onAbort);
|
|
90
90
|
} else {
|
|
91
91
|
resolve(nextValue);
|
|
92
92
|
}
|
|
@@ -95,7 +95,7 @@ const createContinuablePromise = (store, promise, getValue) => {
|
|
|
95
95
|
}
|
|
96
96
|
};
|
|
97
97
|
promise.then(onFulfilled(promise), onRejected(promise));
|
|
98
|
-
registerAbortHandler(store, promise, onAbort);
|
|
98
|
+
registerAbortHandler(buildingBlocks, store, promise, onAbort);
|
|
99
99
|
});
|
|
100
100
|
continuablePromiseMap.set(promise, continuablePromise);
|
|
101
101
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Atom, WritableAtom } from './atom.mjs';
|
|
2
2
|
type AnyValue = unknown;
|
|
3
3
|
type AnyError = unknown;
|
|
4
4
|
type AnyAtom = Atom<AnyValue>;
|
|
5
|
-
type
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
type WithOnMount<Args extends unknown[], Result> = {
|
|
6
|
+
onMount: NonNullable<WritableAtom<AnyValue, Args, Result>['onMount']>;
|
|
7
|
+
};
|
|
8
|
+
type WithOnInit = {
|
|
9
|
+
INTERNAL_onInit: NonNullable<Atom<AnyValue>['INTERNAL_onInit']>;
|
|
8
10
|
};
|
|
9
11
|
type OnUnmount = () => void;
|
|
10
12
|
type EpochNumber = number;
|
|
@@ -73,27 +75,27 @@ type MountedMap = WeakMapLike<AnyAtom, Mounted>;
|
|
|
73
75
|
type InvalidatedAtoms = WeakMapLike<AnyAtom, EpochNumber>;
|
|
74
76
|
type ChangedAtoms = SetLike<AnyAtom>;
|
|
75
77
|
type Callbacks = SetLike<() => void>;
|
|
76
|
-
type AtomRead = <Value>(store: Store, atom: Atom<Value>, ...params: Parameters<Atom<Value>['read']>) => Value;
|
|
77
|
-
type AtomWrite = <Value, Args extends unknown[], Result>(store: Store, atom: WritableAtom<Value, Args, Result>, ...params: Parameters<WritableAtom<Value, Args, Result>['write']>) => Result;
|
|
78
|
-
type AtomOnInit = <Value>(store: Store, atom: Atom<Value>) => void;
|
|
79
|
-
type AtomOnMount = <Value, Args extends unknown[], Result>(store: Store, atom:
|
|
80
|
-
type EnsureAtomState = <Value>(store: Store, atom: Atom<Value>) => AtomState<Value>;
|
|
81
|
-
type FlushCallbacks = (store: Store) => void;
|
|
82
|
-
type RecomputeInvalidatedAtoms = (store: Store) => void;
|
|
83
|
-
type ReadAtomState = <Value>(store: Store, atom: Atom<Value>) => AtomState<Value>;
|
|
84
|
-
type InvalidateDependents = (store: Store, atom: AnyAtom) => void;
|
|
85
|
-
type WriteAtomState = <Value, Args extends unknown[], Result>(store: Store, atom: WritableAtom<Value, Args, Result>,
|
|
86
|
-
type MountDependencies = (store: Store, atom: AnyAtom) => void;
|
|
87
|
-
type MountAtom = <Value>(store: Store, atom: Atom<Value>) => Mounted;
|
|
88
|
-
type UnmountAtom = <Value>(store: Store, atom: Atom<Value>) => Mounted | undefined;
|
|
89
|
-
type SetAtomStateValueOrPromise = <Value>(store: Store, atom: Atom<Value>, valueOrPromise: Value) => void;
|
|
90
|
-
type StoreGet = <Value>(store: Store, atom: Atom<Value>) => Value;
|
|
91
|
-
type StoreSet = <Value, Args extends unknown[], Result>(store: Store, atom: WritableAtom<Value, Args, Result>, ...args: Args) => Result;
|
|
92
|
-
type StoreSub = (store: Store, atom: AnyAtom, listener: () => void) => () => void;
|
|
93
|
-
type EnhanceBuildingBlocks = (buildingBlocks: Readonly<BuildingBlocks
|
|
78
|
+
type AtomRead = <Value>(buildingBlocks: Readonly<BuildingBlocks>, store: Store, atom: Atom<Value>, ...params: Parameters<Atom<Value>['read']>) => Value;
|
|
79
|
+
type AtomWrite = <Value, Args extends unknown[], Result>(buildingBlocks: Readonly<BuildingBlocks>, store: Store, atom: WritableAtom<Value, Args, Result>, ...params: Parameters<WritableAtom<Value, Args, Result>['write']>) => Result;
|
|
80
|
+
type AtomOnInit = <Value>(buildingBlocks: Readonly<BuildingBlocks>, store: Store, atom: Atom<Value> & WithOnInit) => void;
|
|
81
|
+
type AtomOnMount = <Value, Args extends unknown[], Result>(buildingBlocks: Readonly<BuildingBlocks>, store: Store, atom: WritableAtom<Value, Args, Result> & WithOnMount<Args, Result>, setAtom: (...args: Args) => Result) => OnUnmount | void;
|
|
82
|
+
type EnsureAtomState = <Value>(buildingBlocks: Readonly<BuildingBlocks>, store: Store, atom: Atom<Value>) => AtomState<Value>;
|
|
83
|
+
type FlushCallbacks = (buildingBlocks: Readonly<BuildingBlocks>, store: Store) => void;
|
|
84
|
+
type RecomputeInvalidatedAtoms = (buildingBlocks: Readonly<BuildingBlocks>, store: Store) => void;
|
|
85
|
+
type ReadAtomState = <Value>(buildingBlocks: Readonly<BuildingBlocks>, store: Store, atom: Atom<Value>) => AtomState<Value>;
|
|
86
|
+
type InvalidateDependents = (buildingBlocks: Readonly<BuildingBlocks>, store: Store, atom: AnyAtom) => void;
|
|
87
|
+
type WriteAtomState = <Value, Args extends unknown[], Result>(buildingBlocks: Readonly<BuildingBlocks>, store: Store, atom: WritableAtom<Value, Args, Result>, args: Args) => Result;
|
|
88
|
+
type MountDependencies = (buildingBlocks: Readonly<BuildingBlocks>, store: Store, atom: AnyAtom) => void;
|
|
89
|
+
type MountAtom = <Value>(buildingBlocks: Readonly<BuildingBlocks>, store: Store, atom: Atom<Value>) => Mounted;
|
|
90
|
+
type UnmountAtom = <Value>(buildingBlocks: Readonly<BuildingBlocks>, store: Store, atom: Atom<Value>) => Mounted | undefined;
|
|
91
|
+
type SetAtomStateValueOrPromise = <Value>(buildingBlocks: Readonly<BuildingBlocks>, store: Store, atom: Atom<Value>, valueOrPromise: Value) => void;
|
|
92
|
+
type StoreGet = <Value>(buildingBlocks: Readonly<BuildingBlocks>, store: Store, atom: Atom<Value>) => Value;
|
|
93
|
+
type StoreSet = <Value, Args extends unknown[], Result>(buildingBlocks: Readonly<BuildingBlocks>, store: Store, atom: WritableAtom<Value, Args, Result>, ...args: Args) => Result;
|
|
94
|
+
type StoreSub = (buildingBlocks: Readonly<BuildingBlocks>, store: Store, atom: AnyAtom, listener: () => void) => () => void;
|
|
95
|
+
type EnhanceBuildingBlocks = (buildingBlocks: Readonly<BuildingBlocks>, store: Store) => Readonly<BuildingBlocks>;
|
|
94
96
|
type AbortHandlersMap = WeakMapLike<PromiseLike<unknown>, Set<() => void>>;
|
|
95
|
-
type RegisterAbortHandler = <T>(store: Store, promise: PromiseLike<T>, abortHandler: () => void) => void;
|
|
96
|
-
type AbortPromise = <T>(store: Store, promise: PromiseLike<T>) => void;
|
|
97
|
+
type RegisterAbortHandler = <T>(buildingBlocks: Readonly<BuildingBlocks>, store: Store, promise: PromiseLike<T>, abortHandler: () => void) => void;
|
|
98
|
+
type AbortPromise = <T>(buildingBlocks: Readonly<BuildingBlocks>, store: Store, promise: PromiseLike<T>) => void;
|
|
97
99
|
type StoreEpochHolder = [n: EpochNumber];
|
|
98
100
|
type Store = {
|
|
99
101
|
get: <Value>(atom: Atom<Value>) => Value;
|
|
@@ -132,13 +134,15 @@ type BuildingBlocks = [
|
|
|
132
134
|
storeEpochHolder: StoreEpochHolder
|
|
133
135
|
];
|
|
134
136
|
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, };
|
|
135
|
-
declare function hasInitialValue<T extends
|
|
137
|
+
declare function hasInitialValue<T extends AnyAtom>(atom: T): atom is T & (T extends Atom<infer Value> ? {
|
|
136
138
|
init: Value;
|
|
137
139
|
} : never);
|
|
138
|
-
|
|
139
|
-
declare function
|
|
140
|
+
type ActuallyWritableAtom<T extends AnyAtom> = T extends WritableAtom<infer V, infer A, infer R> ? T & WritableAtom<V, A, R> : T extends Atom<infer V> ? T & WritableAtom<V, unknown[], unknown> : never;
|
|
141
|
+
declare function isActuallyWritableAtom<T extends AnyAtom>(atom: T): atom is ActuallyWritableAtom<T>;
|
|
142
|
+
declare function isAtomStateInitialized(atomState: AtomState<AnyValue>): boolean;
|
|
140
143
|
declare function returnAtomValue<Value>(atomState: AtomState<Value>): Value;
|
|
141
144
|
declare function isPromiseLike(p: unknown): p is PromiseLike<unknown>;
|
|
145
|
+
declare function shouldThrowSynchronously(error: unknown): boolean;
|
|
142
146
|
declare function addPendingPromiseToDependency(atom: AnyAtom, promise: PromiseLike<AnyValue>, dependencyAtomState: AtomState): void;
|
|
143
147
|
declare function getMountedOrPendingDependents(atom: AnyAtom, atomState: AtomState, mountedMap: MountedMap): Iterable<AnyAtom>;
|
|
144
148
|
type StoreHook = {
|
|
@@ -167,5 +171,5 @@ type StoreHooks = {
|
|
|
167
171
|
};
|
|
168
172
|
declare function initializeStoreHooks(storeHooks: StoreHooks): Required<StoreHooks>;
|
|
169
173
|
declare function getBuildingBlocks(store: Store): Readonly<BuildingBlocks>;
|
|
170
|
-
declare function buildStore(...
|
|
171
|
-
export { buildStore as
|
|
174
|
+
declare function buildStore(...partialBuildingBlocks: Partial<BuildingBlocks>): Store;
|
|
175
|
+
export { buildStore as INTERNAL_buildStoreRev3, getBuildingBlocks as INTERNAL_getBuildingBlocksRev3, initializeStoreHooks as INTERNAL_initializeStoreHooksRev3, hasInitialValue as INTERNAL_hasInitialValue, isActuallyWritableAtom as INTERNAL_isActuallyWritableAtom, isAtomStateInitialized as INTERNAL_isAtomStateInitialized, returnAtomValue as INTERNAL_returnAtomValue, isPromiseLike as INTERNAL_isPromiseLike, shouldThrowSynchronously as INTERNAL_shouldThrowSynchronously, addPendingPromiseToDependency as INTERNAL_addPendingPromiseToDependency, getMountedOrPendingDependents as INTERNAL_getMountedOrPendingDependents, };
|