1 | declare namespace Less {
|
2 |
|
3 | interface RootFileInfo {
|
4 |
|
5 | rewriteUrls?: boolean | undefined;
|
6 |
|
7 | filename: string;
|
8 | relativeUrls: boolean;
|
9 |
|
10 | rootpath: string;
|
11 |
|
12 | currentDirectory: string;
|
13 |
|
14 | entryPath: string;
|
15 |
|
16 | rootFilename: string;
|
17 |
|
18 | reference: boolean;
|
19 | }
|
20 |
|
21 | class PluginManager {
|
22 | constructor(less: LessStatic);
|
23 |
|
24 | addPreProcessor(preProcessor: PreProcessor, priority?: number): void;
|
25 |
|
26 | addFileManager(fileManager: FileManager): void;
|
27 | }
|
28 |
|
29 | interface Plugin {
|
30 | install: (less: LessStatic, pluginManager: PluginManager) => void;
|
31 | minVersion?: [number, number, number] | undefined;
|
32 | }
|
33 |
|
34 | interface PreProcessor {
|
35 | process: (src: string, extra: PreProcessorExtraInfo) => string;
|
36 | }
|
37 |
|
38 | interface PreProcessorExtraInfo {
|
39 | context: {
|
40 | pluginManager: PluginManager;
|
41 | };
|
42 |
|
43 | fileInfo: RootFileInfo;
|
44 |
|
45 | imports: {
|
46 | [key: string]: any;
|
47 | };
|
48 | }
|
49 |
|
50 | interface FileLoadResult {
|
51 |
|
52 | filename: string;
|
53 |
|
54 |
|
55 | contents: string;
|
56 | }
|
57 |
|
58 | interface FileLoadError {
|
59 |
|
60 | error: unknown;
|
61 | }
|
62 |
|
63 | class FileManager extends AbstractFileManager {
|
64 | |
65 |
|
66 |
|
67 |
|
68 | supports(
|
69 | filename: string,
|
70 | currentDirectory: string,
|
71 | options: LoadFileOptions,
|
72 | environment: Environment,
|
73 | ): boolean;
|
74 |
|
75 | |
76 |
|
77 |
|
78 | loadFile(
|
79 | filename: string,
|
80 | currentDirectory: string,
|
81 | options: LoadFileOptions,
|
82 | environment: Environment,
|
83 | ): Promise<FileLoadResult>;
|
84 |
|
85 | |
86 |
|
87 |
|
88 | loadFileSync(
|
89 | filename: string,
|
90 | currentDirectory: string,
|
91 | options: LoadFileOptions,
|
92 | environment: Environment,
|
93 | ): FileLoadResult | FileLoadError;
|
94 | }
|
95 |
|
96 | class AbstractFileManager {
|
97 | |
98 |
|
99 |
|
100 | getPath(filename: string): string;
|
101 |
|
102 | |
103 |
|
104 |
|
105 | tryAppendLessExtension(filename: string): string;
|
106 |
|
107 | |
108 |
|
109 |
|
110 |
|
111 | alwaysMakePathsAbsolute(): boolean;
|
112 |
|
113 | |
114 |
|
115 |
|
116 | isPathAbsolute(path: string): boolean;
|
117 |
|
118 | |
119 |
|
120 |
|
121 | join(basePath: string, laterPath: string): string;
|
122 |
|
123 | |
124 |
|
125 |
|
126 |
|
127 |
|
128 | pathDiff(url: string, baseUrl: string): string;
|
129 |
|
130 | |
131 |
|
132 |
|
133 |
|
134 | supportsSync(
|
135 | filename: string,
|
136 | currentDirectory: string,
|
137 | options: LoadFileOptions,
|
138 | environment: Environment,
|
139 | ): boolean;
|
140 | }
|
141 |
|
142 | interface LoadFileOptions {
|
143 | paths?: string[] | undefined;
|
144 | prefixes?: string[] | undefined;
|
145 | ext?: string | undefined;
|
146 | rawBuffer?: any;
|
147 | syncImport?: boolean | undefined;
|
148 | }
|
149 |
|
150 | interface Environment {
|
151 | |
152 |
|
153 |
|
154 | encodeBase64(str: string): string;
|
155 |
|
156 | |
157 |
|
158 |
|
159 | mimeLookup(filename: string): string;
|
160 |
|
161 | |
162 |
|
163 |
|
164 | charsetLookup(mime: string): string;
|
165 |
|
166 | |
167 |
|
168 |
|
169 | getSourceMapGenerator(): any;
|
170 | }
|
171 |
|
172 | interface SourceMapOption {
|
173 | sourceMapURL?: string | undefined;
|
174 | sourceMapBasepath?: string | undefined;
|
175 | sourceMapRootpath?: string | undefined;
|
176 | outputSourceFiles?: boolean | undefined;
|
177 | sourceMapFileInline?: boolean | undefined;
|
178 | }
|
179 |
|
180 | interface StaticOptions {
|
181 | async: boolean;
|
182 | fileAsync: boolean;
|
183 | modifyVars: { [variable: string]: string };
|
184 | }
|
185 |
|
186 | interface ImportManager {
|
187 | contents: { [fileName: string]: string };
|
188 | }
|
189 |
|
190 | |
191 |
|
192 |
|
193 |
|
194 |
|
195 |
|
196 |
|
197 | interface Options {
|
198 | sourceMap?: SourceMapOption | undefined;
|
199 |
|
200 | filename?: string | undefined;
|
201 |
|
202 | paths?: string[] | undefined;
|
203 |
|
204 | lint?: boolean | undefined;
|
205 |
|
206 | plugins?: Plugin[] | undefined;
|
207 |
|
208 | compress?: boolean | undefined;
|
209 | strictImports?: boolean | undefined;
|
210 |
|
211 | insecure?: boolean | undefined;
|
212 | depends?: boolean | undefined;
|
213 | maxLineLen?: number | undefined;
|
214 |
|
215 | color?: boolean | undefined;
|
216 |
|
217 | ieCompat?: boolean | undefined;
|
218 |
|
219 | javascriptEnabled?: boolean | undefined;
|
220 |
|
221 | dumpLineNumbers?: "comment" | string | undefined;
|
222 |
|
223 | rootpath?: string | undefined;
|
224 |
|
225 | math?: "always" | "strict" | "parens-division" | "parens" | "strict-legacy" | number | undefined;
|
226 |
|
227 | silent?: boolean | undefined;
|
228 |
|
229 | strictUnits?: boolean | undefined;
|
230 |
|
231 | globalVars?: {
|
232 | [key: string]: string;
|
233 | } | undefined;
|
234 |
|
235 | modifyVars?: {
|
236 | [key: string]: string;
|
237 | } | undefined;
|
238 |
|
239 | syncImport?: boolean | undefined;
|
240 | }
|
241 |
|
242 | interface RenderError {
|
243 | column: number;
|
244 | extract: string[];
|
245 | filename: string;
|
246 | index: number;
|
247 | line: number;
|
248 | message: string;
|
249 | type: string;
|
250 | }
|
251 |
|
252 | interface RenderOutput {
|
253 | css: string;
|
254 | map: string;
|
255 | imports: string[];
|
256 | }
|
257 |
|
258 | interface RefreshOutput {
|
259 | endTime: Date;
|
260 | startTime: Date;
|
261 | sheets: number;
|
262 | totalMilliseconds: number;
|
263 | }
|
264 | }
|
265 |
|
266 | interface LessStatic {
|
267 | options: Less.StaticOptions;
|
268 |
|
269 | importManager?: Less.ImportManager | undefined;
|
270 | sheets: HTMLLinkElement[];
|
271 |
|
272 | modifyVars(vars: { [name: string]: string }): Promise<Less.RefreshOutput>;
|
273 |
|
274 | refreshStyles(): void;
|
275 |
|
276 | render(input: string, callback: (error: Less.RenderError, output: Less.RenderOutput | undefined) => void): void;
|
277 | render(
|
278 | input: string,
|
279 | options: Less.Options,
|
280 | callback: (error: Less.RenderError, output: Less.RenderOutput | undefined) => void,
|
281 | ): void;
|
282 |
|
283 | render(input: string): Promise<Less.RenderOutput>;
|
284 | render(input: string, options: Less.Options): Promise<Less.RenderOutput>;
|
285 |
|
286 | refresh(
|
287 | reload?: boolean,
|
288 | modifyVars?: { [variable: string]: string },
|
289 | clearFileCache?: boolean,
|
290 | ): Promise<Less.RefreshOutput>;
|
291 |
|
292 | version: number[];
|
293 |
|
294 | watch(): void;
|
295 |
|
296 | FileManager: typeof Less.FileManager;
|
297 | PluginManager: typeof Less.PluginManager;
|
298 | }
|
299 |
|
300 | declare module "less" {
|
301 | export = less;
|
302 | }
|
303 |
|
304 | declare var less: LessStatic;
|