@mtkruto/node 0.1.200 → 0.1.201

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/esm/client/4_client.d.ts +5 -8
  2. package/esm/client/4_client.js +5 -14
  3. package/package.json +1 -1
  4. package/script/client/4_client.d.ts +5 -8
  5. package/script/client/4_client.js +5 -14
  6. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/DomHandler.d.ts +0 -83
  7. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/DomHandler.js +0 -203
  8. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/DomSerializer.d.ts +0 -50
  9. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/DomSerializer.js +0 -274
  10. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/ElementType.d.ts +0 -47
  11. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/ElementType.js +0 -51
  12. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/FeedHandler.d.ts +0 -66
  13. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/FeedHandler.js +0 -191
  14. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/Node.d.ts +0 -168
  15. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/Node.js +0 -385
  16. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/Parser.d.ts +0 -159
  17. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/Parser.js +0 -431
  18. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/Tokenizer.d.ts +0 -181
  19. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/Tokenizer.js +0 -1046
  20. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/mod.d.ts +0 -42
  21. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/mod.js +0 -52
  22. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode.d.ts +0 -11
  23. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode.js +0 -122
  24. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode_codepoint.d.ts +0 -1
  25. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode_codepoint.js +0 -24
  26. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/encode.d.ts +0 -46
  27. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/encode.js +0 -121
  28. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/decode.d.ts +0 -31
  29. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/decode.js +0 -30
  30. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/entities.d.ts +0 -2128
  31. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/entities.js +0 -2127
  32. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/legacy.d.ts +0 -109
  33. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/legacy.js +0 -108
  34. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/xml.d.ts +0 -8
  35. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/xml.js +0 -1
  36. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/mod.d.ts +0 -90
  37. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/mod.js +0 -95
  38. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/helpers.d.ts +0 -50
  39. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/helpers.js +0 -128
  40. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/legacy.d.ts +0 -46
  41. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/legacy.js +0 -110
  42. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/manipulation.d.ts +0 -42
  43. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/manipulation.js +0 -120
  44. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/mod.d.ts +0 -6
  45. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/mod.js +0 -6
  46. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/querying.d.ts +0 -54
  47. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/querying.js +0 -110
  48. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/stringify.d.ts +0 -40
  49. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/stringify.js +0 -75
  50. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/traversal.d.ts +0 -58
  51. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/traversal.js +0 -101
  52. package/script/deps/deno.land/x/html_parser@v0.1.3/src/DomHandler.d.ts +0 -83
  53. package/script/deps/deno.land/x/html_parser@v0.1.3/src/DomHandler.js +0 -207
  54. package/script/deps/deno.land/x/html_parser@v0.1.3/src/DomSerializer.d.ts +0 -50
  55. package/script/deps/deno.land/x/html_parser@v0.1.3/src/DomSerializer.js +0 -301
  56. package/script/deps/deno.land/x/html_parser@v0.1.3/src/ElementType.d.ts +0 -47
  57. package/script/deps/deno.land/x/html_parser@v0.1.3/src/ElementType.js +0 -55
  58. package/script/deps/deno.land/x/html_parser@v0.1.3/src/FeedHandler.d.ts +0 -66
  59. package/script/deps/deno.land/x/html_parser@v0.1.3/src/FeedHandler.js +0 -222
  60. package/script/deps/deno.land/x/html_parser@v0.1.3/src/Node.d.ts +0 -168
  61. package/script/deps/deno.land/x/html_parser@v0.1.3/src/Node.js +0 -404
  62. package/script/deps/deno.land/x/html_parser@v0.1.3/src/Parser.d.ts +0 -159
  63. package/script/deps/deno.land/x/html_parser@v0.1.3/src/Parser.js +0 -438
  64. package/script/deps/deno.land/x/html_parser@v0.1.3/src/Tokenizer.d.ts +0 -181
  65. package/script/deps/deno.land/x/html_parser@v0.1.3/src/Tokenizer.js +0 -1052
  66. package/script/deps/deno.land/x/html_parser@v0.1.3/src/mod.d.ts +0 -42
  67. package/script/deps/deno.land/x/html_parser@v0.1.3/src/mod.js +0 -88
  68. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode.d.ts +0 -11
  69. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode.js +0 -128
  70. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode_codepoint.d.ts +0 -1
  71. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode_codepoint.js +0 -30
  72. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/encode.d.ts +0 -46
  73. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/encode.js +0 -129
  74. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/decode.d.ts +0 -31
  75. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/decode.js +0 -32
  76. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/entities.d.ts +0 -2128
  77. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/entities.js +0 -2129
  78. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/legacy.d.ts +0 -109
  79. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/legacy.js +0 -110
  80. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/xml.d.ts +0 -8
  81. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/xml.js +0 -3
  82. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/mod.d.ts +0 -90
  83. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/mod.js +0 -114
  84. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/helpers.d.ts +0 -50
  85. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/helpers.js +0 -134
  86. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/legacy.d.ts +0 -46
  87. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/legacy.js +0 -118
  88. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/manipulation.d.ts +0 -42
  89. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/manipulation.js +0 -129
  90. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/mod.d.ts +0 -6
  91. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/mod.js +0 -22
  92. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/querying.d.ts +0 -54
  93. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/querying.js +0 -119
  94. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/stringify.d.ts +0 -40
  95. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/stringify.js +0 -86
  96. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/traversal.d.ts +0 -58
  97. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/traversal.js +0 -112
@@ -1,168 +0,0 @@
1
- import { ElementType } from './ElementType.js';
2
- /**
3
- * This object will be used as the prototype for Nodes when creating a
4
- * DOM-Level-1-compliant structure.
5
- */
6
- export declare class Node {
7
- type: ElementType;
8
- /** Parent of the node */
9
- parent: NodeWithChildren | null;
10
- /** Previous sibling */
11
- prev: Node | null;
12
- /** Next sibling */
13
- next: Node | null;
14
- /** The start index of the node. Requires `withStartIndices` on the handler to be `true. */
15
- startIndex: number | null;
16
- /** The end index of the node. Requires `withEndIndices` on the handler to be `true. */
17
- endIndex: number | null;
18
- /**
19
- *
20
- * @param type The type of the node.
21
- */
22
- constructor(type: ElementType);
23
- get nodeType(): number;
24
- get parentNode(): NodeWithChildren | null;
25
- set parentNode(parent: NodeWithChildren | null);
26
- get previousSibling(): Node | null;
27
- set previousSibling(prev: Node | null);
28
- get nextSibling(): Node | null;
29
- set nextSibling(next: Node | null);
30
- /**
31
- * Clone this node, and optionally its children.
32
- *
33
- * @param recursive Clone child nodes as well.
34
- * @returns A clone of the node.
35
- */
36
- cloneNode<T extends Node>(this: T, recursive?: boolean): T;
37
- }
38
- /**
39
- * A node that contains some data.
40
- */
41
- export declare class DataNode extends Node {
42
- data: string;
43
- /**
44
- * @param type The type of the node
45
- * @param data The content of the data node
46
- */
47
- constructor(type: ElementType.Comment | ElementType.Text | ElementType.Directive, data: string);
48
- get nodeValue(): string;
49
- set nodeValue(data: string);
50
- }
51
- /**
52
- * Text within the document.
53
- */
54
- export declare class Text extends DataNode {
55
- constructor(data: string);
56
- }
57
- /**
58
- * Comments within the document.
59
- */
60
- export declare class Comment extends DataNode {
61
- constructor(data: string);
62
- }
63
- /**
64
- * Processing instructions, including doc types.
65
- */
66
- export declare class ProcessingInstruction extends DataNode {
67
- name: string;
68
- constructor(name: string, data: string);
69
- 'x-name'?: string;
70
- 'x-publicId'?: string;
71
- 'x-systemId'?: string;
72
- }
73
- /**
74
- * A `Node` that can have children.
75
- */
76
- export declare class NodeWithChildren extends Node {
77
- children: Node[];
78
- /**
79
- * @param type Type of the node.
80
- * @param children Children of the node. Only certain node types can have children.
81
- */
82
- constructor(type: ElementType.Root | ElementType.CDATA | ElementType.Script | ElementType.Style | ElementType.Tag, children: Node[]);
83
- get firstChild(): Node | null;
84
- get lastChild(): Node | null;
85
- get childNodes(): Node[];
86
- set childNodes(children: Node[]);
87
- }
88
- /**
89
- * The root node of the document.
90
- */
91
- export declare class Document extends NodeWithChildren {
92
- constructor(children: Node[]);
93
- 'x-mode'?: 'no-quirks' | 'quirks' | 'limited-quirks';
94
- }
95
- /**
96
- * The description of an individual attribute.
97
- */
98
- interface Attribute {
99
- name: string;
100
- value: string;
101
- namespace?: string;
102
- prefix?: string;
103
- }
104
- /**
105
- * An element within the DOM.
106
- */
107
- export declare class Element extends NodeWithChildren {
108
- name: string;
109
- attribs: {
110
- [name: string]: string;
111
- };
112
- /**
113
- * @param name Name of the tag, eg. `div`, `span`.
114
- * @param attribs Object mapping attribute names to attribute values.
115
- * @param children Children of the node.
116
- */
117
- constructor(name: string, attribs: {
118
- [name: string]: string;
119
- }, children?: Node[], type?: ElementType.Tag | ElementType.Script | ElementType.Style);
120
- get tagName(): string;
121
- set tagName(name: string);
122
- get attributes(): Attribute[];
123
- 'x-attribsNamespace'?: Record<string, string>;
124
- 'x-attribsPrefix'?: Record<string, string>;
125
- }
126
- /**
127
- * @param node Node to check.
128
- * @returns `true` if the node is a `Element`, `false` otherwise.
129
- */
130
- export declare function isTag(node: Node): node is Element;
131
- /**
132
- * @param node Node to check.
133
- * @returns `true` if the node has the type `CDATA`, `false` otherwise.
134
- */
135
- export declare function isCDATA(node: Node): node is NodeWithChildren;
136
- /**
137
- * @param node Node to check.
138
- * @returns `true` if the node has the type `Text`, `false` otherwise.
139
- */
140
- export declare function isText(node: Node): node is Text;
141
- /**
142
- * @param node Node to check.
143
- * @returns `true` if the node has the type `Comment`, `false` otherwise.
144
- */
145
- export declare function isComment(node: Node): node is DataNode;
146
- /**
147
- * @param node Node to check.
148
- * @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.
149
- */
150
- export declare function isDirective(node: Node): node is ProcessingInstruction;
151
- /**
152
- * @param node Node to check.
153
- * @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.
154
- */
155
- export declare function isDocument(node: Node): node is Document;
156
- /**
157
- * @param node Node to check.
158
- * @returns `true` if the node is a `NodeWithChildren` (has children), `false` otherwise.
159
- */
160
- export declare function hasChildren(node: Node): node is NodeWithChildren;
161
- /**
162
- * Clone a node, and optionally its children.
163
- *
164
- * @param recursive Clone child nodes as well.
165
- * @returns A clone of the node.
166
- */
167
- export declare function cloneNode<T extends Node>(node: T, recursive?: boolean): T;
168
- export {};
@@ -1,404 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.cloneNode = exports.hasChildren = exports.isDocument = exports.isDirective = exports.isComment = exports.isText = exports.isCDATA = exports.isTag = exports.Element = exports.Document = exports.NodeWithChildren = exports.ProcessingInstruction = exports.Comment = exports.Text = exports.DataNode = exports.Node = void 0;
4
- const ElementType_js_1 = require("./ElementType.js");
5
- const nodeTypes = new Map([
6
- [ElementType_js_1.ElementType.Tag, 1],
7
- [ElementType_js_1.ElementType.Script, 1],
8
- [ElementType_js_1.ElementType.Style, 1],
9
- [ElementType_js_1.ElementType.Directive, 1],
10
- [ElementType_js_1.ElementType.Text, 3],
11
- [ElementType_js_1.ElementType.CDATA, 4],
12
- [ElementType_js_1.ElementType.Comment, 8],
13
- [ElementType_js_1.ElementType.Root, 9],
14
- ]);
15
- /**
16
- * This object will be used as the prototype for Nodes when creating a
17
- * DOM-Level-1-compliant structure.
18
- */
19
- class Node {
20
- /**
21
- *
22
- * @param type The type of the node.
23
- */
24
- constructor(type) {
25
- Object.defineProperty(this, "type", {
26
- enumerable: true,
27
- configurable: true,
28
- writable: true,
29
- value: type
30
- });
31
- /** Parent of the node */
32
- Object.defineProperty(this, "parent", {
33
- enumerable: true,
34
- configurable: true,
35
- writable: true,
36
- value: null
37
- });
38
- /** Previous sibling */
39
- Object.defineProperty(this, "prev", {
40
- enumerable: true,
41
- configurable: true,
42
- writable: true,
43
- value: null
44
- });
45
- /** Next sibling */
46
- Object.defineProperty(this, "next", {
47
- enumerable: true,
48
- configurable: true,
49
- writable: true,
50
- value: null
51
- });
52
- /** The start index of the node. Requires `withStartIndices` on the handler to be `true. */
53
- Object.defineProperty(this, "startIndex", {
54
- enumerable: true,
55
- configurable: true,
56
- writable: true,
57
- value: null
58
- });
59
- /** The end index of the node. Requires `withEndIndices` on the handler to be `true. */
60
- Object.defineProperty(this, "endIndex", {
61
- enumerable: true,
62
- configurable: true,
63
- writable: true,
64
- value: null
65
- });
66
- }
67
- // Read-only aliases
68
- get nodeType() {
69
- return nodeTypes.get(this.type) ?? 1;
70
- }
71
- // Read-write aliases for properties
72
- get parentNode() {
73
- return this.parent;
74
- }
75
- set parentNode(parent) {
76
- this.parent = parent;
77
- }
78
- get previousSibling() {
79
- return this.prev;
80
- }
81
- set previousSibling(prev) {
82
- this.prev = prev;
83
- }
84
- get nextSibling() {
85
- return this.next;
86
- }
87
- set nextSibling(next) {
88
- this.next = next;
89
- }
90
- /**
91
- * Clone this node, and optionally its children.
92
- *
93
- * @param recursive Clone child nodes as well.
94
- * @returns A clone of the node.
95
- */
96
- cloneNode(recursive = false) {
97
- return cloneNode(this, recursive);
98
- }
99
- }
100
- exports.Node = Node;
101
- /**
102
- * A node that contains some data.
103
- */
104
- class DataNode extends Node {
105
- /**
106
- * @param type The type of the node
107
- * @param data The content of the data node
108
- */
109
- constructor(type, data) {
110
- super(type);
111
- Object.defineProperty(this, "data", {
112
- enumerable: true,
113
- configurable: true,
114
- writable: true,
115
- value: data
116
- });
117
- }
118
- get nodeValue() {
119
- return this.data;
120
- }
121
- set nodeValue(data) {
122
- this.data = data;
123
- }
124
- }
125
- exports.DataNode = DataNode;
126
- /**
127
- * Text within the document.
128
- */
129
- class Text extends DataNode {
130
- constructor(data) {
131
- super(ElementType_js_1.ElementType.Text, data);
132
- }
133
- }
134
- exports.Text = Text;
135
- /**
136
- * Comments within the document.
137
- */
138
- class Comment extends DataNode {
139
- constructor(data) {
140
- super(ElementType_js_1.ElementType.Comment, data);
141
- }
142
- }
143
- exports.Comment = Comment;
144
- /**
145
- * Processing instructions, including doc types.
146
- */
147
- class ProcessingInstruction extends DataNode {
148
- constructor(name, data) {
149
- super(ElementType_js_1.ElementType.Directive, data);
150
- Object.defineProperty(this, "name", {
151
- enumerable: true,
152
- configurable: true,
153
- writable: true,
154
- value: name
155
- });
156
- Object.defineProperty(this, 'x-name', {
157
- enumerable: true,
158
- configurable: true,
159
- writable: true,
160
- value: void 0
161
- });
162
- Object.defineProperty(this, 'x-publicId', {
163
- enumerable: true,
164
- configurable: true,
165
- writable: true,
166
- value: void 0
167
- });
168
- Object.defineProperty(this, 'x-systemId', {
169
- enumerable: true,
170
- configurable: true,
171
- writable: true,
172
- value: void 0
173
- });
174
- }
175
- }
176
- exports.ProcessingInstruction = ProcessingInstruction;
177
- /**
178
- * A `Node` that can have children.
179
- */
180
- class NodeWithChildren extends Node {
181
- /**
182
- * @param type Type of the node.
183
- * @param children Children of the node. Only certain node types can have children.
184
- */
185
- constructor(type, children) {
186
- super(type);
187
- Object.defineProperty(this, "children", {
188
- enumerable: true,
189
- configurable: true,
190
- writable: true,
191
- value: children
192
- });
193
- }
194
- // Aliases
195
- get firstChild() {
196
- return this.children[0] ?? null;
197
- }
198
- get lastChild() {
199
- return this.children.length > 0
200
- ? this.children[this.children.length - 1]
201
- : null;
202
- }
203
- get childNodes() {
204
- return this.children;
205
- }
206
- set childNodes(children) {
207
- this.children = children;
208
- }
209
- }
210
- exports.NodeWithChildren = NodeWithChildren;
211
- /**
212
- * The root node of the document.
213
- */
214
- class Document extends NodeWithChildren {
215
- constructor(children) {
216
- super(ElementType_js_1.ElementType.Root, children);
217
- Object.defineProperty(this, 'x-mode', {
218
- enumerable: true,
219
- configurable: true,
220
- writable: true,
221
- value: void 0
222
- });
223
- }
224
- }
225
- exports.Document = Document;
226
- /**
227
- * An element within the DOM.
228
- */
229
- class Element extends NodeWithChildren {
230
- /**
231
- * @param name Name of the tag, eg. `div`, `span`.
232
- * @param attribs Object mapping attribute names to attribute values.
233
- * @param children Children of the node.
234
- */
235
- constructor(name, attribs, children = [], type = name === 'script'
236
- ? ElementType_js_1.ElementType.Script
237
- : name === 'style'
238
- ? ElementType_js_1.ElementType.Style
239
- : ElementType_js_1.ElementType.Tag) {
240
- super(type, children);
241
- Object.defineProperty(this, "name", {
242
- enumerable: true,
243
- configurable: true,
244
- writable: true,
245
- value: name
246
- });
247
- Object.defineProperty(this, "attribs", {
248
- enumerable: true,
249
- configurable: true,
250
- writable: true,
251
- value: attribs
252
- });
253
- Object.defineProperty(this, 'x-attribsNamespace', {
254
- enumerable: true,
255
- configurable: true,
256
- writable: true,
257
- value: void 0
258
- });
259
- Object.defineProperty(this, 'x-attribsPrefix', {
260
- enumerable: true,
261
- configurable: true,
262
- writable: true,
263
- value: void 0
264
- });
265
- }
266
- // DOM Level 1 aliases
267
- get tagName() {
268
- return this.name;
269
- }
270
- set tagName(name) {
271
- this.name = name;
272
- }
273
- get attributes() {
274
- return Object.keys(this.attribs).map(name => ({
275
- name,
276
- value: this.attribs[name],
277
- namespace: this['x-attribsNamespace']?.[name],
278
- prefix: this['x-attribsPrefix']?.[name],
279
- }));
280
- }
281
- }
282
- exports.Element = Element;
283
- /**
284
- * @param node Node to check.
285
- * @returns `true` if the node is a `Element`, `false` otherwise.
286
- */
287
- function isTag(node) {
288
- return (0, ElementType_js_1.isTag)(node);
289
- }
290
- exports.isTag = isTag;
291
- /**
292
- * @param node Node to check.
293
- * @returns `true` if the node has the type `CDATA`, `false` otherwise.
294
- */
295
- function isCDATA(node) {
296
- return node.type === ElementType_js_1.ElementType.CDATA;
297
- }
298
- exports.isCDATA = isCDATA;
299
- /**
300
- * @param node Node to check.
301
- * @returns `true` if the node has the type `Text`, `false` otherwise.
302
- */
303
- function isText(node) {
304
- return node.type === ElementType_js_1.ElementType.Text;
305
- }
306
- exports.isText = isText;
307
- /**
308
- * @param node Node to check.
309
- * @returns `true` if the node has the type `Comment`, `false` otherwise.
310
- */
311
- function isComment(node) {
312
- return node.type === ElementType_js_1.ElementType.Comment;
313
- }
314
- exports.isComment = isComment;
315
- /**
316
- * @param node Node to check.
317
- * @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.
318
- */
319
- function isDirective(node) {
320
- return node.type === ElementType_js_1.ElementType.Directive;
321
- }
322
- exports.isDirective = isDirective;
323
- /**
324
- * @param node Node to check.
325
- * @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.
326
- */
327
- function isDocument(node) {
328
- return node.type === ElementType_js_1.ElementType.Root;
329
- }
330
- exports.isDocument = isDocument;
331
- /**
332
- * @param node Node to check.
333
- * @returns `true` if the node is a `NodeWithChildren` (has children), `false` otherwise.
334
- */
335
- function hasChildren(node) {
336
- return Object.prototype.hasOwnProperty.call(node, 'children');
337
- }
338
- exports.hasChildren = hasChildren;
339
- /**
340
- * Clone a node, and optionally its children.
341
- *
342
- * @param recursive Clone child nodes as well.
343
- * @returns A clone of the node.
344
- */
345
- function cloneNode(node, recursive = false) {
346
- let result;
347
- if (isText(node)) {
348
- result = new Text(node.data);
349
- }
350
- else if (isComment(node)) {
351
- result = new Comment(node.data);
352
- }
353
- else if (isTag(node)) {
354
- const children = recursive ? cloneChildren(node.children) : [];
355
- const clone = new Element(node.name, { ...node.attribs }, children);
356
- children.forEach(child => (child.parent = clone));
357
- if (node['x-attribsNamespace']) {
358
- clone['x-attribsNamespace'] = { ...node['x-attribsNamespace'] };
359
- }
360
- if (node['x-attribsPrefix']) {
361
- clone['x-attribsPrefix'] = { ...node['x-attribsPrefix'] };
362
- }
363
- result = clone;
364
- }
365
- else if (isCDATA(node)) {
366
- const children = recursive ? cloneChildren(node.children) : [];
367
- const clone = new NodeWithChildren(ElementType_js_1.ElementType.CDATA, children);
368
- children.forEach(child => (child.parent = clone));
369
- result = clone;
370
- }
371
- else if (isDocument(node)) {
372
- const children = recursive ? cloneChildren(node.children) : [];
373
- const clone = new Document(children);
374
- children.forEach(child => (child.parent = clone));
375
- if (node['x-mode']) {
376
- clone['x-mode'] = node['x-mode'];
377
- }
378
- result = clone;
379
- }
380
- else if (isDirective(node)) {
381
- const instruction = new ProcessingInstruction(node.name, node.data);
382
- if (node['x-name'] != null) {
383
- instruction['x-name'] = node['x-name'];
384
- instruction['x-publicId'] = node['x-publicId'];
385
- instruction['x-systemId'] = node['x-systemId'];
386
- }
387
- result = instruction;
388
- }
389
- else {
390
- throw new Error(`Not implemented yet: ${node.type}`);
391
- }
392
- result.startIndex = node.startIndex;
393
- result.endIndex = node.endIndex;
394
- return result;
395
- }
396
- exports.cloneNode = cloneNode;
397
- function cloneChildren(childs) {
398
- const children = childs.map(child => cloneNode(child, true));
399
- for (let i = 1; i < children.length; i++) {
400
- children[i].prev = children[i - 1];
401
- children[i - 1].next = children[i];
402
- }
403
- return children;
404
- }