parse-tmx 2.34.2 → 2.36.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.d.ts +17 -17
- package/dist/index.js +12 -15
- package/package.json +8 -8
package/dist/index.d.ts
CHANGED
|
@@ -143,10 +143,24 @@ declare enum Flipped {
|
|
|
143
143
|
Vertically = 1073741824,
|
|
144
144
|
Horizontally = 2147483648
|
|
145
145
|
}
|
|
146
|
-
declare const Flippeds:
|
|
146
|
+
declare const Flippeds: readonly Flipped[];
|
|
147
|
+
declare enum TMXNodeType {
|
|
148
|
+
Data = "data",
|
|
149
|
+
EditorSettings = "editorsettings",
|
|
150
|
+
Export = "export",
|
|
151
|
+
Group = "group",
|
|
152
|
+
Image = "image",
|
|
153
|
+
ImageLayer = "imagelayer",
|
|
154
|
+
Layer = "layer",
|
|
155
|
+
Object = "object",
|
|
156
|
+
Objectgroup = "objectgroup",
|
|
157
|
+
Properties = "properties",
|
|
158
|
+
Property = "property",
|
|
159
|
+
Tileset = "tileset"
|
|
160
|
+
}
|
|
147
161
|
declare class BaseTMXNode<T> {
|
|
148
|
-
#private;
|
|
149
162
|
[key: string]: unknown;
|
|
163
|
+
readonly "#name": TMXNodeType;
|
|
150
164
|
$: T;
|
|
151
165
|
}
|
|
152
166
|
declare const cloneNodeWithType: <TParsed>(node: BaseTMXNode<unknown>) => TParsed;
|
|
@@ -205,7 +219,7 @@ interface TMXGroupLayerNode extends TMXNode<TMXGroupLayerShared, TMXLayerNode> {
|
|
|
205
219
|
}
|
|
206
220
|
declare const parseGroup: (node: TMXGroupLayerNode, expectedCount: number, translateFlips: boolean) => Promise<TMXGroupLayerParsed>;
|
|
207
221
|
declare const parseLayer: (node: TMXLayerNode) => TMXLayerParsed;
|
|
208
|
-
declare const parseNode: <TNode extends TMXGroupLayerNode | TMXLayerNode, TParsedNode =
|
|
222
|
+
declare const parseNode: <TNode extends TMXGroupLayerNode | TMXLayerNode, TParsedNode = TNode extends TMXLayerNode ? TMXLayerParsed : TMXGroupLayerParsed>(node: TNode, expectedCount: number, translateFlips: boolean) => Promise<TParsedNode>;
|
|
209
223
|
declare const parseObject: (node: TMXObjectNode) => TMXObjectParsed;
|
|
210
224
|
declare const parseObjectShape: (node: TMXObjectNode) => Shape;
|
|
211
225
|
declare const parseProperties: (properties: {
|
|
@@ -230,19 +244,5 @@ interface TMXMapNode extends TMXNode<TMXMapShared, TMXEditorSettingsNode | TMXGr
|
|
|
230
244
|
interface TMX {
|
|
231
245
|
map: TMXMapNode;
|
|
232
246
|
}
|
|
233
|
-
declare enum TMXNodeType {
|
|
234
|
-
Data = "data",
|
|
235
|
-
EditorSettings = "editorsettings",
|
|
236
|
-
Export = "export",
|
|
237
|
-
Group = "group",
|
|
238
|
-
Image = "image",
|
|
239
|
-
ImageLayer = "imagelayer",
|
|
240
|
-
Layer = "layer",
|
|
241
|
-
Object = "object",
|
|
242
|
-
Objectgroup = "objectgroup",
|
|
243
|
-
Properties = "properties",
|
|
244
|
-
Property = "property",
|
|
245
|
-
Tileset = "tileset"
|
|
246
|
-
}
|
|
247
247
|
interface TMXExportParsed extends TMXExportShared {}
|
|
248
248
|
export { BaseTMXNode, Compression, Encoding, Flipped, Flippeds, Shape, TMX, TMXBaseTilesetShared, TMXDataNode, TMXEditorSettingsNode, TMXEditorSettingsParsed, TMXEmbeddedTilesetNode, TMXEmbeddedTilesetParsed, TMXEmbeddedTilesetShared, TMXExportNode, TMXExportParsed, TMXExportShared, TMXExternalTilesetNode, TMXExternalTilesetParsed, TMXExternalTilesetShared, TMXFlipsParsed, TMXGroupLayerNode, TMXGroupLayerParsed, TMXGroupLayerShared, TMXImageNode, TMXImageParsed, TMXImageShared, TMXLayerNode, TMXLayerParsed, TMXLayerShared, TMXMapNode, TMXMapParsed, TMXMapShared, TMXNode, TMXNodeType, TMXObjectNode, TMXObjectParsed, TMXObjectShared, TMXParsed, TMXPropertiesNode, TMXPropertiesParsed, TMXPropertyNode, TMXTileNode, TMXTileParsed, TMXTileShared, TMXTilesetNode, TMXTilesetParsed, cloneNodeWithType, getDecompressedBytes, isExternalTileset, isTMXEmbeddedTilesetNode, parseFlips, parseGroup, parseLayer, parseNode, parseObject, parseObjectShape, parseProperties, parseTile, parseTileId, parseTileLayer, parseTileset, parseTmx, parseXmlString, parseXmlValue, unpackTileBytes };
|
package/dist/index.js
CHANGED
|
@@ -34,7 +34,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
34
34
|
}
|
|
35
35
|
return to;
|
|
36
36
|
};
|
|
37
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
37
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
38
38
|
value: mod,
|
|
39
39
|
enumerable: true
|
|
40
40
|
}) : target, mod));
|
|
@@ -100,7 +100,7 @@ let Flipped = /* @__PURE__ */ function(Flipped) {
|
|
|
100
100
|
Flipped[Flipped["Horizontally"] = 2147483648] = "Horizontally";
|
|
101
101
|
return Flipped;
|
|
102
102
|
}({});
|
|
103
|
-
const Flippeds =
|
|
103
|
+
const Flippeds = Object.values(Flipped).filter((value) => typeof value === "number");
|
|
104
104
|
const parseFlips = (gid) => ({
|
|
105
105
|
Diagonal: Boolean(gid & 536870912),
|
|
106
106
|
Horizontal: Boolean(gid & 2147483648),
|
|
@@ -127,7 +127,7 @@ const parseProperties = (properties) => properties.map(({ property }) => {
|
|
|
127
127
|
value: value ?? _
|
|
128
128
|
};
|
|
129
129
|
});
|
|
130
|
-
const FLIPPED_MASK = ~
|
|
130
|
+
const FLIPPED_MASK = ~Flippeds.reduce((acc, curr) => acc | curr, 0);
|
|
131
131
|
const parseTileId = (gid) => gid & FLIPPED_MASK;
|
|
132
132
|
const parseObject = (node) => {
|
|
133
133
|
const { $, polygon, properties, text } = node;
|
|
@@ -212,7 +212,7 @@ const parseTileLayer = async (node, expectedCount, translateFlips) => {
|
|
|
212
212
|
break;
|
|
213
213
|
}
|
|
214
214
|
case "csv":
|
|
215
|
-
layer.data = layerData.split(",").map((d) => parseInt(d));
|
|
215
|
+
layer.data = layerData.split(",").map((d) => Number.parseInt(d));
|
|
216
216
|
break;
|
|
217
217
|
default: exhaustiveGuard(encoding);
|
|
218
218
|
}
|
|
@@ -238,7 +238,7 @@ const isExternalTileset = (tileset) => "source" in tileset;
|
|
|
238
238
|
const parseTile = (node) => {
|
|
239
239
|
const { $, animation, objectgroup, properties } = node;
|
|
240
240
|
const tile = structuredClone($);
|
|
241
|
-
if (animation) tile.animation = { frames: takeOne(takeOne(animation), "frame").map(({
|
|
241
|
+
if (animation) tile.animation = { frames: takeOne(takeOne(animation), "frame").map(({ $: frameData }) => structuredClone(frameData)) };
|
|
242
242
|
if (objectgroup) tile.objects = takeOne(takeOne(objectgroup), "object").map((o) => parseObject(o));
|
|
243
243
|
if (properties) tile.properties = parseProperties(properties);
|
|
244
244
|
return tile;
|
|
@@ -264,7 +264,7 @@ const parseXmlValue = (value) => {
|
|
|
264
264
|
else if (value === "false") return false;
|
|
265
265
|
else if (NUMBER_REGEX.test(value)) {
|
|
266
266
|
const parsedValue = Number(value);
|
|
267
|
-
return isNaN(parsedValue) ? value : parsedValue;
|
|
267
|
+
return Number.isNaN(parsedValue) ? value : parsedValue;
|
|
268
268
|
} else return value;
|
|
269
269
|
};
|
|
270
270
|
var require_utils$2 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
@@ -1940,9 +1940,7 @@ var require_utils$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1940
1940
|
case "value":
|
|
1941
1941
|
result = value;
|
|
1942
1942
|
break;
|
|
1943
|
-
case "key+value":
|
|
1944
|
-
result = [key, value];
|
|
1945
|
-
break;
|
|
1943
|
+
case "key+value": result = [key, value];
|
|
1946
1944
|
}
|
|
1947
1945
|
return {
|
|
1948
1946
|
value: result,
|
|
@@ -25882,7 +25880,7 @@ var init_punycode_es6 = __esmMin((() => {
|
|
|
25882
25880
|
"not-basic": "Illegal input >= 0x80 (not a basic code point)",
|
|
25883
25881
|
"invalid-input": "Invalid input"
|
|
25884
25882
|
};
|
|
25885
|
-
baseMinusTMin =
|
|
25883
|
+
baseMinusTMin = 35;
|
|
25886
25884
|
floor = Math.floor;
|
|
25887
25885
|
stringFromCharCode = String.fromCharCode;
|
|
25888
25886
|
ucs2encode = (codePoints) => String.fromCodePoint(...codePoints);
|
|
@@ -59850,9 +59848,7 @@ var require_tr46 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
59850
59848
|
if (transitionalProcessing) processed += mapping;
|
|
59851
59849
|
else processed += ch;
|
|
59852
59850
|
break;
|
|
59853
|
-
case STATUS_MAPPING.valid:
|
|
59854
|
-
processed += ch;
|
|
59855
|
-
break;
|
|
59851
|
+
case STATUS_MAPPING.valid: processed += ch;
|
|
59856
59852
|
}
|
|
59857
59853
|
}
|
|
59858
59854
|
return processed;
|
|
@@ -62092,7 +62088,8 @@ var import_parser = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exp
|
|
|
62092
62088
|
};
|
|
62093
62089
|
})))(), 1);
|
|
62094
62090
|
const parseXmlString = (xmlString) => {
|
|
62095
|
-
|
|
62091
|
+
const xml = (0, import_parser.default)(xmlString) ?? xmlString;
|
|
62092
|
+
return parseStringPromise(xml, {
|
|
62096
62093
|
attrValueProcessors: [(value) => parseXmlValue(value)],
|
|
62097
62094
|
explicitChildren: true,
|
|
62098
62095
|
preserveChildrenOrder: true
|
|
@@ -62135,7 +62132,7 @@ const parseTmx = async (xmlString, translateFlips = false) => {
|
|
|
62135
62132
|
return new TMXParsed(map);
|
|
62136
62133
|
};
|
|
62137
62134
|
var BaseTMXNode = class {
|
|
62135
|
+
"#name";
|
|
62138
62136
|
$;
|
|
62139
|
-
#name;
|
|
62140
62137
|
};
|
|
62141
62138
|
export { BaseTMXNode, Compression, Encoding, Flipped, Flippeds, Shape, TMXMapParsed, TMXMapShared, TMXNodeType, TMXParsed, cloneNodeWithType, getDecompressedBytes, isExternalTileset, isTMXEmbeddedTilesetNode, parseFlips, parseGroup, parseLayer, parseNode, parseObject, parseObjectShape, parseProperties, parseTile, parseTileId, parseTileLayer, parseTileset, parseTmx, parseXmlString, parseXmlValue, unpackTileBytes };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "parse-tmx",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.36.0",
|
|
4
4
|
"description": "A parser for tmx.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"game-development",
|
|
@@ -45,19 +45,19 @@
|
|
|
45
45
|
"typecheck": "tsgo"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@esposter/shared": "2.
|
|
49
|
-
"@esposter/xml2js": "2.
|
|
48
|
+
"@esposter/shared": "2.36.0",
|
|
49
|
+
"@esposter/xml2js": "2.36.0",
|
|
50
50
|
"data-urls": "^7.0.0",
|
|
51
51
|
"dayjs": "^1.11.21"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@esposter/configuration": "2.
|
|
54
|
+
"@esposter/configuration": "2.36.0",
|
|
55
55
|
"@types/data-urls": "^3.0.5",
|
|
56
56
|
"@types/xml2js": "^0.4.14",
|
|
57
|
-
"ctix": "^2.8.
|
|
58
|
-
"rolldown": "^1.1
|
|
57
|
+
"ctix": "^2.8.2",
|
|
58
|
+
"rolldown": "^1.2.1",
|
|
59
59
|
"type-fest": "^5.8.0",
|
|
60
|
-
"vitest": "^4.1.
|
|
60
|
+
"vitest": "^4.1.10"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "786902aca40292b2883de2ad1eb876ca32f6ac75"
|
|
63
63
|
}
|