atom.io 0.6.5 → 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/README.md +32 -78
- package/dist/index.d.mts +11 -43
- package/dist/index.d.ts +11 -43
- package/dist/index.js +111 -291
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +108 -278
- 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 +350 -0
- package/introspection/dist/index.js.map +1 -0
- package/introspection/dist/index.mjs +327 -0
- package/introspection/dist/index.mjs.map +1 -0
- package/introspection/package.json +15 -0
- package/package.json +22 -12
- 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 -10
- package/react-devtools/dist/index.d.ts +347 -10
- package/react-devtools/dist/index.js +2743 -696
- package/react-devtools/dist/index.js.map +1 -1
- package/react-devtools/dist/index.mjs +2739 -701
- 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/index.ts +0 -1
- package/src/internal/operation.ts +15 -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 +22 -24
- package/src/internal/subscribe-internal.ts +7 -1
- 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 +6 -4
- 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-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 +59 -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 -97
- 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 +3 -4
- package/src/react-explorer/explorer-states.ts +1 -1
- package/src/react-explorer/space-states.ts +3 -1
- 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
|
@@ -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,59 @@
|
|
|
1
|
+
import type { ReadonlySelectorFamily, Store } from "atom.io"
|
|
2
|
+
import { __INTERNAL__, timeline } from "atom.io"
|
|
3
|
+
|
|
4
|
+
import { withdraw, type Timeline, Subject } 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) =>
|
|
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
|
+
},
|
|
26
|
+
effects: (key) => [
|
|
27
|
+
({ setSelf }) => {
|
|
28
|
+
const tl = store.timelines.get(key)
|
|
29
|
+
tl?.subject.subscribe((_) => {
|
|
30
|
+
if (store.operation.open === true) {
|
|
31
|
+
const subscription = store.subject.operationStatus.subscribe(
|
|
32
|
+
(operationStatus) => {
|
|
33
|
+
if (operationStatus.open === false) {
|
|
34
|
+
subscription.unsubscribe()
|
|
35
|
+
setSelf({ ...tl })
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
)
|
|
39
|
+
} else {
|
|
40
|
+
setSelf({ ...tl })
|
|
41
|
+
}
|
|
42
|
+
})
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
store,
|
|
47
|
+
)
|
|
48
|
+
const findTimelineLogState = __INTERNAL__.selectorFamily__INTERNAL<
|
|
49
|
+
Timeline,
|
|
50
|
+
string
|
|
51
|
+
>(
|
|
52
|
+
{
|
|
53
|
+
key: `👁🗨 Timeline Update Log`,
|
|
54
|
+
get: (key) => ({ get }) => get(findTimelineLogState__INTERNAL(key)),
|
|
55
|
+
},
|
|
56
|
+
store,
|
|
57
|
+
)
|
|
58
|
+
return findTimelineLogState
|
|
59
|
+
}
|
|
@@ -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>
|
|
@@ -1,107 +1,107 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { StoreHooks } from "atom.io/react"
|
|
3
|
-
import { useI, useO, useIO } from "atom.io/react"
|
|
1
|
+
import { useO, useIO } from "atom.io/react"
|
|
4
2
|
import { LayoutGroup, motion, spring } from "framer-motion"
|
|
5
3
|
import { useRef } from "react"
|
|
6
|
-
import type { FC } from "react"
|
|
7
4
|
|
|
8
|
-
import {
|
|
9
|
-
|
|
5
|
+
import {
|
|
6
|
+
atomIndex,
|
|
7
|
+
devtoolsAreOpenState,
|
|
8
|
+
devtoolsViewOptionsState,
|
|
9
|
+
devtoolsViewSelectionState,
|
|
10
|
+
selectorIndex,
|
|
11
|
+
} from "."
|
|
12
|
+
import { StateIndex } from "./StateIndex"
|
|
13
|
+
import { TimelineIndex } from "./TimelineIndex"
|
|
14
|
+
import { TransactionIndex } from "./TransactionIndex"
|
|
10
15
|
|
|
11
16
|
import "./devtools.scss"
|
|
12
17
|
|
|
13
|
-
const
|
|
14
|
-
|
|
18
|
+
export const AtomIODevtools = (): JSX.Element => {
|
|
19
|
+
const constraintsRef = useRef(null)
|
|
15
20
|
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
effects: [lazyLocalStorageEffect(`👁🗨_devtools_are_open`)],
|
|
20
|
-
})
|
|
21
|
+
const [devtoolsAreOpen, setDevtoolsAreOpen] = useIO(devtoolsAreOpenState)
|
|
22
|
+
const [devtoolsView, setDevtoolsView] = useIO(devtoolsViewSelectionState)
|
|
23
|
+
const devtoolsViewOptions = useO(devtoolsViewOptionsState)
|
|
21
24
|
|
|
22
|
-
|
|
23
|
-
const Devtools: FC = () => {
|
|
24
|
-
const constraintsRef = useRef(null)
|
|
25
|
+
const mouseHasMoved = useRef(false)
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
27
|
+
return (
|
|
28
|
+
<>
|
|
29
|
+
<motion.span
|
|
30
|
+
ref={constraintsRef}
|
|
31
|
+
className="atom_io_devtools_zone"
|
|
32
|
+
style={{
|
|
33
|
+
position: `fixed`,
|
|
34
|
+
top: 0,
|
|
35
|
+
left: 0,
|
|
36
|
+
right: 0,
|
|
37
|
+
bottom: 0,
|
|
38
|
+
pointerEvents: `none`,
|
|
39
|
+
}}
|
|
40
|
+
/>
|
|
41
|
+
<motion.main
|
|
42
|
+
drag
|
|
43
|
+
dragConstraints={constraintsRef}
|
|
44
|
+
className="atom_io_devtools"
|
|
45
|
+
transition={spring}
|
|
46
|
+
style={
|
|
47
|
+
devtoolsAreOpen
|
|
48
|
+
? {}
|
|
49
|
+
: {
|
|
50
|
+
backgroundColor: `#0000`,
|
|
51
|
+
borderColor: `#0000`,
|
|
52
|
+
maxHeight: 28,
|
|
53
|
+
maxWidth: 33,
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
>
|
|
57
|
+
{devtoolsAreOpen ? (
|
|
58
|
+
<>
|
|
59
|
+
<motion.header>
|
|
60
|
+
<h1>atom.io</h1>
|
|
61
|
+
<nav>
|
|
62
|
+
{devtoolsViewOptions.map((viewOption) => (
|
|
63
|
+
<button
|
|
64
|
+
key={viewOption}
|
|
65
|
+
type="button"
|
|
66
|
+
className={viewOption === devtoolsView ? `active` : ``}
|
|
67
|
+
onClick={() => setDevtoolsView(viewOption)}
|
|
68
|
+
disabled={viewOption === devtoolsView}
|
|
69
|
+
>
|
|
70
|
+
{viewOption}
|
|
71
|
+
</button>
|
|
72
|
+
))}
|
|
73
|
+
</nav>
|
|
74
|
+
</motion.header>
|
|
75
|
+
<motion.main>
|
|
76
|
+
<LayoutGroup>
|
|
77
|
+
{devtoolsView === `atoms` ? (
|
|
78
|
+
<StateIndex tokenIndex={atomIndex} />
|
|
79
|
+
) : devtoolsView === `selectors` ? (
|
|
80
|
+
<StateIndex tokenIndex={selectorIndex} />
|
|
81
|
+
) : devtoolsView === `transactions` ? (
|
|
82
|
+
<TransactionIndex />
|
|
83
|
+
) : devtoolsView === `timelines` ? (
|
|
84
|
+
<TimelineIndex />
|
|
85
|
+
) : null}
|
|
86
|
+
</LayoutGroup>
|
|
87
|
+
</motion.main>
|
|
88
|
+
</>
|
|
89
|
+
) : null}
|
|
90
|
+
<footer>
|
|
91
|
+
<button
|
|
92
|
+
type="button"
|
|
93
|
+
onMouseDown={() => (mouseHasMoved.current = false)}
|
|
94
|
+
onMouseMove={() => (mouseHasMoved.current = true)}
|
|
95
|
+
onMouseUp={() => {
|
|
96
|
+
if (!mouseHasMoved.current) {
|
|
97
|
+
setDevtoolsAreOpen((open) => !open)
|
|
98
|
+
}
|
|
99
|
+
}}
|
|
100
|
+
>
|
|
101
|
+
👁🗨
|
|
102
|
+
</button>
|
|
103
|
+
</footer>
|
|
104
|
+
</motion.main>
|
|
105
|
+
</>
|
|
106
|
+
)
|
|
105
107
|
}
|
|
106
|
-
|
|
107
|
-
export const AtomIODevtools = composeDevtools({ useI, useO, useIO })
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { FC } from "react"
|
|
2
|
+
|
|
3
|
+
import type { Modifier } from "~/packages/anvl/src/function"
|
|
4
|
+
|
|
5
|
+
export const OpenClose: FC<{
|
|
6
|
+
isOpen: boolean
|
|
7
|
+
setIsOpen: (next: Modifier<boolean> | boolean) => void
|
|
8
|
+
disabled?: boolean
|
|
9
|
+
}> = ({ isOpen, setIsOpen, disabled }) => {
|
|
10
|
+
return (
|
|
11
|
+
<button
|
|
12
|
+
type="button"
|
|
13
|
+
className={`carat ${isOpen ? `open` : `closed`}`}
|
|
14
|
+
onClick={() => setIsOpen((isOpen) => !isOpen)}
|
|
15
|
+
disabled={disabled}
|
|
16
|
+
>
|
|
17
|
+
▶
|
|
18
|
+
</button>
|
|
19
|
+
)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const button = {
|
|
23
|
+
OpenClose,
|
|
24
|
+
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import type { ReadonlySelectorToken, StateToken } from "atom.io"
|
|
2
|
-
import
|
|
2
|
+
import { useO, useIO } from "atom.io/react"
|
|
3
3
|
import type { FC } from "react"
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { fallback } from "~/packages/anvl/src/function"
|
|
6
|
+
import { isJson } from "~/packages/anvl/src/json"
|
|
6
7
|
import { ElasticInput } from "~/packages/hamr/src/react-elastic-input"
|
|
7
8
|
import { JsonEditor } from "~/packages/hamr/src/react-json-editor"
|
|
8
9
|
|
|
9
10
|
export const StateEditor: FC<{
|
|
10
|
-
storeHooks: StoreHooks
|
|
11
11
|
token: StateToken<unknown>
|
|
12
|
-
}> = ({
|
|
13
|
-
const [data, set] =
|
|
14
|
-
return
|
|
12
|
+
}> = ({ token }) => {
|
|
13
|
+
const [data, set] = useIO(token)
|
|
14
|
+
return isJson(data) ? (
|
|
15
15
|
<JsonEditor data={data} set={set} schema={true} />
|
|
16
16
|
) : (
|
|
17
17
|
<div className="json_editor">
|
|
@@ -23,7 +23,7 @@ export const StateEditor: FC<{
|
|
|
23
23
|
? `Map ` + JSON.stringify([...data])
|
|
24
24
|
: Object.getPrototypeOf(data).constructor.name +
|
|
25
25
|
` ` +
|
|
26
|
-
JSON.stringify(data)
|
|
26
|
+
fallback(() => JSON.stringify(data), `?`)
|
|
27
27
|
}
|
|
28
28
|
disabled={true}
|
|
29
29
|
/>
|
|
@@ -31,12 +31,11 @@ export const StateEditor: FC<{
|
|
|
31
31
|
)
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
export const
|
|
35
|
-
storeHooks: StoreHooks
|
|
34
|
+
export const ReadonlySelectorViewer: FC<{
|
|
36
35
|
token: ReadonlySelectorToken<unknown>
|
|
37
|
-
}> = ({
|
|
38
|
-
const data =
|
|
39
|
-
return
|
|
36
|
+
}> = ({ token }) => {
|
|
37
|
+
const data = useO(token)
|
|
38
|
+
return isJson(data) ? (
|
|
40
39
|
<JsonEditor
|
|
41
40
|
data={data}
|
|
42
41
|
set={() => null}
|
|
@@ -62,11 +61,10 @@ export const ReadonlySelectorEditor: FC<{
|
|
|
62
61
|
}
|
|
63
62
|
|
|
64
63
|
export const StoreEditor: FC<{
|
|
65
|
-
storeHooks: StoreHooks
|
|
66
64
|
token: ReadonlySelectorToken<unknown> | StateToken<unknown>
|
|
67
|
-
}> = ({
|
|
65
|
+
}> = ({ token }) => {
|
|
68
66
|
if (token.type === `readonly_selector`) {
|
|
69
|
-
return <
|
|
67
|
+
return <ReadonlySelectorViewer token={token} />
|
|
70
68
|
}
|
|
71
|
-
return <StateEditor
|
|
69
|
+
return <StateEditor token={token} />
|
|
72
70
|
}
|