generated from JS-DevTools/template-node-typescript
-
Notifications
You must be signed in to change notification settings - Fork 3
/
types.ts
50 lines (44 loc) · 942 Bytes
/
types.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
import { Node } from "unist";
import { VFile } from "vfile";
/**
* Selection criteria for a URL attribute
*/
export interface UrlSelector {
tagName: string;
propertyName: string;
pattern?: RegExp;
}
/**
* Returns the URL(s) for the given node.
*/
export type UrlExtractor = (node: NodeInfo) => undefined | string | ExtractedUrl | Array<string | ExtractedUrl>;
/**
* A URL that was extracted from a HAST node.
*/
export interface ExtractedUrl {
url: string;
propertyName?: string;
}
/**
* Information about the HAST node where a URL was found.
*/
export interface NodeInfo {
node: HtmlElementNode;
root: Node;
file: VFile;
}
/**
* A URL that was found in the document
*/
export type UrlMatch = ExtractedUrl & NodeInfo;
/**
* An HTML element node
*/
export interface HtmlElementNode extends Node {
type: "element";
tagName: string;
properties?: {
[prop: string]: unknown;
};
children?: Node[];
}