@e-mc/document 0.0.1

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.
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@e-mc/document",
3
+ "version": "0.0.1",
4
+ "description": "Document constructor for e-mc.",
5
+ "main": "index.js",
6
+ "types": "index.d.ts",
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/anpham6/e-mc.git",
13
+ "directory": "src/document"
14
+ },
15
+ "keywords": [
16
+ "squared",
17
+ "squared-functions"
18
+ ],
19
+ "author": "An Pham <anpham6@gmail.com>",
20
+ "license": "BSD 3-Clause",
21
+ "homepage": "https://github.com/anpham6/e-mc#readme",
22
+ "dependencies": {
23
+ "@e-mc/core": "0.0.1",
24
+ "@e-mc/db": "0.0.1",
25
+ "chalk": "4.1.2",
26
+ "htmlparser2": "^8.0.1",
27
+ "jimp": "^0.22.7",
28
+ "js-yaml": "^4.1.0",
29
+ "picomatch": "^2.3.1"
30
+ }
31
+ }
@@ -0,0 +1,237 @@
1
+ import type { XmlTagNode as IXmlTagNode, TagAppend, TagData } from '../../types/lib/squared';
2
+
3
+ // @ts-ignore
4
+ import type { ParserOptions } from 'htmlparser2';
5
+ // @ts-ignore
6
+ import type { AnyNode, Element } from 'domhandler';
7
+
8
+ export interface IGNORE_FLAG {
9
+ NONE: 0;
10
+ INTERIOR: 1;
11
+ LOCATOR: 2;
12
+ }
13
+
14
+ export interface ParserAction {
15
+ parser?: ParserOptions;
16
+ outDom?: AnyNode[];
17
+ }
18
+
19
+ export interface SourceIndex {
20
+ startIndex: number;
21
+ endIndex: number;
22
+ }
23
+
24
+ export interface SourceContent extends SourceIndex {
25
+ outerXml: string;
26
+ type?: "node" | "comment" | "cdata" | "block";
27
+ }
28
+
29
+ export interface SourceTagNode extends SourceContent, TagData {
30
+ id?: string;
31
+ ignoreCase?: boolean;
32
+ }
33
+
34
+ export interface XmlTagNode extends IXmlTagNode, Partial<SourceIndex> {}
35
+
36
+ export type AttributeMap = Map<string, unknown>;
37
+ export type AttributeList = [string, unknown][];
38
+ export type TagOffsetMap = ObjectMap<Undef<number>>;
39
+ export type WriteResult = [string, string, Null<Error>?];
40
+ export type SaveResult = [string, Null<Error>?];
41
+ export type XmlWriterOptions = ParserAction;
42
+
43
+ export interface ParserResult extends Partial<TagData>, ParserAction {
44
+ element: Null<Element>;
45
+ error: Null<Error>;
46
+ }
47
+
48
+ export interface ReplaceOptions extends SourceIndex {
49
+ append?: TagAppend;
50
+ remove?: boolean;
51
+ }
52
+
53
+ export interface FindElementOptions extends ParserAction {
54
+ document?: string;
55
+ id?: string;
56
+ locatorAttr?: string;
57
+ tagCount?: number;
58
+ }
59
+
60
+ export interface TagOffsetOptions extends ParserAction {
61
+ ignoreCase?: boolean;
62
+ ignoreTagName?: string;
63
+ ignoreTagGroup?: string[];
64
+ }
65
+
66
+ export interface TagNodeOptions {
67
+ tagVoid?: boolean;
68
+ }
69
+
70
+ export interface TagNodeByIdOptions extends TagNodeOptions {
71
+ tagName?: string;
72
+ }
73
+
74
+ export interface XmlElementOptions extends TagNodeOptions, ParserAction {}
75
+
76
+ export interface DomWriterOptions extends ParserAction {
77
+ normalize?: boolean | string;
78
+ ignoreTagGroup?: string[];
79
+ escapeEntities?: boolean;
80
+ stripComments?: boolean | string;
81
+ }
82
+
83
+ export interface ReplaceMatchOptions {
84
+ pattern?: RegExp;
85
+ trimLeading?: boolean;
86
+ trimTrailing?: boolean;
87
+ }
88
+
89
+ export interface NormalizeOptions {
90
+ newline?: string;
91
+ ignoreChar?: string;
92
+ ignoreTagGroup?: string[];
93
+ escapeEntities?: boolean;
94
+ }
95
+
96
+ export class IXmlBase {
97
+ newline: string;
98
+ readonly documentName: string;
99
+ write(...args: unknown[]): unknown;
100
+ save(...args: unknown[]): unknown;
101
+ reset(): void;
102
+ get nameOfId(): string;
103
+ get patternId(): RegExp;
104
+ get modified(): boolean;
105
+ }
106
+
107
+ export class IXmlWriter extends IXmlBase {
108
+ elements: XmlTagNode[];
109
+ parser?: ParserOptions;
110
+ ignoreTagName?: string;
111
+ ignoreTagGroup?: string[];
112
+ readonly rootName?: string;
113
+ readonly ignoreCaseTagName?: boolean;
114
+ init(offsetMap?: TagOffsetMap): void;
115
+ getInvalidArea(): Undef<SourceContent[]>;
116
+ ignoreFlag(...values: number[]): void;
117
+ insertNodes(nodes?: XmlTagNode[]): void;
118
+ fromNode(node: XmlTagNode, append?: TagAppend): IXmlElement;
119
+ newElement(node: XmlTagNode): IXmlElement;
120
+ append(node: XmlTagNode): Null<IXmlElement>;
121
+ write(element: IXmlElement): boolean;
122
+ save(): string;
123
+ close(): string;
124
+ update(node: XmlTagNode, outerXml: string, append?: TagAppend, offsetMap?: Null<TagOffsetMap>): void;
125
+ increment(nodes: XmlTagNode[], offset?: number): void;
126
+ decrement(node: XmlTagNode, offset?: number, remove?: boolean): XmlTagNode[];
127
+ renameTag(node: XmlTagNode, tagName: string): void;
128
+ indexTag(tagName: string, append?: TagAppend, offset?: number): void;
129
+ resetTag(tagName: string): void;
130
+ ignoreTag(value: string): void;
131
+ resetPosition(startIndex?: number): void;
132
+ getElementById(id: string, ignoreCase?: boolean, options?: TagNodeByIdOptions): Undef<SourceTagNode>;
133
+ getElementsByTagName(tagName: string, ignoreCase?: boolean, options?: TagNodeOptions): SourceTagNode[];
134
+ setRawString(targetXml: string, outerXml: string): string;
135
+ getRawString(index: SourceIndex): string;
136
+ spliceRawString(content: SourceContent, reset?: boolean): string;
137
+ getComments(): Null<SourceContent[]>;
138
+ hasErrors(): boolean;
139
+ get newId(): string;
140
+ get patternIgnore(): Null<RegExp>;
141
+ set source(value);
142
+ get source(): string;
143
+ }
144
+
145
+ export interface XmlWriterConstructor {
146
+ readonly PATTERN_ATTRNAME: string;
147
+ readonly PATTERN_ATTRVALUE: string;
148
+ readonly PATTERN_TAGNAME: string;
149
+ readonly PATTERN_TAGOPEN: string;
150
+ readonly PATTERN_QUOTEVALUE: string;
151
+ readonly PATTERN_COMMENT: string;
152
+ readonly PATTERN_TRAILINGSPACE: string;
153
+ replaceMatch(match: RegExpMatchArray, source: string, content: NumString, options: ReplaceMatchOptions): string;
154
+ replaceMatch(match: RegExpMatchArray, source: string, content?: NumString, pattern?: RegExp): string;
155
+ escapeXmlString(value: string, ampersand?: boolean): string;
156
+ escapeAttributes(source: string): string;
157
+ getNewlineString(leading: string, trailing: string, newline?: string): string;
158
+ findCloseTag(source: string, startIndex?: number): number;
159
+ findElement(source: string, node: XmlTagNode, options?: FindElementOptions): ParserResult;
160
+ getTagOffset(source: string, options?: TagOffsetOptions): TagOffsetMap;
161
+ getTagOffset(source: string, replacement?: string, options?: TagOffsetOptions): TagOffsetMap;
162
+ getNodeId(node: XmlTagNode, document: string): string;
163
+ getNameOfId(document: string): string;
164
+ getCommentsAndCDATA(source: string, tagPattern: unknown, ignoreCase: boolean, stripXml: true): string;
165
+ getCommentsAndCDATA(source: string, tagPattern?: StringOfArray | [Undef<string>, Undef<string[]>], ignoreCase?: boolean, stripXml?: boolean): SourceContent[];
166
+ isEqual(node: XmlTagNode, other: XmlTagNode, ignoreCase: boolean): boolean;
167
+ isEqual(node: XmlTagNode, other: XmlTagNode, documentName?: string, ignoreCase?: boolean): boolean;
168
+ isIndex(value: Undef<number>): value is number;
169
+ isCount(value: Undef<number>): value is number;
170
+ isSpace(ch: string): boolean;
171
+ readonly prototype: IXmlWriter;
172
+ new(documentName: string, source: string, elements: XmlTagNode[], options?: XmlWriterOptions): IXmlWriter;
173
+ }
174
+
175
+ export class IXmlElement extends IXmlBase {
176
+ TAG_VOID: string[];
177
+ parser?: ParserOptions;
178
+ readonly node: XmlTagNode;
179
+ setAppend(value?: TagAppend): void;
180
+ parseOuterXml(value?: string, tagVoid?: boolean): [string, string, boolean];
181
+ getTagOffset(replacement?: string, options?: TagOffsetOptions): Undef<TagOffsetMap>;
182
+ setAttribute(name: string, value: string): void;
183
+ getAttribute(name: string): Optional<string>;
184
+ removeAttribute(...names: string[]): void;
185
+ hasAttribute(name: string): boolean;
186
+ hasModifiedContent(): boolean;
187
+ write(source: string, invalid?: SourceIndex[]): WriteResult;
188
+ save(source: string, invalid?: SourceIndex[]): SaveResult;
189
+ replace(source: string, options: ReplaceOptions): WriteResult;
190
+ findIndexOf(source: string): Undef<SourceIndex>;
191
+ getOuterContent(): [string, AttributeList, string];
192
+ getInnerOffset(tagName: string): number;
193
+ hasPosition(): boolean;
194
+ set id(value: string);
195
+ get id(): string;
196
+ set tagName(value: string);
197
+ get tagName(): string;
198
+ get tagVoid(): boolean;
199
+ set innerXml(value: string);
200
+ get innerXml(): string;
201
+ get outerXml(): string;
202
+ set remove(value);
203
+ get remove(): boolean;
204
+ get append(): Undef<TagAppend>;
205
+ set tagOffset(value: Undef<TagOffsetMap>);
206
+ get tagOffset(): Undef<TagOffsetMap>;
207
+ get ignoreCase(): boolean;
208
+ }
209
+
210
+ export interface XmlElementConstructor {
211
+ writeAttributes(attrs: AttributeMap | AttributeList, escapeEntities?: boolean): string;
212
+ readonly prototype: IXmlElement;
213
+ new(documentName: string, node: XmlTagNode, attributes?: PlainObject, options?: XmlElementOptions): IXmlElement;
214
+ new(documentName: string, node: XmlTagNode, attributes?: PlainObject, tagVoid?: boolean, parser?: ParserOptions): IXmlElement;
215
+ }
216
+
217
+ export class IDomWriter extends IXmlWriter {
218
+ documentElement: Null<XmlTagNode>;
219
+ readonly initOpts: DomWriterOptions;
220
+ }
221
+
222
+ export interface DomWriterConstructor extends XmlWriterConstructor {
223
+ hasInnerXml(tagName: string): boolean;
224
+ normalize(source: string, options: NormalizeOptions): string;
225
+ normalize(source: string, newline?: string, ignoreChar?: string, escapeEntities?: boolean): string;
226
+ getDocumentElement(source: string, parser?: ParserOptions): ParserResult;
227
+ getElementsByTagName(tagName: string | ((name: string) => boolean), nodes: ArrayOf<AnyNode>, recurse?: boolean, limit?: number): Element[];
228
+ readonly prototype: IDomWriter;
229
+ new(documentName: string, source: string, elements: XmlTagNode[], options?: DomWriterOptions): IDomWriter;
230
+ new(documentName: string, source: string, elements: XmlTagNode[], normalize?: boolean | string, escapeEntities?: boolean, parser?: ParserOptions): IDomWriter;
231
+ }
232
+
233
+ export class IHtmlElement extends IXmlElement {}
234
+
235
+ export interface HtmlElementConstructor extends XmlElementConstructor {
236
+ new(documentName: string, node: XmlTagNode, attributes?: PlainObject, options?: ParserAction): IHtmlElement;
237
+ }
package/parse/dom.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import type { IGNORE_FLAG, DomWriterConstructor, HtmlElementConstructor } from './document';
2
+
3
+ declare namespace dom {
4
+ const IGNORE_FLAG: IGNORE_FLAG;
5
+ const DomWriter: DomWriterConstructor;
6
+ const HtmlElement: HtmlElementConstructor;
7
+ }
8
+
9
+ export = dom;
package/parse/dom.js ADDED
@@ -0,0 +1,256 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IGNORE_FLAG = exports.HtmlElement = exports.DomWriter = void 0;
4
+ const htmlparser2 = require("htmlparser2");
5
+ const domhandler = require("domhandler");
6
+ const domutils = require("domutils");
7
+ const types_1 = require("../../types");
8
+ const util_1 = require("../util");
9
+ const index_1 = require("./index");
10
+ Object.defineProperty(exports, "IGNORE_FLAG", { enumerable: true, get: function () { return index_1.IGNORE_FLAG; } });
11
+ const Parser = htmlparser2.Parser;
12
+ const DomHandler = domhandler.DomHandler;
13
+ const TAG_VOID = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr'];
14
+ const REGEXP_VOID = TAG_VOID.map(tagName => new RegExp(`(\\s*)</${tagName}\\s*>` + index_1.XmlWriter.PATTERN_TRAILINGSPACE, 'gi'));
15
+ const REGEXP_TAGNAME = new RegExp(`^${index_1.XmlWriter.PATTERN_TAGNAME}$`);
16
+ const PARSER_OPTIONS = Object.freeze({ xmlMode: false, decodeEntities: false });
17
+ class DomWriter extends index_1.XmlWriter {
18
+ static hasInnerXml(tagName) {
19
+ return !TAG_VOID.includes(tagName);
20
+ }
21
+ static normalize(source, newline, ignoreChar = '', escapeEntities) {
22
+ let ignoreTagGroup;
23
+ if ((0, types_1.isObject)(newline)) {
24
+ ({ newline, ignoreChar = '', ignoreTagGroup, escapeEntities } = newline);
25
+ }
26
+ for (const tag of REGEXP_VOID) {
27
+ source = source.replace(tag, (...capture) => index_1.XmlWriter.getNewlineString(capture[1], capture[2], newline));
28
+ }
29
+ const tagGroup = [];
30
+ if (ignoreTagGroup) {
31
+ for (let i = 0, length = ignoreTagGroup.length; i < length; i += 2) {
32
+ const start = ignoreTagGroup[i];
33
+ if (start[0] === '<') {
34
+ tagGroup.push(new RegExp('^' + (0, types_1.escapePattern)(start)));
35
+ }
36
+ const end = ignoreTagGroup[i + 1];
37
+ if (end?.[end.length - 1] === '>') {
38
+ tagGroup.push(new RegExp((0, types_1.escapePattern)(start) + '$'));
39
+ }
40
+ }
41
+ }
42
+ const pattern = new RegExp(`<(?:!--[\\S\\s]*?--|([^\\s<>/${ignoreChar}]+)(${index_1.XmlWriter.PATTERN_TAGOPEN}*?)(\\s*\\/?\\s*)|\\/([^\\s>]+)(\\s*))>`, 'g');
43
+ let match;
44
+ while (match = pattern.exec(source)) {
45
+ let tag;
46
+ if (match[1]) {
47
+ if (!REGEXP_TAGNAME.test(match[1])) {
48
+ if (match[0][1] === '!') {
49
+ if (match[1].toUpperCase() === '!DOCTYPE') {
50
+ continue;
51
+ }
52
+ tag = '<!--' + match[1].substring(1) + match[2] + '-->';
53
+ }
54
+ else if (tagGroup.length === 0 || !tagGroup.some(item => item.test(match[0]))) {
55
+ tag = index_1.XmlWriter.escapeXmlString(match[0]);
56
+ }
57
+ }
58
+ else {
59
+ const trailing = match[match.length - 3];
60
+ if (escapeEntities) {
61
+ const outerTag = '<' + match[1] + match[2] + '>';
62
+ tag = index_1.XmlWriter.escapeAttributes(outerTag);
63
+ if (!trailing && tag === outerTag) {
64
+ continue;
65
+ }
66
+ }
67
+ else if (trailing) {
68
+ tag = '<' + match[1] + match[2] + '>';
69
+ }
70
+ }
71
+ }
72
+ else if (match[7]) {
73
+ if (!REGEXP_TAGNAME.test(match[7])) {
74
+ tag = `<!--${match[7]}-->`;
75
+ }
76
+ else if (match[8]) {
77
+ tag = `</${match[8]}>`;
78
+ }
79
+ }
80
+ if (tag) {
81
+ source = source.substring(0, match.index) + tag + source.substring(match.index + match[0].length);
82
+ pattern.lastIndex += tag.length - match[0].length;
83
+ }
84
+ }
85
+ pattern.lastIndex = 0;
86
+ return source;
87
+ }
88
+ static getDocumentElement(source, parser) {
89
+ const result = { element: null, error: null };
90
+ new Parser(new DomHandler((err, dom) => {
91
+ if (!err) {
92
+ result.element = domutils.findOne(elem => elem.tagName === "html" /* VALUES.ROOT */, dom);
93
+ }
94
+ else {
95
+ result.error = err;
96
+ }
97
+ }, { withStartIndices: true, withEndIndices: true }), { decodeEntities: false, ...parser, xmlMode: false }).end(source);
98
+ return result;
99
+ }
100
+ static getElementsByTagName(tagName, nodes, recurse, limit) {
101
+ return domutils.getElementsByTagName(tagName, nodes, recurse, limit);
102
+ }
103
+ constructor(documentName, source, elements, options, escapeEntities, parser) {
104
+ let normalize, stripComments, ignoreTagGroup;
105
+ if ((0, types_1.isObject)(options)) {
106
+ ({ normalize, escapeEntities, stripComments, ignoreTagGroup, parser } = options);
107
+ }
108
+ else {
109
+ options = { normalize: options, escapeEntities, parser };
110
+ }
111
+ parser || (parser = { ...PARSER_OPTIONS });
112
+ super(documentName, source, elements, { parser });
113
+ this.documentElement = null;
114
+ this.ignoreTagName = "title|style|script" /* VALUES.IGNORE_TAGNAME */;
115
+ this.rootName = "html" /* VALUES.ROOT */;
116
+ this.ignoreCaseTagName = true;
117
+ const items = [];
118
+ let outerXml = '', documentElement, offsetMap, startIndex = -1;
119
+ for (const item of elements) {
120
+ if (!item.ignoreCase) {
121
+ item.tagName = item.tagName.toLowerCase();
122
+ item.ignoreCase = true;
123
+ }
124
+ if (item.tagName === "html" /* VALUES.ROOT */) {
125
+ items.push(item);
126
+ if (!documentElement && item.innerXml) {
127
+ documentElement = item;
128
+ }
129
+ }
130
+ }
131
+ const setNewline = (value) => this.newline = (0, util_1.getNewline)(value);
132
+ if (!documentElement) {
133
+ setNewline(source);
134
+ if (normalize) {
135
+ source = DomWriter.normalize(source, { newline: this.newline, ignoreChar: typeof normalize === 'string' ? normalize : '', ignoreTagGroup, escapeEntities });
136
+ }
137
+ else if (escapeEntities) {
138
+ source = index_1.XmlWriter.escapeAttributes(source);
139
+ }
140
+ }
141
+ else {
142
+ setNewline(documentElement.innerXml);
143
+ }
144
+ const html = /<html[\s>]/i.exec(source);
145
+ if (html) {
146
+ const endIndex = index_1.XmlWriter.findCloseTag(source, html.index);
147
+ if (endIndex !== -1) {
148
+ startIndex = html.index;
149
+ outerXml = source.substring(startIndex, endIndex + 1);
150
+ }
151
+ }
152
+ if (documentElement) {
153
+ let leading;
154
+ if (startIndex === -1) {
155
+ leading = '<!DOCTYPE html>' + this.newline;
156
+ startIndex = leading.length;
157
+ outerXml = '<html>';
158
+ leading += outerXml;
159
+ }
160
+ else {
161
+ leading = source.substring(0, startIndex + outerXml.length);
162
+ }
163
+ source = documentElement.innerXml;
164
+ if (escapeEntities) {
165
+ source = index_1.XmlWriter.escapeAttributes(source);
166
+ }
167
+ source = leading + this.newline + source + this.newline + '</html>';
168
+ this.documentElement = documentElement;
169
+ }
170
+ else {
171
+ const trailing = items.filter(item => item.textContent);
172
+ if (trailing.length) {
173
+ const match = /<\/body\s*>/i.exec(source);
174
+ if (match) {
175
+ const textContent = trailing.reduce((a, b) => a + b.textContent, '');
176
+ offsetMap = index_1.XmlWriter.getTagOffset(textContent, { ignoreCase: this.ignoreCaseTagName, ignoreTagName: this.ignoreTagName, parser: this.parser });
177
+ source = source.substring(0, match.index) + textContent + source.substring(match.index);
178
+ trailing.forEach(item => delete item.textContent);
179
+ }
180
+ }
181
+ }
182
+ if (stripComments) {
183
+ source = DomWriter.getCommentsAndCDATA(source, '', true, true);
184
+ }
185
+ this.source = source;
186
+ this.initOpts = options;
187
+ if (outerXml) {
188
+ const endIndex = startIndex + outerXml.length - 1;
189
+ for (const item of items) {
190
+ item.startIndex = startIndex;
191
+ item.endIndex = endIndex;
192
+ item.outerXml = outerXml;
193
+ }
194
+ }
195
+ this.init(offsetMap);
196
+ }
197
+ save() {
198
+ if (this.modified && this.documentElement) {
199
+ let innerXml;
200
+ for (const item of this.elements) {
201
+ if (item.tagName === "html" /* VALUES.ROOT */) {
202
+ if (!innerXml && index_1.XmlWriter.isIndex(item.endIndex)) {
203
+ innerXml = this.source.substring(item.endIndex + 1, this.source.length - 7).trim();
204
+ }
205
+ item.innerXml = innerXml;
206
+ }
207
+ }
208
+ }
209
+ return super.save();
210
+ }
211
+ close() {
212
+ if (this.documentElement || this._appendCount > 0) {
213
+ this.source = this.source.replace(new RegExp(this.patternId, 'g'), '');
214
+ }
215
+ return super.close();
216
+ }
217
+ newElement(node) {
218
+ return new HtmlElement(this.documentName, node);
219
+ }
220
+ get nameOfId() {
221
+ return index_1.XmlWriter.getNameOfId(this.documentName);
222
+ }
223
+ }
224
+ exports.DomWriter = DomWriter;
225
+ class HtmlElement extends index_1.XmlElement {
226
+ constructor(documentName, node, attributes, options = {}) {
227
+ options.parser || (options.parser = { ...PARSER_OPTIONS });
228
+ super(documentName, node, attributes, { ...options, tagVoid: TAG_VOID.includes(node.tagName) });
229
+ this.TAG_VOID = TAG_VOID;
230
+ }
231
+ getTagOffset(source) {
232
+ switch (this.node.append?.tagName || this.tagName) {
233
+ case 'html':
234
+ case 'title':
235
+ case 'style':
236
+ case 'script':
237
+ return;
238
+ default:
239
+ return super.getTagOffset(source, { ignoreCase: this.ignoreCase, ignoreTagName: "title|style|script" /* VALUES.IGNORE_TAGNAME */, parser: this.parser });
240
+ }
241
+ }
242
+ findIndexOf(source) {
243
+ const { element } = index_1.XmlWriter.findElement(source, this.node, { document: this.documentName, id: this.id, locatorAttr: 'id', parser: this.parser });
244
+ if (element) {
245
+ return { startIndex: element.startIndex, endIndex: element.endIndex };
246
+ }
247
+ }
248
+ get outerXml() {
249
+ const [tagName, items, innerXml] = this.getOuterContent();
250
+ return '<' + tagName + HtmlElement.writeAttributes(items) + '>' + (DomWriter.hasInnerXml(tagName) && tagName !== "html" /* VALUES.ROOT */ ? (tagName === 'title' ? index_1.XmlWriter.escapeXmlString(innerXml) : innerXml) + `</${tagName}>` : '');
251
+ }
252
+ get nameOfId() {
253
+ return index_1.XmlWriter.getNameOfId(this.documentName);
254
+ }
255
+ }
256
+ exports.HtmlElement = HtmlElement;
@@ -0,0 +1,9 @@
1
+ import type { IGNORE_FLAG, XmlWriterConstructor, XmlElementConstructor } from './document';
2
+
3
+ declare namespace parse {
4
+ const IGNORE_FLAG: IGNORE_FLAG;
5
+ const XmlWriter: XmlWriterConstructor;
6
+ const XmlElement: XmlElementConstructor;
7
+ }
8
+
9
+ export = parse;