MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / main

Function main

packages/core/scripts/debug-timeline.ts:195–316  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

193}
194
195function main() {
196 const { inputPath, forcedFps, forcedMaxDuration } = parseArgs();
197 if (!inputPath) {
198 console.error("Usage: bun run debug:timeline <path-to-html> [--fps 30] [--max-duration 1800]");
199 process.exit(2);
200 }
201
202 const resolvedPath = path.resolve(process.cwd(), inputPath);
203 if (!fs.existsSync(resolvedPath)) {
204 console.error(`File not found: ${resolvedPath}`);
205 process.exit(2);
206 }
207
208 const html = fs.readFileSync(resolvedPath, "utf-8");
209 const tags = parseTags(html);
210 const root = resolveRootTag(tags);
211 const rootCompositionId = root?.attrs["data-composition-id"] ?? null;
212
213 const maxDuration =
214 (forcedMaxDuration != null && forcedMaxDuration > 0
215 ? forcedMaxDuration
216 : extractWindowNumber(html, "window.__HF_MAX_DURATION_SEC")) ?? 1800;
217 const canonicalFps =
218 (forcedFps != null && forcedFps > 0
219 ? forcedFps
220 : (parseNum(root?.attrs["data-fps"]) ?? extractWindowNumber(html, "window.__HF_FPS"))) ?? 30;
221
222 const rootDurationRaw =
223 parseNum(root?.attrs["data-composition-duration"]) ??
224 parseNum(root?.attrs["data-duration"]) ??
225 parseNum(
226 tags.find((tag) => tag.tagName === "html")?.attrs["data-composition-duration"] ?? null,
227 );
228 const rootDuration = normalizeDurationSeconds(rootDurationRaw, null, maxDuration);
229
230 const nodes = tags.filter((tag) => shouldIncludeTimelineNode(tag, rootCompositionId));
231 const clips: TimelineClip[] = [];
232 let maxEnd = 0;
233 let unresolvedClipCount = 0;
234
235 for (let i = 0; i < nodes.length; i += 1) {
236 const node = nodes[i];
237 const attrs = node.attrs;
238 const start = Math.max(0, parseNum(attrs["data-start"]) ?? 0);
239 const inferredDuration = inferClipDuration(node, start, maxDuration);
240 const hasDeterministicDuration = inferredDuration != null && inferredDuration > 0;
241 let duration = hasDeterministicDuration
242 ? normalizeDurationSeconds(inferredDuration, 0, maxDuration)
243 : 0;
244 let durationSource: "deterministic" | "fallback" = "deterministic";
245 if (duration <= 0 && rootDuration > start) {
246 duration = normalizeDurationSeconds(rootDuration - start, 0, maxDuration);
247 durationSource = "fallback";
248 }
249 if (duration <= 0) {
250 unresolvedClipCount += 1;
251 continue;
252 }

Callers 1

debug-timeline.tsFile · 0.70

Calls 11

parseTagsFunction · 0.85
resolveRootTagFunction · 0.85
extractWindowNumberFunction · 0.85
normalizeDurationSecondsFunction · 0.85
inferClipDurationFunction · 0.85
errorMethod · 0.80
parseArgsFunction · 0.70
parseNumFunction · 0.70
resolveNodeAssetUrlFunction · 0.70
findMethod · 0.65

Tested by

no test coverage detected