atom.io 0.9.9 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +11 -4
- package/dist/index.d.ts +11 -4
- package/dist/index.js +36 -56
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -55
- package/dist/index.mjs.map +1 -1
- package/internal/dist/index.d.mts +52 -25
- package/internal/dist/index.d.ts +52 -25
- package/internal/dist/index.js +352 -385
- package/internal/dist/index.js.map +1 -1
- package/internal/dist/index.mjs +349 -385
- package/internal/dist/index.mjs.map +1 -1
- package/internal/src/atom/create-atom.ts +5 -5
- package/internal/src/atom/delete-atom.ts +9 -2
- package/internal/src/atom/is-default.ts +2 -2
- package/internal/src/caching.ts +7 -5
- package/internal/src/get-state-internal.ts +4 -4
- package/internal/src/index.ts +1 -0
- package/internal/src/keys.ts +30 -0
- package/internal/src/mutable/create-mutable-atom.ts +2 -2
- package/internal/src/mutable/tracker.ts +1 -1
- package/internal/src/operation.ts +7 -7
- package/internal/src/selector/create-read-write-selector.ts +2 -8
- package/internal/src/selector/create-readonly-selector.ts +1 -1
- package/internal/src/selector/create-selector.ts +5 -3
- package/internal/src/selector/get-selector-dependency-keys.ts +20 -0
- package/internal/src/selector/index.ts +1 -1
- package/internal/src/selector/register-selector.ts +4 -11
- package/internal/src/selector/trace-selector-atoms.ts +26 -26
- package/internal/src/selector/update-selector-atoms.ts +14 -14
- package/internal/src/set-state/copy-mutable-if-needed.ts +1 -1
- package/internal/src/set-state/copy-mutable-in-transaction.ts +1 -1
- package/internal/src/set-state/emit-update.ts +1 -1
- package/internal/src/set-state/evict-downstream.ts +5 -6
- package/internal/src/set-state/set-atom.ts +1 -4
- package/internal/src/set-state/stow-update.ts +10 -4
- package/internal/src/store/index.ts +0 -1
- package/internal/src/store/store.ts +27 -10
- package/internal/src/store/withdraw-new-family-member.ts +1 -1
- package/internal/src/store/withdraw.ts +1 -1
- package/internal/src/subscribe/recall-state.ts +2 -2
- package/internal/src/subscribe/subscribe-to-root-atoms.ts +7 -8
- package/internal/src/timeline/add-atom-to-timeline.ts +8 -8
- package/internal/src/timeline/time-travel-internal.ts +12 -12
- package/internal/src/timeline/timeline-internal.ts +2 -2
- package/internal/src/transaction/abort-transaction.ts +3 -3
- package/internal/src/transaction/apply-transaction.ts +6 -6
- package/internal/src/transaction/build-transaction.ts +2 -3
- package/internal/src/transaction/redo-transaction.ts +1 -1
- package/internal/src/transaction/transaction-internal.ts +2 -2
- package/internal/src/transaction/undo-transaction.ts +1 -1
- package/package.json +3 -3
- package/react-devtools/dist/index.d.mts +3 -3
- package/react-devtools/dist/index.d.ts +3 -3
- package/realtime-client/dist/index.js +6 -9
- package/realtime-client/dist/index.js.map +1 -1
- package/realtime-client/dist/index.mjs +6 -9
- package/realtime-client/dist/index.mjs.map +1 -1
- package/realtime-client/src/use-server-action.ts +6 -8
- package/src/atom.ts +3 -0
- package/src/logger.ts +25 -36
- package/src/subscribe.ts +7 -7
- package/internal/src/selector/lookup-selector-sources.ts +0 -20
- package/internal/src/store/lookup.ts +0 -26
package/src/subscribe.ts
CHANGED
|
@@ -32,18 +32,18 @@ export function subscribe<T>(
|
|
|
32
32
|
)
|
|
33
33
|
}
|
|
34
34
|
const unsubFunction = state.subject.subscribe(key, handleUpdate)
|
|
35
|
-
store.
|
|
35
|
+
store.logger.info(`👀 adding subscription "${key}" to "${state.key}"`)
|
|
36
36
|
const dependencyUnsubFunctions =
|
|
37
37
|
state.type !== `atom` ? subscribeToRootAtoms(state, store) : null
|
|
38
38
|
|
|
39
39
|
const unsubscribe =
|
|
40
40
|
dependencyUnsubFunctions === null
|
|
41
41
|
? () => {
|
|
42
|
-
store.
|
|
42
|
+
store.logger.info(`🙈 unsubscribe from "${state.key}"`)
|
|
43
43
|
unsubFunction()
|
|
44
44
|
}
|
|
45
45
|
: () => {
|
|
46
|
-
store.
|
|
46
|
+
store.logger.info(
|
|
47
47
|
`🙈 unsubscribe from "${state.key}" and its dependencies`,
|
|
48
48
|
)
|
|
49
49
|
unsubFunction()
|
|
@@ -71,10 +71,10 @@ export const subscribeToTransaction = <ƒ extends ƒn>(
|
|
|
71
71
|
`Cannot subscribe to transaction "${token.key}": transaction not found in store "${store.config.name}".`,
|
|
72
72
|
)
|
|
73
73
|
}
|
|
74
|
-
store.
|
|
74
|
+
store.logger.info(`👀 subscribe to transaction "${token.key}"`)
|
|
75
75
|
const unsubscribe = tx.subject.subscribe(key, handleUpdate)
|
|
76
76
|
return () => {
|
|
77
|
-
store.
|
|
77
|
+
store.logger.info(`🙈 unsubscribe from transaction "${token.key}"`)
|
|
78
78
|
unsubscribe()
|
|
79
79
|
}
|
|
80
80
|
}
|
|
@@ -91,10 +91,10 @@ export const subscribeToTimeline = (
|
|
|
91
91
|
`Cannot subscribe to timeline "${token.key}": timeline not found in store "${store.config.name}".`,
|
|
92
92
|
)
|
|
93
93
|
}
|
|
94
|
-
store.
|
|
94
|
+
store.logger.info(`👀 subscribe to timeline "${token.key}"`)
|
|
95
95
|
const unsubscribe = tl.subject.subscribe(key, handleUpdate)
|
|
96
96
|
return () => {
|
|
97
|
-
store.
|
|
97
|
+
store.logger.info(`🙈 unsubscribe from timeline "${token.key}"`)
|
|
98
98
|
unsubscribe()
|
|
99
99
|
}
|
|
100
100
|
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { AtomToken, ReadonlySelectorToken, SelectorToken } from "atom.io"
|
|
2
|
-
|
|
3
|
-
import type { Store } from "../store"
|
|
4
|
-
import { lookup } from "../store"
|
|
5
|
-
import { target } from "../transaction"
|
|
6
|
-
|
|
7
|
-
export const lookupSelectorSources = (
|
|
8
|
-
key: string,
|
|
9
|
-
store: Store,
|
|
10
|
-
): (
|
|
11
|
-
| AtomToken<unknown>
|
|
12
|
-
| ReadonlySelectorToken<unknown>
|
|
13
|
-
| SelectorToken<unknown>
|
|
14
|
-
)[] => {
|
|
15
|
-
const sources = target(store)
|
|
16
|
-
.selectorGraph.getRelationEntries({ downstreamSelectorKey: key })
|
|
17
|
-
.filter(([_, { source }]) => source !== key)
|
|
18
|
-
.map(([_, { source }]) => lookup(source, store))
|
|
19
|
-
return sources
|
|
20
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { AtomToken, ReadonlySelectorToken, SelectorToken } from "atom.io"
|
|
2
|
-
|
|
3
|
-
import { target } from "../transaction"
|
|
4
|
-
import type { Store } from "./store"
|
|
5
|
-
|
|
6
|
-
export function lookup(
|
|
7
|
-
key: string,
|
|
8
|
-
store: Store,
|
|
9
|
-
): AtomToken<unknown> | ReadonlySelectorToken<unknown> | SelectorToken<unknown> {
|
|
10
|
-
const core = target(store)
|
|
11
|
-
let type: string = core.atoms.has(key)
|
|
12
|
-
? `atom`
|
|
13
|
-
: core.selectors.has(key)
|
|
14
|
-
? `selector`
|
|
15
|
-
: core.readonlySelectors.has(key)
|
|
16
|
-
? `readonly_selector`
|
|
17
|
-
: ``
|
|
18
|
-
if (!type) {
|
|
19
|
-
const errorId = Math.random().toString(36)
|
|
20
|
-
type = `🚨 This state could not be found by lookup! Check the console for "${errorId}"`
|
|
21
|
-
store.config.logger?.error(
|
|
22
|
-
`${errorId}: Key "${key}" does not exist in the store.`,
|
|
23
|
-
)
|
|
24
|
-
}
|
|
25
|
-
return { key, type } as any
|
|
26
|
-
}
|