@exodus/atoms 10.1.0 → 10.2.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/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [10.2.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/atoms@10.1.0...@exodus/atoms@10.2.0) (2026-03-23)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- feat(atoms): difference with skipInitial option (#15641)
|
|
11
|
+
|
|
12
|
+
- feat: convert wallet-accounts feature to TypeScript (#15556)
|
|
13
|
+
|
|
6
14
|
## [10.1.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/atoms@10.0.0...@exodus/atoms@10.1.0) (2026-01-29)
|
|
7
15
|
|
|
8
16
|
### Features
|
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
import type { Atom } from '../utils/types.js';
|
|
2
2
|
type Diff<T> = {
|
|
3
|
-
previous
|
|
3
|
+
previous: T | undefined;
|
|
4
4
|
current: T;
|
|
5
5
|
};
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
type NonInitialDiff<T> = {
|
|
7
|
+
previous: T;
|
|
8
|
+
current: T;
|
|
9
|
+
};
|
|
10
|
+
type Options = {
|
|
11
|
+
skipInitial?: boolean;
|
|
12
|
+
};
|
|
13
|
+
type DiffForOptions<T, O extends Options | undefined> = O extends {
|
|
14
|
+
skipInitial: true;
|
|
15
|
+
} ? NonInitialDiff<T> : Diff<T>;
|
|
16
|
+
declare const difference: <T, O extends Options | undefined = undefined>(atom: Atom<T>, options?: O) => Omit<Atom<T>, "observe"> & {
|
|
17
|
+
observe: Atom<DiffForOptions<T, O>>["observe"];
|
|
8
18
|
};
|
|
9
19
|
export default difference;
|
|
@@ -1,12 +1,20 @@
|
|
|
1
|
-
const difference = (atom) => {
|
|
1
|
+
const difference = (atom, options) => {
|
|
2
2
|
const observe = (callback) => {
|
|
3
3
|
let prev;
|
|
4
|
+
let initialValueAssigned = false;
|
|
4
5
|
const selector = (value) => {
|
|
5
6
|
const p = prev;
|
|
6
7
|
prev = value;
|
|
7
8
|
return { previous: p, current: value };
|
|
8
9
|
};
|
|
9
|
-
return atom.observe((value) =>
|
|
10
|
+
return atom.observe((value) => {
|
|
11
|
+
const diffWrappedValue = selector(value);
|
|
12
|
+
if (options?.skipInitial && !initialValueAssigned) {
|
|
13
|
+
initialValueAssigned = true;
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
return callback(diffWrappedValue);
|
|
17
|
+
});
|
|
10
18
|
};
|
|
11
19
|
return {
|
|
12
20
|
...atom,
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import type { Atom } from '../utils/types.js';
|
|
2
2
|
import type { Storage } from '@exodus/storage-interface';
|
|
3
|
-
type FactoryParams<T> = {
|
|
4
|
-
storage: Storage<T>;
|
|
5
|
-
};
|
|
6
3
|
type Params<D> = {
|
|
7
4
|
key: string;
|
|
8
5
|
defaultValue?: D;
|
|
6
|
+
isSoleWriter?: boolean;
|
|
9
7
|
};
|
|
10
|
-
declare
|
|
8
|
+
declare function createStorageAtomFactory<T>(params: {
|
|
9
|
+
storage: Storage<T>;
|
|
10
|
+
}): ReturnType<typeof _createStorageAtomFactory<T>>;
|
|
11
|
+
declare function createStorageAtomFactory<T = unknown>(params: {
|
|
12
|
+
storage: Storage;
|
|
13
|
+
}): ReturnType<typeof _createStorageAtomFactory<T>>;
|
|
14
|
+
declare const _createStorageAtomFactory: <T = unknown>({ storage }: {
|
|
15
|
+
storage: Storage;
|
|
16
|
+
}) => {
|
|
11
17
|
(opts: Omit<Params<unknown>, "defaultValue">): Atom<T | undefined>;
|
|
12
18
|
<D extends T>(opts: Params<D>): Atom<T | D>;
|
|
13
19
|
};
|
package/lib/factories/storage.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import createSimpleObserver from '../simple-observer.js';
|
|
2
2
|
import enforceObservableRules from '../enforce-rules.js';
|
|
3
|
-
|
|
3
|
+
function createStorageAtomFactory({ storage, }) {
|
|
4
|
+
return _createStorageAtomFactory({ storage });
|
|
5
|
+
}
|
|
6
|
+
const _createStorageAtomFactory = ({ storage }) => {
|
|
4
7
|
function createStorageAtom({ key, defaultValue }) {
|
|
5
8
|
let version = 0;
|
|
6
9
|
const { notify, observe, listeners } = createSimpleObserver({ enable: true });
|
|
@@ -35,7 +38,7 @@ const createStorageAtomFactory = ({ storage }) => {
|
|
|
35
38
|
return cached;
|
|
36
39
|
}
|
|
37
40
|
const currentVersion = version;
|
|
38
|
-
const value = await storage.get(key);
|
|
41
|
+
const value = (await storage.get(key));
|
|
39
42
|
if (currentVersion !== version) {
|
|
40
43
|
return get();
|
|
41
44
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/atoms",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.2.0",
|
|
4
4
|
"description": "Abstraction for encapsulating a piece of data behind a simple unified interface: get, set, observe",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@exodus/atom-tests": "^1.0.0",
|
|
47
47
|
"@exodus/deferring-storage": "^1.0.2",
|
|
48
48
|
"@exodus/storage-encrypted": "^1.5.1",
|
|
49
|
-
"@exodus/storage-memory": "^2.
|
|
49
|
+
"@exodus/storage-memory": "^2.4.0",
|
|
50
50
|
"@types/jest": "^29.5.11",
|
|
51
51
|
"@types/json-stringify-safe": "^5.0.3",
|
|
52
52
|
"@types/lodash": "^4.14.200",
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"publishConfig": {
|
|
57
57
|
"provenance": false
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "ac175d43359e60fe2b201bf72c889c8ec501dc86"
|
|
60
60
|
}
|