@lukekaalim/act-insight 1.1.0 → 2.0.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/CHANGELOG.md +14 -0
- package/InsightApp.module.css +36 -0
- package/InsightApp2.ts +82 -0
- package/TreeViewer.module.css +3 -8
- package/TreeViewer.ts +16 -12
- package/Virtual.ts +29 -11
- package/assets/icons/ancestor_column.png +0 -0
- package/assets/icons/ancestor_column.svg +26 -0
- package/assets/icons/ancestor_skip_row_column.png +0 -0
- package/assets/icons/ancestor_skip_row_column.svg +52 -0
- package/assets/icons/breakpoint.png +0 -0
- package/assets/icons/breakpoint.svg +33 -0
- package/assets/icons/breakpoint_arrow.png +0 -0
- package/assets/icons/breakpoint_arrow.svg +22 -0
- package/assets/icons/breakpoint_arrow_paused.png +0 -0
- package/assets/icons/breakpoint_arrow_paused.svg +38 -0
- package/assets/icons/breakpoint_panel.png +0 -0
- package/assets/icons/breakpoint_panel.svg +121 -0
- package/assets/icons/breakpoint_unset.png +0 -0
- package/assets/icons/breakpoint_unset.svg +26 -0
- package/assets/icons/bug.png +0 -0
- package/assets/icons/bug.svg +65 -0
- package/assets/icons/children.png +0 -0
- package/assets/icons/children.svg +38 -0
- package/assets/icons/collapse.png +0 -0
- package/assets/icons/collapse.svg +38 -0
- package/assets/icons/commit.png +0 -0
- package/assets/icons/commit.svg +30 -0
- package/assets/icons/commit_tree.png +0 -0
- package/assets/icons/commit_tree.svg +44 -0
- package/assets/icons/effect.png +0 -0
- package/assets/icons/effect.svg +28 -0
- package/assets/icons/expand.png +0 -0
- package/assets/icons/expand.svg +47 -0
- package/assets/icons/eye.png +0 -0
- package/assets/icons/eye.svg +36 -0
- package/assets/icons/eye_closed.png +0 -0
- package/assets/icons/eye_closed.svg +32 -0
- package/assets/icons/filter.png +0 -0
- package/assets/icons/filter.svg +22 -0
- package/assets/icons/graph.png +0 -0
- package/assets/icons/graph.svg +129 -0
- package/assets/icons/history_list.png +0 -0
- package/assets/icons/history_list.svg +60 -0
- package/assets/icons/hook.png +0 -0
- package/assets/icons/hook.svg +22 -0
- package/assets/icons/index.ts +76 -0
- package/assets/icons/inspector_panel.png +0 -0
- package/assets/icons/inspector_panel.svg +135 -0
- package/assets/icons/magnifying_glass.png +0 -0
- package/assets/icons/magnifying_glass.svg +39 -0
- package/assets/icons/pause.png +0 -0
- package/assets/icons/pause.svg +34 -0
- package/assets/icons/play.png +0 -0
- package/assets/icons/play.svg +23 -0
- package/assets/icons/reload.png +0 -0
- package/assets/icons/reload.svg +39 -0
- package/assets/icons/selection.png +0 -0
- package/assets/icons/selection.svg +22 -0
- package/assets/icons/side_effects.png +0 -0
- package/assets/icons/side_effects.svg +48 -0
- package/assets/icons/skip.png +0 -0
- package/assets/icons/skip.svg +22 -0
- package/assets/icons/source.svg +1366 -0
- package/assets/icons/step.png +0 -0
- package/assets/icons/step.svg +51 -0
- package/assets/icons/step_over_children.png +0 -0
- package/assets/icons/step_over_children.svg +57 -0
- package/assets/icons/thread.png +0 -0
- package/assets/icons/thread.svg +32 -0
- package/assets/icons/tree_column.png +0 -0
- package/assets/icons/tree_column.svg +26 -0
- package/assets/icons/tree_end.png +0 -0
- package/assets/icons/tree_end.svg +35 -0
- package/assets/icons/tree_junction.png +0 -0
- package/assets/icons/tree_junction.svg +35 -0
- package/assets/icons/vertical_grab_handle.png +0 -0
- package/assets/icons/vertical_grab_handle.svg +36 -0
- package/components/BreakpointPanel.ts +110 -0
- package/components/BreakpointToggle.ts +14 -0
- package/components/Button.ts +53 -0
- package/components/Checkbox.ts +17 -0
- package/components/CommitInspector.ts +161 -0
- package/components/CommitTree.ts +295 -0
- package/components/ControlBar.ts +60 -0
- package/components/EffectTable.ts +125 -0
- package/components/FiltersPanel.ts +45 -0
- package/components/HistoryList.ts +0 -0
- package/components/InspectorPanel.ts +54 -0
- package/components/PlaybackBar.ts +42 -0
- package/components/ThreadInspector.ts +26 -0
- package/components/index.module.css +414 -0
- package/lib/controller.ts +222 -0
- package/lib/list.ts +82 -0
- package/lib/selection.ts +32 -0
- package/package.json +4 -4
- package/public/icons/icons.svg +520 -0
- package/public/icons/icons__breakpoint.png +0 -0
- package/public/icons/icons__breakpoint.svg +30 -0
- package/public/icons/icons__breakpoint_panel.png +0 -0
- package/public/icons/icons__breakpoint_panel.svg +121 -0
- package/public/icons/icons__children.png +0 -0
- package/public/icons/icons__children.svg +38 -0
- package/public/icons/icons__eye.png +0 -0
- package/public/icons/icons__eye.svg +36 -0
- package/public/icons/icons__inspector_panel.png +0 -0
- package/public/icons/icons__inspector_panel.svg +131 -0
- package/public/icons/icons__magnifying_glass.png +0 -0
- package/public/icons/icons__magnifying_glass.svg +39 -0
- package/public/icons/icons__pause.png +0 -0
- package/public/icons/icons__pause.svg +34 -0
- package/public/icons/icons__play.png +0 -0
- package/public/icons/icons__play.svg +23 -0
- package/public/icons/icons__skip.png +0 -0
- package/public/icons/icons__skip.svg +22 -0
- package/public/icons/icons__step.png +0 -0
- package/public/icons/icons__step.svg +51 -0
- package/utils.ts +71 -7
- package/InsightApp.ts +0 -404
- package/MenuBar.module.css +0 -18
- package/MenuBar.ts +0 -39
- package/ScheduleControls.ts +0 -61
- package/lookup.ts +0 -185
package/InsightApp.ts
DELETED
|
@@ -1,404 +0,0 @@
|
|
|
1
|
-
import { Component, h, useEffect, useMemo, useRef, useState } from '@lukekaalim/act';
|
|
2
|
-
import { CommitDetailsReport, CommitReport, DeltaReport, ReconcilerDebugController, ReconcilerDebugEventBus, ThreadReport, updateTreeReport, ValueReport, WorkTaskReport } from '@lukekaalim/act-debug';
|
|
3
|
-
import { CommitID } from '@lukekaalim/act-recon';
|
|
4
|
-
import { CommitPreview, TreeViewer } from './TreeViewer';
|
|
5
|
-
import { ScheduleControls } from './ScheduleControls';
|
|
6
|
-
import { CommitLookupCache, ThreadLookupCache } from './lookup';
|
|
7
|
-
import { Virtual1D } from './Virtual';
|
|
8
|
-
import { CommitAttributeTag } from './AttributeTag';
|
|
9
|
-
|
|
10
|
-
export type InsightAppProps = {
|
|
11
|
-
controller: ReconcilerDebugController,
|
|
12
|
-
bus: ReconcilerDebugEventBus,
|
|
13
|
-
|
|
14
|
-
document: Document,
|
|
15
|
-
|
|
16
|
-
onReady(): void,
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export type InsightAppState = {
|
|
20
|
-
breakOnAfterUpdate: boolean,
|
|
21
|
-
breakOnBeforeUpdate: boolean,
|
|
22
|
-
|
|
23
|
-
commitBreakpoints: Set<CommitID>,
|
|
24
|
-
|
|
25
|
-
paused: boolean,
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const INSIGHT_SETTINGS_LOCALSTORAGE_KEY = `INSIGHT_SETTINGS`;
|
|
29
|
-
|
|
30
|
-
export const InsightApp: Component<InsightAppProps> = ({ onReady, controller, bus, document = window.document }) => {
|
|
31
|
-
const [c, setRenderCounter] = useState(0);
|
|
32
|
-
|
|
33
|
-
const storedState = useMemo(() => {
|
|
34
|
-
const settings = window.localStorage.getItem(INSIGHT_SETTINGS_LOCALSTORAGE_KEY)
|
|
35
|
-
if (!settings)
|
|
36
|
-
return;
|
|
37
|
-
return JSON.parse(settings) as { breakOnAfterUpdate: boolean, breakOnBeforeUpdate: boolean };
|
|
38
|
-
}, [])
|
|
39
|
-
|
|
40
|
-
const [insightState, setInsightState] = useState<InsightAppState>({
|
|
41
|
-
commitBreakpoints: new Set(),
|
|
42
|
-
breakOnAfterUpdate: storedState ? storedState.breakOnAfterUpdate : false,
|
|
43
|
-
breakOnBeforeUpdate: storedState ? storedState.breakOnBeforeUpdate : false,
|
|
44
|
-
paused: false,
|
|
45
|
-
});
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
window.localStorage.setItem(INSIGHT_SETTINGS_LOCALSTORAGE_KEY, JSON.stringify({
|
|
48
|
-
breakOnAfterUpdate: insightState.breakOnAfterUpdate,
|
|
49
|
-
breakOnBeforeUpdate: insightState.breakOnBeforeUpdate,
|
|
50
|
-
}))
|
|
51
|
-
}, [insightState])
|
|
52
|
-
|
|
53
|
-
const commitCache = useRef(() => new CommitLookupCache()).current;
|
|
54
|
-
const deltaCache = useRef(() => new ThreadLookupCache(commitCache)).current;
|
|
55
|
-
|
|
56
|
-
useMemo(() => {
|
|
57
|
-
commitCache.setTree(controller.getTree())
|
|
58
|
-
deltaCache.reset();
|
|
59
|
-
}, [])
|
|
60
|
-
|
|
61
|
-
useEffect(() => {
|
|
62
|
-
console.log('[Insight] Populate Cache')
|
|
63
|
-
|
|
64
|
-
bus.externalUpdate = () => {
|
|
65
|
-
const delta = controller.getDelta();
|
|
66
|
-
const thread = controller.getThread();
|
|
67
|
-
|
|
68
|
-
commitCache.setTree(controller.getTree())
|
|
69
|
-
|
|
70
|
-
deltaCache.ingestDelta(delta);
|
|
71
|
-
deltaCache.ingestThread(thread);
|
|
72
|
-
setRenderCounter(c => c + 1);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
bus.onThreadDone = (thread, delta) => {
|
|
76
|
-
console.log('[Insight] ThreadDone')
|
|
77
|
-
commitCache.ingest(delta);
|
|
78
|
-
deltaCache.ingestDelta(delta);
|
|
79
|
-
deltaCache.ingestThread(thread);
|
|
80
|
-
deltaCache.prevTask = null;
|
|
81
|
-
setRenderCounter(c => c + 1);
|
|
82
|
-
|
|
83
|
-
for (const subscriber of cacheSubscribers) {
|
|
84
|
-
subscriber();
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
bus.thread.onQueue = (reason) => {
|
|
88
|
-
console.log('[Insight] OnQueue')
|
|
89
|
-
const thread = controller.getThread();
|
|
90
|
-
|
|
91
|
-
if (thread.reasons.length === 1) {
|
|
92
|
-
if (insightState.breakOnBeforeUpdate)
|
|
93
|
-
controller.scheduler.intercept = true;
|
|
94
|
-
|
|
95
|
-
commitCache.setTree(controller.getTree())
|
|
96
|
-
|
|
97
|
-
deltaCache.reset();
|
|
98
|
-
deltaCache.ingestThread(thread);
|
|
99
|
-
setRenderCounter(c => c + 1);
|
|
100
|
-
|
|
101
|
-
for (const subscriber of cacheSubscribers) {
|
|
102
|
-
subscriber();
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
bus.thread.onWork = (prevTask, nextTask, isDone) => {
|
|
107
|
-
|
|
108
|
-
if (insightState.breakOnAfterUpdate && isDone) {
|
|
109
|
-
controller.scheduler.intercept = true;
|
|
110
|
-
}
|
|
111
|
-
if (nextTask && insightState.commitBreakpoints.has(nextTask.id)) {
|
|
112
|
-
controller.scheduler.intercept = true;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
if (controller.scheduler.intercept) {
|
|
116
|
-
const thread = controller.getThread();
|
|
117
|
-
const delta = controller.getDelta();
|
|
118
|
-
|
|
119
|
-
deltaCache.ingestDelta(delta);
|
|
120
|
-
deltaCache.ingestThread(thread);
|
|
121
|
-
setRenderCounter(c => c + 1);
|
|
122
|
-
|
|
123
|
-
for (const subscriber of cacheSubscribers) {
|
|
124
|
-
subscriber();
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
if (prevTask)
|
|
128
|
-
deltaCache.prevTask = prevTask;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
onReady();
|
|
133
|
-
}, [controller, bus, insightState]);
|
|
134
|
-
|
|
135
|
-
const cacheSubscribers = useRef<Set<() => void>>(new Set()).current;
|
|
136
|
-
|
|
137
|
-
const scrollToCommitIndex = useMemo(() => {
|
|
138
|
-
return (index: number) => {
|
|
139
|
-
if (!viewportRef.current)
|
|
140
|
-
return;
|
|
141
|
-
const viewPortRect = viewportRef.current.getBoundingClientRect();
|
|
142
|
-
if (index) {
|
|
143
|
-
viewportRef.current.scrollTo({
|
|
144
|
-
top: (index * 33) - (viewPortRect.height / 2),
|
|
145
|
-
behavior: 'smooth'
|
|
146
|
-
})
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}, []);
|
|
151
|
-
|
|
152
|
-
useEffect(() => {
|
|
153
|
-
const { nextTask, prevTask } = deltaCache;
|
|
154
|
-
|
|
155
|
-
const task = nextTask || prevTask;
|
|
156
|
-
const index = task && commits.findIndex(c => (nextTask && c.id === nextTask.id) || (prevTask && prevTask.id === c.id));
|
|
157
|
-
|
|
158
|
-
if (index && index !== -1) {
|
|
159
|
-
scrollToCommitIndex(index);
|
|
160
|
-
}
|
|
161
|
-
}, [deltaCache.prevTask, deltaCache.nextTask, scrollToCommitIndex])
|
|
162
|
-
|
|
163
|
-
const renderCommit = useMemo(() => (commitId: CommitID) => {
|
|
164
|
-
return h(CommitComponent, { commitId })
|
|
165
|
-
}, []);
|
|
166
|
-
|
|
167
|
-
const CommitComponent = useMemo((): Component<{ commitId: CommitID }> => ({ commitId }) => {
|
|
168
|
-
const [c, setRenderCounter] = useState(0);
|
|
169
|
-
|
|
170
|
-
useEffect(() => {
|
|
171
|
-
const subscription = () => {
|
|
172
|
-
const commit = deltaCache.all.get(commitId);
|
|
173
|
-
const originalCommit = commitCache.map.get(commitId);
|
|
174
|
-
|
|
175
|
-
const inTaskList = deltaCache.allTasks.has(commitId);
|
|
176
|
-
|
|
177
|
-
if (commit !== originalCommit || inTaskList || (deltaCache.prevTask && deltaCache.prevTask.id === commitId))
|
|
178
|
-
setRenderCounter(c => c + 1);
|
|
179
|
-
}
|
|
180
|
-
cacheSubscribers.add(subscription);
|
|
181
|
-
subscription();
|
|
182
|
-
|
|
183
|
-
return () => {
|
|
184
|
-
console.log(`[Commit] Cleaning up ${commitId}`)
|
|
185
|
-
cacheSubscribers.delete(subscription);
|
|
186
|
-
}
|
|
187
|
-
}, [commitId])
|
|
188
|
-
|
|
189
|
-
const commit = deltaCache.all.get(commitId) || null;
|
|
190
|
-
if (!commit)
|
|
191
|
-
return (console.warn(`[Commit] Commit ${commitId} not found in delta cache`), null);
|
|
192
|
-
|
|
193
|
-
const color =
|
|
194
|
-
(deltaCache.nextTask && deltaCache.nextTask.id === commit.id) ? '#e1d600ff'
|
|
195
|
-
: deltaCache.targets.has(commit.id) ? '#db55e7ff'
|
|
196
|
-
: deltaCache.allTasks.has(commit.id) ? '#ea931aff'
|
|
197
|
-
: deltaCache.created.has(commit.id) ? (deltaCache.prevTask && deltaCache.prevTask.id === commit.id ? '#4bc847ff' : '#21a51cff')
|
|
198
|
-
: deltaCache.removed.has(commit.id) ? '#f25252ff'
|
|
199
|
-
: deltaCache.updated.has(commit.id) ? '#1ab9eaff'
|
|
200
|
-
: deltaCache.visited.has(commit.id) ? '#6f6f97ff'
|
|
201
|
-
: '#cacaca';
|
|
202
|
-
|
|
203
|
-
if (!commit)
|
|
204
|
-
return (console.log(`[Commit] ${commitId} not ready yet??`), null);
|
|
205
|
-
|
|
206
|
-
return useMemo(() => h(CommitPreview, { commit, renderCommit, color, onClick: () => setSelectedCommitId(commit.id) }), [
|
|
207
|
-
commit.version,
|
|
208
|
-
color,
|
|
209
|
-
])
|
|
210
|
-
}, [])
|
|
211
|
-
|
|
212
|
-
const reload = () => {
|
|
213
|
-
commitCache.setTree(controller.getTree())
|
|
214
|
-
deltaCache.reset();
|
|
215
|
-
deltaCache.ingestDelta(controller.getDelta());
|
|
216
|
-
deltaCache.ingestThread(controller.getThread());
|
|
217
|
-
|
|
218
|
-
setRenderCounter(c => c + 1)
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
const viewportRef = useRef<HTMLElement | null>(null);
|
|
222
|
-
|
|
223
|
-
const [selectedCommitId, setSelectedCommitId] = useState<CommitID | null>(null)
|
|
224
|
-
const [selectedCommitDetails, setSelectedCommitDetails] = useState<CommitDetailsReport | null>(null)
|
|
225
|
-
|
|
226
|
-
useEffect(() => {
|
|
227
|
-
if (!selectedCommitId)
|
|
228
|
-
return;
|
|
229
|
-
|
|
230
|
-
const details = controller.getDetails(selectedCommitId);
|
|
231
|
-
setSelectedCommitDetails(details)
|
|
232
|
-
}, [selectedCommitId])
|
|
233
|
-
|
|
234
|
-
const roots = [...deltaCache.roots.keys()];
|
|
235
|
-
const commits = deltaCache.getFlat();
|
|
236
|
-
|
|
237
|
-
const CHUNK_SIZE = 8;
|
|
238
|
-
|
|
239
|
-
return h('div', { style: { display: 'flex', 'flex-direction': 'column', position: 'absolute', top: 0, left: 0, right: 0, bottom: 0 } }, [
|
|
240
|
-
h('div', { style: { flex: 0, display: 'flex' } }, [
|
|
241
|
-
h(ScheduleControls, {
|
|
242
|
-
controller: controller.scheduler,
|
|
243
|
-
bus: bus.scheduler,
|
|
244
|
-
reconciler: controller,
|
|
245
|
-
|
|
246
|
-
state: insightState,
|
|
247
|
-
onStateChange: setInsightState,
|
|
248
|
-
}),
|
|
249
|
-
h('button', { onClick: reload}, 'Reload'),
|
|
250
|
-
]),
|
|
251
|
-
h('div', { style: { flex: 1, overflow: 'hidden', background: '#c0d7ddff', display: 'flex' } }, [
|
|
252
|
-
h('div', { style: { flex: 1 } },
|
|
253
|
-
//h(TreeViewer, { roots, renderCommit }),
|
|
254
|
-
h(Virtual1D, { viewportRef, windowRange: 5, chunkCount: commits.length / CHUNK_SIZE, chunkSize: (33 * CHUNK_SIZE), renderChunk(index) {
|
|
255
|
-
if (index < 0)
|
|
256
|
-
return null;
|
|
257
|
-
|
|
258
|
-
return Array.from({ length: CHUNK_SIZE }).map((_, chunkIndex) => {
|
|
259
|
-
const report = commits[(index * CHUNK_SIZE) + (chunkIndex)];
|
|
260
|
-
if (!report)
|
|
261
|
-
return null;
|
|
262
|
-
|
|
263
|
-
const color = getCommitColor(deltaCache, report.id);
|
|
264
|
-
|
|
265
|
-
const onClick = () => {
|
|
266
|
-
setSelectedCommitId(report.id);
|
|
267
|
-
};
|
|
268
|
-
const attributes: [string, string][] = [
|
|
269
|
-
insightState.commitBreakpoints.has(report.id) ? ['Breakpoint', 'Enabled'] as [string, string] : null
|
|
270
|
-
].filter(x => !!x)
|
|
271
|
-
|
|
272
|
-
return h('div', { style: { 'margin-left': ((report.distance - 1) * 32) + 'px', height: '33px' } }, [
|
|
273
|
-
h(CommitPreview, { color, commit: report, onClick, attributes })
|
|
274
|
-
])
|
|
275
|
-
});
|
|
276
|
-
}, })
|
|
277
|
-
),
|
|
278
|
-
h('div', { style: { 'min-width': '300px', flex: 0, background: '#ffdeabff' } }, [
|
|
279
|
-
deltaCache.thread && h('div', { }, [
|
|
280
|
-
h('dl', {}, [
|
|
281
|
-
h('dt', {}, 'Thread ID'),
|
|
282
|
-
h('dd', {}, deltaCache.thread.id),
|
|
283
|
-
h('dt', {}, 'Thread Done'),
|
|
284
|
-
h('dd', {}, deltaCache.thread.done.toString()),
|
|
285
|
-
h('dt', {}, 'Thread Passes'),
|
|
286
|
-
h('dd', {}, deltaCache.thread.passes),
|
|
287
|
-
h('dt', {}, 'Tasks (count)'),
|
|
288
|
-
h('dd', {}, deltaCache.thread.pendingTasks.length),
|
|
289
|
-
h('dt', {}, 'Visited (count)'),
|
|
290
|
-
h('dd', {}, deltaCache.thread.visited.length),
|
|
291
|
-
h('dt', {}, 'Created (count)'),
|
|
292
|
-
h('dd', {}, deltaCache.created.size),
|
|
293
|
-
h('dt', {}, 'Updated (count)'),
|
|
294
|
-
h('dd', {}, deltaCache.updated.size),
|
|
295
|
-
h('dt', {}, 'Removed (count)'),
|
|
296
|
-
h('dd', {}, deltaCache.removed.size),
|
|
297
|
-
h('dt', {}, 'MustRender '),
|
|
298
|
-
h('dd', {}, deltaCache.thread.mustRender.map(commitId => {
|
|
299
|
-
const commit = deltaCache.all.get(commitId);
|
|
300
|
-
if (!commit)
|
|
301
|
-
return null;
|
|
302
|
-
const color = getCommitColor(deltaCache, commitId);
|
|
303
|
-
|
|
304
|
-
return h(CommitPreview, {
|
|
305
|
-
commit,
|
|
306
|
-
color,
|
|
307
|
-
onClick: () => (scrollToCommitIndex(commits.indexOf(commit)), setSelectedCommitId(commitId))
|
|
308
|
-
})
|
|
309
|
-
})),
|
|
310
|
-
h('dt', {}, 'Missed'),
|
|
311
|
-
h('dd', {}, deltaCache.thread.missed.map(commitId => {
|
|
312
|
-
const commit = deltaCache.all.get(commitId);
|
|
313
|
-
if (!commit)
|
|
314
|
-
return null;
|
|
315
|
-
const color = getCommitColor(deltaCache, commitId);
|
|
316
|
-
|
|
317
|
-
return h(CommitPreview, {
|
|
318
|
-
commit,
|
|
319
|
-
color,
|
|
320
|
-
onClick: () => (scrollToCommitIndex(commits.indexOf(commit)), setSelectedCommitId(commitId))
|
|
321
|
-
})
|
|
322
|
-
})),
|
|
323
|
-
])
|
|
324
|
-
]),
|
|
325
|
-
h('hr'),
|
|
326
|
-
selectedCommitDetails && [
|
|
327
|
-
h(CommitPreview, {
|
|
328
|
-
commit: selectedCommitDetails.commit,
|
|
329
|
-
color: getCommitColor(deltaCache, selectedCommitDetails.commit.id),
|
|
330
|
-
onClick: () => (scrollToCommitIndex(commits.indexOf(selectedCommitDetails.commit)), setSelectedCommitId(selectedCommitDetails.commit.id))
|
|
331
|
-
}),
|
|
332
|
-
h('button', { onClick: () => {
|
|
333
|
-
setInsightState(state => {
|
|
334
|
-
const prev = state.commitBreakpoints;
|
|
335
|
-
if (prev.has(selectedCommitDetails.commit.id)) {
|
|
336
|
-
prev.delete(selectedCommitDetails.commit.id)
|
|
337
|
-
return { ...state, commitBreakpoints: new Set(prev) };
|
|
338
|
-
}
|
|
339
|
-
prev.add(selectedCommitDetails.commit.id)
|
|
340
|
-
return { ...state, commitBreakpoints: new Set(prev) }
|
|
341
|
-
})
|
|
342
|
-
}}, 'Toggle Breakpoint'),
|
|
343
|
-
h('h3', {}, 'Parent'),
|
|
344
|
-
(() => {
|
|
345
|
-
const parentId = selectedCommitDetails.commit.parent;
|
|
346
|
-
if (!parentId)
|
|
347
|
-
return 'NO PARENT';
|
|
348
|
-
const parent = deltaCache.all.get(parentId);
|
|
349
|
-
if (!parent)
|
|
350
|
-
return h(CommitAttributeTag, { name: 'ParentID', value: parentId.toString() });
|
|
351
|
-
|
|
352
|
-
return h(CommitPreview, {
|
|
353
|
-
commit: parent,
|
|
354
|
-
color: getCommitColor(deltaCache, parent.id),
|
|
355
|
-
onClick: () => (scrollToCommitIndex(commits.indexOf(parent)), setSelectedCommitId(parent.id))
|
|
356
|
-
});
|
|
357
|
-
})(),
|
|
358
|
-
h('h3', {}, 'Props'),
|
|
359
|
-
h('ul', {},
|
|
360
|
-
Object.entries(selectedCommitDetails.props).map(([prop, value]) => {
|
|
361
|
-
return h('li', {}, `${prop} = ${getTextForValue(value)}`);
|
|
362
|
-
})
|
|
363
|
-
)
|
|
364
|
-
]
|
|
365
|
-
])
|
|
366
|
-
])
|
|
367
|
-
])
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
export const getTextForValue = (value: ValueReport): string => {
|
|
372
|
-
switch (value.type) {
|
|
373
|
-
case 'primitive':
|
|
374
|
-
switch (typeof value.value) {
|
|
375
|
-
case 'object':
|
|
376
|
-
return `null`;
|
|
377
|
-
case 'string':
|
|
378
|
-
case 'boolean':
|
|
379
|
-
case 'number':
|
|
380
|
-
return value.value.toString();
|
|
381
|
-
}
|
|
382
|
-
case 'complex':
|
|
383
|
-
return value.name;
|
|
384
|
-
case 'undefined':
|
|
385
|
-
return `undefined`;
|
|
386
|
-
default:
|
|
387
|
-
return value;
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
const getCommitColor = (deltaCache: ThreadLookupCache, commitId: CommitID) => {
|
|
392
|
-
|
|
393
|
-
const color =
|
|
394
|
-
(deltaCache.nextTask && deltaCache.nextTask.id === commitId) ? '#e1d600ff'
|
|
395
|
-
: deltaCache.targets.has(commitId) ? '#db55e7ff'
|
|
396
|
-
: deltaCache.allTasks.has(commitId) ? '#ea931aff'
|
|
397
|
-
: deltaCache.created.has(commitId) ? (deltaCache.prevTask && deltaCache.prevTask.id === commitId ? '#4bc847ff' : '#21a51cff')
|
|
398
|
-
: deltaCache.removed.has(commitId) ? '#f25252ff'
|
|
399
|
-
: deltaCache.updated.has(commitId) ? '#1ab9eaff'
|
|
400
|
-
: deltaCache.visited.has(commitId) ? '#6f6f97ff'
|
|
401
|
-
: '#cacaca';
|
|
402
|
-
|
|
403
|
-
return color;
|
|
404
|
-
}
|
package/MenuBar.module.css
DELETED
package/MenuBar.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { Component, h } from "@lukekaalim/act";
|
|
2
|
-
import { InsightMode } from "./mode";
|
|
3
|
-
import { hs } from "@lukekaalim/act-web";
|
|
4
|
-
|
|
5
|
-
import classes from './MenuBar.module.css';
|
|
6
|
-
|
|
7
|
-
export type MenuBarProps = {
|
|
8
|
-
currentMode: InsightMode,
|
|
9
|
-
onSelectMode: (mode: InsightMode) => unknown,
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const MenuBar: Component<MenuBarProps> = ({ currentMode, onSelectMode }) => {
|
|
13
|
-
return hs('menu', { className: classes.menuBar }, [
|
|
14
|
-
hs('li', { className: classes.menuBarEntry },
|
|
15
|
-
h(ModeButton, { onSelectMode, currentMode, mode: 'tree' }, 'Tree')),
|
|
16
|
-
hs('li', { className: classes.menuBarEntry },
|
|
17
|
-
h(ModeButton, { onSelectMode, currentMode, mode: 'thread' }, 'Thread')),
|
|
18
|
-
hs('li', { className: classes.menuBarEntry },
|
|
19
|
-
h(ModeButton, { onSelectMode, currentMode, mode: 'reports' }, 'Reports')),
|
|
20
|
-
])
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
type ModeButtonProps = {
|
|
24
|
-
mode: InsightMode,
|
|
25
|
-
currentMode: InsightMode,
|
|
26
|
-
onSelectMode: (mode: InsightMode) => unknown,
|
|
27
|
-
}
|
|
28
|
-
const ModeButton: Component<ModeButtonProps> = ({ currentMode, mode, children, onSelectMode }) => {
|
|
29
|
-
const selected = mode === currentMode;
|
|
30
|
-
const onClick = () => {
|
|
31
|
-
onSelectMode(mode);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
return hs('button', {
|
|
35
|
-
className: [classes.modeButton, selected && classes.selected].join(' '),
|
|
36
|
-
onClick,
|
|
37
|
-
disabled: selected
|
|
38
|
-
}, children);
|
|
39
|
-
}
|
package/ScheduleControls.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { Component, h, useEffect, useState } from '@lukekaalim/act';
|
|
2
|
-
import { ReconcilerDebugController, ReconcilerDebugEventBus, ScheduleController, ScheduleEventBus } from '@lukekaalim/act-debug';
|
|
3
|
-
import { InsightAppState } from './InsightApp';
|
|
4
|
-
|
|
5
|
-
export type ScheduleControlsProps = {
|
|
6
|
-
controller: ScheduleController,
|
|
7
|
-
bus: ScheduleEventBus,
|
|
8
|
-
|
|
9
|
-
reconciler: ReconcilerDebugController,
|
|
10
|
-
|
|
11
|
-
state: InsightAppState,
|
|
12
|
-
onStateChange?: (newState: InsightAppState) => void,
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const ScheduleControls: Component<ScheduleControlsProps> = ({ controller, bus, reconciler, state, onStateChange = () => {} }) => {
|
|
16
|
-
useEffect(() => {
|
|
17
|
-
bus.onInterceptStart = () => {
|
|
18
|
-
onStateChange({ ...state, paused: true });
|
|
19
|
-
//onPauseChange(false)
|
|
20
|
-
}
|
|
21
|
-
bus.onInterceptEnd = () => {
|
|
22
|
-
onStateChange({ ...state, paused: false });
|
|
23
|
-
//onPauseChange(false)
|
|
24
|
-
}
|
|
25
|
-
bus.onAfterCallbackExecute = () => {
|
|
26
|
-
//reconciler.getThread();
|
|
27
|
-
}
|
|
28
|
-
}, [bus, reconciler, state])
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const onStepClick = () => {
|
|
32
|
-
controller.step();
|
|
33
|
-
}
|
|
34
|
-
const onResumeClick = () => {
|
|
35
|
-
controller.cancelIntercept();
|
|
36
|
-
}
|
|
37
|
-
const onChangeBreakBeforeUpdate = (event: Event) => {
|
|
38
|
-
onStateChange({ ...state, breakOnBeforeUpdate: (event.target as HTMLInputElement).checked });
|
|
39
|
-
}
|
|
40
|
-
const onChangeBreakAfterUpdate = (event: Event) => {
|
|
41
|
-
onStateChange({ ...state, breakOnAfterUpdate: (event.target as HTMLInputElement).checked });
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return h('div', { style: { background: state.paused ? 'red' : 'white', padding: '8px', display: 'flex', gap: '12px' }}, [
|
|
45
|
-
h('div', { style: { display: 'flex', 'flex-direction': 'column' } }, [
|
|
46
|
-
h('label', { style: { 'margin': 'auto 0' } }, [
|
|
47
|
-
h('span', {}, `Break Before Update`),
|
|
48
|
-
h('input', { type: 'checkbox', checked: state.breakOnBeforeUpdate, onChange: onChangeBreakBeforeUpdate }),
|
|
49
|
-
]),
|
|
50
|
-
h('label', { style: { 'margin': 'auto 0' } }, [
|
|
51
|
-
h('span', {}, `Break After Update`),
|
|
52
|
-
h('input', { type: 'checkbox', checked: state.breakOnAfterUpdate, onChange: onChangeBreakAfterUpdate }),
|
|
53
|
-
]),
|
|
54
|
-
]),
|
|
55
|
-
h('button', { onClick: onStepClick, disabled: !state.paused, style: { padding: '8px' } }, 'Step'),
|
|
56
|
-
h('button', { onClick: onResumeClick, disabled: !state.paused, style: { padding: '8px' } }, 'Resume'),
|
|
57
|
-
h('span', {
|
|
58
|
-
style: { border: `2px solid ${state.paused ? 'orange' : 'black'}`, 'border-radius': '8px', padding: '8px' }
|
|
59
|
-
}, state.paused ? `Paused` : `Ready`),
|
|
60
|
-
])
|
|
61
|
-
};
|