atom.io 0.33.2 → 0.33.4
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/dist/data/index.d.ts +3 -3
- package/dist/data/index.d.ts.map +1 -1
- package/dist/data/index.js.map +1 -1
- package/dist/eslint-plugin/index.d.ts.map +1 -1
- package/dist/internal/index.d.ts +118 -54
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +381 -128
- package/dist/internal/index.js.map +1 -1
- package/dist/introspection/index.d.ts +11 -10
- package/dist/introspection/index.d.ts.map +1 -1
- package/dist/introspection/index.js +4 -4
- package/dist/introspection/index.js.map +1 -1
- package/dist/json/index.d.ts +3 -3
- package/dist/json/index.d.ts.map +1 -1
- package/dist/json/index.js +2 -2
- package/dist/json/index.js.map +1 -1
- package/dist/main/index.d.ts +157 -36
- package/dist/main/index.d.ts.map +1 -1
- package/dist/main/index.js +15 -3
- package/dist/main/index.js.map +1 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/{devtools-Jyn42mZm.css → react-devtools/index.css} +1 -1
- package/dist/react-devtools/index.css.map +1 -0
- package/dist/react-devtools/index.d.ts +0 -1
- package/dist/react-devtools/index.d.ts.map +1 -1
- package/dist/react-devtools/index.js +8 -3
- package/dist/react-devtools/index.js.map +1 -1
- package/dist/realtime/index.d.ts +3 -2
- package/dist/realtime/index.d.ts.map +1 -1
- package/dist/realtime/index.js.map +1 -1
- package/dist/realtime-client/index.d.ts +4 -1
- package/dist/realtime-client/index.d.ts.map +1 -1
- package/dist/realtime-client/index.js.map +1 -1
- package/dist/realtime-react/index.d.ts.map +1 -1
- package/dist/realtime-react/index.js.map +1 -1
- package/dist/realtime-server/index.d.ts +27 -2
- package/dist/realtime-server/index.d.ts.map +1 -1
- package/dist/realtime-server/index.js.map +1 -1
- package/dist/realtime-testing/index.d.ts.map +1 -1
- package/dist/transceivers/set-rtx/index.d.ts.map +1 -1
- package/dist/web/index.d.ts.map +1 -1
- package/package.json +21 -21
- package/src/data/dict.ts +5 -5
- package/src/data/struct-family.ts +2 -2
- package/src/data/struct.ts +1 -1
- package/src/internal/atom/create-regular-atom.ts +14 -17
- package/src/internal/caching.ts +1 -1
- package/src/internal/families/create-readonly-held-selector-family.ts +81 -0
- package/src/internal/families/{create-readonly-selector-family.ts → create-readonly-pure-selector-family.ts} +26 -23
- package/src/internal/families/create-selector-family.ts +39 -16
- package/src/internal/families/create-writable-held-selector-family.ts +80 -0
- package/src/internal/families/{create-writable-selector-family.ts → create-writable-pure-selector-family.ts} +26 -23
- package/src/internal/families/dispose-from-store.ts +4 -2
- package/src/internal/families/find-in-store.ts +8 -8
- package/src/internal/families/get-family-of-token.ts +8 -8
- package/src/internal/families/index.ts +3 -3
- package/src/internal/families/init-family-member.ts +12 -10
- package/src/internal/families/seek-in-store.ts +13 -11
- package/src/internal/get-state/get-from-store.ts +5 -2
- package/src/internal/get-state/read-or-compute-value.ts +4 -2
- package/src/internal/index.ts +97 -20
- package/src/internal/join/join-internal.ts +18 -18
- package/src/internal/keys.ts +1 -1
- package/src/internal/mutable/create-mutable-atom.ts +17 -15
- package/src/internal/mutable/get-json-family.ts +4 -4
- package/src/internal/mutable/get-json-token.ts +7 -7
- package/src/internal/selector/create-readonly-held-selector.ts +50 -0
- package/src/internal/selector/create-readonly-pure-selector.ts +51 -0
- package/src/internal/selector/create-standalone-selector.ts +48 -15
- package/src/internal/selector/create-writable-held-selector.ts +68 -0
- package/src/internal/selector/{create-writable-selector.ts → create-writable-pure-selector.ts} +18 -25
- package/src/internal/selector/dispose-selector.ts +37 -7
- package/src/internal/selector/get-selector-dependency-keys.ts +1 -1
- package/src/internal/selector/index.ts +4 -2
- package/src/internal/selector/register-selector.ts +17 -5
- package/src/internal/selector/trace-selector-atoms.ts +5 -5
- package/src/internal/selector/update-selector-atoms.ts +16 -10
- package/src/internal/set-state/emit-update.ts +4 -2
- package/src/internal/set-state/set-atom-or-selector.ts +2 -1
- package/src/internal/store/counterfeit.ts +13 -11
- package/src/internal/store/deposit.ts +18 -14
- package/src/internal/store/store.ts +9 -14
- package/src/internal/store/withdraw.ts +83 -7
- package/src/internal/subscribe/subscribe-in-store.ts +4 -2
- package/src/internal/subscribe/subscribe-to-state.ts +2 -1
- package/src/internal/timeline/create-timeline.ts +4 -2
- package/src/internal/transaction/build-transaction.ts +1 -1
- package/src/introspection/attach-atom-index.ts +2 -2
- package/src/introspection/attach-introspection-states.ts +9 -9
- package/src/introspection/attach-selector-index.ts +3 -3
- package/src/introspection/attach-timeline-family.ts +2 -2
- package/src/introspection/attach-timeline-index.ts +2 -2
- package/src/introspection/attach-transaction-index.ts +2 -2
- package/src/introspection/attach-transaction-logs.ts +2 -2
- package/src/introspection/attach-type-selectors.ts +5 -5
- package/src/introspection/auditor.ts +3 -3
- package/src/json/select-json-family.ts +5 -5
- package/src/json/select-json.ts +1 -1
- package/src/main/find-state.ts +8 -8
- package/src/main/index.ts +51 -6
- package/src/main/join.ts +13 -13
- package/src/main/logger.ts +32 -15
- package/src/main/selector.ts +164 -30
- package/src/main/transaction.ts +3 -3
- package/src/main/validators.ts +16 -12
- package/src/react-devtools/StateEditor.tsx +14 -4
- package/src/react-devtools/StateIndex.tsx +6 -4
- package/src/react-devtools/TimelineIndex.tsx +2 -2
- package/src/react-devtools/TransactionIndex.tsx +2 -2
- package/src/realtime/shared-room-store.ts +3 -3
- package/src/realtime-client/realtime-client-stores/client-main-store.ts +1 -1
- package/src/realtime-react/use-pull-selector-family-member.ts +1 -0
- package/src/realtime-server/realtime-server-stores/server-room-external-store.ts +2 -2
- package/dist/devtools-CAg2k57t.js +0 -0
- package/dist/devtools-Jyn42mZm.css.map +0 -1
- package/src/internal/selector/create-readonly-selector.ts +0 -55
|
@@ -2,10 +2,18 @@ import type {
|
|
|
2
2
|
AtomFamilyToken,
|
|
3
3
|
AtomIOToken,
|
|
4
4
|
AtomToken,
|
|
5
|
+
HeldSelectorFamilyToken,
|
|
6
|
+
HeldSelectorToken,
|
|
5
7
|
MutableAtomFamilyToken,
|
|
6
8
|
MutableAtomToken,
|
|
9
|
+
PureSelectorFamilyToken,
|
|
10
|
+
PureSelectorToken,
|
|
7
11
|
ReadableFamilyToken,
|
|
8
12
|
ReadableToken,
|
|
13
|
+
ReadonlyHeldSelectorFamilyToken,
|
|
14
|
+
ReadonlyHeldSelectorToken,
|
|
15
|
+
ReadonlyPureSelectorFamilyToken,
|
|
16
|
+
ReadonlyPureSelectorToken,
|
|
9
17
|
ReadonlySelectorFamilyToken,
|
|
10
18
|
ReadonlySelectorToken,
|
|
11
19
|
RegularAtomFamilyToken,
|
|
@@ -16,6 +24,10 @@ import type {
|
|
|
16
24
|
TimelineToken,
|
|
17
25
|
TransactionToken,
|
|
18
26
|
WritableFamilyToken,
|
|
27
|
+
WritableHeldSelectorFamilyToken,
|
|
28
|
+
WritableHeldSelectorToken,
|
|
29
|
+
WritablePureSelectorFamilyToken,
|
|
30
|
+
WritablePureSelectorToken,
|
|
19
31
|
WritableSelectorFamilyToken,
|
|
20
32
|
WritableSelectorToken,
|
|
21
33
|
WritableToken,
|
|
@@ -27,10 +39,18 @@ import type {
|
|
|
27
39
|
AtomFamily,
|
|
28
40
|
AtomIOInternalResource,
|
|
29
41
|
Func,
|
|
42
|
+
HeldSelector,
|
|
43
|
+
HeldSelectorFamily,
|
|
30
44
|
MutableAtom,
|
|
31
45
|
MutableAtomFamily,
|
|
46
|
+
PureSelector,
|
|
47
|
+
PureSelectorFamily,
|
|
32
48
|
ReadableFamily,
|
|
33
49
|
ReadableState,
|
|
50
|
+
ReadonlyHeldSelector,
|
|
51
|
+
ReadonlyHeldSelectorFamily,
|
|
52
|
+
ReadonlyPureSelector,
|
|
53
|
+
ReadonlyPureSelectorFamily,
|
|
34
54
|
ReadonlySelector,
|
|
35
55
|
ReadonlySelectorFamily,
|
|
36
56
|
RegularAtom,
|
|
@@ -39,6 +59,10 @@ import type {
|
|
|
39
59
|
SelectorFamily,
|
|
40
60
|
Transceiver,
|
|
41
61
|
WritableFamily,
|
|
62
|
+
WritableHeldSelector,
|
|
63
|
+
WritableHeldSelectorFamily,
|
|
64
|
+
WritablePureSelector,
|
|
65
|
+
WritablePureSelectorFamily,
|
|
42
66
|
WritableSelector,
|
|
43
67
|
WritableSelectorFamily,
|
|
44
68
|
WritableState,
|
|
@@ -59,12 +83,36 @@ export function withdraw<T extends Transceiver<any>>(
|
|
|
59
83
|
export function withdraw<T>(store: Store, token: AtomToken<T>): Atom<T>
|
|
60
84
|
export function withdraw<T>(
|
|
61
85
|
store: Store,
|
|
62
|
-
token:
|
|
63
|
-
):
|
|
86
|
+
token: WritableHeldSelectorToken<T>,
|
|
87
|
+
): WritableHeldSelector<T>
|
|
88
|
+
export function withdraw<T>(
|
|
89
|
+
store: Store,
|
|
90
|
+
token: ReadonlyHeldSelectorToken<T>,
|
|
91
|
+
): ReadonlyHeldSelector<T>
|
|
92
|
+
export function withdraw<T>(
|
|
93
|
+
store: Store,
|
|
94
|
+
token: WritablePureSelectorToken<T>,
|
|
95
|
+
): WritablePureSelector<T>
|
|
96
|
+
export function withdraw<T>(
|
|
97
|
+
store: Store,
|
|
98
|
+
token: ReadonlyPureSelectorToken<T>,
|
|
99
|
+
): ReadonlyPureSelector<T>
|
|
64
100
|
export function withdraw<T>(
|
|
65
101
|
store: Store,
|
|
66
102
|
token: ReadonlySelectorToken<T>,
|
|
67
103
|
): ReadonlySelector<T>
|
|
104
|
+
export function withdraw<T>(
|
|
105
|
+
store: Store,
|
|
106
|
+
token: WritableSelectorToken<T>,
|
|
107
|
+
): WritableSelector<T>
|
|
108
|
+
export function withdraw<T>(
|
|
109
|
+
store: Store,
|
|
110
|
+
token: HeldSelectorToken<T>,
|
|
111
|
+
): HeldSelector<T>
|
|
112
|
+
export function withdraw<T>(
|
|
113
|
+
store: Store,
|
|
114
|
+
token: PureSelectorToken<T>,
|
|
115
|
+
): PureSelector<T>
|
|
68
116
|
export function withdraw<T>(store: Store, token: SelectorToken<T>): Selector<T>
|
|
69
117
|
export function withdraw<T>(
|
|
70
118
|
store: Store,
|
|
@@ -91,6 +139,22 @@ export function withdraw<T, K extends Canonical>(
|
|
|
91
139
|
store: Store,
|
|
92
140
|
token: AtomFamilyToken<T>,
|
|
93
141
|
): AtomFamily<T, any>
|
|
142
|
+
export function withdraw<T, K extends Canonical>(
|
|
143
|
+
store: Store,
|
|
144
|
+
token: ReadonlyHeldSelectorFamilyToken<T, K>,
|
|
145
|
+
): ReadonlyHeldSelectorFamily<T, any>
|
|
146
|
+
export function withdraw<T, K extends Canonical>(
|
|
147
|
+
store: Store,
|
|
148
|
+
token: WritableHeldSelectorFamilyToken<T, K>,
|
|
149
|
+
): WritableHeldSelectorFamily<T, any>
|
|
150
|
+
export function withdraw<T, K extends Canonical>(
|
|
151
|
+
store: Store,
|
|
152
|
+
token: ReadonlyPureSelectorFamilyToken<T, K>,
|
|
153
|
+
): ReadonlyPureSelectorFamily<T, any>
|
|
154
|
+
export function withdraw<T, K extends Canonical>(
|
|
155
|
+
store: Store,
|
|
156
|
+
token: WritablePureSelectorFamilyToken<T, K>,
|
|
157
|
+
): WritablePureSelectorFamily<T, any>
|
|
94
158
|
export function withdraw<T, K extends Canonical>(
|
|
95
159
|
store: Store,
|
|
96
160
|
token: ReadonlySelectorFamilyToken<T, K>,
|
|
@@ -99,6 +163,14 @@ export function withdraw<T, K extends Canonical>(
|
|
|
99
163
|
store: Store,
|
|
100
164
|
token: WritableSelectorFamilyToken<T, K>,
|
|
101
165
|
): WritableSelectorFamily<T, any>
|
|
166
|
+
export function withdraw<T, K extends Canonical>(
|
|
167
|
+
store: Store,
|
|
168
|
+
token: HeldSelectorFamilyToken<T, K>,
|
|
169
|
+
): HeldSelectorFamily<T, any>
|
|
170
|
+
export function withdraw<T, K extends Canonical>(
|
|
171
|
+
store: Store,
|
|
172
|
+
token: PureSelectorFamilyToken<T, K>,
|
|
173
|
+
): PureSelectorFamily<T, any>
|
|
102
174
|
export function withdraw<T, K extends Canonical>(
|
|
103
175
|
store: Store,
|
|
104
176
|
token: SelectorFamilyToken<T, K>,
|
|
@@ -147,16 +219,20 @@ export function withdraw(
|
|
|
147
219
|
case `mutable_atom`:
|
|
148
220
|
withdrawn = target.atoms.get(token.key)
|
|
149
221
|
break
|
|
150
|
-
case `
|
|
151
|
-
|
|
222
|
+
case `writable_pure_selector`:
|
|
223
|
+
case `writable_held_selector`:
|
|
224
|
+
withdrawn = target.writableSelectors.get(token.key)
|
|
152
225
|
break
|
|
153
|
-
case `
|
|
226
|
+
case `readonly_pure_selector`:
|
|
227
|
+
case `readonly_held_selector`:
|
|
154
228
|
withdrawn = target.readonlySelectors.get(token.key)
|
|
155
229
|
break
|
|
156
230
|
case `atom_family`:
|
|
157
231
|
case `mutable_atom_family`:
|
|
158
|
-
case `
|
|
159
|
-
case `
|
|
232
|
+
case `writable_pure_selector_family`:
|
|
233
|
+
case `readonly_pure_selector_family`:
|
|
234
|
+
case `writable_held_selector_family`:
|
|
235
|
+
case `readonly_held_selector_family`:
|
|
160
236
|
withdrawn = target.families.get(token.key)
|
|
161
237
|
break
|
|
162
238
|
case `timeline`:
|
|
@@ -51,8 +51,10 @@ export function subscribeInStore(
|
|
|
51
51
|
switch (token.type) {
|
|
52
52
|
case `atom`:
|
|
53
53
|
case `mutable_atom`:
|
|
54
|
-
case `
|
|
55
|
-
case `
|
|
54
|
+
case `readonly_pure_selector`:
|
|
55
|
+
case `readonly_held_selector`:
|
|
56
|
+
case `writable_pure_selector`:
|
|
57
|
+
case `writable_held_selector`:
|
|
56
58
|
return subscribeToState(store, token, key, handleUpdate)
|
|
57
59
|
case `transaction`:
|
|
58
60
|
return subscribeToTransaction(store, token, key, handleUpdate)
|
|
@@ -26,7 +26,8 @@ export function subscribeToState<T>(
|
|
|
26
26
|
const state = withdraw(store, token)
|
|
27
27
|
store.logger.info(`👀`, state.type, state.key, `Adding subscription "${key}"`)
|
|
28
28
|
const isSelector =
|
|
29
|
-
state.type === `
|
|
29
|
+
state.type === `writable_pure_selector` ||
|
|
30
|
+
state.type === `readonly_pure_selector`
|
|
30
31
|
let dependencyUnsubFunctions: (() => void)[] | null = null
|
|
31
32
|
let updateHandler: UpdateHandler<T> = safelyHandleUpdate
|
|
32
33
|
if (isSelector) {
|
|
@@ -188,11 +188,13 @@ function addAtomToTimeline(
|
|
|
188
188
|
function timelineCapturesAtomUpdate(update) {
|
|
189
189
|
const target = newest(store)
|
|
190
190
|
const currentSelectorKey =
|
|
191
|
-
store.operation.open &&
|
|
191
|
+
store.operation.open &&
|
|
192
|
+
store.operation.token.type === `writable_pure_selector`
|
|
192
193
|
? store.operation.token.key
|
|
193
194
|
: null
|
|
194
195
|
const currentSelectorTime =
|
|
195
|
-
store.operation.open &&
|
|
196
|
+
store.operation.open &&
|
|
197
|
+
store.operation.token.type === `writable_pure_selector`
|
|
196
198
|
? store.operation.time
|
|
197
199
|
: null
|
|
198
200
|
|
|
@@ -43,7 +43,7 @@ export const buildTransaction = (
|
|
|
43
43
|
selectorGraph: new Junction(parent.selectorGraph.toJSON(), {
|
|
44
44
|
makeContentKey: (...keys) => keys.sort().join(`:`),
|
|
45
45
|
}),
|
|
46
|
-
|
|
46
|
+
writableSelectors: new LazyMap(parent.writableSelectors),
|
|
47
47
|
valueMap: new LazyMap(parent.valueMap),
|
|
48
48
|
defaults: parent.defaults,
|
|
49
49
|
disposalTraces: store.disposalTraces.copy(),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AtomToken,
|
|
1
|
+
import type { AtomToken, ReadonlyPureSelectorToken } from "atom.io"
|
|
2
2
|
import type { Store } from "atom.io/internal"
|
|
3
3
|
import {
|
|
4
4
|
createRegularAtom,
|
|
@@ -13,7 +13,7 @@ export type AtomTokenIndex = WritableTokenIndex<AtomToken<unknown>>
|
|
|
13
13
|
|
|
14
14
|
export const attachAtomIndex = (
|
|
15
15
|
store: Store,
|
|
16
|
-
):
|
|
16
|
+
): ReadonlyPureSelectorToken<AtomTokenIndex> => {
|
|
17
17
|
const atomTokenIndexState__INTERNAL = createRegularAtom<AtomTokenIndex>(
|
|
18
18
|
store,
|
|
19
19
|
{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
ReadonlyPureSelectorFamilyToken,
|
|
3
|
+
ReadonlyPureSelectorToken,
|
|
4
4
|
TimelineToken,
|
|
5
5
|
TransactionToken,
|
|
6
6
|
TransactionUpdate,
|
|
@@ -17,16 +17,16 @@ import { attachTransactionLogs } from "./attach-transaction-logs"
|
|
|
17
17
|
import { attachTypeSelectors } from "./attach-type-selectors"
|
|
18
18
|
|
|
19
19
|
export type IntrospectionStates = {
|
|
20
|
-
atomIndex:
|
|
21
|
-
selectorIndex:
|
|
22
|
-
transactionIndex:
|
|
23
|
-
transactionLogSelectors:
|
|
20
|
+
atomIndex: ReadonlyPureSelectorToken<AtomTokenIndex>
|
|
21
|
+
selectorIndex: ReadonlyPureSelectorToken<SelectorTokenIndex>
|
|
22
|
+
transactionIndex: ReadonlyPureSelectorToken<TransactionToken<Func>[]>
|
|
23
|
+
transactionLogSelectors: ReadonlyPureSelectorFamilyToken<
|
|
24
24
|
TransactionUpdate<Func>[],
|
|
25
25
|
string
|
|
26
26
|
>
|
|
27
|
-
timelineIndex:
|
|
28
|
-
timelineSelectors:
|
|
29
|
-
typeSelectors:
|
|
27
|
+
timelineIndex: ReadonlyPureSelectorToken<TimelineToken<any>[]>
|
|
28
|
+
timelineSelectors: ReadonlyPureSelectorFamilyToken<Timeline<any>, string>
|
|
29
|
+
typeSelectors: ReadonlyPureSelectorFamilyToken<string, string>
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export const attachIntrospectionStates = (store: Store): IntrospectionStates => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ReadonlyPureSelectorToken, SelectorToken } from "atom.io"
|
|
2
2
|
import type { Store } from "atom.io/internal"
|
|
3
3
|
import {
|
|
4
4
|
createRegularAtom,
|
|
@@ -13,7 +13,7 @@ export type SelectorTokenIndex = WritableTokenIndex<SelectorToken<unknown>>
|
|
|
13
13
|
|
|
14
14
|
export const attachSelectorIndex = (
|
|
15
15
|
store: Store,
|
|
16
|
-
):
|
|
16
|
+
): ReadonlyPureSelectorToken<SelectorTokenIndex> => {
|
|
17
17
|
const readonlySelectorTokenIndexState__INTERNAL =
|
|
18
18
|
createRegularAtom<SelectorTokenIndex>(
|
|
19
19
|
store,
|
|
@@ -22,7 +22,7 @@ export const attachSelectorIndex = (
|
|
|
22
22
|
key: `🔍 Selector Token Index (Internal)`,
|
|
23
23
|
default: () => {
|
|
24
24
|
const base: SelectorTokenIndex = new Map()
|
|
25
|
-
for (const map of [store.readonlySelectors, store.
|
|
25
|
+
for (const map of [store.readonlySelectors, store.writableSelectors]) {
|
|
26
26
|
for (const [key, val] of map) {
|
|
27
27
|
if (isReservedIntrospectionKey(key)) {
|
|
28
28
|
continue
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ReadonlyPureSelectorFamilyToken } from "atom.io"
|
|
2
2
|
import type { Store, Timeline } from "atom.io/internal"
|
|
3
3
|
import {
|
|
4
4
|
createRegularAtomFamily,
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
|
|
9
9
|
export const attachTimelineFamily = (
|
|
10
10
|
store: Store,
|
|
11
|
-
):
|
|
11
|
+
): ReadonlyPureSelectorFamilyToken<Timeline<any>, string> => {
|
|
12
12
|
const findTimelineLogState__INTERNAL = createRegularAtomFamily<
|
|
13
13
|
Timeline<any>,
|
|
14
14
|
string
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ReadonlyPureSelectorToken, TimelineToken } from "atom.io"
|
|
2
2
|
import type { Store } from "atom.io/internal"
|
|
3
3
|
import { createRegularAtom, createStandaloneSelector } from "atom.io/internal"
|
|
4
4
|
|
|
5
5
|
export const attachTimelineIndex = (
|
|
6
6
|
store: Store,
|
|
7
|
-
):
|
|
7
|
+
): ReadonlyPureSelectorToken<TimelineToken<any>[]> => {
|
|
8
8
|
const timelineTokenIndexState__INTERNAL = createRegularAtom<
|
|
9
9
|
TimelineToken<any>[]
|
|
10
10
|
>(
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ReadonlyPureSelectorToken, TransactionToken } from "atom.io"
|
|
2
2
|
import type { Func, Store } from "atom.io/internal"
|
|
3
3
|
import { createRegularAtom, createStandaloneSelector } from "atom.io/internal"
|
|
4
4
|
|
|
5
5
|
export const attachTransactionIndex = (
|
|
6
6
|
store: Store,
|
|
7
|
-
):
|
|
7
|
+
): ReadonlyPureSelectorToken<TransactionToken<Func>[]> => {
|
|
8
8
|
const transactionTokenIndexState__INTERNAL = createRegularAtom<
|
|
9
9
|
TransactionToken<Func>[]
|
|
10
10
|
>(
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ReadonlyPureSelectorFamilyToken, TransactionUpdate } from "atom.io"
|
|
2
2
|
import type { Func, Store } from "atom.io/internal"
|
|
3
3
|
import { createRegularAtomFamily, createSelectorFamily } from "atom.io/internal"
|
|
4
4
|
|
|
5
5
|
export const attachTransactionLogs = (
|
|
6
6
|
store: Store,
|
|
7
|
-
):
|
|
7
|
+
): ReadonlyPureSelectorFamilyToken<TransactionUpdate<Func>[], string> => {
|
|
8
8
|
const transactionUpdateLogAtoms = createRegularAtomFamily<
|
|
9
9
|
TransactionUpdate<Func>[],
|
|
10
10
|
string
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ReadonlyPureSelectorFamilyToken } from "atom.io"
|
|
2
2
|
import type { Store } from "atom.io/internal"
|
|
3
|
-
import {
|
|
3
|
+
import { createReadonlyPureSelectorFamily } from "atom.io/internal"
|
|
4
4
|
|
|
5
5
|
import { discoverType } from "./refinery"
|
|
6
6
|
|
|
7
7
|
export const attachTypeSelectors = (
|
|
8
8
|
store: Store,
|
|
9
|
-
):
|
|
10
|
-
const typeSelectors =
|
|
9
|
+
): ReadonlyPureSelectorFamilyToken<string, string> => {
|
|
10
|
+
const typeSelectors = createReadonlyPureSelectorFamily<string, string>(store, {
|
|
11
11
|
key: `🔍 State Type`,
|
|
12
12
|
get:
|
|
13
13
|
(key) =>
|
|
@@ -16,7 +16,7 @@ export const attachTypeSelectors = (
|
|
|
16
16
|
try {
|
|
17
17
|
const token =
|
|
18
18
|
store.atoms.get(key) ??
|
|
19
|
-
store.
|
|
19
|
+
store.writableSelectors.get(key) ??
|
|
20
20
|
store.readonlySelectors.get(key)
|
|
21
21
|
if (token === undefined) {
|
|
22
22
|
throw new Error(`Could not find state with key "${key}"`)
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
type AtomToken,
|
|
3
3
|
getState,
|
|
4
4
|
type ReadableToken,
|
|
5
|
-
type
|
|
5
|
+
type ReadonlyPureSelectorToken,
|
|
6
6
|
type SelectorToken,
|
|
7
7
|
} from "atom.io"
|
|
8
8
|
import * as Internal from "atom.io/internal"
|
|
@@ -26,8 +26,8 @@ export class Auditor {
|
|
|
26
26
|
public readonly store: Internal.Store
|
|
27
27
|
public auditorCreatedAt: number = performance.now()
|
|
28
28
|
public statesCreatedAt: Map<string, number> = new Map()
|
|
29
|
-
public readonly atomIndex:
|
|
30
|
-
public readonly selectorIndex:
|
|
29
|
+
public readonly atomIndex: ReadonlyPureSelectorToken<AtomTokenIndex>
|
|
30
|
+
public readonly selectorIndex: ReadonlyPureSelectorToken<SelectorTokenIndex>
|
|
31
31
|
public disposed = false
|
|
32
32
|
|
|
33
33
|
private readonly unsubscribeFromAtomCreation: () => void
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as AtomIO from "atom.io"
|
|
2
2
|
import type { Store, Transceiver } from "atom.io/internal"
|
|
3
|
-
import {
|
|
3
|
+
import { createWritablePureSelectorFamily } from "atom.io/internal"
|
|
4
4
|
|
|
5
5
|
import type { Canonical, Json, JsonInterface } from "."
|
|
6
6
|
|
|
@@ -12,7 +12,7 @@ export function selectJsonFamily<
|
|
|
12
12
|
store: Store,
|
|
13
13
|
atomFamilyToken: AtomIO.MutableAtomFamilyToken<T, J, K>,
|
|
14
14
|
transform: JsonInterface<T, J>,
|
|
15
|
-
): AtomIO.
|
|
15
|
+
): AtomIO.WritablePureSelectorFamilyToken<J, K>
|
|
16
16
|
export function selectJsonFamily<
|
|
17
17
|
T,
|
|
18
18
|
J extends Json.Serializable,
|
|
@@ -21,7 +21,7 @@ export function selectJsonFamily<
|
|
|
21
21
|
store: Store,
|
|
22
22
|
atomFamilyToken: AtomIO.RegularAtomFamilyToken<T, K>,
|
|
23
23
|
transform: JsonInterface<T, J>,
|
|
24
|
-
): AtomIO.
|
|
24
|
+
): AtomIO.WritablePureSelectorFamilyToken<J, K>
|
|
25
25
|
export function selectJsonFamily<
|
|
26
26
|
T,
|
|
27
27
|
J extends Json.Serializable,
|
|
@@ -32,8 +32,8 @@ export function selectJsonFamily<
|
|
|
32
32
|
| AtomIO.MutableAtomFamilyToken<T extends Transceiver<any> ? T : never, J, K>
|
|
33
33
|
| AtomIO.RegularAtomFamilyToken<T, K>,
|
|
34
34
|
transform: JsonInterface<T, J>,
|
|
35
|
-
): AtomIO.
|
|
36
|
-
const jsonFamily =
|
|
35
|
+
): AtomIO.WritablePureSelectorFamilyToken<J, K> {
|
|
36
|
+
const jsonFamily = createWritablePureSelectorFamily<J, K>(
|
|
37
37
|
store,
|
|
38
38
|
{
|
|
39
39
|
key: `${atomFamilyToken.key}:JSON`,
|
package/src/json/select-json.ts
CHANGED
|
@@ -8,7 +8,7 @@ export const selectJson = <T, J extends Json.Serializable>(
|
|
|
8
8
|
atom: AtomIO.AtomToken<T>,
|
|
9
9
|
transform: JsonInterface<T, J>,
|
|
10
10
|
store: Store = IMPLICIT.STORE,
|
|
11
|
-
): AtomIO.
|
|
11
|
+
): AtomIO.WritablePureSelectorToken<J> => {
|
|
12
12
|
return createStandaloneSelector(store, {
|
|
13
13
|
key: `${atom.key}:JSON`,
|
|
14
14
|
get: ({ get }) => transform.toJson(get(atom)),
|
package/src/main/find-state.ts
CHANGED
|
@@ -3,13 +3,13 @@ import type {
|
|
|
3
3
|
MutableAtomToken,
|
|
4
4
|
ReadableFamilyToken,
|
|
5
5
|
ReadableToken,
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
ReadonlyPureSelectorFamilyToken,
|
|
7
|
+
ReadonlyPureSelectorToken,
|
|
8
8
|
RegularAtomFamilyToken,
|
|
9
9
|
RegularAtomToken,
|
|
10
10
|
WritableFamilyToken,
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
WritablePureSelectorFamilyToken,
|
|
12
|
+
WritablePureSelectorToken,
|
|
13
13
|
WritableToken,
|
|
14
14
|
} from "atom.io"
|
|
15
15
|
import type { Transceiver } from "atom.io/internal"
|
|
@@ -54,9 +54,9 @@ export function findState<T, K extends Canonical, Key extends K>(
|
|
|
54
54
|
* @overload Writable Selector
|
|
55
55
|
*/
|
|
56
56
|
export function findState<T, K extends Canonical, Key extends K>(
|
|
57
|
-
token:
|
|
57
|
+
token: WritablePureSelectorFamilyToken<T, K>,
|
|
58
58
|
key: Key,
|
|
59
|
-
):
|
|
59
|
+
): WritablePureSelectorToken<T, K>
|
|
60
60
|
/**
|
|
61
61
|
* @public
|
|
62
62
|
* Finds a state in the store
|
|
@@ -67,9 +67,9 @@ export function findState<T, K extends Canonical, Key extends K>(
|
|
|
67
67
|
* @overload Readonly Selector
|
|
68
68
|
*/
|
|
69
69
|
export function findState<T, K extends Canonical, Key extends K>(
|
|
70
|
-
token:
|
|
70
|
+
token: ReadonlyPureSelectorFamilyToken<T, K>,
|
|
71
71
|
key: Key,
|
|
72
|
-
):
|
|
72
|
+
): ReadonlyPureSelectorToken<T, K>
|
|
73
73
|
/**
|
|
74
74
|
* @public
|
|
75
75
|
* Finds a state in the store
|
package/src/main/index.ts
CHANGED
|
@@ -82,31 +82,76 @@ export type AtomToken<T, K extends Canonical = any> =
|
|
|
82
82
|
| RegularAtomToken<T, K>
|
|
83
83
|
|
|
84
84
|
/** @public */
|
|
85
|
-
export type
|
|
85
|
+
export type WritablePureSelectorToken<T, K extends Canonical = any> = {
|
|
86
86
|
/** The unique identifier of the selector. */
|
|
87
87
|
key: string
|
|
88
88
|
/** Discriminator. */
|
|
89
|
-
type: `
|
|
89
|
+
type: `writable_pure_selector`
|
|
90
90
|
/** Present if the selector belongs to a family. */
|
|
91
91
|
family?: FamilyMetadata<K>
|
|
92
92
|
/** Never present. This is a marker that preserves the type of the selector's value. */
|
|
93
93
|
__T?: T
|
|
94
94
|
}
|
|
95
95
|
/** @public */
|
|
96
|
-
export type
|
|
96
|
+
export type WritableHeldSelectorToken<T, K extends Canonical = any> = {
|
|
97
97
|
/** The unique identifier of the selector. */
|
|
98
98
|
key: string
|
|
99
99
|
/** Discriminator. */
|
|
100
|
-
type: `
|
|
100
|
+
type: `writable_held_selector`
|
|
101
101
|
/** Present if the selector belongs to a family. */
|
|
102
102
|
family?: FamilyMetadata<K>
|
|
103
103
|
/** Never present. This is a marker that preserves the type of the selector's value. */
|
|
104
104
|
__T?: T
|
|
105
105
|
}
|
|
106
|
+
/** @public */
|
|
107
|
+
export type ReadonlyPureSelectorToken<T, K extends Canonical = any> = {
|
|
108
|
+
/** The unique identifier of the selector. */
|
|
109
|
+
key: string
|
|
110
|
+
/** Discriminator. */
|
|
111
|
+
type: `readonly_pure_selector`
|
|
112
|
+
/** Present if the selector belongs to a family. */
|
|
113
|
+
family?: FamilyMetadata<K>
|
|
114
|
+
/** Never present. This is a marker that preserves the type of the selector's value. */
|
|
115
|
+
__T?: T
|
|
116
|
+
}
|
|
117
|
+
/** @public */
|
|
118
|
+
export type ReadonlyHeldSelectorToken<T, K extends Canonical = any> = {
|
|
119
|
+
/** The unique identifier of the selector. */
|
|
120
|
+
key: string
|
|
121
|
+
/** Discriminator. */
|
|
122
|
+
type: `readonly_held_selector`
|
|
123
|
+
/** Present if the selector belongs to a family. */
|
|
124
|
+
family?: FamilyMetadata<K>
|
|
125
|
+
/** Never present. This is a marker that preserves the type of the selector's value. */
|
|
126
|
+
__T?: T
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** @public */
|
|
130
|
+
export type PureSelectorToken<T, K extends Canonical = any> =
|
|
131
|
+
| ReadonlyPureSelectorToken<T, K>
|
|
132
|
+
| WritablePureSelectorToken<T, K>
|
|
133
|
+
|
|
134
|
+
/** @public */
|
|
135
|
+
export type HeldSelectorToken<T, K extends Canonical = any> =
|
|
136
|
+
| ReadonlyHeldSelectorToken<T, K>
|
|
137
|
+
| WritableHeldSelectorToken<T, K>
|
|
138
|
+
|
|
139
|
+
/** @public */
|
|
140
|
+
export type ReadonlySelectorToken<T, K extends Canonical = any> =
|
|
141
|
+
| ReadonlyHeldSelectorToken<T, K>
|
|
142
|
+
| ReadonlyPureSelectorToken<T, K>
|
|
143
|
+
|
|
144
|
+
/** @public */
|
|
145
|
+
export type WritableSelectorToken<T, K extends Canonical = any> =
|
|
146
|
+
| WritableHeldSelectorToken<T, K>
|
|
147
|
+
| WritablePureSelectorToken<T, K>
|
|
148
|
+
|
|
106
149
|
/** @public */
|
|
107
150
|
export type SelectorToken<T, K extends Canonical = any> =
|
|
108
|
-
|
|
|
109
|
-
|
|
|
151
|
+
| ReadonlyHeldSelectorToken<T, K>
|
|
152
|
+
| ReadonlyPureSelectorToken<T, K>
|
|
153
|
+
| WritableHeldSelectorToken<T, K>
|
|
154
|
+
| WritablePureSelectorToken<T, K>
|
|
110
155
|
|
|
111
156
|
/**
|
|
112
157
|
* @public
|
package/src/main/join.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MutableAtomFamilyToken,
|
|
1
|
+
import type { MutableAtomFamilyToken, ReadonlyPureSelectorToken } from "atom.io"
|
|
2
2
|
import type {
|
|
3
3
|
Junction,
|
|
4
4
|
JunctionEntriesBase,
|
|
@@ -105,23 +105,23 @@ export type JoinStates<
|
|
|
105
105
|
> = Cardinality extends `1:1`
|
|
106
106
|
? (Content extends Json.Object
|
|
107
107
|
? {
|
|
108
|
-
readonly [A in ASide as `${A}EntryOf${Capitalize<BSide>}`]:
|
|
108
|
+
readonly [A in ASide as `${A}EntryOf${Capitalize<BSide>}`]: ReadonlyPureSelectorToken<
|
|
109
109
|
[AType, Content] | null,
|
|
110
110
|
BType
|
|
111
111
|
>
|
|
112
112
|
} & {
|
|
113
|
-
readonly [B in BSide as `${B}EntryOf${Capitalize<ASide>}`]:
|
|
113
|
+
readonly [B in BSide as `${B}EntryOf${Capitalize<ASide>}`]: ReadonlyPureSelectorToken<
|
|
114
114
|
[BType, Content] | null,
|
|
115
115
|
AType
|
|
116
116
|
>
|
|
117
117
|
}
|
|
118
118
|
: {}) & {
|
|
119
|
-
readonly [A in ASide as `${A}KeyOf${Capitalize<BSide>}`]:
|
|
119
|
+
readonly [A in ASide as `${A}KeyOf${Capitalize<BSide>}`]: ReadonlyPureSelectorToken<
|
|
120
120
|
AType | null,
|
|
121
121
|
BType
|
|
122
122
|
>
|
|
123
123
|
} & {
|
|
124
|
-
readonly [B in BSide as `${B}KeyOf${Capitalize<ASide>}`]:
|
|
124
|
+
readonly [B in BSide as `${B}KeyOf${Capitalize<ASide>}`]: ReadonlyPureSelectorToken<
|
|
125
125
|
BType | null,
|
|
126
126
|
AType
|
|
127
127
|
>
|
|
@@ -129,23 +129,23 @@ export type JoinStates<
|
|
|
129
129
|
: Cardinality extends `1:n`
|
|
130
130
|
? (Content extends Json.Object
|
|
131
131
|
? {
|
|
132
|
-
readonly [A in ASide as `${A}EntryOf${Capitalize<BSide>}`]:
|
|
132
|
+
readonly [A in ASide as `${A}EntryOf${Capitalize<BSide>}`]: ReadonlyPureSelectorToken<
|
|
133
133
|
[AType, Content] | null,
|
|
134
134
|
BType
|
|
135
135
|
>
|
|
136
136
|
} & {
|
|
137
|
-
readonly [B in BSide as `${B}EntriesOf${Capitalize<ASide>}`]:
|
|
137
|
+
readonly [B in BSide as `${B}EntriesOf${Capitalize<ASide>}`]: ReadonlyPureSelectorToken<
|
|
138
138
|
[BType, Content][],
|
|
139
139
|
AType
|
|
140
140
|
>
|
|
141
141
|
}
|
|
142
142
|
: {}) & {
|
|
143
|
-
readonly [A in ASide as `${A}KeyOf${Capitalize<BSide>}`]:
|
|
143
|
+
readonly [A in ASide as `${A}KeyOf${Capitalize<BSide>}`]: ReadonlyPureSelectorToken<
|
|
144
144
|
AType | null,
|
|
145
145
|
BType
|
|
146
146
|
>
|
|
147
147
|
} & {
|
|
148
|
-
readonly [B in BSide as `${B}KeysOf${Capitalize<ASide>}`]:
|
|
148
|
+
readonly [B in BSide as `${B}KeysOf${Capitalize<ASide>}`]: ReadonlyPureSelectorToken<
|
|
149
149
|
BType[],
|
|
150
150
|
AType
|
|
151
151
|
>
|
|
@@ -153,23 +153,23 @@ export type JoinStates<
|
|
|
153
153
|
: Cardinality extends `n:n`
|
|
154
154
|
? (Content extends Json.Object
|
|
155
155
|
? {
|
|
156
|
-
readonly [A in ASide as `${A}EntriesOf${Capitalize<BSide>}`]:
|
|
156
|
+
readonly [A in ASide as `${A}EntriesOf${Capitalize<BSide>}`]: ReadonlyPureSelectorToken<
|
|
157
157
|
[AType, Content][],
|
|
158
158
|
BType
|
|
159
159
|
>
|
|
160
160
|
} & {
|
|
161
|
-
readonly [B in BSide as `${B}EntriesOf${Capitalize<ASide>}`]:
|
|
161
|
+
readonly [B in BSide as `${B}EntriesOf${Capitalize<ASide>}`]: ReadonlyPureSelectorToken<
|
|
162
162
|
[BType, Content][],
|
|
163
163
|
AType
|
|
164
164
|
>
|
|
165
165
|
}
|
|
166
166
|
: {}) & {
|
|
167
|
-
readonly [A in ASide as `${A}KeysOf${Capitalize<BSide>}`]:
|
|
167
|
+
readonly [A in ASide as `${A}KeysOf${Capitalize<BSide>}`]: ReadonlyPureSelectorToken<
|
|
168
168
|
AType[],
|
|
169
169
|
BType
|
|
170
170
|
>
|
|
171
171
|
} & {
|
|
172
|
-
readonly [B in BSide as `${B}KeysOf${Capitalize<ASide>}`]:
|
|
172
|
+
readonly [B in BSide as `${B}KeysOf${Capitalize<ASide>}`]: ReadonlyPureSelectorToken<
|
|
173
173
|
BType[],
|
|
174
174
|
AType
|
|
175
175
|
>
|