atom.io 0.33.2 → 0.33.3
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/data/index.d.ts +3 -3
- package/dist/data/index.d.ts.map +1 -1
- package/dist/data/index.js.map +1 -1
- package/dist/eslint-plugin/index.d.ts.map +1 -1
- package/dist/internal/index.d.ts +111 -54
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +381 -128
- package/dist/internal/index.js.map +1 -1
- package/dist/introspection/index.d.ts +10 -10
- package/dist/introspection/index.d.ts.map +1 -1
- package/dist/introspection/index.js +4 -4
- package/dist/introspection/index.js.map +1 -1
- package/dist/json/index.d.ts +3 -3
- package/dist/json/index.d.ts.map +1 -1
- package/dist/json/index.js +2 -2
- package/dist/json/index.js.map +1 -1
- package/dist/main/index.d.ts +155 -36
- package/dist/main/index.d.ts.map +1 -1
- package/dist/main/index.js +15 -3
- package/dist/main/index.js.map +1 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/{devtools-Jyn42mZm.css → react-devtools/index.css} +1 -1
- package/dist/react-devtools/index.css.map +1 -0
- package/dist/react-devtools/index.d.ts +0 -1
- package/dist/react-devtools/index.d.ts.map +1 -1
- package/dist/react-devtools/index.js +8 -3
- package/dist/react-devtools/index.js.map +1 -1
- package/dist/realtime/index.d.ts +2 -2
- package/dist/realtime/index.d.ts.map +1 -1
- package/dist/realtime/index.js.map +1 -1
- package/dist/realtime-client/index.d.ts +1 -1
- package/dist/realtime-client/index.d.ts.map +1 -1
- package/dist/realtime-client/index.js.map +1 -1
- package/dist/realtime-react/index.d.ts.map +1 -1
- package/dist/realtime-react/index.js.map +1 -1
- package/dist/realtime-server/index.d.ts +2 -2
- package/dist/realtime-server/index.d.ts.map +1 -1
- package/dist/realtime-server/index.js.map +1 -1
- package/dist/realtime-testing/index.d.ts.map +1 -1
- package/dist/transceivers/set-rtx/index.d.ts.map +1 -1
- package/dist/web/index.d.ts.map +1 -1
- package/package.json +19 -19
- package/src/data/dict.ts +5 -5
- package/src/data/struct-family.ts +2 -2
- package/src/data/struct.ts +1 -1
- package/src/internal/atom/create-regular-atom.ts +14 -17
- package/src/internal/caching.ts +1 -1
- package/src/internal/families/create-readonly-held-selector-family.ts +81 -0
- package/src/internal/families/{create-readonly-selector-family.ts → create-readonly-pure-selector-family.ts} +26 -23
- package/src/internal/families/create-selector-family.ts +39 -16
- package/src/internal/families/create-writable-held-selector-family.ts +80 -0
- package/src/internal/families/{create-writable-selector-family.ts → create-writable-pure-selector-family.ts} +26 -23
- package/src/internal/families/dispose-from-store.ts +4 -2
- package/src/internal/families/find-in-store.ts +8 -8
- package/src/internal/families/get-family-of-token.ts +8 -8
- package/src/internal/families/index.ts +3 -3
- package/src/internal/families/init-family-member.ts +12 -10
- package/src/internal/families/seek-in-store.ts +13 -11
- package/src/internal/get-state/get-from-store.ts +5 -2
- package/src/internal/get-state/read-or-compute-value.ts +4 -2
- package/src/internal/index.ts +97 -20
- package/src/internal/join/join-internal.ts +18 -18
- package/src/internal/keys.ts +1 -1
- package/src/internal/mutable/create-mutable-atom.ts +17 -15
- package/src/internal/mutable/get-json-family.ts +4 -4
- package/src/internal/mutable/get-json-token.ts +7 -7
- package/src/internal/selector/create-readonly-held-selector.ts +50 -0
- package/src/internal/selector/create-readonly-pure-selector.ts +51 -0
- package/src/internal/selector/create-standalone-selector.ts +48 -15
- package/src/internal/selector/create-writable-held-selector.ts +68 -0
- package/src/internal/selector/{create-writable-selector.ts → create-writable-pure-selector.ts} +18 -25
- package/src/internal/selector/dispose-selector.ts +37 -7
- package/src/internal/selector/get-selector-dependency-keys.ts +1 -1
- package/src/internal/selector/index.ts +4 -2
- package/src/internal/selector/register-selector.ts +17 -5
- package/src/internal/selector/trace-selector-atoms.ts +5 -5
- package/src/internal/selector/update-selector-atoms.ts +16 -10
- package/src/internal/set-state/emit-update.ts +4 -2
- package/src/internal/set-state/set-atom-or-selector.ts +2 -1
- package/src/internal/store/counterfeit.ts +13 -11
- package/src/internal/store/deposit.ts +18 -14
- package/src/internal/store/store.ts +9 -14
- package/src/internal/store/withdraw.ts +83 -7
- package/src/internal/subscribe/subscribe-in-store.ts +4 -2
- package/src/internal/subscribe/subscribe-to-state.ts +2 -1
- package/src/internal/timeline/create-timeline.ts +4 -2
- package/src/internal/transaction/build-transaction.ts +1 -1
- package/src/introspection/attach-atom-index.ts +2 -2
- package/src/introspection/attach-introspection-states.ts +9 -9
- package/src/introspection/attach-selector-index.ts +3 -3
- package/src/introspection/attach-timeline-family.ts +2 -2
- package/src/introspection/attach-timeline-index.ts +2 -2
- package/src/introspection/attach-transaction-index.ts +2 -2
- package/src/introspection/attach-transaction-logs.ts +2 -2
- package/src/introspection/attach-type-selectors.ts +5 -5
- package/src/introspection/auditor.ts +3 -3
- package/src/json/select-json-family.ts +5 -5
- package/src/json/select-json.ts +1 -1
- package/src/main/find-state.ts +8 -8
- package/src/main/index.ts +51 -6
- package/src/main/join.ts +13 -13
- package/src/main/logger.ts +32 -15
- package/src/main/selector.ts +164 -30
- package/src/main/transaction.ts +3 -3
- package/src/main/validators.ts +16 -12
- package/src/react-devtools/StateEditor.tsx +14 -4
- package/src/react-devtools/StateIndex.tsx +6 -4
- package/src/react-devtools/TimelineIndex.tsx +2 -2
- package/src/react-devtools/TransactionIndex.tsx +2 -2
- package/src/realtime/shared-room-store.ts +3 -3
- package/src/realtime-client/realtime-client-stores/client-main-store.ts +1 -1
- package/src/realtime-react/use-pull-selector-family-member.ts +1 -0
- package/src/realtime-server/realtime-server-stores/server-room-external-store.ts +2 -2
- package/dist/devtools-CAg2k57t.js +0 -0
- package/dist/devtools-Jyn42mZm.css.map +0 -1
- package/src/internal/selector/create-readonly-selector.ts +0 -55
package/src/main/logger.ts
CHANGED
|
@@ -59,14 +59,18 @@ export type TokenDenomination =
|
|
|
59
59
|
| `molecule`
|
|
60
60
|
| `mutable_atom_family`
|
|
61
61
|
| `mutable_atom`
|
|
62
|
-
| `
|
|
63
|
-
| `
|
|
64
|
-
| `
|
|
65
|
-
| `
|
|
62
|
+
| `readonly_held_selector_family`
|
|
63
|
+
| `readonly_held_selector`
|
|
64
|
+
| `readonly_pure_selector_family`
|
|
65
|
+
| `readonly_pure_selector`
|
|
66
66
|
| `state`
|
|
67
67
|
| `timeline`
|
|
68
68
|
| `transaction`
|
|
69
69
|
| `unknown`
|
|
70
|
+
| `writable_held_selector_family`
|
|
71
|
+
| `writable_held_selector`
|
|
72
|
+
| `writable_pure_selector_family`
|
|
73
|
+
| `writable_pure_selector`
|
|
70
74
|
|
|
71
75
|
export const LOG_LEVELS = [`info`, `warn`, `error`] as const
|
|
72
76
|
export type LogLevel = (typeof LOG_LEVELS)[number]
|
|
@@ -78,7 +82,9 @@ export type LogFn = (
|
|
|
78
82
|
message: string,
|
|
79
83
|
...rest: unknown[]
|
|
80
84
|
) => void
|
|
81
|
-
export type LogFilter = (
|
|
85
|
+
export type LogFilter = (
|
|
86
|
+
...params: Parameters<LogFn>
|
|
87
|
+
) => Parameters<LogFn> | boolean
|
|
82
88
|
|
|
83
89
|
export type Logger = Record<LogLevel, LogFn>
|
|
84
90
|
|
|
@@ -113,22 +119,33 @@ export class AtomIOLogger implements Logger {
|
|
|
113
119
|
}
|
|
114
120
|
|
|
115
121
|
public error: LogFn = (...args) => {
|
|
116
|
-
|
|
117
|
-
|
|
122
|
+
const filterResult = this.filter?.(...args) ?? true
|
|
123
|
+
if (this.logLevel !== null) {
|
|
124
|
+
if (filterResult === true) {
|
|
125
|
+
this.logger.error(...args)
|
|
126
|
+
} else if (filterResult !== false) {
|
|
127
|
+
this.logger.error(...filterResult)
|
|
128
|
+
}
|
|
118
129
|
}
|
|
119
130
|
}
|
|
120
131
|
public info: LogFn = (...args) => {
|
|
121
|
-
|
|
122
|
-
|
|
132
|
+
const filterResult = this.filter?.(...args) ?? true
|
|
133
|
+
if (this.logLevel === `info`) {
|
|
134
|
+
if (filterResult === true) {
|
|
135
|
+
this.logger.info(...args)
|
|
136
|
+
} else if (filterResult !== false) {
|
|
137
|
+
this.logger.info(...filterResult)
|
|
138
|
+
}
|
|
123
139
|
}
|
|
124
140
|
}
|
|
125
141
|
public warn: LogFn = (...args) => {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
142
|
+
const filterResult = this.filter?.(...args) ?? true
|
|
143
|
+
if (this.logLevel !== `error` && this.logLevel !== null) {
|
|
144
|
+
if (filterResult === true) {
|
|
145
|
+
this.logger.warn(...args)
|
|
146
|
+
} else if (filterResult !== false) {
|
|
147
|
+
this.logger.warn(...filterResult)
|
|
148
|
+
}
|
|
132
149
|
}
|
|
133
150
|
}
|
|
134
151
|
}
|
package/src/main/selector.ts
CHANGED
|
@@ -5,89 +5,223 @@ import {
|
|
|
5
5
|
} from "atom.io/internal"
|
|
6
6
|
import type { Canonical } from "atom.io/json"
|
|
7
7
|
|
|
8
|
-
import type {
|
|
8
|
+
import type {
|
|
9
|
+
ReadonlyHeldSelectorToken,
|
|
10
|
+
ReadonlyPureSelectorToken,
|
|
11
|
+
WritableHeldSelectorToken,
|
|
12
|
+
WritablePureSelectorToken,
|
|
13
|
+
} from "."
|
|
9
14
|
import type { Read, Write } from "./transaction"
|
|
10
15
|
|
|
11
|
-
export type
|
|
16
|
+
export type WritablePureSelectorOptions<T> = {
|
|
12
17
|
key: string
|
|
13
18
|
get: Read<() => T>
|
|
14
19
|
set: Write<(newValue: T) => void>
|
|
15
20
|
}
|
|
16
|
-
export type
|
|
21
|
+
export type ReadonlyPureSelectorOptions<T> = {
|
|
17
22
|
key: string
|
|
18
23
|
get: Read<() => T>
|
|
19
24
|
}
|
|
25
|
+
export type ReadonlyHeldSelectorOptions<T extends object> = {
|
|
26
|
+
key: string
|
|
27
|
+
const: T
|
|
28
|
+
get: Read<(permanent: T) => void>
|
|
29
|
+
}
|
|
30
|
+
export type WritableHeldSelectorOptions<T extends object> = {
|
|
31
|
+
key: string
|
|
32
|
+
const: T
|
|
33
|
+
get: Read<(permanent: T) => void>
|
|
34
|
+
set: Write<(newValue: T) => void>
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @public
|
|
39
|
+
* Declare a selector. The value of a selector should depend
|
|
40
|
+
* on the value of atoms or other selectors in the store, and
|
|
41
|
+
* should be recycled when a root atom of the selector is set.
|
|
42
|
+
*
|
|
43
|
+
* A held selector's value must be some object.
|
|
44
|
+
* The reference to that object is permanent and will not be replaced.
|
|
45
|
+
*
|
|
46
|
+
* A writable selector can be "set" to a new value.
|
|
47
|
+
* It is advised to set its dependencies to values
|
|
48
|
+
* that would produce the new value of the selector.
|
|
49
|
+
*
|
|
50
|
+
* @param options - {@link WritableHeldSelectorOptions}.
|
|
51
|
+
* @returns
|
|
52
|
+
* The token for your selector.
|
|
53
|
+
* @overload WritableHeld
|
|
54
|
+
*/
|
|
55
|
+
export function selector<T extends object>(
|
|
56
|
+
options: WritableHeldSelectorOptions<T>,
|
|
57
|
+
): WritableHeldSelectorToken<T>
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @public
|
|
61
|
+
* Declare a selector. The value of a selector should depend
|
|
62
|
+
* on the value of atoms or other selectors in the store,
|
|
63
|
+
* and should be recycled when a root atom of the selector is set.
|
|
64
|
+
*
|
|
65
|
+
* A held selector's value must be some object.
|
|
66
|
+
* The reference to that object is permanent and will not be replaced.
|
|
67
|
+
*
|
|
68
|
+
* A readonly selector can be "gotten" but not "set".
|
|
69
|
+
*
|
|
70
|
+
* @param options - {@link ReadonlyHeldSelectorOptions}.
|
|
71
|
+
* @returns
|
|
72
|
+
* The token for your selector.
|
|
73
|
+
* @overload ReadonlyHeld
|
|
74
|
+
*/
|
|
75
|
+
export function selector<T extends object>(
|
|
76
|
+
options: ReadonlyHeldSelectorOptions<T>,
|
|
77
|
+
): ReadonlyHeldSelectorToken<T>
|
|
20
78
|
|
|
21
79
|
/**
|
|
22
80
|
* @public
|
|
23
81
|
* Declare a selector. The value of a selector should depend
|
|
24
82
|
* on the value of atoms or other selectors in the store.
|
|
25
83
|
*
|
|
84
|
+
* A pure selector's current value is evicted from the store
|
|
85
|
+
* in order to be garbage collected when a root atom of the selector is set.
|
|
86
|
+
*
|
|
26
87
|
* A writable selector can be "set" to a new value.
|
|
27
88
|
* It is advised to set its dependencies to values
|
|
28
89
|
* that would produce the new value of the selector.
|
|
29
|
-
*
|
|
90
|
+
*
|
|
91
|
+
* @param options - {@link TransientWritableSelectorOptions}.
|
|
30
92
|
* @returns
|
|
31
93
|
* The token for your selector.
|
|
32
|
-
* @overload
|
|
94
|
+
* @overload WritablePure
|
|
33
95
|
*/
|
|
34
96
|
export function selector<T>(
|
|
35
|
-
options:
|
|
36
|
-
):
|
|
97
|
+
options: WritablePureSelectorOptions<T>,
|
|
98
|
+
): WritablePureSelectorToken<T>
|
|
37
99
|
|
|
38
100
|
/**
|
|
39
101
|
* @public
|
|
40
102
|
* Declare a selector. The value of a selector should depend
|
|
41
103
|
* on the value of atoms or other selectors in the store.
|
|
42
|
-
*
|
|
104
|
+
*
|
|
105
|
+
* A pure selector's current value is evicted from the store
|
|
106
|
+
* in order to be garbage collected when a root atom of the selector is set.
|
|
107
|
+
*
|
|
108
|
+
* A readonly selector can be "gotten" but not "set".
|
|
109
|
+
*
|
|
110
|
+
* @param options - {@link ReadonlyPureSelectorOptions}.
|
|
111
|
+
* @returns
|
|
112
|
+
* The token for your selector.
|
|
113
|
+
* @overload ReadonlyPure
|
|
43
114
|
*/
|
|
44
115
|
export function selector<T>(
|
|
45
|
-
options:
|
|
46
|
-
):
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
116
|
+
options: ReadonlyPureSelectorOptions<T>,
|
|
117
|
+
): ReadonlyPureSelectorToken<T>
|
|
118
|
+
|
|
119
|
+
export function selector(
|
|
120
|
+
options:
|
|
121
|
+
| ReadonlyHeldSelectorOptions<any>
|
|
122
|
+
| ReadonlyPureSelectorOptions<any>
|
|
123
|
+
| WritableHeldSelectorOptions<any>
|
|
124
|
+
| WritablePureSelectorOptions<any>,
|
|
125
|
+
):
|
|
126
|
+
| ReadonlyHeldSelectorToken<any>
|
|
127
|
+
| ReadonlyPureSelectorToken<any>
|
|
128
|
+
| WritableHeldSelectorToken<any>
|
|
129
|
+
| WritablePureSelectorToken<any> {
|
|
50
130
|
return createStandaloneSelector(IMPLICIT.STORE, options)
|
|
51
131
|
}
|
|
52
132
|
|
|
53
|
-
export type
|
|
133
|
+
export type WritablePureSelectorFamilyOptions<T, K extends Canonical> = {
|
|
54
134
|
key: string
|
|
55
135
|
get: (key: K) => Read<() => T>
|
|
56
136
|
set: (key: K) => Write<(newValue: T) => void>
|
|
57
137
|
}
|
|
58
|
-
export type
|
|
138
|
+
export type ReadonlyPureSelectorFamilyOptions<T, K extends Canonical> = {
|
|
59
139
|
key: string
|
|
60
140
|
get: (key: K) => Read<() => T>
|
|
61
141
|
}
|
|
142
|
+
export type WritableHeldSelectorFamilyOptions<
|
|
143
|
+
T extends object,
|
|
144
|
+
K extends Canonical,
|
|
145
|
+
> = {
|
|
146
|
+
key: string
|
|
147
|
+
const: (key: K) => T
|
|
148
|
+
get: (key: K) => Read<(permanent: T) => void>
|
|
149
|
+
set: (key: K) => Write<(newValue: T) => void>
|
|
150
|
+
}
|
|
151
|
+
export type ReadonlyHeldSelectorFamilyOptions<
|
|
152
|
+
T extends object,
|
|
153
|
+
K extends Canonical,
|
|
154
|
+
> = {
|
|
155
|
+
key: string
|
|
156
|
+
const: (key: K) => T
|
|
157
|
+
get: (key: K) => Read<(permanent: T) => void>
|
|
158
|
+
}
|
|
62
159
|
|
|
63
|
-
export type
|
|
160
|
+
export type WritablePureSelectorFamilyToken<T, K extends Canonical> = {
|
|
64
161
|
key: string
|
|
65
|
-
type: `
|
|
162
|
+
type: `writable_pure_selector_family`
|
|
66
163
|
__T?: T
|
|
67
164
|
__K?: K
|
|
68
165
|
}
|
|
69
|
-
|
|
70
|
-
export type ReadonlySelectorFamilyToken<T, K extends Canonical> = {
|
|
166
|
+
export type ReadonlyPureSelectorFamilyToken<T, K extends Canonical> = {
|
|
71
167
|
key: string
|
|
72
|
-
type: `
|
|
168
|
+
type: `readonly_pure_selector_family`
|
|
169
|
+
__T?: T
|
|
170
|
+
__K?: K
|
|
171
|
+
}
|
|
172
|
+
export type WritableHeldSelectorFamilyToken<T, K extends Canonical> = {
|
|
173
|
+
key: string
|
|
174
|
+
type: `writable_held_selector_family`
|
|
175
|
+
__T?: T
|
|
176
|
+
__K?: K
|
|
177
|
+
}
|
|
178
|
+
export type ReadonlyHeldSelectorFamilyToken<T, K extends Canonical> = {
|
|
179
|
+
key: string
|
|
180
|
+
type: `readonly_held_selector_family`
|
|
73
181
|
__T?: T
|
|
74
182
|
__K?: K
|
|
75
183
|
}
|
|
76
184
|
|
|
185
|
+
export type PureSelectorFamilyToken<T, K extends Canonical> =
|
|
186
|
+
| ReadonlyPureSelectorFamilyToken<T, K>
|
|
187
|
+
| WritablePureSelectorFamilyToken<T, K>
|
|
188
|
+
export type HeldSelectorFamilyToken<T, K extends Canonical> =
|
|
189
|
+
| ReadonlyHeldSelectorFamilyToken<T, K>
|
|
190
|
+
| WritableHeldSelectorFamilyToken<T, K>
|
|
191
|
+
export type ReadonlySelectorFamilyToken<T, K extends Canonical> =
|
|
192
|
+
| ReadonlyHeldSelectorFamilyToken<T, K>
|
|
193
|
+
| ReadonlyPureSelectorFamilyToken<T, K>
|
|
194
|
+
|
|
195
|
+
export type WritableSelectorFamilyToken<T, K extends Canonical> =
|
|
196
|
+
| WritableHeldSelectorFamilyToken<T, K>
|
|
197
|
+
| WritablePureSelectorFamilyToken<T, K>
|
|
198
|
+
|
|
77
199
|
export type SelectorFamilyToken<T, K extends Canonical> =
|
|
78
|
-
|
|
|
79
|
-
|
|
|
200
|
+
| HeldSelectorFamilyToken<T, K>
|
|
201
|
+
| PureSelectorFamilyToken<T, K>
|
|
80
202
|
|
|
203
|
+
export function selectorFamily<T extends object, K extends Canonical>(
|
|
204
|
+
options: WritableHeldSelectorFamilyOptions<T, K>,
|
|
205
|
+
): WritableHeldSelectorFamilyToken<T, K>
|
|
206
|
+
export function selectorFamily<T extends object, K extends Canonical>(
|
|
207
|
+
options: ReadonlyHeldSelectorFamilyOptions<T, K>,
|
|
208
|
+
): ReadonlyHeldSelectorFamilyToken<T, K>
|
|
81
209
|
export function selectorFamily<T, K extends Canonical>(
|
|
82
|
-
options:
|
|
83
|
-
):
|
|
84
|
-
export function selectorFamily<T, K extends Canonical>(
|
|
85
|
-
options: ReadonlySelectorFamilyOptions<T, K>,
|
|
86
|
-
): ReadonlySelectorFamilyToken<T, K>
|
|
210
|
+
options: WritablePureSelectorFamilyOptions<T, K>,
|
|
211
|
+
): WritablePureSelectorFamilyToken<T, K>
|
|
87
212
|
export function selectorFamily<T, K extends Canonical>(
|
|
213
|
+
options: ReadonlyPureSelectorFamilyOptions<T, K>,
|
|
214
|
+
): ReadonlyPureSelectorFamilyToken<T, K>
|
|
215
|
+
export function selectorFamily(
|
|
88
216
|
options:
|
|
89
|
-
|
|
|
90
|
-
|
|
|
91
|
-
|
|
217
|
+
| ReadonlyHeldSelectorFamilyOptions<any, any>
|
|
218
|
+
| ReadonlyPureSelectorFamilyOptions<any, any>
|
|
219
|
+
| WritableHeldSelectorFamilyOptions<any, any>
|
|
220
|
+
| WritablePureSelectorFamilyOptions<any, any>,
|
|
221
|
+
):
|
|
222
|
+
| ReadonlyHeldSelectorFamilyToken<any, any>
|
|
223
|
+
| ReadonlyPureSelectorFamilyToken<any, any>
|
|
224
|
+
| WritableHeldSelectorFamilyToken<any, any>
|
|
225
|
+
| WritablePureSelectorFamilyToken<any, any> {
|
|
92
226
|
return createSelectorFamily(IMPLICIT.STORE, options)
|
|
93
227
|
}
|
package/src/main/transaction.ts
CHANGED
|
@@ -14,7 +14,7 @@ import type {
|
|
|
14
14
|
MutableAtomToken,
|
|
15
15
|
ReadableToken,
|
|
16
16
|
TokenType,
|
|
17
|
-
|
|
17
|
+
WritablePureSelectorToken,
|
|
18
18
|
} from "."
|
|
19
19
|
|
|
20
20
|
export type TransactionToken<F extends Func> = {
|
|
@@ -88,7 +88,7 @@ export type SetterToolkit = Readonly<{
|
|
|
88
88
|
find: typeof findState
|
|
89
89
|
json: <T extends Transceiver<any>, J extends Json.Serializable>(
|
|
90
90
|
state: MutableAtomToken<T, J>,
|
|
91
|
-
) =>
|
|
91
|
+
) => WritablePureSelectorToken<J>
|
|
92
92
|
}>
|
|
93
93
|
export type ActorToolkit = Readonly<{
|
|
94
94
|
get: typeof getState
|
|
@@ -96,7 +96,7 @@ export type ActorToolkit = Readonly<{
|
|
|
96
96
|
find: typeof findState
|
|
97
97
|
json: <T extends Transceiver<any>, J extends Json.Serializable>(
|
|
98
98
|
state: MutableAtomToken<T, J>,
|
|
99
|
-
) =>
|
|
99
|
+
) => WritablePureSelectorToken<J>
|
|
100
100
|
dispose: typeof disposeState
|
|
101
101
|
run: typeof runTransaction
|
|
102
102
|
env: () => EnvironmentData
|
package/src/main/validators.ts
CHANGED
|
@@ -3,13 +3,13 @@ import type {
|
|
|
3
3
|
MutableAtomToken,
|
|
4
4
|
ReadableFamilyToken,
|
|
5
5
|
ReadableToken,
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
ReadonlyPureSelectorFamilyToken,
|
|
7
|
+
ReadonlyPureSelectorToken,
|
|
8
8
|
RegularAtomFamilyToken,
|
|
9
9
|
RegularAtomToken,
|
|
10
10
|
WritableFamilyToken,
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
WritablePureSelectorFamilyToken,
|
|
12
|
+
WritablePureSelectorToken,
|
|
13
13
|
WritableToken,
|
|
14
14
|
} from "atom.io"
|
|
15
15
|
|
|
@@ -29,14 +29,14 @@ export function isToken<KnownToken extends MutableAtomToken<any, any>>(
|
|
|
29
29
|
knownToken: KnownToken,
|
|
30
30
|
unknownToken: ReadableToken<any>,
|
|
31
31
|
): unknownToken is MutableAtomToken<TokenType<KnownToken>, any>
|
|
32
|
-
export function isToken<KnownToken extends
|
|
32
|
+
export function isToken<KnownToken extends WritablePureSelectorToken<any>>(
|
|
33
33
|
knownToken: KnownToken,
|
|
34
34
|
unknownToken: ReadableToken<any>,
|
|
35
|
-
): unknownToken is
|
|
36
|
-
export function isToken<KnownToken extends
|
|
35
|
+
): unknownToken is WritablePureSelectorToken<TokenType<KnownToken>>
|
|
36
|
+
export function isToken<KnownToken extends ReadonlyPureSelectorToken<any>>(
|
|
37
37
|
knownToken: KnownToken,
|
|
38
38
|
unknownToken: ReadableToken<any>,
|
|
39
|
-
): unknownToken is
|
|
39
|
+
): unknownToken is ReadonlyPureSelectorToken<TokenType<KnownToken>>
|
|
40
40
|
export function isToken<KnownToken extends WritableToken<any>>(
|
|
41
41
|
knownToken: KnownToken,
|
|
42
42
|
unknownToken: ReadableToken<any>,
|
|
@@ -60,14 +60,18 @@ export function belongsTo<Family extends MutableAtomFamilyToken<any, any, any>>(
|
|
|
60
60
|
family: Family,
|
|
61
61
|
unknownToken: ReadableToken<any>,
|
|
62
62
|
): unknownToken is MutableAtomToken<TokenType<Family>, any>
|
|
63
|
-
export function belongsTo<
|
|
63
|
+
export function belongsTo<
|
|
64
|
+
Family extends WritablePureSelectorFamilyToken<any, any>,
|
|
65
|
+
>(
|
|
64
66
|
family: Family,
|
|
65
67
|
unknownToken: ReadableToken<any>,
|
|
66
|
-
): unknownToken is
|
|
67
|
-
export function belongsTo<
|
|
68
|
+
): unknownToken is WritablePureSelectorToken<TokenType<Family>>
|
|
69
|
+
export function belongsTo<
|
|
70
|
+
Family extends ReadonlyPureSelectorFamilyToken<any, any>,
|
|
71
|
+
>(
|
|
68
72
|
family: Family,
|
|
69
73
|
unknownToken: ReadableToken<any>,
|
|
70
|
-
): unknownToken is
|
|
74
|
+
): unknownToken is ReadonlyPureSelectorToken<TokenType<Family>>
|
|
71
75
|
export function belongsTo<Family extends WritableFamilyToken<any, any>>(
|
|
72
76
|
family: Family,
|
|
73
77
|
unknownToken: ReadableToken<any>,
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
ReadonlyPureSelectorToken,
|
|
3
|
+
ReadonlySelectorToken,
|
|
4
|
+
WritableToken,
|
|
5
|
+
} from "atom.io"
|
|
2
6
|
import { useI, useO } from "atom.io/react"
|
|
3
7
|
import type { FC } from "react"
|
|
4
8
|
|
|
@@ -31,8 +35,14 @@ export const ReadonlySelectorViewer: FC<{
|
|
|
31
35
|
export const StoreEditor: FC<{
|
|
32
36
|
token: ReadonlySelectorToken<unknown> | WritableToken<unknown>
|
|
33
37
|
}> = ({ token }) => {
|
|
34
|
-
|
|
35
|
-
|
|
38
|
+
switch (token.type) {
|
|
39
|
+
case `readonly_pure_selector`:
|
|
40
|
+
case `readonly_held_selector`:
|
|
41
|
+
return <ReadonlySelectorViewer token={token} />
|
|
42
|
+
case `writable_pure_selector`:
|
|
43
|
+
case `writable_held_selector`:
|
|
44
|
+
case `atom`:
|
|
45
|
+
case `mutable_atom`:
|
|
46
|
+
return <StateEditor token={token} />
|
|
36
47
|
}
|
|
37
|
-
return <StateEditor token={token} />
|
|
38
48
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
ReadableToken,
|
|
3
|
-
|
|
3
|
+
ReadonlyPureSelectorToken,
|
|
4
4
|
RegularAtomToken,
|
|
5
5
|
} from "atom.io"
|
|
6
6
|
import { getState } from "atom.io"
|
|
@@ -19,7 +19,7 @@ import { DevtoolsContext } from "./store"
|
|
|
19
19
|
export const StateIndexLeafNode: FC<{
|
|
20
20
|
node: ReadableToken<unknown>
|
|
21
21
|
isOpenState: RegularAtomToken<boolean>
|
|
22
|
-
typeState:
|
|
22
|
+
typeState: ReadonlyPureSelectorToken<string>
|
|
23
23
|
}> = ({ node, isOpenState, typeState }) => {
|
|
24
24
|
const setIsOpen = useI(isOpenState)
|
|
25
25
|
const isOpen = useO(isOpenState)
|
|
@@ -102,7 +102,7 @@ export const StateIndexTreeNode: FC<{
|
|
|
102
102
|
export const StateIndexNode: FC<{
|
|
103
103
|
node: FamilyNode<ReadableToken<unknown>> | ReadableToken<unknown>
|
|
104
104
|
isOpenState: RegularAtomToken<boolean>
|
|
105
|
-
typeState:
|
|
105
|
+
typeState: ReadonlyPureSelectorToken<string>
|
|
106
106
|
}> = ({ node, isOpenState, typeState }) => {
|
|
107
107
|
return (
|
|
108
108
|
<section className="node state" data-testid={`state-${node.key}`}>
|
|
@@ -120,7 +120,9 @@ export const StateIndexNode: FC<{
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
export const StateIndex: FC<{
|
|
123
|
-
tokenIndex:
|
|
123
|
+
tokenIndex: ReadonlyPureSelectorToken<
|
|
124
|
+
WritableTokenIndex<ReadableToken<unknown>>
|
|
125
|
+
>
|
|
124
126
|
}> = ({ tokenIndex }) => {
|
|
125
127
|
const tokenIds = useO(tokenIndex)
|
|
126
128
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
|
|
2
|
+
ReadonlyPureSelectorToken,
|
|
3
3
|
RegularAtomToken,
|
|
4
4
|
TimelineToken,
|
|
5
5
|
} from "atom.io"
|
|
@@ -19,7 +19,7 @@ export const YouAreHere: FC = () => {
|
|
|
19
19
|
export const TimelineLog: FC<{
|
|
20
20
|
token: TimelineToken<any>
|
|
21
21
|
isOpenState: RegularAtomToken<boolean>
|
|
22
|
-
timelineState:
|
|
22
|
+
timelineState: ReadonlyPureSelectorToken<Timeline<any>>
|
|
23
23
|
}> = ({ token, isOpenState, timelineState }) => {
|
|
24
24
|
const timeline = useO(timelineState)
|
|
25
25
|
const isOpen = useO(isOpenState)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
|
|
2
|
+
ReadonlyPureSelectorToken,
|
|
3
3
|
RegularAtomToken,
|
|
4
4
|
TransactionToken,
|
|
5
5
|
TransactionUpdate,
|
|
@@ -15,7 +15,7 @@ import { article } from "./Updates"
|
|
|
15
15
|
export const TransactionLog: FC<{
|
|
16
16
|
token: TransactionToken<Func>
|
|
17
17
|
isOpenState: RegularAtomToken<boolean>
|
|
18
|
-
logState:
|
|
18
|
+
logState: ReadonlyPureSelectorToken<TransactionUpdate<Func>[]>
|
|
19
19
|
}> = ({ token, isOpenState, logState }) => {
|
|
20
20
|
const log = useO(logState)
|
|
21
21
|
const isOpen = useO(isOpenState)
|
|
@@ -2,8 +2,8 @@ import type {
|
|
|
2
2
|
AtomToken,
|
|
3
3
|
JoinToken,
|
|
4
4
|
MutableAtomToken,
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
ReadonlyPureSelectorFamilyToken,
|
|
6
|
+
ReadonlyPureSelectorToken,
|
|
7
7
|
} from "atom.io"
|
|
8
8
|
import { atom, getInternalRelations, join, selectorFamily } from "atom.io"
|
|
9
9
|
import { Join } from "atom.io/internal"
|
|
@@ -56,7 +56,7 @@ export const usersInRooms: JoinToken<
|
|
|
56
56
|
DEFAULT_USER_IN_ROOM_META,
|
|
57
57
|
)
|
|
58
58
|
|
|
59
|
-
export const usersInMyRoomView:
|
|
59
|
+
export const usersInMyRoomView: ReadonlyPureSelectorFamilyToken<
|
|
60
60
|
MutableAtomToken<SetRTX<string>, SetRTXJson<string>>[],
|
|
61
61
|
string
|
|
62
62
|
> = selectorFamily<
|
|
@@ -6,7 +6,7 @@ export const myIdState__INTERNAL: AtomIO.RegularAtomToken<string | undefined> =
|
|
|
6
6
|
key: `mySocketId__INTERNAL`,
|
|
7
7
|
default: undefined,
|
|
8
8
|
})
|
|
9
|
-
export const myIdState: AtomIO.
|
|
9
|
+
export const myIdState: AtomIO.ReadonlyPureSelectorToken<string | undefined> =
|
|
10
10
|
AtomIO.selector<string | undefined>({
|
|
11
11
|
key: `mySocketId`,
|
|
12
12
|
get: ({ get }) => get(myIdState__INTERNAL),
|
|
@@ -3,7 +3,7 @@ import { spawn } from "node:child_process"
|
|
|
3
3
|
|
|
4
4
|
import type {
|
|
5
5
|
Loadable,
|
|
6
|
-
|
|
6
|
+
ReadonlyPureSelectorFamilyToken,
|
|
7
7
|
RegularAtomFamilyToken,
|
|
8
8
|
} from "atom.io"
|
|
9
9
|
import { atomFamily, selectorFamily } from "atom.io"
|
|
@@ -20,7 +20,7 @@ export const roomArgumentsAtoms: RegularAtomFamilyToken<RoomArguments, string> =
|
|
|
20
20
|
default: [`echo`, [`Hello World!`]],
|
|
21
21
|
})
|
|
22
22
|
|
|
23
|
-
export const roomSelectors:
|
|
23
|
+
export const roomSelectors: ReadonlyPureSelectorFamilyToken<
|
|
24
24
|
Loadable<ChildSocket<any, any>>,
|
|
25
25
|
string
|
|
26
26
|
> = selectorFamily<Loadable<ChildSocket<any, any>>, string>({
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"devtools-Jyn42mZm.css","names":[],"sources":["src/react-devtools/devtools.css"],"sourcesContent":["main[data-css=\"atom_io_devtools\"] {\n\t--fg-color: #eee;\n\t--bg-color: #111;\n\t--bg-tint1: #222;\n\t--fg-border: 1px solid var(--fg-color);\n\t@media (prefers-color-scheme: light) {\n\t\t--fg-color: #444;\n\t\t--bg-color: #ddd;\n\t\t--bg-tint1: #e3e3e3;\n\t}\n\t& {\n\t\tbox-sizing: border-box;\n\t\tcolor: var(--fg-color);\n\t\tbackground-color: var(--bg-color);\n\t\tborder: 2px solid var(--fg-color);\n\t\tposition: fixed;\n\t\tright: 0;\n\t\tbottom: 0;\n\t\theight: 100%;\n\t\tdisplay: flex;\n\t\tflex-flow: column;\n\t\tmax-height: 800px;\n\t\twidth: 100%;\n\t\tmax-width: 500px;\n\t\toverflow-y: scroll;\n\t}\n\t* {\n\t\tfont-size: 16px;\n\t\tfont-family: theia, monospace;\n\t}\n\t> header {\n\t\tpadding: 5px;\n\t\tpadding-left: 10px;\n\t\tpadding-bottom: 0;\n\t\tdisplay: flex;\n\t\tjustify-content: space-between;\n\t\th1 {\n\t\t\tfont-size: inherit;\n\t\t\tmargin: 0;\n\t\t\tfont-size: 24px;\n\t\t\tfont-family: charter, serif;\n\t\t}\n\t\tnav {\n\t\t\tdisplay: flex;\n\t\t\tflex-flow: row nowrap;\n\t\t\tbutton {\n\t\t\t\tcursor: pointer;\n\t\t\t\tbackground: none;\n\t\t\t\tborder: none;\n\t\t\t\tpadding: none;\n\t\t\t\tmargin-bottom: -2px;\n\t\t\t\tz-index: 1000;\n\t\t\t\t&:disabled {\n\t\t\t\t\tcursor: default;\n\t\t\t\t\tbackground-color: var(--bg-tint1);\n\t\t\t\t\tcolor: var(--fg-color);\n\t\t\t\t\tborder: var(--fg-border);\n\t\t\t\t\tborder-bottom: none;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t> main {\n\t\tbackground: var(--bg-tint1);\n\t}\n\tmain {\n\t\toverflow-y: scroll;\n\t\tflex-grow: 1;\n\t\tdisplay: flex;\n\t\tflex-flow: column;\n\t\tgap: 0;\n\t\tarticle.index {\n\t\t\t.node .node {\n\t\t\t\tborder-right: var(--fg-border);\n\t\t\t\tpadding-right: 0;\n\t\t\t\tbackground: #fff3;\n\t\t\t}\n\t\t\t.node > .node {\n\t\t\t\tmargin: 5px 0;\n\t\t\t\tmargin-left: 12px;\n\t\t\t\tborder-left: var(--fg-border);\n\t\t\t}\n\t\t\t.node {\n\t\t\t\tborder-top: var(--fg-border);\n\t\t\t\toverflow-x: scroll;\n\t\t\t\tpadding: 5px;\n\t\t\t\t&:last-of-type {\n\t\t\t\t\tborder-bottom: var(--fg-border);\n\t\t\t\t}\n\t\t\t\t&.transaction_update {\n\t\t\t\t\tpadding: 0;\n\t\t\t\t}\n\t\t\t\theader {\n\t\t\t\t\tdisplay: flex;\n\t\t\t\t\tflex-flow: row;\n\t\t\t\t\tgap: 5px;\n\t\t\t\t\tposition: sticky;\n\t\t\t\t\tz-index: 999;\n\t\t\t\t\ttop: 0;\n\t\t\t\t\tbutton.carat {\n\t\t\t\t\t\tcursor: pointer;\n\t\t\t\t\t\tbackground: none;\n\t\t\t\t\t\tborder: none;\n\t\t\t\t\t\twidth: 20px;\n\t\t\t\t\t\t&.open {\n\t\t\t\t\t\t\ttransform: rotate(90deg);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t&:disabled {\n\t\t\t\t\t\t\tcursor: default;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t> main {\n\t\t\t\t\t\tdisplay: flex;\n\t\t\t\t\t\tflex-flow: row;\n\t\t\t\t\t\tgap: 5px;\n\t\t\t\t\t\tcursor: help;\n\t\t\t\t\t\th2 {\n\t\t\t\t\t\t\tdisplay: inline-block;\n\t\t\t\t\t\t\tmargin: 0;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t.detail {\n\t\t\t\t\t\t\tcolor: #777;\n\t\t\t\t\t\t\t@media (prefers-color-scheme: light) {\n\t\t\t\t\t\t\t\tcolor: #999;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tmain {\n\t\t\t\t\tmargin-left: 15px;\n\t\t\t\t}\n\t\t\t}\n\t\t\tsection.transaction_log {\n\t\t\t\tmargin-top: 0;\n\t\t\t\tmain {\n\t\t\t\t\tdisplay: flex;\n\t\t\t\t\tflex-flow: row wrap;\n\t\t\t\t\tgap: 5px;\n\t\t\t\t\t.transaction_update {\n\t\t\t\t\t\twidth: 100%;\n\t\t\t\t\t\tdisplay: flex;\n\t\t\t\t\t\tflex-flow: row;\n\t\t\t\t\t\talign-items: flex-start;\n\t\t\t\t\t\tjustify-content: flex-start;\n\t\t\t\t\t\tjustify-items: flex-start;\n\t\t\t\t\t\talign-content: flex-start;\n\t\t\t\t\t\tborder-left: var(--fg-border);\n\t\t\t\t\t\tborder-top: var(--fg-border);\n\t\t\t\t\t\theader {\n\t\t\t\t\t\t\tpadding: 5px;\n\t\t\t\t\t\t\th4 {\n\t\t\t\t\t\t\t\tmargin: 0;\n\t\t\t\t\t\t\t\tpadding: 0;\n\t\t\t\t\t\t\t\tfont-size: inherit;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmain {\n\t\t\t\t\t\t\tmargin-left: 0;\n\t\t\t\t\t\t\tdisplay: flex;\n\t\t\t\t\t\t\tflex-flow: column;\n\t\t\t\t\t\t\tgap: 0px;\n\t\t\t\t\t\t\tborder-left: 1px solid #333;\n\t\t\t\t\t\t\tsection ~ section {\n\t\t\t\t\t\t\t\tborder-top: 1px solid #333;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsection {\n\t\t\t\t\t\t\t\tpadding: 5px;\n\t\t\t\t\t\t\t\t&.transaction_output {\n\t\t\t\t\t\t\t\t\tborder-right: none;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t&.transaction_impact {\n\t\t\t\t\t\t\t\t\tpadding: 5px;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tmargin: 0;\n\t\t\t\t\t\t\t\tarticle {\n\t\t\t\t\t\t\t\t\tborder-left: var(--fg-border);\n\t\t\t\t\t\t\t\t\tborder-right: var(--fg-border);\n\t\t\t\t\t\t\t\t\t.summary {\n\t\t\t\t\t\t\t\t\t\twhite-space: nowrap;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tsection.timeline_log {\n\t\t\t\theader {\n\t\t\t\t\tdisplay: flex;\n\t\t\t\t\t> main {\n\t\t\t\t\t\tdisplay: flex;\n\t\t\t\t\t\twidth: 100%;\n\t\t\t\t\t\tflex-grow: 1;\n\t\t\t\t\t\t.gap {\n\t\t\t\t\t\t\tflex-grow: 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tnav {\n\t\t\t\t\t\t\tdisplay: flex;\n\t\t\t\t\t\t\tflex-flow: row nowrap;\n\t\t\t\t\t\t\tgap: 5px;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t.timeline_update {\n\t\t\t\t\tpadding: 5px;\n\t\t\t\t\tborder-left: var(--fg-border);\n\t\t\t\t\th4 {\n\t\t\t\t\t\tmargin: 0;\n\t\t\t\t\t\tpadding: 0;\n\t\t\t\t\t\tfont-size: inherit;\n\t\t\t\t\t}\n\t\t\t\t\tmain {\n\t\t\t\t\t\tmargin: 0;\n\t\t\t\t\t\t.node.atom_update {\n\t\t\t\t\t\t\tborder-left: var(--fg-border);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t.you_are_here {\n\t\t\t\t\tbackground: var(--fg-color);\n\t\t\t\t\tcolor: var(--bg-color);\n\t\t\t\t\ttext-align: center;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfooter {\n\t\tdisplay: flex;\n\t\tjustify-content: flex-end;\n\t\tbutton {\n\t\t\tcursor: pointer;\n\t\t\tbackground: none;\n\t\t\tborder: none;\n\t\t\tpadding: none;\n\t\t\tposition: absolute;\n\t\t\tright: 0;\n\t\t\tbottom: 0;\n\t\t}\n\t}\n\n\t.json_editor {\n\t\tinput {\n\t\t\tfont-family: theia, monospace;\n\t\t\tborder: none;\n\t\t\tborder-bottom: 1px solid;\n\t\t\tbackground: none;\n\t\t\t&:disabled {\n\t\t\t\tborder: none;\n\t\t\t}\n\t\t}\n\t\tbutton {\n\t\t\tbackground: none;\n\t\t\tcolor: #777;\n\t\t\tborder: none;\n\t\t\tfont-family: theia, monospace;\n\t\t\tfont-size: 14px;\n\t\t\tmargin: none;\n\t\t\tpadding: 4px;\n\t\t\tpadding-bottom: 6px;\n\t\t\tcursor: pointer;\n\t\t\t&:hover {\n\t\t\t\tcolor: #333;\n\t\t\t\tbackground-color: #aaa;\n\t\t\t}\n\t\t}\n\t\tselect {\n\t\t\tfont-family: theia, monospace;\n\t\t\tfont-size: 14px;\n\t\t\tbackground: none;\n\t\t\tborder: none;\n\t\t\tcolor: #777;\n\t\t\t@media (prefers-color-scheme: light) {\n\t\t\t\tcolor: #999;\n\t\t\t}\n\t\t}\n\t\t.json_editor_unofficial {\n\t\t\tbackground-color: #777;\n\t\t\tbutton {\n\t\t\t\tcolor: #333;\n\t\t\t}\n\t\t}\n\t\t.json_editor_missing {\n\t\t\tbackground-color: #f055;\n\t\t}\n\t\t.json_editor_key {\n\t\t\tpadding-right: 10px;\n\t\t\tinput {\n\t\t\t\tcolor: #999;\n\t\t\t\t@media (prefers-color-scheme: light) {\n\t\t\t\t\tcolor: #777;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t.json_editor_object {\n\t\t\tborder-left: 2px solid #333;\n\t\t\tpadding-left: 20px;\n\t\t\t@media (prefers-color-scheme: light) {\n\t\t\t\tborder-color: #ccc;\n\t\t\t}\n\t\t\t.json_editor_properties {\n\t\t\t\t> * {\n\t\t\t\t\tborder-bottom: var(--fg-border);\n\t\t\t\t\tmargin-bottom: 2px;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
FamilyMetadata,
|
|
3
|
-
ReadonlySelectorOptions,
|
|
4
|
-
ReadonlySelectorToken,
|
|
5
|
-
} from "atom.io"
|
|
6
|
-
|
|
7
|
-
import type { ReadonlySelector } from ".."
|
|
8
|
-
import { cacheValue } from "../caching"
|
|
9
|
-
import { newest } from "../lineage"
|
|
10
|
-
import type { Store } from "../store"
|
|
11
|
-
import { Subject } from "../subject"
|
|
12
|
-
import { registerSelector } from "./register-selector"
|
|
13
|
-
|
|
14
|
-
export const createReadonlySelector = <T>(
|
|
15
|
-
store: Store,
|
|
16
|
-
options: ReadonlySelectorOptions<T>,
|
|
17
|
-
family: FamilyMetadata | undefined,
|
|
18
|
-
): ReadonlySelectorToken<T> => {
|
|
19
|
-
const target = newest(store)
|
|
20
|
-
const subject = new Subject<{ newValue: T; oldValue: T }>()
|
|
21
|
-
const covered = new Set<string>()
|
|
22
|
-
const { get, find, json } = registerSelector(options.key, covered, target)
|
|
23
|
-
const getSelf = () => {
|
|
24
|
-
const value = options.get({ get, find, json })
|
|
25
|
-
cacheValue(newest(store), options.key, value, subject)
|
|
26
|
-
covered.clear()
|
|
27
|
-
return value
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const readonlySelector: ReadonlySelector<T> = {
|
|
31
|
-
...options,
|
|
32
|
-
subject,
|
|
33
|
-
install: (s: Store) => createReadonlySelector(s, options, family),
|
|
34
|
-
get: getSelf,
|
|
35
|
-
type: `readonly_selector`,
|
|
36
|
-
...(family && { family }),
|
|
37
|
-
}
|
|
38
|
-
target.readonlySelectors.set(options.key, readonlySelector)
|
|
39
|
-
const initialValue = getSelf()
|
|
40
|
-
store.logger.info(
|
|
41
|
-
`✨`,
|
|
42
|
-
readonlySelector.type,
|
|
43
|
-
readonlySelector.key,
|
|
44
|
-
`=`,
|
|
45
|
-
initialValue,
|
|
46
|
-
)
|
|
47
|
-
const token: ReadonlySelectorToken<T> = {
|
|
48
|
-
key: options.key,
|
|
49
|
-
type: `readonly_selector`,
|
|
50
|
-
}
|
|
51
|
-
if (family) {
|
|
52
|
-
token.family = family
|
|
53
|
-
}
|
|
54
|
-
return token
|
|
55
|
-
}
|