atom.io 0.6.8 → 0.7.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/README.md +21 -2
- package/dist/index.d.mts +42 -461
- package/dist/index.d.ts +42 -461
- package/dist/index.js +128 -1792
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +75 -1742
- package/dist/index.mjs.map +1 -1
- package/internal/dist/index.d.mts +342 -0
- package/internal/dist/index.d.ts +342 -0
- package/internal/dist/index.js +1873 -0
- package/internal/dist/index.js.map +1 -0
- package/internal/dist/index.mjs +1798 -0
- package/internal/dist/index.mjs.map +1 -0
- package/internal/package.json +15 -0
- package/internal/src/atom/create-atom.ts +75 -0
- package/internal/src/atom/delete-atom.ts +10 -0
- package/internal/src/atom/index.ts +3 -0
- package/{src/internal → internal/src/atom}/is-default.ts +4 -2
- package/internal/src/caching.ts +21 -0
- package/internal/src/families/create-atom-family.ts +59 -0
- package/internal/src/families/create-readonly-selector-family.ts +45 -0
- package/internal/src/families/create-selector-family.ts +67 -0
- package/internal/src/families/index.ts +3 -0
- package/internal/src/get-state-internal.ts +23 -0
- package/internal/src/index.ts +13 -0
- package/internal/src/mutable/create-mutable-atom-family.ts +25 -0
- package/internal/src/mutable/create-mutable-atom.ts +49 -0
- package/internal/src/mutable/get-json-token.ts +22 -0
- package/internal/src/mutable/get-update-token.ts +20 -0
- package/internal/src/mutable/index.ts +17 -0
- package/internal/src/mutable/is-atom-token-mutable.ts +7 -0
- package/internal/src/mutable/tracker-family.ts +61 -0
- package/internal/src/mutable/tracker.ts +164 -0
- package/internal/src/mutable/transceiver.ts +110 -0
- package/internal/src/operation.ts +68 -0
- package/{src/internal → internal/src}/selector/create-read-write-selector.ts +10 -13
- package/{src/internal → internal/src}/selector/create-readonly-selector.ts +9 -8
- package/internal/src/selector/create-selector.ts +65 -0
- package/{src/internal → internal/src}/selector/index.ts +1 -0
- package/internal/src/selector/lookup-selector-sources.ts +20 -0
- package/{src/internal → internal/src}/selector/register-selector.ts +13 -9
- package/{src/internal → internal/src}/selector/trace-selector-atoms.ts +4 -2
- package/{src/internal → internal/src}/selector/update-selector-atoms.ts +4 -3
- package/internal/src/set-state/become.ts +10 -0
- package/internal/src/set-state/copy-mutable-if-needed.ts +23 -0
- package/internal/src/set-state/copy-mutable-in-transaction.ts +59 -0
- package/internal/src/set-state/copy-mutable-into-new-store.ts +34 -0
- package/internal/src/set-state/emit-update.ts +23 -0
- package/internal/src/set-state/evict-downstream.ts +39 -0
- package/internal/src/set-state/index.ts +2 -0
- package/internal/src/set-state/set-atom-state.ts +38 -0
- package/internal/src/set-state/set-selector-state.ts +19 -0
- package/internal/src/set-state/set-state-internal.ts +18 -0
- package/internal/src/set-state/stow-update.ts +42 -0
- package/internal/src/store/deposit.ts +43 -0
- package/internal/src/store/index.ts +5 -0
- package/internal/src/store/lookup.ts +26 -0
- package/internal/src/store/store.ts +154 -0
- package/internal/src/store/withdraw-new-family-member.ts +53 -0
- package/internal/src/store/withdraw.ts +113 -0
- package/internal/src/subject.ts +21 -0
- package/internal/src/subscribe/index.ts +1 -0
- package/internal/src/subscribe/recall-state.ts +19 -0
- package/internal/src/subscribe/subscribe-to-root-atoms.ts +47 -0
- package/{src/internal → internal/src}/timeline/add-atom-to-timeline.ts +50 -29
- package/internal/src/timeline/index.ts +3 -0
- package/{src/internal → internal/src/timeline}/time-travel-internal.ts +6 -6
- package/{src/internal → internal/src/timeline}/timeline-internal.ts +20 -12
- package/{src/internal → internal/src}/transaction/abort-transaction.ts +1 -1
- package/{src/internal → internal/src}/transaction/apply-transaction.ts +25 -18
- package/{src/internal → internal/src}/transaction/build-transaction.ts +12 -6
- package/{src/internal → internal/src}/transaction/index.ts +3 -2
- package/{src/internal → internal/src}/transaction/redo-transaction.ts +4 -5
- package/{src/internal → internal/src/transaction}/transaction-internal.ts +16 -13
- package/{src/internal → internal/src}/transaction/undo-transaction.ts +4 -5
- package/introspection/dist/index.d.mts +12 -260
- package/introspection/dist/index.d.ts +12 -260
- package/introspection/dist/index.js +125 -140
- package/introspection/dist/index.js.map +1 -1
- package/introspection/dist/index.mjs +103 -116
- package/introspection/dist/index.mjs.map +1 -1
- package/{src/introspection → introspection/src}/attach-atom-index.ts +41 -30
- package/{src/introspection → introspection/src}/attach-introspection-states.ts +6 -10
- package/introspection/src/attach-selector-index.ts +90 -0
- package/{src/introspection → introspection/src}/attach-timeline-family.ts +16 -16
- package/introspection/src/attach-timeline-index.ts +38 -0
- package/introspection/src/attach-transaction-index.ts +40 -0
- package/{src/introspection → introspection/src}/attach-transaction-logs.ts +11 -8
- package/json/dist/index.d.mts +41 -2
- package/json/dist/index.d.ts +41 -2
- package/json/dist/index.js +88 -48
- package/json/dist/index.js.map +1 -1
- package/json/dist/index.mjs +76 -13
- package/json/dist/index.mjs.map +1 -1
- package/json/src/index.ts +5 -0
- package/json/src/select-json-family.ts +35 -0
- package/json/src/select-json.ts +22 -0
- package/package.json +105 -57
- package/react/dist/index.d.mts +9 -17
- package/react/dist/index.d.ts +9 -17
- package/react/dist/index.js +45 -77
- package/react/dist/index.js.map +1 -1
- package/react/dist/index.mjs +18 -34
- package/react/dist/index.mjs.map +1 -1
- package/react/src/store-context.tsx +12 -0
- package/react/src/store-hooks.ts +36 -0
- package/react-devtools/dist/index.css +1 -1
- package/react-devtools/dist/index.css.map +1 -1
- package/react-devtools/dist/index.d.mts +199 -230
- package/react-devtools/dist/index.d.ts +199 -230
- package/react-devtools/dist/index.js +610 -2466
- package/react-devtools/dist/index.js.map +1 -1
- package/react-devtools/dist/index.mjs +543 -2401
- package/react-devtools/dist/index.mjs.map +1 -1
- package/{src/react-devtools → react-devtools/src}/AtomIODevtools.tsx +5 -3
- package/{src/react-devtools → react-devtools/src}/Button.tsx +2 -3
- package/{src/react-devtools → react-devtools/src}/StateEditor.tsx +3 -2
- package/{src/react-devtools → react-devtools/src}/StateIndex.tsx +7 -4
- package/{src/react-devtools → react-devtools/src}/TimelineIndex.tsx +7 -11
- package/{src/react-devtools → react-devtools/src}/TransactionIndex.tsx +4 -4
- package/{src/react-devtools → react-devtools/src}/Updates.tsx +9 -4
- package/{src/react-devtools → react-devtools/src}/index.ts +5 -5
- package/realtime-react/dist/index.d.mts +9 -25
- package/realtime-react/dist/index.d.ts +9 -25
- package/realtime-react/dist/index.js +75 -193
- package/realtime-react/dist/index.js.map +1 -1
- package/realtime-react/dist/index.mjs +44 -148
- package/realtime-react/dist/index.mjs.map +1 -1
- package/realtime-react/src/index.ts +7 -0
- package/{src/realtime-react → realtime-react/src}/realtime-context.tsx +3 -4
- package/realtime-react/src/use-pull-family-member.ts +15 -0
- package/realtime-react/src/use-pull-mutable-family-member.ts +20 -0
- package/realtime-react/src/use-pull-mutable.ts +17 -0
- package/realtime-react/src/use-pull.ts +15 -0
- package/realtime-react/src/use-push.ts +19 -0
- package/realtime-react/src/use-server-action.ts +18 -0
- package/realtime-testing/dist/index.d.mts +49 -0
- package/realtime-testing/dist/index.d.ts +49 -0
- package/realtime-testing/dist/index.js +147 -0
- package/realtime-testing/dist/index.js.map +1 -0
- package/realtime-testing/dist/index.mjs +116 -0
- package/realtime-testing/dist/index.mjs.map +1 -0
- package/{src/realtime-testing → realtime-testing/src}/setup-realtime-test.tsx +10 -8
- package/src/atom.ts +64 -8
- package/src/index.ts +36 -29
- package/src/logger.ts +7 -7
- package/src/selector.ts +5 -5
- package/src/silo.ts +49 -43
- package/src/subscribe.ts +27 -22
- package/src/timeline.ts +9 -4
- package/src/transaction.ts +3 -4
- package/transceivers/set-rtx/dist/index.d.mts +39 -0
- package/transceivers/set-rtx/dist/index.d.ts +39 -0
- package/transceivers/set-rtx/dist/index.js +213 -0
- package/transceivers/set-rtx/dist/index.js.map +1 -0
- package/transceivers/set-rtx/dist/index.mjs +211 -0
- package/transceivers/set-rtx/dist/index.mjs.map +1 -0
- package/{realtime → transceivers/set-rtx}/package.json +1 -1
- package/transceivers/set-rtx/src/index.ts +1 -0
- package/transceivers/set-rtx/src/set-rtx.ts +242 -0
- package/realtime/dist/index.d.mts +0 -25
- package/realtime/dist/index.d.ts +0 -25
- package/realtime/dist/index.js +0 -190
- package/realtime/dist/index.js.map +0 -1
- package/realtime/dist/index.mjs +0 -151
- package/realtime/dist/index.mjs.map +0 -1
- package/src/internal/atom-internal.ts +0 -54
- package/src/internal/families-internal.ts +0 -144
- package/src/internal/get.ts +0 -129
- package/src/internal/index.ts +0 -15
- package/src/internal/operation.ts +0 -139
- package/src/internal/selector/lookup-selector-sources.ts +0 -16
- package/src/internal/selector-internal.ts +0 -58
- package/src/internal/set.ts +0 -99
- package/src/internal/store.ts +0 -151
- package/src/internal/subscribe-internal.ts +0 -88
- package/src/internal/timeline/index.ts +0 -1
- package/src/introspection/attach-selector-index.ts +0 -77
- package/src/introspection/attach-timeline-index.ts +0 -36
- package/src/introspection/attach-transaction-index.ts +0 -38
- package/src/json/index.ts +0 -1
- package/src/json/select-json.ts +0 -18
- package/src/react/store-context.tsx +0 -13
- package/src/react/store-hooks.ts +0 -47
- package/src/react-explorer/AtomIOExplorer.tsx +0 -218
- package/src/react-explorer/explorer-effects.ts +0 -20
- package/src/react-explorer/explorer-states.ts +0 -217
- package/src/react-explorer/index.ts +0 -23
- package/src/react-explorer/space-states.ts +0 -72
- package/src/react-explorer/view-states.ts +0 -41
- package/src/realtime/README.md +0 -33
- package/src/realtime/hook-composition/expose-family.ts +0 -101
- package/src/realtime/hook-composition/expose-single.ts +0 -38
- package/src/realtime/hook-composition/expose-timeline.ts +0 -60
- package/src/realtime/hook-composition/index.ts +0 -12
- package/src/realtime/hook-composition/receive-state.ts +0 -29
- package/src/realtime/hook-composition/receive-transaction.ts +0 -18
- package/src/realtime/index.ts +0 -1
- package/src/realtime-react/index.ts +0 -3
- package/src/realtime-react/realtime-hooks.ts +0 -39
- package/src/realtime-react/realtime-state.ts +0 -10
- package/src/realtime-react/use-pull-family-member.ts +0 -26
- package/src/realtime-react/use-pull-family.ts +0 -24
- package/src/realtime-react/use-pull.ts +0 -24
- package/src/realtime-react/use-push.ts +0 -27
- package/src/realtime-react/use-server-action.ts +0 -33
- package/src/tracker/index.ts +0 -3
- package/src/tracker/tracker.ts +0 -61
- package/src/web-effects/index.ts +0 -1
- package/src/web-effects/storage.ts +0 -30
- /package/{src/introspection → introspection/src}/index.ts +0 -0
- /package/{src/react → react/src}/index.ts +0 -0
- /package/{src/react-devtools → react-devtools/src}/devtools.scss +0 -0
- /package/{src/realtime-testing → realtime-testing/src}/index.ts +0 -0
|
@@ -1,189 +1,36 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import * as atom_io from 'atom.io';
|
|
2
|
+
import { FamilyMetadata, ƒn, TransactionUpdate, StateToken, TimelineUpdate, StateUpdate, AtomFamily, ReadonlySelectorFamily, SelectorFamily, AtomToken, ReadonlySelectorToken, SelectorToken, TransactionToken, TimelineToken, Logger } from 'atom.io';
|
|
3
|
+
import { Json } from 'atom.io/json';
|
|
3
4
|
|
|
4
|
-
type
|
|
5
|
-
|
|
6
|
-
type ƒn = (...parameters: any[]) => any;
|
|
7
|
-
|
|
8
|
-
type JsonInterface<T, J extends Serializable = Serializable> = {
|
|
9
|
-
toJson: (t: T) => J;
|
|
10
|
-
fromJson: (json: J) => T;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
type primitive = boolean | number | string | null;
|
|
14
|
-
|
|
15
|
-
type Serializable = primitive | Readonly<{
|
|
16
|
-
[key: string]: Serializable;
|
|
17
|
-
}> | ReadonlyArray<Serializable>;
|
|
18
|
-
type Object$1<Key extends string = string, Value extends Serializable = Serializable> = Record<Key, Value>;
|
|
19
|
-
|
|
20
|
-
type Identified = {
|
|
21
|
-
id: string;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
declare const RELATION_TYPES: readonly ["1:1", "1:n", "n:n"];
|
|
25
|
-
type RelationType = typeof RELATION_TYPES[number];
|
|
26
|
-
type RelationData<CONTENT extends Object$1 | null = null, A extends string = `from`, B extends string = `to`> = {
|
|
27
|
-
contents: Object$1<string, CONTENT>;
|
|
28
|
-
relations: Object$1<string, string[]>;
|
|
29
|
-
relationType: RelationType;
|
|
30
|
-
a: A;
|
|
31
|
-
b: B;
|
|
32
|
-
};
|
|
33
|
-
type IsRelationDataOptions<CONTENT extends Object$1 | null = null, A extends string = `from`, B extends string = `to`> = {
|
|
34
|
-
from?: A;
|
|
35
|
-
to?: B;
|
|
36
|
-
isContent?: (json: Serializable) => json is CONTENT;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
type NullSafeUnion<Base, Extension> = Extension extends null ? Base : Base & Extension;
|
|
40
|
-
type NullSafeRest<MaybeArg, IfArg = MaybeArg> = MaybeArg extends null ? [] | [undefined] : [IfArg];
|
|
5
|
+
type ClassSignature = abstract new (...args: any) => any;
|
|
41
6
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
] : [Refinement<unknown, CONTENT>]) => JsonInterface<Join<CONTENT, A, B>, RelationData<CONTENT, A, B>>;
|
|
55
|
-
getRelatedId(id: string): string | undefined;
|
|
56
|
-
getRelatedIds(id: string): string[];
|
|
57
|
-
getContent(idA: string, idB: string): CONTENT | undefined;
|
|
58
|
-
getRelationEntries(id: string): [string, CONTENT][];
|
|
59
|
-
getRelationRecord(id: string): Record<string, CONTENT>;
|
|
60
|
-
getRelation(id: string): NullSafeUnion<Identified, CONTENT> | undefined;
|
|
61
|
-
getRelations(id: string): NullSafeUnion<Identified, CONTENT>[];
|
|
62
|
-
setRelations(subject: {
|
|
63
|
-
[from in A]: string;
|
|
64
|
-
} | {
|
|
65
|
-
[to in B]: string;
|
|
66
|
-
}, relations: NullSafeUnion<Identified, CONTENT>[]): Join<CONTENT, A, B>;
|
|
67
|
-
set(relation: {
|
|
68
|
-
[key in A | B]: string;
|
|
69
|
-
}, ...rest: NullSafeRest<CONTENT>): Join<CONTENT, A, B>;
|
|
70
|
-
remove(relation: Partial<Record<A | B, string>>): Join<CONTENT, A, B>;
|
|
7
|
+
type RefinementStrategy = ClassSignature | Refinement$1<unknown, any>;
|
|
8
|
+
type Supported<Refine extends RefinementStrategy> = Refine extends Refinement$1<unknown, infer T> ? T : Refine extends ClassSignature ? InstanceType<Refine> : never;
|
|
9
|
+
type RefinementSupport = Record<string, RefinementStrategy>;
|
|
10
|
+
declare class Refinery<SupportedTypes extends RefinementSupport> {
|
|
11
|
+
supported: SupportedTypes;
|
|
12
|
+
constructor(supported: SupportedTypes);
|
|
13
|
+
refine(input: unknown): {
|
|
14
|
+
[K in keyof SupportedTypes]: {
|
|
15
|
+
type: K;
|
|
16
|
+
data: Supported<SupportedTypes[K]>;
|
|
17
|
+
};
|
|
18
|
+
}[keyof SupportedTypes] | null;
|
|
71
19
|
}
|
|
72
20
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
type: `atom_family`;
|
|
76
|
-
subject: Subject<AtomToken<T>>;
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
type Logger = Pick<Console, `error` | `info` | `warn`>;
|
|
80
|
-
|
|
81
|
-
type TransactionToken<_> = {
|
|
82
|
-
key: string;
|
|
83
|
-
type: `transaction`;
|
|
84
|
-
__brand?: _;
|
|
85
|
-
};
|
|
86
|
-
type TransactionUpdate<ƒ extends ƒn> = {
|
|
87
|
-
key: string;
|
|
88
|
-
atomUpdates: KeyedStateUpdate<unknown>[];
|
|
89
|
-
params: Parameters<ƒ>;
|
|
90
|
-
output: ReturnType<ƒ>;
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
type ReadonlySelectorFamily<T, K extends Serializable = Serializable> = ((key: K) => ReadonlySelectorToken<T>) & {
|
|
94
|
-
key: string;
|
|
95
|
-
type: `readonly_selector_family`;
|
|
96
|
-
subject: Subject<ReadonlySelectorToken<T>>;
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
type StateUpdate<T> = {
|
|
100
|
-
newValue: T;
|
|
101
|
-
oldValue: T;
|
|
102
|
-
};
|
|
103
|
-
type KeyedStateUpdate<T> = StateUpdate<T> & {
|
|
104
|
-
key: string;
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
type TimelineToken = {
|
|
108
|
-
key: string;
|
|
109
|
-
type: `timeline`;
|
|
110
|
-
};
|
|
111
|
-
type TimelineUpdate = TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate;
|
|
112
|
-
|
|
113
|
-
type AtomToken<_> = {
|
|
114
|
-
key: string;
|
|
115
|
-
type: `atom`;
|
|
116
|
-
family?: FamilyMetadata;
|
|
117
|
-
__brand?: _;
|
|
118
|
-
};
|
|
119
|
-
type SelectorToken<_> = {
|
|
120
|
-
key: string;
|
|
121
|
-
type: `selector`;
|
|
122
|
-
family?: FamilyMetadata;
|
|
123
|
-
__brand?: _;
|
|
124
|
-
};
|
|
125
|
-
type StateToken<T> = AtomToken<T> | SelectorToken<T>;
|
|
126
|
-
type ReadonlySelectorToken<_> = {
|
|
127
|
-
key: string;
|
|
128
|
-
type: `readonly_selector`;
|
|
129
|
-
family?: FamilyMetadata;
|
|
130
|
-
__brand?: _;
|
|
131
|
-
};
|
|
132
|
-
type FamilyMetadata = {
|
|
133
|
-
key: string;
|
|
134
|
-
subKey: string;
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
type StoreCore = Pick<Store, `atoms` | `atomsThatAreDefault` | `operation` | `readonlySelectors` | `selectorAtoms` | `selectorGraph` | `selectors` | `timelineAtoms` | `timelines` | `transactions` | `valueMap`>;
|
|
138
|
-
interface Store {
|
|
139
|
-
atoms: Map<string, Atom<any>>;
|
|
140
|
-
atomsThatAreDefault: Set<string>;
|
|
141
|
-
readonlySelectors: Map<string, ReadonlySelector<any>>;
|
|
142
|
-
selectorAtoms: Join<null, `selectorKey`, `atomKey`>;
|
|
143
|
-
selectorGraph: Join<{
|
|
144
|
-
source: string;
|
|
145
|
-
}>;
|
|
146
|
-
selectors: Map<string, Selector<any>>;
|
|
147
|
-
timelineAtoms: Join<null, `timelineKey`, `atomKey`>;
|
|
148
|
-
timelines: Map<string, Timeline>;
|
|
149
|
-
transactions: Map<string, Transaction<any>>;
|
|
150
|
-
valueMap: Map<string, any>;
|
|
151
|
-
subject: {
|
|
152
|
-
atomCreation: Subject<AtomToken<unknown>>;
|
|
153
|
-
selectorCreation: Subject<ReadonlySelectorToken<unknown> | SelectorToken<unknown>>;
|
|
154
|
-
transactionCreation: Subject<TransactionToken<ƒn>>;
|
|
155
|
-
timelineCreation: Subject<TimelineToken>;
|
|
156
|
-
operationStatus: Subject<OperationProgress>;
|
|
157
|
-
};
|
|
158
|
-
operation: OperationProgress;
|
|
159
|
-
transactionStatus: TransactionStatus<ƒn>;
|
|
160
|
-
config: {
|
|
161
|
-
name: string;
|
|
162
|
-
logger: Logger | null;
|
|
163
|
-
logger__INTERNAL: Logger;
|
|
164
|
-
};
|
|
21
|
+
interface Refinement$1<A, B extends A> {
|
|
22
|
+
(a: A): a is B;
|
|
165
23
|
}
|
|
166
24
|
|
|
167
|
-
type
|
|
168
|
-
key: string;
|
|
169
|
-
type: `atom`;
|
|
170
|
-
family?: FamilyMetadata;
|
|
171
|
-
subject: Subject<{
|
|
172
|
-
newValue: T;
|
|
173
|
-
oldValue: T;
|
|
174
|
-
}>;
|
|
175
|
-
default: T;
|
|
176
|
-
};
|
|
25
|
+
type PlainObject = Record<keyof any, unknown>;
|
|
177
26
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
token: StateToken<any>;
|
|
186
|
-
};
|
|
27
|
+
declare class Subject<T> {
|
|
28
|
+
Subscriber: (value: T) => void;
|
|
29
|
+
subscribers: Map<string, this[`Subscriber`]>;
|
|
30
|
+
subscribe(key: string, subscriber: this[`Subscriber`]): () => void;
|
|
31
|
+
private unsubscribe;
|
|
32
|
+
next(value: T): void;
|
|
33
|
+
}
|
|
187
34
|
|
|
188
35
|
type Selector<T> = {
|
|
189
36
|
key: string;
|
|
@@ -209,20 +56,130 @@ type ReadonlySelector<T> = {
|
|
|
209
56
|
get: () => T;
|
|
210
57
|
};
|
|
211
58
|
|
|
212
|
-
type
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
59
|
+
type Transaction<ƒ extends ƒn> = {
|
|
60
|
+
key: string;
|
|
61
|
+
type: `transaction`;
|
|
62
|
+
install: (store: Store) => void;
|
|
63
|
+
subject: Subject<TransactionUpdate<ƒ>>;
|
|
64
|
+
run: (...parameters: Parameters<ƒ>) => ReturnType<ƒ>;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
type TransactionUpdateInProgress<ƒ extends ƒn> = TransactionUpdate<ƒ> & {
|
|
68
|
+
phase: `applying` | `building`;
|
|
69
|
+
time: number;
|
|
70
|
+
core: StoreCore;
|
|
71
|
+
};
|
|
72
|
+
type TransactionIdle = {
|
|
73
|
+
phase: `idle`;
|
|
74
|
+
};
|
|
75
|
+
type TransactionStatus<ƒ extends ƒn> = TransactionIdle | TransactionUpdateInProgress<ƒ>;
|
|
76
|
+
|
|
77
|
+
type primitive = boolean | number | string | null;
|
|
78
|
+
|
|
79
|
+
type Serializable = primitive | Readonly<{
|
|
80
|
+
[key: string]: Serializable;
|
|
81
|
+
}> | ReadonlyArray<Serializable>;
|
|
82
|
+
type Object$1<Key extends string = string, Value extends Serializable = Serializable> = Record<Key, Value>;
|
|
83
|
+
|
|
84
|
+
type Refinement<Unrefined, Refined extends Unrefined> = (value: Unrefined) => value is Refined;
|
|
85
|
+
type Cardinality = `1:1` | `1:n` | `n:n`;
|
|
86
|
+
|
|
87
|
+
interface JunctionEntries<Content extends Object$1 | null> extends Object$1 {
|
|
88
|
+
readonly relations: [string, string[]][];
|
|
89
|
+
readonly contents: [string, Content][];
|
|
90
|
+
}
|
|
91
|
+
interface JunctionSchema<ASide extends string, BSide extends string> extends Object$1 {
|
|
92
|
+
readonly between: [a: ASide, b: BSide];
|
|
93
|
+
readonly cardinality: Cardinality;
|
|
94
|
+
}
|
|
95
|
+
type JunctionAdvancedConfiguration<Content extends Object$1 | null> = {
|
|
96
|
+
externalStore?: (Content extends null ? {
|
|
97
|
+
getContent?: undefined;
|
|
98
|
+
setContent?: undefined;
|
|
99
|
+
deleteContent?: undefined;
|
|
100
|
+
} : {
|
|
101
|
+
getContent: (contentKey: string) => Content | undefined;
|
|
102
|
+
setContent: (contentKey: string, content: Content) => void;
|
|
103
|
+
deleteContent: (contentKey: string) => void;
|
|
104
|
+
}) & {
|
|
105
|
+
addRelation: (a: string, b: string) => void;
|
|
106
|
+
deleteRelation: (a: string, b: string) => void;
|
|
107
|
+
getRelatedKeys: (key: string) => Set<string> | undefined;
|
|
108
|
+
has: (a: string, b?: string) => boolean;
|
|
217
109
|
};
|
|
218
|
-
|
|
219
|
-
|
|
110
|
+
isContent?: Refinement<unknown, Content>;
|
|
111
|
+
makeContentKey?: (a: string, b: string) => string;
|
|
112
|
+
};
|
|
113
|
+
type JunctionJSON<ASide extends string, BSide extends string, Content extends Object$1 | null> = JunctionEntries<Content> & JunctionSchema<ASide, BSide>;
|
|
114
|
+
declare class Junction<ASide extends string, BSide extends string, Content extends Object$1 | null = null> {
|
|
115
|
+
readonly a: ASide;
|
|
116
|
+
readonly b: BSide;
|
|
117
|
+
readonly cardinality: Cardinality;
|
|
118
|
+
readonly relations: Map<string, Set<string>>;
|
|
119
|
+
readonly contents: Map<string, Content>;
|
|
120
|
+
isContent: Refinement<unknown, Content> | null;
|
|
121
|
+
makeContentKey: (a: string, b: string) => string;
|
|
122
|
+
getRelatedKeys(key: string): Set<string> | undefined;
|
|
123
|
+
protected addRelation(a: string, b: string): void;
|
|
124
|
+
protected deleteRelation(a: string, b: string): void;
|
|
125
|
+
protected getContentInternal(contentKey: string): Content | undefined;
|
|
126
|
+
protected setContent(contentKey: string, content: Content): void;
|
|
127
|
+
protected deleteContent(contentKey: string): void;
|
|
128
|
+
constructor(data: JunctionSchema<ASide, BSide> & Partial<JunctionEntries<Content>>, config?: JunctionAdvancedConfiguration<Content>);
|
|
129
|
+
toJSON(): JunctionJSON<ASide, BSide, Content>;
|
|
130
|
+
set(a: string, ...rest: Content extends null ? [b: string] : [b: string, content: Content]): this;
|
|
131
|
+
set(relation: {
|
|
132
|
+
[Key in ASide | BSide]: string;
|
|
133
|
+
}, ...rest: Content extends null ? [] | [b?: undefined] : [content: Content]): this;
|
|
134
|
+
delete(a: string, b?: string): this;
|
|
135
|
+
delete(relation: Record<ASide | BSide, string> | Record<ASide, string> | Record<BSide, string>, b?: undefined): this;
|
|
136
|
+
getRelatedKey(key: string): string | undefined;
|
|
137
|
+
getContent(a: string, b: string): Content | undefined;
|
|
138
|
+
getRelationEntries(input: Record<ASide, string> | Record<BSide, string>): [string, Content][];
|
|
139
|
+
has(a: string, b?: string): boolean;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
interface Transceiver<Signal extends Json.Serializable> {
|
|
143
|
+
do: (update: Signal) => void;
|
|
144
|
+
undo: (update: Signal) => void;
|
|
145
|
+
subscribe: (key: string, fn: (update: Signal) => void) => () => void;
|
|
220
146
|
}
|
|
221
147
|
|
|
148
|
+
/**
|
|
149
|
+
* @internal Give the tracker a transceiver state and a store, and it will
|
|
150
|
+
* subscribe to the transceiver's inner value. When the inner value changes,
|
|
151
|
+
* the tracker will update its own state to reflect the change.
|
|
152
|
+
*/
|
|
153
|
+
declare class Tracker<Mutable extends Transceiver<any>> {
|
|
154
|
+
private Update;
|
|
155
|
+
private initializeState;
|
|
156
|
+
private unsubscribeFromInnerValue;
|
|
157
|
+
private observeCore;
|
|
158
|
+
private updateCore;
|
|
159
|
+
mutableState: atom_io.MutableAtomToken<Mutable, Json.Serializable>;
|
|
160
|
+
latestUpdateState: atom_io.AtomToken<typeof this$1.Update | null>;
|
|
161
|
+
constructor(mutableState: atom_io.MutableAtomToken<Mutable, Json.Serializable>, store?: Store);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
interface MutableAtom<T> extends Atom<T> {
|
|
165
|
+
mutable: true;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
type OperationProgress = {
|
|
169
|
+
open: false;
|
|
170
|
+
} | {
|
|
171
|
+
open: true;
|
|
172
|
+
done: Set<string>;
|
|
173
|
+
prev: Map<string, any>;
|
|
174
|
+
time: number;
|
|
175
|
+
token: StateToken<any>;
|
|
176
|
+
};
|
|
177
|
+
|
|
222
178
|
type TimelineAtomUpdate = StateUpdate<unknown> & {
|
|
223
179
|
key: string;
|
|
224
180
|
type: `atom_update`;
|
|
225
181
|
timestamp: number;
|
|
182
|
+
family?: FamilyMetadata;
|
|
226
183
|
};
|
|
227
184
|
type TimelineSelectorUpdate = {
|
|
228
185
|
key: string;
|
|
@@ -236,6 +193,7 @@ type TimelineTransactionUpdate = TransactionUpdate<ƒn> & {
|
|
|
236
193
|
timestamp: number;
|
|
237
194
|
};
|
|
238
195
|
type Timeline = {
|
|
196
|
+
type: `timeline`;
|
|
239
197
|
key: string;
|
|
240
198
|
at: number;
|
|
241
199
|
timeTraveling: `into_future` | `into_past` | null;
|
|
@@ -246,49 +204,60 @@ type Timeline = {
|
|
|
246
204
|
subject: Subject<TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate | `redo` | `undo`>;
|
|
247
205
|
};
|
|
248
206
|
|
|
249
|
-
type
|
|
207
|
+
type StoreCore = Pick<Store, `atoms` | `atomsThatAreDefault` | `families` | `operation` | `readonlySelectors` | `selectorAtoms` | `selectorGraph` | `selectors` | `timelineAtoms` | `timelines` | `trackers` | `transactions` | `valueMap`>;
|
|
208
|
+
declare class Store {
|
|
209
|
+
valueMap: Map<string, any>;
|
|
210
|
+
atoms: Map<string, Atom<any> | MutableAtom<any>>;
|
|
211
|
+
selectors: Map<string, Selector<any>>;
|
|
212
|
+
readonlySelectors: Map<string, ReadonlySelector<any>>;
|
|
213
|
+
trackers: Map<string, Tracker<Transceiver<any>>>;
|
|
214
|
+
families: Map<string, AtomFamily<any, any> | ReadonlySelectorFamily<any, any> | SelectorFamily<any, any>>;
|
|
215
|
+
timelines: Map<string, Timeline>;
|
|
216
|
+
transactions: Map<string, Transaction<ƒn>>;
|
|
217
|
+
atomsThatAreDefault: Set<string>;
|
|
218
|
+
timelineAtoms: Junction<"timelineKey", "atomKey", null>;
|
|
219
|
+
selectorAtoms: Junction<"selectorKey", "atomKey", null>;
|
|
220
|
+
selectorGraph: Junction<"upstreamSelectorKey", "downstreamSelectorKey", {
|
|
221
|
+
source: string;
|
|
222
|
+
}>;
|
|
223
|
+
subject: {
|
|
224
|
+
atomCreation: Subject<AtomToken<unknown>>;
|
|
225
|
+
selectorCreation: Subject<ReadonlySelectorToken<unknown> | SelectorToken<unknown>>;
|
|
226
|
+
transactionCreation: Subject<TransactionToken<ƒn>>;
|
|
227
|
+
timelineCreation: Subject<TimelineToken>;
|
|
228
|
+
operationStatus: Subject<OperationProgress>;
|
|
229
|
+
};
|
|
230
|
+
operation: OperationProgress;
|
|
231
|
+
transactionStatus: TransactionStatus<ƒn>;
|
|
232
|
+
config: {
|
|
233
|
+
name: string;
|
|
234
|
+
logger: Logger | null;
|
|
235
|
+
logger__INTERNAL: Logger;
|
|
236
|
+
};
|
|
237
|
+
constructor(name: string, store?: Store | null);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
type Atom<T> = {
|
|
250
241
|
key: string;
|
|
251
|
-
type: `
|
|
242
|
+
type: `atom`;
|
|
243
|
+
family?: FamilyMetadata;
|
|
252
244
|
install: (store: Store) => void;
|
|
253
|
-
subject: Subject<
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
phase: `applying` | `building`;
|
|
259
|
-
time: number;
|
|
260
|
-
core: StoreCore;
|
|
261
|
-
};
|
|
262
|
-
type TransactionIdle = {
|
|
263
|
-
phase: `idle`;
|
|
245
|
+
subject: Subject<{
|
|
246
|
+
newValue: T;
|
|
247
|
+
oldValue: T;
|
|
248
|
+
}>;
|
|
249
|
+
default: T;
|
|
264
250
|
};
|
|
265
|
-
type TransactionStatus<ƒ extends ƒn> = TransactionIdle | TransactionUpdateInProgress<ƒ>;
|
|
266
251
|
|
|
267
|
-
type AtomTokenIndex = StateTokenIndex<AtomToken
|
|
252
|
+
type AtomTokenIndex = StateTokenIndex<AtomToken<unknown>>;
|
|
268
253
|
|
|
269
|
-
type FamilyNode<Token extends AtomToken
|
|
254
|
+
type FamilyNode<Token extends AtomToken<unknown> | ReadonlySelectorToken<unknown> | SelectorToken<unknown>> = {
|
|
270
255
|
key: string;
|
|
271
256
|
familyMembers: Record<string, Token>;
|
|
272
257
|
};
|
|
273
|
-
type StateTokenIndex<Token extends AtomToken
|
|
274
|
-
|
|
275
|
-
type SelectorTokenIndex = StateTokenIndex<ReadonlySelectorToken$1<unknown> | SelectorToken$1<unknown>>;
|
|
258
|
+
type StateTokenIndex<Token extends AtomToken<unknown> | ReadonlySelectorToken<unknown> | SelectorToken<unknown>> = Record<string, FamilyNode<Token> | Token>;
|
|
276
259
|
|
|
277
|
-
type
|
|
278
|
-
|
|
279
|
-
type RefinementStrategy = ClassSignature | Refinement<unknown, any>;
|
|
280
|
-
type Supported<Refine extends RefinementStrategy> = Refine extends Refinement<unknown, infer T> ? T : Refine extends ClassSignature ? InstanceType<Refine> : never;
|
|
281
|
-
type RefinementSupport = Record<string, RefinementStrategy>;
|
|
282
|
-
declare class Refinery<SupportedTypes extends RefinementSupport> {
|
|
283
|
-
supported: SupportedTypes;
|
|
284
|
-
constructor(supported: SupportedTypes);
|
|
285
|
-
refine(input: unknown): {
|
|
286
|
-
[K in keyof SupportedTypes]: {
|
|
287
|
-
type: K;
|
|
288
|
-
data: Supported<SupportedTypes[K]>;
|
|
289
|
-
};
|
|
290
|
-
}[keyof SupportedTypes] | null;
|
|
291
|
-
}
|
|
260
|
+
type SelectorTokenIndex = StateTokenIndex<ReadonlySelectorToken<unknown> | SelectorToken<unknown>>;
|
|
292
261
|
|
|
293
262
|
type Delta = {
|
|
294
263
|
summary: string;
|
|
@@ -317,17 +286,17 @@ declare class Differ<Leaf extends Record<string, any>, Tree extends Record<strin
|
|
|
317
286
|
|
|
318
287
|
declare const AtomIODevtools: () => JSX.Element;
|
|
319
288
|
|
|
320
|
-
declare const atomIndex: ReadonlySelectorToken<AtomTokenIndex>;
|
|
321
|
-
declare const selectorIndex: ReadonlySelectorToken<SelectorTokenIndex>;
|
|
322
|
-
declare const transactionIndex: ReadonlySelectorToken<TransactionToken
|
|
323
|
-
declare const findTransactionLogState: ReadonlySelectorFamily<TransactionUpdate
|
|
324
|
-
declare const timelineIndex: ReadonlySelectorToken<TimelineToken[]>;
|
|
325
|
-
declare const findTimelineState: ReadonlySelectorFamily<Timeline>;
|
|
326
|
-
declare const devtoolsAreOpenState: AtomToken<boolean>;
|
|
289
|
+
declare const atomIndex: atom_io.ReadonlySelectorToken<AtomTokenIndex>;
|
|
290
|
+
declare const selectorIndex: atom_io.ReadonlySelectorToken<SelectorTokenIndex>;
|
|
291
|
+
declare const transactionIndex: atom_io.ReadonlySelectorToken<atom_io.TransactionToken<atom_io.ƒn>[]>;
|
|
292
|
+
declare const findTransactionLogState: atom_io.ReadonlySelectorFamily<atom_io.TransactionUpdate<atom_io.ƒn>[]>;
|
|
293
|
+
declare const timelineIndex: atom_io.ReadonlySelectorToken<atom_io.TimelineToken[]>;
|
|
294
|
+
declare const findTimelineState: atom_io.ReadonlySelectorFamily<Timeline>;
|
|
295
|
+
declare const devtoolsAreOpenState: atom_io.AtomToken<boolean>;
|
|
327
296
|
type DevtoolsView = `atoms` | `selectors` | `timelines` | `transactions`;
|
|
328
|
-
declare const devtoolsViewSelectionState: AtomToken<DevtoolsView>;
|
|
329
|
-
declare const devtoolsViewOptionsState: AtomToken<DevtoolsView[]>;
|
|
330
|
-
declare const findViewIsOpenState: AtomFamily<boolean, string>;
|
|
297
|
+
declare const devtoolsViewSelectionState: atom_io.AtomToken<DevtoolsView>;
|
|
298
|
+
declare const devtoolsViewOptionsState: atom_io.AtomToken<DevtoolsView[]>;
|
|
299
|
+
declare const findViewIsOpenState: atom_io.AtomFamily<boolean, string>;
|
|
331
300
|
declare const primitiveRefinery: Refinery<{
|
|
332
301
|
number: (input: unknown) => input is number;
|
|
333
302
|
string: (input: unknown) => input is string;
|