@codexo/exojs-tiled 0.15.3 → 0.16.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/README.md +59 -66
- package/dist/esm/TiledLayer.d.ts +2 -1
- package/dist/esm/TiledLayer.d.ts.map +1 -0
- package/dist/esm/TiledLayer.js +106 -108
- package/dist/esm/TiledLayer.js.map +1 -1
- package/dist/esm/TiledMap.d.ts +35 -7
- package/dist/esm/TiledMap.d.ts.map +1 -0
- package/dist/esm/TiledMap.js +714 -589
- package/dist/esm/TiledMap.js.map +1 -1
- package/dist/esm/TiledObject.d.ts +7 -0
- package/dist/esm/TiledObject.d.ts.map +1 -0
- package/dist/esm/TiledObject.js +59 -51
- package/dist/esm/TiledObject.js.map +1 -1
- package/dist/esm/TiledTileset.d.ts +11 -4
- package/dist/esm/TiledTileset.d.ts.map +1 -0
- package/dist/esm/TiledTileset.js +81 -70
- package/dist/esm/TiledTileset.js.map +1 -1
- package/dist/esm/data.d.ts +25 -7
- package/dist/esm/data.d.ts.map +1 -0
- package/dist/esm/decodeLayerData.d.ts +2 -1
- package/dist/esm/decodeLayerData.d.ts.map +1 -0
- package/dist/esm/decodeLayerData.js +53 -92
- package/dist/esm/decodeLayerData.js.map +1 -1
- package/dist/esm/gid.d.ts +2 -1
- package/dist/esm/gid.d.ts.map +1 -0
- package/dist/esm/gid.js +15 -24
- package/dist/esm/gid.js.map +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +14 -12
- package/dist/esm/loadTiledMap.d.ts +11 -5
- package/dist/esm/loadTiledMap.d.ts.map +1 -0
- package/dist/esm/loadTiledMap.js +82 -91
- package/dist/esm/loadTiledMap.js.map +1 -1
- package/dist/esm/objectAlignment.d.ts +28 -0
- package/dist/esm/objectAlignment.d.ts.map +1 -0
- package/dist/esm/objectAlignment.js +79 -0
- package/dist/esm/objectAlignment.js.map +1 -0
- package/dist/esm/public.d.ts +17 -15
- package/dist/esm/public.d.ts.map +1 -0
- package/dist/esm/public.js +14 -0
- package/dist/esm/tileMapType.d.ts +31 -0
- package/dist/esm/tileMapType.d.ts.map +1 -0
- package/dist/esm/tileMapType.js +42 -0
- package/dist/esm/tileMapType.js.map +1 -0
- package/dist/esm/tiledBuildInfo.d.ts +1 -0
- package/dist/esm/tiledBuildInfo.d.ts.map +1 -0
- package/dist/esm/tiledBuildInfo.js +6 -4
- package/dist/esm/tiledBuildInfo.js.map +1 -1
- package/dist/esm/tiledExtension.d.ts +7 -6
- package/dist/esm/tiledExtension.d.ts.map +1 -0
- package/dist/esm/tiledExtension.js +23 -25
- package/dist/esm/tiledExtension.js.map +1 -1
- package/dist/esm/tiledOptions.d.ts +5 -4
- package/dist/esm/tiledOptions.d.ts.map +1 -0
- package/dist/esm/tiledOptions.js +11 -13
- package/dist/esm/tiledOptions.js.map +1 -1
- package/dist/esm/tiledSourceType.d.ts +24 -0
- package/dist/esm/tiledSourceType.d.ts.map +1 -0
- package/dist/esm/tiledSourceType.js +44 -0
- package/dist/esm/tiledSourceType.js.map +1 -0
- package/dist/esm/url.d.ts +2 -1
- package/dist/esm/url.d.ts.map +1 -0
- package/dist/esm/url.js +26 -37
- package/dist/esm/url.js.map +1 -1
- package/dist/esm/validate.d.ts +11 -10
- package/dist/esm/validate.d.ts.map +1 -0
- package/dist/esm/validate.js +485 -534
- package/dist/esm/validate.js.map +1 -1
- package/dist/esm/wangSets.d.ts +5 -4
- package/dist/esm/wangSets.d.ts.map +1 -0
- package/dist/esm/wangSets.js +90 -115
- package/dist/esm/wangSets.js.map +1 -1
- package/package.json +10 -18
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/register.d.ts +0 -1
- package/dist/esm/register.js +0 -22
- package/dist/esm/register.js.map +0 -1
- package/dist/esm/tiledMapBinding.d.ts +0 -19
- package/dist/esm/tiledMapBinding.js +0 -31
- package/dist/esm/tiledMapBinding.js.map +0 -1
- package/dist/esm/tiledRuntimeMapBinding.d.ts +0 -29
- package/dist/esm/tiledRuntimeMapBinding.js +0 -42
- package/dist/esm/tiledRuntimeMapBinding.js.map +0 -1
package/dist/esm/data.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ export interface TiledAnimationFrameData {
|
|
|
37
37
|
readonly duration: number;
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
|
-
* A per-tile definition within a tileset's `tiles` array. Sparse
|
|
40
|
+
* A per-tile definition within a tileset's `tiles` array. Sparse - only
|
|
41
41
|
* tiles carrying metadata (properties, animation, a collision objectgroup,
|
|
42
42
|
* or a collection-of-images source) appear here.
|
|
43
43
|
*/
|
|
@@ -58,7 +58,7 @@ export interface TiledTileData {
|
|
|
58
58
|
/**
|
|
59
59
|
* One color (terrain) entry within a wangset's `colors` array.
|
|
60
60
|
*
|
|
61
|
-
* `tile` is the representative tile local id for this color (
|
|
61
|
+
* `tile` is the representative tile local id for this color (-1 if unset).
|
|
62
62
|
* `probability` is the relative spawn weight used by Tiled's random fill.
|
|
63
63
|
*/
|
|
64
64
|
export interface TiledWangColorData {
|
|
@@ -84,9 +84,9 @@ export interface TiledWangTileData {
|
|
|
84
84
|
* A wangset entry within a tileset's `wangsets` array.
|
|
85
85
|
*
|
|
86
86
|
* `type` is `'corner'`, `'edge'`, or `'mixed'` (Tiled 1.5+). Older files may
|
|
87
|
-
* omit it or use other strings
|
|
87
|
+
* omit it or use other strings - treat unknown values as-is.
|
|
88
88
|
*
|
|
89
|
-
* `tile` is the representative tile local id for this wangset (
|
|
89
|
+
* `tile` is the representative tile local id for this wangset (-1 if unset).
|
|
90
90
|
*/
|
|
91
91
|
export interface TiledWangSetData {
|
|
92
92
|
readonly name: string;
|
|
@@ -96,6 +96,14 @@ export interface TiledWangSetData {
|
|
|
96
96
|
readonly wangtiles: readonly TiledWangTileData[];
|
|
97
97
|
readonly properties?: readonly TiledPropertyData[] | undefined;
|
|
98
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Where a tile object's stored `x`/`y` sits within the tile's bounding box
|
|
101
|
+
* ({@link TiledTilesetData.objectalignment}).
|
|
102
|
+
*
|
|
103
|
+
* `'unspecified'` is Tiled's own default and is orientation-dependent - see
|
|
104
|
+
* {@link import('./objectAlignment').resolveTiledObjectAlignment}.
|
|
105
|
+
*/
|
|
106
|
+
export type TiledObjectAlignment = 'unspecified' | 'topleft' | 'top' | 'topright' | 'left' | 'center' | 'right' | 'bottomleft' | 'bottom' | 'bottomright';
|
|
99
107
|
/**
|
|
100
108
|
* A Tiled tileset, as the root of a standalone `.tsj` file or (minus
|
|
101
109
|
* `firstgid`) embedded inline in a map's `tilesets` array.
|
|
@@ -114,7 +122,8 @@ export interface TiledTilesetData {
|
|
|
114
122
|
readonly imagewidth?: number | undefined;
|
|
115
123
|
readonly imageheight?: number | undefined;
|
|
116
124
|
readonly tileoffset?: TiledPointData | undefined;
|
|
117
|
-
|
|
125
|
+
/** Alignment of a tile object's stored position within its bounding box. Absent means `'unspecified'`. */
|
|
126
|
+
readonly objectalignment?: TiledObjectAlignment | undefined;
|
|
118
127
|
readonly tiles?: readonly TiledTileData[] | undefined;
|
|
119
128
|
readonly wangsets?: readonly TiledWangSetData[] | undefined;
|
|
120
129
|
readonly properties?: readonly TiledPropertyData[] | undefined;
|
|
@@ -130,7 +139,7 @@ export interface TiledExternalTilesetRefData {
|
|
|
130
139
|
export type TiledEmbeddedTilesetRefData = TiledTilesetData & {
|
|
131
140
|
readonly firstgid: number;
|
|
132
141
|
};
|
|
133
|
-
/** One entry of {@link TiledMapData.tilesets}
|
|
142
|
+
/** One entry of {@link TiledMapData.tilesets} - either external (`source`) or embedded. */
|
|
134
143
|
export type TiledTilesetRefData = TiledExternalTilesetRefData | TiledEmbeddedTilesetRefData;
|
|
135
144
|
/** Text rendering options for a `text` object (object layers). */
|
|
136
145
|
export interface TiledTextData {
|
|
@@ -156,8 +165,16 @@ export interface TiledTextData {
|
|
|
156
165
|
export interface TiledObjectData {
|
|
157
166
|
readonly id: number;
|
|
158
167
|
readonly name: string;
|
|
159
|
-
/**
|
|
168
|
+
/**
|
|
169
|
+
* Object class, under the name Tiled 1.10 and later write. Empty when unset.
|
|
170
|
+
*
|
|
171
|
+
* Tiled 1.9 wrote the same value as {@link TiledObjectData.class} instead;
|
|
172
|
+
* see {@link import('./TiledObject').TiledObject.type} for how the two are
|
|
173
|
+
* reconciled.
|
|
174
|
+
*/
|
|
160
175
|
readonly type: string;
|
|
176
|
+
/** Object class as Tiled 1.9 wrote it. Absent in every other version. */
|
|
177
|
+
readonly class?: string | undefined;
|
|
161
178
|
readonly x: number;
|
|
162
179
|
readonly y: number;
|
|
163
180
|
readonly width: number;
|
|
@@ -257,3 +274,4 @@ export interface TiledMapData {
|
|
|
257
274
|
readonly tilesets: readonly TiledTilesetRefData[];
|
|
258
275
|
readonly properties?: readonly TiledPropertyData[] | undefined;
|
|
259
276
|
}
|
|
277
|
+
//# sourceMappingURL=data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../src/data.ts"],"names":[],"mappings":"AAcA,gFAAgF;AAChF,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;CACpB;AAID,0DAA0D;AAC1D,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;AAE5G;;;GAGG;AACH,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,2BAA2B,CAAC;CAClF;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CA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SAAS,iBAAiB,EAAE,GAAG,SAAS,CAAC;CAChE"}
|
|
@@ -6,4 +6,5 @@
|
|
|
6
6
|
* @throws {TiledFormatError} On zstd/unknown compression or malformed data.
|
|
7
7
|
* @internal
|
|
8
8
|
*/
|
|
9
|
-
export declare
|
|
9
|
+
export declare const decodeTiledLayerData: (raw: unknown, source: string) => Promise<unknown>;
|
|
10
|
+
//# sourceMappingURL=decodeLayerData.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decodeLayerData.d.ts","sourceRoot":"","sources":["../../src/decodeLayerData.ts"],"names":[],"mappings":"AA4FA;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,GAAU,KAAK,OAAO,EAAE,QAAQ,MAAM,KAAG,OAAO,CAAC,OAAO,CAKxF,CAAC"}
|
|
@@ -1,100 +1,61 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { TiledFormatError } from "./validate.js";
|
|
2
|
+
import { Codec } from "@codexo/exojs";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
//
|
|
6
|
-
// Tiled can store tile-layer GIDs as plain CSV (a JSON array), or as a base64
|
|
7
|
-
// string that is optionally gzip/zlib/zstd compressed. The rest of the pipeline
|
|
8
|
-
// (validation, `TiledMap`, `toTileMap`) only deals with the decoded `number[]`
|
|
9
|
-
// GID array, so this pass runs first — during the async load phase — and
|
|
10
|
-
// rewrites any base64/compressed `data` (and infinite-map `chunks[].data`) into
|
|
11
|
-
// plain GID arrays in place. After it runs, the document looks like a CSV map to
|
|
12
|
-
// every downstream stage, which stays synchronous and unchanged.
|
|
4
|
+
//#region src/decodeLayerData.ts
|
|
13
5
|
/** Read a little-endian Uint32 GID array out of a decoded byte buffer. */
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
gids[i] = view.getUint32(i * 4, true); // Tiled writes little-endian.
|
|
23
|
-
}
|
|
24
|
-
return gids;
|
|
25
|
-
}
|
|
6
|
+
const bytesToGids = (bytes, source, path) => {
|
|
7
|
+
if (bytes.length % 4 !== 0) throw new TiledFormatError(source, path, `decoded tile data length ${bytes.length} is not a multiple of 4`);
|
|
8
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
9
|
+
const count = bytes.length / 4;
|
|
10
|
+
const gids = new Array(count);
|
|
11
|
+
for (let i = 0; i < count; i++) gids[i] = view.getUint32(i * 4, true);
|
|
12
|
+
return gids;
|
|
13
|
+
};
|
|
26
14
|
/** Decode one base64 `data` string into a GID array, applying any compression. */
|
|
27
|
-
async
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
else if (compression === 'zstd') {
|
|
36
|
-
throw new TiledFormatError(source, path, 'zstd-compressed tile data is not supported (no native decoder; re-export with gzip/zlib or uncompressed)');
|
|
37
|
-
}
|
|
38
|
-
else if (compression !== undefined && compression !== '') {
|
|
39
|
-
throw new TiledFormatError(source, path, `unsupported tile layer compression ${JSON.stringify(compression)}`);
|
|
40
|
-
}
|
|
41
|
-
return bytesToGids(bytes, source, path);
|
|
42
|
-
}
|
|
15
|
+
const decodeBase64Gids = async (data, compression, source, path) => {
|
|
16
|
+
let bytes = Codec.decodeBase64(data);
|
|
17
|
+
if (compression === "gzip") bytes = await Codec.decompress(bytes, "gzip");
|
|
18
|
+
else if (compression === "zlib") bytes = await Codec.decompress(bytes, "deflate");
|
|
19
|
+
else if (compression === "zstd") throw new TiledFormatError(source, path, "zstd-compressed tile data is not supported (no native decoder; re-export with gzip/zlib or uncompressed)");
|
|
20
|
+
else if (compression !== void 0 && compression !== "") throw new TiledFormatError(source, path, `unsupported tile layer compression ${JSON.stringify(compression)}`);
|
|
21
|
+
return bytesToGids(bytes, source, path);
|
|
22
|
+
};
|
|
43
23
|
/** Decode a single tile layer's `data` and/or `chunks[].data` in place. */
|
|
44
|
-
async
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const c = chunk;
|
|
56
|
-
if (typeof c.data === 'string') {
|
|
57
|
-
c.data = await decodeBase64Gids(c.data, layer.compression, source, `${path}.chunks[${i}].data`);
|
|
58
|
-
}
|
|
59
|
-
}));
|
|
60
|
-
}
|
|
61
|
-
// Now that data is a plain GID array, drop the encoding/compression markers so
|
|
62
|
-
// downstream validation treats it like a CSV layer.
|
|
63
|
-
delete layer.encoding;
|
|
64
|
-
delete layer.compression;
|
|
65
|
-
}
|
|
24
|
+
const decodeTileLayer = async (layer, source, path) => {
|
|
25
|
+
if (layer.encoding !== "base64") return;
|
|
26
|
+
if (typeof layer.data === "string") layer.data = await decodeBase64Gids(layer.data, layer.compression, source, `${path}.data`);
|
|
27
|
+
if (Array.isArray(layer.chunks)) await Promise.all(layer.chunks.map(async (chunk, i) => {
|
|
28
|
+
if (typeof chunk !== "object" || chunk === null) return;
|
|
29
|
+
const c = chunk;
|
|
30
|
+
if (typeof c.data === "string") c.data = await decodeBase64Gids(c.data, layer.compression, source, `${path}.chunks[${i}].data`);
|
|
31
|
+
}));
|
|
32
|
+
delete layer.encoding;
|
|
33
|
+
delete layer.compression;
|
|
34
|
+
};
|
|
66
35
|
/** Recursively decode every tile layer under a `layers` array (groups nest). */
|
|
67
|
-
async
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
await decodeTileLayer(l, source, layerPath);
|
|
78
|
-
}
|
|
79
|
-
else if (l.type === 'group') {
|
|
80
|
-
await decodeLayers(l.layers, source, `${layerPath}.layers`);
|
|
81
|
-
}
|
|
82
|
-
}));
|
|
83
|
-
}
|
|
36
|
+
const decodeLayers = async (layers, source, path) => {
|
|
37
|
+
if (!Array.isArray(layers)) return;
|
|
38
|
+
await Promise.all(layers.map(async (layer, i) => {
|
|
39
|
+
if (typeof layer !== "object" || layer === null) return;
|
|
40
|
+
const l = layer;
|
|
41
|
+
const layerPath = `${path}[${i}]`;
|
|
42
|
+
if (l.type === "tilelayer") await decodeTileLayer(l, source, layerPath);
|
|
43
|
+
else if (l.type === "group") await decodeLayers(l.layers, source, `${layerPath}.layers`);
|
|
44
|
+
}));
|
|
45
|
+
};
|
|
84
46
|
/**
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
async
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
return raw;
|
|
97
|
-
}
|
|
47
|
+
* Decode any base64/compressed tile-layer data in a raw Tiled map document into
|
|
48
|
+
* plain GID arrays, mutating `raw` in place and returning it. Safe to call on a
|
|
49
|
+
* pure-CSV map (it does nothing). Runs before validation.
|
|
50
|
+
*
|
|
51
|
+
* @throws {TiledFormatError} On zstd/unknown compression or malformed data.
|
|
52
|
+
* @internal
|
|
53
|
+
*/
|
|
54
|
+
const decodeTiledLayerData = async (raw, source) => {
|
|
55
|
+
if (typeof raw === "object" && raw !== null) await decodeLayers(raw.layers, source, "layers");
|
|
56
|
+
return raw;
|
|
57
|
+
};
|
|
98
58
|
|
|
59
|
+
//#endregion
|
|
99
60
|
export { decodeTiledLayerData };
|
|
100
|
-
//# sourceMappingURL=decodeLayerData.js.map
|
|
61
|
+
//# sourceMappingURL=decodeLayerData.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decodeLayerData.js","sources":["
|
|
1
|
+
{"version":3,"file":"decodeLayerData.js","names":[],"sources":["../../src/decodeLayerData.ts"],"sourcesContent":["// Pre-validation decode pass for Tiled tile-layer data.\n//\n// Tiled can store tile-layer GIDs as plain CSV (a JSON array), or as a base64\n// string that is optionally gzip/zlib/zstd compressed. The rest of the pipeline\n// (validation, `TiledMap`, `toTileMap`) only deals with the decoded `number[]`\n// GID array, so this pass runs first - during the async load phase - and\n// rewrites any base64/compressed `data` (and infinite-map `chunks[].data`) into\n// plain GID arrays in place. After it runs, the document looks like a CSV map to\n// every downstream stage, which stays synchronous and unchanged.\n\nimport { Codec } from '@codexo/exojs';\n\nimport { TiledFormatError } from './validate';\n\n/** Read a little-endian Uint32 GID array out of a decoded byte buffer. */\nconst bytesToGids = (bytes: Uint8Array, source: string, path: string): number[] => {\n if (bytes.length % 4 !== 0) {\n throw new TiledFormatError(source, path, `decoded tile data length ${bytes.length} is not a multiple of 4`);\n }\n const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n const count = bytes.length / 4;\n const gids = new Array<number>(count);\n for (let i = 0; i < count; i++) {\n gids[i] = view.getUint32(i * 4, true); // Tiled writes little-endian.\n }\n return gids;\n};\n\n/** Decode one base64 `data` string into a GID array, applying any compression. */\nconst decodeBase64Gids = async (data: string, compression: unknown, source: string, path: string): Promise<number[]> => {\n let bytes = Codec.decodeBase64(data);\n\n if (compression === 'gzip') {\n bytes = await Codec.decompress(bytes, 'gzip');\n } else if (compression === 'zlib') {\n bytes = await Codec.decompress(bytes, 'deflate');\n } else if (compression === 'zstd') {\n throw new TiledFormatError(source, path, 'zstd-compressed tile data is not supported (no native decoder; re-export with gzip/zlib or uncompressed)');\n } else if (compression !== undefined && compression !== '') {\n throw new TiledFormatError(source, path, `unsupported tile layer compression ${JSON.stringify(compression)}`);\n }\n\n return bytesToGids(bytes, source, path);\n};\n\n/** Decode a single tile layer's `data` and/or `chunks[].data` in place. */\nconst decodeTileLayer = async (layer: Record<string, unknown>, source: string, path: string): Promise<void> => {\n if (layer.encoding !== 'base64') {\n return; // CSV / plain array — nothing to decode.\n }\n\n if (typeof layer.data === 'string') {\n layer.data = await decodeBase64Gids(layer.data, layer.compression, source, `${path}.data`);\n }\n\n if (Array.isArray(layer.chunks)) {\n await Promise.all(\n (layer.chunks as unknown[]).map(async (chunk, i) => {\n if (typeof chunk !== 'object' || chunk === null) return;\n const c = chunk as Record<string, unknown>;\n if (typeof c.data === 'string') {\n c.data = await decodeBase64Gids(c.data, layer.compression, source, `${path}.chunks[${i}].data`);\n }\n }),\n );\n }\n\n // Now that data is a plain GID array, drop the encoding/compression markers so\n // downstream validation treats it like a CSV layer.\n delete layer.encoding;\n delete layer.compression;\n};\n\n/** Recursively decode every tile layer under a `layers` array (groups nest). */\nconst decodeLayers = async (layers: unknown, source: string, path: string): Promise<void> => {\n if (!Array.isArray(layers)) {\n return;\n }\n await Promise.all(\n (layers as unknown[]).map(async (layer, i) => {\n if (typeof layer !== 'object' || layer === null) return;\n const l = layer as Record<string, unknown>;\n const layerPath = `${path}[${i}]`;\n if (l.type === 'tilelayer') {\n await decodeTileLayer(l, source, layerPath);\n } else if (l.type === 'group') {\n await decodeLayers(l.layers, source, `${layerPath}.layers`);\n }\n }),\n );\n};\n\n/**\n * Decode any base64/compressed tile-layer data in a raw Tiled map document into\n * plain GID arrays, mutating `raw` in place and returning it. Safe to call on a\n * pure-CSV map (it does nothing). Runs before validation.\n *\n * @throws {TiledFormatError} On zstd/unknown compression or malformed data.\n * @internal\n */\nexport const decodeTiledLayerData = async (raw: unknown, source: string): Promise<unknown> => {\n if (typeof raw === 'object' && raw !== null) {\n await decodeLayers((raw as Record<string, unknown>).layers, source, 'layers');\n }\n return raw;\n};\n"],"mappings":";;;;;AAeA,MAAM,eAAe,OAAmB,QAAgB,SAA2B;CACjF,IAAI,MAAM,SAAS,MAAM,GACvB,MAAM,IAAI,iBAAiB,QAAQ,MAAM,4BAA4B,MAAM,OAAO,wBAAwB;CAE5G,MAAM,OAAO,IAAI,SAAS,MAAM,QAAQ,MAAM,YAAY,MAAM,UAAU;CAC1E,MAAM,QAAQ,MAAM,SAAS;CAC7B,MAAM,OAAO,IAAI,MAAc,KAAK;CACpC,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,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;EACjD,MAAM,IAAI;EACV,MAAM,YAAY,GAAG,KAAK,GAAG,EAAE;EAC/B,IAAI,EAAE,SAAS,aACb,MAAM,gBAAgB,GAAG,QAAQ,SAAS;OACrC,IAAI,EAAE,SAAS,SACpB,MAAM,aAAa,EAAE,QAAQ,QAAQ,GAAG,UAAU,QAAQ;CAE9D,CAAC,CACH;AACF;;;;;;;;;AAUA,MAAa,uBAAuB,OAAO,KAAc,WAAqC;CAC5F,IAAI,OAAO,QAAQ,YAAY,QAAQ,MACrC,MAAM,aAAc,IAAgC,QAAQ,QAAQ,QAAQ;CAE9E,OAAO;AACT"}
|
package/dist/esm/gid.d.ts
CHANGED
|
@@ -10,4 +10,5 @@ export declare const TILED_ROTATED_HEXAGONAL_120_FLAG = 268435456;
|
|
|
10
10
|
* value is first coerced to an unsigned 32-bit integer via `>>> 0`.
|
|
11
11
|
* @internal
|
|
12
12
|
*/
|
|
13
|
-
export declare
|
|
13
|
+
export declare const maskTiledGid: (raw: number) => number;
|
|
14
|
+
//# sourceMappingURL=gid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gid.d.ts","sourceRoot":"","sources":["../../src/gid.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,+BAA+B,aAAa,CAAC;AAC1D,eAAO,MAAM,6BAA6B,aAAa,CAAC;AACxD,eAAO,MAAM,6BAA6B,YAAa,CAAC;AACxD,eAAO,MAAM,gCAAgC,YAAa,CAAC;AAK3D;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,GAAI,KAAK,MAAM,KAAG,MAAsC,CAAC"}
|
package/dist/esm/gid.js
CHANGED
|
@@ -1,28 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
// These constants exist only to mask flip bits off before resolving a GID
|
|
6
|
-
// against a tileset's [firstgid, firstgid + tilecount) range during source
|
|
7
|
-
// validation. Converting flip bits into a runtime `TileTransform` is a C2
|
|
8
|
-
// (runtime conversion) concern and is intentionally not implemented here.
|
|
9
|
-
// @internal
|
|
10
|
-
const TILED_FLIPPED_HORIZONTALLY_FLAG = 0x80000000;
|
|
11
|
-
const TILED_FLIPPED_VERTICALLY_FLAG = 0x40000000;
|
|
12
|
-
const TILED_FLIPPED_DIAGONALLY_FLAG = 0x20000000;
|
|
1
|
+
//#region src/gid.ts
|
|
2
|
+
const TILED_FLIPPED_HORIZONTALLY_FLAG = 2147483648;
|
|
3
|
+
const TILED_FLIPPED_VERTICALLY_FLAG = 1073741824;
|
|
4
|
+
const TILED_FLIPPED_DIAGONALLY_FLAG = 536870912;
|
|
13
5
|
/** Mask isolating the 28-bit tile id, clearing all four flip/rotation flag bits. */
|
|
14
|
-
const TILED_GID_MASK =
|
|
6
|
+
const TILED_GID_MASK = 268435455;
|
|
15
7
|
/**
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return (raw >>> 0) & TILED_GID_MASK;
|
|
25
|
-
}
|
|
8
|
+
* Strips the flip/rotation flag bits from a raw Tiled GID, returning the
|
|
9
|
+
* plain tileset-relative global tile id (0 = empty cell).
|
|
10
|
+
*
|
|
11
|
+
* GIDs may exceed `2^31` (the horizontal-flip flag alone is `2^31`), so the
|
|
12
|
+
* value is first coerced to an unsigned 32-bit integer via `>>> 0`.
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
const maskTiledGid = (raw) => raw >>> 0 & TILED_GID_MASK;
|
|
26
16
|
|
|
17
|
+
//#endregion
|
|
27
18
|
export { TILED_FLIPPED_DIAGONALLY_FLAG, TILED_FLIPPED_HORIZONTALLY_FLAG, TILED_FLIPPED_VERTICALLY_FLAG, maskTiledGid };
|
|
28
|
-
//# sourceMappingURL=gid.js.map
|
|
19
|
+
//# sourceMappingURL=gid.js.map
|
package/dist/esm/gid.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gid.js","sources":["
|
|
1
|
+
{"version":3,"file":"gid.js","names":[],"sources":["../../src/gid.ts"],"sourcesContent":["// Tiled GID flip-flag bits (TMJ tile-layer `data` / object `gid` values).\n// The high four bits of a 32-bit GID encode flip/rotation state; the\n// remaining 28 bits are the actual tileset-relative global tile id.\n//\n// These constants exist only to mask flip bits off before resolving a GID\n// against a tileset's [firstgid, firstgid + tilecount) range during source\n// validation. Converting flip bits into a runtime `TileTransform` is a C2\n// (runtime conversion) concern and is intentionally not implemented here.\n// @internal\n\nexport const TILED_FLIPPED_HORIZONTALLY_FLAG = 0x80000000;\nexport const TILED_FLIPPED_VERTICALLY_FLAG = 0x40000000;\nexport const TILED_FLIPPED_DIAGONALLY_FLAG = 0x20000000;\nexport const TILED_ROTATED_HEXAGONAL_120_FLAG = 0x10000000;\n\n/** Mask isolating the 28-bit tile id, clearing all four flip/rotation flag bits. */\nconst TILED_GID_MASK = 0x0fffffff;\n\n/**\n * Strips the flip/rotation flag bits from a raw Tiled GID, returning the\n * plain tileset-relative global tile id (0 = empty cell).\n *\n * GIDs may exceed `2^31` (the horizontal-flip flag alone is `2^31`), so the\n * value is first coerced to an unsigned 32-bit integer via `>>> 0`.\n * @internal\n */\nexport const maskTiledGid = (raw: number): number => (raw >>> 0) & TILED_GID_MASK;\n"],"mappings":";AAUA,MAAa,kCAAkC;AAC/C,MAAa,gCAAgC;AAC7C,MAAa,gCAAgC;;AAI7C,MAAM,iBAAiB;;;;;;;;;AAUvB,MAAa,gBAAgB,QAAyB,QAAQ,IAAK"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,UAAU,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { tiledBuildInfo } from "./tiledBuildInfo.js";
|
|
2
|
+
import { TILED_OBJECT_ALIGNMENTS, getTiledObjectAnchorOffset, resolveTiledObjectAlignment } from "./objectAlignment.js";
|
|
3
|
+
import { TiledFormatError } from "./validate.js";
|
|
4
|
+
import { TiledObject } from "./TiledObject.js";
|
|
5
|
+
import { TiledGroupLayer, TiledImageLayer, TiledLayer, TiledObjectLayer, TiledTileLayer, createTiledLayer } from "./TiledLayer.js";
|
|
6
|
+
import { TiledMap } from "./TiledMap.js";
|
|
7
|
+
import { TiledTileset } from "./TiledTileset.js";
|
|
8
|
+
import { TiledSourceAssetType, tiledSourceType } from "./tiledSourceType.js";
|
|
9
|
+
import { TileMapAssetType, tileMapType } from "./tileMapType.js";
|
|
10
|
+
import { tiledExtension } from "./tiledExtension.js";
|
|
11
|
+
import { tiledWangSetToWangSet } from "./wangSets.js";
|
|
12
|
+
import { MapLevelRuntime, MapLevelSide, MapObjectSpawner, MapSpawnError, MapSpawnSession, MapWorld, MapWorldRuntime, ObjectLayer, TILE_TRANSFORM_IDENTITY, TileLayer, TileLayerNode, TileMap, TileMapBand, TileMapNode, TileMapView, TileSet, WangSet, mapObjectDescriptor, mapObjectDescriptors, tilemapExtension } from "./public.js";
|
|
13
|
+
|
|
14
|
+
export { MapLevelRuntime, MapLevelSide, MapObjectSpawner, MapSpawnError, MapSpawnSession, MapWorld, MapWorldRuntime, ObjectLayer, TILED_OBJECT_ALIGNMENTS, TILE_TRANSFORM_IDENTITY, TileLayer, TileLayerNode, TileMap, TileMapAssetType, TileMapBand, TileMapNode, TileMapView, TileSet, TiledFormatError, TiledGroupLayer, TiledImageLayer, TiledLayer, TiledMap, TiledObject, TiledObjectLayer, TiledSourceAssetType, TiledTileLayer, TiledTileset, WangSet, createTiledLayer, getTiledObjectAnchorOffset, mapObjectDescriptor, mapObjectDescriptors, resolveTiledObjectAlignment, tileMapType, tiledBuildInfo, tiledExtension, tiledSourceType, tiledWangSetToWangSet, tilemapExtension };
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { AssetFactoryContext } from '@codexo/exojs';
|
|
2
|
+
import type { TiledMapData } from './data';
|
|
2
3
|
import { TiledMap } from './TiledMap';
|
|
4
|
+
import type { TiledLoadOptions } from './tiledOptions';
|
|
5
|
+
/** What every step below needs from the load it belongs to. */
|
|
6
|
+
type TiledContext = AssetFactoryContext<TiledLoadOptions>;
|
|
3
7
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
8
|
+
* Assembles a validated Tiled document into a {@link TiledMap}: resolves every
|
|
9
|
+
* tileset (external `.tsj` or embedded) and its images, loads every image
|
|
10
|
+
* layer's texture, and validates the GIDs against the assembled tilesets.
|
|
7
11
|
* @internal
|
|
8
12
|
*/
|
|
9
|
-
export declare
|
|
13
|
+
export declare const loadTiledMap: (data: TiledMapData, context: TiledContext) => Promise<TiledMap>;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=loadTiledMap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loadTiledMap.d.ts","sourceRoot":"","sources":["../../src/loadTiledMap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAW,MAAM,eAAe,CAAC;AAGlE,OAAO,KAAK,EAAkB,YAAY,EAAyC,MAAM,QAAQ,CAAC;AAClG,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAKvD,+DAA+D;AAC/D,KAAK,YAAY,GAAG,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;AAyF1D;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAU,MAAM,YAAY,EAAE,SAAS,YAAY,KAAG,OAAO,CAAC,QAAQ,CAQ9F,CAAC"}
|