(rawCss: string)
| 367 | } |
| 368 | |
| 369 | function surfaceCssKeyframes(rawCss: string): SurfacedCssKeyframes[] { |
| 370 | const css = stripCssComments(rawCss); |
| 371 | if (!css.trim()) return []; |
| 372 | const { keyframes, ranges } = collectKeyframeBlocks(css); |
| 373 | if (keyframes.length === 0) return []; |
| 374 | |
| 375 | const selectorsByName = new Map<string, Set<string>>(); |
| 376 | for (const kf of keyframes) selectorsByName.set(kf.name, new Set()); |
| 377 | const knownNames = new Set(keyframes.map((kf) => kf.name)); |
| 378 | const cssWithoutKeyframes = stripRanges(css, ranges); |
| 379 | const ruleRe = /([^{}@]+)\{([^{}]*animation[^{}]*)\}/g; |
| 380 | let rule: RegExpExecArray | null; |
| 381 | while ((rule = ruleRe.exec(cssWithoutKeyframes))) { |
| 382 | const selector = rule[1]!.trim().replace(/\s+/g, " "); |
| 383 | if (!selector) continue; |
| 384 | for (const name of animationNamesFromDeclarations(rule[2]!, knownNames)) { |
| 385 | selectorsByName.get(name)?.add(selector); |
| 386 | } |
| 387 | } |
| 388 | |
| 389 | return keyframes.map((kf) => ({ |
| 390 | name: kf.name, |
| 391 | selectors: [...(selectorsByName.get(kf.name) ?? new Set<string>())], |
| 392 | keyframes: kf.stops, |
| 393 | })); |
| 394 | } |
| 395 | |
| 396 | function valuesFromProperty( |
| 397 | script: string, |
no test coverage detected