Files
clash-verge-rev/scripts/perf/replay.ts
T
Tunglies a0ce1cdadf chore(perf): extract replay tooling into a standalone harness (#8645)
* chore(perf): use the external measurement harness

Keep real Traffic, Logs and Connections scenes and the isolated native
entry beside product APIs. Invoke the standalone runner with an explicit
project path and remove bundled measurement orchestration.

Support the optional owned virtual display and read-only isolation
snapshots without changing ordinary product startup or networking.

* docs: scope agent guidance to the active task

Keep behavior and ownership guidance with the relevant task routes,
including the external performance adapter workflow. Preserve focused
self-review for routine changes and independent review where required.

* docs(perf): link the standalone harness repository

Link the harness repository and operating guide, and document first-time
checkout setup while preserving explicit paths for routine invocation.

* fix(perf): account for external harness dependencies in Knip

* chore(perf): keep tool dependencies and guidance outside the product

* docs(perf): keep product guidance focused on the adapter
2026-11-14 06:11:35 +00:00

38 lines
1.2 KiB
TypeScript

export interface Frame {
sequence: number
timestamp: number
payload: ILogItem[] | IConnections
}
export const params = new URLSearchParams(location.search)
export const scenario = params.get('scenario') ?? 'traffic'
export const layer = params.get('layer') ?? 'component'
const listeners = new Set<(frame: Frame) => void>()
export const subscribe = (listener: (frame: Frame) => void) => {
listeners.add(listener)
return () => {
listeners.delete(listener)
}
}
export function startReplay() {
const data = document.documentElement.dataset
let previous = 0
data.perfReceived = '0'
data.perfGaps = '0'
const socket = new WebSocket(`ws://127.0.0.1:${params.get('port')}`)
socket.onmessage = ({ data: raw }) => {
const frame = JSON.parse(raw) as Frame
if (frame.sequence !== previous + 1)
data.perfGaps = String(Number(data.perfGaps) + 1)
previous = frame.sequence
data.perfReceived = String(previous)
data.perfSourceTime = String(frame.timestamp)
for (const listener of listeners) listener(frame)
}
socket.onerror = () => {
data.perfError = 'replay socket failed'
}
socket.onclose = () => {
data.perfError = 'replay socket closed'
}
}