atom.io 0.17.0 → 0.18.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.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-OEVFAUPE.js +289 -0
- package/dist/chunk-OEVFAUPE.js.map +1 -0
- package/dist/index.cjs +4 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +62 -51
- package/dist/index.js +5 -11
- package/dist/index.js.map +1 -1
- package/internal/dist/index.cjs +163 -64
- package/internal/dist/index.cjs.map +1 -1
- package/internal/dist/index.d.ts +94 -70
- package/internal/dist/index.js +155 -59
- package/internal/dist/index.js.map +1 -1
- package/internal/src/arbitrary.ts +3 -0
- package/internal/src/caching.ts +8 -6
- 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-transaction-update.ts +0 -1
- package/internal/src/selector/create-standalone-selector.ts +0 -2
- package/internal/src/set-state/set-atom.ts +14 -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 +7 -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 +31 -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 +6 -2
- package/package.json +24 -13
- 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 +103 -106
- package/react-devtools/dist/index.js.map +1 -1
- package/react-devtools/src/StateEditor.tsx +6 -6
- package/react-devtools/src/StateIndex.tsx +2 -5
- package/react-devtools/src/TimelineIndex.tsx +3 -3
- package/react-devtools/src/TransactionIndex.tsx +9 -8
- package/react-devtools/src/Updates.tsx +1 -1
- package/react-devtools/src/index.ts +4 -4
- package/realtime/dist/index.cjs +72 -0
- package/realtime/dist/index.cjs.map +1 -0
- package/realtime/dist/index.d.ts +39 -0
- package/realtime/dist/index.js +68 -0
- package/realtime/dist/index.js.map +1 -0
- package/realtime/package.json +16 -0
- package/realtime/src/index.ts +1 -0
- package/realtime/src/realtime-continuity.ts +152 -0
- package/realtime-client/dist/index.cjs +389 -48
- package/realtime-client/dist/index.cjs.map +1 -1
- package/realtime-client/dist/index.d.ts +16 -9
- package/realtime-client/dist/index.js +100 -37
- package/realtime-client/dist/index.js.map +1 -1
- package/realtime-client/src/index.ts +8 -5
- 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} +1 -1
- 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 +2 -2
- package/realtime-client/src/realtime-client-stores/client-sync-store.ts +7 -7
- package/realtime-client/src/sync-continuity.ts +321 -0
- package/realtime-client/src/sync-server-action.ts +18 -20
- package/realtime-react/dist/index.cjs +330 -15
- package/realtime-react/dist/index.cjs.map +1 -1
- package/realtime-react/dist/index.d.ts +26 -6
- package/realtime-react/dist/index.js +43 -12
- package/realtime-react/dist/index.js.map +1 -1
- package/realtime-react/src/index.ts +6 -3
- package/realtime-react/src/use-pull-atom-family-member.ts +21 -0
- package/realtime-react/src/{use-pull-family-member.ts → use-pull-atom.ts} +6 -5
- 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-react/src/use-sync-server-action.ts +3 -2
- package/realtime-server/dist/index.cjs +568 -242
- package/realtime-server/dist/index.cjs.map +1 -1
- package/realtime-server/dist/index.d.ts +124 -49
- package/realtime-server/dist/index.js +555 -238
- package/realtime-server/dist/index.js.map +1 -1
- package/realtime-server/src/index.ts +18 -2
- package/realtime-server/src/ipc-socket.ts +230 -0
- package/realtime-server/src/realtime-action-receiver.ts +8 -5
- package/realtime-server/src/realtime-action-synchronizer.ts +40 -28
- package/realtime-server/src/realtime-continuity-synchronizer.ts +247 -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 +3 -1
- package/realtime-server/src/realtime-server-stores/realtime-continuity-store.ts +90 -0
- package/realtime-server/src/realtime-server-stores/server-room-store.ts +97 -0
- package/realtime-server/src/realtime-server-stores/server-sync-store.ts +2 -72
- 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 +28 -28
- package/realtime-testing/dist/index.cjs.map +1 -1
- package/realtime-testing/dist/index.js +28 -27
- package/realtime-testing/dist/index.js.map +1 -1
- package/realtime-testing/src/setup-realtime-test.tsx +38 -28
- package/src/atom.ts +49 -31
- package/src/logger.ts +10 -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/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
|
|
|
@@ -307,6 +326,8 @@ 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;
|
|
@@ -245,34 +268,6 @@ var Future = class extends Promise {
|
|
|
245
268
|
}
|
|
246
269
|
};
|
|
247
270
|
|
|
248
|
-
// internal/src/set-state/copy-mutable-if-needed.ts
|
|
249
|
-
function copyMutableIfNeeded(atom, origin, target) {
|
|
250
|
-
const originValue = origin.valueMap.get(atom.key);
|
|
251
|
-
const targetValue = target.valueMap.get(atom.key);
|
|
252
|
-
if (originValue === targetValue) {
|
|
253
|
-
origin.logger.info(`\u{1F4C3}`, `atom`, `${atom.key}`, `copying`);
|
|
254
|
-
const jsonValue = atom.toJson(originValue);
|
|
255
|
-
const copiedValue = atom.fromJson(jsonValue);
|
|
256
|
-
target.valueMap.set(atom.key, copiedValue);
|
|
257
|
-
new Tracker(atom, origin);
|
|
258
|
-
return copiedValue;
|
|
259
|
-
}
|
|
260
|
-
return targetValue;
|
|
261
|
-
}
|
|
262
|
-
|
|
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
271
|
// internal/src/caching.ts
|
|
277
272
|
function cacheValue(key, value, subject, target) {
|
|
278
273
|
const currentValue = target.valueMap.get(key);
|
|
@@ -299,10 +294,7 @@ function cacheValue(key, value, subject, target) {
|
|
|
299
294
|
return value;
|
|
300
295
|
}
|
|
301
296
|
var readCachedValue = (token, target) => {
|
|
302
|
-
|
|
303
|
-
if (token.type === `atom`) {
|
|
304
|
-
value = copyMutableIfWithinTransaction(value, token, target);
|
|
305
|
-
}
|
|
297
|
+
const value = target.valueMap.get(token.key);
|
|
306
298
|
return value;
|
|
307
299
|
};
|
|
308
300
|
var evictCachedValue = (key, target) => {
|
|
@@ -549,6 +541,21 @@ var markDone = (key, store) => {
|
|
|
549
541
|
store.operation.done.add(key);
|
|
550
542
|
};
|
|
551
543
|
|
|
544
|
+
// internal/src/set-state/copy-mutable-if-needed.ts
|
|
545
|
+
function copyMutableIfNeeded(atom, origin, target) {
|
|
546
|
+
const originValue = origin.valueMap.get(atom.key);
|
|
547
|
+
const targetValue = target.valueMap.get(atom.key);
|
|
548
|
+
if (originValue === targetValue) {
|
|
549
|
+
origin.logger.info(`\u{1F4C3}`, `atom`, `${atom.key}`, `copying`);
|
|
550
|
+
const jsonValue = atom.toJson(originValue);
|
|
551
|
+
const copiedValue = atom.fromJson(jsonValue);
|
|
552
|
+
target.valueMap.set(atom.key, copiedValue);
|
|
553
|
+
new Tracker(atom, origin);
|
|
554
|
+
return copiedValue;
|
|
555
|
+
}
|
|
556
|
+
return targetValue;
|
|
557
|
+
}
|
|
558
|
+
|
|
552
559
|
// internal/src/set-state/emit-update.ts
|
|
553
560
|
var emitUpdate = (state, update, store) => {
|
|
554
561
|
store.logger.info(
|
|
@@ -640,7 +647,12 @@ var stowUpdate = (state, update, store) => {
|
|
|
640
647
|
// internal/src/set-state/set-atom.ts
|
|
641
648
|
var setAtom = (atom, next, target) => {
|
|
642
649
|
const oldValue = readOrComputeValue(atom, target);
|
|
643
|
-
let newValue =
|
|
650
|
+
let newValue = oldValue;
|
|
651
|
+
if (atom.type === `mutable_atom` && isChildStore(target)) {
|
|
652
|
+
const { parent } = target;
|
|
653
|
+
const copiedValue = copyMutableIfNeeded(atom, parent, target);
|
|
654
|
+
newValue = copiedValue;
|
|
655
|
+
}
|
|
644
656
|
newValue = become(next)(newValue);
|
|
645
657
|
target.logger.info(`\u{1F4DD}`, `atom`, atom.key, `set to`, newValue);
|
|
646
658
|
newValue = cacheValue(atom.key, newValue, atom.subject, target);
|
|
@@ -657,19 +669,14 @@ var setAtom = (atom, next, target) => {
|
|
|
657
669
|
stowUpdate(atom, update, target);
|
|
658
670
|
} else if (atom.key.startsWith(`*`)) {
|
|
659
671
|
const mutableKey = atom.key.slice(1);
|
|
660
|
-
|
|
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
|
-
);
|
|
672
|
+
target.atoms.get(mutableKey);
|
|
673
|
+
let transceiver = target.valueMap.get(mutableKey);
|
|
674
|
+
if (atom.type === `mutable_atom` && isChildStore(target)) {
|
|
675
|
+
const { parent } = target;
|
|
676
|
+
const copiedValue = copyMutableIfNeeded(atom, parent, target);
|
|
677
|
+
transceiver = copiedValue;
|
|
672
678
|
}
|
|
679
|
+
transceiver.do(update.newValue);
|
|
673
680
|
}
|
|
674
681
|
}
|
|
675
682
|
};
|
|
@@ -1037,8 +1044,10 @@ function subscribeToState(token, handleUpdate, key, store) {
|
|
|
1037
1044
|
};
|
|
1038
1045
|
return unsubscribe;
|
|
1039
1046
|
}
|
|
1047
|
+
|
|
1048
|
+
// internal/src/subscribe/subscribe-to-timeline.ts
|
|
1040
1049
|
var subscribeToTimeline = (token, handleUpdate, key, store) => {
|
|
1041
|
-
const tl = withdraw
|
|
1050
|
+
const tl = withdraw(token, store);
|
|
1042
1051
|
if (tl === void 0) {
|
|
1043
1052
|
throw new Error(
|
|
1044
1053
|
`Cannot subscribe to timeline "${token.key}": timeline not found in store "${store.config.name}".`
|
|
@@ -1056,8 +1065,10 @@ var subscribeToTimeline = (token, handleUpdate, key, store) => {
|
|
|
1056
1065
|
unsubscribe();
|
|
1057
1066
|
};
|
|
1058
1067
|
};
|
|
1068
|
+
|
|
1069
|
+
// internal/src/subscribe/subscribe-to-transaction.ts
|
|
1059
1070
|
var subscribeToTransaction = (token, handleUpdate, key, store) => {
|
|
1060
|
-
const tx = withdraw
|
|
1071
|
+
const tx = withdraw(token, store);
|
|
1061
1072
|
if (tx === void 0) {
|
|
1062
1073
|
throw new Error(
|
|
1063
1074
|
`Cannot subscribe to transaction "${token.key}": transaction not found in store "${store.config.name}".`
|
|
@@ -1543,10 +1554,16 @@ function deleteAtom(atomToken, store) {
|
|
|
1543
1554
|
store.logger.info(`\u{1F525}`, `atom`, `${key}`, `deleted`);
|
|
1544
1555
|
}
|
|
1545
1556
|
|
|
1557
|
+
// internal/src/arbitrary.ts
|
|
1558
|
+
function arbitrary(random = Math.random) {
|
|
1559
|
+
return random().toString(36).slice(2);
|
|
1560
|
+
}
|
|
1561
|
+
|
|
1546
1562
|
// internal/src/get-environment-data.ts
|
|
1547
1563
|
function getEnvironmentData(store) {
|
|
1548
1564
|
return {
|
|
1549
|
-
|
|
1565
|
+
window: typeof window === `undefined` ? void 0 : window,
|
|
1566
|
+
global: typeof global === `undefined` ? void 0 : global,
|
|
1550
1567
|
store
|
|
1551
1568
|
};
|
|
1552
1569
|
}
|
|
@@ -1844,7 +1861,17 @@ function createTimeline(options, store, data) {
|
|
|
1844
1861
|
for (const tokenOrFamily of options.atoms) {
|
|
1845
1862
|
let atomKey = tokenOrFamily.key;
|
|
1846
1863
|
if (tokenOrFamily.type === `atom_family` || tokenOrFamily.type === `mutable_atom_family`) {
|
|
1847
|
-
const
|
|
1864
|
+
const familyToken = tokenOrFamily;
|
|
1865
|
+
const family = withdraw(familyToken, store);
|
|
1866
|
+
if (family === void 0) {
|
|
1867
|
+
store.logger.error(
|
|
1868
|
+
`\u274C`,
|
|
1869
|
+
`timeline`,
|
|
1870
|
+
options.key,
|
|
1871
|
+
`Failed to add family "${familyToken.key}" because it does not exist in the store`
|
|
1872
|
+
);
|
|
1873
|
+
continue;
|
|
1874
|
+
}
|
|
1848
1875
|
const familyKey = family.key;
|
|
1849
1876
|
target.timelineAtoms.set({ atomKey: familyKey, timelineKey });
|
|
1850
1877
|
family.subject.subscribe(`timeline:${options.key}`, (token2) => {
|
|
@@ -1997,6 +2024,36 @@ var abortTransaction = (store) => {
|
|
|
1997
2024
|
target.parent.child = null;
|
|
1998
2025
|
};
|
|
1999
2026
|
|
|
2027
|
+
// internal/src/transaction/act-upon-store.ts
|
|
2028
|
+
function actUponStore(token, id, store) {
|
|
2029
|
+
return (...parameters) => {
|
|
2030
|
+
const tx = withdraw(token, store);
|
|
2031
|
+
if (tx) {
|
|
2032
|
+
return tx.run(parameters, id);
|
|
2033
|
+
}
|
|
2034
|
+
throw new NotFoundError(token, store);
|
|
2035
|
+
};
|
|
2036
|
+
}
|
|
2037
|
+
|
|
2038
|
+
// internal/src/transaction/set-epoch-number.ts
|
|
2039
|
+
function setEpochNumberOfContinuity(continuityKey, newEpoch, store) {
|
|
2040
|
+
const isRoot = isRootStore(store);
|
|
2041
|
+
if (isRoot && continuityKey) {
|
|
2042
|
+
store.transactionMeta.epoch.set(continuityKey, newEpoch);
|
|
2043
|
+
}
|
|
2044
|
+
}
|
|
2045
|
+
function setEpochNumberOfAction(transactionKey, newEpoch, store) {
|
|
2046
|
+
const isRoot = isRootStore(store);
|
|
2047
|
+
if (!isRoot) {
|
|
2048
|
+
return;
|
|
2049
|
+
}
|
|
2050
|
+
const continuityKey = store.transactionMeta.actionContinuities.getRelatedKey(transactionKey);
|
|
2051
|
+
if (continuityKey !== void 0) {
|
|
2052
|
+
store.transactionMeta.epoch.set(continuityKey, newEpoch);
|
|
2053
|
+
console.log(`epoch is now`, newEpoch);
|
|
2054
|
+
}
|
|
2055
|
+
}
|
|
2056
|
+
|
|
2000
2057
|
// internal/src/transaction/apply-transaction.ts
|
|
2001
2058
|
var applyTransaction = (output, store) => {
|
|
2002
2059
|
var _a;
|
|
@@ -2045,7 +2102,12 @@ var applyTransaction = (output, store) => {
|
|
|
2045
2102
|
}
|
|
2046
2103
|
ingestTransactionUpdate(`newValue`, child.transactionMeta.update, parent);
|
|
2047
2104
|
if (isRootStore(parent)) {
|
|
2048
|
-
|
|
2105
|
+
console.log(child.transactionMeta.update);
|
|
2106
|
+
setEpochNumberOfAction(
|
|
2107
|
+
child.transactionMeta.update.key,
|
|
2108
|
+
child.transactionMeta.update.epoch,
|
|
2109
|
+
parent
|
|
2110
|
+
);
|
|
2049
2111
|
const myTransaction = withdraw(
|
|
2050
2112
|
{ key: child.transactionMeta.update.key, type: `transaction` },
|
|
2051
2113
|
store
|
|
@@ -2062,6 +2124,21 @@ var applyTransaction = (output, store) => {
|
|
|
2062
2124
|
}
|
|
2063
2125
|
parent.on.transactionApplying.next(null);
|
|
2064
2126
|
};
|
|
2127
|
+
|
|
2128
|
+
// internal/src/transaction/assign-transaction-to-continuity.ts
|
|
2129
|
+
function assignTransactionToContinuity(continuityKey, transactionKey, store) {
|
|
2130
|
+
const isRoot = isRootStore(store);
|
|
2131
|
+
if (!isRoot) {
|
|
2132
|
+
return;
|
|
2133
|
+
}
|
|
2134
|
+
const { epoch, actionContinuities } = store.transactionMeta;
|
|
2135
|
+
actionContinuities.set(continuityKey, transactionKey);
|
|
2136
|
+
if (!epoch.has(continuityKey)) {
|
|
2137
|
+
epoch.set(continuityKey, -1);
|
|
2138
|
+
}
|
|
2139
|
+
}
|
|
2140
|
+
|
|
2141
|
+
// internal/src/transaction/build-transaction.ts
|
|
2065
2142
|
var buildTransaction = (key, params, store, id) => {
|
|
2066
2143
|
const parent = newest(store);
|
|
2067
2144
|
const childBase = {
|
|
@@ -2087,12 +2164,13 @@ var buildTransaction = (key, params, store, id) => {
|
|
|
2087
2164
|
selectors: new LazyMap(parent.selectors),
|
|
2088
2165
|
valueMap: new LazyMap(parent.valueMap)
|
|
2089
2166
|
};
|
|
2167
|
+
const epoch = getEpochNumberOfAction(key, store);
|
|
2090
2168
|
const transactionMeta = {
|
|
2091
2169
|
phase: `building`,
|
|
2092
2170
|
update: {
|
|
2093
2171
|
key,
|
|
2094
|
-
id
|
|
2095
|
-
epoch:
|
|
2172
|
+
id,
|
|
2173
|
+
epoch: epoch === void 0 ? NaN : epoch + 1,
|
|
2096
2174
|
updates: [],
|
|
2097
2175
|
params,
|
|
2098
2176
|
output: void 0
|
|
@@ -2100,7 +2178,7 @@ var buildTransaction = (key, params, store, id) => {
|
|
|
2100
2178
|
transactors: {
|
|
2101
2179
|
get: (token) => getFromStore(token, child),
|
|
2102
2180
|
set: (token, value) => setIntoStore(token, value, child),
|
|
2103
|
-
run: (token, id2) =>
|
|
2181
|
+
run: (token, id2 = arbitrary()) => actUponStore(token, id2, child),
|
|
2104
2182
|
find: (token, key2) => findInStore(token, key2, child),
|
|
2105
2183
|
env: () => getEnvironmentData(child)
|
|
2106
2184
|
}
|
|
@@ -2148,9 +2226,27 @@ function createTransaction(options, store) {
|
|
|
2148
2226
|
return token;
|
|
2149
2227
|
}
|
|
2150
2228
|
|
|
2229
|
+
// internal/src/transaction/get-epoch-number.ts
|
|
2230
|
+
function getContinuityKey(transactionKey, store) {
|
|
2231
|
+
const isRoot = isRootStore(store);
|
|
2232
|
+
const continuity = isRoot ? store.transactionMeta.actionContinuities.getRelatedKey(transactionKey) : void 0;
|
|
2233
|
+
return continuity;
|
|
2234
|
+
}
|
|
2235
|
+
function getEpochNumberOfContinuity(continuityKey, store) {
|
|
2236
|
+
const isRoot = isRootStore(store);
|
|
2237
|
+
const epoch = isRoot && continuityKey ? store.transactionMeta.epoch.get(continuityKey) : void 0;
|
|
2238
|
+
return epoch;
|
|
2239
|
+
}
|
|
2240
|
+
function getEpochNumberOfAction(transactionKey, store) {
|
|
2241
|
+
const isRoot = isRootStore(store);
|
|
2242
|
+
const continuity = isRoot ? store.transactionMeta.actionContinuities.getRelatedKey(transactionKey) : void 0;
|
|
2243
|
+
const epoch = isRoot && continuity !== void 0 ? store.transactionMeta.epoch.get(continuity) : void 0;
|
|
2244
|
+
return epoch;
|
|
2245
|
+
}
|
|
2246
|
+
|
|
2151
2247
|
// internal/src/transaction/index.ts
|
|
2152
2248
|
var TRANSACTION_PHASES = [`idle`, `building`, `applying`];
|
|
2153
2249
|
|
|
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 };
|
|
2250
|
+
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
2251
|
//# sourceMappingURL=out.js.map
|
|
2156
2252
|
//# sourceMappingURL=index.js.map
|