atom.io 0.6.7 → 0.6.9

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.
Files changed (129) hide show
  1. package/dist/index.d.mts +241 -263
  2. package/dist/index.d.ts +241 -263
  3. package/dist/index.js +28 -1911
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +5 -1871
  6. package/dist/index.mjs.map +1 -1
  7. package/introspection/dist/index.d.mts +121 -176
  8. package/introspection/dist/index.d.ts +121 -176
  9. package/introspection/dist/index.js +6 -346
  10. package/introspection/dist/index.js.map +1 -1
  11. package/introspection/dist/index.mjs +5 -324
  12. package/introspection/dist/index.mjs.map +1 -1
  13. package/json/dist/index.d.mts +37 -8
  14. package/json/dist/index.d.ts +37 -8
  15. package/json/dist/index.js +31 -48
  16. package/json/dist/index.js.map +1 -1
  17. package/json/dist/index.mjs +6 -14
  18. package/json/dist/index.mjs.map +1 -1
  19. package/package.json +30 -14
  20. package/react/dist/index.js +34 -83
  21. package/react/dist/index.js.map +1 -1
  22. package/react/dist/index.mjs +7 -43
  23. package/react/dist/index.mjs.map +1 -1
  24. package/react-devtools/dist/index.css +1 -42
  25. package/react-devtools/dist/index.css.map +1 -1
  26. package/react-devtools/dist/index.d.mts +128 -193
  27. package/react-devtools/dist/index.d.ts +128 -193
  28. package/react-devtools/dist/index.js +56 -4154
  29. package/react-devtools/dist/index.js.map +1 -1
  30. package/react-devtools/dist/index.mjs +19 -4117
  31. package/react-devtools/dist/index.mjs.map +1 -1
  32. package/realtime/dist/index.d.mts +7 -11
  33. package/realtime/dist/index.d.ts +7 -11
  34. package/realtime/dist/index.js +26 -185
  35. package/realtime/dist/index.js.map +1 -1
  36. package/realtime/dist/index.mjs +4 -149
  37. package/realtime/dist/index.mjs.map +1 -1
  38. package/realtime-react/dist/index.d.mts +12 -16
  39. package/realtime-react/dist/index.d.ts +12 -16
  40. package/realtime-react/dist/index.js +41 -214
  41. package/realtime-react/dist/index.js.map +1 -1
  42. package/realtime-react/dist/index.mjs +9 -169
  43. package/realtime-react/dist/index.mjs.map +1 -1
  44. package/src/atom.ts +7 -6
  45. package/src/index.ts +12 -9
  46. package/src/logger.ts +5 -5
  47. package/src/selector.ts +16 -14
  48. package/src/silo.ts +36 -39
  49. package/src/subscribe.ts +25 -20
  50. package/src/timeline.ts +9 -4
  51. package/src/transaction.ts +3 -4
  52. package/src/internal/atom-internal.ts +0 -54
  53. package/src/internal/families-internal.ts +0 -141
  54. package/src/internal/get.ts +0 -129
  55. package/src/internal/index.ts +0 -15
  56. package/src/internal/is-default.ts +0 -35
  57. package/src/internal/operation.ts +0 -139
  58. package/src/internal/selector/create-read-write-selector.ts +0 -66
  59. package/src/internal/selector/create-readonly-selector.ts +0 -46
  60. package/src/internal/selector/index.ts +0 -4
  61. package/src/internal/selector/lookup-selector-sources.ts +0 -16
  62. package/src/internal/selector/register-selector.ts +0 -57
  63. package/src/internal/selector/trace-selector-atoms.ts +0 -43
  64. package/src/internal/selector/update-selector-atoms.ts +0 -33
  65. package/src/internal/selector-internal.ts +0 -58
  66. package/src/internal/set.ts +0 -99
  67. package/src/internal/store.ts +0 -151
  68. package/src/internal/subject.ts +0 -24
  69. package/src/internal/subscribe-internal.ts +0 -88
  70. package/src/internal/time-travel-internal.ts +0 -91
  71. package/src/internal/timeline/add-atom-to-timeline.ts +0 -168
  72. package/src/internal/timeline/index.ts +0 -1
  73. package/src/internal/timeline-internal.ts +0 -107
  74. package/src/internal/transaction/abort-transaction.ts +0 -12
  75. package/src/internal/transaction/apply-transaction.ts +0 -57
  76. package/src/internal/transaction/build-transaction.ts +0 -33
  77. package/src/internal/transaction/index.ts +0 -25
  78. package/src/internal/transaction/redo-transaction.ts +0 -23
  79. package/src/internal/transaction/undo-transaction.ts +0 -23
  80. package/src/internal/transaction-internal.ts +0 -61
  81. package/src/introspection/attach-atom-index.ts +0 -73
  82. package/src/introspection/attach-introspection-states.ts +0 -42
  83. package/src/introspection/attach-selector-index.ts +0 -77
  84. package/src/introspection/attach-timeline-family.ts +0 -59
  85. package/src/introspection/attach-timeline-index.ts +0 -36
  86. package/src/introspection/attach-transaction-index.ts +0 -38
  87. package/src/introspection/attach-transaction-logs.ts +0 -40
  88. package/src/introspection/index.ts +0 -20
  89. package/src/json/index.ts +0 -1
  90. package/src/json/select-json.ts +0 -18
  91. package/src/react/index.ts +0 -2
  92. package/src/react/store-context.tsx +0 -13
  93. package/src/react/store-hooks.ts +0 -47
  94. package/src/react-devtools/AtomIODevtools.tsx +0 -107
  95. package/src/react-devtools/Button.tsx +0 -24
  96. package/src/react-devtools/StateEditor.tsx +0 -70
  97. package/src/react-devtools/StateIndex.tsx +0 -153
  98. package/src/react-devtools/TimelineIndex.tsx +0 -92
  99. package/src/react-devtools/TransactionIndex.tsx +0 -70
  100. package/src/react-devtools/Updates.tsx +0 -145
  101. package/src/react-devtools/devtools.scss +0 -311
  102. package/src/react-devtools/index.ts +0 -72
  103. package/src/react-explorer/AtomIOExplorer.tsx +0 -218
  104. package/src/react-explorer/explorer-effects.ts +0 -20
  105. package/src/react-explorer/explorer-states.ts +0 -217
  106. package/src/react-explorer/index.ts +0 -23
  107. package/src/react-explorer/space-states.ts +0 -72
  108. package/src/react-explorer/view-states.ts +0 -41
  109. package/src/realtime/README.md +0 -33
  110. package/src/realtime/hook-composition/expose-family.ts +0 -101
  111. package/src/realtime/hook-composition/expose-single.ts +0 -38
  112. package/src/realtime/hook-composition/expose-timeline.ts +0 -60
  113. package/src/realtime/hook-composition/index.ts +0 -12
  114. package/src/realtime/hook-composition/receive-state.ts +0 -29
  115. package/src/realtime/hook-composition/receive-transaction.ts +0 -18
  116. package/src/realtime/index.ts +0 -1
  117. package/src/realtime-react/index.ts +0 -3
  118. package/src/realtime-react/realtime-context.tsx +0 -30
  119. package/src/realtime-react/realtime-hooks.ts +0 -39
  120. package/src/realtime-react/realtime-state.ts +0 -10
  121. package/src/realtime-react/use-pull-family-member.ts +0 -26
  122. package/src/realtime-react/use-pull-family.ts +0 -24
  123. package/src/realtime-react/use-pull.ts +0 -22
  124. package/src/realtime-react/use-push.ts +0 -25
  125. package/src/realtime-react/use-server-action.ts +0 -33
  126. package/src/realtime-testing/index.ts +0 -1
  127. package/src/realtime-testing/setup-realtime-test.tsx +0 -159
  128. package/src/web-effects/index.ts +0 -1
  129. package/src/web-effects/storage.ts +0 -30
@@ -1,40 +0,0 @@
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
- }
@@ -1,20 +0,0 @@
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>
package/src/json/index.ts DELETED
@@ -1 +0,0 @@
1
- export * from "./select-json"
@@ -1,18 +0,0 @@
1
- import * as AtomIO from "atom.io"
2
-
3
- import type { Json, JsonInterface } from "~/packages/anvl/src/json"
4
-
5
- export const selectJson = <T, J extends Json>(
6
- atom: AtomIO.AtomToken<T>,
7
- transform: JsonInterface<T, J>,
8
- store: AtomIO.Store = AtomIO.__INTERNAL__.IMPLICIT.STORE,
9
- ): AtomIO.SelectorToken<J> =>
10
- AtomIO.__INTERNAL__.selector__INTERNAL(
11
- {
12
- key: `${atom.key}JSON`,
13
- get: ({ get }) => transform.toJson(get(atom)),
14
- set: ({ set }, newValue) => set(atom, transform.fromJson(newValue)),
15
- },
16
- undefined,
17
- store,
18
- )
@@ -1,2 +0,0 @@
1
- export * from "./store-context"
2
- export * from "./store-hooks"
@@ -1,13 +0,0 @@
1
- import * as AtomIO from "atom.io"
2
- import * as React from "react"
3
-
4
- export const StoreContext = React.createContext<AtomIO.Store>(
5
- AtomIO.__INTERNAL__.IMPLICIT.STORE,
6
- )
7
-
8
- export const StoreProvider: React.FC<{
9
- children: React.ReactNode
10
- store?: AtomIO.Store
11
- }> = ({ children, store = AtomIO.__INTERNAL__.IMPLICIT.STORE }) => (
12
- <StoreContext.Provider value={store}>{children}</StoreContext.Provider>
13
- )
@@ -1,47 +0,0 @@
1
- import * as AtomIO from "atom.io"
2
- import * as React from "react"
3
-
4
- import type { Modifier } from "~/packages/anvl/src/function"
5
-
6
- import { StoreContext } from "./store-context"
7
-
8
- export type StoreHooks = {
9
- useI: <T>(token: AtomIO.StateToken<T>) => (next: Modifier<T> | T) => void
10
- useO: <T>(token: AtomIO.ReadonlySelectorToken<T> | AtomIO.StateToken<T>) => T
11
- useIO: <T>(token: AtomIO.StateToken<T>) => [T, (next: Modifier<T> | T) => void]
12
- }
13
- export const storeHooks: StoreHooks = { useI, useO, useIO }
14
-
15
- export function useI<T>(
16
- token: AtomIO.StateToken<T>,
17
- ): (next: Modifier<T> | T) => void {
18
- const store = React.useContext(StoreContext)
19
- const update = (next: Modifier<T> | T) => AtomIO.setState(token, next, store)
20
- return update
21
- }
22
-
23
- export function useO<T>(
24
- token: AtomIO.ReadonlySelectorToken<T> | AtomIO.StateToken<T>,
25
- ): T {
26
- const store = React.useContext(StoreContext)
27
- return React.useSyncExternalStore<T>(
28
- (observe) => AtomIO.subscribe(token, observe, store),
29
- () => AtomIO.getState(token, store),
30
- )
31
- }
32
-
33
- export function useIO<T>(
34
- token: AtomIO.StateToken<T>,
35
- ): [T, (next: Modifier<T> | T) => void] {
36
- return [useO(token), useI(token)]
37
- }
38
-
39
- export function useStore<T>(
40
- token: AtomIO.StateToken<T>,
41
- ): [T, (next: Modifier<T> | T) => void]
42
- export function useStore<T>(token: AtomIO.ReadonlySelectorToken<T>): T
43
- export function useStore<T>(
44
- token: AtomIO.ReadonlySelectorToken<T> | AtomIO.StateToken<T>,
45
- ): T | [T, (next: Modifier<T> | T) => void] {
46
- return token.type === `readonly_selector` ? useO(token) : useIO(token)
47
- }
@@ -1,107 +0,0 @@
1
- import { useO, useIO } from "atom.io/react"
2
- import { LayoutGroup, motion, spring } from "framer-motion"
3
- import { useRef } from "react"
4
-
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"
15
-
16
- import "./devtools.scss"
17
-
18
- export const AtomIODevtools = (): JSX.Element => {
19
- const constraintsRef = useRef(null)
20
-
21
- const [devtoolsAreOpen, setDevtoolsAreOpen] = useIO(devtoolsAreOpenState)
22
- const [devtoolsView, setDevtoolsView] = useIO(devtoolsViewSelectionState)
23
- const devtoolsViewOptions = useO(devtoolsViewOptionsState)
24
-
25
- const mouseHasMoved = useRef(false)
26
-
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
- )
107
- }
@@ -1,24 +0,0 @@
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,70 +0,0 @@
1
- import type { ReadonlySelectorToken, StateToken } from "atom.io"
2
- import { useO, useIO } from "atom.io/react"
3
- import type { FC } from "react"
4
-
5
- import { fallback } from "~/packages/anvl/src/function"
6
- import { isJson } from "~/packages/anvl/src/json"
7
- import { ElasticInput } from "~/packages/hamr/src/react-elastic-input"
8
- import { JsonEditor } from "~/packages/hamr/src/react-json-editor"
9
-
10
- export const StateEditor: FC<{
11
- token: StateToken<unknown>
12
- }> = ({ token }) => {
13
- const [data, set] = useIO(token)
14
- return isJson(data) ? (
15
- <JsonEditor data={data} set={set} schema={true} />
16
- ) : (
17
- <div className="json_editor">
18
- <ElasticInput
19
- value={
20
- data instanceof Set
21
- ? `Set { ${JSON.stringify([...data]).slice(1, -1)} }`
22
- : data instanceof Map
23
- ? `Map ` + JSON.stringify([...data])
24
- : Object.getPrototypeOf(data).constructor.name +
25
- ` ` +
26
- fallback(() => JSON.stringify(data), `?`)
27
- }
28
- disabled={true}
29
- />
30
- </div>
31
- )
32
- }
33
-
34
- export const ReadonlySelectorViewer: FC<{
35
- token: ReadonlySelectorToken<unknown>
36
- }> = ({ token }) => {
37
- const data = useO(token)
38
- return isJson(data) ? (
39
- <JsonEditor
40
- data={data}
41
- set={() => null}
42
- schema={true}
43
- isReadonly={() => true}
44
- />
45
- ) : (
46
- <div className="json_editor">
47
- <ElasticInput
48
- value={
49
- data instanceof Set
50
- ? `Set ` + JSON.stringify([...data])
51
- : data instanceof Map
52
- ? `Map ` + JSON.stringify([...data])
53
- : Object.getPrototypeOf(data).constructor.name +
54
- ` ` +
55
- JSON.stringify(data)
56
- }
57
- disabled={true}
58
- />
59
- </div>
60
- )
61
- }
62
-
63
- export const StoreEditor: FC<{
64
- token: ReadonlySelectorToken<unknown> | StateToken<unknown>
65
- }> = ({ token }) => {
66
- if (token.type === `readonly_selector`) {
67
- return <ReadonlySelectorViewer token={token} />
68
- }
69
- return <StateEditor token={token} />
70
- }
@@ -1,153 +0,0 @@
1
- import type { AtomToken, ReadonlySelectorToken, SelectorToken } from "atom.io"
2
- import { getState, selectorFamily } from "atom.io"
3
- import { useO, useIO } from "atom.io/react"
4
- import type { FC } from "react"
5
-
6
- import { isJson, refineJsonType } from "~/packages/anvl/src/json"
7
-
8
- import { findViewIsOpenState, primitiveRefinery } from "."
9
- import { button } from "./Button"
10
- import { StoreEditor } from "./StateEditor"
11
- import type { FamilyNode, StateTokenIndex } from "../introspection"
12
-
13
- const findStateTypeState = selectorFamily<string, { key: string }>({
14
- key: `👁‍🗨 State Type`,
15
- get: (token) => ({ get }) => {
16
- let state: unknown
17
- try {
18
- state = get(token as any)
19
- } catch (error) {
20
- return `error`
21
- }
22
- if (state === undefined) return `undefined`
23
- if (isJson(state)) return refineJsonType(state).type
24
- return Object.getPrototypeOf(state).constructor.name
25
- },
26
- })
27
-
28
- export const StateIndexLeafNode: FC<{
29
- node:
30
- | AtomToken<unknown>
31
- | ReadonlySelectorToken<unknown>
32
- | SelectorToken<unknown>
33
- isOpenState: AtomToken<boolean>
34
- typeState: ReadonlySelectorToken<string>
35
- }> = ({ node, isOpenState, typeState }) => {
36
- const [isOpen, setIsOpen] = useIO(isOpenState)
37
- const state = useO(node)
38
- const stateType = useO(typeState)
39
-
40
- const isPrimitive = Boolean(primitiveRefinery.refine(state))
41
-
42
- return (
43
- <>
44
- <header>
45
- <button.OpenClose
46
- isOpen={isOpen && !isPrimitive}
47
- setIsOpen={setIsOpen}
48
- disabled={isPrimitive}
49
- />
50
- <label
51
- onClick={() => console.log(node, getState(node))}
52
- onKeyUp={() => console.log(node, getState(node))}
53
- >
54
- <h2>{node.family?.subKey ?? node.key}</h2>
55
- <span className="type detail">({stateType})</span>
56
- </label>
57
- {isPrimitive ? <StoreEditor token={node} /> : null}
58
- </header>
59
- {isOpen && !isPrimitive ? (
60
- <main>
61
- <StoreEditor token={node} />
62
- </main>
63
- ) : null}
64
- </>
65
- )
66
- }
67
- export const StateIndexTreeNode: FC<{
68
- node: FamilyNode<
69
- AtomToken<unknown> | ReadonlySelectorToken<unknown> | SelectorToken<unknown>
70
- >
71
- isOpenState: AtomToken<boolean>
72
- }> = ({ node, isOpenState }) => {
73
- const [isOpen, setIsOpen] = useIO(isOpenState)
74
- Object.entries(node.familyMembers).forEach(([key, childNode]) => {
75
- findViewIsOpenState(key)
76
- findStateTypeState(childNode)
77
- })
78
- return (
79
- <>
80
- <header>
81
- <button.OpenClose isOpen={isOpen} setIsOpen={setIsOpen} />
82
- <label>
83
- <h2>{node.key}</h2>
84
- <span className="type detail"> (family)</span>
85
- </label>
86
- </header>
87
- {isOpen
88
- ? Object.entries(node.familyMembers).map(([key, childNode]) => (
89
- <StateIndexNode
90
- key={key}
91
- node={childNode}
92
- isOpenState={findViewIsOpenState(childNode.key)}
93
- typeState={findStateTypeState(childNode)}
94
- />
95
- ))
96
- : null}
97
- </>
98
- )
99
- }
100
-
101
- export const StateIndexNode: FC<{
102
- node: StateTokenIndex<
103
- AtomToken<unknown> | ReadonlySelectorToken<unknown> | SelectorToken<unknown>
104
- >[string]
105
- isOpenState: AtomToken<boolean>
106
- typeState: ReadonlySelectorToken<string>
107
- }> = ({ node, isOpenState, typeState }) => {
108
- if (node.key.startsWith(`👁‍🗨`)) {
109
- return null
110
- }
111
- return (
112
- <section className="node state">
113
- {`type` in node ? (
114
- <StateIndexLeafNode
115
- node={node}
116
- isOpenState={isOpenState}
117
- typeState={typeState}
118
- />
119
- ) : (
120
- <StateIndexTreeNode node={node} isOpenState={isOpenState} />
121
- )}
122
- </section>
123
- )
124
- }
125
-
126
- export const StateIndex: FC<{
127
- tokenIndex: ReadonlySelectorToken<
128
- StateTokenIndex<
129
- | AtomToken<unknown>
130
- | ReadonlySelectorToken<unknown>
131
- | SelectorToken<unknown>
132
- >
133
- >
134
- }> = ({ tokenIndex }) => {
135
- const tokenIds = useO(tokenIndex)
136
- return (
137
- <article className="index state_index">
138
- {Object.entries(tokenIds)
139
- .filter(([key]) => !key.startsWith(`👁‍🗨`))
140
- .sort()
141
- .map(([key, node]) => {
142
- return (
143
- <StateIndexNode
144
- key={key}
145
- node={node}
146
- isOpenState={findViewIsOpenState(node.key)}
147
- typeState={findStateTypeState(node)}
148
- />
149
- )
150
- })}
151
- </article>
152
- )
153
- }
@@ -1,92 +0,0 @@
1
- import {
2
- undo,
3
- type AtomToken,
4
- type ReadonlySelectorToken,
5
- type TimelineToken,
6
- redo,
7
- } from "atom.io"
8
- import { useIO, useO } from "atom.io/react"
9
- import { Fragment, type FC } from "react"
10
-
11
- import { findTimelineState, findViewIsOpenState, timelineIndex } from "."
12
- import { button } from "./Button"
13
- import { article } from "./Updates"
14
- import type { Timeline } from "../internal"
15
-
16
- export const YouAreHere: FC = () => {
17
- return <span className="you_are_here">you are here</span>
18
- }
19
-
20
- export const TimelineLog: FC<{
21
- token: TimelineToken
22
- isOpenState: AtomToken<boolean>
23
- timelineState: ReadonlySelectorToken<Timeline>
24
- }> = ({ token, isOpenState, timelineState }) => {
25
- const timeline = useO(timelineState)
26
- const [isOpen, setIsOpen] = useIO(isOpenState)
27
-
28
- return (
29
- <section className="node timeline_log">
30
- <header>
31
- <button.OpenClose isOpen={isOpen} setIsOpen={setIsOpen} />
32
- <label>
33
- <h2>{token.key}</h2>
34
- <span className="detail length">
35
- ({timeline.at}/{timeline.history.length})
36
- </span>
37
- <span className="gap" />
38
- <nav>
39
- <button
40
- type="button"
41
- onClick={() => undo(token)}
42
- disabled={timeline.at === 0}
43
- >
44
- undo
45
- </button>
46
- <button
47
- type="button"
48
- onClick={() => redo(token)}
49
- disabled={timeline.at === timeline.history.length}
50
- >
51
- redo
52
- </button>
53
- </nav>
54
- </label>
55
- </header>
56
- {isOpen ? (
57
- <main>
58
- {timeline.history.map((update, index) => (
59
- <Fragment key={update.key + index + timeline.at}>
60
- {index === timeline.at ? <YouAreHere /> : null}
61
- <article.TimelineUpdate timelineUpdate={update} />
62
- {index === timeline.history.length - 1 &&
63
- timeline.at === timeline.history.length ? (
64
- <YouAreHere />
65
- ) : null}
66
- </Fragment>
67
- ))}
68
- </main>
69
- ) : null}
70
- </section>
71
- )
72
- }
73
-
74
- export const TimelineIndex: FC = () => {
75
- const tokenIds = useO(timelineIndex)
76
- return (
77
- <article className="index timeline_index">
78
- {tokenIds
79
- .filter((token) => !token.key.startsWith(`👁‍🗨`))
80
- .map((token) => {
81
- return (
82
- <TimelineLog
83
- key={token.key}
84
- token={token}
85
- isOpenState={findViewIsOpenState(token.key)}
86
- timelineState={findTimelineState(token.key)}
87
- />
88
- )
89
- })}
90
- </article>
91
- )
92
- }
@@ -1,70 +0,0 @@
1
- import type {
2
- AtomToken,
3
- ReadonlySelectorToken,
4
- TransactionToken,
5
- TransactionUpdate,
6
- } from "atom.io"
7
- import { useIO, useO } from "atom.io/react"
8
- import type { FC } from "react"
9
-
10
- import type { ƒn } from "~/packages/anvl/src/function"
11
-
12
- import {
13
- findTransactionLogState,
14
- findViewIsOpenState,
15
- transactionIndex,
16
- } from "."
17
- import { button } from "./Button"
18
- import { article } from "./Updates"
19
-
20
- export const TransactionLog: FC<{
21
- token: TransactionToken<ƒn>
22
- isOpenState: AtomToken<boolean>
23
- logState: ReadonlySelectorToken<TransactionUpdate<ƒn>[]>
24
- }> = ({ token, isOpenState, logState }) => {
25
- const log = useO(logState)
26
- const [isOpen, setIsOpen] = useIO(isOpenState)
27
-
28
- return (
29
- <section className="node transaction_log">
30
- <header>
31
- <button.OpenClose isOpen={isOpen} setIsOpen={setIsOpen} />
32
- <label>
33
- <h2>{token.key}</h2>
34
- <span className="detail length">({log.length})</span>
35
- </label>
36
- </header>
37
- {isOpen ? (
38
- <main>
39
- {log.map((update, index) => (
40
- <article.TransactionUpdate
41
- key={update.key + index}
42
- serialNumber={index}
43
- transactionUpdate={update}
44
- />
45
- ))}
46
- </main>
47
- ) : null}
48
- </section>
49
- )
50
- }
51
-
52
- export const TransactionIndex: FC = () => {
53
- const tokenIds = useO(transactionIndex)
54
- return (
55
- <article className="index transaction_index">
56
- {tokenIds
57
- .filter((token) => !token.key.startsWith(`👁‍🗨`))
58
- .map((token) => {
59
- return (
60
- <TransactionLog
61
- key={token.key}
62
- token={token}
63
- isOpenState={findViewIsOpenState(token.key)}
64
- logState={findTransactionLogState(token.key)}
65
- />
66
- )
67
- })}
68
- </article>
69
- )
70
- }