atom.io 0.19.0 → 0.19.2
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 +99 -79
- package/data/dist/index.js +2 -2
- package/data/src/join.ts +91 -74
- package/dist/{chunk-YDOGCZ53.js → chunk-ATKDGVTV.js} +29 -29
- package/dist/{chunk-CVBEVTM5.js → chunk-CC7IF7QF.js} +5 -42
- package/dist/{chunk-WX2NCOZR.js → chunk-FTONNX2R.js} +8 -8
- package/dist/{chunk-7ZR244C2.js → chunk-MSCJWACE.js} +92 -72
- package/dist/index.cjs +15 -7
- package/dist/index.d.ts +24 -35
- package/dist/index.js +15 -7
- package/internal/dist/index.cjs +56 -44
- package/internal/dist/index.d.ts +21 -21
- package/internal/dist/index.js +49 -37
- package/internal/src/atom/create-regular-atom.ts +7 -5
- package/internal/src/atom/delete-atom.ts +2 -2
- package/internal/src/families/create-readonly-selector-family.ts +2 -2
- package/internal/src/families/create-regular-atom-family.ts +1 -1
- package/internal/src/families/create-writable-selector-family.ts +1 -1
- package/internal/src/future.ts +4 -2
- package/internal/src/lineage.ts +1 -0
- package/internal/src/mutable/create-mutable-atom-family.ts +1 -1
- package/internal/src/mutable/create-mutable-atom.ts +7 -5
- package/internal/src/mutable/tracker.ts +4 -4
- package/internal/src/mutable/transceiver.ts +2 -2
- package/internal/src/selector/delete-selector.ts +1 -1
- package/internal/src/set-state/become.ts +1 -1
- package/internal/src/set-state/copy-mutable-if-needed.ts +1 -1
- package/internal/src/store/deposit.ts +5 -5
- package/internal/src/store/store.ts +5 -5
- package/internal/src/store/withdraw.ts +4 -5
- package/internal/src/subject.ts +3 -1
- package/internal/src/subscribe/subscribe-to-state.ts +2 -2
- package/internal/src/subscribe/subscribe-to-transaction.ts +4 -4
- package/internal/src/timeline/add-atom-to-timeline.ts +16 -11
- package/internal/src/timeline/create-timeline.ts +3 -4
- package/internal/src/transaction/act-upon-store.ts +5 -5
- package/internal/src/transaction/apply-transaction.ts +4 -4
- package/internal/src/transaction/build-transaction.ts +10 -7
- package/internal/src/transaction/create-transaction.ts +10 -10
- package/internal/src/transaction/index.ts +3 -3
- package/internal/src/transaction/is-root-store.ts +2 -2
- package/introspection/dist/index.cjs +3 -2
- package/introspection/dist/index.d.ts +6 -6
- package/introspection/dist/index.js +3 -2
- package/introspection/src/attach-atom-index.ts +5 -4
- package/introspection/src/attach-introspection-states.ts +3 -3
- package/introspection/src/attach-transaction-index.ts +4 -4
- package/introspection/src/attach-transaction-logs.ts +8 -4
- package/introspection/src/index.ts +3 -3
- package/json/dist/index.cjs +6 -2
- package/json/dist/index.d.ts +1 -1
- package/json/dist/index.js +8 -4
- package/json/src/select-json-family.ts +3 -2
- package/json/src/select-json.ts +3 -1
- package/package.json +243 -242
- package/react/dist/index.cjs +9 -3
- package/react/dist/index.js +9 -3
- package/react/src/use-i.ts +3 -1
- package/react/src/use-tl.ts +6 -2
- package/react-devtools/dist/index.cjs +332 -978
- package/react-devtools/dist/index.css +0 -18
- package/react-devtools/dist/index.d.ts +7 -9
- package/react-devtools/dist/index.js +291 -881
- package/react-devtools/src/AtomIODevtools.tsx +5 -2
- package/react-devtools/src/Button.tsx +6 -2
- package/react-devtools/src/StateEditor.tsx +13 -16
- package/react-devtools/src/StateIndex.tsx +28 -21
- package/react-devtools/src/TimelineIndex.tsx +17 -6
- package/react-devtools/src/TransactionIndex.tsx +13 -6
- package/react-devtools/src/Updates.tsx +24 -9
- package/realtime/dist/index.cjs +1 -0
- package/realtime/dist/index.d.ts +2 -2
- package/realtime/dist/index.js +1 -0
- package/realtime/src/realtime-continuity.ts +4 -3
- package/realtime-client/dist/index.cjs +29 -29
- package/realtime-client/dist/index.d.ts +2 -2
- package/realtime-client/dist/index.js +1 -1
- package/realtime-client/src/server-action.ts +2 -2
- package/realtime-client/src/sync-continuity.ts +23 -23
- package/realtime-react/dist/index.cjs +30 -30
- package/realtime-react/dist/index.d.ts +2 -2
- package/realtime-react/dist/index.js +2 -2
- package/realtime-react/src/use-server-action.ts +3 -3
- package/realtime-react/src/use-single-effect.ts +1 -1
- package/realtime-server/dist/index.cjs +54 -44
- package/realtime-server/dist/index.d.ts +6 -6
- package/realtime-server/dist/index.js +34 -24
- package/realtime-server/src/ipc-sockets/child-socket.ts +7 -7
- package/realtime-server/src/ipc-sockets/custom-socket.ts +4 -8
- package/realtime-server/src/ipc-sockets/parent-socket.ts +13 -7
- package/realtime-server/src/realtime-action-receiver.ts +7 -5
- package/realtime-server/src/realtime-continuity-synchronizer.ts +3 -3
- package/realtime-server/src/realtime-server-stores/server-room-external-store.ts +2 -2
- package/realtime-server/src/realtime-state-receiver.ts +3 -1
- package/realtime-testing/dist/index.cjs +15 -13
- package/realtime-testing/dist/index.js +9 -7
- package/realtime-testing/src/setup-realtime-test.tsx +7 -5
- package/src/atom.ts +4 -8
- package/src/dispose.ts +1 -0
- package/src/index.ts +2 -9
- package/src/selector.ts +4 -8
- package/src/silo.ts +13 -3
- package/src/subscribe.ts +6 -6
- package/src/timeline.ts +4 -4
- package/src/transaction.ts +24 -24
- package/src/validators.ts +2 -2
- package/transceivers/set-rtx/dist/index.cjs +11 -12
- package/transceivers/set-rtx/dist/index.js +11 -12
- package/transceivers/set-rtx/src/set-rtx.ts +10 -10
- /package/dist/{chunk-VAE5OCKN.js → chunk-BF4MVQF6.js} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -33,10 +33,7 @@ type RegularAtomFamilyToken<T, K extends Json.Serializable> = {
|
|
|
33
33
|
__T?: T;
|
|
34
34
|
__K?: K;
|
|
35
35
|
};
|
|
36
|
-
type RegularAtomFamilyTokenWithCall<T, K extends Json.Serializable> = RegularAtomFamilyToken<T, K> &
|
|
37
|
-
/** @deprecated Prefer the `findState`, `findInStore`, or `find` functions. */
|
|
38
|
-
(key: K): RegularAtomToken<T>;
|
|
39
|
-
};
|
|
36
|
+
type RegularAtomFamilyTokenWithCall<T, K extends Json.Serializable> = RegularAtomFamilyToken<T, K> & /** @deprecated Prefer the `findState`, `findInStore`, or `find` functions. */ ((key: K) => RegularAtomToken<T>);
|
|
40
37
|
type RegularAtomFamily<T, K extends Json.Serializable> = RegularAtomFamilyToken<T, K> & {
|
|
41
38
|
(key: K): RegularAtomToken<T>;
|
|
42
39
|
subject: Subject<RegularAtomToken<T>>;
|
|
@@ -55,10 +52,7 @@ type MutableAtomFamilyToken<T extends Transceiver<any>, J extends Json.Serializa
|
|
|
55
52
|
__J?: J;
|
|
56
53
|
__K?: K;
|
|
57
54
|
};
|
|
58
|
-
type MutableAtomFamilyTokenWithCall<T extends Transceiver<any>, J extends Json.Serializable, K extends Json.Serializable> = MutableAtomFamilyToken<T, J, K> &
|
|
59
|
-
/** @deprecated Prefer the `findState`, `findInStore`, or `find` functions. */
|
|
60
|
-
(key: K): MutableAtomToken<T, J>;
|
|
61
|
-
};
|
|
55
|
+
type MutableAtomFamilyTokenWithCall<T extends Transceiver<any>, J extends Json.Serializable, K extends Json.Serializable> = MutableAtomFamilyToken<T, J, K> & /** @deprecated Prefer the `findState`, `findInStore`, or `find` functions. */ ((key: K) => MutableAtomToken<T, J>);
|
|
62
56
|
type MutableAtomFamily<T extends Transceiver<any>, J extends Json.Serializable, K extends Json.Serializable> = JsonInterface<T, J> & MutableAtomFamilyToken<T, J, K> & {
|
|
63
57
|
(key: K): MutableAtomToken<T, J>;
|
|
64
58
|
subject: Subject<MutableAtomToken<T, J>>;
|
|
@@ -69,19 +63,19 @@ type AtomFamilyToken<T, K extends Json.Serializable = Json.Serializable> = Mutab
|
|
|
69
63
|
declare function atomFamily<T extends Transceiver<any>, J extends Json.Serializable, K extends Json.Serializable>(options: MutableAtomFamilyOptions<T, J, K>): MutableAtomFamilyTokenWithCall<T, J, K>;
|
|
70
64
|
declare function atomFamily<T, K extends Json.Serializable>(options: RegularAtomFamilyOptions<T, K>): RegularAtomFamilyTokenWithCall<T, K>;
|
|
71
65
|
|
|
72
|
-
type TransactionToken<F> = {
|
|
66
|
+
type TransactionToken<F extends Func> = {
|
|
73
67
|
key: string;
|
|
74
68
|
type: `transaction`;
|
|
75
69
|
__F?: F;
|
|
76
70
|
};
|
|
77
|
-
type TransactionUpdateContent = KeyedStateUpdate<unknown> | TransactionUpdate
|
|
78
|
-
type TransactionUpdate
|
|
71
|
+
type TransactionUpdateContent = KeyedStateUpdate<unknown> | TransactionUpdate<Func>;
|
|
72
|
+
type TransactionUpdate<F extends Func> = {
|
|
79
73
|
key: string;
|
|
80
74
|
id: string;
|
|
81
75
|
epoch: number;
|
|
82
76
|
updates: TransactionUpdateContent[];
|
|
83
|
-
params: Parameters
|
|
84
|
-
output: ReturnType
|
|
77
|
+
params: Parameters<F>;
|
|
78
|
+
output: ReturnType<F>;
|
|
85
79
|
};
|
|
86
80
|
type Transactors = Readonly<{
|
|
87
81
|
get: <S>(state: ReadonlySelectorToken<S> | WritableToken<S>) => S;
|
|
@@ -96,16 +90,16 @@ type TransactorsWithRunAndEnv = Readonly<{
|
|
|
96
90
|
env: () => EnvironmentData;
|
|
97
91
|
}>;
|
|
98
92
|
type ReadonlyTransactors = Pick<Transactors, `find` | `get`>;
|
|
99
|
-
type Read
|
|
100
|
-
type Write
|
|
101
|
-
type Transact
|
|
102
|
-
type TransactionOptions
|
|
93
|
+
type Read<F extends Func> = (transactors: ReadonlyTransactors, ...parameters: Parameters<F>) => ReturnType<F>;
|
|
94
|
+
type Write<F extends Func> = (transactors: Transactors, ...parameters: Parameters<F>) => ReturnType<F>;
|
|
95
|
+
type Transact<F extends Func> = (transactors: TransactorsWithRunAndEnv, ...parameters: Parameters<F>) => ReturnType<F>;
|
|
96
|
+
type TransactionOptions<F extends Func> = {
|
|
103
97
|
key: string;
|
|
104
|
-
do: Transact
|
|
98
|
+
do: Transact<F>;
|
|
105
99
|
};
|
|
106
|
-
type TransactionIO<Token extends TransactionToken<any>> = Token extends TransactionToken<infer
|
|
107
|
-
declare function transaction
|
|
108
|
-
declare function runTransaction
|
|
100
|
+
type TransactionIO<Token extends TransactionToken<any>> = Token extends TransactionToken<infer F> ? F : never;
|
|
101
|
+
declare function transaction<F extends Func>(options: TransactionOptions<F>): TransactionToken<F>;
|
|
102
|
+
declare function runTransaction<F extends Func>(token: TransactionToken<F>, id?: string): (...parameters: Parameters<F>) => ReturnType<F>;
|
|
109
103
|
|
|
110
104
|
type WritableSelectorOptions<T> = {
|
|
111
105
|
key: string;
|
|
@@ -133,10 +127,7 @@ type WritableSelectorFamilyToken<T, K extends Json.Serializable> = {
|
|
|
133
127
|
__T?: T;
|
|
134
128
|
__K?: K;
|
|
135
129
|
};
|
|
136
|
-
type WritableSelectorFamilyTokenWithCall<T, K extends Json.Serializable> = WritableSelectorFamilyToken<T, K> &
|
|
137
|
-
/** @deprecated Prefer the `findState`, `findInStore`, or `find` functions. */
|
|
138
|
-
(key: K): WritableSelectorToken<T>;
|
|
139
|
-
};
|
|
130
|
+
type WritableSelectorFamilyTokenWithCall<T, K extends Json.Serializable> = WritableSelectorFamilyToken<T, K> & /** @deprecated Prefer the `findState`, `findInStore`, or `find` functions. */ ((key: K) => WritableSelectorToken<T>);
|
|
140
131
|
type WritableSelectorFamily<T, K extends Json.Serializable> = WritableSelectorFamilyToken<T, K> & {
|
|
141
132
|
(key: K): WritableSelectorToken<T>;
|
|
142
133
|
subject: Subject<WritableSelectorToken<T>>;
|
|
@@ -148,10 +139,7 @@ type ReadonlySelectorFamilyToken<T, K extends Json.Serializable> = {
|
|
|
148
139
|
__T?: T;
|
|
149
140
|
__K?: K;
|
|
150
141
|
};
|
|
151
|
-
type ReadonlySelectorFamilyTokenWithCall<T, K extends Json.Serializable> = ReadonlySelectorFamilyToken<T, K> &
|
|
152
|
-
/** @deprecated Prefer the `findState`, `findInStore`, or `find` functions. */
|
|
153
|
-
(key: K): ReadonlySelectorToken<T>;
|
|
154
|
-
};
|
|
142
|
+
type ReadonlySelectorFamilyTokenWithCall<T, K extends Json.Serializable> = ReadonlySelectorFamilyToken<T, K> & /** @deprecated Prefer the `findState`, `findInStore`, or `find` functions. */ ((key: K) => ReadonlySelectorToken<T>);
|
|
155
143
|
type ReadonlySelectorFamily<T, K extends Json.Serializable> = ((key: K) => ReadonlySelectorToken<T>) & {
|
|
156
144
|
key: string;
|
|
157
145
|
type: `readonly_selector_family`;
|
|
@@ -254,6 +242,7 @@ declare class Silo {
|
|
|
254
242
|
selectorFamily: typeof selectorFamily;
|
|
255
243
|
transaction: typeof transaction;
|
|
256
244
|
timeline: typeof timeline;
|
|
245
|
+
findState: typeof findState;
|
|
257
246
|
getState: typeof getState;
|
|
258
247
|
setState: typeof setState;
|
|
259
248
|
subscribe: typeof subscribe;
|
|
@@ -271,9 +260,9 @@ type KeyedStateUpdate<T> = StateUpdate<T> & {
|
|
|
271
260
|
family?: FamilyMetadata;
|
|
272
261
|
};
|
|
273
262
|
type UpdateHandler<T> = (update: StateUpdate<T>) => void;
|
|
274
|
-
type TransactionUpdateHandler
|
|
263
|
+
type TransactionUpdateHandler<F extends Func> = (data: TransactionUpdate<F>) => void;
|
|
275
264
|
declare function subscribe<T>(token: ReadableToken<T>, handleUpdate: UpdateHandler<T>, key?: string, store?: Store): () => void;
|
|
276
|
-
declare function subscribe
|
|
265
|
+
declare function subscribe<F extends Func>(token: TransactionToken<F>, handleUpdate: TransactionUpdateHandler<F>, key?: string, store?: Store): () => void;
|
|
277
266
|
declare function subscribe<M extends TimelineManageable>(token: TimelineToken<M>, handleUpdate: (update: TimelineUpdate<M> | `redo` | `undo`) => void, key?: string, store?: Store): () => void;
|
|
278
267
|
|
|
279
268
|
type TimelineManageable = AtomFamilyToken<any, any> | AtomToken<any>;
|
|
@@ -289,8 +278,8 @@ type TimelineOptions<ManagedAtom extends TimelineManageable> = {
|
|
|
289
278
|
};
|
|
290
279
|
type TimelineUpdate<ManagedAtom extends TimelineManageable> = TimelineAtomUpdate<ManagedAtom> | TimelineSelectorUpdate<ManagedAtom> | TimelineTransactionUpdate;
|
|
291
280
|
declare const timeline: <ManagedAtom extends TimelineManageable>(options: TimelineOptions<ManagedAtom>) => TimelineToken<ManagedAtom>;
|
|
292
|
-
declare const redo: (
|
|
293
|
-
declare const undo: (
|
|
281
|
+
declare const redo: (tl: TimelineToken<any>) => void;
|
|
282
|
+
declare const undo: (tl: TimelineToken<any>) => void;
|
|
294
283
|
|
|
295
284
|
type TokenType<Comparison extends ReadableFamilyToken$1<any, any> | ReadableToken$1<any>> = Comparison extends ReadableToken$1<infer RepresentedValue> ? RepresentedValue : Comparison extends ReadableFamilyToken$1<infer RepresentedValue, any> ? RepresentedValue : never;
|
|
296
285
|
declare function isToken<KnownToken extends RegularAtomToken$1<any>>(knownToken: KnownToken, unknownToken: ReadableToken$1<any>): unknownToken is RegularAtomToken$1<TokenType<KnownToken>>;
|
|
@@ -306,7 +295,7 @@ declare function belongsTo<Family extends ReadonlySelectorFamilyToken$1<any, any
|
|
|
306
295
|
declare function belongsTo<Family extends WritableFamilyToken$1<any, any>>(family: Family, unknownToken: ReadableToken$1<any>): unknownToken is WritableToken$1<TokenType<Family>>;
|
|
307
296
|
declare function belongsTo<Family extends ReadableFamilyToken$1<any, any>>(family: Family, unknownToken: ReadableToken$1<any>): unknownToken is ReadableToken$1<TokenType<Family>>;
|
|
308
297
|
|
|
309
|
-
type
|
|
298
|
+
type Func = (...parameters: any[]) => any;
|
|
310
299
|
type RegularAtomToken<T> = {
|
|
311
300
|
key: string;
|
|
312
301
|
type: `atom`;
|
|
@@ -345,4 +334,4 @@ type FamilyMetadata = {
|
|
|
345
334
|
subKey: string;
|
|
346
335
|
};
|
|
347
336
|
|
|
348
|
-
export { type AtomEffect, type AtomFamily, type AtomFamilyToken, AtomIOLogger, type AtomToken, type Effectors, type FamilyMetadata, type KeyedStateUpdate, LOG_LEVELS, type LogFilter, type LogFn, type LogLevel, type Logger, type LoggerIcon, type MutableAtomFamily, type MutableAtomFamilyOptions, type MutableAtomFamilyToken, type MutableAtomFamilyTokenWithCall, type MutableAtomOptions, type MutableAtomToken, type Read, type ReadableFamily, type ReadableFamilyToken, type ReadableToken, type ReadonlySelectorFamily, type ReadonlySelectorFamilyOptions, type ReadonlySelectorFamilyToken, type ReadonlySelectorFamilyTokenWithCall, type ReadonlySelectorOptions, type ReadonlySelectorToken, type ReadonlyTransactors, type RegularAtomFamily, type RegularAtomFamilyOptions, type RegularAtomFamilyToken, type RegularAtomFamilyTokenWithCall, type RegularAtomOptions, type RegularAtomToken, type SelectorFamily, type SelectorFamilyToken, type SelectorToken, Silo, type StateUpdate, type TimelineManageable, type TimelineOptions, type TimelineToken, type TimelineUpdate, type TokenDenomination, type TokenType, type Transact, type TransactionIO, type TransactionOptions, type TransactionToken, type TransactionUpdate, type TransactionUpdateContent, type TransactionUpdateHandler, type Transactors, type TransactorsWithRunAndEnv, type UpdateHandler, type WritableFamily, type WritableFamilyToken, type WritableSelectorFamily, type WritableSelectorFamilyOptions, type WritableSelectorFamilyToken, type WritableSelectorFamilyTokenWithCall, type WritableSelectorOptions, type WritableSelectorToken, type WritableToken, type Write, atom, atomFamily, belongsTo, dispose, findState, getState, isToken, redo, runTransaction, selector, selectorFamily, setState, simpleLog, simpleLogger, subscribe, timeline, transaction, undo
|
|
337
|
+
export { type AtomEffect, type AtomFamily, type AtomFamilyToken, AtomIOLogger, type AtomToken, type Effectors, type FamilyMetadata, type Func, type KeyedStateUpdate, LOG_LEVELS, type LogFilter, type LogFn, type LogLevel, type Logger, type LoggerIcon, type MutableAtomFamily, type MutableAtomFamilyOptions, type MutableAtomFamilyToken, type MutableAtomFamilyTokenWithCall, type MutableAtomOptions, type MutableAtomToken, type Read, type ReadableFamily, type ReadableFamilyToken, type ReadableToken, type ReadonlySelectorFamily, type ReadonlySelectorFamilyOptions, type ReadonlySelectorFamilyToken, type ReadonlySelectorFamilyTokenWithCall, type ReadonlySelectorOptions, type ReadonlySelectorToken, type ReadonlyTransactors, type RegularAtomFamily, type RegularAtomFamilyOptions, type RegularAtomFamilyToken, type RegularAtomFamilyTokenWithCall, type RegularAtomOptions, type RegularAtomToken, type SelectorFamily, type SelectorFamilyToken, type SelectorToken, Silo, type StateUpdate, type TimelineManageable, type TimelineOptions, type TimelineToken, type TimelineUpdate, type TokenDenomination, type TokenType, type Transact, type TransactionIO, type TransactionOptions, type TransactionToken, type TransactionUpdate, type TransactionUpdateContent, type TransactionUpdateHandler, type Transactors, type TransactorsWithRunAndEnv, type UpdateHandler, type WritableFamily, type WritableFamilyToken, type WritableSelectorFamily, type WritableSelectorFamilyOptions, type WritableSelectorFamilyToken, type WritableSelectorFamilyTokenWithCall, type WritableSelectorOptions, type WritableSelectorToken, type WritableToken, type Write, atom, atomFamily, belongsTo, dispose, findState, getState, isToken, redo, runTransaction, selector, selectorFamily, setState, simpleLog, simpleLogger, subscribe, timeline, transaction, undo };
|
package/dist/index.js
CHANGED
|
@@ -11,6 +11,7 @@ function atomFamily(options) {
|
|
|
11
11
|
function dispose(token, store = Internal.IMPLICIT.STORE) {
|
|
12
12
|
switch (token.type) {
|
|
13
13
|
case `atom`:
|
|
14
|
+
case `mutable_atom`:
|
|
14
15
|
Internal.deleteAtom(token, store);
|
|
15
16
|
break;
|
|
16
17
|
case `selector`:
|
|
@@ -90,11 +91,18 @@ var Silo = class {
|
|
|
90
91
|
this.selectorFamily = (options) => createSelectorFamily(options, s);
|
|
91
92
|
this.transaction = (options) => createTransaction(options, s);
|
|
92
93
|
this.timeline = (options) => createTimeline(options, s);
|
|
94
|
+
this.findState = (token, key) => findInStore(token, key, s);
|
|
93
95
|
this.getState = (token) => getFromStore(token, s);
|
|
94
|
-
this.setState = (token, newValue) =>
|
|
96
|
+
this.setState = (token, newValue) => {
|
|
97
|
+
setIntoStore(token, newValue, s);
|
|
98
|
+
};
|
|
95
99
|
this.subscribe = (token, handler, key) => subscribe(token, handler, key, s);
|
|
96
|
-
this.undo = (token) =>
|
|
97
|
-
|
|
100
|
+
this.undo = (token) => {
|
|
101
|
+
timeTravel(`undo`, token, s);
|
|
102
|
+
};
|
|
103
|
+
this.redo = (token) => {
|
|
104
|
+
timeTravel(`redo`, token, s);
|
|
105
|
+
};
|
|
98
106
|
}
|
|
99
107
|
};
|
|
100
108
|
function subscribe(token, handleUpdate, key = arbitrary(), store = IMPLICIT.STORE) {
|
|
@@ -113,11 +121,11 @@ function subscribe(token, handleUpdate, key = arbitrary(), store = IMPLICIT.STOR
|
|
|
113
121
|
var timeline = (options) => {
|
|
114
122
|
return createTimeline(options, IMPLICIT.STORE);
|
|
115
123
|
};
|
|
116
|
-
var redo = (
|
|
117
|
-
timeTravel(`redo`,
|
|
124
|
+
var redo = (tl) => {
|
|
125
|
+
timeTravel(`redo`, tl, IMPLICIT.STORE);
|
|
118
126
|
};
|
|
119
|
-
var undo = (
|
|
120
|
-
timeTravel(`undo`,
|
|
127
|
+
var undo = (tl) => {
|
|
128
|
+
timeTravel(`undo`, tl, IMPLICIT.STORE);
|
|
121
129
|
};
|
|
122
130
|
function transaction(options) {
|
|
123
131
|
return createTransaction(options, IMPLICIT.STORE);
|
package/internal/dist/index.cjs
CHANGED
|
@@ -212,16 +212,16 @@ var Junction = class {
|
|
|
212
212
|
if (a === void 0 && typeof b === `string`) {
|
|
213
213
|
const bRelations = this.getRelatedKeys(b);
|
|
214
214
|
if (bRelations) {
|
|
215
|
-
for (const
|
|
216
|
-
this.delete(
|
|
215
|
+
for (const bRelation of bRelations) {
|
|
216
|
+
this.delete(bRelation, b);
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
220
|
if (typeof a === `string` && b === void 0) {
|
|
221
221
|
const aRelations = this.getRelatedKeys(a);
|
|
222
222
|
if (aRelations) {
|
|
223
|
-
for (const
|
|
224
|
-
this.delete(a,
|
|
223
|
+
for (const aRelation of aRelations) {
|
|
224
|
+
this.delete(a, aRelation);
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
227
|
}
|
|
@@ -274,18 +274,18 @@ var Junction = class {
|
|
|
274
274
|
if (a !== void 0 && b === void 0) {
|
|
275
275
|
const aRelations = this.getRelatedKeys(a);
|
|
276
276
|
if (aRelations) {
|
|
277
|
-
return [...aRelations].map((
|
|
277
|
+
return [...aRelations].map((aRelation) => {
|
|
278
278
|
var _a;
|
|
279
|
-
return [
|
|
279
|
+
return [aRelation, (_a = this.getContent(a, aRelation)) != null ? _a : null];
|
|
280
280
|
});
|
|
281
281
|
}
|
|
282
282
|
}
|
|
283
283
|
if (a === void 0 && b !== void 0) {
|
|
284
284
|
const bRelations = this.getRelatedKeys(b);
|
|
285
285
|
if (bRelations) {
|
|
286
|
-
return [...bRelations].map((
|
|
286
|
+
return [...bRelations].map((bRelation) => {
|
|
287
287
|
var _a;
|
|
288
|
-
return [
|
|
288
|
+
return [bRelation, (_a = this.getContent(bRelation, b)) != null ? _a : null];
|
|
289
289
|
});
|
|
290
290
|
}
|
|
291
291
|
}
|
|
@@ -308,7 +308,9 @@ var Subject = class {
|
|
|
308
308
|
}
|
|
309
309
|
subscribe(key, subscriber) {
|
|
310
310
|
this.subscribers.set(key, subscriber);
|
|
311
|
-
const unsubscribe = () =>
|
|
311
|
+
const unsubscribe = () => {
|
|
312
|
+
this.unsubscribe(key);
|
|
313
|
+
};
|
|
312
314
|
return unsubscribe;
|
|
313
315
|
}
|
|
314
316
|
unsubscribe(key) {
|
|
@@ -541,8 +543,12 @@ function withdrawOrCreate(token, store) {
|
|
|
541
543
|
var Future = class extends Promise {
|
|
542
544
|
constructor(executor) {
|
|
543
545
|
super((resolve, reject) => {
|
|
544
|
-
const pass = (value) =>
|
|
545
|
-
|
|
546
|
+
const pass = (value) => {
|
|
547
|
+
this.isCanceled ? reject(`canceled`) : resolve(value);
|
|
548
|
+
};
|
|
549
|
+
const fail = (reason) => {
|
|
550
|
+
this.isCanceled ? reject(`canceled`) : reject(reason);
|
|
551
|
+
};
|
|
546
552
|
if (typeof executor === `function`) {
|
|
547
553
|
executor(pass, fail);
|
|
548
554
|
} else {
|
|
@@ -564,7 +570,7 @@ function copyMutableIfNeeded(atom, origin, target) {
|
|
|
564
570
|
if (originValue === void 0) {
|
|
565
571
|
return typeof atom.default === `function` ? atom.default() : atom.default;
|
|
566
572
|
}
|
|
567
|
-
origin.logger.info(`\u{1F4C3}`, `atom`,
|
|
573
|
+
origin.logger.info(`\u{1F4C3}`, `atom`, atom.key, `copying`);
|
|
568
574
|
const jsonValue = atom.toJson(originValue);
|
|
569
575
|
const copiedValue = atom.fromJson(jsonValue);
|
|
570
576
|
target.valueMap.set(atom.key, copiedValue);
|
|
@@ -669,7 +675,7 @@ function createRegularAtomFamily(options, store) {
|
|
|
669
675
|
key: options.key,
|
|
670
676
|
type: `atom_family`,
|
|
671
677
|
subject,
|
|
672
|
-
install: (
|
|
678
|
+
install: (s) => createRegularAtomFamily(options, s)
|
|
673
679
|
}
|
|
674
680
|
);
|
|
675
681
|
const target = newest(store);
|
|
@@ -710,7 +716,7 @@ function createReadonlySelectorFamily(options, store) {
|
|
|
710
716
|
key: options.key,
|
|
711
717
|
type: `readonly_selector_family`,
|
|
712
718
|
subject,
|
|
713
|
-
install: (
|
|
719
|
+
install: (s) => createReadonlySelectorFamily(options, s)
|
|
714
720
|
}
|
|
715
721
|
);
|
|
716
722
|
store.families.set(options.key, readonlySelectorFamily);
|
|
@@ -743,7 +749,7 @@ function createWritableSelectorFamily(options, store) {
|
|
|
743
749
|
key: options.key,
|
|
744
750
|
type: `selector_family`,
|
|
745
751
|
subject,
|
|
746
|
-
install: (
|
|
752
|
+
install: (s) => createWritableSelectorFamily(options, s)
|
|
747
753
|
}
|
|
748
754
|
);
|
|
749
755
|
store.families.set(options.key, selectorFamily);
|
|
@@ -1252,7 +1258,7 @@ function deleteSelector(selectorToken, store) {
|
|
|
1252
1258
|
}
|
|
1253
1259
|
}
|
|
1254
1260
|
target.selectorGraph.delete(key);
|
|
1255
|
-
store.logger.info(`\u{1F525}`, selectorToken.type,
|
|
1261
|
+
store.logger.info(`\u{1F525}`, selectorToken.type, key, `deleted`);
|
|
1256
1262
|
}
|
|
1257
1263
|
|
|
1258
1264
|
// internal/src/subscribe/recall-state.ts
|
|
@@ -1431,18 +1437,18 @@ var Tracker = class {
|
|
|
1431
1437
|
this.unsubscribeFromInnerValue();
|
|
1432
1438
|
this.unsubscribeFromInnerValue = update.newValue.subscribe(
|
|
1433
1439
|
subscriptionKey,
|
|
1434
|
-
(
|
|
1440
|
+
(transceiverUpdate) => {
|
|
1435
1441
|
if (target.operation.open) {
|
|
1436
1442
|
const unsubscribe = target.on.operationClose.subscribe(
|
|
1437
1443
|
subscriptionKey,
|
|
1438
1444
|
() => {
|
|
1439
1445
|
unsubscribe();
|
|
1440
|
-
setIntoStore(latestUpdateState,
|
|
1446
|
+
setIntoStore(latestUpdateState, transceiverUpdate, target);
|
|
1441
1447
|
}
|
|
1442
1448
|
);
|
|
1443
1449
|
} else {
|
|
1444
1450
|
setIntoStore(mutableState, (current) => current, target);
|
|
1445
|
-
setIntoStore(latestUpdateState,
|
|
1451
|
+
setIntoStore(latestUpdateState, transceiverUpdate, target);
|
|
1446
1452
|
}
|
|
1447
1453
|
}
|
|
1448
1454
|
);
|
|
@@ -1551,14 +1557,14 @@ function createMutableAtom(options, family, store) {
|
|
|
1551
1557
|
const subject = new Subject();
|
|
1552
1558
|
const newAtom = __spreadProps(__spreadValues({}, options), {
|
|
1553
1559
|
type: `mutable_atom`,
|
|
1554
|
-
install: (
|
|
1555
|
-
|
|
1560
|
+
install: (s) => {
|
|
1561
|
+
s.logger.info(
|
|
1556
1562
|
`\u{1F6E0}\uFE0F`,
|
|
1557
1563
|
`atom`,
|
|
1558
1564
|
options.key,
|
|
1559
|
-
`installing in store "${
|
|
1565
|
+
`installing in store "${s.config.name}"`
|
|
1560
1566
|
);
|
|
1561
|
-
return createMutableAtom(options, family,
|
|
1567
|
+
return createMutableAtom(options, family, s);
|
|
1562
1568
|
},
|
|
1563
1569
|
subject
|
|
1564
1570
|
});
|
|
@@ -1575,7 +1581,9 @@ function createMutableAtom(options, family, store) {
|
|
|
1575
1581
|
const cleanupFunctions = [];
|
|
1576
1582
|
for (const effect of options.effects) {
|
|
1577
1583
|
const cleanup = effect({
|
|
1578
|
-
setSelf: (next) =>
|
|
1584
|
+
setSelf: (next) => {
|
|
1585
|
+
setIntoStore(token, next, store);
|
|
1586
|
+
},
|
|
1579
1587
|
onSet: (handle) => subscribeToState(token, handle, `effect[${effectIndex}]`, store)
|
|
1580
1588
|
});
|
|
1581
1589
|
if (cleanup) {
|
|
@@ -1660,7 +1668,7 @@ function createMutableAtomFamily(options, store) {
|
|
|
1660
1668
|
key: options.key,
|
|
1661
1669
|
type: `mutable_atom_family`,
|
|
1662
1670
|
subject,
|
|
1663
|
-
install: (
|
|
1671
|
+
install: (s) => createMutableAtomFamily(options, s),
|
|
1664
1672
|
toJson: options.toJson,
|
|
1665
1673
|
fromJson: options.fromJson
|
|
1666
1674
|
}
|
|
@@ -1756,14 +1764,14 @@ function createRegularAtom(options, family, store) {
|
|
|
1756
1764
|
const subject = new Subject();
|
|
1757
1765
|
const newAtom = __spreadProps(__spreadValues({}, options), {
|
|
1758
1766
|
type: `atom`,
|
|
1759
|
-
install: (
|
|
1760
|
-
|
|
1767
|
+
install: (s) => {
|
|
1768
|
+
s.logger.info(
|
|
1761
1769
|
`\u{1F6E0}\uFE0F`,
|
|
1762
1770
|
`atom`,
|
|
1763
1771
|
options.key,
|
|
1764
|
-
`installing in store "${
|
|
1772
|
+
`installing in store "${s.config.name}"`
|
|
1765
1773
|
);
|
|
1766
|
-
return createRegularAtom(options, family,
|
|
1774
|
+
return createRegularAtom(options, family, s);
|
|
1767
1775
|
},
|
|
1768
1776
|
subject
|
|
1769
1777
|
});
|
|
@@ -1783,7 +1791,9 @@ function createRegularAtom(options, family, store) {
|
|
|
1783
1791
|
const cleanupFunctions = [];
|
|
1784
1792
|
for (const effect of options.effects) {
|
|
1785
1793
|
const cleanup = effect({
|
|
1786
|
-
setSelf: (next) =>
|
|
1794
|
+
setSelf: (next) => {
|
|
1795
|
+
setIntoStore(token, next, store);
|
|
1796
|
+
},
|
|
1787
1797
|
onSet: (handle) => subscribeToState(token, handle, `effect[${effectIndex}]`, store)
|
|
1788
1798
|
});
|
|
1789
1799
|
if (cleanup) {
|
|
@@ -1820,7 +1830,7 @@ function deleteAtom(atomToken, store) {
|
|
|
1820
1830
|
store.logger.error(
|
|
1821
1831
|
`\u274C`,
|
|
1822
1832
|
`atom`,
|
|
1823
|
-
|
|
1833
|
+
key,
|
|
1824
1834
|
`Tried to delete atom, but it does not exist in the store.`
|
|
1825
1835
|
);
|
|
1826
1836
|
}
|
|
@@ -1843,7 +1853,7 @@ function deleteAtom(atomToken, store) {
|
|
|
1843
1853
|
const updateToken = getUpdateToken(atomToken);
|
|
1844
1854
|
deleteAtom(updateToken, store);
|
|
1845
1855
|
}
|
|
1846
|
-
store.logger.info(`\u{1F525}`, `atom`,
|
|
1856
|
+
store.logger.info(`\u{1F525}`, `atom`, key, `deleted`);
|
|
1847
1857
|
}
|
|
1848
1858
|
|
|
1849
1859
|
// internal/src/arbitrary.ts
|
|
@@ -1987,7 +1997,7 @@ var addAtomToTimeline = (atomToken, tl, store) => {
|
|
|
1987
1997
|
tl.transactionKey = currentTransactionKey;
|
|
1988
1998
|
const unsubscribe = currentTransaction.subject.subscribe(
|
|
1989
1999
|
`timeline:${tl.key}`,
|
|
1990
|
-
(
|
|
2000
|
+
(transactionUpdate) => {
|
|
1991
2001
|
var _a2, _b2;
|
|
1992
2002
|
unsubscribe();
|
|
1993
2003
|
if (tl.timeTraveling === null && currentTransactionInstanceId) {
|
|
@@ -1995,11 +2005,11 @@ var addAtomToTimeline = (atomToken, tl, store) => {
|
|
|
1995
2005
|
tl.history.splice(tl.at);
|
|
1996
2006
|
}
|
|
1997
2007
|
const filterUpdates = (updates2) => updates2.filter((updateFromTx) => {
|
|
1998
|
-
const
|
|
2008
|
+
const newestStore = newest(store);
|
|
1999
2009
|
if (`updates` in updateFromTx) {
|
|
2000
2010
|
return true;
|
|
2001
2011
|
}
|
|
2002
|
-
const atomOrFamilyKeys =
|
|
2012
|
+
const atomOrFamilyKeys = newestStore.timelineAtoms.getRelatedKeys(tl.key);
|
|
2003
2013
|
return atomOrFamilyKeys ? [...atomOrFamilyKeys].some(
|
|
2004
2014
|
(key) => {
|
|
2005
2015
|
var _a3;
|
|
@@ -2014,11 +2024,11 @@ var addAtomToTimeline = (atomToken, tl, store) => {
|
|
|
2014
2024
|
}
|
|
2015
2025
|
return updateFromTx;
|
|
2016
2026
|
});
|
|
2017
|
-
const updates = filterUpdates(
|
|
2027
|
+
const updates = filterUpdates(transactionUpdate.updates);
|
|
2018
2028
|
const timelineTransactionUpdate = __spreadProps(__spreadValues({
|
|
2019
2029
|
type: `transaction_update`,
|
|
2020
2030
|
timestamp: Date.now()
|
|
2021
|
-
},
|
|
2031
|
+
}, transactionUpdate), {
|
|
2022
2032
|
updates
|
|
2023
2033
|
});
|
|
2024
2034
|
const willCapture = (_b2 = (_a2 = tl.shouldCapture) == null ? void 0 : _a2.call(tl, timelineTransactionUpdate, tl)) != null ? _b2 : true;
|
|
@@ -2033,7 +2043,7 @@ var addAtomToTimeline = (atomToken, tl, store) => {
|
|
|
2033
2043
|
`\u231B`,
|
|
2034
2044
|
`timeline`,
|
|
2035
2045
|
tl.key,
|
|
2036
|
-
`got a transaction_update "${
|
|
2046
|
+
`got a transaction_update "${transactionUpdate.key}"`
|
|
2037
2047
|
);
|
|
2038
2048
|
}
|
|
2039
2049
|
);
|
|
@@ -2133,7 +2143,7 @@ function createTimeline(options, store, data) {
|
|
|
2133
2143
|
transactionKey: null
|
|
2134
2144
|
}, data), {
|
|
2135
2145
|
history: (_a = data == null ? void 0 : data.history.map((update) => __spreadValues({}, update))) != null ? _a : [],
|
|
2136
|
-
install: (
|
|
2146
|
+
install: (s) => createTimeline(options, s, tl),
|
|
2137
2147
|
subject: new Subject()
|
|
2138
2148
|
});
|
|
2139
2149
|
if (options.shouldCapture) {
|
|
@@ -2424,16 +2434,18 @@ var buildTransaction = (key, params, store, id) => {
|
|
|
2424
2434
|
update: {
|
|
2425
2435
|
key,
|
|
2426
2436
|
id,
|
|
2427
|
-
epoch: epoch === void 0 ? NaN : epoch + 1,
|
|
2437
|
+
epoch: epoch === void 0 ? Number.NaN : epoch + 1,
|
|
2428
2438
|
updates: [],
|
|
2429
2439
|
params,
|
|
2430
2440
|
output: void 0
|
|
2431
2441
|
},
|
|
2432
2442
|
transactors: {
|
|
2433
2443
|
get: (token) => getFromStore(token, child),
|
|
2434
|
-
set: (token, value) =>
|
|
2435
|
-
|
|
2436
|
-
|
|
2444
|
+
set: (token, value) => {
|
|
2445
|
+
setIntoStore(token, value, child);
|
|
2446
|
+
},
|
|
2447
|
+
run: (token, identifier = arbitrary()) => actUponStore(token, identifier, child),
|
|
2448
|
+
find: (token, k) => findInStore(token, k, child),
|
|
2437
2449
|
env: () => getEnvironmentData(child)
|
|
2438
2450
|
}
|
|
2439
2451
|
};
|
|
@@ -2470,7 +2482,7 @@ function createTransaction(options, store) {
|
|
|
2470
2482
|
throw thrown;
|
|
2471
2483
|
}
|
|
2472
2484
|
},
|
|
2473
|
-
install: (
|
|
2485
|
+
install: (s) => createTransaction(options, s),
|
|
2474
2486
|
subject: new Subject()
|
|
2475
2487
|
};
|
|
2476
2488
|
const target = newest(store);
|
package/internal/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Func, TransactionToken, TransactionUpdate, TransactionOptions, TransactorsWithRunAndEnv, RegularAtomToken, MutableAtomToken, WritableSelectorToken, ReadonlySelectorToken, WritableToken, ReadableToken, TimelineManageable, StateUpdate, TokenType, FamilyMetadata, TimelineUpdate, TimelineOptions, TimelineToken, AtomToken, WritableSelectorFamily, MutableAtomFamily, RegularAtomFamily, ReadonlySelectorFamily, AtomIOLogger, Logger, AtomFamily, SelectorFamily, SelectorToken, RegularAtomFamilyToken, MutableAtomFamilyToken, AtomFamilyToken, ReadonlySelectorFamilyToken, WritableSelectorFamilyToken, SelectorFamilyToken, MutableAtomOptions, MutableAtomFamilyOptions, RegularAtomOptions, RegularAtomFamilyOptions, ReadonlySelectorFamilyOptions, WritableSelectorFamilyOptions, WritableFamilyToken, ReadableFamilyToken, KeyedStateUpdate, ReadonlySelectorOptions, WritableSelectorOptions, Transactors, UpdateHandler, TransactionUpdateHandler } from 'atom.io';
|
|
2
2
|
import { Json, JsonInterface } from 'atom.io/json';
|
|
3
3
|
|
|
4
4
|
type primitive = boolean | number | string | null;
|
|
@@ -77,9 +77,9 @@ declare class Junction<const ASide extends string, const BSide extends string, c
|
|
|
77
77
|
|
|
78
78
|
declare const abortTransaction: (store: Store) => void;
|
|
79
79
|
|
|
80
|
-
declare function actUponStore
|
|
80
|
+
declare function actUponStore<F extends Func>(token: TransactionToken<F>, id: string, store: Store): (...parameters: Parameters<F>) => ReturnType<F>;
|
|
81
81
|
|
|
82
|
-
declare const applyTransaction:
|
|
82
|
+
declare const applyTransaction: <F extends Func>(output: ReturnType<F>, store: Store) => void;
|
|
83
83
|
|
|
84
84
|
declare function assignTransactionToContinuity(continuityKey: string, transactionKey: string, store: Store): void;
|
|
85
85
|
|
|
@@ -89,7 +89,7 @@ interface RootStore extends Store {
|
|
|
89
89
|
child: ChildStore | null;
|
|
90
90
|
}
|
|
91
91
|
interface ChildStore extends Store {
|
|
92
|
-
transactionMeta: TransactionProgress<
|
|
92
|
+
transactionMeta: TransactionProgress<Func>;
|
|
93
93
|
parent: ChildStore | RootStore;
|
|
94
94
|
child: ChildStore | null;
|
|
95
95
|
}
|
|
@@ -111,14 +111,14 @@ declare class StatefulSubject<T> extends Subject<T> {
|
|
|
111
111
|
next(value: T): void;
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
type Transaction
|
|
114
|
+
type Transaction<F extends Func> = {
|
|
115
115
|
key: string;
|
|
116
116
|
type: `transaction`;
|
|
117
117
|
install: (store: Store) => void;
|
|
118
|
-
subject: Subject<TransactionUpdate
|
|
119
|
-
run: (parameters: Parameters
|
|
118
|
+
subject: Subject<TransactionUpdate<F>>;
|
|
119
|
+
run: (parameters: Parameters<F>, id?: string) => ReturnType<F>;
|
|
120
120
|
};
|
|
121
|
-
declare function createTransaction
|
|
121
|
+
declare function createTransaction<F extends Func>(options: TransactionOptions<F>, store: Store): TransactionToken<F>;
|
|
122
122
|
|
|
123
123
|
declare function getContinuityKey(transactionKey: string, store: Store): string | undefined;
|
|
124
124
|
declare function getEpochNumberOfContinuity(continuityKey: string, store: Store): number | undefined;
|
|
@@ -129,9 +129,9 @@ declare function setEpochNumberOfAction(transactionKey: string, newEpoch: number
|
|
|
129
129
|
|
|
130
130
|
declare const TRANSACTION_PHASES: readonly ["idle", "building", "applying"];
|
|
131
131
|
type TransactionPhase = (typeof TRANSACTION_PHASES)[number];
|
|
132
|
-
type TransactionProgress
|
|
132
|
+
type TransactionProgress<F extends Func> = {
|
|
133
133
|
phase: `applying` | `building`;
|
|
134
|
-
update: TransactionUpdate
|
|
134
|
+
update: TransactionUpdate<F>;
|
|
135
135
|
transactors: TransactorsWithRunAndEnv;
|
|
136
136
|
};
|
|
137
137
|
type TransactionEpoch = {
|
|
@@ -144,7 +144,7 @@ declare function deposit<T extends Transceiver<any>>(state: MutableAtom<T, any>)
|
|
|
144
144
|
declare function deposit<T>(state: WritableSelector<T>): WritableSelectorToken<T>;
|
|
145
145
|
declare function deposit<T>(state: ReadonlySelector<T>): ReadonlySelectorToken<T>;
|
|
146
146
|
declare function deposit<T>(state: WritableState<T>): WritableToken<T>;
|
|
147
|
-
declare function deposit<T>(state: Transaction<T
|
|
147
|
+
declare function deposit<T extends Func>(state: Transaction<T>): TransactionToken<T>;
|
|
148
148
|
declare function deposit<T>(state: ReadableState<T>): ReadableToken<T>;
|
|
149
149
|
|
|
150
150
|
interface Lineage {
|
|
@@ -179,7 +179,7 @@ type TimelineSelectorUpdate<ManagedAtom extends TimelineManageable> = {
|
|
|
179
179
|
timestamp: number;
|
|
180
180
|
atomUpdates: Omit<TimelineAtomUpdate<ManagedAtom>, `timestamp`>[];
|
|
181
181
|
};
|
|
182
|
-
type TimelineTransactionUpdate = TransactionUpdate<
|
|
182
|
+
type TimelineTransactionUpdate = TransactionUpdate<Func> & {
|
|
183
183
|
key: string;
|
|
184
184
|
type: `transaction_update`;
|
|
185
185
|
timestamp: number;
|
|
@@ -212,7 +212,7 @@ declare class Store implements Lineage {
|
|
|
212
212
|
trackers: Map<string, Tracker<Transceiver<any>>>;
|
|
213
213
|
families: Map<string, WritableSelectorFamily<any, any> | MutableAtomFamily<any, any, any> | RegularAtomFamily<any, any> | ReadonlySelectorFamily<any, any>>;
|
|
214
214
|
timelines: Map<string, Timeline<any>>;
|
|
215
|
-
transactions: Map<string, Transaction<
|
|
215
|
+
transactions: Map<string, Transaction<Func>>;
|
|
216
216
|
atomsThatAreDefault: Set<string>;
|
|
217
217
|
timelineAtoms: Junction<"timelineKey", "atomKey", null>;
|
|
218
218
|
selectorAtoms: Junction<"selectorKey", "atomKey", null>;
|
|
@@ -222,13 +222,13 @@ declare class Store implements Lineage {
|
|
|
222
222
|
on: {
|
|
223
223
|
atomCreation: Subject<AtomToken<unknown>>;
|
|
224
224
|
selectorCreation: Subject<ReadonlySelectorToken<unknown> | WritableSelectorToken<unknown>>;
|
|
225
|
-
transactionCreation: Subject<TransactionToken<
|
|
225
|
+
transactionCreation: Subject<TransactionToken<Func>>;
|
|
226
226
|
timelineCreation: Subject<TimelineToken<unknown>>;
|
|
227
|
-
transactionApplying: StatefulSubject<TransactionProgress<
|
|
227
|
+
transactionApplying: StatefulSubject<TransactionProgress<Func> | null>;
|
|
228
228
|
operationClose: Subject<OperationProgress>;
|
|
229
229
|
};
|
|
230
230
|
operation: OperationProgress;
|
|
231
|
-
transactionMeta: TransactionEpoch | TransactionProgress<
|
|
231
|
+
transactionMeta: TransactionEpoch | TransactionProgress<Func>;
|
|
232
232
|
config: {
|
|
233
233
|
name: string;
|
|
234
234
|
};
|
|
@@ -242,7 +242,7 @@ declare const IMPLICIT: {
|
|
|
242
242
|
};
|
|
243
243
|
declare const clearStore: (store: Store) => void;
|
|
244
244
|
|
|
245
|
-
type Withdrawable = Atom<any> | AtomFamily<any, any> | MutableAtom<any, any> | MutableAtomFamily<any, any, any> | ReadableState<any> |
|
|
245
|
+
type Withdrawable = Atom<any> | AtomFamily<any, any> | MutableAtom<any, any> | MutableAtomFamily<any, any, any> | ReadableState<any> | ReadonlySelector<any> | ReadonlySelectorFamily<any, any> | RegularAtom<any> | RegularAtomFamily<any, any> | Selector<any> | SelectorFamily<any, any> | Timeline<any> | Transaction<any> | WritableSelector<any> | WritableSelectorFamily<any, any> | WritableState<any>;
|
|
246
246
|
declare function withdraw<T>(token: RegularAtomToken<T>, store: Store): RegularAtom<T>;
|
|
247
247
|
declare function withdraw<T extends Transceiver<any>>(token: MutableAtomToken<T, any>, store: Store): MutableAtom<T, any>;
|
|
248
248
|
declare function withdraw<T>(token: AtomToken<T>, store: Store): Atom<T>;
|
|
@@ -257,7 +257,7 @@ declare function withdraw<T, K extends Json.Serializable>(token: AtomFamilyToken
|
|
|
257
257
|
declare function withdraw<T, K extends Json.Serializable>(token: ReadonlySelectorFamilyToken<T, K>, store: Store): ReadonlySelectorFamily<T, any>;
|
|
258
258
|
declare function withdraw<T, K extends Json.Serializable>(token: WritableSelectorFamilyToken<T, K>, store: Store): WritableSelectorFamily<T, any>;
|
|
259
259
|
declare function withdraw<T, K extends Json.Serializable>(token: SelectorFamilyToken<T, K>, store: Store): SelectorFamily<T, any>;
|
|
260
|
-
declare function withdraw<T>(token: TransactionToken<T>, store: Store): Transaction<T extends
|
|
260
|
+
declare function withdraw<T extends Func>(token: TransactionToken<T>, store: Store): Transaction<T extends Func ? T : never>;
|
|
261
261
|
declare function withdraw<T>(token: TimelineToken<T>, store: Store): Timeline<T extends TimelineManageable ? T : never>;
|
|
262
262
|
|
|
263
263
|
declare function withdrawOrCreate<T>(token: RegularAtomToken<T>, store: Store): Atom<T>;
|
|
@@ -275,7 +275,7 @@ interface Transceiver<Signal extends Json.Serializable> {
|
|
|
275
275
|
}
|
|
276
276
|
declare function isTransceiver(value: unknown): value is Transceiver<Json.Serializable>;
|
|
277
277
|
type TransceiverMode = `playback` | `record` | `transaction`;
|
|
278
|
-
type Signal<TVR extends Transceiver<any>> = TVR extends Transceiver<infer
|
|
278
|
+
type Signal<TVR extends Transceiver<any>> = TVR extends Transceiver<infer S> ? S : never;
|
|
279
279
|
|
|
280
280
|
declare function createMutableAtom<T extends Transceiver<any>, J extends Json.Serializable>(options: MutableAtomOptions<T, J>, family: FamilyMetadata | undefined, store: Store): MutableAtomToken<T, J>;
|
|
281
281
|
|
|
@@ -437,7 +437,7 @@ declare const traceAllSelectorAtoms: (selector: Selector<any>, store: Store) =>
|
|
|
437
437
|
declare const updateSelectorAtoms: (selectorKey: string, dependency: ReadonlySelectorToken<unknown> | WritableToken<unknown>, store: Store) => void;
|
|
438
438
|
|
|
439
439
|
type Modify<T> = (thing: T) => T;
|
|
440
|
-
declare const become: <T>(nextVersionOfThing: T |
|
|
440
|
+
declare const become: <T>(nextVersionOfThing: Modify<T> | T) => (originalThing: T) => T;
|
|
441
441
|
|
|
442
442
|
declare const setAtomOrSelector: <T>(state: WritableState<T>, value: T | ((oldValue: T) => T), store: Store) => void;
|
|
443
443
|
|
|
@@ -449,7 +449,7 @@ declare function subscribeToState<T>(token: ReadableToken<T>, handleUpdate: Upda
|
|
|
449
449
|
|
|
450
450
|
declare const subscribeToTimeline: <ManagedAtom extends TimelineManageable>(token: TimelineToken<ManagedAtom>, handleUpdate: (update: TimelineUpdate<any> | `redo` | `undo`) => void, key: string, store: Store) => (() => void);
|
|
451
451
|
|
|
452
|
-
declare const subscribeToTransaction:
|
|
452
|
+
declare const subscribeToTransaction: <F extends Func>(token: TransactionToken<F>, handleUpdate: TransactionUpdateHandler<F>, key: string, store: Store) => (() => void);
|
|
453
453
|
|
|
454
454
|
type AtomIOState = {
|
|
455
455
|
key: string;
|