@codexo/exojs-ldtk 0.16.2 → 0.18.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,7 +1,6 @@
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
+ Official ExoJS extension for loading [LDtk](https://ldtk.io) level files (`.ldtk`) into runtime `TileMap`s — one per LDtk level — ready to render with the generic tilemap node.
5
4
 
6
5
  ## Installation
7
6
 
@@ -9,44 +8,28 @@ Official ExoJS extension for loading [LDtk](https://ldtk.io) level files (`.ldtk
9
8
  npm install @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.
11
+ Both `@codexo/exojs` and `@codexo/exojs-tilemap` are **peer** dependencies, so install them explicitly alongside the adapter. Nothing is pulled in transitively: strict package managers (pnpm, Yarn PnP) will not resolve an unlisted peer, and npm's auto-install of peers still leaves the versions outside your control. Keep the engine and every adapter on the same version.
16
12
 
17
13
  ## What this package provides
18
14
 
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`
15
+ - `LdtkMap` — parsed LDtk world; the result of `loader.load('world.ldtk')`. Exposes the raw `data`, the converted runtime `levels` (`readonly TileMap[]`, in document order), and `getLevelByName(identifier)`
16
+ - `LdtkProject` — the streaming counterpart of `LdtkMap`: the result of `loader.load(Asset.type('ldtkProject', 'world.ldtk'))`. Loads the document and every tileset atlas, and **no** level payload. Exposes the world layout (`worlds` / `world`, one `MapWorld` per LDtk world) and `createRuntime({ scope })` for loading levels one at a time
17
+ - `ldtkToMapWorld` — build the format-neutral world model (level ids, bounds, neighbours) from a raw document, without reading any layer payload
18
+ - `ldtkToTileMap` — convert a single LDtk level to a `TileMap` (used internally; available for custom pipelines), plus its `LdtkToTileMapOptions`
30
19
  - `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
20
+ - `createLdtkIntGridCellSource` — the layer's IntGrid as a `TileCellSource`, ready to hand to `buildTileCollisionGeometry` or `TileColliderStreamer` for collision authored per cell
33
21
  - `ldtkExtension` — extension descriptor; depends on `tilemapExtension` automatically
34
22
  - `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)
23
+ - The raw LDtk JSON types (`LdtkData`, `LdtkLevel`, `LdtkLayerInstance`, `LdtkEntityInstance`, …) and the flip-bit constants (`LDTK_FLIP_X`, `LDTK_FLIP_Y`, `LDTK_FLIP_XY`, `LDTK_FLIP_NONE`)
24
+ - `TileMap`, `TileMapNode`, `TileMapView`, `TileLayer`, `TileSet`, `ObjectLayer`, … re-exported from `@codexo/exojs-tilemap` (same class identity — `instanceof TileMap` holds across both import paths)
40
25
 
41
26
  ## Usage
42
27
 
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:
28
+ Register the extension and load a `.ldtk` world. One extension enables **both** loading and rendering — `ldtkExtension` depends on `tilemapExtension`, so the tile chunk renderer bindings are materialised automatically:
46
29
 
47
30
  ```ts
48
31
  import { Application } from '@codexo/exojs';
49
- import { LdtkMap, TileMapNode, ldtkExtension } from '@codexo/exojs-ldtk';
32
+ import { TileMapNode, ldtkExtension } from '@codexo/exojs-ldtk';
50
33
 
51
34
  const app = new Application({ extensions: [ldtkExtension] });
52
35
 
@@ -57,15 +40,11 @@ const level = world.getLevelByName('Level_0') ?? world.levels[0];
57
40
  app.scenes.root.addChild(new TileMapNode(level));
58
41
  ```
59
42
 
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).
43
+ `TileMapNode` is the same class exported by `@codexo/exojs-tilemap` (see its [README](https://www.npmjs.com/package/@codexo/exojs-tilemap) for the rendering/culling model and actor interleaving).
63
44
 
64
45
  ### Streaming levels
65
46
 
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:
47
+ `ldtkMap` converts every level up front. For a project too large for that, load it as an `ldtkProject` and load levels individually — each gets its own `LoaderScope`, and external `.ldtkl` payloads are fetched only when their level is:
69
48
 
70
49
  ```ts
71
50
  import { Application, Asset } from '@codexo/exojs';
@@ -82,24 +61,20 @@ const forest = await runtime.loadLevel(project.world.getLevelByName('Forest')!.i
82
61
  forest.destroy(); // map, spawned objects and the level's asset claims, in that order
83
62
  ```
84
63
 
85
- Which levels to load, and when, stays game policy — `project.world` carries the bounds and
86
- neighbour graph to decide with.
64
+ Which levels to load, and when, stays game policy — `project.world` carries the bounds and neighbour graph to decide with.
87
65
 
88
66
  ## Texture ownership
89
67
 
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.
68
+ Tileset textures are loaded via the Loader and stay in the Loader cache. `LdtkMap.destroy()` destroys the owned runtime `TileMap`s but does **not** unload textures (Loader-owned) or remove any scene nodes — the application owns those.
93
69
 
94
70
  ## Core compatibility
95
71
 
96
- | `@codexo/exojs-ldtk` | `@codexo/exojs` |
97
- | -------------------- | --------------- |
98
- | 0.14.x | 0.14.x |
72
+ This package follows the Core lockstep release line. Its `@codexo/exojs` and `@codexo/exojs-tilemap` peer dependencies require the matching minor release.
99
73
 
100
74
  ## Links
101
75
 
102
- - [API reference](https://exojs.dev/api/exojs-ldtk)
76
+ - [LDtk guide](https://exoridus.github.io/ExoJS/en/guide/assets/ldtk/)
77
+ - [API reference](https://exoridus.github.io/ExoJS/en/api/)
103
78
  - [LDtk level editor](https://ldtk.io)
104
79
 
105
80
  ## License
@@ -34,6 +34,18 @@ export interface LdtkTileData {
34
34
  * field has no value set).
35
35
  */
36
36
  export type LdtkFieldScalarType = 'Int' | 'Float' | 'Bool' | 'String' | 'Multilines' | 'Color' | 'FilePath' | 'Enum';
37
+ /**
38
+ * The `__type` LDtk writes for an enum-valued field: the enum's identifier
39
+ * qualified by where it is defined. The `__value` is the selected entry's
40
+ * identifier as a plain string, so an enum field reaches the runtime as the
41
+ * string LDtk shows in the editor.
42
+ */
43
+ export type LdtkFieldEnumType = `LocalEnum.${string}` | `ExternEnum.${string}`;
44
+ /**
45
+ * Whether a raw LDtk `__type` names an enum. Applies to an `Array<T>` element
46
+ * type as well - LDtk spells a list of enum values `Array<LocalEnum.Name>`.
47
+ */
48
+ export declare const isLdtkFieldEnumType: (typeName: string) => typeName is LdtkFieldEnumType;
37
49
  /**
38
50
  * Raw `__value` shape for a `Point`-typed field. Structurally identical to
39
51
  * {@link TilePropertyPoint} minus its `kind` tag, so the canonical shape is
@@ -82,6 +94,10 @@ export type LdtkFieldInstance = {
82
94
  readonly __identifier: string;
83
95
  readonly __type: 'Tile';
84
96
  readonly __value: LdtkFieldTileValue | null;
97
+ } | {
98
+ readonly __identifier: string;
99
+ readonly __type: LdtkFieldEnumType;
100
+ readonly __value: string | null;
85
101
  } | {
86
102
  readonly __identifier: string;
87
103
  readonly __type: `Array<${string}>`;
@@ -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;IAC3B,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,4EAA4E;IAC5E,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC;;;OAGG;IACH,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,8CAA8C;IAC9C,QAAQ,CAA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;CAC5C"}
@@ -4,7 +4,12 @@ const LDTK_FLIP_NONE = 0;
4
4
  const LDTK_FLIP_X = 1;
5
5
  const LDTK_FLIP_Y = 2;
6
6
  const LDTK_FLIP_XY = 3;
7
+ /**
8
+ * Whether a raw LDtk `__type` names an enum. Applies to an `Array<T>` element
9
+ * type as well - LDtk spells a list of enum values `Array<LocalEnum.Name>`.
10
+ */
11
+ const isLdtkFieldEnumType = (typeName) => typeName.startsWith("LocalEnum.") || typeName.startsWith("ExternEnum.");
7
12
 
8
13
  //#endregion
9
- export { LDTK_FLIP_NONE, LDTK_FLIP_X, LDTK_FLIP_XY, LDTK_FLIP_Y };
14
+ export { LDTK_FLIP_NONE, LDTK_FLIP_X, LDTK_FLIP_XY, LDTK_FLIP_Y, isLdtkFieldEnumType };
10
15
  //# sourceMappingURL=LdtkData.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LdtkData.js","names":[],"sources":["../../src/LdtkData.ts"],"sourcesContent":["/**\n * TypeScript types for the LDtk JSON format (version 1.5.x).\n *\n * These interfaces model the root LDtk JSON document as produced by the LDtk\n * level editor. Only the fields consumed by the ExoJS runtime adapter are\n * declared here; unknown fields are not stripped at parse time.\n *\n * @see https://ldtk.io/json/\n */\n\nimport type { TilePropertyPoint, TilePropertyTileRef } from '@codexo/exojs-tilemap';\n\n// ── Tile data ─────────────────────────────────────────────────────────────────\n\n/** Flip-bit constants for {@link LdtkTileData.f}. */\nexport const LDTK_FLIP_NONE = 0;\nexport const LDTK_FLIP_X = 1;\nexport const LDTK_FLIP_Y = 2;\nexport const LDTK_FLIP_XY = 3;\n\n/** A single tile placed in a Tiles or AutoLayer layer instance. */\nexport interface LdtkTileData {\n /** Pixel position `[x, y]` of this tile within the layer. */\n readonly px: readonly [number, number];\n /** Source position `[x, y]` in the tileset image (top-left of the tile). */\n readonly src: readonly [number, number];\n /**\n * Flip bits: `0` = none, `1` = flipX, `2` = flipY, `3` = flipX + flipY.\n * Use {@link LDTK_FLIP_X} / {@link LDTK_FLIP_Y} constants for clarity.\n */\n readonly f: number;\n /** Local tile index in the owning tileset. */\n readonly t: number;\n /** Per-tile opacity in `[0, 1]`. Defaults to `1` when absent. */\n readonly a?: number;\n}\n\n// ── Entity data ───────────────────────────────────────────────────────────────\n\n/**\n * LDtk field types whose `__value` is a bare scalar (or `null`, when the\n * field has no value set).\n */\nexport type LdtkFieldScalarType = 'Int' | 'Float' | 'Bool' | 'String' | 'Multilines' | 'Color' | 'FilePath' | 'Enum';\n\n/**\n * Raw `__value` shape for a `Point`-typed field. Structurally identical to\n * {@link TilePropertyPoint} minus its `kind` tag, so the canonical shape is\n * reused directly rather than duplicated.\n */\nexport type LdtkFieldPointValue = Omit<TilePropertyPoint, 'kind'>;\n\n/**\n * Raw `__value` shape for an `EntityRef`-typed field: the referenced\n * entity's own iid plus LDtk's navigation context (owning layer/level/world).\n * Maps to {@link import('@codexo/exojs-tilemap').TilePropertyObjectRef} -\n * `entityIid` becomes `id`.\n */\nexport interface LdtkFieldEntityRefValue {\n readonly entityIid: string;\n readonly layerIid: string;\n readonly levelIid: string;\n readonly worldIid: string;\n}\n\n/**\n * Raw `__value` shape for a `Tile`-typed field. Structurally identical to\n * {@link TilePropertyTileRef} minus its `kind` tag, so the canonical shape is\n * reused directly rather than duplicated.\n */\nexport type LdtkFieldTileValue = Omit<TilePropertyTileRef, 'kind'>;\n\n/**\n * A field value on an entity or level instance, discriminated by `__type`.\n * `Array<T>` fields (e.g. `Array<Int>`, `Array<Point>`) carry a raw element\n * array whose per-element shape matches the corresponding non-array\n * `__value` shape above; see {@link import('./ldtkToTileMap').ldtkToTileMap}'s\n * field conversion for the exhaustive mapping into the canonical\n * {@link import('@codexo/exojs-tilemap').TilePropertyValue}.\n */\nexport type LdtkFieldInstance =\n | {\n readonly __identifier: string;\n readonly __type: LdtkFieldScalarType;\n readonly __value: string | number | boolean | null;\n }\n | {\n readonly __identifier: string;\n readonly __type: 'Point';\n readonly __value: LdtkFieldPointValue | null;\n }\n | {\n readonly __identifier: string;\n readonly __type: 'EntityRef';\n readonly __value: LdtkFieldEntityRefValue | null;\n }\n | {\n readonly __identifier: string;\n readonly __type: 'Tile';\n readonly __value: LdtkFieldTileValue | null;\n }\n | {\n readonly __identifier: string;\n readonly __type: `Array<${string}>`;\n readonly __value: readonly unknown[] | null;\n };\n\n/** An entity instance placed in an Entities layer. */\nexport interface LdtkEntityInstance {\n /** Entity definition identifier (class name). */\n readonly __identifier: string;\n /** Alias of `__identifier`, mirrors the entity definition type. */\n readonly __type: string;\n /**\n * Pixel position `[x, y]` of the entity's pivot-adjusted anchor - NOT the\n * top-left corner. Combine with {@link __pivot} to recover the bounding\n * box's top-left corner: `topLeftX = px[0] - width * __pivot[0]`.\n */\n readonly px: readonly [number, number];\n readonly width: number;\n readonly height: number;\n /**\n * Normalised `[x, y]` anchor point within the entity's bounding box, each\n * in `[0, 1]`. `[0, 0]` = top-left, `[0.5, 0.5]` = center, `[1, 1]` =\n * bottom-right. Determines how {@link px} relates to the bounding box.\n */\n readonly __pivot: readonly [number, number];\n readonly fieldInstances: readonly LdtkFieldInstance[];\n /** Globally unique instance id (UUID string). */\n readonly iid: string;\n /** UID of the entity definition this instance was created from. */\n readonly defUid: number;\n}\n\n// ── Layer instances ───────────────────────────────────────────────────────────\n\n/** Discriminant string for a layer instance type. */\nexport type LdtkLayerType = 'Tiles' | 'IntGrid' | 'Entities' | 'AutoLayer';\n\n/** A layer instance within a level. */\nexport interface LdtkLayerInstance {\n /** Layer definition identifier. */\n readonly __identifier: string;\n /** Layer type discriminant. */\n readonly __type: LdtkLayerType;\n /** Layer width in grid cells. */\n readonly __cWid: number;\n /** Layer height in grid cells. */\n readonly __cHei: number;\n /** Grid / tile size in pixels. */\n readonly __gridSize: number;\n /** UID of the layer definition. */\n readonly layerDefUid: number;\n /** UID of the parent level. */\n readonly levelId: number;\n readonly visible: boolean;\n /** Globally unique instance id (UUID string). */\n readonly iid: string;\n /**\n * UID of the tileset used by this layer, or `null` on a layer that draws no\n * tiles - LDtk writes the key either way.\n */\n readonly __tilesetDefUid?: number | null;\n /** Placed tiles for `Tiles` layer type. */\n readonly gridTiles?: readonly LdtkTileData[];\n /** Auto-computed tiles for `AutoLayer` (and `IntGrid` + auto-rules) layer types. */\n readonly autoLayerTiles?: readonly LdtkTileData[];\n /** Entity instances for `Entities` layer type. */\n readonly entityInstances?: readonly LdtkEntityInstance[];\n /**\n * Flat CSV array of IntGrid values for `IntGrid` layer type.\n * Index = `y * __cWid + x`. `0` = empty cell.\n */\n readonly intGridCsv?: readonly number[];\n /** Horizontal pixel offset applied to the layer. */\n readonly pxOffsetX?: number;\n /** Vertical pixel offset applied to the layer. */\n readonly pxOffsetY?: number;\n /** Layer opacity in `[0, 1]`. */\n readonly opacity?: number;\n}\n\n// ── Levels ────────────────────────────────────────────────────────────────────\n\n/**\n * One entry of a level's `__neighbours` array: an adjacency to another level,\n * plus the direction code LDtk assigned it.\n */\nexport interface LdtkLevelNeighbour {\n /** `iid` of the neighbouring level. */\n readonly levelIid: string;\n /**\n * Direction code: `\"n\"`, `\"s\"`, `\"e\"`, `\"w\"` for the cardinal sides, and\n * `\"<\"`, `\">\"`, `\"o\"` for the depth relations LDtk 1.x adds (lower depth,\n * greater depth, overlapping at the same depth). Mapped onto\n * {@link import('@codexo/exojs-tilemap').MapLevelSide} by\n * {@link import('./ldtkToMapWorld').ldtkToMapWorld}.\n */\n readonly dir: string;\n}\n\n/** A level in the LDtk world. */\nexport interface LdtkLevel {\n /** Human-readable level identifier (unique within the world). */\n readonly identifier: string;\n readonly uid: number;\n /** Globally unique instance id (UUID string). */\n readonly iid: string;\n /** World-space X position of the level's top-left corner in pixels. */\n readonly worldX: number;\n /** World-space Y position of the level's top-left corner in pixels. */\n readonly worldY: number;\n /** Level width in pixels. */\n readonly pxWid: number;\n /** Level height in pixels. */\n readonly pxHei: number;\n readonly bgColor?: string;\n /**\n * Layer instances in this level (top-to-bottom render order).\n * `null` when the level is stored in a separate `.ldtkl` file and has not\n * been loaded yet.\n */\n readonly layerInstances: readonly LdtkLayerInstance[] | null;\n readonly fieldInstances?: readonly LdtkFieldInstance[];\n /**\n * Relative path to this level's external `.ldtkl` file, or `null` when the\n * project does not save levels separately - LDtk writes the key either way.\n */\n readonly externalRelPath?: string | null;\n /**\n * Levels LDtk computed as adjacent to this one. Absent in documents written\n * before LDtk emitted the field, and empty for an isolated level.\n */\n readonly __neighbours?: readonly LdtkLevelNeighbour[] | null;\n}\n\n// ── Worlds ────────────────────────────────────────────────────────────────────\n\n/**\n * How a {@link LdtkWorldData}'s levels are spatially organised. `null` is a\n * valid LDtk value (unset), same as the other nullable enum-ish fields in\n * this file.\n */\nexport type LdtkWorldLayout = 'Free' | 'GridVania' | 'LinearHorizontal' | 'LinearVertical' | null;\n\n/**\n * A single world in a multi-world LDtk project (`root.worlds[]`, populated\n * when the project has \"Multi-Worlds\" enabled in its advanced settings).\n * Each world owns its own {@link levels}; `defs` (tilesets/layers/entity\n * definitions) is declared once at the document root and shared by every\n * world rather than duplicated per-world - see {@link LdtkData.defs}.\n */\nexport interface LdtkWorldData {\n /** Human-readable world identifier (unique within the project). */\n readonly identifier: string;\n /** Globally unique instance id (UUID string). */\n readonly iid: string;\n /** Width of the world grid in pixels. */\n readonly worldGridWidth: number;\n /** Height of the world grid in pixels. */\n readonly worldGridHeight: number;\n /** How this world's levels are spatially organised. */\n readonly worldLayout: LdtkWorldLayout;\n /** Levels belonging to this world, in document order. */\n readonly levels: readonly LdtkLevel[];\n}\n\n// ── Definitions ───────────────────────────────────────────────────────────────\n\n/** Tileset definition from `defs.tilesets`. */\nexport interface LdtkTilesetDef {\n readonly uid: number;\n /** Human-readable tileset identifier. */\n readonly identifier: string;\n /**\n * Relative path to the tileset atlas image.\n * `null` for internal / embedded tilesets with no image.\n */\n readonly relPath: string | null;\n /** Tile grid size (both width and height) in pixels. */\n readonly tileGridSize: number;\n /** Tileset image width in pixels. */\n readonly pxWid: number;\n /** Tileset image height in pixels. */\n readonly pxHei: number;\n /** Pixel spacing between tiles in the atlas. */\n readonly spacing?: number;\n /** Pixel padding (margin) around the atlas edges. */\n readonly padding?: number;\n}\n\n/** An IntGrid value definition (maps a raw int to a named, coloured entry). */\nexport interface LdtkIntGridValueDef {\n readonly value: number;\n readonly identifier: string | null;\n readonly color: string;\n}\n\n/** Layer definition from `defs.layers`. */\nexport interface LdtkLayerDef {\n readonly uid: number;\n readonly identifier: string;\n readonly type: LdtkLayerType;\n /** UID of the default tileset for this layer. `null` or absent = none. */\n readonly tilesetDefUid?: number | null;\n readonly gridSize: number;\n readonly intGridValues?: readonly LdtkIntGridValueDef[];\n /** Definition-level horizontal pixel offset, added to each layer instance offset. */\n readonly pxOffsetX?: number;\n /** Definition-level vertical pixel offset, added to each layer instance offset. */\n readonly pxOffsetY?: number;\n /**\n * Parallax horizontal factor, in `[-1, 1]`. `0` (the default) means \"no\n * parallax\" - the layer scrolls at normal camera speed, same as every\n * other layer. See {@link import('./ldtkToTileMap').ldtkToTileMap} for how\n * this is carried onto the runtime layer's `parallaxX`.\n */\n readonly parallaxFactorX?: number;\n /** Parallax vertical factor, in `[-1, 1]`. `0` (the default) means \"no parallax\". */\n readonly parallaxFactorY?: number;\n /**\n * Whether a non-zero parallax factor also scales this layer up/down to\n * simulate depth. Defaults to `true` (LDtk's own default) when absent.\n *\n * Converted to the runtime layer's uniform `parallaxScale` multiplier.\n */\n readonly parallaxScaling?: boolean;\n}\n\n/** Top-level definitions block (`defs`). */\nexport interface LdtkDefs {\n readonly tilesets: readonly LdtkTilesetDef[];\n readonly layers: readonly LdtkLayerDef[];\n}\n\n// ── Root document ─────────────────────────────────────────────────────────────\n\n/** Root LDtk JSON document (`*.ldtk`). */\nexport interface LdtkData {\n /** LDtk JSON format version string (e.g. `\"1.5.3\"`). */\n readonly jsonVersion: string;\n readonly worldGridWidth?: number;\n readonly worldGridHeight?: number;\n readonly defaultGridSize?: number;\n readonly bgColor?: string;\n readonly defs: LdtkDefs;\n /**\n * Levels not organised into worlds. Always populated for pre-multi-world\n * documents; kept EMPTY (per the LDtk spec's backward-compatibility rule)\n * when {@link worlds} is used instead - read levels via `worlds[].levels`\n * in that case, or use {@link import('./ldtkLevelEntries').getLdtkLevelEntries}\n * (or simply {@link import('./LdtkMap').LdtkMap.levels} /\n * {@link import('./LdtkMap').LdtkMap.getLevelByName}) to get \"all levels,\n * in order\" regardless of which shape the document uses.\n */\n readonly levels: readonly LdtkLevel[];\n /**\n * Worlds, present and non-empty only when the project has \"Multi-Worlds\"\n * enabled in its advanced settings. Absent or empty for the (overwhelmingly\n * common) single-world case, in which levels live directly in the root\n * {@link levels} array instead. `defs` is NOT duplicated per-world - it\n * stays declared once at the document root regardless of this field.\n */\n readonly worlds?: readonly LdtkWorldData[];\n}\n"],"mappings":";;AAeA,MAAa,iBAAiB;AAC9B,MAAa,cAAc;AAC3B,MAAa,cAAc;AAC3B,MAAa,eAAe"}
1
+ {"version":3,"file":"LdtkData.js","names":[],"sources":["../../src/LdtkData.ts"],"sourcesContent":["/**\n * TypeScript types for the LDtk JSON format (version 1.5.x).\n *\n * These interfaces model the root LDtk JSON document as produced by the LDtk\n * level editor. Only the fields consumed by the ExoJS runtime adapter are\n * declared here; unknown fields are not stripped at parse time.\n *\n * @see https://ldtk.io/json/\n */\n\nimport type { TilePropertyPoint, TilePropertyTileRef } from '@codexo/exojs-tilemap';\n\n// ── Tile data ─────────────────────────────────────────────────────────────────\n\n/** Flip-bit constants for {@link LdtkTileData.f}. */\nexport const LDTK_FLIP_NONE = 0;\nexport const LDTK_FLIP_X = 1;\nexport const LDTK_FLIP_Y = 2;\nexport const LDTK_FLIP_XY = 3;\n\n/** A single tile placed in a Tiles or AutoLayer layer instance. */\nexport interface LdtkTileData {\n /** Pixel position `[x, y]` of this tile within the layer. */\n readonly px: readonly [number, number];\n /** Source position `[x, y]` in the tileset image (top-left of the tile). */\n readonly src: readonly [number, number];\n /**\n * Flip bits: `0` = none, `1` = flipX, `2` = flipY, `3` = flipX + flipY.\n * Use {@link LDTK_FLIP_X} / {@link LDTK_FLIP_Y} constants for clarity.\n */\n readonly f: number;\n /** Local tile index in the owning tileset. */\n readonly t: number;\n /** Per-tile opacity in `[0, 1]`. Defaults to `1` when absent. */\n readonly a?: number;\n}\n\n// ── Entity data ───────────────────────────────────────────────────────────────\n\n/**\n * LDtk field types whose `__value` is a bare scalar (or `null`, when the\n * field has no value set).\n */\nexport type LdtkFieldScalarType = 'Int' | 'Float' | 'Bool' | 'String' | 'Multilines' | 'Color' | 'FilePath' | 'Enum';\n\n/**\n * The `__type` LDtk writes for an enum-valued field: the enum's identifier\n * qualified by where it is defined. The `__value` is the selected entry's\n * identifier as a plain string, so an enum field reaches the runtime as the\n * string LDtk shows in the editor.\n */\nexport type LdtkFieldEnumType = `LocalEnum.${string}` | `ExternEnum.${string}`;\n\n/**\n * Whether a raw LDtk `__type` names an enum. Applies to an `Array<T>` element\n * type as well - LDtk spells a list of enum values `Array<LocalEnum.Name>`.\n */\nexport const isLdtkFieldEnumType = (typeName: string): typeName is LdtkFieldEnumType => typeName.startsWith('LocalEnum.') || typeName.startsWith('ExternEnum.');\n\n/**\n * Raw `__value` shape for a `Point`-typed field. Structurally identical to\n * {@link TilePropertyPoint} minus its `kind` tag, so the canonical shape is\n * reused directly rather than duplicated.\n */\nexport type LdtkFieldPointValue = Omit<TilePropertyPoint, 'kind'>;\n\n/**\n * Raw `__value` shape for an `EntityRef`-typed field: the referenced\n * entity's own iid plus LDtk's navigation context (owning layer/level/world).\n * Maps to {@link import('@codexo/exojs-tilemap').TilePropertyObjectRef} -\n * `entityIid` becomes `id`.\n */\nexport interface LdtkFieldEntityRefValue {\n readonly entityIid: string;\n readonly layerIid: string;\n readonly levelIid: string;\n readonly worldIid: string;\n}\n\n/**\n * Raw `__value` shape for a `Tile`-typed field. Structurally identical to\n * {@link TilePropertyTileRef} minus its `kind` tag, so the canonical shape is\n * reused directly rather than duplicated.\n */\nexport type LdtkFieldTileValue = Omit<TilePropertyTileRef, 'kind'>;\n\n/**\n * A field value on an entity or level instance, discriminated by `__type`.\n * `Array<T>` fields (e.g. `Array<Int>`, `Array<Point>`) carry a raw element\n * array whose per-element shape matches the corresponding non-array\n * `__value` shape above; see {@link import('./ldtkToTileMap').ldtkToTileMap}'s\n * field conversion for the exhaustive mapping into the canonical\n * {@link import('@codexo/exojs-tilemap').TilePropertyValue}.\n */\nexport type LdtkFieldInstance =\n | {\n readonly __identifier: string;\n readonly __type: LdtkFieldScalarType;\n readonly __value: string | number | boolean | null;\n }\n | {\n readonly __identifier: string;\n readonly __type: 'Point';\n readonly __value: LdtkFieldPointValue | null;\n }\n | {\n readonly __identifier: string;\n readonly __type: 'EntityRef';\n readonly __value: LdtkFieldEntityRefValue | null;\n }\n | {\n readonly __identifier: string;\n readonly __type: 'Tile';\n readonly __value: LdtkFieldTileValue | null;\n }\n | {\n readonly __identifier: string;\n readonly __type: LdtkFieldEnumType;\n readonly __value: string | null;\n }\n | {\n readonly __identifier: string;\n readonly __type: `Array<${string}>`;\n readonly __value: readonly unknown[] | null;\n };\n\n/** An entity instance placed in an Entities layer. */\nexport interface LdtkEntityInstance {\n /** Entity definition identifier (class name). */\n readonly __identifier: string;\n /** Alias of `__identifier`, mirrors the entity definition type. */\n readonly __type: string;\n /**\n * Pixel position `[x, y]` of the entity's pivot-adjusted anchor - NOT the\n * top-left corner. Combine with {@link __pivot} to recover the bounding\n * box's top-left corner: `topLeftX = px[0] - width * __pivot[0]`.\n */\n readonly px: readonly [number, number];\n readonly width: number;\n readonly height: number;\n /**\n * Normalised `[x, y]` anchor point within the entity's bounding box, each\n * in `[0, 1]`. `[0, 0]` = top-left, `[0.5, 0.5]` = center, `[1, 1]` =\n * bottom-right. Determines how {@link px} relates to the bounding box.\n */\n readonly __pivot: readonly [number, number];\n readonly fieldInstances: readonly LdtkFieldInstance[];\n /** Globally unique instance id (UUID string). */\n readonly iid: string;\n /** UID of the entity definition this instance was created from. */\n readonly defUid: number;\n}\n\n// ── Layer instances ───────────────────────────────────────────────────────────\n\n/** Discriminant string for a layer instance type. */\nexport type LdtkLayerType = 'Tiles' | 'IntGrid' | 'Entities' | 'AutoLayer';\n\n/** A layer instance within a level. */\nexport interface LdtkLayerInstance {\n /** Layer definition identifier. */\n readonly __identifier: string;\n /** Layer type discriminant. */\n readonly __type: LdtkLayerType;\n /** Layer width in grid cells. */\n readonly __cWid: number;\n /** Layer height in grid cells. */\n readonly __cHei: number;\n /** Grid / tile size in pixels. */\n readonly __gridSize: number;\n /** UID of the layer definition. */\n readonly layerDefUid: number;\n /** UID of the parent level. */\n readonly levelId: number;\n readonly visible: boolean;\n /** Globally unique instance id (UUID string). */\n readonly iid: string;\n /**\n * UID of the tileset used by this layer, or `null` on a layer that draws no\n * tiles - LDtk writes the key either way.\n */\n readonly __tilesetDefUid?: number | null;\n /** Placed tiles for `Tiles` layer type. */\n readonly gridTiles?: readonly LdtkTileData[];\n /** Auto-computed tiles for `AutoLayer` (and `IntGrid` + auto-rules) layer types. */\n readonly autoLayerTiles?: readonly LdtkTileData[];\n /** Entity instances for `Entities` layer type. */\n readonly entityInstances?: readonly LdtkEntityInstance[];\n /**\n * Flat CSV array of IntGrid values for `IntGrid` layer type.\n * Index = `y * __cWid + x`. `0` = empty cell.\n */\n readonly intGridCsv?: readonly number[];\n /** Horizontal pixel offset applied to the layer. */\n readonly pxOffsetX?: number;\n /** Vertical pixel offset applied to the layer. */\n readonly pxOffsetY?: number;\n /** Layer opacity in `[0, 1]`. */\n readonly opacity?: number;\n}\n\n// ── Levels ────────────────────────────────────────────────────────────────────\n\n/**\n * One entry of a level's `__neighbours` array: an adjacency to another level,\n * plus the direction code LDtk assigned it.\n */\nexport interface LdtkLevelNeighbour {\n /** `iid` of the neighbouring level. */\n readonly levelIid: string;\n /**\n * Direction code: `\"n\"`, `\"s\"`, `\"e\"`, `\"w\"` for the cardinal sides, and\n * `\"<\"`, `\">\"`, `\"o\"` for the depth relations LDtk 1.x adds (lower depth,\n * greater depth, overlapping at the same depth). Mapped onto\n * {@link import('@codexo/exojs-tilemap').MapLevelSide} by\n * {@link import('./ldtkToMapWorld').ldtkToMapWorld}.\n */\n readonly dir: string;\n}\n\n/** A level in the LDtk world. */\nexport interface LdtkLevel {\n /** Human-readable level identifier (unique within the world). */\n readonly identifier: string;\n readonly uid: number;\n /** Globally unique instance id (UUID string). */\n readonly iid: string;\n /** World-space X position of the level's top-left corner in pixels. */\n readonly worldX: number;\n /** World-space Y position of the level's top-left corner in pixels. */\n readonly worldY: number;\n /** Level width in pixels. */\n readonly pxWid: number;\n /** Level height in pixels. */\n readonly pxHei: number;\n readonly bgColor?: string;\n /**\n * Layer instances in this level (top-to-bottom render order).\n * `null` when the level is stored in a separate `.ldtkl` file and has not\n * been loaded yet.\n */\n readonly layerInstances: readonly LdtkLayerInstance[] | null;\n readonly fieldInstances?: readonly LdtkFieldInstance[];\n /**\n * Relative path to this level's external `.ldtkl` file, or `null` when the\n * project does not save levels separately - LDtk writes the key either way.\n */\n readonly externalRelPath?: string | null;\n /**\n * Levels LDtk computed as adjacent to this one. Absent in documents written\n * before LDtk emitted the field, and empty for an isolated level.\n */\n readonly __neighbours?: readonly LdtkLevelNeighbour[] | null;\n}\n\n// ── Worlds ────────────────────────────────────────────────────────────────────\n\n/**\n * How a {@link LdtkWorldData}'s levels are spatially organised. `null` is a\n * valid LDtk value (unset), same as the other nullable enum-ish fields in\n * this file.\n */\nexport type LdtkWorldLayout = 'Free' | 'GridVania' | 'LinearHorizontal' | 'LinearVertical' | null;\n\n/**\n * A single world in a multi-world LDtk project (`root.worlds[]`, populated\n * when the project has \"Multi-Worlds\" enabled in its advanced settings).\n * Each world owns its own {@link levels}; `defs` (tilesets/layers/entity\n * definitions) is declared once at the document root and shared by every\n * world rather than duplicated per-world - see {@link LdtkData.defs}.\n */\nexport interface LdtkWorldData {\n /** Human-readable world identifier (unique within the project). */\n readonly identifier: string;\n /** Globally unique instance id (UUID string). */\n readonly iid: string;\n /** Width of the world grid in pixels. */\n readonly worldGridWidth: number;\n /** Height of the world grid in pixels. */\n readonly worldGridHeight: number;\n /** How this world's levels are spatially organised. */\n readonly worldLayout: LdtkWorldLayout;\n /** Levels belonging to this world, in document order. */\n readonly levels: readonly LdtkLevel[];\n}\n\n// ── Definitions ───────────────────────────────────────────────────────────────\n\n/** Tileset definition from `defs.tilesets`. */\nexport interface LdtkTilesetDef {\n readonly uid: number;\n /** Human-readable tileset identifier. */\n readonly identifier: string;\n /**\n * Relative path to the tileset atlas image.\n * `null` for internal / embedded tilesets with no image.\n */\n readonly relPath: string | null;\n /** Tile grid size (both width and height) in pixels. */\n readonly tileGridSize: number;\n /** Tileset image width in pixels. */\n readonly pxWid: number;\n /** Tileset image height in pixels. */\n readonly pxHei: number;\n /** Pixel spacing between tiles in the atlas. */\n readonly spacing?: number;\n /** Pixel padding (margin) around the atlas edges. */\n readonly padding?: number;\n}\n\n/** An IntGrid value definition (maps a raw int to a named, coloured entry). */\nexport interface LdtkIntGridValueDef {\n readonly value: number;\n readonly identifier: string | null;\n readonly color: string;\n}\n\n/** Layer definition from `defs.layers`. */\nexport interface LdtkLayerDef {\n readonly uid: number;\n readonly identifier: string;\n readonly type: LdtkLayerType;\n /** UID of the default tileset for this layer. `null` or absent = none. */\n readonly tilesetDefUid?: number | null;\n readonly gridSize: number;\n readonly intGridValues?: readonly LdtkIntGridValueDef[];\n /** Definition-level horizontal pixel offset, added to each layer instance offset. */\n readonly pxOffsetX?: number;\n /** Definition-level vertical pixel offset, added to each layer instance offset. */\n readonly pxOffsetY?: number;\n /**\n * Parallax horizontal factor, in `[-1, 1]`. `0` (the default) means \"no\n * parallax\" - the layer scrolls at normal camera speed, same as every\n * other layer. See {@link import('./ldtkToTileMap').ldtkToTileMap} for how\n * this is carried onto the runtime layer's `parallaxX`.\n */\n readonly parallaxFactorX?: number;\n /** Parallax vertical factor, in `[-1, 1]`. `0` (the default) means \"no parallax\". */\n readonly parallaxFactorY?: number;\n /**\n * Whether a non-zero parallax factor also scales this layer up/down to\n * simulate depth. Defaults to `true` (LDtk's own default) when absent.\n *\n * Converted to the runtime layer's uniform `parallaxScale` multiplier.\n */\n readonly parallaxScaling?: boolean;\n}\n\n/** Top-level definitions block (`defs`). */\nexport interface LdtkDefs {\n readonly tilesets: readonly LdtkTilesetDef[];\n readonly layers: readonly LdtkLayerDef[];\n}\n\n// ── Root document ─────────────────────────────────────────────────────────────\n\n/** Root LDtk JSON document (`*.ldtk`). */\nexport interface LdtkData {\n /** LDtk JSON format version string (e.g. `\"1.5.3\"`). */\n readonly jsonVersion: string;\n readonly worldGridWidth?: number;\n readonly worldGridHeight?: number;\n readonly defaultGridSize?: number;\n readonly bgColor?: string;\n readonly defs: LdtkDefs;\n /**\n * Levels not organised into worlds. Always populated for pre-multi-world\n * documents; kept EMPTY (per the LDtk spec's backward-compatibility rule)\n * when {@link worlds} is used instead - read levels via `worlds[].levels`\n * in that case, or use {@link import('./ldtkLevelEntries').getLdtkLevelEntries}\n * (or simply {@link import('./LdtkMap').LdtkMap.levels} /\n * {@link import('./LdtkMap').LdtkMap.getLevelByName}) to get \"all levels,\n * in order\" regardless of which shape the document uses.\n */\n readonly levels: readonly LdtkLevel[];\n /**\n * Worlds, present and non-empty only when the project has \"Multi-Worlds\"\n * enabled in its advanced settings. Absent or empty for the (overwhelmingly\n * common) single-world case, in which levels live directly in the root\n * {@link levels} array instead. `defs` is NOT duplicated per-world - it\n * stays declared once at the document root regardless of this field.\n */\n readonly worlds?: readonly LdtkWorldData[];\n}\n"],"mappings":";;AAeA,MAAa,iBAAiB;AAC9B,MAAa,cAAc;AAC3B,MAAa,cAAc;AAC3B,MAAa,eAAe;;;;;AAuC5B,MAAa,uBAAuB,aAAoD,SAAS,WAAW,YAAY,KAAK,SAAS,WAAW,aAAa"}
@@ -76,8 +76,6 @@ export declare class LdtkProject {
76
76
  /** World layout, one entry per LDtk world. See {@link import('./ldtkToMapWorld').ldtkToMapWorld}. */
77
77
  readonly worlds: readonly MapWorld[];
78
78
  private readonly _entries;
79
- /** Projects are produced by the `ldtkProject` asset binding. @internal */
80
- constructor(source: string, data: LdtkData, tilesets: ReadonlyMap<number, TileSet>);
81
79
  /**
82
80
  * The project's only world. For a multi-world project this is the first in
83
81
  * document order; read {@link worlds} to reach the others.
@@ -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,uBAAuB,CAAC;AAC7F,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,KAAK,EAAE,QAAQ,EAAa,MAAM,YAAY,CAAC;AAQtD,qDAAqD;AACrD,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,qBAAa,WAAW;IACtB,iDAAiD;IACjD,SAAgB,MAAM,EAAE,MAAM,CAAC;IAC/B,4FAA4F;IAC5F,SAAgB,IAAI,EAAE,QAAQ,CAAC;IAC/B,wFAAwF;IACxF,SAAgB,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvD,qGAAqG;IACrG,SAAgB,MAAM,EAAE,SAAS,QAAQ,EAAE,CAAC;IAE5C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA4B;IAErD,0EAA0E;gBACvD,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC;IAQzF;;;OAGG;IACH,IAAW,KAAK,IAAI,QAAQ,CAQ3B;IAED,sDAAsD;I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EAAE,kBAAkB,GAAG,eAAe;YAcpD,UAAU;IAYxB;;;;;OAKG;YACW,aAAa;CAiB5B"}
package/dist/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { LDTK_FLIP_NONE, LDTK_FLIP_X, LDTK_FLIP_XY, LDTK_FLIP_Y } from "./LdtkData.js";
1
+ import { LDTK_FLIP_NONE, LDTK_FLIP_X, LDTK_FLIP_XY, LDTK_FLIP_Y, isLdtkFieldEnumType } from "./LdtkData.js";
2
2
  import { createLdtkIntGridCellSource, getLdtkIntGridValueAt, ldtkIntGridCsvProperty, ldtkIntGridValuesProperty, ldtkToTileMap } from "./ldtkToTileMap.js";
3
3
  import { ldtkToMapWorld } from "./ldtkToMapWorld.js";
4
4
  import { LdtkMap } from "./LdtkMap.js";
@@ -8,4 +8,4 @@ import { LdtkMapAssetType, LdtkProjectAssetType, ldtkMapType, ldtkProjectType }
8
8
  import { ldtkExtension } from "./ldtkExtension.js";
9
9
  import { MapLevelRuntime, MapLevelSide, MapObjectSpawner, MapSpawnError, MapSpawnSession, MapWorld, MapWorldRuntime, ObjectKind, ObjectLayer, TILE_TRANSFORM_IDENTITY, TileLayer, TileMap, TileMapView, TilePropertyKind, TileSet, mapObjectDescriptor, mapObjectDescriptors, tilemapExtension } from "./public.js";
10
10
 
11
- export { LDTK_FLIP_NONE, LDTK_FLIP_X, LDTK_FLIP_XY, LDTK_FLIP_Y, LdtkFormatError, LdtkMap, LdtkMapAssetType, LdtkProject, LdtkProjectAssetType, MapLevelRuntime, MapLevelSide, MapObjectSpawner, MapSpawnError, MapSpawnSession, MapWorld, MapWorldRuntime, ObjectKind, ObjectLayer, TILE_TRANSFORM_IDENTITY, TileLayer, TileMap, TileMapView, TilePropertyKind, TileSet, createLdtkIntGridCellSource, getLdtkIntGridValueAt, ldtkExtension, ldtkIntGridCsvProperty, ldtkIntGridValuesProperty, ldtkMapType, ldtkProjectType, ldtkToMapWorld, ldtkToTileMap, mapObjectDescriptor, mapObjectDescriptors, tilemapExtension };
11
+ export { LDTK_FLIP_NONE, LDTK_FLIP_X, LDTK_FLIP_XY, LDTK_FLIP_Y, LdtkFormatError, LdtkMap, LdtkMapAssetType, LdtkProject, LdtkProjectAssetType, MapLevelRuntime, MapLevelSide, MapObjectSpawner, MapSpawnError, MapSpawnSession, MapWorld, MapWorldRuntime, ObjectKind, ObjectLayer, TILE_TRANSFORM_IDENTITY, TileLayer, TileMap, TileMapView, TilePropertyKind, TileSet, createLdtkIntGridCellSource, getLdtkIntGridValueAt, isLdtkFieldEnumType, ldtkExtension, ldtkIntGridCsvProperty, ldtkIntGridValuesProperty, ldtkMapType, ldtkProjectType, ldtkToMapWorld, ldtkToTileMap, mapObjectDescriptor, mapObjectDescriptors, tilemapExtension };
@@ -1,6 +1,6 @@
1
- import type { TileCellSource, TileProperties, TileSet } from '@codexo/exojs-tilemap';
2
- import { TILE_TRANSFORM_IDENTITY, TileLayer, TileMap } from '@codexo/exojs-tilemap';
3
- import type { LdtkData, LdtkIntGridValueDef, LdtkLevel } from './LdtkData';
1
+ import type { TileCellSource, TileSet } from '@codexo/exojs-tilemap';
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}.
@@ -42,23 +42,6 @@ export interface LdtkToTileMapOptions {
42
42
  * tagged with its owning world's iid under the reserved `ldtkWorldIid` key.
43
43
  */
44
44
  export declare const ldtkToTileMap: (data: LdtkData, options?: LdtkToTileMapOptions) => LdtkMap;
45
- /**
46
- * Convert one already-resolved LDtk level into its runtime {@link TileMap}.
47
- *
48
- * `level.layerInstances` must be present: an externalized level has to have its
49
- * `.ldtkl` payload merged in first, or the result is an empty map.
50
- * @internal
51
- */
52
- export declare const ldtkLevelToTileMap: (level: LdtkLevel, worldIid: string | undefined, levelIndex: number, data: LdtkData, tilesets: ReadonlyMap<number, TileSet>) => TileMap;
53
- /**
54
- * The property bag a level contributes to its runtime representation - user
55
- * fields first, then the reserved LDtk keys, so a same-named user field can
56
- * never clobber them. `ldtkWorldIid` is added only for multi-world documents;
57
- * a single-world document's properties stay exactly as they were before
58
- * multi-world support existed.
59
- * @internal
60
- */
61
- export declare const buildLdtkLevelProperties: (level: LdtkLevel, worldIid: string | undefined) => TileProperties;
62
45
  /**
63
46
  * Reserved {@link TileLayer.properties} key holding the JSON-encoded raw
64
47
  * IntGrid CSV array (`readonly number[]`) for a `TileLayer` converted from an
@@ -1 +1 @@
1
- {"version":3,"file":"ldtkToTileMap.d.ts","sourceRoot":"","sources":["../../src/ldtkToTileMap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAiB,cAAc,EAAqB,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACvH,OAAO,EAAe,uBAAuB,EAAE,SAAS,EAAE,OAAO,EAAoB,MAAM,uBAAuB,CAAC;AAEnH,OAAO,KAAK,EAAE,QAAQ,EAAyC,mBAAmB,EAAqB,SAAS,EAAgB,MAAM,YAAY,CAAC;AAGnJ,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;AAIF;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAC7B,OAAO,SAAS,EAChB,UAAU,MAAM,GAAG,SAAS,EAC5B,YAAY,MAAM,EAClB,MAAM,QAAQ,EACd,UAAU,WAAW,CAAC,MAAM,EAA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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,5 +1,5 @@
1
1
  import { getLdtkLevelEntries } from "./ldtkLevelEntries.js";
2
- import { LDTK_FLIP_X, LDTK_FLIP_Y } from "./LdtkData.js";
2
+ import { LDTK_FLIP_X, LDTK_FLIP_Y, isLdtkFieldEnumType } from "./LdtkData.js";
3
3
  import { resolveLdtkLayerParallax } from "./ldtkParallax.js";
4
4
  import { LdtkMap } from "./LdtkMap.js";
5
5
  import { ObjectLayer, TileLayer, TileMap, TilePropertyKind } from "@codexo/exojs-tilemap";
@@ -314,8 +314,9 @@ const convertEntity = (entity, id) => {
314
314
  /**
315
315
  * Project LDtk field instances to a flat {@link TileProperties} bag.
316
316
  * Every LDtk field type maps to a canonical {@link TilePropertyValue}
317
- * (scalars pass through; `Point`/`EntityRef`/`Tile` become their tagged
318
- * structured variants; `Array<T>` fields recursively convert each element).
317
+ * (scalars and enum entries pass through as their raw value;
318
+ * `Point`/`EntityRef`/`Tile` become their tagged structured variants;
319
+ * `Array<T>` fields recursively convert each element).
319
320
  * A field whose raw `__value` is `null` (LDtk's "not set" convention) is
320
321
  * omitted from the bag entirely, matching the property-absent case rather
321
322
  * than a present-but-null value.
@@ -335,6 +336,8 @@ const convertFieldInstances = (fields) => {
335
336
  * union member for the compiler; a predicate on `field` itself does.
336
337
  */
337
338
  const isLdtkArrayField = (field) => field.__type.startsWith("Array<");
339
+ /** See {@link isLdtkArrayField} for why the narrowing needs a predicate on `field`. */
340
+ const isLdtkEnumField = (field) => isLdtkFieldEnumType(field.__type);
338
341
  /** Convert one {@link LdtkFieldInstance} to its canonical {@link TilePropertyValue}, or `undefined` for a `null` (unset) field. */
339
342
  const convertField = (field) => {
340
343
  switch (field.__type) {
@@ -350,6 +353,7 @@ const convertField = (field) => {
350
353
  case "EntityRef":
351
354
  case "Tile": return mapLdtkFieldValue(field.__type, field.__value);
352
355
  }
356
+ if (isLdtkEnumField(field)) return mapLdtkFieldValue(field.__type, field.__value);
353
357
  if (isLdtkArrayField(field)) {
354
358
  if (field.__value === null) return void 0;
355
359
  const elementType = field.__type.slice(6, -1);
@@ -367,10 +371,13 @@ const convertField = (field) => {
367
371
  * {@link TilePropertyValue}, given the LDtk type name it was declared with.
368
372
  * Shared by {@link convertField} (top-level fields) and array-element
369
373
  * conversion (`typeName` is the `T` extracted from an `Array<T>` field).
370
- * Returns `undefined` for a `null` value or an unrecognised `typeName`.
374
+ * Returns `undefined` for a `null` value; throws on a type name this package
375
+ * does not model, at the top level and inside an array alike, so an
376
+ * unsupported field type is never mistaken for an absent or empty one.
371
377
  */
372
378
  const mapLdtkFieldValue = (typeName, value) => {
373
379
  if (value === null || value === void 0) return void 0;
380
+ if (isLdtkFieldEnumType(typeName)) return value;
374
381
  switch (typeName) {
375
382
  case "Int":
376
383
  case "Float":
@@ -409,7 +416,7 @@ const mapLdtkFieldValue = (typeName, value) => {
409
416
  h: v.h
410
417
  };
411
418
  }
412
- default: return;
419
+ default: throw new Error(`convertFieldInstances: unrecognised LDtk field type "${typeName}".`);
413
420
  }
414
421
  };
415
422
  const pickLevelGridSize = (level, fallback) => {
@@ -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 { LdtkData, LdtkEntityInstance, LdtkFieldInstance, LdtkIntGridValueDef, LdtkLayerInstance, LdtkLevel, LdtkTileData } from './LdtkData';\nimport { 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 pass through; `Point`/`EntityRef`/`Tile` become their tagged\n * structured variants; `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/** 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 (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 or an unrecognised `typeName`.\n */\nconst mapLdtkFieldValue = (typeName: string, value: unknown): TilePropertyValue | undefined => {\n if (value === null || value === undefined) return undefined;\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 // Unknown/unsupported array element type (e.g. a future LDtk type\n // inside Array<T>) - skip rather than throw, since this path is not\n // compiler-exhaustive (element types are plain runtime strings).\n return undefined;\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":";;;;;;;;;;;;;;;;;;;;;;;;AAoDA,MAAa,iBAAiB,MAAgB,YAA4C;CACxF,MAAM,SAAS,SAAS,UAAU;CAClC,MAAM,WAAW,SA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AAqB,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 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\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,MAAM,MAAM;AACzC;;;;;;;;AAWA,MAAa,sBACX,OACA,UACA,YACA,MACA,aACY,aAAa,OAAO,UAAU,YAAY,MAAM,QAAQ;AAEtE,MAAM,gBAAgB,OAAkB,UAA8B,YAAoB,MAAgB,aAAoD;CAE5J,MAAM,WAAW,kBAAkB,OAAO,KAAK,mBAAmB,EAAE;CACpE,MAAM,WAAW,KAAK,IAAI,GAAG,KAAK,KAAK,MAAM,QAAQ,QAAQ,CAAC;CAC9D,MAAM,YAAY,KAAK,IAAI,GAAG,KAAK,KAAK,MAAM,QAAQ,QAAQ,CAAC;CAE/D,MA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Ac,QAAW,SAAS,KAAK,SAAS;EACtD;EACA,OAAO,OAAO,OAAO,QAAQ;CAC/B;CAMA,MAAM,IAAI,MAAM,wDAAyD,MAA4B,OAAO,GAAG;AACjH;;;;;;;;;;AAWA,MAAM,qBAAqB,UAAkB,UAAkD;CAC7F,IAAI,UAAU,QAAQ,UAAU,QAAW,OAAO;CAGlD,IAAI,oBAAoB,QAAQ,GAC9B,OAAO;CAGT,QAAQ,UAAR;EACE,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,QACH,OAAO;EAET,KAAK,SAAS;GACZ,MAAM,IAAI;GACV,OAAO;IAAE,MAAM,iBAAiB;IAAO,IAAI,EAAE;IAAI,IAAI,EAAE;GAAG;EAC5D;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,37 +1,2 @@
1
- import type { AssetFactoryContext } from '@codexo/exojs';
2
- import { TileSet } from '@codexo/exojs-tilemap';
3
- import type { LdtkTilesetDef } from './LdtkData';
4
- import type { LdtkMap } from './LdtkMap';
5
- /**
6
- * Load one LDtk tileset definition into a runtime {@link TileSet}.
7
- *
8
- * Returns `null` only for an embed-atlas tileset (`relPath` null or empty),
9
- * whose image ships with the LDtk editor and cannot be resolved from the
10
- * document - that case warns rather than passing unnoticed, because every tile
11
- * drawn from it is missing from the runtime map.
12
- *
13
- * @throws {LdtkFormatError} when the tileset names an atlas that cannot yield a
14
- * single tile (its declared size is smaller than one padded tile). Dropping it
15
- * would make every cell and entity referencing it vanish without a diagnostic.
16
- * @internal
17
- */
18
- export declare const loadLdtkTileset: (def: LdtkTilesetDef, ldtkSource: string, context: AssetFactoryContext) => Promise<TileSet | null>;
19
- /**
20
- * Read a `.ldtk` document, load all referenced tileset images, resolve any
21
- * externalized (`.ldtkl`) levels, and return a fully assembled {@link LdtkMap}
22
- * with one runtime {@link import('@codexo/exojs-tilemap').TileMap} per level.
23
- *
24
- * The fetched document - and every external `.ldtkl` payload - is validated
25
- * before use; a structural problem throws
26
- * {@link import('./validate').LdtkFormatError} naming the file and the
27
- * offending property path.
28
- *
29
- * A tileset whose declared atlas cannot hold a single tile is a
30
- * {@link import('./validate').LdtkFormatError} too - dropping it would make
31
- * every cell referencing it disappear without a diagnostic. An embed-atlas
32
- * tileset (`relPath = null`) is the one case that is skipped rather than
33
- * rejected, since its image lives inside the LDtk editor; that skip warns.
34
- * @internal
35
- */
36
- export declare const loadLdtkMap: (context: AssetFactoryContext) => Promise<LdtkMap>;
1
+ export {};
37
2
  //# sourceMappingURL=loadLdtkMap.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"loadLdtkMap.d.ts","sourceRoot":"","sources":["../../src/loadLdtkMap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEzD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,OAAO,KAAK,EAAuB,cAAc,EAAE,MAAM,YAAY,CAAC;AAEtE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOzC;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe,GAAU,KAAK,cAAc,EAAE,YAAY,MAAM,EAAE,SAAS,mBAAmB,KAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAoDnI,CAAC;AAgEF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,WAAW,GAAU,SAAS,mBAAmB,KAAG,OAAO,CAAC,OAAO,CAwB/E,CAAC"}
1
+ {"version":3,"file":"loadLdtkMap.d.ts","sourceRoot":"","sources":["../../src/loadLdtkMap.ts"],"names":[],"mappings":""}
@@ -1,17 +1,2 @@
1
- import type { AssetFactoryContext } from '@codexo/exojs';
2
- import { LdtkProject } from './LdtkProject';
3
- /**
4
- * Read and validate a `.ldtk` document and load every tileset atlas it
5
- * references, without touching any level payload.
6
- *
7
- * External `.ldtkl` levels are deliberately left unfetched - that is the whole
8
- * point of {@link LdtkProject}: the world layout arrives, the levels arrive
9
- * when a level runtime asks for them.
10
- *
11
- * @throws {import('./validate').LdtkFormatError} for a structurally invalid
12
- * document, or a tileset whose declared atlas cannot hold a single tile. An
13
- * embed-atlas tileset (`relPath = null`) is skipped with a warning instead.
14
- * @internal
15
- */
16
- export declare const loadLdtkProject: (context: AssetFactoryContext) => Promise<LdtkProject>;
1
+ export {};
17
2
  //# sourceMappingURL=loadLdtkProject.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"loadLdtkProject.d.ts","sourceRoot":"","sources":["../../src/loadLdtkProject.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAIzD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAI5C;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe,GAAU,SAAS,mBAAmB,KAAG,OAAO,CAAC,WAAW,CAavF,CAAC"}
1
+ {"version":3,"file":"loadLdtkProject.d.ts","sourceRoot":"","sources":["../../src/loadLdtkProject.ts"],"names":[],"mappings":""}
@@ -6,8 +6,8 @@ export { LdtkProject } from './LdtkProject';
6
6
  export { ldtkToMapWorld } from './ldtkToMapWorld';
7
7
  export type { LdtkToTileMapOptions } from './ldtkToTileMap';
8
8
  export { createLdtkIntGridCellSource, getLdtkIntGridValueAt, ldtkIntGridCsvProperty, ldtkIntGridValuesProperty, ldtkToTileMap } from './ldtkToTileMap';
9
- export type { LdtkData, LdtkDefs, LdtkEntityInstance, LdtkFieldInstance, LdtkIntGridValueDef, LdtkLayerDef, LdtkLayerInstance, LdtkLayerType, LdtkLevel, LdtkLevelNeighbour, LdtkTileData, LdtkTilesetDef, LdtkWorldData, LdtkWorldLayout, } from './LdtkData';
10
- export { LDTK_FLIP_NONE, LDTK_FLIP_X, LDTK_FLIP_XY, LDTK_FLIP_Y } from './LdtkData';
9
+ export type { LdtkData, LdtkDefs, LdtkEntityInstance, LdtkFieldEnumType, LdtkFieldInstance, LdtkIntGridValueDef, LdtkLayerDef, LdtkLayerInstance, LdtkLayerType, LdtkLevel, LdtkLevelNeighbour, LdtkTileData, LdtkTilesetDef, LdtkWorldData, LdtkWorldLayout, } from './LdtkData';
10
+ export { isLdtkFieldEnumType, LDTK_FLIP_NONE, LDTK_FLIP_X, LDTK_FLIP_XY, LDTK_FLIP_Y } from './LdtkData';
11
11
  export { LdtkFormatError } from './validate';
12
12
  export type { ChunkCoord, EllipseObject, MapBounds, MapLevel, MapLevelCancelOptions, MapLevelLoadContext, MapLevelLoadOptions, MapLevelNeighbour, MapLevelProvider, MapObjectDescriptor, MapObjectFactories, MapObjectFactory, MapObjectSpawnerOptions, MapSpawnErrorReason, MapSpawnOptions, MapWorldOptions, MapWorldRuntimeOptions, 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, UnknownMapObjectPolicy, } from '@codexo/exojs-tilemap';
13
13
  export { MapLevelRuntime, MapLevelSide, mapObjectDescriptor, mapObjectDescriptors, MapObjectSpawner, MapSpawnError, MapSpawnSession, MapWorld, MapWorldRuntime, ObjectKind, ObjectLayer, TILE_TRANSFORM_IDENTITY, TileLayer, TileMap, tilemapExtension, TileMapView, TilePropertyKind, TileSet, } from '@codexo/exojs-tilemap';
@@ -1 +1 @@
1
- {"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/public.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAGnG,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,YAAY,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,YAAY,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,2BAA2B,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGvJ,YAAY,EACV,QAAQ,EACR,QAAQ,EACR,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,SAAS,EACT,kBAAkB,EAClB,YAAY,EACZ,cAAc,EACd,aAAa,EACb,eAAe,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAGpF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAK7C,YAAY,EACV,UAAU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AI,CAAC;SACf,CAAC;KACH;CACF"}
@@ -1,4 +1,4 @@
1
- import { LDTK_FLIP_NONE, LDTK_FLIP_X, LDTK_FLIP_XY, LDTK_FLIP_Y } from "./LdtkData.js";
1
+ import { LDTK_FLIP_NONE, LDTK_FLIP_X, LDTK_FLIP_XY, LDTK_FLIP_Y, isLdtkFieldEnumType } from "./LdtkData.js";
2
2
  import { createLdtkIntGridCellSource, getLdtkIntGridValueAt, ldtkIntGridCsvProperty, ldtkIntGridValuesProperty, ldtkToTileMap } from "./ldtkToTileMap.js";
3
3
  import { ldtkToMapWorld } from "./ldtkToMapWorld.js";
4
4
  import { LdtkMap } from "./LdtkMap.js";
@@ -8,4 +8,4 @@ import { LdtkMapAssetType, LdtkProjectAssetType, ldtkMapType, ldtkProjectType }
8
8
  import { ldtkExtension } from "./ldtkExtension.js";
9
9
  import { MapLevelRuntime, MapLevelSide as MapLevelSide$1, MapObjectSpawner, MapSpawnError, MapSpawnSession, MapWorld as MapWorld$1, MapWorldRuntime as MapWorldRuntime$1, ObjectKind, ObjectLayer as ObjectLayer$1, TILE_TRANSFORM_IDENTITY, TileLayer as TileLayer$1, TileMap as TileMap$1, TileMapView, TilePropertyKind as TilePropertyKind$1, TileSet as TileSet$1, mapObjectDescriptor, mapObjectDescriptors, tilemapExtension as tilemapExtension$1 } from "@codexo/exojs-tilemap";
10
10
 
11
- export { LDTK_FLIP_NONE, LDTK_FLIP_X, LDTK_FLIP_XY, LDTK_FLIP_Y, LdtkFormatError, LdtkMap, LdtkMapAssetType, LdtkProject, LdtkProjectAssetType, MapLevelRuntime, MapLevelSide$1 as MapLevelSide, MapObjectSpawner, MapSpawnError, MapSpawnSession, MapWorld$1 as MapWorld, MapWorldRuntime$1 as MapWorldRuntime, ObjectKind, ObjectLayer$1 as ObjectLayer, TILE_TRANSFORM_IDENTITY, TileLayer$1 as TileLayer, TileMap$1 as TileMap, TileMapView, TilePropertyKind$1 as TilePropertyKind, TileSet$1 as TileSet, createLdtkIntGridCellSource, getLdtkIntGridValueAt, ldtkExtension, ldtkIntGridCsvProperty, ldtkIntGridValuesProperty, ldtkMapType, ldtkProjectType, ldtkToMapWorld, ldtkToTileMap, mapObjectDescriptor, mapObjectDescriptors, tilemapExtension$1 as tilemapExtension };
11
+ export { LDTK_FLIP_NONE, LDTK_FLIP_X, LDTK_FLIP_XY, LDTK_FLIP_Y, LdtkFormatError, LdtkMap, LdtkMapAssetType, LdtkProject, LdtkProjectAssetType, MapLevelRuntime, MapLevelSide$1 as MapLevelSide, MapObjectSpawner, MapSpawnError, MapSpawnSession, MapWorld$1 as MapWorld, MapWorldRuntime$1 as MapWorldRuntime, ObjectKind, ObjectLayer$1 as ObjectLayer, TILE_TRANSFORM_IDENTITY, TileLayer$1 as TileLayer, TileMap$1 as TileMap, TileMapView, TilePropertyKind$1 as TilePropertyKind, TileSet$1 as TileSet, createLdtkIntGridCellSource, getLdtkIntGridValueAt, isLdtkFieldEnumType, ldtkExtension, ldtkIntGridCsvProperty, ldtkIntGridValuesProperty, ldtkMapType, ldtkProjectType, ldtkToMapWorld, ldtkToTileMap, mapObjectDescriptor, mapObjectDescriptors, tilemapExtension$1 as tilemapExtension };
package/dist/esm/url.d.ts CHANGED
@@ -1,16 +1,2 @@
1
- /**
2
- * Resolves `ref` (a path read from an LDtk file, e.g. a tileset `relPath` or a
3
- * level `externalRelPath`) relative to `base` (the resolved location of the
4
- * file that referenced it).
5
- *
6
- * - If `ref` is already absolute (scheme, protocol- or root-relative, or a
7
- * `data:`/`blob:` URL), it is returned unchanged.
8
- * - If `base` is an absolute URL, standard `new URL(ref, base)` resolution is
9
- * used.
10
- * - Otherwise both are relative ExoJS asset paths; `../`/`./` segments are
11
- * collapsed via a synthetic origin and the result is returned relative again.
12
- *
13
- * @internal
14
- */
15
- export declare const resolveLdtkUrl: (ref: string, base: string) => string;
1
+ export {};
16
2
  //# sourceMappingURL=url.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../src/url.ts"],"names":[],"mappings":"AAgBA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,cAAc,GAAI,KAAK,MAAM,EAAE,MAAM,MAAM,KAAG,MAgB1D,CAAC"}
1
+ {"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../src/url.ts"],"names":[],"mappings":""}
@@ -1,4 +1,3 @@
1
- import type { LdtkData, LdtkLevel } from './LdtkData';
2
1
  /**
3
2
  * Thrown when an LDtk JSON document does not match the expected shape.
4
3
  * `source` is the URL of the file being parsed; `path` is a JSON-path-like
@@ -10,18 +9,4 @@ export declare class LdtkFormatError extends Error {
10
9
  readonly path: string;
11
10
  constructor(source: string, path: string, message: string);
12
11
  }
13
- /**
14
- * Validate the root of a `.ldtk` file and return it typed as {@link LdtkData}.
15
- * Throws {@link LdtkFormatError} on any structural problem, naming the source
16
- * URL and the property path of the offending value.
17
- * @internal
18
- */
19
- export declare const validateLdtkData: (raw: unknown, source: string) => LdtkData;
20
- /**
21
- * Validate an external `.ldtkl` payload and return it typed as
22
- * {@link LdtkLevel}. Paths in a thrown {@link LdtkFormatError} are relative to
23
- * the level object, since that object is the root of the `.ldtkl` file.
24
- * @internal
25
- */
26
- export declare const validateLdtkLevelData: (raw: unknown, source: string) => LdtkLevel;
27
12
  //# sourceMappingURL=validate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/validate.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,QAAQ,EAAiB,SAAS,EAAmB,MAAM,YAAY,CAAC;AAEtF;;;;;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;AAyYD;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAAI,KAAK,OAAO,EAAE,QAAQ,MAAM,KAAG,QAgB/D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAAI,KAAK,OAAO,EAAE,QAAQ,MAAM,KAAG,SAIpE,CAAC"}
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,3 +1,5 @@
1
+ import { isLdtkFieldEnumType } from "./LdtkData.js";
2
+
1
3
  //#region src/validate.ts
2
4
  /**
3
5
  * Thrown when an LDtk JSON document does not match the expected shape.
@@ -154,11 +156,15 @@ const validateDefs = (raw, source, path) => {
154
156
  * genuine one until something read it.
155
157
  *
156
158
  * A `__type` this package does not model (a future LDtk field type, or an
157
- * `Array<T>` element type of one) is left unchecked: forward compatibility
158
- * matters more than rejecting a value the conversion already skips.
159
+ * `Array<T>` element type of one) is left unchecked here: the conversion pass
160
+ * is where an unsupported type is reported, and it names the type.
159
161
  */
160
162
  const validateFieldValue = (typeName, value, source, path) => {
161
163
  if (value === null || value === void 0) return;
164
+ if (isLdtkFieldEnumType(typeName)) {
165
+ expectString(value, source, path);
166
+ return;
167
+ }
162
168
  switch (typeName) {
163
169
  case "Int":
164
170
  expectInteger(value, source, path);
@@ -1 +1 @@
1
- {"version":3,"file":"validate.js","names":[],"sources":["../../src/validate.ts"],"sourcesContent":["// Runtime validation for LDtk JSON (`.ldtk` / `.ldtkl`) documents. Both entry\n// points take `unknown` (the result of `JSON.parse`) and either return the same\n// value typed as `LdtkData` / `LdtkLevel`, or throw an {@link LdtkFormatError}\n// carrying the source URL and a JSON-path-like pointer to the offending value.\n//\n// Deliberately leaner than the Tiled adapter's `validate.ts`: it checks the\n// fields declared as required by this package's `LdtkData` model plus the\n// optional ones the adapter actually reads, and nothing else. Field-instance\n// `__value`s are checked against the shape their `__type` declares, because the\n// conversion pass casts rather than probes; a `__type` this package does not\n// model is left alone so a future LDtk field type still loads.\n//\n// Unlike the Tiled validator, this one asserts in place and hands the caller\n// back the very object it was given rather than rebuilding a normalised copy.\n// That keeps `LdtkMap.data` byte-for-byte what LDtk wrote, matching the\n// \"unknown fields are not stripped at parse time\" contract documented on\n// `LdtkData`.\n\nimport type { LdtkData, LdtkLayerType, LdtkLevel, LdtkWorldLayout } from './LdtkData';\n\n/**\n * Thrown when an LDtk JSON document does not match the expected shape.\n * `source` is the URL of the file being parsed; `path` is a JSON-path-like\n * pointer (e.g. `levels[0].layerInstances[1].gridTiles[0].px`) to the\n * offending value, or `''` for the document root.\n */\nexport class LdtkFormatError extends Error {\n public readonly source: string;\n public readonly path: string;\n\n public constructor(source: string, path: string, message: string) {\n super(`Invalid LDtk data in \"${source}\" at ${path === '' ? '<root>' : path}: ${message}`);\n this.name = 'LdtkFormatError';\n this.source = source;\n this.path = path;\n }\n}\n\n// ── Primitive helpers ────────────────────────────────────────────────────────\n\nconst describeValue = (value: unknown): string => {\n if (value === null) return 'null';\n if (value === undefined) return 'undefined';\n if (Array.isArray(value)) return 'an array';\n return typeof value;\n};\n\nconst joinPath = (path: string, key: string | number): string => {\n if (typeof key === 'number') return `${path}[${key}]`;\n return path === '' ? key : `${path}.${key}`;\n};\n\nconst expectObject = (value: unknown, source: string, path: string): Record<string, unknown> => {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n throw new LdtkFormatError(source, path, `expected an object, got ${describeValue(value)}`);\n }\n return value as Record<string, unknown>;\n};\n\nconst expectArray = (value: unknown, source: string, path: string): readonly unknown[] => {\n if (!Array.isArray(value)) {\n throw new LdtkFormatError(source, path, `expected an array, got ${describeValue(value)}`);\n }\n return value as readonly unknown[];\n};\n\nconst expectString = (value: unknown, source: string, path: string): string => {\n if (typeof value !== 'string') {\n throw new LdtkFormatError(source, path, `expected a string, got ${describeValue(value)}`);\n }\n return value;\n};\n\nconst expectNumber = (value: unknown, source: string, path: string): number => {\n if (typeof value !== 'number' || !Number.isFinite(value)) {\n throw new LdtkFormatError(source, path, `expected a finite number, got ${describeValue(value)}`);\n }\n return value;\n};\n\nconst expectInteger = (value: unknown, source: string, path: string): number => {\n const n = expectNumber(value, source, path);\n if (!Number.isInteger(n)) {\n throw new LdtkFormatError(source, path, `expected an integer, got ${n}`);\n }\n return n;\n};\n\nconst expectNonNegativeInteger = (value: unknown, source: string, path: string): number => {\n const n = expectInteger(value, source, path);\n if (n < 0) {\n throw new LdtkFormatError(source, path, `expected a non-negative integer, got ${n}`);\n }\n return n;\n};\n\nconst expectPositiveInteger = (value: unknown, source: string, path: string): number => {\n const n = expectInteger(value, source, path);\n if (n <= 0) {\n throw new LdtkFormatError(source, path, `expected a positive integer, got ${n}`);\n }\n return n;\n};\n\nconst expectBoolean = (value: unknown, source: string, path: string): void => {\n if (typeof value !== 'boolean') {\n throw new LdtkFormatError(source, path, `expected a boolean, got ${describeValue(value)}`);\n }\n};\n\n/** `[x, y]` pixel/grid pairs (`px`, `src`, `__pivot`) are always two finite numbers. */\nconst expectNumberPair = (value: unknown, source: string, path: string): void => {\n const pair = expectArray(value, source, path);\n if (pair.length !== 2) {\n throw new LdtkFormatError(source, path, `expected a pair of numbers, got ${pair.length} entries`);\n }\n expectNumber(pair[0], source, joinPath(path, 0));\n expectNumber(pair[1], source, joinPath(path, 1));\n};\n\nconst optionalNumber = (obj: Record<string, unknown>, key: string, source: string, path: string): void => {\n if (obj[key] !== undefined) expectNumber(obj[key], source, joinPath(path, key));\n};\n\nconst optionalNonNegativeInteger = (obj: Record<string, unknown>, key: string, source: string, path: string): void => {\n if (obj[key] !== undefined) expectNonNegativeInteger(obj[key], source, joinPath(path, key));\n};\n\n/**\n * LDtk writes an unset optional as an explicit `null` rather than omitting the\n * key, so a validator that only tolerates `undefined` rejects the files the\n * editor actually produces.\n */\nconst nullableString = (obj: Record<string, unknown>, key: string, source: string, path: string): void => {\n if (obj[key] !== undefined && obj[key] !== null) expectString(obj[key], source, joinPath(path, key));\n};\n\n/** See {@link nullableString}. */\nconst nullableInteger = (obj: Record<string, unknown>, key: string, source: string, path: string): void => {\n if (obj[key] !== undefined && obj[key] !== null) expectInteger(obj[key], source, joinPath(path, key));\n};\n\nconst optionalBoolean = (obj: Record<string, unknown>, key: string, source: string, path: string): void => {\n if (obj[key] !== undefined) expectBoolean(obj[key], source, joinPath(path, key));\n};\n\nconst eachEntry = (value: unknown, source: string, path: string, visit: (item: unknown, itemPath: string) => void): void => {\n const array = expectArray(value, source, path);\n for (let i = 0; i < array.length; i++) {\n visit(array[i], joinPath(path, i));\n }\n};\n\n// ── Definitions ──────────────────────────────────────────────────────────────\n\nconst LAYER_TYPES: readonly LdtkLayerType[] = ['Tiles', 'IntGrid', 'Entities', 'AutoLayer'];\nconst WORLD_LAYOUTS: readonly LdtkWorldLayout[] = ['Free', 'GridVania', 'LinearHorizontal', 'LinearVertical'];\n\nconst validateLayerType = (value: unknown, source: string, path: string): void => {\n const type = expectString(value, source, path);\n if (!LAYER_TYPES.includes(type as LdtkLayerType)) {\n throw new LdtkFormatError(source, path, `unknown layer type \"${type}\" (expected one of ${LAYER_TYPES.join(', ')})`);\n }\n};\n\nconst validateTilesetDef = (raw: unknown, source: string, path: string): void => {\n const def = expectObject(raw, source, path);\n\n expectInteger(def.uid, source, joinPath(path, 'uid'));\n expectString(def.identifier, source, joinPath(path, 'identifier'));\n\n // `relPath` is null for an embedded (\"embed atlas\") tileset, which the loader\n // skips - anything other than a string or null is malformed.\n const relPathPath = joinPath(path, 'relPath');\n if (def.relPath !== null) expectString(def.relPath, source, relPathPath);\n\n // A zero or negative grid size would make the loader's column arithmetic\n // divide by zero and yield a non-finite tile count.\n expectPositiveInteger(def.tileGridSize, source, joinPath(path, 'tileGridSize'));\n expectNonNegativeInteger(def.pxWid, source, joinPath(path, 'pxWid'));\n expectNonNegativeInteger(def.pxHei, source, joinPath(path, 'pxHei'));\n optionalNonNegativeInteger(def, 'spacing', source, path);\n optionalNonNegativeInteger(def, 'padding', source, path);\n};\n\nconst validateIntGridValueDef = (raw: unknown, source: string, path: string): void => {\n const value = expectObject(raw, source, path);\n\n expectNumber(value.value, source, joinPath(path, 'value'));\n const identifierPath = joinPath(path, 'identifier');\n if (value.identifier !== null) expectString(value.identifier, source, identifierPath);\n expectString(value.color, source, joinPath(path, 'color'));\n};\n\nconst validateLayerDef = (raw: unknown, source: string, path: string): void => {\n const def = expectObject(raw, source, path);\n\n expectInteger(def.uid, source, joinPath(path, 'uid'));\n expectString(def.identifier, source, joinPath(path, 'identifier'));\n validateLayerType(def.type, source, joinPath(path, 'type'));\n expectNonNegativeInteger(def.gridSize, source, joinPath(path, 'gridSize'));\n optionalNumber(def, 'pxOffsetX', source, path);\n optionalNumber(def, 'pxOffsetY', source, path);\n optionalNumber(def, 'parallaxFactorX', source, path);\n optionalNumber(def, 'parallaxFactorY', source, path);\n optionalBoolean(def, 'parallaxScaling', source, path);\n\n if (def.intGridValues !== undefined) {\n eachEntry(def.intGridValues, source, joinPath(path, 'intGridValues'), (item, itemPath) => validateIntGridValueDef(item, source, itemPath));\n }\n};\n\nconst validateDefs = (raw: unknown, source: string, path: string): void => {\n const defs = expectObject(raw, source, path);\n\n eachEntry(defs.tilesets, source, joinPath(path, 'tilesets'), (item, itemPath) => validateTilesetDef(item, source, itemPath));\n eachEntry(defs.layers, source, joinPath(path, 'layers'), (item, itemPath) => validateLayerDef(item, source, itemPath));\n};\n\n// ── Instances ────────────────────────────────────────────────────────────────\n\n/**\n * Validate one field-instance `__value` against the shape its `__type` declares.\n *\n * `null` is LDtk's \"not set\" and always passes - the conversion drops the\n * property. Everything else is checked here because the conversion pass casts\n * rather than probes: a `Point` whose value is not `{cx, cy}` used to reach the\n * runtime as a point with `undefined` coordinates, indistinguishable from a\n * genuine one until something read it.\n *\n * A `__type` this package does not model (a future LDtk field type, or an\n * `Array<T>` element type of one) is left unchecked: forward compatibility\n * matters more than rejecting a value the conversion already skips.\n */\nconst validateFieldValue = (typeName: string, value: unknown, source: string, path: string): void => {\n if (value === null || value === undefined) return;\n\n switch (typeName) {\n case 'Int':\n expectInteger(value, source, path);\n return;\n\n case 'Float':\n expectNumber(value, source, path);\n return;\n\n case 'Bool':\n expectBoolean(value, source, path);\n return;\n\n case 'String':\n case 'Multilines':\n case 'Color':\n case 'FilePath':\n case 'Enum':\n expectString(value, source, path);\n return;\n\n case 'Point': {\n const point = expectObject(value, source, path);\n\n expectNumber(point.cx, source, joinPath(path, 'cx'));\n expectNumber(point.cy, source, joinPath(path, 'cy'));\n\n return;\n }\n\n case 'EntityRef': {\n const ref = expectObject(value, source, path);\n\n for (const key of ['entityIid', 'layerIid', 'levelIid', 'worldIid'] as const) {\n expectString(ref[key], source, joinPath(path, key));\n }\n\n return;\n }\n\n case 'Tile': {\n const tile = expectObject(value, source, path);\n\n expectInteger(tile.tilesetUid, source, joinPath(path, 'tilesetUid'));\n\n for (const key of ['x', 'y', 'w', 'h'] as const) {\n expectNumber(tile[key], source, joinPath(path, key));\n }\n\n return;\n }\n\n default:\n if (typeName.startsWith('Array<') && typeName.endsWith('>')) {\n const elementType = typeName.slice('Array<'.length, -1);\n\n eachEntry(value, source, path, (item, itemPath) => validateFieldValue(elementType, item, source, itemPath));\n }\n }\n};\n\n/**\n * A field instance is validated down to its identifier, declared type and the\n * shape of `__value` that type implies - see {@link validateFieldValue}.\n */\nconst validateFieldInstance = (raw: unknown, source: string, path: string): void => {\n const field = expectObject(raw, source, path);\n\n expectString(field.__identifier, source, joinPath(path, '__identifier'));\n\n const typeName = expectString(field.__type, source, joinPath(path, '__type'));\n\n validateFieldValue(typeName, field.__value, source, joinPath(path, '__value'));\n};\n\nconst validateFieldInstances = (value: unknown, source: string, path: string): void => {\n eachEntry(value, source, path, (item, itemPath) => validateFieldInstance(item, source, itemPath));\n};\n\nconst validateTile = (raw: unknown, source: string, path: string): void => {\n const tile = expectObject(raw, source, path);\n\n expectNumberPair(tile.px, source, joinPath(path, 'px'));\n expectNumberPair(tile.src, source, joinPath(path, 'src'));\n expectNumber(tile.f, source, joinPath(path, 'f'));\n expectNumber(tile.t, source, joinPath(path, 't'));\n};\n\nconst validateTiles = (value: unknown, source: string, path: string): void => {\n eachEntry(value, source, path, (item, itemPath) => validateTile(item, source, itemPath));\n};\n\nconst validateEntityInstance = (raw: unknown, source: string, path: string): void => {\n const entity = expectObject(raw, source, path);\n\n expectString(entity.__identifier, source, joinPath(path, '__identifier'));\n expectString(entity.__type, source, joinPath(path, '__type'));\n expectNumberPair(entity.px, source, joinPath(path, 'px'));\n expectNumber(entity.width, source, joinPath(path, 'width'));\n expectNumber(entity.height, source, joinPath(path, 'height'));\n expectNumberPair(entity.__pivot, source, joinPath(path, '__pivot'));\n expectString(entity.iid, source, joinPath(path, 'iid'));\n expectInteger(entity.defUid, source, joinPath(path, 'defUid'));\n validateFieldInstances(entity.fieldInstances, source, joinPath(path, 'fieldInstances'));\n};\n\nconst validateLayerInstance = (raw: unknown, source: string, path: string): void => {\n const layer = expectObject(raw, source, path);\n\n expectString(layer.__identifier, source, joinPath(path, '__identifier'));\n validateLayerType(layer.__type, source, joinPath(path, '__type'));\n expectNonNegativeInteger(layer.__cWid, source, joinPath(path, '__cWid'));\n expectNonNegativeInteger(layer.__cHei, source, joinPath(path, '__cHei'));\n expectNonNegativeInteger(layer.__gridSize, source, joinPath(path, '__gridSize'));\n expectInteger(layer.layerDefUid, source, joinPath(path, 'layerDefUid'));\n expectInteger(layer.levelId, source, joinPath(path, 'levelId'));\n expectBoolean(layer.visible, source, joinPath(path, 'visible'));\n expectString(layer.iid, source, joinPath(path, 'iid'));\n\n nullableInteger(layer, '__tilesetDefUid', source, path);\n if (layer.gridTiles !== undefined) {\n validateTiles(layer.gridTiles, source, joinPath(path, 'gridTiles'));\n }\n if (layer.autoLayerTiles !== undefined) {\n validateTiles(layer.autoLayerTiles, source, joinPath(path, 'autoLayerTiles'));\n }\n if (layer.entityInstances !== undefined) {\n eachEntry(layer.entityInstances, source, joinPath(path, 'entityInstances'), (item, itemPath) => validateEntityInstance(item, source, itemPath));\n }\n if (layer.intGridCsv !== undefined) {\n eachEntry(layer.intGridCsv, source, joinPath(path, 'intGridCsv'), (item, itemPath) => expectNumber(item, source, itemPath));\n }\n optionalNumber(layer, 'pxOffsetX', source, path);\n optionalNumber(layer, 'pxOffsetY', source, path);\n optionalNumber(layer, 'opacity', source, path);\n};\n\nconst validateLevel = (raw: unknown, source: string, path: string): void => {\n const level = expectObject(raw, source, path);\n\n expectString(level.identifier, source, joinPath(path, 'identifier'));\n expectInteger(level.uid, source, joinPath(path, 'uid'));\n expectString(level.iid, source, joinPath(path, 'iid'));\n expectNumber(level.worldX, source, joinPath(path, 'worldX'));\n expectNumber(level.worldY, source, joinPath(path, 'worldY'));\n expectNumber(level.pxWid, source, joinPath(path, 'pxWid'));\n expectNumber(level.pxHei, source, joinPath(path, 'pxHei'));\n nullableString(level, 'externalRelPath', source, path);\n\n // Same explicit-null rule as the fields above: an isolated level can arrive\n // with a null here rather than an empty array.\n if (level.__neighbours !== undefined && level.__neighbours !== null) {\n eachEntry(level.__neighbours, source, joinPath(path, '__neighbours'), (item, itemPath) => {\n const neighbour = expectObject(item, source, itemPath);\n expectString(neighbour.levelIid, source, joinPath(itemPath, 'levelIid'));\n expectString(neighbour.dir, source, joinPath(itemPath, 'dir'));\n });\n }\n\n if (level.fieldInstances !== undefined) {\n validateFieldInstances(level.fieldInstances, source, joinPath(path, 'fieldInstances'));\n }\n\n // `null` marks a level whose layers live in a separate `.ldtkl` file; the\n // loader resolves those before conversion.\n const layerInstancesPath = joinPath(path, 'layerInstances');\n if (level.layerInstances !== null) {\n eachEntry(level.layerInstances, source, layerInstancesPath, (item, itemPath) => validateLayerInstance(item, source, itemPath));\n }\n};\n\nconst validateWorld = (raw: unknown, source: string, path: string): void => {\n const world = expectObject(raw, source, path);\n\n expectString(world.identifier, source, joinPath(path, 'identifier'));\n expectString(world.iid, source, joinPath(path, 'iid'));\n expectNumber(world.worldGridWidth, source, joinPath(path, 'worldGridWidth'));\n expectNumber(world.worldGridHeight, source, joinPath(path, 'worldGridHeight'));\n\n const layoutPath = joinPath(path, 'worldLayout');\n if (world.worldLayout !== null) {\n const layout = expectString(world.worldLayout, source, layoutPath);\n if (!WORLD_LAYOUTS.includes(layout as LdtkWorldLayout)) {\n throw new LdtkFormatError(source, layoutPath, `unknown world layout \"${layout}\" (expected one of ${WORLD_LAYOUTS.join(', ')} or null)`);\n }\n }\n\n eachEntry(world.levels, source, joinPath(path, 'levels'), (item, itemPath) => validateLevel(item, source, itemPath));\n};\n\n// ── Entry points ─────────────────────────────────────────────────────────────\n\n/**\n * Validate the root of a `.ldtk` file and return it typed as {@link LdtkData}.\n * Throws {@link LdtkFormatError} on any structural problem, naming the source\n * URL and the property path of the offending value.\n * @internal\n */\nexport const validateLdtkData = (raw: unknown, source: string): LdtkData => {\n const root = expectObject(raw, source, '');\n\n expectString(root.jsonVersion, source, 'jsonVersion');\n optionalNumber(root, 'defaultGridSize', source, '');\n validateDefs(root.defs, source, 'defs');\n\n // Both root shapes carry `levels`: it holds every level in a single-world\n // document and is present-but-empty once `worlds[]` is used.\n eachEntry(root.levels, source, 'levels', (item, itemPath) => validateLevel(item, source, itemPath));\n\n if (root.worlds !== undefined) {\n eachEntry(root.worlds, source, 'worlds', (item, itemPath) => validateWorld(item, source, itemPath));\n }\n\n return raw as LdtkData;\n};\n\n/**\n * Validate an external `.ldtkl` payload and return it typed as\n * {@link LdtkLevel}. Paths in a thrown {@link LdtkFormatError} are relative to\n * the level object, since that object is the root of the `.ldtkl` file.\n * @internal\n */\nexport const validateLdtkLevelData = (raw: unknown, source: string): LdtkLevel => {\n validateLevel(raw, source, '');\n\n return raw as LdtkLevel;\n};\n"],"mappings":";;;;;;;AA0BA,IAAa,kBAAb,cAAqC,MAAM;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c,MAAM,QAAQ,QAAQ,CAAC;CAElG,IAAI,KAAK,WAAW,QAClB,UAAU,KAAK,QAAQ,QAAQ,WAAW,MAAM,aAAa,cAAc,MAAM,QAAQ,QAAQ,CAAC;CAGpG,OAAO;AACT;;;;;;;AAQA,MAAa,yBAAyB,KAAc,WAA8B;CAChF,cAAc,KAAK,QAAQ,EAAE;CAE7B,OAAO;AACT"}
1
+ {"version":3,"file":"validate.js","names":[],"sources":["../../src/validate.ts"],"sourcesContent":["// Runtime validation for LDtk JSON (`.ldtk` / `.ldtkl`) documents. Both entry\n// points take `unknown` (the result of `JSON.parse`) and either return the same\n// value typed as `LdtkData` / `LdtkLevel`, or throw an {@link LdtkFormatError}\n// carrying the source URL and a JSON-path-like pointer to the offending value.\n//\n// Deliberately leaner than the Tiled adapter's `validate.ts`: it checks the\n// fields declared as required by this package's `LdtkData` model plus the\n// optional ones the adapter actually reads, and nothing else. Field-instance\n// `__value`s are checked against the shape their `__type` declares, because the\n// conversion pass casts rather than probes; a `__type` this package does not\n// model is left alone so a future LDtk field type still loads.\n//\n// Unlike the Tiled validator, this one asserts in place and hands the caller\n// back the very object it was given rather than rebuilding a normalised copy.\n// That keeps `LdtkMap.data` byte-for-byte what LDtk wrote, matching the\n// \"unknown fields are not stripped at parse time\" contract documented on\n// `LdtkData`.\n\nimport type { LdtkData, LdtkLayerType, LdtkLevel, LdtkWorldLayout } from './LdtkData';\nimport { isLdtkFieldEnumType } from './LdtkData';\n\n/**\n * Thrown when an LDtk JSON document does not match the expected shape.\n * `source` is the URL of the file being parsed; `path` is a JSON-path-like\n * pointer (e.g. `levels[0].layerInstances[1].gridTiles[0].px`) to the\n * offending value, or `''` for the document root.\n */\nexport class LdtkFormatError extends Error {\n public readonly source: string;\n public readonly path: string;\n\n public constructor(source: string, path: string, message: string) {\n super(`Invalid LDtk data in \"${source}\" at ${path === '' ? '<root>' : path}: ${message}`);\n this.name = 'LdtkFormatError';\n this.source = source;\n this.path = path;\n }\n}\n\n// ── Primitive helpers ────────────────────────────────────────────────────────\n\nconst describeValue = (value: unknown): string => {\n if (value === null) return 'null';\n if (value === undefined) return 'undefined';\n if (Array.isArray(value)) return 'an array';\n return typeof value;\n};\n\nconst joinPath = (path: string, key: string | number): string => {\n if (typeof key === 'number') return `${path}[${key}]`;\n return path === '' ? key : `${path}.${key}`;\n};\n\nconst expectObject = (value: unknown, source: string, path: string): Record<string, unknown> => {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n throw new LdtkFormatError(source, path, `expected an object, got ${describeValue(value)}`);\n }\n return value as Record<string, unknown>;\n};\n\nconst expectArray = (value: unknown, source: string, path: string): readonly unknown[] => {\n if (!Array.isArray(value)) {\n throw new LdtkFormatError(source, path, `expected an array, got ${describeValue(value)}`);\n }\n return value as readonly unknown[];\n};\n\nconst expectString = (value: unknown, source: string, path: string): string => {\n if (typeof value !== 'string') {\n throw new LdtkFormatError(source, path, `expected a string, got ${describeValue(value)}`);\n }\n return value;\n};\n\nconst expectNumber = (value: unknown, source: string, path: string): number => {\n if (typeof value !== 'number' || !Number.isFinite(value)) {\n throw new LdtkFormatError(source, path, `expected a finite number, got ${describeValue(value)}`);\n }\n return value;\n};\n\nconst expectInteger = (value: unknown, source: string, path: string): number => {\n const n = expectNumber(value, source, path);\n if (!Number.isInteger(n)) {\n throw new LdtkFormatError(source, path, `expected an integer, got ${n}`);\n }\n return n;\n};\n\nconst expectNonNegativeInteger = (value: unknown, source: string, path: string): number => {\n const n = expectInteger(value, source, path);\n if (n < 0) {\n throw new LdtkFormatError(source, path, `expected a non-negative integer, got ${n}`);\n }\n return n;\n};\n\nconst expectPositiveInteger = (value: unknown, source: string, path: string): number => {\n const n = expectInteger(value, source, path);\n if (n <= 0) {\n throw new LdtkFormatError(source, path, `expected a positive integer, got ${n}`);\n }\n return n;\n};\n\nconst expectBoolean = (value: unknown, source: string, path: string): void => {\n if (typeof value !== 'boolean') {\n throw new LdtkFormatError(source, path, `expected a boolean, got ${describeValue(value)}`);\n }\n};\n\n/** `[x, y]` pixel/grid pairs (`px`, `src`, `__pivot`) are always two finite numbers. */\nconst expectNumberPair = (value: unknown, source: string, path: string): void => {\n const pair = expectArray(value, source, path);\n if (pair.length !== 2) {\n throw new LdtkFormatError(source, path, `expected a pair of numbers, got ${pair.length} entries`);\n }\n expectNumber(pair[0], source, joinPath(path, 0));\n expectNumber(pair[1], source, joinPath(path, 1));\n};\n\nconst optionalNumber = (obj: Record<string, unknown>, key: string, source: string, path: string): void => {\n if (obj[key] !== undefined) expectNumber(obj[key], source, joinPath(path, key));\n};\n\nconst optionalNonNegativeInteger = (obj: Record<string, unknown>, key: string, source: string, path: string): void => {\n if (obj[key] !== undefined) expectNonNegativeInteger(obj[key], source, joinPath(path, key));\n};\n\n/**\n * LDtk writes an unset optional as an explicit `null` rather than omitting the\n * key, so a validator that only tolerates `undefined` rejects the files the\n * editor actually produces.\n */\nconst nullableString = (obj: Record<string, unknown>, key: string, source: string, path: string): void => {\n if (obj[key] !== undefined && obj[key] !== null) expectString(obj[key], source, joinPath(path, key));\n};\n\n/** See {@link nullableString}. */\nconst nullableInteger = (obj: Record<string, unknown>, key: string, source: string, path: string): void => {\n if (obj[key] !== undefined && obj[key] !== null) expectInteger(obj[key], source, joinPath(path, key));\n};\n\nconst optionalBoolean = (obj: Record<string, unknown>, key: string, source: string, path: string): void => {\n if (obj[key] !== undefined) expectBoolean(obj[key], source, joinPath(path, key));\n};\n\nconst eachEntry = (value: unknown, source: string, path: string, visit: (item: unknown, itemPath: string) => void): void => {\n const array = expectArray(value, source, path);\n for (let i = 0; i < array.length; i++) {\n visit(array[i], joinPath(path, i));\n }\n};\n\n// ── Definitions ──────────────────────────────────────────────────────────────\n\nconst LAYER_TYPES: readonly LdtkLayerType[] = ['Tiles', 'IntGrid', 'Entities', 'AutoLayer'];\nconst WORLD_LAYOUTS: readonly LdtkWorldLayout[] = ['Free', 'GridVania', 'LinearHorizontal', 'LinearVertical'];\n\nconst validateLayerType = (value: unknown, source: string, path: string): void => {\n const type = expectString(value, source, path);\n if (!LAYER_TYPES.includes(type as LdtkLayerType)) {\n throw new LdtkFormatError(source, path, `unknown layer type \"${type}\" (expected one of ${LAYER_TYPES.join(', ')})`);\n }\n};\n\nconst validateTilesetDef = (raw: unknown, source: string, path: string): void => {\n const def = expectObject(raw, source, path);\n\n expectInteger(def.uid, source, joinPath(path, 'uid'));\n expectString(def.identifier, source, joinPath(path, 'identifier'));\n\n // `relPath` is null for an embedded (\"embed atlas\") tileset, which the loader\n // skips - anything other than a string or null is malformed.\n const relPathPath = joinPath(path, 'relPath');\n if (def.relPath !== null) expectString(def.relPath, source, relPathPath);\n\n // A zero or negative grid size would make the loader's column arithmetic\n // divide by zero and yield a non-finite tile count.\n expectPositiveInteger(def.tileGridSize, source, joinPath(path, 'tileGridSize'));\n expectNonNegativeInteger(def.pxWid, source, joinPath(path, 'pxWid'));\n expectNonNegativeInteger(def.pxHei, source, joinPath(path, 'pxHei'));\n optionalNonNegativeInteger(def, 'spacing', source, path);\n optionalNonNegativeInteger(def, 'padding', source, path);\n};\n\nconst validateIntGridValueDef = (raw: unknown, source: string, path: string): void => {\n const value = expectObject(raw, source, path);\n\n expectNumber(value.value, source, joinPath(path, 'value'));\n const identifierPath = joinPath(path, 'identifier');\n if (value.identifier !== null) expectString(value.identifier, source, identifierPath);\n expectString(value.color, source, joinPath(path, 'color'));\n};\n\nconst validateLayerDef = (raw: unknown, source: string, path: string): void => {\n const def = expectObject(raw, source, path);\n\n expectInteger(def.uid, source, joinPath(path, 'uid'));\n expectString(def.identifier, source, joinPath(path, 'identifier'));\n validateLayerType(def.type, source, joinPath(path, 'type'));\n expectNonNegativeInteger(def.gridSize, source, joinPath(path, 'gridSize'));\n optionalNumber(def, 'pxOffsetX', source, path);\n optionalNumber(def, 'pxOffsetY', source, path);\n optionalNumber(def, 'parallaxFactorX', source, path);\n optionalNumber(def, 'parallaxFactorY', source, path);\n optionalBoolean(def, 'parallaxScaling', source, path);\n\n if (def.intGridValues !== undefined) {\n eachEntry(def.intGridValues, source, joinPath(path, 'intGridValues'), (item, itemPath) => validateIntGridValueDef(item, source, itemPath));\n }\n};\n\nconst validateDefs = (raw: unknown, source: string, path: string): void => {\n const defs = expectObject(raw, source, path);\n\n eachEntry(defs.tilesets, source, joinPath(path, 'tilesets'), (item, itemPath) => validateTilesetDef(item, source, itemPath));\n eachEntry(defs.layers, source, joinPath(path, 'layers'), (item, itemPath) => validateLayerDef(item, source, itemPath));\n};\n\n// ── Instances ────────────────────────────────────────────────────────────────\n\n/**\n * Validate one field-instance `__value` against the shape its `__type` declares.\n *\n * `null` is LDtk's \"not set\" and always passes - the conversion drops the\n * property. Everything else is checked here because the conversion pass casts\n * rather than probes: a `Point` whose value is not `{cx, cy}` used to reach the\n * runtime as a point with `undefined` coordinates, indistinguishable from a\n * genuine one until something read it.\n *\n * A `__type` this package does not model (a future LDtk field type, or an\n * `Array<T>` element type of one) is left unchecked here: the conversion pass\n * is where an unsupported type is reported, and it names the type.\n */\nconst validateFieldValue = (typeName: string, value: unknown, source: string, path: string): void => {\n if (value === null || value === undefined) return;\n\n // `LocalEnum.X` / `ExternEnum.X` - the selected entry's identifier.\n if (isLdtkFieldEnumType(typeName)) {\n expectString(value, source, path);\n\n return;\n }\n\n switch (typeName) {\n case 'Int':\n expectInteger(value, source, path);\n return;\n\n case 'Float':\n expectNumber(value, source, path);\n return;\n\n case 'Bool':\n expectBoolean(value, source, path);\n return;\n\n case 'String':\n case 'Multilines':\n case 'Color':\n case 'FilePath':\n case 'Enum':\n expectString(value, source, path);\n return;\n\n case 'Point': {\n const point = expectObject(value, source, path);\n\n expectNumber(point.cx, source, joinPath(path, 'cx'));\n expectNumber(point.cy, source, joinPath(path, 'cy'));\n\n return;\n }\n\n case 'EntityRef': {\n const ref = expectObject(value, source, path);\n\n for (const key of ['entityIid', 'layerIid', 'levelIid', 'worldIid'] as const) {\n expectString(ref[key], source, joinPath(path, key));\n }\n\n return;\n }\n\n case 'Tile': {\n const tile = expectObject(value, source, path);\n\n expectInteger(tile.tilesetUid, source, joinPath(path, 'tilesetUid'));\n\n for (const key of ['x', 'y', 'w', 'h'] as const) {\n expectNumber(tile[key], source, joinPath(path, key));\n }\n\n return;\n }\n\n default:\n if (typeName.startsWith('Array<') && typeName.endsWith('>')) {\n const elementType = typeName.slice('Array<'.length, -1);\n\n eachEntry(value, source, path, (item, itemPath) => validateFieldValue(elementType, item, source, itemPath));\n }\n }\n};\n\n/**\n * A field instance is validated down to its identifier, declared type and the\n * shape of `__value` that type implies - see {@link validateFieldValue}.\n */\nconst validateFieldInstance = (raw: unknown, source: string, path: string): void => {\n const field = expectObject(raw, source, path);\n\n expectString(field.__identifier, source, joinPath(path, '__identifier'));\n\n const typeName = expectString(field.__type, source, joinPath(path, '__type'));\n\n validateFieldValue(typeName, field.__value, source, joinPath(path, '__value'));\n};\n\nconst validateFieldInstances = (value: unknown, source: string, path: string): void => {\n eachEntry(value, source, path, (item, itemPath) => validateFieldInstance(item, source, itemPath));\n};\n\nconst validateTile = (raw: unknown, source: string, path: string): void => {\n const tile = expectObject(raw, source, path);\n\n expectNumberPair(tile.px, source, joinPath(path, 'px'));\n expectNumberPair(tile.src, source, joinPath(path, 'src'));\n expectNumber(tile.f, source, joinPath(path, 'f'));\n expectNumber(tile.t, source, joinPath(path, 't'));\n};\n\nconst validateTiles = (value: unknown, source: string, path: string): void => {\n eachEntry(value, source, path, (item, itemPath) => validateTile(item, source, itemPath));\n};\n\nconst validateEntityInstance = (raw: unknown, source: string, path: string): void => {\n const entity = expectObject(raw, source, path);\n\n expectString(entity.__identifier, source, joinPath(path, '__identifier'));\n expectString(entity.__type, source, joinPath(path, '__type'));\n expectNumberPair(entity.px, source, joinPath(path, 'px'));\n expectNumber(entity.width, source, joinPath(path, 'width'));\n expectNumber(entity.height, source, joinPath(path, 'height'));\n expectNumberPair(entity.__pivot, source, joinPath(path, '__pivot'));\n expectString(entity.iid, source, joinPath(path, 'iid'));\n expectInteger(entity.defUid, source, joinPath(path, 'defUid'));\n validateFieldInstances(entity.fieldInstances, source, joinPath(path, 'fieldInstances'));\n};\n\nconst validateLayerInstance = (raw: unknown, source: string, path: string): void => {\n const layer = expectObject(raw, source, path);\n\n expectString(layer.__identifier, source, joinPath(path, '__identifier'));\n validateLayerType(layer.__type, source, joinPath(path, '__type'));\n expectNonNegativeInteger(layer.__cWid, source, joinPath(path, '__cWid'));\n expectNonNegativeInteger(layer.__cHei, source, joinPath(path, '__cHei'));\n expectNonNegativeInteger(layer.__gridSize, source, joinPath(path, '__gridSize'));\n expectInteger(layer.layerDefUid, source, joinPath(path, 'layerDefUid'));\n expectInteger(layer.levelId, source, joinPath(path, 'levelId'));\n expectBoolean(layer.visible, source, joinPath(path, 'visible'));\n expectString(layer.iid, source, joinPath(path, 'iid'));\n\n nullableInteger(layer, '__tilesetDefUid', source, path);\n if (layer.gridTiles !== undefined) {\n validateTiles(layer.gridTiles, source, joinPath(path, 'gridTiles'));\n }\n if (layer.autoLayerTiles !== undefined) {\n validateTiles(layer.autoLayerTiles, source, joinPath(path, 'autoLayerTiles'));\n }\n if (layer.entityInstances !== undefined) {\n eachEntry(layer.entityInstances, source, joinPath(path, 'entityInstances'), (item, itemPath) => validateEntityInstance(item, source, itemPath));\n }\n if (layer.intGridCsv !== undefined) {\n eachEntry(layer.intGridCsv, source, joinPath(path, 'intGridCsv'), (item, itemPath) => expectNumber(item, source, itemPath));\n }\n optionalNumber(layer, 'pxOffsetX', source, path);\n optionalNumber(layer, 'pxOffsetY', source, path);\n optionalNumber(layer, 'opacity', source, path);\n};\n\nconst validateLevel = (raw: unknown, source: string, path: string): void => {\n const level = expectObject(raw, source, path);\n\n expectString(level.identifier, source, joinPath(path, 'identifier'));\n expectInteger(level.uid, source, joinPath(path, 'uid'));\n expectString(level.iid, source, joinPath(path, 'iid'));\n expectNumber(level.worldX, source, joinPath(path, 'worldX'));\n expectNumber(level.worldY, source, joinPath(path, 'worldY'));\n expectNumber(level.pxWid, source, joinPath(path, 'pxWid'));\n expectNumber(level.pxHei, source, joinPath(path, 'pxHei'));\n nullableString(level, 'externalRelPath', source, path);\n\n // Same explicit-null rule as the fields above: an isolated level can arrive\n // with a null here rather than an empty array.\n if (level.__neighbours !== undefined && level.__neighbours !== null) {\n eachEntry(level.__neighbours, source, joinPath(path, '__neighbours'), (item, itemPath) => {\n const neighbour = expectObject(item, source, itemPath);\n expectString(neighbour.levelIid, source, joinPath(itemPath, 'levelIid'));\n expectString(neighbour.dir, source, joinPath(itemPath, 'dir'));\n });\n }\n\n if (level.fieldInstances !== undefined) {\n validateFieldInstances(level.fieldInstances, source, joinPath(path, 'fieldInstances'));\n }\n\n // `null` marks a level whose layers live in a separate `.ldtkl` file; the\n // loader resolves those before conversion.\n const layerInstancesPath = joinPath(path, 'layerInstances');\n if (level.layerInstances !== null) {\n eachEntry(level.layerInstances, source, layerInstancesPath, (item, itemPath) => validateLayerInstance(item, source, itemPath));\n }\n};\n\nconst validateWorld = (raw: unknown, source: string, path: string): void => {\n const world = expectObject(raw, source, path);\n\n expectString(world.identifier, source, joinPath(path, 'identifier'));\n expectString(world.iid, source, joinPath(path, 'iid'));\n expectNumber(world.worldGridWidth, source, joinPath(path, 'worldGridWidth'));\n expectNumber(world.worldGridHeight, source, joinPath(path, 'worldGridHeight'));\n\n const layoutPath = joinPath(path, 'worldLayout');\n if (world.worldLayout !== null) {\n const layout = expectString(world.worldLayout, source, layoutPath);\n if (!WORLD_LAYOUTS.includes(layout as LdtkWorldLayout)) {\n throw new LdtkFormatError(source, layoutPath, `unknown world layout \"${layout}\" (expected one of ${WORLD_LAYOUTS.join(', ')} or null)`);\n }\n }\n\n eachEntry(world.levels, source, joinPath(path, 'levels'), (item, itemPath) => validateLevel(item, source, itemPath));\n};\n\n// ── Entry points ─────────────────────────────────────────────────────────────\n\n/**\n * Validate the root of a `.ldtk` file and return it typed as {@link LdtkData}.\n * Throws {@link LdtkFormatError} on any structural problem, naming the source\n * URL and the property path of the offending value.\n * @internal\n */\nexport const validateLdtkData = (raw: unknown, source: string): LdtkData => {\n const root = expectObject(raw, source, '');\n\n expectString(root.jsonVersion, source, 'jsonVersion');\n optionalNumber(root, 'defaultGridSize', source, '');\n validateDefs(root.defs, source, 'defs');\n\n // Both root shapes carry `levels`: it holds every level in a single-world\n // document and is present-but-empty once `worlds[]` is used.\n eachEntry(root.levels, source, 'levels', (item, itemPath) => validateLevel(item, source, itemPath));\n\n if (root.worlds !== undefined) {\n eachEntry(root.worlds, source, 'worlds', (item, itemPath) => validateWorld(item, source, itemPath));\n }\n\n return raw as LdtkData;\n};\n\n/**\n * Validate an external `.ldtkl` payload and return it typed as\n * {@link LdtkLevel}. Paths in a thrown {@link LdtkFormatError} are relative to\n * the level object, since that object is the root of the `.ldtkl` file.\n * @internal\n */\nexport const validateLdtkLevelData = (raw: unknown, source: string): LdtkLevel => {\n validateLevel(raw, source, '');\n\n return raw as LdtkLevel;\n};\n"],"mappings":";;;;;;;;;AA2BA,IAAa,kBAAb,cAAqC,MAAM;CACzC,AAAgB;CAChB,AAAgB;CAEhB,AAAO,YAAY,QAAgB,MAAc,SAAiB;EAChE,MAAM,yBAAyB,OAAO,OAAO,SAAS,KAAK,WAAW,KAAK,IAAI,SAAS;EACxF,KAAK,OAAO;EACZ,KAAK,SAAS;EACd,KAAK,OAAO;CACd;AACF;AAIA,MAAM,iBAAiB,UAA2B;CAChD,IAAI,UAAU,MAAM,OAAO;CAC3B,IAAI,UAAU,QAAW,OAAO;CAChC,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO;CACjC,OAAO,OAAO;AAChB;AAEA,MAAM,YAAY,MAAc,QAAiC;CAC/D,IAAI,OAAO,QAAQ,UAAU,OAAO,GAAG,KAAK,GAAG,IAAI;CACnD,OAAO,SAAS,KAAK,MAAM,GAAG,KAAK,GAAG;AACxC;AAEA,MAAM,gBAAgB,OAAgB,QAAgB,SAA0C;CAC9F,IAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,MAAM,QAAQ,KAAK,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AM,gBAAgB,CAAC;CAC3E,aAAa,MAAM,iBAAiB,QAAQ,SAAS,MAAM,iBAAiB,CAAC;CAE7E,MAAM,aAAa,SAAS,MAAM,aAAa;CAC/C,IAAI,MAAM,gBAAgB,MAAM;EAC9B,MAAM,SAAS,aAAa,MAAM,aAAa,QAAQ,UAAU;EACjE,IAAI,CAAC,cAAc,SAAS,MAAyB,GACnD,MAAM,IAAI,gBAAgB,QAAQ,YAAY,yBAAyB,OAAO,qBAAqB,cAAc,KAAK,IAAI,EAAE,UAAU;CAE1I;CAEA,UAAU,MAAM,QAAQ,QAAQ,SAAS,MAAM,QAAQ,IAAI,MAAM,aAAa,cAAc,MAAM,QAAQ,QAAQ,CAAC;AACrH;;;;;;;AAUA,MAAa,oBAAoB,KAAc,WAA6B;CAC1E,MAAM,OAAO,aAAa,KAAK,QAAQ,EAAE;CAEzC,aAAa,KAAK,aAAa,QAAQ,aAAa;CACpD,eAAe,MAAM,mBAAmB,QAAQ,EAAE;CAClD,aAAa,KAAK,MAAM,QAAQ,MAAM;CAItC,UAAU,KAAK,QAAQ,QAAQ,WAAW,MAAM,aAAa,cAAc,MAAM,QAAQ,QAAQ,CAAC;CAElG,IAAI,KAAK,WAAW,QAClB,UAAU,KAAK,QAAQ,QAAQ,WAAW,MAAM,aAAa,cAAc,MAAM,QAAQ,QAAQ,CAAC;CAGpG,OAAO;AACT;;;;;;;AAQA,MAAa,yBAAyB,KAAc,WAA8B;CAChF,cAAc,KAAK,QAAQ,EAAE;CAE7B,OAAO;AACT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codexo/exojs-ldtk",
3
- "version": "0.16.2",
3
+ "version": "0.18.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.16.x",
30
- "@codexo/exojs-tilemap": "0.16.x"
29
+ "@codexo/exojs": "0.18.x",
30
+ "@codexo/exojs-tilemap": "0.18.x"
31
31
  },
32
32
  "devDependencies": {
33
- "@codexo/exojs": "0.16.2",
33
+ "@codexo/exojs": "0.18.0",
34
34
  "@codexo/exojs-config": "0.0.0",
35
- "@codexo/exojs-tilemap": "0.16.2"
35
+ "@codexo/exojs-tilemap": "0.18.0"
36
36
  },
37
37
  "license": "MIT",
38
38
  "publishConfig": {