atom.io 0.6.6 → 0.6.7
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/index.d.mts +7 -8
- package/dist/index.d.ts +7 -8
- package/dist/index.js +66 -93
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +66 -83
- package/dist/index.mjs.map +1 -1
- package/introspection/dist/index.d.mts +273 -0
- package/introspection/dist/index.d.ts +273 -0
- package/introspection/dist/index.js +41 -3
- package/introspection/dist/index.js.map +1 -1
- package/introspection/dist/index.mjs +41 -3
- package/introspection/dist/index.mjs.map +1 -1
- package/package.json +12 -12
- package/react-devtools/dist/index.d.mts +8 -10
- package/react-devtools/dist/index.d.ts +8 -10
- package/react-devtools/dist/index.js +104 -105
- package/react-devtools/dist/index.js.map +1 -1
- package/react-devtools/dist/index.mjs +105 -106
- package/react-devtools/dist/index.mjs.map +1 -1
- package/src/internal/atom-internal.ts +5 -6
- package/src/internal/get.ts +7 -9
- package/src/internal/operation.ts +14 -21
- package/src/internal/selector/create-read-write-selector.ts +8 -4
- package/src/internal/selector/create-readonly-selector.ts +1 -7
- package/src/internal/selector-internal.ts +1 -3
- package/src/internal/set.ts +1 -4
- package/src/internal/store.ts +19 -22
- package/src/internal/subscribe-internal.ts +7 -1
- package/src/internal/timeline-internal.ts +1 -3
- package/src/internal/transaction/apply-transaction.ts +9 -6
- package/src/internal/transaction/build-transaction.ts +6 -6
- package/src/internal/transaction-internal.ts +1 -7
- package/src/introspection/attach-timeline-family.ts +14 -4
- package/src/introspection/attach-transaction-logs.ts +1 -1
- package/src/react-devtools/AtomIODevtools.tsx +1 -2
- package/src/react-explorer/AtomIOExplorer.tsx +3 -3
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import HAMT from "hamt_plus"
|
|
2
|
-
|
|
3
1
|
import { Subject } from "."
|
|
4
2
|
import { deposit } from "./get"
|
|
5
3
|
import { markAtomAsDefault } from "./is-default"
|
|
6
|
-
import { cacheValue
|
|
4
|
+
import { cacheValue } from "./operation"
|
|
7
5
|
import type { Store } from "./store"
|
|
8
6
|
import { IMPLICIT } from "./store"
|
|
9
7
|
import { target } from "./transaction-internal"
|
|
@@ -25,11 +23,12 @@ export function atom__INTERNAL<T>(
|
|
|
25
23
|
store: Store = IMPLICIT.STORE,
|
|
26
24
|
): AtomToken<T> {
|
|
27
25
|
const core = target(store)
|
|
28
|
-
|
|
26
|
+
const existing = core.atoms.get(options.key)
|
|
27
|
+
if (existing) {
|
|
29
28
|
store.config.logger?.error?.(
|
|
30
29
|
`Key "${options.key}" already exists in the store.`,
|
|
31
30
|
)
|
|
32
|
-
return deposit(
|
|
31
|
+
return deposit(existing)
|
|
33
32
|
}
|
|
34
33
|
const subject = new Subject<{ newValue: T; oldValue: T }>()
|
|
35
34
|
const newAtom = {
|
|
@@ -40,7 +39,7 @@ export function atom__INTERNAL<T>(
|
|
|
40
39
|
} as const
|
|
41
40
|
const initialValue =
|
|
42
41
|
options.default instanceof Function ? options.default() : options.default
|
|
43
|
-
core.atoms
|
|
42
|
+
core.atoms.set(newAtom.key, newAtom)
|
|
44
43
|
markAtomAsDefault(options.key, store)
|
|
45
44
|
cacheValue(options.key, initialValue, store)
|
|
46
45
|
const token = deposit(newAtom)
|
package/src/internal/get.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import HAMT from "hamt_plus"
|
|
2
|
-
|
|
3
1
|
import type { ƒn } from "~/packages/anvl/src/function"
|
|
4
2
|
|
|
5
3
|
import type {
|
|
@@ -29,9 +27,9 @@ export function lookup(
|
|
|
29
27
|
store: Store,
|
|
30
28
|
): AtomToken<unknown> | ReadonlySelectorToken<unknown> | SelectorToken<unknown> {
|
|
31
29
|
const core = target(store)
|
|
32
|
-
const type =
|
|
30
|
+
const type = core.atoms.has(key)
|
|
33
31
|
? `atom`
|
|
34
|
-
:
|
|
32
|
+
: core.selectors.has(key)
|
|
35
33
|
? `selector`
|
|
36
34
|
: `readonly_selector`
|
|
37
35
|
return { key, type } as any
|
|
@@ -75,11 +73,11 @@ export function withdraw<T>(
|
|
|
75
73
|
| null {
|
|
76
74
|
const core = target(store)
|
|
77
75
|
return (
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
76
|
+
core.atoms.get(token.key) ??
|
|
77
|
+
core.selectors.get(token.key) ??
|
|
78
|
+
core.readonlySelectors.get(token.key) ??
|
|
79
|
+
core.transactions.get(token.key) ??
|
|
80
|
+
core.timelines.get(token.key) ??
|
|
83
81
|
null
|
|
84
82
|
)
|
|
85
83
|
}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import type { Hamt } from "hamt_plus"
|
|
2
|
-
import HAMT from "hamt_plus"
|
|
3
|
-
|
|
4
1
|
import type { Atom, ReadonlySelector, Selector } from "."
|
|
5
2
|
import { target } from "."
|
|
6
3
|
import type { Store } from "./store"
|
|
@@ -14,7 +11,7 @@ export type OperationProgress =
|
|
|
14
11
|
| {
|
|
15
12
|
open: true
|
|
16
13
|
done: Set<string>
|
|
17
|
-
prev:
|
|
14
|
+
prev: Map<string, any>
|
|
18
15
|
time: number
|
|
19
16
|
token: StateToken<any>
|
|
20
17
|
}
|
|
@@ -30,7 +27,7 @@ export const openOperation = (token: StateToken<any>, store: Store): void => {
|
|
|
30
27
|
core.operation = {
|
|
31
28
|
open: true,
|
|
32
29
|
done: new Set(),
|
|
33
|
-
prev: store.valueMap,
|
|
30
|
+
prev: new Map(store.valueMap),
|
|
34
31
|
time: Date.now(),
|
|
35
32
|
token,
|
|
36
33
|
}
|
|
@@ -74,9 +71,9 @@ export const recallState = <T>(
|
|
|
74
71
|
store.config.logger?.warn(
|
|
75
72
|
`recall called outside of an operation. This is probably a bug.`,
|
|
76
73
|
)
|
|
77
|
-
return
|
|
74
|
+
return core.valueMap.get(state.key)
|
|
78
75
|
}
|
|
79
|
-
return
|
|
76
|
+
return core.operation.prev.get(state.key)
|
|
80
77
|
}
|
|
81
78
|
|
|
82
79
|
export const cacheValue = (
|
|
@@ -85,7 +82,7 @@ export const cacheValue = (
|
|
|
85
82
|
store: Store = IMPLICIT.STORE,
|
|
86
83
|
): void => {
|
|
87
84
|
const core = target(store)
|
|
88
|
-
core.valueMap
|
|
85
|
+
core.valueMap.set(key, value)
|
|
89
86
|
}
|
|
90
87
|
|
|
91
88
|
export const evictCachedValue = (
|
|
@@ -93,24 +90,24 @@ export const evictCachedValue = (
|
|
|
93
90
|
store: Store = IMPLICIT.STORE,
|
|
94
91
|
): void => {
|
|
95
92
|
const core = target(store)
|
|
96
|
-
core.valueMap
|
|
93
|
+
core.valueMap.delete(key)
|
|
97
94
|
}
|
|
98
95
|
export const readCachedValue = <T>(
|
|
99
96
|
key: string,
|
|
100
97
|
store: Store = IMPLICIT.STORE,
|
|
101
|
-
): T =>
|
|
98
|
+
): T => target(store).valueMap.get(key)
|
|
102
99
|
|
|
103
100
|
export const isValueCached = (
|
|
104
101
|
key: string,
|
|
105
102
|
store: Store = IMPLICIT.STORE,
|
|
106
|
-
): boolean =>
|
|
103
|
+
): boolean => target(store).valueMap.has(key)
|
|
107
104
|
|
|
108
105
|
export const storeAtom = (
|
|
109
106
|
atom: Atom<any>,
|
|
110
107
|
store: Store = IMPLICIT.STORE,
|
|
111
108
|
): void => {
|
|
112
109
|
const core = target(store)
|
|
113
|
-
core.atoms
|
|
110
|
+
core.atoms.set(atom.key, atom)
|
|
114
111
|
}
|
|
115
112
|
|
|
116
113
|
export const storeSelector = (
|
|
@@ -118,7 +115,7 @@ export const storeSelector = (
|
|
|
118
115
|
store: Store = IMPLICIT.STORE,
|
|
119
116
|
): void => {
|
|
120
117
|
const core = target(store)
|
|
121
|
-
core.selectors
|
|
118
|
+
core.selectors.set(selector.key, selector)
|
|
122
119
|
}
|
|
123
120
|
|
|
124
121
|
export const storeReadonlySelector = (
|
|
@@ -126,11 +123,7 @@ export const storeReadonlySelector = (
|
|
|
126
123
|
store: Store = IMPLICIT.STORE,
|
|
127
124
|
): void => {
|
|
128
125
|
const core = target(store)
|
|
129
|
-
core.readonlySelectors
|
|
130
|
-
selector.key,
|
|
131
|
-
selector,
|
|
132
|
-
core.readonlySelectors,
|
|
133
|
-
)
|
|
126
|
+
core.readonlySelectors.set(selector.key, selector)
|
|
134
127
|
}
|
|
135
128
|
|
|
136
129
|
export const hasKeyBeenUsed = (
|
|
@@ -139,8 +132,8 @@ export const hasKeyBeenUsed = (
|
|
|
139
132
|
): boolean => {
|
|
140
133
|
const core = target(store)
|
|
141
134
|
return (
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
135
|
+
core.atoms.has(key) ||
|
|
136
|
+
core.selectors.has(key) ||
|
|
137
|
+
core.readonlySelectors.has(key)
|
|
145
138
|
)
|
|
146
139
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import HAMT from "hamt_plus"
|
|
2
|
-
|
|
3
1
|
import { become } from "~/packages/anvl/src/function"
|
|
4
2
|
|
|
5
3
|
import { Subject } from ".."
|
|
@@ -30,8 +28,14 @@ export const createReadWriteSelector = <T>(
|
|
|
30
28
|
}
|
|
31
29
|
|
|
32
30
|
const setSelf = (next: T | ((oldValue: T) => T)): void => {
|
|
33
|
-
store.config.logger?.info(` <- "${options.key}" became`, next)
|
|
34
31
|
const oldValue = getSelf()
|
|
32
|
+
store.config.logger?.info(
|
|
33
|
+
` <- "${options.key}" went (`,
|
|
34
|
+
oldValue,
|
|
35
|
+
`->`,
|
|
36
|
+
next,
|
|
37
|
+
`)`,
|
|
38
|
+
)
|
|
35
39
|
const newValue = become(next)(oldValue)
|
|
36
40
|
cacheValue(options.key, newValue, store)
|
|
37
41
|
markDone(options.key, store)
|
|
@@ -49,7 +53,7 @@ export const createReadWriteSelector = <T>(
|
|
|
49
53
|
type: `selector`,
|
|
50
54
|
...(family && { family }),
|
|
51
55
|
}
|
|
52
|
-
core.selectors
|
|
56
|
+
core.selectors.set(options.key, mySelector)
|
|
53
57
|
const initialValue = getSelf()
|
|
54
58
|
store.config.logger?.info(` ✨ "${options.key}" =`, initialValue)
|
|
55
59
|
const token: SelectorToken<T> = {
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import HAMT from "hamt_plus"
|
|
2
|
-
|
|
3
1
|
import { registerSelector } from "./register-selector"
|
|
4
2
|
import { Subject } from ".."
|
|
5
3
|
import type {
|
|
@@ -35,11 +33,7 @@ export const createReadonlySelector = <T>(
|
|
|
35
33
|
type: `readonly_selector`,
|
|
36
34
|
...(family && { family }),
|
|
37
35
|
}
|
|
38
|
-
core.readonlySelectors
|
|
39
|
-
options.key,
|
|
40
|
-
readonlySelector,
|
|
41
|
-
core.readonlySelectors,
|
|
42
|
-
)
|
|
36
|
+
core.readonlySelectors.set(options.key, readonlySelector)
|
|
43
37
|
const initialValue = getSelf()
|
|
44
38
|
store.config.logger?.info(` ✨ "${options.key}" =`, initialValue)
|
|
45
39
|
const token: ReadonlySelectorToken<T> = {
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import HAMT from "hamt_plus"
|
|
2
|
-
|
|
3
1
|
import { target, IMPLICIT } from "."
|
|
4
2
|
import type { Store, Subject } from "."
|
|
5
3
|
import { createReadWriteSelector } from "./selector/create-read-write-selector"
|
|
@@ -47,7 +45,7 @@ export function selector__INTERNAL<T>(
|
|
|
47
45
|
): ReadonlySelectorToken<T> | SelectorToken<T> {
|
|
48
46
|
const core = target(store)
|
|
49
47
|
|
|
50
|
-
if (
|
|
48
|
+
if (core.selectors.has(options.key)) {
|
|
51
49
|
store.config.logger?.error(
|
|
52
50
|
`Key "${options.key}" already exists in the store.`,
|
|
53
51
|
)
|
package/src/internal/set.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import HAMT from "hamt_plus"
|
|
2
|
-
|
|
3
1
|
import { become } from "~/packages/anvl/src/function"
|
|
4
2
|
|
|
5
3
|
import type { Atom, Selector, Store } from "."
|
|
@@ -37,8 +35,7 @@ export const evictDownStream = <T>(
|
|
|
37
35
|
return
|
|
38
36
|
}
|
|
39
37
|
const state =
|
|
40
|
-
|
|
41
|
-
HAMT.get(stateKey, core.readonlySelectors)
|
|
38
|
+
core.selectors.get(stateKey) ?? core.readonlySelectors.get(stateKey)
|
|
42
39
|
if (!state) {
|
|
43
40
|
store.config.logger?.info(
|
|
44
41
|
` || ${stateKey} is an atom, and can't be downstream`,
|
package/src/internal/store.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import type { Hamt } from "hamt_plus"
|
|
2
|
-
import HAMT from "hamt_plus"
|
|
3
|
-
|
|
4
1
|
import type { ƒn } from "~/packages/anvl/src/function"
|
|
5
2
|
import { doNothing } from "~/packages/anvl/src/function"
|
|
6
3
|
import { Join } from "~/packages/anvl/src/join"
|
|
@@ -40,16 +37,16 @@ export type StoreCore = Pick<
|
|
|
40
37
|
>
|
|
41
38
|
|
|
42
39
|
export interface Store {
|
|
43
|
-
atoms:
|
|
40
|
+
atoms: Map<string, Atom<any>>
|
|
44
41
|
atomsThatAreDefault: Set<string>
|
|
45
|
-
readonlySelectors:
|
|
42
|
+
readonlySelectors: Map<string, ReadonlySelector<any>>
|
|
46
43
|
selectorAtoms: Join<null, `selectorKey`, `atomKey`>
|
|
47
44
|
selectorGraph: Join<{ source: string }>
|
|
48
|
-
selectors:
|
|
45
|
+
selectors: Map<string, Selector<any>>
|
|
49
46
|
timelineAtoms: Join<null, `timelineKey`, `atomKey`>
|
|
50
|
-
timelines:
|
|
51
|
-
transactions:
|
|
52
|
-
valueMap:
|
|
47
|
+
timelines: Map<string, Timeline>
|
|
48
|
+
transactions: Map<string, Transaction<any>>
|
|
49
|
+
valueMap: Map<string, any>
|
|
53
50
|
|
|
54
51
|
subject: {
|
|
55
52
|
atomCreation: Subject<AtomToken<unknown>>
|
|
@@ -71,7 +68,7 @@ export interface Store {
|
|
|
71
68
|
}
|
|
72
69
|
|
|
73
70
|
export const createStore = (name: string, store: Store | null = null): Store => {
|
|
74
|
-
const
|
|
71
|
+
const created = {
|
|
75
72
|
...(store ??
|
|
76
73
|
(() => ({
|
|
77
74
|
atomsThatAreDefault: new Set(),
|
|
@@ -79,14 +76,14 @@ export const createStore = (name: string, store: Store | null = null): Store =>
|
|
|
79
76
|
.from(`selectorKey`)
|
|
80
77
|
.to(`atomKey`),
|
|
81
78
|
selectorGraph: new Join({ relationType: `n:n` }),
|
|
82
|
-
valueMap: HAMT.make<any, string>(),
|
|
83
79
|
}))()),
|
|
84
80
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
81
|
+
valueMap: new Map(store?.valueMap),
|
|
82
|
+
atoms: new Map(),
|
|
83
|
+
readonlySelectors: new Map(),
|
|
84
|
+
selectors: new Map(),
|
|
85
|
+
transactions: new Map(),
|
|
86
|
+
timelines: new Map(),
|
|
90
87
|
|
|
91
88
|
timelineAtoms: new Join({ relationType: `1:n` })
|
|
92
89
|
.from(`timelineKey`)
|
|
@@ -122,22 +119,22 @@ export const createStore = (name: string, store: Store | null = null): Store =>
|
|
|
122
119
|
|
|
123
120
|
store?.atoms.forEach((atom) => {
|
|
124
121
|
const copiedAtom = { ...atom, subject: new Subject() } satisfies Atom<any>
|
|
125
|
-
|
|
122
|
+
created.atoms.set(atom.key, copiedAtom)
|
|
126
123
|
})
|
|
127
124
|
store?.readonlySelectors.forEach((selector) => {
|
|
128
|
-
selector.install(
|
|
125
|
+
selector.install(created)
|
|
129
126
|
})
|
|
130
127
|
store?.selectors.forEach((selector) => {
|
|
131
|
-
selector.install(
|
|
128
|
+
selector.install(created)
|
|
132
129
|
})
|
|
133
130
|
store?.transactions.forEach((tx) => {
|
|
134
|
-
tx.install(
|
|
131
|
+
tx.install(created)
|
|
135
132
|
})
|
|
136
133
|
store?.timelines.forEach((timeline) => {
|
|
137
|
-
timeline.install(
|
|
134
|
+
timeline.install(created)
|
|
138
135
|
})
|
|
139
136
|
|
|
140
|
-
return
|
|
137
|
+
return created
|
|
141
138
|
}
|
|
142
139
|
|
|
143
140
|
export const IMPLICIT = {
|
|
@@ -74,7 +74,13 @@ export const subscribeToRootAtoms = <T>(
|
|
|
74
74
|
)
|
|
75
75
|
const oldValue = recallState(state, store)
|
|
76
76
|
const newValue = getState__INTERNAL(state, store)
|
|
77
|
-
store.config.logger?.info(
|
|
77
|
+
store.config.logger?.info(
|
|
78
|
+
` <- "${state.key}" went (`,
|
|
79
|
+
oldValue,
|
|
80
|
+
`->`,
|
|
81
|
+
newValue,
|
|
82
|
+
`)`,
|
|
83
|
+
)
|
|
78
84
|
state.subject.next({ newValue, oldValue })
|
|
79
85
|
})
|
|
80
86
|
})
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import HAMT from "hamt_plus"
|
|
2
|
-
|
|
3
1
|
import type { ƒn } from "~/packages/anvl/src/function"
|
|
4
2
|
|
|
5
3
|
import type { Store } from "."
|
|
@@ -99,7 +97,7 @@ export function timeline__INTERNAL(
|
|
|
99
97
|
})
|
|
100
98
|
}
|
|
101
99
|
|
|
102
|
-
store.timelines
|
|
100
|
+
store.timelines.set(options.key, tl)
|
|
103
101
|
const token: TimelineToken = {
|
|
104
102
|
key: options.key,
|
|
105
103
|
type: `timeline`,
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import HAMT from "hamt_plus"
|
|
2
|
-
|
|
3
1
|
import type { ƒn } from "~/packages/anvl/src/function"
|
|
4
2
|
|
|
5
3
|
import type { Store } from ".."
|
|
@@ -26,10 +24,15 @@ export const applyTransaction = <ƒ extends ƒn>(
|
|
|
26
24
|
|
|
27
25
|
for (const { key, newValue } of atomUpdates) {
|
|
28
26
|
const token: AtomToken<unknown> = { key, type: `atom` }
|
|
29
|
-
if (!
|
|
30
|
-
const newAtom =
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
if (!store.valueMap.has(token.key)) {
|
|
28
|
+
const newAtom = store.transactionStatus.core.atoms.get(token.key)
|
|
29
|
+
if (!newAtom) {
|
|
30
|
+
throw new Error(
|
|
31
|
+
`Absurd Error: Atom "${token.key}" not found while copying updates from transaction "${store.transactionStatus.key}" to store "${store.config.name}"`,
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
store.atoms.set(newAtom.key, newAtom)
|
|
35
|
+
store.valueMap.set(newAtom.key, newAtom.default)
|
|
33
36
|
store.config.logger?.info(`🔧`, `add atom "${newAtom.key}"`)
|
|
34
37
|
}
|
|
35
38
|
setState(token, newValue, store)
|
|
@@ -10,17 +10,17 @@ export const buildTransaction = (
|
|
|
10
10
|
phase: `building`,
|
|
11
11
|
time: Date.now(),
|
|
12
12
|
core: {
|
|
13
|
-
atoms: store.atoms,
|
|
13
|
+
atoms: new Map(store.atoms),
|
|
14
14
|
atomsThatAreDefault: store.atomsThatAreDefault,
|
|
15
15
|
operation: { open: false },
|
|
16
|
-
readonlySelectors: store.readonlySelectors,
|
|
17
|
-
timelines: store.timelines,
|
|
16
|
+
readonlySelectors: new Map(store.readonlySelectors),
|
|
17
|
+
timelines: new Map(store.timelines),
|
|
18
18
|
timelineAtoms: store.timelineAtoms,
|
|
19
|
-
transactions: store.transactions,
|
|
19
|
+
transactions: new Map(store.transactions),
|
|
20
20
|
selectorAtoms: store.selectorAtoms,
|
|
21
21
|
selectorGraph: store.selectorGraph,
|
|
22
|
-
selectors: store.selectors,
|
|
23
|
-
valueMap: store.valueMap,
|
|
22
|
+
selectors: new Map(store.selectors),
|
|
23
|
+
valueMap: new Map(store.valueMap),
|
|
24
24
|
},
|
|
25
25
|
atomUpdates: [],
|
|
26
26
|
params,
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import HAMT from "hamt_plus"
|
|
2
|
-
|
|
3
1
|
import type { ƒn } from "~/packages/anvl/src/function"
|
|
4
2
|
|
|
5
3
|
import type { Store, StoreCore } from "."
|
|
@@ -51,11 +49,7 @@ export function transaction__INTERNAL<ƒ extends ƒn>(
|
|
|
51
49
|
subject: new Subject(),
|
|
52
50
|
}
|
|
53
51
|
const core = target(store)
|
|
54
|
-
core.transactions
|
|
55
|
-
newTransaction.key,
|
|
56
|
-
newTransaction,
|
|
57
|
-
core.transactions,
|
|
58
|
-
)
|
|
52
|
+
core.transactions.set(newTransaction.key, newTransaction)
|
|
59
53
|
const token = deposit(newTransaction)
|
|
60
54
|
store.subject.transactionCreation.next(token)
|
|
61
55
|
return token
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ReadonlySelectorFamily, Store } from "atom.io"
|
|
2
|
-
import { __INTERNAL__ } from "atom.io"
|
|
2
|
+
import { __INTERNAL__, timeline } from "atom.io"
|
|
3
3
|
|
|
4
|
-
import type
|
|
4
|
+
import { withdraw, type Timeline, Subject } from "../internal"
|
|
5
5
|
|
|
6
6
|
export const attachTimelineFamily = (
|
|
7
7
|
store: Store = __INTERNAL__.IMPLICIT.STORE,
|
|
@@ -12,11 +12,21 @@ export const attachTimelineFamily = (
|
|
|
12
12
|
>(
|
|
13
13
|
{
|
|
14
14
|
key: `👁🗨 Timeline Update Log (Internal)`,
|
|
15
|
-
default: (key) =>
|
|
15
|
+
default: (key) =>
|
|
16
|
+
store.timelines.get(key) ?? {
|
|
17
|
+
key: ``,
|
|
18
|
+
at: 0,
|
|
19
|
+
timeTraveling: false,
|
|
20
|
+
history: [],
|
|
21
|
+
selectorTime: null,
|
|
22
|
+
transactionKey: null,
|
|
23
|
+
install: () => {},
|
|
24
|
+
subject: new Subject(),
|
|
25
|
+
},
|
|
16
26
|
effects: (key) => [
|
|
17
27
|
({ setSelf }) => {
|
|
18
28
|
const tl = store.timelines.get(key)
|
|
19
|
-
tl
|
|
29
|
+
tl?.subject.subscribe((_) => {
|
|
20
30
|
if (store.operation.open === true) {
|
|
21
31
|
const subscription = store.subject.operationStatus.subscribe(
|
|
22
32
|
(operationStatus) => {
|
|
@@ -16,7 +16,7 @@ export const attachTransactionLogs = (
|
|
|
16
16
|
effects: (key) => [
|
|
17
17
|
({ setSelf }) => {
|
|
18
18
|
const tx = store.transactions.get(key)
|
|
19
|
-
tx
|
|
19
|
+
tx?.subject.subscribe((transactionUpdate) => {
|
|
20
20
|
if (transactionUpdate.key === key) {
|
|
21
21
|
setSelf((state) => [...state, transactionUpdate])
|
|
22
22
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { useO, useIO } from "atom.io/react"
|
|
2
2
|
import { LayoutGroup, motion, spring } from "framer-motion"
|
|
3
3
|
import { useRef } from "react"
|
|
4
|
-
import type { FC } from "react"
|
|
5
4
|
|
|
6
5
|
import {
|
|
7
6
|
atomIndex,
|
|
@@ -16,7 +15,7 @@ import { TransactionIndex } from "./TransactionIndex"
|
|
|
16
15
|
|
|
17
16
|
import "./devtools.scss"
|
|
18
17
|
|
|
19
|
-
export const AtomIODevtools
|
|
18
|
+
export const AtomIODevtools = (): JSX.Element => {
|
|
20
19
|
const constraintsRef = useRef(null)
|
|
21
20
|
|
|
22
21
|
const [devtoolsAreOpen, setDevtoolsAreOpen] = useIO(devtoolsAreOpenState)
|
|
@@ -3,7 +3,7 @@ import type { FC, ReactNode } from "react"
|
|
|
3
3
|
import { useEffect } from "react"
|
|
4
4
|
import { Link, MemoryRouter, useLocation } from "react-router-dom"
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { RecoverableErrorBoundary } from "~/packages/hamr/src/react-error-boundary"
|
|
7
7
|
import type { WC } from "~/packages/hamr/src/react-json-editor"
|
|
8
8
|
|
|
9
9
|
import { attachExplorerState } from "./explorer-states"
|
|
@@ -132,14 +132,14 @@ export const composeExplorer = ({
|
|
|
132
132
|
const view = useO(findViewState(focusedViewId))
|
|
133
133
|
return (
|
|
134
134
|
<div className="space">
|
|
135
|
-
<
|
|
135
|
+
<RecoverableErrorBoundary>
|
|
136
136
|
<MemoryRouter
|
|
137
137
|
initialEntries={view.location ? [view.location.pathname] : []}
|
|
138
138
|
>
|
|
139
139
|
<TabBar spaceId={spaceId} viewIds={viewIds} />
|
|
140
140
|
<View viewId={focusedViewId}>{children}</View>
|
|
141
141
|
</MemoryRouter>
|
|
142
|
-
</
|
|
142
|
+
</RecoverableErrorBoundary>
|
|
143
143
|
</div>
|
|
144
144
|
)
|
|
145
145
|
}
|