1 | import type { TAG_ID } from './html.js';
|
2 | export declare enum TokenType {
|
3 | CHARACTER = 0,
|
4 | NULL_CHARACTER = 1,
|
5 | WHITESPACE_CHARACTER = 2,
|
6 | START_TAG = 3,
|
7 | END_TAG = 4,
|
8 | COMMENT = 5,
|
9 | DOCTYPE = 6,
|
10 | EOF = 7,
|
11 | HIBERNATION = 8
|
12 | }
|
13 | export interface Location {
|
14 |
|
15 | startLine: number;
|
16 |
|
17 | startCol: number;
|
18 |
|
19 | startOffset: number;
|
20 |
|
21 | endLine: number;
|
22 |
|
23 | endCol: number;
|
24 |
|
25 | endOffset: number;
|
26 | }
|
27 | export interface LocationWithAttributes extends Location {
|
28 |
|
29 | attrs?: Record<string, Location>;
|
30 | }
|
31 | export interface ElementLocation extends LocationWithAttributes {
|
32 |
|
33 | startTag?: Location;
|
34 | |
35 |
|
36 |
|
37 |
|
38 | endTag?: Location;
|
39 | }
|
40 | interface TokenBase {
|
41 | readonly type: TokenType;
|
42 | location: Location | null;
|
43 | }
|
44 | export interface DoctypeToken extends TokenBase {
|
45 | readonly type: TokenType.DOCTYPE;
|
46 | name: string | null;
|
47 | forceQuirks: boolean;
|
48 | publicId: string | null;
|
49 | systemId: string | null;
|
50 | }
|
51 | export interface Attribute {
|
52 |
|
53 | name: string;
|
54 |
|
55 | namespace?: string;
|
56 |
|
57 | prefix?: string;
|
58 |
|
59 | value: string;
|
60 | }
|
61 | export interface TagToken extends TokenBase {
|
62 | readonly type: TokenType.START_TAG | TokenType.END_TAG;
|
63 | tagName: string;
|
64 |
|
65 | tagID: TAG_ID;
|
66 | selfClosing: boolean;
|
67 | ackSelfClosing: boolean;
|
68 | attrs: Attribute[];
|
69 | location: LocationWithAttributes | null;
|
70 | }
|
71 | export declare function getTokenAttr(token: TagToken, attrName: string): string | null;
|
72 | export interface CommentToken extends TokenBase {
|
73 | readonly type: TokenType.COMMENT;
|
74 | data: string;
|
75 | }
|
76 | export interface EOFToken extends TokenBase {
|
77 | readonly type: TokenType.EOF;
|
78 | }
|
79 | export interface CharacterToken extends TokenBase {
|
80 | type: TokenType.CHARACTER | TokenType.NULL_CHARACTER | TokenType.WHITESPACE_CHARACTER;
|
81 | chars: string;
|
82 | }
|
83 | export type Token = DoctypeToken | TagToken | CommentToken | EOFToken | CharacterToken;
|
84 | export {};
|
85 |
|
\ | No newline at end of file |