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

Function collectKeyframeBlocks

packages/cli/src/commands/keyframes.ts:296–321  ·  view source on GitHub ↗
(css: string)

Source from the content-addressed store, hash-verified

294}
295
296function collectKeyframeBlocks(css: string): {
297 keyframes: Array<{ name: string; stops: CssKeyframeStop[] }>;
298 ranges: Array<{ start: number; end: number }>;
299} {
300 const keyframes: Array<{ name: string; stops: CssKeyframeStop[] }> = [];
301 const ranges: Array<{ start: number; end: number }> = [];
302 const re = /@keyframes\s+([a-zA-Z0-9_-]+)/g;
303 let match: RegExpExecArray | null;
304 while ((match = re.exec(css))) {
305 const open = css.indexOf("{", re.lastIndex);
306 const block = open >= 0 ? readBalancedBlock(css, open) : null;
307 if (!block) continue;
308 ranges.push({ start: match.index, end: block.end });
309 const stops: CssKeyframeStop[] = [];
310 const stopRe = /([^{}]+)\{([^{}]*)\}/g;
311 let stop: RegExpExecArray | null;
312 while ((stop = stopRe.exec(block.body))) {
313 stops.push({
314 selector: stop[1]!.trim().replace(/\s+/g, " "),
315 declarations: parseDeclarations(stop[2]!),
316 });
317 }
318 keyframes.push({ name: match[1]!, stops });
319 }
320 return { keyframes, ranges };
321}
322
323function stripQuotes(raw: string): string {
324 return raw.trim().replace(/^["']|["']$/g, "");

Callers 1

surfaceCssKeyframesFunction · 0.85

Calls 2

readBalancedBlockFunction · 0.85
parseDeclarationsFunction · 0.70

Tested by

no test coverage detected