forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stylus.d.ts
1447 lines (1163 loc) · 42.7 KB
/
stylus.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Type definitions for stylus 0.48.1
// Project: https://github.com/LearnBoost/stylus
// Definitions by: Maxime LUCE <https://github.com/SomaticIT>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../node/node.d.ts" />
declare namespace Stylus {
export interface Static {
/**
* Return a new `Renderer` for the given `str` and `options`.
*/
(str: string): Renderer;
(str: string, options: RenderOptions): Renderer;
/**
* Library version.
*/
version: string;
/**
* Expose nodes.
*/
nodes: NodeStatic;
/**
* Expose BIFs.
*/
functions: Functions;
/**
* Expose utils.
*/
utils: Utils;
Visitor: typeof Visitor;
Parser: typeof Parser;
Evaluator: typeof Evaluator;
Compiler: typeof Compiler;
/**
* Expose middleware.
*/
middleware(dir: string): Middleware;
middleware(options: any): Middleware;
/**
* Convert the given `css` to `stylus` source.
*/
convertCSS(css: string): string;
/**
* Render the given `str` with `options` and callback `fn(err, css)`.
*/
render(str: string, callback: RenderCallback): void;
render(str: string, options: RenderOptions, callback: RenderCallback): void;
/**
* Return a url() function with the given `options`.
*/
url: UrlFunction;
/**
* Return a url() function with the given `options`.
*/
resolver(options: any): LiteralFunction;
}
//#region Internal Modules
export interface NodeStatic {
Node: typeof Nodes.Node;
Root: typeof Nodes.Root;
Null: typeof Nodes.Null;
Each: typeof Nodes.Each;
If: typeof Nodes.If;
Call: typeof Nodes.Call;
UnaryOp: typeof Nodes.UnaryOp;
BinOp: typeof Nodes.BinOp;
Ternary: typeof Nodes.Ternary;
Block: typeof Nodes.Block;
Unit: typeof Nodes.Unit;
String: typeof Nodes.String;
HSLA: typeof Nodes.HSLA;
RGBA: typeof Nodes.RGBA;
Ident: typeof Nodes.Ident;
Group: typeof Nodes.Group;
Literal: typeof Nodes.Literal;
Boolean: typeof Nodes.Boolean;
Return: typeof Nodes.Return;
Media: typeof Nodes.Media;
QueryList: typeof Nodes.QueryList;
Query: typeof Nodes.Query;
QueryExpr: typeof Nodes.QueryExpr;
Params: typeof Nodes.Params;
Comment: typeof Nodes.Comment;
Keyframes: typeof Nodes.Keyframes;
Member: typeof Nodes.Member;
Charset: typeof Nodes.Charset;
Namespace: typeof Nodes.Namespace;
Import: typeof Nodes.Import;
Extend: typeof Nodes.Extend;
Object: typeof Nodes.Object;
Function: typeof Nodes.Function;
Property: typeof Nodes.Property;
Selector: typeof Nodes.Selector;
Expression: typeof Nodes.Expression;
Arguments: typeof Nodes.Arguments;
Atblock: typeof Nodes.Atblock;
Atrule: typeof Nodes.Atrule;
true: Nodes.Boolean;
false: Nodes.Boolean;
null: Nodes.Null;
}
export interface Functions {
/**
* Convert the given `color` to an `HSLA` node,
* or h,s,l,a component values.
*/
hsla(rgba: Nodes.RGBA): Nodes.HSLA;
hsla(hsla: Nodes.HSLA): Nodes.HSLA;
hsla(hue: Nodes.Unit, saturation: Nodes.Unit, lightness: Nodes.Unit, alpha: Nodes.Unit): Nodes.HSLA;
/**
* Convert the given `color` to an `HSLA` node,
* or h,s,l component values.
*/
hsl(rgba: Nodes.RGBA): Nodes.HSLA;
hsl(hsla: Nodes.HSLA): Nodes.HSLA;
hsl(hue: Nodes.Unit, saturation: Nodes.Unit, lightness: Nodes.Unit): Nodes.HSLA;
/**
* Return type of `node`.
*/
type(node: Nodes.Node): string;
/**
* Return type of `node`.
*/
typeof(node: Nodes.Node): string;
/**
* Return type of `node`.
*/
"type-of"(node: Nodes.Node): string;
/**
* Return component `name` for the given `color`.
*/
component(color: Nodes.RGBA, name: Nodes.String): Nodes.Unit;
component(color: Nodes.HSLA, name: Nodes.String): Nodes.Unit;
/**
* Return component `name` for the given `color`.
*/
basename(path: Nodes.String): string;
basename(path: Nodes.String, ext: Nodes.String): string;
/**
* Return the dirname of `path`.
*/
dirname(path: Nodes.String): string;
/**
* Return the extension of `path`.
*/
extname(path: Nodes.String): string;
/**
* Joins given paths
*/
pathjoin(...paths: Nodes.String[]): string;
/**
* Return the red component of the given `color`,
* or set the red component to the optional second `value` argument.
*/
red(color: Nodes.RGBA): Nodes.Unit;
red(color: Nodes.HSLA): Nodes.Unit;
red(color: Nodes.RGBA, value: Nodes.Unit): Nodes.RGBA;
red(color: Nodes.HSLA, value: Nodes.Unit): Nodes.RGBA;
/**
* Return the green component of the given `color`,
* or set the green component to the optional second `value` argument.
*/
green(color: Nodes.RGBA): Nodes.Unit;
green(color: Nodes.HSLA): Nodes.Unit;
green(color: Nodes.RGBA, value: Nodes.Unit): Nodes.RGBA;
green(color: Nodes.HSLA, value: Nodes.Unit): Nodes.RGBA;
/**
* Return the blue component of the given `color`,
* or set the blue component to the optional second `value` argument.
*/
blue(color: Nodes.RGBA): Nodes.Unit;
blue(color: Nodes.HSLA): Nodes.Unit;
blue(color: Nodes.RGBA, value: Nodes.Unit): Nodes.RGBA;
blue(color: Nodes.HSLA, value: Nodes.Unit): Nodes.RGBA;
/**
* Return the alpha component of the given `color`,
* or set the alpha component to the optional second `value` argument.
*/
alpha(color: Nodes.RGBA): Nodes.Unit;
alpha(color: Nodes.HSLA): Nodes.Unit;
alpha(color: Nodes.RGBA, value: Nodes.Unit): Nodes.RGBA;
alpha(color: Nodes.HSLA, value: Nodes.Unit): Nodes.RGBA;
/**
* Return the hue component of the given `color`,
* or set the hue component to the optional second `value` argument.
*/
hue(color: Nodes.RGBA): Nodes.Unit;
hue(color: Nodes.HSLA): Nodes.Unit;
hue(color: Nodes.RGBA, value: Nodes.Unit): Nodes.RGBA;
hue(color: Nodes.HSLA, value: Nodes.Unit): Nodes.RGBA;
/**
* Return the saturation component of the given `color`,
* or set the saturation component to the optional second `value` argument.
*/
saturation(color: Nodes.RGBA): Nodes.Unit;
saturation(color: Nodes.HSLA): Nodes.Unit;
saturation(color: Nodes.RGBA, value: Nodes.Unit): Nodes.RGBA;
saturation(color: Nodes.HSLA, value: Nodes.Unit): Nodes.RGBA;
/**
* Return the lightness component of the given `color`,
* or set the lightness component to the optional second `value` argument.
*/
lightness(color: Nodes.RGBA): Nodes.Unit;
lightness(color: Nodes.HSLA): Nodes.Unit;
lightness(color: Nodes.RGBA, value: Nodes.Unit): Nodes.RGBA;
lightness(color: Nodes.HSLA, value: Nodes.Unit): Nodes.RGBA;
/**
* Return a `RGBA` from the r,g,b,a channels.
*/
rgba(rgba: Nodes.RGBA): Nodes.RGBA;
rgba(hsla: Nodes.HSLA): Nodes.RGBA;
rgba(hue: Nodes.Unit, saturation: Nodes.Unit, lightness: Nodes.Unit, alpha: Nodes.Unit): Nodes.RGBA;
/**
* Return a `RGBA` from the r,g,b channels.
*/
rgb(rgba: Nodes.RGBA): Nodes.RGBA;
rgb(hsla: Nodes.HSLA): Nodes.RGBA;
rgb(hue: Nodes.Unit, saturation: Nodes.Unit, lightness: Nodes.Unit, alpha: Nodes.Unit): Nodes.RGBA;
/**
* Blend the `top` color over the `bottom`
*/
blend(top: Nodes.RGBA): Nodes.RGBA;
blend(top: Nodes.RGBA, bottom: Nodes.RGBA): Nodes.RGBA;
blend(top: Nodes.RGBA, bottom: Nodes.HSLA): Nodes.RGBA;
blend(top: Nodes.HSLA): Nodes.RGBA;
blend(top: Nodes.HSLA, bottom: Nodes.RGBA): Nodes.RGBA;
blend(top: Nodes.HSLA, bottom: Nodes.HSLA): Nodes.RGBA;
/**
* Returns the relative luminance of the given `color`,
* see http://www.w3.org/TR/WCAG20/#relativeluminancedef
*/
luminosity(rgba: Nodes.RGBA): Nodes.Unit;
luminosity(rgba: Nodes.HSLA): Nodes.Unit;
/**
* Returns the contrast ratio object between `top` and `bottom` colors,
* based on http://leaverou.github.io/contrast-ratio/
* and https://github.com/LeaVerou/contrast-ratio/blob/gh-pages/color.js#L108
*/
contrast(top: Nodes.RGBA): Nodes.Object;
contrast(top: Nodes.RGBA, bottom: Nodes.RGBA): Nodes.Object;
contrast(top: Nodes.RGBA, bottom: Nodes.HSLA): Nodes.Object;
contrast(top: Nodes.HSLA): Nodes.Object;
contrast(top: Nodes.HSLA, bottom: Nodes.RGBA): Nodes.Object;
contrast(top: Nodes.HSLA, bottom: Nodes.HSLA): Nodes.Object;
/**
* Returns the transparent version of the given `top` color,
* as if it was blend over the given `bottom` color.
*/
transparentify(top: Nodes.RGBA): Nodes.Object;
transparentify(top: Nodes.RGBA, bottom: Nodes.RGBA, alpha?: Nodes.Unit): Nodes.Object;
transparentify(top: Nodes.RGBA, bottom: Nodes.HSLA, alpha?: Nodes.Unit): Nodes.Object;
transparentify(top: Nodes.HSLA): Nodes.Object;
transparentify(top: Nodes.HSLA, bottom: Nodes.RGBA, alpha?: Nodes.Unit): Nodes.Object;
transparentify(top: Nodes.HSLA, bottom: Nodes.HSLA, alpha?: Nodes.Unit): Nodes.Object;
/**
* Convert a .json file into stylus variables or object.
* Nested variable object keys are joined with a dash (-)
*
* Given this sample media-queries.json file:
* {
* "small": "screen and (max-width:400px)",
* "tablet": {
* "landscape": "screen and (min-width:600px) and (orientation:landscape)",
* "portrait": "screen and (min-width:600px) and (orientation:portrait)"
* }
* }
*/
json(path: Nodes.String, local: Nodes.Boolean, namePrefix: Nodes.String): any;
/**
* Use the given `plugin`.
*/
use(plugin: Nodes.String): void;
use(plugin: Nodes.String, options: any): void;
/**
* Unquote the given `string`.
*/
unquote(str: Nodes.String): Nodes.Literal;
/**
* Like `unquote` but tries to convert the given `str` to a Stylus node.
*/
convert(str: Nodes.String): Nodes.Node;
/**
* Assign `type` to the given `unit` or return `unit`'s type.
*/
unit(unit: Nodes.Unit, type: Nodes.String): Nodes.Unit;
/**
* Lookup variable `name` or return Null.
*/
lookup(name: Nodes.String): Nodes.Node;
/**
* Set a variable `name` on current scope.
*/
define(name: Nodes.String, expr: Nodes.Expression): Nodes.Node;
/**
* Perform `op` on the `left` and `right` operands.
*/
operate(op: Nodes.String, left: Nodes.Node, right: Nodes.Node): Nodes.Node;
/**
* Test if `val` matches the given `pattern`.
*/
match(pattern: Nodes.String, val: Nodes.String): Nodes.Boolean;
match(pattern: Nodes.String, val: Nodes.Ident): Nodes.Boolean;
/**
* Returns substring of the given `val`.
*/
substr(val: Nodes.String, start: Nodes.Number, length: Nodes.Number): Nodes.String;
substr(val: Nodes.Ident, start: Nodes.Number, length: Nodes.Number): Nodes.Ident;
/**
* Returns string with all matches of `pattern` replaced by `replacement` in given `val`
*/
replace(pattern: Nodes.String, replacement: Nodes.String, val: Nodes.String): Nodes.String;
replace(pattern: Nodes.String, replacement: Nodes.String, val: Nodes.Ident): Nodes.Ident;
/**
* Splits the given `val` by `delim`
*/
split(pattern: Nodes.String, val: Nodes.String): Nodes.Expression;
split(pattern: Nodes.String, val: Nodes.Ident): Nodes.Expression;
/**
* Return length of the given `expr`.
*/
length(expr: Nodes.Expression): Nodes.Unit;
/**
* Inspect the given `expr`.
*/
length(...expr: Nodes.Expression[]): Nodes.Null;
/**
* Throw an error with the given `msg`.
*/
error(msg: Nodes.String): void;
/**
* Warn with the given `msg` prefixed by "Warning: ".
*/
warn(msg: Nodes.String): Nodes.Null;
/**
* Output stack trace.
*/
trace(): Nodes.Null;
/**
* Push the given args to `expr`.
*/
push(expr: Nodes.Expression, ...nodes: Nodes.Node[]): Nodes.Unit;
/**
* Pop a value from `expr`.
*/
pop(expr: Nodes.Expression): Nodes.Node;
/**
* Unshift the given args to `expr`.
*/
unshift(expr: Nodes.Expression, ...nodes: Nodes.Node[]): Nodes.Unit;
/**
* Unshift the given args to `expr`..
*/
prepend(expr: Nodes.Expression, ...nodes: Nodes.Node[]): Nodes.Unit;
/**
* Shift a value from `expr`.
*/
shift(expr: Nodes.Expression): Nodes.Node;
/**
* Return a `Literal` with the given `fmt`, and variable number of arguments.
*/
s(fmt: Nodes.String, ...nodes: Nodes.Node[]): Nodes.Literal;
/**
* Return a `Literal` `num` converted to the provided `base`, padded to `width`
* with zeroes (default width is 2)
*/
"base-convert"(num: Nodes.Number, base: Nodes.Number, width: Nodes.Number): Nodes.Literal;
/**
* Return the opposites of the given `positions`.
*/
"opposite-position"(positions: Nodes.Expression): Nodes.Expression;
/**
* Return the width and height of the given `img` path.
*/
"image-size"(img: Nodes.String, ignoreErr: Nodes.Boolean): Nodes.Expression;
/**
* Return the tangent of the given `angle`.
*/
tan(angle: Nodes.Unit): Nodes.Unit;
/**
* Return the tangent of the given `angle`.
*/
math(n: Nodes.Unit, fn: Nodes.String): Nodes.Unit;
/**
* Return the opposites of the given `positions`.
*/
"-math-prop"(prop: Nodes.String): Nodes.Unit;
/**
* Adjust HSL `color` `prop` by `amount`.
*/
adjust(rgba: Nodes.RGBA, prop: Nodes.String, amount: Nodes.Unit): Nodes.RGBA;
adjust(hsla: Nodes.HSLA, prop: Nodes.String, amount: Nodes.Unit): Nodes.RGBA;
/**
* Return a clone of the given `expr`.
*/
clone(expr: Nodes.Expression): Nodes.Expression;
/**
* Add property `name` with the given `expr` to the mixin-able block.
*/
"add-property"(name: Nodes.String, expr: Nodes.Expression): Nodes.Property;
/**
* Merge the object `dest` with the given args.
*/
merge(dest: Nodes.Object, ...objs: Nodes.Object[]): Nodes.Object;
/**
* Merge the object `dest` with the given args.
*/
extend(dest: Nodes.Object, ...objs: Nodes.Object[]): Nodes.Object;
/**
* Return the current selector or compile `sel` selector.
*/
selector(): string;
selector(sel: Nodes.String): string;
/**
* Prefix css classes in a block
*/
"-prefix-classes"(prefix: Nodes.String, block: Nodes.Block): Nodes.Block;
/**
* Returns the @media string for the current block
*/
"current-media"(): Nodes.String;
/**
* Return the separator of the given `list`.
*/
"list-separator"(list: Nodes.Expression): Nodes.String;
}
export interface Utils {
/**
* Check if `path` looks absolute.
*/
absolute(path: string): boolean;
/**
* Attempt to lookup `path` within `paths` from tail to head.
* Optionally a path to `ignore` may be passed.
*/
lookup(path: string, paths: string, ignore: string, resolveURL: boolean): string;
/**
* Attempt to lookup `path` within `paths` from tail to head.
* Optionally a path to `ignore` may be passed.
*/
lookupIndex(path: string, paths: string, filename: string): string[];
/**
* Like `utils.lookup` but uses `glob` to find files.
*/
find(path: string, paths: string, ignore: string): string[];
/**
* Format the given `err` with the given `options`.
*/
formatException(err: Error, options: ExceptionOptions): Error;
/**
* Assert that `node` is of the given `type`, or throw.
*/
assertType(node: Nodes.Node, type: string, param: string): void;
/**
* Assert that `node` is a `String` or `Ident`.
*/
assertString(node: Nodes.Node, param: string): void;
/**
* Assert that `node` is a `RGBA` or `HSLA`.
*/
assertColor(node: Nodes.Node, param: string): void;
/**
* Assert that param `name` is given, aka the `node` is passed.
*/
assertPresent(node: Nodes.Node, name: string): void;
/**
* Unwrap `expr`.
*
* Takes an expressions with length of 1
* such as `((1 2 3))` and unwraps it to `(1 2 3)`.
*/
unwrap(expr: Nodes.Expression): Nodes.Node;
/**
* Coerce JavaScript values to their Stylus equivalents.
*/
coerce(val: any): Nodes.Node;
coerce(val: any, raw: boolean): Nodes.Node;
/**
* Coerce a javascript `Array` to a Stylus `Expression`.
*/
coerceArray(val: any): Nodes.Expression;
coerceArray(val: any, raw: boolean): Nodes.Expression;
/**
* Coerce a javascript object to a Stylus `Expression` or `Object`.
*
* For example `{ foo: 'bar', bar: 'baz' }` would become
* the expression `(foo 'bar') (bar 'baz')`. If `raw` is true
* given `obj` would become a Stylus hash object.
*/
coerceObject(obj: any): Nodes.Expression;
coerceObject(obj: any, raw: boolean): Nodes.Expression;
/**
* Return param names for `fn`.
*/
params(fn: Function): string[];
/**
* Merge object `b` with `a`.
*/
merge(a: any, b: any): any;
/**
* Returns an array with unique values.
*/
uniq(arr: any[]): any[];
/**
* Compile selector strings in `arr` from the bottom-up
* to produce the selector combinations. For example
* the following Stylus:
*/
compileSelectors(arr: string[], leaveHidden: boolean): string[];
}
export interface UrlFunction {
(options: UrlOptions): LiteralFunction;
mimes: {
".gif": string;
".png": string;
".jpg": string;
".jpeg": string;
".svg": string;
".ttf": string;
".eot": string;
".woff": string;
};
}
export interface Middleware {
(req: any, res: any, next: Function): void;
}
//#endregion
//#region Internal Classes
export class Visitor {
}
export class Parser {
}
export class Evaluator {
}
export class Compiler {
}
export class Renderer implements NodeJS.EventEmitter {
options: RenderOptions;
str: string;
events: any;
constructor(str: string);
constructor(str: string, options: RenderOptions);
/**
* Parse and evaluate AST, then callback `fn(err, css, js)`.
*/
render(callback: RenderCallback): void;
/**
* Parse and evaluate AST and return the result.
*/
render(): string;
/**
* Get dependencies of the compiled file.
*/
deps(filename: string): string[];
/**
* Set option `key` to `val`.
*/
set(key: string, val: any): Renderer;
/**
* Get option `key`.
*/
get(key: string): any;
/**
* Include the given `path` to the lookup paths array.
*/
include(path: string): Renderer;
/**
* Use the given `fn`.
*
* This allows for plugins to alter the renderer in
* any way they wish, exposing paths etc.
*/
use(fn: (renderer: Renderer) => any): Renderer;
/**
* Define function or global var with the given `name`. Optionally
* the function may accept full expressions, by setting `raw`
* to `true`.
*/
define(name: string, fn: Function): Renderer;
define(name: string, node: Nodes.Node): Renderer;
define(name: string, val: any): Renderer;
define(name: string, fn: Function, raw: boolean): Renderer;
define(name: string, node: Nodes.Node, raw: boolean): Renderer;
define(name: string, val: any, raw: boolean): Renderer;
/**
* Import the given `file`.
*/
import(file: string): Renderer;
//#region EventEmitter Members
addListener(event: string, listener: Function): this;
on(event: string, listener: Function): this;
once(event: string, listener: Function): this;
removeListener(event: string, listener: Function): this;
removeAllListeners(event?: string): this;
setMaxListeners(n: number): this;
getMaxListeners(): number;
listeners(event: string): Function[];
emit(event: string, ...args: any[]): boolean;
listenerCount(type: string): number;
//#endregion
}
//#endregion
//#region Nodes Classes
export module Nodes {
export class Node {
lineno: number;
column: number;
filename: string;
first: Node;
hash: string;
nodeName: string;
constructor();
/**
* Return a clone of this node.
*/
clone(): Node;
/**
* Return a JSON representation of this node.
*/
toJSON(): { lineno: number; column: number; filename: string };
/**
* Nodes by default evaluate to themselves.
*/
eval(): Node;
/**
* Return true.
*/
toBoolean(): Boolean;
/**
* Return the expression, or wrap this node in an expression.
*/
toExpression(): Expression;
/**
* Return false if `op` is generally not coerced.
*/
shouldCoerce(op: string): boolean;
/**
* Operate on `right` with the given `op`.
*/
operate(op: string, right: Node): Node;
/**
* Default coercion throws.
*/
coerce(other: Node): Node;
}
export class Root extends Node {
nodes: Node[];
/**
* Push a `node` to this block.
*/
push(node: Node): void;
/**
* Unshift a `node` to this block.
*/
unshift(node: Node): void;
/**
* Return a JSON representation of this node.
*/
toJSON(): { nodes: Node[]; lineno: number; column: number; filename: string };
}
export class String extends Node {
val: string;
string: string;
prefixed: boolean;
quote: string;
constructor(val: string);
constructor(val: string, quote: string);
/**
* Return a JSON representation of this node.
*/
toJSON(): { val: string; quote: string; lineno: number; column: number; filename: string };
}
export class Number extends Node {
}
export class Boolean extends Node {
val: boolean;
isTrue: boolean;
isFalse: boolean;
constructor();
constructor(val: boolean);
/**
* Negate the value.
*/
negate(): Boolean;
/**
* Return 'Boolean'.
*/
inspect(): Boolean;
/**
* Return a JSON representation of this node.
*/
toJSON(): { __type: string; val: boolean; lineno: number; column: number; filename: string };
}
export class Object extends Node {
vals: Dictionary<Node>;
length: number;
constructor();
/**
* Set `key` to `val`.
*/
set(key: string, value: Node): Object;
/**
* Get `key`.
*/
get(key: string): Node;
/**
* Has `key`?
*/
has(key: string): boolean;
/**
* Convert object to string with properties.
*/
toBlock(): string;
/**
* Return a JSON representation of this node.
*/
toJSON(): { __type: string; vals: Dictionary<Node>; lineno: number; column: number; filename: string };
}
export class Null extends Node {
isNull: boolean;
constructor();
/**
* Return a JSON representation of this node.
*/
toJSON(): { __type: string; lineno: number; column: number; filename: string };
}
export class Ident extends Node {
name: string;
string: string;
val: Node;
mixin: boolean;
isEmpty: boolean;
constructor(name: string, val: Node);
constructor(name: string, val: Node, mixin: boolean);
/**
* Return a JSON representation of this node.
*/
toJSON(): { __type: string; name: string; val: Node; mixin: boolean; lineno: number; column: number; filename: string };
}
export class Literal extends Node {
val: string;
string: string;
prefixed: boolean;
constructor(str: string);
/**
* Return a JSON representation of this node.
*/
toJSON(): { __type: string; string: string; val: string; prefixed: boolean; lineno: number; column: number; filename: string };
}
export class Unit extends Node {
val: number;
type: string;
constructor(val: number, type: string);
/**
* Return a JSON representation of this node.
*/
toJSON(): { __type: string; val: number; type: string; lineno: number; column: number; filename: string };
}
export class RGBA extends Node {
r: number;
g: number;
b: number;
a: number;
rgba: RGBA;
hsla: HSLA;
constructor(r: number, g: number, b: number, a: number);
/**
* Return an `RGBA` without clamping values.
*/
static withoutClamping(r: number, g: number, b: number, a: number): RGBA;
/**
* Return a `RGBA` from the given `hsla`.
*/
static fromHSLA(hsla: HSLA): RGBA;
/**
* Add r,g,b,a to the current component values
*/
add(r: number, g: number, b: number, a: number): RGBA;
/**
* Subtract r,g,b,a from the current component values
*/
substract(r: number, g: number, b: number, a: number): RGBA;
/**
* Multiply rgb components by `n`.
*/
multiply(n: number): RGBA;
/**
* Divide rgb components by `n`.
*/
divide(n: number): RGBA;
/**
* Return a JSON representation of this node.
*/
toJSON(): { __type: string; r: number; g: number; b: number; a: number; lineno: number; column: number; filename: string };
}
export class HSLA extends Node {
h: number;
s: number;
l: number;
a: number;
hsla: HSLA;
rgba: RGBA;
constructor(h: number, s: number, l: number, a: number);
/**
* Return a `HSLA` from the given `hsla`.
*/
static fromRGBA(rgba: RGBA): HSLA;
/**
* Add h,s,l to the current component values
*/
add(h: number, s: number, l: number): HSLA;
/**
* Subtract h,s,l from the current component values
*/
substract(h: number, s: number, l: number): HSLA;
/**
* Adjust lightness by `percent`.
*/
adjustLightness(percent: number): HSLA;
/**
* djust hue by `deg`.
*/
adjustHue(deg: number): HSLA;
/**