dev3000 0.0.191 → 0.0.193
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/README.md +19 -2
- package/dist/runtime/browser-capture.d.ts +117 -0
- package/dist/runtime/browser-capture.d.ts.map +1 -0
- package/dist/runtime/browser-capture.js +274 -0
- package/dist/runtime/browser-capture.js.map +1 -0
- package/dist/runtime/browser-compare.d.ts +91 -0
- package/dist/runtime/browser-compare.d.ts.map +1 -0
- package/dist/runtime/browser-compare.js +129 -0
- package/dist/runtime/browser-compare.js.map +1 -0
- package/dist/runtime/browser-metrics.d.ts +1 -0
- package/dist/runtime/browser-metrics.d.ts.map +1 -1
- package/dist/runtime/browser-metrics.js +1 -1
- package/dist/runtime/browser-metrics.js.map +1 -1
- package/dist/runtime/chrome-isolation.d.ts +1 -0
- package/dist/runtime/chrome-isolation.d.ts.map +1 -1
- package/dist/runtime/chrome-isolation.js +4 -1
- package/dist/runtime/chrome-isolation.js.map +1 -1
- package/dist/runtime/cli.js +6 -2
- package/dist/runtime/cli.js.map +1 -1
- package/dist/runtime/desktop-mcp.d.ts +12 -1
- package/dist/runtime/desktop-mcp.d.ts.map +1 -1
- package/dist/runtime/desktop-mcp.js +18 -0
- package/dist/runtime/desktop-mcp.js.map +1 -1
- package/dist/runtime/managed-cdp.d.ts +10 -0
- package/dist/runtime/managed-cdp.d.ts.map +1 -0
- package/dist/runtime/managed-cdp.js +80 -0
- package/dist/runtime/managed-cdp.js.map +1 -0
- package/dist/runtime/package-manager.d.ts +13 -0
- package/dist/runtime/package-manager.d.ts.map +1 -0
- package/dist/runtime/package-manager.js +69 -0
- package/dist/runtime/package-manager.js.map +1 -0
- package/dist/runtime/runtime.d.ts +3 -0
- package/dist/runtime/runtime.d.ts.map +1 -1
- package/dist/runtime/runtime.js +6 -13
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/runtime/sandbox-cleanup.d.ts.map +1 -1
- package/dist/runtime/sandbox-cleanup.js +33 -5
- package/dist/runtime/sandbox-cleanup.js.map +1 -1
- package/dist/runtime/sandbox-command.d.ts.map +1 -1
- package/dist/runtime/sandbox-command.js +12 -1
- package/dist/runtime/sandbox-command.js.map +1 -1
- package/dist/runtime/sandbox-env.d.ts +7 -0
- package/dist/runtime/sandbox-env.d.ts.map +1 -0
- package/dist/runtime/sandbox-env.js +22 -0
- package/dist/runtime/sandbox-env.js.map +1 -0
- package/dist/runtime/sandbox-git.d.ts +19 -0
- package/dist/runtime/sandbox-git.d.ts.map +1 -0
- package/dist/runtime/sandbox-git.js +42 -0
- package/dist/runtime/sandbox-git.js.map +1 -0
- package/dist/runtime/sandbox-local-harness.d.ts.map +1 -1
- package/dist/runtime/sandbox-local-harness.js +15 -2
- package/dist/runtime/sandbox-local-harness.js.map +1 -1
- package/dist/runtime/sandbox-ports.d.ts +6 -0
- package/dist/runtime/sandbox-ports.d.ts.map +1 -0
- package/dist/runtime/sandbox-ports.js +11 -0
- package/dist/runtime/sandbox-ports.js.map +1 -0
- package/dist/runtime/sandbox-sessions.d.ts +2 -0
- package/dist/runtime/sandbox-sessions.d.ts.map +1 -1
- package/dist/runtime/sandbox-sessions.js +6 -0
- package/dist/runtime/sandbox-sessions.js.map +1 -1
- package/dist/runtime/sandbox-setup.d.ts +2 -1
- package/dist/runtime/sandbox-setup.d.ts.map +1 -1
- package/dist/runtime/sandbox-setup.js +10 -3
- package/dist/runtime/sandbox-setup.js.map +1 -1
- package/dist/runtime/sandbox-workspace.d.ts +1 -1
- package/dist/runtime/sandbox-workspace.d.ts.map +1 -1
- package/dist/runtime/sandbox-workspace.js +1 -1
- package/dist/runtime/sandbox-workspace.js.map +1 -1
- package/dist/runtime/sandbox.d.ts +2 -0
- package/dist/runtime/sandbox.d.ts.map +1 -1
- package/dist/runtime/sandbox.js +54 -27
- package/dist/runtime/sandbox.js.map +1 -1
- package/dist/runtime/workspace-client.d.ts.map +1 -1
- package/dist/runtime/workspace-client.js +5 -1
- package/dist/runtime/workspace-client.js.map +1 -1
- package/package.json +1 -1
- package/skills/d3k/SKILL.md +13 -1
package/README.md
CHANGED
|
@@ -98,9 +98,11 @@ d3k browser snapshot -i
|
|
|
98
98
|
d3k events --level error
|
|
99
99
|
```
|
|
100
100
|
|
|
101
|
-
Development environment values pass through launcher memory into the sandbox; d3k does not save a local env file or project checkout. The laptop keeps d3k, its browser profile, and session metadata. Other agents require their own authentication. Automatic creation
|
|
101
|
+
Development environment values pass through launcher memory into the sandbox; d3k does not save a local env file or project checkout. The laptop keeps d3k, its browser profile, and session metadata. Other agents require their own authentication. Automatic creation supports public GitHub repositories and private repositories already onboarded to Vercel managed Sandbox Git. d3k detects an existing `git:write` Bound for the exact linked repository and requests brokered credentials using your configured Git name and email. The project must have the Sandbox Git credentials and signed-commits flags enabled and the Vercel GitHub App installed. The current platform warm-pool workaround requires six vCPUs for these sessions; effective team limits must permit that shape. Use `--vcpus 16` for a large monorepo needing 32 GiB of memory; Vercel assigns 2 GiB per vCPU. Resource overrides are saved for resume and apply when the next compute session starts. d3k does not change authorization policies or copy laptop GitHub credentials into the VM. `--attach my-dev` remains available for a provisioned sandbox. For private npm packages, create the sandbox with `--managed-npm`. Vercel uses the team’s configured npm credentials at the network layer; the credential is not copied from your laptop or exposed to sandbox processes. This requires managed npm availability and configured team npm credentials, and is retained on resume. It cannot be added to an existing sandbox. Development-environment access is checked before allocating compute; if Vercel requires fresh authentication, d3k prints the project-scoped command to complete it. The sandbox CLI reserves port 3000 for the app and exposes its authenticated proxy on a separate infrastructure port, so project startup checks do not mistake d3k for an existing dev server.
|
|
102
102
|
|
|
103
|
-
|
|
103
|
+
Project dependencies use the repository's package manager: `packageManager` takes precedence, followed by Bun, pnpm, Yarn, or npm lockfiles (npm is used when none is identified). Workspace installs run from the directory declaring that manager or containing its lockfile. Conflicting lockfiles require a `packageManager` declaration or an explicit command. A CLI `--install-command` overrides the Vercel project install setting; either explicit command runs from the project directory.
|
|
104
|
+
|
|
105
|
+
Use `--branch feature`, `--command 'pnpm run dev'`, or `--install-command 'pnpm install'` to override project defaults. Dev commands must honor `PORT`, which identifies the private upstream port. `--no-shell` retains the local browser companion without opening a shell; `--headless` runs local Chrome headlessly. Sandbox compute and Gateway keys both default to a 60-minute lifetime; `--timeout <minutes>` changes both equally. Exiting stops the runtime and any sandbox created by this invocation, preserving its filesystem for `--attach <name>`. An attached sandbox stays running when the companion exits. Closing the dedicated Chrome also ends the session.
|
|
104
106
|
|
|
105
107
|
Chrome loads a stable local HTTPS origin: `https://<project>.d3k.localhost`. Use `--hostname songbook` for `https://songbook.d3k.localhost`. Canonical Portless must be ready on the laptop; no Portless installation is needed in the VM. A loopback streaming proxy forwards app traffic over verified HTTPS to the sandbox, preserving the local Host and forwarded origin, redirects, cookies, and WebSockets. The public sandbox app endpoint requires a fresh session token injected by the companion. Add the exact local callback URL to your auth provider's redirect allowlist (for example, `https://songbook.d3k.localhost/api/auth/callback`). A persistent outbound authenticated WSS connection carries CDP back to the VM; no externally reachable laptop listener, VPN, screen streaming, or file synchronization is needed. The VM exposes CDP discovery only on loopback. An in-VM streaming proxy preserves HTTP and application WebSockets and validates the exact app Origin before adapting Next.js HMR upgrades. Remote source edits can update local Chrome without a reload or project configuration change.
|
|
106
108
|
|
|
@@ -207,6 +209,21 @@ These are explicit snapshots with provisional vitals, using the existing browser
|
|
|
207
209
|
|
|
208
210
|
The core commands are `start`, `stop`, `status`, `events`, `logs`, `errors`, `browser`, `portless status/setup`, `sandbox`, `mcp`, and explicit `upgrade`. Root options are for sandbox startup; local options belong after `start`. Unsupported options fail instead of being silently ignored.
|
|
209
211
|
|
|
212
|
+
For an explicit loading or jank investigation, capture a baseline **before editing**, then repeat the same scenario after the edit:
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
d3k browser capture https://my-app.localhost/about --output /tmp/about-before --ready '#content' --actions '[{"click":"#expand"},{"scroll":600}]'
|
|
216
|
+
# Make the intended code change, wait for HMR/build readiness, then repeat unchanged:
|
|
217
|
+
d3k browser capture https://my-app.localhost/about --output /tmp/about-after --ready '#content' --actions '[{"click":"#expand"},{"scroll":600}]'
|
|
218
|
+
d3k browser compare /tmp/about-before /tmp/about-after --output /tmp/about-comparison.html
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
Capture uses Chrome 153+'s native AV1 MP4 API in the existing managed browser: no extra browser, encoder installation or Chrome download. It warms the page once and records three runs by default (`--runs 1..5`), starting before navigation. `--ready` waits for a CSS selector after the load event; `--settle-ms 250..5000` defaults to 1000 before and after actions. Actions are repeatable CSS `click`, pixel `scroll`, or selector `waitFor` steps (up to ten); clicks are trusted browser input. Actions must stay in the same document; capture another page as a separate scenario. Scenarios that mutate application state need a repeatable reset or idempotent actions; d3k does not reset application data between runs.
|
|
222
|
+
|
|
223
|
+
Each new output directory contains requested videos and `capture.json`: navigation/paint timing, provisional LCP and CLS, long tasks, long animation frames, main-thread animation gaps and observed interaction durations. Existing directories are never overwritten. Browser IO streams are exported by the client without granting Chrome access to arbitrary output paths. For desktop MCP `sandbox_browser`, output paths are on the **laptop companion**; CLI commands running inside a sandbox export there instead. Comparison needs both directories on the same machine; move the HTML together with its referenced videos when sharing. Videos can contain authenticated page data; exports are explicit and remain until deleted.
|
|
224
|
+
|
|
225
|
+
The comparison report has synchronized side-by-side playback, run selection, seeking and slow playback, plus median/min/max metrics and comparability warnings. Navigation alignment is estimated from CDP timing, not frame-exact. Matching settings do not guarantee matching cache, CPU or network conditions; use repeatable production builds for performance decisions. Main-thread animation gaps are not compositor dropped-frame counts, observed interaction maxima are not INP, and unavailable values stay `null`. This workflow supplies evidence rather than an automatic Core Web Vitals pass/fail.
|
|
226
|
+
|
|
210
227
|
The previous local runtime, terminal UI, tmux agent launcher/resume, built-in skill catalog/installer, `fix`, `crawl`, and `cdp-port` have been removed. Replace `d3k -t` with `d3k start`, file-backed `logs`/`errors` with live timeline reads, and `d3k agent-browser` with `d3k browser`. Use `start --command` instead of `--port`/`--script`; Portless assigns local ports. Harnesses can run independently or through `--harness`. Screenshot capture is explicit through `browser screenshot`.
|
|
211
228
|
|
|
212
229
|
The npm package ships JavaScript, requires Node.js 24+, and exposes the same runtime through all three executable names. Standalone binaries are not yet distributed. Existing files from older versions are left untouched but are no longer read.
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { type BrowserInvoke, connectManagedCdp, type ManagedCdp } from "./managed-cdp.js";
|
|
2
|
+
type Action = {
|
|
3
|
+
click: string;
|
|
4
|
+
} | {
|
|
5
|
+
scroll: number;
|
|
6
|
+
} | {
|
|
7
|
+
waitFor: string;
|
|
8
|
+
};
|
|
9
|
+
export interface CaptureOptions {
|
|
10
|
+
url: string;
|
|
11
|
+
output: string;
|
|
12
|
+
runs: number;
|
|
13
|
+
settleMs: number;
|
|
14
|
+
ready?: string;
|
|
15
|
+
actions: Action[];
|
|
16
|
+
}
|
|
17
|
+
export declare function parseCaptureOptions(args: string[]): CaptureOptions;
|
|
18
|
+
/** Bounded aggregate probes; animation gaps measure main-thread scheduling, not compositor frame loss. */
|
|
19
|
+
export declare function jankObserverScript(key: string): string;
|
|
20
|
+
/** Stream to a new file with a hard size cap; the browser needs no output-path access. */
|
|
21
|
+
export declare function saveRecording(cdp: ManagedCdp, path: string): Promise<number>;
|
|
22
|
+
export declare function captureBrowserLoading(args: string[], invoke: BrowserInvoke, connect?: typeof connectManagedCdp): Promise<{
|
|
23
|
+
version: number;
|
|
24
|
+
capturedAt: string;
|
|
25
|
+
scenario: {
|
|
26
|
+
url: string;
|
|
27
|
+
identity: string;
|
|
28
|
+
ready: string | null;
|
|
29
|
+
actions: Action[];
|
|
30
|
+
settleMs: number;
|
|
31
|
+
warmups: number;
|
|
32
|
+
cache: string;
|
|
33
|
+
throttling: string;
|
|
34
|
+
frameRate: number;
|
|
35
|
+
};
|
|
36
|
+
browser: unknown;
|
|
37
|
+
runs: {
|
|
38
|
+
video: string;
|
|
39
|
+
bytes: number;
|
|
40
|
+
triggerOffsetMs: number;
|
|
41
|
+
viewport: any;
|
|
42
|
+
metrics: {
|
|
43
|
+
url: string;
|
|
44
|
+
capturedAt: unknown;
|
|
45
|
+
measurement: {
|
|
46
|
+
type: string;
|
|
47
|
+
cache: string;
|
|
48
|
+
throttling: string;
|
|
49
|
+
observation: string;
|
|
50
|
+
observerStartedAtMs: number | null;
|
|
51
|
+
observedUntilMs: number | null;
|
|
52
|
+
provisional: boolean;
|
|
53
|
+
};
|
|
54
|
+
navigation: {
|
|
55
|
+
type: {} | null;
|
|
56
|
+
dnsMs: number | null;
|
|
57
|
+
connectMs: number | null;
|
|
58
|
+
tlsMs: number | null;
|
|
59
|
+
ttfbMs: number | null;
|
|
60
|
+
serverWaitMs: number | null;
|
|
61
|
+
downloadMs: number | null;
|
|
62
|
+
domInteractiveMs: number | null;
|
|
63
|
+
domContentLoadedMs: number | null;
|
|
64
|
+
loadMs: number | null;
|
|
65
|
+
redirectMs: number | null;
|
|
66
|
+
visibleRedirectCount: {} | null;
|
|
67
|
+
transferBytes: {} | null;
|
|
68
|
+
encodedBodyBytes: {} | null;
|
|
69
|
+
decodedBodyBytes: {} | null;
|
|
70
|
+
protocol: {} | null;
|
|
71
|
+
};
|
|
72
|
+
paint: {
|
|
73
|
+
firstPaintMs: number | null;
|
|
74
|
+
fcpMs: number | null;
|
|
75
|
+
};
|
|
76
|
+
webVitals: {
|
|
77
|
+
lcp: {
|
|
78
|
+
valueMs: number;
|
|
79
|
+
element: string | null;
|
|
80
|
+
url: string | null;
|
|
81
|
+
} | {
|
|
82
|
+
valueMs: number | null;
|
|
83
|
+
element: string | undefined;
|
|
84
|
+
url: string | null;
|
|
85
|
+
} | null;
|
|
86
|
+
cls: number | null;
|
|
87
|
+
inp: {} | null;
|
|
88
|
+
};
|
|
89
|
+
longTasks: {
|
|
90
|
+
count: number;
|
|
91
|
+
totalMs: number;
|
|
92
|
+
maxMs: number;
|
|
93
|
+
} | null;
|
|
94
|
+
resources: {
|
|
95
|
+
retainedEntries: unknown;
|
|
96
|
+
summarizedEntries: number;
|
|
97
|
+
truncated: boolean;
|
|
98
|
+
byInitiator: Record<string, number>;
|
|
99
|
+
transferBytes: number;
|
|
100
|
+
slowest: {
|
|
101
|
+
initiatorType: string;
|
|
102
|
+
transferSize: number;
|
|
103
|
+
encodedBodySize: number;
|
|
104
|
+
decodedBodySize: number;
|
|
105
|
+
name: string;
|
|
106
|
+
duration: number | null;
|
|
107
|
+
}[];
|
|
108
|
+
};
|
|
109
|
+
notes: string[];
|
|
110
|
+
};
|
|
111
|
+
jank: any;
|
|
112
|
+
}[];
|
|
113
|
+
notes: string[];
|
|
114
|
+
output: string;
|
|
115
|
+
}>;
|
|
116
|
+
export {};
|
|
117
|
+
//# sourceMappingURL=browser-capture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-capture.d.ts","sourceRoot":"","sources":["../../src/runtime/browser-capture.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,aAAa,EAAE,iBAAiB,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAGzF,KAAK,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAA;AAC1E,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,EAAE,CAAA;CAClB;AAGD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,cAAc,CAyClE;AAQD,0GAA0G;AAC1G,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAwBtD;AAyCD,0FAA0F;AAC1F,wBAAsB,aAAa,CAAC,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAsBlF;AAED,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,2BAAoB;;;;QAwFtG,GAAG;QACH,QAAQ;QACR,KAAK;QACL,OAAO;QACP,QAAQ;QACR,OAAO;QACP,KAAK;QACL,UAAU;QACV,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiChB"}
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
2
|
+
import { mkdir, open, writeFile } from "node:fs/promises";
|
|
3
|
+
import { isAbsolute, join } from "node:path";
|
|
4
|
+
import { metricsObserverScript, snapshotScript, summarizeBrowserMetrics } from "./browser-metrics.js";
|
|
5
|
+
import { connectManagedCdp } from "./managed-cdp.js";
|
|
6
|
+
import { safeNetworkUrl } from "./network-evidence.js";
|
|
7
|
+
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
8
|
+
export function parseCaptureOptions(args) {
|
|
9
|
+
const url = args[0];
|
|
10
|
+
const options = {};
|
|
11
|
+
for (let index = 1; index < args.length; index += 2) {
|
|
12
|
+
const name = args[index];
|
|
13
|
+
const value = args[index + 1];
|
|
14
|
+
if (!["--output", "--runs", "--settle-ms", "--ready", "--actions"].includes(name) ||
|
|
15
|
+
value === undefined ||
|
|
16
|
+
options[name] !== undefined)
|
|
17
|
+
throw new Error("Use browser capture URL --output ABSOLUTE_DIRECTORY [--runs 3] [--ready CSS] [--settle-ms 1000] [--actions JSON]");
|
|
18
|
+
options[name] = value;
|
|
19
|
+
}
|
|
20
|
+
const parsed = new URL(url);
|
|
21
|
+
if (!["http:", "https:"].includes(parsed.protocol) || parsed.username || parsed.password)
|
|
22
|
+
throw new Error("Capture URL must use HTTP(S) without embedded credentials");
|
|
23
|
+
if (!options["--output"] || !isAbsolute(options["--output"]))
|
|
24
|
+
throw new Error("Capture requires an absolute output directory");
|
|
25
|
+
const runs = Number(options["--runs"] ?? 3);
|
|
26
|
+
const settleMs = Number(options["--settle-ms"] ?? 1000);
|
|
27
|
+
if (!Number.isInteger(runs) || runs < 1 || runs > 5)
|
|
28
|
+
throw new Error("Capture runs must be 1–5");
|
|
29
|
+
if (!Number.isInteger(settleMs) || settleMs < 250 || settleMs > 5000)
|
|
30
|
+
throw new Error("Capture settle-ms must be 250–5000");
|
|
31
|
+
const actions = JSON.parse(options["--actions"] || "[]");
|
|
32
|
+
if (!Array.isArray(actions) || actions.length > 10)
|
|
33
|
+
throw new Error("Capture supports up to ten actions");
|
|
34
|
+
for (const action of actions) {
|
|
35
|
+
if (!action || typeof action !== "object" || Object.keys(action).length !== 1)
|
|
36
|
+
throw new Error("Invalid capture action");
|
|
37
|
+
if ("scroll" in action) {
|
|
38
|
+
if (!Number.isInteger(action.scroll) || Math.abs(action.scroll) > 5000 || !action.scroll)
|
|
39
|
+
throw new Error("Scroll must be a nonzero pixel distance within ±5000");
|
|
40
|
+
}
|
|
41
|
+
else if ("click" in action || "waitFor" in action) {
|
|
42
|
+
const selector = "click" in action ? action.click : action.waitFor;
|
|
43
|
+
if (typeof selector !== "string" || !selector.trim() || selector.length > 2000)
|
|
44
|
+
throw new Error("Actions require a CSS selector");
|
|
45
|
+
}
|
|
46
|
+
else
|
|
47
|
+
throw new Error("Actions support click, scroll and waitFor");
|
|
48
|
+
}
|
|
49
|
+
return { url: parsed.href, output: options["--output"], runs, settleMs, ready: options["--ready"], actions };
|
|
50
|
+
}
|
|
51
|
+
async function evaluate(cdp, expression) {
|
|
52
|
+
const result = await cdp.send("Runtime.evaluate", { expression, returnByValue: true });
|
|
53
|
+
if (result.exceptionDetails)
|
|
54
|
+
throw new Error("Page evaluation failed during capture");
|
|
55
|
+
return result.result?.value;
|
|
56
|
+
}
|
|
57
|
+
/** Bounded aggregate probes; animation gaps measure main-thread scheduling, not compositor frame loss. */
|
|
58
|
+
export function jankObserverScript(key) {
|
|
59
|
+
return `(() => {
|
|
60
|
+
const state = { visibility: document.visibilityState, frames: 0, maxFrameGapMs: 0, gapsOver50Ms: 0, maxInteractionMs: null, longAnimationFrames: null };
|
|
61
|
+
globalThis[${JSON.stringify(key)}] = state;
|
|
62
|
+
let previous, frame; const observers = [];
|
|
63
|
+
function tick(now) { if (previous !== undefined) { const gap = now - previous; state.maxFrameGapMs = Math.max(state.maxFrameGapMs, gap); if (gap > 50) state.gapsOver50Ms++; } previous = now; state.frames++; frame = requestAnimationFrame(tick); }
|
|
64
|
+
frame = requestAnimationFrame(tick);
|
|
65
|
+
if (PerformanceObserver.supportedEntryTypes.includes('long-animation-frame')) {
|
|
66
|
+
state.longAnimationFrames = { count: 0, totalBlockingMs: 0, maxDurationMs: 0, slowestScripts: [] };
|
|
67
|
+
const observer = new PerformanceObserver(list => { for (const entry of list.getEntries()) {
|
|
68
|
+
state.longAnimationFrames.count++; state.longAnimationFrames.totalBlockingMs += entry.blockingDuration; state.longAnimationFrames.maxDurationMs = Math.max(state.longAnimationFrames.maxDurationMs, entry.duration);
|
|
69
|
+
for (const script of entry.scripts || []) state.longAnimationFrames.slowestScripts.push({durationMs:script.duration, sourceUrl:(script.sourceURL || '').slice(0,4000), functionName:(script.sourceFunctionName || '').slice(0,200), sourceCharPosition:script.sourceCharPosition});
|
|
70
|
+
state.longAnimationFrames.slowestScripts.sort((a,b)=>b.durationMs-a.durationMs); state.longAnimationFrames.slowestScripts.length = Math.min(5,state.longAnimationFrames.slowestScripts.length);
|
|
71
|
+
} });
|
|
72
|
+
observer.observe({type: 'long-animation-frame', buffered: true}); observers.push(observer);
|
|
73
|
+
}
|
|
74
|
+
if (PerformanceObserver.supportedEntryTypes.includes('event')) {
|
|
75
|
+
const observer = new PerformanceObserver(list => { for (const entry of list.getEntries()) if (entry.interactionId) state.maxInteractionMs = Math.max(state.maxInteractionMs || 0, entry.duration); });
|
|
76
|
+
observer.observe({type: 'event', buffered: true, durationThreshold: 16}); observers.push(observer);
|
|
77
|
+
}
|
|
78
|
+
document.addEventListener('visibilitychange', visibility);
|
|
79
|
+
function visibility() { if (document.visibilityState !== 'visible') state.visibility = 'hidden-during-capture'; }
|
|
80
|
+
state.dispose = () => { cancelAnimationFrame(frame); for (const observer of observers) observer.disconnect(); document.removeEventListener('visibilitychange', visibility); delete globalThis[${JSON.stringify(key)}]; };
|
|
81
|
+
})()`;
|
|
82
|
+
}
|
|
83
|
+
async function waitFor(cdp, expression) {
|
|
84
|
+
const deadline = performance.now() + 15000;
|
|
85
|
+
while (!(await evaluate(cdp, expression))) {
|
|
86
|
+
if (performance.now() >= deadline)
|
|
87
|
+
throw new Error("Capture readiness timed out after 15000ms");
|
|
88
|
+
await delay(100);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
async function navigate(cdp, options) {
|
|
92
|
+
const previousOrigin = await evaluate(cdp, "performance.timeOrigin");
|
|
93
|
+
const result = await cdp.send("Page.navigate", { url: options.url });
|
|
94
|
+
if (result.errorText)
|
|
95
|
+
throw new Error(`Capture navigation failed: ${result.errorText}`);
|
|
96
|
+
await waitFor(cdp, `location.href !== 'about:blank' && document.readyState === 'complete' && performance.timeOrigin !== ${JSON.stringify(previousOrigin)}`);
|
|
97
|
+
if (options.ready)
|
|
98
|
+
await waitFor(cdp, `!!document.querySelector(${JSON.stringify(options.ready)})`);
|
|
99
|
+
}
|
|
100
|
+
async function performActions(cdp, actions) {
|
|
101
|
+
for (const action of actions) {
|
|
102
|
+
if ("waitFor" in action) {
|
|
103
|
+
await waitFor(cdp, `!!document.querySelector(${JSON.stringify(action.waitFor)})`);
|
|
104
|
+
}
|
|
105
|
+
else if ("scroll" in action) {
|
|
106
|
+
const point = (await evaluate(cdp, `({x:innerWidth/2,y:innerHeight/2})`));
|
|
107
|
+
await cdp.send("Input.dispatchMouseEvent", { type: "mouseWheel", ...point, deltaX: 0, deltaY: action.scroll });
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
const point = (await evaluate(cdp, `(() => { const elements = document.querySelectorAll(${JSON.stringify(action.click)}); if (elements.length !== 1) return null; const element = elements[0]; element.scrollIntoView({block:'center',behavior:'instant'}); const r = element.getBoundingClientRect(); const x = r.x+r.width/2, y = r.y+r.height/2; const hit = document.elementFromPoint(x,y); return r.width && r.height && hit && (hit === element || element.contains(hit)) ? {x,y} : null; })()`));
|
|
111
|
+
if (!point)
|
|
112
|
+
throw new Error(`Capture click needs one visible, unobstructed match: ${action.click}`);
|
|
113
|
+
await cdp.send("Input.dispatchMouseEvent", { type: "mousePressed", ...point, button: "left", clickCount: 1 });
|
|
114
|
+
await cdp.send("Input.dispatchMouseEvent", { type: "mouseReleased", ...point, button: "left", clickCount: 1 });
|
|
115
|
+
}
|
|
116
|
+
await delay(250);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/** Stream to a new file with a hard size cap; the browser needs no output-path access. */
|
|
120
|
+
export async function saveRecording(cdp, path) {
|
|
121
|
+
const { stream } = await cdp.send("Page.stopScreenRecording");
|
|
122
|
+
if (typeof stream !== "string" || !stream)
|
|
123
|
+
throw new Error("Chrome returned no recording stream");
|
|
124
|
+
let file;
|
|
125
|
+
let bytes = 0;
|
|
126
|
+
try {
|
|
127
|
+
file = await open(path, "wx", 0o600);
|
|
128
|
+
while (true) {
|
|
129
|
+
const result = await cdp.send("IO.read", { handle: stream, size: 1024 * 1024 });
|
|
130
|
+
if (typeof result.data !== "string")
|
|
131
|
+
throw new Error("Invalid Chrome recording chunk");
|
|
132
|
+
const chunk = Buffer.from(result.data, result.base64Encoded ? "base64" : "utf8");
|
|
133
|
+
bytes += chunk.length;
|
|
134
|
+
if (bytes > 128 * 1024 * 1024)
|
|
135
|
+
throw new Error("Recording exceeded 128MiB; reduce the scenario duration");
|
|
136
|
+
await file.writeFile(chunk);
|
|
137
|
+
if (result.eof)
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
if (!bytes)
|
|
141
|
+
throw new Error("Chrome returned an empty recording");
|
|
142
|
+
return bytes;
|
|
143
|
+
}
|
|
144
|
+
finally {
|
|
145
|
+
await file?.close();
|
|
146
|
+
await cdp.send("IO.close", { handle: stream }).catch(() => { });
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
export async function captureBrowserLoading(args, invoke, connect = connectManagedCdp) {
|
|
150
|
+
const options = parseCaptureOptions(args);
|
|
151
|
+
// A new directory prevents overwriting baseline evidence or mixing old and new runs.
|
|
152
|
+
await mkdir(options.output, { mode: 0o700 });
|
|
153
|
+
const connection = await connect(invoke);
|
|
154
|
+
let runDeadline = Number.POSITIVE_INFINITY;
|
|
155
|
+
const cdp = {
|
|
156
|
+
close: connection.close,
|
|
157
|
+
send: async (method, params) => {
|
|
158
|
+
if (performance.now() > runDeadline)
|
|
159
|
+
throw new Error("Capture exceeded the 60000ms run limit");
|
|
160
|
+
return connection.send(method, params);
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
const key = `__d3kCapture_${randomUUID().replaceAll("-", "")}`;
|
|
164
|
+
const jankKey = `${key}_jank`;
|
|
165
|
+
let installed;
|
|
166
|
+
let recording = false;
|
|
167
|
+
try {
|
|
168
|
+
const browser = await cdp.send("Browser.getVersion");
|
|
169
|
+
await cdp.send("Page.enable");
|
|
170
|
+
await cdp.send("Page.bringToFront");
|
|
171
|
+
installed = String((await cdp.send("Page.addScriptToEvaluateOnNewDocument", {
|
|
172
|
+
source: `${metricsObserverScript(key)};${jankObserverScript(jankKey)}`
|
|
173
|
+
})).identifier);
|
|
174
|
+
// Warm the dev server and HTTP cache equally before each capture set; cookies are untouched.
|
|
175
|
+
await navigate(cdp, options);
|
|
176
|
+
await delay(options.settleMs);
|
|
177
|
+
const runs = [];
|
|
178
|
+
for (let run = 1; run <= options.runs; run++) {
|
|
179
|
+
await cdp.send("Page.navigate", { url: "about:blank" });
|
|
180
|
+
await waitFor(cdp, `location.href === 'about:blank'`);
|
|
181
|
+
const recordingRequestedAt = performance.now();
|
|
182
|
+
runDeadline = recordingRequestedAt + 60000;
|
|
183
|
+
try {
|
|
184
|
+
await cdp.send("Page.startScreenRecording", {
|
|
185
|
+
frameRate: 60,
|
|
186
|
+
maxWidth: 1920,
|
|
187
|
+
maxHeight: 1080,
|
|
188
|
+
captureArea: "target",
|
|
189
|
+
audio: false
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
catch (error) {
|
|
193
|
+
throw new Error(`Native recording unavailable in ${String(browser.product)}; Chrome 153+ with Page.startScreenRecording is required. ${String(error)}`);
|
|
194
|
+
}
|
|
195
|
+
recording = true;
|
|
196
|
+
await delay(150);
|
|
197
|
+
const triggerOffsetMs = performance.now() - recordingRequestedAt;
|
|
198
|
+
await navigate(cdp, options);
|
|
199
|
+
await delay(options.settleMs);
|
|
200
|
+
const documentOrigin = await evaluate(cdp, "performance.timeOrigin");
|
|
201
|
+
await performActions(cdp, options.actions);
|
|
202
|
+
await delay(options.settleMs);
|
|
203
|
+
if ((await evaluate(cdp, "performance.timeOrigin")) !== documentOrigin)
|
|
204
|
+
throw new Error("An action navigated to a new document; capture that page as a separate scenario");
|
|
205
|
+
const snapshot = JSON.parse(String(await evaluate(cdp, snapshotScript(key))));
|
|
206
|
+
const details = await evaluate(cdp, `JSON.stringify({jank:globalThis[${JSON.stringify(jankKey)}],viewport:{width:innerWidth,height:innerHeight,dpr:devicePixelRatio},url:location.href})`);
|
|
207
|
+
const context = JSON.parse(String(details));
|
|
208
|
+
for (const script of context.jank?.longAnimationFrames?.slowestScripts || []) {
|
|
209
|
+
script.sourceUrl = safeNetworkUrl(script.sourceUrl);
|
|
210
|
+
}
|
|
211
|
+
if (!snapshot.observation || !context.jank)
|
|
212
|
+
throw new Error("Capture observers were lost; retry the scenario");
|
|
213
|
+
if (context.jank.visibility !== "visible")
|
|
214
|
+
throw new Error("Capture tab was hidden; keep it visible and retry");
|
|
215
|
+
const video = `run-${run}.mp4`;
|
|
216
|
+
const bytes = await saveRecording(cdp, join(options.output, video));
|
|
217
|
+
recording = false;
|
|
218
|
+
runs.push({
|
|
219
|
+
video,
|
|
220
|
+
bytes,
|
|
221
|
+
triggerOffsetMs,
|
|
222
|
+
viewport: context.viewport,
|
|
223
|
+
metrics: summarizeBrowserMetrics(snapshot, {}),
|
|
224
|
+
jank: context.jank
|
|
225
|
+
});
|
|
226
|
+
runDeadline = Number.POSITIVE_INFINITY;
|
|
227
|
+
}
|
|
228
|
+
const manifest = {
|
|
229
|
+
version: 1,
|
|
230
|
+
capturedAt: new Date().toISOString(),
|
|
231
|
+
scenario: {
|
|
232
|
+
url: safeNetworkUrl(options.url),
|
|
233
|
+
identity: createHash("sha256").update(options.url).digest("hex"),
|
|
234
|
+
ready: options.ready ?? null,
|
|
235
|
+
actions: options.actions,
|
|
236
|
+
settleMs: options.settleMs,
|
|
237
|
+
warmups: 1,
|
|
238
|
+
cache: "existing-profile-warmed",
|
|
239
|
+
throttling: "unchanged",
|
|
240
|
+
frameRate: 60
|
|
241
|
+
},
|
|
242
|
+
browser: browser.product,
|
|
243
|
+
runs,
|
|
244
|
+
notes: [
|
|
245
|
+
"Local lab measurements, not field Core Web Vitals or a performance guarantee.",
|
|
246
|
+
"Video trigger offsets are estimates from CDP request timing, not frame-exact synchronization.",
|
|
247
|
+
"Animation gaps measure main-thread scheduling, not dropped compositor frames. maxInteractionMs is an observed Event Timing maximum, not INP; null can mean no qualifying event.",
|
|
248
|
+
"Use matching production builds for performance conclusions; dev compilation, HMR, machine load, cache and network state can change results.",
|
|
249
|
+
"Videos contain visible page data. Capture is explicit; delete the output directory when it is no longer needed."
|
|
250
|
+
]
|
|
251
|
+
};
|
|
252
|
+
await writeFile(join(options.output, "capture.json"), JSON.stringify(manifest, null, 2), {
|
|
253
|
+
flag: "wx",
|
|
254
|
+
mode: 0o600
|
|
255
|
+
});
|
|
256
|
+
return { output: options.output, ...manifest };
|
|
257
|
+
}
|
|
258
|
+
finally {
|
|
259
|
+
runDeadline = Number.POSITIVE_INFINITY;
|
|
260
|
+
if (recording)
|
|
261
|
+
await cdp
|
|
262
|
+
.send("Page.stopScreenRecording")
|
|
263
|
+
.then(async ({ stream }) => {
|
|
264
|
+
if (stream)
|
|
265
|
+
await cdp.send("IO.close", { handle: stream });
|
|
266
|
+
})
|
|
267
|
+
.catch(() => { });
|
|
268
|
+
if (installed)
|
|
269
|
+
await cdp.send("Page.removeScriptToEvaluateOnNewDocument", { identifier: installed }).catch(() => { });
|
|
270
|
+
await evaluate(cdp, `globalThis[${JSON.stringify(key)}]?.dispose();globalThis[${JSON.stringify(jankKey)}]?.dispose()`).catch(() => { });
|
|
271
|
+
cdp.close();
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
//# sourceMappingURL=browser-capture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-capture.js","sourceRoot":"","sources":["../../src/runtime/browser-capture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAA;AACrG,OAAO,EAAsB,iBAAiB,EAAmB,MAAM,kBAAkB,CAAA;AACzF,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAWtD,MAAM,KAAK,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAA;AAErF,MAAM,UAAU,mBAAmB,CAAC,IAAc;IAChD,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;IACnB,MA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;QACpB,IAAI,SAAS;YAAE,MAAM,GAAG,CAAC,IAAI,CAAC,0CAA0C,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;QACpH,MAAM,QAAQ,CACZ,GAAG,EACH,cAAc,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,2BAA2B,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,cAAc,CAClG,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;QACjB,GAAG,CAAC,KAAK,EAAE,CAAA;IACb,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
interface Run {
|
|
2
|
+
video: string;
|
|
3
|
+
triggerOffsetMs: number;
|
|
4
|
+
viewport: {
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
dpr: number;
|
|
8
|
+
};
|
|
9
|
+
metrics: {
|
|
10
|
+
url: string;
|
|
11
|
+
webVitals: {
|
|
12
|
+
lcp: {
|
|
13
|
+
valueMs: number;
|
|
14
|
+
} | null;
|
|
15
|
+
cls: number | null;
|
|
16
|
+
};
|
|
17
|
+
paint: {
|
|
18
|
+
fcpMs: number | null;
|
|
19
|
+
};
|
|
20
|
+
navigation: {
|
|
21
|
+
ttfbMs: number | null;
|
|
22
|
+
};
|
|
23
|
+
longTasks: {
|
|
24
|
+
totalMs: number;
|
|
25
|
+
} | null;
|
|
26
|
+
};
|
|
27
|
+
jank: {
|
|
28
|
+
maxFrameGapMs: number;
|
|
29
|
+
maxInteractionMs: number | null;
|
|
30
|
+
longAnimationFrames: {
|
|
31
|
+
totalBlockingMs: number;
|
|
32
|
+
} | null;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
interface Capture {
|
|
36
|
+
version: number;
|
|
37
|
+
browser: string;
|
|
38
|
+
scenario: unknown;
|
|
39
|
+
runs: Run[];
|
|
40
|
+
}
|
|
41
|
+
export declare function distribution(values: Array<number | null | undefined>): {
|
|
42
|
+
observed: number;
|
|
43
|
+
median: number | null;
|
|
44
|
+
min: number;
|
|
45
|
+
max: number | null;
|
|
46
|
+
};
|
|
47
|
+
export declare function compareCaptures(before: Capture, after: Capture): {
|
|
48
|
+
comparable: boolean;
|
|
49
|
+
warnings: string[];
|
|
50
|
+
metrics: {
|
|
51
|
+
name: string;
|
|
52
|
+
before: {
|
|
53
|
+
observed: number;
|
|
54
|
+
median: number | null;
|
|
55
|
+
min: number;
|
|
56
|
+
max: number | null;
|
|
57
|
+
};
|
|
58
|
+
after: {
|
|
59
|
+
observed: number;
|
|
60
|
+
median: number | null;
|
|
61
|
+
min: number;
|
|
62
|
+
max: number | null;
|
|
63
|
+
};
|
|
64
|
+
medianDelta: number | null;
|
|
65
|
+
}[];
|
|
66
|
+
notes: string[];
|
|
67
|
+
};
|
|
68
|
+
export declare function compareBrowserCaptures(args: string[]): Promise<{
|
|
69
|
+
comparable: boolean;
|
|
70
|
+
warnings: string[];
|
|
71
|
+
metrics: {
|
|
72
|
+
name: string;
|
|
73
|
+
before: {
|
|
74
|
+
observed: number;
|
|
75
|
+
median: number | null;
|
|
76
|
+
min: number;
|
|
77
|
+
max: number | null;
|
|
78
|
+
};
|
|
79
|
+
after: {
|
|
80
|
+
observed: number;
|
|
81
|
+
median: number | null;
|
|
82
|
+
min: number;
|
|
83
|
+
max: number | null;
|
|
84
|
+
};
|
|
85
|
+
medianDelta: number | null;
|
|
86
|
+
}[];
|
|
87
|
+
notes: string[];
|
|
88
|
+
output: string;
|
|
89
|
+
}>;
|
|
90
|
+
export {};
|
|
91
|
+
//# sourceMappingURL=browser-compare.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-compare.d.ts","sourceRoot":"","sources":["../../src/runtime/browser-compare.ts"],"names":[],"mappings":"AAGA,UAAU,GAAG;IACX,KAAK,EAAE,MAAM,CAAA;IACb,eAAe,EAAE,MAAM,CA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