atom.io 0.6.4 → 0.6.6
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 +32 -78
- package/dist/index.d.mts +4 -35
- package/dist/index.d.ts +4 -35
- package/dist/index.js +17 -129
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -129
- package/dist/index.mjs.map +1 -1
- package/introspection/dist/index.js +312 -0
- package/introspection/dist/index.js.map +1 -0
- package/introspection/dist/index.mjs +289 -0
- package/introspection/dist/index.mjs.map +1 -0
- package/introspection/package.json +15 -0
- package/package.json +17 -8
- package/react-devtools/dist/index.css +22 -5
- package/react-devtools/dist/index.css.map +1 -1
- package/react-devtools/dist/index.d.mts +347 -8
- package/react-devtools/dist/index.d.ts +347 -8
- package/react-devtools/dist/index.js +2722 -674
- package/react-devtools/dist/index.js.map +1 -1
- package/react-devtools/dist/index.mjs +2669 -630
- package/react-devtools/dist/index.mjs.map +1 -1
- package/src/internal/index.ts +0 -1
- package/src/internal/operation.ts +1 -0
- package/src/internal/store.ts +3 -2
- package/src/internal/time-travel-internal.ts +2 -0
- package/src/internal/timeline/add-atom-to-timeline.ts +11 -12
- package/src/internal/timeline-internal.ts +5 -1
- package/src/introspection/attach-atom-index.ts +73 -0
- package/src/introspection/attach-introspection-states.ts +42 -0
- package/src/introspection/attach-selector-index.ts +77 -0
- package/src/introspection/attach-timeline-family.ts +49 -0
- package/src/introspection/attach-timeline-index.ts +36 -0
- package/src/introspection/attach-transaction-index.ts +38 -0
- package/src/introspection/attach-transaction-logs.ts +40 -0
- package/src/introspection/index.ts +20 -0
- package/src/react-devtools/AtomIODevtools.tsx +97 -96
- package/src/react-devtools/Button.tsx +24 -0
- package/src/react-devtools/StateEditor.tsx +14 -16
- package/src/react-devtools/StateIndex.tsx +153 -0
- package/src/react-devtools/TimelineIndex.tsx +92 -0
- package/src/react-devtools/TransactionIndex.tsx +70 -0
- package/src/react-devtools/Updates.tsx +145 -0
- package/src/react-devtools/devtools.scss +196 -15
- package/src/react-devtools/index.ts +71 -0
- package/src/react-explorer/AtomIOExplorer.tsx +0 -1
- package/src/react-explorer/explorer-effects.ts +3 -3
- package/src/react-explorer/explorer-states.ts +1 -1
- package/src/react-explorer/space-states.ts +6 -4
- package/src/react-explorer/view-states.ts +0 -2
- package/realtime-testing/dist/index.d.mts +0 -49
- package/realtime-testing/dist/index.d.ts +0 -49
- package/realtime-testing/dist/index.js +0 -165
- package/realtime-testing/dist/index.js.map +0 -1
- package/realtime-testing/dist/index.mjs +0 -129
- package/realtime-testing/dist/index.mjs.map +0 -1
- package/src/internal/meta/attach-meta.ts +0 -17
- package/src/internal/meta/index.ts +0 -4
- package/src/internal/meta/meta-state.ts +0 -135
- package/src/internal/meta/meta-timelines.ts +0 -1
- package/src/internal/meta/meta-transactions.ts +0 -1
- package/src/react-devtools/TokenList.tsx +0 -61
package/src/internal/index.ts
CHANGED
|
@@ -42,6 +42,7 @@ export const closeOperation = (store: Store): void => {
|
|
|
42
42
|
const core = target(store)
|
|
43
43
|
core.operation = { open: false }
|
|
44
44
|
store.config.logger?.info(`🔴 operation done`)
|
|
45
|
+
store.subject.operationStatus.next(core.operation)
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
export const isDone = (key: string, store: Store = IMPLICIT.STORE): boolean => {
|
package/src/internal/store.ts
CHANGED
|
@@ -56,8 +56,9 @@ export interface Store {
|
|
|
56
56
|
selectorCreation: Subject<
|
|
57
57
|
ReadonlySelectorToken<unknown> | SelectorToken<unknown>
|
|
58
58
|
>
|
|
59
|
-
transactionCreation: Subject<TransactionToken
|
|
59
|
+
transactionCreation: Subject<TransactionToken<ƒn>>
|
|
60
60
|
timelineCreation: Subject<TimelineToken>
|
|
61
|
+
operationStatus: Subject<OperationProgress>
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
operation: OperationProgress
|
|
@@ -96,7 +97,7 @@ export const createStore = (name: string, store: Store | null = null): Store =>
|
|
|
96
97
|
selectorCreation: new Subject(),
|
|
97
98
|
transactionCreation: new Subject(),
|
|
98
99
|
timelineCreation: new Subject(),
|
|
99
|
-
|
|
100
|
+
operationStatus: new Subject(),
|
|
100
101
|
},
|
|
101
102
|
|
|
102
103
|
operation: {
|
|
@@ -39,6 +39,7 @@ export const redo__INTERNAL = (
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
++timelineData.at
|
|
42
|
+
timelineData.subject.next(`redo`)
|
|
42
43
|
timelineData.timeTraveling = false
|
|
43
44
|
store.config.logger?.info(
|
|
44
45
|
`⏹️ "${token.key}" is now at ${timelineData.at} / ${timelineData.history.length}`,
|
|
@@ -82,6 +83,7 @@ export const undo__INTERNAL = (
|
|
|
82
83
|
break
|
|
83
84
|
}
|
|
84
85
|
}
|
|
86
|
+
timelineData.subject.next(`undo`)
|
|
85
87
|
timelineData.timeTraveling = false
|
|
86
88
|
store.config.logger?.info(
|
|
87
89
|
`⏹️ "${token.key}" is now at ${timelineData.at} / ${timelineData.history.length}`,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { IMPLICIT, withdraw } from ".."
|
|
2
2
|
import type {
|
|
3
|
-
TimelineSelectorUpdate,
|
|
4
3
|
Timeline,
|
|
5
4
|
Store,
|
|
6
5
|
TimelineTransactionUpdate,
|
|
@@ -58,9 +57,6 @@ export const addAtomToTimeline = (
|
|
|
58
57
|
`Timeline "${tl.key}" has a selectorTime, but no history. This is most likely a bug in AtomIO.`,
|
|
59
58
|
)
|
|
60
59
|
}
|
|
61
|
-
if (mostRecentUpdate.type === `selector_update`) {
|
|
62
|
-
tl.subject.next(mostRecentUpdate)
|
|
63
|
-
}
|
|
64
60
|
}
|
|
65
61
|
if (
|
|
66
62
|
currentTransactionKey &&
|
|
@@ -83,6 +79,7 @@ export const addAtomToTimeline = (
|
|
|
83
79
|
}
|
|
84
80
|
tl.transactionKey = currentTransactionKey
|
|
85
81
|
const subscription = currentTransaction.subject.subscribe((update) => {
|
|
82
|
+
subscription.unsubscribe()
|
|
86
83
|
if (tl.timeTraveling === false && currentTransactionTime) {
|
|
87
84
|
if (tl.at !== tl.history.length) {
|
|
88
85
|
tl.history.splice(tl.at)
|
|
@@ -96,10 +93,9 @@ export const addAtomToTimeline = (
|
|
|
96
93
|
),
|
|
97
94
|
}
|
|
98
95
|
tl.history.push(timelineTransactionUpdate)
|
|
96
|
+
tl.at = tl.history.length
|
|
99
97
|
tl.subject.next(timelineTransactionUpdate)
|
|
100
98
|
}
|
|
101
|
-
tl.at = tl.history.length
|
|
102
|
-
subscription.unsubscribe()
|
|
103
99
|
tl.transactionKey = null
|
|
104
100
|
store.config.logger?.info(
|
|
105
101
|
`⌛ timeline "${tl.key}" got a transaction_update "${update.key}"`,
|
|
@@ -107,14 +103,16 @@ export const addAtomToTimeline = (
|
|
|
107
103
|
})
|
|
108
104
|
}
|
|
109
105
|
} else if (currentSelectorKey && currentSelectorTime) {
|
|
106
|
+
let latestUpdate: TimelineUpdate | undefined = tl.history.at(-1)
|
|
107
|
+
|
|
110
108
|
if (currentSelectorTime !== tl.selectorTime) {
|
|
111
|
-
|
|
109
|
+
latestUpdate = {
|
|
112
110
|
type: `selector_update`,
|
|
113
111
|
timestamp: currentSelectorTime,
|
|
114
112
|
key: currentSelectorKey,
|
|
115
113
|
atomUpdates: [],
|
|
116
114
|
}
|
|
117
|
-
|
|
115
|
+
latestUpdate.atomUpdates.push({
|
|
118
116
|
key: atom.key,
|
|
119
117
|
type: `atom_update`,
|
|
120
118
|
...update,
|
|
@@ -122,16 +120,16 @@ export const addAtomToTimeline = (
|
|
|
122
120
|
if (tl.at !== tl.history.length) {
|
|
123
121
|
tl.history.splice(tl.at)
|
|
124
122
|
}
|
|
125
|
-
tl.history.push(
|
|
123
|
+
tl.history.push(latestUpdate)
|
|
126
124
|
|
|
127
125
|
store.config.logger?.info(
|
|
128
126
|
`⌛ timeline "${tl.key}" got a selector_update "${currentSelectorKey}" with`,
|
|
129
|
-
|
|
127
|
+
latestUpdate.atomUpdates.map((atomUpdate) => atomUpdate.key),
|
|
130
128
|
)
|
|
129
|
+
|
|
131
130
|
tl.at = tl.history.length
|
|
132
131
|
tl.selectorTime = currentSelectorTime
|
|
133
132
|
} else {
|
|
134
|
-
const latestUpdate = tl.history.at(-1)
|
|
135
133
|
if (latestUpdate?.type === `selector_update`) {
|
|
136
134
|
latestUpdate.atomUpdates.push({
|
|
137
135
|
key: atom.key,
|
|
@@ -144,6 +142,7 @@ export const addAtomToTimeline = (
|
|
|
144
142
|
)
|
|
145
143
|
}
|
|
146
144
|
}
|
|
145
|
+
if (latestUpdate) tl.subject.next(latestUpdate)
|
|
147
146
|
} else {
|
|
148
147
|
const timestamp = Date.now()
|
|
149
148
|
tl.selectorTime = null
|
|
@@ -160,7 +159,7 @@ export const addAtomToTimeline = (
|
|
|
160
159
|
tl.history.push(atomUpdate)
|
|
161
160
|
tl.subject.next(atomUpdate)
|
|
162
161
|
store.config.logger?.info(
|
|
163
|
-
`⌛ timeline "${tl.key}" got
|
|
162
|
+
`⌛ timeline "${tl.key}" got an atom_update to "${atom.key}"`,
|
|
164
163
|
)
|
|
165
164
|
tl.at = tl.history.length
|
|
166
165
|
}
|
|
@@ -39,7 +39,11 @@ export type Timeline = {
|
|
|
39
39
|
transactionKey: string | null
|
|
40
40
|
install: (store: Store) => void
|
|
41
41
|
subject: Subject<
|
|
42
|
-
|
|
42
|
+
| TimelineAtomUpdate
|
|
43
|
+
| TimelineSelectorUpdate
|
|
44
|
+
| TimelineTransactionUpdate
|
|
45
|
+
| `redo`
|
|
46
|
+
| `undo`
|
|
43
47
|
>
|
|
44
48
|
}
|
|
45
49
|
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { AtomToken, ReadonlySelectorToken } from "atom.io"
|
|
2
|
+
import { __INTERNAL__ } from "atom.io"
|
|
3
|
+
|
|
4
|
+
import type { StateTokenIndex } from "."
|
|
5
|
+
|
|
6
|
+
export type AtomTokenIndex = StateTokenIndex<AtomToken<unknown>>
|
|
7
|
+
|
|
8
|
+
export const attachAtomIndex = (
|
|
9
|
+
store: __INTERNAL__.Store = __INTERNAL__.IMPLICIT.STORE,
|
|
10
|
+
): ReadonlySelectorToken<AtomTokenIndex> => {
|
|
11
|
+
const atomTokenIndexState__INTERNAL =
|
|
12
|
+
__INTERNAL__.atom__INTERNAL<AtomTokenIndex>(
|
|
13
|
+
{
|
|
14
|
+
key: `👁🗨 Atom Token Index (Internal)`,
|
|
15
|
+
default: () =>
|
|
16
|
+
[...store.atoms]
|
|
17
|
+
.filter(([key]) => !key.includes(`👁🗨`))
|
|
18
|
+
.reduce<AtomTokenIndex>((acc, [key]) => {
|
|
19
|
+
acc[key] = { key, type: `atom` }
|
|
20
|
+
return acc
|
|
21
|
+
}, {}),
|
|
22
|
+
effects: [
|
|
23
|
+
({ setSelf }) => {
|
|
24
|
+
store.subject.atomCreation.subscribe((atomToken) => {
|
|
25
|
+
if (store.operation.open) {
|
|
26
|
+
return
|
|
27
|
+
}
|
|
28
|
+
if (atomToken.key.includes(`👁🗨`)) {
|
|
29
|
+
return
|
|
30
|
+
}
|
|
31
|
+
setSelf((state) => {
|
|
32
|
+
const { key, family } = atomToken
|
|
33
|
+
if (family) {
|
|
34
|
+
const { key: familyKey, subKey } = family
|
|
35
|
+
const current = state[familyKey]
|
|
36
|
+
if (current === undefined || `familyMembers` in current) {
|
|
37
|
+
const familyKeyState = current || {
|
|
38
|
+
key: familyKey,
|
|
39
|
+
familyMembers: {},
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
...state,
|
|
43
|
+
[familyKey]: {
|
|
44
|
+
...familyKeyState,
|
|
45
|
+
familyMembers: {
|
|
46
|
+
...familyKeyState.familyMembers,
|
|
47
|
+
[subKey]: atomToken,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
...state,
|
|
55
|
+
[key]: atomToken,
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
})
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
},
|
|
62
|
+
undefined,
|
|
63
|
+
store,
|
|
64
|
+
)
|
|
65
|
+
return __INTERNAL__.selector__INTERNAL(
|
|
66
|
+
{
|
|
67
|
+
key: `👁🗨 Atom Token Index`,
|
|
68
|
+
get: ({ get }) => get(atomTokenIndexState__INTERNAL),
|
|
69
|
+
},
|
|
70
|
+
undefined,
|
|
71
|
+
store,
|
|
72
|
+
)
|
|
73
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { __INTERNAL__ } from "atom.io"
|
|
2
|
+
import type {
|
|
3
|
+
ReadonlySelectorFamily,
|
|
4
|
+
ReadonlySelectorToken,
|
|
5
|
+
TimelineToken,
|
|
6
|
+
TimelineUpdate,
|
|
7
|
+
TransactionToken,
|
|
8
|
+
TransactionUpdate,
|
|
9
|
+
} from "atom.io"
|
|
10
|
+
|
|
11
|
+
import type { ƒn } from "~/packages/anvl/src/function"
|
|
12
|
+
|
|
13
|
+
import { attachAtomIndex, type AtomTokenIndex } from "./attach-atom-index"
|
|
14
|
+
import {
|
|
15
|
+
attachSelectorIndex,
|
|
16
|
+
type SelectorTokenIndex,
|
|
17
|
+
} from "./attach-selector-index"
|
|
18
|
+
import { attachTimelineFamily } from "./attach-timeline-family"
|
|
19
|
+
import { attachTimelineIndex } from "./attach-timeline-index"
|
|
20
|
+
import { attachTransactionIndex } from "./attach-transaction-index"
|
|
21
|
+
import { attachTransactionLogs } from "./attach-transaction-logs"
|
|
22
|
+
import type { Timeline } from "../internal"
|
|
23
|
+
|
|
24
|
+
export const attachIntrospectionStates = (
|
|
25
|
+
store: __INTERNAL__.Store = __INTERNAL__.IMPLICIT.STORE,
|
|
26
|
+
): {
|
|
27
|
+
atomIndex: ReadonlySelectorToken<AtomTokenIndex>
|
|
28
|
+
selectorIndex: ReadonlySelectorToken<SelectorTokenIndex>
|
|
29
|
+
transactionIndex: ReadonlySelectorToken<TransactionToken<ƒn>[]>
|
|
30
|
+
findTransactionLogState: ReadonlySelectorFamily<TransactionUpdate<ƒn>[]>
|
|
31
|
+
timelineIndex: ReadonlySelectorToken<TimelineToken[]>
|
|
32
|
+
findTimelineState: ReadonlySelectorFamily<Timeline>
|
|
33
|
+
} => {
|
|
34
|
+
return {
|
|
35
|
+
atomIndex: attachAtomIndex(store),
|
|
36
|
+
selectorIndex: attachSelectorIndex(store),
|
|
37
|
+
transactionIndex: attachTransactionIndex(store),
|
|
38
|
+
findTransactionLogState: attachTransactionLogs(store),
|
|
39
|
+
timelineIndex: attachTimelineIndex(store),
|
|
40
|
+
findTimelineState: attachTimelineFamily(store),
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { __INTERNAL__ } from "atom.io"
|
|
2
|
+
import type { ReadonlySelectorToken, SelectorToken } from "atom.io"
|
|
3
|
+
|
|
4
|
+
import type { StateTokenIndex } from "."
|
|
5
|
+
|
|
6
|
+
export type SelectorTokenIndex = StateTokenIndex<
|
|
7
|
+
ReadonlySelectorToken<unknown> | SelectorToken<unknown>
|
|
8
|
+
>
|
|
9
|
+
|
|
10
|
+
export const attachSelectorIndex = (
|
|
11
|
+
store: __INTERNAL__.Store = __INTERNAL__.IMPLICIT.STORE,
|
|
12
|
+
): ReadonlySelectorToken<SelectorTokenIndex> => {
|
|
13
|
+
const readonlySelectorTokenIndexState__INTERNAL =
|
|
14
|
+
__INTERNAL__.atom__INTERNAL<SelectorTokenIndex>(
|
|
15
|
+
{
|
|
16
|
+
key: `👁🗨 Selector Token Index (Internal)`,
|
|
17
|
+
default: () =>
|
|
18
|
+
Object.assign(
|
|
19
|
+
[...store.readonlySelectors]
|
|
20
|
+
.filter(([key]) => !key.includes(`👁🗨`))
|
|
21
|
+
.reduce<SelectorTokenIndex>((acc, [key]) => {
|
|
22
|
+
acc[key] = { key, type: `readonly_selector` }
|
|
23
|
+
return acc
|
|
24
|
+
}, {}),
|
|
25
|
+
[...store.selectors].reduce<SelectorTokenIndex>((acc, [key]) => {
|
|
26
|
+
acc[key] = { key, type: `selector` }
|
|
27
|
+
return acc
|
|
28
|
+
}, {}),
|
|
29
|
+
),
|
|
30
|
+
effects: [
|
|
31
|
+
({ setSelf }) => {
|
|
32
|
+
store.subject.selectorCreation.subscribe((selectorToken) => {
|
|
33
|
+
if (store.operation.open) {
|
|
34
|
+
return
|
|
35
|
+
}
|
|
36
|
+
if (selectorToken.key.includes(`👁🗨`)) {
|
|
37
|
+
return
|
|
38
|
+
}
|
|
39
|
+
setSelf((state) => {
|
|
40
|
+
const { key, family } = selectorToken
|
|
41
|
+
if (family) {
|
|
42
|
+
const { key: familyKey, subKey } = family
|
|
43
|
+
const current = state[familyKey]
|
|
44
|
+
if (current === undefined || `familyMembers` in current) {
|
|
45
|
+
const familyKeyState = current || {
|
|
46
|
+
key: familyKey,
|
|
47
|
+
familyMembers: {},
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
...state,
|
|
51
|
+
[familyKey]: {
|
|
52
|
+
...familyKeyState,
|
|
53
|
+
familyMembers: {
|
|
54
|
+
...familyKeyState.familyMembers,
|
|
55
|
+
[subKey]: selectorToken,
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
...state,
|
|
63
|
+
[key]: selectorToken,
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
})
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
},
|
|
70
|
+
undefined,
|
|
71
|
+
store,
|
|
72
|
+
)
|
|
73
|
+
return __INTERNAL__.selector__INTERNAL({
|
|
74
|
+
key: `👁🗨 Selector Token Index`,
|
|
75
|
+
get: ({ get }) => get(readonlySelectorTokenIndexState__INTERNAL),
|
|
76
|
+
})
|
|
77
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { ReadonlySelectorFamily, Store } from "atom.io"
|
|
2
|
+
import { __INTERNAL__ } from "atom.io"
|
|
3
|
+
|
|
4
|
+
import type { Timeline } from "../internal"
|
|
5
|
+
|
|
6
|
+
export const attachTimelineFamily = (
|
|
7
|
+
store: Store = __INTERNAL__.IMPLICIT.STORE,
|
|
8
|
+
): ReadonlySelectorFamily<Timeline> => {
|
|
9
|
+
const findTimelineLogState__INTERNAL = __INTERNAL__.atomFamily__INTERNAL<
|
|
10
|
+
Timeline,
|
|
11
|
+
string
|
|
12
|
+
>(
|
|
13
|
+
{
|
|
14
|
+
key: `👁🗨 Timeline Update Log (Internal)`,
|
|
15
|
+
default: (key) => store.timelines.get(key),
|
|
16
|
+
effects: (key) => [
|
|
17
|
+
({ setSelf }) => {
|
|
18
|
+
const tl = store.timelines.get(key)
|
|
19
|
+
tl.subject.subscribe((_) => {
|
|
20
|
+
if (store.operation.open === true) {
|
|
21
|
+
const subscription = store.subject.operationStatus.subscribe(
|
|
22
|
+
(operationStatus) => {
|
|
23
|
+
if (operationStatus.open === false) {
|
|
24
|
+
subscription.unsubscribe()
|
|
25
|
+
setSelf({ ...tl })
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
)
|
|
29
|
+
} else {
|
|
30
|
+
setSelf({ ...tl })
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
store,
|
|
37
|
+
)
|
|
38
|
+
const findTimelineLogState = __INTERNAL__.selectorFamily__INTERNAL<
|
|
39
|
+
Timeline,
|
|
40
|
+
string
|
|
41
|
+
>(
|
|
42
|
+
{
|
|
43
|
+
key: `👁🗨 Timeline Update Log`,
|
|
44
|
+
get: (key) => ({ get }) => get(findTimelineLogState__INTERNAL(key)),
|
|
45
|
+
},
|
|
46
|
+
store,
|
|
47
|
+
)
|
|
48
|
+
return findTimelineLogState
|
|
49
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { ReadonlySelectorToken, Store, TimelineToken } from "atom.io"
|
|
2
|
+
import { __INTERNAL__ } from "atom.io"
|
|
3
|
+
|
|
4
|
+
export const attachTimelineIndex = (
|
|
5
|
+
store: Store = __INTERNAL__.IMPLICIT.STORE,
|
|
6
|
+
): ReadonlySelectorToken<TimelineToken[]> => {
|
|
7
|
+
const timelineTokenIndexState__INTERNAL = __INTERNAL__.atom__INTERNAL<
|
|
8
|
+
TimelineToken[]
|
|
9
|
+
>(
|
|
10
|
+
{
|
|
11
|
+
key: `👁🗨 Timeline Token Index (Internal)`,
|
|
12
|
+
default: () =>
|
|
13
|
+
[...store.timelines].map(([key]) => {
|
|
14
|
+
return { key, type: `timeline` }
|
|
15
|
+
}),
|
|
16
|
+
effects: [
|
|
17
|
+
({ setSelf }) => {
|
|
18
|
+
store.subject.timelineCreation.subscribe((timelineToken) => {
|
|
19
|
+
setSelf((state) => [...state, timelineToken])
|
|
20
|
+
})
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
undefined,
|
|
25
|
+
store,
|
|
26
|
+
)
|
|
27
|
+
const timelineTokenIndex = __INTERNAL__.selector__INTERNAL(
|
|
28
|
+
{
|
|
29
|
+
key: `👁🗨 Timeline Token Index`,
|
|
30
|
+
get: ({ get }) => get(timelineTokenIndexState__INTERNAL),
|
|
31
|
+
},
|
|
32
|
+
undefined,
|
|
33
|
+
store,
|
|
34
|
+
)
|
|
35
|
+
return timelineTokenIndex
|
|
36
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ReadonlySelectorToken, TransactionToken } from "atom.io"
|
|
2
|
+
import { __INTERNAL__ } from "atom.io"
|
|
3
|
+
|
|
4
|
+
import type { ƒn } from "~/packages/anvl/src/function"
|
|
5
|
+
|
|
6
|
+
export const attachTransactionIndex = (
|
|
7
|
+
store: __INTERNAL__.Store = __INTERNAL__.IMPLICIT.STORE,
|
|
8
|
+
): ReadonlySelectorToken<TransactionToken<ƒn>[]> => {
|
|
9
|
+
const transactionTokenIndexState__INTERNAL = __INTERNAL__.atom__INTERNAL<
|
|
10
|
+
TransactionToken<ƒn>[]
|
|
11
|
+
>(
|
|
12
|
+
{
|
|
13
|
+
key: `👁🗨 Transaction Token Index (Internal)`,
|
|
14
|
+
default: () =>
|
|
15
|
+
[...store.transactions].map(([key]) => {
|
|
16
|
+
return { key, type: `transaction` }
|
|
17
|
+
}),
|
|
18
|
+
effects: [
|
|
19
|
+
({ setSelf }) => {
|
|
20
|
+
store.subject.transactionCreation.subscribe((transactionToken) => {
|
|
21
|
+
setSelf((state) => [...state, transactionToken])
|
|
22
|
+
})
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
undefined,
|
|
27
|
+
store,
|
|
28
|
+
)
|
|
29
|
+
const transactionTokenIndex = __INTERNAL__.selector__INTERNAL(
|
|
30
|
+
{
|
|
31
|
+
key: `👁🗨 Transaction Token Index`,
|
|
32
|
+
get: ({ get }) => get(transactionTokenIndexState__INTERNAL),
|
|
33
|
+
},
|
|
34
|
+
undefined,
|
|
35
|
+
store,
|
|
36
|
+
)
|
|
37
|
+
return transactionTokenIndex
|
|
38
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ReadonlySelectorFamily, TransactionUpdate } from "atom.io"
|
|
2
|
+
import { __INTERNAL__ } from "atom.io"
|
|
3
|
+
|
|
4
|
+
import type { ƒn } from "~/packages/anvl/src/function"
|
|
5
|
+
|
|
6
|
+
export const attachTransactionLogs = (
|
|
7
|
+
store: __INTERNAL__.Store = __INTERNAL__.IMPLICIT.STORE,
|
|
8
|
+
): ReadonlySelectorFamily<TransactionUpdate<ƒn>[]> => {
|
|
9
|
+
const findTransactionUpdateLog = __INTERNAL__.atomFamily__INTERNAL<
|
|
10
|
+
TransactionUpdate<ƒn>[],
|
|
11
|
+
string
|
|
12
|
+
>(
|
|
13
|
+
{
|
|
14
|
+
key: `👁🗨 Transaction Update Log (Internal)`,
|
|
15
|
+
default: () => [],
|
|
16
|
+
effects: (key) => [
|
|
17
|
+
({ setSelf }) => {
|
|
18
|
+
const tx = store.transactions.get(key)
|
|
19
|
+
tx.subject.subscribe((transactionUpdate) => {
|
|
20
|
+
if (transactionUpdate.key === key) {
|
|
21
|
+
setSelf((state) => [...state, transactionUpdate])
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
store,
|
|
28
|
+
)
|
|
29
|
+
const findTransactionUpdateLogState = __INTERNAL__.selectorFamily__INTERNAL<
|
|
30
|
+
TransactionUpdate<ƒn>[],
|
|
31
|
+
string
|
|
32
|
+
>(
|
|
33
|
+
{
|
|
34
|
+
key: `👁🗨 Transaction Update Log`,
|
|
35
|
+
get: (key) => ({ get }) => get(findTransactionUpdateLog(key)),
|
|
36
|
+
},
|
|
37
|
+
store,
|
|
38
|
+
)
|
|
39
|
+
return findTransactionUpdateLogState
|
|
40
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { AtomToken, ReadonlySelectorToken, SelectorToken } from "atom.io"
|
|
2
|
+
|
|
3
|
+
export * from "./attach-introspection-states"
|
|
4
|
+
|
|
5
|
+
export type FamilyNode<
|
|
6
|
+
Token extends
|
|
7
|
+
| AtomToken<unknown>
|
|
8
|
+
| ReadonlySelectorToken<unknown>
|
|
9
|
+
| SelectorToken<unknown>,
|
|
10
|
+
> = {
|
|
11
|
+
key: string
|
|
12
|
+
familyMembers: Record<string, Token>
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type StateTokenIndex<
|
|
16
|
+
Token extends
|
|
17
|
+
| AtomToken<unknown>
|
|
18
|
+
| ReadonlySelectorToken<unknown>
|
|
19
|
+
| SelectorToken<unknown>,
|
|
20
|
+
> = Record<string, FamilyNode<Token> | Token>
|