Skip to content

Commit 03e6818

Browse files
committed
fix(inspector): align live timeline contracts
Keep realm-safe target detection through the restack and align floating-point interval boundaries. Update the live group fixture and make the private runtime entry build itself before use.
1 parent f4e8044 commit 03e6818

7 files changed

Lines changed: 38 additions & 26 deletions

File tree

‎packages/cli/src/commands/timeline.ts‎

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,23 @@ export default defineCommand({
9696
description:
9797
"Unique component selector, or JSON target {selector|hfId|ref}; runtime inspection",
9898
},
99-
at: { type: "string", description: "Global second; runtime inspection" },
100-
range: { type: "string", description: "Global start,end (half-open); runtime inspection" },
101-
boundary: { type: "string", description: "Global boundary: crossing, start, end, instant" },
102-
generation: { type: "string" },
103-
offset: { type: "string" },
99+
at: { type: "string", description: "Global second; requires the inspector service" },
100+
range: {
101+
type: "string",
102+
description: "Global start,end (half-open); requires the inspector service",
103+
},
104+
boundary: {
105+
type: "string",
106+
description: "Global boundary second; requires the inspector service",
107+
},
108+
generation: {
109+
type: "string",
110+
description: "Inspector generation for a continued runtime query",
111+
},
112+
offset: {
113+
type: "string",
114+
description: "Group offset for a continued runtime query",
115+
},
104116

105117
json: { type: "boolean", description: "Output as JSON", default: false },
106118
},
@@ -123,7 +135,9 @@ export default defineCommand({
123135
throw new Error(
124136
"Runtime timeline queries require HF_INSPECT_URL from the existing inspector service.",
125137
);
126-
const info = await fetch(`${url}/info`).then((r) => r.json());
138+
const info = await fetch(`${url}/info`, { signal: AbortSignal.timeout(5000) }).then((r) =>
139+
r.json(),
140+
);
127141
const { realpathSync } = await import("node:fs");
128142
const { dirname } = await import("node:path");
129143
if (realpathSync(info.project) !== realpathSync(dirname(project.indexPath)))

‎packages/core/src/runtime/timelineInspection.ts‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { findRootCompositionElement } from "./compositionDimension";
33
import { readElementRateSpec, readMediaStart } from "./playbackRate";
44
import { timeAtSourceTime } from "../speedRamp";
55
import type { ElementRef, Target } from "./inspectionTypes";
6+
import { isElementNode } from "./domRealm";
67
export interface TimelineRequest {
78
component?: Target;
89
at?: number;
@@ -34,6 +35,8 @@ export interface Interval {
3435
export function classify(interval: Interval, q: TimelineRequest): string | null {
3536
const { start, end } = interval;
3637
const near = (a: number, b: number) => Math.abs(a - b) <= 1e-7;
38+
const before = (a: number, b: number) => a < b && !near(a, b);
39+
const beforeOrAt = (a: number, b: number) => a < b || near(a, b);
3740
if (q.boundary != null) {
3841
const t = q.boundary;
3942
if (near(start, end) && near(start, t)) return "instant";
@@ -46,15 +49,15 @@ export function classify(interval: Interval, q: TimelineRequest): string | null
4649
? near(start, q.at)
4750
? "instant"
4851
: null
49-
: start <= q.at && end > q.at
52+
: beforeOrAt(start, q.at) && before(q.at, end)
5053
? "active"
5154
: null;
5255
if (q.range)
5356
return near(start, end)
54-
? start >= q.range[0] && start < q.range[1]
57+
? beforeOrAt(q.range[0], start) && before(start, q.range[1])
5558
? "instant"
5659
: null
57-
: start < q.range[1] && end > q.range[0]
60+
: before(start, q.range[1]) && before(q.range[0], end)
5861
? "intersects"
5962
: null;
6063
return near(start, end) ? "instant" : "scheduled";
@@ -202,9 +205,7 @@ export function inspectTimelineRuntime(
202205
}
203206
const pieces = internal?.getChildren?.(true, true, false) ?? [a];
204207
for (const piece of pieces) {
205-
const targets = (piece.targets?.() ?? []).filter(
206-
(el): el is Element => el instanceof Element,
207-
);
208+
const targets = (piece.targets?.() ?? []).filter(isElementNode);
208209
if (!targets.some((el) => scope === el || scope.contains(el))) continue;
209210
const properties = Object.keys(piece.vars ?? {}).filter(
210211
(k) => !reserved.has(k) && !k.startsWith("on"),

‎packages/inspector/INSPECT-TIMELINE.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ preserves full event times. `boundary` separately labels `crosses`, `starts`, `e
1414
zero-duration `instant`, with a 1e-7-second endpoint tolerance.
1515

1616
Results are short text grouped by component, containing event time, target, properties and
17-
source locations. `generation` and `offset` provide 60-event continuation. Refs expire on source
17+
source locations. `generation` and `offset` provide 60-group continuation. Refs expire on source
1818
changes/page disposal. Component inspection can retrieve complete source blocks from those refs.
1919
Overlapping targets/properties are reported as facts, never diagnosed as errors.
2020

2121
HF's existing timing resolver handles explicit HF item windows. GSAP parent-chain intervals
22-
expand repeat/yoyo/timeScale, excluding repeatDelay. Stagger/internal timeline intervals are expanded per target, so gaps are not reported as active. Root HF timelines
22+
expand repeat/yoyo/timeScale, including repeatDelay. Stagger/internal timeline intervals are expanded per target, so gaps are not reported as active. Root HF timelines
2323
are normally paused and use the player's global clock. No extra host offset is added to the
2424
auto-nested GSAP parent chain.
2525

‎packages/inspector/package.json‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,16 @@
88
"./live": "./dist/live.js"
99
},
1010
"scripts": {
11+
"build": "node build-live.mjs",
1112
"test": "vitest run",
1213
"typecheck": "tsc --noEmit",
13-
"serve": "bun src/server.ts",
14-
"mcp": "bun src/mcp.ts",
14+
"serve": "bun run build && bun src/server.ts",
15+
"mcp": "bun run build && bun src/mcp.ts",
1516
"test:timeline": "bun tests/timeline.ts",
1617
"test:timeline-compositions": "bun tests/timelineCompositions.ts",
1718
"build:live": "node build-live.mjs",
1819
"prepack": "node build-live.mjs",
19-
"test:live": "bun tests/live.ts",
20+
"test:live": "bun run build && bun tests/live.ts",
2021
"test:source-release": "bun tests/sourceRelease.ts"
2122
},
2223
"dependencies": {
@@ -32,11 +33,5 @@
3233
"@types/node": "^25.0.10",
3334
"typescript": "^5.0.0",
3435
"vitest": "^4.1.11"
35-
},
36-
"hyperframesWorkspaceContract": {
37-
"build": {
38-
"optOut": true,
39-
"reason": "Private Bun service runs its TypeScript source directly and has no published artifact."
40-
}
4136
}
4237
}

‎packages/inspector/src/live.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ export function prepareLiveInspection(
4040
raw.results.length !== request.targets.length
4141
)
4242
throw new Error("invalid_live_query");
43-
// The live path never seeks or silently switches to a different page.
4443
if (request.time !== undefined) throw new Error("live_query_does_not_seek");
4544
const result = mapInspection(
4645
raw,

‎packages/inspector/src/mapInspection.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ export function mapInspection(
9494
debugAvailable: true,
9595
elapsedMs: Math.round(performance.now() - start),
9696
};
97-
// Code blocks are atomic. A continuation repeats this query with generation and nextOffset.
9897
const offset = request.offset ?? 0;
9998
if (!Number.isInteger(offset) || offset < 0)
10099
throw new Error("offset must be a non-negative integer");

‎packages/inspector/tests/live.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,11 @@ try {
8181
const result = live.resolve(packet);
8282
assert.deepEqual(
8383
result.results.map((r) => r.status),
84-
["found", "found", "ambiguous", "found"],
84+
["found", "found", "found", "found"],
85+
);
86+
assert.deepEqual(
87+
result.results[2]!.candidates.map((candidate) => candidate.id),
88+
["title", "other"],
8589
);
8690
assert.equal(result.results[0].unmappedAnimations, 0);
8791
assert(

0 commit comments

Comments
 (0)