( variable: string, theme: Theme, variableDependencies: Map<string, Set<string>>, alreadySeenVariables: Set<string> = new Set(), )
| 904 | // Find out if a variable is either used directly or if any of the variables that depend on it are |
| 905 | // used |
| 906 | function isVariableUsed( |
| 907 | variable: string, |
| 908 | theme: Theme, |
| 909 | variableDependencies: Map<string, Set<string>>, |
| 910 | alreadySeenVariables: Set<string> = new Set(), |
| 911 | ): boolean { |
| 912 | // Break recursions when visiting a variable twice |
| 913 | if (alreadySeenVariables.has(variable)) { |
| 914 | return true |
| 915 | } else { |
| 916 | alreadySeenVariables.add(variable) |
| 917 | } |
| 918 | |
| 919 | let options = theme.getOptions(variable) |
| 920 | if (options & (ThemeOptions.STATIC | ThemeOptions.USED)) { |
| 921 | return true |
| 922 | } else { |
| 923 | let dependencies = variableDependencies.get(variable) ?? [] |
| 924 | for (let dependency of dependencies) { |
| 925 | if (isVariableUsed(dependency, theme, variableDependencies, alreadySeenVariables)) { |
| 926 | return true |
| 927 | } |
| 928 | } |
| 929 | } |
| 930 | |
| 931 | return false |
| 932 | } |
| 933 | |
| 934 | function extractKeyframeNames(value: string): string[] { |
| 935 | return value.split(/[\s,]+/) |
no test coverage detected