parse-tmx 2.5.0 → 2.6.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/index.js +14 -15
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -170,7 +170,7 @@ const parseObject = (node) => {
|
|
|
170
170
|
if (text) {
|
|
171
171
|
const textNode = text[0];
|
|
172
172
|
object.text = textNode._;
|
|
173
|
-
object.properties = Object.assign({}, object.properties, textNode.$);
|
|
173
|
+
object.properties = Object.assign({}, ...object.properties ?? [], textNode.$);
|
|
174
174
|
}
|
|
175
175
|
if (object.gid) {
|
|
176
176
|
object.flips = parseFlips(object.gid);
|
|
@@ -401,7 +401,7 @@ const DefaultBuilderOptions = {
|
|
|
401
401
|
},
|
|
402
402
|
rootName: "root",
|
|
403
403
|
xmldec: {
|
|
404
|
-
encoding: "
|
|
404
|
+
encoding: "utf8",
|
|
405
405
|
standalone: true,
|
|
406
406
|
version: "1.0"
|
|
407
407
|
}
|
|
@@ -3259,7 +3259,7 @@ var require_xmlbuilder2_min = __commonJS({ "../../node_modules/.pnpm/xmlbuilder2
|
|
|
3259
3259
|
},
|
|
3260
3260
|
function(e, t, r) {
|
|
3261
3261
|
var n, i$1 = r(18), o = r(188), a = r(84), s = r(45), u = r(189), l = r(116), c = r(57), h = c("IE_PROTO"), p$3 = function() {}, f = function(e$1) {
|
|
3262
|
-
return "<script>" + e$1 + "
|
|
3262
|
+
return "<script>" + e$1 + "<\/script>";
|
|
3263
3263
|
}, d = function() {
|
|
3264
3264
|
try {
|
|
3265
3265
|
n = document.domain && new ActiveXObject("htmlfile");
|
|
@@ -19173,7 +19173,7 @@ const DefaultParserOptions = {
|
|
|
19173
19173
|
xmlns: false
|
|
19174
19174
|
};
|
|
19175
19175
|
const normalize = (string) => string.toLowerCase();
|
|
19176
|
-
const stripBOM = (str) => str.startsWith("") ? str.
|
|
19176
|
+
const stripBOM = (str) => str.startsWith("") ? str.slice(1) : str;
|
|
19177
19177
|
var require_base64_js = __commonJS({ "../../node_modules/.pnpm/base64-js@1.5.1/node_modules/base64-js/index.js"(exports$1) {
|
|
19178
19178
|
exports$1.byteLength = byteLength$1;
|
|
19179
19179
|
exports$1.toByteArray = toByteArray;
|
|
@@ -21940,7 +21940,7 @@ var Parser = class {
|
|
|
21940
21940
|
const newObject = {};
|
|
21941
21941
|
newObject[this.options.charkey] = "";
|
|
21942
21942
|
if (!this.options.ignoreAttrs) {
|
|
21943
|
-
for (const key in node.attributes) if (Object.
|
|
21943
|
+
for (const key in node.attributes) if (Object.hasOwn(node.attributes, key)) {
|
|
21944
21944
|
if (!(this.options.attrkey in newObject) && !this.options.mergeAttrs) newObject[this.options.attrkey] = {};
|
|
21945
21945
|
const newValue = this.options.attrValueProcessors ? processItem(this.options.attrValueProcessors, node.attributes[key], key) : node.attributes[key];
|
|
21946
21946
|
const processedKey = this.options.attrNameProcessors ? processItem(this.options.attrNameProcessors, key, "") : key;
|
|
@@ -21973,14 +21973,14 @@ var Parser = class {
|
|
|
21973
21973
|
delete object[this.options.charkey];
|
|
21974
21974
|
} else {
|
|
21975
21975
|
if (this.options.trim) object[this.options.charkey] = char.trim();
|
|
21976
|
-
if (this.options.normalize) object[this.options.charkey] = char.
|
|
21976
|
+
if (this.options.normalize) object[this.options.charkey] = char.replaceAll(/\s{2,}/g, " ").trim();
|
|
21977
21977
|
object[this.options.charkey] = this.options.valueProcessors ? processItem(this.options.valueProcessors, char, nodeName) : char;
|
|
21978
21978
|
if (Object.keys(object).length === 1 && this.options.charkey in object) object = object[this.options.charkey];
|
|
21979
21979
|
}
|
|
21980
21980
|
if (isEmpty(object)) if (typeof this.options.emptyTag === "function") object = this.options.emptyTag();
|
|
21981
21981
|
else object = this.options.emptyTag || emptyString;
|
|
21982
21982
|
if (this.options.validator) {
|
|
21983
|
-
const xpath = `/${this.stack.map((node) => node[BUILTIN_NAME_KEY])
|
|
21983
|
+
const xpath = `/${[...this.stack.map((node) => node[BUILTIN_NAME_KEY]), nodeName].join("/")}`;
|
|
21984
21984
|
object = this.options.validator(xpath, nextObject?.[nodeName], object);
|
|
21985
21985
|
}
|
|
21986
21986
|
if (this.options.explicitChildren && !this.options.mergeAttrs && typeof object === "object") {
|
|
@@ -22017,11 +22017,11 @@ var Parser = class {
|
|
|
22017
22017
|
const object = this.stack.at(-1);
|
|
22018
22018
|
if (!object) return void 0;
|
|
22019
22019
|
object[this.options.charkey] += text;
|
|
22020
|
-
if (this.options.explicitChildren && this.options.preserveChildrenOrder && this.options.charsAsChildren && (this.options.includeWhiteChars || text.
|
|
22020
|
+
if (this.options.explicitChildren && this.options.preserveChildrenOrder && this.options.charsAsChildren && (this.options.includeWhiteChars || text.replaceAll(String.raw`\\n`, "").trim() !== "")) {
|
|
22021
22021
|
object[this.options.childkey] ??= [];
|
|
22022
22022
|
const charChild = { [BUILTIN_NAME_KEY]: TEXT_NODE_NAME };
|
|
22023
22023
|
charChild[this.options.charkey] = text;
|
|
22024
|
-
if (this.options.normalize) charChild[this.options.charkey] = charChild[this.options.charkey].
|
|
22024
|
+
if (this.options.normalize) charChild[this.options.charkey] = charChild[this.options.charkey].replaceAll(/\s{2,}/g, " ").trim();
|
|
22025
22025
|
object[this.options.childkey].push(charChild);
|
|
22026
22026
|
}
|
|
22027
22027
|
return object;
|
|
@@ -22037,13 +22037,12 @@ var Parser = class {
|
|
|
22037
22037
|
return new Promise((resolve) => this.parseString(convertableToString, resolve));
|
|
22038
22038
|
}
|
|
22039
22039
|
assignOrPush(object, key, newValue) {
|
|
22040
|
-
if (
|
|
22041
|
-
else defineProperty(object, key, [newValue]);
|
|
22042
|
-
else {
|
|
22040
|
+
if (key in object) {
|
|
22043
22041
|
const objectValue = object[key];
|
|
22044
|
-
if (
|
|
22045
|
-
else objectValue
|
|
22046
|
-
}
|
|
22042
|
+
if (Array.isArray(objectValue)) objectValue.push(newValue);
|
|
22043
|
+
else defineProperty(object, key, [objectValue]);
|
|
22044
|
+
} else if (this.options.explicitArray) defineProperty(object, key, [newValue]);
|
|
22045
|
+
else defineProperty(object, key, newValue);
|
|
22047
22046
|
}
|
|
22048
22047
|
parseString(convertableToString, callback) {
|
|
22049
22048
|
const string = stripBOM(convertableToString.toString());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "parse-tmx",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.0",
|
|
4
4
|
"description": "A parser for tmx.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"homepage": "https://github.com/Esposter/Esposter#readme",
|
|
@@ -35,12 +35,12 @@
|
|
|
35
35
|
"export:gen": "ctix build --config ../configuration/.ctirc-ts"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@esposter/xml2js": "2.
|
|
38
|
+
"@esposter/xml2js": "2.6.0",
|
|
39
39
|
"data-urls": "^5.0.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/data-urls": "^3.0.4",
|
|
43
43
|
"@types/xml2js": "^0.4.14"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "45ae08aaf254d1c3d2a66e668d19aaf8f5022119"
|
|
46
46
|
}
|