atom.io 0.31.1 → 0.32.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/data/dist/index.d.ts +867 -101
- package/data/dist/index.js +10 -558
- package/data/src/index.ts +0 -2
- package/data/src/struct-family.ts +1 -1
- package/data/src/struct.ts +1 -2
- package/dist/chunk-354XQWHH.js +153 -0
- package/dist/chunk-4LWKCEW3.js +14 -0
- package/dist/chunk-5F2V7S3B.js +83 -0
- package/dist/chunk-ECOMOMUN.js +631 -0
- package/dist/{chunk-Y5MBNTVU.js → chunk-GY2XQYZY.js} +1791 -703
- package/dist/chunk-NF7FJKJD.js +107 -0
- package/dist/chunk-R3ZUK5EH.js +1024 -0
- package/dist/chunk-Z2UJW4NQ.js +523 -0
- package/dist/index.d.ts +622 -26
- package/dist/index.js +1 -228
- package/eslint-plugin/dist/index.d.ts +1 -30
- package/eslint-plugin/dist/index.js +0 -146
- package/eslint-plugin/src/index.ts +0 -1
- package/eslint-plugin/src/rules/index.ts +0 -1
- package/internal/dist/index.d.ts +783 -64
- package/internal/dist/index.js +1 -1
- package/internal/src/atom/create-regular-atom.ts +3 -3
- package/internal/src/atom/dispose-atom.ts +4 -13
- package/internal/src/atom/is-default.ts +3 -3
- package/internal/src/caching.ts +5 -5
- package/internal/src/capitalize.ts +3 -0
- package/internal/src/families/create-readonly-selector-family.ts +5 -6
- package/internal/src/families/create-writable-selector-family.ts +1 -4
- package/internal/src/families/dispose-from-store.ts +3 -13
- package/internal/src/get-state/get-from-store.ts +2 -2
- package/internal/src/get-state/read-or-compute-value.ts +1 -1
- package/internal/src/index.ts +2 -0
- package/internal/src/install-into-store.ts +1 -1
- package/internal/src/join/edit-relations-in-store.ts +32 -0
- package/internal/src/join/find-relations-in-store.ts +124 -0
- package/internal/src/join/get-internal-relations-from-store.ts +14 -0
- package/internal/src/join/get-join.ts +31 -0
- package/internal/src/join/index.ts +5 -0
- package/{data/src/join.ts → internal/src/join/join-internal.ts} +20 -429
- package/internal/src/keys.ts +7 -7
- package/internal/src/mutable/create-mutable-atom-family.ts +1 -1
- package/internal/src/mutable/create-mutable-atom.ts +3 -3
- package/internal/src/mutable/get-json-token.ts +1 -1
- package/internal/src/mutable/tracker-family.ts +19 -17
- package/internal/src/mutable/tracker.ts +8 -8
- package/internal/src/pretty-print.ts +1 -1
- package/internal/src/selector/create-readonly-selector.ts +3 -7
- package/internal/src/selector/create-writable-selector.ts +4 -4
- package/internal/src/selector/dispose-selector.ts +20 -11
- package/internal/src/selector/get-selector-dependency-keys.ts +1 -1
- package/internal/src/selector/register-selector.ts +6 -9
- package/internal/src/selector/trace-selector-atoms.ts +2 -2
- package/internal/src/set-state/copy-mutable-if-needed.ts +1 -1
- package/internal/src/set-state/emit-update.ts +1 -1
- package/internal/src/set-state/evict-downstream.ts +1 -1
- package/internal/src/set-state/set-atom-or-selector.ts +1 -1
- package/internal/src/set-state/set-atom.ts +10 -10
- package/internal/src/set-state/set-into-store.ts +2 -2
- package/internal/src/set-state/stow-update.ts +1 -1
- package/internal/src/store/store.ts +1 -1
- package/internal/src/store/withdraw.ts +22 -22
- package/internal/src/subscribe/recall-state.ts +1 -1
- package/internal/src/subscribe/subscribe-in-store.ts +3 -3
- package/internal/src/subscribe/subscribe-to-root-atoms.ts +3 -3
- package/internal/src/subscribe/subscribe-to-state.ts +5 -5
- package/internal/src/subscribe/subscribe-to-timeline.ts +3 -3
- package/internal/src/subscribe/subscribe-to-transaction.ts +3 -3
- package/internal/src/timeline/create-timeline.ts +17 -37
- package/internal/src/transaction/act-upon-store.ts +2 -2
- package/internal/src/transaction/apply-transaction.ts +5 -5
- package/internal/src/transaction/assign-transaction-to-continuity.ts +1 -1
- package/internal/src/transaction/build-transaction.ts +5 -8
- package/internal/src/transaction/create-transaction.ts +3 -3
- package/internal/src/transaction/get-epoch-number.ts +3 -3
- package/internal/src/transaction/set-epoch-number.ts +2 -2
- package/introspection/dist/index.d.ts +922 -6
- package/introspection/dist/index.js +2 -620
- package/json/dist/index.d.ts +899 -5
- package/json/dist/index.js +1 -80
- package/json/src/select-json-family.ts +3 -14
- package/package.json +24 -42
- package/react/dist/index.d.ts +921 -3
- package/react/dist/index.js +2 -82
- package/react/src/use-o.ts +1 -1
- package/react/src/use-tl.ts +2 -2
- package/react-devtools/dist/index.css +16 -14
- package/react-devtools/dist/index.d.ts +26 -1
- package/react-devtools/dist/index.js +6 -6
- package/react-devtools/src/devtools.scss +16 -14
- package/realtime/dist/index.d.ts +202 -8
- package/realtime/dist/index.js +2 -107
- package/realtime/src/realtime-continuity.ts +2 -2
- package/realtime/src/shared-room-store.ts +1 -2
- package/realtime-client/dist/index.d.ts +960 -22
- package/realtime-client/dist/index.js +3 -509
- package/realtime-client/src/continuity/register-and-attempt-confirmed-update.ts +3 -3
- package/realtime-client/src/continuity/use-conceal-state.ts +1 -1
- package/realtime-client/src/pull-atom-family-member.ts +2 -2
- package/realtime-client/src/pull-atom.ts +2 -2
- package/realtime-client/src/pull-mutable-atom-family-member.ts +2 -2
- package/realtime-client/src/pull-mutable-atom.ts +2 -2
- package/realtime-client/src/pull-selector-family-member.ts +4 -4
- package/realtime-client/src/pull-selector.ts +4 -4
- package/realtime-client/src/push-state.ts +5 -10
- package/realtime-client/src/server-action.ts +4 -4
- package/realtime-client/src/sync-continuity.ts +6 -6
- package/realtime-react/dist/index.d.ts +166 -12
- package/realtime-react/dist/index.js +5 -154
- package/realtime-react/src/use-pull-atom-family-member.ts +1 -1
- package/realtime-react/src/use-pull-atom.ts +1 -1
- package/realtime-react/src/use-pull-mutable-atom.ts +1 -1
- package/realtime-react/src/use-pull-mutable-family-member.ts +1 -1
- package/realtime-react/src/use-pull-selector-family-member.ts +1 -1
- package/realtime-react/src/use-pull-selector.ts +1 -1
- package/realtime-react/src/use-push.ts +1 -1
- package/realtime-react/src/use-server-action.ts +2 -2
- package/realtime-react/src/use-sync-continuity.ts +1 -1
- package/realtime-server/dist/index.d.ts +971 -28
- package/realtime-server/dist/index.js +3 -1001
- package/realtime-server/src/continuity/prepare-to-serve-transaction-request.ts +1 -1
- package/realtime-server/src/continuity/prepare-to-sync-realtime-continuity.ts +3 -3
- package/realtime-server/src/continuity/subscribe-to-continuity-actions.ts +2 -2
- package/realtime-server/src/continuity/subscribe-to-continuity-perpectives.ts +2 -2
- package/realtime-server/src/realtime-action-receiver.ts +1 -1
- package/realtime-server/src/realtime-family-provider.ts +2 -2
- package/realtime-server/src/realtime-mutable-family-provider.ts +2 -2
- package/realtime-server/src/realtime-mutable-provider.ts +2 -2
- package/realtime-server/src/realtime-server-stores/server-room-external-actions.ts +2 -1
- package/realtime-server/src/realtime-server-stores/server-room-external-store.ts +1 -1
- package/realtime-server/src/realtime-server-stores/server-user-store.ts +1 -2
- package/realtime-server/src/realtime-state-provider.ts +2 -2
- package/realtime-testing/dist/index.d.ts +1091 -3
- package/realtime-testing/dist/index.js +20 -22
- package/realtime-testing/src/setup-realtime-test.tsx +2 -1
- package/src/index.ts +4 -0
- package/src/join.ts +218 -0
- package/src/silo.ts +4 -4
- package/src/timeline.ts +1 -1
- package/src/transaction.ts +4 -8
- package/transceivers/set-rtx/dist/index.d.ts +37 -2
- package/transceivers/set-rtx/dist/index.js +1 -215
- package/web/dist/index.d.ts +30 -1
- package/web/dist/index.js +1 -15
- package/data/src/until.ts +0 -15
- package/ephemeral/dist/index.d.ts +0 -67
- package/ephemeral/dist/index.js +0 -9
- package/ephemeral/package.json +0 -13
- package/ephemeral/src/index.ts +0 -1
- package/eslint-plugin/src/rules/lifespan.ts +0 -203
- package/immortal/dist/index.d.ts +0 -12
- package/immortal/dist/index.js +0 -9
- package/immortal/package.json +0 -13
- package/immortal/src/index.ts +0 -1
- package/immortal/src/seek-state.ts +0 -60
- /package/{ephemeral/src → src}/find-state.ts +0 -0
package/internal/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,655 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
type primitive = boolean | number | string | null;
|
|
2
|
+
declare namespace Json {
|
|
3
|
+
namespace Tree {
|
|
4
|
+
type Array<Element = unknown> = ReadonlyArray<Element>;
|
|
5
|
+
type Object<K extends string = string, V = unknown> = Record<K, V>;
|
|
6
|
+
type Fork = Array | Object;
|
|
7
|
+
type Leaf = primitive;
|
|
8
|
+
type Node = Fork | Leaf;
|
|
9
|
+
}
|
|
10
|
+
type Serializable = primitive | Readonly<{
|
|
11
|
+
[key: string]: Serializable;
|
|
12
|
+
}> | ReadonlyArray<Serializable>;
|
|
13
|
+
type Object<Key extends string = string, Value extends Serializable = Serializable> = Record<Key, Value>;
|
|
14
|
+
type Array<Element extends Serializable = Serializable> = ReadonlyArray<Element>;
|
|
15
|
+
}
|
|
16
|
+
type stringified<J extends Json.Serializable> = J extends string ? `"${J}"` : J extends number ? `${J}` : J extends true ? `true` : J extends false ? `false` : J extends boolean ? `false` | `true` : J extends null ? `null` : string & {
|
|
17
|
+
__json?: J;
|
|
18
|
+
};
|
|
19
|
+
type Canonical = primitive | ReadonlyArray<Canonical>;
|
|
20
|
+
type JsonInterface<T, J extends Json.Serializable = Json.Serializable> = {
|
|
21
|
+
toJson: (t: T) => J;
|
|
22
|
+
fromJson: (json: J) => T;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/** @public */
|
|
26
|
+
type Effectors<T> = {
|
|
27
|
+
/**
|
|
28
|
+
* Set the value of the atom
|
|
29
|
+
* @param next - The new value of the atom, or a setter function
|
|
30
|
+
*/
|
|
31
|
+
setSelf: <New extends T>(next: New | Setter<T, New>) => void;
|
|
32
|
+
/** Subscribe to changes to the atom */
|
|
33
|
+
onSet: (callback: (options: {
|
|
34
|
+
newValue: T;
|
|
35
|
+
oldValue: T;
|
|
36
|
+
}) => void) => void;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* @public
|
|
40
|
+
* A function that runs side effects when the atom is set
|
|
41
|
+
* @param tools - {@link Effectors} that can be used to run side effects
|
|
42
|
+
* @returns
|
|
43
|
+
* Optionally, a cleanup function that will be called when the atom is disposed
|
|
44
|
+
*/
|
|
45
|
+
type AtomEffect<T> = (tools: Effectors<T>) => (() => void) | void;
|
|
46
|
+
/** @public */
|
|
47
|
+
type RegularAtomOptions<T> = {
|
|
48
|
+
/** The unique identifier of the atom */
|
|
49
|
+
key: string;
|
|
50
|
+
/** The starting value of the atom */
|
|
51
|
+
default: T | (() => T);
|
|
52
|
+
/** Hooks used to run side effects when the atom is set */
|
|
53
|
+
effects?: AtomEffect<T>[];
|
|
54
|
+
};
|
|
55
|
+
type MutableAtomOptions<T extends Transceiver<any>, J extends Json.Serializable> = JsonInterface<T, J> & Omit<RegularAtomOptions<T>, `default`> & {
|
|
56
|
+
default: () => T;
|
|
57
|
+
mutable: true;
|
|
58
|
+
};
|
|
59
|
+
/** @public */
|
|
60
|
+
type RegularAtomFamilyOptions<T, K extends Canonical> = {
|
|
61
|
+
/** The unique identifier of the atom family */
|
|
62
|
+
key: string;
|
|
63
|
+
/** The starting value of the atom family */
|
|
64
|
+
default: T | ((key: K) => T);
|
|
65
|
+
/** Hooks used to run side effects when an atom in the family is set */
|
|
66
|
+
effects?: (key: K) => AtomEffect<T>[];
|
|
67
|
+
};
|
|
68
|
+
type RegularAtomFamilyToken<T, K extends Canonical> = {
|
|
69
|
+
key: string;
|
|
70
|
+
type: `atom_family`;
|
|
71
|
+
__T?: T;
|
|
72
|
+
__K?: K;
|
|
73
|
+
};
|
|
74
|
+
type MutableAtomFamilyOptions<T extends Transceiver<any>, J extends Json.Serializable, K extends Canonical> = JsonInterface<T, J> & {
|
|
75
|
+
key: string;
|
|
76
|
+
default: (key: K) => T;
|
|
77
|
+
effects?: (key: K) => AtomEffect<T>[];
|
|
78
|
+
mutable: true;
|
|
79
|
+
};
|
|
80
|
+
type MutableAtomFamilyToken<T extends Transceiver<any>, J extends Json.Serializable, K extends Canonical> = {
|
|
81
|
+
key: string;
|
|
82
|
+
type: `mutable_atom_family`;
|
|
83
|
+
__T?: T;
|
|
84
|
+
__J?: J;
|
|
85
|
+
__K?: K;
|
|
86
|
+
};
|
|
87
|
+
type AtomFamilyToken<T, K extends Canonical = Canonical> = MutableAtomFamilyToken<T extends Transceiver<any> ? T : never, any, K> | RegularAtomFamilyToken<T, K>;
|
|
88
|
+
|
|
89
|
+
type TransactionToken<F extends Func> = {
|
|
90
|
+
key: string;
|
|
91
|
+
type: `transaction`;
|
|
92
|
+
__F?: F;
|
|
93
|
+
};
|
|
94
|
+
type StateCreation<Token extends ReadableToken<any>> = {
|
|
95
|
+
type: `state_creation`;
|
|
96
|
+
token: Token;
|
|
97
|
+
};
|
|
98
|
+
type AtomDisposal<Token extends ReadableToken<any>> = {
|
|
99
|
+
type: `state_disposal`;
|
|
100
|
+
subType: `atom`;
|
|
101
|
+
token: Token;
|
|
102
|
+
value: TokenType<Token>;
|
|
103
|
+
};
|
|
104
|
+
type SelectorDisposal<Token extends ReadableToken<any>> = {
|
|
105
|
+
type: `state_disposal`;
|
|
106
|
+
subType: `selector`;
|
|
107
|
+
token: Token;
|
|
108
|
+
};
|
|
109
|
+
type StateDisposal<Token extends ReadableToken<any>> = AtomDisposal<Token> | SelectorDisposal<Token>;
|
|
110
|
+
type MoleculeCreation = {
|
|
111
|
+
type: `molecule_creation`;
|
|
112
|
+
key: Canonical;
|
|
113
|
+
provenance: Canonical;
|
|
114
|
+
};
|
|
115
|
+
type MoleculeDisposal = {
|
|
116
|
+
type: `molecule_disposal`;
|
|
117
|
+
key: Canonical;
|
|
118
|
+
provenance: stringified<Canonical>[];
|
|
119
|
+
values: [key: string, value: any][];
|
|
120
|
+
};
|
|
121
|
+
type MoleculeTransfer = {
|
|
122
|
+
type: `molecule_transfer`;
|
|
123
|
+
key: Canonical;
|
|
124
|
+
from: Canonical[];
|
|
125
|
+
to: Canonical[];
|
|
126
|
+
};
|
|
127
|
+
type TransactionUpdateContent = KeyedStateUpdate<unknown> | MoleculeCreation | MoleculeDisposal | MoleculeTransfer | StateCreation<ReadableToken<unknown>> | StateDisposal<ReadableToken<unknown>> | TransactionUpdate<Func>;
|
|
128
|
+
type TransactionUpdate<F extends Func> = {
|
|
129
|
+
type: `transaction_update`;
|
|
130
|
+
key: string;
|
|
131
|
+
id: string;
|
|
132
|
+
epoch: number;
|
|
133
|
+
updates: TransactionUpdateContent[];
|
|
134
|
+
params: Parameters<F>;
|
|
135
|
+
output: ReturnType<F>;
|
|
136
|
+
};
|
|
137
|
+
type GetterToolkit = Pick<SetterToolkit, `find` | `get` | `json`>;
|
|
138
|
+
type SetterToolkit = Readonly<{
|
|
139
|
+
get: typeof getState;
|
|
140
|
+
set: typeof setState;
|
|
141
|
+
find: typeof findState;
|
|
142
|
+
json: <T extends Transceiver<any>, J extends Json.Serializable>(state: MutableAtomToken<T, J>) => WritableSelectorToken<J>;
|
|
143
|
+
}>;
|
|
144
|
+
type ActorToolkit = Readonly<{
|
|
145
|
+
get: typeof getState;
|
|
146
|
+
set: typeof setState;
|
|
147
|
+
find: typeof findState;
|
|
148
|
+
json: <T extends Transceiver<any>, J extends Json.Serializable>(state: MutableAtomToken<T, J>) => WritableSelectorToken<J>;
|
|
149
|
+
dispose: typeof disposeState;
|
|
150
|
+
run: typeof runTransaction;
|
|
151
|
+
env: () => EnvironmentData;
|
|
152
|
+
}>;
|
|
153
|
+
type Read<F extends Func> = (toolkit: GetterToolkit, ...parameters: Parameters<F>) => ReturnType<F>;
|
|
154
|
+
type Write<F extends Func> = (toolkit: SetterToolkit, ...parameters: Parameters<F>) => ReturnType<F>;
|
|
155
|
+
type Transact<F extends Func> = (toolkit: ActorToolkit, ...parameters: Parameters<F>) => ReturnType<F>;
|
|
156
|
+
type TransactionOptions<F extends Func> = {
|
|
157
|
+
key: string;
|
|
158
|
+
do: Transact<F>;
|
|
159
|
+
};
|
|
160
|
+
declare function runTransaction<F extends Func>(token: TransactionToken<F>, id?: string): (...parameters: Parameters<F>) => ReturnType<F>;
|
|
161
|
+
|
|
162
|
+
type WritableSelectorOptions<T> = {
|
|
163
|
+
key: string;
|
|
164
|
+
get: Read<() => T>;
|
|
165
|
+
set: Write<(newValue: T) => void>;
|
|
166
|
+
};
|
|
167
|
+
type ReadonlySelectorOptions<T> = {
|
|
168
|
+
key: string;
|
|
169
|
+
get: Read<() => T>;
|
|
170
|
+
};
|
|
171
|
+
type WritableSelectorFamilyOptions<T, K extends Canonical> = {
|
|
172
|
+
key: string;
|
|
173
|
+
get: (key: K) => Read<() => T>;
|
|
174
|
+
set: (key: K) => Write<(newValue: T) => void>;
|
|
175
|
+
};
|
|
176
|
+
type ReadonlySelectorFamilyOptions<T, K extends Canonical> = {
|
|
177
|
+
key: string;
|
|
178
|
+
get: (key: K) => Read<() => T>;
|
|
179
|
+
};
|
|
180
|
+
type WritableSelectorFamilyToken<T, K extends Canonical> = {
|
|
181
|
+
key: string;
|
|
182
|
+
type: `selector_family`;
|
|
183
|
+
__T?: T;
|
|
184
|
+
__K?: K;
|
|
185
|
+
};
|
|
186
|
+
type ReadonlySelectorFamilyToken<T, K extends Canonical> = {
|
|
187
|
+
key: string;
|
|
188
|
+
type: `readonly_selector_family`;
|
|
189
|
+
__T?: T;
|
|
190
|
+
__K?: K;
|
|
191
|
+
};
|
|
192
|
+
type SelectorFamilyToken<T, K extends Canonical> = ReadonlySelectorFamilyToken<T, K> | WritableSelectorFamilyToken<T, K>;
|
|
193
|
+
|
|
194
|
+
type TimelineManageable = AtomFamilyToken<any, any> | AtomToken<any>;
|
|
195
|
+
type AtomOnly<M extends TimelineManageable> = M extends AtomFamilyToken<any, any> ? AtomToken<any> : M extends AtomToken<any> ? M : never;
|
|
196
|
+
type TimelineToken<M> = {
|
|
197
|
+
key: string;
|
|
198
|
+
type: `timeline`;
|
|
199
|
+
__M?: M;
|
|
200
|
+
};
|
|
201
|
+
type TimelineOptions<ManagedAtom extends TimelineManageable> = {
|
|
202
|
+
key: string;
|
|
203
|
+
scope: ManagedAtom[];
|
|
204
|
+
shouldCapture?: (update: TimelineUpdate<ManagedAtom>, timeline: Timeline<TimelineManageable>) => boolean;
|
|
205
|
+
};
|
|
206
|
+
type TimelineUpdate<ManagedAtom extends TimelineManageable> = TimelineAtomUpdate<ManagedAtom> | TimelineMoleculeCreation | TimelineMoleculeDisposal | TimelineSelectorUpdate<ManagedAtom> | TimelineStateCreation<AtomOnly<ManagedAtom>> | TimelineStateDisposal<AtomOnly<ManagedAtom>> | TimelineTransactionUpdate;
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* @public
|
|
210
|
+
* Disposes of a state in the implicit store
|
|
211
|
+
* @param token - The token of the state to dispose
|
|
212
|
+
* @overload Default
|
|
213
|
+
*/
|
|
214
|
+
declare function disposeState(token: ReadableToken<any>): void;
|
|
215
|
+
/**
|
|
216
|
+
* @public
|
|
217
|
+
* Disposes of a state family in the implicit store
|
|
218
|
+
* @param token - The token of the state family to dispose
|
|
219
|
+
* @param key - The unique key of the state to dispose
|
|
220
|
+
*/
|
|
221
|
+
declare function disposeState<K extends Canonical>(token: ReadableFamilyToken<any, K>, key: K): void;
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* @public
|
|
225
|
+
* Finds a {@link MutableAtomToken} in the store
|
|
226
|
+
* @param token - A {@link MutableAtomFamilyToken}
|
|
227
|
+
* @param key - The key of the state
|
|
228
|
+
* @returns
|
|
229
|
+
* The current value of the state
|
|
230
|
+
* @overload Mutable Atom
|
|
231
|
+
*/
|
|
232
|
+
declare function findState<T extends Transceiver<any>, J extends Json.Serializable, K extends Canonical, Key extends K>(token: MutableAtomFamilyToken<T, J, K>, key: Key): MutableAtomToken<T, J, K>;
|
|
233
|
+
/**
|
|
234
|
+
* @public
|
|
235
|
+
* Finds a state in the store
|
|
236
|
+
* @param token - The token of the state family
|
|
237
|
+
* @param key - The key of the state
|
|
238
|
+
* @returns
|
|
239
|
+
* The current value of the state
|
|
240
|
+
* @overload Regular Atom
|
|
241
|
+
*/
|
|
242
|
+
declare function findState<T, K extends Canonical, Key extends K>(token: RegularAtomFamilyToken<T, K>, key: Key): RegularAtomToken<T, K>;
|
|
243
|
+
/**
|
|
244
|
+
* @public
|
|
245
|
+
* Finds a state in the store
|
|
246
|
+
* @param token - The token of the state family
|
|
247
|
+
* @param key - The key of the state
|
|
248
|
+
* @returns
|
|
249
|
+
* The current value of the state
|
|
250
|
+
* @overload Writable Selector
|
|
251
|
+
*/
|
|
252
|
+
declare function findState<T, K extends Canonical, Key extends K>(token: WritableSelectorFamilyToken<T, K>, key: Key): WritableSelectorToken<T, K>;
|
|
253
|
+
/**
|
|
254
|
+
* @public
|
|
255
|
+
* Finds a state in the store
|
|
256
|
+
* @param token - The token of the state family
|
|
257
|
+
* @param key - The key of the state
|
|
258
|
+
* @returns
|
|
259
|
+
* The current value of the state
|
|
260
|
+
* @overload Readonly Selector
|
|
261
|
+
*/
|
|
262
|
+
declare function findState<T, K extends Canonical, Key extends K>(token: ReadonlySelectorFamilyToken<T, K>, key: Key): ReadonlySelectorToken<T, K>;
|
|
263
|
+
/**
|
|
264
|
+
* @public
|
|
265
|
+
* Finds a state in the store
|
|
266
|
+
* @param token - The token of the state family
|
|
267
|
+
* @param key - The key of the state
|
|
268
|
+
* @returns
|
|
269
|
+
* The current value of the state
|
|
270
|
+
* @overload Writable State
|
|
271
|
+
*/
|
|
272
|
+
declare function findState<T, K extends Canonical, Key extends K>(token: WritableFamilyToken<T, K>, key: Key): WritableToken<T, K>;
|
|
273
|
+
/**
|
|
274
|
+
* @public
|
|
275
|
+
* Finds a {@link ReadableToken} in the store
|
|
276
|
+
* @param token - A {@link ReadableFamilyToken}
|
|
277
|
+
* @param key - The key of the state
|
|
278
|
+
* @returns
|
|
279
|
+
* The current value of the state
|
|
280
|
+
* @overload Unknown
|
|
281
|
+
* @default
|
|
282
|
+
*/
|
|
283
|
+
declare function findState<T, K extends Canonical, Key extends K>(token: ReadableFamilyToken<T, K>, key: Key): ReadableToken<T, K>;
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* @public
|
|
287
|
+
* Get the current value of a state
|
|
288
|
+
* @param token - The token of the state to get
|
|
289
|
+
* @return The current value of the state
|
|
290
|
+
* @overload Default
|
|
291
|
+
* @default
|
|
292
|
+
*/
|
|
293
|
+
declare function getState<T>(token: ReadableToken<T>): T;
|
|
294
|
+
/**
|
|
295
|
+
* @public
|
|
296
|
+
* Get the current value of a state family
|
|
297
|
+
* @param token - The token of a state family
|
|
298
|
+
* @param key - The unique key of the state to get
|
|
299
|
+
* @return The current value of the state
|
|
300
|
+
* @overload Streamlined
|
|
301
|
+
*/
|
|
302
|
+
declare function getState<T, K extends Canonical, Key extends K>(token: ReadableFamilyToken<T, K>, key: Key): T;
|
|
303
|
+
|
|
304
|
+
type SetUpdate = `add:${string}` | `clear:${string}` | `del:${string}` | `tx:${string}`;
|
|
305
|
+
type NumberedSetUpdate = `${number}=${SetUpdate}`;
|
|
306
|
+
interface SetRTXJson<P extends primitive> extends Json.Object {
|
|
307
|
+
members: P[];
|
|
308
|
+
cache: (NumberedSetUpdate | null)[];
|
|
309
|
+
cacheLimit: number;
|
|
310
|
+
cacheIdx: number;
|
|
311
|
+
cacheUpdateNumber: number;
|
|
312
|
+
}
|
|
313
|
+
declare class SetRTX<P extends primitive> extends Set<P> implements Transceiver<NumberedSetUpdate>, Lineage {
|
|
314
|
+
mode: TransceiverMode;
|
|
315
|
+
readonly subject: Subject<SetUpdate>;
|
|
316
|
+
cacheLimit: number;
|
|
317
|
+
cache: (NumberedSetUpdate | null)[];
|
|
318
|
+
cacheIdx: number;
|
|
319
|
+
cacheUpdateNumber: number;
|
|
320
|
+
constructor(values?: Iterable<P>, cacheLimit?: number);
|
|
321
|
+
toJSON(): SetRTXJson<P>;
|
|
322
|
+
static fromJSON<P extends primitive>(json: SetRTXJson<P>): SetRTX<P>;
|
|
323
|
+
add(value: P): this;
|
|
324
|
+
clear(): void;
|
|
325
|
+
delete(value: P): boolean;
|
|
326
|
+
readonly parent: SetRTX<P> | null;
|
|
327
|
+
child: SetRTX<P> | null;
|
|
328
|
+
transactionUpdates: SetUpdate[] | null;
|
|
329
|
+
transaction(run: (child: SetRTX<P>) => boolean): void;
|
|
330
|
+
protected _subscribe(key: string, fn: (update: SetUpdate) => void): () => void;
|
|
331
|
+
subscribe(key: string, fn: (update: NumberedSetUpdate) => void): () => void;
|
|
332
|
+
emit(update: SetUpdate): void;
|
|
333
|
+
private doStep;
|
|
334
|
+
getUpdateNumber(update: NumberedSetUpdate): number;
|
|
335
|
+
do(update: NumberedSetUpdate): number | `OUT_OF_RANGE` | null;
|
|
336
|
+
undoStep(update: SetUpdate): void;
|
|
337
|
+
undo(update: NumberedSetUpdate): number | null;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
interface JoinOptions<ASide extends string, AType extends string, BSide extends string, BType extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json.Object | null> extends JunctionSchemaBase<ASide, BSide>, Partial<JunctionEntriesBase<AType, BType, Content>> {
|
|
341
|
+
readonly key: string;
|
|
342
|
+
readonly cardinality: Cardinality;
|
|
343
|
+
readonly isAType: Refinement<string, AType>;
|
|
344
|
+
readonly isBType: Refinement<string, BType>;
|
|
345
|
+
}
|
|
346
|
+
type JoinToken<ASide extends string, AType extends string, BSide extends string, BType extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json.Object | null = null> = {
|
|
347
|
+
key: string;
|
|
348
|
+
type: `join`;
|
|
349
|
+
cardinality: Cardinality;
|
|
350
|
+
a: ASide;
|
|
351
|
+
b: BSide;
|
|
352
|
+
__aType?: AType;
|
|
353
|
+
__bType?: BType;
|
|
354
|
+
__content?: Content;
|
|
355
|
+
};
|
|
356
|
+
type JoinStates<ASide extends string, AType extends string, BSide extends string, BType extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json.Object | null> = Cardinality extends `1:1` ? (Content extends Json.Object ? {
|
|
357
|
+
readonly [A in ASide as `${A}EntryOf${Capitalize<BSide>}`]: ReadonlySelectorToken<[
|
|
358
|
+
AType,
|
|
359
|
+
Content
|
|
360
|
+
] | null, BType>;
|
|
361
|
+
} & {
|
|
362
|
+
readonly [B in BSide as `${B}EntryOf${Capitalize<ASide>}`]: ReadonlySelectorToken<[
|
|
363
|
+
BType,
|
|
364
|
+
Content
|
|
365
|
+
] | null, AType>;
|
|
366
|
+
} : {}) & {
|
|
367
|
+
readonly [A in ASide as `${A}KeyOf${Capitalize<BSide>}`]: ReadonlySelectorToken<AType | null, BType>;
|
|
368
|
+
} & {
|
|
369
|
+
readonly [B in BSide as `${B}KeyOf${Capitalize<ASide>}`]: ReadonlySelectorToken<BType | null, AType>;
|
|
370
|
+
} : Cardinality extends `1:n` ? (Content extends Json.Object ? {
|
|
371
|
+
readonly [A in ASide as `${A}EntryOf${Capitalize<BSide>}`]: ReadonlySelectorToken<[
|
|
372
|
+
AType,
|
|
373
|
+
Content
|
|
374
|
+
] | null, BType>;
|
|
375
|
+
} & {
|
|
376
|
+
readonly [B in BSide as `${B}EntriesOf${Capitalize<ASide>}`]: ReadonlySelectorToken<[
|
|
377
|
+
BType,
|
|
378
|
+
Content
|
|
379
|
+
][], AType>;
|
|
380
|
+
} : {}) & {
|
|
381
|
+
readonly [A in ASide as `${A}KeyOf${Capitalize<BSide>}`]: ReadonlySelectorToken<AType | null, BType>;
|
|
382
|
+
} & {
|
|
383
|
+
readonly [B in BSide as `${B}KeysOf${Capitalize<ASide>}`]: ReadonlySelectorToken<BType[], AType>;
|
|
384
|
+
} : Cardinality extends `n:n` ? (Content extends Json.Object ? {
|
|
385
|
+
readonly [A in ASide as `${A}EntriesOf${Capitalize<BSide>}`]: ReadonlySelectorToken<[
|
|
386
|
+
AType,
|
|
387
|
+
Content
|
|
388
|
+
][], BType>;
|
|
389
|
+
} & {
|
|
390
|
+
readonly [B in BSide as `${B}EntriesOf${Capitalize<ASide>}`]: ReadonlySelectorToken<[
|
|
391
|
+
BType,
|
|
392
|
+
Content
|
|
393
|
+
][], AType>;
|
|
394
|
+
} : {}) & {
|
|
395
|
+
readonly [A in ASide as `${A}KeysOf${Capitalize<BSide>}`]: ReadonlySelectorToken<AType[], BType>;
|
|
396
|
+
} & {
|
|
397
|
+
readonly [B in BSide as `${B}KeysOf${Capitalize<ASide>}`]: ReadonlySelectorToken<BType[], AType>;
|
|
398
|
+
} : never;
|
|
399
|
+
|
|
400
|
+
declare const LoggerIconDictionary: {
|
|
401
|
+
readonly "\u231B": "Timeline event fully captured";
|
|
402
|
+
readonly "\u23E9": "Timeline redo";
|
|
403
|
+
readonly "\u23EA": "Timeline undo";
|
|
404
|
+
readonly "\u23ED\uFE0F": "Transaction redo";
|
|
405
|
+
readonly "\u23EE\uFE0F": "Transaction undo";
|
|
406
|
+
readonly "\u23F3": "Timeline event partially captured";
|
|
407
|
+
readonly "\u23F9\uFE0F": "Time-travel complete";
|
|
408
|
+
readonly "\u2705": "Realtime transaction success";
|
|
409
|
+
readonly "\u2728": "Computation complete";
|
|
410
|
+
readonly "\u274C": "Conflict prevents attempted action";
|
|
411
|
+
readonly "\u2B55": "Operation start";
|
|
412
|
+
readonly "\uD83D\uDD34": "Operation complete";
|
|
413
|
+
readonly "\u2757": "Operation blocked";
|
|
414
|
+
readonly "\uD83D\uDFE2": "Operation unblocked";
|
|
415
|
+
readonly "\uD83D\uDC1E": "Possible bug in AtomIO";
|
|
416
|
+
readonly "\uD83D\uDC40": "Subscription added";
|
|
417
|
+
readonly "\uD83D\uDC4B": "Greeting";
|
|
418
|
+
readonly "\uD83D\uDC4D": "Realtime acknowledgment";
|
|
419
|
+
readonly "\uD83D\uDC6A": "Family member added";
|
|
420
|
+
readonly "\uD83D\uDC81": "Notice";
|
|
421
|
+
readonly "\uD83D\uDCA5": "Caught";
|
|
422
|
+
readonly "\uD83D\uDCC1": "Stow update";
|
|
423
|
+
readonly "\uD83D\uDCC3": "Copy mutable";
|
|
424
|
+
readonly "\uD83D\uDCD6": "Read state";
|
|
425
|
+
readonly "\uD83D\uDCDD": "Write state";
|
|
426
|
+
readonly "\uD83D\uDCE2": "Notify subscribers";
|
|
427
|
+
readonly "\uD83D\uDD04": "Realtime transaction synchronized";
|
|
428
|
+
readonly "\uD83D\uDD0C": "Register dependency";
|
|
429
|
+
readonly "\uD83D\uDD0D": "Discover root";
|
|
430
|
+
readonly "\uD83D\uDD25": "Delete state";
|
|
431
|
+
readonly "\uD83D\uDD27": "Create mutable atom";
|
|
432
|
+
readonly "\uD83D\uDD28": "Create immutable atom";
|
|
433
|
+
readonly "\uD83D\uDDD1": "Evict cached value";
|
|
434
|
+
readonly "\uD83D\uDE48": "Subscription canceled";
|
|
435
|
+
readonly "\uD83D\uDE80": "Performance measure";
|
|
436
|
+
readonly "\uD83D\uDEC4": "Apply transaction";
|
|
437
|
+
readonly "\uD83D\uDEE0\uFE0F": "Install atom into store";
|
|
438
|
+
readonly "\uD83D\uDEEB": "Begin transaction";
|
|
439
|
+
readonly "\uD83D\uDEEC": "Complete transaction";
|
|
440
|
+
readonly "\uD83E\uDDEE": "Computing selector";
|
|
441
|
+
readonly "\uD83E\uDDF9": "Prepare to evict";
|
|
442
|
+
readonly "\uD83E\uDE82": "Abort transaction";
|
|
443
|
+
readonly "\uD83E\uDD1E": "Realtime optimistic update enqueued";
|
|
444
|
+
readonly "\uD83D\uDC48": "Realtime confirmed update enqueued";
|
|
445
|
+
readonly "\uD83E\uDDD1\u200D\u2696\uFE0F": "Realtime update beginning reconciliation";
|
|
446
|
+
readonly "\uD83D\uDECE\uFE0F": "Realtime transaction received";
|
|
447
|
+
readonly "\uD83D\uDD2D": "Determining realtime perspective";
|
|
448
|
+
readonly "\uD83D\uDD8C": "Redacting realtime update";
|
|
449
|
+
readonly "\uD83D\uDC41": "Determining perspective";
|
|
450
|
+
};
|
|
451
|
+
type LoggerIcon = keyof typeof LoggerIconDictionary;
|
|
452
|
+
type TokenDenomination = `atom_family` | `atom` | `continuity` | `molecule_family` | `molecule` | `mutable_atom_family` | `mutable_atom` | `readonly_selector_family` | `readonly_selector` | `selector_family` | `selector` | `state` | `timeline` | `transaction` | `unknown`;
|
|
453
|
+
declare const LOG_LEVELS: readonly ["info", "warn", "error"];
|
|
454
|
+
type LogLevel = (typeof LOG_LEVELS)[number];
|
|
455
|
+
type LogFn = (icon: LoggerIcon, denomination: TokenDenomination, tokenKey: string, message: string, ...rest: unknown[]) => void;
|
|
456
|
+
type LogFilter = (...params: Parameters<LogFn>) => boolean;
|
|
457
|
+
type Logger = Record<LogLevel, LogFn>;
|
|
458
|
+
declare class AtomIOLogger implements Logger {
|
|
459
|
+
logLevel: `error` | `info` | `warn` | null;
|
|
460
|
+
private readonly filter?;
|
|
461
|
+
private readonly logger;
|
|
462
|
+
constructor(logLevel: `error` | `info` | `warn` | null, filter?: LogFilter | undefined, logger?: Logger);
|
|
463
|
+
error: LogFn;
|
|
464
|
+
info: LogFn;
|
|
465
|
+
warn: LogFn;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
declare const $claim: unique symbol;
|
|
469
|
+
type Claim<K extends Canonical> = K & {
|
|
470
|
+
[$claim]?: true;
|
|
471
|
+
};
|
|
472
|
+
declare class Realm<H extends Hierarchy> {
|
|
473
|
+
store: Store;
|
|
474
|
+
constructor(store?: Store);
|
|
475
|
+
allocate<V extends Vassal<H>, A extends Above<V, H>>(provenance: A, key: V, attachmentStyle?: `all` | `any`): Claim<V>;
|
|
476
|
+
fuse<C extends CompoundFrom<H>, T extends C extends CompoundTypedKey<infer t, any, any> ? t : never, A extends C extends CompoundTypedKey<any, infer v, any> ? v : never, B extends C extends CompoundTypedKey<any, any, infer m> ? m : never>(type: T, reagentA: SingularTypedKey<A>, reagentB: SingularTypedKey<B>): Claim<CompoundTypedKey<T, A, B>>;
|
|
477
|
+
deallocate<V extends Vassal<H>>(claim: Claim<V>): void;
|
|
478
|
+
claim<V extends Exclude<Vassal<H>, CompoundTypedKey>, A extends Above<V, H>>(newProvenance: A, claim: Claim<V>, exclusive?: `exclusive`): Claim<V>;
|
|
479
|
+
}
|
|
480
|
+
declare class Anarchy {
|
|
481
|
+
store: Store;
|
|
482
|
+
realm: Realm<any>;
|
|
483
|
+
constructor(store?: Store);
|
|
484
|
+
allocate(provenance: Canonical, key: Canonical, attachmentStyle?: `all` | `any`): void;
|
|
485
|
+
deallocate(key: Canonical): void;
|
|
486
|
+
claim(newProvenance: Canonical, key: Canonical, exclusive?: `exclusive`): void;
|
|
487
|
+
}
|
|
488
|
+
declare const T$ = "T$";
|
|
489
|
+
type T$ = typeof T$;
|
|
490
|
+
type TypeTag<T extends string> = `${T$}--${T}`;
|
|
491
|
+
type SingularTypedKey<T extends string = string> = `${T}::${string}`;
|
|
492
|
+
type CompoundTypedKey<A extends string = string, B extends string = string, C extends string = string> = `${TypeTag<A>}==${SingularTypedKey<B>}++${SingularTypedKey<C>}`;
|
|
493
|
+
type TypedKey<A extends string = string, B extends string = string, C extends string = string> = CompoundTypedKey<A, B, C> | SingularTypedKey<A>;
|
|
494
|
+
type Scope = SingularTypedKey[];
|
|
495
|
+
type MutualFealty = {
|
|
496
|
+
above: Scope;
|
|
497
|
+
below: CompoundTypedKey;
|
|
498
|
+
};
|
|
499
|
+
type ExclusiveFealty = {
|
|
500
|
+
above: TypedKey | `root`;
|
|
501
|
+
below: Scope;
|
|
502
|
+
};
|
|
503
|
+
type Fealty = ExclusiveFealty | MutualFealty;
|
|
504
|
+
type Hierarchy<F extends Fealty[] = Fealty[]> = Each<F>;
|
|
505
|
+
type Vassal<H extends Hierarchy> = {
|
|
506
|
+
[K in keyof H]: H[K] extends MutualFealty ? H[K][`below`] : H[K] extends {
|
|
507
|
+
below: Array<infer V>;
|
|
508
|
+
} ? V extends TypedKey ? V : never : never;
|
|
509
|
+
}[keyof H];
|
|
510
|
+
type Above<TK extends TypedKey, H extends Hierarchy> = {
|
|
511
|
+
[K in keyof H]: H[K] extends MutualFealty ? TK extends H[K][`below`] ? H[K][`above`] : never : H[K] extends {
|
|
512
|
+
below: Array<infer V>;
|
|
513
|
+
} ? TK extends V ? H[K] extends ExclusiveFealty ? H[K][`above`] : never : never : never;
|
|
514
|
+
}[keyof H];
|
|
515
|
+
type CompoundFrom<H extends Hierarchy> = {
|
|
516
|
+
[K in keyof H]: H[K] extends MutualFealty ? H[K][`below`] : never;
|
|
517
|
+
}[keyof H];
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* @public
|
|
521
|
+
* A function that sets the value of a state.
|
|
522
|
+
* @param oldValue - The current value of the state.
|
|
523
|
+
* @returns
|
|
524
|
+
* The new value of the state.
|
|
525
|
+
*/
|
|
526
|
+
type Setter<T, New extends T> = (oldValue: T) => New;
|
|
527
|
+
/**
|
|
528
|
+
* @public
|
|
529
|
+
* Set the value of a state into the implicit store.
|
|
530
|
+
* @param token - An atom or writable selector token.
|
|
531
|
+
* @param value - The new value of the state.
|
|
532
|
+
* @overload Default
|
|
533
|
+
* @default
|
|
534
|
+
*/
|
|
535
|
+
declare function setState<T, New extends T>(token: WritableToken<T>, value: New | Setter<T, New>): void;
|
|
536
|
+
/**
|
|
537
|
+
* @public
|
|
538
|
+
* Set the value of a state into the implicit store.
|
|
539
|
+
* @param token - An atom family or writable selector family token.
|
|
540
|
+
* @param key - The unique key of the state to set.
|
|
541
|
+
* @param value - The new value of the state.
|
|
542
|
+
* @overload Streamlined
|
|
543
|
+
*/
|
|
544
|
+
declare function setState<T, K extends Canonical, New extends T, Key extends K>(token: WritableFamilyToken<T, K>, key: Key, value: New | Setter<T, New>): void;
|
|
545
|
+
|
|
546
|
+
type StateUpdate<T> = {
|
|
547
|
+
newValue: T;
|
|
548
|
+
oldValue: T;
|
|
549
|
+
};
|
|
550
|
+
type KeyedStateUpdate<T> = Flat<StateUpdate<T> & {
|
|
551
|
+
key: string;
|
|
552
|
+
type: `atom_update` | `selector_update`;
|
|
553
|
+
family?: FamilyMetadata;
|
|
554
|
+
}>;
|
|
555
|
+
type UpdateHandler<T> = (update: StateUpdate<T>) => void;
|
|
556
|
+
type TransactionUpdateHandler<F extends Func> = (data: TransactionUpdate<F>) => void;
|
|
557
|
+
|
|
558
|
+
type TokenType<Comparison extends ReadableFamilyToken<any, any> | ReadableToken<any>> = Comparison extends ReadableToken<infer RepresentedValue> ? RepresentedValue : Comparison extends ReadableFamilyToken<infer RepresentedValue, any> ? RepresentedValue : never;
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* @public
|
|
562
|
+
* A token is an object that uniquely identifies a particular state, family, timeline, or transaction.
|
|
563
|
+
*
|
|
564
|
+
* While they represent one of these resources, they are not the resource itself. Think of them like paper currency representing money in the bank.
|
|
565
|
+
*
|
|
566
|
+
* Tokens are returned from resource creation functions, such as {@link atom} and {@link transaction}.
|
|
567
|
+
*
|
|
568
|
+
* Tokens can be used as parameters to functions that take a token, such as {@link getState}, {@link setState}, or {@link runTransaction}.
|
|
569
|
+
*
|
|
570
|
+
* Tokens are fully serializable, so they can be passed between processes.
|
|
571
|
+
*/
|
|
572
|
+
type AtomIOToken = ReadableFamilyToken<any, any> | ReadableToken<any> | TimelineToken<any> | TransactionToken<any>;
|
|
573
|
+
/** @public */
|
|
574
|
+
type RegularAtomToken<T, K extends Canonical = any> = {
|
|
575
|
+
/** The unique identifier of the atom. */
|
|
576
|
+
key: string;
|
|
577
|
+
/** Discriminator. */
|
|
578
|
+
type: `atom`;
|
|
579
|
+
/** Present if the atom belongs to a family. */
|
|
580
|
+
family?: FamilyMetadata<K>;
|
|
581
|
+
/** Never present. This is a marker that preserves the type of the atom's value. */
|
|
582
|
+
__T?: T;
|
|
583
|
+
};
|
|
584
|
+
/** @public */
|
|
585
|
+
type MutableAtomToken<T extends Transceiver<any>, J extends Json.Serializable, K extends Canonical = any> = {
|
|
586
|
+
/** The unique identifier of the atom. */
|
|
587
|
+
key: string;
|
|
588
|
+
/** Discriminator. */
|
|
589
|
+
type: `mutable_atom`;
|
|
590
|
+
/** Present if the atom belongs to a family. */
|
|
591
|
+
family?: FamilyMetadata<K>;
|
|
592
|
+
/** Never present. This is a marker that preserves the JSON form of the atom's transceiver value. */
|
|
593
|
+
__J?: J;
|
|
594
|
+
/** Never present. This is a marker that preserves the type of the atom's transceiver value. */
|
|
595
|
+
__U?: T extends Transceiver<infer Update> ? Update : never;
|
|
596
|
+
};
|
|
597
|
+
/** @public */
|
|
598
|
+
type AtomToken<T, K extends Canonical = any> = MutableAtomToken<T extends Transceiver<any> ? T : never, any, K> | RegularAtomToken<T, K>;
|
|
599
|
+
/** @public */
|
|
600
|
+
type WritableSelectorToken<T, K extends Canonical = any> = {
|
|
601
|
+
/** The unique identifier of the selector. */
|
|
602
|
+
key: string;
|
|
603
|
+
/** Discriminator. */
|
|
604
|
+
type: `selector`;
|
|
605
|
+
/** Present if the selector belongs to a family. */
|
|
606
|
+
family?: FamilyMetadata<K>;
|
|
607
|
+
/** Never present. This is a marker that preserves the type of the selector's value. */
|
|
608
|
+
__T?: T;
|
|
609
|
+
};
|
|
610
|
+
/** @public */
|
|
611
|
+
type ReadonlySelectorToken<T, K extends Canonical = any> = {
|
|
612
|
+
/** The unique identifier of the selector. */
|
|
613
|
+
key: string;
|
|
614
|
+
/** Discriminator. */
|
|
615
|
+
type: `readonly_selector`;
|
|
616
|
+
/** Present if the selector belongs to a family. */
|
|
617
|
+
family?: FamilyMetadata<K>;
|
|
618
|
+
/** Never present. This is a marker that preserves the type of the selector's value. */
|
|
619
|
+
__T?: T;
|
|
620
|
+
};
|
|
621
|
+
/** @public */
|
|
622
|
+
type SelectorToken<T, K extends Canonical = any> = ReadonlySelectorToken<T, K> | WritableSelectorToken<T, K>;
|
|
623
|
+
/**
|
|
624
|
+
* @public
|
|
625
|
+
* These states can be set.
|
|
626
|
+
*/
|
|
627
|
+
type WritableToken<T, K extends Canonical = any> = AtomToken<T, K> | WritableSelectorToken<T, K>;
|
|
628
|
+
/**
|
|
629
|
+
* @public
|
|
630
|
+
* These states cannot be set.
|
|
631
|
+
*/
|
|
632
|
+
type ReadableToken<T, K extends Canonical = any> = AtomToken<T, K> | SelectorToken<T, K>;
|
|
633
|
+
/**
|
|
634
|
+
* @public
|
|
635
|
+
* States belonging to this family can be set.
|
|
636
|
+
*/
|
|
637
|
+
type WritableFamilyToken<T, K extends Canonical> = AtomFamilyToken<T, K> | WritableSelectorFamilyToken<T, K>;
|
|
638
|
+
/**
|
|
639
|
+
* @public
|
|
640
|
+
* States belonging to this family cannot be set.
|
|
641
|
+
*/
|
|
642
|
+
type ReadableFamilyToken<T, K extends Canonical> = AtomFamilyToken<T, K> | SelectorFamilyToken<T, K>;
|
|
643
|
+
/**
|
|
644
|
+
* @public
|
|
645
|
+
* Identifies a state's connection to its family.
|
|
646
|
+
*/
|
|
647
|
+
type FamilyMetadata<K extends Canonical = any> = {
|
|
648
|
+
/** The family's unique key. */
|
|
649
|
+
key: string;
|
|
650
|
+
/** The family member's unique identifier, in the form of a string. */
|
|
651
|
+
subKey: stringified<K>;
|
|
652
|
+
};
|
|
5
653
|
|
|
6
654
|
declare class CircularBuffer<T> {
|
|
7
655
|
protected _buffer: T[];
|
|
@@ -142,11 +790,11 @@ declare class Junction<const ASide extends string, const AType extends string, c
|
|
|
142
790
|
|
|
143
791
|
declare const abortTransaction: (store: Store) => void;
|
|
144
792
|
|
|
145
|
-
declare function actUponStore<F extends Func>(token: TransactionToken<F>, id: string
|
|
793
|
+
declare function actUponStore<F extends Func>(store: Store, token: TransactionToken<F>, id: string): (...parameters: Parameters<F>) => ReturnType<F>;
|
|
146
794
|
|
|
147
795
|
declare const applyTransaction: <F extends Func>(output: ReturnType<F>, store: Store) => void;
|
|
148
796
|
|
|
149
|
-
declare function assignTransactionToContinuity(
|
|
797
|
+
declare function assignTransactionToContinuity(store: Store, continuityKey: string, transactionKey: string): void;
|
|
150
798
|
|
|
151
799
|
interface RootStore extends Store {
|
|
152
800
|
transactionMeta: TransactionEpoch;
|
|
@@ -161,7 +809,7 @@ interface ChildStore extends Store {
|
|
|
161
809
|
declare function isRootStore(store: Store): store is RootStore;
|
|
162
810
|
declare function isChildStore(store: Store): store is ChildStore;
|
|
163
811
|
|
|
164
|
-
declare const buildTransaction: (key: string, params: any[],
|
|
812
|
+
declare const buildTransaction: (store: Store, key: string, params: any[], id: string) => ChildStore;
|
|
165
813
|
|
|
166
814
|
declare class Subject<T> {
|
|
167
815
|
Subscriber: (value: T) => void;
|
|
@@ -183,14 +831,14 @@ type Transaction<F extends Func> = {
|
|
|
183
831
|
subject: Subject<TransactionUpdate<F>>;
|
|
184
832
|
run: (parameters: Parameters<F>, id?: string) => ReturnType<F>;
|
|
185
833
|
};
|
|
186
|
-
declare function createTransaction<F extends Func>(options: TransactionOptions<F
|
|
834
|
+
declare function createTransaction<F extends Func>(store: Store, options: TransactionOptions<F>): TransactionToken<F>;
|
|
187
835
|
|
|
188
|
-
declare function getContinuityKey(
|
|
189
|
-
declare function getEpochNumberOfContinuity(
|
|
190
|
-
declare function getEpochNumberOfAction(
|
|
836
|
+
declare function getContinuityKey(store: Store, transactionKey: string): string | undefined;
|
|
837
|
+
declare function getEpochNumberOfContinuity(store: Store, continuityKey: string): number | undefined;
|
|
838
|
+
declare function getEpochNumberOfAction(store: Store, transactionKey: string): number | undefined;
|
|
191
839
|
|
|
192
|
-
declare function setEpochNumberOfContinuity(continuityKey: string, newEpoch: number
|
|
193
|
-
declare function setEpochNumberOfAction(transactionKey: string, newEpoch: number
|
|
840
|
+
declare function setEpochNumberOfContinuity(store: Store, continuityKey: string, newEpoch: number): void;
|
|
841
|
+
declare function setEpochNumberOfAction(store: Store, transactionKey: string, newEpoch: number): void;
|
|
194
842
|
|
|
195
843
|
declare const TRANSACTION_PHASES: readonly ["idle", "building", "applying"];
|
|
196
844
|
type TransactionPhase = (typeof TRANSACTION_PHASES)[number];
|
|
@@ -224,11 +872,11 @@ declare function deposit<T extends Func>(state: Transaction<T>): TransactionToke
|
|
|
224
872
|
declare function deposit<M extends TimelineManageable>(state: Timeline<M>): TimelineToken<M>;
|
|
225
873
|
declare function deposit(resource: AtomIOInternalResource): AtomIOToken;
|
|
226
874
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
declare function
|
|
875
|
+
declare function editRelationsInStore<ASide extends string, AType extends string, BSide extends string, BType extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json.Object | null>(token: JoinToken<ASide, AType, BSide, BType, Cardinality, Content>, change: (relations: Junction<ASide, AType, BSide, BType, Content>) => void, store: Store): void;
|
|
876
|
+
|
|
877
|
+
declare function findRelationsInStore<ASide extends string, AType extends string, BSide extends string, BType extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json.Object | null>(token: JoinToken<ASide, AType, BSide, BType, Cardinality, Content>, key: AType | BType, store: Store): JoinStates<ASide, AType, BSide, BType, Cardinality, Content>;
|
|
878
|
+
|
|
879
|
+
declare function getInternalRelationsFromStore(token: JoinToken<any, any, any, any, any, any>, store: Store): MutableAtomFamilyToken<SetRTX<string>, SetRTXJson<string>, string>;
|
|
232
880
|
|
|
233
881
|
type Molecule<K extends Canonical> = {
|
|
234
882
|
readonly key: K;
|
|
@@ -241,6 +889,74 @@ declare function fuseWithinStore<H extends Hierarchy, C extends CompoundFrom<H>,
|
|
|
241
889
|
declare function deallocateFromStore<H extends Hierarchy, V extends Vassal<H>>(store: Store, claim: Claim<V>): void;
|
|
242
890
|
declare function claimWithinStore<H extends Hierarchy, V extends Exclude<Vassal<H>, CompoundTypedKey>, A extends Above<V, H>>(store: Store, newProvenance: A, claim: Claim<V>, exclusive?: `exclusive`): Claim<V>;
|
|
243
891
|
|
|
892
|
+
type JoinStateFamilies<ASide extends string, AType extends string, BSide extends string, BType extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json.Object | null> = Cardinality extends `1:1` ? (Content extends Json.Object ? {
|
|
893
|
+
readonly [A in ASide as `${A}EntryOf${Capitalize<BSide>}`]: ReadonlySelectorFamilyToken<[
|
|
894
|
+
AType,
|
|
895
|
+
Content
|
|
896
|
+
] | null, BType>;
|
|
897
|
+
} & {
|
|
898
|
+
readonly [B in BSide as `${B}EntryOf${Capitalize<ASide>}`]: ReadonlySelectorFamilyToken<[
|
|
899
|
+
BType,
|
|
900
|
+
Content
|
|
901
|
+
] | null, AType>;
|
|
902
|
+
} : {}) & {
|
|
903
|
+
readonly [A in ASide as `${A}KeyOf${Capitalize<BSide>}`]: ReadonlySelectorFamilyToken<AType | null, BType>;
|
|
904
|
+
} & {
|
|
905
|
+
readonly [B in BSide as `${B}KeyOf${Capitalize<ASide>}`]: ReadonlySelectorFamilyToken<BType | null, AType>;
|
|
906
|
+
} : Cardinality extends `1:n` ? (Content extends Json.Object ? {
|
|
907
|
+
readonly [A in ASide as `${A}EntryOf${Capitalize<BSide>}`]: ReadonlySelectorFamilyToken<[
|
|
908
|
+
AType,
|
|
909
|
+
Content
|
|
910
|
+
] | null, BType>;
|
|
911
|
+
} & {
|
|
912
|
+
readonly [B in BSide as `${B}EntriesOf${Capitalize<ASide>}`]: ReadonlySelectorFamilyToken<[
|
|
913
|
+
BType,
|
|
914
|
+
Content
|
|
915
|
+
][], AType>;
|
|
916
|
+
} : {}) & {
|
|
917
|
+
readonly [A in ASide as `${A}KeyOf${Capitalize<BSide>}`]: ReadonlySelectorFamilyToken<AType | null, BType>;
|
|
918
|
+
} & {
|
|
919
|
+
readonly [B in BSide as `${B}KeysOf${Capitalize<ASide>}`]: ReadonlySelectorFamilyToken<BType[], AType>;
|
|
920
|
+
} : Cardinality extends `n:n` ? (Content extends Json.Object ? {
|
|
921
|
+
readonly [A in ASide as `${A}EntriesOf${Capitalize<BSide>}`]: ReadonlySelectorFamilyToken<[
|
|
922
|
+
AType,
|
|
923
|
+
Content
|
|
924
|
+
][], BType>;
|
|
925
|
+
} & {
|
|
926
|
+
readonly [B in BSide as `${B}EntriesOf${Capitalize<ASide>}`]: ReadonlySelectorFamilyToken<[
|
|
927
|
+
BType,
|
|
928
|
+
Content
|
|
929
|
+
][], AType>;
|
|
930
|
+
} : {}) & {
|
|
931
|
+
readonly [A in ASide as `${A}KeysOf${Capitalize<BSide>}`]: ReadonlySelectorFamilyToken<AType[], BType>;
|
|
932
|
+
} & {
|
|
933
|
+
readonly [B in BSide as `${B}KeysOf${Capitalize<ASide>}`]: ReadonlySelectorFamilyToken<BType[], AType>;
|
|
934
|
+
} : never;
|
|
935
|
+
declare class Join<const ASide extends string, const AType extends string, const BSide extends string, const BType extends string, const Cardinality extends `1:1` | `1:n` | `n:n`, const Content extends Json.Object | null = null, const ContentKey extends CompoundTypedKey<`content`, ASide, BSide> = CompoundTypedKey<`content`, ASide, BSide>> {
|
|
936
|
+
private toolkit;
|
|
937
|
+
options: JoinOptions<ASide, AType, BSide, BType, Cardinality, Content>;
|
|
938
|
+
defaultContent: Content | undefined;
|
|
939
|
+
molecules: Map<string, Molecule<any>>;
|
|
940
|
+
relations: Junction<ASide, AType, BSide, BType, Content>;
|
|
941
|
+
states: JoinStateFamilies<ASide, AType, BSide, BType, Cardinality, Content>;
|
|
942
|
+
core: {
|
|
943
|
+
relatedKeysAtoms: MutableAtomFamilyToken<SetRTX<string>, SetRTXJson<string>, string>;
|
|
944
|
+
};
|
|
945
|
+
transact(toolkit: SetterToolkit, run: (join: Join<ASide, AType, BSide, BType, Cardinality, Content>) => void): void;
|
|
946
|
+
store: Store;
|
|
947
|
+
realm: Anarchy;
|
|
948
|
+
[Symbol.dispose](): void;
|
|
949
|
+
constructor(options: JoinOptions<ASide, AType, BSide, BType, Cardinality, Content>, defaultContent: Content | undefined, store?: Store);
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
declare function getJoin<ASide extends string, AType extends string, BSide extends string, BType extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json.Object | null>(token: JoinToken<ASide, AType, BSide, BType, Cardinality, Content>, store: Store): Join<ASide, AType, BSide, BType, Cardinality, Content>;
|
|
953
|
+
|
|
954
|
+
interface Lineage {
|
|
955
|
+
parent: typeof this | null;
|
|
956
|
+
child: typeof this | null;
|
|
957
|
+
}
|
|
958
|
+
declare function newest<T extends Lineage>(scion: T): T;
|
|
959
|
+
|
|
244
960
|
type OperationProgress = {
|
|
245
961
|
open: false;
|
|
246
962
|
} | {
|
|
@@ -297,7 +1013,7 @@ type Timeline<ManagedAtom extends TimelineManageable> = {
|
|
|
297
1013
|
subject: Subject<TimelineUpdate<ManagedAtom> | `redo` | `undo`>;
|
|
298
1014
|
subscriptions: Map<string, () => void>;
|
|
299
1015
|
};
|
|
300
|
-
declare function createTimeline<ManagedAtom extends TimelineManageable>(options: TimelineOptions<ManagedAtom>,
|
|
1016
|
+
declare function createTimeline<ManagedAtom extends TimelineManageable>(store: Store, options: TimelineOptions<ManagedAtom>, data?: Timeline<ManagedAtom>): TimelineToken<ManagedAtom>;
|
|
301
1017
|
|
|
302
1018
|
declare const timeTravel: (store: Store, action: `redo` | `undo`, token: TimelineToken<any>) => void;
|
|
303
1019
|
|
|
@@ -360,27 +1076,27 @@ declare const IMPLICIT: {
|
|
|
360
1076
|
};
|
|
361
1077
|
declare const clearStore: (store: Store) => void;
|
|
362
1078
|
|
|
363
|
-
declare function withdraw<T>(token: RegularAtomToken<T
|
|
364
|
-
declare function withdraw<T extends Transceiver<any>>(token: MutableAtomToken<T, any
|
|
365
|
-
declare function withdraw<T>(token: AtomToken<T
|
|
366
|
-
declare function withdraw<T>(token: WritableSelectorToken<T
|
|
367
|
-
declare function withdraw<T>(token: ReadonlySelectorToken<T
|
|
368
|
-
declare function withdraw<T>(token: SelectorToken<T
|
|
369
|
-
declare function withdraw<T>(token: WritableToken<T
|
|
370
|
-
declare function withdraw<T>(token: ReadableToken<T
|
|
371
|
-
declare function withdraw<T, K extends Canonical>(token: RegularAtomFamilyToken<T, K
|
|
372
|
-
declare function withdraw<T extends Transceiver<any>, J extends Json.Serializable, K extends Canonical>(token: MutableAtomFamilyToken<T, J, K
|
|
373
|
-
declare function withdraw<T, K extends Canonical>(token: AtomFamilyToken<T
|
|
374
|
-
declare function withdraw<T, K extends Canonical>(token: ReadonlySelectorFamilyToken<T, K
|
|
375
|
-
declare function withdraw<T, K extends Canonical>(token: WritableSelectorFamilyToken<T, K
|
|
376
|
-
declare function withdraw<T, K extends Canonical>(token: SelectorFamilyToken<T, K
|
|
377
|
-
declare function withdraw<T, K extends Canonical>(token: ReadableFamilyToken<T, K
|
|
378
|
-
declare function withdraw<T, K extends Canonical>(token: WritableFamilyToken<T, K
|
|
379
|
-
declare function withdraw<T extends Func>(token: TransactionToken<T
|
|
380
|
-
declare function withdraw<T>(token: TimelineToken<T
|
|
381
|
-
declare function withdraw<T>(token: WritableToken<T
|
|
382
|
-
declare function withdraw<T>(token: ReadableToken<T
|
|
383
|
-
declare function withdraw(
|
|
1079
|
+
declare function withdraw<T>(store: Store, token: RegularAtomToken<T>): RegularAtom<T>;
|
|
1080
|
+
declare function withdraw<T extends Transceiver<any>>(store: Store, token: MutableAtomToken<T, any>): MutableAtom<T, any>;
|
|
1081
|
+
declare function withdraw<T>(store: Store, token: AtomToken<T>): Atom<T>;
|
|
1082
|
+
declare function withdraw<T>(store: Store, token: WritableSelectorToken<T>): WritableSelector<T>;
|
|
1083
|
+
declare function withdraw<T>(store: Store, token: ReadonlySelectorToken<T>): ReadonlySelector<T>;
|
|
1084
|
+
declare function withdraw<T>(store: Store, token: SelectorToken<T>): Selector<T>;
|
|
1085
|
+
declare function withdraw<T>(store: Store, token: WritableToken<T>): WritableState<T>;
|
|
1086
|
+
declare function withdraw<T>(store: Store, token: ReadableToken<T>): ReadableState<T>;
|
|
1087
|
+
declare function withdraw<T, K extends Canonical>(store: Store, token: RegularAtomFamilyToken<T, K>): RegularAtomFamily<T, K>;
|
|
1088
|
+
declare function withdraw<T extends Transceiver<any>, J extends Json.Serializable, K extends Canonical>(store: Store, token: MutableAtomFamilyToken<T, J, K>): MutableAtomFamily<T, J, K>;
|
|
1089
|
+
declare function withdraw<T, K extends Canonical>(store: Store, token: AtomFamilyToken<T>): AtomFamily<T, any>;
|
|
1090
|
+
declare function withdraw<T, K extends Canonical>(store: Store, token: ReadonlySelectorFamilyToken<T, K>): ReadonlySelectorFamily<T, any>;
|
|
1091
|
+
declare function withdraw<T, K extends Canonical>(store: Store, token: WritableSelectorFamilyToken<T, K>): WritableSelectorFamily<T, any>;
|
|
1092
|
+
declare function withdraw<T, K extends Canonical>(store: Store, token: SelectorFamilyToken<T, K>): SelectorFamily<T, any>;
|
|
1093
|
+
declare function withdraw<T, K extends Canonical>(store: Store, token: ReadableFamilyToken<T, K>): ReadableFamily<T, any>;
|
|
1094
|
+
declare function withdraw<T, K extends Canonical>(store: Store, token: WritableFamilyToken<T, K>): WritableFamily<T, any>;
|
|
1095
|
+
declare function withdraw<T extends Func>(store: Store, token: TransactionToken<T>): Transaction<T extends Func ? T : never>;
|
|
1096
|
+
declare function withdraw<T>(store: Store, token: TimelineToken<T>): Timeline<T extends TimelineManageable ? T : never>;
|
|
1097
|
+
declare function withdraw<T>(store: Store, token: WritableToken<T>): WritableState<T>;
|
|
1098
|
+
declare function withdraw<T>(store: Store, token: ReadableToken<T>): ReadableState<T>;
|
|
1099
|
+
declare function withdraw(store: Store, token: AtomIOToken): AtomIOInternalResource;
|
|
384
1100
|
|
|
385
1101
|
interface Transceiver<S extends Json.Serializable> {
|
|
386
1102
|
do: (update: S) => number | `OUT_OF_RANGE` | null;
|
|
@@ -419,11 +1135,12 @@ declare class Tracker<Mutable extends Transceiver<any>> {
|
|
|
419
1135
|
private updateCore;
|
|
420
1136
|
mutableState: MutableAtomToken<Mutable, Json.Serializable>;
|
|
421
1137
|
latestUpdateState: RegularAtomToken<typeof this.Update | null>;
|
|
422
|
-
dispose: () => void;
|
|
1138
|
+
[Symbol.dispose]: () => void;
|
|
423
1139
|
constructor(mutableState: MutableAtomToken<Mutable, Json.Serializable>, store: Store);
|
|
424
1140
|
}
|
|
425
1141
|
|
|
426
1142
|
declare class FamilyTracker<Core extends Transceiver<any>, FamilyMemberKey extends Canonical> {
|
|
1143
|
+
private trackers;
|
|
427
1144
|
private readonly Update;
|
|
428
1145
|
readonly latestUpdateAtoms: RegularAtomFamily<typeof this.Update | null, FamilyMemberKey>;
|
|
429
1146
|
readonly mutableAtoms: MutableAtomFamily<Core, any, FamilyMemberKey>;
|
|
@@ -437,11 +1154,11 @@ declare function createRegularAtom<T>(store: Store, options: RegularAtomOptions<
|
|
|
437
1154
|
declare function createStandaloneAtom<T>(store: Store, options: RegularAtomOptions<T>): RegularAtomToken<T>;
|
|
438
1155
|
declare function createStandaloneAtom<T extends Transceiver<any>, J extends Json.Serializable>(store: Store, options: MutableAtomOptions<T, J>): MutableAtomToken<T, J>;
|
|
439
1156
|
|
|
440
|
-
declare function disposeAtom(atomToken: AtomToken<unknown
|
|
1157
|
+
declare function disposeAtom(store: Store, atomToken: AtomToken<unknown>): void;
|
|
441
1158
|
|
|
442
|
-
declare const isAtomDefault: (
|
|
443
|
-
declare const markAtomAsDefault: (
|
|
444
|
-
declare const markAtomAsNotDefault: (
|
|
1159
|
+
declare const isAtomDefault: (store: Store, key: string) => boolean;
|
|
1160
|
+
declare const markAtomAsDefault: (store: Store, key: string) => void;
|
|
1161
|
+
declare const markAtomAsNotDefault: (store: Store, key: string) => void;
|
|
445
1162
|
|
|
446
1163
|
/**
|
|
447
1164
|
* A Promise whose incoming value can be hot swapped.
|
|
@@ -463,11 +1180,13 @@ declare class Future<T> extends Promise<T> {
|
|
|
463
1180
|
use(value: Promise<T> | T): void;
|
|
464
1181
|
}
|
|
465
1182
|
|
|
466
|
-
declare function cacheValue<T>(key: string, value: T, subject: Subject<StateUpdate<unknown
|
|
467
|
-
declare function cacheValue<T extends Promise<any>>(key: string, value: T, subject: Subject<StateUpdate<unknown
|
|
1183
|
+
declare function cacheValue<T>(store: Store, key: string, value: T, subject: Subject<StateUpdate<unknown>>): T;
|
|
1184
|
+
declare function cacheValue<T extends Promise<any>>(store: Store, key: string, value: T, subject: Subject<StateUpdate<unknown>>): Future<T>;
|
|
468
1185
|
declare const readCachedValue: <T>(token: ReadableState<any>, target: Store) => T;
|
|
469
1186
|
declare const evictCachedValue: (key: string, target: Store) => void;
|
|
470
1187
|
|
|
1188
|
+
declare function capitalize<S extends string>(string: S): Capitalize<S>;
|
|
1189
|
+
|
|
471
1190
|
declare function createAtomFamily<T extends Transceiver<any>, J extends Json.Serializable, K extends Canonical>(store: Store, options: MutableAtomFamilyOptions<T, J, K>): MutableAtomFamilyToken<T, J, K>;
|
|
472
1191
|
declare function createAtomFamily<T, K extends Canonical>(store: Store, options: RegularAtomFamilyOptions<T, K>): RegularAtomFamilyToken<T, K>;
|
|
473
1192
|
|
|
@@ -516,7 +1235,7 @@ declare function getEnvironmentData(store: Store): EnvironmentData;
|
|
|
516
1235
|
declare function getFromStore<T>(store: Store, token: ReadableToken<T>): T;
|
|
517
1236
|
declare function getFromStore<T, K extends Canonical>(store: Store, token: ReadableFamilyToken<T, K>, key: K): T;
|
|
518
1237
|
|
|
519
|
-
declare const readOrComputeValue: <T>(state: ReadableState<T
|
|
1238
|
+
declare const readOrComputeValue: <T>(target: Store, state: ReadableState<T>) => T;
|
|
520
1239
|
|
|
521
1240
|
declare function getTrace(error: Error): string;
|
|
522
1241
|
|
|
@@ -544,11 +1263,11 @@ type ReadonlySelectorKey<T> = string & {
|
|
|
544
1263
|
__readonlySelectorKey?: never;
|
|
545
1264
|
__brand?: T;
|
|
546
1265
|
};
|
|
547
|
-
declare const isAtomKey: (
|
|
548
|
-
declare const isSelectorKey: (
|
|
549
|
-
declare const isReadonlySelectorKey: (
|
|
1266
|
+
declare const isAtomKey: (store: Store, key: string) => key is AtomKey<unknown>;
|
|
1267
|
+
declare const isSelectorKey: (store: Store, key: string) => key is SelectorKey<unknown>;
|
|
1268
|
+
declare const isReadonlySelectorKey: (store: Store, key: string) => key is ReadonlySelectorKey<unknown>;
|
|
550
1269
|
type StateKey<T> = AtomKey<T> | ReadonlySelectorKey<T> | SelectorKey<T>;
|
|
551
|
-
declare const isStateKey: (
|
|
1270
|
+
declare const isStateKey: (store: Store, key: string) => key is StateKey<unknown>;
|
|
552
1271
|
|
|
553
1272
|
declare class LazyMap<K, V> extends Map<K, V> {
|
|
554
1273
|
protected readonly source: Map<K, V>;
|
|
@@ -574,7 +1293,7 @@ declare function createStandaloneSelector<T>(store: Store, options: ReadonlySele
|
|
|
574
1293
|
|
|
575
1294
|
declare const createWritableSelector: <T>(store: Store, options: WritableSelectorOptions<T>, family: FamilyMetadata | undefined) => WritableSelectorToken<T>;
|
|
576
1295
|
|
|
577
|
-
declare function disposeSelector(selectorToken:
|
|
1296
|
+
declare function disposeSelector(store: Store, selectorToken: SelectorToken<unknown>): void;
|
|
578
1297
|
|
|
579
1298
|
declare const getSelectorDependencyKeys: (key: string, store: Store) => (AtomKey<unknown> | ReadonlySelectorKey<unknown> | SelectorKey<unknown>)[];
|
|
580
1299
|
|
|
@@ -588,25 +1307,25 @@ declare const updateSelectorAtoms: (selectorKey: string, dependency: ReadonlySel
|
|
|
588
1307
|
type Modify<T> = (thing: T) => T;
|
|
589
1308
|
declare const become: <T>(nextVersionOfThing: Modify<T> | T) => (originalThing: T) => T;
|
|
590
1309
|
|
|
591
|
-
declare const setAtomOrSelector: <T>(state: WritableState<T>, value: T | ((oldValue: T) => T)
|
|
1310
|
+
declare const setAtomOrSelector: <T>(store: Store, state: WritableState<T>, value: T | ((oldValue: T) => T)) => void;
|
|
592
1311
|
|
|
593
1312
|
declare function setIntoStore<T, New extends T>(store: Store, token: WritableToken<T>, value: New | ((oldValue: T) => New)): void;
|
|
594
1313
|
declare function setIntoStore<T, K extends Canonical, New extends T>(store: Store, token: WritableFamilyToken<T, K>, key: K, value: New | ((oldValue: T) => New)): void;
|
|
595
1314
|
|
|
596
|
-
declare const recallState: <T>(state: ReadableState<T
|
|
1315
|
+
declare const recallState: <T>(store: Store, state: ReadableState<T>) => T;
|
|
597
1316
|
|
|
598
|
-
declare function subscribeInStore<T>(store: Store
|
|
599
|
-
declare function subscribeInStore<F extends Func
|
|
600
|
-
declare function subscribeInStore<M extends TimelineManageable>(store: Store
|
|
601
|
-
declare function subscribeInStore<M extends TimelineManageable>(store: Store
|
|
1317
|
+
declare function subscribeInStore<T>(store: Store, token: ReadableToken<T>, handleUpdate: UpdateHandler<T>, key?: string): () => void;
|
|
1318
|
+
declare function subscribeInStore<F extends Func>(store: Store, token: TransactionToken<F>, handleUpdate: TransactionUpdateHandler<F>, key?: string): () => void;
|
|
1319
|
+
declare function subscribeInStore<M extends TimelineManageable>(store: Store, token: TimelineToken<M>, handleUpdate: (update: TimelineUpdate<M> | `redo` | `undo`) => void, key?: string): () => void;
|
|
1320
|
+
declare function subscribeInStore<M extends TimelineManageable>(store: Store, token: ReadableToken<any> | TimelineToken<M> | TransactionToken<any>, handleUpdate: TransactionUpdateHandler<any> | UpdateHandler<any> | ((update: TimelineUpdate<M> | `redo` | `undo`) => void), key?: string): () => void;
|
|
602
1321
|
|
|
603
|
-
declare const subscribeToRootAtoms: <T>(selector: Selector<T
|
|
1322
|
+
declare const subscribeToRootAtoms: <T>(store: Store, selector: Selector<T>) => (() => void)[];
|
|
604
1323
|
|
|
605
|
-
declare function subscribeToState<T>(
|
|
1324
|
+
declare function subscribeToState<T>(store: Store, token: ReadableToken<T>, key: string, handleUpdate: UpdateHandler<T>): () => void;
|
|
606
1325
|
|
|
607
|
-
declare const subscribeToTimeline: <ManagedAtom extends TimelineManageable>(token: TimelineToken<ManagedAtom>, handleUpdate: (update: TimelineUpdate<any> | `redo` | `undo`) => void
|
|
1326
|
+
declare const subscribeToTimeline: <ManagedAtom extends TimelineManageable>(store: Store, token: TimelineToken<ManagedAtom>, key: string, handleUpdate: (update: TimelineUpdate<any> | `redo` | `undo`) => void) => (() => void);
|
|
608
1327
|
|
|
609
|
-
declare const subscribeToTransaction: <F extends Func>(
|
|
1328
|
+
declare const subscribeToTransaction: <F extends Func>(store: Store, token: TransactionToken<F>, key: string, handleUpdate: TransactionUpdateHandler<F>) => (() => void);
|
|
610
1329
|
|
|
611
1330
|
type AtomIOState = {
|
|
612
1331
|
key: string;
|
|
@@ -670,4 +1389,4 @@ type WritableFamily<T, K extends Canonical> = AtomFamily<T, K> | WritableSelecto
|
|
|
670
1389
|
type ReadableFamily<T, K extends Canonical> = AtomFamily<T, K> | SelectorFamily<T, K>;
|
|
671
1390
|
type AtomIOInternalResource = ReadableFamily<any, any> | ReadableState<any> | Timeline<any> | Transaction<any>;
|
|
672
1391
|
|
|
673
|
-
export { type Atom, type AtomFamily, type AtomIOInternalResource, type AtomIOState, type AtomKey, type BaseExternalStoreConfiguration, type ChildStore, CircularBuffer, type Count, type Each, type Empty, type EnvironmentData, type ExternalStoreConfiguration, type ExternalStoreWithContentConfiguration, FAMILY_MEMBER_TOKEN_TYPES, FamilyTracker, type Flat, type Func, Future, IMPLICIT, Junction, type JunctionAdvancedConfiguration, type JunctionEntries, type JunctionEntriesBase, type JunctionJSON, type JunctionSchema, type JunctionSchemaBase, LazyMap, type Lineage, type Modify, type Molecule, type MutableAtom, type MutableAtomFamily, NotFoundError, type OperationProgress, type ReadableFamily, type ReadableState, type ReadonlySelector, type ReadonlySelectorFamily, type ReadonlySelectorKey, type Refinement, type RegularAtom, type RegularAtomFamily, type RootStore, type Selector, type SelectorFamily, type SelectorKey, type Signal, type StateKey, StatefulSubject, Store, Subject, TRANSACTION_PHASES, type Timeline, type TimelineAtomUpdate, type TimelineMoleculeCreation, type TimelineMoleculeDisposal, type TimelineSelectorUpdate, type TimelineStateCreation, type TimelineStateDisposal, type TimelineTransactionUpdate, Tracker, type Transaction, type TransactionEpoch, type TransactionPhase, type TransactionProgress, type Transceiver, type TransceiverMode, type WritableFamily, type WritableSelector, type WritableSelectorFamily, type WritableState, abortTransaction, actUponStore, allocateIntoStore, applyTransaction, arbitrary, assignTransactionToContinuity, become, buildTransaction, cacheValue, claimWithinStore, clearStore, closeOperation, counterfeit, createAtomFamily, createMutableAtom, createMutableAtomFamily, createReadonlySelector, createReadonlySelectorFamily, createRegularAtom, createRegularAtomFamily, createSelectorFamily, createStandaloneAtom, createStandaloneSelector, createTimeline, createTransaction, createWritableSelector, deallocateFromStore, deposit, disposeAtom, disposeFromStore, disposeSelector, evictCachedValue, findInStore, fuseWithinStore, getContinuityKey, getEnvironmentData, getEpochNumberOfAction, getEpochNumberOfContinuity, getFromStore, getJsonFamily, getJsonToken, getSelectorDependencyKeys, getTrace, getUpdateFamily, getUpdateToken, ingestAtomUpdate, ingestCreationEvent, ingestDisposalEvent, ingestMoleculeCreationEvent, ingestMoleculeDisposalEvent, ingestMoleculeTransferEvent, ingestSelectorUpdate, ingestTransactionUpdate, initFamilyMemberInStore, isAtomDefault, isAtomKey, isChildStore, isDone, isReadonlySelectorKey, isRootStore, isSelectorKey, isStateKey, isTransceiver, makeRootMoleculeInStore, markAtomAsDefault, markAtomAsNotDefault, markDone, newest, openOperation, prettyPrintTokenType, readCachedValue, readOrComputeValue, recallState, registerSelector, seekInStore, setAtomOrSelector, setEpochNumberOfAction, setEpochNumberOfContinuity, setIntoStore, subscribeInStore, subscribeToRootAtoms, subscribeToState, subscribeToTimeline, subscribeToTransaction, timeTravel, traceAllSelectorAtoms, traceSelectorAtoms, updateSelectorAtoms, withdraw };
|
|
1392
|
+
export { type Atom, type AtomFamily, type AtomIOInternalResource, type AtomIOState, type AtomKey, type BaseExternalStoreConfiguration, type ChildStore, CircularBuffer, type Count, type Each, type Empty, type EnvironmentData, type ExternalStoreConfiguration, type ExternalStoreWithContentConfiguration, FAMILY_MEMBER_TOKEN_TYPES, FamilyTracker, type Flat, type Func, Future, IMPLICIT, Join, type JoinStateFamilies, Junction, type JunctionAdvancedConfiguration, type JunctionEntries, type JunctionEntriesBase, type JunctionJSON, type JunctionSchema, type JunctionSchemaBase, LazyMap, type Lineage, type Modify, type Molecule, type MutableAtom, type MutableAtomFamily, NotFoundError, type OperationProgress, type ReadableFamily, type ReadableState, type ReadonlySelector, type ReadonlySelectorFamily, type ReadonlySelectorKey, type Refinement, type RegularAtom, type RegularAtomFamily, type RootStore, type Selector, type SelectorFamily, type SelectorKey, type Signal, type StateKey, StatefulSubject, Store, Subject, TRANSACTION_PHASES, type Timeline, type TimelineAtomUpdate, type TimelineMoleculeCreation, type TimelineMoleculeDisposal, type TimelineSelectorUpdate, type TimelineStateCreation, type TimelineStateDisposal, type TimelineTransactionUpdate, Tracker, type Transaction, type TransactionEpoch, type TransactionPhase, type TransactionProgress, type Transceiver, type TransceiverMode, type WritableFamily, type WritableSelector, type WritableSelectorFamily, type WritableState, abortTransaction, actUponStore, allocateIntoStore, applyTransaction, arbitrary, assignTransactionToContinuity, become, buildTransaction, cacheValue, capitalize, claimWithinStore, clearStore, closeOperation, counterfeit, createAtomFamily, createMutableAtom, createMutableAtomFamily, createReadonlySelector, createReadonlySelectorFamily, createRegularAtom, createRegularAtomFamily, createSelectorFamily, createStandaloneAtom, createStandaloneSelector, createTimeline, createTransaction, createWritableSelector, deallocateFromStore, deposit, disposeAtom, disposeFromStore, disposeSelector, editRelationsInStore, evictCachedValue, findInStore, findRelationsInStore, fuseWithinStore, getContinuityKey, getEnvironmentData, getEpochNumberOfAction, getEpochNumberOfContinuity, getFromStore, getInternalRelationsFromStore, getJoin, getJsonFamily, getJsonToken, getSelectorDependencyKeys, getTrace, getUpdateFamily, getUpdateToken, ingestAtomUpdate, ingestCreationEvent, ingestDisposalEvent, ingestMoleculeCreationEvent, ingestMoleculeDisposalEvent, ingestMoleculeTransferEvent, ingestSelectorUpdate, ingestTransactionUpdate, initFamilyMemberInStore, isAtomDefault, isAtomKey, isChildStore, isDone, isReadonlySelectorKey, isRootStore, isSelectorKey, isStateKey, isTransceiver, makeRootMoleculeInStore, markAtomAsDefault, markAtomAsNotDefault, markDone, newest, openOperation, prettyPrintTokenType, readCachedValue, readOrComputeValue, recallState, registerSelector, seekInStore, setAtomOrSelector, setEpochNumberOfAction, setEpochNumberOfContinuity, setIntoStore, subscribeInStore, subscribeToRootAtoms, subscribeToState, subscribeToTimeline, subscribeToTransaction, timeTravel, traceAllSelectorAtoms, traceSelectorAtoms, updateSelectorAtoms, withdraw };
|