@deck.gl/geo-layers 9.3.0-beta.1 → 9.3.0
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/dist/dist.dev.js +1202 -233
- package/dist.min.js +18 -18
- package/package.json +6 -6
package/dist/dist.dev.js
CHANGED
|
@@ -8661,6 +8661,19 @@ var __exports__ = (() => {
|
|
|
8661
8661
|
function isExist(v2) {
|
|
8662
8662
|
return typeof v2 !== "undefined";
|
|
8663
8663
|
}
|
|
8664
|
+
var DANGEROUS_PROPERTY_NAMES = [
|
|
8665
|
+
// '__proto__',
|
|
8666
|
+
// 'constructor',
|
|
8667
|
+
// 'prototype',
|
|
8668
|
+
"hasOwnProperty",
|
|
8669
|
+
"toString",
|
|
8670
|
+
"valueOf",
|
|
8671
|
+
"__defineGetter__",
|
|
8672
|
+
"__defineSetter__",
|
|
8673
|
+
"__lookupGetter__",
|
|
8674
|
+
"__lookupSetter__"
|
|
8675
|
+
];
|
|
8676
|
+
var criticalProperties = ["__proto__", "constructor", "prototype"];
|
|
8664
8677
|
|
|
8665
8678
|
// ../../node_modules/fast-xml-parser/src/validator.js
|
|
8666
8679
|
var defaultOptions = {
|
|
@@ -8902,7 +8915,7 @@ var __exports__ = (() => {
|
|
|
8902
8915
|
if (!validateAttrName(attrName)) {
|
|
8903
8916
|
return getErrorObject("InvalidAttr", "Attribute '" + attrName + "' is an invalid name.", getPositionFromMatch(matches3[i]));
|
|
8904
8917
|
}
|
|
8905
|
-
if (!
|
|
8918
|
+
if (!Object.prototype.hasOwnProperty.call(attrNames, attrName)) {
|
|
8906
8919
|
attrNames[attrName] = 1;
|
|
8907
8920
|
} else {
|
|
8908
8921
|
return getErrorObject("InvalidAttr", "Attribute '" + attrName + "' is repeated.", getPositionFromMatch(matches3[i]));
|
|
@@ -8971,6 +8984,12 @@ var __exports__ = (() => {
|
|
|
8971
8984
|
}
|
|
8972
8985
|
|
|
8973
8986
|
// ../../node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js
|
|
8987
|
+
var defaultOnDangerousProperty = (name12) => {
|
|
8988
|
+
if (DANGEROUS_PROPERTY_NAMES.includes(name12)) {
|
|
8989
|
+
return "__" + name12;
|
|
8990
|
+
}
|
|
8991
|
+
return name12;
|
|
8992
|
+
};
|
|
8974
8993
|
var defaultOptions2 = {
|
|
8975
8994
|
preserveOrder: false,
|
|
8976
8995
|
attributeNamePrefix: "@_",
|
|
@@ -9014,8 +9033,29 @@ var __exports__ = (() => {
|
|
|
9014
9033
|
return tagName;
|
|
9015
9034
|
},
|
|
9016
9035
|
// skipEmptyListItem: false
|
|
9017
|
-
captureMetaData: false
|
|
9036
|
+
captureMetaData: false,
|
|
9037
|
+
maxNestedTags: 100,
|
|
9038
|
+
strictReservedNames: true,
|
|
9039
|
+
jPath: true,
|
|
9040
|
+
// if true, pass jPath string to callbacks; if false, pass matcher instance
|
|
9041
|
+
onDangerousProperty: defaultOnDangerousProperty
|
|
9018
9042
|
};
|
|
9043
|
+
function validatePropertyName(propertyName, optionName) {
|
|
9044
|
+
if (typeof propertyName !== "string") {
|
|
9045
|
+
return;
|
|
9046
|
+
}
|
|
9047
|
+
const normalized = propertyName.toLowerCase();
|
|
9048
|
+
if (DANGEROUS_PROPERTY_NAMES.some((dangerous) => normalized === dangerous.toLowerCase())) {
|
|
9049
|
+
throw new Error(
|
|
9050
|
+
`[SECURITY] Invalid ${optionName}: "${propertyName}" is a reserved JavaScript keyword that could cause prototype pollution`
|
|
9051
|
+
);
|
|
9052
|
+
}
|
|
9053
|
+
if (criticalProperties.some((dangerous) => normalized === dangerous.toLowerCase())) {
|
|
9054
|
+
throw new Error(
|
|
9055
|
+
`[SECURITY] Invalid ${optionName}: "${propertyName}" is a reserved JavaScript keyword that could cause prototype pollution`
|
|
9056
|
+
);
|
|
9057
|
+
}
|
|
9058
|
+
}
|
|
9019
9059
|
function normalizeProcessEntities(value) {
|
|
9020
9060
|
if (typeof value === "boolean") {
|
|
9021
9061
|
return {
|
|
@@ -9025,6 +9065,7 @@ var __exports__ = (() => {
|
|
|
9025
9065
|
maxExpansionDepth: 10,
|
|
9026
9066
|
maxTotalExpansions: 1e3,
|
|
9027
9067
|
maxExpandedLength: 1e5,
|
|
9068
|
+
maxEntityCount: 100,
|
|
9028
9069
|
allowedTags: null,
|
|
9029
9070
|
tagFilter: null
|
|
9030
9071
|
};
|
|
@@ -9032,11 +9073,11 @@ var __exports__ = (() => {
|
|
|
9032
9073
|
if (typeof value === "object" && value !== null) {
|
|
9033
9074
|
return {
|
|
9034
9075
|
enabled: value.enabled !== false,
|
|
9035
|
-
|
|
9036
|
-
|
|
9037
|
-
|
|
9038
|
-
|
|
9039
|
-
|
|
9076
|
+
maxEntitySize: Math.max(1, value.maxEntitySize ?? 1e4),
|
|
9077
|
+
maxExpansionDepth: Math.max(1, value.maxExpansionDepth ?? 1e4),
|
|
9078
|
+
maxTotalExpansions: Math.max(1, value.maxTotalExpansions ?? Infinity),
|
|
9079
|
+
maxExpandedLength: Math.max(1, value.maxExpandedLength ?? 1e5),
|
|
9080
|
+
maxEntityCount: Math.max(1, value.maxEntityCount ?? 1e3),
|
|
9040
9081
|
allowedTags: value.allowedTags ?? null,
|
|
9041
9082
|
tagFilter: value.tagFilter ?? null
|
|
9042
9083
|
};
|
|
@@ -9045,7 +9086,31 @@ var __exports__ = (() => {
|
|
|
9045
9086
|
}
|
|
9046
9087
|
var buildOptions = function(options) {
|
|
9047
9088
|
const built = Object.assign({}, defaultOptions2, options);
|
|
9089
|
+
const propertyNameOptions = [
|
|
9090
|
+
{ value: built.attributeNamePrefix, name: "attributeNamePrefix" },
|
|
9091
|
+
{ value: built.attributesGroupName, name: "attributesGroupName" },
|
|
9092
|
+
{ value: built.textNodeName, name: "textNodeName" },
|
|
9093
|
+
{ value: built.cdataPropName, name: "cdataPropName" },
|
|
9094
|
+
{ value: built.commentPropName, name: "commentPropName" }
|
|
9095
|
+
];
|
|
9096
|
+
for (const { value, name: name12 } of propertyNameOptions) {
|
|
9097
|
+
if (value) {
|
|
9098
|
+
validatePropertyName(value, name12);
|
|
9099
|
+
}
|
|
9100
|
+
}
|
|
9101
|
+
if (built.onDangerousProperty === null) {
|
|
9102
|
+
built.onDangerousProperty = defaultOnDangerousProperty;
|
|
9103
|
+
}
|
|
9048
9104
|
built.processEntities = normalizeProcessEntities(built.processEntities);
|
|
9105
|
+
built.unpairedTagsSet = new Set(built.unpairedTags);
|
|
9106
|
+
if (built.stopNodes && Array.isArray(built.stopNodes)) {
|
|
9107
|
+
built.stopNodes = built.stopNodes.map((node) => {
|
|
9108
|
+
if (typeof node === "string" && node.startsWith("*.")) {
|
|
9109
|
+
return ".." + node.substring(2);
|
|
9110
|
+
}
|
|
9111
|
+
return node;
|
|
9112
|
+
});
|
|
9113
|
+
}
|
|
9049
9114
|
return built;
|
|
9050
9115
|
};
|
|
9051
9116
|
|
|
@@ -9060,7 +9125,7 @@ var __exports__ = (() => {
|
|
|
9060
9125
|
constructor(tagname) {
|
|
9061
9126
|
this.tagname = tagname;
|
|
9062
9127
|
this.child = [];
|
|
9063
|
-
this[":@"] =
|
|
9128
|
+
this[":@"] = /* @__PURE__ */ Object.create(null);
|
|
9064
9129
|
}
|
|
9065
9130
|
add(key, val) {
|
|
9066
9131
|
if (key === "__proto__")
|
|
@@ -9092,7 +9157,8 @@ var __exports__ = (() => {
|
|
|
9092
9157
|
this.options = options;
|
|
9093
9158
|
}
|
|
9094
9159
|
readDocType(xmlData, i) {
|
|
9095
|
-
const entities =
|
|
9160
|
+
const entities = /* @__PURE__ */ Object.create(null);
|
|
9161
|
+
let entityCount = 0;
|
|
9096
9162
|
if (xmlData[i + 3] === "O" && xmlData[i + 4] === "C" && xmlData[i + 5] === "T" && xmlData[i + 6] === "Y" && xmlData[i + 7] === "P" && xmlData[i + 8] === "E") {
|
|
9097
9163
|
i = i + 9;
|
|
9098
9164
|
let angleBracketsCount = 1;
|
|
@@ -9105,11 +9171,17 @@ var __exports__ = (() => {
|
|
|
9105
9171
|
let entityName, val;
|
|
9106
9172
|
[entityName, val, i] = this.readEntityExp(xmlData, i + 1, this.suppressValidationErr);
|
|
9107
9173
|
if (val.indexOf("&") === -1) {
|
|
9108
|
-
|
|
9174
|
+
if (this.options.enabled !== false && this.options.maxEntityCount != null && entityCount >= this.options.maxEntityCount) {
|
|
9175
|
+
throw new Error(
|
|
9176
|
+
`Entity count (${entityCount + 1}) exceeds maximum allowed (${this.options.maxEntityCount})`
|
|
9177
|
+
);
|
|
9178
|
+
}
|
|
9179
|
+
const escaped = entityName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
9109
9180
|
entities[entityName] = {
|
|
9110
9181
|
regx: RegExp(`&${escaped};`, "g"),
|
|
9111
9182
|
val
|
|
9112
9183
|
};
|
|
9184
|
+
entityCount++;
|
|
9113
9185
|
}
|
|
9114
9186
|
} else if (hasBody && hasSeq(xmlData, "!ELEMENT", i)) {
|
|
9115
9187
|
i += 8;
|
|
@@ -9155,11 +9227,11 @@ var __exports__ = (() => {
|
|
|
9155
9227
|
}
|
|
9156
9228
|
readEntityExp(xmlData, i) {
|
|
9157
9229
|
i = skipWhitespace(xmlData, i);
|
|
9158
|
-
|
|
9230
|
+
const startIndex = i;
|
|
9159
9231
|
while (i < xmlData.length && !/\s/.test(xmlData[i]) && xmlData[i] !== '"' && xmlData[i] !== "'") {
|
|
9160
|
-
entityName += xmlData[i];
|
|
9161
9232
|
i++;
|
|
9162
9233
|
}
|
|
9234
|
+
let entityName = xmlData.substring(startIndex, i);
|
|
9163
9235
|
validateEntityName(entityName);
|
|
9164
9236
|
i = skipWhitespace(xmlData, i);
|
|
9165
9237
|
if (!this.suppressValidationErr) {
|
|
@@ -9171,7 +9243,7 @@ var __exports__ = (() => {
|
|
|
9171
9243
|
}
|
|
9172
9244
|
let entityValue = "";
|
|
9173
9245
|
[i, entityValue] = this.readIdentifierVal(xmlData, i, "entity");
|
|
9174
|
-
if (this.options.enabled !== false && this.options.maxEntitySize && entityValue.length > this.options.maxEntitySize) {
|
|
9246
|
+
if (this.options.enabled !== false && this.options.maxEntitySize != null && entityValue.length > this.options.maxEntitySize) {
|
|
9175
9247
|
throw new Error(
|
|
9176
9248
|
`Entity "${entityName}" size (${entityValue.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`
|
|
9177
9249
|
);
|
|
@@ -9181,11 +9253,11 @@ var __exports__ = (() => {
|
|
|
9181
9253
|
}
|
|
9182
9254
|
readNotationExp(xmlData, i) {
|
|
9183
9255
|
i = skipWhitespace(xmlData, i);
|
|
9184
|
-
|
|
9256
|
+
const startIndex = i;
|
|
9185
9257
|
while (i < xmlData.length && !/\s/.test(xmlData[i])) {
|
|
9186
|
-
notationName += xmlData[i];
|
|
9187
9258
|
i++;
|
|
9188
9259
|
}
|
|
9260
|
+
let notationName = xmlData.substring(startIndex, i);
|
|
9189
9261
|
!this.suppressValidationErr && validateEntityName(notationName);
|
|
9190
9262
|
i = skipWhitespace(xmlData, i);
|
|
9191
9263
|
const identifierType = xmlData.substring(i, i + 6).toUpperCase();
|
|
@@ -9217,10 +9289,11 @@ var __exports__ = (() => {
|
|
|
9217
9289
|
throw new Error(`Expected quoted string, found "${startChar}"`);
|
|
9218
9290
|
}
|
|
9219
9291
|
i++;
|
|
9292
|
+
const startIndex = i;
|
|
9220
9293
|
while (i < xmlData.length && xmlData[i] !== startChar) {
|
|
9221
|
-
identifierVal += xmlData[i];
|
|
9222
9294
|
i++;
|
|
9223
9295
|
}
|
|
9296
|
+
identifierVal = xmlData.substring(startIndex, i);
|
|
9224
9297
|
if (xmlData[i] !== startChar) {
|
|
9225
9298
|
throw new Error(`Unterminated ${type} value`);
|
|
9226
9299
|
}
|
|
@@ -9229,11 +9302,11 @@ var __exports__ = (() => {
|
|
|
9229
9302
|
}
|
|
9230
9303
|
readElementExp(xmlData, i) {
|
|
9231
9304
|
i = skipWhitespace(xmlData, i);
|
|
9232
|
-
|
|
9305
|
+
const startIndex = i;
|
|
9233
9306
|
while (i < xmlData.length && !/\s/.test(xmlData[i])) {
|
|
9234
|
-
elementName += xmlData[i];
|
|
9235
9307
|
i++;
|
|
9236
9308
|
}
|
|
9309
|
+
let elementName = xmlData.substring(startIndex, i);
|
|
9237
9310
|
if (!this.suppressValidationErr && !isName(elementName)) {
|
|
9238
9311
|
throw new Error(`Invalid element name: "${elementName}"`);
|
|
9239
9312
|
}
|
|
@@ -9245,10 +9318,11 @@ var __exports__ = (() => {
|
|
|
9245
9318
|
i += 2;
|
|
9246
9319
|
else if (xmlData[i] === "(") {
|
|
9247
9320
|
i++;
|
|
9321
|
+
const startIndex2 = i;
|
|
9248
9322
|
while (i < xmlData.length && xmlData[i] !== ")") {
|
|
9249
|
-
contentModel += xmlData[i];
|
|
9250
9323
|
i++;
|
|
9251
9324
|
}
|
|
9325
|
+
contentModel = xmlData.substring(startIndex2, i);
|
|
9252
9326
|
if (xmlData[i] !== ")") {
|
|
9253
9327
|
throw new Error("Unterminated content model");
|
|
9254
9328
|
}
|
|
@@ -9263,18 +9337,18 @@ var __exports__ = (() => {
|
|
|
9263
9337
|
}
|
|
9264
9338
|
readAttlistExp(xmlData, i) {
|
|
9265
9339
|
i = skipWhitespace(xmlData, i);
|
|
9266
|
-
let
|
|
9340
|
+
let startIndex = i;
|
|
9267
9341
|
while (i < xmlData.length && !/\s/.test(xmlData[i])) {
|
|
9268
|
-
elementName += xmlData[i];
|
|
9269
9342
|
i++;
|
|
9270
9343
|
}
|
|
9344
|
+
let elementName = xmlData.substring(startIndex, i);
|
|
9271
9345
|
validateEntityName(elementName);
|
|
9272
9346
|
i = skipWhitespace(xmlData, i);
|
|
9273
|
-
|
|
9347
|
+
startIndex = i;
|
|
9274
9348
|
while (i < xmlData.length && !/\s/.test(xmlData[i])) {
|
|
9275
|
-
attributeName += xmlData[i];
|
|
9276
9349
|
i++;
|
|
9277
9350
|
}
|
|
9351
|
+
let attributeName = xmlData.substring(startIndex, i);
|
|
9278
9352
|
if (!validateEntityName(attributeName)) {
|
|
9279
9353
|
throw new Error(`Invalid attribute name: "${attributeName}"`);
|
|
9280
9354
|
}
|
|
@@ -9290,11 +9364,11 @@ var __exports__ = (() => {
|
|
|
9290
9364
|
i++;
|
|
9291
9365
|
let allowedNotations = [];
|
|
9292
9366
|
while (i < xmlData.length && xmlData[i] !== ")") {
|
|
9293
|
-
|
|
9367
|
+
const startIndex2 = i;
|
|
9294
9368
|
while (i < xmlData.length && xmlData[i] !== "|" && xmlData[i] !== ")") {
|
|
9295
|
-
notation += xmlData[i];
|
|
9296
9369
|
i++;
|
|
9297
9370
|
}
|
|
9371
|
+
let notation = xmlData.substring(startIndex2, i);
|
|
9298
9372
|
notation = notation.trim();
|
|
9299
9373
|
if (!validateEntityName(notation)) {
|
|
9300
9374
|
throw new Error(`Invalid notation name: "${notation}"`);
|
|
@@ -9311,10 +9385,11 @@ var __exports__ = (() => {
|
|
|
9311
9385
|
i++;
|
|
9312
9386
|
attributeType += " (" + allowedNotations.join("|") + ")";
|
|
9313
9387
|
} else {
|
|
9388
|
+
const startIndex2 = i;
|
|
9314
9389
|
while (i < xmlData.length && !/\s/.test(xmlData[i])) {
|
|
9315
|
-
attributeType += xmlData[i];
|
|
9316
9390
|
i++;
|
|
9317
9391
|
}
|
|
9392
|
+
attributeType += xmlData.substring(startIndex2, i);
|
|
9318
9393
|
const validTypes = ["CDATA", "ID", "IDREF", "IDREFS", "ENTITY", "ENTITIES", "NMTOKEN", "NMTOKENS"];
|
|
9319
9394
|
if (!this.suppressValidationErr && !validTypes.includes(attributeType.toUpperCase())) {
|
|
9320
9395
|
throw new Error(`Invalid attribute type: "${attributeType}"`);
|
|
@@ -9368,20 +9443,26 @@ var __exports__ = (() => {
|
|
|
9368
9443
|
// oct: false,
|
|
9369
9444
|
leadingZeros: true,
|
|
9370
9445
|
decimalPoint: ".",
|
|
9371
|
-
eNotation: true
|
|
9372
|
-
//skipLike: /regex
|
|
9446
|
+
eNotation: true,
|
|
9447
|
+
//skipLike: /regex/,
|
|
9448
|
+
infinity: "original"
|
|
9449
|
+
// "null", "infinity" (Infinity type), "string" ("Infinity" (the string literal))
|
|
9373
9450
|
};
|
|
9374
9451
|
function toNumber(str7, options = {}) {
|
|
9375
9452
|
options = Object.assign({}, consider, options);
|
|
9376
9453
|
if (!str7 || typeof str7 !== "string")
|
|
9377
9454
|
return str7;
|
|
9378
9455
|
let trimmedStr = str7.trim();
|
|
9379
|
-
if (
|
|
9456
|
+
if (trimmedStr.length === 0)
|
|
9380
9457
|
return str7;
|
|
9381
|
-
else if (
|
|
9458
|
+
else if (options.skipLike !== void 0 && options.skipLike.test(trimmedStr))
|
|
9459
|
+
return str7;
|
|
9460
|
+
else if (trimmedStr === "0")
|
|
9382
9461
|
return 0;
|
|
9383
9462
|
else if (options.hex && hexRegex.test(trimmedStr)) {
|
|
9384
9463
|
return parse_int(trimmedStr, 16);
|
|
9464
|
+
} else if (!isFinite(trimmedStr)) {
|
|
9465
|
+
return handleInfinity(str7, Number(trimmedStr), options);
|
|
9385
9466
|
} else if (trimmedStr.includes("e") || trimmedStr.includes("E")) {
|
|
9386
9467
|
return resolveEnotation(str7, trimmedStr, options);
|
|
9387
9468
|
} else {
|
|
@@ -9445,11 +9526,15 @@ var __exports__ = (() => {
|
|
|
9445
9526
|
return str7;
|
|
9446
9527
|
else if (leadingZeros.length === 1 && (notation[3].startsWith(`.${eChar}`) || notation[3][0] === eChar)) {
|
|
9447
9528
|
return Number(trimmedStr);
|
|
9448
|
-
} else if (
|
|
9449
|
-
|
|
9529
|
+
} else if (leadingZeros.length > 0) {
|
|
9530
|
+
if (options.leadingZeros && !eAdjacentToLeadingZeros) {
|
|
9531
|
+
trimmedStr = (notation[1] || "") + notation[3];
|
|
9532
|
+
return Number(trimmedStr);
|
|
9533
|
+
} else
|
|
9534
|
+
return str7;
|
|
9535
|
+
} else {
|
|
9450
9536
|
return Number(trimmedStr);
|
|
9451
|
-
}
|
|
9452
|
-
return str7;
|
|
9537
|
+
}
|
|
9453
9538
|
} else {
|
|
9454
9539
|
return str7;
|
|
9455
9540
|
}
|
|
@@ -9477,6 +9562,20 @@ var __exports__ = (() => {
|
|
|
9477
9562
|
else
|
|
9478
9563
|
throw new Error("parseInt, Number.parseInt, window.parseInt are not supported");
|
|
9479
9564
|
}
|
|
9565
|
+
function handleInfinity(str7, num, options) {
|
|
9566
|
+
const isPositive2 = num === Infinity;
|
|
9567
|
+
switch (options.infinity.toLowerCase()) {
|
|
9568
|
+
case "null":
|
|
9569
|
+
return null;
|
|
9570
|
+
case "infinity":
|
|
9571
|
+
return num;
|
|
9572
|
+
case "string":
|
|
9573
|
+
return isPositive2 ? "Infinity" : "-Infinity";
|
|
9574
|
+
case "original":
|
|
9575
|
+
default:
|
|
9576
|
+
return str7;
|
|
9577
|
+
}
|
|
9578
|
+
}
|
|
9480
9579
|
|
|
9481
9580
|
// ../../node_modules/fast-xml-parser/src/ignoreAttributes.js
|
|
9482
9581
|
function getIgnoreAttributesFn(ignoreAttributes) {
|
|
@@ -9498,7 +9597,776 @@ var __exports__ = (() => {
|
|
|
9498
9597
|
return () => false;
|
|
9499
9598
|
}
|
|
9500
9599
|
|
|
9600
|
+
// ../../node_modules/path-expression-matcher/src/Expression.js
|
|
9601
|
+
var Expression = class {
|
|
9602
|
+
/**
|
|
9603
|
+
* Create a new Expression
|
|
9604
|
+
* @param {string} pattern - Pattern string (e.g., "root.users.user", "..user[id]")
|
|
9605
|
+
* @param {Object} options - Configuration options
|
|
9606
|
+
* @param {string} options.separator - Path separator (default: '.')
|
|
9607
|
+
*/
|
|
9608
|
+
constructor(pattern, options = {}, data) {
|
|
9609
|
+
this.pattern = pattern;
|
|
9610
|
+
this.separator = options.separator || ".";
|
|
9611
|
+
this.segments = this._parse(pattern);
|
|
9612
|
+
this.data = data;
|
|
9613
|
+
this._hasDeepWildcard = this.segments.some((seg) => seg.type === "deep-wildcard");
|
|
9614
|
+
this._hasAttributeCondition = this.segments.some((seg) => seg.attrName !== void 0);
|
|
9615
|
+
this._hasPositionSelector = this.segments.some((seg) => seg.position !== void 0);
|
|
9616
|
+
}
|
|
9617
|
+
/**
|
|
9618
|
+
* Parse pattern string into segments
|
|
9619
|
+
* @private
|
|
9620
|
+
* @param {string} pattern - Pattern to parse
|
|
9621
|
+
* @returns {Array} Array of segment objects
|
|
9622
|
+
*/
|
|
9623
|
+
_parse(pattern) {
|
|
9624
|
+
const segments = [];
|
|
9625
|
+
let i = 0;
|
|
9626
|
+
let currentPart = "";
|
|
9627
|
+
while (i < pattern.length) {
|
|
9628
|
+
if (pattern[i] === this.separator) {
|
|
9629
|
+
if (i + 1 < pattern.length && pattern[i + 1] === this.separator) {
|
|
9630
|
+
if (currentPart.trim()) {
|
|
9631
|
+
segments.push(this._parseSegment(currentPart.trim()));
|
|
9632
|
+
currentPart = "";
|
|
9633
|
+
}
|
|
9634
|
+
segments.push({ type: "deep-wildcard" });
|
|
9635
|
+
i += 2;
|
|
9636
|
+
} else {
|
|
9637
|
+
if (currentPart.trim()) {
|
|
9638
|
+
segments.push(this._parseSegment(currentPart.trim()));
|
|
9639
|
+
}
|
|
9640
|
+
currentPart = "";
|
|
9641
|
+
i++;
|
|
9642
|
+
}
|
|
9643
|
+
} else {
|
|
9644
|
+
currentPart += pattern[i];
|
|
9645
|
+
i++;
|
|
9646
|
+
}
|
|
9647
|
+
}
|
|
9648
|
+
if (currentPart.trim()) {
|
|
9649
|
+
segments.push(this._parseSegment(currentPart.trim()));
|
|
9650
|
+
}
|
|
9651
|
+
return segments;
|
|
9652
|
+
}
|
|
9653
|
+
/**
|
|
9654
|
+
* Parse a single segment
|
|
9655
|
+
* @private
|
|
9656
|
+
* @param {string} part - Segment string (e.g., "user", "ns::user", "user[id]", "ns::user:first")
|
|
9657
|
+
* @returns {Object} Segment object
|
|
9658
|
+
*/
|
|
9659
|
+
_parseSegment(part) {
|
|
9660
|
+
const segment = { type: "tag" };
|
|
9661
|
+
let bracketContent = null;
|
|
9662
|
+
let withoutBrackets = part;
|
|
9663
|
+
const bracketMatch = part.match(/^([^\[]+)(\[[^\]]*\])(.*)$/);
|
|
9664
|
+
if (bracketMatch) {
|
|
9665
|
+
withoutBrackets = bracketMatch[1] + bracketMatch[3];
|
|
9666
|
+
if (bracketMatch[2]) {
|
|
9667
|
+
const content = bracketMatch[2].slice(1, -1);
|
|
9668
|
+
if (content) {
|
|
9669
|
+
bracketContent = content;
|
|
9670
|
+
}
|
|
9671
|
+
}
|
|
9672
|
+
}
|
|
9673
|
+
let namespace = void 0;
|
|
9674
|
+
let tagAndPosition = withoutBrackets;
|
|
9675
|
+
if (withoutBrackets.includes("::")) {
|
|
9676
|
+
const nsIndex = withoutBrackets.indexOf("::");
|
|
9677
|
+
namespace = withoutBrackets.substring(0, nsIndex).trim();
|
|
9678
|
+
tagAndPosition = withoutBrackets.substring(nsIndex + 2).trim();
|
|
9679
|
+
if (!namespace) {
|
|
9680
|
+
throw new Error(`Invalid namespace in pattern: ${part}`);
|
|
9681
|
+
}
|
|
9682
|
+
}
|
|
9683
|
+
let tag = void 0;
|
|
9684
|
+
let positionMatch = null;
|
|
9685
|
+
if (tagAndPosition.includes(":")) {
|
|
9686
|
+
const colonIndex = tagAndPosition.lastIndexOf(":");
|
|
9687
|
+
const tagPart = tagAndPosition.substring(0, colonIndex).trim();
|
|
9688
|
+
const posPart = tagAndPosition.substring(colonIndex + 1).trim();
|
|
9689
|
+
const isPositionKeyword = ["first", "last", "odd", "even"].includes(posPart) || /^nth\(\d+\)$/.test(posPart);
|
|
9690
|
+
if (isPositionKeyword) {
|
|
9691
|
+
tag = tagPart;
|
|
9692
|
+
positionMatch = posPart;
|
|
9693
|
+
} else {
|
|
9694
|
+
tag = tagAndPosition;
|
|
9695
|
+
}
|
|
9696
|
+
} else {
|
|
9697
|
+
tag = tagAndPosition;
|
|
9698
|
+
}
|
|
9699
|
+
if (!tag) {
|
|
9700
|
+
throw new Error(`Invalid segment pattern: ${part}`);
|
|
9701
|
+
}
|
|
9702
|
+
segment.tag = tag;
|
|
9703
|
+
if (namespace) {
|
|
9704
|
+
segment.namespace = namespace;
|
|
9705
|
+
}
|
|
9706
|
+
if (bracketContent) {
|
|
9707
|
+
if (bracketContent.includes("=")) {
|
|
9708
|
+
const eqIndex = bracketContent.indexOf("=");
|
|
9709
|
+
segment.attrName = bracketContent.substring(0, eqIndex).trim();
|
|
9710
|
+
segment.attrValue = bracketContent.substring(eqIndex + 1).trim();
|
|
9711
|
+
} else {
|
|
9712
|
+
segment.attrName = bracketContent.trim();
|
|
9713
|
+
}
|
|
9714
|
+
}
|
|
9715
|
+
if (positionMatch) {
|
|
9716
|
+
const nthMatch = positionMatch.match(/^nth\((\d+)\)$/);
|
|
9717
|
+
if (nthMatch) {
|
|
9718
|
+
segment.position = "nth";
|
|
9719
|
+
segment.positionValue = parseInt(nthMatch[1], 10);
|
|
9720
|
+
} else {
|
|
9721
|
+
segment.position = positionMatch;
|
|
9722
|
+
}
|
|
9723
|
+
}
|
|
9724
|
+
return segment;
|
|
9725
|
+
}
|
|
9726
|
+
/**
|
|
9727
|
+
* Get the number of segments
|
|
9728
|
+
* @returns {number}
|
|
9729
|
+
*/
|
|
9730
|
+
get length() {
|
|
9731
|
+
return this.segments.length;
|
|
9732
|
+
}
|
|
9733
|
+
/**
|
|
9734
|
+
* Check if expression contains deep wildcard
|
|
9735
|
+
* @returns {boolean}
|
|
9736
|
+
*/
|
|
9737
|
+
hasDeepWildcard() {
|
|
9738
|
+
return this._hasDeepWildcard;
|
|
9739
|
+
}
|
|
9740
|
+
/**
|
|
9741
|
+
* Check if expression has attribute conditions
|
|
9742
|
+
* @returns {boolean}
|
|
9743
|
+
*/
|
|
9744
|
+
hasAttributeCondition() {
|
|
9745
|
+
return this._hasAttributeCondition;
|
|
9746
|
+
}
|
|
9747
|
+
/**
|
|
9748
|
+
* Check if expression has position selectors
|
|
9749
|
+
* @returns {boolean}
|
|
9750
|
+
*/
|
|
9751
|
+
hasPositionSelector() {
|
|
9752
|
+
return this._hasPositionSelector;
|
|
9753
|
+
}
|
|
9754
|
+
/**
|
|
9755
|
+
* Get string representation
|
|
9756
|
+
* @returns {string}
|
|
9757
|
+
*/
|
|
9758
|
+
toString() {
|
|
9759
|
+
return this.pattern;
|
|
9760
|
+
}
|
|
9761
|
+
};
|
|
9762
|
+
|
|
9763
|
+
// ../../node_modules/path-expression-matcher/src/ExpressionSet.js
|
|
9764
|
+
var ExpressionSet = class {
|
|
9765
|
+
constructor() {
|
|
9766
|
+
this._byDepthAndTag = /* @__PURE__ */ new Map();
|
|
9767
|
+
this._wildcardByDepth = /* @__PURE__ */ new Map();
|
|
9768
|
+
this._deepWildcards = [];
|
|
9769
|
+
this._patterns = /* @__PURE__ */ new Set();
|
|
9770
|
+
this._sealed = false;
|
|
9771
|
+
}
|
|
9772
|
+
/**
|
|
9773
|
+
* Add an Expression to the set.
|
|
9774
|
+
* Duplicate patterns (same pattern string) are silently ignored.
|
|
9775
|
+
*
|
|
9776
|
+
* @param {import('./Expression.js').default} expression - A pre-constructed Expression instance
|
|
9777
|
+
* @returns {this} for chaining
|
|
9778
|
+
* @throws {TypeError} if called after seal()
|
|
9779
|
+
*
|
|
9780
|
+
* @example
|
|
9781
|
+
* set.add(new Expression('root.users.user'));
|
|
9782
|
+
* set.add(new Expression('..script'));
|
|
9783
|
+
*/
|
|
9784
|
+
add(expression) {
|
|
9785
|
+
if (this._sealed) {
|
|
9786
|
+
throw new TypeError(
|
|
9787
|
+
"ExpressionSet is sealed. Create a new ExpressionSet to add more expressions."
|
|
9788
|
+
);
|
|
9789
|
+
}
|
|
9790
|
+
if (this._patterns.has(expression.pattern))
|
|
9791
|
+
return this;
|
|
9792
|
+
this._patterns.add(expression.pattern);
|
|
9793
|
+
if (expression.hasDeepWildcard()) {
|
|
9794
|
+
this._deepWildcards.push(expression);
|
|
9795
|
+
return this;
|
|
9796
|
+
}
|
|
9797
|
+
const depth = expression.length;
|
|
9798
|
+
const lastSeg = expression.segments[expression.segments.length - 1];
|
|
9799
|
+
const tag = lastSeg?.tag;
|
|
9800
|
+
if (!tag || tag === "*") {
|
|
9801
|
+
if (!this._wildcardByDepth.has(depth))
|
|
9802
|
+
this._wildcardByDepth.set(depth, []);
|
|
9803
|
+
this._wildcardByDepth.get(depth).push(expression);
|
|
9804
|
+
} else {
|
|
9805
|
+
const key = `${depth}:${tag}`;
|
|
9806
|
+
if (!this._byDepthAndTag.has(key))
|
|
9807
|
+
this._byDepthAndTag.set(key, []);
|
|
9808
|
+
this._byDepthAndTag.get(key).push(expression);
|
|
9809
|
+
}
|
|
9810
|
+
return this;
|
|
9811
|
+
}
|
|
9812
|
+
/**
|
|
9813
|
+
* Add multiple expressions at once.
|
|
9814
|
+
*
|
|
9815
|
+
* @param {import('./Expression.js').default[]} expressions - Array of Expression instances
|
|
9816
|
+
* @returns {this} for chaining
|
|
9817
|
+
*
|
|
9818
|
+
* @example
|
|
9819
|
+
* set.addAll([
|
|
9820
|
+
* new Expression('root.users.user'),
|
|
9821
|
+
* new Expression('root.config.setting'),
|
|
9822
|
+
* ]);
|
|
9823
|
+
*/
|
|
9824
|
+
addAll(expressions) {
|
|
9825
|
+
for (const expr of expressions)
|
|
9826
|
+
this.add(expr);
|
|
9827
|
+
return this;
|
|
9828
|
+
}
|
|
9829
|
+
/**
|
|
9830
|
+
* Check whether a pattern string is already present in the set.
|
|
9831
|
+
*
|
|
9832
|
+
* @param {import('./Expression.js').default} expression
|
|
9833
|
+
* @returns {boolean}
|
|
9834
|
+
*/
|
|
9835
|
+
has(expression) {
|
|
9836
|
+
return this._patterns.has(expression.pattern);
|
|
9837
|
+
}
|
|
9838
|
+
/**
|
|
9839
|
+
* Number of expressions in the set.
|
|
9840
|
+
* @type {number}
|
|
9841
|
+
*/
|
|
9842
|
+
get size() {
|
|
9843
|
+
return this._patterns.size;
|
|
9844
|
+
}
|
|
9845
|
+
/**
|
|
9846
|
+
* Seal the set against further modifications.
|
|
9847
|
+
* Useful to prevent accidental mutations after config is built.
|
|
9848
|
+
* Calling add() or addAll() on a sealed set throws a TypeError.
|
|
9849
|
+
*
|
|
9850
|
+
* @returns {this}
|
|
9851
|
+
*/
|
|
9852
|
+
seal() {
|
|
9853
|
+
this._sealed = true;
|
|
9854
|
+
return this;
|
|
9855
|
+
}
|
|
9856
|
+
/**
|
|
9857
|
+
* Whether the set has been sealed.
|
|
9858
|
+
* @type {boolean}
|
|
9859
|
+
*/
|
|
9860
|
+
get isSealed() {
|
|
9861
|
+
return this._sealed;
|
|
9862
|
+
}
|
|
9863
|
+
/**
|
|
9864
|
+
* Test whether the matcher's current path matches any expression in the set.
|
|
9865
|
+
*
|
|
9866
|
+
* Evaluation order (cheapest → most expensive):
|
|
9867
|
+
* 1. Exact depth + tag bucket — O(1) lookup, typically 0–2 expressions
|
|
9868
|
+
* 2. Depth-only wildcard bucket — O(1) lookup, rare
|
|
9869
|
+
* 3. Deep-wildcard list — always checked, but usually small
|
|
9870
|
+
*
|
|
9871
|
+
* @param {import('./Matcher.js').default} matcher - Matcher instance (or readOnly view)
|
|
9872
|
+
* @returns {boolean} true if any expression matches the current path
|
|
9873
|
+
*
|
|
9874
|
+
* @example
|
|
9875
|
+
* if (stopNodes.matchesAny(matcher)) {
|
|
9876
|
+
* // handle stop node
|
|
9877
|
+
* }
|
|
9878
|
+
*/
|
|
9879
|
+
matchesAny(matcher) {
|
|
9880
|
+
return this.findMatch(matcher) !== null;
|
|
9881
|
+
}
|
|
9882
|
+
/**
|
|
9883
|
+
* Find and return the first Expression that matches the matcher's current path.
|
|
9884
|
+
*
|
|
9885
|
+
* Uses the same evaluation order as matchesAny (cheapest → most expensive):
|
|
9886
|
+
* 1. Exact depth + tag bucket
|
|
9887
|
+
* 2. Depth-only wildcard bucket
|
|
9888
|
+
* 3. Deep-wildcard list
|
|
9889
|
+
*
|
|
9890
|
+
* @param {import('./Matcher.js').default} matcher - Matcher instance (or readOnly view)
|
|
9891
|
+
* @returns {import('./Expression.js').default | null} the first matching Expression, or null
|
|
9892
|
+
*
|
|
9893
|
+
* @example
|
|
9894
|
+
* const expr = stopNodes.findMatch(matcher);
|
|
9895
|
+
* if (expr) {
|
|
9896
|
+
* // access expr.config, expr.pattern, etc.
|
|
9897
|
+
* }
|
|
9898
|
+
*/
|
|
9899
|
+
findMatch(matcher) {
|
|
9900
|
+
const depth = matcher.getDepth();
|
|
9901
|
+
const tag = matcher.getCurrentTag();
|
|
9902
|
+
const exactKey = `${depth}:${tag}`;
|
|
9903
|
+
const exactBucket = this._byDepthAndTag.get(exactKey);
|
|
9904
|
+
if (exactBucket) {
|
|
9905
|
+
for (let i = 0; i < exactBucket.length; i++) {
|
|
9906
|
+
if (matcher.matches(exactBucket[i]))
|
|
9907
|
+
return exactBucket[i];
|
|
9908
|
+
}
|
|
9909
|
+
}
|
|
9910
|
+
const wildcardBucket = this._wildcardByDepth.get(depth);
|
|
9911
|
+
if (wildcardBucket) {
|
|
9912
|
+
for (let i = 0; i < wildcardBucket.length; i++) {
|
|
9913
|
+
if (matcher.matches(wildcardBucket[i]))
|
|
9914
|
+
return wildcardBucket[i];
|
|
9915
|
+
}
|
|
9916
|
+
}
|
|
9917
|
+
for (let i = 0; i < this._deepWildcards.length; i++) {
|
|
9918
|
+
if (matcher.matches(this._deepWildcards[i]))
|
|
9919
|
+
return this._deepWildcards[i];
|
|
9920
|
+
}
|
|
9921
|
+
return null;
|
|
9922
|
+
}
|
|
9923
|
+
};
|
|
9924
|
+
|
|
9925
|
+
// ../../node_modules/path-expression-matcher/src/Matcher.js
|
|
9926
|
+
var MUTATING_METHODS = /* @__PURE__ */ new Set(["push", "pop", "reset", "updateCurrent", "restore"]);
|
|
9927
|
+
var Matcher = class {
|
|
9928
|
+
/**
|
|
9929
|
+
* Create a new Matcher
|
|
9930
|
+
* @param {Object} options - Configuration options
|
|
9931
|
+
* @param {string} options.separator - Default path separator (default: '.')
|
|
9932
|
+
*/
|
|
9933
|
+
constructor(options = {}) {
|
|
9934
|
+
this.separator = options.separator || ".";
|
|
9935
|
+
this.path = [];
|
|
9936
|
+
this.siblingStacks = [];
|
|
9937
|
+
this._pathStringCache = null;
|
|
9938
|
+
this._frozenPathCache = null;
|
|
9939
|
+
this._frozenSiblingsCache = null;
|
|
9940
|
+
}
|
|
9941
|
+
/**
|
|
9942
|
+
* Push a new tag onto the path
|
|
9943
|
+
* @param {string} tagName - Name of the tag
|
|
9944
|
+
* @param {Object} attrValues - Attribute key-value pairs for current node (optional)
|
|
9945
|
+
* @param {string} namespace - Namespace for the tag (optional)
|
|
9946
|
+
*/
|
|
9947
|
+
push(tagName, attrValues = null, namespace = null) {
|
|
9948
|
+
this._pathStringCache = null;
|
|
9949
|
+
this._frozenPathCache = null;
|
|
9950
|
+
this._frozenSiblingsCache = null;
|
|
9951
|
+
if (this.path.length > 0) {
|
|
9952
|
+
const prev = this.path[this.path.length - 1];
|
|
9953
|
+
prev.values = void 0;
|
|
9954
|
+
}
|
|
9955
|
+
const currentLevel = this.path.length;
|
|
9956
|
+
if (!this.siblingStacks[currentLevel]) {
|
|
9957
|
+
this.siblingStacks[currentLevel] = /* @__PURE__ */ new Map();
|
|
9958
|
+
}
|
|
9959
|
+
const siblings = this.siblingStacks[currentLevel];
|
|
9960
|
+
const siblingKey = namespace ? `${namespace}:${tagName}` : tagName;
|
|
9961
|
+
const counter = siblings.get(siblingKey) || 0;
|
|
9962
|
+
let position = 0;
|
|
9963
|
+
for (const count of siblings.values()) {
|
|
9964
|
+
position += count;
|
|
9965
|
+
}
|
|
9966
|
+
siblings.set(siblingKey, counter + 1);
|
|
9967
|
+
const node = {
|
|
9968
|
+
tag: tagName,
|
|
9969
|
+
position,
|
|
9970
|
+
counter
|
|
9971
|
+
};
|
|
9972
|
+
if (namespace !== null && namespace !== void 0) {
|
|
9973
|
+
node.namespace = namespace;
|
|
9974
|
+
}
|
|
9975
|
+
if (attrValues !== null && attrValues !== void 0) {
|
|
9976
|
+
node.values = attrValues;
|
|
9977
|
+
}
|
|
9978
|
+
this.path.push(node);
|
|
9979
|
+
}
|
|
9980
|
+
/**
|
|
9981
|
+
* Pop the last tag from the path
|
|
9982
|
+
* @returns {Object|undefined} The popped node
|
|
9983
|
+
*/
|
|
9984
|
+
pop() {
|
|
9985
|
+
if (this.path.length === 0)
|
|
9986
|
+
return void 0;
|
|
9987
|
+
this._pathStringCache = null;
|
|
9988
|
+
this._frozenPathCache = null;
|
|
9989
|
+
this._frozenSiblingsCache = null;
|
|
9990
|
+
const node = this.path.pop();
|
|
9991
|
+
if (this.siblingStacks.length > this.path.length + 1) {
|
|
9992
|
+
this.siblingStacks.length = this.path.length + 1;
|
|
9993
|
+
}
|
|
9994
|
+
return node;
|
|
9995
|
+
}
|
|
9996
|
+
/**
|
|
9997
|
+
* Update current node's attribute values
|
|
9998
|
+
* Useful when attributes are parsed after push
|
|
9999
|
+
* @param {Object} attrValues - Attribute values
|
|
10000
|
+
*/
|
|
10001
|
+
updateCurrent(attrValues) {
|
|
10002
|
+
if (this.path.length > 0) {
|
|
10003
|
+
const current = this.path[this.path.length - 1];
|
|
10004
|
+
if (attrValues !== null && attrValues !== void 0) {
|
|
10005
|
+
current.values = attrValues;
|
|
10006
|
+
this._frozenPathCache = null;
|
|
10007
|
+
}
|
|
10008
|
+
}
|
|
10009
|
+
}
|
|
10010
|
+
/**
|
|
10011
|
+
* Get current tag name
|
|
10012
|
+
* @returns {string|undefined}
|
|
10013
|
+
*/
|
|
10014
|
+
getCurrentTag() {
|
|
10015
|
+
return this.path.length > 0 ? this.path[this.path.length - 1].tag : void 0;
|
|
10016
|
+
}
|
|
10017
|
+
/**
|
|
10018
|
+
* Get current namespace
|
|
10019
|
+
* @returns {string|undefined}
|
|
10020
|
+
*/
|
|
10021
|
+
getCurrentNamespace() {
|
|
10022
|
+
return this.path.length > 0 ? this.path[this.path.length - 1].namespace : void 0;
|
|
10023
|
+
}
|
|
10024
|
+
/**
|
|
10025
|
+
* Get current node's attribute value
|
|
10026
|
+
* @param {string} attrName - Attribute name
|
|
10027
|
+
* @returns {*} Attribute value or undefined
|
|
10028
|
+
*/
|
|
10029
|
+
getAttrValue(attrName) {
|
|
10030
|
+
if (this.path.length === 0)
|
|
10031
|
+
return void 0;
|
|
10032
|
+
const current = this.path[this.path.length - 1];
|
|
10033
|
+
return current.values?.[attrName];
|
|
10034
|
+
}
|
|
10035
|
+
/**
|
|
10036
|
+
* Check if current node has an attribute
|
|
10037
|
+
* @param {string} attrName - Attribute name
|
|
10038
|
+
* @returns {boolean}
|
|
10039
|
+
*/
|
|
10040
|
+
hasAttr(attrName) {
|
|
10041
|
+
if (this.path.length === 0)
|
|
10042
|
+
return false;
|
|
10043
|
+
const current = this.path[this.path.length - 1];
|
|
10044
|
+
return current.values !== void 0 && attrName in current.values;
|
|
10045
|
+
}
|
|
10046
|
+
/**
|
|
10047
|
+
* Get current node's sibling position (child index in parent)
|
|
10048
|
+
* @returns {number}
|
|
10049
|
+
*/
|
|
10050
|
+
getPosition() {
|
|
10051
|
+
if (this.path.length === 0)
|
|
10052
|
+
return -1;
|
|
10053
|
+
return this.path[this.path.length - 1].position ?? 0;
|
|
10054
|
+
}
|
|
10055
|
+
/**
|
|
10056
|
+
* Get current node's repeat counter (occurrence count of this tag name)
|
|
10057
|
+
* @returns {number}
|
|
10058
|
+
*/
|
|
10059
|
+
getCounter() {
|
|
10060
|
+
if (this.path.length === 0)
|
|
10061
|
+
return -1;
|
|
10062
|
+
return this.path[this.path.length - 1].counter ?? 0;
|
|
10063
|
+
}
|
|
10064
|
+
/**
|
|
10065
|
+
* Get current node's sibling index (alias for getPosition for backward compatibility)
|
|
10066
|
+
* @returns {number}
|
|
10067
|
+
* @deprecated Use getPosition() or getCounter() instead
|
|
10068
|
+
*/
|
|
10069
|
+
getIndex() {
|
|
10070
|
+
return this.getPosition();
|
|
10071
|
+
}
|
|
10072
|
+
/**
|
|
10073
|
+
* Get current path depth
|
|
10074
|
+
* @returns {number}
|
|
10075
|
+
*/
|
|
10076
|
+
getDepth() {
|
|
10077
|
+
return this.path.length;
|
|
10078
|
+
}
|
|
10079
|
+
/**
|
|
10080
|
+
* Get path as string
|
|
10081
|
+
* @param {string} separator - Optional separator (uses default if not provided)
|
|
10082
|
+
* @param {boolean} includeNamespace - Whether to include namespace in output (default: true)
|
|
10083
|
+
* @returns {string}
|
|
10084
|
+
*/
|
|
10085
|
+
toString(separator, includeNamespace = true) {
|
|
10086
|
+
const sep = separator || this.separator;
|
|
10087
|
+
const isDefault = sep === this.separator && includeNamespace === true;
|
|
10088
|
+
if (isDefault) {
|
|
10089
|
+
if (this._pathStringCache !== null && this._pathStringCache !== void 0) {
|
|
10090
|
+
return this._pathStringCache;
|
|
10091
|
+
}
|
|
10092
|
+
const result = this.path.map(
|
|
10093
|
+
(n) => includeNamespace && n.namespace ? `${n.namespace}:${n.tag}` : n.tag
|
|
10094
|
+
).join(sep);
|
|
10095
|
+
this._pathStringCache = result;
|
|
10096
|
+
return result;
|
|
10097
|
+
}
|
|
10098
|
+
return this.path.map(
|
|
10099
|
+
(n) => includeNamespace && n.namespace ? `${n.namespace}:${n.tag}` : n.tag
|
|
10100
|
+
).join(sep);
|
|
10101
|
+
}
|
|
10102
|
+
/**
|
|
10103
|
+
* Get path as array of tag names
|
|
10104
|
+
* @returns {string[]}
|
|
10105
|
+
*/
|
|
10106
|
+
toArray() {
|
|
10107
|
+
return this.path.map((n) => n.tag);
|
|
10108
|
+
}
|
|
10109
|
+
/**
|
|
10110
|
+
* Reset the path to empty
|
|
10111
|
+
*/
|
|
10112
|
+
reset() {
|
|
10113
|
+
this._pathStringCache = null;
|
|
10114
|
+
this._frozenPathCache = null;
|
|
10115
|
+
this._frozenSiblingsCache = null;
|
|
10116
|
+
this.path = [];
|
|
10117
|
+
this.siblingStacks = [];
|
|
10118
|
+
}
|
|
10119
|
+
/**
|
|
10120
|
+
* Match current path against an Expression
|
|
10121
|
+
* @param {Expression} expression - The expression to match against
|
|
10122
|
+
* @returns {boolean} True if current path matches the expression
|
|
10123
|
+
*/
|
|
10124
|
+
matches(expression) {
|
|
10125
|
+
const segments = expression.segments;
|
|
10126
|
+
if (segments.length === 0) {
|
|
10127
|
+
return false;
|
|
10128
|
+
}
|
|
10129
|
+
if (expression.hasDeepWildcard()) {
|
|
10130
|
+
return this._matchWithDeepWildcard(segments);
|
|
10131
|
+
}
|
|
10132
|
+
return this._matchSimple(segments);
|
|
10133
|
+
}
|
|
10134
|
+
/**
|
|
10135
|
+
* Match simple path (no deep wildcards)
|
|
10136
|
+
* @private
|
|
10137
|
+
*/
|
|
10138
|
+
_matchSimple(segments) {
|
|
10139
|
+
if (this.path.length !== segments.length) {
|
|
10140
|
+
return false;
|
|
10141
|
+
}
|
|
10142
|
+
for (let i = 0; i < segments.length; i++) {
|
|
10143
|
+
const segment = segments[i];
|
|
10144
|
+
const node = this.path[i];
|
|
10145
|
+
const isCurrentNode = i === this.path.length - 1;
|
|
10146
|
+
if (!this._matchSegment(segment, node, isCurrentNode)) {
|
|
10147
|
+
return false;
|
|
10148
|
+
}
|
|
10149
|
+
}
|
|
10150
|
+
return true;
|
|
10151
|
+
}
|
|
10152
|
+
/**
|
|
10153
|
+
* Match path with deep wildcards
|
|
10154
|
+
* @private
|
|
10155
|
+
*/
|
|
10156
|
+
_matchWithDeepWildcard(segments) {
|
|
10157
|
+
let pathIdx = this.path.length - 1;
|
|
10158
|
+
let segIdx = segments.length - 1;
|
|
10159
|
+
while (segIdx >= 0 && pathIdx >= 0) {
|
|
10160
|
+
const segment = segments[segIdx];
|
|
10161
|
+
if (segment.type === "deep-wildcard") {
|
|
10162
|
+
segIdx--;
|
|
10163
|
+
if (segIdx < 0) {
|
|
10164
|
+
return true;
|
|
10165
|
+
}
|
|
10166
|
+
const nextSeg = segments[segIdx];
|
|
10167
|
+
let found = false;
|
|
10168
|
+
for (let i = pathIdx; i >= 0; i--) {
|
|
10169
|
+
const isCurrentNode = i === this.path.length - 1;
|
|
10170
|
+
if (this._matchSegment(nextSeg, this.path[i], isCurrentNode)) {
|
|
10171
|
+
pathIdx = i - 1;
|
|
10172
|
+
segIdx--;
|
|
10173
|
+
found = true;
|
|
10174
|
+
break;
|
|
10175
|
+
}
|
|
10176
|
+
}
|
|
10177
|
+
if (!found) {
|
|
10178
|
+
return false;
|
|
10179
|
+
}
|
|
10180
|
+
} else {
|
|
10181
|
+
const isCurrentNode = pathIdx === this.path.length - 1;
|
|
10182
|
+
if (!this._matchSegment(segment, this.path[pathIdx], isCurrentNode)) {
|
|
10183
|
+
return false;
|
|
10184
|
+
}
|
|
10185
|
+
pathIdx--;
|
|
10186
|
+
segIdx--;
|
|
10187
|
+
}
|
|
10188
|
+
}
|
|
10189
|
+
return segIdx < 0;
|
|
10190
|
+
}
|
|
10191
|
+
/**
|
|
10192
|
+
* Match a single segment against a node
|
|
10193
|
+
* @private
|
|
10194
|
+
* @param {Object} segment - Segment from Expression
|
|
10195
|
+
* @param {Object} node - Node from path
|
|
10196
|
+
* @param {boolean} isCurrentNode - Whether this is the current (last) node
|
|
10197
|
+
* @returns {boolean}
|
|
10198
|
+
*/
|
|
10199
|
+
_matchSegment(segment, node, isCurrentNode) {
|
|
10200
|
+
if (segment.tag !== "*" && segment.tag !== node.tag) {
|
|
10201
|
+
return false;
|
|
10202
|
+
}
|
|
10203
|
+
if (segment.namespace !== void 0) {
|
|
10204
|
+
if (segment.namespace !== "*" && segment.namespace !== node.namespace) {
|
|
10205
|
+
return false;
|
|
10206
|
+
}
|
|
10207
|
+
}
|
|
10208
|
+
if (segment.attrName !== void 0) {
|
|
10209
|
+
if (!isCurrentNode) {
|
|
10210
|
+
return false;
|
|
10211
|
+
}
|
|
10212
|
+
if (!node.values || !(segment.attrName in node.values)) {
|
|
10213
|
+
return false;
|
|
10214
|
+
}
|
|
10215
|
+
if (segment.attrValue !== void 0) {
|
|
10216
|
+
const actualValue = node.values[segment.attrName];
|
|
10217
|
+
if (String(actualValue) !== String(segment.attrValue)) {
|
|
10218
|
+
return false;
|
|
10219
|
+
}
|
|
10220
|
+
}
|
|
10221
|
+
}
|
|
10222
|
+
if (segment.position !== void 0) {
|
|
10223
|
+
if (!isCurrentNode) {
|
|
10224
|
+
return false;
|
|
10225
|
+
}
|
|
10226
|
+
const counter = node.counter ?? 0;
|
|
10227
|
+
if (segment.position === "first" && counter !== 0) {
|
|
10228
|
+
return false;
|
|
10229
|
+
} else if (segment.position === "odd" && counter % 2 !== 1) {
|
|
10230
|
+
return false;
|
|
10231
|
+
} else if (segment.position === "even" && counter % 2 !== 0) {
|
|
10232
|
+
return false;
|
|
10233
|
+
} else if (segment.position === "nth") {
|
|
10234
|
+
if (counter !== segment.positionValue) {
|
|
10235
|
+
return false;
|
|
10236
|
+
}
|
|
10237
|
+
}
|
|
10238
|
+
}
|
|
10239
|
+
return true;
|
|
10240
|
+
}
|
|
10241
|
+
/**
|
|
10242
|
+
* Match any expression in the given set against the current path.
|
|
10243
|
+
* @param {ExpressionSet} exprSet - The set of expressions to match against.
|
|
10244
|
+
* @returns {boolean} - True if any expression in the set matches the current path, false otherwise.
|
|
10245
|
+
*/
|
|
10246
|
+
matchesAny(exprSet) {
|
|
10247
|
+
return exprSet.matchesAny(this);
|
|
10248
|
+
}
|
|
10249
|
+
/**
|
|
10250
|
+
* Create a snapshot of current state
|
|
10251
|
+
* @returns {Object} State snapshot
|
|
10252
|
+
*/
|
|
10253
|
+
snapshot() {
|
|
10254
|
+
return {
|
|
10255
|
+
path: this.path.map((node) => ({ ...node })),
|
|
10256
|
+
siblingStacks: this.siblingStacks.map((map2) => new Map(map2))
|
|
10257
|
+
};
|
|
10258
|
+
}
|
|
10259
|
+
/**
|
|
10260
|
+
* Restore state from snapshot
|
|
10261
|
+
* @param {Object} snapshot - State snapshot
|
|
10262
|
+
*/
|
|
10263
|
+
restore(snapshot) {
|
|
10264
|
+
this._pathStringCache = null;
|
|
10265
|
+
this._frozenPathCache = null;
|
|
10266
|
+
this._frozenSiblingsCache = null;
|
|
10267
|
+
this.path = snapshot.path.map((node) => ({ ...node }));
|
|
10268
|
+
this.siblingStacks = snapshot.siblingStacks.map((map2) => new Map(map2));
|
|
10269
|
+
}
|
|
10270
|
+
/**
|
|
10271
|
+
* Return a read-only view of this matcher.
|
|
10272
|
+
*
|
|
10273
|
+
* The returned object exposes all query/inspection methods but throws a
|
|
10274
|
+
* TypeError if any state-mutating method is called (`push`, `pop`, `reset`,
|
|
10275
|
+
* `updateCurrent`, `restore`). Property reads (e.g. `.path`, `.separator`)
|
|
10276
|
+
* are allowed but the returned arrays/objects are frozen so callers cannot
|
|
10277
|
+
* mutate internal state through them either.
|
|
10278
|
+
*
|
|
10279
|
+
* @returns {ReadOnlyMatcher} A proxy that forwards read operations and blocks writes.
|
|
10280
|
+
*
|
|
10281
|
+
* @example
|
|
10282
|
+
* const matcher = new Matcher();
|
|
10283
|
+
* matcher.push("root", {});
|
|
10284
|
+
*
|
|
10285
|
+
* const ro = matcher.readOnly();
|
|
10286
|
+
* ro.matches(expr); // ✓ works
|
|
10287
|
+
* ro.getCurrentTag(); // ✓ works
|
|
10288
|
+
* ro.push("child", {}); // ✗ throws TypeError
|
|
10289
|
+
* ro.reset(); // ✗ throws TypeError
|
|
10290
|
+
*/
|
|
10291
|
+
readOnly() {
|
|
10292
|
+
const self2 = this;
|
|
10293
|
+
return new Proxy(self2, {
|
|
10294
|
+
get(target, prop, receiver) {
|
|
10295
|
+
if (MUTATING_METHODS.has(prop)) {
|
|
10296
|
+
return () => {
|
|
10297
|
+
throw new TypeError(
|
|
10298
|
+
`Cannot call '${prop}' on a read-only Matcher. Obtain a writable instance to mutate state.`
|
|
10299
|
+
);
|
|
10300
|
+
};
|
|
10301
|
+
}
|
|
10302
|
+
if (prop === "path") {
|
|
10303
|
+
if (target._frozenPathCache === null) {
|
|
10304
|
+
target._frozenPathCache = Object.freeze(
|
|
10305
|
+
target.path.map((node) => Object.freeze({ ...node }))
|
|
10306
|
+
);
|
|
10307
|
+
}
|
|
10308
|
+
return target._frozenPathCache;
|
|
10309
|
+
}
|
|
10310
|
+
if (prop === "siblingStacks") {
|
|
10311
|
+
if (target._frozenSiblingsCache === null) {
|
|
10312
|
+
target._frozenSiblingsCache = Object.freeze(
|
|
10313
|
+
target.siblingStacks.map((map2) => Object.freeze(new Map(map2)))
|
|
10314
|
+
);
|
|
10315
|
+
}
|
|
10316
|
+
return target._frozenSiblingsCache;
|
|
10317
|
+
}
|
|
10318
|
+
const value = Reflect.get(target, prop, receiver);
|
|
10319
|
+
if (typeof value === "function") {
|
|
10320
|
+
return value.bind(target);
|
|
10321
|
+
}
|
|
10322
|
+
return value;
|
|
10323
|
+
},
|
|
10324
|
+
// Prevent any property assignment on the read-only view
|
|
10325
|
+
set(_target, prop) {
|
|
10326
|
+
throw new TypeError(
|
|
10327
|
+
`Cannot set property '${String(prop)}' on a read-only Matcher.`
|
|
10328
|
+
);
|
|
10329
|
+
},
|
|
10330
|
+
// Prevent property deletion
|
|
10331
|
+
deleteProperty(_target, prop) {
|
|
10332
|
+
throw new TypeError(
|
|
10333
|
+
`Cannot delete property '${String(prop)}' from a read-only Matcher.`
|
|
10334
|
+
);
|
|
10335
|
+
}
|
|
10336
|
+
});
|
|
10337
|
+
}
|
|
10338
|
+
};
|
|
10339
|
+
|
|
9501
10340
|
// ../../node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js
|
|
10341
|
+
function extractRawAttributes(prefixedAttrs, options) {
|
|
10342
|
+
if (!prefixedAttrs)
|
|
10343
|
+
return {};
|
|
10344
|
+
const attrs = options.attributesGroupName ? prefixedAttrs[options.attributesGroupName] : prefixedAttrs;
|
|
10345
|
+
if (!attrs)
|
|
10346
|
+
return {};
|
|
10347
|
+
const rawAttrs = {};
|
|
10348
|
+
for (const key in attrs) {
|
|
10349
|
+
if (key.startsWith(options.attributeNamePrefix)) {
|
|
10350
|
+
const rawName = key.substring(options.attributeNamePrefix.length);
|
|
10351
|
+
rawAttrs[rawName] = attrs[key];
|
|
10352
|
+
} else {
|
|
10353
|
+
rawAttrs[key] = attrs[key];
|
|
10354
|
+
}
|
|
10355
|
+
}
|
|
10356
|
+
return rawAttrs;
|
|
10357
|
+
}
|
|
10358
|
+
function extractNamespace(rawTagName) {
|
|
10359
|
+
if (!rawTagName || typeof rawTagName !== "string")
|
|
10360
|
+
return void 0;
|
|
10361
|
+
const colonIndex = rawTagName.indexOf(":");
|
|
10362
|
+
if (colonIndex !== -1 && colonIndex > 0) {
|
|
10363
|
+
const ns = rawTagName.substring(0, colonIndex);
|
|
10364
|
+
if (ns !== "xmlns") {
|
|
10365
|
+
return ns;
|
|
10366
|
+
}
|
|
10367
|
+
}
|
|
10368
|
+
return void 0;
|
|
10369
|
+
}
|
|
9502
10370
|
var OrderedObjParser = class {
|
|
9503
10371
|
constructor(options) {
|
|
9504
10372
|
this.options = options;
|
|
@@ -9542,19 +10410,21 @@ var __exports__ = (() => {
|
|
|
9542
10410
|
this.ignoreAttributesFn = getIgnoreAttributesFn(this.options.ignoreAttributes);
|
|
9543
10411
|
this.entityExpansionCount = 0;
|
|
9544
10412
|
this.currentExpandedLength = 0;
|
|
9545
|
-
|
|
9546
|
-
|
|
9547
|
-
|
|
9548
|
-
|
|
9549
|
-
|
|
9550
|
-
|
|
9551
|
-
|
|
9552
|
-
|
|
9553
|
-
|
|
9554
|
-
|
|
9555
|
-
|
|
10413
|
+
this.matcher = new Matcher();
|
|
10414
|
+
this.readonlyMatcher = this.matcher.readOnly();
|
|
10415
|
+
this.isCurrentNodeStopNode = false;
|
|
10416
|
+
this.stopNodeExpressionsSet = new ExpressionSet();
|
|
10417
|
+
const stopNodesOpts = this.options.stopNodes;
|
|
10418
|
+
if (stopNodesOpts && stopNodesOpts.length > 0) {
|
|
10419
|
+
for (let i = 0; i < stopNodesOpts.length; i++) {
|
|
10420
|
+
const stopNodeExp = stopNodesOpts[i];
|
|
10421
|
+
if (typeof stopNodeExp === "string") {
|
|
10422
|
+
this.stopNodeExpressionsSet.add(new Expression(stopNodeExp));
|
|
10423
|
+
} else if (stopNodeExp instanceof Expression) {
|
|
10424
|
+
this.stopNodeExpressionsSet.add(stopNodeExp);
|
|
9556
10425
|
}
|
|
9557
10426
|
}
|
|
10427
|
+
this.stopNodeExpressionsSet.seal();
|
|
9558
10428
|
}
|
|
9559
10429
|
}
|
|
9560
10430
|
};
|
|
@@ -9570,24 +10440,26 @@ var __exports__ = (() => {
|
|
|
9570
10440
|
}
|
|
9571
10441
|
}
|
|
9572
10442
|
function parseTextData(val, tagName, jPath, dontTrim, hasAttributes, isLeafNode, escapeEntities) {
|
|
10443
|
+
const options = this.options;
|
|
9573
10444
|
if (val !== void 0) {
|
|
9574
|
-
if (
|
|
10445
|
+
if (options.trimValues && !dontTrim) {
|
|
9575
10446
|
val = val.trim();
|
|
9576
10447
|
}
|
|
9577
10448
|
if (val.length > 0) {
|
|
9578
10449
|
if (!escapeEntities)
|
|
9579
10450
|
val = this.replaceEntitiesValue(val, tagName, jPath);
|
|
9580
|
-
const
|
|
10451
|
+
const jPathOrMatcher = options.jPath ? jPath.toString() : jPath;
|
|
10452
|
+
const newval = options.tagValueProcessor(tagName, val, jPathOrMatcher, hasAttributes, isLeafNode);
|
|
9581
10453
|
if (newval === null || newval === void 0) {
|
|
9582
10454
|
return val;
|
|
9583
10455
|
} else if (typeof newval !== typeof val || newval !== val) {
|
|
9584
10456
|
return newval;
|
|
9585
|
-
} else if (
|
|
9586
|
-
return parseValue(val,
|
|
10457
|
+
} else if (options.trimValues) {
|
|
10458
|
+
return parseValue(val, options.parseTagValue, options.numberParseOptions);
|
|
9587
10459
|
} else {
|
|
9588
10460
|
const trimmedVal = val.trim();
|
|
9589
10461
|
if (trimmedVal === val) {
|
|
9590
|
-
return parseValue(val,
|
|
10462
|
+
return parseValue(val, options.parseTagValue, options.numberParseOptions);
|
|
9591
10463
|
} else {
|
|
9592
10464
|
return val;
|
|
9593
10465
|
}
|
|
@@ -9610,51 +10482,64 @@ var __exports__ = (() => {
|
|
|
9610
10482
|
}
|
|
9611
10483
|
var attrsRegx = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm");
|
|
9612
10484
|
function buildAttributesMap(attrStr, jPath, tagName) {
|
|
9613
|
-
|
|
10485
|
+
const options = this.options;
|
|
10486
|
+
if (options.ignoreAttributes !== true && typeof attrStr === "string") {
|
|
9614
10487
|
const matches3 = getAllMatches(attrStr, attrsRegx);
|
|
9615
10488
|
const len5 = matches3.length;
|
|
9616
10489
|
const attrs = {};
|
|
10490
|
+
const processedVals = new Array(len5);
|
|
10491
|
+
let hasRawAttrs = false;
|
|
10492
|
+
const rawAttrsForMatcher = {};
|
|
10493
|
+
for (let i = 0; i < len5; i++) {
|
|
10494
|
+
const attrName = this.resolveNameSpace(matches3[i][1]);
|
|
10495
|
+
const oldVal = matches3[i][4];
|
|
10496
|
+
if (attrName.length && oldVal !== void 0) {
|
|
10497
|
+
let val = oldVal;
|
|
10498
|
+
if (options.trimValues)
|
|
10499
|
+
val = val.trim();
|
|
10500
|
+
val = this.replaceEntitiesValue(val, tagName, this.readonlyMatcher);
|
|
10501
|
+
processedVals[i] = val;
|
|
10502
|
+
rawAttrsForMatcher[attrName] = val;
|
|
10503
|
+
hasRawAttrs = true;
|
|
10504
|
+
}
|
|
10505
|
+
}
|
|
10506
|
+
if (hasRawAttrs && typeof jPath === "object" && jPath.updateCurrent) {
|
|
10507
|
+
jPath.updateCurrent(rawAttrsForMatcher);
|
|
10508
|
+
}
|
|
10509
|
+
const jPathStr = options.jPath ? jPath.toString() : this.readonlyMatcher;
|
|
10510
|
+
let hasAttrs = false;
|
|
9617
10511
|
for (let i = 0; i < len5; i++) {
|
|
9618
10512
|
const attrName = this.resolveNameSpace(matches3[i][1]);
|
|
9619
|
-
if (this.ignoreAttributesFn(attrName,
|
|
10513
|
+
if (this.ignoreAttributesFn(attrName, jPathStr))
|
|
9620
10514
|
continue;
|
|
9621
|
-
|
|
9622
|
-
let oldVal = matches3[i][4];
|
|
9623
|
-
let aName = this.options.attributeNamePrefix + attrName;
|
|
10515
|
+
let aName = options.attributeNamePrefix + attrName;
|
|
9624
10516
|
if (attrName.length) {
|
|
9625
|
-
if (
|
|
9626
|
-
aName =
|
|
10517
|
+
if (options.transformAttributeName) {
|
|
10518
|
+
aName = options.transformAttributeName(aName);
|
|
9627
10519
|
}
|
|
9628
|
-
|
|
9629
|
-
|
|
9630
|
-
|
|
9631
|
-
|
|
9632
|
-
oldVal = oldVal.trim();
|
|
9633
|
-
}
|
|
9634
|
-
oldVal = this.replaceEntitiesValue(oldVal, tagName, jPath);
|
|
9635
|
-
const newVal = this.options.attributeValueProcessor(attrName, oldVal, jPath);
|
|
10520
|
+
aName = sanitizeName(aName, options);
|
|
10521
|
+
if (matches3[i][4] !== void 0) {
|
|
10522
|
+
const oldVal = processedVals[i];
|
|
10523
|
+
const newVal = options.attributeValueProcessor(attrName, oldVal, jPathStr);
|
|
9636
10524
|
if (newVal === null || newVal === void 0) {
|
|
9637
10525
|
attrs[aName] = oldVal;
|
|
9638
10526
|
} else if (typeof newVal !== typeof oldVal || newVal !== oldVal) {
|
|
9639
10527
|
attrs[aName] = newVal;
|
|
9640
10528
|
} else {
|
|
9641
|
-
attrs[aName] = parseValue(
|
|
9642
|
-
oldVal,
|
|
9643
|
-
this.options.parseAttributeValue,
|
|
9644
|
-
this.options.numberParseOptions
|
|
9645
|
-
);
|
|
10529
|
+
attrs[aName] = parseValue(oldVal, options.parseAttributeValue, options.numberParseOptions);
|
|
9646
10530
|
}
|
|
9647
|
-
|
|
10531
|
+
hasAttrs = true;
|
|
10532
|
+
} else if (options.allowBooleanAttributes) {
|
|
9648
10533
|
attrs[aName] = true;
|
|
10534
|
+
hasAttrs = true;
|
|
9649
10535
|
}
|
|
9650
10536
|
}
|
|
9651
10537
|
}
|
|
9652
|
-
if (!
|
|
10538
|
+
if (!hasAttrs)
|
|
9653
10539
|
return;
|
|
9654
|
-
|
|
9655
|
-
if (this.options.attributesGroupName) {
|
|
10540
|
+
if (options.attributesGroupName) {
|
|
9656
10541
|
const attrCollection = {};
|
|
9657
|
-
attrCollection[
|
|
10542
|
+
attrCollection[options.attributesGroupName] = attrs;
|
|
9658
10543
|
return attrCollection;
|
|
9659
10544
|
}
|
|
9660
10545
|
return attrs;
|
|
@@ -9665,123 +10550,144 @@ var __exports__ = (() => {
|
|
|
9665
10550
|
const xmlObj = new XmlNode("!xml");
|
|
9666
10551
|
let currentNode = xmlObj;
|
|
9667
10552
|
let textData = "";
|
|
9668
|
-
|
|
10553
|
+
this.matcher.reset();
|
|
9669
10554
|
this.entityExpansionCount = 0;
|
|
9670
10555
|
this.currentExpandedLength = 0;
|
|
9671
|
-
|
|
9672
|
-
|
|
10556
|
+
this.docTypeEntitiesKeys = [];
|
|
10557
|
+
this.lastEntitiesKeys = Object.keys(this.lastEntities);
|
|
10558
|
+
this.htmlEntitiesKeys = this.options.htmlEntities ? Object.keys(this.htmlEntities) : [];
|
|
10559
|
+
const options = this.options;
|
|
10560
|
+
const docTypeReader = new DocTypeReader(options.processEntities);
|
|
10561
|
+
const xmlLen = xmlData.length;
|
|
10562
|
+
for (let i = 0; i < xmlLen; i++) {
|
|
9673
10563
|
const ch = xmlData[i];
|
|
9674
10564
|
if (ch === "<") {
|
|
9675
|
-
|
|
10565
|
+
const c1 = xmlData.charCodeAt(i + 1);
|
|
10566
|
+
if (c1 === 47) {
|
|
9676
10567
|
const closeIndex = findClosingIndex(xmlData, ">", i, "Closing Tag is not closed.");
|
|
9677
10568
|
let tagName = xmlData.substring(i + 2, closeIndex).trim();
|
|
9678
|
-
if (
|
|
10569
|
+
if (options.removeNSPrefix) {
|
|
9679
10570
|
const colonIndex = tagName.indexOf(":");
|
|
9680
10571
|
if (colonIndex !== -1) {
|
|
9681
10572
|
tagName = tagName.substr(colonIndex + 1);
|
|
9682
10573
|
}
|
|
9683
10574
|
}
|
|
9684
|
-
|
|
9685
|
-
tagName = this.options.transformTagName(tagName);
|
|
9686
|
-
}
|
|
10575
|
+
tagName = transformTagName(options.transformTagName, tagName, "", options).tagName;
|
|
9687
10576
|
if (currentNode) {
|
|
9688
|
-
textData = this.saveTextToParentTag(textData, currentNode,
|
|
10577
|
+
textData = this.saveTextToParentTag(textData, currentNode, this.readonlyMatcher);
|
|
9689
10578
|
}
|
|
9690
|
-
const lastTagName =
|
|
9691
|
-
if (tagName &&
|
|
10579
|
+
const lastTagName = this.matcher.getCurrentTag();
|
|
10580
|
+
if (tagName && options.unpairedTagsSet.has(tagName)) {
|
|
9692
10581
|
throw new Error(`Unpaired tag can not be used as closing tag: </${tagName}>`);
|
|
9693
10582
|
}
|
|
9694
|
-
|
|
9695
|
-
|
|
9696
|
-
propIndex = jPath.lastIndexOf(".", jPath.lastIndexOf(".") - 1);
|
|
10583
|
+
if (lastTagName && options.unpairedTagsSet.has(lastTagName)) {
|
|
10584
|
+
this.matcher.pop();
|
|
9697
10585
|
this.tagsNodeStack.pop();
|
|
9698
|
-
} else {
|
|
9699
|
-
propIndex = jPath.lastIndexOf(".");
|
|
9700
10586
|
}
|
|
9701
|
-
|
|
10587
|
+
this.matcher.pop();
|
|
10588
|
+
this.isCurrentNodeStopNode = false;
|
|
9702
10589
|
currentNode = this.tagsNodeStack.pop();
|
|
9703
10590
|
textData = "";
|
|
9704
10591
|
i = closeIndex;
|
|
9705
|
-
} else if (
|
|
10592
|
+
} else if (c1 === 63) {
|
|
9706
10593
|
let tagData = readTagExp(xmlData, i, false, "?>");
|
|
9707
10594
|
if (!tagData)
|
|
9708
10595
|
throw new Error("Pi Tag is not closed.");
|
|
9709
|
-
textData = this.saveTextToParentTag(textData, currentNode,
|
|
9710
|
-
if (
|
|
10596
|
+
textData = this.saveTextToParentTag(textData, currentNode, this.readonlyMatcher);
|
|
10597
|
+
if (options.ignoreDeclaration && tagData.tagName === "?xml" || options.ignorePiTags) {
|
|
9711
10598
|
} else {
|
|
9712
10599
|
const childNode = new XmlNode(tagData.tagName);
|
|
9713
|
-
childNode.add(
|
|
10600
|
+
childNode.add(options.textNodeName, "");
|
|
9714
10601
|
if (tagData.tagName !== tagData.tagExp && tagData.attrExpPresent) {
|
|
9715
|
-
childNode[":@"] = this.buildAttributesMap(tagData.tagExp,
|
|
10602
|
+
childNode[":@"] = this.buildAttributesMap(tagData.tagExp, this.matcher, tagData.tagName);
|
|
9716
10603
|
}
|
|
9717
|
-
this.addChild(currentNode, childNode,
|
|
10604
|
+
this.addChild(currentNode, childNode, this.readonlyMatcher, i);
|
|
9718
10605
|
}
|
|
9719
10606
|
i = tagData.closeIndex + 1;
|
|
9720
|
-
} else if (xmlData.
|
|
10607
|
+
} else if (c1 === 33 && xmlData.charCodeAt(i + 2) === 45 && xmlData.charCodeAt(i + 3) === 45) {
|
|
9721
10608
|
const endIndex = findClosingIndex(xmlData, "-->", i + 4, "Comment is not closed.");
|
|
9722
|
-
if (
|
|
10609
|
+
if (options.commentPropName) {
|
|
9723
10610
|
const comment = xmlData.substring(i + 4, endIndex - 2);
|
|
9724
|
-
textData = this.saveTextToParentTag(textData, currentNode,
|
|
9725
|
-
currentNode.add(
|
|
10611
|
+
textData = this.saveTextToParentTag(textData, currentNode, this.readonlyMatcher);
|
|
10612
|
+
currentNode.add(options.commentPropName, [{ [options.textNodeName]: comment }]);
|
|
9726
10613
|
}
|
|
9727
10614
|
i = endIndex;
|
|
9728
|
-
} else if (xmlData.
|
|
10615
|
+
} else if (c1 === 33 && xmlData.charCodeAt(i + 2) === 68) {
|
|
9729
10616
|
const result = docTypeReader.readDocType(xmlData, i);
|
|
9730
10617
|
this.docTypeEntities = result.entities;
|
|
10618
|
+
this.docTypeEntitiesKeys = Object.keys(this.docTypeEntities) || [];
|
|
9731
10619
|
i = result.i;
|
|
9732
|
-
} else if (xmlData.
|
|
10620
|
+
} else if (c1 === 33 && xmlData.charCodeAt(i + 2) === 91) {
|
|
9733
10621
|
const closeIndex = findClosingIndex(xmlData, "]]>", i, "CDATA is not closed.") - 2;
|
|
9734
10622
|
const tagExp = xmlData.substring(i + 9, closeIndex);
|
|
9735
|
-
textData = this.saveTextToParentTag(textData, currentNode,
|
|
9736
|
-
let val = this.parseTextData(tagExp, currentNode.tagname,
|
|
10623
|
+
textData = this.saveTextToParentTag(textData, currentNode, this.readonlyMatcher);
|
|
10624
|
+
let val = this.parseTextData(tagExp, currentNode.tagname, this.readonlyMatcher, true, false, true, true);
|
|
9737
10625
|
if (val == void 0)
|
|
9738
10626
|
val = "";
|
|
9739
|
-
if (
|
|
9740
|
-
currentNode.add(
|
|
10627
|
+
if (options.cdataPropName) {
|
|
10628
|
+
currentNode.add(options.cdataPropName, [{ [options.textNodeName]: tagExp }]);
|
|
9741
10629
|
} else {
|
|
9742
|
-
currentNode.add(
|
|
10630
|
+
currentNode.add(options.textNodeName, val);
|
|
9743
10631
|
}
|
|
9744
10632
|
i = closeIndex + 2;
|
|
9745
10633
|
} else {
|
|
9746
|
-
let result = readTagExp(xmlData, i,
|
|
10634
|
+
let result = readTagExp(xmlData, i, options.removeNSPrefix);
|
|
10635
|
+
if (!result) {
|
|
10636
|
+
const context = xmlData.substring(Math.max(0, i - 50), Math.min(xmlLen, i + 50));
|
|
10637
|
+
throw new Error(`readTagExp returned undefined at position ${i}. Context: "${context}"`);
|
|
10638
|
+
}
|
|
9747
10639
|
let tagName = result.tagName;
|
|
9748
10640
|
const rawTagName = result.rawTagName;
|
|
9749
10641
|
let tagExp = result.tagExp;
|
|
9750
10642
|
let attrExpPresent = result.attrExpPresent;
|
|
9751
10643
|
let closeIndex = result.closeIndex;
|
|
9752
|
-
|
|
9753
|
-
|
|
9754
|
-
|
|
9755
|
-
tagExp = newTagName;
|
|
9756
|
-
}
|
|
9757
|
-
tagName = newTagName;
|
|
10644
|
+
({ tagName, tagExp } = transformTagName(options.transformTagName, tagName, tagExp, options));
|
|
10645
|
+
if (options.strictReservedNames && (tagName === options.commentPropName || tagName === options.cdataPropName || tagName === options.textNodeName || tagName === options.attributesGroupName)) {
|
|
10646
|
+
throw new Error(`Invalid tag name: ${tagName}`);
|
|
9758
10647
|
}
|
|
9759
10648
|
if (currentNode && textData) {
|
|
9760
10649
|
if (currentNode.tagname !== "!xml") {
|
|
9761
|
-
textData = this.saveTextToParentTag(textData, currentNode,
|
|
10650
|
+
textData = this.saveTextToParentTag(textData, currentNode, this.readonlyMatcher, false);
|
|
9762
10651
|
}
|
|
9763
10652
|
}
|
|
9764
10653
|
const lastTag = currentNode;
|
|
9765
|
-
if (lastTag &&
|
|
10654
|
+
if (lastTag && options.unpairedTagsSet.has(lastTag.tagname)) {
|
|
9766
10655
|
currentNode = this.tagsNodeStack.pop();
|
|
9767
|
-
|
|
10656
|
+
this.matcher.pop();
|
|
10657
|
+
}
|
|
10658
|
+
let isSelfClosing = false;
|
|
10659
|
+
if (tagExp.length > 0 && tagExp.lastIndexOf("/") === tagExp.length - 1) {
|
|
10660
|
+
isSelfClosing = true;
|
|
10661
|
+
if (tagName[tagName.length - 1] === "/") {
|
|
10662
|
+
tagName = tagName.substr(0, tagName.length - 1);
|
|
10663
|
+
tagExp = tagName;
|
|
10664
|
+
} else {
|
|
10665
|
+
tagExp = tagExp.substr(0, tagExp.length - 1);
|
|
10666
|
+
}
|
|
10667
|
+
attrExpPresent = tagName !== tagExp;
|
|
9768
10668
|
}
|
|
10669
|
+
let prefixedAttrs = null;
|
|
10670
|
+
let rawAttrs = {};
|
|
10671
|
+
let namespace = void 0;
|
|
10672
|
+
namespace = extractNamespace(rawTagName);
|
|
9769
10673
|
if (tagName !== xmlObj.tagname) {
|
|
9770
|
-
|
|
10674
|
+
this.matcher.push(tagName, {}, namespace);
|
|
10675
|
+
}
|
|
10676
|
+
if (tagName !== tagExp && attrExpPresent) {
|
|
10677
|
+
prefixedAttrs = this.buildAttributesMap(tagExp, this.matcher, tagName);
|
|
10678
|
+
if (prefixedAttrs) {
|
|
10679
|
+
rawAttrs = extractRawAttributes(prefixedAttrs, options);
|
|
10680
|
+
}
|
|
10681
|
+
}
|
|
10682
|
+
if (tagName !== xmlObj.tagname) {
|
|
10683
|
+
this.isCurrentNodeStopNode = this.isItStopNode();
|
|
9771
10684
|
}
|
|
9772
10685
|
const startIndex = i;
|
|
9773
|
-
if (this.
|
|
10686
|
+
if (this.isCurrentNodeStopNode) {
|
|
9774
10687
|
let tagContent = "";
|
|
9775
|
-
if (
|
|
9776
|
-
if (tagName[tagName.length - 1] === "/") {
|
|
9777
|
-
tagName = tagName.substr(0, tagName.length - 1);
|
|
9778
|
-
jPath = jPath.substr(0, jPath.length - 1);
|
|
9779
|
-
tagExp = tagName;
|
|
9780
|
-
} else {
|
|
9781
|
-
tagExp = tagExp.substr(0, tagExp.length - 1);
|
|
9782
|
-
}
|
|
10688
|
+
if (isSelfClosing) {
|
|
9783
10689
|
i = result.closeIndex;
|
|
9784
|
-
} else if (
|
|
10690
|
+
} else if (options.unpairedTagsSet.has(tagName)) {
|
|
9785
10691
|
i = result.closeIndex;
|
|
9786
10692
|
} else {
|
|
9787
10693
|
const result2 = this.readStopNodeData(xmlData, rawTagName, closeIndex + 1);
|
|
@@ -9791,44 +10697,43 @@ var __exports__ = (() => {
|
|
|
9791
10697
|
tagContent = result2.tagContent;
|
|
9792
10698
|
}
|
|
9793
10699
|
const childNode = new XmlNode(tagName);
|
|
9794
|
-
if (
|
|
9795
|
-
childNode[":@"] =
|
|
10700
|
+
if (prefixedAttrs) {
|
|
10701
|
+
childNode[":@"] = prefixedAttrs;
|
|
9796
10702
|
}
|
|
9797
|
-
|
|
9798
|
-
|
|
9799
|
-
|
|
9800
|
-
|
|
9801
|
-
childNode.add(this.options.textNodeName, tagContent);
|
|
9802
|
-
this.addChild(currentNode, childNode, jPath, startIndex);
|
|
10703
|
+
childNode.add(options.textNodeName, tagContent);
|
|
10704
|
+
this.matcher.pop();
|
|
10705
|
+
this.isCurrentNodeStopNode = false;
|
|
10706
|
+
this.addChild(currentNode, childNode, this.readonlyMatcher, startIndex);
|
|
9803
10707
|
} else {
|
|
9804
|
-
if (
|
|
9805
|
-
|
|
9806
|
-
|
|
9807
|
-
|
|
9808
|
-
|
|
9809
|
-
} else {
|
|
9810
|
-
tagExp = tagExp.substr(0, tagExp.length - 1);
|
|
9811
|
-
}
|
|
9812
|
-
if (this.options.transformTagName) {
|
|
9813
|
-
const newTagName = this.options.transformTagName(tagName);
|
|
9814
|
-
if (tagExp === tagName) {
|
|
9815
|
-
tagExp = newTagName;
|
|
9816
|
-
}
|
|
9817
|
-
tagName = newTagName;
|
|
10708
|
+
if (isSelfClosing) {
|
|
10709
|
+
({ tagName, tagExp } = transformTagName(options.transformTagName, tagName, tagExp, options));
|
|
10710
|
+
const childNode = new XmlNode(tagName);
|
|
10711
|
+
if (prefixedAttrs) {
|
|
10712
|
+
childNode[":@"] = prefixedAttrs;
|
|
9818
10713
|
}
|
|
10714
|
+
this.addChild(currentNode, childNode, this.readonlyMatcher, startIndex);
|
|
10715
|
+
this.matcher.pop();
|
|
10716
|
+
this.isCurrentNodeStopNode = false;
|
|
10717
|
+
} else if (options.unpairedTagsSet.has(tagName)) {
|
|
9819
10718
|
const childNode = new XmlNode(tagName);
|
|
9820
|
-
if (
|
|
9821
|
-
childNode[":@"] =
|
|
10719
|
+
if (prefixedAttrs) {
|
|
10720
|
+
childNode[":@"] = prefixedAttrs;
|
|
9822
10721
|
}
|
|
9823
|
-
this.addChild(currentNode, childNode,
|
|
9824
|
-
|
|
10722
|
+
this.addChild(currentNode, childNode, this.readonlyMatcher, startIndex);
|
|
10723
|
+
this.matcher.pop();
|
|
10724
|
+
this.isCurrentNodeStopNode = false;
|
|
10725
|
+
i = result.closeIndex;
|
|
10726
|
+
continue;
|
|
9825
10727
|
} else {
|
|
9826
10728
|
const childNode = new XmlNode(tagName);
|
|
10729
|
+
if (this.tagsNodeStack.length > options.maxNestedTags) {
|
|
10730
|
+
throw new Error("Maximum nested tags exceeded");
|
|
10731
|
+
}
|
|
9827
10732
|
this.tagsNodeStack.push(currentNode);
|
|
9828
|
-
if (
|
|
9829
|
-
childNode[":@"] =
|
|
10733
|
+
if (prefixedAttrs) {
|
|
10734
|
+
childNode[":@"] = prefixedAttrs;
|
|
9830
10735
|
}
|
|
9831
|
-
this.addChild(currentNode, childNode,
|
|
10736
|
+
this.addChild(currentNode, childNode, this.readonlyMatcher, startIndex);
|
|
9832
10737
|
currentNode = childNode;
|
|
9833
10738
|
}
|
|
9834
10739
|
textData = "";
|
|
@@ -9841,10 +10746,11 @@ var __exports__ = (() => {
|
|
|
9841
10746
|
}
|
|
9842
10747
|
return xmlObj.child;
|
|
9843
10748
|
};
|
|
9844
|
-
function addChild(currentNode, childNode,
|
|
10749
|
+
function addChild(currentNode, childNode, matcher, startIndex) {
|
|
9845
10750
|
if (!this.options.captureMetaData)
|
|
9846
10751
|
startIndex = void 0;
|
|
9847
|
-
const
|
|
10752
|
+
const jPathOrMatcher = this.options.jPath ? matcher.toString() : matcher;
|
|
10753
|
+
const result = this.options.updateTag(childNode.tagname, jPathOrMatcher, childNode[":@"]);
|
|
9848
10754
|
if (result === false) {
|
|
9849
10755
|
} else if (typeof result === "string") {
|
|
9850
10756
|
childNode.tagname = result;
|
|
@@ -9853,25 +10759,25 @@ var __exports__ = (() => {
|
|
|
9853
10759
|
currentNode.addChild(childNode, startIndex);
|
|
9854
10760
|
}
|
|
9855
10761
|
}
|
|
9856
|
-
|
|
9857
|
-
if (val.indexOf("&") === -1) {
|
|
9858
|
-
return val;
|
|
9859
|
-
}
|
|
10762
|
+
function replaceEntitiesValue(val, tagName, jPath) {
|
|
9860
10763
|
const entityConfig = this.options.processEntities;
|
|
9861
|
-
if (!entityConfig.enabled) {
|
|
10764
|
+
if (!entityConfig || !entityConfig.enabled) {
|
|
9862
10765
|
return val;
|
|
9863
10766
|
}
|
|
9864
10767
|
if (entityConfig.allowedTags) {
|
|
9865
|
-
|
|
10768
|
+
const jPathOrMatcher = this.options.jPath ? jPath.toString() : jPath;
|
|
10769
|
+
const allowed = Array.isArray(entityConfig.allowedTags) ? entityConfig.allowedTags.includes(tagName) : entityConfig.allowedTags(tagName, jPathOrMatcher);
|
|
10770
|
+
if (!allowed) {
|
|
9866
10771
|
return val;
|
|
9867
10772
|
}
|
|
9868
10773
|
}
|
|
9869
10774
|
if (entityConfig.tagFilter) {
|
|
9870
|
-
|
|
10775
|
+
const jPathOrMatcher = this.options.jPath ? jPath.toString() : jPath;
|
|
10776
|
+
if (!entityConfig.tagFilter(tagName, jPathOrMatcher)) {
|
|
9871
10777
|
return val;
|
|
9872
10778
|
}
|
|
9873
10779
|
}
|
|
9874
|
-
for (
|
|
10780
|
+
for (const entityName of this.docTypeEntitiesKeys) {
|
|
9875
10781
|
const entity = this.docTypeEntities[entityName];
|
|
9876
10782
|
const matches3 = val.match(entity.regx);
|
|
9877
10783
|
if (matches3) {
|
|
@@ -9895,74 +10801,86 @@ var __exports__ = (() => {
|
|
|
9895
10801
|
}
|
|
9896
10802
|
if (val.indexOf("&") === -1)
|
|
9897
10803
|
return val;
|
|
9898
|
-
for (
|
|
10804
|
+
for (const entityName of this.lastEntitiesKeys) {
|
|
9899
10805
|
const entity = this.lastEntities[entityName];
|
|
10806
|
+
const matches3 = val.match(entity.regex);
|
|
10807
|
+
if (matches3) {
|
|
10808
|
+
this.entityExpansionCount += matches3.length;
|
|
10809
|
+
if (entityConfig.maxTotalExpansions && this.entityExpansionCount > entityConfig.maxTotalExpansions) {
|
|
10810
|
+
throw new Error(
|
|
10811
|
+
`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${entityConfig.maxTotalExpansions}`
|
|
10812
|
+
);
|
|
10813
|
+
}
|
|
10814
|
+
}
|
|
9900
10815
|
val = val.replace(entity.regex, entity.val);
|
|
9901
10816
|
}
|
|
9902
10817
|
if (val.indexOf("&") === -1)
|
|
9903
10818
|
return val;
|
|
9904
|
-
|
|
9905
|
-
|
|
9906
|
-
|
|
9907
|
-
|
|
10819
|
+
for (const entityName of this.htmlEntitiesKeys) {
|
|
10820
|
+
const entity = this.htmlEntities[entityName];
|
|
10821
|
+
const matches3 = val.match(entity.regex);
|
|
10822
|
+
if (matches3) {
|
|
10823
|
+
this.entityExpansionCount += matches3.length;
|
|
10824
|
+
if (entityConfig.maxTotalExpansions && this.entityExpansionCount > entityConfig.maxTotalExpansions) {
|
|
10825
|
+
throw new Error(
|
|
10826
|
+
`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${entityConfig.maxTotalExpansions}`
|
|
10827
|
+
);
|
|
10828
|
+
}
|
|
9908
10829
|
}
|
|
10830
|
+
val = val.replace(entity.regex, entity.val);
|
|
9909
10831
|
}
|
|
9910
10832
|
val = val.replace(this.ampEntity.regex, this.ampEntity.val);
|
|
9911
10833
|
return val;
|
|
9912
|
-
}
|
|
9913
|
-
function saveTextToParentTag(textData,
|
|
10834
|
+
}
|
|
10835
|
+
function saveTextToParentTag(textData, parentNode, matcher, isLeafNode) {
|
|
9914
10836
|
if (textData) {
|
|
9915
10837
|
if (isLeafNode === void 0)
|
|
9916
|
-
isLeafNode =
|
|
10838
|
+
isLeafNode = parentNode.child.length === 0;
|
|
9917
10839
|
textData = this.parseTextData(
|
|
9918
10840
|
textData,
|
|
9919
|
-
|
|
9920
|
-
|
|
10841
|
+
parentNode.tagname,
|
|
10842
|
+
matcher,
|
|
9921
10843
|
false,
|
|
9922
|
-
|
|
10844
|
+
parentNode[":@"] ? Object.keys(parentNode[":@"]).length !== 0 : false,
|
|
9923
10845
|
isLeafNode
|
|
9924
10846
|
);
|
|
9925
10847
|
if (textData !== void 0 && textData !== "")
|
|
9926
|
-
|
|
10848
|
+
parentNode.add(this.options.textNodeName, textData);
|
|
9927
10849
|
textData = "";
|
|
9928
10850
|
}
|
|
9929
10851
|
return textData;
|
|
9930
10852
|
}
|
|
9931
|
-
function isItStopNode(
|
|
9932
|
-
if (
|
|
9933
|
-
return
|
|
9934
|
-
|
|
9935
|
-
return true;
|
|
9936
|
-
return false;
|
|
10853
|
+
function isItStopNode() {
|
|
10854
|
+
if (this.stopNodeExpressionsSet.size === 0)
|
|
10855
|
+
return false;
|
|
10856
|
+
return this.matcher.matchesAny(this.stopNodeExpressionsSet);
|
|
9937
10857
|
}
|
|
9938
10858
|
function tagExpWithClosingIndex(xmlData, i, closingChar = ">") {
|
|
9939
|
-
let attrBoundary;
|
|
9940
|
-
|
|
9941
|
-
|
|
9942
|
-
|
|
10859
|
+
let attrBoundary = 0;
|
|
10860
|
+
const chars = [];
|
|
10861
|
+
const len5 = xmlData.length;
|
|
10862
|
+
const closeCode0 = closingChar.charCodeAt(0);
|
|
10863
|
+
const closeCode1 = closingChar.length > 1 ? closingChar.charCodeAt(1) : -1;
|
|
10864
|
+
for (let index = i; index < len5; index++) {
|
|
10865
|
+
const code = xmlData.charCodeAt(index);
|
|
9943
10866
|
if (attrBoundary) {
|
|
9944
|
-
if (
|
|
9945
|
-
attrBoundary =
|
|
9946
|
-
} else if (
|
|
9947
|
-
attrBoundary =
|
|
9948
|
-
} else if (
|
|
9949
|
-
if (
|
|
9950
|
-
if (xmlData
|
|
9951
|
-
return {
|
|
9952
|
-
data: tagExp,
|
|
9953
|
-
index
|
|
9954
|
-
};
|
|
10867
|
+
if (code === attrBoundary)
|
|
10868
|
+
attrBoundary = 0;
|
|
10869
|
+
} else if (code === 34 || code === 39) {
|
|
10870
|
+
attrBoundary = code;
|
|
10871
|
+
} else if (code === closeCode0) {
|
|
10872
|
+
if (closeCode1 !== -1) {
|
|
10873
|
+
if (xmlData.charCodeAt(index + 1) === closeCode1) {
|
|
10874
|
+
return { data: String.fromCharCode(...chars), index };
|
|
9955
10875
|
}
|
|
9956
10876
|
} else {
|
|
9957
|
-
return {
|
|
9958
|
-
data: tagExp,
|
|
9959
|
-
index
|
|
9960
|
-
};
|
|
10877
|
+
return { data: String.fromCharCode(...chars), index };
|
|
9961
10878
|
}
|
|
9962
|
-
} else if (
|
|
9963
|
-
|
|
10879
|
+
} else if (code === 9) {
|
|
10880
|
+
chars.push(32);
|
|
10881
|
+
continue;
|
|
9964
10882
|
}
|
|
9965
|
-
|
|
10883
|
+
chars.push(code);
|
|
9966
10884
|
}
|
|
9967
10885
|
}
|
|
9968
10886
|
function findClosingIndex(xmlData, str7, i, errMsg) {
|
|
@@ -9973,6 +10891,12 @@ var __exports__ = (() => {
|
|
|
9973
10891
|
return closingIndex + str7.length - 1;
|
|
9974
10892
|
}
|
|
9975
10893
|
}
|
|
10894
|
+
function findClosingChar(xmlData, char, i, errMsg) {
|
|
10895
|
+
const closingIndex = xmlData.indexOf(char, i);
|
|
10896
|
+
if (closingIndex === -1)
|
|
10897
|
+
throw new Error(errMsg);
|
|
10898
|
+
return closingIndex;
|
|
10899
|
+
}
|
|
9976
10900
|
function readTagExp(xmlData, i, removeNSPrefix, closingChar = ">") {
|
|
9977
10901
|
const result = tagExpWithClosingIndex(xmlData, i + 1, closingChar);
|
|
9978
10902
|
if (!result)
|
|
@@ -10005,10 +10929,12 @@ var __exports__ = (() => {
|
|
|
10005
10929
|
function readStopNodeData(xmlData, tagName, i) {
|
|
10006
10930
|
const startIndex = i;
|
|
10007
10931
|
let openTagCount = 1;
|
|
10008
|
-
|
|
10932
|
+
const xmllen = xmlData.length;
|
|
10933
|
+
for (; i < xmllen; i++) {
|
|
10009
10934
|
if (xmlData[i] === "<") {
|
|
10010
|
-
|
|
10011
|
-
|
|
10935
|
+
const c1 = xmlData.charCodeAt(i + 1);
|
|
10936
|
+
if (c1 === 47) {
|
|
10937
|
+
const closeIndex = findClosingChar(xmlData, ">", i, `${tagName} is not closed`);
|
|
10012
10938
|
let closeTagName = xmlData.substring(i + 2, closeIndex).trim();
|
|
10013
10939
|
if (closeTagName === tagName) {
|
|
10014
10940
|
openTagCount--;
|
|
@@ -10020,13 +10946,13 @@ var __exports__ = (() => {
|
|
|
10020
10946
|
}
|
|
10021
10947
|
}
|
|
10022
10948
|
i = closeIndex;
|
|
10023
|
-
} else if (
|
|
10949
|
+
} else if (c1 === 63) {
|
|
10024
10950
|
const closeIndex = findClosingIndex(xmlData, "?>", i + 1, "StopNode is not closed.");
|
|
10025
10951
|
i = closeIndex;
|
|
10026
|
-
} else if (xmlData.
|
|
10952
|
+
} else if (c1 === 33 && xmlData.charCodeAt(i + 2) === 45 && xmlData.charCodeAt(i + 3) === 45) {
|
|
10027
10953
|
const closeIndex = findClosingIndex(xmlData, "-->", i + 3, "StopNode is not closed.");
|
|
10028
10954
|
i = closeIndex;
|
|
10029
|
-
} else if (xmlData.
|
|
10955
|
+
} else if (c1 === 33 && xmlData.charCodeAt(i + 2) === 91) {
|
|
10030
10956
|
const closeIndex = findClosingIndex(xmlData, "]]>", i, "StopNode is not closed.") - 2;
|
|
10031
10957
|
i = closeIndex;
|
|
10032
10958
|
} else {
|
|
@@ -10067,23 +10993,60 @@ var __exports__ = (() => {
|
|
|
10067
10993
|
return prefix + str7 + ";";
|
|
10068
10994
|
}
|
|
10069
10995
|
}
|
|
10996
|
+
function transformTagName(fn, tagName, tagExp, options) {
|
|
10997
|
+
if (fn) {
|
|
10998
|
+
const newTagName = fn(tagName);
|
|
10999
|
+
if (tagExp === tagName) {
|
|
11000
|
+
tagExp = newTagName;
|
|
11001
|
+
}
|
|
11002
|
+
tagName = newTagName;
|
|
11003
|
+
}
|
|
11004
|
+
tagName = sanitizeName(tagName, options);
|
|
11005
|
+
return { tagName, tagExp };
|
|
11006
|
+
}
|
|
11007
|
+
function sanitizeName(name12, options) {
|
|
11008
|
+
if (criticalProperties.includes(name12)) {
|
|
11009
|
+
throw new Error(`[SECURITY] Invalid name: "${name12}" is a reserved JavaScript keyword that could cause prototype pollution`);
|
|
11010
|
+
} else if (DANGEROUS_PROPERTY_NAMES.includes(name12)) {
|
|
11011
|
+
return options.onDangerousProperty(name12);
|
|
11012
|
+
}
|
|
11013
|
+
return name12;
|
|
11014
|
+
}
|
|
10070
11015
|
|
|
10071
11016
|
// ../../node_modules/fast-xml-parser/src/xmlparser/node2json.js
|
|
10072
11017
|
var METADATA_SYMBOL2 = XmlNode.getMetaDataSymbol();
|
|
10073
|
-
function
|
|
10074
|
-
|
|
11018
|
+
function stripAttributePrefix(attrs, prefix) {
|
|
11019
|
+
if (!attrs || typeof attrs !== "object")
|
|
11020
|
+
return {};
|
|
11021
|
+
if (!prefix)
|
|
11022
|
+
return attrs;
|
|
11023
|
+
const rawAttrs = {};
|
|
11024
|
+
for (const key in attrs) {
|
|
11025
|
+
if (key.startsWith(prefix)) {
|
|
11026
|
+
const rawName = key.substring(prefix.length);
|
|
11027
|
+
rawAttrs[rawName] = attrs[key];
|
|
11028
|
+
} else {
|
|
11029
|
+
rawAttrs[key] = attrs[key];
|
|
11030
|
+
}
|
|
11031
|
+
}
|
|
11032
|
+
return rawAttrs;
|
|
11033
|
+
}
|
|
11034
|
+
function prettify(node, options, matcher, readonlyMatcher) {
|
|
11035
|
+
return compress(node, options, matcher, readonlyMatcher);
|
|
10075
11036
|
}
|
|
10076
|
-
function compress(arr, options,
|
|
11037
|
+
function compress(arr, options, matcher, readonlyMatcher) {
|
|
10077
11038
|
let text;
|
|
10078
11039
|
const compressedObj = {};
|
|
10079
11040
|
for (let i = 0; i < arr.length; i++) {
|
|
10080
11041
|
const tagObj = arr[i];
|
|
10081
11042
|
const property = propName(tagObj);
|
|
10082
|
-
|
|
10083
|
-
|
|
10084
|
-
|
|
10085
|
-
|
|
10086
|
-
|
|
11043
|
+
if (property !== void 0 && property !== options.textNodeName) {
|
|
11044
|
+
const rawAttrs = stripAttributePrefix(
|
|
11045
|
+
tagObj[":@"] || {},
|
|
11046
|
+
options.attributeNamePrefix
|
|
11047
|
+
);
|
|
11048
|
+
matcher.push(property, rawAttrs);
|
|
11049
|
+
}
|
|
10087
11050
|
if (property === options.textNodeName) {
|
|
10088
11051
|
if (text === void 0)
|
|
10089
11052
|
text = tagObj[property];
|
|
@@ -10092,13 +11055,10 @@ var __exports__ = (() => {
|
|
|
10092
11055
|
} else if (property === void 0) {
|
|
10093
11056
|
continue;
|
|
10094
11057
|
} else if (tagObj[property]) {
|
|
10095
|
-
let val = compress(tagObj[property], options,
|
|
11058
|
+
let val = compress(tagObj[property], options, matcher, readonlyMatcher);
|
|
10096
11059
|
const isLeaf = isLeafTag(val, options);
|
|
10097
|
-
if (tagObj[METADATA_SYMBOL2] !== void 0) {
|
|
10098
|
-
val[METADATA_SYMBOL2] = tagObj[METADATA_SYMBOL2];
|
|
10099
|
-
}
|
|
10100
11060
|
if (tagObj[":@"]) {
|
|
10101
|
-
assignAttributes(val, tagObj[":@"],
|
|
11061
|
+
assignAttributes(val, tagObj[":@"], readonlyMatcher, options);
|
|
10102
11062
|
} else if (Object.keys(val).length === 1 && val[options.textNodeName] !== void 0 && !options.alwaysCreateTextNode) {
|
|
10103
11063
|
val = val[options.textNodeName];
|
|
10104
11064
|
} else if (Object.keys(val).length === 0) {
|
|
@@ -10107,18 +11067,25 @@ var __exports__ = (() => {
|
|
|
10107
11067
|
else
|
|
10108
11068
|
val = "";
|
|
10109
11069
|
}
|
|
10110
|
-
if (
|
|
11070
|
+
if (tagObj[METADATA_SYMBOL2] !== void 0 && typeof val === "object" && val !== null) {
|
|
11071
|
+
val[METADATA_SYMBOL2] = tagObj[METADATA_SYMBOL2];
|
|
11072
|
+
}
|
|
11073
|
+
if (compressedObj[property] !== void 0 && Object.prototype.hasOwnProperty.call(compressedObj, property)) {
|
|
10111
11074
|
if (!Array.isArray(compressedObj[property])) {
|
|
10112
11075
|
compressedObj[property] = [compressedObj[property]];
|
|
10113
11076
|
}
|
|
10114
11077
|
compressedObj[property].push(val);
|
|
10115
11078
|
} else {
|
|
10116
|
-
|
|
11079
|
+
const jPathOrMatcher = options.jPath ? readonlyMatcher.toString() : readonlyMatcher;
|
|
11080
|
+
if (options.isArray(property, jPathOrMatcher, isLeaf)) {
|
|
10117
11081
|
compressedObj[property] = [val];
|
|
10118
11082
|
} else {
|
|
10119
11083
|
compressedObj[property] = val;
|
|
10120
11084
|
}
|
|
10121
11085
|
}
|
|
11086
|
+
if (property !== void 0 && property !== options.textNodeName) {
|
|
11087
|
+
matcher.pop();
|
|
11088
|
+
}
|
|
10122
11089
|
}
|
|
10123
11090
|
}
|
|
10124
11091
|
if (typeof text === "string") {
|
|
@@ -10136,13 +11103,15 @@ var __exports__ = (() => {
|
|
|
10136
11103
|
return key;
|
|
10137
11104
|
}
|
|
10138
11105
|
}
|
|
10139
|
-
function assignAttributes(obj, attrMap,
|
|
11106
|
+
function assignAttributes(obj, attrMap, readonlyMatcher, options) {
|
|
10140
11107
|
if (attrMap) {
|
|
10141
11108
|
const keys = Object.keys(attrMap);
|
|
10142
11109
|
const len5 = keys.length;
|
|
10143
11110
|
for (let i = 0; i < len5; i++) {
|
|
10144
11111
|
const atrrName = keys[i];
|
|
10145
|
-
|
|
11112
|
+
const rawAttrName = atrrName.startsWith(options.attributeNamePrefix) ? atrrName.substring(options.attributeNamePrefix.length) : atrrName;
|
|
11113
|
+
const jPathOrMatcher = options.jPath ? readonlyMatcher.toString() + "." + rawAttrName : readonlyMatcher;
|
|
11114
|
+
if (options.isArray(atrrName, jPathOrMatcher, true, true)) {
|
|
10146
11115
|
obj[atrrName] = [attrMap[atrrName]];
|
|
10147
11116
|
} else {
|
|
10148
11117
|
obj[atrrName] = attrMap[atrrName];
|
|
@@ -10193,7 +11162,7 @@ var __exports__ = (() => {
|
|
|
10193
11162
|
if (this.options.preserveOrder || orderedResult === void 0)
|
|
10194
11163
|
return orderedResult;
|
|
10195
11164
|
else
|
|
10196
|
-
return prettify(orderedResult, this.options);
|
|
11165
|
+
return prettify(orderedResult, this.options, orderedObjParser.matcher, orderedObjParser.readonlyMatcher);
|
|
10197
11166
|
}
|
|
10198
11167
|
/**
|
|
10199
11168
|
* Add Entity which is not by default supported by this library
|