parse-tmx 2.21.0 → 2.23.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 +54 -41
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ var __getOwnPropNames$1 = Object.getOwnPropertyNames;
|
|
|
8
8
|
var __getProtoOf = Object.getPrototypeOf;
|
|
9
9
|
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
10
10
|
var __esmMin$1 = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
11
|
-
var __commonJSMin$1 = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
11
|
+
var __commonJSMin$1 = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
12
12
|
var __exportAll$1 = (all, no_symbols) => {
|
|
13
13
|
let target = {};
|
|
14
14
|
for (var name in all) __defProp$1(target, name, {
|
|
@@ -106,9 +106,9 @@ const Flippeds = new Set(Object.values(Flipped).filter((value) => typeof value =
|
|
|
106
106
|
//#endregion
|
|
107
107
|
//#region src/util/parseFlips.ts
|
|
108
108
|
const parseFlips = (gid) => ({
|
|
109
|
-
Diagonal: Boolean(gid &
|
|
110
|
-
Horizontal: Boolean(gid &
|
|
111
|
-
Vertical: Boolean(gid &
|
|
109
|
+
Diagonal: Boolean(gid & 536870912),
|
|
110
|
+
Horizontal: Boolean(gid & 2147483648),
|
|
111
|
+
Vertical: Boolean(gid & 1073741824)
|
|
112
112
|
});
|
|
113
113
|
//#endregion
|
|
114
114
|
//#region src/models/Shape.ts
|
|
@@ -122,10 +122,10 @@ let Shape = /* @__PURE__ */ function(Shape) {
|
|
|
122
122
|
//#endregion
|
|
123
123
|
//#region src/util/parseObjectShape.ts
|
|
124
124
|
const parseObjectShape = (node) => {
|
|
125
|
-
if ("point" in node) return
|
|
126
|
-
else if ("ellipse" in node) return
|
|
127
|
-
else if ("polygon" in node) return
|
|
128
|
-
else return
|
|
125
|
+
if ("point" in node) return "point";
|
|
126
|
+
else if ("ellipse" in node) return "ellipse";
|
|
127
|
+
else if ("polygon" in node) return "polygon";
|
|
128
|
+
else return "rectangle";
|
|
129
129
|
};
|
|
130
130
|
//#endregion
|
|
131
131
|
//#region src/util/parseProperties.ts
|
|
@@ -217,12 +217,12 @@ const parseTileLayer = async (node, expectedCount, translateFlips) => {
|
|
|
217
217
|
const { compression, encoding } = $;
|
|
218
218
|
const layerData = _.trim();
|
|
219
219
|
switch (encoding) {
|
|
220
|
-
case
|
|
220
|
+
case "base64": {
|
|
221
221
|
const buffer = Buffer.from(layerData, encoding);
|
|
222
222
|
switch (compression) {
|
|
223
|
-
case
|
|
224
|
-
case
|
|
225
|
-
const decompress = compression ===
|
|
223
|
+
case "gzip":
|
|
224
|
+
case "zlib": {
|
|
225
|
+
const decompress = compression === "gzip" ? gunzip : inflate;
|
|
226
226
|
layer.data = await new Promise((resolve, reject) => {
|
|
227
227
|
decompress(buffer, (err, buf) => {
|
|
228
228
|
if (err) {
|
|
@@ -241,7 +241,7 @@ const parseTileLayer = async (node, expectedCount, translateFlips) => {
|
|
|
241
241
|
}
|
|
242
242
|
break;
|
|
243
243
|
}
|
|
244
|
-
case
|
|
244
|
+
case "csv":
|
|
245
245
|
layer.data = layerData.split(",").map((d) => parseInt(d));
|
|
246
246
|
break;
|
|
247
247
|
default: exhaustiveGuard(encoding);
|
|
@@ -262,10 +262,10 @@ const parseTileLayer = async (node, expectedCount, translateFlips) => {
|
|
|
262
262
|
const parseNode = (node, expectedCount, translateFlips) => {
|
|
263
263
|
const tmxNodeType = node["#name"];
|
|
264
264
|
switch (tmxNodeType) {
|
|
265
|
-
case
|
|
266
|
-
case
|
|
267
|
-
case
|
|
268
|
-
case
|
|
265
|
+
case "group": return parseGroup(node, expectedCount, translateFlips);
|
|
266
|
+
case "imagelayer":
|
|
267
|
+
case "objectgroup": return Promise.resolve(parseLayer(node));
|
|
268
|
+
case "layer": return parseTileLayer(node, expectedCount, translateFlips);
|
|
269
269
|
default: throw new InvalidOperationError(Operation.Read, parseNode.name, tmxNodeType);
|
|
270
270
|
}
|
|
271
271
|
};
|
|
@@ -288,7 +288,7 @@ const parseTileset = (node) => {
|
|
|
288
288
|
if (isExternalTileset(node.$)) return structuredClone(node.$);
|
|
289
289
|
const { $, $$, tile } = node;
|
|
290
290
|
for (const childNode of $$) {
|
|
291
|
-
if (childNode["#name"] !==
|
|
291
|
+
if (childNode["#name"] !== "image") continue;
|
|
292
292
|
const image = structuredClone(childNode.$);
|
|
293
293
|
const tiles = tile?.map((t) => parseTile(t)) ?? [];
|
|
294
294
|
return {
|
|
@@ -301,14 +301,14 @@ const parseTileset = (node) => {
|
|
|
301
301
|
};
|
|
302
302
|
//#endregion
|
|
303
303
|
//#region src/util/parseXmlValue.ts
|
|
304
|
+
const NUMBER_REGEX = new RegExp(String.raw`^[+-]?\d+(\.\d+)?$`, "u");
|
|
304
305
|
const parseXmlValue = (value) => {
|
|
305
306
|
if (value === "true") return true;
|
|
306
|
-
if (value === "false") return false;
|
|
307
|
-
if (
|
|
307
|
+
else if (value === "false") return false;
|
|
308
|
+
else if (NUMBER_REGEX.test(value)) {
|
|
308
309
|
const parsedValue = parseFloat(value);
|
|
309
310
|
return isNaN(parsedValue) ? value : parsedValue;
|
|
310
|
-
}
|
|
311
|
-
return value;
|
|
311
|
+
} else return value;
|
|
312
312
|
};
|
|
313
313
|
//#endregion
|
|
314
314
|
//#region ../xml2js/dist/index.js
|
|
@@ -317,7 +317,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
317
317
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
318
318
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
319
319
|
var __esmMin = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
320
|
-
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
320
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
321
321
|
var __exportAll = (all, no_symbols) => {
|
|
322
322
|
let target = {};
|
|
323
323
|
for (var name in all) __defProp(target, name, {
|
|
@@ -15278,11 +15278,10 @@ var require_EventAlgorithm = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
15278
15278
|
*/
|
|
15279
15279
|
const eventTarget = event_determineTheTargetOfAnEventHandler(thisObj, name);
|
|
15280
15280
|
if (eventTarget === null) return;
|
|
15281
|
-
if (value === null)
|
|
15281
|
+
if (value === null);
|
|
15282
15282
|
else {
|
|
15283
15283
|
const eventHandler = eventTarget._eventHandlerMap["onabort"];
|
|
15284
15284
|
if (eventHandler !== void 0) eventHandler.value = value;
|
|
15285
|
-
event_activateAnEventHandler(eventTarget, name);
|
|
15286
15285
|
}
|
|
15287
15286
|
}
|
|
15288
15287
|
/**
|
|
@@ -28493,6 +28492,7 @@ const DefaultParserOptions = {
|
|
|
28493
28492
|
trim: false,
|
|
28494
28493
|
xmlns: false
|
|
28495
28494
|
};
|
|
28495
|
+
new RegExp(String.raw`(?!xmlns)^.*:`, "u");
|
|
28496
28496
|
const normalize = (string) => string.toLowerCase();
|
|
28497
28497
|
const stripBOM = (str) => str.startsWith("") ? str.slice(1) : str;
|
|
28498
28498
|
function BufferList() {
|
|
@@ -29281,7 +29281,8 @@ function WritableState(options, stream) {
|
|
|
29281
29281
|
this.ending = false;
|
|
29282
29282
|
this.ended = false;
|
|
29283
29283
|
this.finished = false;
|
|
29284
|
-
|
|
29284
|
+
var noDecode = options.decodeStrings === false;
|
|
29285
|
+
this.decodeStrings = !noDecode;
|
|
29285
29286
|
this.defaultEncoding = options.defaultEncoding || "utf8";
|
|
29286
29287
|
this.length = 0;
|
|
29287
29288
|
this.writing = false;
|
|
@@ -31121,12 +31122,12 @@ var Parser = class {
|
|
|
31121
31122
|
const nextObject = this.stack.at(-1);
|
|
31122
31123
|
let emptyString = "";
|
|
31123
31124
|
const char = object[this.options.charkey];
|
|
31124
|
-
if (/^\s
|
|
31125
|
+
if (/^\s*$/u.exec(char) && !cdata) {
|
|
31125
31126
|
emptyString = char;
|
|
31126
31127
|
delete object[this.options.charkey];
|
|
31127
31128
|
} else {
|
|
31128
31129
|
if (this.options.trim) object[this.options.charkey] = char.trim();
|
|
31129
|
-
if (this.options.normalize) object[this.options.charkey] = char.replaceAll(/\s{2,}/
|
|
31130
|
+
if (this.options.normalize) object[this.options.charkey] = char.replaceAll(/\s{2,}/gu, " ").trim();
|
|
31130
31131
|
object[this.options.charkey] = this.options.valueProcessors ? processItem(this.options.valueProcessors, char, nodeName) : char;
|
|
31131
31132
|
if (Object.keys(object).length === 1 && this.options.charkey in object) object = object[this.options.charkey];
|
|
31132
31133
|
}
|
|
@@ -31176,7 +31177,7 @@ var Parser = class {
|
|
|
31176
31177
|
[BUILTIN_NAME_KEY]: TEXT_NODE_NAME,
|
|
31177
31178
|
[this.options.charkey]: text
|
|
31178
31179
|
};
|
|
31179
|
-
if (this.options.normalize) charChild[this.options.charkey] = takeOne(charChild, this.options.charkey).replaceAll(/\s{2,}/
|
|
31180
|
+
if (this.options.normalize) charChild[this.options.charkey] = takeOne(charChild, this.options.charkey).replaceAll(/\s{2,}/gu, " ").trim();
|
|
31180
31181
|
object[this.options.childkey].push(charChild);
|
|
31181
31182
|
}
|
|
31182
31183
|
return object;
|
|
@@ -57026,7 +57027,19 @@ var init_punycode_es6 = __esmMin$1((() => {
|
|
|
57026
57027
|
});
|
|
57027
57028
|
};
|
|
57028
57029
|
punycode = {
|
|
57030
|
+
/**
|
|
57031
|
+
* A string representing the current Punycode.js version number.
|
|
57032
|
+
* @memberOf punycode
|
|
57033
|
+
* @type String
|
|
57034
|
+
*/
|
|
57029
57035
|
"version": "2.3.1",
|
|
57036
|
+
/**
|
|
57037
|
+
* An object of methods to convert from JavaScript's internal character
|
|
57038
|
+
* representation (UCS-2) to Unicode code points, and back.
|
|
57039
|
+
* @see <https://mathiasbynens.be/notes/javascript-encoding>
|
|
57040
|
+
* @memberOf punycode
|
|
57041
|
+
* @type Object
|
|
57042
|
+
*/
|
|
57030
57043
|
"ucs2": {
|
|
57031
57044
|
"decode": ucs2decode,
|
|
57032
57045
|
"encode": ucs2encode
|
|
@@ -93166,28 +93179,28 @@ const parseTmx = async (xmlString, translateFlips = false) => {
|
|
|
93166
93179
|
for (const node of $$) {
|
|
93167
93180
|
const tmxNodeType = node["#name"];
|
|
93168
93181
|
switch (tmxNodeType) {
|
|
93169
|
-
case
|
|
93170
|
-
case
|
|
93182
|
+
case "data": break;
|
|
93183
|
+
case "editorsettings":
|
|
93171
93184
|
if (!node.$$) break;
|
|
93172
93185
|
map.editorsettings = Object.assign({}, ...node.$$.map((n) => ({ [n["#name"]]: n.$ })));
|
|
93173
93186
|
break;
|
|
93174
|
-
case
|
|
93175
|
-
case
|
|
93176
|
-
case
|
|
93177
|
-
case
|
|
93178
|
-
case
|
|
93179
|
-
case
|
|
93180
|
-
case
|
|
93181
|
-
case
|
|
93187
|
+
case "export":
|
|
93188
|
+
case "image":
|
|
93189
|
+
case "object":
|
|
93190
|
+
case "property": break;
|
|
93191
|
+
case "group":
|
|
93192
|
+
case "imagelayer":
|
|
93193
|
+
case "layer":
|
|
93194
|
+
case "objectgroup": {
|
|
93182
93195
|
const layer = await parseNode(node, expectedCount, translateFlips);
|
|
93183
93196
|
map.layers.push(layer);
|
|
93184
93197
|
break;
|
|
93185
93198
|
}
|
|
93186
|
-
case
|
|
93199
|
+
case "properties":
|
|
93187
93200
|
if (!node.$$) break;
|
|
93188
93201
|
map.properties = Object.assign({}, ...node.$$.map(({ $: { name, value } }) => ({ [name]: value })));
|
|
93189
93202
|
break;
|
|
93190
|
-
case
|
|
93203
|
+
case "tileset":
|
|
93191
93204
|
map.tilesets.push(parseTileset(node));
|
|
93192
93205
|
break;
|
|
93193
93206
|
default: exhaustiveGuard(tmxNodeType);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "parse-tmx",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.23.0",
|
|
4
4
|
"description": "A parser for tmx.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"parser",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"typecheck": "tsgo"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@esposter/shared": "2.
|
|
41
|
-
"@esposter/xml2js": "2.
|
|
40
|
+
"@esposter/shared": "2.23.0",
|
|
41
|
+
"@esposter/xml2js": "2.23.0",
|
|
42
42
|
"data-urls": "^7.0.0",
|
|
43
43
|
"dayjs": "^1.11.20"
|
|
44
44
|
},
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"@types/data-urls": "^3.0.5",
|
|
47
47
|
"@types/xml2js": "^0.4.14"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "b5172e2824227a4b5e9524a4945f521a70ff5c9d"
|
|
50
50
|
}
|