.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / postcss-selector-parser / postcss-selector-parser.d.ts
1 // Type definitions for postcss-selector-parser 2.2.3
2 // Definitions by: Chris Eppstein <chris@eppsteins.net>
3
4 /*~ Note that ES6 modules cannot directly export callable functions.
5  *~ This file should be imported using the CommonJS-style:
6  *~   import x = require('someLibrary');
7  *~
8  *~ Refer to the documentation to understand common
9  *~ workarounds for this limitation of ES6 modules.
10  */
11
12 /*~ This declaration specifies that the function
13  *~ is the exported object from the file
14  */
15 export = parser;
16
17 declare function parser(): parser.Processor<never>;
18 declare function parser<Transform extends any>(processor: parser.AsyncProcessor<Transform>): parser.Processor<Transform, never>;
19 declare function parser(processor: parser.AsyncProcessor): parser.Processor<never>;
20 declare function parser<Transform extends any>(processor: parser.SyncProcessor<Transform>): parser.Processor<Transform, never>;
21 declare function parser(processor: parser.SyncProcessor): parser.Processor<never>;
22 declare function parser<Transform>(processor?: parser.SyncProcessor<Transform> | parser.AsyncProcessor<Transform>): parser.Processor<Transform>;
23
24 /*~ If you want to expose types from your module as well, you can
25  *~ place them in this block. Often you will want to describe the
26  *~ shape of the return type of the function; that type should
27  *~ be declared in here, as this example shows.
28  */
29 declare namespace parser {
30     /* copied from postcss -- so we don't need to add a dependency */
31     type ErrorOptions = {
32         plugin?: string;
33         word?: string;
34         index?: number
35     };
36     /* the bits we use of postcss.Rule, copied from postcss -- so we don't need to add a dependency */
37     type PostCSSRuleNode = {
38         selector: string
39         /**
40          * @returns postcss.CssSyntaxError but it's a complex object, caller
41          *   should cast to it if they have a dependency on postcss.
42          */
43         error(message: string, options?: ErrorOptions): Error;
44     };
45     /** Accepts a string  */
46     type Selectors = string | PostCSSRuleNode
47     type SyncProcessor<Transform = void> = (root: parser.Root) => Transform
48     type AsyncProcessor<Transform = void> = (root: parser.Root) => Transform | PromiseLike<Transform>
49
50     const TAG: "tag";
51     const STRING: "string";
52     const SELECTOR: "selector";
53     const ROOT: "root";
54     const PSEUDO: "pseudo";
55     const NESTING: "nesting";
56     const ID: "id";
57     const COMMENT: "comment";
58     const COMBINATOR: "combinator";
59     const CLASS: "class";
60     const ATTRIBUTE: "attribute";
61     const UNIVERSAL: "universal";
62
63     interface NodeTypes {
64         tag: Tag,
65         string: String,
66         selector: Selector,
67         root: Root,
68         pseudo: Pseudo,
69         nesting: Nesting,
70         id: Identifier,
71         comment: Comment,
72         combinator: Combinator,
73         class: ClassName,
74         attribute: Attribute,
75         universal: Universal
76     }
77
78     type Node = NodeTypes[keyof NodeTypes];
79
80     function isNode(node: any): node is Node;
81
82     interface Options {
83         /**
84          * Preserve whitespace when true. Default: false;
85          */
86         lossless: boolean;
87         /**
88          * When true and a postcss.Rule is passed, set the result of
89          * processing back onto the rule when done. Default: false.
90          */
91         updateSelector: boolean;
92     }
93     class Processor<
94         TransformType = never,
95         SyncSelectorsType extends Selectors | never = Selectors
96     > {
97         res: Root;
98         readonly result: String;
99         ast(selectors: Selectors, options?: Partial<Options>): Promise<Root>;
100         astSync(selectors: SyncSelectorsType, options?: Partial<Options>): Root;
101         transform(selectors: Selectors, options?: Partial<Options>): Promise<TransformType>;
102         transformSync(selectors: SyncSelectorsType, options?: Partial<Options>): TransformType;
103         process(selectors: Selectors, options?: Partial<Options>): Promise<string>;
104         processSync(selectors: SyncSelectorsType, options?: Partial<Options>): string;
105     }
106     interface ParserOptions {
107         css: string;
108         error: (message: string, options: ErrorOptions) => Error;
109         options: Options;
110     }
111     class Parser {
112         input: ParserOptions;
113         lossy: boolean;
114         position: number;
115         root: Root;
116         selectors: string;
117         current: Selector;
118         constructor(input: ParserOptions);
119         /**
120          * Raises an error, if the processor is invoked on
121          * a postcss Rule node, a better error message is raised.
122          */
123         error(message: string, options?: ErrorOptions): void;
124     }
125     interface NodeSource {
126         start?: {
127             line: number,
128             column: number
129         },
130         end?: {
131             line: number,
132             column: number
133         }
134     }
135     interface SpaceAround {
136       before: string;
137       after: string;
138     }
139     interface Spaces extends SpaceAround {
140       [spaceType: string]: string | Partial<SpaceAround> | undefined;
141     }
142     interface NodeOptions<Value = string> {
143         value: Value;
144         spaces?: Partial<Spaces>;
145         source?: NodeSource;
146         sourceIndex?: number;
147     }
148     interface Base<
149         Value extends string | undefined = string,
150         ParentType extends Container | undefined = Container | undefined
151     > {
152         type: keyof NodeTypes;
153         parent: ParentType;
154         value: Value;
155         spaces: Spaces;
156         source?: NodeSource;
157         sourceIndex: number;
158         remove(): Node;
159         replaceWith(...nodes: Node[]): Node;
160         next(): Node;
161         prev(): Node;
162         clone(opts: {[override: string]:any}): Node;
163         toString(): string;
164     }
165     interface ContainerOptions extends NodeOptions {
166         nodes?: Array<Node>;
167     }
168     interface Container<Value extends string | undefined = string> extends Base<Value> {
169         nodes: Array<Node>;
170         append(selector: Selector): Container;
171         prepend(selector: Selector): Container;
172         at(index: number): Node;
173         index(child: Node): number;
174         readonly first: Node;
175         readonly last: Node;
176         readonly length: number;
177         removeChild(child: Node): Container;
178         removeAll(): Container;
179         empty(): Container;
180         insertAfter(oldNode: Node, newNode: Node): Container;
181         insertBefore(oldNode: Node, newNode: Node): Container;
182         each(callback: (node: Node) => boolean | void): boolean | undefined;
183         walk(callback: (node: Node) => boolean | void): boolean | undefined;
184         walkAttributes(callback: (node: Node) => boolean | void): boolean | undefined;
185         walkClasses(callback: (node: Node) => boolean | void): boolean | undefined;
186         walkCombinators(callback: (node: Node) => boolean | void): boolean | undefined;
187         walkComments(callback: (node: Node) => boolean | void): boolean | undefined;
188         walkIds(callback: (node: Node) => boolean | void): boolean | undefined;
189         walkNesting(callback: (node: Node) => boolean | void): boolean | undefined;
190         walkPseudos(callback: (node: Node) => boolean | void): boolean | undefined;
191         walkTags(callback: (node: Node) => boolean | void): boolean | undefined;
192         split(callback: (node: Node) => boolean): [Node[], Node[]];
193         map(callback: (node: Node) => Node): Node[];
194         reduce<T>(callback: (node: Node) => Node, memo: T): T;
195         every(callback: (node: Node) => boolean): boolean;
196         some(callback: (node: Node) => boolean): boolean;
197         filter(callback: (node: Node) => boolean): Node[];
198         sort(callback: (nodeA: Node, nodeB: Node) => number): Node[];
199         toString(): string;
200     }
201     function isContainer(node: any): node is Root | Selector | Pseudo;
202
203     interface NamespaceOptions<Value extends string | undefined = string> extends NodeOptions<Value> {
204         namespace?: string | true;
205     }
206     interface Namespace<Value extends string | undefined = string> extends Base<Value> {
207         /** alias for namespace */
208         ns: string | true;
209         /**
210          *  namespace prefix.
211          */
212         namespace: string | true;
213         /**
214          * If a namespace exists, prefix the value provided with it, separated by |.
215          */
216         qualifiedName(value: string): string;
217         /**
218          * A string representing the namespace suitable for output.
219          */
220         readonly namespaceString: string;
221     }
222     function isNamespace(node: any): node is ClassName | Attribute | Tag;
223
224     interface Root extends Container<undefined> {
225         type: "root";
226         /**
227          * Raises an error, if the processor is invoked on
228          * a postcss Rule node, a better error message is raised.
229          */
230         error(message: string, options?: ErrorOptions): Error;
231     }
232     function root(opts: ContainerOptions): Root;
233     function isRoot(node: any): node is Root;
234
235     interface Selector extends Container {
236         type: "selector";
237     }
238     function selector(opts: ContainerOptions): Selector;
239     function isSelector(node: any): node is Selector;
240
241     interface Combinator extends Base {
242         type: "combinator"
243     }
244     function combinator(opts: NodeOptions): Combinator;
245     function isCombinator(node: any): node is Combinator;
246
247     interface ClassName extends Namespace {
248         type: "class";
249     }
250     function className(opts: NamespaceOptions): ClassName;
251     function isClassName(node: any): node is ClassName;
252
253     type AttributeOperator = "=" | "~=" | "|=" | "^=" | "$=" | "*=";
254     interface AttributeOptions extends NamespaceOptions<string | undefined> {
255         attribute: string;
256         operator?: AttributeOperator;
257         insensitive?: boolean;
258         quoted?: boolean;
259         spaces?: {
260             before?: string;
261             after?: string;
262             attribute?: Partial<SpaceAround>;
263             operator?: Partial<SpaceAround>;
264             value?: Partial<SpaceAround>;
265             insensitive?: Partial<SpaceAround>;
266         }
267         raws: {
268             unquoted?: string;
269             attribute?: string;
270             operator?: string;
271             value?: string;
272             insensitive?: string;
273             spaces?: {
274                 attribute?: Partial<Spaces>;
275                 operator?: Partial<Spaces>;
276                 value?: Partial<Spaces>;
277                 insensitive?: Partial<Spaces>;
278             }
279         };
280     }
281     interface Attribute extends Namespace<string | undefined> {
282         type: "attribute";
283         attribute: string;
284         operator?: AttributeOperator;
285         insensitive?: boolean;
286         quoted?: boolean;
287         spaces: {
288             before: string;
289             after: string;
290             attribute?: Partial<Spaces>;
291             operator?: Partial<Spaces>;
292             value?: Partial<Spaces>;
293             insensitive?: Partial<Spaces>;
294         }
295         raws: {
296             unquoted?: string;
297             attribute?: string;
298             operator?: string;
299             value?: string;
300             insensitive?: string;
301             spaces?: {
302                 attribute?: Partial<Spaces>;
303                 operator?: Partial<Spaces>;
304                 value?: Partial<Spaces>;
305                 insensitive?: Partial<Spaces>;
306             }
307         };
308         /**
309          * The attribute name after having been qualified with a namespace.
310          */
311         readonly qualifiedAttribute: string;
312         /**
313          * returns the offset of the attribute part specified relative to the
314          * start of the node of the output string.
315          *
316          * * "ns" - alias for "namespace"
317          * * "namespace" - the namespace if it exists.
318          * * "attribute" - the attribute name
319          * * "attributeNS" - the start of the attribute or its namespace
320          * * "operator" - the match operator of the attribute
321          * * "value" - The value (string or identifier)
322          * * "insensitive" - the case insensitivity flag;
323          * @param part One of the possible values inside an attribute.
324          * @returns -1 if the name is invalid or the value doesn't exist in this attribute.
325          */
326         offsetOf(part: "ns" | "namespace" | "attribute" | "attributeNS" | "operator" | "value" | "insensitive"): number;
327     }
328     function attribute(opts: AttributeOptions): Attribute;
329     function isAttribute(node: any): node is Attribute;
330
331     interface Pseudo extends Container {
332         type: "pseudo";
333     }
334     function pseudo(opts: ContainerOptions): Pseudo;
335     /**
336      * Checks wether the node is the Psuedo subtype of node.
337      */
338     function isPseudo(node: any): node is Pseudo;
339
340     /**
341      * Checks wether the node is, specifically, a pseudo element instead of
342      * pseudo class.
343      */
344     function isPseudoElement(node: any): node is Pseudo;
345
346     /**
347      * Checks wether the node is, specifically, a pseudo class instead of
348      * pseudo element.
349      */
350     function isPseudoClass(node: any): node is Pseudo;
351
352
353     interface Tag extends Namespace {
354         type: "tag";
355     }
356     function tag(opts: NamespaceOptions): Tag;
357     function isTag(node: any): node is Tag;
358
359     interface Comment extends Base {
360         type: "comment";
361     }
362     function comment(opts: NodeOptions): Comment;
363     function isComment(node: any): node is Comment;
364
365     interface Identifier extends Base {
366         type: "id";
367     }
368     function id(opts: any): any;
369     function isIdentifier(node: any): node is Identifier;
370
371     interface Nesting extends Base {
372         type: "nesting";
373     }
374     function nesting(opts: any): any;
375     function isNesting(node: any): node is Nesting;
376
377     interface String extends Base {
378         type: "string";
379     }
380     function string(opts: NodeOptions): String;
381     function isString(node: any): node is String;
382
383     interface Universal extends Base {
384         type: "universal";
385     }
386     function universal(opts?: NamespaceOptions): any;
387     function isUniversal(node: any): node is Universal;
388 }