@codexo/exojs-ldtk 0.17.0 → 0.19.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 CHANGED
@@ -1,106 +1,59 @@
1
1
  # @codexo/exojs-ldtk
2
2
 
3
- Official ExoJS extension for loading [LDtk](https://ldtk.io) level files (`.ldtk`) into runtime
4
- `TileMap`s — one per LDtk level — ready to render with the generic tilemap node.
3
+ Load LDtk projects into ExoJS's format-neutral tilemap and world runtime. Use an eager map for a small project or a project runtime for independently owned levels.
5
4
 
6
- ## Installation
5
+ ## Install and activate
7
6
 
8
7
  ```sh
9
- npm install @codexo/exojs @codexo/exojs-tilemap @codexo/exojs-ldtk
8
+ npm install --save-exact @codexo/exojs @codexo/exojs-tilemap @codexo/exojs-ldtk
10
9
  ```
11
10
 
12
- Both `@codexo/exojs` and `@codexo/exojs-tilemap` are **peer** dependencies, so install them
13
- explicitly alongside the adapter. Nothing is pulled in transitively: strict package managers
14
- (pnpm, Yarn PnP) will not resolve an unlisted peer, and npm's auto-install of peers still leaves
15
- the versions outside your control. Keep the engine and every adapter on the same version.
16
-
17
- ## What this package provides
18
-
19
- - `LdtkMap` — parsed LDtk world; the result of `loader.load('world.ldtk')`. Exposes the raw `data`,
20
- the converted runtime `levels` (`readonly TileMap[]`, in document order), and
21
- `getLevelByName(identifier)`
22
- - `LdtkProject` — the streaming counterpart of `LdtkMap`: the result of
23
- `loader.load(Asset.type('ldtkProject', 'world.ldtk'))`. Loads the document and every tileset
24
- atlas, and **no** level payload. Exposes the world layout (`worlds` / `world`, one `MapWorld`
25
- per LDtk world) and `createRuntime({ scope })` for loading levels one at a time
26
- - `ldtkToMapWorld` — build the format-neutral world model (level ids, bounds, neighbours) from a
27
- raw document, without reading any layer payload
28
- - `ldtkToTileMap` — convert a single LDtk level to a `TileMap` (used internally; available for
29
- custom pipelines), plus its `LdtkToTileMapOptions`
30
- - `getLdtkIntGridValueAt` — the named/coloured IntGrid value at a tile coordinate
31
- - `createLdtkIntGridCellSource` — the layer's IntGrid as a `TileCellSource`, ready to hand to
32
- `buildTileCollisionGeometry` or `TileColliderStreamer` for collision authored per cell
33
- - `ldtkExtension` — extension descriptor; depends on `tilemapExtension` automatically
34
- - `ldtkMapBinding` / `ldtkProjectBinding` — the underlying `AssetBinding`s (advanced/custom wiring)
35
- - The raw LDtk JSON types (`LdtkData`, `LdtkLevel`, `LdtkLayerInstance`, `LdtkEntityInstance`, …)
36
- and the flip-bit constants (`LDTK_FLIP_X`, `LDTK_FLIP_Y`, `LDTK_FLIP_XY`, `LDTK_FLIP_NONE`)
37
- - `TileMap`, `TileMapNode`, `TileMapView`, `TileLayer`, `TileSet`, `ObjectLayer`, … re-exported
38
- from `@codexo/exojs-tilemap` (same class identity — `instanceof TileMap` holds across both import
39
- paths)
40
-
41
- ## Usage
42
-
43
- Register the extension and load a `.ldtk` world. One extension enables **both** loading and
44
- rendering — `ldtkExtension` depends on `tilemapExtension`, so the tile chunk renderer bindings are
45
- materialised automatically:
11
+ Core and the tilemap runtime are peer dependencies. `ldtkExtension` depends on `tilemapExtension`, so selecting the adapter installs both its loading capability and the generic tile renderer.
46
12
 
47
13
  ```ts
48
- import { Application } from '@codexo/exojs';
49
- import { LdtkMap, TileMapNode, ldtkExtension } from '@codexo/exojs-ldtk';
50
-
51
- const app = new Application({ extensions: [ldtkExtension] });
52
-
53
- const world = await app.loader.load('levels/world.ldtk');
54
-
55
- // Render the first level (each LDtk level is its own TileMap):
56
- const level = world.getLevelByName('Level_0') ?? world.levels[0];
57
- app.scenes.root.addChild(new TileMapNode(level));
58
- ```
59
-
60
- `TileMapNode` is the same class exported by `@codexo/exojs-tilemap` (see its
61
- [README](https://www.npmjs.com/package/@codexo/exojs-tilemap) for the rendering/culling model and
62
- actor interleaving).
63
-
64
- ### Streaming levels
65
-
66
- `ldtkMap` converts every level up front. For a project too large for that, load it as an
67
- `ldtkProject` and load levels individually — each gets its own `LoaderScope`, and external
68
- `.ldtkl` payloads are fetched only when their level is:
69
-
70
- ```ts
71
- import { Application, Asset } from '@codexo/exojs';
14
+ import { Application, Scene } from '@codexo/exojs';
72
15
  import { ldtkExtension } from '@codexo/exojs-ldtk';
16
+ import { TileMapNode } from '@codexo/exojs-tilemap';
17
+
18
+ class LevelScene extends Scene {
19
+ override async load(): Promise<void> {
20
+ const world = await this.loader.load('levels/world.ldtk');
21
+ const level = world.getLevelByName('Level_0') ?? world.levels[0];
22
+
23
+ if (level === undefined) {
24
+ throw new Error('The LDtk project contains no loadable level.');
25
+ }
26
+ this.root.addChild(new TileMapNode(level));
27
+ }
28
+ }
29
+
30
+ const app = new Application({
31
+ scenes: { LevelScene },
32
+ extensions: [ldtkExtension],
33
+ canvas: { width: 800, height: 600, mount: 'body' },
34
+ loader: { basePath: new URL('assets/', document.baseURI).href },
35
+ });
36
+
37
+ await app.start(LevelScene);
38
+ ```
73
39
 
74
- const app = new Application({ extensions: [ldtkExtension] });
75
-
76
- const project = await app.loader.load(Asset.type('ldtkProject', 'levels/world.ldtk'));
77
- const runtime = project.createRuntime({ scope: app.loader });
78
-
79
- const forest = await runtime.loadLevel(project.world.getLevelByName('Forest')!.id);
40
+ Serve the project and its referenced files beneath the asset base. Each LDtk level becomes its own `TileMap`; loading a project does not automatically select or display every level.
80
41
 
81
- // ... later
82
- forest.destroy(); // map, spawned objects and the level's asset claims, in that order
83
- ```
42
+ ## Eager or streamed?
84
43
 
85
- Which levels to load, and when, stays game policy — `project.world` carries the bounds and
86
- neighbour graph to decide with.
44
+ `ldtkMap` converts all levels up front. `Asset.type('ldtkProject', path)` exposes a world layout and a runtime that can acquire levels individually. External `.ldtkl` payloads are fetched when required; an embedded level's JSON is already part of the project document. Deferred conversion does not remove bytes that the initial document contains.
87
45
 
88
- ## Texture ownership
46
+ The project runtime supplies level ownership, not the game's streaming policy. Choose which levels to load, bound concurrency, and release their runtime handles when they are no longer needed. Use the Guide's failure and cancellation workflow rather than retaining non-null assertions against authored level names.
89
47
 
90
- Tileset textures are loaded via the Loader and stay in the Loader cache. `LdtkMap.destroy()`
91
- destroys the owned runtime `TileMap`s but does **not** unload textures (Loader-owned) or remove any
92
- scene nodes — the application owns those.
48
+ ## Authored data and ownership
93
49
 
94
- ## Core compatibility
50
+ Tile rendering, entity spawning, IntGrid collision, and pathfinding are separate uses of authored data. A visible layer does not create a physics body automatically. `createLdtkIntGridCellSource` exposes cell data for the tilemap-physics bridge when that is the intended collision source.
95
51
 
96
- | `@codexo/exojs-ldtk` | `@codexo/exojs` |
97
- | -------------------- | --------------- |
98
- | 0.14.x | 0.14.x |
52
+ A loader-acquired map and its texture dependencies remain claim-owned. `LdtkMap.destroy()` releases its owned runtime maps, not arbitrary scene nodes or shared loader textures. Remove displaying nodes at their owner boundary and release asset claims through their scope. Import the format-neutral rendering nodes, including `TileMapNode`, from `@codexo/exojs-tilemap`; the adapter owns LDtk loading and conversion.
99
53
 
100
- ## Links
54
+ ## Documentation
101
55
 
102
- - [API reference](https://exojs.dev/api/exojs-ldtk)
103
- - [LDtk level editor](https://ldtk.io)
56
+ [LDtk guide](https://exoridus.github.io/ExoJS/en/guide/assets/ldtk/) · [Worlds and level streaming](https://exoridus.github.io/ExoJS/en/guide/assets/worlds-and-spawning/) · [LdtkMap API](https://exoridus.github.io/ExoJS/en/api/ldtk-map/)
104
57
 
105
58
  ## License
106
59
 
@@ -1 +1 @@
1
- {"version":3,"file":"LdtkData.d.ts","sourceRoot":"","sources":["../../src/LdtkData.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAIpF,qDAAqD;AACrD,eAAO,MAAM,cAAc,IAAI,CAAC;AAChC,eAAO,MAAM,WAAW,IAAI,CAAC;AAC7B,eAAO,MAAM,WAAW,IAAI,CAAC;AAC7B,eAAO,MAAM,YAAY,IAAI,CAAC;AAE9B,mEAAmE;AACnE,MAAM,WAAW,YAAY;IAC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AQ,EAAE,CAGvC;IAED;;;;OAIG;IACH,IAAW,KAAK,IAAI,QAAQ,CAQ3B;IAED;;;;;;;;;;OAUG;IACI,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAM9D;;;;;OAKG;IACI,OAAO,IAAI,IAAI;CAKvB"}
1
+ {"version":3,"file":"LdtkMap.d.ts","sourceRoot":"","sources":["../../src/LdtkMap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAE/D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAI3C;;;;;;;;;;;GAWG;AACH,qBAAa,OAAO;IAClB,6CAA6C;IAC7C,SAAgB,MAAM,EAAE,MAAM,CAAC;IAC/B,oCAAoC;IACpC,SAAgB,IAAI,EAAE,QAAQ,CAAC;IAC/B;;;;;;;;;OASG;IACH,SAAgB,MAAM,EAAE,SAAS,OAAO,EAAE,CAAC;IAE3C,OAAO,CAAC,OAAO,CAAC,CAAsB;IAEtC,YAAmB,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,OAAO,EAAE,EAI5E;IAED;;;;;;;;;OASG;IACH,IAAW,MAAM,IAAI,SAAS,QAAQ,EAAE,CAGvC;IAED;;;;OAIG;IACH,IAAW,KAAK,IAAI,QAAQ,CAQ3B;IAED;;;;;;;;;;OAUG;IACI,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAI7D;IAED;;;;;OAKG;IACI,OAAO,IAAI,IAAI,CAIrB;CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"LdtkProject.d.ts","sourceRoot":"","sources":["../../src/LdtkProject.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,KAAK,EAAuB,QAAQ,EAAW,OAAO,EAAE,MAAM,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AG,SAAS,cAAc,EAY3E,CAAC"}
1
+ {"version":3,"file":"ldtkLevelEntries.d.ts","sourceRoot":"","sources":["../../src/ldtkLevelEntries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEtD;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CACvC;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,mBAAmB,SAAU,QAAQ,KAAG,SAAS,cAAc,EAY3E,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ldtkParallax.d.ts","sourceRoot":"","sources":["../../src/ldtkParallax.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,uEAAuE;AACvE,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,2EAA2E;IAC3E,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,2EAA2E;IAC3E,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;;GAGG;AACH,eAAO,MAAM,wBAAwB,GACnC,MAAM,QAAQ,EACd,OAAO;IACL,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B,KACA,iBAaF,CAAC"}
1
+ {"version":3,"file":"ldtkParallax.d.ts","sourceRoot":"","sources":["../../src/ldtkParallax.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,uEAAuE;AACvE,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,2EAA2E;IAC3E,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,2EAA2E;IAC3E,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;;GAGG;AACH,eAAO,MAAM,wBAAwB,SAC7B,QAAQ,SACP;IACL,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B,KACA,iBAaF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ldtkToMapWorld.d.ts","sourceRoot":"","sources":["../../src/ldtkToMapWorld.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAE/D,OAAO,KAAK,EAAE,QAAQ,EAAa,MAAM,YAAY,CAAC;AAyCtD;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,cAAc,GAAI,MAAM,QAAQ,KAAG,SAAS,QAAQ,EAgBhE,CAAC"}
1
+ {"version":3,"file":"ldtkToMapWorld.d.ts","sourceRoot":"","sources":["../../src/ldtkToMapWorld.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAE/D,OAAO,KAAK,EAAE,QAAQ,EAAa,MAAM,YAAY,CAAC;AAyCtD;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,cAAc,SAAU,QAAQ,KAAG,SAAS,QAAQ,EAgBhE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ldtkToTileMap.d.ts","sourceRoot":"","sources":["../../src/ldtkToTileMap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAoD,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACvH,OAAO,EAAe,uBAAuB,EAAE,SAAS,EAA6B,MAAM,uBAAuB,CAAC;AAEnH,OAAO,KAAK,EACV,QAAQ,EAIR,mBAAmB,EAIpB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMpC;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClD;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,aAAa,GAAI,MAAM,QAAQ,EAAE,UAAU,oBAAoB,KAAG,OAO9E,CAAC;AA2MF;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,mBAAmB,CAAC;AAEvD;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,sBAAsB,CAAC;AAiE7D;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,qBAAqB,GAAI,OAAO,SAAS,EAAE,GAAG,MAAM,EAAE,GAAG,MAAM,KAAG,mBAAmB,GAAG,SAepG,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,2BAA2B,GAAI,OAAO,SAAS,KAAG,cAAc,GAAG,SAuB/E,CAAC;AA2LF,OAAO,EAAE,uBAAuB,EAAE,CAAC"}
1
+ {"version":3,"file":"ldtkToTileMap.d.ts","sourceRoot":"","sources":["../../src/ldtkToTileMap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAoD,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACvH,OAAO,EAAe,uBAAuB,EAAE,SAAS,EAA6B,MAAM,uBAAuB,CAAC;AAEnH,OAAO,KAAK,EACV,QAAQ,EAIR,mBAAmB,EAIpB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMpC;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClD;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,aAAa,SAAU,QAAQ,YAAY,oBAAoB,KAAG,OAO9E,CAAC;AA2MF;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,mBAAmB,CAAC;AAEvD;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,sBAAsB,CAAC;AAiE7D;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,qBAAqB,UAAW,SAAS,KAAK,MAAM,KAAK,MAAM,KAAG,mBAAmB,GAAG,SAepG,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,2BAA2B,UAAW,SAAS,KAAG,cAAc,GAAG,SAuB/E,CAAC;AA0LF,OAAO,EAAE,uBAAuB,EAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ldtkToTileMap.js","names":[],"sources":["../../src/ldtkToTileMap.ts"],"sourcesContent":["import type { TileCellSource, TileMapObject, TileProperties, TilePropertyValue, TileSet } from '@codexo/exojs-tilemap';\nimport { ObjectLayer, TILE_TRANSFORM_IDENTITY, TileLayer, TileMap, TilePropertyKind } from '@codexo/exojs-tilemap';\n\nimport type {\n LdtkData,\n LdtkEntityInstance,\n LdtkFieldEnumType,\n LdtkFieldInstance,\n LdtkIntGridValueDef,\n LdtkLayerInstance,\n LdtkLevel,\n LdtkTileData,\n} from './LdtkData';\nimport { isLdtkFieldEnumType, LDTK_FLIP_X, LDTK_FLIP_Y } from './LdtkData';\nimport { getLdtkLevelEntries } from './ldtkLevelEntries';\nimport { LdtkMap } from './LdtkMap';\nimport type { LdtkLayerParallax } from './ldtkParallax';\nimport { resolveLdtkLayerParallax } from './ldtkParallax';\n\n// ── Public API ────────────────────────────────────────────────────────────────\n\n/**\n * Options for {@link ldtkToTileMap}.\n */\nexport interface LdtkToTileMapOptions {\n /**\n * Source URL of the loaded `.ldtk` file, used as {@link LdtkMap.source}.\n * Defaults to an empty string when omitted (e.g. programmatic / test usage).\n */\n readonly source?: string;\n /**\n * Pre-loaded runtime {@link TileSet}s keyed by LDtk tileset UID.\n *\n * When provided, tile layers are populated with tile data from\n * `gridTiles` / `autoLayerTiles`. Without this map, tile layers are created\n * with the correct dimensions but no tiles are placed - only entity and\n * object layers carry data.\n *\n * Populate via {@link import('./loadLdtkMap').loadLdtkMap} for asset-loading\n * flows, or pass a hand-crafted map for testing.\n */\n readonly tilesets?: ReadonlyMap<number, TileSet>;\n}\n\n/**\n * Convert a raw {@link LdtkData} document into an {@link LdtkMap} containing\n * one runtime {@link TileMap} per LDtk level.\n *\n * Tile layers (`Tiles` / `AutoLayer`) become renderable `TileLayer`s. IntGrid\n * layers become dimension-correct `TileLayer`s - tile data is placed only when\n * the layer carries `autoLayerTiles`. Entity layers become data-only\n * `ObjectLayer`s with entity position, size, and scalar field properties.\n *\n * Pass `options.tilesets` to populate tile data; omit it for structure-only\n * conversion (useful in unit tests that do not need textures).\n *\n * Transparently handles both LDtk root shapes via {@link getLdtkLevelEntries}:\n * single-world (`data.levels`) and multi-world (`data.worlds[].levels`) - in\n * the latter case every converted level's `TileMap.properties` is additionally\n * tagged with its owning world's iid under the reserved `ldtkWorldIid` key.\n */\nexport const ldtkToTileMap = (data: LdtkData, options?: LdtkToTileMapOptions): LdtkMap => {\n const source = options?.source ?? '';\n const tilesets = options?.tilesets ?? new Map<number, TileSet>();\n\n const levels = getLdtkLevelEntries(data).map((entry, levelIndex) => convertLevel(entry.level, entry.worldIid, levelIndex, data, tilesets));\n\n return new LdtkMap(source, data, levels);\n};\n\n// ── Level conversion ──────────────────────────────────────────────────────────\n\n/**\n * Convert one already-resolved LDtk level into its runtime {@link TileMap}.\n *\n * `level.layerInstances` must be present: an externalized level has to have its\n * `.ldtkl` payload merged in first, or the result is an empty map.\n * @internal\n */\nexport const ldtkLevelToTileMap = (\n level: LdtkLevel,\n worldIid: string | undefined,\n levelIndex: number,\n data: LdtkData,\n tilesets: ReadonlyMap<number, TileSet>,\n): TileMap => convertLevel(level, worldIid, levelIndex, data, tilesets);\n\nconst convertLevel = (level: LdtkLevel, worldIid: string | undefined, levelIndex: number, data: LdtkData, tilesets: ReadonlyMap<number, TileSet>): TileMap => {\n // Derive map-level tile size from the first non-entity layer, or fall back.\n const gridSize = pickLevelGridSize(level, data.defaultGridSize ?? 16);\n const mapWidth = Math.max(1, Math.ceil(level.pxWid / gridSize));\n const mapHeight = Math.max(1, Math.ceil(level.pxHei / gridSize));\n\n const runtimeTilesets: TileSet[] = [...tilesets.values()];\n const runtimeLayers: TileLayer[] = [];\n const runtimeObjectLayers: ObjectLayer[] = [];\n\n // LDtk stores layers top-to-bottom (first = top-most); preserve that order.\n const layerInstances = level.layerInstances ?? [];\n let entityCounter = 0;\n\n for (const layerInst of layerInstances) {\n // Layer IDs must be unique within a TileMap (= one level).\n // Use layerDefUid directly - it is unique per layer definition in the file.\n const layerId = layerInst.layerDefUid;\n const parallax = resolveLdtkLayerParallax(data, layerInst);\n\n switch (layerInst.__type) {\n case 'Tiles':\n case 'AutoLayer':\n runtimeLayers.push(convertTilesOrAutoLayer(layerInst, layerId, runtimeTilesets, tilesets, parallax));\n break;\n\n case 'IntGrid':\n runtimeLayers.push(convertIntGridLayer(layerInst, layerId, runtimeTilesets, tilesets, data, parallax));\n break;\n\n case 'Entities':\n runtimeObjectLayers.push(convertEntitiesLayer(layerInst, layerId, levelIndex, entityCounter, parallax));\n entityCounter += layerInst.entityInstances?.length ?? 0;\n break;\n }\n }\n\n return new TileMap({\n name: level.identifier,\n width: mapWidth,\n height: mapHeight,\n tileWidth: gridSize,\n tileHeight: gridSize,\n tilesets: runtimeTilesets,\n layers: runtimeLayers,\n objectLayers: runtimeObjectLayers,\n properties: buildLdtkLevelProperties(level, worldIid),\n });\n};\n\n/**\n * The property bag a level contributes to its runtime representation - user\n * fields first, then the reserved LDtk keys, so a same-named user field can\n * never clobber them. `ldtkWorldIid` is added only for multi-world documents;\n * a single-world document's properties stay exactly as they were before\n * multi-world support existed.\n * @internal\n */\nexport const buildLdtkLevelProperties = (level: LdtkLevel, worldIid: string | undefined): TileProperties => ({\n ...convertFieldInstances(level.fieldInstances ?? []),\n ldtkUid: level.uid,\n ldtkIid: level.iid,\n worldX: level.worldX,\n worldY: level.worldY,\n ...(worldIid !== undefined && { ldtkWorldIid: worldIid }),\n});\n\n// ── Helpers: per-layer-type level conversion ─────────────────────────────────\n\n/** Convert a `Tiles`/`AutoLayer` LDtk layer instance into a runtime {@link TileLayer}. */\nconst convertTilesOrAutoLayer = (\n layerInst: LdtkLayerInstance,\n layerId: number,\n runtimeTilesets: readonly TileSet[],\n tilesets: ReadonlyMap<number, TileSet>,\n parallax: LdtkLayerParallax,\n): TileLayer => {\n const rLayer = makeTileLayer(layerInst, layerId, runtimeTilesets, parallax);\n const tiles = layerInst.__type === 'Tiles' ? (layerInst.gridTiles ?? []) : (layerInst.autoLayerTiles ?? []);\n const tsUid = layerInst.__tilesetDefUid;\n if (tsUid !== undefined && tsUid !== null) {\n const rts = tilesets.get(tsUid);\n if (rts) populateTileLayer(rLayer, tiles, rts, layerInst.__gridSize);\n }\n return rLayer;\n};\n\n/** Convert an `IntGrid` LDtk layer instance into a runtime {@link TileLayer}. */\nconst convertIntGridLayer = (\n layerInst: LdtkLayerInstance,\n layerId: number,\n runtimeTilesets: readonly TileSet[],\n tilesets: ReadonlyMap<number, TileSet>,\n data: LdtkData,\n parallax: LdtkLayerParallax,\n): TileLayer => {\n const intGridProperties = buildIntGridProperties(layerInst, data);\n const rLayer = makeTileLayer(layerInst, layerId, runtimeTilesets, parallax, intGridProperties);\n // IntGrid layers may carry auto-tiles when \"Auto-layer\" rules are\n // configured. Use those for rendering; raw intGridCsv is exposed as\n // data-only layer properties (see buildIntGridProperties).\n const autoTiles = layerInst.autoLayerTiles ?? [];\n const tsUid = layerInst.__tilesetDefUid;\n if (autoTiles.length > 0 && tsUid !== undefined && tsUid !== null) {\n const rts = tilesets.get(tsUid);\n if (rts) populateTileLayer(rLayer, autoTiles, rts, layerInst.__gridSize);\n }\n return rLayer;\n};\n\n/** Convert an `Entities` LDtk layer instance into a runtime {@link ObjectLayer}. */\nconst convertEntitiesLayer = (\n layerInst: LdtkLayerInstance,\n layerId: number,\n levelIndex: number,\n entityCounter: number,\n parallax: LdtkLayerParallax,\n): ObjectLayer => {\n const objects = convertEntityLayer(layerInst, layerInst.__gridSize, levelIndex, entityCounter);\n return new ObjectLayer({\n id: layerId,\n name: layerInst.__identifier,\n visible: layerInst.visible,\n opacity: layerInst.opacity ?? 1,\n offsetX: parallax.offsetX + (layerInst.pxOffsetX ?? 0),\n offsetY: parallax.offsetY + (layerInst.pxOffsetY ?? 0),\n parallaxX: parallax.parallaxX,\n parallaxY: parallax.parallaxY,\n parallaxScale: parallax.parallaxScale,\n objects,\n });\n};\n\n// ── Helpers: TileLayer ────────────────────────────────────────────────────────\n\nconst makeTileLayer = (\n layerInst: LdtkLayerInstance,\n layerId: number,\n tilesets: readonly TileSet[],\n parallax: LdtkLayerParallax,\n properties?: TileProperties,\n): TileLayer =>\n new TileLayer({\n id: layerId,\n name: layerInst.__identifier,\n width: layerInst.__cWid,\n height: layerInst.__cHei,\n tilesets,\n tileWidth: layerInst.__gridSize,\n tileHeight: layerInst.__gridSize,\n visible: layerInst.visible,\n opacity: layerInst.opacity ?? 1,\n offsetX: parallax.offsetX + (layerInst.pxOffsetX ?? 0),\n offsetY: parallax.offsetY + (layerInst.pxOffsetY ?? 0),\n parallaxX: parallax.parallaxX,\n parallaxY: parallax.parallaxY,\n parallaxScale: parallax.parallaxScale,\n ...(properties && { properties }),\n });\n\nconst populateTileLayer = (layer: TileLayer, tiles: readonly LdtkTileData[], tileset: TileSet, gridSize: number): void => {\n for (const tile of tiles) {\n const tx = Math.floor(tile.px[0] / gridSize);\n const ty = Math.floor(tile.px[1] / gridSize);\n if (!layer.inBounds(tx, ty)) continue;\n\n const localTileId = tile.t;\n if (localTileId < 0 || localTileId >= tileset.tileCount) continue;\n\n const f = tile.f;\n layer.setTileAt(tx, ty, {\n tileset,\n localTileId,\n transform: {\n flipX: (f & LDTK_FLIP_X) !== 0,\n flipY: (f & LDTK_FLIP_Y) !== 0,\n diagonal: false,\n },\n });\n }\n};\n\n// ── Helpers: IntGrid ──────────────────────────────────────────────────────────\n\n/**\n * Reserved {@link TileLayer.properties} key holding the JSON-encoded raw\n * IntGrid CSV array (`readonly number[]`) for a `TileLayer` converted from an\n * LDtk `IntGrid` layer instance. Index = `y * layer.width + x`; `0` = empty.\n * Prefer {@link getLdtkIntGridValueAt} over reading this directly.\n */\nexport const ldtkIntGridCsvProperty = 'ldtkIntGridCsv';\n\n/**\n * Reserved {@link TileLayer.properties} key holding the JSON-encoded\n * {@link LdtkIntGridValueDef} array for a `TileLayer` converted from an LDtk\n * `IntGrid` layer instance - the raw-int → named/coloured mapping declared on\n * the owning layer definition (`data.defs.layers[].intGridValues`).\n * Prefer {@link getLdtkIntGridValueAt} over reading this directly.\n */\nexport const ldtkIntGridValuesProperty = 'ldtkIntGridValues';\n\n/**\n * Build the reserved IntGrid properties for a `TileLayer` from an LDtk\n * `IntGrid` layer instance, or `undefined` when the layer carries no\n * `intGridCsv` data (nothing to expose).\n *\n * {@link TileLayer.properties} values are scalar-only, so the raw CSV array\n * and the value-definition mapping are JSON-encoded into two reserved string\n * properties rather than stored as nested structures - the same\n * `properties`-bag mechanism the Tiled adapter already uses for per-layer\n * metadata, just serialized to fit its scalar-only value type.\n */\nconst buildIntGridProperties = (layerInst: LdtkLayerInstance, data: LdtkData): TileProperties | undefined => {\n const csv = layerInst.intGridCsv;\n if (!csv || csv.length === 0) return undefined;\n\n const layerDef = data.defs.layers.find(def => def.uid === layerInst.layerDefUid);\n const values = layerDef?.intGridValues ?? [];\n\n return Object.freeze({\n [ldtkIntGridCsvProperty]: JSON.stringify(csv),\n [ldtkIntGridValuesProperty]: JSON.stringify(values),\n });\n};\n\n/** Parsed, cached form of a `TileLayer`'s {@link ldtkIntGridCsvProperty} / {@link ldtkIntGridValuesProperty}. */\ninterface ParsedIntGridData {\n readonly csv: readonly number[];\n readonly values: readonly LdtkIntGridValueDef[];\n}\n\n/**\n * Per-`TileLayer` cache of parsed IntGrid CSV/value-defs data, populated\n * lazily on first {@link getLdtkIntGridValueAt} lookup for a given layer.\n *\n * Keyed by the `TileLayer` instance itself (`WeakMap`), so an entry is\n * naturally garbage-collected once the layer it was derived from is no\n * longer referenced - no manual invalidation needed since\n * {@link TileLayer.properties} is frozen and copied at construction time and\n * can never change afterwards.\n */\nconst intGridCache = new WeakMap<TileLayer, ParsedIntGridData>();\n\n/**\n * Parse (or retrieve from {@link intGridCache}) the IntGrid CSV/value-defs\n * data attached to `layer`, or `undefined` when `layer` carries no such data\n * (not converted from an IntGrid layer instance).\n */\nconst getParsedIntGridData = (layer: TileLayer): ParsedIntGridData | undefined => {\n const cached = intGridCache.get(layer);\n if (cached) return cached;\n\n const csvRaw = layer.properties[ldtkIntGridCsvProperty];\n const valuesRaw = layer.properties[ldtkIntGridValuesProperty];\n if (typeof csvRaw !== 'string' || typeof valuesRaw !== 'string') return undefined;\n\n const parsed: ParsedIntGridData = {\n csv: JSON.parse(csvRaw) as readonly number[],\n values: JSON.parse(valuesRaw) as readonly LdtkIntGridValueDef[],\n };\n intGridCache.set(layer, parsed);\n return parsed;\n};\n\n/**\n * Look up the named/coloured {@link LdtkIntGridValueDef} at a tile coordinate\n * on a `TileLayer` converted from an LDtk `IntGrid` layer instance.\n *\n * Returns `undefined` when the coordinate is out of bounds, the cell's raw\n * value is `0` (empty), the raw value has no matching definition, or `layer`\n * was not converted from an IntGrid layer instance (no IntGrid data attached\n * via {@link ldtkIntGridCsvProperty} / {@link ldtkIntGridValuesProperty}).\n *\n * The underlying JSON-encoded CSV/value-defs properties are parsed once per\n * layer and cached (see {@link getParsedIntGridData}) - safe to call from a\n * hot path (e.g. per-cell or per-frame collision/classification checks).\n */\nexport const getLdtkIntGridValueAt = (layer: TileLayer, x: number, y: number): LdtkIntGridValueDef | undefined => {\n // `inBounds()` is unconditionally true for an unbounded layer (it has no\n // fixed grid to be out of), but the flat IntGrid CSV this function reads\n // is inherently a bounded-grid concept - LDtk itself only ever produces\n // bounded layers today, but `layer` is typed generically, so guard here\n // rather than let `layer.width` narrow away from `number | undefined`.\n if (!layer.inBounds(x, y) || layer.width === undefined) return undefined;\n\n const parsed = getParsedIntGridData(layer);\n if (!parsed) return undefined;\n\n const raw = parsed.csv[y * layer.width + x];\n if (raw === undefined || raw === 0) return undefined;\n\n return parsed.values.find(v => v.value === raw);\n};\n\n/**\n * Per-cell collision classification for a `TileLayer` converted from an LDtk\n * `IntGrid` layer instance, or `undefined` when the layer carries no IntGrid\n * data (not converted from an IntGrid layer instance, or unbounded).\n *\n * The classification is the value's LDtk-authored identifier, falling back to\n * the raw integer as a string when the value definition declares none. Cells\n * whose raw value is `0` (empty) classify as `null`. Distinct IntGrid values\n * stay distinct strings: what they mean - solid, water, hazard - is the\n * caller's to decide, and an unrecognised value is data, not an error.\n *\n * The result reads the layer's frozen IntGrid data, so it is stable for the\n * lifetime of the layer and safe to hand to a consumer that samples it while\n * building geometry.\n *\n * ```ts\n * const geometry = buildTileCollisionGeometry(layer, { cells: createLdtkIntGridCellSource(layer) });\n * ```\n */\nexport const createLdtkIntGridCellSource = (layer: TileLayer): TileCellSource | undefined => {\n const parsed = getParsedIntGridData(layer);\n const width = layer.width;\n\n // The flat IntGrid CSV is indexed by row stride, which an unbounded layer\n // has no value for; LDtk never produces one, but `layer` is typed generically.\n if (!parsed || width === undefined) return undefined;\n\n const identifiers = new Map<number, string>();\n\n for (const value of parsed.values) {\n identifiers.set(value.value, value.identifier ?? String(value.value));\n }\n\n return (tx, ty) => {\n if (!layer.inBounds(tx, ty)) return null;\n\n const raw = parsed.csv[ty * width + tx];\n\n if (raw === undefined || raw === 0) return null;\n\n return identifiers.get(raw) ?? String(raw);\n };\n};\n\n// ── Helpers: ObjectLayer ──────────────────────────────────────────────────────\n\nconst convertEntityLayer = (layerInst: LdtkLayerInstance, _gridSize: number, levelIndex: number, baseCounter: number): TileMapObject[] => {\n const instances = layerInst.entityInstances ?? [];\n const objects: TileMapObject[] = [];\n\n for (let i = 0; i < instances.length; i++) {\n const entity = instances[i];\n if (entity === undefined) continue;\n // Build a deterministic numeric id: (levelIndex * 1_000_000) + counter.\n const id = levelIndex * 1_000_000 + baseCounter + i;\n objects.push(convertEntity(entity, id));\n }\n\n return objects;\n};\n\nconst convertEntity = (entity: LdtkEntityInstance, id: number): TileMapObject => {\n // entity.px is the pivot-adjusted anchor, not the bounding box's top-left\n // corner - undo the pivot offset to recover the corner TileMapObject expects.\n const x = entity.px[0] - entity.width * entity.__pivot[0];\n const y = entity.px[1] - entity.height * entity.__pivot[1];\n return {\n kind: 'rectangle',\n id,\n // The iid is the only identity LDtk guarantees stable across re-export and\n // level re-ordering, which is what a spawn session and a savegame key on;\n // the numeric id above is derived from document position and is not.\n sourceId: entity.iid,\n name: entity.__identifier,\n type: entity.__identifier,\n x,\n y,\n width: entity.width,\n height: entity.height,\n rotation: 0,\n visible: true,\n properties: convertFieldInstances(entity.fieldInstances),\n source: entity,\n };\n};\n\n/**\n * Project LDtk field instances to a flat {@link TileProperties} bag.\n * Every LDtk field type maps to a canonical {@link TilePropertyValue}\n * (scalars and enum entries pass through as their raw value;\n * `Point`/`EntityRef`/`Tile` become their tagged structured variants;\n * `Array<T>` fields recursively convert each element).\n * A field whose raw `__value` is `null` (LDtk's \"not set\" convention) is\n * omitted from the bag entirely, matching the property-absent case rather\n * than a present-but-null value.\n */\nconst convertFieldInstances = (fields: readonly LdtkFieldInstance[]): TileProperties => {\n if (fields.length === 0) return Object.freeze({});\n const out: Record<string, TilePropertyValue> = {};\n for (const field of fields) {\n const value = convertField(field);\n if (value !== undefined) {\n out[field.__identifier] = value;\n }\n }\n return Object.freeze(out);\n};\n\n/**\n * Type guard narrowing to the `Array<T>` member of {@link LdtkFieldInstance}.\n * `String.prototype.startsWith` alone does not narrow a template-literal\n * union member for the compiler; a predicate on `field` itself does.\n */\nconst isLdtkArrayField = (field: LdtkFieldInstance): field is Extract<LdtkFieldInstance, { readonly __type: `Array<${string}>` }> =>\n field.__type.startsWith('Array<');\n\n/** See {@link isLdtkArrayField} for why the narrowing needs a predicate on `field`. */\nconst isLdtkEnumField = (field: LdtkFieldInstance): field is Extract<LdtkFieldInstance, { readonly __type: LdtkFieldEnumType }> =>\n isLdtkFieldEnumType(field.__type);\n\n/** Convert one {@link LdtkFieldInstance} to its canonical {@link TilePropertyValue}, or `undefined` for a `null` (unset) field. */\nconst convertField = (field: LdtkFieldInstance): TilePropertyValue | undefined => {\n switch (field.__type) {\n case 'Int':\n case 'Float':\n case 'Bool':\n case 'String':\n case 'Multilines':\n case 'Color':\n case 'FilePath':\n case 'Enum':\n case 'Point':\n case 'EntityRef':\n case 'Tile':\n return mapLdtkFieldValue(field.__type, field.__value);\n\n default:\n break;\n }\n\n if (isLdtkEnumField(field)) {\n return mapLdtkFieldValue(field.__type, field.__value);\n }\n\n if (isLdtkArrayField(field)) {\n if (field.__value === null) return undefined;\n const elementType = field.__type.slice('Array<'.length, -1);\n const elements: TilePropertyValue[] = [];\n for (const raw of field.__value) {\n const converted = mapLdtkFieldValue(elementType, raw);\n if (converted !== undefined) elements.push(converted);\n }\n return Object.freeze(elements);\n }\n\n // Exhaustiveness check: if LDtk ever adds a new field type, `field` will\n // fail to narrow to `never` here and tsc will error.\n const _exhaustive: never = field;\n void _exhaustive;\n throw new Error(`convertFieldInstances: unrecognised LDtk field type \"${(field as LdtkFieldInstance).__type}\".`);\n};\n\n/**\n * Map a single raw LDtk field value (or array element) to its canonical\n * {@link TilePropertyValue}, given the LDtk type name it was declared with.\n * Shared by {@link convertField} (top-level fields) and array-element\n * conversion (`typeName` is the `T` extracted from an `Array<T>` field).\n * Returns `undefined` for a `null` value; throws on a type name this package\n * does not model, at the top level and inside an array alike, so an\n * unsupported field type is never mistaken for an absent or empty one.\n */\nconst mapLdtkFieldValue = (typeName: string, value: unknown): TilePropertyValue | undefined => {\n if (value === null || value === undefined) return undefined;\n\n // An enum entry is its identifier; the enum's own name is only in the type.\n if (isLdtkFieldEnumType(typeName)) {\n return value as string;\n }\n\n switch (typeName) {\n case 'Int':\n case 'Float':\n case 'Bool':\n case 'String':\n case 'Multilines':\n case 'Color':\n case 'FilePath':\n case 'Enum':\n return value as string | number | boolean;\n\n case 'Point': {\n const v = value as { cx: number; cy: number };\n return { kind: TilePropertyKind.Point, cx: v.cx, cy: v.cy };\n }\n\n case 'EntityRef': {\n const v = value as { entityIid: string; layerIid: string; levelIid: string; worldIid: string };\n return {\n kind: TilePropertyKind.ObjectRef,\n id: v.entityIid,\n layerIid: v.layerIid,\n levelIid: v.levelIid,\n worldIid: v.worldIid,\n };\n }\n\n case 'Tile': {\n const v = value as { tilesetUid: number; x: number; y: number; w: number; h: number };\n return { kind: TilePropertyKind.TileRef, tilesetUid: v.tilesetUid, x: v.x, y: v.y, w: v.w, h: v.h };\n }\n\n default:\n throw new Error(`convertFieldInstances: unrecognised LDtk field type \"${typeName}\".`);\n }\n};\n\n// ── Helpers: grid size ────────────────────────────────────────────────────────\n\nconst pickLevelGridSize = (level: LdtkLevel, fallback: number): number => {\n const instances = level.layerInstances ?? [];\n for (const layer of instances) {\n if (layer.__type !== 'Entities' && layer.__gridSize > 0) {\n return layer.__gridSize;\n }\n }\n return fallback;\n};\n\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D;EAEA,KAAK,aAAa;GAChB,MAAM,IAAI;GACV,OAAO;IACL,MAAM,iBAAiB;IACvB,IAAI,EAAE;IACN,UAAU,EAAE;IACZ,UAAU,EAAE;IACZ,UAAU,EAAE;GACd;EACF;EAEA,KAAK,QAAQ;GACX,MAAM,IAAI;GACV,OAAO;IAAE,MAAM,iBAAiB;IAAS,YAAY,EAAE;IAAY,GAAG,EAAE;IAAG,GAAG,EAAE;IAAG,GAAG,EAAE;IAAG,GAAG,EAAE;GAAE;EACpG;EAEA,SACE,MAAM,IAAI,MAAM,wDAAwD,SAAS,GAAG;CACxF;AACF;AAIA,MAAM,qBAAqB,OAAkB,aAA6B;CACxE,MAAM,YAAY,MAAM,kBAAkB,CAAC;CAC3C,KAAK,MAAM,SAAS,WAClB,IAAI,MAAM,WAAW,cAAc,MAAM,aAAa,GACpD,OAAO,MAAM;CAGjB,OAAO;AACT"}
1
+ {"version":3,"file":"ldtkToTileMap.js","names":[],"sources":["../../src/ldtkToTileMap.ts"],"sourcesContent":["import type { TileCellSource, TileMapObject, TileProperties, TilePropertyValue, TileSet } from '@codexo/exojs-tilemap';\nimport { ObjectLayer, TILE_TRANSFORM_IDENTITY, TileLayer, TileMap, TilePropertyKind } from '@codexo/exojs-tilemap';\n\nimport type {\n LdtkData,\n LdtkEntityInstance,\n LdtkFieldEnumType,\n LdtkFieldInstance,\n LdtkIntGridValueDef,\n LdtkLayerInstance,\n LdtkLevel,\n LdtkTileData,\n} from './LdtkData';\nimport { isLdtkFieldEnumType, LDTK_FLIP_X, LDTK_FLIP_Y } from './LdtkData';\nimport { getLdtkLevelEntries } from './ldtkLevelEntries';\nimport { LdtkMap } from './LdtkMap';\nimport type { LdtkLayerParallax } from './ldtkParallax';\nimport { resolveLdtkLayerParallax } from './ldtkParallax';\n\n// ── Public API ────────────────────────────────────────────────────────────────\n\n/**\n * Options for {@link ldtkToTileMap}.\n */\nexport interface LdtkToTileMapOptions {\n /**\n * Source URL of the loaded `.ldtk` file, used as {@link LdtkMap.source}.\n * Defaults to an empty string when omitted (e.g. programmatic / test usage).\n */\n readonly source?: string;\n /**\n * Pre-loaded runtime {@link TileSet}s keyed by LDtk tileset UID.\n *\n * When provided, tile layers are populated with tile data from\n * `gridTiles` / `autoLayerTiles`. Without this map, tile layers are created\n * with the correct dimensions but no tiles are placed - only entity and\n * object layers carry data.\n *\n * Populate via {@link import('./loadLdtkMap').loadLdtkMap} for asset-loading\n * flows, or pass a hand-crafted map for testing.\n */\n readonly tilesets?: ReadonlyMap<number, TileSet>;\n}\n\n/**\n * Convert a raw {@link LdtkData} document into an {@link LdtkMap} containing\n * one runtime {@link TileMap} per LDtk level.\n *\n * Tile layers (`Tiles` / `AutoLayer`) become renderable `TileLayer`s. IntGrid\n * layers become dimension-correct `TileLayer`s - tile data is placed only when\n * the layer carries `autoLayerTiles`. Entity layers become data-only\n * `ObjectLayer`s with entity position, size, and scalar field properties.\n *\n * Pass `options.tilesets` to populate tile data; omit it for structure-only\n * conversion (useful in unit tests that do not need textures).\n *\n * Transparently handles both LDtk root shapes via {@link getLdtkLevelEntries}:\n * single-world (`data.levels`) and multi-world (`data.worlds[].levels`) - in\n * the latter case every converted level's `TileMap.properties` is additionally\n * tagged with its owning world's iid under the reserved `ldtkWorldIid` key.\n */\nexport const ldtkToTileMap = (data: LdtkData, options?: LdtkToTileMapOptions): LdtkMap => {\n const source = options?.source ?? '';\n const tilesets = options?.tilesets ?? new Map<number, TileSet>();\n\n const levels = getLdtkLevelEntries(data).map((entry, levelIndex) => convertLevel(entry.level, entry.worldIid, levelIndex, data, tilesets));\n\n return new LdtkMap(source, data, levels);\n};\n\n// ── Level conversion ──────────────────────────────────────────────────────────\n\n/**\n * Convert one already-resolved LDtk level into its runtime {@link TileMap}.\n *\n * `level.layerInstances` must be present: an externalized level has to have its\n * `.ldtkl` payload merged in first, or the result is an empty map.\n * @internal\n */\nexport const ldtkLevelToTileMap = (\n level: LdtkLevel,\n worldIid: string | undefined,\n levelIndex: number,\n data: LdtkData,\n tilesets: ReadonlyMap<number, TileSet>,\n): TileMap => convertLevel(level, worldIid, levelIndex, data, tilesets);\n\nconst convertLevel = (level: LdtkLevel, worldIid: string | undefined, levelIndex: number, data: LdtkData, tilesets: ReadonlyMap<number, TileSet>): TileMap => {\n // Derive map-level tile size from the first non-entity layer, or fall back.\n const gridSize = pickLevelGridSize(level, data.defaultGridSize ?? 16);\n const mapWidth = Math.max(1, Math.ceil(level.pxWid / gridSize));\n const mapHeight = Math.max(1, Math.ceil(level.pxHei / gridSize));\n\n const runtimeTilesets: TileSet[] = [...tilesets.values()];\n const runtimeLayers: TileLayer[] = [];\n const runtimeObjectLayers: ObjectLayer[] = [];\n\n // LDtk stores layers top-to-bottom (first = top-most); preserve that order.\n const layerInstances = level.layerInstances ?? [];\n let entityCounter = 0;\n\n for (const layerInst of layerInstances) {\n // Layer IDs must be unique within a TileMap (= one level).\n // Use layerDefUid directly - it is unique per layer definition in the file.\n const layerId = layerInst.layerDefUid;\n const parallax = resolveLdtkLayerParallax(data, layerInst);\n\n switch (layerInst.__type) {\n case 'Tiles':\n case 'AutoLayer':\n runtimeLayers.push(convertTilesOrAutoLayer(layerInst, layerId, runtimeTilesets, tilesets, parallax));\n break;\n\n case 'IntGrid':\n runtimeLayers.push(convertIntGridLayer(layerInst, layerId, runtimeTilesets, tilesets, data, parallax));\n break;\n\n case 'Entities':\n runtimeObjectLayers.push(convertEntitiesLayer(layerInst, layerId, levelIndex, entityCounter, parallax));\n entityCounter += layerInst.entityInstances?.length ?? 0;\n break;\n }\n }\n\n return new TileMap({\n name: level.identifier,\n width: mapWidth,\n height: mapHeight,\n tileWidth: gridSize,\n tileHeight: gridSize,\n tilesets: runtimeTilesets,\n layers: runtimeLayers,\n objectLayers: runtimeObjectLayers,\n properties: buildLdtkLevelProperties(level, worldIid),\n });\n};\n\n/**\n * The property bag a level contributes to its runtime representation - user\n * fields first, then the reserved LDtk keys, so a same-named user field can\n * never clobber them. `ldtkWorldIid` is added only for multi-world documents;\n * a single-world document's properties stay exactly as they were before\n * multi-world support existed.\n * @internal\n */\nexport const buildLdtkLevelProperties = (level: LdtkLevel, worldIid: string | undefined): TileProperties => ({\n ...convertFieldInstances(level.fieldInstances ?? []),\n ldtkUid: level.uid,\n ldtkIid: level.iid,\n worldX: level.worldX,\n worldY: level.worldY,\n ...(worldIid !== undefined && { ldtkWorldIid: worldIid }),\n});\n\n// ── Helpers: per-layer-type level conversion ─────────────────────────────────\n\n/** Convert a `Tiles`/`AutoLayer` LDtk layer instance into a runtime {@link TileLayer}. */\nconst convertTilesOrAutoLayer = (\n layerInst: LdtkLayerInstance,\n layerId: number,\n runtimeTilesets: readonly TileSet[],\n tilesets: ReadonlyMap<number, TileSet>,\n parallax: LdtkLayerParallax,\n): TileLayer => {\n const rLayer = makeTileLayer(layerInst, layerId, runtimeTilesets, parallax);\n const tiles = layerInst.__type === 'Tiles' ? (layerInst.gridTiles ?? []) : (layerInst.autoLayerTiles ?? []);\n const tsUid = layerInst.__tilesetDefUid;\n if (tsUid !== undefined && tsUid !== null) {\n const rts = tilesets.get(tsUid);\n if (rts) populateTileLayer(rLayer, tiles, rts, layerInst.__gridSize);\n }\n return rLayer;\n};\n\n/** Convert an `IntGrid` LDtk layer instance into a runtime {@link TileLayer}. */\nconst convertIntGridLayer = (\n layerInst: LdtkLayerInstance,\n layerId: number,\n runtimeTilesets: readonly TileSet[],\n tilesets: ReadonlyMap<number, TileSet>,\n data: LdtkData,\n parallax: LdtkLayerParallax,\n): TileLayer => {\n const intGridProperties = buildIntGridProperties(layerInst, data);\n const rLayer = makeTileLayer(layerInst, layerId, runtimeTilesets, parallax, intGridProperties);\n // IntGrid layers may carry auto-tiles when \"Auto-layer\" rules are\n // configured. Use those for rendering; raw intGridCsv is exposed as\n // data-only layer properties (see buildIntGridProperties).\n const autoTiles = layerInst.autoLayerTiles ?? [];\n const tsUid = layerInst.__tilesetDefUid;\n if (autoTiles.length > 0 && tsUid !== undefined && tsUid !== null) {\n const rts = tilesets.get(tsUid);\n if (rts) populateTileLayer(rLayer, autoTiles, rts, layerInst.__gridSize);\n }\n return rLayer;\n};\n\n/** Convert an `Entities` LDtk layer instance into a runtime {@link ObjectLayer}. */\nconst convertEntitiesLayer = (\n layerInst: LdtkLayerInstance,\n layerId: number,\n levelIndex: number,\n entityCounter: number,\n parallax: LdtkLayerParallax,\n): ObjectLayer => {\n const objects = convertEntityLayer(layerInst, layerInst.__gridSize, levelIndex, entityCounter);\n return new ObjectLayer({\n id: layerId,\n name: layerInst.__identifier,\n visible: layerInst.visible,\n opacity: layerInst.opacity ?? 1,\n offsetX: parallax.offsetX + (layerInst.pxOffsetX ?? 0),\n offsetY: parallax.offsetY + (layerInst.pxOffsetY ?? 0),\n parallaxX: parallax.parallaxX,\n parallaxY: parallax.parallaxY,\n parallaxScale: parallax.parallaxScale,\n objects,\n });\n};\n\n// ── Helpers: TileLayer ────────────────────────────────────────────────────────\n\nconst makeTileLayer = (\n layerInst: LdtkLayerInstance,\n layerId: number,\n tilesets: readonly TileSet[],\n parallax: LdtkLayerParallax,\n properties?: TileProperties,\n): TileLayer =>\n new TileLayer({\n id: layerId,\n name: layerInst.__identifier,\n width: layerInst.__cWid,\n height: layerInst.__cHei,\n tilesets,\n tileWidth: layerInst.__gridSize,\n tileHeight: layerInst.__gridSize,\n visible: layerInst.visible,\n opacity: layerInst.opacity ?? 1,\n offsetX: parallax.offsetX + (layerInst.pxOffsetX ?? 0),\n offsetY: parallax.offsetY + (layerInst.pxOffsetY ?? 0),\n parallaxX: parallax.parallaxX,\n parallaxY: parallax.parallaxY,\n parallaxScale: parallax.parallaxScale,\n ...(properties && { properties }),\n });\n\nconst populateTileLayer = (layer: TileLayer, tiles: readonly LdtkTileData[], tileset: TileSet, gridSize: number): void => {\n for (const tile of tiles) {\n const tx = Math.floor(tile.px[0] / gridSize);\n const ty = Math.floor(tile.px[1] / gridSize);\n if (!layer.inBounds(tx, ty)) continue;\n\n const localTileId = tile.t;\n if (localTileId < 0 || localTileId >= tileset.tileCount) continue;\n\n const f = tile.f;\n layer.setTileAt(tx, ty, {\n tileset,\n localTileId,\n transform: {\n flipX: (f & LDTK_FLIP_X) !== 0,\n flipY: (f & LDTK_FLIP_Y) !== 0,\n diagonal: false,\n },\n });\n }\n};\n\n// ── Helpers: IntGrid ──────────────────────────────────────────────────────────\n\n/**\n * Reserved {@link TileLayer.properties} key holding the JSON-encoded raw\n * IntGrid CSV array (`readonly number[]`) for a `TileLayer` converted from an\n * LDtk `IntGrid` layer instance. Index = `y * layer.width + x`; `0` = empty.\n * Prefer {@link getLdtkIntGridValueAt} over reading this directly.\n */\nexport const ldtkIntGridCsvProperty = 'ldtkIntGridCsv';\n\n/**\n * Reserved {@link TileLayer.properties} key holding the JSON-encoded\n * {@link LdtkIntGridValueDef} array for a `TileLayer` converted from an LDtk\n * `IntGrid` layer instance - the raw-int → named/coloured mapping declared on\n * the owning layer definition (`data.defs.layers[].intGridValues`).\n * Prefer {@link getLdtkIntGridValueAt} over reading this directly.\n */\nexport const ldtkIntGridValuesProperty = 'ldtkIntGridValues';\n\n/**\n * Build the reserved IntGrid properties for a `TileLayer` from an LDtk\n * `IntGrid` layer instance, or `undefined` when the layer carries no\n * `intGridCsv` data (nothing to expose).\n *\n * {@link TileLayer.properties} values are scalar-only, so the raw CSV array\n * and the value-definition mapping are JSON-encoded into two reserved string\n * properties rather than stored as nested structures - the same\n * `properties`-bag mechanism the Tiled adapter already uses for per-layer\n * metadata, just serialized to fit its scalar-only value type.\n */\nconst buildIntGridProperties = (layerInst: LdtkLayerInstance, data: LdtkData): TileProperties | undefined => {\n const csv = layerInst.intGridCsv;\n if (!csv || csv.length === 0) return undefined;\n\n const layerDef = data.defs.layers.find(def => def.uid === layerInst.layerDefUid);\n const values = layerDef?.intGridValues ?? [];\n\n return Object.freeze({\n [ldtkIntGridCsvProperty]: JSON.stringify(csv),\n [ldtkIntGridValuesProperty]: JSON.stringify(values),\n });\n};\n\n/** Parsed, cached form of a `TileLayer`'s {@link ldtkIntGridCsvProperty} / {@link ldtkIntGridValuesProperty}. */\ninterface ParsedIntGridData {\n readonly csv: readonly number[];\n readonly values: readonly LdtkIntGridValueDef[];\n}\n\n/**\n * Per-`TileLayer` cache of parsed IntGrid CSV/value-defs data, populated\n * lazily on first {@link getLdtkIntGridValueAt} lookup for a given layer.\n *\n * Keyed by the `TileLayer` instance itself (`WeakMap`), so an entry is\n * naturally garbage-collected once the layer it was derived from is no\n * longer referenced - no manual invalidation needed since\n * {@link TileLayer.properties} is frozen and copied at construction time and\n * can never change afterwards.\n */\nconst intGridCache = new WeakMap<TileLayer, ParsedIntGridData>();\n\n/**\n * Parse (or retrieve from {@link intGridCache}) the IntGrid CSV/value-defs\n * data attached to `layer`, or `undefined` when `layer` carries no such data\n * (not converted from an IntGrid layer instance).\n */\nconst getParsedIntGridData = (layer: TileLayer): ParsedIntGridData | undefined => {\n const cached = intGridCache.get(layer);\n if (cached) return cached;\n\n const csvRaw = layer.properties[ldtkIntGridCsvProperty];\n const valuesRaw = layer.properties[ldtkIntGridValuesProperty];\n if (typeof csvRaw !== 'string' || typeof valuesRaw !== 'string') return undefined;\n\n const parsed: ParsedIntGridData = {\n csv: JSON.parse(csvRaw) as readonly number[],\n values: JSON.parse(valuesRaw) as readonly LdtkIntGridValueDef[],\n };\n intGridCache.set(layer, parsed);\n return parsed;\n};\n\n/**\n * Look up the named/coloured {@link LdtkIntGridValueDef} at a tile coordinate\n * on a `TileLayer` converted from an LDtk `IntGrid` layer instance.\n *\n * Returns `undefined` when the coordinate is out of bounds, the cell's raw\n * value is `0` (empty), the raw value has no matching definition, or `layer`\n * was not converted from an IntGrid layer instance (no IntGrid data attached\n * via {@link ldtkIntGridCsvProperty} / {@link ldtkIntGridValuesProperty}).\n *\n * The underlying JSON-encoded CSV/value-defs properties are parsed once per\n * layer and cached (see {@link getParsedIntGridData}) - safe to call from a\n * hot path (e.g. per-cell or per-frame collision/classification checks).\n */\nexport const getLdtkIntGridValueAt = (layer: TileLayer, x: number, y: number): LdtkIntGridValueDef | undefined => {\n // `inBounds()` is unconditionally true for an unbounded layer (it has no\n // fixed grid to be out of), but the flat IntGrid CSV this function reads\n // is inherently a bounded-grid concept - LDtk itself only ever produces\n // bounded layers today, but `layer` is typed generically, so guard here\n // rather than let `layer.width` narrow away from `number | undefined`.\n if (!layer.inBounds(x, y) || layer.width === undefined) return undefined;\n\n const parsed = getParsedIntGridData(layer);\n if (!parsed) return undefined;\n\n const raw = parsed.csv[y * layer.width + x];\n if (raw === undefined || raw === 0) return undefined;\n\n return parsed.values.find(v => v.value === raw);\n};\n\n/**\n * Per-cell collision classification for a `TileLayer` converted from an LDtk\n * `IntGrid` layer instance, or `undefined` when the layer carries no IntGrid\n * data (not converted from an IntGrid layer instance, or unbounded).\n *\n * The classification is the value's LDtk-authored identifier, falling back to\n * the raw integer as a string when the value definition declares none. Cells\n * whose raw value is `0` (empty) classify as `null`. Distinct IntGrid values\n * stay distinct strings: what they mean - solid, water, hazard - is the\n * caller's to decide, and an unrecognised value is data, not an error.\n *\n * The result reads the layer's frozen IntGrid data, so it is stable for the\n * lifetime of the layer and safe to hand to a consumer that samples it while\n * building geometry.\n *\n * ```ts\n * const geometry = buildTileCollisionGeometry(layer, { cells: createLdtkIntGridCellSource(layer) });\n * ```\n */\nexport const createLdtkIntGridCellSource = (layer: TileLayer): TileCellSource | undefined => {\n const parsed = getParsedIntGridData(layer);\n const width = layer.width;\n\n // The flat IntGrid CSV is indexed by row stride, which an unbounded layer\n // has no value for; LDtk never produces one, but `layer` is typed generically.\n if (!parsed || width === undefined) return undefined;\n\n const identifiers = new Map<number, string>();\n\n for (const value of parsed.values) {\n identifiers.set(value.value, value.identifier ?? String(value.value));\n }\n\n return (tx, ty) => {\n if (!layer.inBounds(tx, ty)) return null;\n\n const raw = parsed.csv[ty * width + tx];\n\n if (raw === undefined || raw === 0) return null;\n\n return identifiers.get(raw) ?? String(raw);\n };\n};\n\n// ── Helpers: ObjectLayer ──────────────────────────────────────────────────────\n\nconst convertEntityLayer = (layerInst: LdtkLayerInstance, _gridSize: number, levelIndex: number, baseCounter: number): TileMapObject[] => {\n const instances = layerInst.entityInstances ?? [];\n const objects: TileMapObject[] = [];\n\n for (let i = 0; i < instances.length; i++) {\n const entity = instances[i];\n if (entity === undefined) continue;\n // Build a deterministic numeric id: (levelIndex * 1_000_000) + counter.\n const id = levelIndex * 1_000_000 + baseCounter + i;\n objects.push(convertEntity(entity, id));\n }\n\n return objects;\n};\n\nconst convertEntity = (entity: LdtkEntityInstance, id: number): TileMapObject => {\n // entity.px is the pivot-adjusted anchor, not the bounding box's top-left\n // corner - undo the pivot offset to recover the corner TileMapObject expects.\n const x = entity.px[0] - entity.width * entity.__pivot[0];\n const y = entity.px[1] - entity.height * entity.__pivot[1];\n return {\n kind: 'rectangle',\n id,\n // The iid is the only identity LDtk guarantees stable across re-export and\n // level re-ordering, which is what a spawn session and a savegame key on;\n // the numeric id above is derived from document position and is not.\n sourceId: entity.iid,\n name: entity.__identifier,\n type: entity.__identifier,\n x,\n y,\n width: entity.width,\n height: entity.height,\n rotation: 0,\n visible: true,\n properties: convertFieldInstances(entity.fieldInstances),\n source: entity,\n };\n};\n\n/**\n * Project LDtk field instances to a flat {@link TileProperties} bag.\n * Every LDtk field type maps to a canonical {@link TilePropertyValue}\n * (scalars and enum entries pass through as their raw value;\n * `Point`/`EntityRef`/`Tile` become their tagged structured variants;\n * `Array<T>` fields recursively convert each element).\n * A field whose raw `__value` is `null` (LDtk's \"not set\" convention) is\n * omitted from the bag entirely, matching the property-absent case rather\n * than a present-but-null value.\n */\nconst convertFieldInstances = (fields: readonly LdtkFieldInstance[]): TileProperties => {\n if (fields.length === 0) return Object.freeze({});\n const out: Record<string, TilePropertyValue> = {};\n for (const field of fields) {\n const value = convertField(field);\n if (value !== undefined) {\n out[field.__identifier] = value;\n }\n }\n return Object.freeze(out);\n};\n\n/**\n * Type guard narrowing to the `Array<T>` member of {@link LdtkFieldInstance}.\n * `String.prototype.startsWith` alone does not narrow a template-literal\n * union member for the compiler; a predicate on `field` itself does.\n */\nconst isLdtkArrayField = (field: LdtkFieldInstance): field is Extract<LdtkFieldInstance, { readonly __type: `Array<${string}>` }> =>\n field.__type.startsWith('Array<');\n\n/** See {@link isLdtkArrayField} for why the narrowing needs a predicate on `field`. */\nconst isLdtkEnumField = (field: LdtkFieldInstance): field is Extract<LdtkFieldInstance, { readonly __type: LdtkFieldEnumType }> =>\n isLdtkFieldEnumType(field.__type);\n\n/** Convert one {@link LdtkFieldInstance} to its canonical {@link TilePropertyValue}, or `undefined` for a `null` (unset) field. */\nconst convertField = (field: LdtkFieldInstance): TilePropertyValue | undefined => {\n switch (field.__type) {\n case 'Int':\n case 'Float':\n case 'Bool':\n case 'String':\n case 'Multilines':\n case 'Color':\n case 'FilePath':\n case 'Enum':\n case 'Point':\n case 'EntityRef':\n case 'Tile':\n return mapLdtkFieldValue(field.__type, field.__value);\n\n default:\n break;\n }\n\n if (isLdtkEnumField(field)) {\n return mapLdtkFieldValue(field.__type, field.__value);\n }\n\n if (isLdtkArrayField(field)) {\n if (field.__value === null) return undefined;\n const elementType = field.__type.slice('Array<'.length, -1);\n const elements: TilePropertyValue[] = [];\n for (const raw of field.__value) {\n const converted = mapLdtkFieldValue(elementType, raw);\n if (converted !== undefined) elements.push(converted);\n }\n return Object.freeze(elements);\n }\n\n // Exhaustiveness check: if LDtk ever adds a new field type, `field` will\n // fail to narrow to `never` here and tsc will error.\n field satisfies never;\n throw new Error(`convertFieldInstances: unrecognised LDtk field type \"${(field as LdtkFieldInstance).__type}\".`);\n};\n\n/**\n * Map a single raw LDtk field value (or array element) to its canonical\n * {@link TilePropertyValue}, given the LDtk type name it was declared with.\n * Shared by {@link convertField} (top-level fields) and array-element\n * conversion (`typeName` is the `T` extracted from an `Array<T>` field).\n * Returns `undefined` for a `null` value; throws on a type name this package\n * does not model, at the top level and inside an array alike, so an\n * unsupported field type is never mistaken for an absent or empty one.\n */\nconst mapLdtkFieldValue = (typeName: string, value: unknown): TilePropertyValue | undefined => {\n if (value === null || value === undefined) return undefined;\n\n // An enum entry is its identifier; the enum's own name is only in the type.\n if (isLdtkFieldEnumType(typeName)) {\n return value as string;\n }\n\n switch (typeName) {\n case 'Int':\n case 'Float':\n case 'Bool':\n case 'String':\n case 'Multilines':\n case 'Color':\n case 'FilePath':\n case 'Enum':\n return value as string | number | boolean;\n\n case 'Point': {\n const v = value as { cx: number; cy: number };\n return { kind: TilePropertyKind.Point, cx: v.cx, cy: v.cy };\n }\n\n case 'EntityRef': {\n const v = value as { entityIid: string; layerIid: string; levelIid: string; worldIid: string };\n return {\n kind: TilePropertyKind.ObjectRef,\n id: v.entityIid,\n layerIid: v.layerIid,\n levelIid: v.levelIid,\n worldIid: v.worldIid,\n };\n }\n\n case 'Tile': {\n const v = value as { tilesetUid: number; x: number; y: number; w: number; h: number };\n return { kind: TilePropertyKind.TileRef, tilesetUid: v.tilesetUid, x: v.x, y: v.y, w: v.w, h: v.h };\n }\n\n default:\n throw new Error(`convertFieldInstances: unrecognised LDtk field type \"${typeName}\".`);\n }\n};\n\n// ── Helpers: grid size ────────────────────────────────────────────────────────\n\nconst pickLevelGridSize = (level: LdtkLevel, fallback: number): number => {\n const instances = level.layerInstances ?? [];\n for (const layer of instances) {\n if (layer.__type !== 'Entities' && layer.__gridSize > 0) {\n return layer.__gridSize;\n }\n }\n return fallback;\n};\n\n// Re-export identity transform constant for convenience (tree-shake friendly).\nexport { TILE_TRANSFORM_IDENTITY };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA6DA,MAAa,iBAAiB,MAAgB,YAA4C;CACxF,MAAM,SAAS,SAAS,UAAU;CAClC,MAAM,WAAW,SAAS,4BAAY,IAAI,IAAqB;CAE/D,MAAM,SAAS,oBAAoB,IAAI,CAAC,CAAC,KAAK,OAAO,eAAe,aAAa,MAAM,OAAO,MAAM,UAAU,YAAY,MAAM,QAAQ,CAAC;CAEzI,OAAO,IAAI,QAAQ,QAAQ,MA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G;CACxF;AACF;AAIA,MAAM,qBAAqB,OAAkB,aAA6B;CACxE,MAAM,YAAY,MAAM,kBAAkB,CAAC;CAC3C,KAAK,MAAM,SAAS,WAClB,IAAI,MAAM,WAAW,cAAc,MAAM,aAAa,GACpD,OAAO,MAAM;CAGjB,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"ldtkTypes.d.ts","sourceRoot":"","sources":["../../src/ldtkTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAI5C;;;;;;;GAOG;AACH,qBAAa,gBAAiB,SAAQ,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC;IAC5D,SAAgB,EAAE,aAAa;IAC/B,SAAyB,UAAU,WAAY;IAC/C,SAAyB,MAAM,iBAAW;IAE1C;;;OAGG;IACa,gBAAgB,IAAI;QAAE,MAAM,EAAE,IAAI,CAAA;KAAE;IAI7C,aAAa,IAAI,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC;CAGpD;AAED;;;;;;;;GAQG;AACH,qBAAa,oBAAqB,SAAQ,SAAS,CAAC,IAAI,EAAE,WAAW,CAAC;IACpE,SAAgB,EAAE,iBAAiB;IACnC,SAAyB,MAAM,qBAAe;IAE9B,gBAAgB,IAAI;QAAE,MAAM,EAAE,IAAI,CAAA;KAAE;IAI7C,aAAa,IAAI,YAAY,CAAC,IAAI,EAAE,WAAW,CAAC;CAGxD;AAED,2EAA2E;AAC3E,eAAO,MAAM,WAAW,kBAAyB,CAAC;AAClD,iFAAiF;AACjF,eAAO,MAAM,eAAe,sBAA6B,CAAC"}
1
+ {"version":3,"file":"ldtkTypes.d.ts","sourceRoot":"","sources":["../../src/ldtkTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAI5C;;;;;;;GAOG;AACH,qBAAa,gBAAiB,SAAQ,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC;IAC5D,SAAgB,EAAE,aAAa;IAC/B,SAAyB,UAAU,WAAY;IAC/C,SAAyB,MAAM,iBAAW;IAE1C;;;OAGG;IACa,gBAAgB,IAAI;QAAE,MAAM,EAAE,IAAI,CAAA;KAAE,CAEnD;IAEM,aAAa,IAAI,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAElD;CACF;AAED;;;;;;;;GAQG;AACH,qBAAa,oBAAqB,SAAQ,SAAS,CAAC,IAAI,EAAE,WAAW,CAAC;IACpE,SAAgB,EAAE,iBAAiB;IACnC,SAAyB,MAAM,qBAAe;IAE9B,gBAAgB,IAAI;QAAE,MAAM,EAAE,IAAI,CAAA;KAAE,CAEnD;IAEM,aAAa,IAAI,YAAY,CAAC,IAAI,EAAE,WAAW,CAAC,CAEtD;CACF;AAED,2EAA2E;AAC3E,eAAO,MAAM,WAAW,kBAAyB,CAAC;AAClD,iFAAiF;AACjF,eAAO,MAAM,eAAe,sBAA6B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/validate.ts"],"names":[],"mappings":"AAqBA;;;;;GAKG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IACxC,SAAgB,MAAM,EAAE,MAAM,CAAC;IAC/B,SAAgB,IAAI,EAAE,MAAM,CAAC;gBAEV,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAMjE"}
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/validate.ts"],"names":[],"mappings":"AAqBA;;;;;GAKG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IACxC,SAAgB,MAAM,EAAE,MAAM,CAAC;IAC/B,SAAgB,IAAI,EAAE,MAAM,CAAC;IAE7B,YAAmB,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAK/D;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codexo/exojs-ldtk",
3
- "version": "0.17.0",
3
+ "version": "0.19.0",
4
4
  "description": "LDtk level format asset extension for ExoJS.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -26,13 +26,13 @@
26
26
  "LICENSE"
27
27
  ],
28
28
  "peerDependencies": {
29
- "@codexo/exojs": "0.17.x",
30
- "@codexo/exojs-tilemap": "0.17.x"
29
+ "@codexo/exojs": "0.19.x",
30
+ "@codexo/exojs-tilemap": "0.19.x"
31
31
  },
32
32
  "devDependencies": {
33
- "@codexo/exojs": "0.17.0",
33
+ "@codexo/exojs": "0.19.0",
34
34
  "@codexo/exojs-config": "0.0.0",
35
- "@codexo/exojs-tilemap": "0.17.0"
35
+ "@codexo/exojs-tilemap": "0.19.0"
36
36
  },
37
37
  "license": "MIT",
38
38
  "publishConfig": {
@@ -41,7 +41,7 @@
41
41
  "scripts": {
42
42
  "build": "tsx ../../scripts/build-extension.ts",
43
43
  "build:dev": "tsx ../../scripts/build-extension.ts --dev",
44
- "typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.test.json",
44
+ "typecheck": "exo-tsc --noEmit && exo-tsc --noEmit -p tsconfig.test.json",
45
45
  "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
46
46
  "test": "vitest run --root ../.. --project=exojs-ldtk"
47
47
  }