@codexo/exojs-ldtk 0.14.0 → 0.15.1

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 ADDED
@@ -0,0 +1,89 @@
1
+ # @codexo/exojs-ldtk
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.
5
+
6
+ ## Installation
7
+
8
+ ```sh
9
+ npm install @codexo/exojs @codexo/exojs-ldtk
10
+ ```
11
+
12
+ `@codexo/exojs` is a peer dependency. `@codexo/exojs-tilemap` is a regular dependency and is
13
+ installed transitively — you do not need to install it manually.
14
+
15
+ ## What this package provides
16
+
17
+ - `LdtkMap` — parsed LDtk world; the result of `loader.load(LdtkMap, url)`. Exposes the raw `data`,
18
+ the converted runtime `levels` (`readonly TileMap[]`, in document order), and
19
+ `getLevelByName(identifier)`
20
+ - `ldtkToTileMap` — convert a single LDtk level to a `TileMap` (used internally; available for
21
+ custom pipelines), plus its `LdtkToTileMapOptions`
22
+ - `ldtkExtension` — extension descriptor; depends on `tilemapExtension` automatically
23
+ - `ldtkMapBinding` — the underlying `AssetBinding` (advanced/custom wiring)
24
+ - The raw LDtk JSON types (`LdtkData`, `LdtkLevel`, `LdtkLayerInstance`, `LdtkEntityInstance`, …)
25
+ and the flip-bit constants (`ldtkFlipX`, `ldtkFlipY`, `ldtkFlipXy`, `ldtkFlipNone`)
26
+ - `TileMap`, `TileMapNode`, `TileMapView`, `TileLayer`, `TileSet`, `ObjectLayer`, … re-exported
27
+ from `@codexo/exojs-tilemap` (same class identity — `instanceof TileMap` holds across both import
28
+ paths)
29
+
30
+ ## Usage
31
+
32
+ Register the extension and load a `.ldtk` world. One extension enables **both** loading and
33
+ rendering — `ldtkExtension` depends on `tilemapExtension`, so the tile chunk renderer bindings are
34
+ materialised automatically:
35
+
36
+ ```ts
37
+ import { Application } from '@codexo/exojs';
38
+ import { LdtkMap, TileMapNode, ldtkExtension } from '@codexo/exojs-ldtk';
39
+
40
+ const app = new Application({ extensions: [ldtkExtension] });
41
+
42
+ const world = await app.loader.load(LdtkMap, 'levels/world.ldtk');
43
+
44
+ // Render the first level (each LDtk level is its own TileMap):
45
+ const level = world.getLevelByName('Level_0') ?? world.levels[0];
46
+ app.scene.root.addChild(new TileMapNode(level));
47
+ ```
48
+
49
+ `TileMapNode` is the same class exported by `@codexo/exojs-tilemap` (see its
50
+ [README](https://www.npmjs.com/package/@codexo/exojs-tilemap) for the rendering/culling model and
51
+ actor interleaving).
52
+
53
+ ## `/register` convenience entry
54
+
55
+ Importing `/register` registers `ldtkExtension` (and its `tilemapExtension` dependency) in the
56
+ global `ExtensionRegistry`, so subsequently created Applications that use global defaults pick them
57
+ up automatically:
58
+
59
+ ```ts
60
+ // Side effect: registers ldtkExtension in the global ExtensionRegistry.
61
+ import '@codexo/exojs-ldtk/register';
62
+
63
+ // All named exports are also re-exported from /register:
64
+ import { LdtkMap, ldtkExtension } from '@codexo/exojs-ldtk/register';
65
+ ```
66
+
67
+ This is the only side-effectful entry — importing the package root (`@codexo/exojs-ldtk`) does
68
+ **not** register anything.
69
+
70
+ ## Texture ownership
71
+
72
+ Tileset textures are loaded via the Loader and stay in the Loader cache. `LdtkMap.destroy()`
73
+ destroys the owned runtime `TileMap`s but does **not** unload textures (Loader-owned) or remove any
74
+ scene nodes — the application owns those.
75
+
76
+ ## Core compatibility
77
+
78
+ | `@codexo/exojs-ldtk` | `@codexo/exojs` |
79
+ |---|---|
80
+ | 0.14.x | 0.14.x |
81
+
82
+ ## Links
83
+
84
+ - [API reference](https://exojs.dev/api/exojs-ldtk)
85
+ - [LDtk level editor](https://ldtk.io)
86
+
87
+ ## License
88
+
89
+ MIT © Codexo
@@ -7,6 +7,7 @@
7
7
  *
8
8
  * @see https://ldtk.io/json/
9
9
  */
10
+ import type { TilePropertyPoint, TilePropertyTileRef } from '@codexo/exojs-tilemap';
10
11
  /** Flip-bit constants for {@link LdtkTileData.f}. */
11
12
  export declare const ldtkFlipNone = 0;
12
13
  export declare const ldtkFlipX = 1;
@@ -28,22 +29,84 @@ export interface LdtkTileData {
28
29
  /** Per-tile opacity in `[0, 1]`. Defaults to `1` when absent. */
29
30
  readonly a?: number;
30
31
  }
31
- /** A field value on an entity or level instance. */
32
- export interface LdtkFieldInstance {
33
- readonly __identifier: string;
34
- readonly __type: string;
35
- readonly __value: unknown;
32
+ /**
33
+ * LDtk field types whose `__value` is a bare scalar (or `null`, when the
34
+ * field has no value set).
35
+ */
36
+ export type LdtkFieldScalarType = 'Int' | 'Float' | 'Bool' | 'String' | 'Multilines' | 'Color' | 'FilePath' | 'Enum';
37
+ /**
38
+ * Raw `__value` shape for a `Point`-typed field. Structurally identical to
39
+ * {@link TilePropertyPoint} minus its `kind` tag, so the canonical shape is
40
+ * reused directly rather than duplicated.
41
+ */
42
+ export type LdtkFieldPointValue = Omit<TilePropertyPoint, 'kind'>;
43
+ /**
44
+ * Raw `__value` shape for an `EntityRef`-typed field: the referenced
45
+ * entity's own iid plus LDtk's navigation context (owning layer/level/world).
46
+ * Maps to {@link import('@codexo/exojs-tilemap').TilePropertyObjectRef} —
47
+ * `entityIid` becomes `id`.
48
+ */
49
+ export interface LdtkFieldEntityRefValue {
50
+ readonly entityIid: string;
51
+ readonly layerIid: string;
52
+ readonly levelIid: string;
53
+ readonly worldIid: string;
36
54
  }
55
+ /**
56
+ * Raw `__value` shape for a `Tile`-typed field. Structurally identical to
57
+ * {@link TilePropertyTileRef} minus its `kind` tag, so the canonical shape is
58
+ * reused directly rather than duplicated.
59
+ */
60
+ export type LdtkFieldTileValue = Omit<TilePropertyTileRef, 'kind'>;
61
+ /**
62
+ * A field value on an entity or level instance, discriminated by `__type`.
63
+ * `Array<T>` fields (e.g. `Array<Int>`, `Array<Point>`) carry a raw element
64
+ * array whose per-element shape matches the corresponding non-array
65
+ * `__value` shape above; see {@link import('./ldtkToTileMap').ldtkToTileMap}'s
66
+ * field conversion for the exhaustive mapping into the canonical
67
+ * {@link import('@codexo/exojs-tilemap').TilePropertyValue}.
68
+ */
69
+ export type LdtkFieldInstance = {
70
+ readonly __identifier: string;
71
+ readonly __type: LdtkFieldScalarType;
72
+ readonly __value: string | number | boolean | null;
73
+ } | {
74
+ readonly __identifier: string;
75
+ readonly __type: 'Point';
76
+ readonly __value: LdtkFieldPointValue | null;
77
+ } | {
78
+ readonly __identifier: string;
79
+ readonly __type: 'EntityRef';
80
+ readonly __value: LdtkFieldEntityRefValue | null;
81
+ } | {
82
+ readonly __identifier: string;
83
+ readonly __type: 'Tile';
84
+ readonly __value: LdtkFieldTileValue | null;
85
+ } | {
86
+ readonly __identifier: string;
87
+ readonly __type: `Array<${string}>`;
88
+ readonly __value: readonly unknown[] | null;
89
+ };
37
90
  /** An entity instance placed in an Entities layer. */
38
91
  export interface LdtkEntityInstance {
39
92
  /** Entity definition identifier (class name). */
40
93
  readonly __identifier: string;
41
94
  /** Alias of `__identifier`, mirrors the entity definition type. */
42
95
  readonly __type: string;
43
- /** Pixel position `[x, y]` of the entity origin. */
96
+ /**
97
+ * Pixel position `[x, y]` of the entity's pivot-adjusted anchor — NOT the
98
+ * top-left corner. Combine with {@link __pivot} to recover the bounding
99
+ * box's top-left corner: `topLeftX = px[0] - width * __pivot[0]`.
100
+ */
44
101
  readonly px: readonly [number, number];
45
102
  readonly width: number;
46
103
  readonly height: number;
104
+ /**
105
+ * Normalised `[x, y]` anchor point within the entity's bounding box, each
106
+ * in `[0, 1]`. `[0, 0]` = top-left, `[0.5, 0.5]` = center, `[1, 1]` =
107
+ * bottom-right. Determines how {@link px} relates to the bounding box.
108
+ */
109
+ readonly __pivot: readonly [number, number];
47
110
  readonly fieldInstances: readonly LdtkFieldInstance[];
48
111
  /** Globally unique instance id (UUID string). */
49
112
  readonly iid: string;
@@ -120,6 +183,33 @@ export interface LdtkLevel {
120
183
  /** Relative path to an external `.ldtkl` file for multi-world setups. */
121
184
  readonly externalRelPath?: string;
122
185
  }
186
+ /**
187
+ * How a {@link LdtkWorldData}'s levels are spatially organised. `null` is a
188
+ * valid LDtk value (unset), same as the other nullable enum-ish fields in
189
+ * this file.
190
+ */
191
+ export type LdtkWorldLayout = 'Free' | 'GridVania' | 'LinearHorizontal' | 'LinearVertical' | null;
192
+ /**
193
+ * A single world in a multi-world LDtk project (`root.worlds[]`, populated
194
+ * when the project has "Multi-Worlds" enabled in its advanced settings).
195
+ * Each world owns its own {@link levels}; `defs` (tilesets/layers/entity
196
+ * definitions) is declared once at the document root and shared by every
197
+ * world rather than duplicated per-world — see {@link LdtkData.defs}.
198
+ */
199
+ export interface LdtkWorldData {
200
+ /** Human-readable world identifier (unique within the project). */
201
+ readonly identifier: string;
202
+ /** Globally unique instance id (UUID string). */
203
+ readonly iid: string;
204
+ /** Width of the world grid in pixels. */
205
+ readonly worldGridWidth: number;
206
+ /** Height of the world grid in pixels. */
207
+ readonly worldGridHeight: number;
208
+ /** How this world's levels are spatially organised. */
209
+ readonly worldLayout: LdtkWorldLayout;
210
+ /** Levels belonging to this world, in document order. */
211
+ readonly levels: readonly LdtkLevel[];
212
+ }
123
213
  /** Tileset definition from `defs.tilesets`. */
124
214
  export interface LdtkTilesetDef {
125
215
  readonly uid: number;
@@ -171,5 +261,22 @@ export interface LdtkData {
171
261
  readonly defaultGridSize?: number;
172
262
  readonly bgColor?: string;
173
263
  readonly defs: LdtkDefs;
264
+ /**
265
+ * Levels not organised into worlds. Always populated for pre-multi-world
266
+ * documents; kept EMPTY (per the LDtk spec's backward-compatibility rule)
267
+ * when {@link worlds} is used instead — read levels via `worlds[].levels`
268
+ * in that case, or use {@link import('./ldtkLevelEntries').getLdtkLevelEntries}
269
+ * (or simply {@link import('./LdtkMap').LdtkMap.levels} /
270
+ * {@link import('./LdtkMap').LdtkMap.getLevelByName}) to get "all levels,
271
+ * in order" regardless of which shape the document uses.
272
+ */
174
273
  readonly levels: readonly LdtkLevel[];
274
+ /**
275
+ * Worlds, present and non-empty only when the project has "Multi-Worlds"
276
+ * enabled in its advanced settings. Absent or empty for the (overwhelmingly
277
+ * common) single-world case, in which levels live directly in the root
278
+ * {@link levels} array instead. `defs` is NOT duplicated per-world — it
279
+ * stays declared once at the document root regardless of this field.
280
+ */
281
+ readonly worlds?: readonly LdtkWorldData[];
175
282
  }
@@ -7,7 +7,6 @@
7
7
  *
8
8
  * @see https://ldtk.io/json/
9
9
  */
10
- /* eslint-disable @typescript-eslint/naming-convention -- LDtk uses __ prefix for runtime fields */
11
10
  // ── Tile data ─────────────────────────────────────────────────────────────────
12
11
  /** Flip-bit constants for {@link LdtkTileData.f}. */
13
12
  const ldtkFlipNone = 0;
@@ -1 +1 @@
1
- {"version":3,"file":"LdtkData.js","sources":["../../../src/LdtkData.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;;;;AAQG;AAEH;AAEA;AAEA;AACO,MAAM,YAAY,GAAG;AACrB,MAAM,SAAS,GAAG;AAClB,MAAM,SAAS,GAAG;AAClB,MAAM,UAAU,GAAG;;;;"}
1
+ {"version":3,"file":"LdtkData.js","sources":["../../../src/LdtkData.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;;;;AAQG;AAMH;AAEA;AACO,MAAM,YAAY,GAAG;AACrB,MAAM,SAAS,GAAG;AAClB,MAAM,SAAS,GAAG;AAClB,MAAM,UAAU,GAAG;;;;"}
@@ -20,9 +20,12 @@ export declare class LdtkMap {
20
20
  /**
21
21
  * Runtime TileMaps — one per LDtk level, in document order.
22
22
  *
23
- * The index here corresponds to `data.levels[i]`. Levels for which
24
- * conversion was skipped (e.g. external `.ldtkl` files not yet loaded)
25
- * are `undefined` at that position.
23
+ * The index here corresponds to
24
+ * {@link import('./ldtkLevelEntries').getLdtkLevelEntries}`(data)[i]`, not
25
+ * `data.levels[i]` the latter is empty for multi-world documents, where
26
+ * levels live under `data.worlds[].levels` instead. `loadLdtkMap` fully
27
+ * resolves external `.ldtkl` levels before conversion, so every entry here
28
+ * is always a fully converted `TileMap`.
26
29
  */
27
30
  readonly levels: readonly TileMap[];
28
31
  constructor(source: string, data: LdtkData, levels: readonly TileMap[]);
@@ -30,6 +33,11 @@ export declare class LdtkMap {
30
33
  * Find a level's runtime {@link TileMap} by the LDtk level `identifier`,
31
34
  * or `undefined` when no level with that name exists.
32
35
  *
36
+ * Searches across {@link import('./ldtkLevelEntries').getLdtkLevelEntries}'s
37
+ * flattened level set rather than `data.levels` directly, so this works for
38
+ * both single-world and multi-world documents — `data.levels` alone is
39
+ * empty for the latter.
40
+ *
33
41
  * The lookup is O(n) in the number of levels.
34
42
  */
35
43
  getLevelByName(identifier: string): TileMap | undefined;
@@ -1,3 +1,5 @@
1
+ import { getLdtkLevelEntries } from './ldtkLevelEntries.js';
2
+
1
3
  /**
2
4
  * A parsed LDtk world document: holds the raw JSON data and the converted
3
5
  * runtime {@link TileMap} for each level.
@@ -18,9 +20,12 @@ class LdtkMap {
18
20
  /**
19
21
  * Runtime TileMaps — one per LDtk level, in document order.
20
22
  *
21
- * The index here corresponds to `data.levels[i]`. Levels for which
22
- * conversion was skipped (e.g. external `.ldtkl` files not yet loaded)
23
- * are `undefined` at that position.
23
+ * The index here corresponds to
24
+ * {@link import('./ldtkLevelEntries').getLdtkLevelEntries}`(data)[i]`, not
25
+ * `data.levels[i]` the latter is empty for multi-world documents, where
26
+ * levels live under `data.worlds[].levels` instead. `loadLdtkMap` fully
27
+ * resolves external `.ldtkl` levels before conversion, so every entry here
28
+ * is always a fully converted `TileMap`.
24
29
  */
25
30
  levels;
26
31
  constructor(source, data, levels) {
@@ -32,10 +37,15 @@ class LdtkMap {
32
37
  * Find a level's runtime {@link TileMap} by the LDtk level `identifier`,
33
38
  * or `undefined` when no level with that name exists.
34
39
  *
40
+ * Searches across {@link import('./ldtkLevelEntries').getLdtkLevelEntries}'s
41
+ * flattened level set rather than `data.levels` directly, so this works for
42
+ * both single-world and multi-world documents — `data.levels` alone is
43
+ * empty for the latter.
44
+ *
35
45
  * The lookup is O(n) in the number of levels.
36
46
  */
37
47
  getLevelByName(identifier) {
38
- const index = this.data.levels.findIndex(level => level.identifier === identifier);
48
+ const index = getLdtkLevelEntries(this.data).findIndex(entry => entry.level.identifier === identifier);
39
49
  if (index === -1)
40
50
  return undefined;
41
51
  return this.levels[index];
@@ -1 +1 @@
1
- {"version":3,"file":"LdtkMap.js","sources":["../../../src/LdtkMap.ts"],"sourcesContent":[null],"names":[],"mappings":"AAIA;;;;;;;;;;;AAWG;MACU,OAAO,CAAA;;AAEF,IAAA,MAAM;;AAEN,IAAA,IAAI;AACpB;;;;;;AAMG;AACa,IAAA,MAAM;AAEtB,IAAA,WAAA,CAAmB,MAAc,EAAE,IAAc,EAAE,MAA0B,EAAA;AAC3E,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM;AACpB,QAAA,IAAI,CAAC,IAAI,GAAG,IAAI;AAChB,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM;IACtB;AAEA;;;;;AAKG;AACI,IAAA,cAAc,CAAC,UAAkB,EAAA;QACtC,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,IAAI,KAAK,CAAC,UAAU,KAAK,UAAU,CAAC;QAClF,IAAI,KAAK,KAAK,EAAE;AAAE,YAAA,OAAO,SAAS;AAClC,QAAA,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;IAC3B;AAEA;;;;;AAKG;IACI,OAAO,GAAA;AACZ,QAAA,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE;YAC/B,KAAK,CAAC,OAAO,EAAE;QACjB;IACF;AACD;;;;"}
1
+ {"version":3,"file":"LdtkMap.js","sources":["../../../src/LdtkMap.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAKA;;;;;;;;;;;AAWG;MACU,OAAO,CAAA;;AAEF,IAAA,MAAM;;AAEN,IAAA,IAAI;AACpB;;;;;;;;;AASG;AACa,IAAA,MAAM;AAEtB,IAAA,WAAA,CAAmB,MAAc,EAAE,IAAc,EAAE,MAA0B,EAAA;AAC3E,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM;AACpB,QAAA,IAAI,CAAC,IAAI,GAAG,IAAI;AAChB,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM;IACtB;AAEA;;;;;;;;;;AAUG;AACI,IAAA,cAAc,CAAC,UAAkB,EAAA;QACtC,MAAM,KAAK,GAAG,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,SAAS,CACpD,KAAK,IAAI,KAAK,CAAC,KAAK,CAAC,UAAU,KAAK,UAAU,CAC/C;QACD,IAAI,KAAK,KAAK,EAAE;AAAE,YAAA,OAAO,SAAS;AAClC,QAAA,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;IAC3B;AAEA;;;;;AAKG;IACI,OAAO,GAAA;AACZ,QAAA,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE;YAC/B,KAAK,CAAC,OAAO,EAAE;QACjB;IACF;AACD;;;;"}
package/dist/esm/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  export { ldtkMapBinding } from './ldtkBinding.js';
2
2
  export { ldtkExtension } from './ldtkExtension.js';
3
3
  export { LdtkMap } from './LdtkMap.js';
4
- export { ldtkToTileMap } from './ldtkToTileMap.js';
4
+ export { getLdtkIntGridValueAt, ldtkIntGridCsvProperty, ldtkIntGridValuesProperty, ldtkToTileMap } from './ldtkToTileMap.js';
5
5
  export { ldtkFlipNone, ldtkFlipX, ldtkFlipXy, ldtkFlipY } from './LdtkData.js';
6
- export { ObjectKind, ObjectLayer, TILE_TRANSFORM_IDENTITY, TileLayer, TileMap, TileMapView, TileSet, tilemapExtension } from '@codexo/exojs-tilemap';
6
+ export { ObjectKind, ObjectLayer, TILE_TRANSFORM_IDENTITY, TileLayer, TileMap, TileMapView, TilePropertyKind, TileSet, tilemapExtension } from '@codexo/exojs-tilemap';
7
7
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,27 @@
1
+ import type { LdtkData, LdtkLevel } from './LdtkData';
2
+ /**
3
+ * One level from a (possibly multi-world) {@link LdtkData} document, paired
4
+ * with the {@link import('./LdtkData').LdtkWorldData.iid} of the world it
5
+ * belongs to. `worldIid` is `undefined` when the document uses the legacy
6
+ * single-world shape (`data.levels`, no `worlds[]`) — the overwhelmingly
7
+ * common case.
8
+ */
9
+ export interface LdtkLevelEntry {
10
+ readonly level: LdtkLevel;
11
+ readonly worldIid: string | undefined;
12
+ }
13
+ /**
14
+ * Flatten a {@link LdtkData} document's levels into one ordered list,
15
+ * abstracting over LDtk's two root shapes: single-world (levels live in the
16
+ * root {@link LdtkData.levels}) and multi-world (levels live in
17
+ * `data.worlds[].levels`, each tagged here with its owning world's `iid`;
18
+ * per the LDtk spec the root `levels` array is kept but EMPTY in this shape).
19
+ *
20
+ * This is the single place that decides which shape a document uses — every
21
+ * consumer that needs "all levels, in document order" ({@link import('./loadLdtkMap').loadLdtkMap}'s
22
+ * external `.ldtkl` resolution, {@link import('./ldtkToTileMap').ldtkToTileMap}'s
23
+ * conversion, and {@link import('./LdtkMap').LdtkMap.getLevelByName}'s lookup)
24
+ * goes through this function rather than re-deriving the single/multi-world
25
+ * detection independently.
26
+ */
27
+ export declare function getLdtkLevelEntries(data: LdtkData): readonly LdtkLevelEntry[];
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Flatten a {@link LdtkData} document's levels into one ordered list,
3
+ * abstracting over LDtk's two root shapes: single-world (levels live in the
4
+ * root {@link LdtkData.levels}) and multi-world (levels live in
5
+ * `data.worlds[].levels`, each tagged here with its owning world's `iid`;
6
+ * per the LDtk spec the root `levels` array is kept but EMPTY in this shape).
7
+ *
8
+ * This is the single place that decides which shape a document uses — every
9
+ * consumer that needs "all levels, in document order" ({@link import('./loadLdtkMap').loadLdtkMap}'s
10
+ * external `.ldtkl` resolution, {@link import('./ldtkToTileMap').ldtkToTileMap}'s
11
+ * conversion, and {@link import('./LdtkMap').LdtkMap.getLevelByName}'s lookup)
12
+ * goes through this function rather than re-deriving the single/multi-world
13
+ * detection independently.
14
+ */
15
+ function getLdtkLevelEntries(data) {
16
+ if (data.worlds && data.worlds.length > 0) {
17
+ const entries = [];
18
+ for (const world of data.worlds) {
19
+ for (const level of world.levels) {
20
+ entries.push({ level, worldIid: world.iid });
21
+ }
22
+ }
23
+ return entries;
24
+ }
25
+ return data.levels.map(level => ({ level, worldIid: undefined }));
26
+ }
27
+
28
+ export { getLdtkLevelEntries };
29
+ //# sourceMappingURL=ldtkLevelEntries.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ldtkLevelEntries.js","sources":["../../../src/ldtkLevelEntries.ts"],"sourcesContent":[null],"names":[],"mappings":"AAcA;;;;;;;;;;;;;AAaG;AACG,SAAU,mBAAmB,CAAC,IAAc,EAAA;AAChD,IAAA,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;QACzC,MAAM,OAAO,GAAqB,EAAE;AACpC,QAAA,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE;AAC/B,YAAA,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,MAAM,EAAE;AAChC,gBAAA,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC;YAC9C;QACF;AACA,QAAA,OAAO,OAAO;IAChB;IAEA,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAC;AACnE;;;;"}
@@ -1,6 +1,6 @@
1
1
  import type { TileSet } from '@codexo/exojs-tilemap';
2
- import { TILE_TRANSFORM_IDENTITY } from '@codexo/exojs-tilemap';
3
- import type { LdtkData } from './LdtkData';
2
+ import { TILE_TRANSFORM_IDENTITY, TileLayer } from '@codexo/exojs-tilemap';
3
+ import type { LdtkData, LdtkIntGridValueDef } from './LdtkData';
4
4
  import { LdtkMap } from './LdtkMap';
5
5
  /**
6
6
  * Options for {@link ldtkToTileMap}.
@@ -35,6 +35,40 @@ export interface LdtkToTileMapOptions {
35
35
  *
36
36
  * Pass `options.tilesets` to populate tile data; omit it for structure-only
37
37
  * conversion (useful in unit tests that do not need textures).
38
+ *
39
+ * Transparently handles both LDtk root shapes via {@link getLdtkLevelEntries}:
40
+ * single-world (`data.levels`) and multi-world (`data.worlds[].levels`) — in
41
+ * the latter case every converted level's `TileMap.properties` is additionally
42
+ * tagged with its owning world's iid under the reserved `ldtkWorldIid` key.
38
43
  */
39
44
  export declare function ldtkToTileMap(data: LdtkData, options?: LdtkToTileMapOptions): LdtkMap;
45
+ /**
46
+ * Reserved {@link TileLayer.properties} key holding the JSON-encoded raw
47
+ * IntGrid CSV array (`readonly number[]`) for a `TileLayer` converted from an
48
+ * LDtk `IntGrid` layer instance. Index = `y * layer.width + x`; `0` = empty.
49
+ * Prefer {@link getLdtkIntGridValueAt} over reading this directly.
50
+ */
51
+ export declare const ldtkIntGridCsvProperty = "ldtkIntGridCsv";
52
+ /**
53
+ * Reserved {@link TileLayer.properties} key holding the JSON-encoded
54
+ * {@link LdtkIntGridValueDef} array for a `TileLayer` converted from an LDtk
55
+ * `IntGrid` layer instance — the raw-int → named/coloured mapping declared on
56
+ * the owning layer definition (`data.defs.layers[].intGridValues`).
57
+ * Prefer {@link getLdtkIntGridValueAt} over reading this directly.
58
+ */
59
+ export declare const ldtkIntGridValuesProperty = "ldtkIntGridValues";
60
+ /**
61
+ * Look up the named/coloured {@link LdtkIntGridValueDef} at a tile coordinate
62
+ * on a `TileLayer` converted from an LDtk `IntGrid` layer instance.
63
+ *
64
+ * Returns `undefined` when the coordinate is out of bounds, the cell's raw
65
+ * value is `0` (empty), the raw value has no matching definition, or `layer`
66
+ * was not converted from an IntGrid layer instance (no IntGrid data attached
67
+ * via {@link ldtkIntGridCsvProperty} / {@link ldtkIntGridValuesProperty}).
68
+ *
69
+ * The underlying JSON-encoded CSV/value-defs properties are parsed once per
70
+ * layer and cached (see {@link getParsedIntGridData}) — safe to call from a
71
+ * hot path (e.g. per-cell or per-frame collision/classification checks).
72
+ */
73
+ export declare function getLdtkIntGridValueAt(layer: TileLayer, x: number, y: number): LdtkIntGridValueDef | undefined;
40
74
  export { TILE_TRANSFORM_IDENTITY };
@@ -1,6 +1,7 @@
1
- import { ObjectLayer, TileMap, TileLayer } from '@codexo/exojs-tilemap';
1
+ import { ObjectLayer, TileMap, TileLayer, TilePropertyKind } from '@codexo/exojs-tilemap';
2
2
  export { TILE_TRANSFORM_IDENTITY } from '@codexo/exojs-tilemap';
3
3
  import { ldtkFlipY, ldtkFlipX } from './LdtkData.js';
4
+ import { getLdtkLevelEntries } from './ldtkLevelEntries.js';
4
5
  import { LdtkMap } from './LdtkMap.js';
5
6
 
6
7
  /**
@@ -14,16 +15,21 @@ import { LdtkMap } from './LdtkMap.js';
14
15
  *
15
16
  * Pass `options.tilesets` to populate tile data; omit it for structure-only
16
17
  * conversion (useful in unit tests that do not need textures).
18
+ *
19
+ * Transparently handles both LDtk root shapes via {@link getLdtkLevelEntries}:
20
+ * single-world (`data.levels`) and multi-world (`data.worlds[].levels`) — in
21
+ * the latter case every converted level's `TileMap.properties` is additionally
22
+ * tagged with its owning world's iid under the reserved `ldtkWorldIid` key.
17
23
  */
18
24
  function ldtkToTileMap(data, options) {
19
25
  const source = options?.source ?? '';
20
26
  const tilesets = options?.tilesets ?? new Map();
21
- const levels = data.levels.map((level, levelIndex) => convertLevel(level, levelIndex, data, tilesets));
27
+ const levels = getLdtkLevelEntries(data).map((entry, levelIndex) => convertLevel(entry.level, entry.worldIid, levelIndex, data, tilesets));
22
28
  return new LdtkMap(source, data, levels);
23
29
  }
24
30
  // ── Level conversion ──────────────────────────────────────────────────────────
25
31
  // eslint-disable-next-line complexity
26
- function convertLevel(level, levelIndex, data, tilesets) {
32
+ function convertLevel(level, worldIid, levelIndex, data, tilesets) {
27
33
  // Derive map-level tile size from the first non-entity layer, or fall back.
28
34
  const gridSize = pickLevelGridSize(level, data.defaultGridSize ?? 16);
29
35
  const mapWidth = Math.max(1, Math.ceil(level.pxWid / gridSize));
@@ -56,9 +62,11 @@ function convertLevel(level, levelIndex, data, tilesets) {
56
62
  break;
57
63
  }
58
64
  case 'IntGrid': {
59
- const rLayer = makeTileLayer(layerInst, layerId, runtimeTilesets);
65
+ const intGridProperties = buildIntGridProperties(layerInst, data);
66
+ const rLayer = makeTileLayer(layerInst, layerId, runtimeTilesets, intGridProperties);
60
67
  // IntGrid layers may carry auto-tiles when "Auto-layer" rules are
61
- // configured. Use those for rendering; raw intGridCsv is data-only.
68
+ // configured. Use those for rendering; raw intGridCsv is exposed as
69
+ // data-only layer properties (see buildIntGridProperties).
62
70
  const autoTiles = layerInst.autoLayerTiles ?? [];
63
71
  const tsUid = layerInst.__tilesetDefUid;
64
72
  if (autoTiles.length > 0 && tsUid !== undefined) {
@@ -94,16 +102,23 @@ function convertLevel(level, levelIndex, data, tilesets) {
94
102
  tilesets: runtimeTilesets,
95
103
  layers: runtimeLayers,
96
104
  objectLayers: runtimeObjectLayers,
105
+ // Convert user-defined level fields first, then apply the reserved keys
106
+ // last so a same-named user field can never clobber them. ldtkWorldIid is
107
+ // only added for multi-world documents (worldIid !== undefined) — a
108
+ // single-world document's properties must stay exactly as they were
109
+ // before multi-world support existed.
97
110
  properties: {
111
+ ...convertFieldInstances(level.fieldInstances ?? []),
98
112
  ldtkUid: level.uid,
99
113
  ldtkIid: level.iid,
100
114
  worldX: level.worldX,
101
115
  worldY: level.worldY,
116
+ ...(worldIid !== undefined && { ldtkWorldIid: worldIid }),
102
117
  },
103
118
  });
104
119
  }
105
120
  // ── Helpers: TileLayer ────────────────────────────────────────────────────────
106
- function makeTileLayer(layerInst, layerId, tilesets) {
121
+ function makeTileLayer(layerInst, layerId, tilesets, properties) {
107
122
  return new TileLayer({
108
123
  id: layerId,
109
124
  name: layerInst.__identifier,
@@ -116,6 +131,7 @@ function makeTileLayer(layerInst, layerId, tilesets) {
116
131
  opacity: layerInst.opacity ?? 1,
117
132
  offsetX: layerInst.pxOffsetX ?? 0,
118
133
  offsetY: layerInst.pxOffsetY ?? 0,
134
+ ...(properties && { properties }),
119
135
  });
120
136
  }
121
137
  function populateTileLayer(layer, tiles, tileset, gridSize) {
@@ -139,6 +155,99 @@ function populateTileLayer(layer, tiles, tileset, gridSize) {
139
155
  });
140
156
  }
141
157
  }
158
+ // ── Helpers: IntGrid ──────────────────────────────────────────────────────────
159
+ /**
160
+ * Reserved {@link TileLayer.properties} key holding the JSON-encoded raw
161
+ * IntGrid CSV array (`readonly number[]`) for a `TileLayer` converted from an
162
+ * LDtk `IntGrid` layer instance. Index = `y * layer.width + x`; `0` = empty.
163
+ * Prefer {@link getLdtkIntGridValueAt} over reading this directly.
164
+ */
165
+ const ldtkIntGridCsvProperty = 'ldtkIntGridCsv';
166
+ /**
167
+ * Reserved {@link TileLayer.properties} key holding the JSON-encoded
168
+ * {@link LdtkIntGridValueDef} array for a `TileLayer` converted from an LDtk
169
+ * `IntGrid` layer instance — the raw-int → named/coloured mapping declared on
170
+ * the owning layer definition (`data.defs.layers[].intGridValues`).
171
+ * Prefer {@link getLdtkIntGridValueAt} over reading this directly.
172
+ */
173
+ const ldtkIntGridValuesProperty = 'ldtkIntGridValues';
174
+ /**
175
+ * Build the reserved IntGrid properties for a `TileLayer` from an LDtk
176
+ * `IntGrid` layer instance, or `undefined` when the layer carries no
177
+ * `intGridCsv` data (nothing to expose).
178
+ *
179
+ * {@link TileLayer.properties} values are scalar-only, so the raw CSV array
180
+ * and the value-definition mapping are JSON-encoded into two reserved string
181
+ * properties rather than stored as nested structures — the same
182
+ * `properties`-bag mechanism the Tiled adapter already uses for per-layer
183
+ * metadata, just serialized to fit its scalar-only value type.
184
+ */
185
+ function buildIntGridProperties(layerInst, data) {
186
+ const csv = layerInst.intGridCsv;
187
+ if (!csv || csv.length === 0)
188
+ return undefined;
189
+ const layerDef = data.defs.layers.find(def => def.uid === layerInst.layerDefUid);
190
+ const values = layerDef?.intGridValues ?? [];
191
+ return Object.freeze({
192
+ [ldtkIntGridCsvProperty]: JSON.stringify(csv),
193
+ [ldtkIntGridValuesProperty]: JSON.stringify(values),
194
+ });
195
+ }
196
+ /**
197
+ * Per-`TileLayer` cache of parsed IntGrid CSV/value-defs data, populated
198
+ * lazily on first {@link getLdtkIntGridValueAt} lookup for a given layer.
199
+ *
200
+ * Keyed by the `TileLayer` instance itself (`WeakMap`), so an entry is
201
+ * naturally garbage-collected once the layer it was derived from is no
202
+ * longer referenced — no manual invalidation needed since
203
+ * {@link TileLayer.properties} is frozen and copied at construction time and
204
+ * can never change afterwards.
205
+ */
206
+ const intGridCache = new WeakMap();
207
+ /**
208
+ * Parse (or retrieve from {@link intGridCache}) the IntGrid CSV/value-defs
209
+ * data attached to `layer`, or `undefined` when `layer` carries no such data
210
+ * (not converted from an IntGrid layer instance).
211
+ */
212
+ function getParsedIntGridData(layer) {
213
+ const cached = intGridCache.get(layer);
214
+ if (cached)
215
+ return cached;
216
+ const csvRaw = layer.properties[ldtkIntGridCsvProperty];
217
+ const valuesRaw = layer.properties[ldtkIntGridValuesProperty];
218
+ if (typeof csvRaw !== 'string' || typeof valuesRaw !== 'string')
219
+ return undefined;
220
+ const parsed = {
221
+ csv: JSON.parse(csvRaw),
222
+ values: JSON.parse(valuesRaw),
223
+ };
224
+ intGridCache.set(layer, parsed);
225
+ return parsed;
226
+ }
227
+ /**
228
+ * Look up the named/coloured {@link LdtkIntGridValueDef} at a tile coordinate
229
+ * on a `TileLayer` converted from an LDtk `IntGrid` layer instance.
230
+ *
231
+ * Returns `undefined` when the coordinate is out of bounds, the cell's raw
232
+ * value is `0` (empty), the raw value has no matching definition, or `layer`
233
+ * was not converted from an IntGrid layer instance (no IntGrid data attached
234
+ * via {@link ldtkIntGridCsvProperty} / {@link ldtkIntGridValuesProperty}).
235
+ *
236
+ * The underlying JSON-encoded CSV/value-defs properties are parsed once per
237
+ * layer and cached (see {@link getParsedIntGridData}) — safe to call from a
238
+ * hot path (e.g. per-cell or per-frame collision/classification checks).
239
+ */
240
+ function getLdtkIntGridValueAt(layer, x, y) {
241
+ if (!layer.inBounds(x, y))
242
+ return undefined;
243
+ const parsed = getParsedIntGridData(layer);
244
+ if (!parsed)
245
+ return undefined;
246
+ const raw = parsed.csv[y * layer.width + x];
247
+ if (raw === undefined || raw === 0)
248
+ return undefined;
249
+ return parsed.values.find(v => v.value === raw);
250
+ }
142
251
  // ── Helpers: ObjectLayer ──────────────────────────────────────────────────────
143
252
  function convertEntityLayer(layerInst, _gridSize, levelIndex, baseCounter) {
144
253
  const instances = layerInst.entityInstances ?? [];
@@ -154,13 +263,17 @@ function convertEntityLayer(layerInst, _gridSize, levelIndex, baseCounter) {
154
263
  return objects;
155
264
  }
156
265
  function convertEntity(entity, id) {
266
+ // entity.px is the pivot-adjusted anchor, not the bounding box's top-left
267
+ // corner — undo the pivot offset to recover the corner TileMapObject expects.
268
+ const x = entity.px[0] - entity.width * entity.__pivot[0];
269
+ const y = entity.px[1] - entity.height * entity.__pivot[1];
157
270
  return {
158
271
  kind: 'rectangle',
159
272
  id,
160
273
  name: entity.__identifier,
161
274
  type: entity.__identifier,
162
- x: entity.px[0],
163
- y: entity.px[1],
275
+ x,
276
+ y,
164
277
  width: entity.width,
165
278
  height: entity.height,
166
279
  rotation: 0,
@@ -170,21 +283,108 @@ function convertEntity(entity, id) {
170
283
  }
171
284
  /**
172
285
  * Project LDtk field instances to a flat {@link TileProperties} bag.
173
- * Only scalar values (string, number, boolean) are forwarded; complex types
174
- * (arrays, colours, enums-as-objects) are silently skipped.
286
+ * Every LDtk field type maps to a canonical {@link TilePropertyValue}
287
+ * (scalars pass through; `Point`/`EntityRef`/`Tile` become their tagged
288
+ * structured variants; `Array<T>` fields recursively convert each element).
289
+ * A field whose raw `__value` is `null` (LDtk's "not set" convention) is
290
+ * omitted from the bag entirely, matching the property-absent case rather
291
+ * than a present-but-null value.
175
292
  */
176
293
  function convertFieldInstances(fields) {
177
294
  if (fields.length === 0)
178
295
  return Object.freeze({});
179
296
  const out = {};
180
297
  for (const field of fields) {
181
- const v = field.__value;
182
- if (typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean') {
183
- out[field.__identifier] = v;
298
+ const value = convertField(field);
299
+ if (value !== undefined) {
300
+ out[field.__identifier] = value;
184
301
  }
185
302
  }
186
303
  return Object.freeze(out);
187
304
  }
305
+ /**
306
+ * Type guard narrowing to the `Array<T>` member of {@link LdtkFieldInstance}.
307
+ * `String.prototype.startsWith` alone does not narrow a template-literal
308
+ * union member for the compiler; a predicate on `field` itself does.
309
+ */
310
+ function isLdtkArrayField(field) {
311
+ return field.__type.startsWith('Array<');
312
+ }
313
+ /** Convert one {@link LdtkFieldInstance} to its canonical {@link TilePropertyValue}, or `undefined` for a `null` (unset) field. */
314
+ function convertField(field) {
315
+ switch (field.__type) {
316
+ case 'Int':
317
+ case 'Float':
318
+ case 'Bool':
319
+ case 'String':
320
+ case 'Multilines':
321
+ case 'Color':
322
+ case 'FilePath':
323
+ case 'Enum':
324
+ case 'Point':
325
+ case 'EntityRef':
326
+ case 'Tile':
327
+ return mapLdtkFieldValue(field.__type, field.__value);
328
+ }
329
+ if (isLdtkArrayField(field)) {
330
+ if (field.__value === null)
331
+ return undefined;
332
+ const elementType = field.__type.slice('Array<'.length, -1);
333
+ const elements = [];
334
+ for (const raw of field.__value) {
335
+ const converted = mapLdtkFieldValue(elementType, raw);
336
+ if (converted !== undefined)
337
+ elements.push(converted);
338
+ }
339
+ return Object.freeze(elements);
340
+ }
341
+ throw new Error(`convertFieldInstances: unrecognised LDtk field type "${field.__type}".`);
342
+ }
343
+ /**
344
+ * Map a single raw LDtk field value (or array element) to its canonical
345
+ * {@link TilePropertyValue}, given the LDtk type name it was declared with.
346
+ * Shared by {@link convertField} (top-level fields) and array-element
347
+ * conversion (`typeName` is the `T` extracted from an `Array<T>` field).
348
+ * Returns `undefined` for a `null` value or an unrecognised `typeName`.
349
+ */
350
+ function mapLdtkFieldValue(typeName, value) {
351
+ if (value === null || value === undefined)
352
+ return undefined;
353
+ switch (typeName) {
354
+ case 'Int':
355
+ case 'Float':
356
+ case 'Bool':
357
+ case 'String':
358
+ case 'Multilines':
359
+ case 'Color':
360
+ case 'FilePath':
361
+ case 'Enum':
362
+ return value;
363
+ case 'Point': {
364
+ const v = value;
365
+ return { kind: TilePropertyKind.Point, cx: v.cx, cy: v.cy };
366
+ }
367
+ case 'EntityRef': {
368
+ const v = value;
369
+ return {
370
+ kind: TilePropertyKind.ObjectRef,
371
+ id: v.entityIid,
372
+ layerIid: v.layerIid,
373
+ levelIid: v.levelIid,
374
+ worldIid: v.worldIid,
375
+ };
376
+ }
377
+ case 'Tile': {
378
+ const v = value;
379
+ return { kind: TilePropertyKind.TileRef, tilesetUid: v.tilesetUid, x: v.x, y: v.y, w: v.w, h: v.h };
380
+ }
381
+ default:
382
+ // Unknown/unsupported array element type (e.g. a future LDtk type
383
+ // inside Array<T>) — skip rather than throw, since this path is not
384
+ // compiler-exhaustive (element types are plain runtime strings).
385
+ return undefined;
386
+ }
387
+ }
188
388
  // ── Helpers: grid size ────────────────────────────────────────────────────────
189
389
  function pickLevelGridSize(level, fallback) {
190
390
  const instances = level.layerInstances ?? [];
@@ -196,5 +396,5 @@ function pickLevelGridSize(level, fallback) {
196
396
  return fallback;
197
397
  }
198
398
 
199
- export { ldtkToTileMap };
399
+ export { getLdtkIntGridValueAt, ldtkIntGridCsvProperty, ldtkIntGridValuesProperty, ldtkToTileMap };
200
400
  //# sourceMappingURL=ldtkToTileMap.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ldtkToTileMap.js","sources":["../../../src/ldtkToTileMap.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAuCA;;;;;;;;;;;AAWG;AACG,SAAU,aAAa,CAAC,IAAc,EAAE,OAA8B,EAAA;AAC1E,IAAA,MAAM,MAAM,GAAG,OAAO,EAAE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exojs';
2
2
  import type { LdtkMap } from './LdtkMap';
3
3
  /**
4
- * Fetch a `.ldtk` file, load all referenced tileset images, and return a
5
- * fully assembled {@link LdtkMap} with one runtime {@link import('@codexo/exojs-tilemap').TileMap}
6
- * per level.
4
+ * Fetch a `.ldtk` file, load all referenced tileset images, resolve any
5
+ * externalized (`.ldtkl`) levels, and return a fully assembled {@link LdtkMap}
6
+ * with one runtime {@link import('@codexo/exojs-tilemap').TileMap} per level.
7
7
  *
8
8
  * Tilesets without an atlas image (`relPath = null`) are silently skipped;
9
9
  * their tiles will not appear in the rendered output.
@@ -1,5 +1,6 @@
1
1
  import { Texture, TextureRegion } from '@codexo/exojs';
2
2
  import { TileSet } from '@codexo/exojs-tilemap';
3
+ import { getLdtkLevelEntries } from './ldtkLevelEntries.js';
3
4
  import { ldtkToTileMap } from './ldtkToTileMap.js';
4
5
 
5
6
  // ── URL resolution ────────────────────────────────────────────────────────────
@@ -49,11 +50,62 @@ async function loadLdtkTileset(def, ldtkSource, context) {
49
50
  margin,
50
51
  });
51
52
  }
53
+ // ── External level loading ───────────────────────────────────────────────────
54
+ /**
55
+ * Resolve a level's external `.ldtkl` payload and merge its layer/field data
56
+ * into the level record.
57
+ *
58
+ * LDtk's "Save levels to separate files" project option nulls out
59
+ * `layerInstances` on the root document; the real layer data lives in a
60
+ * sibling `<levelIdentifier>.ldtkl` file referenced by {@link LdtkLevel.externalRelPath}.
61
+ * That file also carries its own `fieldInstances`, which is authoritative —
62
+ * the root document's copy is typically stripped or stale for externalized
63
+ * levels. Levels that already carry `layerInstances` (not externalized) are
64
+ * returned unchanged.
65
+ */
66
+ async function loadExternalLevel(level, ldtkSource, context) {
67
+ if (level.layerInstances !== null || !level.externalRelPath)
68
+ return level;
69
+ const externalUrl = resolveLdtkUrl(level.externalRelPath, ldtkSource);
70
+ // Cast without deep validation, matching the root document's fetch below —
71
+ // structural errors surface as runtime exceptions during conversion.
72
+ const external = (await context.fetchJson(externalUrl));
73
+ const fieldInstances = external.fieldInstances ?? level.fieldInstances;
74
+ return {
75
+ ...level,
76
+ layerInstances: external.layerInstances,
77
+ ...(fieldInstances !== undefined && { fieldInstances }),
78
+ };
79
+ }
80
+ /**
81
+ * Rebuild an {@link LdtkData} document with its levels replaced by
82
+ * `resolvedLevels` (external `.ldtkl` payloads merged in via
83
+ * {@link loadExternalLevel}), preserving whichever root shape the source
84
+ * document used — single-world (`levels`) or multi-world (`worlds[].levels`).
85
+ *
86
+ * `resolvedLevels` must be in the same flattened order
87
+ * {@link getLdtkLevelEntries} produced for `data` — each world's slice is
88
+ * recovered by walking `data.worlds` in that same order, so a second pass
89
+ * through {@link getLdtkLevelEntries} (performed inside {@link ldtkToTileMap})
90
+ * reproduces an identical flattened list, now with external levels resolved.
91
+ */
92
+ function withResolvedLevels(data, resolvedLevels) {
93
+ if (data.worlds && data.worlds.length > 0) {
94
+ let cursor = 0;
95
+ const worlds = data.worlds.map((world) => {
96
+ const levels = resolvedLevels.slice(cursor, cursor + world.levels.length);
97
+ cursor += world.levels.length;
98
+ return { ...world, levels };
99
+ });
100
+ return { ...data, worlds };
101
+ }
102
+ return { ...data, levels: resolvedLevels };
103
+ }
52
104
  // ── Public loader ─────────────────────────────────────────────────────────────
53
105
  /**
54
- * Fetch a `.ldtk` file, load all referenced tileset images, and return a
55
- * fully assembled {@link LdtkMap} with one runtime {@link import('@codexo/exojs-tilemap').TileMap}
56
- * per level.
106
+ * Fetch a `.ldtk` file, load all referenced tileset images, resolve any
107
+ * externalized (`.ldtkl`) levels, and return a fully assembled {@link LdtkMap}
108
+ * with one runtime {@link import('@codexo/exojs-tilemap').TileMap} per level.
57
109
  *
58
110
  * Tilesets without an atlas image (`relPath = null`) are silently skipped;
59
111
  * their tiles will not appear in the rendered output.
@@ -64,17 +116,23 @@ async function loadLdtkMap(source, context) {
64
116
  // Cast without deep validation — structural errors surface as runtime
65
117
  // exceptions when we access fields during conversion.
66
118
  const data = raw;
67
- // Load all referenced tilesets concurrently.
68
- const tilesetEntries = await Promise.all(data.defs.tilesets.map(async (def) => {
69
- const ts = await loadLdtkTileset(def, source, context);
70
- return [def.uid, ts];
71
- }));
119
+ // Load all referenced tilesets and resolve externalized levels concurrently.
120
+ // Iterate the flattened level list (not raw data.levels) so multi-world
121
+ // documents whose levels live under worlds[].levels, with an empty root
122
+ // levels[] — still get their external .ldtkl files resolved.
123
+ const [tilesetEntries, resolvedLevels] = await Promise.all([
124
+ Promise.all(data.defs.tilesets.map(async (def) => {
125
+ const ts = await loadLdtkTileset(def, source, context);
126
+ return [def.uid, ts];
127
+ })),
128
+ Promise.all(getLdtkLevelEntries(data).map((entry) => loadExternalLevel(entry.level, source, context))),
129
+ ]);
72
130
  const tilesets = new Map();
73
131
  for (const [uid, ts] of tilesetEntries) {
74
132
  if (ts !== null)
75
133
  tilesets.set(uid, ts);
76
134
  }
77
- return ldtkToTileMap(data, { source, tilesets });
135
+ return ldtkToTileMap(withResolvedLevels(data, resolvedLevels), { source, tilesets });
78
136
  }
79
137
 
80
138
  export { loadLdtkMap };
@@ -1 +1 @@
1
- {"version":3,"file":"loadLdtkMap.js","sources":["../../../src/loadLdtkMap.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAOA;AAEA;;;AAGG;AACH,SAAS,cAAc,CAAC,OAAe,EAAE,OAAe,EAAA;IACtD,OAAO,IAAI,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,IAAI;AACvC;AAEA;AAEA;;;;AAIG;AACH,eAAe,eAAe,CAC5B,GAAmB,EACnB,UAAkB,EAClB,OAA2B,EAAA;IAE3B,IAAI,CAAC,GAAG,CAAC,OAAO;AAAE,QAAA,OAAO,IAAI;IAE7B,MAAM,QAAQ,GAAG,cAAc,CAAC,GAAG,CAAC,OAAO,EAAE,UAAU,CAAC;AACxD,IAAA,MAAM,OAAO,IAAI,MAAM,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAY;AAEzE,IAAA,MAAM,QAAQ,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AAc,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;AACzD,QAAA,OAAO,CAAC,GAAG,CACT,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,GAAG,KAAI;YACnC,MAAM,EAAE,GAAG,MAAM,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC;AACtD,YAAA,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAU;AAC/B,QAAA,CAAC,CAAC,CACH;QACD,OAAO,CAAC,GAAG,CACT,mBAAmB,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,KAAK,iBAAiB,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAC1F;AACF,KAAA,CAAC;AAEF,IAAA,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAmB;IAC3C,KAAK,MAAM,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,cAAc,EAAE;QACtC,IAAI,EAAE,KAAK,IAAI;AAAE,YAAA,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC;IACxC;AAEA,IAAA,OAAO,aAAa,CAAC,kBAAkB,CAAC,IAAI,EAAE,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AACtF;;;;"}
@@ -2,11 +2,11 @@ export { ldtkMapBinding } from './ldtkBinding';
2
2
  export { ldtkExtension } from './ldtkExtension';
3
3
  export { LdtkMap } from './LdtkMap';
4
4
  export type { LdtkToTileMapOptions } from './ldtkToTileMap';
5
- export { ldtkToTileMap } from './ldtkToTileMap';
6
- export type { LdtkData, LdtkDefs, LdtkEntityInstance, LdtkFieldInstance, LdtkIntGridValueDef, LdtkLayerDef, LdtkLayerInstance, LdtkLayerType, LdtkLevel, LdtkTileData, LdtkTilesetDef, } from './LdtkData';
5
+ export { getLdtkIntGridValueAt, ldtkIntGridCsvProperty, ldtkIntGridValuesProperty, ldtkToTileMap, } from './ldtkToTileMap';
6
+ export type { LdtkData, LdtkDefs, LdtkEntityInstance, LdtkFieldInstance, LdtkIntGridValueDef, LdtkLayerDef, LdtkLayerInstance, LdtkLayerType, LdtkLevel, LdtkTileData, LdtkTilesetDef, LdtkWorldData, LdtkWorldLayout, } from './LdtkData';
7
7
  export { ldtkFlipNone, ldtkFlipX, ldtkFlipXy, ldtkFlipY } from './LdtkData';
8
- export type { ChunkCoord, EllipseObject, ObjectLayerOptions, ObjectPoint, ObjectQuery, ObjectSchema, PackedTile, PointObject, PolygonObject, PolylineObject, ReadonlyTileChunk, RectangleObject, ResolvedTile, TileDefinition, TileLayerOptions, TileMapObject, TileMapObjectKind, TileMapOptions, TileMapViewOptions, TileObject, TileProperties, TilePropertyValue, TileSetOptions, TileTransform, } from '@codexo/exojs-tilemap';
9
- export { ObjectKind, ObjectLayer, TILE_TRANSFORM_IDENTITY, TileLayer, TileMap, tilemapExtension, TileMapView, TileSet, } from '@codexo/exojs-tilemap';
8
+ export type { ChunkCoord, EllipseObject, ObjectLayerOptions, ObjectPoint, ObjectQuery, ObjectSchema, PackedTile, PointObject, PolygonObject, PolylineObject, ReadonlyTileChunk, RectangleObject, ResolvedTile, TileDefinition, TileLayerOptions, TileMapObject, TileMapObjectKind, TileMapOptions, TileMapViewOptions, TileObject, TileProperties, TilePropertyObjectRef, TilePropertyPoint, TilePropertyTileRef, TilePropertyValue, TileSetOptions, TileTransform, } from '@codexo/exojs-tilemap';
9
+ export { ObjectKind, ObjectLayer, TILE_TRANSFORM_IDENTITY, TileLayer, TileMap, tilemapExtension, TileMapView, TilePropertyKind, TileSet, } from '@codexo/exojs-tilemap';
10
10
  import type { LdtkMap } from './LdtkMap';
11
11
  declare module '@codexo/exojs' {
12
12
  interface ExtensionTypeMap {
@@ -2,9 +2,9 @@ import { ExtensionRegistry } from '@codexo/exojs/extensions';
2
2
  import { ldtkExtension } from './ldtkExtension.js';
3
3
  export { ldtkMapBinding } from './ldtkBinding.js';
4
4
  export { LdtkMap } from './LdtkMap.js';
5
- export { ldtkToTileMap } from './ldtkToTileMap.js';
5
+ export { getLdtkIntGridValueAt, ldtkIntGridCsvProperty, ldtkIntGridValuesProperty, ldtkToTileMap } from './ldtkToTileMap.js';
6
6
  export { ldtkFlipNone, ldtkFlipX, ldtkFlipXy, ldtkFlipY } from './LdtkData.js';
7
- export { ObjectKind, ObjectLayer, TILE_TRANSFORM_IDENTITY, TileLayer, TileMap, TileMapView, TileSet, tilemapExtension } from '@codexo/exojs-tilemap';
7
+ export { ObjectKind, ObjectLayer, TILE_TRANSFORM_IDENTITY, TileLayer, TileMap, TileMapView, TilePropertyKind, TileSet, tilemapExtension } from '@codexo/exojs-tilemap';
8
8
 
9
9
  // @codexo/exojs-ldtk/register — explicit registration entry.
10
10
  // Importing this entry registers the default ldtkExtension descriptor
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codexo/exojs-ldtk",
3
- "version": "0.14.0",
3
+ "version": "0.15.1",
4
4
  "description": "LDtk level format asset extension for ExoJS.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -33,13 +33,13 @@
33
33
  "LICENSE"
34
34
  ],
35
35
  "peerDependencies": {
36
- "@codexo/exojs": "0.14.x"
36
+ "@codexo/exojs": "0.15.x"
37
37
  },
38
38
  "dependencies": {
39
- "@codexo/exojs-tilemap": "0.14.0"
39
+ "@codexo/exojs-tilemap": "0.15.1"
40
40
  },
41
41
  "devDependencies": {
42
- "@codexo/exojs": "0.14.0",
42
+ "@codexo/exojs": "0.15.1",
43
43
  "@codexo/exojs-config": "0.0.0"
44
44
  },
45
45
  "license": "MIT",