@e-mc/document 0.10.0 → 0.10.2
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/LICENSE +10 -10
- package/README.md +196 -196
- package/asset.d.ts +7 -7
- package/asset.js +1 -1
- package/index.d.ts +4 -4
- package/index.js +18 -22
- package/package.json +31 -31
- package/parse/dom.d.ts +8 -8
- package/parse/dom.js +3 -3
- package/parse/index.d.ts +8 -8
- package/parse/index.js +18 -23
- package/parse/types/index.d.ts +240 -240
- package/transform/index.d.ts +7 -7
- package/transform/index.js +2 -2
- package/util.d.ts +20 -20
- package/util.js +2 -2
package/parse/types/index.d.ts
CHANGED
|
@@ -1,241 +1,241 @@
|
|
|
1
|
-
import type { XmlTagNode as IXmlTagNode, TagAppend, TagData } from '../../../types/lib/squared';
|
|
2
|
-
|
|
3
|
-
import type { ParserOptions } from 'htmlparser2';
|
|
4
|
-
import type { AnyNode, Element } from 'domhandler';
|
|
5
|
-
|
|
6
|
-
export interface IGNORE_FLAG {
|
|
7
|
-
NONE: 0;
|
|
8
|
-
INTERIOR: 1;
|
|
9
|
-
LOCATOR: 2;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface ParserAction {
|
|
13
|
-
parser?: ParserOptions;
|
|
14
|
-
outDom?: AnyNode[];
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface SourceIndex {
|
|
18
|
-
startIndex: number;
|
|
19
|
-
endIndex: number;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface SourceContent extends SourceIndex {
|
|
23
|
-
outerXml: string;
|
|
24
|
-
type?: "node" | "comment" | "cdata" | "block";
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface SourceTagNode extends SourceContent, TagData {
|
|
28
|
-
id?: string;
|
|
29
|
-
ignoreCase?: boolean;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface XmlTagNode extends IXmlTagNode, Partial<SourceIndex> {}
|
|
33
|
-
|
|
34
|
-
export type AttributeMap = Map<string, unknown>;
|
|
35
|
-
export type AttributeList = [string, unknown][];
|
|
36
|
-
export type TagOffsetMap = ObjectMap<Undef<number>>;
|
|
37
|
-
export type WriteResult = [string, string, Null<Error>?];
|
|
38
|
-
export type SaveResult = [string, Null<Error>?];
|
|
39
|
-
export type XmlWriterOptions = ParserAction;
|
|
40
|
-
|
|
41
|
-
export interface ParserResult extends Partial<TagData>, ParserAction {
|
|
42
|
-
element: Null<Element>;
|
|
43
|
-
error: Null<Error>;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export interface ReplaceOptions extends SourceIndex {
|
|
47
|
-
append?: TagAppend;
|
|
48
|
-
remove?: boolean;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export interface FindElementOptions extends ParserAction {
|
|
52
|
-
document?: string;
|
|
53
|
-
id?: string;
|
|
54
|
-
locatorAttr?: string;
|
|
55
|
-
tagCount?: number;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export interface TagOffsetOptions extends ParserAction {
|
|
59
|
-
ignoreCase?: boolean;
|
|
60
|
-
ignoreTagName?: string;
|
|
61
|
-
ignoreTagGroup?: string[];
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export interface TagNodeOptions {
|
|
65
|
-
tagVoid?: boolean;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export interface TagNodeByIdOptions extends TagNodeOptions {
|
|
69
|
-
tagName?: string;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export interface XmlElementOptions extends TagNodeOptions, ParserAction {}
|
|
73
|
-
|
|
74
|
-
export interface DomWriterOptions extends ParserAction {
|
|
75
|
-
normalize?: boolean | string;
|
|
76
|
-
ignoreTagGroup?: string[];
|
|
77
|
-
escapeEntities?: boolean;
|
|
78
|
-
stripComments?: boolean | string;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export interface ReplaceMatchOptions {
|
|
82
|
-
pattern?: RegExp;
|
|
83
|
-
trimLeading?: boolean;
|
|
84
|
-
trimTrailing?: boolean;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export interface NormalizeOptions {
|
|
88
|
-
newline?: string;
|
|
89
|
-
ignoreChar?: string;
|
|
90
|
-
ignoreTagGroup?: string[];
|
|
91
|
-
escapeEntities?: boolean;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export class IXmlBase {
|
|
95
|
-
newline: string;
|
|
96
|
-
readonly documentName: string;
|
|
97
|
-
write(...args: unknown[]): unknown;
|
|
98
|
-
save(...args: unknown[]): unknown;
|
|
99
|
-
reset(): void;
|
|
100
|
-
get nameOfId(): string;
|
|
101
|
-
get modified(): boolean;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export class IXmlWriter extends IXmlBase {
|
|
105
|
-
modifyCount: number;
|
|
106
|
-
failCount: number;
|
|
107
|
-
elements: XmlTagNode[];
|
|
108
|
-
errors: Error[];
|
|
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: ArrayOf<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: number | string, options: ReplaceMatchOptions): string;
|
|
154
|
-
replaceMatch(match: RegExpMatchArray, source: string, content?: number | string, 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
|
-
namesOfTagVoid(type: string, values: string[]): void;
|
|
163
|
-
isTagVoid(type: string, tagName: string): boolean;
|
|
164
|
-
getNodeId(node: XmlTagNode, document: string): string;
|
|
165
|
-
getNameOfId(document: string): string;
|
|
166
|
-
getPatternId(name: string): RegExp;
|
|
167
|
-
getCommentsAndCDATA(source: string, tagPattern: unknown, ignoreCase: boolean, stripXml: true): string;
|
|
168
|
-
getCommentsAndCDATA(source: string, tagPattern?: ArrayOf<string> | [Undef<string>, Undef<string[]>], ignoreCase?: boolean, stripXml?: boolean): SourceContent[];
|
|
169
|
-
isEqual(node: XmlTagNode, other: XmlTagNode, ignoreCase: boolean): boolean;
|
|
170
|
-
isEqual(node: XmlTagNode, other: XmlTagNode, documentName?: string, ignoreCase?: boolean): boolean;
|
|
171
|
-
isIndex(value: Undef<number>): value is number;
|
|
172
|
-
isCount(value: Undef<number>): value is number;
|
|
173
|
-
isSpace(ch: string): boolean;
|
|
174
|
-
readonly prototype: IXmlWriter;
|
|
175
|
-
new(documentName: string, source: string, elements: XmlTagNode[], options?: XmlWriterOptions): IXmlWriter;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
export class IXmlElement extends IXmlBase {
|
|
179
|
-
parser?: ParserOptions;
|
|
180
|
-
readonly node: XmlTagNode;
|
|
181
|
-
setAppend(value?: TagAppend): void;
|
|
182
|
-
parseOuterXml(value?: string, tagVoid?: boolean): [string, string, boolean];
|
|
183
|
-
getTagOffset(replacement?: string, options?: TagOffsetOptions): Undef<TagOffsetMap>;
|
|
184
|
-
setAttribute(name: string, value: string): void;
|
|
185
|
-
getAttribute(name: string): string;
|
|
186
|
-
removeAttribute(...names: string[]): void;
|
|
187
|
-
hasAttribute(name: string): boolean;
|
|
188
|
-
hasModifiedContent(): boolean;
|
|
189
|
-
write(source: string, invalid?: SourceIndex[]): WriteResult;
|
|
190
|
-
save(source: string, invalid?: SourceIndex[]): SaveResult;
|
|
191
|
-
replace(source: string, options: ReplaceOptions): WriteResult;
|
|
192
|
-
findIndexOf(source: string): Undef<SourceIndex>;
|
|
193
|
-
getOuterContent(): [string, AttributeList, string];
|
|
194
|
-
getInnerOffset(tagName: string): number;
|
|
195
|
-
hasPosition(): boolean;
|
|
196
|
-
set id(value: string);
|
|
197
|
-
get id(): string;
|
|
198
|
-
set tagName(value: string);
|
|
199
|
-
get tagName(): string;
|
|
200
|
-
get documentType(): string;
|
|
201
|
-
get tagVoid(): boolean;
|
|
202
|
-
set innerXml(value: string);
|
|
203
|
-
get innerXml(): string;
|
|
204
|
-
get outerXml(): string;
|
|
205
|
-
set remove(value);
|
|
206
|
-
get remove(): boolean;
|
|
207
|
-
get append(): Undef<TagAppend>;
|
|
208
|
-
set tagOffset(value: Undef<TagOffsetMap>);
|
|
209
|
-
get tagOffset(): Undef<TagOffsetMap>;
|
|
210
|
-
get ignoreCase(): boolean;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
export interface XmlElementConstructor {
|
|
214
|
-
writeAttributes(attrs: AttributeMap | AttributeList, escapeEntities?: boolean): string;
|
|
215
|
-
readonly prototype: IXmlElement;
|
|
216
|
-
new(documentName: string, node: XmlTagNode, attributes?: PlainObject, options?: XmlElementOptions): IXmlElement;
|
|
217
|
-
new(documentName: string, node: XmlTagNode, attributes?: PlainObject, tagVoid?: boolean, parser?: ParserOptions): IXmlElement;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
export class IDomWriter extends IXmlWriter {
|
|
221
|
-
documentElement: Null<XmlTagNode>;
|
|
222
|
-
readonly initOpts: DomWriterOptions;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
export interface DomWriterConstructor extends XmlWriterConstructor {
|
|
226
|
-
hasInnerXml(tagName: string): boolean;
|
|
227
|
-
normalize(source: string, options: NormalizeOptions): string;
|
|
228
|
-
normalize(source: string, newline?: string, ignoreChar?: string, escapeEntities?: boolean): string;
|
|
229
|
-
getDocumentElement(source: string, parser?: ParserOptions): ParserResult;
|
|
230
|
-
getElementsByTagName(tagName: string | ((name: string) => boolean), nodes: ArrayOf<AnyNode>, recurse?: boolean, limit?: number): Element[];
|
|
231
|
-
readonly prototype: IDomWriter;
|
|
232
|
-
new(documentName: string, source: string, elements: XmlTagNode[], options?: DomWriterOptions): IDomWriter;
|
|
233
|
-
new(documentName: string, source: string, elements: XmlTagNode[], normalize?: boolean | string, escapeEntities?: boolean, parser?: ParserOptions): IDomWriter;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
export class IHtmlElement extends IXmlElement {}
|
|
237
|
-
|
|
238
|
-
export interface HtmlElementConstructor extends XmlElementConstructor {
|
|
239
|
-
readonly prototype: IHtmlElement;
|
|
240
|
-
new(documentName: string, node: XmlTagNode, attributes?: PlainObject, options?: ParserAction): IHtmlElement;
|
|
1
|
+
import type { XmlTagNode as IXmlTagNode, TagAppend, TagData } from '../../../types/lib/squared';
|
|
2
|
+
|
|
3
|
+
import type { ParserOptions } from 'htmlparser2';
|
|
4
|
+
import type { AnyNode, Element } from 'domhandler';
|
|
5
|
+
|
|
6
|
+
export interface IGNORE_FLAG {
|
|
7
|
+
NONE: 0;
|
|
8
|
+
INTERIOR: 1;
|
|
9
|
+
LOCATOR: 2;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface ParserAction {
|
|
13
|
+
parser?: ParserOptions;
|
|
14
|
+
outDom?: AnyNode[];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface SourceIndex {
|
|
18
|
+
startIndex: number;
|
|
19
|
+
endIndex: number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface SourceContent extends SourceIndex {
|
|
23
|
+
outerXml: string;
|
|
24
|
+
type?: "node" | "comment" | "cdata" | "block";
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface SourceTagNode extends SourceContent, TagData {
|
|
28
|
+
id?: string;
|
|
29
|
+
ignoreCase?: boolean;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface XmlTagNode extends IXmlTagNode, Partial<SourceIndex> {}
|
|
33
|
+
|
|
34
|
+
export type AttributeMap = Map<string, unknown>;
|
|
35
|
+
export type AttributeList = [string, unknown][];
|
|
36
|
+
export type TagOffsetMap = ObjectMap<Undef<number>>;
|
|
37
|
+
export type WriteResult = [string, string, Null<Error>?];
|
|
38
|
+
export type SaveResult = [string, Null<Error>?];
|
|
39
|
+
export type XmlWriterOptions = ParserAction;
|
|
40
|
+
|
|
41
|
+
export interface ParserResult extends Partial<TagData>, ParserAction {
|
|
42
|
+
element: Null<Element>;
|
|
43
|
+
error: Null<Error>;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface ReplaceOptions extends SourceIndex {
|
|
47
|
+
append?: TagAppend;
|
|
48
|
+
remove?: boolean;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface FindElementOptions extends ParserAction {
|
|
52
|
+
document?: string;
|
|
53
|
+
id?: string;
|
|
54
|
+
locatorAttr?: string;
|
|
55
|
+
tagCount?: number;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface TagOffsetOptions extends ParserAction {
|
|
59
|
+
ignoreCase?: boolean;
|
|
60
|
+
ignoreTagName?: string;
|
|
61
|
+
ignoreTagGroup?: string[];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface TagNodeOptions {
|
|
65
|
+
tagVoid?: boolean;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface TagNodeByIdOptions extends TagNodeOptions {
|
|
69
|
+
tagName?: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface XmlElementOptions extends TagNodeOptions, ParserAction {}
|
|
73
|
+
|
|
74
|
+
export interface DomWriterOptions extends ParserAction {
|
|
75
|
+
normalize?: boolean | string;
|
|
76
|
+
ignoreTagGroup?: string[];
|
|
77
|
+
escapeEntities?: boolean;
|
|
78
|
+
stripComments?: boolean | string;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface ReplaceMatchOptions {
|
|
82
|
+
pattern?: RegExp;
|
|
83
|
+
trimLeading?: boolean;
|
|
84
|
+
trimTrailing?: boolean;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface NormalizeOptions {
|
|
88
|
+
newline?: string;
|
|
89
|
+
ignoreChar?: string;
|
|
90
|
+
ignoreTagGroup?: string[];
|
|
91
|
+
escapeEntities?: boolean;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export class IXmlBase {
|
|
95
|
+
newline: string;
|
|
96
|
+
readonly documentName: string;
|
|
97
|
+
write(...args: unknown[]): unknown;
|
|
98
|
+
save(...args: unknown[]): unknown;
|
|
99
|
+
reset(): void;
|
|
100
|
+
get nameOfId(): string;
|
|
101
|
+
get modified(): boolean;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export class IXmlWriter extends IXmlBase {
|
|
105
|
+
modifyCount: number;
|
|
106
|
+
failCount: number;
|
|
107
|
+
elements: XmlTagNode[];
|
|
108
|
+
errors: Error[];
|
|
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: ArrayOf<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: number | string, options: ReplaceMatchOptions): string;
|
|
154
|
+
replaceMatch(match: RegExpMatchArray, source: string, content?: number | string, 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
|
+
namesOfTagVoid(type: string, values: string[]): void;
|
|
163
|
+
isTagVoid(type: string, tagName: string): boolean;
|
|
164
|
+
getNodeId(node: XmlTagNode, document: string): string;
|
|
165
|
+
getNameOfId(document: string): string;
|
|
166
|
+
getPatternId(name: string): RegExp;
|
|
167
|
+
getCommentsAndCDATA(source: string, tagPattern: unknown, ignoreCase: boolean, stripXml: true): string;
|
|
168
|
+
getCommentsAndCDATA(source: string, tagPattern?: ArrayOf<string> | [Undef<string>, Undef<string[]>], ignoreCase?: boolean, stripXml?: boolean): SourceContent[];
|
|
169
|
+
isEqual(node: XmlTagNode, other: XmlTagNode, ignoreCase: boolean): boolean;
|
|
170
|
+
isEqual(node: XmlTagNode, other: XmlTagNode, documentName?: string, ignoreCase?: boolean): boolean;
|
|
171
|
+
isIndex(value: Undef<number>): value is number;
|
|
172
|
+
isCount(value: Undef<number>): value is number;
|
|
173
|
+
isSpace(ch: string): boolean;
|
|
174
|
+
readonly prototype: IXmlWriter;
|
|
175
|
+
new(documentName: string, source: string, elements: XmlTagNode[], options?: XmlWriterOptions): IXmlWriter;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export class IXmlElement extends IXmlBase {
|
|
179
|
+
parser?: ParserOptions;
|
|
180
|
+
readonly node: XmlTagNode;
|
|
181
|
+
setAppend(value?: TagAppend): void;
|
|
182
|
+
parseOuterXml(value?: string, tagVoid?: boolean): [string, string, boolean];
|
|
183
|
+
getTagOffset(replacement?: string, options?: TagOffsetOptions): Undef<TagOffsetMap>;
|
|
184
|
+
setAttribute(name: string, value: string): void;
|
|
185
|
+
getAttribute(name: string): string;
|
|
186
|
+
removeAttribute(...names: string[]): void;
|
|
187
|
+
hasAttribute(name: string): boolean;
|
|
188
|
+
hasModifiedContent(): boolean;
|
|
189
|
+
write(source: string, invalid?: SourceIndex[]): WriteResult;
|
|
190
|
+
save(source: string, invalid?: SourceIndex[]): SaveResult;
|
|
191
|
+
replace(source: string, options: ReplaceOptions): WriteResult;
|
|
192
|
+
findIndexOf(source: string): Undef<SourceIndex>;
|
|
193
|
+
getOuterContent(): [string, AttributeList, string];
|
|
194
|
+
getInnerOffset(tagName: string): number;
|
|
195
|
+
hasPosition(): boolean;
|
|
196
|
+
set id(value: string);
|
|
197
|
+
get id(): string;
|
|
198
|
+
set tagName(value: string);
|
|
199
|
+
get tagName(): string;
|
|
200
|
+
get documentType(): string;
|
|
201
|
+
get tagVoid(): boolean;
|
|
202
|
+
set innerXml(value: string);
|
|
203
|
+
get innerXml(): string;
|
|
204
|
+
get outerXml(): string;
|
|
205
|
+
set remove(value);
|
|
206
|
+
get remove(): boolean;
|
|
207
|
+
get append(): Undef<TagAppend>;
|
|
208
|
+
set tagOffset(value: Undef<TagOffsetMap>);
|
|
209
|
+
get tagOffset(): Undef<TagOffsetMap>;
|
|
210
|
+
get ignoreCase(): boolean;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export interface XmlElementConstructor {
|
|
214
|
+
writeAttributes(attrs: AttributeMap | AttributeList, escapeEntities?: boolean): string;
|
|
215
|
+
readonly prototype: IXmlElement;
|
|
216
|
+
new(documentName: string, node: XmlTagNode, attributes?: PlainObject, options?: XmlElementOptions): IXmlElement;
|
|
217
|
+
new(documentName: string, node: XmlTagNode, attributes?: PlainObject, tagVoid?: boolean, parser?: ParserOptions): IXmlElement;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export class IDomWriter extends IXmlWriter {
|
|
221
|
+
documentElement: Null<XmlTagNode>;
|
|
222
|
+
readonly initOpts: DomWriterOptions;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export interface DomWriterConstructor extends XmlWriterConstructor {
|
|
226
|
+
hasInnerXml(tagName: string): boolean;
|
|
227
|
+
normalize(source: string, options: NormalizeOptions): string;
|
|
228
|
+
normalize(source: string, newline?: string, ignoreChar?: string, escapeEntities?: boolean): string;
|
|
229
|
+
getDocumentElement(source: string, parser?: ParserOptions): ParserResult;
|
|
230
|
+
getElementsByTagName(tagName: string | ((name: string) => boolean), nodes: ArrayOf<AnyNode>, recurse?: boolean, limit?: number): Element[];
|
|
231
|
+
readonly prototype: IDomWriter;
|
|
232
|
+
new(documentName: string, source: string, elements: XmlTagNode[], options?: DomWriterOptions): IDomWriter;
|
|
233
|
+
new(documentName: string, source: string, elements: XmlTagNode[], normalize?: boolean | string, escapeEntities?: boolean, parser?: ParserOptions): IDomWriter;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export class IHtmlElement extends IXmlElement {}
|
|
237
|
+
|
|
238
|
+
export interface HtmlElementConstructor extends XmlElementConstructor {
|
|
239
|
+
readonly prototype: IHtmlElement;
|
|
240
|
+
new(documentName: string, node: XmlTagNode, attributes?: PlainObject, options?: ParserAction): IHtmlElement;
|
|
241
241
|
}
|
package/transform/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { SourceMapConstructor, TransformSeriesConstructor } from '../../types/lib/document';
|
|
2
|
-
|
|
3
|
-
declare namespace transform {
|
|
4
|
-
const TransformSeries: TransformSeriesConstructor;
|
|
5
|
-
const SourceMap: SourceMapConstructor;
|
|
6
|
-
}
|
|
7
|
-
|
|
1
|
+
import type { SourceMapConstructor, TransformSeriesConstructor } from '../../types/lib/document';
|
|
2
|
+
|
|
3
|
+
declare namespace transform {
|
|
4
|
+
const TransformSeries: TransformSeriesConstructor;
|
|
5
|
+
const SourceMap: SourceMapConstructor;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
8
|
export = transform;
|
package/transform/index.js
CHANGED
|
@@ -240,7 +240,7 @@ exports.TransformSeries = TransformSeries;
|
|
|
240
240
|
_a = kMetadata, _b = kModulesDir, _c = kUsername;
|
|
241
241
|
class SourceMap {
|
|
242
242
|
static findSourceMap(code, uri) {
|
|
243
|
-
if (code
|
|
243
|
+
if (code ||= uri && core_1.Module.readText(uri)) {
|
|
244
244
|
const pattern = this.RE_SOURCE_MAPPING_URL;
|
|
245
245
|
pattern.lastIndex = 0;
|
|
246
246
|
let match;
|
|
@@ -284,7 +284,7 @@ class SourceMap {
|
|
|
284
284
|
code = items[0];
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
|
-
map
|
|
287
|
+
map ||= SourceMap.findSourceMap(code, uri);
|
|
288
288
|
if (SourceMap.isRaw(map)) {
|
|
289
289
|
this.nextMap('unknown', code, map);
|
|
290
290
|
}
|
package/util.d.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
declare namespace util {
|
|
2
|
-
/** @deprecated Types.IMPORT_MAP */
|
|
3
|
-
const IMPORTS: Record<string, string | undefined>;
|
|
4
|
-
const PATTERN_PARENTHESIS: string;
|
|
5
|
-
function loadPlugins<T = unknown>(name: string | unknown[], plugins?: unknown[]): T[];
|
|
6
|
-
function replaceAll(source: string, valueOf: (name: string) => string, opening?: string, closing?: string): string;
|
|
7
|
-
function concatString(values: string[] | string | undefined, newline?: string): string;
|
|
8
|
-
function spliceString(source: string, startIndex: number, endIndex: number, content: string, pattern?: RegExp): string;
|
|
9
|
-
function spliceMatch(source: string, match: RegExpExecArray, content: string, pattern?: RegExp): string;
|
|
10
|
-
function splitEnclosing(value: string, pattern?: string | RegExp, options?: { trim?: boolean; start?: number; startWith?: number; count?: number } | boolean | number, opening?: string, closing?: string): string[];
|
|
11
|
-
function appendSuffix(filename: string, value: string, separator?: string): string;
|
|
12
|
-
function getIndent(value: string, spaces?: number): string;
|
|
13
|
-
function getNewline(value: string): string;
|
|
14
|
-
function getHashData(value: string): [string, number];
|
|
15
|
-
function hasValue(target: string | string[] | undefined, ...values: string[]): boolean;
|
|
16
|
-
function getModuleName(err: unknown): string | undefined;
|
|
17
|
-
function removeInternalProperties<T extends object>(value: T, retaining?: string[]): T;
|
|
18
|
-
function isObject<T = object>(value: unknown): value is T;
|
|
19
|
-
}
|
|
20
|
-
|
|
1
|
+
declare namespace util {
|
|
2
|
+
/** @deprecated Types.IMPORT_MAP */
|
|
3
|
+
const IMPORTS: Record<string, string | undefined>;
|
|
4
|
+
const PATTERN_PARENTHESIS: string;
|
|
5
|
+
function loadPlugins<T = unknown>(name: string | unknown[], plugins?: unknown[]): T[];
|
|
6
|
+
function replaceAll(source: string, valueOf: (name: string) => string, opening?: string, closing?: string): string;
|
|
7
|
+
function concatString(values: string[] | string | undefined, newline?: string): string;
|
|
8
|
+
function spliceString(source: string, startIndex: number, endIndex: number, content: string, pattern?: RegExp): string;
|
|
9
|
+
function spliceMatch(source: string, match: RegExpExecArray, content: string, pattern?: RegExp): string;
|
|
10
|
+
function splitEnclosing(value: string, pattern?: string | RegExp, options?: { trim?: boolean; start?: number; startWith?: number; count?: number } | boolean | number, opening?: string, closing?: string): string[];
|
|
11
|
+
function appendSuffix(filename: string, value: string, separator?: string): string;
|
|
12
|
+
function getIndent(value: string, spaces?: number): string;
|
|
13
|
+
function getNewline(value: string): string;
|
|
14
|
+
function getHashData(value: string): [string, number];
|
|
15
|
+
function hasValue(target: string | string[] | undefined, ...values: string[]): boolean;
|
|
16
|
+
function getModuleName(err: unknown): string | undefined;
|
|
17
|
+
function removeInternalProperties<T extends object>(value: T, retaining?: string[]): T;
|
|
18
|
+
function isObject<T = object>(value: unknown): value is T;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
21
|
export = util;
|
package/util.js
CHANGED
|
@@ -43,7 +43,7 @@ function replaceAll(source, valueOf, opening = '{{', closing = '}}') {
|
|
|
43
43
|
}
|
|
44
44
|
function concatString(values, newline) {
|
|
45
45
|
if ((0, types_1.isArray)(values)) {
|
|
46
|
-
newline
|
|
46
|
+
newline ||= values.find(item => item.indexOf('\r') !== -1) ? '\r\n' : '\n';
|
|
47
47
|
return values.reduce((a, b) => a + newline + b, '');
|
|
48
48
|
}
|
|
49
49
|
return typeof values === 'string' ? values : '';
|
|
@@ -59,7 +59,7 @@ function spliceMatch(source, match, content, pattern) {
|
|
|
59
59
|
return spliceString(source, index, index + match[0].length, content, pattern);
|
|
60
60
|
}
|
|
61
61
|
function splitEnclosing(value, pattern, options, opening = '(', closing = ')') {
|
|
62
|
-
pattern
|
|
62
|
+
pattern ||= opening;
|
|
63
63
|
let position = 0, index = -1, end = 0, char;
|
|
64
64
|
if (typeof pattern === 'string') {
|
|
65
65
|
if (pattern !== opening) {
|