@codexo/exojs-ldtk 0.19.1 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/esm/LdtkData.d.ts +32 -2
- package/dist/esm/LdtkData.d.ts.map +1 -1
- package/dist/esm/LdtkData.js +1 -2
- package/dist/esm/LdtkData.js.map +1 -1
- package/dist/esm/LdtkMap.d.ts +4 -3
- package/dist/esm/LdtkMap.d.ts.map +1 -1
- package/dist/esm/LdtkMap.js +5 -5
- package/dist/esm/LdtkMap.js.map +1 -1
- package/dist/esm/LdtkProject.d.ts +12 -4
- package/dist/esm/LdtkProject.d.ts.map +1 -1
- package/dist/esm/LdtkProject.js +17 -8
- package/dist/esm/LdtkProject.js.map +1 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/ldtkExtension.d.ts +2 -2
- package/dist/esm/ldtkExtension.d.ts.map +1 -1
- package/dist/esm/ldtkExtension.js +4 -5
- package/dist/esm/ldtkExtension.js.map +1 -1
- package/dist/esm/ldtkLevelEntries.d.ts.map +1 -1
- package/dist/esm/ldtkLevelEntries.js +1 -2
- package/dist/esm/ldtkLevelEntries.js.map +1 -1
- package/dist/esm/ldtkParallax.d.ts.map +1 -1
- package/dist/esm/ldtkParallax.js +1 -2
- package/dist/esm/ldtkToMapWorld.d.ts +1 -1
- package/dist/esm/ldtkToMapWorld.d.ts.map +1 -1
- package/dist/esm/ldtkToMapWorld.js +2 -3
- package/dist/esm/ldtkToMapWorld.js.map +1 -1
- package/dist/esm/ldtkToTileMap.d.ts +9 -4
- package/dist/esm/ldtkToTileMap.d.ts.map +1 -1
- package/dist/esm/ldtkToTileMap.js +34 -14
- package/dist/esm/ldtkToTileMap.js.map +1 -1
- package/dist/esm/ldtkTypes.d.ts.map +1 -1
- package/dist/esm/ldtkTypes.js +1 -2
- package/dist/esm/loadLdtkMap.d.ts.map +1 -1
- package/dist/esm/loadLdtkMap.js +50 -9
- package/dist/esm/loadLdtkMap.js.map +1 -1
- package/dist/esm/loadLdtkProject.d.ts.map +1 -1
- package/dist/esm/loadLdtkProject.js +6 -5
- package/dist/esm/loadLdtkProject.js.map +1 -1
- package/dist/esm/public.d.ts +4 -4
- package/dist/esm/public.d.ts.map +1 -1
- package/dist/esm/public.js +1 -1
- package/dist/esm/url.d.ts.map +1 -1
- package/dist/esm/url.js +1 -2
- package/dist/esm/validate.d.ts.map +1 -1
- package/dist/esm/validate.js +18 -4
- package/dist/esm/validate.js.map +1 -1
- package/package.json +5 -7
package/README.md
CHANGED
|
@@ -5,15 +5,15 @@ Load LDtk projects into ExoJS's format-neutral tilemap and world runtime. Use an
|
|
|
5
5
|
## Install and activate
|
|
6
6
|
|
|
7
7
|
```sh
|
|
8
|
-
npm install --save-exact @codexo/exojs @codexo/exojs-
|
|
8
|
+
npm install --save-exact @codexo/exojs @codexo/exojs-ldtk
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
Core and the tilemap runtime
|
|
11
|
+
Core is a peer dependency and includes the tilemap runtime. `ldtkExtension` depends on `tilemapExtension`, so selecting the adapter installs both its loading capability and the generic tile renderer.
|
|
12
12
|
|
|
13
13
|
```ts
|
|
14
14
|
import { Application, Scene } from '@codexo/exojs';
|
|
15
15
|
import { ldtkExtension } from '@codexo/exojs-ldtk';
|
|
16
|
-
import { TileMapNode } from '@codexo/exojs
|
|
16
|
+
import { TileMapNode } from '@codexo/exojs/tilemap';
|
|
17
17
|
|
|
18
18
|
class LevelScene extends Scene {
|
|
19
19
|
override async load(): Promise<void> {
|
|
@@ -41,7 +41,7 @@ Serve the project and its referenced files beneath the asset base. Each LDtk lev
|
|
|
41
41
|
|
|
42
42
|
## Eager or streamed?
|
|
43
43
|
|
|
44
|
-
`ldtkMap` converts all levels up front. `
|
|
44
|
+
`ldtkMap` converts all levels up front. `{ type: 'ldtkProject', source: path }` exposes a world layout and a runtime that can acquire levels individually. External `.ldtkl` payloads are fetched when required; an embedded level's JSON is already part of the project document. Deferred conversion does not remove bytes that the initial document contains.
|
|
45
45
|
|
|
46
46
|
The project runtime supplies level ownership, not the game's streaming policy. Choose which levels to load, bound concurrency, and release their runtime handles when they are no longer needed. Use the Guide's failure and cancellation workflow rather than retaining non-null assertions against authored level names.
|
|
47
47
|
|
|
@@ -49,7 +49,7 @@ The project runtime supplies level ownership, not the game's streaming policy. C
|
|
|
49
49
|
|
|
50
50
|
Tile rendering, entity spawning, IntGrid collision, and pathfinding are separate uses of authored data. A visible layer does not create a physics body automatically. `createLdtkIntGridCellSource` exposes cell data for the tilemap-physics bridge when that is the intended collision source.
|
|
51
51
|
|
|
52
|
-
A loader-acquired map and its texture dependencies remain claim-owned. `LdtkMap.destroy()` releases its owned runtime maps, not arbitrary scene nodes or shared loader textures. Remove displaying nodes at their owner boundary and release asset claims through their scope. Import the format-neutral rendering nodes, including `TileMapNode`, from `@codexo/exojs
|
|
52
|
+
A loader-acquired map and its texture dependencies remain claim-owned. `LdtkMap.destroy()` releases its owned runtime maps, not arbitrary scene nodes or shared loader textures. Remove displaying nodes at their owner boundary and release asset claims through their scope. Import the format-neutral rendering nodes, including `TileMapNode`, from `@codexo/exojs/tilemap`; the adapter owns LDtk loading and conversion.
|
|
53
53
|
|
|
54
54
|
## Documentation
|
|
55
55
|
|
package/dist/esm/LdtkData.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @see https://ldtk.io/json/
|
|
9
9
|
*/
|
|
10
|
-
import type { TilePropertyPoint, TilePropertyTileRef } from '@codexo/exojs
|
|
10
|
+
import type { TilePropertyPoint, TilePropertyTileRef } from '@codexo/exojs/tilemap';
|
|
11
11
|
/** Flip-bit constants for {@link LdtkTileData.f}. */
|
|
12
12
|
export declare const LDTK_FLIP_NONE = 0;
|
|
13
13
|
export declare const LDTK_FLIP_X = 1;
|
|
@@ -128,6 +128,16 @@ export interface LdtkEntityInstance {
|
|
|
128
128
|
readonly iid: string;
|
|
129
129
|
/** UID of the entity definition this instance was created from. */
|
|
130
130
|
readonly defUid: number;
|
|
131
|
+
/** Tags of the entity definition, in editor order. */
|
|
132
|
+
readonly __tags?: readonly string[];
|
|
133
|
+
/** The tile the editor draws for this entity, as a rectangle in its tileset, or `null` when it has none. */
|
|
134
|
+
readonly __tile?: LdtkFieldTileValue | null;
|
|
135
|
+
/** World-space X of the entity's anchor ({@link px}) in pixels; `null` in worlds without a free or grid layout. */
|
|
136
|
+
readonly __worldX?: number | null;
|
|
137
|
+
/** World-space Y of the entity's anchor ({@link px}) in pixels; `null` in worlds without a free or grid layout. */
|
|
138
|
+
readonly __worldY?: number | null;
|
|
139
|
+
/** The entity's colour in the editor, `#rrggbb`. */
|
|
140
|
+
readonly __smartColor?: string;
|
|
131
141
|
}
|
|
132
142
|
/** Discriminant string for a layer instance type. */
|
|
133
143
|
export type LdtkLayerType = 'Tiles' | 'IntGrid' | 'Entities' | 'AutoLayer';
|
|
@@ -204,7 +214,10 @@ export interface LdtkLevel {
|
|
|
204
214
|
readonly pxWid: number;
|
|
205
215
|
/** Level height in pixels. */
|
|
206
216
|
readonly pxHei: number;
|
|
207
|
-
|
|
217
|
+
/** The level's own background colour, `#rrggbb`; `null` when it uses the project default. */
|
|
218
|
+
readonly bgColor?: string | null;
|
|
219
|
+
/** The background colour in effect, own or project default, `#rrggbb`. */
|
|
220
|
+
readonly __bgColor?: string;
|
|
208
221
|
/**
|
|
209
222
|
* Layer instances in this level (top-to-bottom render order).
|
|
210
223
|
* `null` when the level is stored in a separate `.ldtkl` file and has not
|
|
@@ -270,6 +283,20 @@ export interface LdtkTilesetDef {
|
|
|
270
283
|
readonly spacing?: number;
|
|
271
284
|
/** Pixel padding (margin) around the atlas edges. */
|
|
272
285
|
readonly padding?: number;
|
|
286
|
+
/** Free text attached to single tiles in the editor. */
|
|
287
|
+
readonly customData?: readonly LdtkTileCustomData[];
|
|
288
|
+
/** Enum values tagged on tiles in the editor, each with the ids of the tiles it marks. */
|
|
289
|
+
readonly enumTags?: readonly LdtkTileEnumTag[];
|
|
290
|
+
}
|
|
291
|
+
/** Text attached to one tile of an LDtk tileset. */
|
|
292
|
+
export interface LdtkTileCustomData {
|
|
293
|
+
readonly tileId: number;
|
|
294
|
+
readonly data: string;
|
|
295
|
+
}
|
|
296
|
+
/** One enum value tagged on tiles of an LDtk tileset. */
|
|
297
|
+
export interface LdtkTileEnumTag {
|
|
298
|
+
readonly enumValueId: string;
|
|
299
|
+
readonly tileIds: readonly number[];
|
|
273
300
|
}
|
|
274
301
|
/** An IntGrid value definition (maps a raw int to a named, coloured entry). */
|
|
275
302
|
export interface LdtkIntGridValueDef {
|
|
@@ -319,7 +346,10 @@ export interface LdtkData {
|
|
|
319
346
|
readonly worldGridWidth?: number;
|
|
320
347
|
readonly worldGridHeight?: number;
|
|
321
348
|
readonly defaultGridSize?: number;
|
|
349
|
+
/** Background colour of the editor workspace, `#rrggbb`; not a level colour. */
|
|
322
350
|
readonly bgColor?: string;
|
|
351
|
+
/** Background colour of levels that set none themselves, `#rrggbb`. */
|
|
352
|
+
readonly defaultLevelBgColor?: string;
|
|
323
353
|
readonly defs: LdtkDefs;
|
|
324
354
|
/**
|
|
325
355
|
* Levels not organised into worlds. Always populated for pre-multi-world
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LdtkData.d.ts","
|
|
1
|
+
{"version":3,"file":"LdtkData.d.ts","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,EAA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|
4
4
|
const LDTK_FLIP_X = 1;
|
|
@@ -10,6 +10,5 @@ const LDTK_FLIP_XY = 3;
|
|
|
10
10
|
*/
|
|
11
11
|
const isLdtkFieldEnumType = (typeName) => typeName.startsWith("LocalEnum.") || typeName.startsWith("ExternEnum.");
|
|
12
12
|
|
|
13
|
-
//#endregion
|
|
14
13
|
export { LDTK_FLIP_NONE, LDTK_FLIP_X, LDTK_FLIP_XY, LDTK_FLIP_Y, isLdtkFieldEnumType };
|
|
15
14
|
//# sourceMappingURL=LdtkData.js.map
|
package/dist/esm/LdtkData.js.map
CHANGED
|
@@ -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 * 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"}
|
|
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 =>\n 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 /** Tags of the entity definition, in editor order. */\n readonly __tags?: readonly string[];\n /** The tile the editor draws for this entity, as a rectangle in its tileset, or `null` when it has none. */\n readonly __tile?: LdtkFieldTileValue | null;\n /** World-space X of the entity's anchor ({@link px}) in pixels; `null` in worlds without a free or grid layout. */\n readonly __worldX?: number | null;\n /** World-space Y of the entity's anchor ({@link px}) in pixels; `null` in worlds without a free or grid layout. */\n readonly __worldY?: number | null;\n /** The entity's colour in the editor, `#rrggbb`. */\n readonly __smartColor?: string;\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 /** The level's own background colour, `#rrggbb`; `null` when it uses the project default. */\n readonly bgColor?: string | null;\n /** The background colour in effect, own or project default, `#rrggbb`. */\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 /** Free text attached to single tiles in the editor. */\n readonly customData?: readonly LdtkTileCustomData[];\n /** Enum values tagged on tiles in the editor, each with the ids of the tiles it marks. */\n readonly enumTags?: readonly LdtkTileEnumTag[];\n}\n\n/** Text attached to one tile of an LDtk tileset. */\nexport interface LdtkTileCustomData {\n readonly tileId: number;\n readonly data: string;\n}\n\n/** One enum value tagged on tiles of an LDtk tileset. */\nexport interface LdtkTileEnumTag {\n readonly enumValueId: string;\n readonly tileIds: readonly 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 /** Background colour of the editor workspace, `#rrggbb`; not a level colour. */\n readonly bgColor?: string;\n /** Background colour of levels that set none themselves, `#rrggbb`. */\n readonly defaultLevelBgColor?: 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,aAClC,SAAS,WAAW,YAAY,KAAK,SAAS,WAAW,aAAa"}
|
package/dist/esm/LdtkMap.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MapWorld, TileMap } from '@codexo/exojs
|
|
1
|
+
import type { MapWorld, TileMap } from '@codexo/exojs/tilemap';
|
|
2
2
|
import type { LdtkData } from './LdtkData';
|
|
3
3
|
/**
|
|
4
4
|
* A parsed LDtk world document: holds the raw JSON data and the converted
|
|
@@ -37,8 +37,9 @@ export declare class LdtkMap {
|
|
|
37
37
|
*
|
|
38
38
|
* This is metadata about *where* levels are, independent of the runtime maps
|
|
39
39
|
* in {@link levels}. Use it to navigate; use
|
|
40
|
-
* {@link import('./
|
|
41
|
-
*
|
|
40
|
+
* {@link import('./LdtkProject').LdtkProject} with
|
|
41
|
+
* {@link import('@codexo/exojs/tilemap').MapWorldRuntime} instead when levels
|
|
42
|
+
* should be loaded on demand rather than all at once.
|
|
42
43
|
*/
|
|
43
44
|
get worlds(): readonly MapWorld[];
|
|
44
45
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LdtkMap.d.ts","
|
|
1
|
+
{"version":3,"file":"LdtkMap.d.ts","sources":["../../src/LdtkMap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAE/D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAI3C;;;;;;;;;;;GAWG;AACH,qBAAa,OAAO;IAClB,6CAA6C;IAC7C,SAAgB,MAAM,EAAE,MAAM,CAAC;IAC/B,oCAAoC;IACpC,SAAgB,IAAI,EAAE,QAAQ,CAAC;IAC/B;;;;;;;;;OASG;IACH,SAAgB,MAAM,EAAE,SAAS,OAAO,EAAE,CAAC;IAE3C,OAAO,CAAC,OAAO,CAAC,CAAsB;IAEtC,YAAmB,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,OAAO,EAAE,EAI5E;IAED;;;;;;;;;;OAUG;IACH,IAAW,MAAM,IAAI,SAAS,QAAQ,EAAE,CAIvC;IAED;;;;OAIG;IACH,IAAW,KAAK,IAAI,QAAQ,CAQ3B;IAED;;;;;;;;;;OAUG;IACI,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAQ7D;IAED;;;;;OAKG;IACI,OAAO,IAAI,IAAI,CAIrB;CACF"}
|
package/dist/esm/LdtkMap.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getLdtkLevelEntries } from "./ldtkLevelEntries.js";
|
|
2
2
|
import { ldtkToMapWorld } from "./ldtkToMapWorld.js";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/LdtkMap.ts
|
|
5
5
|
/**
|
|
6
6
|
* A parsed LDtk world document: holds the raw JSON data and the converted
|
|
7
7
|
* runtime {@link TileMap} for each level.
|
|
@@ -43,8 +43,9 @@ var LdtkMap = class {
|
|
|
43
43
|
*
|
|
44
44
|
* This is metadata about *where* levels are, independent of the runtime maps
|
|
45
45
|
* in {@link levels}. Use it to navigate; use
|
|
46
|
-
* {@link import('./
|
|
47
|
-
*
|
|
46
|
+
* {@link import('./LdtkProject').LdtkProject} with
|
|
47
|
+
* {@link import('@codexo/exojs/tilemap').MapWorldRuntime} instead when levels
|
|
48
|
+
* should be loaded on demand rather than all at once.
|
|
48
49
|
*/
|
|
49
50
|
get worlds() {
|
|
50
51
|
this._worlds ??= ldtkToMapWorld(this.data);
|
|
@@ -73,7 +74,7 @@ var LdtkMap = class {
|
|
|
73
74
|
*/
|
|
74
75
|
getLevelByName(identifier) {
|
|
75
76
|
const index = getLdtkLevelEntries(this.data).findIndex((entry) => entry.level.identifier === identifier);
|
|
76
|
-
if (index === -1) return
|
|
77
|
+
if (index === -1) return;
|
|
77
78
|
return this.levels[index];
|
|
78
79
|
}
|
|
79
80
|
/**
|
|
@@ -87,6 +88,5 @@ var LdtkMap = class {
|
|
|
87
88
|
}
|
|
88
89
|
};
|
|
89
90
|
|
|
90
|
-
//#endregion
|
|
91
91
|
export { LdtkMap };
|
|
92
92
|
//# sourceMappingURL=LdtkMap.js.map
|
package/dist/esm/LdtkMap.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LdtkMap.js","names":[],"sources":["../../src/LdtkMap.ts"],"sourcesContent":["import type { MapWorld, TileMap } from '@codexo/exojs
|
|
1
|
+
{"version":3,"file":"LdtkMap.js","names":[],"sources":["../../src/LdtkMap.ts"],"sourcesContent":["import type { MapWorld, TileMap } from '@codexo/exojs/tilemap';\n\nimport type { LdtkData } from './LdtkData';\nimport { getLdtkLevelEntries } from './ldtkLevelEntries';\nimport { ldtkToMapWorld } from './ldtkToMapWorld';\n\n/**\n * A parsed LDtk world document: holds the raw JSON data and the converted\n * runtime {@link TileMap} for each level.\n *\n * `LdtkMap` is the parsed source model. Each LDtk level is independently\n * convertible to a format-independent `TileMap`; access them via\n * {@link levels} (by document order) or by name via {@link getLevelByName}.\n *\n * Construction is cheap - the runtime `TileMap[]` is supplied externally\n * (built by {@link import('./ldtkToTileMap').ldtkToTileMap}). The map does\n * **not** own tileset textures; those remain in the Loader cache.\n */\nexport class LdtkMap {\n /** Resolved URL this map was loaded from. */\n public readonly source: string;\n /** The raw parsed LDtk document. */\n public readonly data: LdtkData;\n /**\n * Runtime TileMaps - one per LDtk level, in document order.\n *\n * The index here corresponds to\n * {@link import('./ldtkLevelEntries').getLdtkLevelEntries}`(data)[i]`, not\n * `data.levels[i]` - the latter is empty for multi-world documents, where\n * levels live under `data.worlds[].levels` instead. `loadLdtkMap` fully\n * resolves external `.ldtkl` levels before conversion, so every entry here\n * is always a fully converted `TileMap`.\n */\n public readonly levels: readonly TileMap[];\n\n private _worlds?: readonly MapWorld[];\n\n public constructor(source: string, data: LdtkData, levels: readonly TileMap[]) {\n this.source = source;\n this.data = data;\n this.levels = levels;\n }\n\n /**\n * The document's world layout: level placement, bounds and neighbour graph,\n * one {@link MapWorld} per LDtk world (exactly one for a single-world\n * project). Built on first access and cached.\n *\n * This is metadata about *where* levels are, independent of the runtime maps\n * in {@link levels}. Use it to navigate; use\n * {@link import('./LdtkProject').LdtkProject} with\n * {@link import('@codexo/exojs/tilemap').MapWorldRuntime} instead when levels\n * should be loaded on demand rather than all at once.\n */\n public get worlds(): readonly MapWorld[] {\n this._worlds ??= ldtkToMapWorld(this.data);\n\n return this._worlds;\n }\n\n /**\n * The document's only world. Convenience for the single-world case; for a\n * multi-world project this is the first world in document order and\n * {@link worlds} is what to read instead.\n */\n public get world(): MapWorld {\n const [first] = this.worlds;\n\n if (first === undefined) {\n throw new Error(`LdtkMap: \"${this.source}\" declares no world.`);\n }\n\n return first;\n }\n\n /**\n * Find a level's runtime {@link TileMap} by the LDtk level `identifier`,\n * or `undefined` when no level with that name exists.\n *\n * Searches across {@link import('./ldtkLevelEntries').getLdtkLevelEntries}'s\n * flattened level set rather than `data.levels` directly, so this works for\n * both single-world and multi-world documents - `data.levels` alone is\n * empty for the latter.\n *\n * The lookup is O(n) in the number of levels.\n */\n public getLevelByName(identifier: string): TileMap | undefined {\n const index = getLdtkLevelEntries(this.data).findIndex(entry => entry.level.identifier === identifier);\n\n if (index === -1) {\n return undefined;\n }\n\n return this.levels[index];\n }\n\n /**\n * Destroy all owned runtime TileMaps.\n *\n * Is idempotent. Does NOT destroy tileset textures (Loader-owned) or any\n * SceneNodes - the application is responsible for those.\n */\n public destroy(): void {\n for (const level of this.levels) {\n level.destroy();\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAkBA,IAAa,UAAb,MAAqB;;CAEnB,AAAgB;;CAEhB,AAAgB;;;;;;;;;;;CAWhB,AAAgB;CAEhB,AAAQ;CAER,AAAO,YAAY,QAAgB,MAAgB,QAA4B;EAC7E,KAAK,SAAS;EACd,KAAK,OAAO;EACZ,KAAK,SAAS;CAChB;;;;;;;;;;;;CAaA,IAAW,SAA8B;EACvC,KAAK,YAAY,eAAe,KAAK,IAAI;EAEzC,OAAO,KAAK;CACd;;;;;;CAOA,IAAW,QAAkB;EAC3B,MAAM,CAAC,SAAS,KAAK;EAErB,IAAI,UAAU,QACZ,MAAM,IAAI,MAAM,aAAa,KAAK,OAAO,qBAAqB;EAGhE,OAAO;CACT;;;;;;;;;;;;CAaA,AAAO,eAAe,YAAyC;EAC7D,MAAM,QAAQ,oBAAoB,KAAK,IAAI,CAAC,CAAC,WAAU,UAAS,MAAM,MAAM,eAAe,UAAU;EAErG,IAAI,UAAU,IACZ;EAGF,OAAO,KAAK,OAAO;CACrB;;;;;;;CAQA,AAAO,UAAgB;EACrB,KAAK,MAAM,SAAS,KAAK,QACvB,MAAM,QAAQ;CAElB;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { LoaderScope } from '@codexo/exojs';
|
|
2
|
-
import type { MapWorld, TileSet } from '@codexo/exojs
|
|
3
|
-
import { MapWorldRuntime } from '@codexo/exojs
|
|
2
|
+
import type { MapWorld, TileSet } from '@codexo/exojs/tilemap';
|
|
3
|
+
import { MapWorldRuntime } from '@codexo/exojs/tilemap';
|
|
4
4
|
import type { LdtkData } from './LdtkData';
|
|
5
5
|
/** Options for {@link LdtkProject.createRuntime}. */
|
|
6
6
|
export interface LdtkRuntimeOptions {
|
|
@@ -54,7 +54,7 @@ export interface LdtkRuntimeOptions {
|
|
|
54
54
|
*
|
|
55
55
|
* @example
|
|
56
56
|
* ```ts
|
|
57
|
-
* const project = await scene.loader.load(
|
|
57
|
+
* const project = await scene.loader.load({ type: 'ldtkProject', source: 'world.ldtk' });
|
|
58
58
|
* const runtime = project.createRuntime({ scope: scene.loader });
|
|
59
59
|
*
|
|
60
60
|
* const forest = await runtime.loadLevel(project.world.getLevelByName('Forest')!.id, {
|
|
@@ -62,7 +62,15 @@ export interface LdtkRuntimeOptions {
|
|
|
62
62
|
* context: { services, save },
|
|
63
63
|
* });
|
|
64
64
|
*
|
|
65
|
-
*
|
|
65
|
+
* const view = forest.map.createView();
|
|
66
|
+
*
|
|
67
|
+
* for (const layer of view.layers) {
|
|
68
|
+
* scene.addChild(layer);
|
|
69
|
+
* }
|
|
70
|
+
*
|
|
71
|
+
* // Release the view before runtime.unloadLevel(); it owns its layer nodes.
|
|
72
|
+
* view.destroy();
|
|
73
|
+
*
|
|
66
74
|
* runtime.unloadLevel(for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AsB5B"}
|
package/dist/esm/LdtkProject.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { getLdtkLevelEntries } from "./ldtkLevelEntries.js";
|
|
2
|
-
import { ldtkLevelToTileMap } from "./ldtkToTileMap.js";
|
|
3
2
|
import { ldtkToMapWorld } from "./ldtkToMapWorld.js";
|
|
3
|
+
import { ldtkLevelToTileMap } from "./ldtkToTileMap.js";
|
|
4
4
|
import { resolveLdtkUrl } from "./url.js";
|
|
5
5
|
import { validateLdtkLevelData } from "./validate.js";
|
|
6
|
-
import { MapWorldRuntime } from "@codexo/exojs
|
|
7
|
-
import { Asset } from "@codexo/exojs";
|
|
6
|
+
import { MapWorldRuntime } from "@codexo/exojs/tilemap";
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
// src/LdtkProject.ts
|
|
10
9
|
/**
|
|
11
10
|
* A loaded LDtk project, prepared for streaming: world layout and tileset
|
|
12
11
|
* atlases are resident, level payloads are not.
|
|
@@ -45,7 +44,7 @@ import { Asset } from "@codexo/exojs";
|
|
|
45
44
|
*
|
|
46
45
|
* @example
|
|
47
46
|
* ```ts
|
|
48
|
-
* const project = await scene.loader.load(
|
|
47
|
+
* const project = await scene.loader.load({ type: 'ldtkProject', source: 'world.ldtk' });
|
|
49
48
|
* const runtime = project.createRuntime({ scope: scene.loader });
|
|
50
49
|
*
|
|
51
50
|
* const forest = await runtime.loadLevel(project.world.getLevelByName('Forest')!.id, {
|
|
@@ -53,7 +52,15 @@ import { Asset } from "@codexo/exojs";
|
|
|
53
52
|
* context: { services, save },
|
|
54
53
|
* });
|
|
55
54
|
*
|
|
56
|
-
*
|
|
55
|
+
* const view = forest.map.createView();
|
|
56
|
+
*
|
|
57
|
+
* for (const layer of view.layers) {
|
|
58
|
+
* scene.addChild(layer);
|
|
59
|
+
* }
|
|
60
|
+
*
|
|
61
|
+
* // Release the view before runtime.unloadLevel(); it owns its layer nodes.
|
|
62
|
+
* view.destroy();
|
|
63
|
+
*
|
|
57
64
|
* runtime.unloadLevel(forest.id);
|
|
58
65
|
* ```
|
|
59
66
|
*/
|
|
@@ -121,7 +128,10 @@ var LdtkProject = class {
|
|
|
121
128
|
async _resolveLevel(level, scope) {
|
|
122
129
|
if (level.layerInstances !== null || level.externalRelPath === void 0 || level.externalRelPath === null || level.externalRelPath === "") return level;
|
|
123
130
|
const url = resolveLdtkUrl(level.externalRelPath, this.source);
|
|
124
|
-
const external = validateLdtkLevelData(await scope.load(
|
|
131
|
+
const external = validateLdtkLevelData(await scope.load({
|
|
132
|
+
type: "json",
|
|
133
|
+
source: url
|
|
134
|
+
}), url);
|
|
125
135
|
const fieldInstances = external.fieldInstances ?? level.fieldInstances;
|
|
126
136
|
return {
|
|
127
137
|
...level,
|
|
@@ -131,6 +141,5 @@ var LdtkProject = class {
|
|
|
131
141
|
}
|
|
132
142
|
};
|
|
133
143
|
|
|
134
|
-
//#endregion
|
|
135
144
|
export { LdtkProject };
|
|
136
145
|
//# sourceMappingURL=LdtkProject.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LdtkProject.js","names":[],"sources":["../../src/LdtkProject.ts"],"sourcesContent":["import type { LoaderScope } from '@codexo/exojs';\nimport
|
|
1
|
+
{"version":3,"file":"LdtkProject.js","names":[],"sources":["../../src/LdtkProject.ts"],"sourcesContent":["import type { LoaderScope } from '@codexo/exojs';\nimport type { MapLevelLoadContext, MapWorld, TileMap, TileSet } from '@codexo/exojs/tilemap';\nimport { MapWorldRuntime } from '@codexo/exojs/tilemap';\n\nimport type { LdtkData, LdtkLevel } from './LdtkData';\nimport type { LdtkLevelEntry } from './ldtkLevelEntries';\nimport { getLdtkLevelEntries } from './ldtkLevelEntries';\nimport { ldtkToMapWorld } from './ldtkToMapWorld';\nimport { ldtkLevelToTileMap } from './ldtkToTileMap';\nimport { resolveLdtkUrl } from './url';\nimport { validateLdtkLevelData } from './validate';\n\n/** Options for {@link LdtkProject.createRuntime}. */\nexport interface LdtkRuntimeOptions {\n /**\n * Parent scope for everything the runtime loads. The runtime creates its own\n * child scope under it and never destroys this one.\n */\n readonly scope: LoaderScope;\n /**\n * Which world of a multi-world project to stream, by identifier. Defaults to\n * the first world in document order, which is the only one a single-world\n * project has.\n */\n readonly world?: string;\n}\n\n/**\n * A loaded LDtk project, prepared for streaming: world layout and tileset\n * atlases are resident, level payloads are not.\n *\n * This is the entry point for a game that loads levels as it needs them. Read\n * {@link worlds} to decide what to load, then drive a\n * {@link MapWorldRuntime} from {@link createRuntime} to load and unload\n * individual levels, each with its own asset scope.\n *\n * What is eager, and why:\n *\n * - the `.ldtk` document itself, because the world layout is what the game\n * navigates by;\n * - every tileset atlas. This is a prefetch policy, not a technical\n * requirement, and it is bounded: LDtk declares tilesets once per project\n * (`defs.tilesets`), never per level, so the count does not grow with the\n * number of levels. Paying for them once keeps a level load off the network\n * entirely for a non-externalized project, and off the *image* network for an\n * externalized one.\n *\n * The atlases are claimed by this asset's own scope, so their residency is tied\n * to how long the `ldtkProject` asset is held - not to a\n * {@link MapWorldRuntime}. Releasing the asset releases them; destroying a\n * runtime does not.\n *\n * What is lazy:\n *\n * - external `.ldtkl` level payloads - fetched when the level loads, claimed\n * by that level's scope, released when it unloads;\n * - the conversion of a level into a runtime `TileMap`;\n * - anything the level's {@link import('@codexo/exojs-tilemap').MapObjectSpawner} creates.\n *\n * Load the whole project at once with the `ldtkMap` asset type instead\n * ({@link import('./LdtkMap').LdtkMap}) when a game is small enough not to\n * need any of this.\n *\n * @example\n * ```ts\n * const project = await scene.loader.load({ type: 'ldtkProject', source: 'world.ldtk' });\n * const runtime = project.createRuntime({ scope: scene.loader });\n *\n * const forest = await runtime.loadLevel(project.world.getLevelByName('Forest')!.id, {\n * spawner,\n * context: { services, save },\n * });\n *\n * const view = forest.map.createView();\n *\n * for (const layer of view.layers) {\n * scene.addChild(layer);\n * }\n *\n * // Release the view before runtime.unloadLevel(); it owns its layer nodes.\n * view.destroy();\n *\n * runtime.unloadLevel(forest.id);\n * ```\n */\nexport class LdtkProject {\n /** Resolved URL this project was loaded from. */\n public readonly source: string;\n /** The raw parsed LDtk document. Externalized levels still carry `layerInstances: null`. */\n public readonly data: LdtkData;\n /** Runtime tilesets keyed by LDtk tileset uid, shared by every level of the project. */\n public readonly tilesets: ReadonlyMap<number, TileSet>;\n /** World layout, one entry per LDtk world. See {@link import('./ldtkToMapWorld').ldtkToMapWorld}. */\n public readonly worlds: readonly MapWorld[];\n\n private readonly _entries: readonly LdtkLevelEntry[];\n\n /** Projects are produced by the `ldtkProject` asset binding. @internal */\n public constructor(source: string, data: LdtkData, tilesets: ReadonlyMap<number, TileSet>) {\n this.source = source;\n this.data = data;\n this.tilesets = tilesets;\n this.worlds = ldtkToMapWorld(data);\n this._entries = getLdtkLevelEntries(data);\n }\n\n /**\n * The project's only world. For a multi-world project this is the first in\n * document order; read {@link worlds} to reach the others.\n */\n public get world(): MapWorld {\n const [first] = this.worlds;\n\n if (first === undefined) {\n throw new Error(`LdtkProject: \"${this.source}\" declares no world.`);\n }\n\n return first;\n }\n\n /** The world with this identifier, or `undefined`. */\n public getWorld(name: string): MapWorld | undefined {\n return this.worlds.find(world => world.name === name);\n }\n\n /**\n * Create the live runtime that loads and unloads this project's levels.\n *\n * The runtime is a separate lifetime from the project: destroying it unloads\n * every level it holds and leaves the project - document, world layout and\n * tilesets - intact, ready for a new runtime.\n *\n * @throws {Error} when `options.world` names no world of this project.\n */\n public createRuntime(options: LdtkRuntimeOptions): MapWorldRuntime {\n const world = options.world === undefined ? this.world : this.getWorld(options.world);\n\n if (world === undefined) {\n throw new Error(`LdtkProject: \"${this.source}\" has no world named \"${options.world ?? ''}\".`);\n }\n\n return new MapWorldRuntime({\n world,\n scope: options.scope,\n load: context => this._loadLevel(context),\n });\n }\n\n private async _loadLevel(context: MapLevelLoadContext): Promise<TileMap> {\n const entry = this._entries[context.level.index];\n\n if (entry === undefined) {\n throw new Error(`LdtkProject: level \"${context.level.id}\" has index ${context.level.index}, which is outside \"${this.source}\".`);\n }\n\n const level = await this._resolveLevel(entry.level, context.scope);\n\n return ldtkLevelToTileMap(level, entry.worldIid, context.level.index, this.data, this.tilesets);\n }\n\n /**\n * Fetch an externalized level's `.ldtkl` payload and merge it into the level\n * record. The fetch is claimed by the level's own scope, so it is released\n * when the level unloads and re-fetched (or served from the loader's cache)\n * on a later load.\n */\n private async _resolveLevel(level: LdtkLevel, scope: LoaderScope): Promise<LdtkLevel> {\n if (\n level.layerInstances !== null ||\n level.externalRelPath === undefined ||\n level.externalRelPath === null ||\n level.externalRelPath === ''\n ) {\n return level;\n }\n\n const url = resolveLdtkUrl(level.externalRelPath, this.source);\n // Validated as strictly as an inlined level, with the `.ldtkl` file as the\n // error source - a malformed external payload must fail as loudly.\n const external = validateLdtkLevelData(await scope.load({ type: 'json', source: url }), url);\n const fieldInstances = external.fieldInstances ?? level.fieldInstances;\n\n return {\n ...level,\n layerInstances: external.layerInstances,\n ...(fieldInstances !== undefined && { fieldInstances }),\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqFA,IAAa,cAAb,MAAyB;;CAEvB,AAAgB;;CAEhB,AAAgB;;CAEhB,AAAgB;;CAEhB,AAAgB;CAEhB,AAAiB;;CAGjB,AAAO,YAAY,QAAgB,MAAgB,UAAwC;EACzF,KAAK,SAAS;EACd,KAAK,OAAO;EACZ,KAAK,WAAW;EAChB,KAAK,SAAS,eAAe,IAAI;EACjC,KAAK,WAAW,oBAAoB,IAAI;CAC1C;;;;;CAMA,IAAW,QAAkB;EAC3B,MAAM,CAAC,SAAS,KAAK;EAErB,IAAI,UAAU,QACZ,MAAM,IAAI,MAAM,iBAAiB,KAAK,OAAO,qBAAqB;EAGpE,OAAO;CACT;;CAGA,AAAO,SAAS,MAAoC;EAClD,OAAO,KAAK,OAAO,MAAK,UAAS,MAAM,SAAS,IAAI;CACtD;;;;;;;;;;CAWA,AAAO,cAAc,SAA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
|
@@ -3,11 +3,11 @@ import type { Extension } from '@codexo/exojs/extensions';
|
|
|
3
3
|
* Default immutable LDtk extension descriptor.
|
|
4
4
|
*
|
|
5
5
|
* Installs two asset types:
|
|
6
|
-
* - {@link ldtkMapType} - `loader.load(ldtkMapType
|
|
6
|
+
* - {@link ldtkMapType} - `loader.load({ type: ldtkMapType, source: 'world.ldtk' })` reads
|
|
7
7
|
* the `.ldtk` document, loads all referenced tileset images, and returns a
|
|
8
8
|
* fully assembled {@link LdtkMap} with one runtime
|
|
9
9
|
* {@link import('@codexo/exojs-tilemap').TileMap} per level.
|
|
10
|
-
* - {@link ldtkProjectType} - `loader.load(ldtkProjectType
|
|
10
|
+
* - {@link ldtkProjectType} - `loader.load({ type: ldtkProjectType, source: 'world.ldtk' })`
|
|
11
11
|
* returns the world layout and tileset atlases only, for games that load
|
|
12
12
|
* levels on demand.
|
|
13
13
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ldtkExtension.d.ts","
|
|
1
|
+
{"version":3,"file":"ldtkExtension.d.ts","sources":["../../src/ldtkExtension.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAK1D;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,aAAa,EAAE,SAI1B,CAAC"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { ldtkMapType, ldtkProjectType } from "./ldtkTypes.js";
|
|
2
|
-
import { tilemapExtension } from "@codexo/exojs
|
|
2
|
+
import { tilemapExtension } from "@codexo/exojs/tilemap";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/ldtkExtension.ts
|
|
5
5
|
/**
|
|
6
6
|
* Default immutable LDtk extension descriptor.
|
|
7
7
|
*
|
|
8
8
|
* Installs two asset types:
|
|
9
|
-
* - {@link ldtkMapType} - `loader.load(ldtkMapType
|
|
9
|
+
* - {@link ldtkMapType} - `loader.load({ type: ldtkMapType, source: 'world.ldtk' })` reads
|
|
10
10
|
* the `.ldtk` document, loads all referenced tileset images, and returns a
|
|
11
11
|
* fully assembled {@link LdtkMap} with one runtime
|
|
12
12
|
* {@link import('@codexo/exojs-tilemap').TileMap} per level.
|
|
13
|
-
* - {@link ldtkProjectType} - `loader.load(ldtkProjectType
|
|
13
|
+
* - {@link ldtkProjectType} - `loader.load({ type: ldtkProjectType, source: 'world.ldtk' })`
|
|
14
14
|
* returns the world layout and tileset atlases only, for games that load
|
|
15
15
|
* levels on demand.
|
|
16
16
|
*
|
|
@@ -26,6 +26,5 @@ const ldtkExtension = Object.freeze({
|
|
|
26
26
|
assets: [ldtkMapType, ldtkProjectType]
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
-
//#endregion
|
|
30
29
|
export { ldtkExtension };
|
|
31
30
|
//# sourceMappingURL=ldtkExtension.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ldtkExtension.js","names":[],"sources":["../../src/ldtkExtension.ts"],"sourcesContent":["import type { Extension } from '@codexo/exojs/extensions';\nimport { tilemapExtension } from '@codexo/exojs
|
|
1
|
+
{"version":3,"file":"ldtkExtension.js","names":[],"sources":["../../src/ldtkExtension.ts"],"sourcesContent":["import type { Extension } from '@codexo/exojs/extensions';\nimport { tilemapExtension } from '@codexo/exojs/tilemap';\n\nimport { ldtkMapType, ldtkProjectType } from './ldtkTypes';\n\n/**\n * Default immutable LDtk extension descriptor.\n *\n * Installs two asset types:\n * - {@link ldtkMapType} - `loader.load({ type: ldtkMapType, source: 'world.ldtk' })` reads\n * the `.ldtk` document, loads all referenced tileset images, and returns a\n * fully assembled {@link LdtkMap} with one runtime\n * {@link import('@codexo/exojs-tilemap').TileMap} per level.\n * - {@link ldtkProjectType} - `loader.load({ type: ldtkProjectType, source: 'world.ldtk' })`\n * returns the world layout and tileset atlases only, for games that load\n * levels on demand.\n *\n * Depends on {@link tilemapExtension} so that snapshot construction always\n * materialises the generic tilemap runtime before the LDtk adapter.\n *\n * Pass it to the application that should have it via\n * `ApplicationOptions.extensions`.\n */\nexport const ldtkExtension: Extension = Object.freeze({\n id: '@codexo/exojs-ldtk',\n dependencies: [tilemapExtension],\n assets: [ldtkMapType, ldtkProjectType],\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,gBAA2B,OAAO,OAAO;CACpD,IAAI;CACJ,cAAc,CAAC,gBAAgB;CAC/B,QAAQ,CAAC,aAAa,eAAe;AACvC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ldtkLevelEntries.d.ts","
|
|
1
|
+
{"version":3,"file":"ldtkLevelEntries.d.ts","sources":["../../src/ldtkLevelEntries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEtD;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CACvC;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,mBAAmB,SAAU,QAAQ,KAAG,SAAS,cAAc,EAc3E,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/ldtkLevelEntries.ts
|
|
2
2
|
/**
|
|
3
3
|
* Flatten a {@link LdtkData} document's levels into one ordered list,
|
|
4
4
|
* abstracting over LDtk's two root shapes: single-world (levels live in the
|
|
@@ -28,6 +28,5 @@ const getLdtkLevelEntries = (data) => {
|
|
|
28
28
|
}));
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
//#endregion
|
|
32
31
|
export { getLdtkLevelEntries };
|
|
33
32
|
//# sourceMappingURL=ldtkLevelEntries.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ldtkLevelEntries.js","names":[],"sources":["../../src/ldtkLevelEntries.ts"],"sourcesContent":["import type { LdtkData, LdtkLevel } from './LdtkData';\n\n/**\n * One level from a (possibly multi-world) {@link LdtkData} document, paired\n * with the {@link import('./LdtkData').LdtkWorldData.iid} of the world it\n * belongs to. `worldIid` is `undefined` when the document uses the legacy\n * single-world shape (`data.levels`, no `worlds[]`) - the overwhelmingly\n * common case.\n */\nexport interface LdtkLevelEntry {\n readonly level: LdtkLevel;\n readonly worldIid: string | undefined;\n}\n\n/**\n * Flatten a {@link LdtkData} document's levels into one ordered list,\n * abstracting over LDtk's two root shapes: single-world (levels live in the\n * root {@link LdtkData.levels}) and multi-world (levels live in\n * `data.worlds[].levels`, each tagged here with its owning world's `iid`;\n * per the LDtk spec the root `levels` array is kept but EMPTY in this shape).\n *\n * This is the single place that decides which shape a document uses - every\n * consumer that needs \"all levels, in document order\" ({@link import('./loadLdtkMap').loadLdtkMap}'s\n * external `.ldtkl` resolution, {@link import('./ldtkToTileMap').ldtkToTileMap}'s\n * conversion, and {@link import('./LdtkMap').LdtkMap.getLevelByName}'s lookup)\n * goes through this function rather than re-deriving the single/multi-world\n * detection independently.\n */\nexport const getLdtkLevelEntries = (data: LdtkData): readonly LdtkLevelEntry[] => {\n if (data.worlds && data.worlds.length > 0) {\n const entries: LdtkLevelEntry[] = [];\n for (const world of data.worlds) {\n for (const level of world.levels) {\n entries.push({ level, worldIid: world.iid });\n }\n }\n return entries;\n }\n\n return data.levels.map(level => ({ level, worldIid: undefined }));\n};\n"],"mappings":";;;;;;;;;;;;;;;AA4BA,MAAa,uBAAuB,SAA8C;CAChF,IAAI,KAAK,UAAU,KAAK,OAAO,SAAS,GAAG;EACzC,MAAM,UAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"ldtkLevelEntries.js","names":[],"sources":["../../src/ldtkLevelEntries.ts"],"sourcesContent":["import type { LdtkData, LdtkLevel } from './LdtkData';\n\n/**\n * One level from a (possibly multi-world) {@link LdtkData} document, paired\n * with the {@link import('./LdtkData').LdtkWorldData.iid} of the world it\n * belongs to. `worldIid` is `undefined` when the document uses the legacy\n * single-world shape (`data.levels`, no `worlds[]`) - the overwhelmingly\n * common case.\n */\nexport interface LdtkLevelEntry {\n readonly level: LdtkLevel;\n readonly worldIid: string | undefined;\n}\n\n/**\n * Flatten a {@link LdtkData} document's levels into one ordered list,\n * abstracting over LDtk's two root shapes: single-world (levels live in the\n * root {@link LdtkData.levels}) and multi-world (levels live in\n * `data.worlds[].levels`, each tagged here with its owning world's `iid`;\n * per the LDtk spec the root `levels` array is kept but EMPTY in this shape).\n *\n * This is the single place that decides which shape a document uses - every\n * consumer that needs \"all levels, in document order\" ({@link import('./loadLdtkMap').loadLdtkMap}'s\n * external `.ldtkl` resolution, {@link import('./ldtkToTileMap').ldtkToTileMap}'s\n * conversion, and {@link import('./LdtkMap').LdtkMap.getLevelByName}'s lookup)\n * goes through this function rather than re-deriving the single/multi-world\n * detection independently.\n */\nexport const getLdtkLevelEntries = (data: LdtkData): readonly LdtkLevelEntry[] => {\n if (data.worlds && data.worlds.length > 0) {\n const entries: LdtkLevelEntry[] = [];\n\n for (const world of data.worlds) {\n for (const level of world.levels) {\n entries.push({ level, worldIid: world.iid });\n }\n }\n\n return entries;\n }\n\n return data.levels.map(level => ({ level, worldIid: undefined }));\n};\n"],"mappings":";;;;;;;;;;;;;;;AA4BA,MAAa,uBAAuB,SAA8C;CAChF,IAAI,KAAK,UAAU,KAAK,OAAO,SAAS,GAAG;EACzC,MAAM,UAA4B,CAAC;EAEnC,KAAK,MAAM,SAAS,KAAK,QACvB,KAAK,MAAM,SAAS,MAAM,QACxB,QAAQ,KAAK;GAAE;GAAO,UAAU,MAAM;EAAI,CAAC;EAI/C,OAAO;CACT;CAEA,OAAO,KAAK,OAAO,KAAI,WAAU;EAAE;EAAO,UAAU;CAAU,EAAE;AAClE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ldtkParallax.d.ts","
|
|
1
|
+
{"version":3,"file":"ldtkParallax.d.ts","sources":["../../src/ldtkParallax.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,uEAAuE;AACvE,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,2EAA2E;IAC3E,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,2EAA2E;IAC3E,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;;GAGG;AACH,eAAO,MAAM,wBAAwB,SAC7B,QAAQ,SACP;IACL,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B,KACA,iBAaF,CAAC"}
|
package/dist/esm/ldtkParallax.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/ldtkParallax.ts
|
|
2
2
|
/**
|
|
3
3
|
* Resolve the runtime parallax transform for a layer instance. Missing
|
|
4
4
|
* definitions and factors use LDtk's defaults: no shift and scale `1`.
|
|
@@ -17,6 +17,5 @@ const resolveLdtkLayerParallax = (data, layer) => {
|
|
|
17
17
|
};
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
//#endregion
|
|
21
20
|
export { resolveLdtkLayerParallax };
|
|
22
21
|
//# sourceMappingURL=ldtkParallax.js.map
|