lakutata 2.0.12 → 2.0.13
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/com/database.cjs +13 -3
- package/com/database.mjs +13 -3
- package/com/docker.cjs +6 -2
- package/com/docker.d.ts +29 -11
- package/com/docker.mjs +6 -2
- package/com/logger.cjs +2 -2
- package/com/logger.mjs +2 -2
- package/decorator/orm.cjs +21 -11
- package/decorator/orm.mjs +13 -3
- package/helper.cjs +12 -12
- package/helper.d.ts +559 -82
- package/helper.mjs +5 -5
- package/lakutata.cjs +2 -2
- package/lakutata.mjs +2 -2
- package/orm.cjs +13 -3
- package/orm.mjs +39 -29
- package/package.json +2 -4
- package/src/components/Database.cjs +17 -7
- package/src/components/Database.mjs +13 -3
- package/src/components/Logger.cjs +2 -2
- package/src/components/Logger.mjs +2 -2
- package/src/components/docker/ConnectionOptionsBuilder.cjs +6 -2
- package/src/components/docker/ConnectionOptionsBuilder.mjs +6 -2
- package/src/components/docker/Docker.cjs +8 -3
- package/src/components/docker/Docker.mjs +8 -3
- package/src/components/docker/lib/DockerContainer.cjs +10 -6
- package/src/components/docker/lib/DockerContainer.mjs +6 -2
- package/src/components/docker/lib/DockerContainerTTY.cjs +6 -2
- package/src/components/docker/lib/DockerContainerTTY.mjs +6 -2
- package/src/decorators/orm/AfterInsert.cjs +13 -3
- package/src/decorators/orm/AfterInsert.mjs +17 -7
- package/src/decorators/orm/AfterLoad.cjs +17 -7
- package/src/decorators/orm/AfterLoad.mjs +13 -3
- package/src/decorators/orm/AfterRecover.cjs +17 -7
- package/src/decorators/orm/AfterRecover.mjs +17 -7
- package/src/decorators/orm/AfterRemove.cjs +17 -7
- package/src/decorators/orm/AfterRemove.mjs +22 -12
- package/src/decorators/orm/AfterSoftRemove.cjs +13 -3
- package/src/decorators/orm/AfterSoftRemove.mjs +24 -14
- package/src/decorators/orm/AfterUpdate.cjs +13 -3
- package/src/decorators/orm/AfterUpdate.mjs +22 -12
- package/src/decorators/orm/BeforeInsert.cjs +17 -7
- package/src/decorators/orm/BeforeInsert.mjs +17 -7
- package/src/decorators/orm/BeforeRecover.cjs +17 -7
- package/src/decorators/orm/BeforeRecover.mjs +22 -12
- package/src/decorators/orm/BeforeRemove.cjs +17 -7
- package/src/decorators/orm/BeforeRemove.mjs +17 -7
- package/src/decorators/orm/BeforeSoftRemove.cjs +17 -7
- package/src/decorators/orm/BeforeSoftRemove.mjs +23 -13
- package/src/decorators/orm/BeforeUpdate.cjs +17 -7
- package/src/decorators/orm/BeforeUpdate.mjs +22 -12
- package/src/decorators/orm/Check.cjs +18 -8
- package/src/decorators/orm/Check.mjs +13 -3
- package/src/decorators/orm/ChildEntity.cjs +13 -3
- package/src/decorators/orm/ChildEntity.mjs +13 -3
- package/src/decorators/orm/Column.cjs +26 -16
- package/src/decorators/orm/Column.mjs +23 -13
- package/src/decorators/orm/CreateDateColumn.cjs +19 -9
- package/src/decorators/orm/CreateDateColumn.mjs +24 -14
- package/src/decorators/orm/DeleteDateColumn.cjs +19 -9
- package/src/decorators/orm/DeleteDateColumn.mjs +23 -13
- package/src/decorators/orm/Entity.cjs +26 -16
- package/src/decorators/orm/Entity.mjs +32 -22
- package/src/decorators/orm/EventSubscriber.cjs +13 -3
- package/src/decorators/orm/EventSubscriber.mjs +18 -8
- package/src/decorators/orm/Exclusion.cjs +21 -11
- package/src/decorators/orm/Exclusion.mjs +21 -11
- package/src/decorators/orm/Generated.cjs +13 -3
- package/src/decorators/orm/Generated.mjs +13 -3
- package/src/decorators/orm/Index.cjs +22 -12
- package/src/decorators/orm/Index.mjs +27 -17
- package/src/decorators/orm/JoinColumn.cjs +19 -9
- package/src/decorators/orm/JoinColumn.mjs +27 -17
- package/src/decorators/orm/JoinTable.cjs +13 -3
- package/src/decorators/orm/JoinTable.mjs +29 -19
- package/src/decorators/orm/ManyToMany.cjs +25 -15
- package/src/decorators/orm/ManyToMany.mjs +26 -16
- package/src/decorators/orm/ManyToOne.cjs +25 -15
- package/src/decorators/orm/ManyToOne.mjs +26 -16
- package/src/decorators/orm/ObjectIdColumn.cjs +13 -3
- package/src/decorators/orm/ObjectIdColumn.mjs +26 -16
- package/src/decorators/orm/OneToMany.cjs +21 -11
- package/src/decorators/orm/OneToMany.mjs +22 -12
- package/src/decorators/orm/OneToOne.cjs +16 -6
- package/src/decorators/orm/OneToOne.mjs +36 -26
- package/src/decorators/orm/PrimaryColumn.cjs +23 -13
- package/src/decorators/orm/PrimaryColumn.mjs +24 -14
- package/src/decorators/orm/PrimaryGeneratedColumn.cjs +32 -22
- package/src/decorators/orm/PrimaryGeneratedColumn.mjs +18 -8
- package/src/decorators/orm/RelationId.cjs +19 -9
- package/src/decorators/orm/RelationId.mjs +18 -8
- package/src/decorators/orm/TableInheritance.cjs +17 -7
- package/src/decorators/orm/TableInheritance.mjs +26 -16
- package/src/decorators/orm/Tree.cjs +13 -3
- package/src/decorators/orm/Tree.mjs +26 -16
- package/src/decorators/orm/TreeChildren.cjs +15 -5
- package/src/decorators/orm/TreeChildren.mjs +18 -8
- package/src/decorators/orm/TreeLevelColumn.cjs +13 -3
- package/src/decorators/orm/TreeLevelColumn.mjs +20 -10
- package/src/decorators/orm/TreeParent.cjs +19 -9
- package/src/decorators/orm/TreeParent.mjs +13 -3
- package/src/decorators/orm/Unique.cjs +29 -19
- package/src/decorators/orm/Unique.mjs +30 -20
- package/src/decorators/orm/UpdateDateColumn.cjs +19 -9
- package/src/decorators/orm/UpdateDateColumn.mjs +25 -15
- package/src/decorators/orm/VersionColumn.cjs +13 -3
- package/src/decorators/orm/VersionColumn.mjs +26 -16
- package/src/decorators/orm/ViewColumn.cjs +13 -3
- package/src/decorators/orm/ViewColumn.mjs +26 -16
- package/src/decorators/orm/ViewEntity.cjs +27 -17
- package/src/decorators/orm/ViewEntity.mjs +19 -9
- package/src/decorators/orm/VirtualColumn.cjs +18 -8
- package/src/decorators/orm/VirtualColumn.mjs +30 -20
- package/src/lib/base/internal/PatternManager.cjs +2 -2
- package/src/lib/base/internal/PatternManager.mjs +2 -2
- package/src/lib/core/Application.cjs +2 -2
- package/src/lib/core/Application.mjs +2 -2
- package/src/lib/helpers/Glob.cjs +1220 -1149
- package/src/lib/helpers/Glob.mjs +769 -700
- package/src/lib/helpers/IsXML.cjs +863 -801
- package/src/lib/helpers/IsXML.mjs +862 -800
- package/src/lib/ioc/ListModules.cjs +967 -909
- package/src/lib/ioc/ListModules.mjs +849 -791
- package/src/lib/validation/VLD.cjs +20 -10
- package/src/lib/validation/VLD.mjs +20 -10
- package/vendor/Package.1.cjs +170 -129
- package/vendor/Package.1.mjs +169 -128
- package/vendor/Package.13.cjs +0 -2
- package/vendor/Package.13.mjs +0 -2
- package/vendor/Package.14.cjs +8756 -8658
- package/vendor/Package.14.mjs +8665 -8581
- package/vendor/Package.16.cjs +36855 -15590
- package/vendor/Package.16.mjs +36893 -15633
- package/vendor/Package.2.cjs +2442 -2440
- package/vendor/Package.2.mjs +444 -442
- package/vendor/Package.4.cjs +325 -319
- package/vendor/Package.4.mjs +326 -320
- package/vendor/Package.7.cjs +299 -299
- package/vendor/Package.7.mjs +299 -299
- package/vendor/TypeDef.5.d.ts +6 -0
|
@@ -1,104 +1,104 @@
|
|
|
1
|
-
import { g as
|
|
1
|
+
import { g as t } from "../../../vendor/Package.5.mjs";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var e = {};
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var n = {};
|
|
6
6
|
|
|
7
|
-
(function(
|
|
7
|
+
(function(t) {
|
|
8
8
|
"use strict";
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const s = new RegExp("^" +
|
|
13
|
-
const r = function(
|
|
14
|
-
const
|
|
15
|
-
let
|
|
16
|
-
while (
|
|
9
|
+
const e = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD";
|
|
10
|
+
const n = e + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040";
|
|
11
|
+
const i = "[" + e + "][" + n + "]*";
|
|
12
|
+
const s = new RegExp("^" + i + "$");
|
|
13
|
+
const r = function(t, e) {
|
|
14
|
+
const n = [];
|
|
15
|
+
let i = e.exec(t);
|
|
16
|
+
while (i) {
|
|
17
17
|
const s = [];
|
|
18
|
-
s.startIndex =
|
|
19
|
-
const r =
|
|
20
|
-
for (let
|
|
21
|
-
s.push(
|
|
18
|
+
s.startIndex = e.lastIndex - i[0].length;
|
|
19
|
+
const r = i.length;
|
|
20
|
+
for (let t = 0; t < r; t++) {
|
|
21
|
+
s.push(i[t]);
|
|
22
22
|
}
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
n.push(s);
|
|
24
|
+
i = e.exec(t);
|
|
25
25
|
}
|
|
26
|
-
return
|
|
26
|
+
return n;
|
|
27
27
|
};
|
|
28
|
-
const o = function(
|
|
29
|
-
const
|
|
30
|
-
return !(
|
|
28
|
+
const o = function(t) {
|
|
29
|
+
const e = s.exec(t);
|
|
30
|
+
return !(e === null || typeof e === "undefined");
|
|
31
31
|
};
|
|
32
|
-
|
|
33
|
-
return typeof
|
|
32
|
+
t.isExist = function(t) {
|
|
33
|
+
return typeof t !== "undefined";
|
|
34
34
|
};
|
|
35
|
-
|
|
36
|
-
return Object.keys(
|
|
35
|
+
t.isEmptyObject = function(t) {
|
|
36
|
+
return Object.keys(t).length === 0;
|
|
37
37
|
};
|
|
38
|
-
|
|
39
|
-
if (
|
|
40
|
-
const
|
|
41
|
-
const s =
|
|
38
|
+
t.merge = function(t, e, n) {
|
|
39
|
+
if (e) {
|
|
40
|
+
const i = Object.keys(e);
|
|
41
|
+
const s = i.length;
|
|
42
42
|
for (let r = 0; r < s; r++) {
|
|
43
|
-
if (
|
|
44
|
-
|
|
43
|
+
if (n === "strict") {
|
|
44
|
+
t[i[r]] = [ e[i[r]] ];
|
|
45
45
|
} else {
|
|
46
|
-
|
|
46
|
+
t[i[r]] = e[i[r]];
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
|
-
|
|
52
|
-
if (
|
|
53
|
-
return
|
|
51
|
+
t.getValue = function(e) {
|
|
52
|
+
if (t.isExist(e)) {
|
|
53
|
+
return e;
|
|
54
54
|
} else {
|
|
55
55
|
return "";
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
})(
|
|
58
|
+
t.isName = o;
|
|
59
|
+
t.getAllMatches = r;
|
|
60
|
+
t.nameRegexp = i;
|
|
61
|
+
})(n);
|
|
62
62
|
|
|
63
|
-
const
|
|
63
|
+
const i = t(n);
|
|
64
64
|
|
|
65
65
|
"use strict";
|
|
66
66
|
|
|
67
|
-
const s =
|
|
67
|
+
const s = n;
|
|
68
68
|
|
|
69
69
|
const r = {
|
|
70
70
|
allowBooleanAttributes: false,
|
|
71
71
|
unpairedTags: []
|
|
72
72
|
};
|
|
73
73
|
|
|
74
|
-
var o =
|
|
75
|
-
|
|
76
|
-
const
|
|
77
|
-
let
|
|
74
|
+
var o = e.validate = function(t, e) {
|
|
75
|
+
e = Object.assign({}, r, e);
|
|
76
|
+
const n = [];
|
|
77
|
+
let i = false;
|
|
78
78
|
let s = false;
|
|
79
|
-
if (
|
|
80
|
-
|
|
79
|
+
if (t[0] === "\ufeff") {
|
|
80
|
+
t = t.substr(1);
|
|
81
81
|
}
|
|
82
|
-
for (let r = 0; r <
|
|
83
|
-
if (
|
|
82
|
+
for (let r = 0; r < t.length; r++) {
|
|
83
|
+
if (t[r] === "<" && t[r + 1] === "?") {
|
|
84
84
|
r += 2;
|
|
85
|
-
r = l(
|
|
85
|
+
r = l(t, r);
|
|
86
86
|
if (r.err) return r;
|
|
87
|
-
} else if (
|
|
87
|
+
} else if (t[r] === "<") {
|
|
88
88
|
let o = r;
|
|
89
89
|
r++;
|
|
90
|
-
if (
|
|
91
|
-
r = u(
|
|
90
|
+
if (t[r] === "!") {
|
|
91
|
+
r = u(t, r);
|
|
92
92
|
continue;
|
|
93
93
|
} else {
|
|
94
94
|
let f = false;
|
|
95
|
-
if (
|
|
95
|
+
if (t[r] === "/") {
|
|
96
96
|
f = true;
|
|
97
97
|
r++;
|
|
98
98
|
}
|
|
99
99
|
let c = "";
|
|
100
|
-
for (;r <
|
|
101
|
-
c +=
|
|
100
|
+
for (;r < t.length && t[r] !== ">" && t[r] !== " " && t[r] !== "\t" && t[r] !== "\n" && t[r] !== "\r"; r++) {
|
|
101
|
+
c += t[r];
|
|
102
102
|
}
|
|
103
103
|
c = c.trim();
|
|
104
104
|
if (c[c.length - 1] === "/") {
|
|
@@ -106,98 +106,100 @@ var o = t.validate = function(e, t) {
|
|
|
106
106
|
r--;
|
|
107
107
|
}
|
|
108
108
|
if (!b(c)) {
|
|
109
|
-
let
|
|
109
|
+
let e;
|
|
110
110
|
if (c.trim().length === 0) {
|
|
111
|
-
|
|
111
|
+
e = "Invalid space after '<'.";
|
|
112
112
|
} else {
|
|
113
|
-
|
|
113
|
+
e = "Tag '" + c + "' is an invalid name.";
|
|
114
114
|
}
|
|
115
|
-
return x("InvalidTag",
|
|
115
|
+
return x("InvalidTag", e, E(t, r));
|
|
116
116
|
}
|
|
117
|
-
const
|
|
118
|
-
if (
|
|
119
|
-
return x("InvalidAttr", "Attributes for '" + c + "' have open quote.", E(
|
|
117
|
+
const d = h(t, r);
|
|
118
|
+
if (d === false) {
|
|
119
|
+
return x("InvalidAttr", "Attributes for '" + c + "' have open quote.", E(t, r));
|
|
120
120
|
}
|
|
121
|
-
let g =
|
|
122
|
-
r =
|
|
121
|
+
let g = d.value;
|
|
122
|
+
r = d.index;
|
|
123
123
|
if (g[g.length - 1] === "/") {
|
|
124
|
-
const
|
|
124
|
+
const n = r - g.length;
|
|
125
125
|
g = g.substring(0, g.length - 1);
|
|
126
|
-
const s = p(g,
|
|
126
|
+
const s = p(g, e);
|
|
127
127
|
if (s === true) {
|
|
128
|
-
|
|
128
|
+
i = true;
|
|
129
129
|
} else {
|
|
130
|
-
return x(s.err.code, s.err.msg, E(
|
|
130
|
+
return x(s.err.code, s.err.msg, E(t, n + s.err.line));
|
|
131
131
|
}
|
|
132
132
|
} else if (f) {
|
|
133
|
-
if (!
|
|
134
|
-
return x("InvalidTag", "Closing tag '" + c + "' doesn't have proper closing.", E(
|
|
133
|
+
if (!d.tagClosed) {
|
|
134
|
+
return x("InvalidTag", "Closing tag '" + c + "' doesn't have proper closing.", E(t, r));
|
|
135
135
|
} else if (g.trim().length > 0) {
|
|
136
|
-
return x("InvalidTag", "Closing tag '" + c + "' can't have attributes or invalid starting.", E(
|
|
136
|
+
return x("InvalidTag", "Closing tag '" + c + "' can't have attributes or invalid starting.", E(t, o));
|
|
137
|
+
} else if (n.length === 0) {
|
|
138
|
+
return x("InvalidTag", "Closing tag '" + c + "' has not been opened.", E(t, o));
|
|
137
139
|
} else {
|
|
138
|
-
const
|
|
139
|
-
if (c !==
|
|
140
|
-
let
|
|
141
|
-
return x("InvalidTag", "Expected closing tag '" +
|
|
140
|
+
const e = n.pop();
|
|
141
|
+
if (c !== e.tagName) {
|
|
142
|
+
let n = E(t, e.tagStartPos);
|
|
143
|
+
return x("InvalidTag", "Expected closing tag '" + e.tagName + "' (opened in line " + n.line + ", col " + n.col + ") instead of closing tag '" + c + "'.", E(t, o));
|
|
142
144
|
}
|
|
143
|
-
if (
|
|
145
|
+
if (n.length == 0) {
|
|
144
146
|
s = true;
|
|
145
147
|
}
|
|
146
148
|
}
|
|
147
149
|
} else {
|
|
148
|
-
const a = p(g,
|
|
150
|
+
const a = p(g, e);
|
|
149
151
|
if (a !== true) {
|
|
150
|
-
return x(a.err.code, a.err.msg, E(
|
|
152
|
+
return x(a.err.code, a.err.msg, E(t, r - g.length + a.err.line));
|
|
151
153
|
}
|
|
152
154
|
if (s === true) {
|
|
153
|
-
return x("InvalidXml", "Multiple possible root nodes found.", E(
|
|
154
|
-
} else if (
|
|
155
|
-
|
|
155
|
+
return x("InvalidXml", "Multiple possible root nodes found.", E(t, r));
|
|
156
|
+
} else if (e.unpairedTags.indexOf(c) !== -1) {} else {
|
|
157
|
+
n.push({
|
|
156
158
|
tagName: c,
|
|
157
159
|
tagStartPos: o
|
|
158
160
|
});
|
|
159
161
|
}
|
|
160
|
-
|
|
162
|
+
i = true;
|
|
161
163
|
}
|
|
162
|
-
for (r++; r <
|
|
163
|
-
if (
|
|
164
|
-
if (
|
|
164
|
+
for (r++; r < t.length; r++) {
|
|
165
|
+
if (t[r] === "<") {
|
|
166
|
+
if (t[r + 1] === "!") {
|
|
165
167
|
r++;
|
|
166
|
-
r = u(
|
|
168
|
+
r = u(t, r);
|
|
167
169
|
continue;
|
|
168
|
-
} else if (
|
|
169
|
-
r = l(
|
|
170
|
+
} else if (t[r + 1] === "?") {
|
|
171
|
+
r = l(t, ++r);
|
|
170
172
|
if (r.err) return r;
|
|
171
173
|
} else {
|
|
172
174
|
break;
|
|
173
175
|
}
|
|
174
|
-
} else if (
|
|
175
|
-
const
|
|
176
|
-
if (
|
|
177
|
-
r =
|
|
176
|
+
} else if (t[r] === "&") {
|
|
177
|
+
const e = m(t, r);
|
|
178
|
+
if (e == -1) return x("InvalidChar", "char '&' is not expected.", E(t, r));
|
|
179
|
+
r = e;
|
|
178
180
|
} else {
|
|
179
|
-
if (s === true && !a(
|
|
180
|
-
return x("InvalidXml", "Extra text at the end", E(
|
|
181
|
+
if (s === true && !a(t[r])) {
|
|
182
|
+
return x("InvalidXml", "Extra text at the end", E(t, r));
|
|
181
183
|
}
|
|
182
184
|
}
|
|
183
185
|
}
|
|
184
|
-
if (
|
|
186
|
+
if (t[r] === "<") {
|
|
185
187
|
r--;
|
|
186
188
|
}
|
|
187
189
|
}
|
|
188
190
|
} else {
|
|
189
|
-
if (a(
|
|
191
|
+
if (a(t[r])) {
|
|
190
192
|
continue;
|
|
191
193
|
}
|
|
192
|
-
return x("InvalidChar", "char '" +
|
|
194
|
+
return x("InvalidChar", "char '" + t[r] + "' is not expected.", E(t, r));
|
|
193
195
|
}
|
|
194
196
|
}
|
|
195
|
-
if (!
|
|
197
|
+
if (!i) {
|
|
196
198
|
return x("InvalidXml", "Start tag expected.", 1);
|
|
197
|
-
} else if (
|
|
198
|
-
return x("InvalidTag", "Unclosed tag '" +
|
|
199
|
-
} else if (
|
|
200
|
-
return x("InvalidXml", "Invalid '" + JSON.stringify(
|
|
199
|
+
} else if (n.length == 1) {
|
|
200
|
+
return x("InvalidTag", "Unclosed tag '" + n[0].tagName + "'.", E(t, n[0].tagStartPos));
|
|
201
|
+
} else if (n.length > 0) {
|
|
202
|
+
return x("InvalidXml", "Invalid '" + JSON.stringify(n.map((t => t.tagName)), null, 4).replace(/\r?\n/g, "") + "' found.", {
|
|
201
203
|
line: 1,
|
|
202
204
|
col: 1
|
|
203
205
|
});
|
|
@@ -205,176 +207,176 @@ var o = t.validate = function(e, t) {
|
|
|
205
207
|
return true;
|
|
206
208
|
};
|
|
207
209
|
|
|
208
|
-
function a(
|
|
209
|
-
return
|
|
210
|
+
function a(t) {
|
|
211
|
+
return t === " " || t === "\t" || t === "\n" || t === "\r";
|
|
210
212
|
}
|
|
211
213
|
|
|
212
|
-
function l(
|
|
213
|
-
const
|
|
214
|
-
for (;
|
|
215
|
-
if (e
|
|
216
|
-
const
|
|
217
|
-
if (
|
|
218
|
-
return x("InvalidXml", "XML declaration allowed only at the start of the document.", E(
|
|
219
|
-
} else if (e
|
|
220
|
-
|
|
214
|
+
function l(t, e) {
|
|
215
|
+
const n = e;
|
|
216
|
+
for (;e < t.length; e++) {
|
|
217
|
+
if (t[e] == "?" || t[e] == " ") {
|
|
218
|
+
const i = t.substr(n, e - n);
|
|
219
|
+
if (e > 5 && i === "xml") {
|
|
220
|
+
return x("InvalidXml", "XML declaration allowed only at the start of the document.", E(t, e));
|
|
221
|
+
} else if (t[e] == "?" && t[e + 1] == ">") {
|
|
222
|
+
e++;
|
|
221
223
|
break;
|
|
222
224
|
} else {
|
|
223
225
|
continue;
|
|
224
226
|
}
|
|
225
227
|
}
|
|
226
228
|
}
|
|
227
|
-
return
|
|
229
|
+
return e;
|
|
228
230
|
}
|
|
229
231
|
|
|
230
|
-
function u(
|
|
231
|
-
if (
|
|
232
|
-
for (
|
|
233
|
-
if (e
|
|
234
|
-
|
|
232
|
+
function u(t, e) {
|
|
233
|
+
if (t.length > e + 5 && t[e + 1] === "-" && t[e + 2] === "-") {
|
|
234
|
+
for (e += 3; e < t.length; e++) {
|
|
235
|
+
if (t[e] === "-" && t[e + 1] === "-" && t[e + 2] === ">") {
|
|
236
|
+
e += 2;
|
|
235
237
|
break;
|
|
236
238
|
}
|
|
237
239
|
}
|
|
238
|
-
} else if (
|
|
239
|
-
let
|
|
240
|
-
for (
|
|
241
|
-
if (e
|
|
242
|
-
|
|
243
|
-
} else if (e
|
|
244
|
-
|
|
245
|
-
if (
|
|
240
|
+
} else if (t.length > e + 8 && t[e + 1] === "D" && t[e + 2] === "O" && t[e + 3] === "C" && t[e + 4] === "T" && t[e + 5] === "Y" && t[e + 6] === "P" && t[e + 7] === "E") {
|
|
241
|
+
let n = 1;
|
|
242
|
+
for (e += 8; e < t.length; e++) {
|
|
243
|
+
if (t[e] === "<") {
|
|
244
|
+
n++;
|
|
245
|
+
} else if (t[e] === ">") {
|
|
246
|
+
n--;
|
|
247
|
+
if (n === 0) {
|
|
246
248
|
break;
|
|
247
249
|
}
|
|
248
250
|
}
|
|
249
251
|
}
|
|
250
|
-
} else if (
|
|
251
|
-
for (
|
|
252
|
-
if (e
|
|
253
|
-
|
|
252
|
+
} else if (t.length > e + 9 && t[e + 1] === "[" && t[e + 2] === "C" && t[e + 3] === "D" && t[e + 4] === "A" && t[e + 5] === "T" && t[e + 6] === "A" && t[e + 7] === "[") {
|
|
253
|
+
for (e += 8; e < t.length; e++) {
|
|
254
|
+
if (t[e] === "]" && t[e + 1] === "]" && t[e + 2] === ">") {
|
|
255
|
+
e += 2;
|
|
254
256
|
break;
|
|
255
257
|
}
|
|
256
258
|
}
|
|
257
259
|
}
|
|
258
|
-
return
|
|
260
|
+
return e;
|
|
259
261
|
}
|
|
260
262
|
|
|
261
263
|
const f = '"';
|
|
262
264
|
|
|
263
265
|
const c = "'";
|
|
264
266
|
|
|
265
|
-
function
|
|
266
|
-
let i = "";
|
|
267
|
+
function h(t, e) {
|
|
267
268
|
let n = "";
|
|
269
|
+
let i = "";
|
|
268
270
|
let s = false;
|
|
269
|
-
for (;
|
|
270
|
-
if (e
|
|
271
|
-
if (
|
|
272
|
-
|
|
273
|
-
} else if (
|
|
274
|
-
|
|
271
|
+
for (;e < t.length; e++) {
|
|
272
|
+
if (t[e] === f || t[e] === c) {
|
|
273
|
+
if (i === "") {
|
|
274
|
+
i = t[e];
|
|
275
|
+
} else if (i !== t[e]) {} else {
|
|
276
|
+
i = "";
|
|
275
277
|
}
|
|
276
|
-
} else if (e
|
|
277
|
-
if (
|
|
278
|
+
} else if (t[e] === ">") {
|
|
279
|
+
if (i === "") {
|
|
278
280
|
s = true;
|
|
279
281
|
break;
|
|
280
282
|
}
|
|
281
283
|
}
|
|
282
|
-
|
|
284
|
+
n += t[e];
|
|
283
285
|
}
|
|
284
|
-
if (
|
|
286
|
+
if (i !== "") {
|
|
285
287
|
return false;
|
|
286
288
|
}
|
|
287
289
|
return {
|
|
288
|
-
value:
|
|
289
|
-
index:
|
|
290
|
+
value: n,
|
|
291
|
+
index: e,
|
|
290
292
|
tagClosed: s
|
|
291
293
|
};
|
|
292
294
|
}
|
|
293
295
|
|
|
294
|
-
const
|
|
296
|
+
const d = new RegExp("(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['\"])(([\\s\\S])*?)\\5)?", "g");
|
|
295
297
|
|
|
296
|
-
function p(
|
|
297
|
-
const
|
|
298
|
-
const
|
|
299
|
-
for (let
|
|
300
|
-
if (
|
|
301
|
-
return x("InvalidAttr", "Attribute '" +
|
|
302
|
-
} else if (
|
|
303
|
-
return x("InvalidAttr", "Attribute '" +
|
|
304
|
-
} else if (
|
|
305
|
-
return x("InvalidAttr", "boolean attribute '" +
|
|
298
|
+
function p(t, e) {
|
|
299
|
+
const n = s.getAllMatches(t, d);
|
|
300
|
+
const i = {};
|
|
301
|
+
for (let t = 0; t < n.length; t++) {
|
|
302
|
+
if (n[t][1].length === 0) {
|
|
303
|
+
return x("InvalidAttr", "Attribute '" + n[t][2] + "' has no space in starting.", v(n[t]));
|
|
304
|
+
} else if (n[t][3] !== undefined && n[t][4] === undefined) {
|
|
305
|
+
return x("InvalidAttr", "Attribute '" + n[t][2] + "' is without value.", v(n[t]));
|
|
306
|
+
} else if (n[t][3] === undefined && !e.allowBooleanAttributes) {
|
|
307
|
+
return x("InvalidAttr", "boolean attribute '" + n[t][2] + "' is not allowed.", v(n[t]));
|
|
306
308
|
}
|
|
307
|
-
const s =
|
|
309
|
+
const s = n[t][2];
|
|
308
310
|
if (!N(s)) {
|
|
309
|
-
return x("InvalidAttr", "Attribute '" + s + "' is an invalid name.", v(
|
|
311
|
+
return x("InvalidAttr", "Attribute '" + s + "' is an invalid name.", v(n[t]));
|
|
310
312
|
}
|
|
311
|
-
if (!
|
|
312
|
-
|
|
313
|
+
if (!i.hasOwnProperty(s)) {
|
|
314
|
+
i[s] = 1;
|
|
313
315
|
} else {
|
|
314
|
-
return x("InvalidAttr", "Attribute '" + s + "' is repeated.", v(
|
|
316
|
+
return x("InvalidAttr", "Attribute '" + s + "' is repeated.", v(n[t]));
|
|
315
317
|
}
|
|
316
318
|
}
|
|
317
319
|
return true;
|
|
318
320
|
}
|
|
319
321
|
|
|
320
|
-
function g(
|
|
321
|
-
let
|
|
322
|
-
if (e
|
|
323
|
-
|
|
324
|
-
|
|
322
|
+
function g(t, e) {
|
|
323
|
+
let n = /\d/;
|
|
324
|
+
if (t[e] === "x") {
|
|
325
|
+
e++;
|
|
326
|
+
n = /[\da-fA-F]/;
|
|
325
327
|
}
|
|
326
|
-
for (;
|
|
327
|
-
if (e
|
|
328
|
-
if (!e
|
|
328
|
+
for (;e < t.length; e++) {
|
|
329
|
+
if (t[e] === ";") return e;
|
|
330
|
+
if (!t[e].match(n)) break;
|
|
329
331
|
}
|
|
330
332
|
return -1;
|
|
331
333
|
}
|
|
332
334
|
|
|
333
|
-
function m(
|
|
334
|
-
|
|
335
|
-
if (e
|
|
336
|
-
if (e
|
|
337
|
-
|
|
338
|
-
return g(
|
|
339
|
-
}
|
|
340
|
-
let
|
|
341
|
-
for (;
|
|
342
|
-
if (e
|
|
343
|
-
if (e
|
|
335
|
+
function m(t, e) {
|
|
336
|
+
e++;
|
|
337
|
+
if (t[e] === ";") return -1;
|
|
338
|
+
if (t[e] === "#") {
|
|
339
|
+
e++;
|
|
340
|
+
return g(t, e);
|
|
341
|
+
}
|
|
342
|
+
let n = 0;
|
|
343
|
+
for (;e < t.length; e++, n++) {
|
|
344
|
+
if (t[e].match(/\w/) && n < 20) continue;
|
|
345
|
+
if (t[e] === ";") break;
|
|
344
346
|
return -1;
|
|
345
347
|
}
|
|
346
|
-
return
|
|
348
|
+
return e;
|
|
347
349
|
}
|
|
348
350
|
|
|
349
|
-
function x(
|
|
351
|
+
function x(t, e, n) {
|
|
350
352
|
return {
|
|
351
353
|
err: {
|
|
352
|
-
code:
|
|
353
|
-
msg:
|
|
354
|
-
line:
|
|
355
|
-
col:
|
|
354
|
+
code: t,
|
|
355
|
+
msg: e,
|
|
356
|
+
line: n.line || n,
|
|
357
|
+
col: n.col
|
|
356
358
|
}
|
|
357
359
|
};
|
|
358
360
|
}
|
|
359
361
|
|
|
360
|
-
function N(
|
|
361
|
-
return s.isName(
|
|
362
|
+
function N(t) {
|
|
363
|
+
return s.isName(t);
|
|
362
364
|
}
|
|
363
365
|
|
|
364
|
-
function b(
|
|
365
|
-
return s.isName(
|
|
366
|
+
function b(t) {
|
|
367
|
+
return s.isName(t);
|
|
366
368
|
}
|
|
367
369
|
|
|
368
|
-
function E(
|
|
369
|
-
const
|
|
370
|
+
function E(t, e) {
|
|
371
|
+
const n = t.substring(0, e).split(/\r?\n/);
|
|
370
372
|
return {
|
|
371
|
-
line:
|
|
372
|
-
col:
|
|
373
|
+
line: n.length,
|
|
374
|
+
col: n[n.length - 1].length + 1
|
|
373
375
|
};
|
|
374
376
|
}
|
|
375
377
|
|
|
376
|
-
function v(
|
|
377
|
-
return
|
|
378
|
+
function v(t) {
|
|
379
|
+
return t.startIndex + t[1].length;
|
|
378
380
|
}
|
|
379
381
|
|
|
380
382
|
var y = {};
|
|
@@ -396,11 +398,11 @@ const T = {
|
|
|
396
398
|
leadingZeros: true,
|
|
397
399
|
eNotation: true
|
|
398
400
|
},
|
|
399
|
-
tagValueProcessor: function(
|
|
400
|
-
return
|
|
401
|
+
tagValueProcessor: function(t, e) {
|
|
402
|
+
return e;
|
|
401
403
|
},
|
|
402
|
-
attributeValueProcessor: function(
|
|
403
|
-
return
|
|
404
|
+
attributeValueProcessor: function(t, e) {
|
|
405
|
+
return e;
|
|
404
406
|
},
|
|
405
407
|
stopNodes: [],
|
|
406
408
|
alwaysCreateTextNode: false,
|
|
@@ -413,150 +415,151 @@ const T = {
|
|
|
413
415
|
ignorePiTags: false,
|
|
414
416
|
transformTagName: false,
|
|
415
417
|
transformAttributeName: false,
|
|
416
|
-
updateTag: function(
|
|
417
|
-
return
|
|
418
|
+
updateTag: function(t, e, n) {
|
|
419
|
+
return t;
|
|
418
420
|
}
|
|
419
421
|
};
|
|
420
422
|
|
|
421
|
-
const O = function(
|
|
422
|
-
return Object.assign({}, T,
|
|
423
|
+
const O = function(t) {
|
|
424
|
+
return Object.assign({}, T, t);
|
|
423
425
|
};
|
|
424
426
|
|
|
425
|
-
var
|
|
427
|
+
var A = y.buildOptions = O;
|
|
426
428
|
|
|
427
429
|
var P = y.defaultOptions = T;
|
|
428
430
|
|
|
429
431
|
"use strict";
|
|
430
432
|
|
|
431
433
|
class XmlNode {
|
|
432
|
-
constructor(
|
|
433
|
-
this.tagname =
|
|
434
|
+
constructor(t) {
|
|
435
|
+
this.tagname = t;
|
|
434
436
|
this.child = [];
|
|
435
437
|
this[":@"] = {};
|
|
436
438
|
}
|
|
437
|
-
add(
|
|
438
|
-
if (
|
|
439
|
+
add(t, e) {
|
|
440
|
+
if (t === "__proto__") t = "#__proto__";
|
|
439
441
|
this.child.push({
|
|
440
|
-
[
|
|
442
|
+
[t]: e
|
|
441
443
|
});
|
|
442
444
|
}
|
|
443
|
-
addChild(
|
|
444
|
-
if (
|
|
445
|
-
if (
|
|
445
|
+
addChild(t) {
|
|
446
|
+
if (t.tagname === "__proto__") t.tagname = "#__proto__";
|
|
447
|
+
if (t[":@"] && Object.keys(t[":@"]).length > 0) {
|
|
446
448
|
this.child.push({
|
|
447
|
-
[
|
|
448
|
-
[":@"]:
|
|
449
|
+
[t.tagname]: t.child,
|
|
450
|
+
[":@"]: t[":@"]
|
|
449
451
|
});
|
|
450
452
|
} else {
|
|
451
453
|
this.child.push({
|
|
452
|
-
[
|
|
454
|
+
[t.tagname]: t.child
|
|
453
455
|
});
|
|
454
456
|
}
|
|
455
457
|
}
|
|
456
458
|
}
|
|
457
459
|
|
|
458
|
-
var
|
|
460
|
+
var w = XmlNode;
|
|
459
461
|
|
|
460
|
-
const
|
|
462
|
+
const C = t(w);
|
|
461
463
|
|
|
462
|
-
const
|
|
464
|
+
const I = n;
|
|
463
465
|
|
|
464
|
-
function
|
|
465
|
-
const
|
|
466
|
-
if (e
|
|
467
|
-
|
|
468
|
-
let
|
|
466
|
+
function S(t, e) {
|
|
467
|
+
const n = {};
|
|
468
|
+
if (t[e + 3] === "O" && t[e + 4] === "C" && t[e + 5] === "T" && t[e + 6] === "Y" && t[e + 7] === "P" && t[e + 8] === "E") {
|
|
469
|
+
e = e + 9;
|
|
470
|
+
let i = 1;
|
|
469
471
|
let s = false, r = false;
|
|
470
472
|
let o = "";
|
|
471
|
-
for (;
|
|
472
|
-
if (e
|
|
473
|
-
if (s && k(
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
473
|
+
for (;e < t.length; e++) {
|
|
474
|
+
if (t[e] === "<" && !r) {
|
|
475
|
+
if (s && k(t, e)) {
|
|
476
|
+
e += 7;
|
|
477
|
+
let i, s;
|
|
478
|
+
[i, s, e] = j(t, e + 1);
|
|
479
|
+
if (s.indexOf("&") === -1) n[D(i)] = {
|
|
480
|
+
regx: RegExp(`&${i};`, "g"),
|
|
481
|
+
val: s
|
|
479
482
|
};
|
|
480
|
-
} else if (s &&
|
|
481
|
-
|
|
483
|
+
} else if (s && F(t, e)) e += 8; else if (s && $(t, e)) e += 8; else if (s && _(t, e)) e += 9; else if (V) r = true; else throw new Error("Invalid DOCTYPE");
|
|
484
|
+
i++;
|
|
482
485
|
o = "";
|
|
483
|
-
} else if (e
|
|
486
|
+
} else if (t[e] === ">") {
|
|
484
487
|
if (r) {
|
|
485
|
-
if (e
|
|
488
|
+
if (t[e - 1] === "-" && t[e - 2] === "-") {
|
|
486
489
|
r = false;
|
|
487
|
-
|
|
490
|
+
i--;
|
|
488
491
|
}
|
|
489
492
|
} else {
|
|
490
|
-
|
|
493
|
+
i--;
|
|
491
494
|
}
|
|
492
|
-
if (
|
|
495
|
+
if (i === 0) {
|
|
493
496
|
break;
|
|
494
497
|
}
|
|
495
|
-
} else if (e
|
|
498
|
+
} else if (t[e] === "[") {
|
|
496
499
|
s = true;
|
|
497
500
|
} else {
|
|
498
|
-
o += e
|
|
501
|
+
o += t[e];
|
|
499
502
|
}
|
|
500
503
|
}
|
|
501
|
-
if (
|
|
504
|
+
if (i !== 0) {
|
|
502
505
|
throw new Error(`Unclosed DOCTYPE`);
|
|
503
506
|
}
|
|
504
507
|
} else {
|
|
505
508
|
throw new Error(`Invalid Tag instead of DOCTYPE`);
|
|
506
509
|
}
|
|
507
510
|
return {
|
|
508
|
-
entities:
|
|
509
|
-
i:
|
|
511
|
+
entities: n,
|
|
512
|
+
i: e
|
|
510
513
|
};
|
|
511
514
|
}
|
|
512
515
|
|
|
513
|
-
function
|
|
514
|
-
let
|
|
515
|
-
for (;
|
|
516
|
-
|
|
516
|
+
function j(t, e) {
|
|
517
|
+
let n = "";
|
|
518
|
+
for (;e < t.length && (t[e] !== "'" && t[e] !== '"'); e++) {
|
|
519
|
+
n += t[e];
|
|
517
520
|
}
|
|
518
|
-
|
|
519
|
-
if (
|
|
520
|
-
const
|
|
521
|
+
n = n.trim();
|
|
522
|
+
if (n.indexOf(" ") !== -1) throw new Error("External entites are not supported");
|
|
523
|
+
const i = t[e++];
|
|
521
524
|
let s = "";
|
|
522
|
-
for (;
|
|
523
|
-
s += e
|
|
525
|
+
for (;e < t.length && t[e] !== i; e++) {
|
|
526
|
+
s += t[e];
|
|
524
527
|
}
|
|
525
|
-
return [
|
|
528
|
+
return [ n, s, e ];
|
|
526
529
|
}
|
|
527
530
|
|
|
528
|
-
function V(
|
|
529
|
-
if (e
|
|
531
|
+
function V(t, e) {
|
|
532
|
+
if (t[e + 1] === "!" && t[e + 2] === "-" && t[e + 3] === "-") return true;
|
|
530
533
|
return false;
|
|
531
534
|
}
|
|
532
535
|
|
|
533
|
-
function k(
|
|
534
|
-
if (e
|
|
536
|
+
function k(t, e) {
|
|
537
|
+
if (t[e + 1] === "!" && t[e + 2] === "E" && t[e + 3] === "N" && t[e + 4] === "T" && t[e + 5] === "I" && t[e + 6] === "T" && t[e + 7] === "Y") return true;
|
|
535
538
|
return false;
|
|
536
539
|
}
|
|
537
540
|
|
|
538
|
-
function
|
|
539
|
-
if (e
|
|
541
|
+
function F(t, e) {
|
|
542
|
+
if (t[e + 1] === "!" && t[e + 2] === "E" && t[e + 3] === "L" && t[e + 4] === "E" && t[e + 5] === "M" && t[e + 6] === "E" && t[e + 7] === "N" && t[e + 8] === "T") return true;
|
|
540
543
|
return false;
|
|
541
544
|
}
|
|
542
545
|
|
|
543
|
-
function
|
|
544
|
-
if (e
|
|
546
|
+
function $(t, e) {
|
|
547
|
+
if (t[e + 1] === "!" && t[e + 2] === "A" && t[e + 3] === "T" && t[e + 4] === "T" && t[e + 5] === "L" && t[e + 6] === "I" && t[e + 7] === "S" && t[e + 8] === "T") return true;
|
|
545
548
|
return false;
|
|
546
549
|
}
|
|
547
550
|
|
|
548
|
-
function
|
|
549
|
-
if (e
|
|
551
|
+
function _(t, e) {
|
|
552
|
+
if (t[e + 1] === "!" && t[e + 2] === "N" && t[e + 3] === "O" && t[e + 4] === "T" && t[e + 5] === "A" && t[e + 6] === "T" && t[e + 7] === "I" && t[e + 8] === "O" && t[e + 9] === "N") return true;
|
|
550
553
|
return false;
|
|
551
554
|
}
|
|
552
555
|
|
|
553
|
-
function
|
|
554
|
-
if (
|
|
556
|
+
function D(t) {
|
|
557
|
+
if (I.isName(t)) return t; else throw new Error(`Invalid entity name ${t}`);
|
|
555
558
|
}
|
|
556
559
|
|
|
557
|
-
var L =
|
|
560
|
+
var L = S;
|
|
558
561
|
|
|
559
|
-
const M =
|
|
562
|
+
const M = t(L);
|
|
560
563
|
|
|
561
564
|
const B = /^[-+]?0x[a-fA-F0-9]+$/;
|
|
562
565
|
|
|
@@ -570,74 +573,99 @@ if (!Number.parseFloat && window.parseFloat) {
|
|
|
570
573
|
Number.parseFloat = window.parseFloat;
|
|
571
574
|
}
|
|
572
575
|
|
|
573
|
-
const
|
|
576
|
+
const G = {
|
|
574
577
|
hex: true,
|
|
575
578
|
leadingZeros: true,
|
|
576
579
|
decimalPoint: ".",
|
|
577
580
|
eNotation: true
|
|
578
581
|
};
|
|
579
582
|
|
|
580
|
-
function
|
|
581
|
-
|
|
582
|
-
if (!
|
|
583
|
-
let
|
|
584
|
-
if (
|
|
585
|
-
return Number.parseInt(
|
|
583
|
+
function R(t, e = {}) {
|
|
584
|
+
e = Object.assign({}, G, e);
|
|
585
|
+
if (!t || typeof t !== "string") return t;
|
|
586
|
+
let n = t.trim();
|
|
587
|
+
if (e.skipLike !== undefined && e.skipLike.test(n)) return t; else if (e.hex && B.test(n)) {
|
|
588
|
+
return Number.parseInt(n, 16);
|
|
586
589
|
} else {
|
|
587
|
-
const
|
|
588
|
-
if (
|
|
589
|
-
const s =
|
|
590
|
-
const r =
|
|
591
|
-
let o = U(
|
|
592
|
-
const a =
|
|
593
|
-
if (!
|
|
594
|
-
const
|
|
595
|
-
const l = "" +
|
|
590
|
+
const i = X.exec(n);
|
|
591
|
+
if (i) {
|
|
592
|
+
const s = i[1];
|
|
593
|
+
const r = i[2];
|
|
594
|
+
let o = U(i[3]);
|
|
595
|
+
const a = i[4] || i[6];
|
|
596
|
+
if (!e.leadingZeros && r.length > 0 && s && n[2] !== ".") return t; else if (!e.leadingZeros && r.length > 0 && !s && n[1] !== ".") return t; else {
|
|
597
|
+
const i = Number(n);
|
|
598
|
+
const l = "" + i;
|
|
596
599
|
if (l.search(/[eE]/) !== -1) {
|
|
597
|
-
if (
|
|
600
|
+
if (e.eNotation) return i; else return t;
|
|
598
601
|
} else if (a) {
|
|
599
|
-
if (
|
|
600
|
-
} else if (
|
|
601
|
-
if (l === "0" && o === "") return
|
|
602
|
+
if (e.eNotation) return i; else return t;
|
|
603
|
+
} else if (n.indexOf(".") !== -1) {
|
|
604
|
+
if (l === "0" && o === "") return i; else if (l === o) return i; else if (s && l === "-" + o) return i; else return t;
|
|
602
605
|
}
|
|
603
606
|
if (r) {
|
|
604
|
-
if (o === l) return
|
|
607
|
+
if (o === l) return i; else if (s + o === l) return i; else return t;
|
|
605
608
|
}
|
|
606
|
-
if (
|
|
607
|
-
return
|
|
609
|
+
if (n === l) return i; else if (n === s + l) return i;
|
|
610
|
+
return t;
|
|
608
611
|
}
|
|
609
612
|
} else {
|
|
610
|
-
return
|
|
613
|
+
return t;
|
|
611
614
|
}
|
|
612
615
|
}
|
|
613
616
|
}
|
|
614
617
|
|
|
615
|
-
function U(
|
|
616
|
-
if (
|
|
617
|
-
|
|
618
|
-
if (
|
|
619
|
-
return
|
|
618
|
+
function U(t) {
|
|
619
|
+
if (t && t.indexOf(".") !== -1) {
|
|
620
|
+
t = t.replace(/0+$/, "");
|
|
621
|
+
if (t === ".") t = "0"; else if (t[0] === ".") t = "0" + t; else if (t[t.length - 1] === ".") t = t.substr(0, t.length - 1);
|
|
622
|
+
return t;
|
|
620
623
|
}
|
|
621
|
-
return
|
|
624
|
+
return t;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
var Y = R;
|
|
628
|
+
|
|
629
|
+
const Z = t(Y);
|
|
630
|
+
|
|
631
|
+
function q(t) {
|
|
632
|
+
if (typeof t === "function") {
|
|
633
|
+
return t;
|
|
634
|
+
}
|
|
635
|
+
if (Array.isArray(t)) {
|
|
636
|
+
return e => {
|
|
637
|
+
for (const n of t) {
|
|
638
|
+
if (typeof n === "string" && e === n) {
|
|
639
|
+
return true;
|
|
640
|
+
}
|
|
641
|
+
if (n instanceof RegExp && n.test(e)) {
|
|
642
|
+
return true;
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
};
|
|
646
|
+
}
|
|
647
|
+
return () => false;
|
|
622
648
|
}
|
|
623
649
|
|
|
624
|
-
var
|
|
650
|
+
var W = q;
|
|
625
651
|
|
|
626
|
-
const
|
|
652
|
+
const z = t(W);
|
|
627
653
|
|
|
628
654
|
"use strict";
|
|
629
655
|
|
|
630
|
-
const
|
|
656
|
+
const J = n;
|
|
657
|
+
|
|
658
|
+
const H = w;
|
|
631
659
|
|
|
632
|
-
const
|
|
660
|
+
const K = L;
|
|
633
661
|
|
|
634
|
-
const
|
|
662
|
+
const Q = Y;
|
|
635
663
|
|
|
636
|
-
const
|
|
664
|
+
const tt = W;
|
|
637
665
|
|
|
638
|
-
let
|
|
639
|
-
constructor(
|
|
640
|
-
this.options =
|
|
666
|
+
let et = class OrderedObjParser {
|
|
667
|
+
constructor(t) {
|
|
668
|
+
this.options = t;
|
|
641
669
|
this.currentNode = null;
|
|
642
670
|
this.tagsNodeStack = [];
|
|
643
671
|
this.docTypeEntities = {};
|
|
@@ -695,84 +723,96 @@ let H = class OrderedObjParser {
|
|
|
695
723
|
inr: {
|
|
696
724
|
regex: /&(inr|#8377);/g,
|
|
697
725
|
val: "₹"
|
|
726
|
+
},
|
|
727
|
+
num_dec: {
|
|
728
|
+
regex: /&#([0-9]{1,7});/g,
|
|
729
|
+
val: (t, e) => String.fromCharCode(Number.parseInt(e, 10))
|
|
730
|
+
},
|
|
731
|
+
num_hex: {
|
|
732
|
+
regex: /&#x([0-9a-fA-F]{1,6});/g,
|
|
733
|
+
val: (t, e) => String.fromCharCode(Number.parseInt(e, 16))
|
|
698
734
|
}
|
|
699
735
|
};
|
|
700
|
-
this.addExternalEntities =
|
|
701
|
-
this.parseXml =
|
|
702
|
-
this.parseTextData =
|
|
703
|
-
this.resolveNameSpace =
|
|
704
|
-
this.buildAttributesMap =
|
|
705
|
-
this.isItStopNode =
|
|
706
|
-
this.replaceEntitiesValue =
|
|
707
|
-
this.readStopNodeData =
|
|
708
|
-
this.saveTextToParentTag =
|
|
709
|
-
this.addChild =
|
|
736
|
+
this.addExternalEntities = nt;
|
|
737
|
+
this.parseXml = at;
|
|
738
|
+
this.parseTextData = it;
|
|
739
|
+
this.resolveNameSpace = st;
|
|
740
|
+
this.buildAttributesMap = ot;
|
|
741
|
+
this.isItStopNode = ct;
|
|
742
|
+
this.replaceEntitiesValue = ut;
|
|
743
|
+
this.readStopNodeData = gt;
|
|
744
|
+
this.saveTextToParentTag = ft;
|
|
745
|
+
this.addChild = lt;
|
|
746
|
+
this.ignoreAttributesFn = tt(this.options.ignoreAttributes);
|
|
710
747
|
}
|
|
711
748
|
};
|
|
712
749
|
|
|
713
|
-
function
|
|
714
|
-
const
|
|
715
|
-
for (let
|
|
716
|
-
const
|
|
717
|
-
this.lastEntities[
|
|
718
|
-
regex: new RegExp("&" +
|
|
719
|
-
val:
|
|
750
|
+
function nt(t) {
|
|
751
|
+
const e = Object.keys(t);
|
|
752
|
+
for (let n = 0; n < e.length; n++) {
|
|
753
|
+
const i = e[n];
|
|
754
|
+
this.lastEntities[i] = {
|
|
755
|
+
regex: new RegExp("&" + i + ";", "g"),
|
|
756
|
+
val: t[i]
|
|
720
757
|
};
|
|
721
758
|
}
|
|
722
759
|
}
|
|
723
760
|
|
|
724
|
-
function
|
|
725
|
-
if (
|
|
726
|
-
if (this.options.trimValues && !
|
|
727
|
-
|
|
761
|
+
function it(t, e, n, i, s, r, o) {
|
|
762
|
+
if (t !== undefined) {
|
|
763
|
+
if (this.options.trimValues && !i) {
|
|
764
|
+
t = t.trim();
|
|
728
765
|
}
|
|
729
|
-
if (
|
|
730
|
-
if (!o)
|
|
731
|
-
const
|
|
732
|
-
if (
|
|
733
|
-
return
|
|
734
|
-
} else if (typeof
|
|
735
|
-
return
|
|
766
|
+
if (t.length > 0) {
|
|
767
|
+
if (!o) t = this.replaceEntitiesValue(t);
|
|
768
|
+
const i = this.options.tagValueProcessor(e, t, n, s, r);
|
|
769
|
+
if (i === null || i === undefined) {
|
|
770
|
+
return t;
|
|
771
|
+
} else if (typeof i !== typeof t || i !== t) {
|
|
772
|
+
return i;
|
|
736
773
|
} else if (this.options.trimValues) {
|
|
737
|
-
return
|
|
774
|
+
return mt(t, this.options.parseTagValue, this.options.numberParseOptions);
|
|
738
775
|
} else {
|
|
739
|
-
const
|
|
740
|
-
if (
|
|
741
|
-
return
|
|
776
|
+
const e = t.trim();
|
|
777
|
+
if (e === t) {
|
|
778
|
+
return mt(t, this.options.parseTagValue, this.options.numberParseOptions);
|
|
742
779
|
} else {
|
|
743
|
-
return
|
|
780
|
+
return t;
|
|
744
781
|
}
|
|
745
782
|
}
|
|
746
783
|
}
|
|
747
784
|
}
|
|
748
785
|
}
|
|
749
786
|
|
|
750
|
-
function
|
|
787
|
+
function st(t) {
|
|
751
788
|
if (this.options.removeNSPrefix) {
|
|
752
|
-
const
|
|
753
|
-
const
|
|
754
|
-
if (
|
|
789
|
+
const e = t.split(":");
|
|
790
|
+
const n = t.charAt(0) === "/" ? "/" : "";
|
|
791
|
+
if (e[0] === "xmlns") {
|
|
755
792
|
return "";
|
|
756
793
|
}
|
|
757
|
-
if (
|
|
758
|
-
|
|
794
|
+
if (e.length === 2) {
|
|
795
|
+
t = n + e[1];
|
|
759
796
|
}
|
|
760
797
|
}
|
|
761
|
-
return
|
|
798
|
+
return t;
|
|
762
799
|
}
|
|
763
800
|
|
|
764
|
-
const
|
|
801
|
+
const rt = new RegExp("([^\\s=]+)\\s*(=\\s*(['\"])([\\s\\S]*?)\\3)?", "gm");
|
|
765
802
|
|
|
766
|
-
function
|
|
767
|
-
if (
|
|
768
|
-
const
|
|
769
|
-
const
|
|
803
|
+
function ot(t, e, n) {
|
|
804
|
+
if (this.options.ignoreAttributes !== true && typeof t === "string") {
|
|
805
|
+
const n = J.getAllMatches(t, rt);
|
|
806
|
+
const i = n.length;
|
|
770
807
|
const s = {};
|
|
771
|
-
for (let
|
|
772
|
-
const
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
808
|
+
for (let t = 0; t < i; t++) {
|
|
809
|
+
const i = this.resolveNameSpace(n[t][1]);
|
|
810
|
+
if (this.ignoreAttributesFn(i, e)) {
|
|
811
|
+
continue;
|
|
812
|
+
}
|
|
813
|
+
let r = n[t][4];
|
|
814
|
+
let o = this.options.attributeNamePrefix + i;
|
|
815
|
+
if (i.length) {
|
|
776
816
|
if (this.options.transformAttributeName) {
|
|
777
817
|
o = this.options.transformAttributeName(o);
|
|
778
818
|
}
|
|
@@ -782,13 +822,13 @@ function ie(e, t, i) {
|
|
|
782
822
|
r = r.trim();
|
|
783
823
|
}
|
|
784
824
|
r = this.replaceEntitiesValue(r);
|
|
785
|
-
const
|
|
786
|
-
if (
|
|
825
|
+
const t = this.options.attributeValueProcessor(i, r, e);
|
|
826
|
+
if (t === null || t === undefined) {
|
|
787
827
|
s[o] = r;
|
|
788
|
-
} else if (typeof
|
|
789
|
-
s[o] =
|
|
828
|
+
} else if (typeof t !== typeof r || t !== r) {
|
|
829
|
+
s[o] = t;
|
|
790
830
|
} else {
|
|
791
|
-
s[o] =
|
|
831
|
+
s[o] = mt(r, this.options.parseAttributeValue, this.options.numberParseOptions);
|
|
792
832
|
}
|
|
793
833
|
} else if (this.options.allowBooleanAttributes) {
|
|
794
834
|
s[o] = true;
|
|
@@ -799,37 +839,37 @@ function ie(e, t, i) {
|
|
|
799
839
|
return;
|
|
800
840
|
}
|
|
801
841
|
if (this.options.attributesGroupName) {
|
|
802
|
-
const
|
|
803
|
-
|
|
804
|
-
return
|
|
842
|
+
const t = {};
|
|
843
|
+
t[this.options.attributesGroupName] = s;
|
|
844
|
+
return t;
|
|
805
845
|
}
|
|
806
846
|
return s;
|
|
807
847
|
}
|
|
808
848
|
}
|
|
809
849
|
|
|
810
|
-
const
|
|
811
|
-
|
|
812
|
-
const
|
|
813
|
-
let
|
|
814
|
-
let
|
|
850
|
+
const at = function(t) {
|
|
851
|
+
t = t.replace(/\r\n?/g, "\n");
|
|
852
|
+
const e = new H("!xml");
|
|
853
|
+
let n = e;
|
|
854
|
+
let i = "";
|
|
815
855
|
let s = "";
|
|
816
|
-
for (let r = 0; r <
|
|
817
|
-
const o =
|
|
856
|
+
for (let r = 0; r < t.length; r++) {
|
|
857
|
+
const o = t[r];
|
|
818
858
|
if (o === "<") {
|
|
819
|
-
if (
|
|
820
|
-
const
|
|
821
|
-
let o =
|
|
859
|
+
if (t[r + 1] === "/") {
|
|
860
|
+
const e = dt(t, ">", r, "Closing Tag is not closed.");
|
|
861
|
+
let o = t.substring(r + 2, e).trim();
|
|
822
862
|
if (this.options.removeNSPrefix) {
|
|
823
|
-
const
|
|
824
|
-
if (
|
|
825
|
-
o = o.substr(
|
|
863
|
+
const t = o.indexOf(":");
|
|
864
|
+
if (t !== -1) {
|
|
865
|
+
o = o.substr(t + 1);
|
|
826
866
|
}
|
|
827
867
|
}
|
|
828
868
|
if (this.options.transformTagName) {
|
|
829
869
|
o = this.options.transformTagName(o);
|
|
830
870
|
}
|
|
831
|
-
if (
|
|
832
|
-
|
|
871
|
+
if (n) {
|
|
872
|
+
i = this.saveTextToParentTag(i, n, s);
|
|
833
873
|
}
|
|
834
874
|
const a = s.substring(s.lastIndexOf(".") + 1);
|
|
835
875
|
if (o && this.options.unpairedTags.indexOf(o) !== -1) {
|
|
@@ -843,52 +883,52 @@ const ne = function(e) {
|
|
|
843
883
|
l = s.lastIndexOf(".");
|
|
844
884
|
}
|
|
845
885
|
s = s.substring(0, l);
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
r =
|
|
849
|
-
} else if (
|
|
850
|
-
let
|
|
851
|
-
if (!
|
|
852
|
-
|
|
853
|
-
if (this.options.ignoreDeclaration &&
|
|
854
|
-
const
|
|
855
|
-
|
|
856
|
-
if (
|
|
857
|
-
|
|
886
|
+
n = this.tagsNodeStack.pop();
|
|
887
|
+
i = "";
|
|
888
|
+
r = e;
|
|
889
|
+
} else if (t[r + 1] === "?") {
|
|
890
|
+
let e = pt(t, r, false, "?>");
|
|
891
|
+
if (!e) throw new Error("Pi Tag is not closed.");
|
|
892
|
+
i = this.saveTextToParentTag(i, n, s);
|
|
893
|
+
if (this.options.ignoreDeclaration && e.tagName === "?xml" || this.options.ignorePiTags) {} else {
|
|
894
|
+
const t = new H(e.tagName);
|
|
895
|
+
t.add(this.options.textNodeName, "");
|
|
896
|
+
if (e.tagName !== e.tagExp && e.attrExpPresent) {
|
|
897
|
+
t[":@"] = this.buildAttributesMap(e.tagExp, s, e.tagName);
|
|
858
898
|
}
|
|
859
|
-
this.addChild(
|
|
899
|
+
this.addChild(n, t, s);
|
|
860
900
|
}
|
|
861
|
-
r =
|
|
862
|
-
} else if (
|
|
863
|
-
const
|
|
901
|
+
r = e.closeIndex + 1;
|
|
902
|
+
} else if (t.substr(r + 1, 3) === "!--") {
|
|
903
|
+
const e = dt(t, "--\x3e", r + 4, "Comment is not closed.");
|
|
864
904
|
if (this.options.commentPropName) {
|
|
865
|
-
const o =
|
|
866
|
-
|
|
867
|
-
|
|
905
|
+
const o = t.substring(r + 4, e - 2);
|
|
906
|
+
i = this.saveTextToParentTag(i, n, s);
|
|
907
|
+
n.add(this.options.commentPropName, [ {
|
|
868
908
|
[this.options.textNodeName]: o
|
|
869
909
|
} ]);
|
|
870
910
|
}
|
|
871
|
-
r =
|
|
872
|
-
} else if (
|
|
873
|
-
const
|
|
874
|
-
this.docTypeEntities =
|
|
875
|
-
r =
|
|
876
|
-
} else if (
|
|
877
|
-
const
|
|
878
|
-
const o =
|
|
879
|
-
|
|
880
|
-
let a = this.parseTextData(o,
|
|
911
|
+
r = e;
|
|
912
|
+
} else if (t.substr(r + 1, 2) === "!D") {
|
|
913
|
+
const e = K(t, r);
|
|
914
|
+
this.docTypeEntities = e.entities;
|
|
915
|
+
r = e.i;
|
|
916
|
+
} else if (t.substr(r + 1, 2) === "![") {
|
|
917
|
+
const e = dt(t, "]]>", r, "CDATA is not closed.") - 2;
|
|
918
|
+
const o = t.substring(r + 9, e);
|
|
919
|
+
i = this.saveTextToParentTag(i, n, s);
|
|
920
|
+
let a = this.parseTextData(o, n.tagname, s, true, false, true, true);
|
|
881
921
|
if (a == undefined) a = "";
|
|
882
922
|
if (this.options.cdataPropName) {
|
|
883
|
-
|
|
923
|
+
n.add(this.options.cdataPropName, [ {
|
|
884
924
|
[this.options.textNodeName]: o
|
|
885
925
|
} ]);
|
|
886
926
|
} else {
|
|
887
|
-
|
|
927
|
+
n.add(this.options.textNodeName, a);
|
|
888
928
|
}
|
|
889
|
-
r =
|
|
929
|
+
r = e + 2;
|
|
890
930
|
} else {
|
|
891
|
-
let o =
|
|
931
|
+
let o = pt(t, r, this.options.removeNSPrefix);
|
|
892
932
|
let a = o.tagName;
|
|
893
933
|
const l = o.rawTagName;
|
|
894
934
|
let u = o.tagExp;
|
|
@@ -897,41 +937,48 @@ const ne = function(e) {
|
|
|
897
937
|
if (this.options.transformTagName) {
|
|
898
938
|
a = this.options.transformTagName(a);
|
|
899
939
|
}
|
|
900
|
-
if (
|
|
901
|
-
if (
|
|
902
|
-
|
|
940
|
+
if (n && i) {
|
|
941
|
+
if (n.tagname !== "!xml") {
|
|
942
|
+
i = this.saveTextToParentTag(i, n, s, false);
|
|
903
943
|
}
|
|
904
944
|
}
|
|
905
|
-
const
|
|
906
|
-
if (
|
|
907
|
-
|
|
945
|
+
const h = n;
|
|
946
|
+
if (h && this.options.unpairedTags.indexOf(h.tagname) !== -1) {
|
|
947
|
+
n = this.tagsNodeStack.pop();
|
|
908
948
|
s = s.substring(0, s.lastIndexOf("."));
|
|
909
949
|
}
|
|
910
|
-
if (a !==
|
|
950
|
+
if (a !== e.tagname) {
|
|
911
951
|
s += s ? "." + a : a;
|
|
912
952
|
}
|
|
913
953
|
if (this.isItStopNode(this.options.stopNodes, s, a)) {
|
|
914
|
-
let
|
|
954
|
+
let e = "";
|
|
915
955
|
if (u.length > 0 && u.lastIndexOf("/") === u.length - 1) {
|
|
956
|
+
if (a[a.length - 1] === "/") {
|
|
957
|
+
a = a.substr(0, a.length - 1);
|
|
958
|
+
s = s.substr(0, s.length - 1);
|
|
959
|
+
u = a;
|
|
960
|
+
} else {
|
|
961
|
+
u = u.substr(0, u.length - 1);
|
|
962
|
+
}
|
|
916
963
|
r = o.closeIndex;
|
|
917
964
|
} else if (this.options.unpairedTags.indexOf(a) !== -1) {
|
|
918
965
|
r = o.closeIndex;
|
|
919
966
|
} else {
|
|
920
|
-
const
|
|
921
|
-
if (!
|
|
922
|
-
r =
|
|
923
|
-
|
|
967
|
+
const n = this.readStopNodeData(t, l, c + 1);
|
|
968
|
+
if (!n) throw new Error(`Unexpected end of ${l}`);
|
|
969
|
+
r = n.i;
|
|
970
|
+
e = n.tagContent;
|
|
924
971
|
}
|
|
925
|
-
const
|
|
972
|
+
const i = new H(a);
|
|
926
973
|
if (a !== u && f) {
|
|
927
|
-
|
|
974
|
+
i[":@"] = this.buildAttributesMap(u, s, a);
|
|
928
975
|
}
|
|
929
|
-
if (
|
|
930
|
-
|
|
976
|
+
if (e) {
|
|
977
|
+
e = this.parseTextData(e, a, s, true, f, true, true);
|
|
931
978
|
}
|
|
932
979
|
s = s.substr(0, s.lastIndexOf("."));
|
|
933
|
-
|
|
934
|
-
this.addChild(
|
|
980
|
+
i.add(this.options.textNodeName, e);
|
|
981
|
+
this.addChild(n, i, s);
|
|
935
982
|
} else {
|
|
936
983
|
if (u.length > 0 && u.lastIndexOf("/") === u.length - 1) {
|
|
937
984
|
if (a[a.length - 1] === "/") {
|
|
@@ -944,94 +991,94 @@ const ne = function(e) {
|
|
|
944
991
|
if (this.options.transformTagName) {
|
|
945
992
|
a = this.options.transformTagName(a);
|
|
946
993
|
}
|
|
947
|
-
const
|
|
994
|
+
const t = new H(a);
|
|
948
995
|
if (a !== u && f) {
|
|
949
|
-
|
|
996
|
+
t[":@"] = this.buildAttributesMap(u, s, a);
|
|
950
997
|
}
|
|
951
|
-
this.addChild(
|
|
998
|
+
this.addChild(n, t, s);
|
|
952
999
|
s = s.substr(0, s.lastIndexOf("."));
|
|
953
1000
|
} else {
|
|
954
|
-
const
|
|
955
|
-
this.tagsNodeStack.push(
|
|
1001
|
+
const t = new H(a);
|
|
1002
|
+
this.tagsNodeStack.push(n);
|
|
956
1003
|
if (a !== u && f) {
|
|
957
|
-
|
|
1004
|
+
t[":@"] = this.buildAttributesMap(u, s, a);
|
|
958
1005
|
}
|
|
959
|
-
this.addChild(
|
|
960
|
-
|
|
1006
|
+
this.addChild(n, t, s);
|
|
1007
|
+
n = t;
|
|
961
1008
|
}
|
|
962
|
-
|
|
1009
|
+
i = "";
|
|
963
1010
|
r = c;
|
|
964
1011
|
}
|
|
965
1012
|
}
|
|
966
1013
|
} else {
|
|
967
|
-
|
|
1014
|
+
i += t[r];
|
|
968
1015
|
}
|
|
969
1016
|
}
|
|
970
|
-
return
|
|
1017
|
+
return e.child;
|
|
971
1018
|
};
|
|
972
1019
|
|
|
973
|
-
function
|
|
974
|
-
const
|
|
975
|
-
if (
|
|
976
|
-
|
|
977
|
-
|
|
1020
|
+
function lt(t, e, n) {
|
|
1021
|
+
const i = this.options.updateTag(e.tagname, n, e[":@"]);
|
|
1022
|
+
if (i === false) {} else if (typeof i === "string") {
|
|
1023
|
+
e.tagname = i;
|
|
1024
|
+
t.addChild(e);
|
|
978
1025
|
} else {
|
|
979
|
-
|
|
1026
|
+
t.addChild(e);
|
|
980
1027
|
}
|
|
981
1028
|
}
|
|
982
1029
|
|
|
983
|
-
const
|
|
1030
|
+
const ut = function(t) {
|
|
984
1031
|
if (this.options.processEntities) {
|
|
985
|
-
for (let
|
|
986
|
-
const
|
|
987
|
-
|
|
1032
|
+
for (let e in this.docTypeEntities) {
|
|
1033
|
+
const n = this.docTypeEntities[e];
|
|
1034
|
+
t = t.replace(n.regx, n.val);
|
|
988
1035
|
}
|
|
989
|
-
for (let
|
|
990
|
-
const
|
|
991
|
-
|
|
1036
|
+
for (let e in this.lastEntities) {
|
|
1037
|
+
const n = this.lastEntities[e];
|
|
1038
|
+
t = t.replace(n.regex, n.val);
|
|
992
1039
|
}
|
|
993
1040
|
if (this.options.htmlEntities) {
|
|
994
|
-
for (let
|
|
995
|
-
const
|
|
996
|
-
|
|
1041
|
+
for (let e in this.htmlEntities) {
|
|
1042
|
+
const n = this.htmlEntities[e];
|
|
1043
|
+
t = t.replace(n.regex, n.val);
|
|
997
1044
|
}
|
|
998
1045
|
}
|
|
999
|
-
|
|
1046
|
+
t = t.replace(this.ampEntity.regex, this.ampEntity.val);
|
|
1000
1047
|
}
|
|
1001
|
-
return
|
|
1048
|
+
return t;
|
|
1002
1049
|
};
|
|
1003
1050
|
|
|
1004
|
-
function
|
|
1005
|
-
if (
|
|
1006
|
-
if (
|
|
1007
|
-
|
|
1008
|
-
if (
|
|
1009
|
-
|
|
1051
|
+
function ft(t, e, n, i) {
|
|
1052
|
+
if (t) {
|
|
1053
|
+
if (i === undefined) i = Object.keys(e.child).length === 0;
|
|
1054
|
+
t = this.parseTextData(t, e.tagname, n, false, e[":@"] ? Object.keys(e[":@"]).length !== 0 : false, i);
|
|
1055
|
+
if (t !== undefined && t !== "") e.add(this.options.textNodeName, t);
|
|
1056
|
+
t = "";
|
|
1010
1057
|
}
|
|
1011
|
-
return
|
|
1058
|
+
return t;
|
|
1012
1059
|
}
|
|
1013
1060
|
|
|
1014
|
-
function
|
|
1015
|
-
const
|
|
1016
|
-
for (const
|
|
1017
|
-
const s =
|
|
1018
|
-
if (
|
|
1061
|
+
function ct(t, e, n) {
|
|
1062
|
+
const i = "*." + n;
|
|
1063
|
+
for (const n in t) {
|
|
1064
|
+
const s = t[n];
|
|
1065
|
+
if (i === s || e === s) return true;
|
|
1019
1066
|
}
|
|
1020
1067
|
return false;
|
|
1021
1068
|
}
|
|
1022
1069
|
|
|
1023
|
-
function
|
|
1024
|
-
let
|
|
1070
|
+
function ht(t, e, n = ">") {
|
|
1071
|
+
let i;
|
|
1025
1072
|
let s = "";
|
|
1026
|
-
for (let r =
|
|
1027
|
-
let
|
|
1028
|
-
if (
|
|
1029
|
-
if (
|
|
1030
|
-
} else if (
|
|
1031
|
-
|
|
1032
|
-
} else if (
|
|
1033
|
-
if (
|
|
1034
|
-
if (
|
|
1073
|
+
for (let r = e; r < t.length; r++) {
|
|
1074
|
+
let e = t[r];
|
|
1075
|
+
if (i) {
|
|
1076
|
+
if (e === i) i = "";
|
|
1077
|
+
} else if (e === '"' || e === "'") {
|
|
1078
|
+
i = e;
|
|
1079
|
+
} else if (e === n[0]) {
|
|
1080
|
+
if (n[1]) {
|
|
1081
|
+
if (t[r + 1] === n[1]) {
|
|
1035
1082
|
return {
|
|
1036
1083
|
data: s,
|
|
1037
1084
|
index: r
|
|
@@ -1043,24 +1090,24 @@ function le(e, t, i = ">") {
|
|
|
1043
1090
|
index: r
|
|
1044
1091
|
};
|
|
1045
1092
|
}
|
|
1046
|
-
} else if (
|
|
1047
|
-
|
|
1093
|
+
} else if (e === "\t") {
|
|
1094
|
+
e = " ";
|
|
1048
1095
|
}
|
|
1049
|
-
s +=
|
|
1096
|
+
s += e;
|
|
1050
1097
|
}
|
|
1051
1098
|
}
|
|
1052
1099
|
|
|
1053
|
-
function
|
|
1054
|
-
const s =
|
|
1100
|
+
function dt(t, e, n, i) {
|
|
1101
|
+
const s = t.indexOf(e, n);
|
|
1055
1102
|
if (s === -1) {
|
|
1056
|
-
throw new Error(
|
|
1103
|
+
throw new Error(i);
|
|
1057
1104
|
} else {
|
|
1058
|
-
return s +
|
|
1105
|
+
return s + e.length - 1;
|
|
1059
1106
|
}
|
|
1060
1107
|
}
|
|
1061
1108
|
|
|
1062
|
-
function
|
|
1063
|
-
const s =
|
|
1109
|
+
function pt(t, e, n, i = ">") {
|
|
1110
|
+
const s = ht(t, e + 1, i);
|
|
1064
1111
|
if (!s) return;
|
|
1065
1112
|
let r = s.data;
|
|
1066
1113
|
const o = s.index;
|
|
@@ -1072,11 +1119,11 @@ function fe(e, t, i, n = ">") {
|
|
|
1072
1119
|
r = r.substring(a + 1).trimStart();
|
|
1073
1120
|
}
|
|
1074
1121
|
const f = l;
|
|
1075
|
-
if (
|
|
1076
|
-
const
|
|
1077
|
-
if (
|
|
1078
|
-
l = l.substr(
|
|
1079
|
-
u = l !== s.data.substr(
|
|
1122
|
+
if (n) {
|
|
1123
|
+
const t = l.indexOf(":");
|
|
1124
|
+
if (t !== -1) {
|
|
1125
|
+
l = l.substr(t + 1);
|
|
1126
|
+
u = l !== s.data.substr(t + 1);
|
|
1080
1127
|
}
|
|
1081
1128
|
}
|
|
1082
1129
|
return {
|
|
@@ -1088,269 +1135,269 @@ function fe(e, t, i, n = ">") {
|
|
|
1088
1135
|
};
|
|
1089
1136
|
}
|
|
1090
1137
|
|
|
1091
|
-
function
|
|
1092
|
-
const
|
|
1138
|
+
function gt(t, e, n) {
|
|
1139
|
+
const i = n;
|
|
1093
1140
|
let s = 1;
|
|
1094
|
-
for (;
|
|
1095
|
-
if (
|
|
1096
|
-
if (
|
|
1097
|
-
const r =
|
|
1098
|
-
let o =
|
|
1099
|
-
if (o ===
|
|
1141
|
+
for (;n < t.length; n++) {
|
|
1142
|
+
if (t[n] === "<") {
|
|
1143
|
+
if (t[n + 1] === "/") {
|
|
1144
|
+
const r = dt(t, ">", n, `${e} is not closed`);
|
|
1145
|
+
let o = t.substring(n + 2, r).trim();
|
|
1146
|
+
if (o === e) {
|
|
1100
1147
|
s--;
|
|
1101
1148
|
if (s === 0) {
|
|
1102
1149
|
return {
|
|
1103
|
-
tagContent:
|
|
1150
|
+
tagContent: t.substring(i, n),
|
|
1104
1151
|
i: r
|
|
1105
1152
|
};
|
|
1106
1153
|
}
|
|
1107
1154
|
}
|
|
1108
|
-
|
|
1109
|
-
} else if (
|
|
1110
|
-
const
|
|
1111
|
-
|
|
1112
|
-
} else if (
|
|
1113
|
-
const
|
|
1114
|
-
|
|
1115
|
-
} else if (
|
|
1116
|
-
const
|
|
1117
|
-
|
|
1155
|
+
n = r;
|
|
1156
|
+
} else if (t[n + 1] === "?") {
|
|
1157
|
+
const e = dt(t, "?>", n + 1, "StopNode is not closed.");
|
|
1158
|
+
n = e;
|
|
1159
|
+
} else if (t.substr(n + 1, 3) === "!--") {
|
|
1160
|
+
const e = dt(t, "--\x3e", n + 3, "StopNode is not closed.");
|
|
1161
|
+
n = e;
|
|
1162
|
+
} else if (t.substr(n + 1, 2) === "![") {
|
|
1163
|
+
const e = dt(t, "]]>", n, "StopNode is not closed.") - 2;
|
|
1164
|
+
n = e;
|
|
1118
1165
|
} else {
|
|
1119
|
-
const
|
|
1120
|
-
if (
|
|
1121
|
-
const
|
|
1122
|
-
if (
|
|
1166
|
+
const i = pt(t, n, ">");
|
|
1167
|
+
if (i) {
|
|
1168
|
+
const t = i && i.tagName;
|
|
1169
|
+
if (t === e && i.tagExp[i.tagExp.length - 1] !== "/") {
|
|
1123
1170
|
s++;
|
|
1124
1171
|
}
|
|
1125
|
-
|
|
1172
|
+
n = i.closeIndex;
|
|
1126
1173
|
}
|
|
1127
1174
|
}
|
|
1128
1175
|
}
|
|
1129
1176
|
}
|
|
1130
1177
|
}
|
|
1131
1178
|
|
|
1132
|
-
function
|
|
1133
|
-
if (
|
|
1134
|
-
const
|
|
1135
|
-
if (
|
|
1179
|
+
function mt(t, e, n) {
|
|
1180
|
+
if (e && typeof t === "string") {
|
|
1181
|
+
const e = t.trim();
|
|
1182
|
+
if (e === "true") return true; else if (e === "false") return false; else return Q(t, n);
|
|
1136
1183
|
} else {
|
|
1137
|
-
if (
|
|
1138
|
-
return
|
|
1184
|
+
if (J.isExist(t)) {
|
|
1185
|
+
return t;
|
|
1139
1186
|
} else {
|
|
1140
1187
|
return "";
|
|
1141
1188
|
}
|
|
1142
1189
|
}
|
|
1143
1190
|
}
|
|
1144
1191
|
|
|
1145
|
-
var
|
|
1192
|
+
var xt = et;
|
|
1146
1193
|
|
|
1147
|
-
const
|
|
1194
|
+
const Nt = t(xt);
|
|
1148
1195
|
|
|
1149
|
-
var
|
|
1196
|
+
var bt = {};
|
|
1150
1197
|
|
|
1151
1198
|
"use strict";
|
|
1152
1199
|
|
|
1153
|
-
function
|
|
1154
|
-
return
|
|
1200
|
+
function Et(t, e) {
|
|
1201
|
+
return vt(t, e);
|
|
1155
1202
|
}
|
|
1156
1203
|
|
|
1157
|
-
function
|
|
1158
|
-
let
|
|
1204
|
+
function vt(t, e, n) {
|
|
1205
|
+
let i;
|
|
1159
1206
|
const s = {};
|
|
1160
|
-
for (let r = 0; r <
|
|
1161
|
-
const o =
|
|
1162
|
-
const a =
|
|
1207
|
+
for (let r = 0; r < t.length; r++) {
|
|
1208
|
+
const o = t[r];
|
|
1209
|
+
const a = yt(o);
|
|
1163
1210
|
let l = "";
|
|
1164
|
-
if (
|
|
1165
|
-
if (a ===
|
|
1166
|
-
if (
|
|
1211
|
+
if (n === undefined) l = a; else l = n + "." + a;
|
|
1212
|
+
if (a === e.textNodeName) {
|
|
1213
|
+
if (i === undefined) i = o[a]; else i += "" + o[a];
|
|
1167
1214
|
} else if (a === undefined) {
|
|
1168
1215
|
continue;
|
|
1169
1216
|
} else if (o[a]) {
|
|
1170
|
-
let
|
|
1171
|
-
const
|
|
1217
|
+
let t = vt(o[a], e, l);
|
|
1218
|
+
const n = Ot(t, e);
|
|
1172
1219
|
if (o[":@"]) {
|
|
1173
|
-
|
|
1174
|
-
} else if (Object.keys(
|
|
1175
|
-
|
|
1176
|
-
} else if (Object.keys(
|
|
1177
|
-
if (
|
|
1220
|
+
Tt(t, o[":@"], l, e);
|
|
1221
|
+
} else if (Object.keys(t).length === 1 && t[e.textNodeName] !== undefined && !e.alwaysCreateTextNode) {
|
|
1222
|
+
t = t[e.textNodeName];
|
|
1223
|
+
} else if (Object.keys(t).length === 0) {
|
|
1224
|
+
if (e.alwaysCreateTextNode) t[e.textNodeName] = ""; else t = "";
|
|
1178
1225
|
}
|
|
1179
1226
|
if (s[a] !== undefined && s.hasOwnProperty(a)) {
|
|
1180
1227
|
if (!Array.isArray(s[a])) {
|
|
1181
1228
|
s[a] = [ s[a] ];
|
|
1182
1229
|
}
|
|
1183
|
-
s[a].push(
|
|
1230
|
+
s[a].push(t);
|
|
1184
1231
|
} else {
|
|
1185
|
-
if (
|
|
1186
|
-
s[a] = [
|
|
1232
|
+
if (e.isArray(a, l, n)) {
|
|
1233
|
+
s[a] = [ t ];
|
|
1187
1234
|
} else {
|
|
1188
|
-
s[a] =
|
|
1235
|
+
s[a] = t;
|
|
1189
1236
|
}
|
|
1190
1237
|
}
|
|
1191
1238
|
}
|
|
1192
1239
|
}
|
|
1193
|
-
if (typeof
|
|
1194
|
-
if (
|
|
1195
|
-
} else if (
|
|
1240
|
+
if (typeof i === "string") {
|
|
1241
|
+
if (i.length > 0) s[e.textNodeName] = i;
|
|
1242
|
+
} else if (i !== undefined) s[e.textNodeName] = i;
|
|
1196
1243
|
return s;
|
|
1197
1244
|
}
|
|
1198
1245
|
|
|
1199
|
-
function
|
|
1200
|
-
const
|
|
1201
|
-
for (let
|
|
1202
|
-
const
|
|
1203
|
-
if (
|
|
1246
|
+
function yt(t) {
|
|
1247
|
+
const e = Object.keys(t);
|
|
1248
|
+
for (let t = 0; t < e.length; t++) {
|
|
1249
|
+
const n = e[t];
|
|
1250
|
+
if (n !== ":@") return n;
|
|
1204
1251
|
}
|
|
1205
1252
|
}
|
|
1206
1253
|
|
|
1207
|
-
function
|
|
1208
|
-
if (
|
|
1209
|
-
const s = Object.keys(
|
|
1254
|
+
function Tt(t, e, n, i) {
|
|
1255
|
+
if (e) {
|
|
1256
|
+
const s = Object.keys(e);
|
|
1210
1257
|
const r = s.length;
|
|
1211
1258
|
for (let o = 0; o < r; o++) {
|
|
1212
1259
|
const r = s[o];
|
|
1213
|
-
if (
|
|
1214
|
-
|
|
1260
|
+
if (i.isArray(r, n + "." + r, true, true)) {
|
|
1261
|
+
t[r] = [ e[r] ];
|
|
1215
1262
|
} else {
|
|
1216
|
-
|
|
1263
|
+
t[r] = e[r];
|
|
1217
1264
|
}
|
|
1218
1265
|
}
|
|
1219
1266
|
}
|
|
1220
1267
|
}
|
|
1221
1268
|
|
|
1222
|
-
function
|
|
1223
|
-
const {textNodeName:
|
|
1224
|
-
const
|
|
1225
|
-
if (
|
|
1269
|
+
function Ot(t, e) {
|
|
1270
|
+
const {textNodeName: n} = e;
|
|
1271
|
+
const i = Object.keys(t).length;
|
|
1272
|
+
if (i === 0) {
|
|
1226
1273
|
return true;
|
|
1227
1274
|
}
|
|
1228
|
-
if (
|
|
1275
|
+
if (i === 1 && (t[n] || typeof t[n] === "boolean" || t[n] === 0)) {
|
|
1229
1276
|
return true;
|
|
1230
1277
|
}
|
|
1231
1278
|
return false;
|
|
1232
1279
|
}
|
|
1233
1280
|
|
|
1234
|
-
var
|
|
1281
|
+
var At = bt.prettify = Et;
|
|
1235
1282
|
|
|
1236
|
-
const {buildOptions:
|
|
1283
|
+
const {buildOptions: Pt} = y;
|
|
1237
1284
|
|
|
1238
|
-
const
|
|
1285
|
+
const wt = xt;
|
|
1239
1286
|
|
|
1240
|
-
const {prettify:
|
|
1287
|
+
const {prettify: Ct} = bt;
|
|
1241
1288
|
|
|
1242
|
-
const
|
|
1289
|
+
const It = e;
|
|
1243
1290
|
|
|
1244
|
-
let
|
|
1245
|
-
constructor(
|
|
1291
|
+
let St = class XMLParser {
|
|
1292
|
+
constructor(t) {
|
|
1246
1293
|
this.externalEntities = {};
|
|
1247
|
-
this.options =
|
|
1294
|
+
this.options = Pt(t);
|
|
1248
1295
|
}
|
|
1249
|
-
parse(
|
|
1250
|
-
if (typeof
|
|
1251
|
-
|
|
1296
|
+
parse(t, e) {
|
|
1297
|
+
if (typeof t === "string") {} else if (t.toString) {
|
|
1298
|
+
t = t.toString();
|
|
1252
1299
|
} else {
|
|
1253
1300
|
throw new Error("XML data is accepted in String or Bytes[] form.");
|
|
1254
1301
|
}
|
|
1255
|
-
if (
|
|
1256
|
-
if (
|
|
1257
|
-
const
|
|
1258
|
-
if (
|
|
1259
|
-
throw Error(`${
|
|
1302
|
+
if (e) {
|
|
1303
|
+
if (e === true) e = {};
|
|
1304
|
+
const n = It.validate(t, e);
|
|
1305
|
+
if (n !== true) {
|
|
1306
|
+
throw Error(`${n.err.msg}:${n.err.line}:${n.err.col}`);
|
|
1260
1307
|
}
|
|
1261
1308
|
}
|
|
1262
|
-
const
|
|
1263
|
-
|
|
1264
|
-
const
|
|
1265
|
-
if (this.options.preserveOrder ||
|
|
1309
|
+
const n = new wt(this.options);
|
|
1310
|
+
n.addExternalEntities(this.externalEntities);
|
|
1311
|
+
const i = n.parseXml(t);
|
|
1312
|
+
if (this.options.preserveOrder || i === undefined) return i; else return Ct(i, this.options);
|
|
1266
1313
|
}
|
|
1267
|
-
addEntity(
|
|
1268
|
-
if (
|
|
1314
|
+
addEntity(t, e) {
|
|
1315
|
+
if (e.indexOf("&") !== -1) {
|
|
1269
1316
|
throw new Error("Entity value can't have '&'");
|
|
1270
|
-
} else if (
|
|
1317
|
+
} else if (t.indexOf("&") !== -1 || t.indexOf(";") !== -1) {
|
|
1271
1318
|
throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '
'");
|
|
1272
|
-
} else if (
|
|
1319
|
+
} else if (e === "&") {
|
|
1273
1320
|
throw new Error("An entity with value '&' is not permitted");
|
|
1274
1321
|
} else {
|
|
1275
|
-
this.externalEntities[
|
|
1322
|
+
this.externalEntities[t] = e;
|
|
1276
1323
|
}
|
|
1277
1324
|
}
|
|
1278
1325
|
};
|
|
1279
1326
|
|
|
1280
|
-
var
|
|
1327
|
+
var jt = St;
|
|
1281
1328
|
|
|
1282
|
-
const
|
|
1329
|
+
const Vt = t(jt);
|
|
1283
1330
|
|
|
1284
|
-
const
|
|
1331
|
+
const kt = "\n";
|
|
1285
1332
|
|
|
1286
|
-
function
|
|
1287
|
-
let
|
|
1288
|
-
if (
|
|
1289
|
-
|
|
1333
|
+
function Ft(t, e) {
|
|
1334
|
+
let n = "";
|
|
1335
|
+
if (e.format && e.indentBy.length > 0) {
|
|
1336
|
+
n = kt;
|
|
1290
1337
|
}
|
|
1291
|
-
return
|
|
1338
|
+
return $t(t, e, "", n);
|
|
1292
1339
|
}
|
|
1293
1340
|
|
|
1294
|
-
function
|
|
1341
|
+
function $t(t, e, n, i) {
|
|
1295
1342
|
let s = "";
|
|
1296
1343
|
let r = false;
|
|
1297
|
-
for (let o = 0; o <
|
|
1298
|
-
const a =
|
|
1299
|
-
const l =
|
|
1344
|
+
for (let o = 0; o < t.length; o++) {
|
|
1345
|
+
const a = t[o];
|
|
1346
|
+
const l = _t(a);
|
|
1300
1347
|
if (l === undefined) continue;
|
|
1301
1348
|
let u = "";
|
|
1302
|
-
if (
|
|
1303
|
-
if (l ===
|
|
1304
|
-
let
|
|
1305
|
-
if (
|
|
1306
|
-
|
|
1307
|
-
|
|
1349
|
+
if (n.length === 0) u = l; else u = `${n}.${l}`;
|
|
1350
|
+
if (l === e.textNodeName) {
|
|
1351
|
+
let t = a[l];
|
|
1352
|
+
if (!Lt(u, e)) {
|
|
1353
|
+
t = e.tagValueProcessor(l, t);
|
|
1354
|
+
t = Mt(t, e);
|
|
1308
1355
|
}
|
|
1309
1356
|
if (r) {
|
|
1310
|
-
s +=
|
|
1357
|
+
s += i;
|
|
1311
1358
|
}
|
|
1312
|
-
s +=
|
|
1359
|
+
s += t;
|
|
1313
1360
|
r = false;
|
|
1314
1361
|
continue;
|
|
1315
|
-
} else if (l ===
|
|
1362
|
+
} else if (l === e.cdataPropName) {
|
|
1316
1363
|
if (r) {
|
|
1317
|
-
s +=
|
|
1364
|
+
s += i;
|
|
1318
1365
|
}
|
|
1319
|
-
s += `<![CDATA[${a[l][0][
|
|
1366
|
+
s += `<![CDATA[${a[l][0][e.textNodeName]}]]>`;
|
|
1320
1367
|
r = false;
|
|
1321
1368
|
continue;
|
|
1322
|
-
} else if (l ===
|
|
1323
|
-
s +=
|
|
1369
|
+
} else if (l === e.commentPropName) {
|
|
1370
|
+
s += i + `\x3c!--${a[l][0][e.textNodeName]}--\x3e`;
|
|
1324
1371
|
r = true;
|
|
1325
1372
|
continue;
|
|
1326
1373
|
} else if (l[0] === "?") {
|
|
1327
|
-
const
|
|
1328
|
-
const
|
|
1329
|
-
let o = a[l][0][
|
|
1374
|
+
const t = Dt(a[":@"], e);
|
|
1375
|
+
const n = l === "?xml" ? "" : i;
|
|
1376
|
+
let o = a[l][0][e.textNodeName];
|
|
1330
1377
|
o = o.length !== 0 ? " " + o : "";
|
|
1331
|
-
s +=
|
|
1378
|
+
s += n + `<${l}${o}${t}?>`;
|
|
1332
1379
|
r = true;
|
|
1333
1380
|
continue;
|
|
1334
1381
|
}
|
|
1335
|
-
let f =
|
|
1382
|
+
let f = i;
|
|
1336
1383
|
if (f !== "") {
|
|
1337
|
-
f +=
|
|
1384
|
+
f += e.indentBy;
|
|
1338
1385
|
}
|
|
1339
|
-
const c =
|
|
1340
|
-
const
|
|
1341
|
-
const
|
|
1342
|
-
if (
|
|
1343
|
-
if (
|
|
1344
|
-
} else if ((!
|
|
1345
|
-
s +=
|
|
1346
|
-
} else if (
|
|
1347
|
-
s +=
|
|
1386
|
+
const c = Dt(a[":@"], e);
|
|
1387
|
+
const h = i + `<${l}${c}`;
|
|
1388
|
+
const d = $t(a[l], e, u, f);
|
|
1389
|
+
if (e.unpairedTags.indexOf(l) !== -1) {
|
|
1390
|
+
if (e.suppressUnpairedNode) s += h + ">"; else s += h + "/>";
|
|
1391
|
+
} else if ((!d || d.length === 0) && e.suppressEmptyNode) {
|
|
1392
|
+
s += h + "/>";
|
|
1393
|
+
} else if (d && d.endsWith(">")) {
|
|
1394
|
+
s += h + `>${d}${i}</${l}>`;
|
|
1348
1395
|
} else {
|
|
1349
|
-
s +=
|
|
1350
|
-
if (
|
|
1351
|
-
s +=
|
|
1396
|
+
s += h + ">";
|
|
1397
|
+
if (d && i !== "" && (d.includes("/>") || d.includes("</"))) {
|
|
1398
|
+
s += i + e.indentBy + d + i;
|
|
1352
1399
|
} else {
|
|
1353
|
-
s +=
|
|
1400
|
+
s += d;
|
|
1354
1401
|
}
|
|
1355
1402
|
s += `</${l}>`;
|
|
1356
1403
|
}
|
|
@@ -1359,60 +1406,62 @@ function Se(e, t, i, n) {
|
|
|
1359
1406
|
return s;
|
|
1360
1407
|
}
|
|
1361
1408
|
|
|
1362
|
-
function
|
|
1363
|
-
const
|
|
1364
|
-
for (let
|
|
1365
|
-
const
|
|
1366
|
-
if (!
|
|
1367
|
-
if (
|
|
1409
|
+
function _t(t) {
|
|
1410
|
+
const e = Object.keys(t);
|
|
1411
|
+
for (let n = 0; n < e.length; n++) {
|
|
1412
|
+
const i = e[n];
|
|
1413
|
+
if (!t.hasOwnProperty(i)) continue;
|
|
1414
|
+
if (i !== ":@") return i;
|
|
1368
1415
|
}
|
|
1369
1416
|
}
|
|
1370
1417
|
|
|
1371
|
-
function
|
|
1372
|
-
let
|
|
1373
|
-
if (
|
|
1374
|
-
for (let
|
|
1375
|
-
if (!
|
|
1376
|
-
let s =
|
|
1377
|
-
s =
|
|
1378
|
-
if (s === true &&
|
|
1379
|
-
|
|
1418
|
+
function Dt(t, e) {
|
|
1419
|
+
let n = "";
|
|
1420
|
+
if (t && !e.ignoreAttributes) {
|
|
1421
|
+
for (let i in t) {
|
|
1422
|
+
if (!t.hasOwnProperty(i)) continue;
|
|
1423
|
+
let s = e.attributeValueProcessor(i, t[i]);
|
|
1424
|
+
s = Mt(s, e);
|
|
1425
|
+
if (s === true && e.suppressBooleanAttributes) {
|
|
1426
|
+
n += ` ${i.substr(e.attributeNamePrefix.length)}`;
|
|
1380
1427
|
} else {
|
|
1381
|
-
|
|
1428
|
+
n += ` ${i.substr(e.attributeNamePrefix.length)}="${s}"`;
|
|
1382
1429
|
}
|
|
1383
1430
|
}
|
|
1384
1431
|
}
|
|
1385
|
-
return
|
|
1432
|
+
return n;
|
|
1386
1433
|
}
|
|
1387
1434
|
|
|
1388
|
-
function
|
|
1389
|
-
|
|
1390
|
-
let
|
|
1391
|
-
for (let
|
|
1392
|
-
if (
|
|
1435
|
+
function Lt(t, e) {
|
|
1436
|
+
t = t.substr(0, t.length - e.textNodeName.length - 1);
|
|
1437
|
+
let n = t.substr(t.lastIndexOf(".") + 1);
|
|
1438
|
+
for (let i in e.stopNodes) {
|
|
1439
|
+
if (e.stopNodes[i] === t || e.stopNodes[i] === "*." + n) return true;
|
|
1393
1440
|
}
|
|
1394
1441
|
return false;
|
|
1395
1442
|
}
|
|
1396
1443
|
|
|
1397
|
-
function
|
|
1398
|
-
if (
|
|
1399
|
-
for (let
|
|
1400
|
-
const
|
|
1401
|
-
|
|
1444
|
+
function Mt(t, e) {
|
|
1445
|
+
if (t && t.length > 0 && e.processEntities) {
|
|
1446
|
+
for (let n = 0; n < e.entities.length; n++) {
|
|
1447
|
+
const i = e.entities[n];
|
|
1448
|
+
t = t.replace(i.regex, i.val);
|
|
1402
1449
|
}
|
|
1403
1450
|
}
|
|
1404
|
-
return
|
|
1451
|
+
return t;
|
|
1405
1452
|
}
|
|
1406
1453
|
|
|
1407
|
-
var
|
|
1454
|
+
var Bt = Ft;
|
|
1408
1455
|
|
|
1409
|
-
const
|
|
1456
|
+
const Xt = t(Bt);
|
|
1410
1457
|
|
|
1411
1458
|
"use strict";
|
|
1412
1459
|
|
|
1413
|
-
const
|
|
1460
|
+
const Gt = Bt;
|
|
1461
|
+
|
|
1462
|
+
const Rt = W;
|
|
1414
1463
|
|
|
1415
|
-
const
|
|
1464
|
+
const Ut = {
|
|
1416
1465
|
attributeNamePrefix: "@_",
|
|
1417
1466
|
attributesGroupName: false,
|
|
1418
1467
|
textNodeName: "#text",
|
|
@@ -1423,11 +1472,11 @@ const Me = {
|
|
|
1423
1472
|
suppressEmptyNode: false,
|
|
1424
1473
|
suppressUnpairedNode: true,
|
|
1425
1474
|
suppressBooleanAttributes: true,
|
|
1426
|
-
tagValueProcessor: function(
|
|
1427
|
-
return
|
|
1475
|
+
tagValueProcessor: function(t, e) {
|
|
1476
|
+
return e;
|
|
1428
1477
|
},
|
|
1429
|
-
attributeValueProcessor: function(
|
|
1430
|
-
return
|
|
1478
|
+
attributeValueProcessor: function(t, e) {
|
|
1479
|
+
return e;
|
|
1431
1480
|
},
|
|
1432
1481
|
preserveOrder: false,
|
|
1433
1482
|
commentPropName: false,
|
|
@@ -1453,19 +1502,20 @@ const Me = {
|
|
|
1453
1502
|
oneListGroup: false
|
|
1454
1503
|
};
|
|
1455
1504
|
|
|
1456
|
-
function
|
|
1457
|
-
this.options = Object.assign({},
|
|
1458
|
-
if (this.options.ignoreAttributes || this.options.attributesGroupName) {
|
|
1505
|
+
function Yt(t) {
|
|
1506
|
+
this.options = Object.assign({}, Ut, t);
|
|
1507
|
+
if (this.options.ignoreAttributes === true || this.options.attributesGroupName) {
|
|
1459
1508
|
this.isAttribute = function() {
|
|
1460
1509
|
return false;
|
|
1461
1510
|
};
|
|
1462
1511
|
} else {
|
|
1512
|
+
this.ignoreAttributesFn = Rt(this.options.ignoreAttributes);
|
|
1463
1513
|
this.attrPrefixLen = this.options.attributeNamePrefix.length;
|
|
1464
|
-
this.isAttribute =
|
|
1514
|
+
this.isAttribute = zt;
|
|
1465
1515
|
}
|
|
1466
|
-
this.processTextOrObjNode =
|
|
1516
|
+
this.processTextOrObjNode = Zt;
|
|
1467
1517
|
if (this.options.format) {
|
|
1468
|
-
this.indentate =
|
|
1518
|
+
this.indentate = Wt;
|
|
1469
1519
|
this.tagEndChar = ">\n";
|
|
1470
1520
|
this.newLine = "\n";
|
|
1471
1521
|
} else {
|
|
@@ -1477,219 +1527,231 @@ function Be(e) {
|
|
|
1477
1527
|
}
|
|
1478
1528
|
}
|
|
1479
1529
|
|
|
1480
|
-
|
|
1530
|
+
Yt.prototype.build = function(t) {
|
|
1481
1531
|
if (this.options.preserveOrder) {
|
|
1482
|
-
return
|
|
1532
|
+
return Gt(t, this.options);
|
|
1483
1533
|
} else {
|
|
1484
|
-
if (Array.isArray(
|
|
1485
|
-
|
|
1486
|
-
[this.options.arrayNodeName]:
|
|
1534
|
+
if (Array.isArray(t) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1) {
|
|
1535
|
+
t = {
|
|
1536
|
+
[this.options.arrayNodeName]: t
|
|
1487
1537
|
};
|
|
1488
1538
|
}
|
|
1489
|
-
return this.j2x(
|
|
1539
|
+
return this.j2x(t, 0, []).val;
|
|
1490
1540
|
}
|
|
1491
1541
|
};
|
|
1492
1542
|
|
|
1493
|
-
|
|
1543
|
+
Yt.prototype.j2x = function(t, e, n) {
|
|
1494
1544
|
let i = "";
|
|
1495
|
-
let
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
if (
|
|
1499
|
-
|
|
1500
|
-
|
|
1545
|
+
let s = "";
|
|
1546
|
+
const r = n.join(".");
|
|
1547
|
+
for (let o in t) {
|
|
1548
|
+
if (!Object.prototype.hasOwnProperty.call(t, o)) continue;
|
|
1549
|
+
if (typeof t[o] === "undefined") {
|
|
1550
|
+
if (this.isAttribute(o)) {
|
|
1551
|
+
s += "";
|
|
1501
1552
|
}
|
|
1502
|
-
} else if (
|
|
1503
|
-
if (this.isAttribute(
|
|
1504
|
-
|
|
1505
|
-
} else if (
|
|
1506
|
-
|
|
1553
|
+
} else if (t[o] === null) {
|
|
1554
|
+
if (this.isAttribute(o)) {
|
|
1555
|
+
s += "";
|
|
1556
|
+
} else if (o[0] === "?") {
|
|
1557
|
+
s += this.indentate(e) + "<" + o + "?" + this.tagEndChar;
|
|
1507
1558
|
} else {
|
|
1508
|
-
|
|
1559
|
+
s += this.indentate(e) + "<" + o + "/" + this.tagEndChar;
|
|
1509
1560
|
}
|
|
1510
|
-
} else if (
|
|
1511
|
-
|
|
1512
|
-
} else if (typeof
|
|
1513
|
-
const
|
|
1514
|
-
if (r) {
|
|
1515
|
-
i += this.buildAttrPairStr(
|
|
1516
|
-
} else {
|
|
1517
|
-
if (
|
|
1518
|
-
let
|
|
1519
|
-
|
|
1561
|
+
} else if (t[o] instanceof Date) {
|
|
1562
|
+
s += this.buildTextValNode(t[o], o, "", e);
|
|
1563
|
+
} else if (typeof t[o] !== "object") {
|
|
1564
|
+
const n = this.isAttribute(o);
|
|
1565
|
+
if (n && !this.ignoreAttributesFn(n, r)) {
|
|
1566
|
+
i += this.buildAttrPairStr(n, "" + t[o]);
|
|
1567
|
+
} else if (!n) {
|
|
1568
|
+
if (o === this.options.textNodeName) {
|
|
1569
|
+
let e = this.options.tagValueProcessor(o, "" + t[o]);
|
|
1570
|
+
s += this.replaceEntitiesValue(e);
|
|
1520
1571
|
} else {
|
|
1521
|
-
|
|
1572
|
+
s += this.buildTextValNode(t[o], o, "", e);
|
|
1522
1573
|
}
|
|
1523
1574
|
}
|
|
1524
|
-
} else if (Array.isArray(
|
|
1525
|
-
const i =
|
|
1575
|
+
} else if (Array.isArray(t[o])) {
|
|
1576
|
+
const i = t[o].length;
|
|
1526
1577
|
let r = "";
|
|
1527
|
-
|
|
1528
|
-
|
|
1578
|
+
let a = "";
|
|
1579
|
+
for (let l = 0; l < i; l++) {
|
|
1580
|
+
const i = t[o][l];
|
|
1529
1581
|
if (typeof i === "undefined") {} else if (i === null) {
|
|
1530
|
-
if (
|
|
1582
|
+
if (o[0] === "?") s += this.indentate(e) + "<" + o + "?" + this.tagEndChar; else s += this.indentate(e) + "<" + o + "/" + this.tagEndChar;
|
|
1531
1583
|
} else if (typeof i === "object") {
|
|
1532
1584
|
if (this.options.oneListGroup) {
|
|
1533
|
-
|
|
1585
|
+
const t = this.j2x(i, e + 1, n.concat(o));
|
|
1586
|
+
r += t.val;
|
|
1587
|
+
if (this.options.attributesGroupName && i.hasOwnProperty(this.options.attributesGroupName)) {
|
|
1588
|
+
a += t.attrStr;
|
|
1589
|
+
}
|
|
1534
1590
|
} else {
|
|
1535
|
-
r += this.processTextOrObjNode(i,
|
|
1591
|
+
r += this.processTextOrObjNode(i, o, e, n);
|
|
1536
1592
|
}
|
|
1537
1593
|
} else {
|
|
1538
|
-
|
|
1594
|
+
if (this.options.oneListGroup) {
|
|
1595
|
+
let t = this.options.tagValueProcessor(o, i);
|
|
1596
|
+
t = this.replaceEntitiesValue(t);
|
|
1597
|
+
r += t;
|
|
1598
|
+
} else {
|
|
1599
|
+
r += this.buildTextValNode(i, o, "", e);
|
|
1600
|
+
}
|
|
1539
1601
|
}
|
|
1540
1602
|
}
|
|
1541
1603
|
if (this.options.oneListGroup) {
|
|
1542
|
-
r = this.buildObjectNode(r,
|
|
1604
|
+
r = this.buildObjectNode(r, o, a, e);
|
|
1543
1605
|
}
|
|
1544
|
-
|
|
1606
|
+
s += r;
|
|
1545
1607
|
} else {
|
|
1546
|
-
if (this.options.attributesGroupName &&
|
|
1547
|
-
const
|
|
1548
|
-
const n =
|
|
1549
|
-
for (let
|
|
1550
|
-
i += this.buildAttrPairStr(
|
|
1608
|
+
if (this.options.attributesGroupName && o === this.options.attributesGroupName) {
|
|
1609
|
+
const e = Object.keys(t[o]);
|
|
1610
|
+
const n = e.length;
|
|
1611
|
+
for (let s = 0; s < n; s++) {
|
|
1612
|
+
i += this.buildAttrPairStr(e[s], "" + t[o][e[s]]);
|
|
1551
1613
|
}
|
|
1552
1614
|
} else {
|
|
1553
|
-
|
|
1615
|
+
s += this.processTextOrObjNode(t[o], o, e, n);
|
|
1554
1616
|
}
|
|
1555
1617
|
}
|
|
1556
1618
|
}
|
|
1557
1619
|
return {
|
|
1558
1620
|
attrStr: i,
|
|
1559
|
-
val:
|
|
1621
|
+
val: s
|
|
1560
1622
|
};
|
|
1561
1623
|
};
|
|
1562
1624
|
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
if (this.options.suppressBooleanAttributes &&
|
|
1567
|
-
return " " +
|
|
1568
|
-
} else return " " +
|
|
1625
|
+
Yt.prototype.buildAttrPairStr = function(t, e) {
|
|
1626
|
+
e = this.options.attributeValueProcessor(t, "" + e);
|
|
1627
|
+
e = this.replaceEntitiesValue(e);
|
|
1628
|
+
if (this.options.suppressBooleanAttributes && e === "true") {
|
|
1629
|
+
return " " + t;
|
|
1630
|
+
} else return " " + t + '="' + e + '"';
|
|
1569
1631
|
};
|
|
1570
1632
|
|
|
1571
|
-
function
|
|
1572
|
-
const
|
|
1573
|
-
if (
|
|
1574
|
-
return this.buildTextValNode(
|
|
1633
|
+
function Zt(t, e, n, i) {
|
|
1634
|
+
const s = this.j2x(t, n + 1, i.concat(e));
|
|
1635
|
+
if (t[this.options.textNodeName] !== undefined && Object.keys(t).length === 1) {
|
|
1636
|
+
return this.buildTextValNode(t[this.options.textNodeName], e, s.attrStr, n);
|
|
1575
1637
|
} else {
|
|
1576
|
-
return this.buildObjectNode(
|
|
1638
|
+
return this.buildObjectNode(s.val, e, s.attrStr, n);
|
|
1577
1639
|
}
|
|
1578
1640
|
}
|
|
1579
1641
|
|
|
1580
|
-
|
|
1581
|
-
if (
|
|
1582
|
-
if (
|
|
1583
|
-
return this.indentate(
|
|
1642
|
+
Yt.prototype.buildObjectNode = function(t, e, n, i) {
|
|
1643
|
+
if (t === "") {
|
|
1644
|
+
if (e[0] === "?") return this.indentate(i) + "<" + e + n + "?" + this.tagEndChar; else {
|
|
1645
|
+
return this.indentate(i) + "<" + e + n + this.closeTag(e) + this.tagEndChar;
|
|
1584
1646
|
}
|
|
1585
1647
|
} else {
|
|
1586
|
-
let s = "</" +
|
|
1648
|
+
let s = "</" + e + this.tagEndChar;
|
|
1587
1649
|
let r = "";
|
|
1588
|
-
if (
|
|
1650
|
+
if (e[0] === "?") {
|
|
1589
1651
|
r = "?";
|
|
1590
1652
|
s = "";
|
|
1591
1653
|
}
|
|
1592
|
-
if ((
|
|
1593
|
-
return this.indentate(
|
|
1594
|
-
} else if (this.options.commentPropName !== false &&
|
|
1595
|
-
return this.indentate(
|
|
1654
|
+
if ((n || n === "") && t.indexOf("<") === -1) {
|
|
1655
|
+
return this.indentate(i) + "<" + e + n + r + ">" + t + s;
|
|
1656
|
+
} else if (this.options.commentPropName !== false && e === this.options.commentPropName && r.length === 0) {
|
|
1657
|
+
return this.indentate(i) + `\x3c!--${t}--\x3e` + this.newLine;
|
|
1596
1658
|
} else {
|
|
1597
|
-
return this.indentate(
|
|
1659
|
+
return this.indentate(i) + "<" + e + n + r + this.tagEndChar + t + this.indentate(i) + s;
|
|
1598
1660
|
}
|
|
1599
1661
|
}
|
|
1600
1662
|
};
|
|
1601
1663
|
|
|
1602
|
-
|
|
1603
|
-
let
|
|
1604
|
-
if (this.options.unpairedTags.indexOf(
|
|
1605
|
-
if (!this.options.suppressUnpairedNode)
|
|
1664
|
+
Yt.prototype.closeTag = function(t) {
|
|
1665
|
+
let e = "";
|
|
1666
|
+
if (this.options.unpairedTags.indexOf(t) !== -1) {
|
|
1667
|
+
if (!this.options.suppressUnpairedNode) e = "/";
|
|
1606
1668
|
} else if (this.options.suppressEmptyNode) {
|
|
1607
|
-
|
|
1669
|
+
e = "/";
|
|
1608
1670
|
} else {
|
|
1609
|
-
|
|
1671
|
+
e = `></${t}`;
|
|
1610
1672
|
}
|
|
1611
|
-
return
|
|
1673
|
+
return e;
|
|
1612
1674
|
};
|
|
1613
1675
|
|
|
1614
|
-
function
|
|
1615
|
-
if (
|
|
1616
|
-
return this.buildObjectNode(e,
|
|
1676
|
+
function qt(t, e, n, i) {
|
|
1677
|
+
if (t !== "") {
|
|
1678
|
+
return this.buildObjectNode(t, e, n, i);
|
|
1617
1679
|
} else {
|
|
1618
|
-
if (
|
|
1619
|
-
return this.indentate(
|
|
1680
|
+
if (e[0] === "?") return this.indentate(i) + "<" + e + n + "?" + this.tagEndChar; else {
|
|
1681
|
+
return this.indentate(i) + "<" + e + n + "/" + this.tagEndChar;
|
|
1620
1682
|
}
|
|
1621
1683
|
}
|
|
1622
1684
|
}
|
|
1623
1685
|
|
|
1624
|
-
|
|
1625
|
-
if (this.options.cdataPropName !== false &&
|
|
1626
|
-
return this.indentate(
|
|
1627
|
-
} else if (this.options.commentPropName !== false &&
|
|
1628
|
-
return this.indentate(
|
|
1629
|
-
} else if (
|
|
1630
|
-
return this.indentate(
|
|
1686
|
+
Yt.prototype.buildTextValNode = function(t, e, n, i) {
|
|
1687
|
+
if (this.options.cdataPropName !== false && e === this.options.cdataPropName) {
|
|
1688
|
+
return this.indentate(i) + `<![CDATA[${t}]]>` + this.newLine;
|
|
1689
|
+
} else if (this.options.commentPropName !== false && e === this.options.commentPropName) {
|
|
1690
|
+
return this.indentate(i) + `\x3c!--${t}--\x3e` + this.newLine;
|
|
1691
|
+
} else if (e[0] === "?") {
|
|
1692
|
+
return this.indentate(i) + "<" + e + n + "?" + this.tagEndChar;
|
|
1631
1693
|
} else {
|
|
1632
|
-
let s = this.options.tagValueProcessor(
|
|
1694
|
+
let s = this.options.tagValueProcessor(e, t);
|
|
1633
1695
|
s = this.replaceEntitiesValue(s);
|
|
1634
1696
|
if (s === "") {
|
|
1635
|
-
return this.indentate(
|
|
1697
|
+
return this.indentate(i) + "<" + e + n + this.closeTag(e) + this.tagEndChar;
|
|
1636
1698
|
} else {
|
|
1637
|
-
return this.indentate(
|
|
1699
|
+
return this.indentate(i) + "<" + e + n + ">" + s + "</" + e + this.tagEndChar;
|
|
1638
1700
|
}
|
|
1639
1701
|
}
|
|
1640
1702
|
};
|
|
1641
1703
|
|
|
1642
|
-
|
|
1643
|
-
if (
|
|
1644
|
-
for (let
|
|
1645
|
-
const
|
|
1646
|
-
|
|
1704
|
+
Yt.prototype.replaceEntitiesValue = function(t) {
|
|
1705
|
+
if (t && t.length > 0 && this.options.processEntities) {
|
|
1706
|
+
for (let e = 0; e < this.options.entities.length; e++) {
|
|
1707
|
+
const n = this.options.entities[e];
|
|
1708
|
+
t = t.replace(n.regex, n.val);
|
|
1647
1709
|
}
|
|
1648
1710
|
}
|
|
1649
|
-
return
|
|
1711
|
+
return t;
|
|
1650
1712
|
};
|
|
1651
1713
|
|
|
1652
|
-
function
|
|
1653
|
-
return this.options.indentBy.repeat(
|
|
1714
|
+
function Wt(t) {
|
|
1715
|
+
return this.options.indentBy.repeat(t);
|
|
1654
1716
|
}
|
|
1655
1717
|
|
|
1656
|
-
function
|
|
1657
|
-
if (
|
|
1658
|
-
return
|
|
1718
|
+
function zt(t) {
|
|
1719
|
+
if (t.startsWith(this.options.attributeNamePrefix) && t !== this.options.textNodeName) {
|
|
1720
|
+
return t.substr(this.attrPrefixLen);
|
|
1659
1721
|
} else {
|
|
1660
1722
|
return false;
|
|
1661
1723
|
}
|
|
1662
1724
|
}
|
|
1663
1725
|
|
|
1664
|
-
var
|
|
1726
|
+
var Jt = Yt;
|
|
1665
1727
|
|
|
1666
|
-
const
|
|
1728
|
+
const Ht = t(Jt);
|
|
1667
1729
|
|
|
1668
1730
|
"use strict";
|
|
1669
1731
|
|
|
1670
|
-
const
|
|
1732
|
+
const Kt = e;
|
|
1671
1733
|
|
|
1672
|
-
const
|
|
1734
|
+
const Qt = jt;
|
|
1673
1735
|
|
|
1674
|
-
const
|
|
1736
|
+
const te = Jt;
|
|
1675
1737
|
|
|
1676
|
-
var
|
|
1677
|
-
XMLParser:
|
|
1678
|
-
XMLValidator:
|
|
1679
|
-
XMLBuilder:
|
|
1738
|
+
var ee = {
|
|
1739
|
+
XMLParser: Qt,
|
|
1740
|
+
XMLValidator: Kt,
|
|
1741
|
+
XMLBuilder: te
|
|
1680
1742
|
};
|
|
1681
1743
|
|
|
1682
|
-
const
|
|
1744
|
+
const ne = t(ee);
|
|
1683
1745
|
|
|
1684
|
-
function
|
|
1746
|
+
function ie(t) {
|
|
1685
1747
|
try {
|
|
1686
|
-
|
|
1748
|
+
ee.XMLValidator.validate(t, {
|
|
1687
1749
|
allowBooleanAttributes: true
|
|
1688
1750
|
});
|
|
1689
1751
|
return true;
|
|
1690
|
-
} catch (
|
|
1752
|
+
} catch (t) {
|
|
1691
1753
|
return false;
|
|
1692
1754
|
}
|
|
1693
1755
|
}
|
|
1694
1756
|
|
|
1695
|
-
export {
|
|
1757
|
+
export { ie as IsXML };
|