@solidnative-dev/devtools 0.0.0-stage → 0.1.0-alpha.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/LICENSE +21 -0
- package/README.md +266 -2
- package/dist/causal-solid.d.ts +30 -0
- package/dist/causal-solid.d.ts.map +1 -0
- package/dist/causal-solid.js +1108 -0
- package/dist/causal-solid.js.map +1 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +220 -0
- package/dist/index.js.map +1 -0
- package/dist/network-service-development.d.ts +6 -0
- package/dist/network-service-development.d.ts.map +1 -0
- package/dist/network-service-development.js +12 -0
- package/dist/network-service-development.js.map +1 -0
- package/dist/network-service.d.ts +13 -0
- package/dist/network-service.d.ts.map +1 -0
- package/dist/network-service.js +37 -0
- package/dist/network-service.js.map +1 -0
- package/dist/network.d.ts +57 -0
- package/dist/network.d.ts.map +1 -0
- package/dist/network.js +353 -0
- package/dist/network.js.map +1 -0
- package/dist/react-native.d.ts +27 -0
- package/dist/react-native.d.ts.map +1 -0
- package/dist/react-native.js +111 -0
- package/dist/react-native.js.map +1 -0
- package/dist/root-development.d.ts +5 -0
- package/dist/root-development.d.ts.map +1 -0
- package/dist/root-development.js +86 -0
- package/dist/root-development.js.map +1 -0
- package/dist/root.d.ts +48 -0
- package/dist/root.d.ts.map +1 -0
- package/dist/root.js +8 -0
- package/dist/root.js.map +1 -0
- package/dist/solid-diagnostics-development.d.ts +30 -0
- package/dist/solid-diagnostics-development.d.ts.map +1 -0
- package/dist/solid-diagnostics-development.js +166 -0
- package/dist/solid-diagnostics-development.js.map +1 -0
- package/dist/solid-diagnostics.d.ts +15 -0
- package/dist/solid-diagnostics.d.ts.map +1 -0
- package/dist/solid-diagnostics.js +20 -0
- package/dist/solid-diagnostics.js.map +1 -0
- package/dist/solid.d.ts +32 -0
- package/dist/solid.d.ts.map +1 -0
- package/dist/solid.js +563 -0
- package/dist/solid.js.map +1 -0
- package/dist/tree-solid.d.ts +106 -0
- package/dist/tree-solid.d.ts.map +1 -0
- package/dist/tree-solid.js +1117 -0
- package/dist/tree-solid.js.map +1 -0
- package/package.json +66 -3
|
@@ -0,0 +1,1108 @@
|
|
|
1
|
+
import { Pressable, ScrollView, Text, TextInput, View, } from "@solidnative-dev/core";
|
|
2
|
+
import { correlateNativeSolidDiagnostics, createCausalDebugSnapshot, explainCausalTimelineSnapshot, groupCausalTimelineSnapshot, } from "@solidnative-dev/observability";
|
|
3
|
+
import { createComponent, createSignal, onCleanup, } from "solid-js";
|
|
4
|
+
import { DEVELOPMENT_TREE_PANEL_DEFAULT_VISIBLE_NODES, DEVELOPMENT_TREE_PANEL_MAX_SEARCH_LENGTH, DEVELOPMENT_TREE_PANEL_MAX_VISIBLE_NODES, TreeHighlightOverlay, TreeNodeRow, captureValidatedTreeSnapshot, correlateTreeWithCausalSnapshot, indexTreeDebugSnapshot, optionalTreeMeasureProvider, optionalTreeSnapshotProvider, resolveTreeHighlightBounds, treeListContent, treeNodeDetailContent, treeSummaryText, } from "./tree-solid.js";
|
|
5
|
+
export const DEVELOPMENT_CAUSAL_PANEL_DEFAULT_VISIBLE_OPERATIONS = 40;
|
|
6
|
+
export const DEVELOPMENT_CAUSAL_PANEL_MAX_VISIBLE_OPERATIONS = 100;
|
|
7
|
+
export const DEVELOPMENT_CAUSAL_PANEL_MAX_SEARCH_LENGTH = 128;
|
|
8
|
+
export const DEVELOPMENT_CAUSAL_PANEL_GROUP_NAME_LIMIT = 6;
|
|
9
|
+
const SHELL_STYLE = Object.freeze({
|
|
10
|
+
flex: 1,
|
|
11
|
+
position: "relative",
|
|
12
|
+
});
|
|
13
|
+
const OVERLAY_SLOT_STYLE = Object.freeze({
|
|
14
|
+
position: "absolute",
|
|
15
|
+
top: 0,
|
|
16
|
+
right: 0,
|
|
17
|
+
bottom: 0,
|
|
18
|
+
left: 0,
|
|
19
|
+
});
|
|
20
|
+
const PANEL_STYLE = Object.freeze({
|
|
21
|
+
position: "absolute",
|
|
22
|
+
top: 0,
|
|
23
|
+
right: 0,
|
|
24
|
+
bottom: 0,
|
|
25
|
+
left: 0,
|
|
26
|
+
backgroundColor: "#071a18",
|
|
27
|
+
paddingTop: 52,
|
|
28
|
+
paddingRight: 16,
|
|
29
|
+
paddingBottom: 24,
|
|
30
|
+
paddingLeft: 16,
|
|
31
|
+
});
|
|
32
|
+
const HEADER_STYLE = Object.freeze({
|
|
33
|
+
flexDirection: "row",
|
|
34
|
+
alignItems: "center",
|
|
35
|
+
justifyContent: "space-between",
|
|
36
|
+
gap: 12,
|
|
37
|
+
marginBottom: 12,
|
|
38
|
+
});
|
|
39
|
+
const HEADER_ACTIONS_STYLE = Object.freeze({
|
|
40
|
+
flexDirection: "row",
|
|
41
|
+
gap: 7,
|
|
42
|
+
});
|
|
43
|
+
const MODE_ACTIONS_STYLE = Object.freeze({
|
|
44
|
+
flexDirection: "row",
|
|
45
|
+
flexWrap: "wrap",
|
|
46
|
+
gap: 8,
|
|
47
|
+
marginBottom: 12,
|
|
48
|
+
});
|
|
49
|
+
const TITLE_STYLE = Object.freeze({
|
|
50
|
+
color: "#ecfdf5",
|
|
51
|
+
fontSize: 23,
|
|
52
|
+
fontWeight: "700",
|
|
53
|
+
});
|
|
54
|
+
const SUMMARY_STYLE = Object.freeze({
|
|
55
|
+
color: "#8fbab0",
|
|
56
|
+
fontSize: 13,
|
|
57
|
+
lineHeight: 18,
|
|
58
|
+
marginBottom: 12,
|
|
59
|
+
});
|
|
60
|
+
const SEARCH_STYLE = Object.freeze({
|
|
61
|
+
backgroundColor: "#0d2925",
|
|
62
|
+
borderColor: "#24564e",
|
|
63
|
+
borderWidth: 1,
|
|
64
|
+
borderRadius: 8,
|
|
65
|
+
color: "#ecfdf5",
|
|
66
|
+
fontSize: 14,
|
|
67
|
+
marginBottom: 12,
|
|
68
|
+
paddingTop: 9,
|
|
69
|
+
paddingRight: 11,
|
|
70
|
+
paddingBottom: 9,
|
|
71
|
+
paddingLeft: 11,
|
|
72
|
+
});
|
|
73
|
+
const BUTTON_STYLE = Object.freeze({
|
|
74
|
+
backgroundColor: "#153c36",
|
|
75
|
+
borderRadius: 7,
|
|
76
|
+
paddingTop: 8,
|
|
77
|
+
paddingRight: 10,
|
|
78
|
+
paddingBottom: 8,
|
|
79
|
+
paddingLeft: 10,
|
|
80
|
+
});
|
|
81
|
+
const BUTTON_TEXT_STYLE = Object.freeze({
|
|
82
|
+
color: "#d1fae5",
|
|
83
|
+
fontSize: 12,
|
|
84
|
+
fontWeight: "700",
|
|
85
|
+
});
|
|
86
|
+
const LIST_STYLE = Object.freeze({
|
|
87
|
+
flexGrow: 1,
|
|
88
|
+
gap: 9,
|
|
89
|
+
paddingBottom: 24,
|
|
90
|
+
});
|
|
91
|
+
const ROW_STYLE = Object.freeze({
|
|
92
|
+
backgroundColor: "#0d2925",
|
|
93
|
+
borderColor: "#24564e",
|
|
94
|
+
borderWidth: 1,
|
|
95
|
+
borderRadius: 9,
|
|
96
|
+
gap: 4,
|
|
97
|
+
padding: 11,
|
|
98
|
+
});
|
|
99
|
+
const ROW_TITLE_STYLE = Object.freeze({
|
|
100
|
+
color: "#d1fae5",
|
|
101
|
+
fontSize: 14,
|
|
102
|
+
fontWeight: "700",
|
|
103
|
+
});
|
|
104
|
+
const ROW_META_STYLE = Object.freeze({
|
|
105
|
+
color: "#8fbab0",
|
|
106
|
+
fontSize: 12,
|
|
107
|
+
lineHeight: 17,
|
|
108
|
+
});
|
|
109
|
+
const OPERATION_ID_STYLE = Object.freeze({
|
|
110
|
+
color: "#6ee7b7",
|
|
111
|
+
fontFamily: "monospace",
|
|
112
|
+
fontSize: 11,
|
|
113
|
+
});
|
|
114
|
+
const SECTION_STYLE = Object.freeze({
|
|
115
|
+
gap: 8,
|
|
116
|
+
marginTop: 8,
|
|
117
|
+
});
|
|
118
|
+
const SECTION_TITLE_STYLE = Object.freeze({
|
|
119
|
+
color: "#a7f3d0",
|
|
120
|
+
fontSize: 13,
|
|
121
|
+
fontWeight: "700",
|
|
122
|
+
textTransform: "uppercase",
|
|
123
|
+
});
|
|
124
|
+
const EMPTY_STYLE = Object.freeze({
|
|
125
|
+
color: "#a7c7c0",
|
|
126
|
+
fontSize: 15,
|
|
127
|
+
paddingTop: 28,
|
|
128
|
+
textAlign: "center",
|
|
129
|
+
});
|
|
130
|
+
const DIAGNOSTICS_STYLE = Object.freeze({
|
|
131
|
+
backgroundColor: "#102f2a",
|
|
132
|
+
borderColor: "#2d6c60",
|
|
133
|
+
borderWidth: 1,
|
|
134
|
+
borderRadius: 9,
|
|
135
|
+
gap: 5,
|
|
136
|
+
marginBottom: 12,
|
|
137
|
+
padding: 11,
|
|
138
|
+
});
|
|
139
|
+
const BADGE_BASE_STYLE = Object.freeze({
|
|
140
|
+
position: "absolute",
|
|
141
|
+
right: 16,
|
|
142
|
+
backgroundColor: "#0d3b34",
|
|
143
|
+
borderColor: "#3c776c",
|
|
144
|
+
borderWidth: 1,
|
|
145
|
+
borderRadius: 18,
|
|
146
|
+
paddingTop: 9,
|
|
147
|
+
paddingRight: 14,
|
|
148
|
+
paddingBottom: 9,
|
|
149
|
+
paddingLeft: 14,
|
|
150
|
+
});
|
|
151
|
+
const BADGE_TEXT_STYLE = Object.freeze({
|
|
152
|
+
color: "#ecfdf5",
|
|
153
|
+
fontSize: 13,
|
|
154
|
+
fontWeight: "700",
|
|
155
|
+
});
|
|
156
|
+
function requireCausalTimeline(value) {
|
|
157
|
+
if (value === null ||
|
|
158
|
+
typeof value !== "object" ||
|
|
159
|
+
typeof value.snapshot !== "function" ||
|
|
160
|
+
typeof value.explain !== "function" ||
|
|
161
|
+
typeof value.clear !== "function" ||
|
|
162
|
+
typeof value.sink !== "function") {
|
|
163
|
+
throw new TypeError("DevelopmentCausalPanel requires a bounded causal timeline.");
|
|
164
|
+
}
|
|
165
|
+
return value;
|
|
166
|
+
}
|
|
167
|
+
function optionalSolidDiagnosticsController(value) {
|
|
168
|
+
if (value === undefined)
|
|
169
|
+
return undefined;
|
|
170
|
+
if (value === null ||
|
|
171
|
+
typeof value !== "object" ||
|
|
172
|
+
typeof value.available !== "boolean" ||
|
|
173
|
+
typeof value.active !== "boolean" ||
|
|
174
|
+
typeof value.begin !== "function" ||
|
|
175
|
+
typeof value.end !== "function" ||
|
|
176
|
+
typeof value.dispose !== "function") {
|
|
177
|
+
throw new TypeError("DevelopmentCausalPanel solidDiagnostics must be a diagnostics controller.");
|
|
178
|
+
}
|
|
179
|
+
return value.available ? value : undefined;
|
|
180
|
+
}
|
|
181
|
+
function operationStatus(operation) {
|
|
182
|
+
if (operation.status === undefined)
|
|
183
|
+
return "active";
|
|
184
|
+
return operation.status;
|
|
185
|
+
}
|
|
186
|
+
function operationMeta(operation) {
|
|
187
|
+
const duration = operation.duration === undefined
|
|
188
|
+
? "running"
|
|
189
|
+
: `${operation.duration.toFixed(2)} ms`;
|
|
190
|
+
const causes = `${String(operation.causes.length)} ${operation.causes.length === 1 ? "cause" : "causes"}`;
|
|
191
|
+
return `${operationStatus(operation)} · ${duration} · ${causes}`;
|
|
192
|
+
}
|
|
193
|
+
function normalizedOperationSearch(value) {
|
|
194
|
+
return value
|
|
195
|
+
.slice(0, DEVELOPMENT_CAUSAL_PANEL_MAX_SEARCH_LENGTH)
|
|
196
|
+
.trim()
|
|
197
|
+
.toLowerCase();
|
|
198
|
+
}
|
|
199
|
+
function operationMatchesSearch(operation, search) {
|
|
200
|
+
if (search.length === 0)
|
|
201
|
+
return true;
|
|
202
|
+
return (operation.name.toLowerCase().includes(search) ||
|
|
203
|
+
operation.operationId.toLowerCase().includes(search));
|
|
204
|
+
}
|
|
205
|
+
function groupMatchesSearch(group, search) {
|
|
206
|
+
return group.operations.some((operation) => operationMatchesSearch(operation, search));
|
|
207
|
+
}
|
|
208
|
+
function groupOperationNames(group) {
|
|
209
|
+
const omitted = Math.max(0, group.operations.length - DEVELOPMENT_CAUSAL_PANEL_GROUP_NAME_LIMIT);
|
|
210
|
+
const names = group.operations
|
|
211
|
+
.slice(-DEVELOPMENT_CAUSAL_PANEL_GROUP_NAME_LIMIT)
|
|
212
|
+
.map((operation) => operation.name.replace(/^solid-native\./u, ""))
|
|
213
|
+
.join(" → ");
|
|
214
|
+
return omitted === 0 ? names : `+${String(omitted)} earlier · ${names}`;
|
|
215
|
+
}
|
|
216
|
+
function counted(count, singular, plural) {
|
|
217
|
+
return `${String(count)} ${count === 1 ? singular : plural}`;
|
|
218
|
+
}
|
|
219
|
+
function groupMeta(group) {
|
|
220
|
+
const duration = group.duration === undefined
|
|
221
|
+
? "running"
|
|
222
|
+
: `${group.duration.toFixed(2)} ms`;
|
|
223
|
+
return `${counted(group.operations.length, "operation", "operations")} · ${String(group.activeOperationCount)} active · ${counted(group.errorOperationCount, "error", "errors")} · ${String(group.cancelledOperationCount)} cancelled · ${duration}`;
|
|
224
|
+
}
|
|
225
|
+
function TraceGroupRow(props) {
|
|
226
|
+
return createComponent(Pressable, {
|
|
227
|
+
accessibilityRole: "button",
|
|
228
|
+
accessibilityLabel: `Inspect causal trace group (${props.group.groupId})`,
|
|
229
|
+
onPress: props.onSelect,
|
|
230
|
+
style: ROW_STYLE,
|
|
231
|
+
get children() {
|
|
232
|
+
return [
|
|
233
|
+
createComponent(Text, {
|
|
234
|
+
style: ROW_TITLE_STYLE,
|
|
235
|
+
children: groupOperationNames(props.group),
|
|
236
|
+
}),
|
|
237
|
+
createComponent(Text, {
|
|
238
|
+
style: ROW_META_STYLE,
|
|
239
|
+
children: groupMeta(props.group),
|
|
240
|
+
}),
|
|
241
|
+
createComponent(Text, {
|
|
242
|
+
selectable: true,
|
|
243
|
+
style: OPERATION_ID_STYLE,
|
|
244
|
+
children: props.group.groupId,
|
|
245
|
+
}),
|
|
246
|
+
];
|
|
247
|
+
},
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
function OperationRow(props) {
|
|
251
|
+
const content = () => [
|
|
252
|
+
createComponent(Text, {
|
|
253
|
+
style: ROW_TITLE_STYLE,
|
|
254
|
+
children: props.operation.name,
|
|
255
|
+
}),
|
|
256
|
+
createComponent(Text, {
|
|
257
|
+
style: ROW_META_STYLE,
|
|
258
|
+
children: operationMeta(props.operation),
|
|
259
|
+
}),
|
|
260
|
+
createComponent(Text, {
|
|
261
|
+
selectable: true,
|
|
262
|
+
style: OPERATION_ID_STYLE,
|
|
263
|
+
children: props.operation.operationId,
|
|
264
|
+
}),
|
|
265
|
+
];
|
|
266
|
+
if (props.onSelect === undefined) {
|
|
267
|
+
return createComponent(View, { style: ROW_STYLE, children: content() });
|
|
268
|
+
}
|
|
269
|
+
return createComponent(Pressable, {
|
|
270
|
+
accessibilityRole: "button",
|
|
271
|
+
accessibilityLabel: `Inspect causal operation ${props.operation.name} (${props.operation.operationId})`,
|
|
272
|
+
onPress: props.onSelect,
|
|
273
|
+
style: ROW_STYLE,
|
|
274
|
+
children: content(),
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
function RelationSection(props) {
|
|
278
|
+
return createComponent(View, {
|
|
279
|
+
style: SECTION_STYLE,
|
|
280
|
+
get children() {
|
|
281
|
+
return [
|
|
282
|
+
createComponent(Text, {
|
|
283
|
+
style: SECTION_TITLE_STYLE,
|
|
284
|
+
children: `${props.title} (${String(props.operations.length)})`,
|
|
285
|
+
}),
|
|
286
|
+
...(props.operations.length === 0
|
|
287
|
+
? [
|
|
288
|
+
createComponent(Text, {
|
|
289
|
+
style: ROW_META_STYLE,
|
|
290
|
+
children: "None retained in this snapshot.",
|
|
291
|
+
}),
|
|
292
|
+
]
|
|
293
|
+
: props.operations.map((operation) => OperationRow({
|
|
294
|
+
operation,
|
|
295
|
+
onSelect: () => props.onSelect(operation),
|
|
296
|
+
}))),
|
|
297
|
+
];
|
|
298
|
+
},
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
function explanationContent(explanation, onSelect, linkedTreeEntries = [], onSelectTreeNode) {
|
|
302
|
+
return [
|
|
303
|
+
createComponent(Text, {
|
|
304
|
+
style: SECTION_TITLE_STYLE,
|
|
305
|
+
children: "Selected operation",
|
|
306
|
+
}),
|
|
307
|
+
OperationRow({ operation: explanation.target }),
|
|
308
|
+
RelationSection({
|
|
309
|
+
title: "Retained causes",
|
|
310
|
+
operations: explanation.ancestors,
|
|
311
|
+
onSelect,
|
|
312
|
+
}),
|
|
313
|
+
RelationSection({
|
|
314
|
+
title: "Retained effects",
|
|
315
|
+
operations: explanation.descendants,
|
|
316
|
+
onSelect,
|
|
317
|
+
}),
|
|
318
|
+
...(linkedTreeEntries.length === 0 || onSelectTreeNode === undefined
|
|
319
|
+
? []
|
|
320
|
+
: [
|
|
321
|
+
createComponent(View, {
|
|
322
|
+
style: SECTION_STYLE,
|
|
323
|
+
get children() {
|
|
324
|
+
return [
|
|
325
|
+
createComponent(Text, {
|
|
326
|
+
style: SECTION_TITLE_STYLE,
|
|
327
|
+
children: `Linked UI nodes (${String(linkedTreeEntries.length)})`,
|
|
328
|
+
}),
|
|
329
|
+
...linkedTreeEntries.map((entry) => TreeNodeRow({
|
|
330
|
+
entry,
|
|
331
|
+
showPrefix: false,
|
|
332
|
+
onSelect: () => onSelectTreeNode(entry.node.handle),
|
|
333
|
+
})),
|
|
334
|
+
];
|
|
335
|
+
},
|
|
336
|
+
}),
|
|
337
|
+
]),
|
|
338
|
+
...(explanation.unresolvedCauseIds.length === 0
|
|
339
|
+
? []
|
|
340
|
+
: [
|
|
341
|
+
createComponent(Text, {
|
|
342
|
+
style: SUMMARY_STYLE,
|
|
343
|
+
children: `${String(explanation.unresolvedCauseIds.length)} cause IDs were evicted before this snapshot.`,
|
|
344
|
+
}),
|
|
345
|
+
]),
|
|
346
|
+
];
|
|
347
|
+
}
|
|
348
|
+
function groupContent(group, maxVisibleOperations, onSelect) {
|
|
349
|
+
const omitted = Math.max(0, group.operations.length - maxVisibleOperations);
|
|
350
|
+
const visible = group.operations.slice(-maxVisibleOperations);
|
|
351
|
+
return [
|
|
352
|
+
createComponent(Text, {
|
|
353
|
+
style: SECTION_TITLE_STYLE,
|
|
354
|
+
children: "Selected trace group",
|
|
355
|
+
}),
|
|
356
|
+
createComponent(Text, {
|
|
357
|
+
style: SUMMARY_STYLE,
|
|
358
|
+
children: `${groupMeta(group)} · ${counted(group.entryOperationIds.length, "entry", "entries")} · ${counted(group.terminalOperationIds.length, "terminal", "terminals")} · ${counted(group.unresolvedCauseIds.length, "unresolved cause", "unresolved causes")}.`,
|
|
359
|
+
}),
|
|
360
|
+
...(omitted === 0
|
|
361
|
+
? []
|
|
362
|
+
: [
|
|
363
|
+
createComponent(Text, {
|
|
364
|
+
style: SUMMARY_STYLE,
|
|
365
|
+
children: `${counted(omitted, "earlier operation is", "earlier operations are")} hidden by the visible-row limit.`,
|
|
366
|
+
}),
|
|
367
|
+
]),
|
|
368
|
+
...visible.map((operation) => OperationRow({
|
|
369
|
+
operation,
|
|
370
|
+
onSelect: () => onSelect(operation),
|
|
371
|
+
})),
|
|
372
|
+
];
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Adds an on-device, manually refreshed causal graph inspector. Refresh is
|
|
376
|
+
* explicit because rendering the inspector itself creates Fabric telemetry;
|
|
377
|
+
* subscribing the view to its own timeline would form a feedback loop.
|
|
378
|
+
*/
|
|
379
|
+
export function DevelopmentCausalPanel(props) {
|
|
380
|
+
const timeline = requireCausalTimeline(props.timeline);
|
|
381
|
+
const solidDiagnostics = optionalSolidDiagnosticsController(props.solidDiagnostics);
|
|
382
|
+
const snapshotTree = optionalTreeSnapshotProvider(props.snapshotTree, "DevelopmentCausalPanel");
|
|
383
|
+
const measureTreeNode = optionalTreeMeasureProvider(props.measureTreeNode, "DevelopmentCausalPanel");
|
|
384
|
+
if (props.initiallyOpen !== undefined &&
|
|
385
|
+
typeof props.initiallyOpen !== "boolean") {
|
|
386
|
+
throw new TypeError("DevelopmentCausalPanel initiallyOpen must be a boolean.");
|
|
387
|
+
}
|
|
388
|
+
const maxVisibleOperations = props.maxVisibleOperations ??
|
|
389
|
+
DEVELOPMENT_CAUSAL_PANEL_DEFAULT_VISIBLE_OPERATIONS;
|
|
390
|
+
if (!Number.isSafeInteger(maxVisibleOperations) ||
|
|
391
|
+
maxVisibleOperations < 1 ||
|
|
392
|
+
maxVisibleOperations > DEVELOPMENT_CAUSAL_PANEL_MAX_VISIBLE_OPERATIONS) {
|
|
393
|
+
throw new TypeError(`DevelopmentCausalPanel maxVisibleOperations must be a safe integer from 1 through ${String(DEVELOPMENT_CAUSAL_PANEL_MAX_VISIBLE_OPERATIONS)}.`);
|
|
394
|
+
}
|
|
395
|
+
const maxVisibleTreeNodes = props.maxVisibleTreeNodes ?? DEVELOPMENT_TREE_PANEL_DEFAULT_VISIBLE_NODES;
|
|
396
|
+
if (!Number.isSafeInteger(maxVisibleTreeNodes) ||
|
|
397
|
+
maxVisibleTreeNodes < 1 ||
|
|
398
|
+
maxVisibleTreeNodes > DEVELOPMENT_TREE_PANEL_MAX_VISIBLE_NODES) {
|
|
399
|
+
throw new TypeError(`DevelopmentCausalPanel maxVisibleTreeNodes must be a safe integer from 1 through ${String(DEVELOPMENT_TREE_PANEL_MAX_VISIBLE_NODES)}.`);
|
|
400
|
+
}
|
|
401
|
+
const badgeBottom = props.badgeBottom ?? 68;
|
|
402
|
+
if (!Number.isFinite(badgeBottom) || badgeBottom < 0 || badgeBottom > 512) {
|
|
403
|
+
throw new TypeError("DevelopmentCausalPanel badgeBottom must be a finite number from 0 through 512.");
|
|
404
|
+
}
|
|
405
|
+
const application = props.children;
|
|
406
|
+
const initialTreeCapture = props.initiallyOpen === true && snapshotTree !== undefined
|
|
407
|
+
? captureValidatedTreeSnapshot(snapshotTree)
|
|
408
|
+
: {};
|
|
409
|
+
const [open, setOpen] = createSignal(props.initiallyOpen === true, {
|
|
410
|
+
ownedWrite: true,
|
|
411
|
+
});
|
|
412
|
+
const [snapshot, setSnapshot] = createSignal(timeline.snapshot(), { ownedWrite: true });
|
|
413
|
+
const [treeSnapshot, setTreeSnapshot] = createSignal(initialTreeCapture.snapshot, { ownedWrite: true });
|
|
414
|
+
const [treeFailure, setTreeFailure] = createSignal(initialTreeCapture.failure, { ownedWrite: true });
|
|
415
|
+
const [selectedOperationId, setSelectedOperationId] = createSignal(undefined, { ownedWrite: true });
|
|
416
|
+
const [selectedGroupId, setSelectedGroupId] = createSignal(undefined, { ownedWrite: true });
|
|
417
|
+
const [selectedTreeNodeHandle, setSelectedTreeNodeHandle] = createSignal(undefined, { ownedWrite: true });
|
|
418
|
+
const [viewMode, setViewMode] = createSignal("operations", { ownedWrite: true });
|
|
419
|
+
const [search, setSearch] = createSignal("", { ownedWrite: true });
|
|
420
|
+
const [treeSearch, setTreeSearch] = createSignal("", { ownedWrite: true });
|
|
421
|
+
const [capturingSolidDiagnostics, setCapturingSolidDiagnostics] = createSignal(false, { ownedWrite: true });
|
|
422
|
+
const [solidDiagnosticsEnvelope, setSolidDiagnosticsEnvelope] = createSignal(undefined, { ownedWrite: true });
|
|
423
|
+
const [solidDiagnosticsCorrelation, setSolidDiagnosticsCorrelation] = createSignal(undefined, {
|
|
424
|
+
ownedWrite: true,
|
|
425
|
+
});
|
|
426
|
+
const [solidDiagnosticsFailure, setSolidDiagnosticsFailure] = createSignal(undefined, { ownedWrite: true });
|
|
427
|
+
const [highlightedTreeNode, setHighlightedTreeNode] = createSignal(undefined, { ownedWrite: true });
|
|
428
|
+
const [treeHighlightError, setTreeHighlightError] = createSignal(undefined, { ownedWrite: true });
|
|
429
|
+
let panelOwnsSolidDiagnostics = false;
|
|
430
|
+
let retainedSearchInput;
|
|
431
|
+
let retainedTreeSearchInput;
|
|
432
|
+
let retainedPanel;
|
|
433
|
+
let highlightRequestId = 0;
|
|
434
|
+
let highlightingTreeNode = false;
|
|
435
|
+
let disposed = false;
|
|
436
|
+
const switchViewMode = (nextMode) => {
|
|
437
|
+
const previousMode = viewMode();
|
|
438
|
+
if (previousMode === "tree" && nextMode !== "tree") {
|
|
439
|
+
retainedTreeSearchInput = undefined;
|
|
440
|
+
highlightingTreeNode = false;
|
|
441
|
+
highlightRequestId += 1;
|
|
442
|
+
setTreeHighlightError(undefined);
|
|
443
|
+
}
|
|
444
|
+
else if (previousMode !== "tree" && nextMode === "tree") {
|
|
445
|
+
retainedSearchInput = undefined;
|
|
446
|
+
}
|
|
447
|
+
setViewMode(nextMode);
|
|
448
|
+
};
|
|
449
|
+
const selectTreeNodeHandle = (handle) => {
|
|
450
|
+
highlightingTreeNode = false;
|
|
451
|
+
highlightRequestId += 1;
|
|
452
|
+
setTreeHighlightError(undefined);
|
|
453
|
+
setSelectedTreeNodeHandle(handle);
|
|
454
|
+
};
|
|
455
|
+
const inspectTreeNode = (handle) => {
|
|
456
|
+
switchViewMode("tree");
|
|
457
|
+
setSelectedOperationId(undefined);
|
|
458
|
+
setSelectedGroupId(undefined);
|
|
459
|
+
selectTreeNodeHandle(handle);
|
|
460
|
+
};
|
|
461
|
+
const inspectCausalOperation = (operation) => {
|
|
462
|
+
switchViewMode("operations");
|
|
463
|
+
selectTreeNodeHandle(undefined);
|
|
464
|
+
setSelectedGroupId(undefined);
|
|
465
|
+
setSelectedOperationId(operation.operationId);
|
|
466
|
+
};
|
|
467
|
+
const refreshTree = () => {
|
|
468
|
+
if (snapshotTree === undefined)
|
|
469
|
+
return;
|
|
470
|
+
highlightingTreeNode = false;
|
|
471
|
+
highlightRequestId += 1;
|
|
472
|
+
setTreeHighlightError(undefined);
|
|
473
|
+
const captured = captureValidatedTreeSnapshot(snapshotTree);
|
|
474
|
+
setTreeSnapshot(captured.snapshot);
|
|
475
|
+
setTreeFailure(captured.failure);
|
|
476
|
+
const currentHandle = selectedTreeNodeHandle();
|
|
477
|
+
if (currentHandle !== undefined) {
|
|
478
|
+
const nextIndex = captured.snapshot === undefined
|
|
479
|
+
? undefined
|
|
480
|
+
: indexTreeDebugSnapshot(captured.snapshot);
|
|
481
|
+
if (nextIndex === undefined || !nextIndex.byHandle.has(currentHandle)) {
|
|
482
|
+
setSelectedTreeNodeHandle(undefined);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
};
|
|
486
|
+
const updateSnapshot = (next, diagnostics = solidDiagnosticsEnvelope()) => {
|
|
487
|
+
setSnapshot(next);
|
|
488
|
+
if (diagnostics === undefined || diagnostics === null)
|
|
489
|
+
return;
|
|
490
|
+
try {
|
|
491
|
+
setSolidDiagnosticsCorrelation(correlateNativeSolidDiagnostics(diagnostics, createCausalDebugSnapshot(next)));
|
|
492
|
+
setSolidDiagnosticsFailure(undefined);
|
|
493
|
+
}
|
|
494
|
+
catch {
|
|
495
|
+
setSolidDiagnosticsCorrelation(undefined);
|
|
496
|
+
setSolidDiagnosticsFailure("The Solid/native correlation could not be validated.");
|
|
497
|
+
}
|
|
498
|
+
};
|
|
499
|
+
const refresh = () => {
|
|
500
|
+
const next = timeline.snapshot();
|
|
501
|
+
updateSnapshot(next);
|
|
502
|
+
refreshTree();
|
|
503
|
+
const selected = selectedOperationId();
|
|
504
|
+
if (selected !== undefined &&
|
|
505
|
+
!next.operations.some((operation) => operation.operationId === selected)) {
|
|
506
|
+
setSelectedOperationId(undefined);
|
|
507
|
+
}
|
|
508
|
+
const selectedGroup = selectedGroupId();
|
|
509
|
+
if (selectedGroup !== undefined &&
|
|
510
|
+
!groupCausalTimelineSnapshot(next).some((group) => group.groupId === selectedGroup)) {
|
|
511
|
+
setSelectedGroupId(undefined);
|
|
512
|
+
}
|
|
513
|
+
};
|
|
514
|
+
const openPanel = () => {
|
|
515
|
+
setHighlightedTreeNode(undefined);
|
|
516
|
+
refresh();
|
|
517
|
+
setOpen(true);
|
|
518
|
+
};
|
|
519
|
+
const returnToInspectorFromHighlight = () => {
|
|
520
|
+
setHighlightedTreeNode(undefined);
|
|
521
|
+
setTreeHighlightError(undefined);
|
|
522
|
+
setOpen(true);
|
|
523
|
+
};
|
|
524
|
+
const dismissTreeHighlight = () => {
|
|
525
|
+
highlightingTreeNode = false;
|
|
526
|
+
highlightRequestId += 1;
|
|
527
|
+
setHighlightedTreeNode(undefined);
|
|
528
|
+
};
|
|
529
|
+
const closePanel = () => {
|
|
530
|
+
highlightingTreeNode = false;
|
|
531
|
+
highlightRequestId += 1;
|
|
532
|
+
setTreeHighlightError(undefined);
|
|
533
|
+
retainedPanel = undefined;
|
|
534
|
+
retainedSearchInput = undefined;
|
|
535
|
+
retainedTreeSearchInput = undefined;
|
|
536
|
+
setOpen(false);
|
|
537
|
+
};
|
|
538
|
+
const highlightTreeNode = (entry, target) => {
|
|
539
|
+
if (measureTreeNode === undefined || highlightingTreeNode)
|
|
540
|
+
return;
|
|
541
|
+
highlightingTreeNode = true;
|
|
542
|
+
const requestId = ++highlightRequestId;
|
|
543
|
+
setTreeHighlightError(undefined);
|
|
544
|
+
void resolveTreeHighlightBounds(measureTreeNode, target.node.handle).then((bounds) => {
|
|
545
|
+
if (disposed || requestId !== highlightRequestId)
|
|
546
|
+
return;
|
|
547
|
+
highlightingTreeNode = false;
|
|
548
|
+
if (bounds === undefined) {
|
|
549
|
+
setTreeHighlightError(`Node #${String(target.node.handle)} is no longer mounted or measurable. Refresh the UI tree.`);
|
|
550
|
+
return;
|
|
551
|
+
}
|
|
552
|
+
setHighlightedTreeNode(Object.freeze({
|
|
553
|
+
selectedHandle: entry.node.handle,
|
|
554
|
+
measuredHandle: target.node.handle,
|
|
555
|
+
summary: entry.summary,
|
|
556
|
+
measuredSummary: target.summary,
|
|
557
|
+
bounds,
|
|
558
|
+
}));
|
|
559
|
+
retainedPanel = undefined;
|
|
560
|
+
retainedSearchInput = undefined;
|
|
561
|
+
retainedTreeSearchInput = undefined;
|
|
562
|
+
setOpen(false);
|
|
563
|
+
});
|
|
564
|
+
};
|
|
565
|
+
const clear = () => {
|
|
566
|
+
timeline.clear();
|
|
567
|
+
setSolidDiagnosticsEnvelope(undefined);
|
|
568
|
+
setSolidDiagnosticsCorrelation(undefined);
|
|
569
|
+
setSolidDiagnosticsFailure(undefined);
|
|
570
|
+
setSelectedOperationId(undefined);
|
|
571
|
+
setSelectedGroupId(undefined);
|
|
572
|
+
setSearch("");
|
|
573
|
+
updateSnapshot(timeline.snapshot(), null);
|
|
574
|
+
};
|
|
575
|
+
const startSolidDiagnosticsCapture = () => {
|
|
576
|
+
if (solidDiagnostics === undefined)
|
|
577
|
+
return;
|
|
578
|
+
if (solidDiagnostics.active) {
|
|
579
|
+
setSolidDiagnosticsFailure("Another Solid diagnostics capture is already active.");
|
|
580
|
+
return;
|
|
581
|
+
}
|
|
582
|
+
try {
|
|
583
|
+
solidDiagnostics.begin();
|
|
584
|
+
panelOwnsSolidDiagnostics = true;
|
|
585
|
+
setSolidDiagnosticsEnvelope(undefined);
|
|
586
|
+
setSolidDiagnosticsCorrelation(undefined);
|
|
587
|
+
setSolidDiagnosticsFailure(undefined);
|
|
588
|
+
setCapturingSolidDiagnostics(true);
|
|
589
|
+
closePanel();
|
|
590
|
+
}
|
|
591
|
+
catch {
|
|
592
|
+
panelOwnsSolidDiagnostics = false;
|
|
593
|
+
setSolidDiagnosticsFailure("The Solid diagnostics capture could not be started.");
|
|
594
|
+
}
|
|
595
|
+
};
|
|
596
|
+
const stopSolidDiagnosticsCapture = () => {
|
|
597
|
+
if (solidDiagnostics === undefined || !panelOwnsSolidDiagnostics)
|
|
598
|
+
return;
|
|
599
|
+
try {
|
|
600
|
+
const diagnostics = solidDiagnostics.end();
|
|
601
|
+
panelOwnsSolidDiagnostics = false;
|
|
602
|
+
setSolidDiagnosticsEnvelope(diagnostics);
|
|
603
|
+
setCapturingSolidDiagnostics(false);
|
|
604
|
+
updateSnapshot(timeline.snapshot(), diagnostics);
|
|
605
|
+
refreshTree();
|
|
606
|
+
}
|
|
607
|
+
catch {
|
|
608
|
+
try {
|
|
609
|
+
solidDiagnostics.dispose();
|
|
610
|
+
}
|
|
611
|
+
catch {
|
|
612
|
+
// Development instrumentation must not destabilize the application.
|
|
613
|
+
}
|
|
614
|
+
panelOwnsSolidDiagnostics = false;
|
|
615
|
+
setCapturingSolidDiagnostics(false);
|
|
616
|
+
setSolidDiagnosticsEnvelope(undefined);
|
|
617
|
+
setSolidDiagnosticsCorrelation(undefined);
|
|
618
|
+
setSolidDiagnosticsFailure("The Solid diagnostics capture could not be completed.");
|
|
619
|
+
refreshTree();
|
|
620
|
+
}
|
|
621
|
+
setOpen(true);
|
|
622
|
+
};
|
|
623
|
+
onCleanup(() => {
|
|
624
|
+
disposed = true;
|
|
625
|
+
highlightRequestId += 1;
|
|
626
|
+
if (!panelOwnsSolidDiagnostics || solidDiagnostics === undefined)
|
|
627
|
+
return;
|
|
628
|
+
panelOwnsSolidDiagnostics = false;
|
|
629
|
+
try {
|
|
630
|
+
solidDiagnostics.dispose();
|
|
631
|
+
}
|
|
632
|
+
catch {
|
|
633
|
+
// Development instrumentation must not destabilize the application.
|
|
634
|
+
}
|
|
635
|
+
});
|
|
636
|
+
const applicationContainer = createComponent(View, {
|
|
637
|
+
style: SHELL_STYLE,
|
|
638
|
+
get accessibilityElementsHidden() {
|
|
639
|
+
return open();
|
|
640
|
+
},
|
|
641
|
+
get importantForAccessibility() {
|
|
642
|
+
return open() ? "no-hide-descendants" : "auto";
|
|
643
|
+
},
|
|
644
|
+
get pointerEvents() {
|
|
645
|
+
return open() ? "none" : "auto";
|
|
646
|
+
},
|
|
647
|
+
children: application,
|
|
648
|
+
});
|
|
649
|
+
const searchInput = () => {
|
|
650
|
+
retainedSearchInput ??= createComponent(TextInput, {
|
|
651
|
+
accessibilityLabel: "Filter causal operations",
|
|
652
|
+
autoCapitalize: "none",
|
|
653
|
+
autoCorrect: false,
|
|
654
|
+
maxLength: DEVELOPMENT_CAUSAL_PANEL_MAX_SEARCH_LENGTH,
|
|
655
|
+
placeholder: "Filter by operation name or ID",
|
|
656
|
+
placeholderTextColor: "#6f9d94",
|
|
657
|
+
style: SEARCH_STYLE,
|
|
658
|
+
get value() {
|
|
659
|
+
return search();
|
|
660
|
+
},
|
|
661
|
+
onChangeText(value) {
|
|
662
|
+
setSearch(value.slice(0, DEVELOPMENT_CAUSAL_PANEL_MAX_SEARCH_LENGTH));
|
|
663
|
+
},
|
|
664
|
+
});
|
|
665
|
+
return retainedSearchInput;
|
|
666
|
+
};
|
|
667
|
+
const treeSearchInput = () => {
|
|
668
|
+
retainedTreeSearchInput ??= createComponent(TextInput, {
|
|
669
|
+
accessibilityLabel: "Filter UI tree nodes",
|
|
670
|
+
autoCapitalize: "none",
|
|
671
|
+
autoCorrect: false,
|
|
672
|
+
maxLength: DEVELOPMENT_TREE_PANEL_MAX_SEARCH_LENGTH,
|
|
673
|
+
placeholder: "Filter by component, #handle, role, prop, event, or causal name",
|
|
674
|
+
placeholderTextColor: "#6f9d94",
|
|
675
|
+
style: SEARCH_STYLE,
|
|
676
|
+
get value() {
|
|
677
|
+
return treeSearch();
|
|
678
|
+
},
|
|
679
|
+
onChangeText(value) {
|
|
680
|
+
setTreeSearch(value.slice(0, DEVELOPMENT_TREE_PANEL_MAX_SEARCH_LENGTH));
|
|
681
|
+
},
|
|
682
|
+
});
|
|
683
|
+
return retainedTreeSearchInput;
|
|
684
|
+
};
|
|
685
|
+
const badge = createComponent(Pressable, {
|
|
686
|
+
accessibilityRole: "button",
|
|
687
|
+
get accessibilityLabel() {
|
|
688
|
+
return capturingSolidDiagnostics()
|
|
689
|
+
? "Stop Solid diagnostics capture"
|
|
690
|
+
: "Open causal trace inspector";
|
|
691
|
+
},
|
|
692
|
+
get onPress() {
|
|
693
|
+
return capturingSolidDiagnostics()
|
|
694
|
+
? stopSolidDiagnosticsCapture
|
|
695
|
+
: openPanel;
|
|
696
|
+
},
|
|
697
|
+
style: { ...BADGE_BASE_STYLE, bottom: badgeBottom },
|
|
698
|
+
testID: "solid-native-development-causal-badge",
|
|
699
|
+
children: createComponent(Text, {
|
|
700
|
+
style: BADGE_TEXT_STYLE,
|
|
701
|
+
get children() {
|
|
702
|
+
return capturingSolidDiagnostics() ? "Stop Solid" : "Trace";
|
|
703
|
+
},
|
|
704
|
+
}),
|
|
705
|
+
});
|
|
706
|
+
const panel = () => {
|
|
707
|
+
retainedPanel ??= createComponent(View, {
|
|
708
|
+
accessibilityViewIsModal: true,
|
|
709
|
+
importantForAccessibility: "yes",
|
|
710
|
+
style: PANEL_STYLE,
|
|
711
|
+
testID: "solid-native-development-causal-panel",
|
|
712
|
+
get children() {
|
|
713
|
+
const mode = viewMode();
|
|
714
|
+
const retained = snapshot();
|
|
715
|
+
const currentTree = treeSnapshot();
|
|
716
|
+
const currentTreeFailure = treeFailure();
|
|
717
|
+
const treeIndex = currentTree === undefined
|
|
718
|
+
? undefined
|
|
719
|
+
: indexTreeDebugSnapshot(currentTree);
|
|
720
|
+
const treeCorrelation = treeIndex === undefined
|
|
721
|
+
? undefined
|
|
722
|
+
: correlateTreeWithCausalSnapshot(treeIndex, retained);
|
|
723
|
+
const diagnosticsCorrelation = solidDiagnosticsCorrelation();
|
|
724
|
+
const diagnosticsFailure = solidDiagnosticsFailure();
|
|
725
|
+
const selected = selectedOperationId();
|
|
726
|
+
const groups = groupCausalTimelineSnapshot(retained);
|
|
727
|
+
const selectedGroup = groups.find((group) => group.groupId === selectedGroupId());
|
|
728
|
+
const explanation = mode === "tree" || selected === undefined
|
|
729
|
+
? undefined
|
|
730
|
+
: explainCausalTimelineSnapshot(retained, selected);
|
|
731
|
+
const selectedTreeEntry = mode === "tree" &&
|
|
732
|
+
selectedTreeNodeHandle() !== undefined &&
|
|
733
|
+
treeIndex !== undefined
|
|
734
|
+
? treeIndex.byHandle.get(selectedTreeNodeHandle())
|
|
735
|
+
: undefined;
|
|
736
|
+
const normalizedSearch = normalizedOperationSearch(search());
|
|
737
|
+
const matchingOperations = retained.operations.filter((operation) => operationMatchesSearch(operation, normalizedSearch));
|
|
738
|
+
const visible = matchingOperations
|
|
739
|
+
.slice(Math.max(0, matchingOperations.length - maxVisibleOperations))
|
|
740
|
+
.reverse();
|
|
741
|
+
const matchingGroups = groups.filter((group) => groupMatchesSearch(group, normalizedSearch));
|
|
742
|
+
const visibleGroups = matchingGroups
|
|
743
|
+
.slice(Math.max(0, matchingGroups.length - maxVisibleOperations))
|
|
744
|
+
.reverse();
|
|
745
|
+
const isDrilledIn = explanation !== undefined ||
|
|
746
|
+
selectedGroup !== undefined ||
|
|
747
|
+
selectedTreeEntry !== undefined;
|
|
748
|
+
return [
|
|
749
|
+
createComponent(View, {
|
|
750
|
+
style: HEADER_STYLE,
|
|
751
|
+
get children() {
|
|
752
|
+
return [
|
|
753
|
+
createComponent(Text, {
|
|
754
|
+
accessibilityRole: "header",
|
|
755
|
+
style: TITLE_STYLE,
|
|
756
|
+
children: "Causal trace",
|
|
757
|
+
}),
|
|
758
|
+
createComponent(View, {
|
|
759
|
+
style: HEADER_ACTIONS_STYLE,
|
|
760
|
+
get children() {
|
|
761
|
+
return [
|
|
762
|
+
...(!isDrilledIn
|
|
763
|
+
? []
|
|
764
|
+
: [
|
|
765
|
+
createComponent(Pressable, {
|
|
766
|
+
accessibilityRole: "button",
|
|
767
|
+
accessibilityLabel: selectedTreeEntry !== undefined
|
|
768
|
+
? "Back to UI tree"
|
|
769
|
+
: explanation !== undefined
|
|
770
|
+
? selectedGroup === undefined
|
|
771
|
+
? "Back to causal operations"
|
|
772
|
+
: "Back to causal trace group"
|
|
773
|
+
: "Back to causal trace groups",
|
|
774
|
+
onPress: () => {
|
|
775
|
+
if (selectedTreeEntry !== undefined) {
|
|
776
|
+
selectTreeNodeHandle(undefined);
|
|
777
|
+
}
|
|
778
|
+
else if (explanation !== undefined) {
|
|
779
|
+
setSelectedOperationId(undefined);
|
|
780
|
+
}
|
|
781
|
+
else {
|
|
782
|
+
setSelectedGroupId(undefined);
|
|
783
|
+
}
|
|
784
|
+
},
|
|
785
|
+
style: BUTTON_STYLE,
|
|
786
|
+
children: createComponent(Text, {
|
|
787
|
+
style: BUTTON_TEXT_STYLE,
|
|
788
|
+
children: "Back",
|
|
789
|
+
}),
|
|
790
|
+
}),
|
|
791
|
+
]),
|
|
792
|
+
...(solidDiagnostics === undefined || isDrilledIn
|
|
793
|
+
? []
|
|
794
|
+
: [
|
|
795
|
+
createComponent(Pressable, {
|
|
796
|
+
accessibilityRole: "button",
|
|
797
|
+
accessibilityLabel: "Start Solid diagnostics capture",
|
|
798
|
+
onPress: startSolidDiagnosticsCapture,
|
|
799
|
+
style: BUTTON_STYLE,
|
|
800
|
+
children: createComponent(Text, {
|
|
801
|
+
style: BUTTON_TEXT_STYLE,
|
|
802
|
+
children: "Capture Solid",
|
|
803
|
+
}),
|
|
804
|
+
}),
|
|
805
|
+
]),
|
|
806
|
+
createComponent(Pressable, {
|
|
807
|
+
accessibilityRole: "button",
|
|
808
|
+
accessibilityLabel: "Refresh causal trace",
|
|
809
|
+
onPress: refresh,
|
|
810
|
+
style: BUTTON_STYLE,
|
|
811
|
+
children: createComponent(Text, {
|
|
812
|
+
style: BUTTON_TEXT_STYLE,
|
|
813
|
+
children: "Refresh",
|
|
814
|
+
}),
|
|
815
|
+
}),
|
|
816
|
+
createComponent(Pressable, {
|
|
817
|
+
accessibilityRole: "button",
|
|
818
|
+
accessibilityLabel: "Close causal trace inspector",
|
|
819
|
+
onPress: closePanel,
|
|
820
|
+
style: BUTTON_STYLE,
|
|
821
|
+
children: createComponent(Text, {
|
|
822
|
+
style: BUTTON_TEXT_STYLE,
|
|
823
|
+
children: "Close",
|
|
824
|
+
}),
|
|
825
|
+
}),
|
|
826
|
+
];
|
|
827
|
+
},
|
|
828
|
+
}),
|
|
829
|
+
];
|
|
830
|
+
},
|
|
831
|
+
}),
|
|
832
|
+
createComponent(Text, {
|
|
833
|
+
style: SUMMARY_STYLE,
|
|
834
|
+
children: mode === "tree"
|
|
835
|
+
? currentTree === undefined
|
|
836
|
+
? "Manual value-free UI tree snapshots prevent self-observation."
|
|
837
|
+
: treeSummaryText(currentTree)
|
|
838
|
+
: `${String(retained.operations.length)} retained · ${String(retained.activeOperationCount)} active${retained.evictedOperationCount === 0 ? "" : ` · ${String(retained.evictedOperationCount)} evicted`}${retained.discardedRecordCount === 0 ? "" : ` · ${String(retained.discardedRecordCount)} discarded`}. Manual snapshots prevent self-observation.`,
|
|
839
|
+
}),
|
|
840
|
+
...(mode === "tree" || diagnosticsFailure === undefined
|
|
841
|
+
? []
|
|
842
|
+
: [
|
|
843
|
+
createComponent(View, {
|
|
844
|
+
style: DIAGNOSTICS_STYLE,
|
|
845
|
+
children: createComponent(Text, {
|
|
846
|
+
style: ROW_META_STYLE,
|
|
847
|
+
children: diagnosticsFailure,
|
|
848
|
+
}),
|
|
849
|
+
}),
|
|
850
|
+
]),
|
|
851
|
+
...(mode === "tree" || diagnosticsCorrelation === undefined
|
|
852
|
+
? []
|
|
853
|
+
: [
|
|
854
|
+
createComponent(View, {
|
|
855
|
+
style: DIAGNOSTICS_STYLE,
|
|
856
|
+
get children() {
|
|
857
|
+
return [
|
|
858
|
+
createComponent(Text, {
|
|
859
|
+
style: SECTION_TITLE_STYLE,
|
|
860
|
+
children: "Solid → native correlation",
|
|
861
|
+
}),
|
|
862
|
+
createComponent(Text, {
|
|
863
|
+
style: ROW_META_STYLE,
|
|
864
|
+
children: `${String(diagnosticsCorrelation.rerunCount)} reruns · ${String(diagnosticsCorrelation.correlatedOutputCount)} correlated outputs · ${String(diagnosticsCorrelation.completeOutputCount)} complete native frame outputs · exact per-rerun join: no`,
|
|
865
|
+
}),
|
|
866
|
+
...diagnosticsCorrelation.outputs.map((output) => createComponent(Text, {
|
|
867
|
+
style: ROW_META_STYLE,
|
|
868
|
+
children: `${output.name} · ${String(output.rerunCount)} reruns · ${String(output.nativeFrameOperationIds.length)} frames`,
|
|
869
|
+
})),
|
|
870
|
+
];
|
|
871
|
+
},
|
|
872
|
+
}),
|
|
873
|
+
]),
|
|
874
|
+
mode === "tree" ? treeSearchInput() : searchInput(),
|
|
875
|
+
...(!isDrilledIn
|
|
876
|
+
? [
|
|
877
|
+
createComponent(View, {
|
|
878
|
+
style: MODE_ACTIONS_STYLE,
|
|
879
|
+
get children() {
|
|
880
|
+
if (mode === "tree") {
|
|
881
|
+
return [
|
|
882
|
+
createComponent(Pressable, {
|
|
883
|
+
accessibilityRole: "button",
|
|
884
|
+
accessibilityLabel: "Show causal operations",
|
|
885
|
+
onPress: () => switchViewMode("operations"),
|
|
886
|
+
style: BUTTON_STYLE,
|
|
887
|
+
children: createComponent(Text, {
|
|
888
|
+
style: BUTTON_TEXT_STYLE,
|
|
889
|
+
children: "Operations",
|
|
890
|
+
}),
|
|
891
|
+
}),
|
|
892
|
+
createComponent(Pressable, {
|
|
893
|
+
accessibilityRole: "button",
|
|
894
|
+
accessibilityLabel: "Group causal operations",
|
|
895
|
+
onPress: () => switchViewMode("groups"),
|
|
896
|
+
style: BUTTON_STYLE,
|
|
897
|
+
children: createComponent(Text, {
|
|
898
|
+
style: BUTTON_TEXT_STYLE,
|
|
899
|
+
children: "Groups",
|
|
900
|
+
}),
|
|
901
|
+
}),
|
|
902
|
+
];
|
|
903
|
+
}
|
|
904
|
+
return [
|
|
905
|
+
createComponent(Pressable, {
|
|
906
|
+
accessibilityRole: "button",
|
|
907
|
+
accessibilityLabel: mode === "groups"
|
|
908
|
+
? "Show causal operations"
|
|
909
|
+
: "Group causal operations",
|
|
910
|
+
onPress: () => switchViewMode(mode === "groups" ? "operations" : "groups"),
|
|
911
|
+
style: BUTTON_STYLE,
|
|
912
|
+
children: createComponent(Text, {
|
|
913
|
+
style: BUTTON_TEXT_STYLE,
|
|
914
|
+
children: mode === "groups"
|
|
915
|
+
? "Show individual operations"
|
|
916
|
+
: "Group connected operations",
|
|
917
|
+
}),
|
|
918
|
+
}),
|
|
919
|
+
...(snapshotTree === undefined
|
|
920
|
+
? []
|
|
921
|
+
: [
|
|
922
|
+
createComponent(Pressable, {
|
|
923
|
+
accessibilityRole: "button",
|
|
924
|
+
accessibilityLabel: "Inspect UI tree",
|
|
925
|
+
onPress: () => {
|
|
926
|
+
switchViewMode("tree");
|
|
927
|
+
setSelectedTreeNodeHandle(undefined);
|
|
928
|
+
},
|
|
929
|
+
style: BUTTON_STYLE,
|
|
930
|
+
children: createComponent(Text, {
|
|
931
|
+
style: BUTTON_TEXT_STYLE,
|
|
932
|
+
children: "UI tree",
|
|
933
|
+
}),
|
|
934
|
+
}),
|
|
935
|
+
]),
|
|
936
|
+
];
|
|
937
|
+
},
|
|
938
|
+
}),
|
|
939
|
+
]
|
|
940
|
+
: []),
|
|
941
|
+
createComponent(ScrollView, {
|
|
942
|
+
style: SHELL_STYLE,
|
|
943
|
+
contentContainerStyle: LIST_STYLE,
|
|
944
|
+
get children() {
|
|
945
|
+
if (mode === "tree") {
|
|
946
|
+
if (selectedTreeEntry !== undefined &&
|
|
947
|
+
treeIndex !== undefined) {
|
|
948
|
+
return treeNodeDetailContent({
|
|
949
|
+
index: treeIndex,
|
|
950
|
+
entry: selectedTreeEntry,
|
|
951
|
+
linkedOperations: treeCorrelation?.operationsByNodeHandle.get(selectedTreeEntry.node.handle) ?? [],
|
|
952
|
+
highlightError: treeHighlightError(),
|
|
953
|
+
onHighlightNode: measureTreeNode === undefined
|
|
954
|
+
? undefined
|
|
955
|
+
: highlightTreeNode,
|
|
956
|
+
onSelectNode: (handle) => selectTreeNodeHandle(handle),
|
|
957
|
+
onSelectOperation: inspectCausalOperation,
|
|
958
|
+
});
|
|
959
|
+
}
|
|
960
|
+
return treeListContent({
|
|
961
|
+
index: treeIndex,
|
|
962
|
+
failure: currentTreeFailure,
|
|
963
|
+
search: treeSearch(),
|
|
964
|
+
maxVisibleNodes: maxVisibleTreeNodes,
|
|
965
|
+
operationsByNodeHandle: treeCorrelation?.operationsByNodeHandle,
|
|
966
|
+
onSelectNode: (handle) => selectTreeNodeHandle(handle),
|
|
967
|
+
});
|
|
968
|
+
}
|
|
969
|
+
if (explanation !== undefined) {
|
|
970
|
+
const linkedHandles = treeCorrelation?.nodeHandlesByOperationId.get(explanation.target.operationId) ?? [];
|
|
971
|
+
const linkedTreeEntries = treeIndex === undefined
|
|
972
|
+
? []
|
|
973
|
+
: linkedHandles
|
|
974
|
+
.map((handle) => treeIndex.byHandle.get(handle))
|
|
975
|
+
.filter((entry) => entry !== undefined);
|
|
976
|
+
return explanationContent(explanation, (operation) => setSelectedOperationId(operation.operationId), linkedTreeEntries, snapshotTree === undefined ? undefined : inspectTreeNode);
|
|
977
|
+
}
|
|
978
|
+
if (selectedGroup !== undefined) {
|
|
979
|
+
return groupContent(selectedGroup, maxVisibleOperations, (operation) => setSelectedOperationId(operation.operationId));
|
|
980
|
+
}
|
|
981
|
+
if (mode === "groups") {
|
|
982
|
+
if (visibleGroups.length === 0) {
|
|
983
|
+
return createComponent(Text, {
|
|
984
|
+
style: EMPTY_STYLE,
|
|
985
|
+
children: retained.operations.length === 0
|
|
986
|
+
? "No causal operations captured."
|
|
987
|
+
: "No causal trace groups match this filter.",
|
|
988
|
+
});
|
|
989
|
+
}
|
|
990
|
+
return [
|
|
991
|
+
createComponent(Text, {
|
|
992
|
+
style: SUMMARY_STYLE,
|
|
993
|
+
children: `${String(matchingGroups.length)} ${matchingGroups.length === 1 ? "matching retained trace group" : "matching retained trace groups"}.`,
|
|
994
|
+
}),
|
|
995
|
+
...visibleGroups.map((group) => TraceGroupRow({
|
|
996
|
+
group,
|
|
997
|
+
onSelect: () => setSelectedGroupId(group.groupId),
|
|
998
|
+
})),
|
|
999
|
+
];
|
|
1000
|
+
}
|
|
1001
|
+
if (visible.length === 0) {
|
|
1002
|
+
return createComponent(Text, {
|
|
1003
|
+
style: EMPTY_STYLE,
|
|
1004
|
+
children: normalizedSearch.length === 0
|
|
1005
|
+
? "No causal operations captured."
|
|
1006
|
+
: "No causal operations match this filter.",
|
|
1007
|
+
});
|
|
1008
|
+
}
|
|
1009
|
+
return [
|
|
1010
|
+
...(normalizedSearch.length === 0
|
|
1011
|
+
? []
|
|
1012
|
+
: [
|
|
1013
|
+
createComponent(Text, {
|
|
1014
|
+
style: SUMMARY_STYLE,
|
|
1015
|
+
children: `${String(matchingOperations.length)} matching retained operations.`,
|
|
1016
|
+
}),
|
|
1017
|
+
]),
|
|
1018
|
+
...visible.map((operation) => OperationRow({
|
|
1019
|
+
operation,
|
|
1020
|
+
onSelect: () => setSelectedOperationId(operation.operationId),
|
|
1021
|
+
})),
|
|
1022
|
+
];
|
|
1023
|
+
},
|
|
1024
|
+
}),
|
|
1025
|
+
...(mode === "tree"
|
|
1026
|
+
? []
|
|
1027
|
+
: [
|
|
1028
|
+
createComponent(Pressable, {
|
|
1029
|
+
accessibilityRole: "button",
|
|
1030
|
+
accessibilityLabel: "Clear causal trace",
|
|
1031
|
+
onPress: clear,
|
|
1032
|
+
style: BUTTON_STYLE,
|
|
1033
|
+
children: createComponent(Text, {
|
|
1034
|
+
style: BUTTON_TEXT_STYLE,
|
|
1035
|
+
children: "Clear retained trace",
|
|
1036
|
+
}),
|
|
1037
|
+
}),
|
|
1038
|
+
]),
|
|
1039
|
+
];
|
|
1040
|
+
},
|
|
1041
|
+
});
|
|
1042
|
+
return retainedPanel;
|
|
1043
|
+
};
|
|
1044
|
+
const highlightSlot = createComponent(View, {
|
|
1045
|
+
collapsable: false,
|
|
1046
|
+
style: OVERLAY_SLOT_STYLE,
|
|
1047
|
+
get accessibilityElementsHidden() {
|
|
1048
|
+
return open() || highlightedTreeNode() === undefined;
|
|
1049
|
+
},
|
|
1050
|
+
get importantForAccessibility() {
|
|
1051
|
+
return !open() && highlightedTreeNode() !== undefined
|
|
1052
|
+
? "auto"
|
|
1053
|
+
: "no-hide-descendants";
|
|
1054
|
+
},
|
|
1055
|
+
get pointerEvents() {
|
|
1056
|
+
return !open() && highlightedTreeNode() !== undefined
|
|
1057
|
+
? "box-none"
|
|
1058
|
+
: "none";
|
|
1059
|
+
},
|
|
1060
|
+
get children() {
|
|
1061
|
+
const activeHighlight = open() ? undefined : highlightedTreeNode();
|
|
1062
|
+
return activeHighlight === undefined
|
|
1063
|
+
? undefined
|
|
1064
|
+
: TreeHighlightOverlay({
|
|
1065
|
+
highlight: activeHighlight,
|
|
1066
|
+
onReturnToInspector: returnToInspectorFromHighlight,
|
|
1067
|
+
onDismiss: dismissTreeHighlight,
|
|
1068
|
+
});
|
|
1069
|
+
},
|
|
1070
|
+
});
|
|
1071
|
+
const badgeSlot = createComponent(View, {
|
|
1072
|
+
style: OVERLAY_SLOT_STYLE,
|
|
1073
|
+
get accessibilityElementsHidden() {
|
|
1074
|
+
return open() || highlightedTreeNode() !== undefined;
|
|
1075
|
+
},
|
|
1076
|
+
get importantForAccessibility() {
|
|
1077
|
+
return open() || highlightedTreeNode() !== undefined
|
|
1078
|
+
? "no-hide-descendants"
|
|
1079
|
+
: "auto";
|
|
1080
|
+
},
|
|
1081
|
+
get pointerEvents() {
|
|
1082
|
+
return open() || highlightedTreeNode() !== undefined
|
|
1083
|
+
? "none"
|
|
1084
|
+
: "box-none";
|
|
1085
|
+
},
|
|
1086
|
+
children: badge,
|
|
1087
|
+
});
|
|
1088
|
+
const panelSlot = createComponent(View, {
|
|
1089
|
+
style: OVERLAY_SLOT_STYLE,
|
|
1090
|
+
get accessibilityElementsHidden() {
|
|
1091
|
+
return !open();
|
|
1092
|
+
},
|
|
1093
|
+
get importantForAccessibility() {
|
|
1094
|
+
return open() ? "auto" : "no-hide-descendants";
|
|
1095
|
+
},
|
|
1096
|
+
get pointerEvents() {
|
|
1097
|
+
return open() ? "box-none" : "none";
|
|
1098
|
+
},
|
|
1099
|
+
get children() {
|
|
1100
|
+
return open() ? panel() : undefined;
|
|
1101
|
+
},
|
|
1102
|
+
});
|
|
1103
|
+
return createComponent(View, {
|
|
1104
|
+
style: SHELL_STYLE,
|
|
1105
|
+
children: [applicationContainer, badgeSlot, highlightSlot, panelSlot],
|
|
1106
|
+
});
|
|
1107
|
+
}
|
|
1108
|
+
//# sourceMappingURL=causal-solid.js.map
|