@solidnative-dev/cli 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 +841 -2
- package/dist/android-apk-signing.d.ts +36 -0
- package/dist/android-apk-signing.d.ts.map +1 -0
- package/dist/android-apk-signing.js +292 -0
- package/dist/android-apk-signing.js.map +1 -0
- package/dist/android-bundle-signing.d.ts +34 -0
- package/dist/android-bundle-signing.d.ts.map +1 -0
- package/dist/android-bundle-signing.js +167 -0
- package/dist/android-bundle-signing.js.map +1 -0
- package/dist/android-causal-debug.d.ts +38 -0
- package/dist/android-causal-debug.d.ts.map +1 -0
- package/dist/android-causal-debug.js +239 -0
- package/dist/android-causal-debug.js.map +1 -0
- package/dist/android-device-proof.d.ts +58 -0
- package/dist/android-device-proof.d.ts.map +1 -0
- package/dist/android-device-proof.js +554 -0
- package/dist/android-device-proof.js.map +1 -0
- package/dist/android-logs.d.ts +50 -0
- package/dist/android-logs.d.ts.map +1 -0
- package/dist/android-logs.js +253 -0
- package/dist/android-logs.js.map +1 -0
- package/dist/android-release-signing.d.ts +12 -0
- package/dist/android-release-signing.d.ts.map +1 -0
- package/dist/android-release-signing.js +165 -0
- package/dist/android-release-signing.js.map +1 -0
- package/dist/android-run-lease.d.ts +15 -0
- package/dist/android-run-lease.d.ts.map +1 -0
- package/dist/android-run-lease.js +333 -0
- package/dist/android-run-lease.js.map +1 -0
- package/dist/android-run-preflight.d.ts +45 -0
- package/dist/android-run-preflight.d.ts.map +1 -0
- package/dist/android-run-preflight.js +183 -0
- package/dist/android-run-preflight.js.map +1 -0
- package/dist/android-signing-shared.d.ts +38 -0
- package/dist/android-signing-shared.d.ts.map +1 -0
- package/dist/android-signing-shared.js +210 -0
- package/dist/android-signing-shared.js.map +1 -0
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +4530 -0
- package/dist/bin.js.map +1 -0
- package/dist/bundle-artifacts.d.ts +48 -0
- package/dist/bundle-artifacts.d.ts.map +1 -0
- package/dist/bundle-artifacts.js +427 -0
- package/dist/bundle-artifacts.js.map +1 -0
- package/dist/causal-debug-compare.d.ts +81 -0
- package/dist/causal-debug-compare.d.ts.map +1 -0
- package/dist/causal-debug-compare.js +238 -0
- package/dist/causal-debug-compare.js.map +1 -0
- package/dist/causal-debug-report.d.ts +33 -0
- package/dist/causal-debug-report.d.ts.map +1 -0
- package/dist/causal-debug-report.js +979 -0
- package/dist/causal-debug-report.js.map +1 -0
- package/dist/causal-debug-watch.d.ts +33 -0
- package/dist/causal-debug-watch.d.ts.map +1 -0
- package/dist/causal-debug-watch.js +92 -0
- package/dist/causal-debug-watch.js.map +1 -0
- package/dist/causal-debug.d.ts +131 -0
- package/dist/causal-debug.d.ts.map +1 -0
- package/dist/causal-debug.js +503 -0
- package/dist/causal-debug.js.map +1 -0
- package/dist/compatibility-catalog.d.ts +88 -0
- package/dist/compatibility-catalog.d.ts.map +1 -0
- package/dist/compatibility-catalog.js +344 -0
- package/dist/compatibility-catalog.js.map +1 -0
- package/dist/deep-link.d.ts +90 -0
- package/dist/deep-link.d.ts.map +1 -0
- package/dist/deep-link.js +346 -0
- package/dist/deep-link.js.map +1 -0
- package/dist/device-proof-signatures.d.ts +307 -0
- package/dist/device-proof-signatures.d.ts.map +1 -0
- package/dist/device-proof-signatures.js +1024 -0
- package/dist/device-proof-signatures.js.map +1 -0
- package/dist/fingerprint.d.ts +35 -0
- package/dist/fingerprint.d.ts.map +1 -0
- package/dist/fingerprint.js +454 -0
- package/dist/fingerprint.js.map +1 -0
- package/dist/index.d.ts +388 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2996 -0
- package/dist/index.js.map +1 -0
- package/dist/ios-causal-debug.d.ts +39 -0
- package/dist/ios-causal-debug.d.ts.map +1 -0
- package/dist/ios-causal-debug.js +318 -0
- package/dist/ios-causal-debug.js.map +1 -0
- package/dist/ios-logs.d.ts +58 -0
- package/dist/ios-logs.d.ts.map +1 -0
- package/dist/ios-logs.js +269 -0
- package/dist/ios-logs.js.map +1 -0
- package/dist/ios-process.d.ts +69 -0
- package/dist/ios-process.d.ts.map +1 -0
- package/dist/ios-process.js +389 -0
- package/dist/ios-process.js.map +1 -0
- package/dist/ios-run-preflight.d.ts +35 -0
- package/dist/ios-run-preflight.d.ts.map +1 -0
- package/dist/ios-run-preflight.js +172 -0
- package/dist/ios-run-preflight.js.map +1 -0
- package/dist/live-causal-debug-report.d.ts +49 -0
- package/dist/live-causal-debug-report.d.ts.map +1 -0
- package/dist/live-causal-debug-report.js +123 -0
- package/dist/live-causal-debug-report.js.map +1 -0
- package/dist/local-symbolication.d.ts +35 -0
- package/dist/local-symbolication.d.ts.map +1 -0
- package/dist/local-symbolication.js +89 -0
- package/dist/local-symbolication.js.map +1 -0
- package/dist/native-archive.d.ts +15 -0
- package/dist/native-archive.d.ts.map +1 -0
- package/dist/native-archive.js +441 -0
- package/dist/native-archive.js.map +1 -0
- package/dist/native-test.d.ts +43 -0
- package/dist/native-test.d.ts.map +1 -0
- package/dist/native-test.js +209 -0
- package/dist/native-test.js.map +1 -0
- package/dist/package-add.d.ts +56 -0
- package/dist/package-add.d.ts.map +1 -0
- package/dist/package-add.js +764 -0
- package/dist/package-add.js.map +1 -0
- package/dist/react-native-upgrade.d.ts +96 -0
- package/dist/react-native-upgrade.d.ts.map +1 -0
- package/dist/react-native-upgrade.js +882 -0
- package/dist/react-native-upgrade.js.map +1 -0
- package/dist/release-device-correlation.d.ts +40 -0
- package/dist/release-device-correlation.d.ts.map +1 -0
- package/dist/release-device-correlation.js +113 -0
- package/dist/release-device-correlation.js.map +1 -0
- package/dist/release-signatures.d.ts +168 -0
- package/dist/release-signatures.d.ts.map +1 -0
- package/dist/release-signatures.js +677 -0
- package/dist/release-signatures.js.map +1 -0
- package/dist/release.d.ts +88 -0
- package/dist/release.d.ts.map +1 -0
- package/dist/release.js +771 -0
- package/dist/release.js.map +1 -0
- package/dist/signature-utilities.d.ts +16 -0
- package/dist/signature-utilities.d.ts.map +1 -0
- package/dist/signature-utilities.js +114 -0
- package/dist/signature-utilities.js.map +1 -0
- package/dist/solid-diagnostics-correlation.d.ts +11 -0
- package/dist/solid-diagnostics-correlation.d.ts.map +1 -0
- package/dist/solid-diagnostics-correlation.js +78 -0
- package/dist/solid-diagnostics-correlation.js.map +1 -0
- package/dist/solid-diagnostics-debug.d.ts +15 -0
- package/dist/solid-diagnostics-debug.d.ts.map +1 -0
- package/dist/solid-diagnostics-debug.js +93 -0
- package/dist/solid-diagnostics-debug.js.map +1 -0
- package/dist/solid-diagnostics-inspection.d.ts +41 -0
- package/dist/solid-diagnostics-inspection.d.ts.map +1 -0
- package/dist/solid-diagnostics-inspection.js +196 -0
- package/dist/solid-diagnostics-inspection.js.map +1 -0
- package/dist/source-map.d.ts +36 -0
- package/dist/source-map.d.ts.map +1 -0
- package/dist/source-map.js +488 -0
- package/dist/source-map.js.map +1 -0
- package/dist/stack-symbolication.d.ts +56 -0
- package/dist/stack-symbolication.d.ts.map +1 -0
- package/dist/stack-symbolication.js +310 -0
- package/dist/stack-symbolication.js.map +1 -0
- package/dist/symbolication.d.ts +27 -0
- package/dist/symbolication.d.ts.map +1 -0
- package/dist/symbolication.js +75 -0
- package/dist/symbolication.js.map +1 -0
- package/dist/tree-debug.d.ts +53 -0
- package/dist/tree-debug.d.ts.map +1 -0
- package/dist/tree-debug.js +283 -0
- package/dist/tree-debug.js.map +1 -0
- package/dist/versions.d.ts +13 -0
- package/dist/versions.d.ts.map +1 -0
- package/dist/versions.js +14 -0
- package/dist/versions.js.map +1 -0
- package/package.json +46 -3
- package/templates/react-native-0.88/README.md +328 -0
- package/templates/react-native-0.88/android/CMakeLists.txt +27 -0
- package/templates/react-native-0.88/android/MainActivity.kt +123 -0
- package/templates/react-native-0.88/android/MainApplication.kt +43 -0
- package/templates/react-native-0.88/android/OnLoad.cpp +60 -0
- package/templates/react-native-0.88/index.js +1 -0
- package/templates/react-native-0.88/ios/AppDelegate.swift +190 -0
- package/templates/react-native-0.88/metro.config.js +16 -0
- package/templates/react-native-0.88/specs/NativeSolidNativeDebug.ts +16 -0
- package/templates/react-native-0.88/specs/NativeSolidNativePlatformAndroid.ts +14 -0
- package/templates/react-native-0.88/src/App.tsx +161 -0
- package/templates/react-native-0.88/src/main.tsx +88 -0
- package/templates/react-native-0.88/test/App.test.tsx +152 -0
|
@@ -0,0 +1,979 @@
|
|
|
1
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
2
|
+
import { link, mkdir, rm, writeFile } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { correlateNativeSolidDiagnostics, parseCausalDebugSnapshot, parseTreeDebugSnapshot, } from "@solidnative-dev/observability";
|
|
5
|
+
import { inspectNativeCausalDebugSnapshot, NATIVE_CAUSAL_TRACE_MAX_FLOW_COUNT, readNativeCausalDebugSnapshotFile, readNativeCausalDebugSnapshotStream, } from "./causal-debug.js";
|
|
6
|
+
import { readNativeSolidDiagnosticsDebugFile } from "./solid-diagnostics-correlation.js";
|
|
7
|
+
import { readNativeTreeDebugSnapshotFile } from "./tree-debug.js";
|
|
8
|
+
export const NATIVE_CAUSAL_DEBUG_MAX_REPORT_BYTES = 33_554_432;
|
|
9
|
+
const REPORT_STYLE = `
|
|
10
|
+
:root {
|
|
11
|
+
color-scheme: dark;
|
|
12
|
+
font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
13
|
+
background: #07110f;
|
|
14
|
+
color: #e7f4ef;
|
|
15
|
+
--panel: #0d1b18;
|
|
16
|
+
--panel-strong: #11241f;
|
|
17
|
+
--line: #24423a;
|
|
18
|
+
--muted: #92aaa2;
|
|
19
|
+
--accent: #58e6b0;
|
|
20
|
+
--accent-strong: #8af5ce;
|
|
21
|
+
--error: #ff6b7d;
|
|
22
|
+
--cancelled: #f7bf64;
|
|
23
|
+
--active: #76a9ff;
|
|
24
|
+
}
|
|
25
|
+
* { box-sizing: border-box; }
|
|
26
|
+
body { margin: 0; min-width: 320px; background: radial-gradient(circle at 15% -20%, #153b31 0, #07110f 38rem); }
|
|
27
|
+
button, input, select { font: inherit; }
|
|
28
|
+
header { padding: 2.4rem clamp(1rem, 4vw, 4rem) 1.25rem; border-bottom: 1px solid var(--line); }
|
|
29
|
+
.eyebrow { margin: 0 0 .5rem; color: var(--accent); font-size: .75rem; font-weight: 750; letter-spacing: .14em; text-transform: uppercase; }
|
|
30
|
+
h1 { margin: 0; font-size: clamp(1.9rem, 5vw, 3.4rem); letter-spacing: -.045em; }
|
|
31
|
+
.subtitle { max-width: 56rem; margin: .8rem 0 0; color: var(--muted); line-height: 1.55; }
|
|
32
|
+
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: .75rem; padding: 1rem clamp(1rem, 4vw, 4rem); margin: 0; }
|
|
33
|
+
.summary div { padding: .85rem 1rem; border: 1px solid var(--line); border-radius: .75rem; background: color-mix(in srgb, var(--panel) 90%, transparent); }
|
|
34
|
+
.summary dt { color: var(--muted); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; }
|
|
35
|
+
.summary dd { margin: .35rem 0 0; font-size: 1.18rem; font-variant-numeric: tabular-nums; }
|
|
36
|
+
.diagnostics-panel { margin: 0 clamp(1rem, 4vw, 4rem) 1rem; padding: 1rem; border: 1px solid var(--line); border-radius: .85rem; background: var(--panel); }
|
|
37
|
+
.diagnostics-panel h2 { margin: 0; font-size: 1rem; }
|
|
38
|
+
.diagnostics-copy { margin: .45rem 0 .85rem; color: var(--muted); font-size: .82rem; line-height: 1.45; }
|
|
39
|
+
.diagnostics-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: .65rem; }
|
|
40
|
+
.diagnostics-output { min-width: 0; padding: .75rem; border: 1px solid var(--line); border-radius: .65rem; background: var(--panel-strong); }
|
|
41
|
+
.diagnostics-output h3 { margin: 0 0 .4rem; color: var(--accent-strong); font-size: .86rem; overflow-wrap: anywhere; }
|
|
42
|
+
.diagnostics-output p { margin: .3rem 0; color: var(--muted); font-size: .76rem; line-height: 1.4; }
|
|
43
|
+
.diagnostics-frames { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .55rem; }
|
|
44
|
+
.tree-panel { margin: 0 clamp(1rem, 4vw, 4rem) 1rem; padding: 1rem; border: 1px solid var(--line); border-radius: .85rem; background: var(--panel); }
|
|
45
|
+
.tree-header { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; margin-bottom: .65rem; }
|
|
46
|
+
.tree-header h2 { margin: 0; font-size: 1rem; }
|
|
47
|
+
.tree-toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
|
|
48
|
+
.tree-toolbar input { min-height: 2.2rem; width: min(20rem, 68vw); color: inherit; background: var(--panel-strong); border: 1px solid var(--line); border-radius: .5rem; padding: .35rem .65rem; font-size: .82rem; }
|
|
49
|
+
.tree-count { color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; }
|
|
50
|
+
.tree-list { list-style: none; margin: 0; padding: 0; max-height: 18rem; overflow: auto; border: 1px solid color-mix(in srgb, var(--line) 70%, transparent); border-radius: .6rem; background: #07110f; }
|
|
51
|
+
.tree-row { border-bottom: 1px solid color-mix(in srgb, var(--line) 35%, transparent); }
|
|
52
|
+
.tree-row:last-child { border-bottom: 0; }
|
|
53
|
+
.tree-node-button { width: 100%; border: 0; color: inherit; background: transparent; display: flex; gap: .45rem; align-items: baseline; text-align: left; padding: .42rem .75rem; cursor: pointer; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: .77rem; }
|
|
54
|
+
.tree-node-button:hover, .tree-node-button:focus-visible { background: var(--panel-strong); outline: none; }
|
|
55
|
+
.tree-node-button[aria-pressed="true"] { background: #18382f; box-shadow: inset .22rem 0 var(--accent); }
|
|
56
|
+
.tree-prefix { color: var(--line); white-space: pre; flex: none; }
|
|
57
|
+
.tree-label { color: var(--accent-strong); font-weight: 650; flex: none; }
|
|
58
|
+
.tree-meta { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
59
|
+
.tree-omitted { padding: .35rem .75rem; color: var(--cancelled); font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: .75rem; }
|
|
60
|
+
.controls { display: flex; flex-wrap: wrap; gap: .75rem; align-items: end; padding: 0 clamp(1rem, 4vw, 4rem) 1rem; }
|
|
61
|
+
.controls label { display: grid; gap: .35rem; color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .08em; }
|
|
62
|
+
.controls input, .controls select { min-height: 2.6rem; color: inherit; background: var(--panel); border: 1px solid var(--line); border-radius: .55rem; padding: .55rem .7rem; text-transform: none; letter-spacing: normal; }
|
|
63
|
+
.controls input { width: min(28rem, 72vw); }
|
|
64
|
+
.visible-count { color: var(--muted); font-size: .85rem; padding-bottom: .65rem; }
|
|
65
|
+
main { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(18rem, .85fr); gap: 1rem; padding: 0 clamp(1rem, 4vw, 4rem) 3rem; align-items: start; }
|
|
66
|
+
.panel { min-width: 0; border: 1px solid var(--line); border-radius: .85rem; background: var(--panel); overflow: hidden; }
|
|
67
|
+
.panel-heading { padding: .8rem 1rem; border-bottom: 1px solid var(--line); color: var(--muted); font-size: .78rem; letter-spacing: .09em; text-transform: uppercase; }
|
|
68
|
+
#operations, #groups { list-style: none; margin: 0; padding: 0; max-height: calc(100vh - 20rem); overflow: auto; }
|
|
69
|
+
[hidden] { display: none !important; }
|
|
70
|
+
.operation-row { border-bottom: 1px solid color-mix(in srgb, var(--line) 65%, transparent); }
|
|
71
|
+
.operation-row:last-child { border-bottom: 0; }
|
|
72
|
+
.operation-row[hidden] { display: none; }
|
|
73
|
+
.operation-button { width: 100%; border: 0; color: inherit; background: transparent; display: grid; grid-template-columns: minmax(9rem, 1.1fr) minmax(9rem, 1.4fr) auto; gap: .8rem; align-items: center; text-align: left; padding: .72rem 1rem; cursor: pointer; }
|
|
74
|
+
.operation-button:hover, .operation-button:focus-visible { background: var(--panel-strong); outline: none; }
|
|
75
|
+
.operation-button[aria-pressed="true"] { background: #18382f; box-shadow: inset .22rem 0 var(--accent); }
|
|
76
|
+
.operation-name { min-width: 0; }
|
|
77
|
+
.operation-name strong, .operation-name code { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
78
|
+
.operation-name strong { font-size: .86rem; }
|
|
79
|
+
.operation-name code { margin-top: .25rem; color: var(--muted); font-size: .71rem; }
|
|
80
|
+
.timeline { width: 100%; height: 1.15rem; overflow: visible; }
|
|
81
|
+
.timeline-track { fill: #193029; }
|
|
82
|
+
.timeline-bar { fill: var(--accent); }
|
|
83
|
+
.timeline-bar.event { fill: #55d6e8; }
|
|
84
|
+
.timeline-bar.computation { fill: #a888ff; }
|
|
85
|
+
.timeline-bar.commit { fill: #58e6b0; }
|
|
86
|
+
.timeline-bar.mount { fill: #e8cf62; }
|
|
87
|
+
.timeline-bar.frame { fill: #ff9e64; }
|
|
88
|
+
.timeline-bar.owner { fill: #e782ff; }
|
|
89
|
+
.timeline-bar.task { fill: #78a8ff; }
|
|
90
|
+
.timeline-bar.command, .timeline-bar.measure { fill: #ff79a7; }
|
|
91
|
+
.status { border: 1px solid var(--line); border-radius: 999px; padding: .25rem .45rem; color: var(--muted); font-size: .68rem; text-transform: uppercase; }
|
|
92
|
+
.status.error { color: var(--error); border-color: color-mix(in srgb, var(--error) 55%, var(--line)); }
|
|
93
|
+
.status.cancelled { color: var(--cancelled); }
|
|
94
|
+
.status.active { color: var(--active); }
|
|
95
|
+
#detail { position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow: auto; padding: 1rem; }
|
|
96
|
+
#detail h2 { margin: 0; font-size: 1.12rem; }
|
|
97
|
+
#detail > code { display: block; margin: .4rem 0 1rem; color: var(--muted); overflow-wrap: anywhere; }
|
|
98
|
+
.detail-grid { display: grid; grid-template-columns: auto 1fr; gap: .45rem .8rem; margin: 0 0 1rem; font-size: .83rem; }
|
|
99
|
+
.detail-grid dt { color: var(--muted); }
|
|
100
|
+
.detail-grid dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
|
|
101
|
+
.link-section { margin-top: 1rem; }
|
|
102
|
+
.link-section h3 { margin: 0 0 .5rem; color: var(--muted); font-size: .74rem; letter-spacing: .08em; text-transform: uppercase; }
|
|
103
|
+
.link-list { display: flex; flex-wrap: wrap; gap: .4rem; }
|
|
104
|
+
.causal-link { max-width: 100%; border: 1px solid var(--line); border-radius: .45rem; color: var(--accent-strong); background: var(--panel-strong); padding: .35rem .5rem; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
105
|
+
.causal-link:hover, .causal-link:focus-visible { border-color: var(--accent); outline: none; }
|
|
106
|
+
.empty { color: var(--muted); font-size: .82rem; }
|
|
107
|
+
.warning { color: var(--cancelled); border-left: .2rem solid var(--cancelled); padding-left: .65rem; font-size: .82rem; line-height: 1.45; }
|
|
108
|
+
pre { white-space: pre-wrap; overflow-wrap: anywhere; padding: .7rem; border-radius: .55rem; background: #07110f; color: #cde1d9; font-size: .72rem; }
|
|
109
|
+
footer { padding: 0 clamp(1rem, 4vw, 4rem) 2rem; color: var(--muted); font-size: .78rem; }
|
|
110
|
+
@media (max-width: 820px) {
|
|
111
|
+
main { grid-template-columns: 1fr; }
|
|
112
|
+
#detail { position: static; max-height: none; }
|
|
113
|
+
#operations, #groups { max-height: 55vh; }
|
|
114
|
+
.operation-button { grid-template-columns: minmax(7rem, 1fr) minmax(7rem, 1fr) auto; }
|
|
115
|
+
}
|
|
116
|
+
`;
|
|
117
|
+
const REPORT_SCRIPT = `
|
|
118
|
+
(function () {
|
|
119
|
+
"use strict";
|
|
120
|
+
var encoded = document.getElementById("report-data").textContent.trim();
|
|
121
|
+
var binary = atob(encoded);
|
|
122
|
+
var bytes = new Uint8Array(binary.length);
|
|
123
|
+
for (var index = 0; index < binary.length; index += 1) bytes[index] = binary.charCodeAt(index);
|
|
124
|
+
var report = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes));
|
|
125
|
+
var byId = new Map(report.operations.map(function (operation) { return [operation.operationId, operation]; }));
|
|
126
|
+
var groupById = new Map(report.groups.map(function (group) { return [group.groupId, group]; }));
|
|
127
|
+
var effects = new Map();
|
|
128
|
+
report.operations.forEach(function (operation) {
|
|
129
|
+
operation.causes.forEach(function (causeId) {
|
|
130
|
+
if (!byId.has(causeId)) return;
|
|
131
|
+
var values = effects.get(causeId) || [];
|
|
132
|
+
values.push(operation.operationId);
|
|
133
|
+
effects.set(causeId, values);
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
function element(name, className, text) {
|
|
138
|
+
var value = document.createElement(name);
|
|
139
|
+
if (className) value.className = className;
|
|
140
|
+
if (text !== undefined) value.textContent = String(text);
|
|
141
|
+
return value;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function metric(term, value) {
|
|
145
|
+
var wrapper = element("div");
|
|
146
|
+
wrapper.append(element("dt", "", term), element("dd", "", value));
|
|
147
|
+
document.getElementById("summary").append(wrapper);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function capturedAt(value) {
|
|
151
|
+
var date = new Date(value);
|
|
152
|
+
return Number.isNaN(date.getTime()) ? String(value) : date.toISOString();
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
metric("Captured", capturedAt(report.capturedAt));
|
|
156
|
+
metric("Groups", report.groupCount);
|
|
157
|
+
metric("Operations", report.operationCount);
|
|
158
|
+
metric("Active", report.activeOperationCount);
|
|
159
|
+
metric("Errors", report.statusCounts.error);
|
|
160
|
+
metric("Evicted", report.evictedOperationCount);
|
|
161
|
+
metric("Discarded", report.discardedRecordCount);
|
|
162
|
+
if (report.diagnosticsCorrelation) {
|
|
163
|
+
var correlation = report.diagnosticsCorrelation;
|
|
164
|
+
metric("Solid reruns", correlation.rerunCount);
|
|
165
|
+
metric("Native frame chains", correlation.outputs.reduce(function (total, output) { return total + output.completeNativeFrameChainCount; }, 0));
|
|
166
|
+
var diagnosticsPanel = document.getElementById("diagnostics-correlation");
|
|
167
|
+
diagnosticsPanel.hidden = false;
|
|
168
|
+
diagnosticsPanel.append(
|
|
169
|
+
element("h2", "", "Solid → native correlation"),
|
|
170
|
+
element("p", "diagnostics-copy", "Static computation names are matched inside the bounded diagnostics window, then followed through retained commit, mount, and frame edges. Exact per-rerun join: no.")
|
|
171
|
+
);
|
|
172
|
+
var diagnosticsList = element("div", "diagnostics-list");
|
|
173
|
+
correlation.outputs.forEach(function (output) {
|
|
174
|
+
var card = element("article", "diagnostics-output");
|
|
175
|
+
card.append(
|
|
176
|
+
element("h3", "", output.name),
|
|
177
|
+
element("p", "", output.rerunCount + " Solid reruns · " + output.nativeComputationOperationIds.length + " native computations · " + output.completeNativeFrameChainCount + " complete frame chains"),
|
|
178
|
+
element("p", "", output.causeNames.length === 0 ? "No retained named causes" : "Named causes: " + output.causeNames.join(", "))
|
|
179
|
+
);
|
|
180
|
+
var frameLinks = element("div", "diagnostics-frames");
|
|
181
|
+
output.nativeFrameOperationIds.filter(function (id) { return byId.has(id); }).forEach(function (id) {
|
|
182
|
+
var button = element("button", "causal-link", id);
|
|
183
|
+
button.type = "button";
|
|
184
|
+
button.addEventListener("click", function () { select(id, true); });
|
|
185
|
+
frameLinks.append(button);
|
|
186
|
+
});
|
|
187
|
+
if (frameLinks.childElementCount > 0) card.append(frameLinks);
|
|
188
|
+
diagnosticsList.append(card);
|
|
189
|
+
});
|
|
190
|
+
diagnosticsPanel.append(diagnosticsList);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
var treeNodeByHandle = new Map();
|
|
194
|
+
var treeRows = new Map();
|
|
195
|
+
var treeNodesByOwner = new Map();
|
|
196
|
+
var treeNodesByComputation = new Map();
|
|
197
|
+
var operationsByNodeHandle = new Map();
|
|
198
|
+
function addIndexEntry(map, key, value) {
|
|
199
|
+
var list = map.get(key) || [];
|
|
200
|
+
if (list.indexOf(value) === -1) list.push(value);
|
|
201
|
+
map.set(key, list);
|
|
202
|
+
}
|
|
203
|
+
function formatTreeNodeSummary(node) {
|
|
204
|
+
if (node.kind === "text") {
|
|
205
|
+
return "#text #" + node.handle + " (" + node.textLength + (node.textLength === 1 ? " char)" : " chars)");
|
|
206
|
+
}
|
|
207
|
+
return node.component + " #" + node.handle;
|
|
208
|
+
}
|
|
209
|
+
function formatTreeNodeMeta(node) {
|
|
210
|
+
var parts = [];
|
|
211
|
+
if (node.kind === "element") {
|
|
212
|
+
if (node.role) parts.push("role=" + node.role);
|
|
213
|
+
if (node.eventNames.length > 0) parts.push("events=" + node.eventNames.join(","));
|
|
214
|
+
if (node.propNames.length > 0) parts.push("props=" + node.propNames.join(","));
|
|
215
|
+
}
|
|
216
|
+
if (node.causalOwner) parts.push("owner=" + node.causalOwner);
|
|
217
|
+
if (node.causalComputation) parts.push("computation=" + node.causalComputation);
|
|
218
|
+
return parts.join(" · ");
|
|
219
|
+
}
|
|
220
|
+
if (report.tree) {
|
|
221
|
+
var tree = report.tree;
|
|
222
|
+
metric("UI tree nodes", tree.truncated ? tree.nodeCount + " (truncated)" : tree.nodeCount);
|
|
223
|
+
metric("Tree sequence", tree.committedSequence);
|
|
224
|
+
var treePanel = document.getElementById("ui-tree-panel");
|
|
225
|
+
treePanel.hidden = false;
|
|
226
|
+
var treeHeader = element("div", "tree-header");
|
|
227
|
+
treeHeader.append(element("h2", "", "UI tree · surface " + tree.surfaceId + " (" + tree.platform + ")"));
|
|
228
|
+
var treeToolbar = element("div", "tree-toolbar");
|
|
229
|
+
var treeSearch = element("input");
|
|
230
|
+
treeSearch.id = "tree-search";
|
|
231
|
+
treeSearch.type = "search";
|
|
232
|
+
treeSearch.autocomplete = "off";
|
|
233
|
+
treeSearch.placeholder = "Filter component, #handle, role, event, or owner";
|
|
234
|
+
var treeCount = element("span", "tree-count", tree.nodeCount + " of " + tree.nodeCount + " nodes");
|
|
235
|
+
treeToolbar.append(treeSearch, treeCount);
|
|
236
|
+
treeHeader.append(treeToolbar);
|
|
237
|
+
treePanel.append(treeHeader);
|
|
238
|
+
treePanel.append(
|
|
239
|
+
element(
|
|
240
|
+
"p",
|
|
241
|
+
"diagnostics-copy",
|
|
242
|
+
"Value-free structural snapshot captured at " + tree.capturedAt + " (committed sequence " + tree.committedSequence + ", " + tree.elementCount + " elements, " + tree.textCount + " text, " + tree.sentinelCount + " sentinels). Select any node to jump to linked causal operations."
|
|
243
|
+
)
|
|
244
|
+
);
|
|
245
|
+
var treeList = element("ol", "tree-list");
|
|
246
|
+
var flatTreeEntries = [];
|
|
247
|
+
function visitTreeNode(node, parentHandle, prefix, connector) {
|
|
248
|
+
var entry = {
|
|
249
|
+
node: node,
|
|
250
|
+
parentHandle: parentHandle,
|
|
251
|
+
childrenHandles: node.kind === "element" ? node.children.map(function (child) { return child.handle; }) : [],
|
|
252
|
+
searchText: (formatTreeNodeSummary(node) + " " + formatTreeNodeMeta(node)).toLocaleLowerCase()
|
|
253
|
+
};
|
|
254
|
+
treeNodeByHandle.set(node.handle, entry);
|
|
255
|
+
if (node.causalOwner) addIndexEntry(treeNodesByOwner, node.causalOwner, node.handle);
|
|
256
|
+
if (node.causalComputation) addIndexEntry(treeNodesByComputation, node.causalComputation, node.handle);
|
|
257
|
+
var row = element("li", "tree-row");
|
|
258
|
+
var button = element("button", "tree-node-button");
|
|
259
|
+
button.type = "button";
|
|
260
|
+
button.dataset.nodeHandle = String(node.handle);
|
|
261
|
+
button.setAttribute("aria-pressed", "false");
|
|
262
|
+
button.append(
|
|
263
|
+
element("span", "tree-prefix", prefix + connector),
|
|
264
|
+
element("span", "tree-label", formatTreeNodeSummary(node)),
|
|
265
|
+
element("span", "tree-meta", formatTreeNodeMeta(node))
|
|
266
|
+
);
|
|
267
|
+
button.addEventListener("click", function () { selectNode(node.handle, true); });
|
|
268
|
+
row.append(button);
|
|
269
|
+
treeList.append(row);
|
|
270
|
+
treeRows.set(node.handle, { row: row, button: button });
|
|
271
|
+
flatTreeEntries.push({ entry: entry, row: row });
|
|
272
|
+
if (node.kind === "element") {
|
|
273
|
+
var childPrefix = connector === "" ? "" : prefix + (connector === "├── " ? "│ " : " ");
|
|
274
|
+
var total = node.children.length + (node.omittedChildCount ? 1 : 0);
|
|
275
|
+
node.children.forEach(function (child, idx) {
|
|
276
|
+
visitTreeNode(child, node.handle, childPrefix, idx === total - 1 ? "└── " : "├── ");
|
|
277
|
+
});
|
|
278
|
+
if (node.omittedChildCount) {
|
|
279
|
+
var omittedRow = element("li", "tree-row tree-omitted", childPrefix + "└── ... (" + node.omittedChildCount + (node.omittedChildCount === 1 ? " omitted child)" : " omitted children)"));
|
|
280
|
+
treeList.append(omittedRow);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
visitTreeNode(tree.root, undefined, "", "");
|
|
285
|
+
treePanel.append(treeList);
|
|
286
|
+
treeSearch.addEventListener("input", function () {
|
|
287
|
+
var query = treeSearch.value.trim().toLocaleLowerCase();
|
|
288
|
+
var visible = 0;
|
|
289
|
+
flatTreeEntries.forEach(function (item) {
|
|
290
|
+
var matches = query === "" || item.entry.searchText.includes(query);
|
|
291
|
+
item.row.hidden = !matches;
|
|
292
|
+
if (matches) visible += 1;
|
|
293
|
+
});
|
|
294
|
+
treeCount.textContent = visible + " of " + flatTreeEntries.length + " nodes";
|
|
295
|
+
});
|
|
296
|
+
report.operations.forEach(function (operation) {
|
|
297
|
+
if (typeof operation.targetNodeHandle === "number" && treeNodeByHandle.has(operation.targetNodeHandle)) {
|
|
298
|
+
addIndexEntry(operationsByNodeHandle, operation.targetNodeHandle, operation.operationId);
|
|
299
|
+
}
|
|
300
|
+
if (operation.treeOwnerName && treeNodesByOwner.has(operation.treeOwnerName)) {
|
|
301
|
+
treeNodesByOwner.get(operation.treeOwnerName).forEach(function (handle) {
|
|
302
|
+
addIndexEntry(operationsByNodeHandle, handle, operation.operationId);
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
if (operation.treeComputationName && treeNodesByComputation.has(operation.treeComputationName)) {
|
|
306
|
+
treeNodesByComputation.get(operation.treeComputationName).forEach(function (handle) {
|
|
307
|
+
addIndexEntry(operationsByNodeHandle, handle, operation.operationId);
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
var span = report.span === 0 ? 1 : report.span;
|
|
314
|
+
|
|
315
|
+
function timeline(offset, duration, kind, label) {
|
|
316
|
+
var svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
317
|
+
svg.setAttribute("class", "timeline");
|
|
318
|
+
svg.setAttribute("viewBox", "0 0 100 1");
|
|
319
|
+
svg.setAttribute("preserveAspectRatio", "none");
|
|
320
|
+
svg.setAttribute("aria-label", label);
|
|
321
|
+
var track = document.createElementNS("http://www.w3.org/2000/svg", "rect");
|
|
322
|
+
track.setAttribute("class", "timeline-track");
|
|
323
|
+
track.setAttribute("x", "0");
|
|
324
|
+
track.setAttribute("y", "0");
|
|
325
|
+
track.setAttribute("width", "100");
|
|
326
|
+
track.setAttribute("height", "1");
|
|
327
|
+
var bar = document.createElementNS("http://www.w3.org/2000/svg", "rect");
|
|
328
|
+
var left = Math.max(0, Math.min(99.7, offset / span * 100));
|
|
329
|
+
var width = Math.max(.3, Math.min(100 - left, duration / span * 100));
|
|
330
|
+
bar.setAttribute("class", "timeline-bar " + kind);
|
|
331
|
+
bar.setAttribute("x", String(left));
|
|
332
|
+
bar.setAttribute("y", "0");
|
|
333
|
+
bar.setAttribute("width", String(width));
|
|
334
|
+
bar.setAttribute("height", "1");
|
|
335
|
+
svg.append(track, bar);
|
|
336
|
+
return svg;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
function groupTitle(group) {
|
|
340
|
+
var names = group.operationNames.map(function (name) { return name.replace("solid-native.", ""); });
|
|
341
|
+
var omitted = Math.max(0, names.length - 4);
|
|
342
|
+
var visible = names.slice(-4).join(" → ");
|
|
343
|
+
return omitted === 0 ? visible : "+" + omitted + " earlier · " + visible;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
var groupList = document.getElementById("groups");
|
|
347
|
+
var groupRows = new Map();
|
|
348
|
+
report.groups.forEach(function (group) {
|
|
349
|
+
var row = element("li", "operation-row");
|
|
350
|
+
var button = element("button", "operation-button");
|
|
351
|
+
button.type = "button";
|
|
352
|
+
button.dataset.groupId = group.groupId;
|
|
353
|
+
button.setAttribute("aria-pressed", "false");
|
|
354
|
+
var label = element("span", "operation-name");
|
|
355
|
+
label.append(element("strong", "", groupTitle(group)), element("code", "", group.groupId));
|
|
356
|
+
button.append(
|
|
357
|
+
label,
|
|
358
|
+
timeline(group.offset, group.duration, "", "Group starts " + group.offset + " ms after origin and spans " + group.duration + " ms"),
|
|
359
|
+
element("span", "status " + group.status, group.status)
|
|
360
|
+
);
|
|
361
|
+
button.addEventListener("click", function () { selectGroup(group.groupId, true); });
|
|
362
|
+
row.append(button);
|
|
363
|
+
groupList.append(row);
|
|
364
|
+
groupRows.set(group.groupId, { row: row, button: button });
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
var list = document.getElementById("operations");
|
|
368
|
+
var rows = new Map();
|
|
369
|
+
report.operations.forEach(function (operation) {
|
|
370
|
+
var row = element("li", "operation-row");
|
|
371
|
+
var button = element("button", "operation-button");
|
|
372
|
+
button.type = "button";
|
|
373
|
+
button.dataset.operationId = operation.operationId;
|
|
374
|
+
button.setAttribute("aria-pressed", "false");
|
|
375
|
+
|
|
376
|
+
var label = element("span", "operation-name");
|
|
377
|
+
label.append(
|
|
378
|
+
element("strong", "", operation.name.replace("solid-native.", "")),
|
|
379
|
+
element("code", "", operation.operationId)
|
|
380
|
+
);
|
|
381
|
+
|
|
382
|
+
button.append(
|
|
383
|
+
label,
|
|
384
|
+
timeline(operation.offset, operation.duration, operation.name.replace("solid-native.", ""), "Starts " + operation.offset + " ms after origin and lasts " + operation.duration + " ms"),
|
|
385
|
+
element("span", "status " + operation.status, operation.status)
|
|
386
|
+
);
|
|
387
|
+
button.addEventListener("click", function () { select(operation.operationId, true); });
|
|
388
|
+
row.append(button);
|
|
389
|
+
list.append(row);
|
|
390
|
+
rows.set(operation.operationId, { row: row, button: button });
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
function closure(initial, next) {
|
|
394
|
+
var seen = new Set();
|
|
395
|
+
var queue = initial.slice();
|
|
396
|
+
while (queue.length > 0) {
|
|
397
|
+
var id = queue.shift();
|
|
398
|
+
if (seen.has(id) || !byId.has(id)) continue;
|
|
399
|
+
seen.add(id);
|
|
400
|
+
next(id).forEach(function (candidate) { if (!seen.has(candidate)) queue.push(candidate); });
|
|
401
|
+
}
|
|
402
|
+
return seen;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
function detailValue(list, term, value) {
|
|
406
|
+
list.append(element("dt", "", term), element("dd", "", value));
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
function linkSection(parent, title, ids, onSelect) {
|
|
410
|
+
var section = element("section", "link-section");
|
|
411
|
+
section.append(element("h3", "", title));
|
|
412
|
+
var links = element("div", "link-list");
|
|
413
|
+
if (ids.length === 0) links.append(element("span", "empty", "None"));
|
|
414
|
+
ids.forEach(function (id) {
|
|
415
|
+
var button = element("button", "causal-link", id);
|
|
416
|
+
button.type = "button";
|
|
417
|
+
button.addEventListener("click", function () { onSelect(id); });
|
|
418
|
+
links.append(button);
|
|
419
|
+
});
|
|
420
|
+
section.append(links);
|
|
421
|
+
parent.append(section);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
function renderDetail(operation) {
|
|
425
|
+
var detail = document.getElementById("detail");
|
|
426
|
+
detail.replaceChildren();
|
|
427
|
+
detail.append(element("h2", "", operation.name), element("code", "", operation.operationId));
|
|
428
|
+
var values = element("dl", "detail-grid");
|
|
429
|
+
var ancestors = closure(operation.causes, function (id) { return byId.get(id).causes; });
|
|
430
|
+
var descendants = closure(effects.get(operation.operationId) || [], function (id) { return effects.get(id) || []; });
|
|
431
|
+
detailValue(values, "Status", operation.status);
|
|
432
|
+
detailValue(values, "Start offset", operation.offset + " ms");
|
|
433
|
+
detailValue(values, "Duration", operation.duration + " ms");
|
|
434
|
+
detailValue(values, "Retained ancestors", ancestors.size);
|
|
435
|
+
detailValue(values, "Retained descendants", descendants.size);
|
|
436
|
+
detail.append(values);
|
|
437
|
+
linkSection(detail, "Retained group", [operation.groupId], function (id) { selectGroup(id, true); });
|
|
438
|
+
linkSection(detail, "Direct causes", operation.causes.filter(function (id) { return byId.has(id); }), function (id) { select(id, true); });
|
|
439
|
+
linkSection(detail, "Direct effects", effects.get(operation.operationId) || [], function (id) { select(id, true); });
|
|
440
|
+
if (report.tree) {
|
|
441
|
+
var linkedHandles = [];
|
|
442
|
+
if (typeof operation.targetNodeHandle === "number" && treeNodeByHandle.has(operation.targetNodeHandle)) {
|
|
443
|
+
linkedHandles.push(operation.targetNodeHandle);
|
|
444
|
+
}
|
|
445
|
+
if (operation.treeOwnerName && treeNodesByOwner.has(operation.treeOwnerName)) {
|
|
446
|
+
treeNodesByOwner.get(operation.treeOwnerName).forEach(function (handle) {
|
|
447
|
+
if (linkedHandles.indexOf(handle) === -1) linkedHandles.push(handle);
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
if (operation.treeComputationName && treeNodesByComputation.has(operation.treeComputationName)) {
|
|
451
|
+
treeNodesByComputation.get(operation.treeComputationName).forEach(function (handle) {
|
|
452
|
+
if (linkedHandles.indexOf(handle) === -1) linkedHandles.push(handle);
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
if (linkedHandles.length > 0) {
|
|
456
|
+
var nodeSection = element("section", "link-section");
|
|
457
|
+
nodeSection.append(element("h3", "", "Linked UI tree nodes"));
|
|
458
|
+
var nodeLinks = element("div", "link-list");
|
|
459
|
+
linkedHandles.forEach(function (handle) {
|
|
460
|
+
var nodeEntry = treeNodeByHandle.get(handle);
|
|
461
|
+
var button = element("button", "causal-link", formatTreeNodeSummary(nodeEntry.node));
|
|
462
|
+
button.type = "button";
|
|
463
|
+
button.addEventListener("click", function () { selectNode(handle, true); });
|
|
464
|
+
nodeLinks.append(button);
|
|
465
|
+
});
|
|
466
|
+
nodeSection.append(nodeLinks);
|
|
467
|
+
detail.append(nodeSection);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
if (operation.unresolvedCauseIds.length > 0) {
|
|
471
|
+
detail.append(element("p", "warning", operation.unresolvedCauseIds.length + " direct cause ID(s) were evicted or came from another process: " + operation.unresolvedCauseIds.join(", ")));
|
|
472
|
+
}
|
|
473
|
+
if (operation.attributes) {
|
|
474
|
+
var attributes = element("section", "link-section");
|
|
475
|
+
attributes.append(element("h3", "", "Explicitly included attributes"));
|
|
476
|
+
attributes.append(element("pre", "", JSON.stringify(operation.attributes, null, 2)));
|
|
477
|
+
detail.append(attributes);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
function renderGroupDetail(group) {
|
|
482
|
+
var detail = document.getElementById("detail");
|
|
483
|
+
detail.replaceChildren();
|
|
484
|
+
detail.append(element("h2", "", "Retained causal group"), element("code", "", group.groupId));
|
|
485
|
+
var values = element("dl", "detail-grid");
|
|
486
|
+
detailValue(values, "Operations", group.operationCount);
|
|
487
|
+
detailValue(values, "Status", group.status);
|
|
488
|
+
detailValue(values, "Start offset", group.offset + " ms");
|
|
489
|
+
detailValue(values, "Span", group.duration + " ms");
|
|
490
|
+
detailValue(values, "Active", group.activeOperationCount);
|
|
491
|
+
detailValue(values, "OK", group.okOperationCount);
|
|
492
|
+
detailValue(values, "Errors", group.errorOperationCount);
|
|
493
|
+
detailValue(values, "Cancelled", group.cancelledOperationCount);
|
|
494
|
+
detail.append(values);
|
|
495
|
+
linkSection(detail, "Operations", group.operationIds, function (id) { select(id, true); });
|
|
496
|
+
linkSection(detail, "Entries", group.entryOperationIds, function (id) { select(id, true); });
|
|
497
|
+
linkSection(detail, "Terminals", group.terminalOperationIds, function (id) { select(id, true); });
|
|
498
|
+
if (group.unresolvedCauseIds.length > 0) {
|
|
499
|
+
detail.append(element("p", "warning", group.unresolvedCauseIds.length + " cause ID(s) were evicted or came from another process: " + group.unresolvedCauseIds.join(", ")));
|
|
500
|
+
}
|
|
501
|
+
detail.append(element("p", "empty", "The group ID is the earliest retained operation ID. It can change after eviction and is not a distributed trace ID."));
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
function renderNodeDetail(entry) {
|
|
505
|
+
var node = entry.node;
|
|
506
|
+
var detail = document.getElementById("detail");
|
|
507
|
+
detail.replaceChildren();
|
|
508
|
+
detail.append(
|
|
509
|
+
element("h2", "", node.kind === "element" ? node.component : "#text"),
|
|
510
|
+
element("code", "", "node #" + node.handle + " · " + node.kind)
|
|
511
|
+
);
|
|
512
|
+
var values = element("dl", "detail-grid");
|
|
513
|
+
detailValue(values, "Handle", "#" + node.handle);
|
|
514
|
+
detailValue(values, "Kind", node.kind);
|
|
515
|
+
if (node.kind === "text") {
|
|
516
|
+
detailValue(values, "Text length", node.textLength + (node.textLength === 1 ? " char" : " chars"));
|
|
517
|
+
} else {
|
|
518
|
+
if (node.role) detailValue(values, "Role", node.role);
|
|
519
|
+
detailValue(values, "Events", node.eventNames.length === 0 ? "None" : node.eventNames.join(", "));
|
|
520
|
+
detailValue(values, "Props", node.propNames.length === 0 ? "None" : node.propNames.join(", "));
|
|
521
|
+
detailValue(values, "Children", node.children.length);
|
|
522
|
+
if (node.omittedChildCount) detailValue(values, "Omitted children", node.omittedChildCount);
|
|
523
|
+
}
|
|
524
|
+
if (node.causalOwner) detailValue(values, "Causal owner", node.causalOwner);
|
|
525
|
+
if (node.causalComputation) detailValue(values, "Causal computation", node.causalComputation);
|
|
526
|
+
detail.append(values);
|
|
527
|
+
if (entry.parentHandle !== undefined && treeNodeByHandle.has(entry.parentHandle)) {
|
|
528
|
+
var parentNode = treeNodeByHandle.get(entry.parentHandle).node;
|
|
529
|
+
var parentSection = element("section", "link-section");
|
|
530
|
+
parentSection.append(element("h3", "", "Parent node"));
|
|
531
|
+
var parentLinks = element("div", "link-list");
|
|
532
|
+
var parentBtn = element("button", "causal-link", formatTreeNodeSummary(parentNode));
|
|
533
|
+
parentBtn.type = "button";
|
|
534
|
+
parentBtn.addEventListener("click", function () { selectNode(entry.parentHandle, true); });
|
|
535
|
+
parentLinks.append(parentBtn);
|
|
536
|
+
parentSection.append(parentLinks);
|
|
537
|
+
detail.append(parentSection);
|
|
538
|
+
}
|
|
539
|
+
if (entry.childrenHandles.length > 0) {
|
|
540
|
+
var childrenSection = element("section", "link-section");
|
|
541
|
+
childrenSection.append(element("h3", "", "Child nodes"));
|
|
542
|
+
var childLinks = element("div", "link-list");
|
|
543
|
+
entry.childrenHandles.forEach(function (childHandle) {
|
|
544
|
+
var childNode = treeNodeByHandle.get(childHandle).node;
|
|
545
|
+
var childBtn = element("button", "causal-link", formatTreeNodeSummary(childNode));
|
|
546
|
+
childBtn.type = "button";
|
|
547
|
+
childBtn.addEventListener("click", function () { selectNode(childHandle, true); });
|
|
548
|
+
childLinks.append(childBtn);
|
|
549
|
+
});
|
|
550
|
+
childrenSection.append(childLinks);
|
|
551
|
+
detail.append(childrenSection);
|
|
552
|
+
}
|
|
553
|
+
linkSection(detail, "Linked causal operations", operationsByNodeHandle.get(node.handle) || [], function (id) {
|
|
554
|
+
view.value = "operations";
|
|
555
|
+
select(id, true);
|
|
556
|
+
filter();
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
var selectedId;
|
|
561
|
+
var selectedGroupId;
|
|
562
|
+
var selectedNodeHandle;
|
|
563
|
+
function clearSelectionHighlight() {
|
|
564
|
+
if (selectedId && rows.has(selectedId)) rows.get(selectedId).button.setAttribute("aria-pressed", "false");
|
|
565
|
+
if (selectedGroupId && groupRows.has(selectedGroupId)) groupRows.get(selectedGroupId).button.setAttribute("aria-pressed", "false");
|
|
566
|
+
if (selectedNodeHandle !== undefined && treeRows.has(selectedNodeHandle)) treeRows.get(selectedNodeHandle).button.setAttribute("aria-pressed", "false");
|
|
567
|
+
selectedId = undefined;
|
|
568
|
+
selectedGroupId = undefined;
|
|
569
|
+
selectedNodeHandle = undefined;
|
|
570
|
+
}
|
|
571
|
+
function select(operationId, updateHash) {
|
|
572
|
+
var operation = byId.get(operationId);
|
|
573
|
+
if (!operation) return;
|
|
574
|
+
clearSelectionHighlight();
|
|
575
|
+
selectedId = operationId;
|
|
576
|
+
rows.get(operationId).button.setAttribute("aria-pressed", "true");
|
|
577
|
+
renderDetail(operation);
|
|
578
|
+
if (updateHash) {
|
|
579
|
+
try { history.replaceState(null, "", "#operation=" + encodeURIComponent(operationId)); } catch (_) {}
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
function selectGroup(groupId, updateHash) {
|
|
584
|
+
var group = groupById.get(groupId);
|
|
585
|
+
if (!group) return;
|
|
586
|
+
clearSelectionHighlight();
|
|
587
|
+
selectedGroupId = groupId;
|
|
588
|
+
groupRows.get(groupId).button.setAttribute("aria-pressed", "true");
|
|
589
|
+
renderGroupDetail(group);
|
|
590
|
+
if (updateHash) {
|
|
591
|
+
try { history.replaceState(null, "", "#group=" + encodeURIComponent(groupId)); } catch (_) {}
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
function selectNode(handle, updateHash) {
|
|
596
|
+
var entry = treeNodeByHandle.get(handle);
|
|
597
|
+
if (!entry) return;
|
|
598
|
+
clearSelectionHighlight();
|
|
599
|
+
selectedNodeHandle = handle;
|
|
600
|
+
var rowRef = treeRows.get(handle);
|
|
601
|
+
if (rowRef) {
|
|
602
|
+
rowRef.row.hidden = false;
|
|
603
|
+
rowRef.button.setAttribute("aria-pressed", "true");
|
|
604
|
+
if (typeof rowRef.button.scrollIntoView === "function") {
|
|
605
|
+
rowRef.button.scrollIntoView({ block: "nearest" });
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
renderNodeDetail(entry);
|
|
609
|
+
if (updateHash) {
|
|
610
|
+
try { history.replaceState(null, "", "#node=" + encodeURIComponent(String(handle))); } catch (_) {}
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
var search = document.getElementById("search");
|
|
615
|
+
var status = document.getElementById("status-filter");
|
|
616
|
+
var view = document.getElementById("view-filter");
|
|
617
|
+
function filter() {
|
|
618
|
+
var query = search.value.trim().toLocaleLowerCase();
|
|
619
|
+
var statusValue = status.value;
|
|
620
|
+
var grouped = view.value === "groups";
|
|
621
|
+
groupList.hidden = !grouped;
|
|
622
|
+
list.hidden = grouped;
|
|
623
|
+
var values = grouped ? report.groups : report.operations;
|
|
624
|
+
var visible = 0;
|
|
625
|
+
values.forEach(function (value) {
|
|
626
|
+
var ids = grouped ? value.operationIds : [value.operationId];
|
|
627
|
+
var names = grouped ? value.operationNames : [value.name];
|
|
628
|
+
var matchesText = query === "" || ids.concat(names).some(function (candidate) { return candidate.toLocaleLowerCase().includes(query); });
|
|
629
|
+
var matchesStatus = statusValue === "all" || value.status === statusValue;
|
|
630
|
+
var row = grouped ? groupRows.get(value.groupId).row : rows.get(value.operationId).row;
|
|
631
|
+
row.hidden = !(matchesText && matchesStatus);
|
|
632
|
+
if (matchesText && matchesStatus) visible += 1;
|
|
633
|
+
});
|
|
634
|
+
document.getElementById("visible-count").textContent = visible + " of " + values.length + (grouped ? " groups" : " operations");
|
|
635
|
+
}
|
|
636
|
+
search.addEventListener("input", filter);
|
|
637
|
+
status.addEventListener("change", filter);
|
|
638
|
+
view.addEventListener("change", function () {
|
|
639
|
+
if (view.value === "groups" && selectedId && byId.has(selectedId)) selectGroup(byId.get(selectedId).groupId, true);
|
|
640
|
+
else if (view.value === "operations" && selectedGroupId && groupById.has(selectedGroupId)) {
|
|
641
|
+
var ids = groupById.get(selectedGroupId).operationIds;
|
|
642
|
+
if (ids.length > 0) select(ids[0], true);
|
|
643
|
+
}
|
|
644
|
+
filter();
|
|
645
|
+
});
|
|
646
|
+
document.addEventListener("keydown", function (event) {
|
|
647
|
+
if (event.key === "/" && document.activeElement !== search) {
|
|
648
|
+
event.preventDefault();
|
|
649
|
+
search.focus();
|
|
650
|
+
}
|
|
651
|
+
});
|
|
652
|
+
window.addEventListener("hashchange", function () {
|
|
653
|
+
var values = new URLSearchParams(location.hash.slice(1));
|
|
654
|
+
var operationId = values.get("operation");
|
|
655
|
+
var groupId = values.get("group");
|
|
656
|
+
var nodeParam = values.get("node");
|
|
657
|
+
if (operationId) { view.value = "operations"; select(operationId, false); filter(); }
|
|
658
|
+
else if (groupId) { view.value = "groups"; selectGroup(groupId, false); filter(); }
|
|
659
|
+
else if (nodeParam !== null && /^\\d+$/.test(nodeParam)) { selectNode(Number(nodeParam), false); }
|
|
660
|
+
});
|
|
661
|
+
var hashValues = new URLSearchParams(location.hash.slice(1));
|
|
662
|
+
var hashOperationId = hashValues.get("operation");
|
|
663
|
+
var hashGroupId = hashValues.get("group");
|
|
664
|
+
var hashNodeParam = hashValues.get("node");
|
|
665
|
+
if (hashOperationId && byId.has(hashOperationId)) {
|
|
666
|
+
view.value = "operations";
|
|
667
|
+
select(hashOperationId, false);
|
|
668
|
+
} else if (hashGroupId && groupById.has(hashGroupId)) {
|
|
669
|
+
selectGroup(hashGroupId, false);
|
|
670
|
+
} else if (hashNodeParam !== null && /^\\d+$/.test(hashNodeParam) && treeNodeByHandle.has(Number(hashNodeParam))) {
|
|
671
|
+
selectNode(Number(hashNodeParam), false);
|
|
672
|
+
} else if (report.selectedOperationId && byId.has(report.selectedOperationId)) {
|
|
673
|
+
view.value = "operations";
|
|
674
|
+
select(report.selectedOperationId, false);
|
|
675
|
+
} else if (report.groups.length > 0) {
|
|
676
|
+
selectGroup(report.groups[0].groupId, false);
|
|
677
|
+
}
|
|
678
|
+
filter();
|
|
679
|
+
})();
|
|
680
|
+
`;
|
|
681
|
+
function cspHash(source) {
|
|
682
|
+
return createHash("sha256").update(source, "utf8").digest("base64");
|
|
683
|
+
}
|
|
684
|
+
function operationTiming(snapshot, operation) {
|
|
685
|
+
const duration = operation.duration ?? snapshot.capturedAt - operation.startedAt;
|
|
686
|
+
const end = operation.startedAt + duration;
|
|
687
|
+
if (!Number.isFinite(duration) || duration < 0 || !Number.isFinite(end)) {
|
|
688
|
+
throw new RangeError(`Causal operation ${JSON.stringify(operation.operationId)} cannot be represented in the offline report timeline.`);
|
|
689
|
+
}
|
|
690
|
+
return { duration, end };
|
|
691
|
+
}
|
|
692
|
+
function indexTreeSnapshot(tree) {
|
|
693
|
+
const handles = new Set();
|
|
694
|
+
const owners = new Set();
|
|
695
|
+
const computations = new Set();
|
|
696
|
+
const walk = (node) => {
|
|
697
|
+
handles.add(node.handle);
|
|
698
|
+
if (node.causalOwner !== undefined)
|
|
699
|
+
owners.add(node.causalOwner);
|
|
700
|
+
if (node.causalComputation !== undefined) {
|
|
701
|
+
computations.add(node.causalComputation);
|
|
702
|
+
}
|
|
703
|
+
if (node.kind === "element") {
|
|
704
|
+
for (const child of node.children)
|
|
705
|
+
walk(child);
|
|
706
|
+
}
|
|
707
|
+
};
|
|
708
|
+
walk(tree.root);
|
|
709
|
+
return { handles, owners, computations };
|
|
710
|
+
}
|
|
711
|
+
/** Creates one offline, content-security-policy-locked causal debugger. */
|
|
712
|
+
export function createNativeCausalDebugReport(value, options = {}) {
|
|
713
|
+
const snapshot = parseCausalDebugSnapshot(value);
|
|
714
|
+
const diagnosticsCorrelation = options.diagnostics === undefined
|
|
715
|
+
? undefined
|
|
716
|
+
: correlateNativeSolidDiagnostics(options.diagnostics, snapshot);
|
|
717
|
+
const tree = options.tree === undefined
|
|
718
|
+
? undefined
|
|
719
|
+
: parseTreeDebugSnapshot(options.tree);
|
|
720
|
+
const treeIndex = tree === undefined ? undefined : indexTreeSnapshot(tree);
|
|
721
|
+
const inspection = inspectNativeCausalDebugSnapshot(snapshot, options);
|
|
722
|
+
const retainedIds = new Set(snapshot.operations.map((operation) => operation.operationId));
|
|
723
|
+
let retainedFlowCount = 0;
|
|
724
|
+
const timings = new Map();
|
|
725
|
+
for (const operation of snapshot.operations) {
|
|
726
|
+
timings.set(operation.operationId, operationTiming(snapshot, operation));
|
|
727
|
+
for (const causeId of operation.causes) {
|
|
728
|
+
if (!retainedIds.has(causeId))
|
|
729
|
+
continue;
|
|
730
|
+
retainedFlowCount += 1;
|
|
731
|
+
if (retainedFlowCount > NATIVE_CAUSAL_TRACE_MAX_FLOW_COUNT) {
|
|
732
|
+
throw new RangeError(`The causal debug report exceeds ${NATIVE_CAUSAL_TRACE_MAX_FLOW_COUNT} retained flows.`);
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
const origin = snapshot.operations.reduce((minimum, operation) => Math.min(minimum, operation.startedAt), snapshot.capturedAt);
|
|
737
|
+
const end = snapshot.operations.reduce((maximum, operation) => Math.max(maximum, timings.get(operation.operationId).end), snapshot.capturedAt);
|
|
738
|
+
const span = end - origin;
|
|
739
|
+
if (!Number.isFinite(span) || span < 0) {
|
|
740
|
+
throw new RangeError("The causal debug snapshot cannot be represented in the offline report timeline.");
|
|
741
|
+
}
|
|
742
|
+
const groupIdByOperationId = new Map(inspection.groups.flatMap((group) => group.operationIds.map((operationId) => [operationId, group.groupId])));
|
|
743
|
+
const operations = snapshot.operations.map((operation) => {
|
|
744
|
+
const timing = timings.get(operation.operationId);
|
|
745
|
+
const offset = operation.startedAt - origin;
|
|
746
|
+
if (!Number.isFinite(offset) || offset < 0) {
|
|
747
|
+
throw new RangeError(`Causal operation ${JSON.stringify(operation.operationId)} has an invalid offline report offset.`);
|
|
748
|
+
}
|
|
749
|
+
const groupId = groupIdByOperationId.get(operation.operationId);
|
|
750
|
+
if (groupId === undefined) {
|
|
751
|
+
throw new TypeError(`Causal operation ${JSON.stringify(operation.operationId)} has no retained report group.`);
|
|
752
|
+
}
|
|
753
|
+
const rawTargetNode = operation.startAttributes["target.node"];
|
|
754
|
+
const targetNodeHandle = treeIndex !== undefined &&
|
|
755
|
+
typeof rawTargetNode === "number" &&
|
|
756
|
+
Number.isSafeInteger(rawTargetNode) &&
|
|
757
|
+
treeIndex.handles.has(rawTargetNode)
|
|
758
|
+
? rawTargetNode
|
|
759
|
+
: undefined;
|
|
760
|
+
const rawOwnerName = operation.startAttributes["owner.name"];
|
|
761
|
+
const treeOwnerName = treeIndex !== undefined &&
|
|
762
|
+
typeof rawOwnerName === "string" &&
|
|
763
|
+
treeIndex.owners.has(rawOwnerName)
|
|
764
|
+
? rawOwnerName
|
|
765
|
+
: undefined;
|
|
766
|
+
const rawComputationName = operation.startAttributes["computation.name"];
|
|
767
|
+
const treeComputationName = treeIndex !== undefined &&
|
|
768
|
+
typeof rawComputationName === "string" &&
|
|
769
|
+
treeIndex.computations.has(rawComputationName)
|
|
770
|
+
? rawComputationName
|
|
771
|
+
: undefined;
|
|
772
|
+
return {
|
|
773
|
+
operationId: operation.operationId,
|
|
774
|
+
groupId,
|
|
775
|
+
name: operation.name,
|
|
776
|
+
status: operation.status ?? "active",
|
|
777
|
+
causes: operation.causes,
|
|
778
|
+
unresolvedCauseIds: operation.causes.filter((causeId) => !retainedIds.has(causeId)),
|
|
779
|
+
offset,
|
|
780
|
+
duration: timing.duration,
|
|
781
|
+
...(targetNodeHandle === undefined ? {} : { targetNodeHandle }),
|
|
782
|
+
...(treeOwnerName === undefined ? {} : { treeOwnerName }),
|
|
783
|
+
...(treeComputationName === undefined ? {} : { treeComputationName }),
|
|
784
|
+
...(options.includeAttributes === true
|
|
785
|
+
? {
|
|
786
|
+
attributes: {
|
|
787
|
+
start: operation.startAttributes,
|
|
788
|
+
...(operation.finishAttributes === undefined
|
|
789
|
+
? {}
|
|
790
|
+
: { finish: operation.finishAttributes }),
|
|
791
|
+
},
|
|
792
|
+
}
|
|
793
|
+
: {}),
|
|
794
|
+
};
|
|
795
|
+
});
|
|
796
|
+
const groups = inspection.groups.map((group) => {
|
|
797
|
+
const groupEnd = group.operationIds.reduce((maximum, operationId) => Math.max(maximum, timings.get(operationId).end), group.startedAt);
|
|
798
|
+
const offset = group.startedAt - origin;
|
|
799
|
+
const duration = groupEnd - group.startedAt;
|
|
800
|
+
if (!Number.isFinite(offset) ||
|
|
801
|
+
offset < 0 ||
|
|
802
|
+
!Number.isFinite(duration) ||
|
|
803
|
+
duration < 0) {
|
|
804
|
+
throw new RangeError(`Causal group ${JSON.stringify(group.groupId)} cannot be represented in the offline report timeline.`);
|
|
805
|
+
}
|
|
806
|
+
const status = group.errorOperationCount > 0
|
|
807
|
+
? "error"
|
|
808
|
+
: group.activeOperationCount > 0
|
|
809
|
+
? "active"
|
|
810
|
+
: group.cancelledOperationCount > 0
|
|
811
|
+
? "cancelled"
|
|
812
|
+
: "ok";
|
|
813
|
+
return {
|
|
814
|
+
...group,
|
|
815
|
+
status,
|
|
816
|
+
offset,
|
|
817
|
+
duration,
|
|
818
|
+
};
|
|
819
|
+
});
|
|
820
|
+
const document = {
|
|
821
|
+
kind: "solid-native.causal-debug-report",
|
|
822
|
+
schemaVersion: 1,
|
|
823
|
+
capturedAt: snapshot.capturedAt,
|
|
824
|
+
origin,
|
|
825
|
+
span,
|
|
826
|
+
operationCount: inspection.operationCount,
|
|
827
|
+
groupCount: groups.length,
|
|
828
|
+
activeOperationCount: inspection.activeOperationCount,
|
|
829
|
+
evictedOperationCount: inspection.evictedOperationCount,
|
|
830
|
+
discardedRecordCount: inspection.discardedRecordCount,
|
|
831
|
+
statusCounts: inspection.statusCounts,
|
|
832
|
+
...(options.operationId === undefined
|
|
833
|
+
? {}
|
|
834
|
+
: { selectedOperationId: options.operationId }),
|
|
835
|
+
...(diagnosticsCorrelation === undefined ? {} : { diagnosticsCorrelation }),
|
|
836
|
+
...(tree === undefined ? {} : { tree }),
|
|
837
|
+
operations,
|
|
838
|
+
groups,
|
|
839
|
+
};
|
|
840
|
+
const encoded = Buffer.from(JSON.stringify(document), "utf8").toString("base64");
|
|
841
|
+
const csp = [
|
|
842
|
+
"default-src 'none'",
|
|
843
|
+
`script-src 'sha256-${cspHash(REPORT_SCRIPT)}'`,
|
|
844
|
+
`style-src 'sha256-${cspHash(REPORT_STYLE)}'`,
|
|
845
|
+
"base-uri 'none'",
|
|
846
|
+
"connect-src 'none'",
|
|
847
|
+
"form-action 'none'",
|
|
848
|
+
"frame-src 'none'",
|
|
849
|
+
"object-src 'none'",
|
|
850
|
+
].join("; ");
|
|
851
|
+
const html = `<!doctype html>
|
|
852
|
+
<html lang="en">
|
|
853
|
+
<head>
|
|
854
|
+
<meta charset="utf-8">
|
|
855
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
856
|
+
<meta http-equiv="Content-Security-Policy" content="${csp}">
|
|
857
|
+
<title>Solid Native causal report</title>
|
|
858
|
+
<style>${REPORT_STYLE}</style>
|
|
859
|
+
</head>
|
|
860
|
+
<body>
|
|
861
|
+
<header>
|
|
862
|
+
<p class="eyebrow">Solid Native · Offline debugger</p>
|
|
863
|
+
<h1>Causal report</h1>
|
|
864
|
+
<p class="subtitle">Follow native work from input and Solid computations through Fabric commits, mounts, and frame opportunities. This file makes no network requests.</p>
|
|
865
|
+
</header>
|
|
866
|
+
<dl class="summary" id="summary"></dl>
|
|
867
|
+
<section class="diagnostics-panel" id="diagnostics-correlation" aria-label="Solid to native diagnostics correlation" hidden></section>
|
|
868
|
+
<section class="tree-panel" id="ui-tree-panel" aria-label="UI tree snapshot" hidden></section>
|
|
869
|
+
<section class="controls" aria-label="Operation filters">
|
|
870
|
+
<label>View<select id="view-filter"><option value="groups">Causal groups</option><option value="operations">Operations</option></select></label>
|
|
871
|
+
<label>Search<input id="search" type="search" autocomplete="off" placeholder="Group, operation ID, or kind" aria-keyshortcuts="/"></label>
|
|
872
|
+
<label>Status<select id="status-filter"><option value="all">All</option><option value="active">Active</option><option value="ok">OK</option><option value="error">Error</option><option value="cancelled">Cancelled</option></select></label>
|
|
873
|
+
<span class="visible-count" id="visible-count"></span>
|
|
874
|
+
</section>
|
|
875
|
+
<main>
|
|
876
|
+
<section class="panel" aria-label="Causal timeline"><div class="panel-heading">Timeline</div><ol id="groups"></ol><ol id="operations" hidden></ol></section>
|
|
877
|
+
<aside class="panel" id="detail" aria-live="polite"><p class="empty">Select an operation to inspect its causal neighborhood.</p></aside>
|
|
878
|
+
</main>
|
|
879
|
+
<footer>${options.includeAttributes === true ? "Application-authored attributes were explicitly included." : "Application-authored attributes were excluded. Regenerate with --show-attributes only when their disclosure is intended."}${diagnosticsCorrelation === undefined ? "" : " Bounded static Solid diagnostics names were explicitly included; reactive values remain excluded."}${tree === undefined ? "" : " Bounded value-free UI tree structure was included; rendered text and prop values remain excluded."}</footer>
|
|
880
|
+
<div id="report-data" hidden>${encoded}</div>
|
|
881
|
+
<script>${REPORT_SCRIPT}</script>
|
|
882
|
+
</body>
|
|
883
|
+
</html>
|
|
884
|
+
`;
|
|
885
|
+
if (Buffer.byteLength(html, "utf8") > NATIVE_CAUSAL_DEBUG_MAX_REPORT_BYTES) {
|
|
886
|
+
throw new RangeError(`The causal debug report exceeds ${NATIVE_CAUSAL_DEBUG_MAX_REPORT_BYTES} bytes.`);
|
|
887
|
+
}
|
|
888
|
+
return html;
|
|
889
|
+
}
|
|
890
|
+
export async function createNativeCausalDebugReportFile(options) {
|
|
891
|
+
if (typeof options !== "object" || options === null) {
|
|
892
|
+
throw new TypeError("Causal debug report file options are required.");
|
|
893
|
+
}
|
|
894
|
+
if (options.diagnostics !== undefined &&
|
|
895
|
+
options.diagnosticsPath !== undefined) {
|
|
896
|
+
throw new TypeError("Causal debug report diagnostics and diagnosticsPath are mutually exclusive.");
|
|
897
|
+
}
|
|
898
|
+
if (options.tree !== undefined && options.treePath !== undefined) {
|
|
899
|
+
throw new TypeError("Causal debug report tree and treePath are mutually exclusive.");
|
|
900
|
+
}
|
|
901
|
+
const [snapshot, fileDiagnostics, fileTree] = await Promise.all([
|
|
902
|
+
readNativeCausalDebugSnapshotFile(options.snapshotPath, options.cwd),
|
|
903
|
+
options.diagnosticsPath === undefined
|
|
904
|
+
? undefined
|
|
905
|
+
: readNativeSolidDiagnosticsDebugFile(options.diagnosticsPath, options.cwd),
|
|
906
|
+
options.treePath === undefined
|
|
907
|
+
? undefined
|
|
908
|
+
: readNativeTreeDebugSnapshotFile(options.treePath, options.cwd),
|
|
909
|
+
]);
|
|
910
|
+
return createNativeCausalDebugReport(snapshot, {
|
|
911
|
+
...(options.includeAttributes === undefined
|
|
912
|
+
? {}
|
|
913
|
+
: { includeAttributes: options.includeAttributes }),
|
|
914
|
+
...(options.operationId === undefined
|
|
915
|
+
? {}
|
|
916
|
+
: { operationId: options.operationId }),
|
|
917
|
+
...(options.diagnostics === undefined && fileDiagnostics === undefined
|
|
918
|
+
? {}
|
|
919
|
+
: { diagnostics: options.diagnostics ?? fileDiagnostics }),
|
|
920
|
+
...(options.tree === undefined && fileTree === undefined
|
|
921
|
+
? {}
|
|
922
|
+
: { tree: options.tree ?? fileTree }),
|
|
923
|
+
});
|
|
924
|
+
}
|
|
925
|
+
export async function createNativeCausalDebugReportStream(stream, options = {}) {
|
|
926
|
+
return createNativeCausalDebugReport(await readNativeCausalDebugSnapshotStream(stream), options);
|
|
927
|
+
}
|
|
928
|
+
/**
|
|
929
|
+
* Publishes a generated report as a private, atomic, no-clobber local file.
|
|
930
|
+
* The returned path is absolute so a CLI can identify the exact artifact.
|
|
931
|
+
*/
|
|
932
|
+
export async function writeNativeCausalDebugReportFile(options) {
|
|
933
|
+
if (typeof options !== "object" || options === null) {
|
|
934
|
+
throw new TypeError("Causal debug report output options are required.");
|
|
935
|
+
}
|
|
936
|
+
if (typeof options.report !== "string" ||
|
|
937
|
+
!options.report.startsWith("<!doctype html>") ||
|
|
938
|
+
Buffer.byteLength(options.report, "utf8") >
|
|
939
|
+
NATIVE_CAUSAL_DEBUG_MAX_REPORT_BYTES) {
|
|
940
|
+
throw new TypeError("The causal debug report output must be bounded HTML.");
|
|
941
|
+
}
|
|
942
|
+
if (typeof options.outputPath !== "string" ||
|
|
943
|
+
options.outputPath.length === 0 ||
|
|
944
|
+
options.outputPath.includes("\0")) {
|
|
945
|
+
throw new TypeError("The causal debug report output path is invalid.");
|
|
946
|
+
}
|
|
947
|
+
if (options.cwd !== undefined &&
|
|
948
|
+
(typeof options.cwd !== "string" || options.cwd.length === 0)) {
|
|
949
|
+
throw new TypeError("The causal debug report output cwd is invalid.");
|
|
950
|
+
}
|
|
951
|
+
const outputPath = path.resolve(options.cwd ?? process.cwd(), options.outputPath);
|
|
952
|
+
const outputDirectory = path.dirname(outputPath);
|
|
953
|
+
await mkdir(outputDirectory, { recursive: true, mode: 0o700 });
|
|
954
|
+
const temporaryPath = path.join(outputDirectory, `.${path.basename(outputPath)}.solid-native-${randomUUID()}.tmp`);
|
|
955
|
+
try {
|
|
956
|
+
await writeFile(temporaryPath, options.report, {
|
|
957
|
+
encoding: "utf8",
|
|
958
|
+
flag: "wx",
|
|
959
|
+
mode: 0o600,
|
|
960
|
+
});
|
|
961
|
+
try {
|
|
962
|
+
await link(temporaryPath, outputPath);
|
|
963
|
+
}
|
|
964
|
+
catch (error) {
|
|
965
|
+
if (typeof error === "object" &&
|
|
966
|
+
error !== null &&
|
|
967
|
+
"code" in error &&
|
|
968
|
+
error.code === "EEXIST") {
|
|
969
|
+
throw new TypeError(`The causal debug report output already exists at ${outputPath}; refusing to overwrite it.`);
|
|
970
|
+
}
|
|
971
|
+
throw error;
|
|
972
|
+
}
|
|
973
|
+
return outputPath;
|
|
974
|
+
}
|
|
975
|
+
finally {
|
|
976
|
+
await rm(temporaryPath, { force: true });
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
//# sourceMappingURL=causal-debug-report.js.map
|