atom.io 0.17.0 → 0.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/data/dist/index.cjs +62 -40
- package/data/dist/index.cjs.map +1 -1
- package/data/dist/index.d.ts +8 -2
- package/data/dist/index.js +64 -42
- package/data/dist/index.js.map +1 -1
- package/data/src/dict.ts +8 -4
- package/data/src/join.ts +74 -33
- package/data/src/struct-family.ts +18 -17
- package/dist/chunk-IZHOMSXA.js +331 -0
- package/dist/chunk-IZHOMSXA.js.map +1 -0
- package/dist/chunk-JDUNWJFB.js +18 -0
- package/dist/chunk-JDUNWJFB.js.map +1 -0
- package/dist/index.cjs +4 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +66 -51
- package/dist/index.js +5 -11
- package/dist/index.js.map +1 -1
- package/internal/dist/index.cjs +187 -58
- package/internal/dist/index.cjs.map +1 -1
- package/internal/dist/index.d.ts +95 -71
- package/internal/dist/index.js +179 -53
- package/internal/dist/index.js.map +1 -1
- package/internal/src/arbitrary.ts +3 -0
- package/internal/src/atom/delete-atom.ts +7 -6
- package/internal/src/caching.ts +6 -4
- package/internal/src/families/find-in-store.ts +16 -0
- package/internal/src/get-environment-data.ts +4 -7
- package/internal/src/index.ts +6 -5
- package/internal/src/ingest-updates/ingest-atom-update.ts +6 -2
- package/internal/src/ingest-updates/ingest-transaction-update.ts +0 -1
- package/internal/src/selector/create-standalone-selector.ts +0 -2
- package/internal/src/set-state/copy-mutable-if-needed.ts +5 -0
- package/internal/src/set-state/emit-update.ts +25 -11
- package/internal/src/set-state/set-atom.ts +15 -18
- package/internal/src/store/store.ts +14 -2
- package/internal/src/store/withdraw.ts +72 -2
- package/internal/src/subscribe/subscribe-to-timeline.ts +2 -2
- package/internal/src/subscribe/subscribe-to-transaction.ts +2 -2
- package/internal/src/timeline/create-timeline.ts +12 -1
- package/internal/src/transaction/act-upon-store.ts +19 -0
- package/internal/src/transaction/apply-transaction.ts +6 -1
- package/internal/src/transaction/assign-transaction-to-continuity.ts +18 -0
- package/internal/src/transaction/build-transaction.ts +7 -6
- package/internal/src/transaction/create-transaction.ts +1 -1
- package/internal/src/transaction/get-epoch-number.ts +40 -0
- package/internal/src/transaction/index.ts +10 -1
- package/internal/src/transaction/set-epoch-number.ts +30 -0
- package/introspection/dist/index.cjs.map +1 -1
- package/introspection/dist/index.d.ts +3 -3
- package/introspection/dist/index.js.map +1 -1
- package/introspection/src/attach-introspection-states.ts +6 -2
- package/introspection/src/attach-timeline-family.ts +5 -2
- package/introspection/src/attach-transaction-logs.ts +2 -2
- package/json/dist/index.d.ts +3 -1
- package/json/src/index.ts +4 -0
- package/package.json +241 -230
- package/react/dist/index.cjs.map +1 -1
- package/react/dist/index.d.ts +1 -1
- package/react/dist/index.js.map +1 -1
- package/react/src/use-json.ts +1 -1
- package/react-devtools/dist/index.cjs +131 -134
- package/react-devtools/dist/index.cjs.map +1 -1
- package/react-devtools/dist/index.css +2 -2
- package/react-devtools/dist/index.css.map +1 -1
- package/react-devtools/dist/index.d.ts +3 -3
- package/react-devtools/dist/index.js +91 -108
- package/react-devtools/dist/index.js.map +1 -1
- package/react-devtools/src/StateEditor.tsx +4 -4
- package/react-devtools/src/StateIndex.tsx +1 -4
- package/react-devtools/src/TimelineIndex.tsx +3 -3
- package/react-devtools/src/TransactionIndex.tsx +9 -8
- package/react-devtools/src/index.ts +2 -2
- package/realtime/dist/index.cjs +120 -0
- package/realtime/dist/index.cjs.map +1 -0
- package/realtime/dist/index.d.ts +146 -0
- package/realtime/dist/index.js +111 -0
- package/realtime/dist/index.js.map +1 -0
- package/realtime/package.json +16 -0
- package/realtime/src/index.ts +2 -0
- package/realtime/src/realtime-continuity.ts +162 -0
- package/realtime/src/shared-room-store.ts +48 -0
- package/realtime-client/dist/index.cjs +424 -170
- package/realtime-client/dist/index.cjs.map +1 -1
- package/realtime-client/dist/index.d.ts +15 -11
- package/realtime-client/dist/index.js +96 -177
- package/realtime-client/dist/index.js.map +1 -1
- package/realtime-client/src/index.ts +8 -7
- package/realtime-client/src/{pull-family-member.ts → pull-atom-family-member.ts} +2 -2
- package/realtime-client/src/{pull-state.ts → pull-atom.ts} +2 -2
- package/realtime-client/src/{pull-mutable-family-member.ts → pull-mutable-atom-family-member.ts} +6 -6
- package/realtime-client/src/{pull-mutable.ts → pull-mutable-atom.ts} +1 -1
- package/realtime-client/src/pull-selector-family-member.ts +42 -0
- package/realtime-client/src/pull-selector.ts +38 -0
- package/realtime-client/src/realtime-client-stores/client-main-store.ts +12 -2
- package/realtime-client/src/realtime-client-stores/client-sync-store.ts +7 -7
- package/realtime-client/src/sync-continuity.ts +368 -0
- package/realtime-react/dist/index.cjs +367 -27
- package/realtime-react/dist/index.cjs.map +1 -1
- package/realtime-react/dist/index.d.ts +24 -8
- package/realtime-react/dist/index.js +38 -22
- package/realtime-react/dist/index.js.map +1 -1
- package/realtime-react/src/index.ts +6 -5
- package/realtime-react/src/use-pull-atom-family-member.ts +21 -0
- package/realtime-react/src/{use-sync.ts → use-pull-atom.ts} +4 -4
- package/realtime-react/src/{use-pull-mutable.ts → use-pull-mutable-atom.ts} +4 -3
- package/realtime-react/src/use-pull-mutable-family-member.ts +9 -4
- package/realtime-react/src/use-pull-selector-family-member.ts +21 -0
- package/realtime-react/src/{use-pull.ts → use-pull-selector.ts} +7 -5
- package/realtime-react/src/use-push.ts +3 -2
- package/realtime-react/src/use-server-action.ts +3 -2
- package/realtime-react/src/use-sync-continuity.ts +12 -0
- package/realtime-server/dist/index.cjs +769 -371
- package/realtime-server/dist/index.cjs.map +1 -1
- package/realtime-server/dist/index.d.ts +130 -60
- package/realtime-server/dist/index.js +753 -361
- package/realtime-server/dist/index.js.map +1 -1
- package/realtime-server/src/index.ts +17 -3
- package/realtime-server/src/ipc-sockets/child-socket.ts +135 -0
- package/realtime-server/src/ipc-sockets/custom-socket.ts +90 -0
- package/realtime-server/src/ipc-sockets/index.ts +3 -0
- package/realtime-server/src/ipc-sockets/parent-socket.ts +185 -0
- package/realtime-server/src/realtime-action-receiver.ts +8 -5
- package/realtime-server/src/realtime-continuity-synchronizer.ts +376 -0
- package/realtime-server/src/realtime-family-provider.ts +30 -71
- package/realtime-server/src/realtime-mutable-family-provider.ts +24 -86
- package/realtime-server/src/realtime-server-stores/index.ts +4 -1
- package/realtime-server/src/realtime-server-stores/realtime-continuity-store.ts +109 -0
- package/realtime-server/src/realtime-server-stores/server-room-external-actions.ts +64 -0
- package/realtime-server/src/realtime-server-stores/server-room-external-store.ts +42 -0
- package/realtime-server/src/realtime-server-stores/server-sync-store.ts +51 -98
- package/realtime-server/src/realtime-server-stores/server-user-store.ts +14 -29
- package/realtime-server/src/realtime-state-receiver.ts +0 -1
- package/realtime-testing/dist/index.cjs +34 -32
- package/realtime-testing/dist/index.cjs.map +1 -1
- package/realtime-testing/dist/index.d.ts +1 -0
- package/realtime-testing/dist/index.js +33 -31
- package/realtime-testing/dist/index.js.map +1 -1
- package/realtime-testing/src/setup-realtime-test.tsx +44 -32
- package/src/atom.ts +49 -31
- package/src/logger.ts +14 -5
- package/src/selector.ts +44 -25
- package/src/subscribe.ts +2 -1
- package/src/timeline.ts +4 -4
- package/src/transaction.ts +13 -17
- package/src/validators.ts +15 -9
- package/dist/chunk-H4Q5FTPZ.js +0 -11
- package/dist/chunk-H4Q5FTPZ.js.map +0 -1
- package/internal/src/set-state/copy-mutable-in-transaction.ts +0 -19
- package/realtime-client/src/sync-server-action.ts +0 -170
- package/realtime-client/src/sync-state.ts +0 -19
- package/realtime-react/src/use-pull-family-member.ts +0 -16
- package/realtime-react/src/use-sync-server-action.ts +0 -16
- package/realtime-server/src/realtime-action-synchronizer.ts +0 -152
package/internal/dist/index.d.ts
CHANGED
|
@@ -1,64 +1,5 @@
|
|
|
1
|
-
import { ƒn as _n, TransactionUpdate, TransactionOptions,
|
|
1
|
+
import { ƒn as _n, 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
|
-
import { Store as Store$1 } from 'atom.io/internal';
|
|
4
|
-
|
|
5
|
-
declare const abortTransaction: (store: Store) => void;
|
|
6
|
-
|
|
7
|
-
declare const applyTransaction: <ƒ extends _n>(output: ReturnType<ƒ>, store: Store) => void;
|
|
8
|
-
|
|
9
|
-
interface RootStore extends Store {
|
|
10
|
-
transactionMeta: TransactionEpoch;
|
|
11
|
-
parent: null;
|
|
12
|
-
child: ChildStore | null;
|
|
13
|
-
}
|
|
14
|
-
interface ChildStore extends Store {
|
|
15
|
-
transactionMeta: TransactionProgress<_n>;
|
|
16
|
-
parent: ChildStore | RootStore;
|
|
17
|
-
child: ChildStore | null;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
declare const buildTransaction: (key: string, params: any[], store: Store, id?: string) => ChildStore;
|
|
21
|
-
|
|
22
|
-
declare class Subject<T> {
|
|
23
|
-
Subscriber: (value: T) => void;
|
|
24
|
-
subscribers: Map<string, this[`Subscriber`]>;
|
|
25
|
-
subscribe(key: string, subscriber: this[`Subscriber`]): () => void;
|
|
26
|
-
private unsubscribe;
|
|
27
|
-
next(value: T): void;
|
|
28
|
-
}
|
|
29
|
-
declare class StatefulSubject<T> extends Subject<T> {
|
|
30
|
-
state: T;
|
|
31
|
-
constructor(initialState: T);
|
|
32
|
-
next(value: T): void;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
type Transaction<ƒ extends _n> = {
|
|
36
|
-
key: string;
|
|
37
|
-
type: `transaction`;
|
|
38
|
-
install: (store: Store) => void;
|
|
39
|
-
subject: Subject<TransactionUpdate<ƒ>>;
|
|
40
|
-
run: (parameters: Parameters<ƒ>, id?: string) => ReturnType<ƒ>;
|
|
41
|
-
};
|
|
42
|
-
declare function createTransaction<ƒ extends _n>(options: TransactionOptions<ƒ>, store: Store): TransactionToken<ƒ>;
|
|
43
|
-
|
|
44
|
-
declare const TRANSACTION_PHASES: readonly ["idle", "building", "applying"];
|
|
45
|
-
type TransactionPhase = (typeof TRANSACTION_PHASES)[number];
|
|
46
|
-
type TransactionProgress<ƒ extends _n> = {
|
|
47
|
-
phase: `applying` | `building`;
|
|
48
|
-
update: TransactionUpdate<ƒ>;
|
|
49
|
-
transactors: TransactorsWithRunAndEnv;
|
|
50
|
-
};
|
|
51
|
-
type TransactionEpoch = {
|
|
52
|
-
epoch: number;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
declare function deposit<T>(state: RegularAtom<T>): RegularAtomToken<T>;
|
|
56
|
-
declare function deposit<T extends Transceiver<any>>(state: MutableAtom<T, any>): MutableAtomToken<T, any>;
|
|
57
|
-
declare function deposit<T>(state: WritableSelector<T>): WritableSelectorToken<T>;
|
|
58
|
-
declare function deposit<T>(state: ReadonlySelector<T>): ReadonlySelectorToken<T>;
|
|
59
|
-
declare function deposit<T>(state: WritableState<T>): WritableToken<T>;
|
|
60
|
-
declare function deposit<T>(state: Transaction<T extends _n ? T : never>): TransactionToken<T>;
|
|
61
|
-
declare function deposit<T>(state: ReadableState<T>): ReadableToken<T>;
|
|
62
3
|
|
|
63
4
|
type primitive = boolean | number | string | null;
|
|
64
5
|
|
|
@@ -134,6 +75,78 @@ declare class Junction<const ASide extends string, const BSide extends string, c
|
|
|
134
75
|
has(a: string, b?: string): boolean;
|
|
135
76
|
}
|
|
136
77
|
|
|
78
|
+
declare const abortTransaction: (store: Store) => void;
|
|
79
|
+
|
|
80
|
+
declare function actUponStore<ƒ extends _n>(token: TransactionToken<ƒ>, id: string, store: Store): (...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
81
|
+
|
|
82
|
+
declare const applyTransaction: <ƒ extends _n>(output: ReturnType<ƒ>, store: Store) => void;
|
|
83
|
+
|
|
84
|
+
declare function assignTransactionToContinuity(continuityKey: string, transactionKey: string, store: Store): void;
|
|
85
|
+
|
|
86
|
+
interface RootStore extends Store {
|
|
87
|
+
transactionMeta: TransactionEpoch;
|
|
88
|
+
parent: null;
|
|
89
|
+
child: ChildStore | null;
|
|
90
|
+
}
|
|
91
|
+
interface ChildStore extends Store {
|
|
92
|
+
transactionMeta: TransactionProgress<_n>;
|
|
93
|
+
parent: ChildStore | RootStore;
|
|
94
|
+
child: ChildStore | null;
|
|
95
|
+
}
|
|
96
|
+
declare function isRootStore(store: Store): store is RootStore;
|
|
97
|
+
declare function isChildStore(store: Store): store is ChildStore;
|
|
98
|
+
|
|
99
|
+
declare const buildTransaction: (key: string, params: any[], store: Store, id: string) => ChildStore;
|
|
100
|
+
|
|
101
|
+
declare class Subject<T> {
|
|
102
|
+
Subscriber: (value: T) => void;
|
|
103
|
+
subscribers: Map<string, this[`Subscriber`]>;
|
|
104
|
+
subscribe(key: string, subscriber: this[`Subscriber`]): () => void;
|
|
105
|
+
private unsubscribe;
|
|
106
|
+
next(value: T): void;
|
|
107
|
+
}
|
|
108
|
+
declare class StatefulSubject<T> extends Subject<T> {
|
|
109
|
+
state: T;
|
|
110
|
+
constructor(initialState: T);
|
|
111
|
+
next(value: T): void;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
type Transaction<ƒ extends _n> = {
|
|
115
|
+
key: string;
|
|
116
|
+
type: `transaction`;
|
|
117
|
+
install: (store: Store) => void;
|
|
118
|
+
subject: Subject<TransactionUpdate<ƒ>>;
|
|
119
|
+
run: (parameters: Parameters<ƒ>, id?: string) => ReturnType<ƒ>;
|
|
120
|
+
};
|
|
121
|
+
declare function createTransaction<ƒ extends _n>(options: TransactionOptions<ƒ>, store: Store): TransactionToken<ƒ>;
|
|
122
|
+
|
|
123
|
+
declare function getContinuityKey(transactionKey: string, store: Store): string | undefined;
|
|
124
|
+
declare function getEpochNumberOfContinuity(continuityKey: string, store: Store): number | undefined;
|
|
125
|
+
declare function getEpochNumberOfAction(transactionKey: string, store: Store): number | undefined;
|
|
126
|
+
|
|
127
|
+
declare function setEpochNumberOfContinuity(continuityKey: string, newEpoch: number, store: Store): void;
|
|
128
|
+
declare function setEpochNumberOfAction(transactionKey: string, newEpoch: number, store: Store): void;
|
|
129
|
+
|
|
130
|
+
declare const TRANSACTION_PHASES: readonly ["idle", "building", "applying"];
|
|
131
|
+
type TransactionPhase = (typeof TRANSACTION_PHASES)[number];
|
|
132
|
+
type TransactionProgress<ƒ extends _n> = {
|
|
133
|
+
phase: `applying` | `building`;
|
|
134
|
+
update: TransactionUpdate<ƒ>;
|
|
135
|
+
transactors: TransactorsWithRunAndEnv;
|
|
136
|
+
};
|
|
137
|
+
type TransactionEpoch = {
|
|
138
|
+
epoch: Map<string, number>;
|
|
139
|
+
actionContinuities: Junction<`continuity`, `action`>;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
declare function deposit<T>(state: RegularAtom<T>): RegularAtomToken<T>;
|
|
143
|
+
declare function deposit<T extends Transceiver<any>>(state: MutableAtom<T, any>): MutableAtomToken<T, any>;
|
|
144
|
+
declare function deposit<T>(state: WritableSelector<T>): WritableSelectorToken<T>;
|
|
145
|
+
declare function deposit<T>(state: ReadonlySelector<T>): ReadonlySelectorToken<T>;
|
|
146
|
+
declare function deposit<T>(state: WritableState<T>): WritableToken<T>;
|
|
147
|
+
declare function deposit<T>(state: Transaction<T extends _n ? T : never>): TransactionToken<T>;
|
|
148
|
+
declare function deposit<T>(state: ReadableState<T>): ReadableToken<T>;
|
|
149
|
+
|
|
137
150
|
interface Lineage {
|
|
138
151
|
parent: typeof this | null;
|
|
139
152
|
child: typeof this | null;
|
|
@@ -229,7 +242,7 @@ declare const IMPLICIT: {
|
|
|
229
242
|
};
|
|
230
243
|
declare const clearStore: (store: Store) => void;
|
|
231
244
|
|
|
232
|
-
type Withdrawable = ReadableState<any> | Timeline<any> | Transaction<any>;
|
|
245
|
+
type Withdrawable = Atom<any> | AtomFamily<any, any> | MutableAtom<any, any> | MutableAtomFamily<any, any, any> | ReadableState<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>;
|
|
233
246
|
declare function withdraw<T>(token: RegularAtomToken<T>, store: Store): RegularAtom<T> | undefined;
|
|
234
247
|
declare function withdraw<T extends Transceiver<any>>(token: MutableAtomToken<T, any>, store: Store): MutableAtom<T, any> | undefined;
|
|
235
248
|
declare function withdraw<T>(token: AtomToken<T>, store: Store): Atom<T> | undefined;
|
|
@@ -238,6 +251,12 @@ declare function withdraw<T>(token: ReadonlySelectorToken<T>, store: Store): Rea
|
|
|
238
251
|
declare function withdraw<T>(token: SelectorToken<T>, store: Store): Selector<T> | undefined;
|
|
239
252
|
declare function withdraw<T>(token: WritableToken<T>, store: Store): WritableState<T> | undefined;
|
|
240
253
|
declare function withdraw<T>(token: ReadableToken<T>, store: Store): ReadableState<T> | undefined;
|
|
254
|
+
declare function withdraw<T, K extends Json.Serializable>(token: RegularAtomFamilyToken<T, K>, store: Store): RegularAtomFamily<T, K> | undefined;
|
|
255
|
+
declare function withdraw<T extends Transceiver<any>, J extends Json.Serializable, K extends Json.Serializable>(token: MutableAtomFamilyToken<T, J, K>, store: Store): MutableAtomFamily<T, J, K> | undefined;
|
|
256
|
+
declare function withdraw<T, K extends Json.Serializable>(token: AtomFamilyToken<T>, store: Store): AtomFamily<T, any> | undefined;
|
|
257
|
+
declare function withdraw<T, K extends Json.Serializable>(token: ReadonlySelectorFamilyToken<T, K>, store: Store): ReadonlySelectorFamily<T, any> | undefined;
|
|
258
|
+
declare function withdraw<T, K extends Json.Serializable>(token: WritableSelectorFamilyToken<T, K>, store: Store): WritableSelectorFamily<T, any> | undefined;
|
|
259
|
+
declare function withdraw<T, K extends Json.Serializable>(token: SelectorFamilyToken<T, K>, store: Store): SelectorFamily<T, any> | undefined;
|
|
241
260
|
declare function withdraw<T>(token: TransactionToken<T>, store: Store): Transaction<T extends _n ? T : never> | undefined;
|
|
242
261
|
declare function withdraw<T>(token: TimelineToken<T>, store: Store): Timeline<T extends TimelineManageable ? T : never> | undefined;
|
|
243
262
|
|
|
@@ -301,12 +320,14 @@ declare function createStandaloneAtom<T extends Transceiver<any>, J extends Json
|
|
|
301
320
|
|
|
302
321
|
declare function createRegularAtom<T>(options: MutableAtomOptions<any, any> | RegularAtomOptions<T>, family: FamilyMetadata | undefined, store: Store): RegularAtomToken<T>;
|
|
303
322
|
|
|
304
|
-
declare function deleteAtom(atomToken:
|
|
323
|
+
declare function deleteAtom(atomToken: AtomToken<unknown>, store: Store): void;
|
|
305
324
|
|
|
306
325
|
declare const isAtomDefault: (key: string, store: Store) => boolean;
|
|
307
326
|
declare const markAtomAsDefault: (key: string, store: Store) => void;
|
|
308
327
|
declare const markAtomAsNotDefault: (key: string, store: Store) => void;
|
|
309
328
|
|
|
329
|
+
declare function arbitrary(random?: () => number): string;
|
|
330
|
+
|
|
310
331
|
/**
|
|
311
332
|
* A Promise that can be canceled.
|
|
312
333
|
* @internal
|
|
@@ -339,13 +360,16 @@ declare function createSelectorFamily<T, K extends Json.Serializable>(options: R
|
|
|
339
360
|
|
|
340
361
|
declare function findInStore<T extends Transceiver<any>, J extends Json.Serializable, K extends Json.Serializable, Key extends K>(token: MutableAtomFamilyToken<T, J, K>, key: Key, store: Store): MutableAtomToken<T, J>;
|
|
341
362
|
declare function findInStore<T, K extends Json.Serializable, Key extends K>(token: RegularAtomFamilyToken<T, K>, key: Key, store: Store): RegularAtomToken<T>;
|
|
363
|
+
declare function findInStore<T, K extends Json.Serializable, Key extends K>(token: AtomFamilyToken<T, K>, key: Key, store: Store): AtomToken<T>;
|
|
342
364
|
declare function findInStore<T, K extends Json.Serializable, Key extends K>(token: WritableSelectorFamilyToken<T, K>, key: Key, store: Store): WritableSelectorToken<T>;
|
|
343
365
|
declare function findInStore<T, K extends Json.Serializable, Key extends K>(token: ReadonlySelectorFamilyToken<T, K>, key: Key, store: Store): ReadonlySelectorToken<T>;
|
|
366
|
+
declare function findInStore<T, K extends Json.Serializable, Key extends K>(token: SelectorFamilyToken<T, K>, key: Key, store: Store): SelectorToken<T>;
|
|
344
367
|
declare function findInStore<T, K extends Json.Serializable, Key extends K>(token: WritableFamilyToken<T, K>, key: Key, store: Store): WritableToken<T>;
|
|
345
368
|
declare function findInStore<T, K extends Json.Serializable, Key extends K>(token: ReadableFamilyToken<T, K>, key: Key, store: Store): ReadableToken<T>;
|
|
346
369
|
|
|
347
370
|
type EnvironmentData = {
|
|
348
|
-
|
|
371
|
+
window: typeof window | undefined;
|
|
372
|
+
global: typeof global | undefined;
|
|
349
373
|
store: Store;
|
|
350
374
|
};
|
|
351
375
|
declare function getEnvironmentData(store: Store): EnvironmentData;
|
|
@@ -423,11 +447,11 @@ declare const subscribeToRootAtoms: <T>(selector: Selector<T>, store: Store) =>
|
|
|
423
447
|
|
|
424
448
|
declare function subscribeToState<T>(token: ReadableToken<T>, handleUpdate: UpdateHandler<T>, key: string, store: Store): () => void;
|
|
425
449
|
|
|
426
|
-
declare const subscribeToTimeline: <ManagedAtom extends TimelineManageable>(token: TimelineToken<ManagedAtom>, handleUpdate: (update: TimelineUpdate<any> | `redo` | `undo`) => void, key: string, store: Store
|
|
450
|
+
declare const subscribeToTimeline: <ManagedAtom extends TimelineManageable>(token: TimelineToken<ManagedAtom>, handleUpdate: (update: TimelineUpdate<any> | `redo` | `undo`) => void, key: string, store: Store) => (() => void);
|
|
427
451
|
|
|
428
|
-
declare const subscribeToTransaction: <ƒ extends _n>(token: TransactionToken<ƒ>, handleUpdate: TransactionUpdateHandler<ƒ>, key: string, store: Store
|
|
452
|
+
declare const subscribeToTransaction: <ƒ extends _n>(token: TransactionToken<ƒ>, handleUpdate: TransactionUpdateHandler<ƒ>, key: string, store: Store) => (() => void);
|
|
429
453
|
|
|
430
|
-
type
|
|
454
|
+
type AtomIOState = {
|
|
431
455
|
key: string;
|
|
432
456
|
family?: FamilyMetadata;
|
|
433
457
|
install: (store: Store) => void;
|
|
@@ -436,23 +460,23 @@ type BaseStateData = {
|
|
|
436
460
|
oldValue: any;
|
|
437
461
|
}>;
|
|
438
462
|
};
|
|
439
|
-
type RegularAtom<T> =
|
|
463
|
+
type RegularAtom<T> = AtomIOState & {
|
|
440
464
|
type: `atom`;
|
|
441
465
|
default: T | (() => T);
|
|
442
466
|
cleanup?: () => void;
|
|
443
467
|
};
|
|
444
|
-
type MutableAtom<T extends Transceiver<any>, J extends Json.Serializable> =
|
|
468
|
+
type MutableAtom<T extends Transceiver<any>, J extends Json.Serializable> = AtomIOState & JsonInterface<T, J> & {
|
|
445
469
|
type: `mutable_atom`;
|
|
446
470
|
default: T | (() => T);
|
|
447
471
|
cleanup?: () => void;
|
|
448
472
|
};
|
|
449
473
|
type Atom<T> = RegularAtom<T> | (T extends Transceiver<any> ? MutableAtom<T, any> : never);
|
|
450
|
-
type WritableSelector<T> =
|
|
474
|
+
type WritableSelector<T> = AtomIOState & {
|
|
451
475
|
type: `selector`;
|
|
452
476
|
get: () => T;
|
|
453
477
|
set: (newValue: T | ((oldValue: T) => T)) => void;
|
|
454
478
|
};
|
|
455
|
-
type ReadonlySelector<T> =
|
|
479
|
+
type ReadonlySelector<T> = AtomIOState & {
|
|
456
480
|
type: `readonly_selector`;
|
|
457
481
|
get: () => T;
|
|
458
482
|
};
|
|
@@ -460,4 +484,4 @@ type Selector<T> = ReadonlySelector<T> | WritableSelector<T>;
|
|
|
460
484
|
type WritableState<T> = Atom<T> | WritableSelector<T>;
|
|
461
485
|
type ReadableState<T> = Atom<T> | Selector<T>;
|
|
462
486
|
|
|
463
|
-
export { type Atom, type AtomKey, type
|
|
487
|
+
export { type Atom, type AtomIOState, type AtomKey, type ChildStore, type EnvironmentData, FamilyTracker, Future, IMPLICIT, LazyMap, type Lineage, type Modify, type MutableAtom, NotFoundError, type OperationProgress, type ReadableState, type ReadonlySelector, type ReadonlySelectorKey, type RegularAtom, type RootStore, type Selector, type SelectorKey, type Signal, type StateKey, StatefulSubject, Store, Subject, TRANSACTION_PHASES, type Timeline, type TimelineAtomUpdate, type TimelineSelectorUpdate, type TimelineTransactionUpdate, Tracker, type Transaction, type TransactionEpoch, type TransactionPhase, type TransactionProgress, type Transceiver, type TransceiverMode, type Withdrawable, type WritableSelector, type WritableState, abortTransaction, actUponStore, addAtomToTimeline, applyTransaction, arbitrary, assignTransactionToContinuity, become, buildTransaction, cacheValue, clearStore, closeOperation, createAtomFamily, createMutableAtom, createMutableAtomFamily, createReadonlySelector, createReadonlySelectorFamily, createRegularAtom, createRegularAtomFamily, createSelectorFamily, createStandaloneAtom, createStandaloneSelector, createTimeline, createTransaction, createWritableSelector, deleteAtom, deleteSelector, deposit, evictCachedValue, findInStore, getContinuityKey, getEnvironmentData, getEpochNumberOfAction, getEpochNumberOfContinuity, getFromStore, getJsonFamily, getJsonToken, getSelectorDependencyKeys, getUpdateToken, ingestAtomUpdate, ingestSelectorUpdate, ingestTransactionUpdate, isAtomDefault, isAtomKey, isChildStore, isDone, isMutable, isReadonlySelectorKey, isRootStore, isSelectorKey, isStateKey, isTransceiver, markAtomAsDefault, markAtomAsNotDefault, markDone, newest, openOperation, readCachedValue, readOrComputeValue, registerSelector, setAtomOrSelector, setEpochNumberOfAction, setEpochNumberOfContinuity, setIntoStore, subscribeToRootAtoms, subscribeToState, subscribeToTimeline, subscribeToTransaction, timeTravel, traceAllSelectorAtoms, traceSelectorAtoms, updateSelectorAtoms, withdraw, withdrawNewFamilyMember };
|
package/internal/dist/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { Junction } from '../../dist/chunk-NYTGCPHB.js';
|
|
2
|
-
import { isChildStore, isRootStore } from '../../dist/chunk-H4Q5FTPZ.js';
|
|
3
2
|
import { __spreadValues, __spreadProps } from '../../dist/chunk-PZLG2HP3.js';
|
|
4
3
|
import { stringifyJson, selectJson, parseJson, selectJsonFamily } from 'atom.io/json';
|
|
5
|
-
import { AtomIOLogger
|
|
6
|
-
import { withdraw as withdraw$1 } from 'atom.io/internal';
|
|
4
|
+
import { AtomIOLogger } from 'atom.io';
|
|
7
5
|
|
|
8
6
|
// internal/src/lineage.ts
|
|
9
7
|
function newest(scion) {
|
|
@@ -56,6 +54,14 @@ var StatefulSubject = class extends Subject {
|
|
|
56
54
|
}
|
|
57
55
|
};
|
|
58
56
|
|
|
57
|
+
// internal/src/transaction/is-root-store.ts
|
|
58
|
+
function isRootStore(store) {
|
|
59
|
+
return `epoch` in store.transactionMeta;
|
|
60
|
+
}
|
|
61
|
+
function isChildStore(store) {
|
|
62
|
+
return `phase` in store.transactionMeta;
|
|
63
|
+
}
|
|
64
|
+
|
|
59
65
|
// internal/src/store/store.ts
|
|
60
66
|
var Store = class {
|
|
61
67
|
constructor(name, store = null) {
|
|
@@ -99,7 +105,11 @@ var Store = class {
|
|
|
99
105
|
};
|
|
100
106
|
this.operation = { open: false };
|
|
101
107
|
this.transactionMeta = {
|
|
102
|
-
epoch:
|
|
108
|
+
epoch: /* @__PURE__ */ new Map(),
|
|
109
|
+
actionContinuities: new Junction({
|
|
110
|
+
between: [`continuity`, `action`],
|
|
111
|
+
cardinality: `1:n`
|
|
112
|
+
})
|
|
103
113
|
};
|
|
104
114
|
this.config = {
|
|
105
115
|
name: `IMPLICIT_STORE`
|
|
@@ -124,7 +134,14 @@ var Store = class {
|
|
|
124
134
|
if (store !== null) {
|
|
125
135
|
this.valueMap = new Map(store == null ? void 0 : store.valueMap);
|
|
126
136
|
this.operation = __spreadValues({}, store == null ? void 0 : store.operation);
|
|
127
|
-
|
|
137
|
+
if (isRootStore(store)) {
|
|
138
|
+
this.transactionMeta = {
|
|
139
|
+
epoch: new Map(store == null ? void 0 : store.transactionMeta.epoch),
|
|
140
|
+
actionContinuities: new Junction(
|
|
141
|
+
store == null ? void 0 : store.transactionMeta.actionContinuities.toJSON()
|
|
142
|
+
)
|
|
143
|
+
};
|
|
144
|
+
}
|
|
128
145
|
this.config = __spreadProps(__spreadValues({}, store == null ? void 0 : store.config), {
|
|
129
146
|
name
|
|
130
147
|
});
|
|
@@ -191,6 +208,12 @@ function withdraw(token, store) {
|
|
|
191
208
|
case `readonly_selector`:
|
|
192
209
|
withdrawn = target.readonlySelectors.get(token.key);
|
|
193
210
|
break;
|
|
211
|
+
case `atom_family`:
|
|
212
|
+
case `mutable_atom_family`:
|
|
213
|
+
case `selector_family`:
|
|
214
|
+
case `readonly_selector_family`:
|
|
215
|
+
withdrawn = target.families.get(token.key);
|
|
216
|
+
break;
|
|
194
217
|
case `timeline`:
|
|
195
218
|
withdrawn = target.timelines.get(token.key);
|
|
196
219
|
break;
|
|
@@ -250,6 +273,9 @@ function copyMutableIfNeeded(atom, origin, target) {
|
|
|
250
273
|
const originValue = origin.valueMap.get(atom.key);
|
|
251
274
|
const targetValue = target.valueMap.get(atom.key);
|
|
252
275
|
if (originValue === targetValue) {
|
|
276
|
+
if (originValue === void 0) {
|
|
277
|
+
return typeof atom.default === `function` ? atom.default() : atom.default;
|
|
278
|
+
}
|
|
253
279
|
origin.logger.info(`\u{1F4C3}`, `atom`, `${atom.key}`, `copying`);
|
|
254
280
|
const jsonValue = atom.toJson(originValue);
|
|
255
281
|
const copiedValue = atom.fromJson(jsonValue);
|
|
@@ -260,19 +286,6 @@ function copyMutableIfNeeded(atom, origin, target) {
|
|
|
260
286
|
return targetValue;
|
|
261
287
|
}
|
|
262
288
|
|
|
263
|
-
// internal/src/set-state/copy-mutable-in-transaction.ts
|
|
264
|
-
function copyMutableIfWithinTransaction(oldValue, atom, store) {
|
|
265
|
-
const target = newest(store);
|
|
266
|
-
const parent = target.parent;
|
|
267
|
-
if (parent !== null) {
|
|
268
|
-
if (atom.type === `mutable_atom`) {
|
|
269
|
-
const copiedValue = copyMutableIfNeeded(atom, parent, target);
|
|
270
|
-
return copiedValue;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
return oldValue;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
289
|
// internal/src/caching.ts
|
|
277
290
|
function cacheValue(key, value, subject, target) {
|
|
278
291
|
const currentValue = target.valueMap.get(key);
|
|
@@ -300,8 +313,10 @@ function cacheValue(key, value, subject, target) {
|
|
|
300
313
|
}
|
|
301
314
|
var readCachedValue = (token, target) => {
|
|
302
315
|
let value = target.valueMap.get(token.key);
|
|
303
|
-
if (token.type === `
|
|
304
|
-
|
|
316
|
+
if (token.type === `mutable_atom` && isChildStore(target)) {
|
|
317
|
+
const { parent } = target;
|
|
318
|
+
const copiedValue = copyMutableIfNeeded(token, parent, target);
|
|
319
|
+
value = copiedValue;
|
|
305
320
|
}
|
|
306
321
|
return value;
|
|
307
322
|
};
|
|
@@ -551,17 +566,31 @@ var markDone = (key, store) => {
|
|
|
551
566
|
|
|
552
567
|
// internal/src/set-state/emit-update.ts
|
|
553
568
|
var emitUpdate = (state, update, store) => {
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
569
|
+
switch (state.type) {
|
|
570
|
+
case `mutable_atom`:
|
|
571
|
+
store.logger.info(
|
|
572
|
+
`\u{1F4E2}`,
|
|
573
|
+
state.type,
|
|
574
|
+
state.key,
|
|
575
|
+
`is now (`,
|
|
576
|
+
update.newValue,
|
|
577
|
+
`) subscribers:`,
|
|
578
|
+
state.subject.subscribers
|
|
579
|
+
);
|
|
580
|
+
break;
|
|
581
|
+
default:
|
|
582
|
+
store.logger.info(
|
|
583
|
+
`\u{1F4E2}`,
|
|
584
|
+
state.type,
|
|
585
|
+
state.key,
|
|
586
|
+
`went (`,
|
|
587
|
+
update.oldValue,
|
|
588
|
+
`->`,
|
|
589
|
+
update.newValue,
|
|
590
|
+
`) subscribers:`,
|
|
591
|
+
state.subject.subscribers
|
|
592
|
+
);
|
|
593
|
+
}
|
|
565
594
|
state.subject.next(update);
|
|
566
595
|
};
|
|
567
596
|
|
|
@@ -640,7 +669,12 @@ var stowUpdate = (state, update, store) => {
|
|
|
640
669
|
// internal/src/set-state/set-atom.ts
|
|
641
670
|
var setAtom = (atom, next, target) => {
|
|
642
671
|
const oldValue = readOrComputeValue(atom, target);
|
|
643
|
-
let newValue =
|
|
672
|
+
let newValue = oldValue;
|
|
673
|
+
if (atom.type === `mutable_atom` && isChildStore(target)) {
|
|
674
|
+
const { parent } = target;
|
|
675
|
+
const copiedValue = copyMutableIfNeeded(atom, parent, target);
|
|
676
|
+
newValue = copiedValue;
|
|
677
|
+
}
|
|
644
678
|
newValue = become(next)(newValue);
|
|
645
679
|
target.logger.info(`\u{1F4DD}`, `atom`, atom.key, `set to`, newValue);
|
|
646
680
|
newValue = cacheValue(atom.key, newValue, atom.subject, target);
|
|
@@ -658,18 +692,15 @@ var setAtom = (atom, next, target) => {
|
|
|
658
692
|
} else if (atom.key.startsWith(`*`)) {
|
|
659
693
|
const mutableKey = atom.key.slice(1);
|
|
660
694
|
const mutableAtom = target.atoms.get(mutableKey);
|
|
661
|
-
let
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
`\u274C`,
|
|
667
|
-
`mutable_atom`,
|
|
668
|
-
mutableKey,
|
|
669
|
-
`could not be updated.`,
|
|
670
|
-
typeof output === `number` ? `Expected update number ${mutable.cacheUpdateNumber + 1}, but got ${output}` : output
|
|
671
|
-
);
|
|
695
|
+
let transceiver = target.valueMap.get(mutableKey);
|
|
696
|
+
if (mutableAtom.type === `mutable_atom` && isChildStore(target)) {
|
|
697
|
+
const { parent } = target;
|
|
698
|
+
const copiedValue = copyMutableIfNeeded(mutableAtom, parent, target);
|
|
699
|
+
transceiver = copiedValue;
|
|
672
700
|
}
|
|
701
|
+
const accepted = transceiver.do(update.newValue) === null;
|
|
702
|
+
if (accepted)
|
|
703
|
+
evictDownStream(mutableAtom, target);
|
|
673
704
|
}
|
|
674
705
|
}
|
|
675
706
|
};
|
|
@@ -1037,8 +1068,10 @@ function subscribeToState(token, handleUpdate, key, store) {
|
|
|
1037
1068
|
};
|
|
1038
1069
|
return unsubscribe;
|
|
1039
1070
|
}
|
|
1071
|
+
|
|
1072
|
+
// internal/src/subscribe/subscribe-to-timeline.ts
|
|
1040
1073
|
var subscribeToTimeline = (token, handleUpdate, key, store) => {
|
|
1041
|
-
const tl = withdraw
|
|
1074
|
+
const tl = withdraw(token, store);
|
|
1042
1075
|
if (tl === void 0) {
|
|
1043
1076
|
throw new Error(
|
|
1044
1077
|
`Cannot subscribe to timeline "${token.key}": timeline not found in store "${store.config.name}".`
|
|
@@ -1056,8 +1089,10 @@ var subscribeToTimeline = (token, handleUpdate, key, store) => {
|
|
|
1056
1089
|
unsubscribe();
|
|
1057
1090
|
};
|
|
1058
1091
|
};
|
|
1092
|
+
|
|
1093
|
+
// internal/src/subscribe/subscribe-to-transaction.ts
|
|
1059
1094
|
var subscribeToTransaction = (token, handleUpdate, key, store) => {
|
|
1060
|
-
const tx = withdraw
|
|
1095
|
+
const tx = withdraw(token, store);
|
|
1061
1096
|
if (tx === void 0) {
|
|
1062
1097
|
throw new Error(
|
|
1063
1098
|
`Cannot subscribe to transaction "${token.key}": transaction not found in store "${store.config.name}".`
|
|
@@ -1540,13 +1575,23 @@ function deleteAtom(atomToken, store) {
|
|
|
1540
1575
|
target.selectorAtoms.delete(key);
|
|
1541
1576
|
target.atomsThatAreDefault.delete(key);
|
|
1542
1577
|
target.timelineAtoms.delete(key);
|
|
1578
|
+
if (atomToken.type === `mutable_atom`) {
|
|
1579
|
+
const updateToken = getUpdateToken(atomToken);
|
|
1580
|
+
deleteAtom(updateToken, store);
|
|
1581
|
+
}
|
|
1543
1582
|
store.logger.info(`\u{1F525}`, `atom`, `${key}`, `deleted`);
|
|
1544
1583
|
}
|
|
1545
1584
|
|
|
1585
|
+
// internal/src/arbitrary.ts
|
|
1586
|
+
function arbitrary(random = Math.random) {
|
|
1587
|
+
return random().toString(36).slice(2);
|
|
1588
|
+
}
|
|
1589
|
+
|
|
1546
1590
|
// internal/src/get-environment-data.ts
|
|
1547
1591
|
function getEnvironmentData(store) {
|
|
1548
1592
|
return {
|
|
1549
|
-
|
|
1593
|
+
window: typeof window === `undefined` ? void 0 : window,
|
|
1594
|
+
global: typeof global === `undefined` ? void 0 : global,
|
|
1550
1595
|
store
|
|
1551
1596
|
};
|
|
1552
1597
|
}
|
|
@@ -1565,7 +1610,11 @@ function getFromStore(token, store) {
|
|
|
1565
1610
|
function ingestAtomUpdate(applying, atomUpdate, store) {
|
|
1566
1611
|
const { key, newValue, oldValue } = atomUpdate;
|
|
1567
1612
|
const value = applying === `newValue` ? newValue : oldValue;
|
|
1568
|
-
|
|
1613
|
+
const token = { key, type: `atom` };
|
|
1614
|
+
if (atomUpdate.family) {
|
|
1615
|
+
Object.assign(token, { family: atomUpdate.family });
|
|
1616
|
+
}
|
|
1617
|
+
setIntoStore(token, value, store);
|
|
1569
1618
|
}
|
|
1570
1619
|
|
|
1571
1620
|
// internal/src/ingest-updates/ingest-selector-update.ts
|
|
@@ -1844,7 +1893,17 @@ function createTimeline(options, store, data) {
|
|
|
1844
1893
|
for (const tokenOrFamily of options.atoms) {
|
|
1845
1894
|
let atomKey = tokenOrFamily.key;
|
|
1846
1895
|
if (tokenOrFamily.type === `atom_family` || tokenOrFamily.type === `mutable_atom_family`) {
|
|
1847
|
-
const
|
|
1896
|
+
const familyToken = tokenOrFamily;
|
|
1897
|
+
const family = withdraw(familyToken, store);
|
|
1898
|
+
if (family === void 0) {
|
|
1899
|
+
store.logger.error(
|
|
1900
|
+
`\u274C`,
|
|
1901
|
+
`timeline`,
|
|
1902
|
+
options.key,
|
|
1903
|
+
`Failed to add family "${familyToken.key}" because it does not exist in the store`
|
|
1904
|
+
);
|
|
1905
|
+
continue;
|
|
1906
|
+
}
|
|
1848
1907
|
const familyKey = family.key;
|
|
1849
1908
|
target.timelineAtoms.set({ atomKey: familyKey, timelineKey });
|
|
1850
1909
|
family.subject.subscribe(`timeline:${options.key}`, (token2) => {
|
|
@@ -1997,6 +2056,35 @@ var abortTransaction = (store) => {
|
|
|
1997
2056
|
target.parent.child = null;
|
|
1998
2057
|
};
|
|
1999
2058
|
|
|
2059
|
+
// internal/src/transaction/act-upon-store.ts
|
|
2060
|
+
function actUponStore(token, id, store) {
|
|
2061
|
+
return (...parameters) => {
|
|
2062
|
+
const tx = withdraw(token, store);
|
|
2063
|
+
if (tx) {
|
|
2064
|
+
return tx.run(parameters, id);
|
|
2065
|
+
}
|
|
2066
|
+
throw new NotFoundError(token, store);
|
|
2067
|
+
};
|
|
2068
|
+
}
|
|
2069
|
+
|
|
2070
|
+
// internal/src/transaction/set-epoch-number.ts
|
|
2071
|
+
function setEpochNumberOfContinuity(continuityKey, newEpoch, store) {
|
|
2072
|
+
const isRoot = isRootStore(store);
|
|
2073
|
+
if (isRoot && continuityKey) {
|
|
2074
|
+
store.transactionMeta.epoch.set(continuityKey, newEpoch);
|
|
2075
|
+
}
|
|
2076
|
+
}
|
|
2077
|
+
function setEpochNumberOfAction(transactionKey, newEpoch, store) {
|
|
2078
|
+
const isRoot = isRootStore(store);
|
|
2079
|
+
if (!isRoot) {
|
|
2080
|
+
return;
|
|
2081
|
+
}
|
|
2082
|
+
const continuityKey = store.transactionMeta.actionContinuities.getRelatedKey(transactionKey);
|
|
2083
|
+
if (continuityKey !== void 0) {
|
|
2084
|
+
store.transactionMeta.epoch.set(continuityKey, newEpoch);
|
|
2085
|
+
}
|
|
2086
|
+
}
|
|
2087
|
+
|
|
2000
2088
|
// internal/src/transaction/apply-transaction.ts
|
|
2001
2089
|
var applyTransaction = (output, store) => {
|
|
2002
2090
|
var _a;
|
|
@@ -2045,7 +2133,11 @@ var applyTransaction = (output, store) => {
|
|
|
2045
2133
|
}
|
|
2046
2134
|
ingestTransactionUpdate(`newValue`, child.transactionMeta.update, parent);
|
|
2047
2135
|
if (isRootStore(parent)) {
|
|
2048
|
-
|
|
2136
|
+
setEpochNumberOfAction(
|
|
2137
|
+
child.transactionMeta.update.key,
|
|
2138
|
+
child.transactionMeta.update.epoch,
|
|
2139
|
+
parent
|
|
2140
|
+
);
|
|
2049
2141
|
const myTransaction = withdraw(
|
|
2050
2142
|
{ key: child.transactionMeta.update.key, type: `transaction` },
|
|
2051
2143
|
store
|
|
@@ -2062,6 +2154,21 @@ var applyTransaction = (output, store) => {
|
|
|
2062
2154
|
}
|
|
2063
2155
|
parent.on.transactionApplying.next(null);
|
|
2064
2156
|
};
|
|
2157
|
+
|
|
2158
|
+
// internal/src/transaction/assign-transaction-to-continuity.ts
|
|
2159
|
+
function assignTransactionToContinuity(continuityKey, transactionKey, store) {
|
|
2160
|
+
const isRoot = isRootStore(store);
|
|
2161
|
+
if (!isRoot) {
|
|
2162
|
+
return;
|
|
2163
|
+
}
|
|
2164
|
+
const { epoch, actionContinuities } = store.transactionMeta;
|
|
2165
|
+
actionContinuities.set(continuityKey, transactionKey);
|
|
2166
|
+
if (!epoch.has(continuityKey)) {
|
|
2167
|
+
epoch.set(continuityKey, -1);
|
|
2168
|
+
}
|
|
2169
|
+
}
|
|
2170
|
+
|
|
2171
|
+
// internal/src/transaction/build-transaction.ts
|
|
2065
2172
|
var buildTransaction = (key, params, store, id) => {
|
|
2066
2173
|
const parent = newest(store);
|
|
2067
2174
|
const childBase = {
|
|
@@ -2087,12 +2194,13 @@ var buildTransaction = (key, params, store, id) => {
|
|
|
2087
2194
|
selectors: new LazyMap(parent.selectors),
|
|
2088
2195
|
valueMap: new LazyMap(parent.valueMap)
|
|
2089
2196
|
};
|
|
2197
|
+
const epoch = getEpochNumberOfAction(key, store);
|
|
2090
2198
|
const transactionMeta = {
|
|
2091
2199
|
phase: `building`,
|
|
2092
2200
|
update: {
|
|
2093
2201
|
key,
|
|
2094
|
-
id
|
|
2095
|
-
epoch:
|
|
2202
|
+
id,
|
|
2203
|
+
epoch: epoch === void 0 ? NaN : epoch + 1,
|
|
2096
2204
|
updates: [],
|
|
2097
2205
|
params,
|
|
2098
2206
|
output: void 0
|
|
@@ -2100,7 +2208,7 @@ var buildTransaction = (key, params, store, id) => {
|
|
|
2100
2208
|
transactors: {
|
|
2101
2209
|
get: (token) => getFromStore(token, child),
|
|
2102
2210
|
set: (token, value) => setIntoStore(token, value, child),
|
|
2103
|
-
run: (token, id2) =>
|
|
2211
|
+
run: (token, id2 = arbitrary()) => actUponStore(token, id2, child),
|
|
2104
2212
|
find: (token, key2) => findInStore(token, key2, child),
|
|
2105
2213
|
env: () => getEnvironmentData(child)
|
|
2106
2214
|
}
|
|
@@ -2148,9 +2256,27 @@ function createTransaction(options, store) {
|
|
|
2148
2256
|
return token;
|
|
2149
2257
|
}
|
|
2150
2258
|
|
|
2259
|
+
// internal/src/transaction/get-epoch-number.ts
|
|
2260
|
+
function getContinuityKey(transactionKey, store) {
|
|
2261
|
+
const isRoot = isRootStore(store);
|
|
2262
|
+
const continuity = isRoot ? store.transactionMeta.actionContinuities.getRelatedKey(transactionKey) : void 0;
|
|
2263
|
+
return continuity;
|
|
2264
|
+
}
|
|
2265
|
+
function getEpochNumberOfContinuity(continuityKey, store) {
|
|
2266
|
+
const isRoot = isRootStore(store);
|
|
2267
|
+
const epoch = isRoot && continuityKey ? store.transactionMeta.epoch.get(continuityKey) : void 0;
|
|
2268
|
+
return epoch;
|
|
2269
|
+
}
|
|
2270
|
+
function getEpochNumberOfAction(transactionKey, store) {
|
|
2271
|
+
const isRoot = isRootStore(store);
|
|
2272
|
+
const continuity = isRoot ? store.transactionMeta.actionContinuities.getRelatedKey(transactionKey) : void 0;
|
|
2273
|
+
const epoch = isRoot && continuity !== void 0 ? store.transactionMeta.epoch.get(continuity) : void 0;
|
|
2274
|
+
return epoch;
|
|
2275
|
+
}
|
|
2276
|
+
|
|
2151
2277
|
// internal/src/transaction/index.ts
|
|
2152
2278
|
var TRANSACTION_PHASES = [`idle`, `building`, `applying`];
|
|
2153
2279
|
|
|
2154
|
-
export { FamilyTracker, Future, IMPLICIT, LazyMap, NotFoundError, StatefulSubject, Store, Subject, TRANSACTION_PHASES, Tracker, abortTransaction, addAtomToTimeline, applyTransaction, become, buildTransaction, cacheValue, clearStore, closeOperation, createAtomFamily, createMutableAtom, createMutableAtomFamily, createReadonlySelector, createReadonlySelectorFamily, createRegularAtom, createRegularAtomFamily, createSelectorFamily, createStandaloneAtom, createStandaloneSelector, createTimeline, createTransaction, createWritableSelector, deleteAtom, deleteSelector, deposit, evictCachedValue, findInStore, getEnvironmentData, getFromStore, getJsonFamily, getJsonToken, getSelectorDependencyKeys, getUpdateToken, ingestAtomUpdate, ingestSelectorUpdate, ingestTransactionUpdate, isAtomDefault, isAtomKey, isDone, isMutable, isReadonlySelectorKey, isSelectorKey, isStateKey, isTransceiver, markAtomAsDefault, markAtomAsNotDefault, markDone, newest, openOperation, readCachedValue, readOrComputeValue, registerSelector, setAtomOrSelector, setIntoStore, subscribeToRootAtoms, subscribeToState, subscribeToTimeline, subscribeToTransaction, timeTravel, traceAllSelectorAtoms, traceSelectorAtoms, updateSelectorAtoms, withdraw, withdrawNewFamilyMember };
|
|
2280
|
+
export { FamilyTracker, Future, IMPLICIT, LazyMap, NotFoundError, StatefulSubject, Store, Subject, TRANSACTION_PHASES, Tracker, abortTransaction, actUponStore, addAtomToTimeline, applyTransaction, arbitrary, assignTransactionToContinuity, become, buildTransaction, cacheValue, clearStore, closeOperation, createAtomFamily, createMutableAtom, createMutableAtomFamily, createReadonlySelector, createReadonlySelectorFamily, createRegularAtom, createRegularAtomFamily, createSelectorFamily, createStandaloneAtom, createStandaloneSelector, createTimeline, createTransaction, createWritableSelector, deleteAtom, deleteSelector, deposit, evictCachedValue, findInStore, getContinuityKey, getEnvironmentData, getEpochNumberOfAction, getEpochNumberOfContinuity, getFromStore, getJsonFamily, getJsonToken, getSelectorDependencyKeys, getUpdateToken, ingestAtomUpdate, ingestSelectorUpdate, ingestTransactionUpdate, isAtomDefault, isAtomKey, isChildStore, isDone, isMutable, isReadonlySelectorKey, isRootStore, isSelectorKey, isStateKey, isTransceiver, markAtomAsDefault, markAtomAsNotDefault, markDone, newest, openOperation, readCachedValue, readOrComputeValue, registerSelector, setAtomOrSelector, setEpochNumberOfAction, setEpochNumberOfContinuity, setIntoStore, subscribeToRootAtoms, subscribeToState, subscribeToTimeline, subscribeToTransaction, timeTravel, traceAllSelectorAtoms, traceSelectorAtoms, updateSelectorAtoms, withdraw, withdrawNewFamilyMember };
|
|
2155
2281
|
//# sourceMappingURL=out.js.map
|
|
2156
2282
|
//# sourceMappingURL=index.js.map
|