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
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import type { AtomToken, ReadonlySelectorToken, SelectorToken } from "../.."
|
|
2
|
-
import { selector, atom } from "../.."
|
|
3
|
-
import type { Store } from "../store"
|
|
4
|
-
import { IMPLICIT } from "../store"
|
|
5
|
-
|
|
6
|
-
export type StateTokenIndex<
|
|
7
|
-
Token extends
|
|
8
|
-
| AtomToken<unknown>
|
|
9
|
-
| ReadonlySelectorToken<unknown>
|
|
10
|
-
| SelectorToken<unknown>,
|
|
11
|
-
> = Record<
|
|
12
|
-
string,
|
|
13
|
-
| Token
|
|
14
|
-
| {
|
|
15
|
-
key: string
|
|
16
|
-
familyMembers: Record<string, Token>
|
|
17
|
-
}
|
|
18
|
-
>
|
|
19
|
-
|
|
20
|
-
export type AtomTokenIndex = StateTokenIndex<AtomToken<unknown>>
|
|
21
|
-
export type SelectorTokenIndex = StateTokenIndex<
|
|
22
|
-
ReadonlySelectorToken<unknown> | SelectorToken<unknown>
|
|
23
|
-
>
|
|
24
|
-
|
|
25
|
-
export const attachMetaAtoms = (
|
|
26
|
-
store: Store = IMPLICIT.STORE,
|
|
27
|
-
): ReadonlySelectorToken<AtomTokenIndex> => {
|
|
28
|
-
const atomTokenIndexState__INTERNAL = atom<AtomTokenIndex>({
|
|
29
|
-
key: `👁🗨_atom_token_index__INTERNAL`,
|
|
30
|
-
default: () =>
|
|
31
|
-
[...store.atoms].reduce<AtomTokenIndex>((acc, [key]) => {
|
|
32
|
-
acc[key] = { key, type: `atom` }
|
|
33
|
-
return acc
|
|
34
|
-
}, {}),
|
|
35
|
-
effects: [
|
|
36
|
-
({ setSelf }) => {
|
|
37
|
-
store.subject.atomCreation.subscribe((atomToken) => {
|
|
38
|
-
if (store.operation.open) {
|
|
39
|
-
return
|
|
40
|
-
}
|
|
41
|
-
setSelf((state) => {
|
|
42
|
-
const { key, family } = atomToken
|
|
43
|
-
if (family) {
|
|
44
|
-
const { key: familyKey, subKey } = family
|
|
45
|
-
const current = state[familyKey]
|
|
46
|
-
if (current === undefined || `familyMembers` in current) {
|
|
47
|
-
const familyKeyState = current || {
|
|
48
|
-
key: familyKey,
|
|
49
|
-
familyMembers: {},
|
|
50
|
-
}
|
|
51
|
-
return {
|
|
52
|
-
...state,
|
|
53
|
-
[familyKey]: {
|
|
54
|
-
...familyKeyState,
|
|
55
|
-
familyMembers: {
|
|
56
|
-
...familyKeyState.familyMembers,
|
|
57
|
-
[subKey]: atomToken,
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return {
|
|
64
|
-
...state,
|
|
65
|
-
[key]: atomToken,
|
|
66
|
-
}
|
|
67
|
-
})
|
|
68
|
-
})
|
|
69
|
-
},
|
|
70
|
-
],
|
|
71
|
-
})
|
|
72
|
-
return selector({
|
|
73
|
-
key: `👁🗨_atom_token_index`,
|
|
74
|
-
get: ({ get }) => get(atomTokenIndexState__INTERNAL),
|
|
75
|
-
})
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export const attachMetaSelectors = (
|
|
79
|
-
store: Store = IMPLICIT.STORE,
|
|
80
|
-
): ReadonlySelectorToken<SelectorTokenIndex> => {
|
|
81
|
-
const readonlySelectorTokenIndexState__INTERNAL = atom<SelectorTokenIndex>({
|
|
82
|
-
key: `👁🗨_selector_token_index__INTERNAL`,
|
|
83
|
-
default: () =>
|
|
84
|
-
Object.assign(
|
|
85
|
-
[...store.readonlySelectors].reduce<SelectorTokenIndex>((acc, [key]) => {
|
|
86
|
-
acc[key] = { key, type: `readonly_selector` }
|
|
87
|
-
return acc
|
|
88
|
-
}, {}),
|
|
89
|
-
[...store.selectors].reduce<SelectorTokenIndex>((acc, [key]) => {
|
|
90
|
-
acc[key] = { key, type: `selector` }
|
|
91
|
-
return acc
|
|
92
|
-
}, {}),
|
|
93
|
-
),
|
|
94
|
-
effects: [
|
|
95
|
-
({ setSelf }) => {
|
|
96
|
-
store.subject.selectorCreation.subscribe((selectorToken) => {
|
|
97
|
-
if (store.operation.open) {
|
|
98
|
-
return
|
|
99
|
-
}
|
|
100
|
-
setSelf((state) => {
|
|
101
|
-
const { key, family } = selectorToken
|
|
102
|
-
if (family) {
|
|
103
|
-
const { key: familyKey, subKey } = family
|
|
104
|
-
const current = state[familyKey]
|
|
105
|
-
if (current === undefined || `familyMembers` in current) {
|
|
106
|
-
const familyKeyState = current || {
|
|
107
|
-
key: familyKey,
|
|
108
|
-
familyMembers: {},
|
|
109
|
-
}
|
|
110
|
-
return {
|
|
111
|
-
...state,
|
|
112
|
-
[familyKey]: {
|
|
113
|
-
...familyKeyState,
|
|
114
|
-
familyMembers: {
|
|
115
|
-
...familyKeyState.familyMembers,
|
|
116
|
-
[subKey]: selectorToken,
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
return {
|
|
123
|
-
...state,
|
|
124
|
-
[key]: selectorToken,
|
|
125
|
-
}
|
|
126
|
-
})
|
|
127
|
-
})
|
|
128
|
-
},
|
|
129
|
-
],
|
|
130
|
-
})
|
|
131
|
-
return selector({
|
|
132
|
-
key: `👁🗨_selector_token_index`,
|
|
133
|
-
get: ({ get }) => get(readonlySelectorTokenIndexState__INTERNAL),
|
|
134
|
-
})
|
|
135
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
AtomToken,
|
|
3
|
-
ReadonlySelectorToken,
|
|
4
|
-
SelectorToken,
|
|
5
|
-
__INTERNAL__,
|
|
6
|
-
} from "atom.io"
|
|
7
|
-
import { getState } from "atom.io"
|
|
8
|
-
import type { StoreHooks } from "atom.io/react"
|
|
9
|
-
import { Fragment } from "react"
|
|
10
|
-
import type { FC } from "react"
|
|
11
|
-
|
|
12
|
-
import { recordToEntries } from "~/packages/anvl/src/object"
|
|
13
|
-
|
|
14
|
-
import { StoreEditor } from "./StateEditor"
|
|
15
|
-
|
|
16
|
-
export const TokenList: FC<{
|
|
17
|
-
storeHooks: StoreHooks
|
|
18
|
-
tokenIndex: ReadonlySelectorToken<
|
|
19
|
-
__INTERNAL__.META.StateTokenIndex<
|
|
20
|
-
| AtomToken<unknown>
|
|
21
|
-
| ReadonlySelectorToken<unknown>
|
|
22
|
-
| SelectorToken<unknown>
|
|
23
|
-
>
|
|
24
|
-
>
|
|
25
|
-
}> = ({ storeHooks, tokenIndex }) => {
|
|
26
|
-
const tokenIds = storeHooks.useO(tokenIndex)
|
|
27
|
-
return (
|
|
28
|
-
<>
|
|
29
|
-
{Object.entries(tokenIds).map(([key, token]) => {
|
|
30
|
-
let logState: () => void
|
|
31
|
-
return (
|
|
32
|
-
<Fragment key={key}>
|
|
33
|
-
{key.startsWith(`👁🗨_`) ? null : (
|
|
34
|
-
<div className="node">
|
|
35
|
-
{`type` in token
|
|
36
|
-
? ((logState = () => console.log(token, getState(token))),
|
|
37
|
-
(
|
|
38
|
-
<>
|
|
39
|
-
<label onClick={logState} onKeyUp={logState}>
|
|
40
|
-
{key}
|
|
41
|
-
</label>
|
|
42
|
-
<StoreEditor storeHooks={storeHooks} token={token} />
|
|
43
|
-
</>
|
|
44
|
-
))
|
|
45
|
-
: recordToEntries(token.familyMembers).map(([key, token]) => (
|
|
46
|
-
<>
|
|
47
|
-
<label>{key}</label>
|
|
48
|
-
<div key={key} className="node">
|
|
49
|
-
{key}:
|
|
50
|
-
<StoreEditor storeHooks={storeHooks} token={token} />
|
|
51
|
-
</div>
|
|
52
|
-
</>
|
|
53
|
-
))}
|
|
54
|
-
</div>
|
|
55
|
-
)}
|
|
56
|
-
</Fragment>
|
|
57
|
-
)
|
|
58
|
-
})}
|
|
59
|
-
</>
|
|
60
|
-
)
|
|
61
|
-
}
|