@marko/language-tools
Advanced tools
| import { type Range } from "../../parser"; | ||
| import { type Extracted, Extractor } from "../../util/extractor"; | ||
| export interface ExtractCSSModuleOptions { | ||
| code: string; | ||
| fileName: string; | ||
| } | ||
| /** | ||
| * Produce a virtual TypeScript module typing a CSS module's default export as | ||
| * an object of its class/id names. The type is exported directly (not via a | ||
| * named `const`) so no internal binding name leaks into hover/go-to-definition, | ||
| * and each name is mapped back to every selector it was defined at. | ||
| */ | ||
| export declare function extractCSSModule(opts: ExtractCSSModuleOptions): Extracted; | ||
| /** | ||
| * Write an object type whose properties are the given CSS module class/id | ||
| * names, each source-mapped to the selector(s) it was defined at. Shared by the | ||
| * standalone `.module.css` extractor and the embedded `<style/var>` extractor. | ||
| */ | ||
| export declare function writeStyleModuleType(extractor: Extractor, selectors: Map<string, Range[]>): void; |
| declare const _default: { | ||
| extensions: (".module.css" | ".module.scss" | ".module.less")[]; | ||
| create({ ts }: import(".").CreateProcessorOptions): { | ||
| getScriptExtension(): import("typescript").Extension.Ts; | ||
| getScriptKind(): import("typescript").ScriptKind.TS; | ||
| extract(fileName: string, code: string): import("..").Extracted; | ||
| print({ extracted }: import(".").PrintContext): { | ||
| code: string; | ||
| }; | ||
| printTypes({ sourceFile, printer }: import(".").PrintContext): { | ||
| code: string; | ||
| }; | ||
| }; | ||
| }; | ||
| export default _default; |
| import type { Range } from "../parser"; | ||
| /** | ||
| * Collect class (`.name`) and id (`#name`) selectors, mapping each unique name | ||
| * to every source {@link Range} it was defined at. A name only counts when it | ||
| * appears in a prelude that ends with `{`; names in declaration values or | ||
| * at-rules (ending with `;`/`}`) are discarded, which keeps hex colors and | ||
| * numbers out. Names in `:global` scope -- `:global(.x)`, a bare `:global .x`, | ||
| * or a `:global { ... }` block (and their `:local` inverses) -- are excluded, | ||
| * matching what a CSS module actually exports. Comments, strings and | ||
| * interpolations are skipped. `offset` is added to every range so callers can | ||
| * scan a slice of a larger document (eg an embedded `<style>` block) in the | ||
| * original document's coordinate space. | ||
| */ | ||
| export declare function findStyleSelectors(code: string, offset?: number): Map<string, Range[]>; |
+1
-0
@@ -0,1 +1,2 @@ | ||
| export * from "./extractors/css-module"; | ||
| export * from "./extractors/html"; | ||
@@ -2,0 +3,0 @@ export * from "./extractors/script"; |
@@ -5,3 +5,3 @@ import type ts from "typescript/lib/tsserverlibrary"; | ||
| export interface ProcessorConfig { | ||
| extension: ProcessorExtension; | ||
| extensions: ProcessorExtension[]; | ||
| create(options: CreateProcessorOptions): Processor; | ||
@@ -36,3 +36,7 @@ } | ||
| export declare const extensions: ProcessorExtension[]; | ||
| export declare function create(options: CreateProcessorOptions): Record<ProcessorExtension, Processor>; | ||
| export declare function create(options: CreateProcessorOptions): Record<`.${string}`, Processor>; | ||
| /** Resolve a file's processor extension, including compound `.module.css`. */ | ||
| export declare function getProcessorExtension(fileName: string): ProcessorExtension | undefined; | ||
| export declare function has(fileName: string): boolean; | ||
| /** Whether a file is a CSS module (`.module.css`, `.module.scss`, `.module.less`). */ | ||
| export declare function isCSSModule(fileName: string): boolean; |
| import type ts from "typescript/lib/tsserverlibrary"; | ||
| declare const _default: { | ||
| extension: ".marko"; | ||
| extensions: ".marko"[]; | ||
| create({ ts, host, configFile }: import(".").CreateProcessorOptions): { | ||
@@ -5,0 +5,0 @@ getRootNames(): string[]; |
@@ -1,2 +0,13 @@ | ||
| import { type Location, type Parsed, type Position, type Range } from "../parser"; | ||
| import { type Location, type Position, type Range } from "../parser"; | ||
| /** | ||
| * The minimal source an {@link Extractor} needs to maintain a source mapping. | ||
| * A Marko `Parsed` satisfies it, as does any other parsed source (eg a CSS | ||
| * module). | ||
| */ | ||
| export interface ExtractorSource { | ||
| code: string; | ||
| filename: string; | ||
| positionAt(offset: number): Position; | ||
| locationAt(range: Range): Location; | ||
| } | ||
| declare const enum Mapping { | ||
@@ -20,3 +31,3 @@ full = 0, | ||
| #private; | ||
| constructor(parsed: Parsed); | ||
| constructor(parsed: ExtractorSource); | ||
| write(str: string): this; | ||
@@ -29,4 +40,4 @@ copy(range: Range | Range[] | string | false | void | undefined | null): this; | ||
| #private; | ||
| parsed: Parsed; | ||
| constructor(parsed: Parsed, generated: string, tokens: Token[]); | ||
| parsed: ExtractorSource; | ||
| constructor(parsed: ExtractorSource, generated: string, tokens: Token[]); | ||
| sourceOffsetAt(generatedOffset: number): number | undefined; | ||
@@ -33,0 +44,0 @@ sourcePositionAt(generatedOffset: number): Position | undefined; |
+1
-1
| { | ||
| "name": "@marko/language-tools", | ||
| "version": "2.5.64", | ||
| "version": "2.6.0", | ||
| "description": "Marko Language Tools", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
350859
6.05%28
12%10705
6.23%