| 1 |
import { EventEmitter } from "events"; |
| 2 |
import { RenderOptions, RenderCallback } from ".."; |
| 3 |
import stylus = require(".."); |
| 4 |
|
| 5 |
// TODO: rewrite this to proper import in futures |
| 6 |
declare type Node = typeof stylus["nodes"]["Node"]; |
| 7 |
|
| 8 |
declare class Renderer extends EventEmitter { |
| 9 |
options: RenderOptions; |
| 10 |
str: string; |
| 11 |
events: any; |
| 12 |
|
| 13 |
constructor(str: string); |
| 14 |
constructor(str: string, options: RenderOptions); |
| 15 |
|
| 16 |
/** |
| 17 |
* Parse and evaluate AST, then callback `fn(err, css, js)`. |
| 18 |
*/ |
| 19 |
render(callback: RenderCallback): void; |
| 20 |
|
| 21 |
/** |
| 22 |
* Parse and evaluate AST and return the result. |
| 23 |
*/ |
| 24 |
render(): string; |
| 25 |
|
| 26 |
/** |
| 27 |
* Get dependencies of the compiled file. |
| 28 |
*/ |
| 29 |
deps(filename?: string): string[]; |
| 30 |
|
| 31 |
/** |
| 32 |
* Set option `key` to `val`. |
| 33 |
*/ |
| 34 |
set(key: string, val: any): this; |
| 35 |
|
| 36 |
/** |
| 37 |
* Get option `key`. |
| 38 |
*/ |
| 39 |
get(key: string): any; |
| 40 |
|
| 41 |
/** |
| 42 |
* Include the given `path` to the lookup paths array. |
| 43 |
*/ |
| 44 |
include(path: string): this; |
| 45 |
|
| 46 |
/** |
| 47 |
* Use the given `fn`. |
| 48 |
* |
| 49 |
* This allows for plugins to alter the renderer in |
| 50 |
* any way they wish, exposing paths etc. |
| 51 |
*/ |
| 52 |
use(fn: (renderer: Renderer) => any): this; |
| 53 |
|
| 54 |
/** |
| 55 |
* Define function or global var with the given `name`. Optionally |
| 56 |
* the function may accept full expressions, by setting `raw` |
| 57 |
* to `true`. |
| 58 |
*/ |
| 59 |
define(name: string, fn: (...args: any[]) => any): this; |
| 60 |
define(name: string, node: Node): this; |
| 61 |
define(name: string, val: any): this; |
| 62 |
define(name: string, fn: (...args: any[]) => any, raw: boolean): this; |
| 63 |
define(name: string, node: Node, raw: boolean): this; |
| 64 |
define(name: string, val: any, raw: boolean): this; |
| 65 |
|
| 66 |
/** |
| 67 |
* Import the given `file`. |
| 68 |
*/ |
| 69 |
import(file: string): this; |
| 70 |
|
| 71 |
//#region EventEmitter Members |
| 72 |
addListener(event: string, listener: (...args: any[]) => any): this; |
| 73 |
on(event: string, listener: (...args: any[]) => any): this; |
| 74 |
once(event: string, listener: (...args: any[]) => any): this; |
| 75 |
removeListener(event: string, listener: (...args: any[]) => any): this; |
| 76 |
removeAllListeners(event?: string): this; |
| 77 |
setMaxListeners(n: number): this; |
| 78 |
getMaxListeners(): number; |
| 79 |
listeners(event: string): Array<(...args: any[]) => any>; |
| 80 |
emit(event: string, ...args: any[]): boolean; |
| 81 |
listenerCount(type: string): number; |
| 82 |
} |
| 83 |
|
| 84 |
export = Renderer; |