(this: MacroContext | void, css: string)
| 1125 | } |
| 1126 | |
| 1127 | export function keyframes(this: MacroContext | void, css: string): string { |
| 1128 | // Check if `this` is undefined, which means style was not called as a macro but as a normal function. |
| 1129 | // We also check if this is globalThis, which happens in non-strict mode bundles. |
| 1130 | // Also allow style to be called as a normal function in tests. |
| 1131 | // @ts-ignore |
| 1132 | |
| 1133 | if ((this == null || this === globalThis) && process.env.NODE_ENV !== 'test') { |
| 1134 | throw new Error('The keyframes macro must be imported with {type: "macro"}.'); |
| 1135 | } |
| 1136 | let name = generateArbitraryValueSelector(css, true); |
| 1137 | css = `@keyframes ${name} { |
| 1138 | ${css} |
| 1139 | }`; |
| 1140 | if (this && typeof this.addAsset === 'function') { |
| 1141 | this.addAsset({ |
| 1142 | type: 'css', |
| 1143 | content: css |
| 1144 | }); |
| 1145 | } |
| 1146 | return name; |
| 1147 | } |
no test coverage detected