atom.io 0.11.0 → 0.12.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/data/dist/index.cjs +614 -0
- package/data/dist/index.cjs.map +1 -0
- package/data/dist/index.d.cts +158 -0
- package/data/dist/index.d.ts +118 -1
- package/data/dist/index.js +551 -30
- package/data/dist/index.js.map +1 -1
- package/data/dist/metafile-cjs.json +1 -0
- package/data/dist/metafile-esm.json +1 -0
- package/data/package.json +4 -3
- package/data/src/index.ts +1 -0
- package/data/src/join.ts +450 -0
- package/data/src/struct-family.ts +34 -24
- package/data/src/struct.ts +6 -8
- package/dist/index.cjs +257 -0
- package/dist/index.cjs.map +1 -0
- package/dist/{index.d.mts → index.d.cts} +10 -11
- package/dist/index.d.ts +10 -11
- package/dist/index.js +63 -104
- package/dist/index.js.map +1 -1
- package/dist/metafile-cjs.json +1 -0
- package/dist/metafile-esm.json +1 -0
- package/internal/dist/{index.mjs → index.cjs} +716 -495
- package/internal/dist/index.cjs.map +1 -0
- package/internal/dist/{index.d.mts → index.d.cts} +124 -105
- package/internal/dist/index.d.ts +124 -105
- package/internal/dist/index.js +651 -555
- package/internal/dist/index.js.map +1 -1
- package/internal/dist/metafile-cjs.json +1 -0
- package/internal/dist/metafile-esm.json +1 -0
- package/internal/package.json +4 -3
- package/internal/src/atom/create-atom.ts +29 -16
- package/internal/src/atom/delete-atom.ts +25 -6
- package/internal/src/atom/is-default.ts +4 -17
- package/internal/src/caching.ts +28 -23
- package/internal/src/families/create-atom-family.ts +3 -2
- package/internal/src/families/create-readonly-selector-family.ts +1 -1
- package/internal/src/families/create-selector-family.ts +4 -4
- package/internal/src/index.ts +4 -2
- package/internal/src/lazy-map.ts +33 -0
- package/internal/src/mutable/create-mutable-atom-family.ts +2 -2
- package/internal/src/mutable/create-mutable-atom.ts +1 -2
- package/internal/src/mutable/get-json-family.ts +22 -0
- package/internal/src/mutable/get-json-token.ts +1 -0
- package/internal/src/mutable/index.ts +1 -0
- package/internal/src/mutable/tracker-family.ts +1 -2
- package/internal/src/mutable/tracker.ts +8 -6
- package/internal/src/mutable/transceiver.ts +2 -0
- package/internal/src/not-found-error.ts +27 -0
- package/internal/src/operation.ts +2 -3
- package/internal/src/{get-state-internal.ts → read-or-compute-value.ts} +13 -6
- package/internal/src/selector/create-selector.ts +6 -7
- package/internal/src/selector/delete-selector.ts +37 -0
- package/internal/src/selector/index.ts +2 -1
- package/internal/src/selector/register-selector.ts +7 -7
- package/internal/src/set-state/copy-mutable-in-transaction.ts +3 -2
- package/internal/src/set-state/emit-update.ts +1 -3
- package/internal/src/set-state/evict-downstream.ts +6 -8
- package/internal/src/set-state/index.ts +1 -1
- package/internal/src/set-state/{set-state-internal.ts → set-atom-or-selector.ts} +2 -3
- package/internal/src/set-state/set-atom.ts +5 -6
- package/internal/src/store/store.ts +1 -1
- package/internal/src/store/withdraw-new-family-member.ts +6 -6
- package/internal/src/subscribe/recall-state.ts +1 -2
- package/internal/src/subscribe/subscribe-to-root-atoms.ts +2 -2
- package/internal/src/timeline/add-atom-to-timeline.ts +5 -16
- package/internal/src/timeline/{timeline-internal.ts → create-timeline.ts} +4 -5
- package/internal/src/timeline/index.ts +2 -2
- package/internal/src/timeline/time-travel.ts +89 -0
- package/internal/src/transaction/build-transaction.ts +8 -7
- package/internal/src/transaction/{transaction-internal.ts → create-transaction.ts} +6 -5
- package/internal/src/transaction/index.ts +2 -3
- package/introspection/dist/{index.mjs → index.cjs} +54 -29
- package/introspection/dist/index.cjs.map +1 -0
- package/introspection/dist/{index.d.mts → index.d.cts} +2 -2
- package/introspection/dist/index.d.ts +2 -2
- package/introspection/dist/index.js +32 -49
- package/introspection/dist/index.js.map +1 -1
- package/introspection/dist/metafile-cjs.json +1 -0
- package/introspection/dist/metafile-esm.json +1 -0
- package/introspection/package.json +4 -3
- package/introspection/src/attach-introspection-states.ts +2 -2
- package/introspection/src/attach-selector-index.ts +8 -4
- package/json/dist/{index.mjs → index.cjs} +20 -7
- package/json/dist/{index.mjs.map → index.cjs.map} +1 -1
- package/json/dist/{index.d.mts → index.d.cts} +1 -1
- package/json/dist/index.d.ts +1 -1
- package/json/dist/index.js +6 -19
- package/json/dist/index.js.map +1 -1
- package/json/dist/metafile-cjs.json +1 -0
- package/json/dist/metafile-esm.json +1 -0
- package/json/package.json +4 -3
- package/package.json +48 -47
- package/react/dist/index.cjs +59 -0
- package/react/dist/index.cjs.map +1 -0
- package/react/dist/index.js +20 -42
- package/react/dist/index.js.map +1 -1
- package/react/dist/metafile-cjs.json +1 -0
- package/react/dist/metafile-esm.json +1 -0
- package/react/package.json +4 -3
- package/react/src/store-hooks.ts +8 -2
- package/react-devtools/dist/{index.mjs → index.cjs} +286 -240
- package/react-devtools/dist/index.cjs.map +1 -0
- package/react-devtools/dist/{index.d.mts → index.d.cts} +29 -17
- package/react-devtools/dist/index.d.ts +29 -17
- package/react-devtools/dist/index.js +251 -273
- package/react-devtools/dist/index.js.map +1 -1
- package/react-devtools/dist/metafile-cjs.json +1 -0
- package/react-devtools/dist/metafile-esm.json +1 -0
- package/react-devtools/package.json +4 -3
- package/react-devtools/src/StateEditor.tsx +8 -8
- package/realtime-client/dist/{index.mjs → index.cjs} +50 -21
- package/realtime-client/dist/index.js +20 -49
- package/realtime-client/dist/metafile-cjs.json +1 -0
- package/realtime-client/dist/metafile-esm.json +1 -0
- package/realtime-client/package.json +4 -3
- package/realtime-react/dist/index.cjs +99 -0
- package/realtime-react/dist/index.js +35 -66
- package/realtime-react/dist/metafile-cjs.json +1 -0
- package/realtime-react/dist/metafile-esm.json +1 -0
- package/realtime-react/package.json +4 -3
- package/realtime-server/dist/{index.mjs → index.cjs} +67 -40
- package/realtime-server/dist/index.js +39 -66
- package/realtime-server/dist/metafile-cjs.json +1 -0
- package/realtime-server/dist/metafile-esm.json +1 -0
- package/realtime-server/package.json +4 -3
- package/realtime-testing/dist/{index.mjs → index.cjs} +54 -23
- package/realtime-testing/dist/index.js +22 -53
- package/realtime-testing/dist/metafile-cjs.json +1 -0
- package/realtime-testing/dist/metafile-esm.json +1 -0
- package/realtime-testing/package.json +4 -3
- package/src/atom.ts +6 -8
- package/src/dispose.ts +18 -0
- package/src/get-state.ts +16 -0
- package/src/index.ts +3 -1
- package/src/logger.ts +1 -1
- package/src/selector.ts +3 -3
- package/src/set-state.ts +22 -0
- package/src/silo.ts +7 -8
- package/src/timeline.ts +6 -11
- package/src/transaction.ts +2 -2
- package/transceivers/set-rtx/dist/{index.mjs → index.cjs} +40 -36
- package/transceivers/set-rtx/dist/index.cjs.map +1 -0
- package/transceivers/set-rtx/dist/{index.d.mts → index.d.cts} +2 -1
- package/transceivers/set-rtx/dist/index.d.ts +2 -1
- package/transceivers/set-rtx/dist/index.js +37 -37
- package/transceivers/set-rtx/dist/index.js.map +1 -1
- package/transceivers/set-rtx/dist/metafile-cjs.json +1 -0
- package/transceivers/set-rtx/dist/metafile-esm.json +1 -0
- package/transceivers/set-rtx/package.json +4 -3
- package/transceivers/set-rtx/src/set-rtx.ts +29 -26
- package/data/dist/index.d.mts +0 -41
- package/data/dist/index.mjs +0 -82
- package/data/dist/index.mjs.map +0 -1
- package/dist/index.mjs +0 -215
- package/dist/index.mjs.map +0 -1
- package/internal/dist/index.mjs.map +0 -1
- package/internal/src/set-state/set-selector-state.ts +0 -8
- package/internal/src/timeline/time-travel-internal.ts +0 -109
- package/introspection/dist/index.mjs.map +0 -1
- package/react/dist/index.mjs +0 -29
- package/react/dist/index.mjs.map +0 -1
- package/react-devtools/dist/index.mjs.map +0 -1
- package/realtime-react/dist/index.mjs +0 -68
- package/src/get-set.ts +0 -48
- package/transceivers/set-rtx/dist/index.mjs.map +0 -1
- /package/react/dist/{index.d.mts → index.d.cts} +0 -0
- /package/realtime-client/dist/{index.mjs.map → index.cjs.map} +0 -0
- /package/realtime-client/dist/{index.d.mts → index.d.cts} +0 -0
- /package/realtime-react/dist/{index.mjs.map → index.cjs.map} +0 -0
- /package/realtime-react/dist/{index.d.mts → index.d.cts} +0 -0
- /package/realtime-server/dist/{index.mjs.map → index.cjs.map} +0 -0
- /package/realtime-server/dist/{index.d.mts → index.d.cts} +0 -0
- /package/realtime-testing/dist/{index.mjs.map → index.cjs.map} +0 -0
- /package/realtime-testing/dist/{index.d.mts → index.d.cts} +0 -0
package/internal/dist/index.d.ts
CHANGED
|
@@ -1,28 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FamilyMetadata, SelectorOptions, SelectorToken, ReadonlySelectorOptions, ReadonlySelectorToken, Transactors, StateToken, ƒn, TransactionUpdate, TransactionOptions, TransactionToken, AtomToken, MutableAtomOptions, MutableAtomToken, MutableAtomFamilyOptions, MutableAtomFamily, SelectorFamily, AtomFamily, StateUpdate, TimelineUpdate, TimelineOptions, TimelineToken, ReadonlySelectorFamily, AtomIOLogger, Logger, AtomOptions, AtomFamilyOptions, ReadonlySelectorFamilyOptions, SelectorFamilyOptions } from 'atom.io';
|
|
2
2
|
import { Json } from 'atom.io/json';
|
|
3
3
|
|
|
4
|
-
type AtomKey<T> = string & {
|
|
5
|
-
__atomKey?: never;
|
|
6
|
-
__brand?: T;
|
|
7
|
-
};
|
|
8
|
-
type SelectorKey<T> = string & {
|
|
9
|
-
__selectorKey?: never;
|
|
10
|
-
__brand?: T;
|
|
11
|
-
};
|
|
12
|
-
type ReadonlySelectorKey<T> = string & {
|
|
13
|
-
__readonlySelectorKey?: never;
|
|
14
|
-
__brand?: T;
|
|
15
|
-
};
|
|
16
|
-
declare const isAtomKey: (key: string, store: Store) => key is AtomKey<unknown>;
|
|
17
|
-
declare const isSelectorKey: (key: string, store: Store) => key is SelectorKey<unknown>;
|
|
18
|
-
declare const isReadonlySelectorKey: (key: string, store: Store) => key is ReadonlySelectorKey<unknown>;
|
|
19
|
-
type StateKey<T> = AtomKey<T> | ReadonlySelectorKey<T> | SelectorKey<T>;
|
|
20
|
-
declare const isStateKey: (key: string, store: Store) => key is StateKey<unknown>;
|
|
21
|
-
|
|
22
|
-
declare const getSelectorDependencyKeys: (key: string, store: Store) => (AtomKey<unknown> | ReadonlySelectorKey<unknown> | SelectorKey<unknown>)[];
|
|
23
|
-
|
|
24
|
-
declare const registerSelector: (selectorKey: string, store?: Store) => Transactors;
|
|
25
|
-
|
|
26
4
|
declare class Subject<T> {
|
|
27
5
|
Subscriber: (value: T) => void;
|
|
28
6
|
subscribers: Map<string, this[`Subscriber`]>;
|
|
@@ -34,7 +12,7 @@ declare class Subject<T> {
|
|
|
34
12
|
type Selector<T> = {
|
|
35
13
|
key: string;
|
|
36
14
|
type: `selector`;
|
|
37
|
-
family?: FamilyMetadata
|
|
15
|
+
family?: FamilyMetadata;
|
|
38
16
|
install: (store: Store) => void;
|
|
39
17
|
subject: Subject<{
|
|
40
18
|
newValue: T;
|
|
@@ -46,7 +24,7 @@ type Selector<T> = {
|
|
|
46
24
|
type ReadonlySelector<T> = {
|
|
47
25
|
key: string;
|
|
48
26
|
type: `readonly_selector`;
|
|
49
|
-
family?: FamilyMetadata
|
|
27
|
+
family?: FamilyMetadata;
|
|
50
28
|
install: (store: Store) => void;
|
|
51
29
|
subject: Subject<{
|
|
52
30
|
newValue: T;
|
|
@@ -54,14 +32,44 @@ type ReadonlySelector<T> = {
|
|
|
54
32
|
}>;
|
|
55
33
|
get: () => T;
|
|
56
34
|
};
|
|
57
|
-
declare function createSelector<T>(options: SelectorOptions<T>, family
|
|
58
|
-
declare function createSelector<T>(options: ReadonlySelectorOptions<T>, family
|
|
35
|
+
declare function createSelector<T>(options: SelectorOptions<T>, family: FamilyMetadata | undefined, store: Store): SelectorToken<T>;
|
|
36
|
+
declare function createSelector<T>(options: ReadonlySelectorOptions<T>, family: FamilyMetadata | undefined, store: Store): ReadonlySelectorToken<T>;
|
|
37
|
+
|
|
38
|
+
declare function deleteSelector(selectorToken: ReadonlySelectorToken<unknown> | SelectorToken<unknown>, store: Store): void;
|
|
39
|
+
|
|
40
|
+
type AtomKey<T> = string & {
|
|
41
|
+
__atomKey?: never;
|
|
42
|
+
__brand?: T;
|
|
43
|
+
};
|
|
44
|
+
type SelectorKey<T> = string & {
|
|
45
|
+
__selectorKey?: never;
|
|
46
|
+
__brand?: T;
|
|
47
|
+
};
|
|
48
|
+
type ReadonlySelectorKey<T> = string & {
|
|
49
|
+
__readonlySelectorKey?: never;
|
|
50
|
+
__brand?: T;
|
|
51
|
+
};
|
|
52
|
+
declare const isAtomKey: (key: string, store: Store) => key is AtomKey<unknown>;
|
|
53
|
+
declare const isSelectorKey: (key: string, store: Store) => key is SelectorKey<unknown>;
|
|
54
|
+
declare const isReadonlySelectorKey: (key: string, store: Store) => key is ReadonlySelectorKey<unknown>;
|
|
55
|
+
type StateKey<T> = AtomKey<T> | ReadonlySelectorKey<T> | SelectorKey<T>;
|
|
56
|
+
declare const isStateKey: (key: string, store: Store) => key is StateKey<unknown>;
|
|
57
|
+
|
|
58
|
+
declare const getSelectorDependencyKeys: (key: string, store: Store) => (AtomKey<unknown> | ReadonlySelectorKey<unknown> | SelectorKey<unknown>)[];
|
|
59
|
+
|
|
60
|
+
declare const registerSelector: (selectorKey: string, store: Store) => Transactors;
|
|
59
61
|
|
|
60
62
|
declare const traceSelectorAtoms: (selectorKey: string, directDependencyKey: StateKey<unknown>, store: Store) => AtomKey<unknown>[];
|
|
61
63
|
declare const traceAllSelectorAtoms: (selectorKey: string, store: Store) => AtomKey<unknown>[];
|
|
62
64
|
|
|
63
65
|
declare const updateSelectorAtoms: (selectorKey: string, dependency: ReadonlySelectorToken<unknown> | StateToken<unknown>, store: Store) => void;
|
|
64
66
|
|
|
67
|
+
declare const abortTransaction: (store: Store) => void;
|
|
68
|
+
|
|
69
|
+
declare const applyTransaction: <ƒ extends ƒn>(output: ReturnType<ƒ>, store: Store) => void;
|
|
70
|
+
|
|
71
|
+
declare const buildTransaction: (key: string, params: any[], store: Store) => void;
|
|
72
|
+
|
|
65
73
|
type Transaction<ƒ extends ƒn> = {
|
|
66
74
|
key: string;
|
|
67
75
|
type: `transaction`;
|
|
@@ -69,21 +77,15 @@ type Transaction<ƒ extends ƒn> = {
|
|
|
69
77
|
subject: Subject<TransactionUpdate<ƒ>>;
|
|
70
78
|
run: (...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
71
79
|
};
|
|
72
|
-
declare function
|
|
73
|
-
declare const target: (store
|
|
74
|
-
|
|
75
|
-
declare const abortTransaction: (store: Store) => void;
|
|
76
|
-
|
|
77
|
-
declare const applyTransaction: <ƒ extends ƒn>(output: ReturnType<ƒ>, store: Store) => void;
|
|
78
|
-
|
|
79
|
-
declare const buildTransaction: (key: string, params: any[], store: Store) => void;
|
|
80
|
+
declare function createTransaction<ƒ extends ƒn>(options: TransactionOptions<ƒ>, store: Store): TransactionToken<ƒ>;
|
|
81
|
+
declare const target: (store: Store) => StoreCore;
|
|
80
82
|
|
|
81
83
|
declare const redoTransactionUpdate: <ƒ extends ƒn>(update: TransactionUpdate<ƒ>, store: Store) => void;
|
|
82
84
|
|
|
83
85
|
declare const undoTransactionUpdate: <ƒ extends ƒn>(update: TransactionUpdate<ƒ>, store: Store) => void;
|
|
84
86
|
|
|
85
87
|
declare const TRANSACTION_PHASES: readonly ["idle", "building", "applying"];
|
|
86
|
-
type TransactionPhase = typeof TRANSACTION_PHASES[number];
|
|
88
|
+
type TransactionPhase = (typeof TRANSACTION_PHASES)[number];
|
|
87
89
|
type TransactionUpdateInProgress<ƒ extends ƒn> = TransactionUpdate<ƒ> & {
|
|
88
90
|
phase: `applying` | `building`;
|
|
89
91
|
time: number;
|
|
@@ -94,7 +96,7 @@ type TransactionIdle = {
|
|
|
94
96
|
};
|
|
95
97
|
type TransactionStatus<ƒ extends ƒn> = TransactionIdle | TransactionUpdateInProgress<ƒ>;
|
|
96
98
|
|
|
97
|
-
declare function deposit<T>(state: Atom<T>): AtomToken
|
|
99
|
+
declare function deposit<T>(state: Atom<T>): AtomToken<T>;
|
|
98
100
|
declare function deposit<T>(state: Selector<T>): SelectorToken<T>;
|
|
99
101
|
declare function deposit<T>(state: Atom<T> | Selector<T>): StateToken<T>;
|
|
100
102
|
declare function deposit<T>(state: ReadonlySelector<T>): ReadonlySelectorToken<T>;
|
|
@@ -119,26 +121,30 @@ interface JunctionSchema<ASide extends string, BSide extends string> extends Obj
|
|
|
119
121
|
readonly between: [a: ASide, b: BSide];
|
|
120
122
|
readonly cardinality: Cardinality;
|
|
121
123
|
}
|
|
124
|
+
type BaseExternalStoreConfiguration = {
|
|
125
|
+
addRelation: (a: string, b: string) => void;
|
|
126
|
+
deleteRelation: (a: string, b: string) => void;
|
|
127
|
+
replaceRelationsSafely: (a: string, bs: string[]) => void;
|
|
128
|
+
replaceRelationsUnsafely: (a: string, bs: string[]) => void;
|
|
129
|
+
getRelatedKeys: (key: string) => Set<string> | undefined;
|
|
130
|
+
has: (a: string, b?: string) => boolean;
|
|
131
|
+
};
|
|
132
|
+
type ExternalStoreWithContentConfiguration<Content extends Object$1> = {
|
|
133
|
+
getContent: (contentKey: string) => Content | undefined;
|
|
134
|
+
setContent: (contentKey: string, content: Content) => void;
|
|
135
|
+
deleteContent: (contentKey: string) => void;
|
|
136
|
+
};
|
|
137
|
+
type Empty<Obj extends object> = {
|
|
138
|
+
[Key in keyof Obj]?: undefined;
|
|
139
|
+
};
|
|
140
|
+
type ExternalStoreConfiguration<Content extends Object$1 | null> = Content extends Object$1 ? BaseExternalStoreConfiguration & ExternalStoreWithContentConfiguration<Content> : BaseExternalStoreConfiguration & Empty<ExternalStoreWithContentConfiguration<Object$1>>;
|
|
122
141
|
type JunctionAdvancedConfiguration<Content extends Object$1 | null> = {
|
|
123
|
-
externalStore?:
|
|
124
|
-
getContent?: undefined;
|
|
125
|
-
setContent?: undefined;
|
|
126
|
-
deleteContent?: undefined;
|
|
127
|
-
} : {
|
|
128
|
-
getContent: (contentKey: string) => Content | undefined;
|
|
129
|
-
setContent: (contentKey: string, content: Content) => void;
|
|
130
|
-
deleteContent: (contentKey: string) => void;
|
|
131
|
-
}) & {
|
|
132
|
-
addRelation: (a: string, b: string) => void;
|
|
133
|
-
deleteRelation: (a: string, b: string) => void;
|
|
134
|
-
getRelatedKeys: (key: string) => Set<string> | undefined;
|
|
135
|
-
has: (a: string, b?: string) => boolean;
|
|
136
|
-
};
|
|
142
|
+
externalStore?: ExternalStoreConfiguration<Content>;
|
|
137
143
|
isContent?: Refinement<unknown, Content>;
|
|
138
144
|
makeContentKey?: (a: string, b: string) => string;
|
|
139
145
|
};
|
|
140
146
|
type JunctionJSON<ASide extends string, BSide extends string, Content extends Object$1 | null> = JunctionEntries<Content> & JunctionSchema<ASide, BSide>;
|
|
141
|
-
declare class Junction<ASide extends string, BSide extends string, Content extends Object$1 | null = null> {
|
|
147
|
+
declare class Junction<const ASide extends string, const BSide extends string, const Content extends Object$1 | null = null> {
|
|
142
148
|
readonly a: ASide;
|
|
143
149
|
readonly b: BSide;
|
|
144
150
|
readonly cardinality: Cardinality;
|
|
@@ -149,6 +155,8 @@ declare class Junction<ASide extends string, BSide extends string, Content exten
|
|
|
149
155
|
getRelatedKeys(key: string): Set<string> | undefined;
|
|
150
156
|
protected addRelation(a: string, b: string): void;
|
|
151
157
|
protected deleteRelation(a: string, b: string): void;
|
|
158
|
+
protected replaceRelationsUnsafely(a: string, bs: string[]): void;
|
|
159
|
+
protected replaceRelationsSafely(a: string, bs: string[]): void;
|
|
152
160
|
protected getContentInternal(contentKey: string): Content | undefined;
|
|
153
161
|
protected setContent(contentKey: string, content: Content): void;
|
|
154
162
|
protected deleteContent(contentKey: string): void;
|
|
@@ -161,6 +169,9 @@ declare class Junction<ASide extends string, BSide extends string, Content exten
|
|
|
161
169
|
delete(a: string, b?: string): this;
|
|
162
170
|
delete(relation: Record<ASide | BSide, string> | Record<ASide, string> | Record<BSide, string>, b?: undefined): this;
|
|
163
171
|
getRelatedKey(key: string): string | undefined;
|
|
172
|
+
replaceRelations(a: string, relations: Content extends null ? string[] : Record<string, Content>, config?: {
|
|
173
|
+
reckless: boolean;
|
|
174
|
+
}): this;
|
|
164
175
|
getContent(a: string, b: string): Content | undefined;
|
|
165
176
|
getRelationEntries(input: Record<ASide, string> | Record<BSide, string>): [string, Content][];
|
|
166
177
|
has(a: string, b?: string): boolean;
|
|
@@ -170,20 +181,24 @@ interface Transceiver<Signal extends Json.Serializable> {
|
|
|
170
181
|
do: (update: Signal) => void;
|
|
171
182
|
undo: (update: Signal) => void;
|
|
172
183
|
subscribe: (key: string, fn: (update: Signal) => void) => () => void;
|
|
184
|
+
cacheUpdateNumber: number;
|
|
185
|
+
getUpdateNumber: (update: Signal) => number;
|
|
173
186
|
}
|
|
174
187
|
declare function isTransceiver(value: unknown): value is Transceiver<Json.Serializable>;
|
|
175
188
|
type TransceiverMode = `playback` | `record` | `transaction`;
|
|
176
189
|
type Signal<TVR extends Transceiver<any>> = TVR extends Transceiver<infer Signal> ? Signal : never;
|
|
177
190
|
|
|
178
|
-
declare function createMutableAtom<Core extends Transceiver<any>, SerializableCore extends Json.Serializable>(options: MutableAtomOptions<Core, SerializableCore>, store
|
|
191
|
+
declare function createMutableAtom<Core extends Transceiver<any>, SerializableCore extends Json.Serializable>(options: MutableAtomOptions<Core, SerializableCore>, store: Store): MutableAtomToken<Core, SerializableCore>;
|
|
179
192
|
|
|
180
|
-
declare function createMutableAtomFamily<Core extends Transceiver<any>, SerializableCore extends Json.Serializable, Key extends string>(options: MutableAtomFamilyOptions<Core, SerializableCore, Key>, store
|
|
193
|
+
declare function createMutableAtomFamily<Core extends Transceiver<any>, SerializableCore extends Json.Serializable, Key extends string>(options: MutableAtomFamilyOptions<Core, SerializableCore, Key>, store: Store): MutableAtomFamily<Core, SerializableCore, Key>;
|
|
194
|
+
|
|
195
|
+
declare const getJsonFamily: <Core extends Transceiver<Json.Serializable>, SerializableCore extends Json.Serializable, Key extends string>(mutableAtomFamily: MutableAtomFamily<Core, SerializableCore, Key>, store: Store) => SelectorFamily<SerializableCore, Key>;
|
|
181
196
|
|
|
182
197
|
declare const getJsonToken: <Core extends Transceiver<Json.Serializable>, SerializableCore extends Json.Serializable>(mutableAtomToken: MutableAtomToken<Core, SerializableCore>) => SelectorToken<SerializableCore>;
|
|
183
198
|
|
|
184
|
-
declare const getUpdateToken: <Core extends Transceiver<Json.Serializable>, SerializableCore extends Json.Serializable>(mutableAtomToken: MutableAtomToken<Core, SerializableCore>) => AtomToken
|
|
199
|
+
declare const getUpdateToken: <Core extends Transceiver<Json.Serializable>, SerializableCore extends Json.Serializable>(mutableAtomToken: MutableAtomToken<Core, SerializableCore>) => AtomToken<Signal<Core>>;
|
|
185
200
|
|
|
186
|
-
declare function isAtomTokenMutable(token: AtomToken
|
|
201
|
+
declare function isAtomTokenMutable(token: AtomToken<any>): token is MutableAtomToken<any, any>;
|
|
187
202
|
|
|
188
203
|
/**
|
|
189
204
|
* @internal Give the tracker a transceiver state and a store, and it will
|
|
@@ -197,15 +212,15 @@ declare class Tracker<Mutable extends Transceiver<any>> {
|
|
|
197
212
|
private observeCore;
|
|
198
213
|
private updateCore;
|
|
199
214
|
mutableState: MutableAtomToken<Mutable, Json.Serializable>;
|
|
200
|
-
latestUpdateState: AtomToken
|
|
201
|
-
constructor(mutableState: MutableAtomToken<Mutable, Json.Serializable>, store
|
|
215
|
+
latestUpdateState: AtomToken<typeof this.Update | null>;
|
|
216
|
+
constructor(mutableState: MutableAtomToken<Mutable, Json.Serializable>, store: Store);
|
|
202
217
|
}
|
|
203
218
|
|
|
204
219
|
declare class FamilyTracker<Core extends Transceiver<any>, FamilyMemberKey extends Json.Serializable> {
|
|
205
220
|
private readonly Update;
|
|
206
221
|
readonly findLatestUpdateState: AtomFamily<typeof this.Update | null, FamilyMemberKey>;
|
|
207
222
|
readonly findMutableState: AtomFamily<Core, FamilyMemberKey>;
|
|
208
|
-
constructor(findMutableState: AtomFamily<Core, FamilyMemberKey>, store
|
|
223
|
+
constructor(findMutableState: AtomFamily<Core, FamilyMemberKey>, store: Store);
|
|
209
224
|
}
|
|
210
225
|
|
|
211
226
|
interface MutableAtom<T> extends Atom<T> {
|
|
@@ -224,14 +239,14 @@ type OperationProgress = {
|
|
|
224
239
|
};
|
|
225
240
|
declare const openOperation: (token: StateToken<any>, store: Store) => `rejection` | undefined;
|
|
226
241
|
declare const closeOperation: (store: Store) => void;
|
|
227
|
-
declare const isDone: (key: string, store
|
|
228
|
-
declare const markDone: (key: string, store
|
|
242
|
+
declare const isDone: (key: string, store: Store) => boolean;
|
|
243
|
+
declare const markDone: (key: string, store: Store) => void;
|
|
229
244
|
|
|
230
245
|
type TimelineAtomUpdate = StateUpdate<unknown> & {
|
|
231
246
|
key: string;
|
|
232
247
|
type: `atom_update`;
|
|
233
248
|
timestamp: number;
|
|
234
|
-
family?: FamilyMetadata
|
|
249
|
+
family?: FamilyMetadata;
|
|
235
250
|
};
|
|
236
251
|
type TimelineSelectorUpdate = {
|
|
237
252
|
key: string;
|
|
@@ -256,12 +271,11 @@ type Timeline = {
|
|
|
256
271
|
install: (store: Store) => void;
|
|
257
272
|
subject: Subject<TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate | `redo` | `undo`>;
|
|
258
273
|
};
|
|
259
|
-
declare function
|
|
274
|
+
declare function createTimeline(options: TimelineOptions, store: Store, data?: Timeline): TimelineToken;
|
|
260
275
|
|
|
261
|
-
declare const addAtomToTimeline: (atomToken: AtomToken
|
|
276
|
+
declare const addAtomToTimeline: (atomToken: AtomToken<any>, tl: Timeline, store: Store) => void;
|
|
262
277
|
|
|
263
|
-
declare const
|
|
264
|
-
declare const undo__INTERNAL: (token: TimelineToken, store?: Store) => void;
|
|
278
|
+
declare const timeTravel: (direction: `backward` | `forward`, token: TimelineToken, store: Store) => void;
|
|
265
279
|
|
|
266
280
|
type StoreCore = Pick<Store, `atoms` | `atomsThatAreDefault` | `families` | `operation` | `readonlySelectors` | `selectorAtoms` | `selectorGraph` | `selectors` | `timelineAtoms` | `timelines` | `trackers` | `transactions` | `valueMap`>;
|
|
267
281
|
declare class Store {
|
|
@@ -280,8 +294,8 @@ declare class Store {
|
|
|
280
294
|
source: string;
|
|
281
295
|
}>;
|
|
282
296
|
subject: {
|
|
283
|
-
atomCreation: Subject<AtomToken
|
|
284
|
-
selectorCreation: Subject<
|
|
297
|
+
atomCreation: Subject<AtomToken<unknown>>;
|
|
298
|
+
selectorCreation: Subject<ReadonlySelectorToken<unknown> | SelectorToken<unknown>>;
|
|
285
299
|
transactionCreation: Subject<TransactionToken<ƒn>>;
|
|
286
300
|
timelineCreation: Subject<TimelineToken>;
|
|
287
301
|
operationStatus: Subject<OperationProgress>;
|
|
@@ -299,9 +313,9 @@ declare const IMPLICIT: {
|
|
|
299
313
|
STORE_INTERNAL: Store | undefined;
|
|
300
314
|
readonly STORE: Store;
|
|
301
315
|
};
|
|
302
|
-
declare const clearStore: (store
|
|
316
|
+
declare const clearStore: (store: Store) => void;
|
|
303
317
|
|
|
304
|
-
declare function withdraw<T>(token: AtomToken
|
|
318
|
+
declare function withdraw<T>(token: AtomToken<T>, store: Store): Atom<T> | undefined;
|
|
305
319
|
declare function withdraw<T>(token: SelectorToken<T>, store: Store): Selector<T> | undefined;
|
|
306
320
|
declare function withdraw<T>(token: StateToken<T>, store: Store): Atom<T> | Selector<T> | undefined;
|
|
307
321
|
declare function withdraw<T>(token: ReadonlySelectorToken<T>, store: Store): ReadonlySelector<T> | undefined;
|
|
@@ -309,7 +323,7 @@ declare function withdraw<T>(token: TransactionToken<T>, store: Store): Transact
|
|
|
309
323
|
declare function withdraw<T>(token: ReadonlySelectorToken<T> | StateToken<T>, store: Store): Atom<T> | ReadonlySelector<T> | Selector<T> | undefined;
|
|
310
324
|
declare function withdraw<T>(token: TimelineToken, store: Store): Timeline | undefined;
|
|
311
325
|
|
|
312
|
-
declare function withdrawNewFamilyMember<T>(token: AtomToken
|
|
326
|
+
declare function withdrawNewFamilyMember<T>(token: AtomToken<T>, store: Store): Atom<T> | undefined;
|
|
313
327
|
declare function withdrawNewFamilyMember<T>(token: SelectorToken<T>, store: Store): Selector<T> | undefined;
|
|
314
328
|
declare function withdrawNewFamilyMember<T>(token: ReadonlySelectorToken<T>, store: Store): ReadonlySelector<T> | undefined;
|
|
315
329
|
declare function withdrawNewFamilyMember<T>(token: StateToken<T>, store: Store): Atom<T> | Selector<T> | undefined;
|
|
@@ -318,45 +332,23 @@ declare function withdrawNewFamilyMember<T>(token: ReadonlySelectorToken<T> | St
|
|
|
318
332
|
type Atom<T> = {
|
|
319
333
|
key: string;
|
|
320
334
|
type: `atom`;
|
|
321
|
-
family?: FamilyMetadata
|
|
335
|
+
family?: FamilyMetadata;
|
|
322
336
|
install: (store: Store) => void;
|
|
323
337
|
subject: Subject<{
|
|
324
338
|
newValue: T;
|
|
325
339
|
oldValue: T;
|
|
326
340
|
}>;
|
|
327
|
-
default: T;
|
|
328
|
-
|
|
329
|
-
declare function createAtom<T>(options: AtomOptions<T> | MutableAtomOptions<any, any>, family?: FamilyMetadata$1, store?: Store): AtomToken$1<T>;
|
|
330
|
-
|
|
331
|
-
type AtomToken<_> = {
|
|
332
|
-
key: string;
|
|
333
|
-
type: `atom`;
|
|
334
|
-
family?: FamilyMetadata;
|
|
335
|
-
__brand?: _;
|
|
336
|
-
};
|
|
337
|
-
type FamilyMetadata = {
|
|
338
|
-
key: string;
|
|
339
|
-
subKey: string;
|
|
341
|
+
default: T | (() => T);
|
|
342
|
+
cleanup?: () => void;
|
|
340
343
|
};
|
|
344
|
+
declare function createAtom<T>(options: AtomOptions<T> | MutableAtomOptions<any, any>, family: FamilyMetadata | undefined, store: Store): AtomToken<T>;
|
|
341
345
|
|
|
342
|
-
declare function deleteAtom(atomToken: AtomToken<unknown>, store
|
|
343
|
-
|
|
344
|
-
declare const isAtomDefault: (key: string, store?: Store) => boolean;
|
|
345
|
-
declare const markAtomAsDefault: (key: string, store?: Store) => void;
|
|
346
|
-
declare const markAtomAsNotDefault: (key: string, store?: Store) => void;
|
|
347
|
-
declare const isSelectorDefault: (key: string, store?: Store) => boolean;
|
|
348
|
-
|
|
349
|
-
declare const cacheValue: (key: string, value: unknown, subject: Subject<StateUpdate<unknown>>, store?: Store) => void;
|
|
350
|
-
declare const readCachedValue: <T>(key: string, store?: Store) => T;
|
|
351
|
-
declare const isValueCached: (key: string, store?: Store) => boolean;
|
|
352
|
-
declare const evictCachedValue: (key: string, store?: Store) => void;
|
|
346
|
+
declare function deleteAtom(atomToken: AtomToken<unknown>, store: Store): void;
|
|
353
347
|
|
|
354
|
-
declare
|
|
355
|
-
|
|
356
|
-
declare
|
|
357
|
-
|
|
358
|
-
declare function createSelectorFamily<T, K extends Json.Serializable>(options: SelectorFamilyOptions<T, K>, store?: Store): SelectorFamily<T, K>;
|
|
359
|
-
declare function createSelectorFamily<T, K extends Json.Serializable>(options: ReadonlySelectorFamilyOptions<T, K>, store?: Store): ReadonlySelectorFamily<T, K>;
|
|
348
|
+
declare const isAtomDefault: (key: string, store: Store) => boolean;
|
|
349
|
+
declare const markAtomAsDefault: (key: string, store: Store) => void;
|
|
350
|
+
declare const markAtomAsNotDefault: (key: string, store: Store) => void;
|
|
351
|
+
declare const isSelectorDefault: (key: string, store: Store) => boolean;
|
|
360
352
|
|
|
361
353
|
/**
|
|
362
354
|
* A Promise that can be canceled.
|
|
@@ -373,13 +365,40 @@ declare class Future<T> extends Promise<T> {
|
|
|
373
365
|
cancel(): void;
|
|
374
366
|
}
|
|
375
367
|
|
|
376
|
-
declare
|
|
368
|
+
declare function cacheValue<T>(key: string, value: T, subject: Subject<StateUpdate<unknown>>, store: Store): T;
|
|
369
|
+
declare function cacheValue<T extends Promise<any>>(key: string, value: T, subject: Subject<StateUpdate<unknown>>, store: Store): Future<T>;
|
|
370
|
+
declare const readCachedValue: <T>(key: string, store: Store) => T;
|
|
371
|
+
declare const isValueCached: (key: string, store: Store) => boolean;
|
|
372
|
+
declare const evictCachedValue: (key: string, store: Store) => void;
|
|
373
|
+
|
|
374
|
+
declare function createAtomFamily<T, K extends Json.Serializable>(options: AtomFamilyOptions<T, K>, store: Store): AtomFamily<T, K>;
|
|
375
|
+
|
|
376
|
+
declare function createReadonlySelectorFamily<T, K extends Json.Serializable>(options: ReadonlySelectorFamilyOptions<T, K>, store: Store): ReadonlySelectorFamily<T, K>;
|
|
377
|
+
|
|
378
|
+
declare function createSelectorFamily<T, K extends Json.Serializable>(options: SelectorFamilyOptions<T, K>, store: Store): SelectorFamily<T, K>;
|
|
379
|
+
declare function createSelectorFamily<T, K extends Json.Serializable>(options: ReadonlySelectorFamilyOptions<T, K>, store: Store): ReadonlySelectorFamily<T, K>;
|
|
380
|
+
|
|
381
|
+
declare class LazyMap<K, V> extends Map<K, V> {
|
|
382
|
+
protected readonly source: Map<K, V>;
|
|
383
|
+
deleted: Set<K>;
|
|
384
|
+
constructor(source: Map<K, V>);
|
|
385
|
+
get(key: K): V | undefined;
|
|
386
|
+
_has(key: K): boolean;
|
|
387
|
+
has(key: K): boolean;
|
|
388
|
+
delete(key: K): boolean;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
declare class NotFoundError extends Error {
|
|
392
|
+
constructor(token: ReadonlySelectorToken<any> | StateToken<any>, store: Store);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
declare const readOrComputeValue: <T>(state: Atom<T> | ReadonlySelector<T> | Selector<T>, store: Store) => T;
|
|
377
396
|
|
|
378
397
|
type Modify<T> = (thing: T) => T;
|
|
379
398
|
declare const become: <T>(nextVersionOfThing: T | Modify<T>) => (originalThing: T) => T;
|
|
380
399
|
|
|
381
|
-
declare const
|
|
400
|
+
declare const setAtomOrSelector: <T>(state: Atom<T> | Selector<T>, value: T | ((oldValue: T) => T), store: Store) => void;
|
|
382
401
|
|
|
383
402
|
declare const subscribeToRootAtoms: <T>(state: ReadonlySelector<T> | Selector<T>, store: Store) => (() => void)[] | null;
|
|
384
403
|
|
|
385
|
-
export { type Atom, type AtomKey, FamilyTracker, Future, IMPLICIT, type Modify, type MutableAtom, type OperationProgress, type ReadonlySelector, type ReadonlySelectorKey, type Selector, type SelectorKey, type Signal, type StateKey, Store, type StoreCore, Subject, TRANSACTION_PHASES, type Timeline, type TimelineAtomUpdate, type TimelineSelectorUpdate, type TimelineTransactionUpdate, Tracker, type Transaction, type TransactionIdle, type TransactionPhase, type TransactionStatus, type TransactionUpdateInProgress, type Transceiver, type TransceiverMode, abortTransaction, addAtomToTimeline, applyTransaction, become, buildTransaction, cacheValue, clearStore, closeOperation, createAtom, createAtomFamily, createMutableAtom, createMutableAtomFamily, createReadonlySelectorFamily, createSelector, createSelectorFamily, deleteAtom, deposit, evictCachedValue, getJsonToken, getSelectorDependencyKeys,
|
|
404
|
+
export { type Atom, type AtomKey, FamilyTracker, Future, IMPLICIT, LazyMap, type Modify, type MutableAtom, NotFoundError, type OperationProgress, type ReadonlySelector, type ReadonlySelectorKey, type Selector, type SelectorKey, type Signal, type StateKey, Store, type StoreCore, Subject, TRANSACTION_PHASES, type Timeline, type TimelineAtomUpdate, type TimelineSelectorUpdate, type TimelineTransactionUpdate, Tracker, type Transaction, type TransactionIdle, type TransactionPhase, type TransactionStatus, type TransactionUpdateInProgress, type Transceiver, type TransceiverMode, abortTransaction, addAtomToTimeline, applyTransaction, become, buildTransaction, cacheValue, clearStore, closeOperation, createAtom, createAtomFamily, createMutableAtom, createMutableAtomFamily, createReadonlySelectorFamily, createSelector, createSelectorFamily, createTimeline, createTransaction, deleteAtom, deleteSelector, deposit, evictCachedValue, getJsonFamily, getJsonToken, getSelectorDependencyKeys, getUpdateToken, isAtomDefault, isAtomKey, isAtomMutable, isAtomTokenMutable, isDone, isReadonlySelectorKey, isSelectorDefault, isSelectorKey, isStateKey, isTransceiver, isValueCached, markAtomAsDefault, markAtomAsNotDefault, markDone, openOperation, readCachedValue, readOrComputeValue, redoTransactionUpdate, registerSelector, setAtomOrSelector, subscribeToRootAtoms, target, timeTravel, traceAllSelectorAtoms, traceSelectorAtoms, undoTransactionUpdate, updateSelectorAtoms, withdraw, withdrawNewFamilyMember };
|