@codexo/exojs-tilemap 0.19.1 → 0.20.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 +7 -163
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +12 -20
- package/dist/esm/ChunkSource.d.ts +0 -33
- package/dist/esm/ChunkSource.d.ts.map +0 -1
- package/dist/esm/ChunkStreamer.d.ts +0 -104
- package/dist/esm/ChunkStreamer.d.ts.map +0 -1
- package/dist/esm/ChunkStreamer.js +0 -229
- package/dist/esm/ChunkStreamer.js.map +0 -1
- package/dist/esm/ImageLayer.d.ts +0 -89
- package/dist/esm/ImageLayer.d.ts.map +0 -1
- package/dist/esm/ImageLayer.js +0 -74
- package/dist/esm/ImageLayer.js.map +0 -1
- package/dist/esm/ImageLayerNode.d.ts +0 -91
- package/dist/esm/ImageLayerNode.d.ts.map +0 -1
- package/dist/esm/ImageLayerNode.js +0 -210
- package/dist/esm/ImageLayerNode.js.map +0 -1
- package/dist/esm/MapObject.d.ts +0 -70
- package/dist/esm/MapObject.d.ts.map +0 -1
- package/dist/esm/MapObject.js +0 -34
- package/dist/esm/MapObject.js.map +0 -1
- package/dist/esm/MapObjectSpawner.d.ts +0 -133
- package/dist/esm/MapObjectSpawner.d.ts.map +0 -1
- package/dist/esm/MapObjectSpawner.js +0 -147
- package/dist/esm/MapObjectSpawner.js.map +0 -1
- package/dist/esm/MapSpawnSession.d.ts +0 -46
- package/dist/esm/MapSpawnSession.d.ts.map +0 -1
- package/dist/esm/MapSpawnSession.js +0 -88
- package/dist/esm/MapSpawnSession.js.map +0 -1
- package/dist/esm/MapWorld.d.ts +0 -134
- package/dist/esm/MapWorld.d.ts.map +0 -1
- package/dist/esm/MapWorld.js +0 -150
- package/dist/esm/MapWorld.js.map +0 -1
- package/dist/esm/MapWorldRuntime.d.ts +0 -180
- package/dist/esm/MapWorldRuntime.d.ts.map +0 -1
- package/dist/esm/MapWorldRuntime.js +0 -261
- package/dist/esm/MapWorldRuntime.js.map +0 -1
- package/dist/esm/ObjectLayer.d.ts +0 -379
- package/dist/esm/ObjectLayer.d.ts.map +0 -1
- package/dist/esm/ObjectLayer.js +0 -221
- package/dist/esm/ObjectLayer.js.map +0 -1
- package/dist/esm/SampledChunkSource.d.ts +0 -43
- package/dist/esm/SampledChunkSource.d.ts.map +0 -1
- package/dist/esm/SampledChunkSource.js +0 -48
- package/dist/esm/SampledChunkSource.js.map +0 -1
- package/dist/esm/TileAnimator.d.ts +0 -72
- package/dist/esm/TileAnimator.d.ts.map +0 -1
- package/dist/esm/TileAnimator.js +0 -158
- package/dist/esm/TileAnimator.js.map +0 -1
- package/dist/esm/TileChunk.d.ts +0 -103
- package/dist/esm/TileChunk.d.ts.map +0 -1
- package/dist/esm/TileChunk.js +0 -194
- package/dist/esm/TileChunk.js.map +0 -1
- package/dist/esm/TileChunkNode.d.ts +0 -2
- package/dist/esm/TileChunkNode.d.ts.map +0 -1
- package/dist/esm/TileChunkNode.js +0 -145
- package/dist/esm/TileChunkNode.js.map +0 -1
- package/dist/esm/TileLayer.d.ts +0 -286
- package/dist/esm/TileLayer.d.ts.map +0 -1
- package/dist/esm/TileLayer.js +0 -526
- package/dist/esm/TileLayer.js.map +0 -1
- package/dist/esm/TileLayerNode.d.ts +0 -129
- package/dist/esm/TileLayerNode.d.ts.map +0 -1
- package/dist/esm/TileLayerNode.js +0 -245
- package/dist/esm/TileLayerNode.js.map +0 -1
- package/dist/esm/TileMap.d.ts +0 -317
- package/dist/esm/TileMap.d.ts.map +0 -1
- package/dist/esm/TileMap.js +0 -406
- package/dist/esm/TileMap.js.map +0 -1
- package/dist/esm/TileMapBand.d.ts +0 -80
- package/dist/esm/TileMapBand.d.ts.map +0 -1
- package/dist/esm/TileMapBand.js +0 -155
- package/dist/esm/TileMapBand.js.map +0 -1
- package/dist/esm/TileMapNode.d.ts +0 -92
- package/dist/esm/TileMapNode.d.ts.map +0 -1
- package/dist/esm/TileMapNode.js +0 -134
- package/dist/esm/TileMapNode.js.map +0 -1
- package/dist/esm/TileMapView.d.ts +0 -248
- package/dist/esm/TileMapView.d.ts.map +0 -1
- package/dist/esm/TileMapView.js +0 -394
- package/dist/esm/TileMapView.js.map +0 -1
- package/dist/esm/TileProjection.d.ts +0 -59
- package/dist/esm/TileProjection.d.ts.map +0 -1
- package/dist/esm/TileProjection.js +0 -106
- package/dist/esm/TileProjection.js.map +0 -1
- package/dist/esm/TileSet.d.ts +0 -116
- package/dist/esm/TileSet.d.ts.map +0 -1
- package/dist/esm/TileSet.js +0 -168
- package/dist/esm/TileSet.js.map +0 -1
- package/dist/esm/WangSet.d.ts +0 -80
- package/dist/esm/WangSet.d.ts.map +0 -1
- package/dist/esm/WangSet.js +0 -73
- package/dist/esm/WangSet.js.map +0 -1
- package/dist/esm/WorkerSampledChunkSource.d.ts +0 -94
- package/dist/esm/WorkerSampledChunkSource.d.ts.map +0 -1
- package/dist/esm/WorkerSampledChunkSource.js +0 -113
- package/dist/esm/WorkerSampledChunkSource.js.map +0 -1
- package/dist/esm/autoTile.d.ts +0 -88
- package/dist/esm/autoTile.d.ts.map +0 -1
- package/dist/esm/autoTile.js +0 -173
- package/dist/esm/autoTile.js.map +0 -1
- package/dist/esm/chunkGeometry.d.ts +0 -2
- package/dist/esm/chunkGeometry.d.ts.map +0 -1
- package/dist/esm/chunkGeometry.js +0 -116
- package/dist/esm/chunkGeometry.js.map +0 -1
- package/dist/esm/index.d.ts +0 -2
- package/dist/esm/index.d.ts.map +0 -1
- package/dist/esm/index.js +0 -27
- package/dist/esm/nodeBounds.d.ts +0 -2
- package/dist/esm/nodeBounds.d.ts.map +0 -1
- package/dist/esm/nodeBounds.js +0 -40
- package/dist/esm/nodeBounds.js.map +0 -1
- package/dist/esm/pixelSnap.d.ts +0 -2
- package/dist/esm/pixelSnap.d.ts.map +0 -1
- package/dist/esm/pixelSnap.js +0 -21
- package/dist/esm/pixelSnap.js.map +0 -1
- package/dist/esm/projectObject.d.ts +0 -4
- package/dist/esm/projectObject.d.ts.map +0 -1
- package/dist/esm/projectObject.js +0 -87
- package/dist/esm/projectObject.js.map +0 -1
- package/dist/esm/public.d.ts +0 -48
- package/dist/esm/public.d.ts.map +0 -1
- package/dist/esm/tileCollision.d.ts +0 -190
- package/dist/esm/tileCollision.d.ts.map +0 -1
- package/dist/esm/tileCollision.js +0 -399
- package/dist/esm/tileCollision.js.map +0 -1
- package/dist/esm/tileWord.d.ts +0 -2
- package/dist/esm/tileWord.d.ts.map +0 -1
- package/dist/esm/tileWord.js +0 -16
- package/dist/esm/tileWord.js.map +0 -1
- package/dist/esm/tilemapExtension.d.ts +0 -20
- package/dist/esm/tilemapExtension.d.ts.map +0 -1
- package/dist/esm/tilemapExtension.js +0 -53
- package/dist/esm/tilemapExtension.js.map +0 -1
- package/dist/esm/tilemapSerializers.d.ts +0 -2
- package/dist/esm/tilemapSerializers.d.ts.map +0 -1
- package/dist/esm/tilemapSerializers.js +0 -54
- package/dist/esm/tilemapSerializers.js.map +0 -1
- package/dist/esm/types.d.ts +0 -231
- package/dist/esm/types.d.ts.map +0 -1
- package/dist/esm/types.js +0 -129
- package/dist/esm/types.js.map +0 -1
- package/dist/esm/webgl2/WebGl2TileChunkRenderer.d.ts +0 -2
- package/dist/esm/webgl2/WebGl2TileChunkRenderer.d.ts.map +0 -1
- package/dist/esm/webgl2/WebGl2TileChunkRenderer.js +0 -376
- package/dist/esm/webgl2/WebGl2TileChunkRenderer.js.map +0 -1
- package/dist/esm/webgl2/shaders/tile-chunk.frag.js +0 -6
- package/dist/esm/webgl2/shaders/tile-chunk.frag.js.map +0 -1
- package/dist/esm/webgl2/shaders/tile-chunk.vert.js +0 -6
- package/dist/esm/webgl2/shaders/tile-chunk.vert.js.map +0 -1
- package/dist/esm/webgpu/WebGpuTileChunkRenderer.d.ts +0 -2
- package/dist/esm/webgpu/WebGpuTileChunkRenderer.d.ts.map +0 -1
- package/dist/esm/webgpu/WebGpuTileChunkRenderer.js +0 -539
- package/dist/esm/webgpu/WebGpuTileChunkRenderer.js.map +0 -1
- package/dist/esm/webgpu/shaders/tile-chunk.wgsl.js +0 -6
- package/dist/esm/webgpu/shaders/tile-chunk.wgsl.js.map +0 -1
package/dist/esm/TileLayer.js
DELETED
|
@@ -1,526 +0,0 @@
|
|
|
1
|
-
import { packTile, tileToChunkCoord, tileToLocalInChunk, unpackTile, validateInteger, validateNonNegativeInteger, validatePairedDimensions, validatePositiveInteger } from "./types.js";
|
|
2
|
-
import { TileChunk } from "./TileChunk.js";
|
|
3
|
-
import { TileProjection } from "./TileProjection.js";
|
|
4
|
-
|
|
5
|
-
//#region src/TileLayer.ts
|
|
6
|
-
const DEFAULT_CHUNK_SIZE = 32;
|
|
7
|
-
/** Resolve and validate the optional uniform parallax scale. */
|
|
8
|
-
const resolveParallaxScale = (value = 1) => {
|
|
9
|
-
if (!Number.isFinite(value) || value <= 0) throw new Error("TileLayer parallaxScale must be a positive finite number.");
|
|
10
|
-
return value;
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* Validate a {@link TileLayerOptions} bag and resolve its optional fields
|
|
14
|
-
* (chunk size, opacity, offset, parallax) to concrete defaults.
|
|
15
|
-
* @throws When dimensions, chunk size, or other options are invalid.
|
|
16
|
-
*/
|
|
17
|
-
const validateTileLayerOptions = (options) => {
|
|
18
|
-
validateNonNegativeInteger(options.id, "layer.id");
|
|
19
|
-
if (!options.name || typeof options.name !== "string") throw new Error("TileLayer name must be a non-empty string.");
|
|
20
|
-
validatePairedDimensions(options.width, options.height, "TileLayer", "layer");
|
|
21
|
-
validatePositiveInteger(options.tileWidth, "layer.tileWidth");
|
|
22
|
-
validatePositiveInteger(options.tileHeight, "layer.tileHeight");
|
|
23
|
-
const chunkWidth = options.chunkWidth ?? DEFAULT_CHUNK_SIZE;
|
|
24
|
-
const chunkHeight = options.chunkHeight ?? DEFAULT_CHUNK_SIZE;
|
|
25
|
-
validatePositiveInteger(chunkWidth, "chunkWidth");
|
|
26
|
-
validatePositiveInteger(chunkHeight, "chunkHeight");
|
|
27
|
-
if (!Array.isArray(options.tilesets)) throw new Error("TileLayer tilesets must be an array.");
|
|
28
|
-
const opacity = options.opacity ?? 1;
|
|
29
|
-
if (typeof opacity !== "number" || opacity < 0 || opacity > 1) throw new Error(`TileLayer opacity must be 0..1 (got ${opacity}).`);
|
|
30
|
-
const offsetX = options.offsetX ?? 0;
|
|
31
|
-
const offsetY = options.offsetY ?? 0;
|
|
32
|
-
if (!Number.isFinite(offsetX) || !Number.isFinite(offsetY)) throw new Error("TileLayer offset must be finite numbers.");
|
|
33
|
-
const parallaxX = options.parallaxX ?? 1;
|
|
34
|
-
const parallaxY = options.parallaxY ?? 1;
|
|
35
|
-
if (!Number.isFinite(parallaxX) || !Number.isFinite(parallaxY)) throw new Error("TileLayer parallax must be finite numbers.");
|
|
36
|
-
return {
|
|
37
|
-
chunkWidth,
|
|
38
|
-
chunkHeight,
|
|
39
|
-
opacity,
|
|
40
|
-
offsetX,
|
|
41
|
-
offsetY,
|
|
42
|
-
parallaxX,
|
|
43
|
-
parallaxY,
|
|
44
|
-
parallaxScale: resolveParallaxScale(options.parallaxScale)
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
/**
|
|
48
|
-
* A generic, format-independent tile layer with chunk-first storage.
|
|
49
|
-
*
|
|
50
|
-
* Tile data is stored in fixed-size {@link TileChunk}s indexed by signed
|
|
51
|
-
* chunk coordinates. For finite maps, only chunks that intersect the layer
|
|
52
|
-
* bounds exist.
|
|
53
|
-
*
|
|
54
|
-
* **Mutation must go through the layer's public APIs only.**
|
|
55
|
-
* `setTileAt` / `clearTileAt` validate coordinates, tileset references,
|
|
56
|
-
* and increment revision counters only when the stored value actually
|
|
57
|
-
* changes. Direct chunk mutation is not supported - the layer owns chunk
|
|
58
|
-
* storage and exposes only a {@link ReadonlyTileChunk} view.
|
|
59
|
-
*
|
|
60
|
-
* The layer is NOT a SceneNode - that integration lives in
|
|
61
|
-
* {@link import('./TileLayerNode').TileLayerNode}.
|
|
62
|
-
*
|
|
63
|
-
* @advanced
|
|
64
|
-
*/
|
|
65
|
-
var TileLayer = class {
|
|
66
|
-
projection;
|
|
67
|
-
/** Stable unique ID within the map. */
|
|
68
|
-
id;
|
|
69
|
-
/** Display name (may not be unique). */
|
|
70
|
-
name;
|
|
71
|
-
/** Width in tiles, or `undefined` if unbounded. */
|
|
72
|
-
width;
|
|
73
|
-
/** Height in tiles, or `undefined` if unbounded. */
|
|
74
|
-
height;
|
|
75
|
-
/** Chunk width (tiles). */
|
|
76
|
-
chunkWidth;
|
|
77
|
-
/** Chunk height (tiles). */
|
|
78
|
-
chunkHeight;
|
|
79
|
-
/** Tile width in pixels. */
|
|
80
|
-
tileWidth;
|
|
81
|
-
/** Tile height in pixels. */
|
|
82
|
-
tileHeight;
|
|
83
|
-
/** `true` if this layer has a fixed width/height; `false` if unbounded. */
|
|
84
|
-
get bounded() {
|
|
85
|
-
return this.width !== void 0 && this.height !== void 0;
|
|
86
|
-
}
|
|
87
|
-
/** Pixel width, or `undefined` if unbounded. */
|
|
88
|
-
get pixelWidth() {
|
|
89
|
-
return this.width === void 0 || this.height === void 0 ? void 0 : this.projection.getBounds(0, 0, this.width, this.height).width;
|
|
90
|
-
}
|
|
91
|
-
/** Pixel height, or `undefined` if unbounded. */
|
|
92
|
-
get pixelHeight() {
|
|
93
|
-
return this.width === void 0 || this.height === void 0 ? void 0 : this.projection.getBounds(0, 0, this.width, this.height).height;
|
|
94
|
-
}
|
|
95
|
-
/** Visibility flag (mutable). */
|
|
96
|
-
visible;
|
|
97
|
-
/** Opacity 0..1 (mutable). */
|
|
98
|
-
opacity;
|
|
99
|
-
/** Horizontal pixel offset (mutable). */
|
|
100
|
-
offsetX;
|
|
101
|
-
/** Vertical pixel offset (mutable). */
|
|
102
|
-
offsetY;
|
|
103
|
-
/**
|
|
104
|
-
* Parallax scroll factor on the X axis.
|
|
105
|
-
* `1.0` = full camera speed, `0.5` = half speed, `0.0` = stationary.
|
|
106
|
-
*/
|
|
107
|
-
parallaxX;
|
|
108
|
-
/**
|
|
109
|
-
* Parallax scroll factor on the Y axis.
|
|
110
|
-
* `1.0` = full camera speed, `0.5` = half speed, `0.0` = stationary.
|
|
111
|
-
*/
|
|
112
|
-
parallaxY;
|
|
113
|
-
/** Uniform scale applied around the layer origin during parallax rendering. */
|
|
114
|
-
parallaxScale;
|
|
115
|
-
/** Layer class/type string (Tiled `class`; may be empty). */
|
|
116
|
-
class;
|
|
117
|
-
/** Multiplicative layer tint as `0xRRGGBB`, or `null` for no tint. */
|
|
118
|
-
tintColor;
|
|
119
|
-
/** Immutable layer properties. */
|
|
120
|
-
properties;
|
|
121
|
-
/** The tilesets available to this layer (shared array reference). */
|
|
122
|
-
tilesets;
|
|
123
|
-
/** Chunk storage: chunkKey → mutable TileChunk (internal). */
|
|
124
|
-
_chunks = /* @__PURE__ */ new Map();
|
|
125
|
-
/** Package-internal structural (adopt/evict) listeners. */
|
|
126
|
-
_structuralListeners = null;
|
|
127
|
-
/**
|
|
128
|
-
* Monotonic layer revision counter.
|
|
129
|
-
* Increments on every cell mutation that actually changes a stored value.
|
|
130
|
-
* Does NOT increment on no-op writes or failed mutations.
|
|
131
|
-
*/
|
|
132
|
-
_revision = 0;
|
|
133
|
-
/** Whether the layer has been destroyed. */
|
|
134
|
-
_destroyed = false;
|
|
135
|
-
/**
|
|
136
|
-
* @throws When dimensions, chunk size, or other options are invalid.
|
|
137
|
-
*/
|
|
138
|
-
constructor(options) {
|
|
139
|
-
const { chunkWidth, chunkHeight, opacity, offsetX, offsetY, parallaxX, parallaxY, parallaxScale } = validateTileLayerOptions(options);
|
|
140
|
-
this.id = options.id;
|
|
141
|
-
this.name = options.name;
|
|
142
|
-
this.width = options.width;
|
|
143
|
-
this.height = options.height;
|
|
144
|
-
this.chunkWidth = chunkWidth;
|
|
145
|
-
this.chunkHeight = chunkHeight;
|
|
146
|
-
this.tileWidth = options.tileWidth;
|
|
147
|
-
this.tileHeight = options.tileHeight;
|
|
148
|
-
this.projection = options.projection ?? new TileProjection({
|
|
149
|
-
tileWidth: options.tileWidth,
|
|
150
|
-
tileHeight: options.tileHeight
|
|
151
|
-
});
|
|
152
|
-
if (this.projection.tileWidth !== this.tileWidth || this.projection.tileHeight !== this.tileHeight) throw new Error("Projection tile dimensions must match the layer or map.");
|
|
153
|
-
this.tilesets = options.tilesets;
|
|
154
|
-
this.visible = options.visible ?? true;
|
|
155
|
-
this.opacity = opacity;
|
|
156
|
-
this.offsetX = offsetX;
|
|
157
|
-
this.offsetY = offsetY;
|
|
158
|
-
this.parallaxX = parallaxX;
|
|
159
|
-
this.parallaxY = parallaxY;
|
|
160
|
-
this.parallaxScale = parallaxScale;
|
|
161
|
-
this.class = options.class ?? "";
|
|
162
|
-
this.tintColor = options.tintColor ?? null;
|
|
163
|
-
this.properties = options.properties ? Object.freeze({ ...options.properties }) : Object.freeze({});
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Check whether a tile coordinate lies within the layer bounds.
|
|
167
|
-
* Always `true` for an unbounded layer.
|
|
168
|
-
* @advanced
|
|
169
|
-
*/
|
|
170
|
-
inBounds(tx, ty) {
|
|
171
|
-
if (this.width === void 0 || this.height === void 0) return true;
|
|
172
|
-
return tx >= 0 && tx < this.width && ty >= 0 && ty < this.height;
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Compute the range of chunk coordinates that intersect this layer, or
|
|
176
|
-
* `null` if the layer is unbounded (any signed chunk coordinate is valid).
|
|
177
|
-
*/
|
|
178
|
-
chunkRange() {
|
|
179
|
-
if (this.width === void 0 || this.height === void 0) return null;
|
|
180
|
-
return {
|
|
181
|
-
minCx: 0,
|
|
182
|
-
minCy: 0,
|
|
183
|
-
maxCx: Math.floor((this.width - 1) / this.chunkWidth),
|
|
184
|
-
maxCy: Math.floor((this.height - 1) / this.chunkHeight)
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
_chunkKey(cx, cy) {
|
|
188
|
-
return `${cx},${cy}`;
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Get a readonly view of a chunk by signed chunk coordinates,
|
|
192
|
-
* or undefined if it does not exist (never been touched).
|
|
193
|
-
* @advanced
|
|
194
|
-
*/
|
|
195
|
-
getChunk(cx, cy) {
|
|
196
|
-
return this._chunks.get(this._chunkKey(cx, cy));
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Get or create a chunk at the given coordinates.
|
|
200
|
-
* For a bounded layer, creation is only allowed within the valid chunk
|
|
201
|
-
* range and edge chunks are clamped to the layer's remaining size. For an
|
|
202
|
-
* unbounded layer, any signed chunk coordinate is accepted and every
|
|
203
|
-
* chunk is full-size ({@link chunkWidth} × {@link chunkHeight}).
|
|
204
|
-
*
|
|
205
|
-
* @internal Package-private: used by {@link setTileAt}, {@link fillRect},
|
|
206
|
-
* and future adapter ingest. External users should not allocate
|
|
207
|
-
* chunks - use {@link setTileAt} to populate tiles.
|
|
208
|
-
*/
|
|
209
|
-
_ensureChunk(cx, cy) {
|
|
210
|
-
this._checkDestroyed();
|
|
211
|
-
const key = this._chunkKey(cx, cy);
|
|
212
|
-
let chunk = this._chunks.get(key);
|
|
213
|
-
if (!chunk) {
|
|
214
|
-
const range = this.chunkRange();
|
|
215
|
-
let cw = this.chunkWidth;
|
|
216
|
-
let ch = this.chunkHeight;
|
|
217
|
-
if (range !== null && this.width !== void 0 && this.height !== void 0) {
|
|
218
|
-
if (cx < range.minCx || cx > range.maxCx || cy < range.minCy || cy > range.maxCy) throw new Error(`Chunk (${cx}, ${cy}) outside layer chunk range [${range.minCx}..${range.maxCx}, ${range.minCy}..${range.maxCy}].`);
|
|
219
|
-
const startTx = cx * this.chunkWidth;
|
|
220
|
-
const startTy = cy * this.chunkHeight;
|
|
221
|
-
cw = Math.min(this.chunkWidth, this.width - startTx);
|
|
222
|
-
ch = Math.min(this.chunkHeight, this.height - startTy);
|
|
223
|
-
}
|
|
224
|
-
chunk = new TileChunk(cx, cy, cw, ch);
|
|
225
|
-
this._chunks.set(key, chunk);
|
|
226
|
-
}
|
|
227
|
-
return chunk;
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Install a chunk-provider-supplied payload directly, bypassing per-tile
|
|
231
|
-
* `setTileAt` cost. Overwrites any existing chunk at `(cx, cy)`. Always
|
|
232
|
-
* bumps the layer revision (installing a chunk is always a structural
|
|
233
|
-
* change, even if the payload happens to be all-zero).
|
|
234
|
-
*
|
|
235
|
-
* Does not validate `(cx, cy)` against {@link chunkRange} - callers
|
|
236
|
-
* (chunk-streaming controllers) are trusted to request coordinates within
|
|
237
|
-
* whatever range they intend to manage.
|
|
238
|
-
*
|
|
239
|
-
* @internal Package-private: for future chunk-provider/streaming use.
|
|
240
|
-
*/
|
|
241
|
-
_adoptChunk(cx, cy, payload) {
|
|
242
|
-
this._checkDestroyed();
|
|
243
|
-
const chunk = new TileChunk(cx, cy, payload.width, payload.height, payload.tiles);
|
|
244
|
-
this._chunks.set(this._chunkKey(cx, cy), chunk);
|
|
245
|
-
this._revision++;
|
|
246
|
-
this._notifyStructural({
|
|
247
|
-
cx,
|
|
248
|
-
cy,
|
|
249
|
-
chunk
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
/**
|
|
253
|
-
* Evict a chunk from storage, freeing it for garbage collection. No-op if
|
|
254
|
-
* no chunk is loaded at `(cx, cy)`.
|
|
255
|
-
*
|
|
256
|
-
* @returns `true` if a chunk was found and removed, `false` otherwise.
|
|
257
|
-
* @internal Package-private: for future chunk-streaming eviction use.
|
|
258
|
-
*/
|
|
259
|
-
_evictChunk(cx, cy) {
|
|
260
|
-
this._checkDestroyed();
|
|
261
|
-
const key = this._chunkKey(cx, cy);
|
|
262
|
-
if (!this._chunks.delete(key)) return false;
|
|
263
|
-
this._revision++;
|
|
264
|
-
this._notifyStructural({
|
|
265
|
-
cx,
|
|
266
|
-
cy,
|
|
267
|
-
chunk: null
|
|
268
|
-
});
|
|
269
|
-
return true;
|
|
270
|
-
}
|
|
271
|
-
/**
|
|
272
|
-
* Register a callback invoked synchronously whenever a chunk is installed
|
|
273
|
-
* ({@link _adoptChunk}) or evicted ({@link _evictChunk}). Package-internal:
|
|
274
|
-
* {@link import('./TileLayerNode').TileLayerNode} subscribes to keep its
|
|
275
|
-
* chunk-node children in sync with chunk-provider-driven adopt/evict calls
|
|
276
|
-
* (e.g. from {@link import('./ChunkStreamer').ChunkStreamer}) without
|
|
277
|
-
* needing a full {@link import('./TileLayerNode').TileLayerNode.refresh}.
|
|
278
|
-
* @internal
|
|
279
|
-
*/
|
|
280
|
-
_addStructuralListener(listener) {
|
|
281
|
-
(this._structuralListeners ??= /* @__PURE__ */ new Set()).add(listener);
|
|
282
|
-
}
|
|
283
|
-
/**
|
|
284
|
-
* Unregister a listener added via {@link _addStructuralListener} (node destroy).
|
|
285
|
-
* @internal
|
|
286
|
-
*/
|
|
287
|
-
_removeStructuralListener(listener) {
|
|
288
|
-
this._structuralListeners?.delete(listener);
|
|
289
|
-
}
|
|
290
|
-
_notifyStructural(event) {
|
|
291
|
-
if (this._structuralListeners === null) return;
|
|
292
|
-
for (const listener of this._structuralListeners) listener(event);
|
|
293
|
-
}
|
|
294
|
-
/**
|
|
295
|
-
* Iterate over all loaded chunks in deterministic (cy, cx) ascending order.
|
|
296
|
-
* Returns readonly chunk views - callers cannot mutate storage.
|
|
297
|
-
* @advanced
|
|
298
|
-
*/
|
|
299
|
-
loadedChunks() {
|
|
300
|
-
const entries = [...this._chunks.values()];
|
|
301
|
-
entries.sort((a, b) => a.cy - b.cy || a.cx - b.cx);
|
|
302
|
-
return entries[Symbol.iterator]();
|
|
303
|
-
}
|
|
304
|
-
/**
|
|
305
|
-
* Get the raw packed tile word at (tx, ty). Returns 0 for empty or out-of-bounds.
|
|
306
|
-
* @advanced
|
|
307
|
-
*/
|
|
308
|
-
getRawTileAt(tx, ty) {
|
|
309
|
-
validateInteger(tx, "tx");
|
|
310
|
-
validateInteger(ty, "ty");
|
|
311
|
-
if (!this.inBounds(tx, ty)) return 0;
|
|
312
|
-
const { cx, cy } = tileToChunkCoord(tx, ty, this.chunkWidth, this.chunkHeight);
|
|
313
|
-
const chunk = this._chunks.get(this._chunkKey(cx, cy));
|
|
314
|
-
if (!chunk) return 0;
|
|
315
|
-
const { lx, ly } = tileToLocalInChunk(tx, ty, this.chunkWidth, this.chunkHeight);
|
|
316
|
-
return chunk.getRawAt(lx, ly);
|
|
317
|
-
}
|
|
318
|
-
/**
|
|
319
|
-
* Query a resolved tile at (tx, ty). Returns null for empty or out-of-bounds.
|
|
320
|
-
* @advanced
|
|
321
|
-
*/
|
|
322
|
-
getTileAt(tx, ty) {
|
|
323
|
-
const packed = this.getRawTileAt(tx, ty);
|
|
324
|
-
if (packed === 0) return null;
|
|
325
|
-
const decoded = unpackTile(packed);
|
|
326
|
-
if (!decoded) return null;
|
|
327
|
-
if (decoded.tilesetIndex >= this.tilesets.length) return null;
|
|
328
|
-
const tileset = this.tilesets[decoded.tilesetIndex];
|
|
329
|
-
if (decoded.localTileId >= tileset.tileCount) return null;
|
|
330
|
-
return {
|
|
331
|
-
tileset,
|
|
332
|
-
localTileId: decoded.localTileId,
|
|
333
|
-
transform: decoded.transform
|
|
334
|
-
};
|
|
335
|
-
}
|
|
336
|
-
/**
|
|
337
|
-
* Validate a tile reference against the layer's tilesets.
|
|
338
|
-
* Returns the packed form or throws.
|
|
339
|
-
*/
|
|
340
|
-
_validateTileRef(tile) {
|
|
341
|
-
if (!tile?.tileset) throw new Error("setTileAt requires a valid ResolvedTile.");
|
|
342
|
-
const tilesetIndex = this.tilesets.indexOf(tile.tileset);
|
|
343
|
-
if (tilesetIndex === -1) throw new Error(`Tileset "${tile.tileset.name}" is not available to layer "${this.name}".`);
|
|
344
|
-
if (tile.localTileId < 0 || tile.localTileId >= tile.tileset.tileCount) throw new Error(`localTileId ${tile.localTileId} out of range for tileset "${tile.tileset.name}" (max ${tile.tileset.tileCount - 1}).`);
|
|
345
|
-
return packTile(tilesetIndex, tile.localTileId, tile.transform);
|
|
346
|
-
}
|
|
347
|
-
/**
|
|
348
|
-
* Set a tile at the given tile coordinates.
|
|
349
|
-
* No-op if the effective value is unchanged.
|
|
350
|
-
* @throws If coordinates are out of bounds or the tile reference is invalid.
|
|
351
|
-
* @advanced
|
|
352
|
-
*/
|
|
353
|
-
setTileAt(tx, ty, tile) {
|
|
354
|
-
this._checkDestroyed();
|
|
355
|
-
validateInteger(tx, "tx");
|
|
356
|
-
validateInteger(ty, "ty");
|
|
357
|
-
if (!this.inBounds(tx, ty)) {
|
|
358
|
-
const boundsMsg = this.width !== void 0 && this.height !== void 0 ? `[0..${this.width - 1}, 0..${this.height - 1}]` : "[unbounded]";
|
|
359
|
-
throw new Error(`setTileAt (${tx}, ${ty}) out of bounds ${boundsMsg}.`);
|
|
360
|
-
}
|
|
361
|
-
const packed = this._validateTileRef(tile);
|
|
362
|
-
const { cx, cy } = tileToChunkCoord(tx, ty, this.chunkWidth, this.chunkHeight);
|
|
363
|
-
const chunk = this._ensureChunk(cx, cy);
|
|
364
|
-
const { lx, ly } = tileToLocalInChunk(tx, ty, this.chunkWidth, this.chunkHeight);
|
|
365
|
-
if (chunk._setRawAt(lx, ly, packed)) this._revision++;
|
|
366
|
-
}
|
|
367
|
-
/**
|
|
368
|
-
* Clear (erase) the tile at the given coordinates.
|
|
369
|
-
* No-op if the cell is already empty.
|
|
370
|
-
* @throws If coordinates are out of bounds.
|
|
371
|
-
* @advanced
|
|
372
|
-
*/
|
|
373
|
-
clearTileAt(tx, ty) {
|
|
374
|
-
this._checkDestroyed();
|
|
375
|
-
validateInteger(tx, "tx");
|
|
376
|
-
validateInteger(ty, "ty");
|
|
377
|
-
if (!this.inBounds(tx, ty)) {
|
|
378
|
-
const boundsMsg = this.width !== void 0 && this.height !== void 0 ? `[0..${this.width - 1}, 0..${this.height - 1}]` : "[unbounded]";
|
|
379
|
-
throw new Error(`clearTileAt (${tx}, ${ty}) out of bounds ${boundsMsg}.`);
|
|
380
|
-
}
|
|
381
|
-
const { cx, cy } = tileToChunkCoord(tx, ty, this.chunkWidth, this.chunkHeight);
|
|
382
|
-
const chunk = this._chunks.get(this._chunkKey(cx, cy));
|
|
383
|
-
if (!chunk) return;
|
|
384
|
-
const { lx, ly } = tileToLocalInChunk(tx, ty, this.chunkWidth, this.chunkHeight);
|
|
385
|
-
if (chunk._setRawAt(lx, ly, 0)) this._revision++;
|
|
386
|
-
}
|
|
387
|
-
/**
|
|
388
|
-
* Fill a rectangular region with a tile.
|
|
389
|
-
* @advanced
|
|
390
|
-
*/
|
|
391
|
-
fillRect(x, y, w, h, tile) {
|
|
392
|
-
this._checkDestroyed();
|
|
393
|
-
const packed = this._validateTileRef(tile);
|
|
394
|
-
let changed = false;
|
|
395
|
-
for (let ty = y; ty < y + h; ty++) for (let tx = x; tx < x + w; tx++) {
|
|
396
|
-
if (!this.inBounds(tx, ty)) continue;
|
|
397
|
-
const { cx, cy } = tileToChunkCoord(tx, ty, this.chunkWidth, this.chunkHeight);
|
|
398
|
-
const chunk = this._ensureChunk(cx, cy);
|
|
399
|
-
const { lx, ly } = tileToLocalInChunk(tx, ty, this.chunkWidth, this.chunkHeight);
|
|
400
|
-
if (chunk._setRawAt(lx, ly, packed)) changed = true;
|
|
401
|
-
}
|
|
402
|
-
if (changed) this._revision++;
|
|
403
|
-
}
|
|
404
|
-
/**
|
|
405
|
-
* Clear a rectangular region.
|
|
406
|
-
* @advanced
|
|
407
|
-
*/
|
|
408
|
-
clearRect(x, y, w, h) {
|
|
409
|
-
this._checkDestroyed();
|
|
410
|
-
let changed = false;
|
|
411
|
-
for (let ty = y; ty < y + h; ty++) for (let tx = x; tx < x + w; tx++) {
|
|
412
|
-
if (!this.inBounds(tx, ty)) continue;
|
|
413
|
-
const { cx, cy } = tileToChunkCoord(tx, ty, this.chunkWidth, this.chunkHeight);
|
|
414
|
-
const chunk = this._chunks.get(this._chunkKey(cx, cy));
|
|
415
|
-
if (!chunk) continue;
|
|
416
|
-
const { lx, ly } = tileToLocalInChunk(tx, ty, this.chunkWidth, this.chunkHeight);
|
|
417
|
-
if (chunk._setRawAt(lx, ly, 0)) changed = true;
|
|
418
|
-
}
|
|
419
|
-
if (changed) this._revision++;
|
|
420
|
-
}
|
|
421
|
-
/**
|
|
422
|
-
* Iterate non-empty tiles within a rectangular region in row-major order.
|
|
423
|
-
* Yields (tx, ty, resolvedTile) tuples. Skips empty cells.
|
|
424
|
-
* @advanced
|
|
425
|
-
*/
|
|
426
|
-
*tilesInRect(x, y, w, h) {
|
|
427
|
-
const startCx = Math.floor(x / this.chunkWidth);
|
|
428
|
-
const endCx = Math.floor((x + w - 1) / this.chunkWidth);
|
|
429
|
-
const startCy = Math.floor(y / this.chunkHeight);
|
|
430
|
-
const endCy = Math.floor((y + h - 1) / this.chunkHeight);
|
|
431
|
-
for (let cy = startCy; cy <= endCy; cy++) for (let cx = startCx; cx <= endCx; cx++) {
|
|
432
|
-
const chunk = this._chunks.get(this._chunkKey(cx, cy));
|
|
433
|
-
if (!chunk || chunk.empty) continue;
|
|
434
|
-
const chunkStartTx = cx * this.chunkWidth;
|
|
435
|
-
const chunkStartTy = cy * this.chunkHeight;
|
|
436
|
-
const minLx = Math.max(0, x - chunkStartTx);
|
|
437
|
-
const maxLx = Math.min(chunk.width - 1, x + w - 1 - chunkStartTx);
|
|
438
|
-
const minLy = Math.max(0, y - chunkStartTy);
|
|
439
|
-
const maxLy = Math.min(chunk.height - 1, y + h - 1 - chunkStartTy);
|
|
440
|
-
for (let ly = minLy; ly <= maxLy; ly++) for (let lx = minLx; lx <= maxLx; lx++) {
|
|
441
|
-
const packed = chunk.getRawAt(lx, ly);
|
|
442
|
-
if (packed === 0) continue;
|
|
443
|
-
const decoded = unpackTile(packed);
|
|
444
|
-
if (!decoded) continue;
|
|
445
|
-
if (decoded.tilesetIndex >= this.tilesets.length) continue;
|
|
446
|
-
const tileset = this.tilesets[decoded.tilesetIndex];
|
|
447
|
-
if (decoded.localTileId >= tileset.tileCount) continue;
|
|
448
|
-
yield {
|
|
449
|
-
tx: chunkStartTx + lx,
|
|
450
|
-
ty: chunkStartTy + ly,
|
|
451
|
-
tile: {
|
|
452
|
-
tileset,
|
|
453
|
-
localTileId: decoded.localTileId,
|
|
454
|
-
transform: decoded.transform
|
|
455
|
-
}
|
|
456
|
-
};
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
/** Display layer translation expressed as a logical simulation-space vector. */
|
|
461
|
-
get logicalOffset() {
|
|
462
|
-
const p = this.projection;
|
|
463
|
-
return p.pixelToLogical(p.originX + this.offsetX, p.originY + this.offsetY);
|
|
464
|
-
}
|
|
465
|
-
/**
|
|
466
|
-
* Convert a grid vertex to display pixels (the top diamond vertex for isometric cells)
|
|
467
|
-
* including the layer's display offset.
|
|
468
|
-
* @advanced
|
|
469
|
-
*/
|
|
470
|
-
tileToPixel(tx, ty) {
|
|
471
|
-
const point = this.projection.tileToPixel(tx, ty);
|
|
472
|
-
return {
|
|
473
|
-
x: point.x + this.offsetX,
|
|
474
|
-
y: point.y + this.offsetY
|
|
475
|
-
};
|
|
476
|
-
}
|
|
477
|
-
/**
|
|
478
|
-
* Convert a local pixel position to the tile coordinate that contains it.
|
|
479
|
-
* Uses `floor`, so a point exactly on a tile boundary maps to the tile.
|
|
480
|
-
* May return coordinates outside layer bounds.
|
|
481
|
-
* @advanced
|
|
482
|
-
*/
|
|
483
|
-
pixelToTile(px, py) {
|
|
484
|
-
return this.projection.pixelToTile(px - this.offsetX, py - this.offsetY);
|
|
485
|
-
}
|
|
486
|
-
/**
|
|
487
|
-
* Monotonic layer revision counter.
|
|
488
|
-
* Increments on every cell mutation that changes a stored value.
|
|
489
|
-
* No-op writes and failed mutations do NOT increment.
|
|
490
|
-
* @advanced
|
|
491
|
-
*/
|
|
492
|
-
get revision() {
|
|
493
|
-
return this._revision;
|
|
494
|
-
}
|
|
495
|
-
/** Whether the layer has been destroyed. */
|
|
496
|
-
get destroyed() {
|
|
497
|
-
return this._destroyed;
|
|
498
|
-
}
|
|
499
|
-
_checkDestroyed() {
|
|
500
|
-
if (this._destroyed) throw new Error(`TileLayer "${this.name}" has been destroyed.`);
|
|
501
|
-
}
|
|
502
|
-
/**
|
|
503
|
-
* Destroy this layer: clear chunk storage and mark destroyed.
|
|
504
|
-
* Does NOT destroy tileset textures or external resources.
|
|
505
|
-
* Idempotent.
|
|
506
|
-
*/
|
|
507
|
-
destroy() {
|
|
508
|
-
if (this._destroyed) return;
|
|
509
|
-
this._destroyed = true;
|
|
510
|
-
this._chunks.clear();
|
|
511
|
-
}
|
|
512
|
-
/**
|
|
513
|
-
* Total number of non-empty tiles across all chunks.
|
|
514
|
-
* Walk is cheap for dense layers; sparse layers benefit from empty-chunk fast path.
|
|
515
|
-
* @advanced
|
|
516
|
-
*/
|
|
517
|
-
countNonEmptyTiles() {
|
|
518
|
-
let count = 0;
|
|
519
|
-
for (const chunk of this._chunks.values()) for (let ly = 0; ly < chunk.height; ly++) for (let lx = 0; lx < chunk.width; lx++) if (chunk.getRawAt(lx, ly) !== 0) count++;
|
|
520
|
-
return count;
|
|
521
|
-
}
|
|
522
|
-
};
|
|
523
|
-
|
|
524
|
-
//#endregion
|
|
525
|
-
export { TileLayer };
|
|
526
|
-
//# sourceMappingURL=TileLayer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TileLayer.js","names":[],"sources":["../../src/TileLayer.ts"],"sourcesContent":["import type { ChunkPayload } from './ChunkSource';\nimport type { ReadonlyTileChunk } from './TileChunk';\nimport { TileChunk } from './TileChunk';\nimport { TileProjection } from './TileProjection';\nimport type { TileSet } from './TileSet';\nimport type { TileProperties } from './types';\nimport type { PackedTile, ResolvedTile } from './types';\nimport { packTile, unpackTile, validateInteger, validateNonNegativeInteger, validatePairedDimensions, validatePositiveInteger } from './types';\nimport { tileToChunkCoord, tileToLocalInChunk } from './types';\n\n/**\n * Options for constructing a {@link TileLayer}.\n * @advanced\n */\nexport interface TileLayerOptions {\n /** Shared projection; defaults to an orthogonal grid of the supplied tile size. */\n readonly projection?: TileProjection;\n /** Stable layer ID (unique within the map). */\n readonly id: number;\n /** Display name (need not be unique). */\n readonly name: string;\n /**\n * Layer width in tiles. Omit together with {@link height} for an\n * unbounded layer - chunk storage then accepts any signed chunk\n * coordinate instead of being clamped to a fixed grid.\n */\n readonly width?: number;\n /** Layer height in tiles. Must be provided iff {@link width} is. */\n readonly height?: number;\n /** Chunk width in tiles (default 32). */\n readonly chunkWidth?: number;\n /** Chunk height in tiles (default 32). */\n readonly chunkHeight?: number;\n /** Tilesets available to this layer (shared with the map). */\n readonly tilesets: readonly TileSet[];\n /** Tile width in pixels (for coordinate conversion). */\n readonly tileWidth: number;\n /** Tile height in pixels (for coordinate conversion). */\n readonly tileHeight: number;\n /** Initial visibility. Default true. */\n readonly visible?: boolean;\n /** Opacity 0..1. Default 1. */\n readonly opacity?: number;\n /** Layer pixel offset X. Default 0. */\n readonly offsetX?: number;\n /** Layer pixel offset Y. Default 0. */\n readonly offsetY?: number;\n /**\n * Parallax scroll factor on the X axis. `1.0` = full camera speed (normal),\n * `0.5` = half speed (farther away), `0.0` = stationary. Default 1.\n */\n readonly parallaxX?: number;\n /**\n * Parallax scroll factor on the Y axis. `1.0` = full camera speed (normal),\n * `0.5` = half speed (farther away), `0.0` = stationary. Default 1.\n */\n readonly parallaxY?: number;\n /**\n * Uniform scale applied together with the camera-relative parallax shift.\n * `1` keeps the layer at its authored size. Default `1`.\n */\n readonly parallaxScale?: number;\n /** Layer class/type string (Tiled `class`). Defaults to `''`. */\n readonly class?: string;\n /**\n * Multiplicative layer tint as a `0xRRGGBB` integer, or `null` for none\n * (Tiled `tintcolor`). Applied to every chunk's render tint. Default `null`.\n */\n readonly tintColor?: number | null;\n /** Layer properties (copied and frozen). */\n readonly properties?: TileProperties;\n}\n\nconst DEFAULT_CHUNK_SIZE = 32;\n\n/**\n * The inclusive range of chunk coordinates that intersect a bounded\n * {@link TileLayer}. `null` for an unbounded layer (no range limit).\n * @advanced\n */\nexport interface ChunkRange {\n readonly minCx: number;\n readonly minCy: number;\n readonly maxCx: number;\n readonly maxCy: number;\n}\n\n/**\n * Fired via {@link TileLayer._addStructuralListener} whenever a chunk is\n * installed ({@link TileLayer._adoptChunk}) or evicted\n * ({@link TileLayer._evictChunk}) - structural changes only, not per-tile\n * edits (see {@link import('./TileChunk').TileChunk._addDirtyListener} for\n * those). `chunk` is `null` on eviction.\n * @internal\n */\nexport interface ChunkStructuralEvent {\n readonly cx: number;\n readonly cy: number;\n readonly chunk: ReadonlyTileChunk | null;\n}\n\n/**\n * Resolved, defaulted subset of {@link TileLayerOptions} produced by\n * {@link validateTileLayerOptions}.\n */\ninterface ResolvedTileLayerOptions {\n readonly chunkWidth: number;\n readonly chunkHeight: number;\n readonly opacity: number;\n readonly offsetX: number;\n readonly offsetY: number;\n readonly parallaxX: number;\n readonly parallaxY: number;\n readonly parallaxScale: number;\n}\n\n/** Resolve and validate the optional uniform parallax scale. */\nconst resolveParallaxScale = (value = 1): number => {\n if (!Number.isFinite(value) || value <= 0) {\n throw new Error('TileLayer parallaxScale must be a positive finite number.');\n }\n\n return value;\n};\n\n/**\n * Validate a {@link TileLayerOptions} bag and resolve its optional fields\n * (chunk size, opacity, offset, parallax) to concrete defaults.\n * @throws When dimensions, chunk size, or other options are invalid.\n */\nconst validateTileLayerOptions = (options: TileLayerOptions): ResolvedTileLayerOptions => {\n validateNonNegativeInteger(options.id, 'layer.id');\n if (!options.name || typeof options.name !== 'string') {\n throw new Error('TileLayer name must be a non-empty string.');\n }\n validatePairedDimensions(options.width, options.height, 'TileLayer', 'layer');\n validatePositiveInteger(options.tileWidth, 'layer.tileWidth');\n validatePositiveInteger(options.tileHeight, 'layer.tileHeight');\n\n const chunkWidth = options.chunkWidth ?? DEFAULT_CHUNK_SIZE;\n const chunkHeight = options.chunkHeight ?? DEFAULT_CHUNK_SIZE;\n validatePositiveInteger(chunkWidth, 'chunkWidth');\n validatePositiveInteger(chunkHeight, 'chunkHeight');\n\n if (!Array.isArray(options.tilesets)) {\n throw new Error('TileLayer tilesets must be an array.');\n }\n\n const opacity = options.opacity ?? 1;\n if (typeof opacity !== 'number' || opacity < 0 || opacity > 1) {\n throw new Error(`TileLayer opacity must be 0..1 (got ${opacity}).`);\n }\n\n const offsetX = options.offsetX ?? 0;\n const offsetY = options.offsetY ?? 0;\n if (!Number.isFinite(offsetX) || !Number.isFinite(offsetY)) {\n throw new Error('TileLayer offset must be finite numbers.');\n }\n\n const parallaxX = options.parallaxX ?? 1;\n const parallaxY = options.parallaxY ?? 1;\n if (!Number.isFinite(parallaxX) || !Number.isFinite(parallaxY)) {\n throw new Error('TileLayer parallax must be finite numbers.');\n }\n\n const parallaxScale = resolveParallaxScale(options.parallaxScale);\n\n return { chunkWidth, chunkHeight, opacity, offsetX, offsetY, parallaxX, parallaxY, parallaxScale };\n};\n\n/**\n * A generic, format-independent tile layer with chunk-first storage.\n *\n * Tile data is stored in fixed-size {@link TileChunk}s indexed by signed\n * chunk coordinates. For finite maps, only chunks that intersect the layer\n * bounds exist.\n *\n * **Mutation must go through the layer's public APIs only.**\n * `setTileAt` / `clearTileAt` validate coordinates, tileset references,\n * and increment revision counters only when the stored value actually\n * changes. Direct chunk mutation is not supported - the layer owns chunk\n * storage and exposes only a {@link ReadonlyTileChunk} view.\n *\n * The layer is NOT a SceneNode - that integration lives in\n * {@link import('./TileLayerNode').TileLayerNode}.\n *\n * @advanced\n */\nexport class TileLayer {\n public readonly projection: TileProjection;\n /** Stable unique ID within the map. */\n public readonly id: number;\n /** Display name (may not be unique). */\n public readonly name: string;\n\n /** Width in tiles, or `undefined` if unbounded. */\n public readonly width: number | undefined;\n /** Height in tiles, or `undefined` if unbounded. */\n public readonly height: number | undefined;\n\n /** Chunk width (tiles). */\n public readonly chunkWidth: number;\n /** Chunk height (tiles). */\n public readonly chunkHeight: number;\n\n /** Tile width in pixels. */\n public readonly tileWidth: number;\n /** Tile height in pixels. */\n public readonly tileHeight: number;\n\n /** `true` if this layer has a fixed width/height; `false` if unbounded. */\n public get bounded(): boolean {\n return this.width !== undefined && this.height !== undefined;\n }\n\n /** Pixel width, or `undefined` if unbounded. */\n public get pixelWidth(): number | undefined {\n return this.width === undefined || this.height === undefined ? undefined : this.projection.getBounds(0, 0, this.width, this.height).width;\n }\n /** Pixel height, or `undefined` if unbounded. */\n public get pixelHeight(): number | undefined {\n return this.width === undefined || this.height === undefined ? undefined : this.projection.getBounds(0, 0, this.width, this.height).height;\n }\n\n /** Visibility flag (mutable). */\n public visible: boolean;\n /** Opacity 0..1 (mutable). */\n public opacity: number;\n /** Horizontal pixel offset (mutable). */\n public offsetX: number;\n /** Vertical pixel offset (mutable). */\n public offsetY: number;\n /**\n * Parallax scroll factor on the X axis.\n * `1.0` = full camera speed, `0.5` = half speed, `0.0` = stationary.\n */\n public readonly parallaxX: number;\n /**\n * Parallax scroll factor on the Y axis.\n * `1.0` = full camera speed, `0.5` = half speed, `0.0` = stationary.\n */\n public readonly parallaxY: number;\n /** Uniform scale applied around the layer origin during parallax rendering. */\n public readonly parallaxScale: number;\n\n /** Layer class/type string (Tiled `class`; may be empty). */\n public readonly class: string;\n /** Multiplicative layer tint as `0xRRGGBB`, or `null` for no tint. */\n public readonly tintColor: number | null;\n\n /** Immutable layer properties. */\n public readonly properties: TileProperties;\n\n /** The tilesets available to this layer (shared array reference). */\n public readonly tilesets: readonly TileSet[];\n\n /** Chunk storage: chunkKey → mutable TileChunk (internal). */\n private readonly _chunks = new Map<string, TileChunk>();\n\n /** Package-internal structural (adopt/evict) listeners. */\n private _structuralListeners: Set<(event: ChunkStructuralEvent) => void> | null = null;\n\n /**\n * Monotonic layer revision counter.\n * Increments on every cell mutation that actually changes a stored value.\n * Does NOT increment on no-op writes or failed mutations.\n */\n private _revision = 0;\n\n /** Whether the layer has been destroyed. */\n private _destroyed = false;\n\n /**\n * @throws When dimensions, chunk size, or other options are invalid.\n */\n public constructor(options: TileLayerOptions) {\n const { chunkWidth, chunkHeight, opacity, offsetX, offsetY, parallaxX, parallaxY, parallaxScale } = validateTileLayerOptions(options);\n\n this.id = options.id;\n this.name = options.name;\n this.width = options.width;\n this.height = options.height;\n this.chunkWidth = chunkWidth;\n this.chunkHeight = chunkHeight;\n this.tileWidth = options.tileWidth;\n this.tileHeight = options.tileHeight;\n this.projection = options.projection ?? new TileProjection({ tileWidth: options.tileWidth, tileHeight: options.tileHeight });\n if (this.projection.tileWidth !== this.tileWidth || this.projection.tileHeight !== this.tileHeight) {\n throw new Error('Projection tile dimensions must match the layer or map.');\n }\n this.tilesets = options.tilesets;\n this.visible = options.visible ?? true;\n this.opacity = opacity;\n this.offsetX = offsetX;\n this.offsetY = offsetY;\n this.parallaxX = parallaxX;\n this.parallaxY = parallaxY;\n this.parallaxScale = parallaxScale;\n this.class = options.class ?? '';\n this.tintColor = options.tintColor ?? null;\n this.properties = options.properties ? Object.freeze({ ...options.properties }) : Object.freeze({});\n }\n\n // ── Bounds helpers ────────────────────────────────────────────────────\n\n /**\n * Check whether a tile coordinate lies within the layer bounds.\n * Always `true` for an unbounded layer.\n * @advanced\n */\n public inBounds(tx: number, ty: number): boolean {\n if (this.width === undefined || this.height === undefined) return true;\n return tx >= 0 && tx < this.width && ty >= 0 && ty < this.height;\n }\n\n /**\n * Compute the range of chunk coordinates that intersect this layer, or\n * `null` if the layer is unbounded (any signed chunk coordinate is valid).\n */\n public chunkRange(): ChunkRange | null {\n if (this.width === undefined || this.height === undefined) return null;\n return {\n minCx: 0,\n minCy: 0,\n maxCx: Math.floor((this.width - 1) / this.chunkWidth),\n maxCy: Math.floor((this.height - 1) / this.chunkHeight),\n };\n }\n\n // ── Chunk keying ──────────────────────────────────────────────────────\n\n private _chunkKey(cx: number, cy: number): string {\n return `${cx},${cy}`;\n }\n\n /**\n * Get a readonly view of a chunk by signed chunk coordinates,\n * or undefined if it does not exist (never been touched).\n * @advanced\n */\n public getChunk(cx: number, cy: number): ReadonlyTileChunk | undefined {\n return this._chunks.get(this._chunkKey(cx, cy));\n }\n\n /**\n * Get or create a chunk at the given coordinates.\n * For a bounded layer, creation is only allowed within the valid chunk\n * range and edge chunks are clamped to the layer's remaining size. For an\n * unbounded layer, any signed chunk coordinate is accepted and every\n * chunk is full-size ({@link chunkWidth} × {@link chunkHeight}).\n *\n * @internal Package-private: used by {@link setTileAt}, {@link fillRect},\n * and future adapter ingest. External users should not allocate\n * chunks - use {@link setTileAt} to populate tiles.\n */\n public _ensureChunk(cx: number, cy: number): TileChunk {\n this._checkDestroyed();\n const key = this._chunkKey(cx, cy);\n let chunk = this._chunks.get(key);\n if (!chunk) {\n const range = this.chunkRange();\n let cw = this.chunkWidth;\n let ch = this.chunkHeight;\n if (range !== null && this.width !== undefined && this.height !== undefined) {\n if (cx < range.minCx || cx > range.maxCx || cy < range.minCy || cy > range.maxCy) {\n throw new Error(`Chunk (${cx}, ${cy}) outside layer chunk range ` + `[${range.minCx}..${range.maxCx}, ${range.minCy}..${range.maxCy}].`);\n }\n // Compute the actual tile dimensions for this chunk (edge chunks may be smaller).\n const startTx = cx * this.chunkWidth;\n const startTy = cy * this.chunkHeight;\n cw = Math.min(this.chunkWidth, this.width - startTx);\n ch = Math.min(this.chunkHeight, this.height - startTy);\n }\n chunk = new TileChunk(cx, cy, cw, ch);\n this._chunks.set(key, chunk);\n }\n return chunk;\n }\n\n /**\n * Install a chunk-provider-supplied payload directly, bypassing per-tile\n * `setTileAt` cost. Overwrites any existing chunk at `(cx, cy)`. Always\n * bumps the layer revision (installing a chunk is always a structural\n * change, even if the payload happens to be all-zero).\n *\n * Does not validate `(cx, cy)` against {@link chunkRange} - callers\n * (chunk-streaming controllers) are trusted to request coordinates within\n * whatever range they intend to manage.\n *\n * @internal Package-private: for future chunk-provider/streaming use.\n */\n public _adoptChunk(cx: number, cy: number, payload: ChunkPayload): void {\n this._checkDestroyed();\n const chunk = new TileChunk(cx, cy, payload.width, payload.height, payload.tiles);\n this._chunks.set(this._chunkKey(cx, cy), chunk);\n this._revision++;\n this._notifyStructural({ cx, cy, chunk });\n }\n\n /**\n * Evict a chunk from storage, freeing it for garbage collection. No-op if\n * no chunk is loaded at `(cx, cy)`.\n *\n * @returns `true` if a chunk was found and removed, `false` otherwise.\n * @internal Package-private: for future chunk-streaming eviction use.\n */\n public _evictChunk(cx: number, cy: number): boolean {\n this._checkDestroyed();\n const key = this._chunkKey(cx, cy);\n if (!this._chunks.delete(key)) return false;\n this._revision++;\n this._notifyStructural({ cx, cy, chunk: null });\n return true;\n }\n\n /**\n * Register a callback invoked synchronously whenever a chunk is installed\n * ({@link _adoptChunk}) or evicted ({@link _evictChunk}). Package-internal:\n * {@link import('./TileLayerNode').TileLayerNode} subscribes to keep its\n * chunk-node children in sync with chunk-provider-driven adopt/evict calls\n * (e.g. from {@link import('./ChunkStreamer').ChunkStreamer}) without\n * needing a full {@link import('./TileLayerNode').TileLayerNode.refresh}.\n * @internal\n */\n public _addStructuralListener(listener: (event: ChunkStructuralEvent) => void): void {\n (this._structuralListeners ??= new Set()).add(listener);\n }\n\n /**\n * Unregister a listener added via {@link _addStructuralListener} (node destroy).\n * @internal\n */\n public _removeStructuralListener(listener: (event: ChunkStructuralEvent) => void): void {\n this._structuralListeners?.delete(listener);\n }\n\n private _notifyStructural(event: ChunkStructuralEvent): void {\n if (this._structuralListeners === null) return;\n for (const listener of this._structuralListeners) {\n listener(event);\n }\n }\n\n /**\n * Iterate over all loaded chunks in deterministic (cy, cx) ascending order.\n * Returns readonly chunk views - callers cannot mutate storage.\n * @advanced\n */\n public loadedChunks(): IterableIterator<ReadonlyTileChunk> {\n const entries = [...this._chunks.values()];\n entries.sort((a, b) => a.cy - b.cy || a.cx - b.cx);\n return entries[Symbol.iterator]();\n }\n\n // ── Tile queries ──────────────────────────────────────────────────────\n\n /**\n * Get the raw packed tile word at (tx, ty). Returns 0 for empty or out-of-bounds.\n * @advanced\n */\n public getRawTileAt(tx: number, ty: number): PackedTile {\n validateInteger(tx, 'tx');\n validateInteger(ty, 'ty');\n if (!this.inBounds(tx, ty)) return 0;\n const { cx, cy } = tileToChunkCoord(tx, ty, this.chunkWidth, this.chunkHeight);\n const chunk = this._chunks.get(this._chunkKey(cx, cy));\n if (!chunk) return 0;\n const { lx, ly } = tileToLocalInChunk(tx, ty, this.chunkWidth, this.chunkHeight);\n return chunk.getRawAt(lx, ly);\n }\n\n /**\n * Query a resolved tile at (tx, ty). Returns null for empty or out-of-bounds.\n * @advanced\n */\n public getTileAt(tx: number, ty: number): ResolvedTile | null {\n const packed = this.getRawTileAt(tx, ty);\n if (packed === 0) return null;\n const decoded = unpackTile(packed);\n if (!decoded) return null;\n if (decoded.tilesetIndex >= this.tilesets.length) return null;\n const tileset = this.tilesets[decoded.tilesetIndex]!;\n if (decoded.localTileId >= tileset.tileCount) return null;\n return {\n tileset,\n localTileId: decoded.localTileId,\n transform: decoded.transform,\n };\n }\n\n // ── Mutation ──────────────────────────────────────────────────────────\n\n /**\n * Validate a tile reference against the layer's tilesets.\n * Returns the packed form or throws.\n */\n private _validateTileRef(tile: ResolvedTile): PackedTile {\n if (!tile?.tileset) {\n throw new Error('setTileAt requires a valid ResolvedTile.');\n }\n const tilesetIndex = this.tilesets.indexOf(tile.tileset);\n if (tilesetIndex === -1) {\n throw new Error(`Tileset \"${tile.tileset.name}\" is not available to layer \"${this.name}\".`);\n }\n if (tile.localTileId < 0 || tile.localTileId >= tile.tileset.tileCount) {\n throw new Error(`localTileId ${tile.localTileId} out of range for tileset \"${tile.tileset.name}\" ` + `(max ${tile.tileset.tileCount - 1}).`);\n }\n return packTile(tilesetIndex, tile.localTileId, tile.transform);\n }\n\n /**\n * Set a tile at the given tile coordinates.\n * No-op if the effective value is unchanged.\n * @throws If coordinates are out of bounds or the tile reference is invalid.\n * @advanced\n */\n public setTileAt(tx: number, ty: number, tile: ResolvedTile): void {\n this._checkDestroyed();\n validateInteger(tx, 'tx');\n validateInteger(ty, 'ty');\n if (!this.inBounds(tx, ty)) {\n const boundsMsg = this.width !== undefined && this.height !== undefined ? `[0..${this.width - 1}, 0..${this.height - 1}]` : '[unbounded]';\n throw new Error(`setTileAt (${tx}, ${ty}) out of bounds ${boundsMsg}.`);\n }\n const packed = this._validateTileRef(tile);\n const { cx, cy } = tileToChunkCoord(tx, ty, this.chunkWidth, this.chunkHeight);\n const chunk = this._ensureChunk(cx, cy);\n const { lx, ly } = tileToLocalInChunk(tx, ty, this.chunkWidth, this.chunkHeight);\n if (chunk._setRawAt(lx, ly, packed)) {\n this._revision++;\n }\n }\n\n /**\n * Clear (erase) the tile at the given coordinates.\n * No-op if the cell is already empty.\n * @throws If coordinates are out of bounds.\n * @advanced\n */\n public clearTileAt(tx: number, ty: number): void {\n this._checkDestroyed();\n validateInteger(tx, 'tx');\n validateInteger(ty, 'ty');\n if (!this.inBounds(tx, ty)) {\n const boundsMsg = this.width !== undefined && this.height !== undefined ? `[0..${this.width - 1}, 0..${this.height - 1}]` : '[unbounded]';\n throw new Error(`clearTileAt (${tx}, ${ty}) out of bounds ${boundsMsg}.`);\n }\n const { cx, cy } = tileToChunkCoord(tx, ty, this.chunkWidth, this.chunkHeight);\n const chunk = this._chunks.get(this._chunkKey(cx, cy));\n if (!chunk) return; // no chunk = already empty\n const { lx, ly } = tileToLocalInChunk(tx, ty, this.chunkWidth, this.chunkHeight);\n if (chunk._setRawAt(lx, ly, 0)) {\n this._revision++;\n }\n }\n\n // ── Bulk fill ─────────────────────────────────────────────────────────\n\n /**\n * Fill a rectangular region with a tile.\n * @advanced\n */\n public fillRect(x: number, y: number, w: number, h: number, tile: ResolvedTile): void {\n this._checkDestroyed();\n const packed = this._validateTileRef(tile);\n let changed = false;\n for (let ty = y; ty < y + h; ty++) {\n for (let tx = x; tx < x + w; tx++) {\n if (!this.inBounds(tx, ty)) continue;\n const { cx, cy } = tileToChunkCoord(tx, ty, this.chunkWidth, this.chunkHeight);\n const chunk = this._ensureChunk(cx, cy);\n const { lx, ly } = tileToLocalInChunk(tx, ty, this.chunkWidth, this.chunkHeight);\n if (chunk._setRawAt(lx, ly, packed)) {\n changed = true;\n }\n }\n }\n if (changed) this._revision++;\n }\n\n /**\n * Clear a rectangular region.\n * @advanced\n */\n public clearRect(x: number, y: number, w: number, h: number): void {\n this._checkDestroyed();\n let changed = false;\n for (let ty = y; ty < y + h; ty++) {\n for (let tx = x; tx < x + w; tx++) {\n if (!this.inBounds(tx, ty)) continue;\n const { cx, cy } = tileToChunkCoord(tx, ty, this.chunkWidth, this.chunkHeight);\n const chunk = this._chunks.get(this._chunkKey(cx, cy));\n if (!chunk) continue;\n const { lx, ly } = tileToLocalInChunk(tx, ty, this.chunkWidth, this.chunkHeight);\n if (chunk._setRawAt(lx, ly, 0)) {\n changed = true;\n }\n }\n }\n if (changed) this._revision++;\n }\n\n // ── Iteration ─────────────────────────────────────────────────────────\n\n /**\n * Iterate non-empty tiles within a rectangular region in row-major order.\n * Yields (tx, ty, resolvedTile) tuples. Skips empty cells.\n * @advanced\n */\n public *tilesInRect(x: number, y: number, w: number, h: number): Generator<{ tx: number; ty: number; tile: ResolvedTile }> {\n const startCx = Math.floor(x / this.chunkWidth);\n const endCx = Math.floor((x + w - 1) / this.chunkWidth);\n const startCy = Math.floor(y / this.chunkHeight);\n const endCy = Math.floor((y + h - 1) / this.chunkHeight);\n\n for (let cy = startCy; cy <= endCy; cy++) {\n for (let cx = startCx; cx <= endCx; cx++) {\n const chunk = this._chunks.get(this._chunkKey(cx, cy));\n if (!chunk || chunk.empty) continue;\n\n const chunkStartTx = cx * this.chunkWidth;\n const chunkStartTy = cy * this.chunkHeight;\n const minLx = Math.max(0, x - chunkStartTx);\n const maxLx = Math.min(chunk.width - 1, x + w - 1 - chunkStartTx);\n const minLy = Math.max(0, y - chunkStartTy);\n const maxLy = Math.min(chunk.height - 1, y + h - 1 - chunkStartTy);\n\n for (let ly = minLy; ly <= maxLy; ly++) {\n for (let lx = minLx; lx <= maxLx; lx++) {\n const packed = chunk.getRawAt(lx, ly);\n if (packed === 0) continue;\n const decoded = unpackTile(packed);\n if (!decoded) continue;\n if (decoded.tilesetIndex >= this.tilesets.length) continue;\n const tileset = this.tilesets[decoded.tilesetIndex]!;\n if (decoded.localTileId >= tileset.tileCount) continue;\n yield {\n tx: chunkStartTx + lx,\n ty: chunkStartTy + ly,\n tile: {\n tileset,\n localTileId: decoded.localTileId,\n transform: decoded.transform,\n },\n };\n }\n }\n }\n }\n }\n\n /** Display layer translation expressed as a logical simulation-space vector. */\n public get logicalOffset(): { x: number; y: number } {\n const p = this.projection;\n return p.pixelToLogical(p.originX + this.offsetX, p.originY + this.offsetY);\n }\n\n // ── Coordinate conversion ─────────────────────────────────────────────\n\n /**\n * Convert a grid vertex to display pixels (the top diamond vertex for isometric cells)\n * including the layer's display offset.\n * @advanced\n */\n public tileToPixel(tx: number, ty: number): { x: number; y: number } {\n const point = this.projection.tileToPixel(tx, ty);\n return { x: point.x + this.offsetX, y: point.y + this.offsetY };\n }\n\n /**\n * Convert a local pixel position to the tile coordinate that contains it.\n * Uses `floor`, so a point exactly on a tile boundary maps to the tile.\n * May return coordinates outside layer bounds.\n * @advanced\n */\n public pixelToTile(px: number, py: number): { tx: number; ty: number } {\n return this.projection.pixelToTile(px - this.offsetX, py - this.offsetY);\n }\n\n // ── Revision / lifecycle ──────────────────────────────────────────────\n\n /**\n * Monotonic layer revision counter.\n * Increments on every cell mutation that changes a stored value.\n * No-op writes and failed mutations do NOT increment.\n * @advanced\n */\n public get revision(): number {\n return this._revision;\n }\n\n /** Whether the layer has been destroyed. */\n public get destroyed(): boolean {\n return this._destroyed;\n }\n\n private _checkDestroyed(): void {\n if (this._destroyed) {\n throw new Error(`TileLayer \"${this.name}\" has been destroyed.`);\n }\n }\n\n /**\n * Destroy this layer: clear chunk storage and mark destroyed.\n * Does NOT destroy tileset textures or external resources.\n * Idempotent.\n */\n public destroy(): void {\n if (this._destroyed) return;\n this._destroyed = true;\n this._chunks.clear();\n }\n\n /**\n * Total number of non-empty tiles across all chunks.\n * Walk is cheap for dense layers; sparse layers benefit from empty-chunk fast path.\n * @advanced\n */\n public countNonEmptyTiles(): number {\n let count = 0;\n for (const chunk of this._chunks.values()) {\n for (let ly = 0; ly < chunk.height; ly++) {\n for (let lx = 0; lx < chunk.width; lx++) {\n if (chunk.getRawAt(lx, ly) !== 0) count++;\n }\n }\n }\n return count;\n }\n}\n"],"mappings":";;;;;AAyEA,MAAM,qBAAqB;;AA4C3B,MAAM,wBAAwB,QAAQ,MAAc;CAClD,IAAI,CAAC,OAAO,SAAS,KAAK,KAAK,SAAS,GACtC,MAAM,IAAI,MAAM,2DAA2D;CAG7E,OAAO;AACT;;;;;;AAOA,MAAM,4BAA4B,YAAwD;CACxF,2BAA2B,QAAQ,IAAI,UAAU;CACjD,IAAI,CAAC,QAAQ,QAAQ,OAAO,QAAQ,SAAS,UAC3C,MAAM,IAAI,MAAM,4CAA4C;CAE9D,yBAAyB,QAAQ,OAAO,QAAQ,QAAQ,aAAa,OAAO;CAC5E,wBAAwB,QAAQ,WAAW,iBAAiB;CAC5D,wBAAwB,QAAQ,YAAY,kBAAkB;CAE9D,MAAM,aAAa,QAAQ,cAAc;CACzC,MAAM,cAAc,QAAQ,eAAe;CAC3C,wBAAwB,YAAY,YAAY;CAChD,wBAAwB,aAAa,aAAa;CAElD,IAAI,CAAC,MAAM,QAAQ,QAAQ,QAAQ,GACjC,MAAM,IAAI,MAAM,sCAAsC;CAGxD,MAAM,UAAU,QAAQ,WAAW;CACnC,IAAI,OAAO,YAAY,YAAY,UAAU,KAAK,UAAU,GAC1D,MAAM,IAAI,MAAM,uCAAuC,QAAQ,GAAG;CAGpE,MAAM,UAAU,QAAQ,WAAW;CACnC,MAAM,UAAU,QAAQ,WAAW;CACnC,IAAI,CAAC,OAAO,SAAS,OAAO,KAAK,CAAC,OAAO,SAAS,OAAO,GACvD,MAAM,IAAI,MAAM,0CAA0C;CAG5D,MAAM,YAAY,QAAQ,aAAa;CACvC,MAAM,YAAY,QAAQ,aAAa;CACvC,IA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