@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.
Files changed (51) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +266 -2
  3. package/dist/causal-solid.d.ts +30 -0
  4. package/dist/causal-solid.d.ts.map +1 -0
  5. package/dist/causal-solid.js +1108 -0
  6. package/dist/causal-solid.js.map +1 -0
  7. package/dist/index.d.ts +46 -0
  8. package/dist/index.d.ts.map +1 -0
  9. package/dist/index.js +220 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/network-service-development.d.ts +6 -0
  12. package/dist/network-service-development.d.ts.map +1 -0
  13. package/dist/network-service-development.js +12 -0
  14. package/dist/network-service-development.js.map +1 -0
  15. package/dist/network-service.d.ts +13 -0
  16. package/dist/network-service.d.ts.map +1 -0
  17. package/dist/network-service.js +37 -0
  18. package/dist/network-service.js.map +1 -0
  19. package/dist/network.d.ts +57 -0
  20. package/dist/network.d.ts.map +1 -0
  21. package/dist/network.js +353 -0
  22. package/dist/network.js.map +1 -0
  23. package/dist/react-native.d.ts +27 -0
  24. package/dist/react-native.d.ts.map +1 -0
  25. package/dist/react-native.js +111 -0
  26. package/dist/react-native.js.map +1 -0
  27. package/dist/root-development.d.ts +5 -0
  28. package/dist/root-development.d.ts.map +1 -0
  29. package/dist/root-development.js +86 -0
  30. package/dist/root-development.js.map +1 -0
  31. package/dist/root.d.ts +48 -0
  32. package/dist/root.d.ts.map +1 -0
  33. package/dist/root.js +8 -0
  34. package/dist/root.js.map +1 -0
  35. package/dist/solid-diagnostics-development.d.ts +30 -0
  36. package/dist/solid-diagnostics-development.d.ts.map +1 -0
  37. package/dist/solid-diagnostics-development.js +166 -0
  38. package/dist/solid-diagnostics-development.js.map +1 -0
  39. package/dist/solid-diagnostics.d.ts +15 -0
  40. package/dist/solid-diagnostics.d.ts.map +1 -0
  41. package/dist/solid-diagnostics.js +20 -0
  42. package/dist/solid-diagnostics.js.map +1 -0
  43. package/dist/solid.d.ts +32 -0
  44. package/dist/solid.d.ts.map +1 -0
  45. package/dist/solid.js +563 -0
  46. package/dist/solid.js.map +1 -0
  47. package/dist/tree-solid.d.ts +106 -0
  48. package/dist/tree-solid.d.ts.map +1 -0
  49. package/dist/tree-solid.js +1117 -0
  50. package/dist/tree-solid.js.map +1 -0
  51. package/package.json +66 -3
@@ -0,0 +1,1117 @@
1
+ import { Pressable, ScrollView, Text, TextInput, View, } from "@solidnative-dev/core";
2
+ import { parseTreeDebugSnapshot, } from "@solidnative-dev/observability";
3
+ import { createComponent, createSignal, onCleanup, } from "solid-js";
4
+ export const DEVELOPMENT_TREE_PANEL_DEFAULT_VISIBLE_NODES = 80;
5
+ export const DEVELOPMENT_TREE_PANEL_MAX_VISIBLE_NODES = 250;
6
+ export const DEVELOPMENT_TREE_PANEL_MAX_SEARCH_LENGTH = 128;
7
+ const MAX_VISUAL_INDENT_DEPTH = 10;
8
+ const INLINE_PROP_NAME_PREVIEW_LIMIT = 4;
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 TITLE_STYLE = Object.freeze({
44
+ color: "#ecfdf5",
45
+ fontSize: 23,
46
+ fontWeight: "700",
47
+ });
48
+ const SUMMARY_STYLE = Object.freeze({
49
+ color: "#8fbab0",
50
+ fontSize: 13,
51
+ lineHeight: 18,
52
+ marginBottom: 12,
53
+ });
54
+ const SEARCH_STYLE = Object.freeze({
55
+ backgroundColor: "#0d2925",
56
+ borderColor: "#24564e",
57
+ borderWidth: 1,
58
+ borderRadius: 8,
59
+ color: "#ecfdf5",
60
+ fontSize: 14,
61
+ marginBottom: 12,
62
+ paddingTop: 9,
63
+ paddingRight: 11,
64
+ paddingBottom: 9,
65
+ paddingLeft: 11,
66
+ });
67
+ const BUTTON_STYLE = Object.freeze({
68
+ backgroundColor: "#153c36",
69
+ borderRadius: 7,
70
+ paddingTop: 8,
71
+ paddingRight: 10,
72
+ paddingBottom: 8,
73
+ paddingLeft: 10,
74
+ });
75
+ const BUTTON_TEXT_STYLE = Object.freeze({
76
+ color: "#d1fae5",
77
+ fontSize: 12,
78
+ fontWeight: "700",
79
+ });
80
+ const LIST_STYLE = Object.freeze({
81
+ flexGrow: 1,
82
+ gap: 9,
83
+ paddingBottom: 24,
84
+ });
85
+ const ROW_STYLE = Object.freeze({
86
+ backgroundColor: "#0d2925",
87
+ borderColor: "#24564e",
88
+ borderWidth: 1,
89
+ borderRadius: 9,
90
+ gap: 4,
91
+ padding: 11,
92
+ });
93
+ const ROW_TITLE_STYLE = Object.freeze({
94
+ color: "#d1fae5",
95
+ fontFamily: "monospace",
96
+ fontSize: 13,
97
+ fontWeight: "700",
98
+ });
99
+ const ROW_META_STYLE = Object.freeze({
100
+ color: "#8fbab0",
101
+ fontSize: 12,
102
+ lineHeight: 17,
103
+ });
104
+ const CAUSAL_TAG_STYLE = Object.freeze({
105
+ color: "#6ee7b7",
106
+ fontFamily: "monospace",
107
+ fontSize: 11,
108
+ lineHeight: 16,
109
+ });
110
+ const SECTION_STYLE = Object.freeze({
111
+ gap: 8,
112
+ marginTop: 8,
113
+ });
114
+ const SECTION_TITLE_STYLE = Object.freeze({
115
+ color: "#a7f3d0",
116
+ fontSize: 13,
117
+ fontWeight: "700",
118
+ textTransform: "uppercase",
119
+ });
120
+ const DETAIL_CARD_STYLE = Object.freeze({
121
+ backgroundColor: "#102f2a",
122
+ borderColor: "#2d6c60",
123
+ borderWidth: 1,
124
+ borderRadius: 9,
125
+ gap: 5,
126
+ padding: 12,
127
+ });
128
+ const EMPTY_STYLE = Object.freeze({
129
+ color: "#a7c7c0",
130
+ fontSize: 15,
131
+ paddingTop: 28,
132
+ textAlign: "center",
133
+ });
134
+ const BADGE_BASE_STYLE = Object.freeze({
135
+ position: "absolute",
136
+ right: 16,
137
+ backgroundColor: "#0d3b34",
138
+ borderColor: "#3c776c",
139
+ borderWidth: 1,
140
+ borderRadius: 18,
141
+ paddingTop: 9,
142
+ paddingRight: 14,
143
+ paddingBottom: 9,
144
+ paddingLeft: 14,
145
+ });
146
+ const BADGE_TEXT_STYLE = Object.freeze({
147
+ color: "#ecfdf5",
148
+ fontSize: 13,
149
+ fontWeight: "700",
150
+ });
151
+ const HIGHLIGHT_ACTION_STYLE = Object.freeze({
152
+ alignSelf: "flex-start",
153
+ backgroundColor: "#047857",
154
+ borderColor: "#34d399",
155
+ borderWidth: 1,
156
+ borderRadius: 8,
157
+ marginTop: 6,
158
+ paddingTop: 9,
159
+ paddingRight: 12,
160
+ paddingBottom: 9,
161
+ paddingLeft: 12,
162
+ });
163
+ const HIGHLIGHT_ACTION_TEXT_STYLE = Object.freeze({
164
+ color: "#ecfdf5",
165
+ fontSize: 13,
166
+ fontWeight: "700",
167
+ });
168
+ const HIGHLIGHT_ERROR_STYLE = Object.freeze({
169
+ color: "#fca5a5",
170
+ fontSize: 12,
171
+ lineHeight: 17,
172
+ marginTop: 4,
173
+ });
174
+ const HIGHLIGHT_BANNER_BASE_STYLE = Object.freeze({
175
+ position: "absolute",
176
+ left: 16,
177
+ right: 16,
178
+ backgroundColor: "#071a18",
179
+ borderColor: "#34d399",
180
+ borderWidth: 1,
181
+ borderRadius: 12,
182
+ gap: 8,
183
+ padding: 12,
184
+ });
185
+ const HIGHLIGHT_BANNER_ACTIONS_STYLE = Object.freeze({
186
+ flexDirection: "row",
187
+ gap: 8,
188
+ });
189
+ function counted(count, singular, plural) {
190
+ return `${String(count)} ${count === 1 ? singular : plural}`;
191
+ }
192
+ export function optionalTreeSnapshotProvider(value, ownerName) {
193
+ if (value === undefined)
194
+ return undefined;
195
+ if (typeof value !== "function") {
196
+ throw new TypeError(`${ownerName} snapshotTree must be a function.`);
197
+ }
198
+ return value;
199
+ }
200
+ export function optionalTreeMeasureProvider(value, ownerName) {
201
+ if (value === undefined)
202
+ return undefined;
203
+ if (typeof value !== "function") {
204
+ throw new TypeError(`${ownerName} measureTreeNode must be a function.`);
205
+ }
206
+ return value;
207
+ }
208
+ function isValidTreeNodeBounds(value) {
209
+ if (value === null || typeof value !== "object")
210
+ return false;
211
+ const candidate = value;
212
+ return (typeof candidate.x === "number" &&
213
+ Number.isFinite(candidate.x) &&
214
+ typeof candidate.y === "number" &&
215
+ Number.isFinite(candidate.y) &&
216
+ typeof candidate.width === "number" &&
217
+ Number.isFinite(candidate.width) &&
218
+ candidate.width >= 0 &&
219
+ typeof candidate.height === "number" &&
220
+ Number.isFinite(candidate.height) &&
221
+ candidate.height >= 0 &&
222
+ typeof candidate.pageX === "number" &&
223
+ Number.isFinite(candidate.pageX) &&
224
+ typeof candidate.pageY === "number" &&
225
+ Number.isFinite(candidate.pageY));
226
+ }
227
+ export async function resolveTreeHighlightBounds(provider, handle) {
228
+ try {
229
+ const raw = await provider(handle);
230
+ if (!isValidTreeNodeBounds(raw))
231
+ return undefined;
232
+ return Object.freeze({
233
+ x: raw.x,
234
+ y: raw.y,
235
+ width: raw.width,
236
+ height: raw.height,
237
+ pageX: raw.pageX,
238
+ pageY: raw.pageY,
239
+ });
240
+ }
241
+ catch {
242
+ return undefined;
243
+ }
244
+ }
245
+ function formatCoordinate(value) {
246
+ const rounded = Math.round(value * 10) / 10;
247
+ return Number.isInteger(rounded) ? String(rounded) : rounded.toFixed(1);
248
+ }
249
+ export function formatTreeNodeBounds(bounds) {
250
+ return `x=${formatCoordinate(bounds.pageX)}, y=${formatCoordinate(bounds.pageY)} · ${formatCoordinate(bounds.width)}×${formatCoordinate(bounds.height)}`;
251
+ }
252
+ export function TreeHighlightOverlay(props) {
253
+ const { highlight } = props;
254
+ const { bounds } = highlight;
255
+ const label = highlight.selectedHandle === highlight.measuredHandle
256
+ ? highlight.summary
257
+ : `${highlight.summary} (via ${highlight.measuredSummary})`;
258
+ const bannerPosition = bounds.pageY < 190 ? { bottom: 84 } : { top: 68 };
259
+ return createComponent(View, {
260
+ collapsable: false,
261
+ pointerEvents: "box-none",
262
+ style: OVERLAY_SLOT_STYLE,
263
+ testID: "solid-native-development-tree-highlight-overlay",
264
+ get children() {
265
+ return [
266
+ createComponent(View, {
267
+ collapsable: false,
268
+ pointerEvents: "none",
269
+ style: {
270
+ position: "absolute",
271
+ left: bounds.pageX,
272
+ top: bounds.pageY,
273
+ width: Math.max(bounds.width, 2),
274
+ height: Math.max(bounds.height, 2),
275
+ borderWidth: 2,
276
+ borderColor: "#10b981",
277
+ backgroundColor: "rgba(16, 185, 129, 0.18)",
278
+ borderRadius: 4,
279
+ },
280
+ testID: "solid-native-development-tree-highlight-box",
281
+ }),
282
+ createComponent(View, {
283
+ collapsable: false,
284
+ style: { ...HIGHLIGHT_BANNER_BASE_STYLE, ...bannerPosition },
285
+ testID: "solid-native-development-tree-highlight-banner",
286
+ get children() {
287
+ return [
288
+ createComponent(Text, {
289
+ style: ROW_TITLE_STYLE,
290
+ children: `Highlight · ${label}`,
291
+ }),
292
+ createComponent(Text, {
293
+ style: CAUSAL_TAG_STYLE,
294
+ children: formatTreeNodeBounds(bounds),
295
+ }),
296
+ createComponent(View, {
297
+ style: HIGHLIGHT_BANNER_ACTIONS_STYLE,
298
+ get children() {
299
+ return [
300
+ createComponent(Pressable, {
301
+ accessibilityRole: "button",
302
+ accessibilityLabel: "Return to UI tree inspector",
303
+ onPress: props.onReturnToInspector,
304
+ style: BUTTON_STYLE,
305
+ children: createComponent(Text, {
306
+ style: BUTTON_TEXT_STYLE,
307
+ children: "Inspector",
308
+ }),
309
+ }),
310
+ createComponent(Pressable, {
311
+ accessibilityRole: "button",
312
+ accessibilityLabel: "Dismiss UI node highlight",
313
+ onPress: props.onDismiss,
314
+ style: BUTTON_STYLE,
315
+ children: createComponent(Text, {
316
+ style: BUTTON_TEXT_STYLE,
317
+ children: "Dismiss",
318
+ }),
319
+ }),
320
+ ];
321
+ },
322
+ }),
323
+ ];
324
+ },
325
+ }),
326
+ ];
327
+ },
328
+ });
329
+ }
330
+ export function requireTreeSnapshotProvider(value) {
331
+ if (typeof value !== "function") {
332
+ throw new TypeError("DevelopmentTreePanel requires a snapshotTree function.");
333
+ }
334
+ return value;
335
+ }
336
+ export function captureValidatedTreeSnapshot(provider) {
337
+ try {
338
+ const raw = provider();
339
+ if (raw === undefined)
340
+ return {};
341
+ return { snapshot: parseTreeDebugSnapshot(raw) };
342
+ }
343
+ catch {
344
+ return { failure: "The UI tree snapshot could not be validated." };
345
+ }
346
+ }
347
+ export function normalizedTreeSearch(value) {
348
+ return value
349
+ .slice(0, DEVELOPMENT_TREE_PANEL_MAX_SEARCH_LENGTH)
350
+ .trim()
351
+ .toLowerCase();
352
+ }
353
+ export function formatTreeNodeSummary(node) {
354
+ if (node.kind === "text") {
355
+ return `#text #${String(node.handle)} (${counted(node.textLength, "char", "chars")})`;
356
+ }
357
+ const role = node.role === undefined ? "" : ` [${node.role}]`;
358
+ return `<${node.component}> #${String(node.handle)}${role}`;
359
+ }
360
+ export function formatTreeNodeAccessibilityLabel(node) {
361
+ if (node.kind === "text") {
362
+ return `Inspect UI text node (#${String(node.handle)})`;
363
+ }
364
+ return `Inspect UI node ${node.component} (#${String(node.handle)})`;
365
+ }
366
+ export function formatTreeNodeMeta(node, linkedOperationCount = 0) {
367
+ const parts = [];
368
+ if (node.kind === "text") {
369
+ parts.push(`length: ${counted(node.textLength, "char", "chars")}`);
370
+ }
371
+ else {
372
+ if (node.propNames.length > 0) {
373
+ const preview = node.propNames
374
+ .slice(0, INLINE_PROP_NAME_PREVIEW_LIMIT)
375
+ .join(", ");
376
+ const remaining = node.propNames.length - INLINE_PROP_NAME_PREVIEW_LIMIT;
377
+ parts.push(`props: ${preview}${remaining > 0 ? ` (+${String(remaining)})` : ""}`);
378
+ }
379
+ if (node.eventNames.length > 0) {
380
+ parts.push(`events: ${node.eventNames.join(", ")}`);
381
+ }
382
+ if (node.children.length > 0 || node.omittedChildCount !== undefined) {
383
+ const omitted = node.omittedChildCount === undefined
384
+ ? ""
385
+ : ` (+${String(node.omittedChildCount)} omitted)`;
386
+ parts.push(`children: ${String(node.children.length)}${omitted}`);
387
+ }
388
+ if (parts.length === 0) {
389
+ parts.push("empty element");
390
+ }
391
+ }
392
+ if (linkedOperationCount > 0) {
393
+ parts.push(counted(linkedOperationCount, "linked op", "linked ops"));
394
+ }
395
+ return parts.join(" · ");
396
+ }
397
+ function formatTreeNodeCausalTags(node) {
398
+ const parts = [];
399
+ if (node.causalOwner !== undefined) {
400
+ parts.push(`owner=${node.causalOwner}`);
401
+ }
402
+ if (node.causalComputation !== undefined) {
403
+ parts.push(`computation=${node.causalComputation}`);
404
+ }
405
+ return parts.length === 0 ? undefined : parts.join(" · ");
406
+ }
407
+ export function treeSummaryText(snapshot) {
408
+ const sentinels = snapshot.sentinelCount === 0
409
+ ? ""
410
+ : `, ${String(snapshot.sentinelCount)} sentinels`;
411
+ const truncated = snapshot.truncated ? " · truncated" : "";
412
+ return `${snapshot.platform} · seq ${String(snapshot.committedSequence)} · ${counted(snapshot.nodeCount, "node", "nodes")} (${String(snapshot.elementCount)} elements, ${String(snapshot.textCount)} text${sentinels}) · depth ${String(snapshot.maxDepth)}${truncated}. Value-free snapshot.`;
413
+ }
414
+ function buildSearchText(node) {
415
+ const tokens = [
416
+ `#${String(node.handle)}`,
417
+ String(node.handle),
418
+ node.kind,
419
+ ];
420
+ if (node.kind === "text") {
421
+ tokens.push("#text");
422
+ }
423
+ else {
424
+ tokens.push(node.component);
425
+ if (node.role !== undefined)
426
+ tokens.push(node.role);
427
+ for (const propName of node.propNames)
428
+ tokens.push(propName);
429
+ for (const eventName of node.eventNames)
430
+ tokens.push(eventName);
431
+ }
432
+ if (node.causalOwner !== undefined)
433
+ tokens.push(node.causalOwner);
434
+ if (node.causalComputation !== undefined)
435
+ tokens.push(node.causalComputation);
436
+ return tokens.join(" ").toLowerCase();
437
+ }
438
+ function pushMapEntry(map, key, value) {
439
+ const existing = map.get(key);
440
+ if (existing === undefined) {
441
+ map.set(key, [value]);
442
+ }
443
+ else if (!existing.includes(value)) {
444
+ existing.push(value);
445
+ }
446
+ }
447
+ export function indexTreeDebugSnapshot(snapshot) {
448
+ const entries = [];
449
+ const byHandle = new Map();
450
+ const handlesByOwner = new Map();
451
+ const handlesByComputation = new Map();
452
+ const visit = (node, depth, parentHandle, ancestorPrefix, connector) => {
453
+ const visualPrefix = depth <= MAX_VISUAL_INDENT_DEPTH
454
+ ? `${ancestorPrefix}${connector}`
455
+ : `${ancestorPrefix}[d${String(depth)}] ${connector}`;
456
+ const childrenHandles = node.kind === "element"
457
+ ? Object.freeze(node.children.map((child) => child.handle))
458
+ : Object.freeze([]);
459
+ const entry = Object.freeze({
460
+ node,
461
+ depth,
462
+ parentHandle,
463
+ childrenHandles,
464
+ prefix: visualPrefix,
465
+ summary: formatTreeNodeSummary(node),
466
+ searchText: buildSearchText(node),
467
+ });
468
+ entries.push(entry);
469
+ byHandle.set(node.handle, entry);
470
+ if (node.causalOwner !== undefined) {
471
+ pushMapEntry(handlesByOwner, node.causalOwner, node.handle);
472
+ }
473
+ if (node.causalComputation !== undefined) {
474
+ pushMapEntry(handlesByComputation, node.causalComputation, node.handle);
475
+ }
476
+ if (node.kind === "element") {
477
+ const nextAncestorPrefix = depth >= MAX_VISUAL_INDENT_DEPTH
478
+ ? ancestorPrefix
479
+ : connector === ""
480
+ ? ""
481
+ : `${ancestorPrefix}${connector === "├ " ? "│ " : " "}`;
482
+ const childCount = node.children.length;
483
+ for (let index = 0; index < childCount; index += 1) {
484
+ const child = node.children[index];
485
+ const isLast = index === childCount - 1;
486
+ visit(child, depth + 1, node.handle, nextAncestorPrefix, isLast ? "└ " : "├ ");
487
+ }
488
+ }
489
+ };
490
+ visit(snapshot.root, 0, undefined, "", "");
491
+ return Object.freeze({
492
+ snapshot,
493
+ entries: Object.freeze(entries),
494
+ byHandle,
495
+ handlesByOwner,
496
+ handlesByComputation,
497
+ });
498
+ }
499
+ export function correlateTreeWithCausalSnapshot(index, timelineSnapshot) {
500
+ const operationsByNodeHandle = new Map();
501
+ const nodeHandlesByOperationId = new Map();
502
+ const link = (handle, operation) => {
503
+ pushMapEntry(operationsByNodeHandle, handle, operation);
504
+ pushMapEntry(nodeHandlesByOperationId, operation.operationId, handle);
505
+ };
506
+ for (const operation of timelineSnapshot.operations) {
507
+ const rawTargetNode = operation.startAttributes["target.node"];
508
+ if (typeof rawTargetNode === "number" &&
509
+ Number.isSafeInteger(rawTargetNode) &&
510
+ index.byHandle.has(rawTargetNode)) {
511
+ link(rawTargetNode, operation);
512
+ }
513
+ const rawOwnerName = operation.startAttributes["owner.name"];
514
+ if (typeof rawOwnerName === "string") {
515
+ const ownerHandles = index.handlesByOwner.get(rawOwnerName);
516
+ if (ownerHandles !== undefined) {
517
+ for (const handle of ownerHandles) {
518
+ link(handle, operation);
519
+ }
520
+ }
521
+ }
522
+ const rawComputationName = operation.startAttributes["computation.name"];
523
+ if (typeof rawComputationName === "string") {
524
+ const computationHandles = index.handlesByComputation.get(rawComputationName);
525
+ if (computationHandles !== undefined) {
526
+ for (const handle of computationHandles) {
527
+ link(handle, operation);
528
+ }
529
+ }
530
+ }
531
+ }
532
+ return Object.freeze({
533
+ operationsByNodeHandle,
534
+ nodeHandlesByOperationId,
535
+ });
536
+ }
537
+ export function TreeNodeRow(props) {
538
+ const causalTags = formatTreeNodeCausalTags(props.entry.node);
539
+ return createComponent(Pressable, {
540
+ accessibilityRole: "button",
541
+ accessibilityLabel: formatTreeNodeAccessibilityLabel(props.entry.node),
542
+ onPress: props.onSelect,
543
+ style: ROW_STYLE,
544
+ get children() {
545
+ return [
546
+ createComponent(Text, {
547
+ style: ROW_TITLE_STYLE,
548
+ children: `${props.showPrefix === false ? "" : props.entry.prefix}${props.entry.summary}`,
549
+ }),
550
+ createComponent(Text, {
551
+ style: ROW_META_STYLE,
552
+ children: formatTreeNodeMeta(props.entry.node, props.linkedOperationCount ?? 0),
553
+ }),
554
+ ...(causalTags === undefined
555
+ ? []
556
+ : [
557
+ createComponent(Text, {
558
+ style: CAUSAL_TAG_STYLE,
559
+ children: causalTags,
560
+ }),
561
+ ]),
562
+ ];
563
+ },
564
+ });
565
+ }
566
+ export function treeListContent(options) {
567
+ if (options.failure !== undefined) {
568
+ return createComponent(Text, {
569
+ style: EMPTY_STYLE,
570
+ children: options.failure,
571
+ });
572
+ }
573
+ if (options.index === undefined) {
574
+ return createComponent(Text, {
575
+ style: EMPTY_STYLE,
576
+ children: "No UI tree snapshot captured.",
577
+ });
578
+ }
579
+ const normalized = normalizedTreeSearch(options.search);
580
+ const matching = normalized.length === 0
581
+ ? options.index.entries
582
+ : options.index.entries.filter((entry) => entry.searchText.includes(normalized));
583
+ if (matching.length === 0) {
584
+ return createComponent(Text, {
585
+ style: EMPTY_STYLE,
586
+ children: "No UI tree nodes match this filter.",
587
+ });
588
+ }
589
+ const visible = matching.slice(0, options.maxVisibleNodes);
590
+ const omitted = matching.length - visible.length;
591
+ return [
592
+ ...(normalized.length === 0
593
+ ? []
594
+ : [
595
+ createComponent(Text, {
596
+ style: SUMMARY_STYLE,
597
+ children: `${counted(matching.length, "matching UI node", "matching UI nodes")}.`,
598
+ }),
599
+ ]),
600
+ ...(omitted === 0
601
+ ? []
602
+ : [
603
+ createComponent(Text, {
604
+ style: SUMMARY_STYLE,
605
+ children: `${counted(omitted, "additional node is", "additional nodes are")} hidden by the visible-row limit.`,
606
+ }),
607
+ ]),
608
+ ...visible.map((entry) => TreeNodeRow({
609
+ entry,
610
+ linkedOperationCount: options.operationsByNodeHandle?.get(entry.node.handle)?.length ?? 0,
611
+ showPrefix: normalized.length === 0,
612
+ onSelect: () => options.onSelectNode(entry.node.handle),
613
+ })),
614
+ ];
615
+ }
616
+ export function resolveTreeHighlightTarget(index, entry) {
617
+ if (entry.node.kind === "element")
618
+ return entry;
619
+ if (entry.parentHandle === undefined)
620
+ return undefined;
621
+ const parent = index.byHandle.get(entry.parentHandle);
622
+ return parent?.node.kind === "element" ? parent : undefined;
623
+ }
624
+ export function treeNodeDetailContent(options) {
625
+ const { node } = options.entry;
626
+ const highlightTarget = resolveTreeHighlightTarget(options.index, options.entry);
627
+ const parentEntry = options.entry.parentHandle === undefined
628
+ ? undefined
629
+ : options.index.byHandle.get(options.entry.parentHandle);
630
+ const childEntries = options.entry.childrenHandles
631
+ .map((handle) => options.index.byHandle.get(handle))
632
+ .filter((child) => child !== undefined);
633
+ const linkedOperations = options.linkedOperations ?? [];
634
+ const detailLines = [
635
+ `Handle: #${String(node.handle)} · Kind: ${node.kind} · Depth: ${String(options.entry.depth)}`,
636
+ ];
637
+ if (node.kind === "text") {
638
+ detailLines.push(`Text length: ${counted(node.textLength, "char", "chars")} (content omitted)`);
639
+ }
640
+ else {
641
+ if (node.role !== undefined) {
642
+ detailLines.push(`Accessibility role: ${node.role}`);
643
+ }
644
+ detailLines.push(`Props (${String(node.propNames.length)}): ${node.propNames.length === 0 ? "None" : node.propNames.join(", ")}`);
645
+ detailLines.push(`Events (${String(node.eventNames.length)}): ${node.eventNames.length === 0 ? "None" : node.eventNames.join(", ")}`);
646
+ const omittedSuffix = node.omittedChildCount === undefined
647
+ ? ""
648
+ : ` (${String(node.omittedChildCount)} omitted)`;
649
+ detailLines.push(`Children: ${String(node.children.length)}${omittedSuffix}`);
650
+ }
651
+ if (node.causalOwner !== undefined) {
652
+ detailLines.push(`Causal owner: ${node.causalOwner}`);
653
+ }
654
+ if (node.causalComputation !== undefined) {
655
+ detailLines.push(`Causal computation: ${node.causalComputation}`);
656
+ }
657
+ return [
658
+ createComponent(Text, {
659
+ style: SECTION_TITLE_STYLE,
660
+ children: "Selected UI node",
661
+ }),
662
+ createComponent(View, {
663
+ style: DETAIL_CARD_STYLE,
664
+ get children() {
665
+ return [
666
+ createComponent(Text, {
667
+ style: ROW_TITLE_STYLE,
668
+ children: options.entry.summary,
669
+ }),
670
+ ...detailLines.map((line) => createComponent(Text, {
671
+ style: ROW_META_STYLE,
672
+ children: line,
673
+ })),
674
+ ...(options.onHighlightNode === undefined ||
675
+ highlightTarget === undefined
676
+ ? []
677
+ : [
678
+ createComponent(Pressable, {
679
+ accessibilityRole: "button",
680
+ accessibilityLabel: "Highlight UI node on screen",
681
+ disabled: options.highlighting === true,
682
+ onPress: () => options.onHighlightNode(options.entry, highlightTarget),
683
+ style: HIGHLIGHT_ACTION_STYLE,
684
+ children: createComponent(Text, {
685
+ style: HIGHLIGHT_ACTION_TEXT_STYLE,
686
+ children: options.highlighting === true
687
+ ? "Measuring…"
688
+ : node.kind === "text"
689
+ ? "Highlight parent on screen"
690
+ : "Highlight on screen",
691
+ }),
692
+ }),
693
+ ]),
694
+ ...(options.highlightError === undefined
695
+ ? []
696
+ : [
697
+ createComponent(Text, {
698
+ style: HIGHLIGHT_ERROR_STYLE,
699
+ children: options.highlightError,
700
+ }),
701
+ ]),
702
+ ];
703
+ },
704
+ }),
705
+ ...(options.onSelectOperation === undefined
706
+ ? []
707
+ : [
708
+ createComponent(View, {
709
+ style: SECTION_STYLE,
710
+ get children() {
711
+ return [
712
+ createComponent(Text, {
713
+ style: SECTION_TITLE_STYLE,
714
+ children: `Linked causal operations (${String(linkedOperations.length)})`,
715
+ }),
716
+ ...(linkedOperations.length === 0
717
+ ? [
718
+ createComponent(Text, {
719
+ style: ROW_META_STYLE,
720
+ children: "None retained in this snapshot.",
721
+ }),
722
+ ]
723
+ : linkedOperations.map((operation) => createComponent(Pressable, {
724
+ accessibilityRole: "button",
725
+ accessibilityLabel: `Inspect causal operation ${operation.name} (${operation.operationId})`,
726
+ onPress: () => options.onSelectOperation(operation),
727
+ style: ROW_STYLE,
728
+ get children() {
729
+ const duration = operation.duration === undefined
730
+ ? "running"
731
+ : `${operation.duration.toFixed(2)} ms`;
732
+ return [
733
+ createComponent(Text, {
734
+ style: ROW_TITLE_STYLE,
735
+ children: operation.name,
736
+ }),
737
+ createComponent(Text, {
738
+ style: ROW_META_STYLE,
739
+ children: `${operation.status ?? "active"} · ${duration}`,
740
+ }),
741
+ createComponent(Text, {
742
+ selectable: true,
743
+ style: CAUSAL_TAG_STYLE,
744
+ children: operation.operationId,
745
+ }),
746
+ ];
747
+ },
748
+ }))),
749
+ ];
750
+ },
751
+ }),
752
+ ]),
753
+ ...(parentEntry === undefined
754
+ ? []
755
+ : [
756
+ createComponent(View, {
757
+ style: SECTION_STYLE,
758
+ get children() {
759
+ return [
760
+ createComponent(Text, {
761
+ style: SECTION_TITLE_STYLE,
762
+ children: "Parent node",
763
+ }),
764
+ TreeNodeRow({
765
+ entry: parentEntry,
766
+ showPrefix: false,
767
+ onSelect: () => options.onSelectNode(parentEntry.node.handle),
768
+ }),
769
+ ];
770
+ },
771
+ }),
772
+ ]),
773
+ ...(childEntries.length === 0
774
+ ? []
775
+ : [
776
+ createComponent(View, {
777
+ style: SECTION_STYLE,
778
+ get children() {
779
+ return [
780
+ createComponent(Text, {
781
+ style: SECTION_TITLE_STYLE,
782
+ children: `Child nodes (${String(childEntries.length)})`,
783
+ }),
784
+ ...childEntries.map((child) => TreeNodeRow({
785
+ entry: child,
786
+ showPrefix: false,
787
+ onSelect: () => options.onSelectNode(child.node.handle),
788
+ })),
789
+ ];
790
+ },
791
+ }),
792
+ ]),
793
+ ];
794
+ }
795
+ /**
796
+ * Adds a standalone, manually refreshed value-free live UI tree inspector.
797
+ * Snapshots are captured before opening or on explicit Refresh so rendering
798
+ * the inspector never feeds back into continuous tree updates.
799
+ */
800
+ export function DevelopmentTreePanel(props) {
801
+ const snapshotTree = requireTreeSnapshotProvider(props.snapshotTree);
802
+ const measureTreeNode = optionalTreeMeasureProvider(props.measureTreeNode, "DevelopmentTreePanel");
803
+ if (props.initiallyOpen !== undefined &&
804
+ typeof props.initiallyOpen !== "boolean") {
805
+ throw new TypeError("DevelopmentTreePanel initiallyOpen must be a boolean.");
806
+ }
807
+ const maxVisibleNodes = props.maxVisibleNodes ?? DEVELOPMENT_TREE_PANEL_DEFAULT_VISIBLE_NODES;
808
+ if (!Number.isSafeInteger(maxVisibleNodes) ||
809
+ maxVisibleNodes < 1 ||
810
+ maxVisibleNodes > DEVELOPMENT_TREE_PANEL_MAX_VISIBLE_NODES) {
811
+ throw new TypeError(`DevelopmentTreePanel maxVisibleNodes must be a safe integer from 1 through ${String(DEVELOPMENT_TREE_PANEL_MAX_VISIBLE_NODES)}.`);
812
+ }
813
+ const badgeBottom = props.badgeBottom ?? 68;
814
+ if (!Number.isFinite(badgeBottom) || badgeBottom < 0 || badgeBottom > 512) {
815
+ throw new TypeError("DevelopmentTreePanel badgeBottom must be a finite number from 0 through 512.");
816
+ }
817
+ const application = props.children;
818
+ const initialCapture = props.initiallyOpen === true
819
+ ? captureValidatedTreeSnapshot(snapshotTree)
820
+ : {};
821
+ const [open, setOpen] = createSignal(props.initiallyOpen === true, {
822
+ ownedWrite: true,
823
+ });
824
+ const [treeSnapshot, setTreeSnapshot] = createSignal(initialCapture.snapshot, { ownedWrite: true });
825
+ const [treeFailure, setTreeFailure] = createSignal(initialCapture.failure, { ownedWrite: true });
826
+ const [selectedHandle, setSelectedHandle] = createSignal(undefined, { ownedWrite: true });
827
+ const [search, setSearch] = createSignal("", { ownedWrite: true });
828
+ const [highlightedNode, setHighlightedNode] = createSignal(undefined, { ownedWrite: true });
829
+ const [highlightError, setHighlightError] = createSignal(undefined, { ownedWrite: true });
830
+ let retainedSearchInput;
831
+ let retainedPanel;
832
+ let highlightRequestId = 0;
833
+ let highlighting = false;
834
+ let disposed = false;
835
+ onCleanup(() => {
836
+ disposed = true;
837
+ highlighting = false;
838
+ highlightRequestId += 1;
839
+ });
840
+ const selectNode = (handle) => {
841
+ highlighting = false;
842
+ highlightRequestId += 1;
843
+ setHighlightError(undefined);
844
+ setSelectedHandle(handle);
845
+ };
846
+ const refresh = () => {
847
+ highlighting = false;
848
+ highlightRequestId += 1;
849
+ setHighlightError(undefined);
850
+ const captured = captureValidatedTreeSnapshot(snapshotTree);
851
+ setTreeSnapshot(captured.snapshot);
852
+ setTreeFailure(captured.failure);
853
+ const currentSelection = selectedHandle();
854
+ if (currentSelection !== undefined) {
855
+ const nextIndex = captured.snapshot === undefined
856
+ ? undefined
857
+ : indexTreeDebugSnapshot(captured.snapshot);
858
+ if (nextIndex === undefined ||
859
+ !nextIndex.byHandle.has(currentSelection)) {
860
+ setSelectedHandle(undefined);
861
+ }
862
+ }
863
+ };
864
+ const openPanel = () => {
865
+ setHighlightedNode(undefined);
866
+ refresh();
867
+ setOpen(true);
868
+ };
869
+ const returnToInspector = () => {
870
+ setHighlightedNode(undefined);
871
+ setHighlightError(undefined);
872
+ setOpen(true);
873
+ };
874
+ const dismissHighlight = () => {
875
+ highlighting = false;
876
+ highlightRequestId += 1;
877
+ setHighlightedNode(undefined);
878
+ };
879
+ const closePanel = () => {
880
+ highlighting = false;
881
+ highlightRequestId += 1;
882
+ setHighlightError(undefined);
883
+ retainedPanel = undefined;
884
+ retainedSearchInput = undefined;
885
+ setOpen(false);
886
+ };
887
+ const highlightNode = (entry, target) => {
888
+ if (measureTreeNode === undefined || highlighting)
889
+ return;
890
+ highlighting = true;
891
+ const requestId = ++highlightRequestId;
892
+ setHighlightError(undefined);
893
+ void resolveTreeHighlightBounds(measureTreeNode, target.node.handle).then((bounds) => {
894
+ if (disposed || requestId !== highlightRequestId)
895
+ return;
896
+ highlighting = false;
897
+ if (bounds === undefined) {
898
+ setHighlightError(`Node #${String(target.node.handle)} is no longer mounted or measurable. Refresh the UI tree.`);
899
+ return;
900
+ }
901
+ setHighlightedNode(Object.freeze({
902
+ selectedHandle: entry.node.handle,
903
+ measuredHandle: target.node.handle,
904
+ summary: entry.summary,
905
+ measuredSummary: target.summary,
906
+ bounds,
907
+ }));
908
+ retainedPanel = undefined;
909
+ retainedSearchInput = undefined;
910
+ setOpen(false);
911
+ });
912
+ };
913
+ const applicationContainer = createComponent(View, {
914
+ style: SHELL_STYLE,
915
+ get accessibilityElementsHidden() {
916
+ return open();
917
+ },
918
+ get importantForAccessibility() {
919
+ return open() ? "no-hide-descendants" : "auto";
920
+ },
921
+ get pointerEvents() {
922
+ return open() ? "none" : "auto";
923
+ },
924
+ children: application,
925
+ });
926
+ const searchInput = () => {
927
+ retainedSearchInput ??= createComponent(TextInput, {
928
+ accessibilityLabel: "Filter UI tree nodes",
929
+ autoCapitalize: "none",
930
+ autoCorrect: false,
931
+ maxLength: DEVELOPMENT_TREE_PANEL_MAX_SEARCH_LENGTH,
932
+ placeholder: "Filter by component, #handle, role, prop, event, or causal name",
933
+ placeholderTextColor: "#6f9d94",
934
+ style: SEARCH_STYLE,
935
+ get value() {
936
+ return search();
937
+ },
938
+ onChangeText(value) {
939
+ setSearch(value.slice(0, DEVELOPMENT_TREE_PANEL_MAX_SEARCH_LENGTH));
940
+ },
941
+ });
942
+ return retainedSearchInput;
943
+ };
944
+ const badge = createComponent(Pressable, {
945
+ accessibilityRole: "button",
946
+ accessibilityLabel: "Open UI tree inspector",
947
+ onPress: openPanel,
948
+ style: { ...BADGE_BASE_STYLE, bottom: badgeBottom },
949
+ testID: "solid-native-development-tree-badge",
950
+ children: createComponent(Text, {
951
+ style: BADGE_TEXT_STYLE,
952
+ children: "UI Tree",
953
+ }),
954
+ });
955
+ const panel = () => {
956
+ retainedPanel ??= createComponent(View, {
957
+ accessibilityViewIsModal: true,
958
+ importantForAccessibility: "yes",
959
+ style: PANEL_STYLE,
960
+ testID: "solid-native-development-tree-panel",
961
+ get children() {
962
+ const snapshot = treeSnapshot();
963
+ const failure = treeFailure();
964
+ const index = snapshot === undefined ? undefined : indexTreeDebugSnapshot(snapshot);
965
+ const selected = selectedHandle();
966
+ const selectedEntry = selected === undefined || index === undefined
967
+ ? undefined
968
+ : index.byHandle.get(selected);
969
+ return [
970
+ createComponent(View, {
971
+ style: HEADER_STYLE,
972
+ get children() {
973
+ return [
974
+ createComponent(Text, {
975
+ accessibilityRole: "header",
976
+ style: TITLE_STYLE,
977
+ children: "UI tree",
978
+ }),
979
+ createComponent(View, {
980
+ style: HEADER_ACTIONS_STYLE,
981
+ get children() {
982
+ return [
983
+ ...(selectedEntry === undefined
984
+ ? []
985
+ : [
986
+ createComponent(Pressable, {
987
+ accessibilityRole: "button",
988
+ accessibilityLabel: "Back to UI tree",
989
+ onPress: () => selectNode(undefined),
990
+ style: BUTTON_STYLE,
991
+ children: createComponent(Text, {
992
+ style: BUTTON_TEXT_STYLE,
993
+ children: "Back",
994
+ }),
995
+ }),
996
+ ]),
997
+ createComponent(Pressable, {
998
+ accessibilityRole: "button",
999
+ accessibilityLabel: "Refresh UI tree",
1000
+ onPress: refresh,
1001
+ style: BUTTON_STYLE,
1002
+ children: createComponent(Text, {
1003
+ style: BUTTON_TEXT_STYLE,
1004
+ children: "Refresh",
1005
+ }),
1006
+ }),
1007
+ createComponent(Pressable, {
1008
+ accessibilityRole: "button",
1009
+ accessibilityLabel: "Close UI tree inspector",
1010
+ onPress: closePanel,
1011
+ style: BUTTON_STYLE,
1012
+ children: createComponent(Text, {
1013
+ style: BUTTON_TEXT_STYLE,
1014
+ children: "Close",
1015
+ }),
1016
+ }),
1017
+ ];
1018
+ },
1019
+ }),
1020
+ ];
1021
+ },
1022
+ }),
1023
+ createComponent(Text, {
1024
+ style: SUMMARY_STYLE,
1025
+ children: snapshot === undefined
1026
+ ? "Manual value-free UI tree snapshots prevent self-observation."
1027
+ : treeSummaryText(snapshot),
1028
+ }),
1029
+ searchInput(),
1030
+ createComponent(ScrollView, {
1031
+ style: SHELL_STYLE,
1032
+ contentContainerStyle: LIST_STYLE,
1033
+ get children() {
1034
+ if (selectedEntry !== undefined && index !== undefined) {
1035
+ return treeNodeDetailContent({
1036
+ index,
1037
+ entry: selectedEntry,
1038
+ highlightError: highlightError(),
1039
+ onHighlightNode: measureTreeNode === undefined ? undefined : highlightNode,
1040
+ onSelectNode: (handle) => selectNode(handle),
1041
+ });
1042
+ }
1043
+ return treeListContent({
1044
+ index,
1045
+ failure,
1046
+ search: search(),
1047
+ maxVisibleNodes,
1048
+ onSelectNode: (handle) => selectNode(handle),
1049
+ });
1050
+ },
1051
+ }),
1052
+ ];
1053
+ },
1054
+ });
1055
+ return retainedPanel;
1056
+ };
1057
+ const highlightSlot = createComponent(View, {
1058
+ collapsable: false,
1059
+ style: OVERLAY_SLOT_STYLE,
1060
+ get accessibilityElementsHidden() {
1061
+ return open() || highlightedNode() === undefined;
1062
+ },
1063
+ get importantForAccessibility() {
1064
+ return !open() && highlightedNode() !== undefined
1065
+ ? "auto"
1066
+ : "no-hide-descendants";
1067
+ },
1068
+ get pointerEvents() {
1069
+ return !open() && highlightedNode() !== undefined ? "box-none" : "none";
1070
+ },
1071
+ get children() {
1072
+ const activeHighlight = open() ? undefined : highlightedNode();
1073
+ return activeHighlight === undefined
1074
+ ? undefined
1075
+ : TreeHighlightOverlay({
1076
+ highlight: activeHighlight,
1077
+ onReturnToInspector: returnToInspector,
1078
+ onDismiss: dismissHighlight,
1079
+ });
1080
+ },
1081
+ });
1082
+ const badgeSlot = createComponent(View, {
1083
+ style: OVERLAY_SLOT_STYLE,
1084
+ get accessibilityElementsHidden() {
1085
+ return open() || highlightedNode() !== undefined;
1086
+ },
1087
+ get importantForAccessibility() {
1088
+ return open() || highlightedNode() !== undefined
1089
+ ? "no-hide-descendants"
1090
+ : "auto";
1091
+ },
1092
+ get pointerEvents() {
1093
+ return open() || highlightedNode() !== undefined ? "none" : "box-none";
1094
+ },
1095
+ children: badge,
1096
+ });
1097
+ const panelSlot = createComponent(View, {
1098
+ style: OVERLAY_SLOT_STYLE,
1099
+ get accessibilityElementsHidden() {
1100
+ return !open();
1101
+ },
1102
+ get importantForAccessibility() {
1103
+ return open() ? "auto" : "no-hide-descendants";
1104
+ },
1105
+ get pointerEvents() {
1106
+ return open() ? "box-none" : "none";
1107
+ },
1108
+ get children() {
1109
+ return open() ? panel() : undefined;
1110
+ },
1111
+ });
1112
+ return createComponent(View, {
1113
+ style: SHELL_STYLE,
1114
+ children: [applicationContainer, badgeSlot, highlightSlot, panelSlot],
1115
+ });
1116
+ }
1117
+ //# sourceMappingURL=tree-solid.js.map