@ogygia/devtools 0.0.0 → 0.11.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 +24 -1
- package/dist/client.d.ts +3 -0
- package/dist/client.js +24 -0
- package/dist/devtools/BoundaryOverlay.svelte +396 -0
- package/dist/devtools/BoundaryOverlay.svelte.d.ts +19 -0
- package/dist/devtools/Devtools.svelte +663 -0
- package/dist/devtools/Devtools.svelte.d.ts +15 -0
- package/dist/devtools/HubTab.svelte +206 -0
- package/dist/devtools/HubTab.svelte.d.ts +11 -0
- package/dist/devtools/HydrationTab.svelte +237 -0
- package/dist/devtools/HydrationTab.svelte.d.ts +13 -0
- package/dist/devtools/IslandDetail.svelte +615 -0
- package/dist/devtools/IslandDetail.svelte.d.ts +15 -0
- package/dist/devtools/LedgerTab.svelte +287 -0
- package/dist/devtools/LedgerTab.svelte.d.ts +11 -0
- package/dist/devtools/LensTab.svelte +290 -0
- package/dist/devtools/LensTab.svelte.d.ts +19 -0
- package/dist/devtools/NavTab.svelte +229 -0
- package/dist/devtools/NavTab.svelte.d.ts +11 -0
- package/dist/devtools/PageTab.svelte +1122 -0
- package/dist/devtools/PageTab.svelte.d.ts +15 -0
- package/dist/devtools/ProfilerTab.svelte +755 -0
- package/dist/devtools/ProfilerTab.svelte.d.ts +15 -0
- package/dist/devtools/PropsTree.svelte +155 -0
- package/dist/devtools/PropsTree.svelte.d.ts +15 -0
- package/dist/devtools/SessionTab.svelte +796 -0
- package/dist/devtools/SessionTab.svelte.d.ts +11 -0
- package/dist/devtools/TimelineTab.svelte +267 -0
- package/dist/devtools/TimelineTab.svelte.d.ts +11 -0
- package/dist/devtools/WireTab.svelte +149 -0
- package/dist/devtools/WireTab.svelte.d.ts +11 -0
- package/dist/devtools/bytes.d.ts +70 -0
- package/dist/devtools/bytes.js +82 -0
- package/dist/devtools/cache-headers.d.ts +20 -0
- package/dist/devtools/cache-headers.js +81 -0
- package/dist/devtools/highlight.d.ts +7 -0
- package/dist/devtools/highlight.js +83 -0
- package/dist/devtools/hydration.d.ts +48 -0
- package/dist/devtools/hydration.js +93 -0
- package/dist/devtools/index.d.ts +3 -0
- package/dist/devtools/index.js +3 -0
- package/dist/devtools/ledger-dom.d.ts +7 -0
- package/dist/devtools/ledger-dom.js +151 -0
- package/dist/devtools/leftovers.d.ts +77 -0
- package/dist/devtools/leftovers.js +319 -0
- package/dist/devtools/names.d.ts +1 -0
- package/dist/devtools/names.js +34 -0
- package/dist/devtools/page.d.ts +96 -0
- package/dist/devtools/page.js +957 -0
- package/dist/devtools/profile-anchors.d.ts +22 -0
- package/dist/devtools/profile-anchors.js +135 -0
- package/dist/devtools/profile-store.d.ts +175 -0
- package/dist/devtools/profile-store.js +239 -0
- package/dist/devtools/regions.d.ts +77 -0
- package/dist/devtools/regions.js +132 -0
- package/dist/devtools/session.d.ts +31 -0
- package/dist/devtools/session.js +455 -0
- package/dist/devtools/since-load.d.ts +50 -0
- package/dist/devtools/since-load.js +89 -0
- package/dist/devtools/source-lines.d.ts +24 -0
- package/dist/devtools/source-lines.js +106 -0
- package/dist/devtools/styles.d.ts +52 -0
- package/dist/devtools/styles.js +248 -0
- package/dist/devtools/testing-engine.d.ts +83 -0
- package/dist/devtools/testing-engine.js +220 -0
- package/dist/devtools/ui-app.d.ts +5 -0
- package/dist/devtools/ui-app.js +69 -0
- package/dist/devtools/ui.d.ts +50 -0
- package/dist/devtools/ui.js +175 -0
- package/dist/profiler/alloc.d.ts +75 -0
- package/dist/profiler/alloc.js +76 -0
- package/dist/profiler/analyze.d.ts +437 -0
- package/dist/profiler/analyze.js +1941 -0
- package/dist/profiler/app-path.d.ts +7 -0
- package/dist/profiler/app-path.js +26 -0
- package/dist/profiler/async-io.d.ts +58 -0
- package/dist/profiler/async-io.js +187 -0
- package/dist/profiler/beacon-standalone.d.ts +4 -0
- package/dist/profiler/beacon-standalone.js +409 -0
- package/dist/profiler/browser-findings.d.ts +25 -0
- package/dist/profiler/browser-findings.js +260 -0
- package/dist/profiler/byte-strip.d.ts +58 -0
- package/dist/profiler/byte-strip.js +228 -0
- package/dist/profiler/client-files.d.ts +16 -0
- package/dist/profiler/client-files.js +60 -0
- package/dist/profiler/client-windows.d.ts +49 -0
- package/dist/profiler/client-windows.js +95 -0
- package/dist/profiler/client.d.ts +40 -0
- package/dist/profiler/client.js +82 -0
- package/dist/profiler/compare.d.ts +308 -0
- package/dist/profiler/compare.js +733 -0
- package/dist/profiler/compress.d.ts +10 -0
- package/dist/profiler/compress.js +36 -0
- package/dist/profiler/contention.d.ts +60 -0
- package/dist/profiler/contention.js +86 -0
- package/dist/profiler/crypto.d.ts +19 -0
- package/dist/profiler/crypto.js +101 -0
- package/dist/profiler/doc-diff.d.ts +47 -0
- package/dist/profiler/doc-diff.js +214 -0
- package/dist/profiler/dom-diff.d.ts +43 -0
- package/dist/profiler/dom-diff.js +121 -0
- package/dist/profiler/drill.d.ts +89 -0
- package/dist/profiler/drill.js +553 -0
- package/dist/profiler/embedded-maps.d.ts +37 -0
- package/dist/profiler/embedded-maps.js +135 -0
- package/dist/profiler/env.d.ts +6 -0
- package/dist/profiler/env.js +10 -0
- package/dist/profiler/forecast.d.ts +76 -0
- package/dist/profiler/forecast.js +225 -0
- package/dist/profiler/frames.d.ts +11 -0
- package/dist/profiler/frames.js +42 -0
- package/dist/profiler/gc.d.ts +144 -0
- package/dist/profiler/gc.js +271 -0
- package/dist/profiler/hole-slots.d.ts +31 -0
- package/dist/profiler/hole-slots.js +90 -0
- package/dist/profiler/index.d.ts +288 -0
- package/dist/profiler/index.js +4921 -0
- package/dist/profiler/insights.d.ts +96 -0
- package/dist/profiler/insights.js +239 -0
- package/dist/profiler/ledger.d.ts +121 -0
- package/dist/profiler/ledger.js +440 -0
- package/dist/profiler/lineage.d.ts +81 -0
- package/dist/profiler/lineage.js +359 -0
- package/dist/profiler/module-map.d.ts +12 -0
- package/dist/profiler/module-map.js +94 -0
- package/dist/profiler/net.d.ts +169 -0
- package/dist/profiler/net.js +586 -0
- package/dist/profiler/on-demand.d.ts +11 -0
- package/dist/profiler/on-demand.js +15 -0
- package/dist/profiler/own-requests.d.ts +9 -0
- package/dist/profiler/own-requests.js +17 -0
- package/dist/profiler/patterns.d.ts +476 -0
- package/dist/profiler/patterns.js +2203 -0
- package/dist/profiler/profiler-router.d.ts +245 -0
- package/dist/profiler/profiler-router.js +113 -0
- package/dist/profiler/refresh-stub.d.ts +2 -0
- package/dist/profiler/refresh-stub.js +37 -0
- package/dist/profiler/report.d.ts +1404 -0
- package/dist/profiler/report.js +2638 -0
- package/dist/profiler/river.d.ts +65 -0
- package/dist/profiler/river.js +298 -0
- package/dist/profiler/route-files.d.ts +22 -0
- package/dist/profiler/route-files.js +55 -0
- package/dist/profiler/route-imports.d.ts +14 -0
- package/dist/profiler/route-imports.js +83 -0
- package/dist/profiler/saving.d.ts +22 -0
- package/dist/profiler/saving.js +42 -0
- package/dist/profiler/score.d.ts +109 -0
- package/dist/profiler/score.js +261 -0
- package/dist/profiler/session-cookie.d.ts +28 -0
- package/dist/profiler/session-cookie.js +45 -0
- package/dist/profiler/sink.d.ts +81 -0
- package/dist/profiler/sink.js +124 -0
- package/dist/profiler/site-fixes.d.ts +25 -0
- package/dist/profiler/site-fixes.js +62 -0
- package/dist/profiler/source-scan.d.ts +210 -0
- package/dist/profiler/source-scan.js +1724 -0
- package/dist/profiler/span.d.ts +90 -0
- package/dist/profiler/span.js +109 -0
- package/dist/profiler/stacks.d.ts +43 -0
- package/dist/profiler/stacks.js +107 -0
- package/dist/profiler/standalone.d.ts +27 -0
- package/dist/profiler/standalone.js +98 -0
- package/dist/profiler/steps.d.ts +39 -0
- package/dist/profiler/steps.js +74 -0
- package/dist/profiler/storage/index.d.ts +87 -0
- package/dist/profiler/storage/index.js +76 -0
- package/dist/profiler/storage/postgres.d.ts +12 -0
- package/dist/profiler/storage/postgres.js +94 -0
- package/dist/profiler/storage/redis.d.ts +19 -0
- package/dist/profiler/storage/redis.js +148 -0
- package/dist/profiler/storage/sqlite.d.ts +2 -0
- package/dist/profiler/storage/sqlite.js +85 -0
- package/dist/profiler/storage/visits.d.ts +4 -0
- package/dist/profiler/storage/visits.js +6 -0
- package/dist/profiler/stream-tail.d.ts +26 -0
- package/dist/profiler/stream-tail.js +74 -0
- package/dist/profiler/timeline.d.ts +279 -0
- package/dist/profiler/timeline.js +690 -0
- package/dist/profiler/ui/AllocStrip.svelte +146 -0
- package/dist/profiler/ui/AllocStrip.svelte.d.ts +17 -0
- package/dist/profiler/ui/Awaits.svelte +363 -0
- package/dist/profiler/ui/Awaits.svelte.d.ts +16 -0
- package/dist/profiler/ui/ByteStrip.svelte +182 -0
- package/dist/profiler/ui/ByteStrip.svelte.d.ts +18 -0
- package/dist/profiler/ui/Compare.svelte +24 -0
- package/dist/profiler/ui/Compare.svelte.d.ts +16 -0
- package/dist/profiler/ui/CompareBody.svelte +429 -0
- package/dist/profiler/ui/CompareBody.svelte.d.ts +8 -0
- package/dist/profiler/ui/ComponentsTable.svelte +265 -0
- package/dist/profiler/ui/ComponentsTable.svelte.d.ts +20 -0
- package/dist/profiler/ui/Dashboard.svelte +492 -0
- package/dist/profiler/ui/Dashboard.svelte.d.ts +31 -0
- package/dist/profiler/ui/DataRiver.svelte +206 -0
- package/dist/profiler/ui/DataRiver.svelte.d.ts +13 -0
- package/dist/profiler/ui/DomTravel.svelte +207 -0
- package/dist/profiler/ui/DomTravel.svelte.d.ts +9 -0
- package/dist/profiler/ui/DownloadHtml.svelte +52 -0
- package/dist/profiler/ui/DownloadHtml.svelte.d.ts +10 -0
- package/dist/profiler/ui/Drill.svelte +276 -0
- package/dist/profiler/ui/Drill.svelte.d.ts +12 -0
- package/dist/profiler/ui/ExportButton.svelte +59 -0
- package/dist/profiler/ui/ExportButton.svelte.d.ts +8 -0
- package/dist/profiler/ui/Flame.svelte +222 -0
- package/dist/profiler/ui/Flame.svelte.d.ts +12 -0
- package/dist/profiler/ui/FrameDetails.svelte +308 -0
- package/dist/profiler/ui/FrameDetails.svelte.d.ts +16 -0
- package/dist/profiler/ui/FunctionsTable.svelte +156 -0
- package/dist/profiler/ui/FunctionsTable.svelte.d.ts +17 -0
- package/dist/profiler/ui/IslandHeatmap.svelte +151 -0
- package/dist/profiler/ui/IslandHeatmap.svelte.d.ts +16 -0
- package/dist/profiler/ui/IslandsTable.svelte +448 -0
- package/dist/profiler/ui/IslandsTable.svelte.d.ts +16 -0
- package/dist/profiler/ui/KeepLocal.svelte +46 -0
- package/dist/profiler/ui/KeepLocal.svelte.d.ts +8 -0
- package/dist/profiler/ui/Ledger.svelte +196 -0
- package/dist/profiler/ui/Ledger.svelte.d.ts +18 -0
- package/dist/profiler/ui/LocalCompare.svelte +48 -0
- package/dist/profiler/ui/LocalCompare.svelte.d.ts +8 -0
- package/dist/profiler/ui/LocalReports.svelte +68 -0
- package/dist/profiler/ui/LocalReports.svelte.d.ts +7 -0
- package/dist/profiler/ui/Login.svelte +13 -0
- package/dist/profiler/ui/Login.svelte.d.ts +12 -0
- package/dist/profiler/ui/LoginForm.svelte +42 -0
- package/dist/profiler/ui/LoginForm.svelte.d.ts +7 -0
- package/dist/profiler/ui/Message.svelte +10 -0
- package/dist/profiler/ui/Message.svelte.d.ts +12 -0
- package/dist/profiler/ui/OnThisPage.svelte +137 -0
- package/dist/profiler/ui/OnThisPage.svelte.d.ts +3 -0
- package/dist/profiler/ui/OneClock.svelte +297 -0
- package/dist/profiler/ui/OneClock.svelte.d.ts +27 -0
- package/dist/profiler/ui/Panel.svelte +10 -0
- package/dist/profiler/ui/Panel.svelte.d.ts +16 -0
- package/dist/profiler/ui/Paths.svelte +269 -0
- package/dist/profiler/ui/Paths.svelte.d.ts +15 -0
- package/dist/profiler/ui/Patterns.svelte +364 -0
- package/dist/profiler/ui/Patterns.svelte.d.ts +15 -0
- package/dist/profiler/ui/PermalinkGate.svelte +143 -0
- package/dist/profiler/ui/PermalinkGate.svelte.d.ts +10 -0
- package/dist/profiler/ui/RenderSteps.svelte +218 -0
- package/dist/profiler/ui/RenderSteps.svelte.d.ts +13 -0
- package/dist/profiler/ui/Report.svelte +28 -0
- package/dist/profiler/ui/Report.svelte.d.ts +20 -0
- package/dist/profiler/ui/ReportBody.svelte +2592 -0
- package/dist/profiler/ui/ReportBody.svelte.d.ts +21 -0
- package/dist/profiler/ui/Run.svelte +17 -0
- package/dist/profiler/ui/Run.svelte.d.ts +14 -0
- package/dist/profiler/ui/RunView.svelte +146 -0
- package/dist/profiler/ui/RunView.svelte.d.ts +10 -0
- package/dist/profiler/ui/ScoreCard.svelte +197 -0
- package/dist/profiler/ui/ScoreCard.svelte.d.ts +7 -0
- package/dist/profiler/ui/Scrub.svelte +293 -0
- package/dist/profiler/ui/Scrub.svelte.d.ts +18 -0
- package/dist/profiler/ui/SeedExplainer.svelte +193 -0
- package/dist/profiler/ui/SeedExplainer.svelte.d.ts +16 -0
- package/dist/profiler/ui/ShareLink.svelte +148 -0
- package/dist/profiler/ui/ShareLink.svelte.d.ts +8 -0
- package/dist/profiler/ui/Shell.svelte +50 -0
- package/dist/profiler/ui/Shell.svelte.d.ts +27 -0
- package/dist/profiler/ui/Sidebar.svelte +312 -0
- package/dist/profiler/ui/Sidebar.svelte.d.ts +7 -0
- package/dist/profiler/ui/Site.svelte +20 -0
- package/dist/profiler/ui/Site.svelte.d.ts +23 -0
- package/dist/profiler/ui/SiteView.svelte +385 -0
- package/dist/profiler/ui/SiteView.svelte.d.ts +27 -0
- package/dist/profiler/ui/ThemeSwitch.svelte +78 -0
- package/dist/profiler/ui/ThemeSwitch.svelte.d.ts +3 -0
- package/dist/profiler/ui/Timeline.svelte +672 -0
- package/dist/profiler/ui/Timeline.svelte.d.ts +22 -0
- package/dist/profiler/ui/Treemap.svelte +278 -0
- package/dist/profiler/ui/Treemap.svelte.d.ts +20 -0
- package/dist/profiler/ui/Upload.svelte +19 -0
- package/dist/profiler/ui/Upload.svelte.d.ts +10 -0
- package/dist/profiler/ui/UploadForm.svelte +59 -0
- package/dist/profiler/ui/UploadForm.svelte.d.ts +6 -0
- package/dist/profiler/ui/WaitingTable.svelte +55 -0
- package/dist/profiler/ui/WaitingTable.svelte.d.ts +14 -0
- package/dist/profiler/ui/Waterfall.svelte +371 -0
- package/dist/profiler/ui/Waterfall.svelte.d.ts +7 -0
- package/dist/profiler/ui/WhatIf.svelte +87 -0
- package/dist/profiler/ui/WhatIf.svelte.d.ts +18 -0
- package/dist/profiler/ui/fake-progress.svelte.d.ts +15 -0
- package/dist/profiler/ui/fake-progress.svelte.js +38 -0
- package/dist/profiler/ui/format.d.ts +20 -0
- package/dist/profiler/ui/format.js +71 -0
- package/dist/profiler/ui/permalink.d.ts +9 -0
- package/dist/profiler/ui/permalink.js +108 -0
- package/dist/profiler/ui/press.d.ts +5 -0
- package/dist/profiler/ui/press.js +19 -0
- package/dist/profiler/ui/profiler.css +650 -0
- package/dist/profiler/ui/report-data.d.ts +189 -0
- package/dist/profiler/ui/report-data.js +393 -0
- package/dist/profiler/ui/report-request.d.ts +6 -0
- package/dist/profiler/ui/report-request.js +50 -0
- package/dist/profiler/ui/row-anchor.svelte.d.ts +12 -0
- package/dist/profiler/ui/row-anchor.svelte.js +44 -0
- package/dist/profiler/ui/sort.svelte.d.ts +14 -0
- package/dist/profiler/ui/sort.svelte.js +37 -0
- package/dist/profiler/ui/store.d.ts +45 -0
- package/dist/profiler/ui/store.js +92 -0
- package/dist/profiler/visit.d.ts +389 -0
- package/dist/profiler/visit.js +1002 -0
- package/dist/report.d.ts +5 -0
- package/dist/report.js +4 -0
- package/dist/server.d.ts +11 -0
- package/dist/server.js +38 -0
- package/dist/vite.d.ts +12 -0
- package/dist/vite.js +78 -0
- package/package.json +105 -6
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
// src/profiler/dom-diff.ts
|
|
2
|
+
const TOKEN_RE = /<!--[\s\S]*?-->|<[^>]+>|[^<]+/g;
|
|
3
|
+
function tokenize_html(s) {
|
|
4
|
+
const out = [];
|
|
5
|
+
let m;
|
|
6
|
+
TOKEN_RE.lastIndex = 0;
|
|
7
|
+
while (m = TOKEN_RE.exec(s)) {
|
|
8
|
+
const t = m[0];
|
|
9
|
+
if (t[0] !== "<" && t.length > 40) out.push(...t.split(/(\s+)/).filter(Boolean));
|
|
10
|
+
else out.push(t);
|
|
11
|
+
}
|
|
12
|
+
return out;
|
|
13
|
+
}
|
|
14
|
+
const MAX_CELLS = 2e6;
|
|
15
|
+
function html_diff(a, b) {
|
|
16
|
+
if (a === b) return {
|
|
17
|
+
ops: [{
|
|
18
|
+
kind: "same",
|
|
19
|
+
text: a
|
|
20
|
+
}],
|
|
21
|
+
added: 0,
|
|
22
|
+
removed: 0,
|
|
23
|
+
truncated: false,
|
|
24
|
+
same_ratio: 1
|
|
25
|
+
};
|
|
26
|
+
const A = tokenize_html(a);
|
|
27
|
+
const B = tokenize_html(b);
|
|
28
|
+
let p = 0;
|
|
29
|
+
while (p < A.length && p < B.length && A[p] === B[p]) p++;
|
|
30
|
+
let s = 0;
|
|
31
|
+
while (s < A.length - p && s < B.length - p && A[A.length - 1 - s] === B[B.length - 1 - s]) s++;
|
|
32
|
+
const midA = A.slice(p, A.length - s);
|
|
33
|
+
const midB = B.slice(p, B.length - s);
|
|
34
|
+
const ops = [];
|
|
35
|
+
if (p) ops.push({
|
|
36
|
+
kind: "same",
|
|
37
|
+
text: A.slice(0, p).join("")
|
|
38
|
+
});
|
|
39
|
+
let truncated = false;
|
|
40
|
+
let same_mid = 0;
|
|
41
|
+
if (midA.length * midB.length > MAX_CELLS) {
|
|
42
|
+
truncated = true;
|
|
43
|
+
if (midA.length) ops.push({
|
|
44
|
+
kind: "del",
|
|
45
|
+
text: midA.join("")
|
|
46
|
+
});
|
|
47
|
+
if (midB.length) ops.push({
|
|
48
|
+
kind: "add",
|
|
49
|
+
text: midB.join("")
|
|
50
|
+
});
|
|
51
|
+
} else if (midA.length || midB.length) {
|
|
52
|
+
const n = midA.length;
|
|
53
|
+
const m = midB.length;
|
|
54
|
+
const L = new Uint32Array((n + 1) * (m + 1));
|
|
55
|
+
for (let i = n - 1; i >= 0; i--) for (let j = m - 1; j >= 0; j--) L[i * (m + 1) + j] = midA[i] === midB[j] ? L[(i + 1) * (m + 1) + j + 1] + 1 : Math.max(L[(i + 1) * (m + 1) + j], L[i * (m + 1) + j + 1]);
|
|
56
|
+
let i = 0;
|
|
57
|
+
let j = 0;
|
|
58
|
+
const push = (kind, text) => {
|
|
59
|
+
const last = ops[ops.length - 1];
|
|
60
|
+
if (last && last.kind === kind) last.text += text;
|
|
61
|
+
else ops.push({
|
|
62
|
+
kind,
|
|
63
|
+
text
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
while (i < n && j < m) if (midA[i] === midB[j]) {
|
|
67
|
+
push("same", midA[i]);
|
|
68
|
+
same_mid++;
|
|
69
|
+
i++;
|
|
70
|
+
j++;
|
|
71
|
+
} else if (L[(i + 1) * (m + 1) + j] >= L[i * (m + 1) + j + 1]) push("del", midA[i++]);
|
|
72
|
+
else push("add", midB[j++]);
|
|
73
|
+
while (i < n) push("del", midA[i++]);
|
|
74
|
+
while (j < m) push("add", midB[j++]);
|
|
75
|
+
}
|
|
76
|
+
if (s) {
|
|
77
|
+
const tail = A.slice(A.length - s).join("");
|
|
78
|
+
const last = ops[ops.length - 1];
|
|
79
|
+
if (last && last.kind === "same") last.text += tail;
|
|
80
|
+
else ops.push({
|
|
81
|
+
kind: "same",
|
|
82
|
+
text: tail
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
const added = ops.filter((o) => o.kind === "add").reduce((x, o) => x + o.text.length, 0);
|
|
86
|
+
const removed = ops.filter((o) => o.kind === "del").reduce((x, o) => x + o.text.length, 0);
|
|
87
|
+
const longer = Math.max(A.length, B.length) || 1;
|
|
88
|
+
return {
|
|
89
|
+
ops,
|
|
90
|
+
added,
|
|
91
|
+
removed,
|
|
92
|
+
truncated,
|
|
93
|
+
same_ratio: Math.round((p + s + same_mid) / longer * 1e3) / 1e3
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
/** Layout-shift rectangles normalized to the viewport, biggest shift first; boxes outside the
|
|
97
|
+
* viewport are clipped, a missing rect is skipped. */
|
|
98
|
+
function shift_boxes(shifts, viewport) {
|
|
99
|
+
const [vw, vh] = viewport ?? [1, 1];
|
|
100
|
+
if (!(vw > 0 && vh > 0)) return [];
|
|
101
|
+
const clamp = (n) => Math.max(0, Math.min(1, n));
|
|
102
|
+
const out = [];
|
|
103
|
+
for (const s of shifts) {
|
|
104
|
+
const to = s.to ?? s.from;
|
|
105
|
+
if (!to) continue;
|
|
106
|
+
const from = s.from ?? to;
|
|
107
|
+
out.push({
|
|
108
|
+
x: clamp(to[0] / vw),
|
|
109
|
+
y: clamp(to[1] / vh),
|
|
110
|
+
w: clamp(to[2] / vw),
|
|
111
|
+
h: clamp(to[3] / vh),
|
|
112
|
+
fx: clamp(from[0] / vw),
|
|
113
|
+
fy: clamp(from[1] / vh),
|
|
114
|
+
value: s.value,
|
|
115
|
+
t: s.t,
|
|
116
|
+
...s.fp ? { fp: s.fp } : {}
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
return out.sort((a, b) => b.value - a.value);
|
|
120
|
+
}
|
|
121
|
+
export { html_diff, shift_boxes, tokenize_html };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { Timeline } from "./timeline.js";
|
|
2
|
+
import { LedgerLine } from "./ledger.js";
|
|
3
|
+
import { Pattern } from "./patterns.js";
|
|
4
|
+
export interface DrillNode {
|
|
5
|
+
label: string;
|
|
6
|
+
ms: number;
|
|
7
|
+
/** what the time was: CPU, waiting on calls, a gap nothing recorded, or a mix (a phase) */
|
|
8
|
+
kind: "render" | "phase" | "lane" | "cpu" | "wait" | "gap" | "line" | "more";
|
|
9
|
+
/** a place to open: `file:line` */
|
|
10
|
+
at?: string;
|
|
11
|
+
/** calls behind a wait row */
|
|
12
|
+
calls?: number;
|
|
13
|
+
/** a CPU owner row: its lowest and highest ms over the profiled renders (its noise) */
|
|
14
|
+
runs?: [number, number];
|
|
15
|
+
/** a CPU owner row: its ms in the COLD first render (module load, compile, first-call caches),
|
|
16
|
+
* when that stands out against its warm renders */
|
|
17
|
+
cold?: number;
|
|
18
|
+
/** an HTTP wait row, on the calls' OWN clocks (summed over its calls, not the shared wall):
|
|
19
|
+
* until the headers came, what the other side's Server-Timing claims of that (`theirs_ms`, over
|
|
20
|
+
* `told` of the calls), the rest (`network_ms`: the network, TLS, their framework, a queue — or
|
|
21
|
+
* all of it when they told nothing), and reading the body */
|
|
22
|
+
split?: {
|
|
23
|
+
calls: number;
|
|
24
|
+
theirs_ms?: number;
|
|
25
|
+
told?: number;
|
|
26
|
+
network_ms: number;
|
|
27
|
+
body_ms: number;
|
|
28
|
+
top?: {
|
|
29
|
+
name: string;
|
|
30
|
+
ms: number;
|
|
31
|
+
}[];
|
|
32
|
+
};
|
|
33
|
+
/** the page-data keys this row's lines feed (lineage), and whether anything reads each */
|
|
34
|
+
fills?: {
|
|
35
|
+
key: string;
|
|
36
|
+
read: boolean;
|
|
37
|
+
}[];
|
|
38
|
+
/** a wait row: the ms nothing else was in flight (the render waited on this endpoint alone);
|
|
39
|
+
* 0 = always beside other calls, so a faster answer alone saves nothing */
|
|
40
|
+
alone?: number;
|
|
41
|
+
/** WHY: the slow patterns (their kinds) found on this row's line, or its lines' — the where and
|
|
42
|
+
* the why in one tree */
|
|
43
|
+
why?: string[];
|
|
44
|
+
/** a line row: its code, trimmed — how a compare tells a line an edit above renumbered (the same
|
|
45
|
+
* code at another number) from one that changed */
|
|
46
|
+
code?: string;
|
|
47
|
+
children?: DrillNode[];
|
|
48
|
+
}
|
|
49
|
+
/** `lib/x.ts:42` or `lib/x.ts:42:7` → the file and the line; undefined when `at` names no line */
|
|
50
|
+
export declare function at_line(at: string): {
|
|
51
|
+
file: string;
|
|
52
|
+
line: number;
|
|
53
|
+
} | undefined;
|
|
54
|
+
/** `GET host/api/product/P12` → `GET host/api/product/:id`: one row per endpoint, not per id */
|
|
55
|
+
export declare function call_group(label: string): string;
|
|
56
|
+
/**
|
|
57
|
+
* WHAT A ROW WAS FOR: the page-data keys its lines feed. A wait or a computation whose line (its
|
|
58
|
+
* own, or one of the lines under it) is among a key's source lines in its load (lineage +
|
|
59
|
+
* `key_sources`) fills that key. When every key it fills is read by nothing, the row's whole time
|
|
60
|
+
* bought nothing.
|
|
61
|
+
*/
|
|
62
|
+
export declare function tag_fills(root: DrillNode, keys: readonly {
|
|
63
|
+
key: string;
|
|
64
|
+
from: string | null;
|
|
65
|
+
lines?: number[];
|
|
66
|
+
names?: string[];
|
|
67
|
+
verdict: string;
|
|
68
|
+
}[]): void;
|
|
69
|
+
/** THE WORK FOR NOTHING: the rows of one render whose every key is unread (the topmost such row on
|
|
70
|
+
* each path, so nothing counts twice), biggest first */
|
|
71
|
+
export declare function unread_rows(root: DrillNode | undefined): {
|
|
72
|
+
label: string;
|
|
73
|
+
ms: number;
|
|
74
|
+
kind: DrillNode["kind"];
|
|
75
|
+
keys: string[];
|
|
76
|
+
at?: string;
|
|
77
|
+
}[];
|
|
78
|
+
/** a garbage maker, as the GC attribution names it: the line it is charged to and its pause time */
|
|
79
|
+
export type GcMakerLite = {
|
|
80
|
+
name: string;
|
|
81
|
+
url: string;
|
|
82
|
+
line: number;
|
|
83
|
+
at?: {
|
|
84
|
+
path: string;
|
|
85
|
+
line: number;
|
|
86
|
+
};
|
|
87
|
+
gc_ms: number;
|
|
88
|
+
};
|
|
89
|
+
export declare function build_drill(tl: Timeline, ledger?: readonly LedgerLine[], patterns?: readonly Pick<Pattern, "kind" | "sites">[], gc_makers?: readonly GcMakerLite[], renders_of?: ReadonlyMap<string, number>, owner_runs?: Readonly<Record<string, number[]>>, cold_owners?: ReadonlyMap<string, number>, wait_runs?: Readonly<Record<string, number[]>>): DrillNode | undefined;
|