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