atom.io 0.9.6 → 0.9.8
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 +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/internal/dist/index.d.mts +1 -0
- package/internal/dist/index.d.ts +1 -0
- package/internal/dist/index.js +36 -17
- package/internal/dist/index.js.map +1 -1
- package/internal/dist/index.mjs +36 -17
- package/internal/dist/index.mjs.map +1 -1
- package/internal/src/timeline/add-atom-to-timeline.ts +24 -7
- package/internal/src/timeline/timeline-internal.ts +12 -3
- package/package.json +4 -4
- package/react-devtools/dist/index.d.mts +1 -0
- package/react-devtools/dist/index.d.ts +1 -0
- package/src/timeline.ts +2 -0
|
@@ -109,9 +109,13 @@ export const addAtomToTimeline = (
|
|
|
109
109
|
...update,
|
|
110
110
|
atomUpdates,
|
|
111
111
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
112
|
+
const willCapture =
|
|
113
|
+
tl.shouldCapture?.(timelineTransactionUpdate, tl) ?? true
|
|
114
|
+
if (willCapture) {
|
|
115
|
+
tl.history.push(timelineTransactionUpdate)
|
|
116
|
+
tl.at = tl.history.length
|
|
117
|
+
tl.subject.next(timelineTransactionUpdate)
|
|
118
|
+
}
|
|
115
119
|
}
|
|
116
120
|
tl.transactionKey = null
|
|
117
121
|
store.config.logger?.info(
|
|
@@ -138,6 +142,7 @@ export const addAtomToTimeline = (
|
|
|
138
142
|
if (tl.at !== tl.history.length) {
|
|
139
143
|
tl.history.splice(tl.at)
|
|
140
144
|
}
|
|
145
|
+
|
|
141
146
|
tl.history.push(latestUpdate)
|
|
142
147
|
|
|
143
148
|
store.config.logger?.info(
|
|
@@ -160,7 +165,16 @@ export const addAtomToTimeline = (
|
|
|
160
165
|
)
|
|
161
166
|
}
|
|
162
167
|
}
|
|
163
|
-
if (latestUpdate)
|
|
168
|
+
if (latestUpdate) {
|
|
169
|
+
const willCaptureSelectorUpdate =
|
|
170
|
+
tl.shouldCapture?.(latestUpdate, tl) ?? true
|
|
171
|
+
if (willCaptureSelectorUpdate) {
|
|
172
|
+
tl.subject.next(latestUpdate)
|
|
173
|
+
} else {
|
|
174
|
+
tl.history.pop()
|
|
175
|
+
tl.at = tl.history.length
|
|
176
|
+
}
|
|
177
|
+
}
|
|
164
178
|
} else {
|
|
165
179
|
const timestamp = Date.now()
|
|
166
180
|
tl.selectorTime = null
|
|
@@ -177,12 +191,15 @@ export const addAtomToTimeline = (
|
|
|
177
191
|
if (atom.family) {
|
|
178
192
|
atomUpdate.family = atom.family
|
|
179
193
|
}
|
|
180
|
-
tl.
|
|
181
|
-
tl.subject.next(atomUpdate)
|
|
194
|
+
const willCapture = tl.shouldCapture?.(atomUpdate, tl) ?? true
|
|
182
195
|
store.config.logger?.info(
|
|
183
196
|
`⌛ timeline "${tl.key}" got an atom_update to "${atom.key}"`,
|
|
184
197
|
)
|
|
185
|
-
|
|
198
|
+
if (willCapture) {
|
|
199
|
+
tl.history.push(atomUpdate)
|
|
200
|
+
tl.at = tl.history.length
|
|
201
|
+
tl.subject.next(atomUpdate)
|
|
202
|
+
}
|
|
186
203
|
}
|
|
187
204
|
}
|
|
188
205
|
})
|
|
@@ -36,6 +36,7 @@ export type Timeline = {
|
|
|
36
36
|
type: `timeline`
|
|
37
37
|
key: string
|
|
38
38
|
at: number
|
|
39
|
+
shouldCapture?: (update: TimelineUpdate, timeline: Timeline) => boolean
|
|
39
40
|
timeTraveling: `into_future` | `into_past` | null
|
|
40
41
|
history: TimelineUpdate[]
|
|
41
42
|
selectorTime: number | null
|
|
@@ -67,6 +68,9 @@ export function timeline__INTERNAL(
|
|
|
67
68
|
install: (store) => timeline__INTERNAL(options, store, tl),
|
|
68
69
|
subject: new Subject(),
|
|
69
70
|
}
|
|
71
|
+
if (options.shouldCapture) {
|
|
72
|
+
tl.shouldCapture = options.shouldCapture
|
|
73
|
+
}
|
|
70
74
|
|
|
71
75
|
const core = target(store)
|
|
72
76
|
for (const tokenOrFamily of options.atoms) {
|
|
@@ -80,10 +84,15 @@ export function timeline__INTERNAL(
|
|
|
80
84
|
if (tokenOrFamily.type === `atom_family`) {
|
|
81
85
|
const family = tokenOrFamily
|
|
82
86
|
family.subject.subscribe(`timeline:${options.key}`, (token) => {
|
|
83
|
-
if (!core.atoms.has(token.key)) {
|
|
84
|
-
|
|
85
|
-
}
|
|
87
|
+
// if (!core.atoms.has(token.key)) {
|
|
88
|
+
addAtomToTimeline(token, tl, store)
|
|
89
|
+
// }
|
|
86
90
|
})
|
|
91
|
+
for (const atom of core.atoms.values()) {
|
|
92
|
+
if (atom.family?.key === family.key) {
|
|
93
|
+
addAtomToTimeline(atom, tl, store)
|
|
94
|
+
}
|
|
95
|
+
}
|
|
87
96
|
} else {
|
|
88
97
|
const token = tokenOrFamily
|
|
89
98
|
if (`family` in token && token.family) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "atom.io",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.8",
|
|
4
4
|
"description": "Composable and testable reactive data library.",
|
|
5
5
|
"homepage": "https://atom.io.fyi",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -56,13 +56,13 @@
|
|
|
56
56
|
"@vitest/coverage-v8": "0.34.6",
|
|
57
57
|
"concurrently": "8.2.2",
|
|
58
58
|
"eslint": "8.53.0",
|
|
59
|
-
"framer-motion": "10.16.
|
|
59
|
+
"framer-motion": "10.16.5",
|
|
60
60
|
"happy-dom": "12.10.3",
|
|
61
61
|
"npmlog": "7.0.1",
|
|
62
|
-
"preact": "10.
|
|
62
|
+
"preact": "10.19.2",
|
|
63
63
|
"react": "18.2.0",
|
|
64
64
|
"react-dom": "18.2.0",
|
|
65
|
-
"react-router-dom": "6.
|
|
65
|
+
"react-router-dom": "6.19.0",
|
|
66
66
|
"socket.io": "4.7.2",
|
|
67
67
|
"socket.io-client": "4.7.2",
|
|
68
68
|
"tmp": "0.2.1",
|
|
@@ -196,6 +196,7 @@ type Timeline = {
|
|
|
196
196
|
type: `timeline`;
|
|
197
197
|
key: string;
|
|
198
198
|
at: number;
|
|
199
|
+
shouldCapture?: (update: TimelineUpdate, timeline: Timeline) => boolean;
|
|
199
200
|
timeTraveling: `into_future` | `into_past` | null;
|
|
200
201
|
history: TimelineUpdate[];
|
|
201
202
|
selectorTime: number | null;
|
|
@@ -196,6 +196,7 @@ type Timeline = {
|
|
|
196
196
|
type: `timeline`;
|
|
197
197
|
key: string;
|
|
198
198
|
at: number;
|
|
199
|
+
shouldCapture?: (update: TimelineUpdate, timeline: Timeline) => boolean;
|
|
199
200
|
timeTraveling: `into_future` | `into_past` | null;
|
|
200
201
|
history: TimelineUpdate[];
|
|
201
202
|
selectorTime: number | null;
|
package/src/timeline.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type {
|
|
2
|
+
Timeline,
|
|
2
3
|
TimelineAtomUpdate,
|
|
3
4
|
TimelineSelectorUpdate,
|
|
4
5
|
TimelineTransactionUpdate,
|
|
@@ -20,6 +21,7 @@ export type TimelineToken = {
|
|
|
20
21
|
export type TimelineOptions = {
|
|
21
22
|
key: string
|
|
22
23
|
atoms: (AtomFamily<any, any> | AtomToken<any>)[]
|
|
24
|
+
shouldCapture?: (update: TimelineUpdate, timeline: Timeline) => boolean
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
export type TimelineUpdate =
|