/** * CSS token scanning for the D53 unsafe-CSS gates. * * Both gates ask a question about CSS *tokens*: "does this stylesheet declare * an `@import` at-rule" and "does a `url()` name a relative address". Text * scanning answers neither, and it fails in both directions at once: a `)` * inside a quoted URL ends a regex match early, so `url("./mark).svg")` — a * legal reference to a legal filename — matches nothing and walks past the * gate into a production build that 404s; while a `url(...)` written inside a * string literal, which is text and not a reference at all, matches and gets * refused. One scanner, reading the token grammar, is what both gates need, * so both read the stream produced here instead of writing a private regex. * * Coverage is CSS Syntax Level 3 tokenization as far as those two questions * reach: comments, strings (escapes, line continuations, bad-string), ident * sequences, at-keywords, function tokens, and both url forms (the unquoted * url-token and the `url(` function over a string), including bad-url * recovery. Selectors, declarations, at-rule blocks, and numeric detail stay * unparsed — CSS remains raw and unowned under D53, and this is a reader of * addresses, not a CSS parser. */ /** A token one of the unsafe-CSS gates asks about. */ export type CssToken = /** `@import`, `@media`, … — the at-rule name, escapes already decoded. */ { readonly kind: "at-keyword"; readonly name: string; } /** A `url()` address, escapes decoded, exactly what a browser resolves. */ | { readonly kind: "url"; readonly value: string; } /** A bare string that the image-set grammar defines as a URL. */ | { readonly kind: "asset-address"; readonly value: string; readonly syntax: "image-set" | "-webkit-image-set"; }; /** * Yields the at-keyword and url tokens of a stylesheet. Every other token is * still tokenized — that is the whole point, a string is skipped as a string * and a comment as a comment — it is simply not reported. */ export declare function cssTokens(source: string): Generator; /** * True when `value` is one balanced CSS declaration value: text a generated * rule can place after `property:` with no way to end that declaration, the * rule around it, or the stylesheet segment the rule lives in. * * A Look property's value reaches the DOM through `setProperty` on a custom * property and cannot escape, which is why the value vocabulary deliberately * accepts arbitrary text for the `text`, `filter`, `transform`, and * `animation` kinds (D73 rule 187). `keyframes:` reuses that same checker on a * path that concatenates into stylesheet text instead, so a `}` in a stop's * value closed the generated rule and everything after it became author-owned * CSS in the compiler-owned segment. This is the gate for the concatenating * path only: `{`, `}`, `;`, and `@` never appear outside a string, parens * balance, and strings and comments terminate. */ export declare function isCssDeclarationValue(value: string): boolean; //# sourceMappingURL=css-tokens.d.ts.map