@codexo/exojs-tiled 0.15.3 → 0.16.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 +59 -66
- package/dist/esm/TiledLayer.d.ts +2 -1
- package/dist/esm/TiledLayer.d.ts.map +1 -0
- package/dist/esm/TiledLayer.js +106 -108
- package/dist/esm/TiledLayer.js.map +1 -1
- package/dist/esm/TiledMap.d.ts +35 -7
- package/dist/esm/TiledMap.d.ts.map +1 -0
- package/dist/esm/TiledMap.js +714 -589
- package/dist/esm/TiledMap.js.map +1 -1
- package/dist/esm/TiledObject.d.ts +7 -0
- package/dist/esm/TiledObject.d.ts.map +1 -0
- package/dist/esm/TiledObject.js +59 -51
- package/dist/esm/TiledObject.js.map +1 -1
- package/dist/esm/TiledTileset.d.ts +11 -4
- package/dist/esm/TiledTileset.d.ts.map +1 -0
- package/dist/esm/TiledTileset.js +81 -70
- package/dist/esm/TiledTileset.js.map +1 -1
- package/dist/esm/data.d.ts +25 -7
- package/dist/esm/data.d.ts.map +1 -0
- package/dist/esm/decodeLayerData.d.ts +2 -1
- package/dist/esm/decodeLayerData.d.ts.map +1 -0
- package/dist/esm/decodeLayerData.js +53 -92
- package/dist/esm/decodeLayerData.js.map +1 -1
- package/dist/esm/gid.d.ts +2 -1
- package/dist/esm/gid.d.ts.map +1 -0
- package/dist/esm/gid.js +15 -24
- package/dist/esm/gid.js.map +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +14 -12
- package/dist/esm/loadTiledMap.d.ts +11 -5
- package/dist/esm/loadTiledMap.d.ts.map +1 -0
- package/dist/esm/loadTiledMap.js +82 -91
- package/dist/esm/loadTiledMap.js.map +1 -1
- package/dist/esm/objectAlignment.d.ts +28 -0
- package/dist/esm/objectAlignment.d.ts.map +1 -0
- package/dist/esm/objectAlignment.js +79 -0
- package/dist/esm/objectAlignment.js.map +1 -0
- package/dist/esm/public.d.ts +17 -15
- package/dist/esm/public.d.ts.map +1 -0
- package/dist/esm/public.js +14 -0
- package/dist/esm/tileMapType.d.ts +31 -0
- package/dist/esm/tileMapType.d.ts.map +1 -0
- package/dist/esm/tileMapType.js +42 -0
- package/dist/esm/tileMapType.js.map +1 -0
- package/dist/esm/tiledBuildInfo.d.ts +1 -0
- package/dist/esm/tiledBuildInfo.d.ts.map +1 -0
- package/dist/esm/tiledBuildInfo.js +6 -4
- package/dist/esm/tiledBuildInfo.js.map +1 -1
- package/dist/esm/tiledExtension.d.ts +7 -6
- package/dist/esm/tiledExtension.d.ts.map +1 -0
- package/dist/esm/tiledExtension.js +23 -25
- package/dist/esm/tiledExtension.js.map +1 -1
- package/dist/esm/tiledOptions.d.ts +5 -4
- package/dist/esm/tiledOptions.d.ts.map +1 -0
- package/dist/esm/tiledOptions.js +11 -13
- package/dist/esm/tiledOptions.js.map +1 -1
- package/dist/esm/tiledSourceType.d.ts +24 -0
- package/dist/esm/tiledSourceType.d.ts.map +1 -0
- package/dist/esm/tiledSourceType.js +44 -0
- package/dist/esm/tiledSourceType.js.map +1 -0
- package/dist/esm/url.d.ts +2 -1
- package/dist/esm/url.d.ts.map +1 -0
- package/dist/esm/url.js +26 -37
- package/dist/esm/url.js.map +1 -1
- package/dist/esm/validate.d.ts +11 -10
- package/dist/esm/validate.d.ts.map +1 -0
- package/dist/esm/validate.js +485 -534
- package/dist/esm/validate.js.map +1 -1
- package/dist/esm/wangSets.d.ts +5 -4
- package/dist/esm/wangSets.d.ts.map +1 -0
- package/dist/esm/wangSets.js +90 -115
- package/dist/esm/wangSets.js.map +1 -1
- package/package.json +10 -18
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/register.d.ts +0 -1
- package/dist/esm/register.js +0 -22
- package/dist/esm/register.js.map +0 -1
- package/dist/esm/tiledMapBinding.d.ts +0 -19
- package/dist/esm/tiledMapBinding.js +0 -31
- package/dist/esm/tiledMapBinding.js.map +0 -1
- package/dist/esm/tiledRuntimeMapBinding.d.ts +0 -29
- package/dist/esm/tiledRuntimeMapBinding.js +0 -42
- package/dist/esm/tiledRuntimeMapBinding.js.map +0 -1
package/dist/esm/loadTiledMap.js
CHANGED
|
@@ -1,98 +1,89 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { TiledMap } from
|
|
4
|
-
import { TiledTileset } from
|
|
5
|
-
import {
|
|
6
|
-
import { validateTiledMapData, validateTiledTilesetFileData } from './validate.js';
|
|
1
|
+
import { validateTiledTilesetFileData } from "./validate.js";
|
|
2
|
+
import { resolveTiledUrl } from "./url.js";
|
|
3
|
+
import { TiledMap } from "./TiledMap.js";
|
|
4
|
+
import { TiledTileset } from "./TiledTileset.js";
|
|
5
|
+
import { Asset } from "@codexo/exojs";
|
|
7
6
|
|
|
7
|
+
//#region src/loadTiledMap.ts
|
|
8
8
|
/**
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
9
|
+
* Resolves and loads the image(s) referenced by a tileset: the atlas
|
|
10
|
+
* `image` (if present) and any collection-of-images per-tile `image`
|
|
11
|
+
* entries, relative to `baseUrl` (the resolved location of the file the
|
|
12
|
+
* tileset data came from - the `.tmj` for an embedded tileset, the `.tsj`
|
|
13
|
+
* for an external one).
|
|
14
|
+
*
|
|
15
|
+
* Textures are claimed by this map's own dependency scope, which deduplicates
|
|
16
|
+
* concurrent and repeated loads of the same normalized URL and releases them
|
|
17
|
+
* with the map.
|
|
18
|
+
*/
|
|
19
|
+
const loadTiledTilesetResources = async (data, baseUrl, context, source) => {
|
|
20
|
+
let imageUrl;
|
|
21
|
+
let texture;
|
|
22
|
+
if (data.image !== void 0) {
|
|
23
|
+
imageUrl = resolveTiledUrl(data.image, baseUrl);
|
|
24
|
+
texture = await context.dependencies.load(Asset.type("texture", imageUrl));
|
|
25
|
+
}
|
|
26
|
+
let tileTextures;
|
|
27
|
+
if (data.tiles !== void 0) for (const tile of data.tiles) {
|
|
28
|
+
if (tile.image === void 0) continue;
|
|
29
|
+
const tileImageUrl = resolveTiledUrl(tile.image, baseUrl);
|
|
30
|
+
const tileTexture = await context.dependencies.load(Asset.type("texture", tileImageUrl));
|
|
31
|
+
tileTextures ??= /* @__PURE__ */ new Map();
|
|
32
|
+
tileTextures.set(tile.id, tileTexture);
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
source,
|
|
36
|
+
imageUrl,
|
|
37
|
+
texture,
|
|
38
|
+
tileTextures
|
|
39
|
+
};
|
|
40
|
+
};
|
|
39
41
|
/**
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
async
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
42
|
+
* Resolves one `tilesets[]` entry of a `.tmj` file to a {@link TiledTileset}:
|
|
43
|
+
* fetches and validates the external `.tsj` if `ref.source` is set, or uses
|
|
44
|
+
* the embedded tileset data directly, then resolves and loads its image(s).
|
|
45
|
+
*/
|
|
46
|
+
const loadTiledTileset = async (ref, mapSource, context) => {
|
|
47
|
+
if ("source" in ref) {
|
|
48
|
+
const tsjUrl = resolveTiledUrl(ref.source, mapSource);
|
|
49
|
+
const raw = await context.dependencies.load(Asset.type("json", tsjUrl));
|
|
50
|
+
const data = validateTiledTilesetFileData(raw, tsjUrl);
|
|
51
|
+
const resources = await loadTiledTilesetResources(data, tsjUrl, context, tsjUrl);
|
|
52
|
+
return new TiledTileset(data, ref.firstgid, resources);
|
|
53
|
+
}
|
|
54
|
+
const resources = await loadTiledTilesetResources(ref, mapSource, context);
|
|
55
|
+
return new TiledTileset(ref, ref.firstgid, resources);
|
|
56
|
+
};
|
|
55
57
|
/**
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
async
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return result;
|
|
77
|
-
}
|
|
58
|
+
* Recursively walks the layer tree and loads the image for every
|
|
59
|
+
* `imagelayer` encountered. Returns a `Map` keyed by layer `id` so that
|
|
60
|
+
* {@link TiledMap.toTileMap} can attach the pre-loaded {@link Texture} to each
|
|
61
|
+
* runtime image layer without performing additional I/O.
|
|
62
|
+
*/
|
|
63
|
+
const loadImageLayerTextures = async (layers, mapSource, context) => {
|
|
64
|
+
const result = /* @__PURE__ */ new Map();
|
|
65
|
+
for (const layer of layers) if (layer.type === "imagelayer" && layer.image) {
|
|
66
|
+
const imageUrl = resolveTiledUrl(layer.image, mapSource);
|
|
67
|
+
const texture = await context.dependencies.load(Asset.type("texture", imageUrl));
|
|
68
|
+
result.set(layer.id, texture);
|
|
69
|
+
} else if (layer.type === "group") {
|
|
70
|
+
const nested = await loadImageLayerTextures(layer.layers, mapSource, context);
|
|
71
|
+
for (const [id, tex] of nested) result.set(id, tex);
|
|
72
|
+
}
|
|
73
|
+
return result;
|
|
74
|
+
};
|
|
78
75
|
/**
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
async
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const data = validateTiledMapData(raw, source);
|
|
90
|
-
const [tilesets, imageTextures] = await Promise.all([
|
|
91
|
-
Promise.all(data.tilesets.map(ref => loadTiledTileset(ref, source, context))),
|
|
92
|
-
loadImageLayerTextures(data.layers, source, context),
|
|
93
|
-
]);
|
|
94
|
-
return new TiledMap(source, data, tilesets, imageTextures);
|
|
95
|
-
}
|
|
76
|
+
* Assembles a validated Tiled document into a {@link TiledMap}: resolves every
|
|
77
|
+
* tileset (external `.tsj` or embedded) and its images, loads every image
|
|
78
|
+
* layer's texture, and validates the GIDs against the assembled tilesets.
|
|
79
|
+
* @internal
|
|
80
|
+
*/
|
|
81
|
+
const loadTiledMap = async (data, context) => {
|
|
82
|
+
const source = context.source;
|
|
83
|
+
const [tilesets, imageTextures] = await Promise.all([Promise.all(data.tilesets.map((ref) => loadTiledTileset(ref, source, context))), loadImageLayerTextures(data.layers, source, context)]);
|
|
84
|
+
return new TiledMap(source, data, tilesets, imageTextures);
|
|
85
|
+
};
|
|
96
86
|
|
|
87
|
+
//#endregion
|
|
97
88
|
export { loadTiledMap };
|
|
98
|
-
//# sourceMappingURL=loadTiledMap.js.map
|
|
89
|
+
//# sourceMappingURL=loadTiledMap.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadTiledMap.js","sources":["
|
|
1
|
+
{"version":3,"file":"loadTiledMap.js","names":[],"sources":["../../src/loadTiledMap.ts"],"sourcesContent":["import type { AssetFactoryContext, Texture } from '@codexo/exojs';\nimport { Asset } from '@codexo/exojs';\n\nimport type { TiledLayerData, TiledMapData, TiledTilesetData, TiledTilesetRefData } from './data';\nimport { TiledMap } from './TiledMap';\nimport type { TiledLoadOptions } from './tiledOptions';\nimport { TiledTileset, type TiledTilesetResources } from './TiledTileset';\nimport { resolveTiledUrl } from './url';\nimport { validateTiledTilesetFileData } from './validate';\n\n/** What every step below needs from the load it belongs to. */\ntype TiledContext = AssetFactoryContext<TiledLoadOptions>;\n\n/**\n * Resolves and loads the image(s) referenced by a tileset: the atlas\n * `image` (if present) and any collection-of-images per-tile `image`\n * entries, relative to `baseUrl` (the resolved location of the file the\n * tileset data came from - the `.tmj` for an embedded tileset, the `.tsj`\n * for an external one).\n *\n * Textures are claimed by this map's own dependency scope, which deduplicates\n * concurrent and repeated loads of the same normalized URL and releases them\n * with the map.\n */\nconst loadTiledTilesetResources = async (data: TiledTilesetData, baseUrl: string, context: TiledContext, source?: string): Promise<TiledTilesetResources> => {\n let imageUrl: string | undefined;\n let texture: Texture | undefined;\n\n if (data.image !== undefined) {\n imageUrl = resolveTiledUrl(data.image, baseUrl);\n texture = await context.dependencies.load(Asset.type('texture', imageUrl));\n }\n\n let tileTextures: Map<number, Texture> | undefined;\n\n if (data.tiles !== undefined) {\n for (const tile of data.tiles) {\n if (tile.image === undefined) {\n continue;\n }\n\n const tileImageUrl = resolveTiledUrl(tile.image, baseUrl);\n const tileTexture: Texture = await context.dependencies.load(Asset.type('texture', tileImageUrl));\n\n tileTextures ??= new Map();\n tileTextures.set(tile.id, tileTexture);\n }\n }\n\n return { source, imageUrl, texture, tileTextures };\n};\n\n/**\n * Resolves one `tilesets[]` entry of a `.tmj` file to a {@link TiledTileset}:\n * fetches and validates the external `.tsj` if `ref.source` is set, or uses\n * the embedded tileset data directly, then resolves and loads its image(s).\n */\nconst loadTiledTileset = async (ref: TiledTilesetRefData, mapSource: string, context: TiledContext): Promise<TiledTileset> => {\n if ('source' in ref) {\n const tsjUrl = resolveTiledUrl(ref.source, mapSource);\n // An external tileset is an ordinary JSON asset: acquiring it through the\n // dependency scope gives it its own identity and cache record, and shares\n // one download between every map that references it.\n const raw = await context.dependencies.load(Asset.type('json', tsjUrl));\n const data = validateTiledTilesetFileData(raw, tsjUrl);\n const resources = await loadTiledTilesetResources(data, tsjUrl, context, tsjUrl);\n\n return new TiledTileset(data, ref.firstgid, resources);\n }\n\n const resources = await loadTiledTilesetResources(ref, mapSource, context);\n\n return new TiledTileset(ref, ref.firstgid, resources);\n};\n\n/**\n * Recursively walks the layer tree and loads the image for every\n * `imagelayer` encountered. Returns a `Map` keyed by layer `id` so that\n * {@link TiledMap.toTileMap} can attach the pre-loaded {@link Texture} to each\n * runtime image layer without performing additional I/O.\n */\nconst loadImageLayerTextures = async (layers: readonly TiledLayerData[], mapSource: string, context: TiledContext): Promise<Map<number, Texture>> => {\n const result = new Map<number, Texture>();\n\n for (const layer of layers) {\n if (layer.type === 'imagelayer' && layer.image) {\n const imageUrl = resolveTiledUrl(layer.image, mapSource);\n const texture: Texture = await context.dependencies.load(Asset.type('texture', imageUrl));\n result.set(layer.id, texture);\n } else if (layer.type === 'group') {\n const nested = await loadImageLayerTextures(layer.layers, mapSource, context);\n for (const [id, tex] of nested) {\n result.set(id, tex);\n }\n }\n }\n\n return result;\n};\n\n/**\n * Assembles a validated Tiled document into a {@link TiledMap}: resolves every\n * tileset (external `.tsj` or embedded) and its images, loads every image\n * layer's texture, and validates the GIDs against the assembled tilesets.\n * @internal\n */\nexport const loadTiledMap = async (data: TiledMapData, context: TiledContext): Promise<TiledMap> => {\n const source = context.source;\n const [tilesets, imageTextures] = await Promise.all([\n Promise.all(data.tilesets.map(ref => loadTiledTileset(ref, source, context))),\n loadImageLayerTextures(data.layers, source, context),\n ]);\n\n return new TiledMap(source, data, tilesets, imageTextures);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAwBA,MAAM,4BAA4B,OAAO,MAAwB,SAAiB,SAAuB,WAAoD;CAC3J,IAAI;CACJ,IAAI;CAEJ,IAAI,KAAK,UAAU,QAAW;EAC5B,WAAW,gBAAgB,KAAK,OAAO,OAAO;EAC9C,UAAU,MAAM,QAAQ,aAAa,KAAK,MAAM,KAAK,WAAW,QAAQ,CAAC;CAC3E;CAEA,IAAI;CAEJ,IAAI,KAAK,UAAU,QACjB,KAAK,MAAM,QAAQ,KAAK,OAAO;EAC7B,IAAI,KAAK,UAAU,QACjB;EAGF,MAAM,eAAe,gBAAgB,KAAK,OAAO,OAAO;EACxD,MAAM,cAAu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,iBAAiB,MAAM,QAAQ,IAAI,CAClD,QAAQ,IAAI,KAAK,SAAS,KAAI,QAAO,iBAAiB,KAAK,QAAQ,OAAO,CAAC,CAAC,GAC5E,uBAAuB,KAAK,QAAQ,QAAQ,OAAO,CACrD,CAAC;CAED,OAAO,IAAI,SAAS,QAAQ,MAAM,UAAU,aAAa;AAC3D"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { TiledObjectAlignment, TiledOrientation } from './data';
|
|
2
|
+
/** A {@link TiledObjectAlignment} with Tiled's orientation-dependent default already applied. */
|
|
3
|
+
export type TiledResolvedObjectAlignment = Exclude<TiledObjectAlignment, 'unspecified'>;
|
|
4
|
+
/** Every value Tiled accepts for a tileset's `objectalignment`. */
|
|
5
|
+
export declare const TILED_OBJECT_ALIGNMENTS: readonly TiledObjectAlignment[];
|
|
6
|
+
/**
|
|
7
|
+
* Resolve a tileset's `objectalignment` into a concrete alignment for tile
|
|
8
|
+
* objects on a map of the given `orientation`.
|
|
9
|
+
*
|
|
10
|
+
* Tiled's default (`'unspecified'`, and an absent field) is orientation
|
|
11
|
+
* dependent: `'bottom'` on an isometric map and `'bottomleft'` on every other
|
|
12
|
+
* orientation, including staggered and hexagonal.
|
|
13
|
+
* @advanced
|
|
14
|
+
*/
|
|
15
|
+
export declare const resolveTiledObjectAlignment: (alignment: TiledObjectAlignment | undefined, orientation: TiledOrientation) => TiledResolvedObjectAlignment;
|
|
16
|
+
/**
|
|
17
|
+
* Offset of a tile object's stored `x`/`y` anchor from the top-left corner of
|
|
18
|
+
* its `width` × `height` bounding box, for an already-resolved `alignment`.
|
|
19
|
+
*
|
|
20
|
+
* Subtract this from the stored position to obtain the corner:
|
|
21
|
+
* `cornerX = object.x - offset.x`.
|
|
22
|
+
* @advanced
|
|
23
|
+
*/
|
|
24
|
+
export declare const getTiledObjectAnchorOffset: (alignment: TiledResolvedObjectAlignment, width: number, height: number) => {
|
|
25
|
+
readonly x: number;
|
|
26
|
+
readonly y: number;
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=objectAlignment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objectAlignment.d.ts","sourceRoot":"","sources":["../../src/objectAlignment.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAErE,iGAAiG;AACjG,MAAM,MAAM,4BAA4B,GAAG,OAAO,CAAC,oBAAoB,EAAE,aAAa,CAAC,CAAC;AAExF,mEAAmE;AACnE,eAAO,MAAM,uBAAuB,EAAE,SAAS,oBAAoB,EAWlE,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,2BAA2B,GAAI,WAAW,oBAAoB,GAAG,SAAS,EAAE,aAAa,gBAAgB,KAAG,4BAMxH,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,0BAA0B,GACrC,WAAW,4BAA4B,EACvC,OAAO,MAAM,EACb,QAAQ,MAAM,KACb;IAAE,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAA;CAqB1C,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
//#region src/objectAlignment.ts
|
|
2
|
+
/** Every value Tiled accepts for a tileset's `objectalignment`. */
|
|
3
|
+
const TILED_OBJECT_ALIGNMENTS = [
|
|
4
|
+
"unspecified",
|
|
5
|
+
"topleft",
|
|
6
|
+
"top",
|
|
7
|
+
"topright",
|
|
8
|
+
"left",
|
|
9
|
+
"center",
|
|
10
|
+
"right",
|
|
11
|
+
"bottomleft",
|
|
12
|
+
"bottom",
|
|
13
|
+
"bottomright"
|
|
14
|
+
];
|
|
15
|
+
/**
|
|
16
|
+
* Resolve a tileset's `objectalignment` into a concrete alignment for tile
|
|
17
|
+
* objects on a map of the given `orientation`.
|
|
18
|
+
*
|
|
19
|
+
* Tiled's default (`'unspecified'`, and an absent field) is orientation
|
|
20
|
+
* dependent: `'bottom'` on an isometric map and `'bottomleft'` on every other
|
|
21
|
+
* orientation, including staggered and hexagonal.
|
|
22
|
+
* @advanced
|
|
23
|
+
*/
|
|
24
|
+
const resolveTiledObjectAlignment = (alignment, orientation) => {
|
|
25
|
+
if (alignment !== void 0 && alignment !== "unspecified") return alignment;
|
|
26
|
+
return orientation === "isometric" ? "bottom" : "bottomleft";
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Offset of a tile object's stored `x`/`y` anchor from the top-left corner of
|
|
30
|
+
* its `width` × `height` bounding box, for an already-resolved `alignment`.
|
|
31
|
+
*
|
|
32
|
+
* Subtract this from the stored position to obtain the corner:
|
|
33
|
+
* `cornerX = object.x - offset.x`.
|
|
34
|
+
* @advanced
|
|
35
|
+
*/
|
|
36
|
+
const getTiledObjectAnchorOffset = (alignment, width, height) => {
|
|
37
|
+
switch (alignment) {
|
|
38
|
+
case "topleft": return {
|
|
39
|
+
x: 0,
|
|
40
|
+
y: 0
|
|
41
|
+
};
|
|
42
|
+
case "top": return {
|
|
43
|
+
x: width / 2,
|
|
44
|
+
y: 0
|
|
45
|
+
};
|
|
46
|
+
case "topright": return {
|
|
47
|
+
x: width,
|
|
48
|
+
y: 0
|
|
49
|
+
};
|
|
50
|
+
case "left": return {
|
|
51
|
+
x: 0,
|
|
52
|
+
y: height / 2
|
|
53
|
+
};
|
|
54
|
+
case "center": return {
|
|
55
|
+
x: width / 2,
|
|
56
|
+
y: height / 2
|
|
57
|
+
};
|
|
58
|
+
case "right": return {
|
|
59
|
+
x: width,
|
|
60
|
+
y: height / 2
|
|
61
|
+
};
|
|
62
|
+
case "bottomleft": return {
|
|
63
|
+
x: 0,
|
|
64
|
+
y: height
|
|
65
|
+
};
|
|
66
|
+
case "bottom": return {
|
|
67
|
+
x: width / 2,
|
|
68
|
+
y: height
|
|
69
|
+
};
|
|
70
|
+
case "bottomright": return {
|
|
71
|
+
x: width,
|
|
72
|
+
y: height
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
//#endregion
|
|
78
|
+
export { TILED_OBJECT_ALIGNMENTS, getTiledObjectAnchorOffset, resolveTiledObjectAlignment };
|
|
79
|
+
//# sourceMappingURL=objectAlignment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objectAlignment.js","names":[],"sources":["../../src/objectAlignment.ts"],"sourcesContent":["// Tile-object anchoring rules, mirroring Tiled's own `MapObject::alignment()`\n// and `alignmentOffset()` from libtiled.\n\nimport type { TiledObjectAlignment, TiledOrientation } from './data';\n\n/** A {@link TiledObjectAlignment} with Tiled's orientation-dependent default already applied. */\nexport type TiledResolvedObjectAlignment = Exclude<TiledObjectAlignment, 'unspecified'>;\n\n/** Every value Tiled accepts for a tileset's `objectalignment`. */\nexport const TILED_OBJECT_ALIGNMENTS: readonly TiledObjectAlignment[] = [\n 'unspecified',\n 'topleft',\n 'top',\n 'topright',\n 'left',\n 'center',\n 'right',\n 'bottomleft',\n 'bottom',\n 'bottomright',\n];\n\n/**\n * Resolve a tileset's `objectalignment` into a concrete alignment for tile\n * objects on a map of the given `orientation`.\n *\n * Tiled's default (`'unspecified'`, and an absent field) is orientation\n * dependent: `'bottom'` on an isometric map and `'bottomleft'` on every other\n * orientation, including staggered and hexagonal.\n * @advanced\n */\nexport const resolveTiledObjectAlignment = (alignment: TiledObjectAlignment | undefined, orientation: TiledOrientation): TiledResolvedObjectAlignment => {\n if (alignment !== undefined && alignment !== 'unspecified') {\n return alignment;\n }\n\n return orientation === 'isometric' ? 'bottom' : 'bottomleft';\n};\n\n/**\n * Offset of a tile object's stored `x`/`y` anchor from the top-left corner of\n * its `width` × `height` bounding box, for an already-resolved `alignment`.\n *\n * Subtract this from the stored position to obtain the corner:\n * `cornerX = object.x - offset.x`.\n * @advanced\n */\nexport const getTiledObjectAnchorOffset = (\n alignment: TiledResolvedObjectAlignment,\n width: number,\n height: number,\n): { readonly x: number; readonly y: number } => {\n switch (alignment) {\n case 'topleft':\n return { x: 0, y: 0 };\n case 'top':\n return { x: width / 2, y: 0 };\n case 'topright':\n return { x: width, y: 0 };\n case 'left':\n return { x: 0, y: height / 2 };\n case 'center':\n return { x: width / 2, y: height / 2 };\n case 'right':\n return { x: width, y: height / 2 };\n case 'bottomleft':\n return { x: 0, y: height };\n case 'bottom':\n return { x: width / 2, y: height };\n case 'bottomright':\n return { x: width, y: height };\n }\n};\n"],"mappings":";;AASA,MAAa,0BAA2D;CACtE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;;;;AAWA,MAAa,+BAA+B,WAA6C,gBAAgE;CACvJ,IAAI,cAAc,UAAa,cAAc,eAC3C,OAAO;CAGT,OAAO,gBAAgB,cAAc,WAAW;AAClD;;;;;;;;;AAUA,MAAa,8BACX,WACA,OACA,WAC+C;CAC/C,QAAQ,WAAR;EACE,KAAK,WACH,OAAO;GAAE,GAAG;GAAG,GAAG;EAAE;EACtB,KAAK,OACH,OAAO;GAAE,GAAG,QAAQ;GAAG,GAAG;EAAE;EAC9B,KAAK,YACH,OAAO;GAAE,GAAG;GAAO,GAAG;EAAE;EAC1B,KAAK,QACH,OAAO;GAAE,GAAG;GAAG,GAAG,SAAS;EAAE;EAC/B,KAAK,UACH,OAAO;GAAE,GAAG,QAAQ;GAAG,GAAG,SAAS;EAAE;EACvC,KAAK,SACH,OAAO;GAAE,GAAG;GAAO,GAAG,SAAS;EAAE;EACnC,KAAK,cACH,OAAO;GAAE,GAAG;GAAG,GAAG;EAAO;EAC3B,KAAK,UACH,OAAO;GAAE,GAAG,QAAQ;GAAG,GAAG;EAAO;EACnC,KAAK,eACH,OAAO;GAAE,GAAG;GAAO,GAAG;EAAO;CACjC;AACF"}
|
package/dist/esm/public.d.ts
CHANGED
|
@@ -1,31 +1,29 @@
|
|
|
1
1
|
export { type TiledLoadOptions } from './tiledOptions';
|
|
2
|
-
export type {
|
|
2
|
+
export type { AssetEntry, Extension } from '@codexo/exojs/extensions';
|
|
3
3
|
export type { TiledBuildInfo } from './tiledBuildInfo';
|
|
4
4
|
export { tiledBuildInfo } from './tiledBuildInfo';
|
|
5
5
|
export { tiledExtension } from './tiledExtension';
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export type { ChunkCoord, EllipseObject, ObjectLayerOptions, ObjectPoint, ObjectQuery, PackedTile, PointObject, PolygonObject, PolylineObject, ReadonlyTileChunk, RectangleObject, ResolvedTile, TileDefinition, TileLayerNodeOptions, TileLayerOptions, TileLayerSelector, TileMapBandDefinition, TileMapNodeOptions, TileMapObject, TileMapObjectKind, TileMapOptions, TileMapViewOptions, TileObject, TileProperties, TilePropertyValue, TileSetOptions, TileTransform, WangSetOptions, } from '@codexo/exojs-tilemap';
|
|
9
|
-
export { ObjectLayer, TILE_TRANSFORM_IDENTITY, TileLayer, TileLayerNode, TileMap, TileMapBand, tilemapExtension, TileMapNode, TileMapView, TileSet, WangSet, } from '@codexo/exojs-tilemap';
|
|
10
|
-
export type { TiledAnimationFrameData, TiledChunkData, TiledClassPropertyValueData, TiledEmbeddedTilesetRefData, TiledExternalTilesetRefData, TiledGroupLayerData, TiledImageLayerData, TiledLayerData, TiledLayerDataBase, TiledMapData, TiledObjectData, TiledObjectLayerData, TiledOrientation, TiledPointData, TiledPropertyData, TiledPropertyType, TiledRenderOrder, TiledTextData, TiledTileData, TiledTileLayerData, TiledTilesetData, TiledTilesetRefData, TiledWangColorData, TiledWangSetData, TiledWangTileData, } from './data';
|
|
6
|
+
export { TiledSourceAssetType, tiledSourceType } from './tiledSourceType';
|
|
7
|
+
export { TileMapAssetType, tileMapType } from './tileMapType';
|
|
8
|
+
export type { ChunkCoord, EllipseObject, MapBounds, MapLevel, MapLevelCancelOptions, MapLevelLoadContext, MapLevelLoadOptions, MapLevelNeighbour, MapLevelProvider, MapObjectDescriptor, MapObjectFactories, MapObjectFactory, MapObjectSpawnerOptions, MapSpawnErrorReason, MapSpawnOptions, MapWorldOptions, MapWorldRuntimeOptions, ObjectLayerOptions, ObjectPoint, ObjectQuery, PackedTile, PointObject, PolygonObject, PolylineObject, ReadonlyTileChunk, RectangleObject, ResolvedTile, TileDefinition, TileLayerNodeOptions, TileLayerOptions, TileLayerSelector, TileMapBandDefinition, TileMapNodeOptions, TileMapObject, TileMapObjectKind, TileMapOptions, TileMapViewOptions, TileObject, TileProperties, TilePropertyValue, TileSetOptions, TileTransform, UnknownMapObjectPolicy, WangSetOptions, } from '@codexo/exojs-tilemap';
|
|
9
|
+
export { MapLevelRuntime, MapLevelSide, mapObjectDescriptor, mapObjectDescriptors, MapObjectSpawner, MapSpawnError, MapSpawnSession, MapWorld, MapWorldRuntime, ObjectLayer, TILE_TRANSFORM_IDENTITY, TileLayer, TileLayerNode, TileMap, TileMapBand, tilemapExtension, TileMapNode, TileMapView, TileSet, WangSet, } from '@codexo/exojs-tilemap';
|
|
10
|
+
export type { TiledAnimationFrameData, TiledChunkData, TiledClassPropertyValueData, TiledEmbeddedTilesetRefData, TiledExternalTilesetRefData, TiledGroupLayerData, TiledImageLayerData, TiledLayerData, TiledLayerDataBase, TiledMapData, TiledObjectAlignment, TiledObjectData, TiledObjectLayerData, TiledOrientation, TiledPointData, TiledPropertyData, TiledPropertyType, TiledRenderOrder, TiledTextData, TiledTileData, TiledTileLayerData, TiledTilesetData, TiledTilesetRefData, TiledWangColorData, TiledWangSetData, TiledWangTileData, } from './data';
|
|
11
11
|
export type { TiledLayerType } from './TiledLayer';
|
|
12
|
-
export { createTiledLayer, TiledGroupLayer, TiledImageLayer, TiledLayer, TiledObjectLayer, TiledTileLayer
|
|
12
|
+
export { createTiledLayer, TiledGroupLayer, TiledImageLayer, TiledLayer, TiledObjectLayer, TiledTileLayer } from './TiledLayer';
|
|
13
13
|
export { TiledMap } from './TiledMap';
|
|
14
14
|
export { TiledObject } from './TiledObject';
|
|
15
15
|
export type { TiledTilesetResources } from './TiledTileset';
|
|
16
16
|
export { TiledTileset } from './TiledTileset';
|
|
17
|
+
export type { TiledResolvedObjectAlignment } from './objectAlignment';
|
|
18
|
+
export { getTiledObjectAnchorOffset, resolveTiledObjectAlignment, TILED_OBJECT_ALIGNMENTS } from './objectAlignment';
|
|
17
19
|
export { tiledWangSetToWangSet } from './wangSets';
|
|
18
20
|
export { TiledFormatError } from './validate';
|
|
19
21
|
import type { TileMap } from '@codexo/exojs-tilemap';
|
|
20
22
|
import type { TiledMap } from './TiledMap';
|
|
21
23
|
declare module '@codexo/exojs' {
|
|
22
|
-
interface
|
|
23
|
-
/** `.tmj` path
|
|
24
|
-
tmj:
|
|
25
|
-
}
|
|
26
|
-
interface ExtensionTokenTypeMap {
|
|
27
|
-
/** The advanced parsed-source token is also accepted for `.tmj`: `load(TiledMap, 'world.tmj')`. */
|
|
28
|
-
tmj: TiledMap;
|
|
24
|
+
interface ExtensionKindMap {
|
|
25
|
+
/** `.tmj` bare-path loads resolve to the generic runtime `tileMap` type ({@link TileMap}). */
|
|
26
|
+
tmj: 'tileMap';
|
|
29
27
|
}
|
|
30
28
|
interface AssetDefinitions {
|
|
31
29
|
tileMap: {
|
|
@@ -34,13 +32,17 @@ declare module '@codexo/exojs' {
|
|
|
34
32
|
source: string;
|
|
35
33
|
format?: 'tiled';
|
|
36
34
|
};
|
|
35
|
+
isValue: true;
|
|
37
36
|
};
|
|
38
|
-
|
|
37
|
+
tiledSource: {
|
|
39
38
|
resource: TiledMap;
|
|
40
39
|
config: {
|
|
41
40
|
source: string;
|
|
42
41
|
format?: 'tiled';
|
|
43
42
|
};
|
|
43
|
+
/** See `tileMap` - `tiledSourceType` keeps the default leaf too. */
|
|
44
|
+
isValue: true;
|
|
44
45
|
};
|
|
45
46
|
}
|
|
46
47
|
}
|
|
48
|
+
//# sourceMappingURL=public.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/public.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,gBAAgB,EAAE,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gBAAgB;QACxB,OAAO,EAAE;YACP,QAAQ,EAAE,OAAO,CAAC;YAClB,MAAM,EAAE;gBAAE,MAAM,EAAE,MAAM,CAAC;gBAAC,MAAM,CAAC,EAAE,OAAO,CAAA;aAAE,CAAC;YAG7C,OAAO,EAAE,IAAI,CAAC;SACf,CAAC;QACF,WAAW,EAAE;YACX,QAAQ,EAAE,QAAQ,CAAC;YACnB,MAAM,EAAE;gBAAE,MAAM,EAAE,MAAM,CAAC;gBAAC,MAAM,CAAC,EAAE,OAAO,CAAA;aAAE,CAAC;YAC7C,oEAAoE;YACpE,OAAO,EAAE,IAAI,CAAC;SACf,CAAC;KACH;CACF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { tiledBuildInfo } from "./tiledBuildInfo.js";
|
|
2
|
+
import { TILED_OBJECT_ALIGNMENTS, getTiledObjectAnchorOffset, resolveTiledObjectAlignment } from "./objectAlignment.js";
|
|
3
|
+
import { TiledFormatError } from "./validate.js";
|
|
4
|
+
import { TiledObject } from "./TiledObject.js";
|
|
5
|
+
import { TiledGroupLayer, TiledImageLayer, TiledLayer, TiledObjectLayer, TiledTileLayer, createTiledLayer } from "./TiledLayer.js";
|
|
6
|
+
import { TiledMap } from "./TiledMap.js";
|
|
7
|
+
import { TiledTileset } from "./TiledTileset.js";
|
|
8
|
+
import { TiledSourceAssetType, tiledSourceType } from "./tiledSourceType.js";
|
|
9
|
+
import { TileMapAssetType, tileMapType } from "./tileMapType.js";
|
|
10
|
+
import { tiledExtension } from "./tiledExtension.js";
|
|
11
|
+
import { tiledWangSetToWangSet } from "./wangSets.js";
|
|
12
|
+
import { MapLevelRuntime, MapLevelSide, MapObjectSpawner, MapSpawnError, MapSpawnSession, MapWorld, MapWorldRuntime, ObjectLayer as ObjectLayer$1, TILE_TRANSFORM_IDENTITY, TileLayer as TileLayer$1, TileLayerNode, TileMap as TileMap$1, TileMapBand, TileMapNode, TileMapView, TileSet as TileSet$1, WangSet as WangSet$1, mapObjectDescriptor, mapObjectDescriptors, tilemapExtension as tilemapExtension$1 } from "@codexo/exojs-tilemap";
|
|
13
|
+
|
|
14
|
+
export { MapLevelRuntime, MapLevelSide, MapObjectSpawner, MapSpawnError, MapSpawnSession, MapWorld, MapWorldRuntime, ObjectLayer$1 as ObjectLayer, TILED_OBJECT_ALIGNMENTS, TILE_TRANSFORM_IDENTITY, TileLayer$1 as TileLayer, TileLayerNode, TileMap$1 as TileMap, TileMapAssetType, TileMapBand, TileMapNode, TileMapView, TileSet$1 as TileSet, TiledFormatError, TiledGroupLayer, TiledImageLayer, TiledLayer, TiledMap, TiledObject, TiledObjectLayer, TiledSourceAssetType, TiledTileLayer, TiledTileset, WangSet$1 as WangSet, createTiledLayer, getTiledObjectAnchorOffset, mapObjectDescriptor, mapObjectDescriptors, resolveTiledObjectAlignment, tileMapType, tiledBuildInfo, tiledExtension, tiledSourceType, tiledWangSetToWangSet, tilemapExtension$1 as tilemapExtension };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { AssetFactory } from '@codexo/exojs';
|
|
2
|
+
import { type AssetRequest, AssetType } from '@codexo/exojs';
|
|
3
|
+
import { TileMap } from '@codexo/exojs-tilemap';
|
|
4
|
+
import { type TiledLoadOptions } from './tiledOptions';
|
|
5
|
+
/**
|
|
6
|
+
* The format-independent runtime {@link TileMap} produced from a `.tmj` file -
|
|
7
|
+
* the common case.
|
|
8
|
+
*
|
|
9
|
+
* The `.tmj` itself is acquired once as a `tiledSource` dependency, so loading
|
|
10
|
+
* both the runtime map and the source model for one URL shares a single
|
|
11
|
+
* download and a single parsed document.
|
|
12
|
+
*/
|
|
13
|
+
export declare class TileMapAssetType extends AssetType<void, TileMap, TiledLoadOptions> {
|
|
14
|
+
readonly id = "tileMap";
|
|
15
|
+
readonly extensions: string[];
|
|
16
|
+
readonly _token: typeof TileMap;
|
|
17
|
+
resourceIdentity({ options }: AssetRequest<TiledLoadOptions>): string;
|
|
18
|
+
/**
|
|
19
|
+
* The runtime map has no source data of its own: it is built from the
|
|
20
|
+
* `tiledSource` asset its factory loads. Acquiring the document here as well
|
|
21
|
+
* would download, parse and validate it a second time under a second
|
|
22
|
+
* identity.
|
|
23
|
+
*/
|
|
24
|
+
unacquiredSource(): {
|
|
25
|
+
source: void;
|
|
26
|
+
};
|
|
27
|
+
createFactory(): AssetFactory<void, TileMap, TiledLoadOptions>;
|
|
28
|
+
}
|
|
29
|
+
/** The runtime tilemap asset type for Tiled maps. Install it through `tiledExtension`. */
|
|
30
|
+
export declare const tileMapType: TileMapAssetType;
|
|
31
|
+
//# sourceMappingURL=tileMapType.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tileMapType.d.ts","sourceRoot":"","sources":["../../src/tileMapType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,KAAK,YAAY,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,OAAO,EAAuB,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAG5E;;;;;;;GAOG;AACH,qBAAa,gBAAiB,SAAQ,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,gBAAgB,CAAC;IAC9E,SAAgB,EAAE,aAAa;IAC/B,SAAyB,UAAU,WAAW;IAC9C,SAAyB,MAAM,iBAAW;IAE1B,gBAAgB,CAAC,EAAE,OAAO,EAAE,EAAE,YAAY,CAAC,gBAAgB,CAAC,GAAG,MAAM;IAIrF;;;;;OAKG;IACa,gBAAgB,IAAI;QAAE,MAAM,EAAE,IAAI,CAAA;KAAE;IAI7C,aAAa,IAAI,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,gBAAgB,CAAC;CAStE;AAED,0FAA0F;AAC1F,eAAO,MAAM,WAAW,kBAAyB,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { resolveTiledOptions } from "./tiledOptions.js";
|
|
2
|
+
import { tiledSourceType } from "./tiledSourceType.js";
|
|
3
|
+
import { TileMap } from "@codexo/exojs-tilemap";
|
|
4
|
+
import { AssetType } from "@codexo/exojs";
|
|
5
|
+
|
|
6
|
+
//#region src/tileMapType.ts
|
|
7
|
+
/**
|
|
8
|
+
* The format-independent runtime {@link TileMap} produced from a `.tmj` file -
|
|
9
|
+
* the common case.
|
|
10
|
+
*
|
|
11
|
+
* The `.tmj` itself is acquired once as a `tiledSource` dependency, so loading
|
|
12
|
+
* both the runtime map and the source model for one URL shares a single
|
|
13
|
+
* download and a single parsed document.
|
|
14
|
+
*/
|
|
15
|
+
var TileMapAssetType = class extends AssetType {
|
|
16
|
+
id = "tileMap";
|
|
17
|
+
extensions = ["tmj"];
|
|
18
|
+
_token = TileMap;
|
|
19
|
+
resourceIdentity({ options }) {
|
|
20
|
+
return resolveTiledOptions(options).format;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The runtime map has no source data of its own: it is built from the
|
|
24
|
+
* `tiledSource` asset its factory loads. Acquiring the document here as well
|
|
25
|
+
* would download, parse and validate it a second time under a second
|
|
26
|
+
* identity.
|
|
27
|
+
*/
|
|
28
|
+
unacquiredSource() {
|
|
29
|
+
return { source: void 0 };
|
|
30
|
+
}
|
|
31
|
+
createFactory() {
|
|
32
|
+
return { async create(_source, context) {
|
|
33
|
+
return (await context.dependencies.load(tiledSourceType.asset(context.source, context.options))).toTileMap();
|
|
34
|
+
} };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
/** The runtime tilemap asset type for Tiled maps. Install it through `tiledExtension`. */
|
|
38
|
+
const tileMapType = new TileMapAssetType();
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
export { TileMapAssetType, tileMapType };
|
|
42
|
+
//# sourceMappingURL=tileMapType.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tileMapType.js","names":[],"sources":["../../src/tileMapType.ts"],"sourcesContent":["import type { AssetFactory } from '@codexo/exojs';\nimport { type AssetRequest, AssetType } from '@codexo/exojs';\nimport { TileMap } from '@codexo/exojs-tilemap';\n\nimport { resolveTiledOptions, type TiledLoadOptions } from './tiledOptions';\nimport { tiledSourceType } from './tiledSourceType';\n\n/**\n * The format-independent runtime {@link TileMap} produced from a `.tmj` file -\n * the common case.\n *\n * The `.tmj` itself is acquired once as a `tiledSource` dependency, so loading\n * both the runtime map and the source model for one URL shares a single\n * download and a single parsed document.\n */\nexport class TileMapAssetType extends AssetType<void, TileMap, TiledLoadOptions> {\n public readonly id = 'tileMap';\n public override readonly extensions = ['tmj'];\n public override readonly _token = TileMap;\n\n public override resourceIdentity({ options }: AssetRequest<TiledLoadOptions>): string {\n return resolveTiledOptions(options).format;\n }\n\n /**\n * The runtime map has no source data of its own: it is built from the\n * `tiledSource` asset its factory loads. Acquiring the document here as well\n * would download, parse and validate it a second time under a second\n * identity.\n */\n public override unacquiredSource(): { source: void } {\n return { source: undefined };\n }\n\n public createFactory(): AssetFactory<void, TileMap, TiledLoadOptions> {\n return {\n async create(_source, context) {\n const tiledMap = await context.dependencies.load(tiledSourceType.asset(context.source, context.options));\n\n return tiledMap.toTileMap();\n },\n };\n }\n}\n\n/** The runtime tilemap asset type for Tiled maps. Install it through `tiledExtension`. */\nexport const tileMapType = new TileMapAssetType();\n"],"mappings":";;;;;;;;;;;;;;AAeA,IAAa,mBAAb,cAAsC,UAA2C;CAC/E,AAAgB,KAAK;CACrB,AAAyB,aAAa,CAAC,KAAK;CAC5C,AAAyB,SAAS;CAElC,AAAgB,iBAAiB,EAAE,WAAmD;EACpF,OAAO,oBAAoB,OAAO,CAAC,CAAC;CACtC;;;;;;;CAQA,AAAgB,mBAAqC;EACnD,OAAO,EAAE,QAAQ,OAAU;CAC7B;CAEA,AAAO,gBAA+D;EACpE,OAAO,EACL,MAAM,OAAO,SAAS,SAAS;GAG7B,QAAO,MAFgB,QAAQ,aAAa,KAAK,gBAAgB,MAAM,QAAQ,QAAQ,QAAQ,OAAO,CAAC,EAExF,CAAC,UAAU;EAC5B,EACF;CACF;AACF;;AAGA,MAAa,cAAc,IAAI,iBAAiB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tiledBuildInfo.d.ts","sourceRoot":"","sources":["../../src/tiledBuildInfo.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;CAC/B;AAED,eAAO,MAAM,cAAc,EAAE,cAI3B,CAAC"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
//#region src/tiledBuildInfo.ts
|
|
1
2
|
const tiledBuildInfo = Object.freeze({
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
version: "0.16.0",
|
|
4
|
+
revision: "3a59179",
|
|
5
|
+
development: false
|
|
5
6
|
});
|
|
6
7
|
|
|
8
|
+
//#endregion
|
|
7
9
|
export { tiledBuildInfo };
|
|
8
|
-
//# sourceMappingURL=tiledBuildInfo.js.map
|
|
10
|
+
//# sourceMappingURL=tiledBuildInfo.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tiledBuildInfo.js","sources":["
|
|
1
|
+
{"version":3,"file":"tiledBuildInfo.js","names":[],"sources":["../../src/tiledBuildInfo.ts"],"sourcesContent":["/**\n * Immutable compile-time build metadata for `@codexo/exojs-tiled`.\n *\n * `development` mirrors the `__DEV__` compile-time constant and is statically\n * replaced before tree shaking. `version` is the exact `package.json` version\n * of the Tiled package at build time. `revision` is the short\n * source-control revision (appended with `-dirty` when uncommitted changes are\n * present) or `\"unknown\"` when no revision information is available.\n */\nexport interface TiledBuildInfo {\n readonly version: string;\n readonly revision: string;\n readonly development: boolean;\n}\n\nexport const tiledBuildInfo: TiledBuildInfo = Object.freeze({\n version: __VERSION__,\n revision: __REVISION__,\n development: __DEV__,\n});\n"],"mappings":";AAeA,MAAa,iBAAiC,OAAO,OAAO;CAC1D;CACA;CACA;AACF,CAAC"}
|
|
@@ -2,16 +2,17 @@ import type { Extension } from '@codexo/exojs/extensions';
|
|
|
2
2
|
/**
|
|
3
3
|
* Default immutable Tiled extension descriptor.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
* - {@link
|
|
7
|
-
*
|
|
8
|
-
* - {@link
|
|
5
|
+
* Installs two asset types:
|
|
6
|
+
* - {@link tileMapType} - `loader.load(tileMapType.asset('world.tmj'))` returns
|
|
7
|
+
* a format-independent runtime {@link TileMap} (common case).
|
|
8
|
+
* - {@link tiledSourceType} - `loader.load(tiledSourceType.asset('world.tmj'))`
|
|
9
9
|
* returns the raw parsed {@link TiledMap} source model (advanced/diagnostic).
|
|
10
10
|
*
|
|
11
11
|
* Depends on {@link tilemapExtension} so that snapshot construction always
|
|
12
12
|
* materialises the generic tilemap runtime before the Tiled adapter.
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
* `
|
|
14
|
+
* Pass it to the application that should have it via
|
|
15
|
+
* `ApplicationOptions.extensions`.
|
|
16
16
|
*/
|
|
17
17
|
export declare const tiledExtension: Extension;
|
|
18
|
+
//# sourceMappingURL=tiledExtension.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tiledExtension.d.ts","sourceRoot":"","sources":["../../src/tiledExtension.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAM1D;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,cAAc,EAAE,SAM3B,CAAC"}
|