@@ -2,14 +2,42 @@ import { NodeTypes } from "../constants";
22import { SimpleNode } from "./simple-node" ;
33import { BaseNode } from "./base-node" ;
44
5+ export interface DocumentNode extends BaseNode {
6+ type : NodeTypes . Document ;
7+ children : Array <
8+ TextNode | TagNode | ScriptTagNode | StyleTagNode | CommentNode
9+ > ;
10+ }
11+
512export type TextNode = SimpleNode < NodeTypes . Text > ;
613
7- export type CloseTagNode = SimpleNode < NodeTypes . CloseTag > ;
14+ export interface TagNode extends BaseNode {
15+ type : NodeTypes . Tag ;
16+ selfClosing : boolean ;
17+ name : string ;
18+ openStart : OpenTagStartNode ;
19+ openEnd : OpenTagEndNode ;
20+ close ?: CloseTagNode ;
21+ children : Array <
22+ TextNode | TagNode | ScriptTagNode | StyleTagNode | CommentNode
23+ > ;
24+ attributes : Array < AttributeNode > ;
25+ }
826
927export type OpenTagStartNode = SimpleNode < NodeTypes . OpenTagStart > ;
1028
1129export type OpenTagEndNode = SimpleNode < NodeTypes . OpenTagEnd > ;
1230
31+ export type CloseTagNode = SimpleNode < NodeTypes . CloseTag > ;
32+
33+ export interface AttributeNode extends BaseNode {
34+ type : NodeTypes . Attribute ;
35+ key : AttributeKeyNode ;
36+ value ?: AttributeValueNode ;
37+ startWrapper ?: AttributeValueWrapperStartNode ;
38+ endWrapper ?: AttributeValueWrapperEndNode ;
39+ }
40+
1341export type AttributeKeyNode = SimpleNode < NodeTypes . AttributeKey > ;
1442
1543export type AttributeValueNode = SimpleNode < NodeTypes . AttributeValue > ;
@@ -20,84 +48,61 @@ export type AttributeValueWrapperStartNode =
2048export type AttributeValueWrapperEndNode =
2149 SimpleNode < NodeTypes . AttributeValueWrapperEnd > ;
2250
23- export type OpenTagStartStyleNode = SimpleNode < NodeTypes . OpenTagStartStyle > ;
24-
25- export type OpenTagEndStyleNode = SimpleNode < NodeTypes . OpenTagEndStyle > ;
26-
51+ export interface ScriptTagNode extends BaseNode {
52+ type : NodeTypes . ScriptTag ;
53+ attributes : Array < AttributeNode > ;
54+ openStart : OpenTagStartScriptNode ;
55+ openEnd : OpenTagEndScriptNode ;
56+ close : CloseTagScriptNode ;
57+ value ?: ScriptTagContentNode ;
58+ }
2759export type OpenTagStartScriptNode = SimpleNode < NodeTypes . OpenTagStartScript > ;
2860
61+ export type CloseTagScriptNode = SimpleNode < NodeTypes . CloseTagScript > ;
62+
2963export type OpenTagEndScriptNode = SimpleNode < NodeTypes . OpenTagEndScript > ;
3064
31- export type CommentStartNode = SimpleNode < NodeTypes . CommentStart > ;
65+ export type ScriptTagContentNode = SimpleNode < NodeTypes . ScriptTagContent > ;
3266
33- export type CommentEndNode = SimpleNode < NodeTypes . CommentEnd > ;
67+ export interface StyleTagNode extends BaseNode {
68+ type : NodeTypes . StyleTag ;
69+ attributes : Array < AttributeNode > ;
70+ openStart : OpenTagStartStyleNode ;
71+ openEnd : OpenTagEndStyleNode ;
72+ close : CloseTagStyleNode ;
73+ value ?: StyleTagContentNode ;
74+ }
3475
35- export type CommentContentNode = SimpleNode < NodeTypes . CommentContent > ;
76+ export type OpenTagStartStyleNode = SimpleNode < NodeTypes . OpenTagStartStyle > ;
3677
37- export type ScriptTagContentNode = SimpleNode < NodeTypes . ScriptTagContent > ;
78+ export type OpenTagEndStyleNode = SimpleNode < NodeTypes . OpenTagEndStyle > ;
3879
3980export type StyleTagContentNode = SimpleNode < NodeTypes . StyleTagContent > ;
4081
41- export type DoctypeStartNode = SimpleNode < NodeTypes . DoctypeStart > ;
42-
43- export type CloseTagScriptNode = SimpleNode < NodeTypes . CloseTagScript > ;
44-
4582export type CloseTagStyleNode = SimpleNode < NodeTypes . CloseTagStyle > ;
4683
47- export type DoctypeAttributeValueNode =
48- SimpleNode < NodeTypes . DoctypeAttributeValue > ;
49-
50- export type DoctypeAttributeWrapperStart =
51- SimpleNode < NodeTypes . DoctypeAttributeWrapperStart > ;
84+ export interface CommentNode extends BaseNode {
85+ type : NodeTypes . Comment ;
86+ start : CommentStartNode ;
87+ end : CommentEndNode ;
88+ value : CommentContentNode ;
89+ }
5290
53- export type DoctypeAttributeWrapperEnd =
54- SimpleNode < NodeTypes . DoctypeAttributeWrapperEnd > ;
91+ export type CommentStartNode = SimpleNode < NodeTypes . CommentStart > ;
5592
56- export interface DocumentNode extends BaseNode {
57- type : NodeTypes . Document ;
58- children : Array <
59- TextNode | TagNode | ScriptNode | StyleNode | CommentNode | TextNode
60- > ;
61- }
93+ export type CommentEndNode = SimpleNode < NodeTypes . CommentEnd > ;
6294
63- export interface TagNode extends BaseNode {
64- type : NodeTypes . Tag ;
65- selfClosing : boolean ;
66- name : string ;
67- close ?: CloseTagNode ;
68- openEnd : OpenTagEndNode ;
69- openStart : OpenTagStartNode ;
70- children : Array <
71- TextNode | TagNode | ScriptNode | StyleNode | CommentNode | TextNode
72- > ;
73- attributes : Array < AttributeNode > ;
74- }
95+ export type CommentContentNode = SimpleNode < NodeTypes . CommentContent > ;
7596
76- export interface AttributeNode extends BaseNode {
77- type : NodeTypes . Attribute ;
78- key : AttributeKeyNode ;
79- startWrapper ?: AttributeValueWrapperStartNode ;
80- value ?: AttributeValueNode ;
81- endWrapper ?: AttributeValueWrapperEndNode ;
97+ export interface DoctypeNode extends BaseNode {
98+ type : NodeTypes . Doctype ;
99+ start : DoctypeStartNode ;
100+ end : DoctypeEndNode ;
82101}
83102
84- export interface StyleNode extends BaseNode {
85- type : NodeTypes . StyleTag ;
86- attributes : Array < AttributeNode > ;
87- openStart : OpenTagStartStyleNode ;
88- openEnd : OpenTagEndStyleNode ;
89- close : CloseTagStyleNode ;
90- value ?: StyleTagContentNode ;
91- }
103+ export type DoctypeStartNode = SimpleNode < NodeTypes . DoctypeStart > ;
92104
93- export interface ScriptNode extends BaseNode {
94- type : NodeTypes . ScriptTag ;
95- attributes : Array < AttributeNode > ;
96- openStart : OpenTagStartScriptNode ;
97- openEnd : OpenTagEndScriptNode ;
98- close : CloseTagScriptNode ;
99- value ?: ScriptTagContentNode ;
100- }
105+ export type DoctypeEndNode = SimpleNode < NodeTypes . DoctypeEnd > ;
101106
102107export interface DoctypeAttributeNode extends BaseNode {
103108 type : NodeTypes . Attribute ;
@@ -107,15 +112,11 @@ export interface DoctypeAttributeNode extends BaseNode {
107112 endWrapper ?: DoctypeAttributeWrapperEnd ;
108113}
109114
110- export interface DoctypeNode extends BaseNode {
111- type : NodeTypes . Doctype ;
112- start : DoctypeStartNode ;
113- end : DoctypeNode ;
114- }
115+ export type DoctypeAttributeValueNode =
116+ SimpleNode < NodeTypes . DoctypeAttributeValue > ;
115117
116- export interface CommentNode extends BaseNode {
117- type : NodeTypes . Comment ;
118- start : CommentStartNode ;
119- end : CommentEndNode ;
120- value : CommentContentNode ;
121- }
118+ export type DoctypeAttributeWrapperStart =
119+ SimpleNode < NodeTypes . DoctypeAttributeWrapperStart > ;
120+
121+ export type DoctypeAttributeWrapperEnd =
122+ SimpleNode < NodeTypes . DoctypeAttributeWrapperEnd > ;
0 commit comments