@codexo/exojs-tiled 0.13.0 → 0.15.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/esm/TiledLayer.d.ts +3 -3
- package/dist/esm/TiledMap.d.ts +8 -6
- package/dist/esm/TiledMap.js +355 -34
- package/dist/esm/TiledMap.js.map +1 -1
- package/dist/esm/TiledObject.d.ts +5 -5
- package/dist/esm/TiledTileset.d.ts +13 -11
- package/dist/esm/TiledTileset.js +3 -0
- package/dist/esm/TiledTileset.js.map +1 -1
- package/dist/esm/data.d.ts +101 -59
- package/dist/esm/decodeLayerData.d.ts +9 -0
- package/dist/esm/decodeLayerData.js +100 -0
- package/dist/esm/decodeLayerData.js.map +1 -0
- package/dist/esm/index.js +2 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/loadTiledMap.js +32 -2
- package/dist/esm/loadTiledMap.js.map +1 -1
- package/dist/esm/public.d.ts +4 -3
- package/dist/esm/register.js +2 -1
- package/dist/esm/register.js.map +1 -1
- package/dist/esm/tiledBuildInfo.js +2 -2
- package/dist/esm/validate.js +38 -0
- package/dist/esm/validate.js.map +1 -1
- package/dist/esm/wangSets.d.ts +43 -0
- package/dist/esm/wangSets.js +127 -0
- package/dist/esm/wangSets.js.map +1 -0
- package/package.json +5 -5
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Texture } from '@codexo/exojs';
|
|
2
|
-
import type { TiledPointData, TiledPropertyData, TiledTileData, TiledTilesetData } from './data';
|
|
2
|
+
import type { TiledPointData, TiledPropertyData, TiledTileData, TiledTilesetData, TiledWangSetData } from './data';
|
|
3
3
|
/**
|
|
4
4
|
* Loader-resolved resources for a {@link TiledTileset}: the absolute image
|
|
5
5
|
* URL(s) and the {@link Texture} instance(s) loaded for them. All textures
|
|
@@ -8,13 +8,13 @@ import type { TiledPointData, TiledPropertyData, TiledTileData, TiledTilesetData
|
|
|
8
8
|
*/
|
|
9
9
|
export interface TiledTilesetResources {
|
|
10
10
|
/** Resolved URL of the external `.tsj` file, or `undefined` for an embedded tileset. */
|
|
11
|
-
readonly source?: string;
|
|
11
|
+
readonly source?: string | undefined;
|
|
12
12
|
/** Resolved URL of the tileset's atlas {@link TiledTilesetData.image}, or `undefined` for a collection-of-images tileset. */
|
|
13
|
-
readonly imageUrl?: string;
|
|
13
|
+
readonly imageUrl?: string | undefined;
|
|
14
14
|
/** Texture loaded for {@link imageUrl}. */
|
|
15
|
-
readonly texture?: Texture;
|
|
15
|
+
readonly texture?: Texture | undefined;
|
|
16
16
|
/** Textures loaded for collection-of-images {@link TiledTileData.image} entries, keyed by local tile id. */
|
|
17
|
-
readonly tileTextures?: ReadonlyMap<number, Texture
|
|
17
|
+
readonly tileTextures?: ReadonlyMap<number, Texture> | undefined;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* A parsed Tiled tileset — either embedded inline in a map's `tilesets`
|
|
@@ -28,7 +28,7 @@ export declare class TiledTileset {
|
|
|
28
28
|
/** First global tile id owned by this tileset. */
|
|
29
29
|
readonly firstGid: number;
|
|
30
30
|
/** Resolved URL of the external `.tsj` file, or `undefined` for an embedded tileset. */
|
|
31
|
-
readonly source?: string;
|
|
31
|
+
readonly source?: string | undefined;
|
|
32
32
|
readonly name: string;
|
|
33
33
|
readonly class: string;
|
|
34
34
|
readonly tileWidth: number;
|
|
@@ -38,14 +38,16 @@ export declare class TiledTileset {
|
|
|
38
38
|
readonly spacing: number;
|
|
39
39
|
readonly margin: number;
|
|
40
40
|
/** Resolved URL of the tileset's atlas image, or `undefined` for a collection-of-images tileset. */
|
|
41
|
-
readonly imageUrl?: string;
|
|
42
|
-
readonly imageWidth?: number;
|
|
43
|
-
readonly imageHeight?: number;
|
|
41
|
+
readonly imageUrl?: string | undefined;
|
|
42
|
+
readonly imageWidth?: number | undefined;
|
|
43
|
+
readonly imageHeight?: number | undefined;
|
|
44
44
|
/** Texture loaded for {@link imageUrl}. Loader-owned; not destroyed by {@link TiledMap.destroy}. */
|
|
45
|
-
readonly texture?: Texture;
|
|
45
|
+
readonly texture?: Texture | undefined;
|
|
46
46
|
readonly tileOffset: TiledPointData;
|
|
47
|
-
readonly objectAlignment?: string;
|
|
47
|
+
readonly objectAlignment?: string | undefined;
|
|
48
48
|
readonly tiles: readonly TiledTileData[];
|
|
49
|
+
/** Wang sets (terrain/auto-tile definitions) declared on this tileset. Empty when none are defined. */
|
|
50
|
+
readonly wangSets: readonly TiledWangSetData[];
|
|
49
51
|
/** Textures loaded for collection-of-images tiles, keyed by local tile id. Loader-owned. */
|
|
50
52
|
readonly tileTextures: ReadonlyMap<number, Texture>;
|
|
51
53
|
readonly properties: readonly TiledPropertyData[];
|
package/dist/esm/TiledTileset.js
CHANGED
|
@@ -28,6 +28,8 @@ class TiledTileset {
|
|
|
28
28
|
tileOffset;
|
|
29
29
|
objectAlignment;
|
|
30
30
|
tiles;
|
|
31
|
+
/** Wang sets (terrain/auto-tile definitions) declared on this tileset. Empty when none are defined. */
|
|
32
|
+
wangSets;
|
|
31
33
|
/** Textures loaded for collection-of-images tiles, keyed by local tile id. Loader-owned. */
|
|
32
34
|
tileTextures;
|
|
33
35
|
properties;
|
|
@@ -49,6 +51,7 @@ class TiledTileset {
|
|
|
49
51
|
this.tileOffset = data.tileoffset ?? { x: 0, y: 0 };
|
|
50
52
|
this.objectAlignment = data.objectalignment;
|
|
51
53
|
this.tiles = data.tiles ?? [];
|
|
54
|
+
this.wangSets = data.wangsets ?? [];
|
|
52
55
|
this.tileTextures = resources.tileTextures ?? new Map();
|
|
53
56
|
this.properties = data.properties ?? [];
|
|
54
57
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TiledTileset.js","sources":["../../../src/TiledTileset.ts"],"sourcesContent":[null],"names":[],"mappings":"AAqBA;;;;;;;AAOG;MACU,YAAY,CAAA;;AAEP,IAAA,QAAQ;;AAER,IAAA,MAAM;AACN,IAAA,IAAI;AACJ,IAAA,KAAK;AACL,IAAA,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QAAQ,GAAG,IAAI,CAAC,SAAS,GAAG,CAAC;IAC3C;;AAGO,IAAA,OAAO,CAAC,OAAe,EAAA;AAC5B,QAAA,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,EAAE,KAAK,OAAO,CAAC;IACrD;;AAGO,IAAA,WAAW,CAAC,IAAY,EAAA;AAC7B,QAAA,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,IAAI,KAAK,IAAI,CAAC;IACjE;AACD;;;;"}
|
package/dist/esm/data.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export interface TiledClassPropertyValueData {
|
|
|
26
26
|
export interface TiledPropertyData {
|
|
27
27
|
readonly name: string;
|
|
28
28
|
readonly type: TiledPropertyType;
|
|
29
|
-
readonly propertytype?: string;
|
|
29
|
+
readonly propertytype?: string | undefined;
|
|
30
30
|
readonly value: string | number | boolean | TiledClassPropertyValueData;
|
|
31
31
|
}
|
|
32
32
|
/** One frame of a tile's animation sequence. */
|
|
@@ -45,15 +45,56 @@ export interface TiledTileData {
|
|
|
45
45
|
/** Local tile id within the owning tileset. */
|
|
46
46
|
readonly id: number;
|
|
47
47
|
/** Tile class (`class`/`type` field depending on Tiled version). */
|
|
48
|
-
readonly type?: string;
|
|
49
|
-
readonly properties?: readonly TiledPropertyData[];
|
|
50
|
-
readonly animation?: readonly TiledAnimationFrameData[];
|
|
48
|
+
readonly type?: string | undefined;
|
|
49
|
+
readonly properties?: readonly TiledPropertyData[] | undefined;
|
|
50
|
+
readonly animation?: readonly TiledAnimationFrameData[] | undefined;
|
|
51
51
|
/** Per-tile collision shapes, structurally identical to an object layer. */
|
|
52
|
-
readonly objectgroup?: TiledObjectLayerData;
|
|
52
|
+
readonly objectgroup?: TiledObjectLayerData | undefined;
|
|
53
53
|
/** Collection-of-images tile source, relative to the tileset's location. */
|
|
54
|
-
readonly image?: string;
|
|
55
|
-
readonly imagewidth?: number;
|
|
56
|
-
readonly imageheight?: number;
|
|
54
|
+
readonly image?: string | undefined;
|
|
55
|
+
readonly imagewidth?: number | undefined;
|
|
56
|
+
readonly imageheight?: number | undefined;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* One color (terrain) entry within a wangset's `colors` array.
|
|
60
|
+
*
|
|
61
|
+
* `tile` is the representative tile local id for this color (–1 if unset).
|
|
62
|
+
* `probability` is the relative spawn weight used by Tiled's random fill.
|
|
63
|
+
*/
|
|
64
|
+
export interface TiledWangColorData {
|
|
65
|
+
readonly name: string;
|
|
66
|
+
readonly color: string;
|
|
67
|
+
readonly tile: number;
|
|
68
|
+
readonly probability: number;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* One wang-tile entry within a wangset's `wangtiles` array.
|
|
72
|
+
*
|
|
73
|
+
* `tileid` is the local tile id within the owning tileset.
|
|
74
|
+
*
|
|
75
|
+
* `wangid` is an 8-element array of color indices (1-based; 0 = unset) whose
|
|
76
|
+
* positions correspond to (in order): top, top-right, right, bottom-right,
|
|
77
|
+
* bottom, bottom-left, left, top-left.
|
|
78
|
+
*/
|
|
79
|
+
export interface TiledWangTileData {
|
|
80
|
+
readonly tileid: number;
|
|
81
|
+
readonly wangid: readonly number[];
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* A wangset entry within a tileset's `wangsets` array.
|
|
85
|
+
*
|
|
86
|
+
* `type` is `'corner'`, `'edge'`, or `'mixed'` (Tiled 1.5+). Older files may
|
|
87
|
+
* omit it or use other strings — treat unknown values as-is.
|
|
88
|
+
*
|
|
89
|
+
* `tile` is the representative tile local id for this wangset (–1 if unset).
|
|
90
|
+
*/
|
|
91
|
+
export interface TiledWangSetData {
|
|
92
|
+
readonly name: string;
|
|
93
|
+
readonly type: string;
|
|
94
|
+
readonly tile: number;
|
|
95
|
+
readonly colors: readonly TiledWangColorData[];
|
|
96
|
+
readonly wangtiles: readonly TiledWangTileData[];
|
|
97
|
+
readonly properties?: readonly TiledPropertyData[] | undefined;
|
|
57
98
|
}
|
|
58
99
|
/**
|
|
59
100
|
* A Tiled tileset, as the root of a standalone `.tsj` file or (minus
|
|
@@ -61,23 +102,24 @@ export interface TiledTileData {
|
|
|
61
102
|
*/
|
|
62
103
|
export interface TiledTilesetData {
|
|
63
104
|
readonly name: string;
|
|
64
|
-
readonly class?: string;
|
|
105
|
+
readonly class?: string | undefined;
|
|
65
106
|
readonly tilewidth: number;
|
|
66
107
|
readonly tileheight: number;
|
|
67
108
|
readonly tilecount: number;
|
|
68
109
|
readonly columns: number;
|
|
69
|
-
readonly spacing?: number;
|
|
70
|
-
readonly margin?: number;
|
|
110
|
+
readonly spacing?: number | undefined;
|
|
111
|
+
readonly margin?: number | undefined;
|
|
71
112
|
/** Single-image ("atlas") tileset source, relative to the tileset's location. Absent for collection-of-images tilesets. */
|
|
72
|
-
readonly image?: string;
|
|
73
|
-
readonly imagewidth?: number;
|
|
74
|
-
readonly imageheight?: number;
|
|
75
|
-
readonly tileoffset?: TiledPointData;
|
|
76
|
-
readonly objectalignment?: string;
|
|
77
|
-
readonly tiles?: readonly TiledTileData[];
|
|
78
|
-
readonly
|
|
79
|
-
readonly
|
|
80
|
-
readonly
|
|
113
|
+
readonly image?: string | undefined;
|
|
114
|
+
readonly imagewidth?: number | undefined;
|
|
115
|
+
readonly imageheight?: number | undefined;
|
|
116
|
+
readonly tileoffset?: TiledPointData | undefined;
|
|
117
|
+
readonly objectalignment?: string | undefined;
|
|
118
|
+
readonly tiles?: readonly TiledTileData[] | undefined;
|
|
119
|
+
readonly wangsets?: readonly TiledWangSetData[] | undefined;
|
|
120
|
+
readonly properties?: readonly TiledPropertyData[] | undefined;
|
|
121
|
+
readonly tiledversion?: string | undefined;
|
|
122
|
+
readonly version?: string | number | undefined;
|
|
81
123
|
}
|
|
82
124
|
/** A map's `tilesets[]` entry referencing an external `.tsj` file by relative path. */
|
|
83
125
|
export interface TiledExternalTilesetRefData {
|
|
@@ -93,17 +135,17 @@ export type TiledTilesetRefData = TiledExternalTilesetRefData | TiledEmbeddedTil
|
|
|
93
135
|
/** Text rendering options for a `text` object (object layers). */
|
|
94
136
|
export interface TiledTextData {
|
|
95
137
|
readonly text: string;
|
|
96
|
-
readonly bold?: boolean;
|
|
97
|
-
readonly color?: string;
|
|
98
|
-
readonly fontfamily?: string;
|
|
99
|
-
readonly halign?: 'center' | 'right' | 'justify' | 'left';
|
|
100
|
-
readonly italic?: boolean;
|
|
101
|
-
readonly kerning?: boolean;
|
|
102
|
-
readonly pixelsize?: number;
|
|
103
|
-
readonly strikeout?: boolean;
|
|
104
|
-
readonly underline?: boolean;
|
|
105
|
-
readonly valign?: 'center' | 'bottom' | 'top';
|
|
106
|
-
readonly wrap?: boolean;
|
|
138
|
+
readonly bold?: boolean | undefined;
|
|
139
|
+
readonly color?: string | undefined;
|
|
140
|
+
readonly fontfamily?: string | undefined;
|
|
141
|
+
readonly halign?: 'center' | 'right' | 'justify' | 'left' | undefined;
|
|
142
|
+
readonly italic?: boolean | undefined;
|
|
143
|
+
readonly kerning?: boolean | undefined;
|
|
144
|
+
readonly pixelsize?: number | undefined;
|
|
145
|
+
readonly strikeout?: boolean | undefined;
|
|
146
|
+
readonly underline?: boolean | undefined;
|
|
147
|
+
readonly valign?: 'center' | 'bottom' | 'top' | undefined;
|
|
148
|
+
readonly wrap?: boolean | undefined;
|
|
107
149
|
}
|
|
108
150
|
/**
|
|
109
151
|
* An object placed in an object layer (or a tile's collision `objectgroup`).
|
|
@@ -123,31 +165,31 @@ export interface TiledObjectData {
|
|
|
123
165
|
readonly rotation: number;
|
|
124
166
|
readonly visible: boolean;
|
|
125
167
|
/** Tile object reference; may carry flip/rotation flag bits in the high bits. */
|
|
126
|
-
readonly gid?: number;
|
|
127
|
-
readonly point?: boolean;
|
|
128
|
-
readonly ellipse?: boolean;
|
|
129
|
-
readonly polygon?: readonly TiledPointData[];
|
|
130
|
-
readonly polyline?: readonly TiledPointData[];
|
|
131
|
-
readonly text?: TiledTextData;
|
|
168
|
+
readonly gid?: number | undefined;
|
|
169
|
+
readonly point?: boolean | undefined;
|
|
170
|
+
readonly ellipse?: boolean | undefined;
|
|
171
|
+
readonly polygon?: readonly TiledPointData[] | undefined;
|
|
172
|
+
readonly polyline?: readonly TiledPointData[] | undefined;
|
|
173
|
+
readonly text?: TiledTextData | undefined;
|
|
132
174
|
/** Path to a `.tx` object template this object was instantiated from. */
|
|
133
|
-
readonly template?: string;
|
|
134
|
-
readonly properties?: readonly TiledPropertyData[];
|
|
175
|
+
readonly template?: string | undefined;
|
|
176
|
+
readonly properties?: readonly TiledPropertyData[] | undefined;
|
|
135
177
|
}
|
|
136
178
|
/** Fields shared by every layer type. */
|
|
137
179
|
export interface TiledLayerDataBase {
|
|
138
180
|
readonly id: number;
|
|
139
181
|
readonly name: string;
|
|
140
|
-
readonly class?: string;
|
|
182
|
+
readonly class?: string | undefined;
|
|
141
183
|
readonly visible: boolean;
|
|
142
184
|
readonly opacity: number;
|
|
143
185
|
readonly x: number;
|
|
144
186
|
readonly y: number;
|
|
145
|
-
readonly offsetx?: number;
|
|
146
|
-
readonly offsety?: number;
|
|
147
|
-
readonly parallaxx?: number;
|
|
148
|
-
readonly parallaxy?: number;
|
|
149
|
-
readonly tintcolor?: string;
|
|
150
|
-
readonly properties?: readonly TiledPropertyData[];
|
|
187
|
+
readonly offsetx?: number | undefined;
|
|
188
|
+
readonly offsety?: number | undefined;
|
|
189
|
+
readonly parallaxx?: number | undefined;
|
|
190
|
+
readonly parallaxy?: number | undefined;
|
|
191
|
+
readonly tintcolor?: string | undefined;
|
|
192
|
+
readonly properties?: readonly TiledPropertyData[] | undefined;
|
|
151
193
|
}
|
|
152
194
|
/** A chunk of tile data within an infinite tile layer. */
|
|
153
195
|
export interface TiledChunkData {
|
|
@@ -165,20 +207,20 @@ export interface TiledTileLayerData extends TiledLayerDataBase {
|
|
|
165
207
|
readonly type: 'tilelayer';
|
|
166
208
|
readonly width: number;
|
|
167
209
|
readonly height: number;
|
|
168
|
-
readonly data?: readonly number[];
|
|
169
|
-
readonly chunks?: readonly TiledChunkData[];
|
|
210
|
+
readonly data?: readonly number[] | undefined;
|
|
211
|
+
readonly chunks?: readonly TiledChunkData[] | undefined;
|
|
170
212
|
}
|
|
171
213
|
export interface TiledObjectLayerData extends TiledLayerDataBase {
|
|
172
214
|
readonly type: 'objectgroup';
|
|
173
|
-
readonly draworder?: 'topdown' | 'index';
|
|
215
|
+
readonly draworder?: 'topdown' | 'index' | undefined;
|
|
174
216
|
readonly objects: readonly TiledObjectData[];
|
|
175
217
|
}
|
|
176
218
|
export interface TiledImageLayerData extends TiledLayerDataBase {
|
|
177
219
|
readonly type: 'imagelayer';
|
|
178
220
|
/** Image source, relative to the map's location. Empty string if unset. */
|
|
179
221
|
readonly image: string;
|
|
180
|
-
readonly repeatx?: boolean;
|
|
181
|
-
readonly repeaty?: boolean;
|
|
222
|
+
readonly repeatx?: boolean | undefined;
|
|
223
|
+
readonly repeaty?: boolean | undefined;
|
|
182
224
|
}
|
|
183
225
|
export interface TiledGroupLayerData extends TiledLayerDataBase {
|
|
184
226
|
readonly type: 'group';
|
|
@@ -194,10 +236,10 @@ export type TiledRenderOrder = 'right-down' | 'right-up' | 'left-down' | 'left-u
|
|
|
194
236
|
export interface TiledMapData {
|
|
195
237
|
readonly type: 'map';
|
|
196
238
|
readonly version: string | number;
|
|
197
|
-
readonly tiledversion?: string;
|
|
198
|
-
readonly class?: string;
|
|
239
|
+
readonly tiledversion?: string | undefined;
|
|
240
|
+
readonly class?: string | undefined;
|
|
199
241
|
readonly orientation: TiledOrientation;
|
|
200
|
-
readonly renderorder?: TiledRenderOrder;
|
|
242
|
+
readonly renderorder?: TiledRenderOrder | undefined;
|
|
201
243
|
/** Map width in tiles. */
|
|
202
244
|
readonly width: number;
|
|
203
245
|
/** Map height in tiles. */
|
|
@@ -207,11 +249,11 @@ export interface TiledMapData {
|
|
|
207
249
|
/** Tile grid cell height in pixels. */
|
|
208
250
|
readonly tileheight: number;
|
|
209
251
|
readonly infinite: boolean;
|
|
210
|
-
readonly compressionlevel?: number;
|
|
211
|
-
readonly nextlayerid?: number;
|
|
212
|
-
readonly nextobjectid?: number;
|
|
213
|
-
readonly backgroundcolor?: string;
|
|
252
|
+
readonly compressionlevel?: number | undefined;
|
|
253
|
+
readonly nextlayerid?: number | undefined;
|
|
254
|
+
readonly nextobjectid?: number | undefined;
|
|
255
|
+
readonly backgroundcolor?: string | undefined;
|
|
214
256
|
readonly layers: readonly TiledLayerData[];
|
|
215
257
|
readonly tilesets: readonly TiledTilesetRefData[];
|
|
216
|
-
readonly properties?: readonly TiledPropertyData[];
|
|
258
|
+
readonly properties?: readonly TiledPropertyData[] | undefined;
|
|
217
259
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decode any base64/compressed tile-layer data in a raw Tiled map document into
|
|
3
|
+
* plain GID arrays, mutating `raw` in place and returning it. Safe to call on a
|
|
4
|
+
* pure-CSV map (it does nothing). Runs before validation.
|
|
5
|
+
*
|
|
6
|
+
* @throws {TiledFormatError} On zstd/unknown compression or malformed data.
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export declare function decodeTiledLayerData(raw: unknown, source: string): Promise<unknown>;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { Codec } from '@codexo/exojs';
|
|
2
|
+
import { TiledFormatError } from './validate.js';
|
|
3
|
+
|
|
4
|
+
// Pre-validation decode pass for Tiled tile-layer data.
|
|
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.
|
|
13
|
+
/** Read a little-endian Uint32 GID array out of a decoded byte buffer. */
|
|
14
|
+
function bytesToGids(bytes, source, path) {
|
|
15
|
+
if (bytes.length % 4 !== 0) {
|
|
16
|
+
throw new TiledFormatError(source, path, `decoded tile data length ${bytes.length} is not a multiple of 4`);
|
|
17
|
+
}
|
|
18
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
19
|
+
const count = bytes.length / 4;
|
|
20
|
+
const gids = new Array(count);
|
|
21
|
+
for (let i = 0; i < count; i++) {
|
|
22
|
+
gids[i] = view.getUint32(i * 4, true); // Tiled writes little-endian.
|
|
23
|
+
}
|
|
24
|
+
return gids;
|
|
25
|
+
}
|
|
26
|
+
/** Decode one base64 `data` string into a GID array, applying any compression. */
|
|
27
|
+
async function decodeBase64Gids(data, compression, source, path) {
|
|
28
|
+
let bytes = Codec.decodeBase64(data);
|
|
29
|
+
if (compression === 'gzip') {
|
|
30
|
+
bytes = await Codec.decompress(bytes, 'gzip');
|
|
31
|
+
}
|
|
32
|
+
else if (compression === 'zlib') {
|
|
33
|
+
bytes = await Codec.decompress(bytes, 'deflate');
|
|
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
|
+
}
|
|
43
|
+
/** Decode a single tile layer's `data` and/or `chunks[].data` in place. */
|
|
44
|
+
async function decodeTileLayer(layer, source, path) {
|
|
45
|
+
if (layer.encoding !== 'base64') {
|
|
46
|
+
return; // CSV / plain array — nothing to decode.
|
|
47
|
+
}
|
|
48
|
+
if (typeof layer.data === 'string') {
|
|
49
|
+
layer.data = await decodeBase64Gids(layer.data, layer.compression, source, `${path}.data`);
|
|
50
|
+
}
|
|
51
|
+
if (Array.isArray(layer.chunks)) {
|
|
52
|
+
await Promise.all(layer.chunks.map(async (chunk, i) => {
|
|
53
|
+
if (typeof chunk !== 'object' || chunk === null)
|
|
54
|
+
return;
|
|
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
|
+
}
|
|
66
|
+
/** Recursively decode every tile layer under a `layers` array (groups nest). */
|
|
67
|
+
async function decodeLayers(layers, source, path) {
|
|
68
|
+
if (!Array.isArray(layers)) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
await Promise.all(layers.map(async (layer, i) => {
|
|
72
|
+
if (typeof layer !== 'object' || layer === null)
|
|
73
|
+
return;
|
|
74
|
+
const l = layer;
|
|
75
|
+
const layerPath = `${path}[${i}]`;
|
|
76
|
+
if (l.type === 'tilelayer') {
|
|
77
|
+
await decodeTileLayer(l, source, layerPath);
|
|
78
|
+
}
|
|
79
|
+
else if (l.type === 'group') {
|
|
80
|
+
await decodeLayers(l.layers, source, `${layerPath}.layers`);
|
|
81
|
+
}
|
|
82
|
+
}));
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Decode any base64/compressed tile-layer data in a raw Tiled map document into
|
|
86
|
+
* plain GID arrays, mutating `raw` in place and returning it. Safe to call on a
|
|
87
|
+
* pure-CSV map (it does nothing). Runs before validation.
|
|
88
|
+
*
|
|
89
|
+
* @throws {TiledFormatError} On zstd/unknown compression or malformed data.
|
|
90
|
+
* @internal
|
|
91
|
+
*/
|
|
92
|
+
async function decodeTiledLayerData(raw, source) {
|
|
93
|
+
if (typeof raw === 'object' && raw !== null) {
|
|
94
|
+
await decodeLayers(raw.layers, source, 'layers');
|
|
95
|
+
}
|
|
96
|
+
return raw;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export { decodeTiledLayerData };
|
|
100
|
+
//# sourceMappingURL=decodeLayerData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decodeLayerData.js","sources":["../../../src/decodeLayerData.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA;AACA,SAAS,WAAW,CAAC,KAAiB,EAAE,MAAc,EAAE,IAAY,EAAA;IAClE,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,EAAE;AAC1B,QAAA,MAAM,IAAI,gBAAgB,CAAC,MAAM,EAAE,IAAI,EAAE,CAAA,yBAAA,EAA4B,KAAK,CAAC,MAAM,CAAA,uBAAA,CAAyB,CAAC;IAC7G;AACA,IAAA,MAAM,IAAI,GAAG,IAAI,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC;AAC3E,IAAA,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC;AAC9B,IAAA,MAAM,IAAI,GAAG,IAAI,KAAK,CAAS,KAAK,CAAC;AACrC,IAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE;AAC9B,QAAA,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC;IACxC;AACA,IAAA,OAAO,IAAI;AACb;AAEA;AACA,eAAe,gBAAgB,CAC7B,IAAY,EACZ,WAAoB,EACpB,MAAc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,eAAe,oBAAoB,CAAC,GAAY,EAAE,MAAc,EAAA;IACrE,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,EAAE;QAC3C,MAAM,YAAY,CAAE,GAA+B,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC;IAC/E;AACA,IAAA,OAAO,GAAG;AACZ;;;;"}
|
package/dist/esm/index.js
CHANGED
|
@@ -2,10 +2,11 @@ export { tiledBuildInfo } from './tiledBuildInfo.js';
|
|
|
2
2
|
export { tiledExtension } from './tiledExtension.js';
|
|
3
3
|
export { tiledMapBinding } from './tiledMapBinding.js';
|
|
4
4
|
export { tiledRuntimeMapBinding } from './tiledRuntimeMapBinding.js';
|
|
5
|
-
export { TILE_TRANSFORM_IDENTITY, TileLayer, TileLayerNode, TileMap, TileMapBand, TileMapNode, TileMapView, TileSet, tilemapExtension } from '@codexo/exojs-tilemap';
|
|
5
|
+
export { ObjectLayer, TILE_TRANSFORM_IDENTITY, TileLayer, TileLayerNode, TileMap, TileMapBand, TileMapNode, TileMapView, TileSet, WangSet, tilemapExtension } from '@codexo/exojs-tilemap';
|
|
6
6
|
export { TiledGroupLayer, TiledImageLayer, TiledLayer, TiledObjectLayer, TiledTileLayer, createTiledLayer } from './TiledLayer.js';
|
|
7
7
|
export { TiledMap } from './TiledMap.js';
|
|
8
8
|
export { TiledObject } from './TiledObject.js';
|
|
9
9
|
export { TiledTileset } from './TiledTileset.js';
|
|
10
|
+
export { tiledWangSetToWangSet } from './wangSets.js';
|
|
10
11
|
export { TiledFormatError } from './validate.js';
|
|
11
12
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
|
package/dist/esm/loadTiledMap.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Texture } from '@codexo/exojs';
|
|
2
|
+
import { decodeTiledLayerData } from './decodeLayerData.js';
|
|
2
3
|
import { TiledMap } from './TiledMap.js';
|
|
3
4
|
import { TiledTileset } from './TiledTileset.js';
|
|
4
5
|
import { resolveTiledUrl } from './url.js';
|
|
@@ -51,6 +52,29 @@ async function loadTiledTileset(ref, mapSource, context) {
|
|
|
51
52
|
const resources = await loadTiledTilesetResources(ref, mapSource, context);
|
|
52
53
|
return new TiledTileset(ref, ref.firstgid, resources);
|
|
53
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Recursively walks the layer tree and loads the image for every
|
|
57
|
+
* `imagelayer` encountered. Returns a `Map` keyed by layer `id` so that
|
|
58
|
+
* {@link TiledMap.toTileMap} can attach the pre-loaded {@link Texture} to each
|
|
59
|
+
* runtime image layer without performing additional I/O.
|
|
60
|
+
*/
|
|
61
|
+
async function loadImageLayerTextures(layers, mapSource, context) {
|
|
62
|
+
const result = new Map();
|
|
63
|
+
for (const layer of layers) {
|
|
64
|
+
if (layer.type === 'imagelayer' && layer.image) {
|
|
65
|
+
const imageUrl = resolveTiledUrl(layer.image, mapSource);
|
|
66
|
+
const texture = await context.loader.load(Texture, imageUrl);
|
|
67
|
+
result.set(layer.id, texture);
|
|
68
|
+
}
|
|
69
|
+
else if (layer.type === 'group') {
|
|
70
|
+
const nested = await loadImageLayerTextures(layer.layers, mapSource, context);
|
|
71
|
+
for (const [id, tex] of nested) {
|
|
72
|
+
result.set(id, tex);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
54
78
|
/**
|
|
55
79
|
* Loads and resolves a Tiled map: fetches and validates the `.tmj`, resolves
|
|
56
80
|
* each tileset (external `.tsj` or embedded) and its image(s), and returns
|
|
@@ -59,9 +83,15 @@ async function loadTiledTileset(ref, mapSource, context) {
|
|
|
59
83
|
*/
|
|
60
84
|
async function loadTiledMap(source, context) {
|
|
61
85
|
const raw = await context.fetchJson(source);
|
|
86
|
+
// Decode any base64/gzip/zlib tile-layer data into plain GID arrays before
|
|
87
|
+
// validation, so the rest of the pipeline stays CSV-shaped and synchronous.
|
|
88
|
+
await decodeTiledLayerData(raw, source);
|
|
62
89
|
const data = validateTiledMapData(raw, source);
|
|
63
|
-
const tilesets = await Promise.all(
|
|
64
|
-
|
|
90
|
+
const [tilesets, imageTextures] = await Promise.all([
|
|
91
|
+
Promise.all(data.tilesets.map(ref => loadTiledTileset(ref, source, context))),
|
|
92
|
+
loadImageLayerTextures(data.layers, source, context),
|
|
93
|
+
]);
|
|
94
|
+
return new TiledMap(source, data, tilesets, imageTextures);
|
|
65
95
|
}
|
|
66
96
|
|
|
67
97
|
export { loadTiledMap };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadTiledMap.js","sources":["../../../src/loadTiledMap.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"loadTiledMap.js","sources":["../../../src/loadTiledMap.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;AASA;;;;;;;;;AASG;AACH,eAAe,yBAAyB,CAAC,IAAsB,EAAE,OAAe,EAAE,OAA2B,EAAE,MAAe,EAAA;AAC5H,IAAA,IAAI,QAA4B;AAChC,IAAA,IAAI,OAA4B;AAEhC,IAAA,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE;QAC5B,QAAQ,GAAG,eAAe,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC;AAC/C,QAAA,OAAO,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC;IACxD;AAEA,IAAA,IAAI,YAA8C;AAElD,IAAA,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE;AAC5B,QAAA,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE;AAC7B,YAAA,IAAI,IAAI,CAAC,KAA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AAC;IAEF,OAAO,IAAI,QAAQ,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,aAAa,CAAC;AAC5D;;;;"}
|
package/dist/esm/public.d.ts
CHANGED
|
@@ -5,15 +5,16 @@ export { tiledBuildInfo } from './tiledBuildInfo';
|
|
|
5
5
|
export { tiledExtension } from './tiledExtension';
|
|
6
6
|
export { tiledMapBinding } from './tiledMapBinding';
|
|
7
7
|
export { tiledRuntimeMapBinding } from './tiledRuntimeMapBinding';
|
|
8
|
-
export type { ChunkCoord, PackedTile, ReadonlyTileChunk, ResolvedTile, TileDefinition, TileLayerNodeOptions, TileLayerOptions, TileLayerSelector, TileMapBandDefinition, TileMapNodeOptions, TileMapOptions, TileMapViewOptions, TileProperties, TilePropertyValue, TileSetOptions, TileTransform, } from '@codexo/exojs-tilemap';
|
|
9
|
-
export { TILE_TRANSFORM_IDENTITY, TileLayer, TileLayerNode, TileMap, TileMapBand, tilemapExtension, TileMapNode, TileMapView, TileSet, } from '@codexo/exojs-tilemap';
|
|
10
|
-
export type { TiledAnimationFrameData, TiledChunkData, TiledClassPropertyValueData, TiledEmbeddedTilesetRefData, TiledExternalTilesetRefData, TiledGroupLayerData, TiledImageLayerData, TiledLayerData, TiledLayerDataBase, TiledMapData, TiledObjectData, TiledObjectLayerData, TiledOrientation, TiledPointData, TiledPropertyData, TiledPropertyType, TiledRenderOrder, TiledTextData, TiledTileData, TiledTileLayerData, TiledTilesetData, TiledTilesetRefData, } from './data';
|
|
8
|
+
export type { ChunkCoord, EllipseObject, ObjectLayerOptions, ObjectPoint, ObjectQuery, PackedTile, PointObject, PolygonObject, PolylineObject, ReadonlyTileChunk, RectangleObject, ResolvedTile, TileDefinition, TileLayerNodeOptions, TileLayerOptions, TileLayerSelector, TileMapBandDefinition, TileMapNodeOptions, TileMapObject, TileMapObjectKind, TileMapOptions, TileMapViewOptions, TileObject, TileProperties, TilePropertyValue, TileSetOptions, TileTransform, WangSetOptions, } from '@codexo/exojs-tilemap';
|
|
9
|
+
export { ObjectLayer, TILE_TRANSFORM_IDENTITY, TileLayer, TileLayerNode, TileMap, TileMapBand, tilemapExtension, TileMapNode, TileMapView, TileSet, WangSet, } from '@codexo/exojs-tilemap';
|
|
10
|
+
export type { TiledAnimationFrameData, TiledChunkData, TiledClassPropertyValueData, TiledEmbeddedTilesetRefData, TiledExternalTilesetRefData, TiledGroupLayerData, TiledImageLayerData, TiledLayerData, TiledLayerDataBase, TiledMapData, TiledObjectData, TiledObjectLayerData, TiledOrientation, TiledPointData, TiledPropertyData, TiledPropertyType, TiledRenderOrder, TiledTextData, TiledTileData, TiledTileLayerData, TiledTilesetData, TiledTilesetRefData, TiledWangColorData, TiledWangSetData, TiledWangTileData, } from './data';
|
|
11
11
|
export type { TiledLayerType } from './TiledLayer';
|
|
12
12
|
export { createTiledLayer, TiledGroupLayer, TiledImageLayer, TiledLayer, TiledObjectLayer, TiledTileLayer, } from './TiledLayer';
|
|
13
13
|
export { TiledMap } from './TiledMap';
|
|
14
14
|
export { TiledObject } from './TiledObject';
|
|
15
15
|
export type { TiledTilesetResources } from './TiledTileset';
|
|
16
16
|
export { TiledTileset } from './TiledTileset';
|
|
17
|
+
export { tiledWangSetToWangSet } from './wangSets';
|
|
17
18
|
export { TiledFormatError } from './validate';
|
|
18
19
|
import type { TileMap } from '@codexo/exojs-tilemap';
|
|
19
20
|
import type { TiledMap } from './TiledMap';
|
package/dist/esm/register.js
CHANGED
|
@@ -3,11 +3,12 @@ import { tiledExtension } from './tiledExtension.js';
|
|
|
3
3
|
export { tiledBuildInfo } from './tiledBuildInfo.js';
|
|
4
4
|
export { tiledMapBinding } from './tiledMapBinding.js';
|
|
5
5
|
export { tiledRuntimeMapBinding } from './tiledRuntimeMapBinding.js';
|
|
6
|
-
export { TILE_TRANSFORM_IDENTITY, TileLayer, TileLayerNode, TileMap, TileMapBand, TileMapNode, TileMapView, TileSet, tilemapExtension } from '@codexo/exojs-tilemap';
|
|
6
|
+
export { ObjectLayer, TILE_TRANSFORM_IDENTITY, TileLayer, TileLayerNode, TileMap, TileMapBand, TileMapNode, TileMapView, TileSet, WangSet, tilemapExtension } from '@codexo/exojs-tilemap';
|
|
7
7
|
export { TiledGroupLayer, TiledImageLayer, TiledLayer, TiledObjectLayer, TiledTileLayer, createTiledLayer } from './TiledLayer.js';
|
|
8
8
|
export { TiledMap } from './TiledMap.js';
|
|
9
9
|
export { TiledObject } from './TiledObject.js';
|
|
10
10
|
export { TiledTileset } from './TiledTileset.js';
|
|
11
|
+
export { tiledWangSetToWangSet } from './wangSets.js';
|
|
11
12
|
export { TiledFormatError } from './validate.js';
|
|
12
13
|
|
|
13
14
|
// @codexo/exojs-tiled/register — explicit registration entry.
|
package/dist/esm/register.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register.js","sources":["../../../src/register.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"register.js","sources":["../../../src/register.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AAMA,iBAAiB,CAAC,QAAQ,CAAC,cAAc,CAAC;;;;"}
|