@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
|
@@ -1,31 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { tiledSourceType } from "./tiledSourceType.js";
|
|
2
|
+
import { tileMapType } from "./tileMapType.js";
|
|
3
|
+
import { tilemapExtension } from "@codexo/exojs-tilemap";
|
|
4
4
|
|
|
5
|
+
//#region src/tiledExtension.ts
|
|
5
6
|
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
7
|
+
* Default immutable Tiled extension descriptor.
|
|
8
|
+
*
|
|
9
|
+
* Installs two asset types:
|
|
10
|
+
* - {@link tileMapType} - `loader.load(tileMapType.asset('world.tmj'))` returns
|
|
11
|
+
* a format-independent runtime {@link TileMap} (common case).
|
|
12
|
+
* - {@link tiledSourceType} - `loader.load(tiledSourceType.asset('world.tmj'))`
|
|
13
|
+
* returns the raw parsed {@link TiledMap} source model (advanced/diagnostic).
|
|
14
|
+
*
|
|
15
|
+
* Depends on {@link tilemapExtension} so that snapshot construction always
|
|
16
|
+
* materialises the generic tilemap runtime before the Tiled adapter.
|
|
17
|
+
*
|
|
18
|
+
* Pass it to the application that should have it via
|
|
19
|
+
* `ApplicationOptions.extensions`.
|
|
20
|
+
*/
|
|
20
21
|
const tiledExtension = Object.freeze({
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
// untyped Extension.assets contract here. Runtime behavior is unaffected —
|
|
25
|
-
// materializeAssetBindings calls create() and bindAsset() correctly regardless
|
|
26
|
-
// of the erased Options type.
|
|
27
|
-
assets: [tiledRuntimeMapBinding, tiledMapBinding],
|
|
22
|
+
id: "@codexo/exojs-tiled",
|
|
23
|
+
dependencies: [tilemapExtension],
|
|
24
|
+
assets: [tileMapType, tiledSourceType]
|
|
28
25
|
});
|
|
29
26
|
|
|
27
|
+
//#endregion
|
|
30
28
|
export { tiledExtension };
|
|
31
|
-
//# sourceMappingURL=tiledExtension.js.map
|
|
29
|
+
//# sourceMappingURL=tiledExtension.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tiledExtension.js","sources":["
|
|
1
|
+
{"version":3,"file":"tiledExtension.js","names":[],"sources":["../../src/tiledExtension.ts"],"sourcesContent":["import type { Extension } from '@codexo/exojs/extensions';\nimport { tilemapExtension } from '@codexo/exojs-tilemap';\n\nimport { tiledSourceType } from './tiledSourceType';\nimport { tileMapType } from './tileMapType';\n\n/**\n * Default immutable Tiled extension descriptor.\n *\n * Installs two asset types:\n * - {@link tileMapType} - `loader.load(tileMapType.asset('world.tmj'))` returns\n * a format-independent runtime {@link TileMap} (common case).\n * - {@link tiledSourceType} - `loader.load(tiledSourceType.asset('world.tmj'))`\n * returns the raw parsed {@link TiledMap} source model (advanced/diagnostic).\n *\n * Depends on {@link tilemapExtension} so that snapshot construction always\n * materialises the generic tilemap runtime before the Tiled adapter.\n *\n * Pass it to the application that should have it via\n * `ApplicationOptions.extensions`.\n */\nexport const tiledExtension: Extension = Object.freeze({\n id: '@codexo/exojs-tiled',\n dependencies: [tilemapExtension],\n // Localized erasure cast: typed types (Options=TiledLoadOptions) meet the\n // untyped Extension.assets contract here. Runtime behavior is unaffected.\n assets: [tileMapType, tiledSourceType],\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAqBA,MAAa,iBAA4B,OAAO,OAAO;CACrD,IAAI;CACJ,cAAc,CAAC,gBAAgB;CAG/B,QAAQ,CAAC,aAAa,eAAe;AACvC,CAAC"}
|
|
@@ -9,7 +9,7 @@ export interface TiledLoadOptions {
|
|
|
9
9
|
*
|
|
10
10
|
* `.tmj`/`.tsj` paths are recognised by extension and need no hint. Provide
|
|
11
11
|
* `format: 'tiled'` when loading Tiled map data from a generic `.json` path:
|
|
12
|
-
* `loader.load(
|
|
12
|
+
* `loader.load(Asset.type('tileMap', 'world.json', { format: 'tiled' }))`. `'tiled'` is the
|
|
13
13
|
* only accepted value, so a foreign format (e.g. `'ldtk'`) is a compile error
|
|
14
14
|
* rather than a silent runtime fall-through.
|
|
15
15
|
*
|
|
@@ -23,9 +23,10 @@ export interface TiledLoadOptions {
|
|
|
23
23
|
*
|
|
24
24
|
* Tiled parsing is unconditionally strict: {@link validateTiledMapData} throws
|
|
25
25
|
* a `TiledFormatError` on any malformed *known* field and silently preserves
|
|
26
|
-
* unknown fields. There is intentionally no `strict` toggle
|
|
26
|
+
* unknown fields. There is intentionally no `strict` toggle - a permissive
|
|
27
27
|
* parse mode is a potential v0.14 follow-up, not part of v0.13.
|
|
28
28
|
*/
|
|
29
|
-
export declare
|
|
30
|
-
format:
|
|
29
|
+
export declare const resolveTiledOptions: (options: TiledLoadOptions | undefined) => {
|
|
30
|
+
format: "tiled";
|
|
31
31
|
};
|
|
32
|
+
//# sourceMappingURL=tiledOptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tiledOptions.d.ts","sourceRoot":"","sources":["../../src/tiledOptions.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,GAAI,SAAS,gBAAgB,GAAG,SAAS,KAAG;IAAE,MAAM,EAAE,OAAO,CAAA;CAE3F,CAAC"}
|
package/dist/esm/tiledOptions.js
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
|
+
//#region src/tiledOptions.ts
|
|
1
2
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return {
|
|
11
|
-
format: options?.format ?? 'tiled',
|
|
12
|
-
};
|
|
13
|
-
}
|
|
3
|
+
* Applies defaults and returns a normalized options object.
|
|
4
|
+
*
|
|
5
|
+
* Tiled parsing is unconditionally strict: {@link validateTiledMapData} throws
|
|
6
|
+
* a `TiledFormatError` on any malformed *known* field and silently preserves
|
|
7
|
+
* unknown fields. There is intentionally no `strict` toggle - a permissive
|
|
8
|
+
* parse mode is a potential v0.14 follow-up, not part of v0.13.
|
|
9
|
+
*/
|
|
10
|
+
const resolveTiledOptions = (options) => ({ format: options?.format ?? "tiled" });
|
|
14
11
|
|
|
12
|
+
//#endregion
|
|
15
13
|
export { resolveTiledOptions };
|
|
16
|
-
//# sourceMappingURL=tiledOptions.js.map
|
|
14
|
+
//# sourceMappingURL=tiledOptions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tiledOptions.js","sources":["
|
|
1
|
+
{"version":3,"file":"tiledOptions.js","names":[],"sources":["../../src/tiledOptions.ts"],"sourcesContent":["/**\n * Options accepted by both the runtime (`TileMap`) and source (`TiledMap`)\n * asset bindings when loading a Tiled map.\n * @advanced\n */\nexport interface TiledLoadOptions {\n /**\n * Explicit format hint for ambiguous file extensions.\n *\n * `.tmj`/`.tsj` paths are recognised by extension and need no hint. Provide\n * `format: 'tiled'` when loading Tiled map data from a generic `.json` path:\n * `loader.load(Asset.type('tileMap', 'world.json', { format: 'tiled' }))`. `'tiled'` is the\n * only accepted value, so a foreign format (e.g. `'ldtk'`) is a compile error\n * rather than a silent runtime fall-through.\n *\n * The hint participates in the asset identity key, so the same source loaded\n * under different (future) formats resolves to distinct cache entries.\n */\n readonly format?: 'tiled';\n}\n\n/**\n * Applies defaults and returns a normalized options object.\n *\n * Tiled parsing is unconditionally strict: {@link validateTiledMapData} throws\n * a `TiledFormatError` on any malformed *known* field and silently preserves\n * unknown fields. There is intentionally no `strict` toggle - a permissive\n * parse mode is a potential v0.14 follow-up, not part of v0.13.\n */\nexport const resolveTiledOptions = (options: TiledLoadOptions | undefined): { format: 'tiled' } => ({\n format: options?.format ?? 'tiled',\n});\n"],"mappings":";;;;;;;;;AA6BA,MAAa,uBAAuB,aAAgE,EAClG,QAAQ,SAAS,UAAU,QAC7B"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { AssetFactory, AssetSourceCodec } from '@codexo/exojs';
|
|
2
|
+
import { type AssetRequest, AssetType } from '@codexo/exojs';
|
|
3
|
+
import type { TiledMapData } from './data';
|
|
4
|
+
import { TiledMap } from './TiledMap';
|
|
5
|
+
import { type TiledLoadOptions } from './tiledOptions';
|
|
6
|
+
/**
|
|
7
|
+
* The raw parsed Tiled source model, for diagnostics and for tools that need
|
|
8
|
+
* the `.tmj` as authored.
|
|
9
|
+
*
|
|
10
|
+
* It claims no file suffixes: `.tmj` belongs to the runtime `tileMap` type,
|
|
11
|
+
* which is what a bare Tiled path should resolve to. The name is `tiledSource`
|
|
12
|
+
* rather than `tiledMap` because the runtime type next to it is `tileMap`, and
|
|
13
|
+
* two ids one letter apart resolve to the wrong type instead of failing.
|
|
14
|
+
*/
|
|
15
|
+
export declare class TiledSourceAssetType extends AssetType<TiledMapData, TiledMap, TiledLoadOptions, string> {
|
|
16
|
+
readonly id = "tiledSource";
|
|
17
|
+
readonly _token: typeof TiledMap;
|
|
18
|
+
readonly codec: AssetSourceCodec<TiledMapData, string>;
|
|
19
|
+
resourceIdentity({ options }: AssetRequest<TiledLoadOptions>): string;
|
|
20
|
+
createFactory(): AssetFactory<TiledMapData, TiledMap, TiledLoadOptions>;
|
|
21
|
+
}
|
|
22
|
+
/** The Tiled source-model asset type. Install it through `tiledExtension`. */
|
|
23
|
+
export declare const tiledSourceType: TiledSourceAssetType;
|
|
24
|
+
//# sourceMappingURL=tiledSourceType.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tiledSourceType.d.ts","sourceRoot":"","sources":["../../src/tiledSourceType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,EAAE,KAAK,YAAY,EAAE,SAAS,EAAmB,MAAM,eAAe,CAAC;AAE9E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAG3C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAuB,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAM5E;;;;;;;;GAQG;AACH,qBAAa,oBAAqB,SAAQ,SAAS,CAAC,YAAY,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,CAAC;IACnG,SAAgB,EAAE,iBAAiB;IACnC,SAAyB,MAAM,kBAAY;IAI3C,SAAyB,KAAK,EAAE,gBAAgB,CAAC,YAAY,EAAE,MAAM,CAAC,CAYpE;IAEc,gBAAgB,CAAC,EAAE,OAAO,EAAE,EAAE,YAAY,CAAC,gBAAgB,CAAC,GAAG,MAAM;IAI9E,aAAa,IAAI,YAAY,CAAC,YAAY,EAAE,QAAQ,EAAE,gBAAgB,CAAC;CAG/E;AAED,8EAA8E;AAC9E,eAAO,MAAM,eAAe,sBAA6B,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { validateTiledMapData } from "./validate.js";
|
|
2
|
+
import { decodeTiledLayerData } from "./decodeLayerData.js";
|
|
3
|
+
import { TiledMap } from "./TiledMap.js";
|
|
4
|
+
import { loadTiledMap } from "./loadTiledMap.js";
|
|
5
|
+
import { resolveTiledOptions } from "./tiledOptions.js";
|
|
6
|
+
import { AssetType, jsonSourceCodec } from "@codexo/exojs";
|
|
7
|
+
|
|
8
|
+
//#region src/tiledSourceType.ts
|
|
9
|
+
/** The JSON codec, narrowed to the two acquisition halves this type reuses verbatim. */
|
|
10
|
+
const jsonStringCodec = jsonSourceCodec;
|
|
11
|
+
/**
|
|
12
|
+
* The raw parsed Tiled source model, for diagnostics and for tools that need
|
|
13
|
+
* the `.tmj` as authored.
|
|
14
|
+
*
|
|
15
|
+
* It claims no file suffixes: `.tmj` belongs to the runtime `tileMap` type,
|
|
16
|
+
* which is what a bare Tiled path should resolve to. The name is `tiledSource`
|
|
17
|
+
* rather than `tiledMap` because the runtime type next to it is `tileMap`, and
|
|
18
|
+
* two ids one letter apart resolve to the wrong type instead of failing.
|
|
19
|
+
*/
|
|
20
|
+
var TiledSourceAssetType = class extends AssetType {
|
|
21
|
+
id = "tiledSource";
|
|
22
|
+
_token = TiledMap;
|
|
23
|
+
codec = {
|
|
24
|
+
fromResponse: (response, context) => jsonStringCodec.fromResponse(response, context),
|
|
25
|
+
fromBytes: (bytes, context) => jsonStringCodec.fromBytes(bytes, context),
|
|
26
|
+
async decode(stored, context) {
|
|
27
|
+
const raw = JSON.parse(stored);
|
|
28
|
+
await decodeTiledLayerData(raw, context.locator);
|
|
29
|
+
return validateTiledMapData(raw, context.locator);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
resourceIdentity({ options }) {
|
|
33
|
+
return resolveTiledOptions(options).format;
|
|
34
|
+
}
|
|
35
|
+
createFactory() {
|
|
36
|
+
return { create: (source, context) => loadTiledMap(source, context) };
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
/** The Tiled source-model asset type. Install it through `tiledExtension`. */
|
|
40
|
+
const tiledSourceType = new TiledSourceAssetType();
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
43
|
+
export { TiledSourceAssetType, tiledSourceType };
|
|
44
|
+
//# sourceMappingURL=tiledSourceType.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tiledSourceType.js","names":[],"sources":["../../src/tiledSourceType.ts"],"sourcesContent":["import type { AssetFactory, AssetSourceCodec } from '@codexo/exojs';\nimport { type AssetRequest, AssetType, jsonSourceCodec } from '@codexo/exojs';\n\nimport type { TiledMapData } from './data';\nimport { decodeTiledLayerData } from './decodeLayerData';\nimport { loadTiledMap } from './loadTiledMap';\nimport { TiledMap } from './TiledMap';\nimport { resolveTiledOptions, type TiledLoadOptions } from './tiledOptions';\nimport { validateTiledMapData } from './validate';\n\n/** The JSON codec, narrowed to the two acquisition halves this type reuses verbatim. */\nconst jsonStringCodec = jsonSourceCodec as Required<AssetSourceCodec<unknown, string>>;\n\n/**\n * The raw parsed Tiled source model, for diagnostics and for tools that need\n * the `.tmj` as authored.\n *\n * It claims no file suffixes: `.tmj` belongs to the runtime `tileMap` type,\n * which is what a bare Tiled path should resolve to. The name is `tiledSource`\n * rather than `tiledMap` because the runtime type next to it is `tileMap`, and\n * two ids one letter apart resolve to the wrong type instead of failing.\n */\nexport class TiledSourceAssetType extends AssetType<TiledMapData, TiledMap, TiledLoadOptions, string> {\n public readonly id = 'tiledSource';\n public override readonly _token = TiledMap;\n // Stored as the text that arrived; decoding is where the compressed layer\n // payloads are expanded and the document is validated, so a cache hit is\n // re-read exactly like a fresh download.\n public override readonly codec: AssetSourceCodec<TiledMapData, string> = {\n fromResponse: (response, context) => jsonStringCodec.fromResponse(response, context),\n fromBytes: (bytes, context) => jsonStringCodec.fromBytes(bytes, context),\n async decode(stored, context) {\n const raw: unknown = JSON.parse(stored);\n\n // Expand any base64/gzip/zlib tile-layer payload before validation, so the\n // rest of the pipeline stays CSV-shaped and synchronous.\n await decodeTiledLayerData(raw, context.locator);\n\n return validateTiledMapData(raw, context.locator);\n },\n };\n\n public override resourceIdentity({ options }: AssetRequest<TiledLoadOptions>): string {\n return resolveTiledOptions(options).format;\n }\n\n public createFactory(): AssetFactory<TiledMapData, TiledMap, TiledLoadOptions> {\n return { create: (source, context) => loadTiledMap(source, context) };\n }\n}\n\n/** The Tiled source-model asset type. Install it through `tiledExtension`. */\nexport const tiledSourceType = new TiledSourceAssetType();\n"],"mappings":";;;;;;;;;AAWA,MAAM,kBAAkB;;;;;;;;;;AAWxB,IAAa,uBAAb,cAA0C,UAA4D;CACpG,AAAgB,KAAK;CACrB,AAAyB,SAAS;CAIlC,AAAyB,QAAgD;EACvE,eAAe,UAAU,YAAY,gBAAgB,aAAa,UAAU,OAAO;EACnF,YAAY,OAAO,YAAY,gBAAgB,UAAU,OAAO,OAAO;EACvE,MAAM,OAAO,QAAQ,SAAS;GAC5B,MAAM,MAAe,KAAK,MAAM,MAAM;GAItC,MAAM,qBAAqB,KAAK,QAAQ,OAAO;GAE/C,OAAO,qBAAqB,KAAK,QAAQ,OAAO;EAClD;CACF;CAEA,AAAgB,iBAAiB,EAAE,WAAmD;EACpF,OAAO,oBAAoB,OAAO,CAAC,CAAC;CACtC;CAEA,AAAO,gBAAwE;EAC7E,OAAO,EAAE,SAAS,QAAQ,YAAY,aAAa,QAAQ,OAAO,EAAE;CACtE;AACF;;AAGA,MAAa,kBAAkB,IAAI,qBAAqB"}
|
package/dist/esm/url.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../src/url.ts"],"names":[],"mappings":"AAeA;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,eAAe,GAAI,KAAK,MAAM,EAAE,MAAM,MAAM,KAAG,MAgB3D,CAAC"}
|
package/dist/esm/url.js
CHANGED
|
@@ -1,45 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
// image). Tiled stores every cross-file reference as a path relative to the
|
|
3
|
-
// file that contains it; ExoJS asset sources are themselves often relative
|
|
4
|
-
// (resolved against an asset root configured outside the Loader), so plain
|
|
5
|
-
// `new URL(ref, base)` cannot be used directly when `base` has no scheme.
|
|
1
|
+
//#region src/url.ts
|
|
6
2
|
/** Matches references that are already absolute and must not be re-resolved: scheme:, protocol-relative `//`, root-relative `/`, and data/blob URLs. */
|
|
7
3
|
const ABSOLUTE_REF = /^(?:[a-z][a-z\d+.-]*:|\/\/|\/)/i;
|
|
8
4
|
/** Matches a base that is itself an absolute URL with a scheme. */
|
|
9
5
|
const ABSOLUTE_BASE = /^[a-z][a-z\d+.-]*:/i;
|
|
10
6
|
/** Synthetic origin used to borrow `URL`'s `../`/`./` collapsing for relative bases. */
|
|
11
|
-
const SYNTHETIC_ORIGIN =
|
|
7
|
+
const SYNTHETIC_ORIGIN = "https://exojs.invalid/";
|
|
12
8
|
/**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
const resolved = new URL(ref, SYNTHETIC_ORIGIN + base.replace(/^\/+/, ''));
|
|
37
|
-
const relative = resolved.href.slice(SYNTHETIC_ORIGIN.length);
|
|
38
|
-
// A root-relative base must produce a root-relative result again — dropping
|
|
39
|
-
// the leading slash would make the browser re-resolve the reference against
|
|
40
|
-
// the document base URL (e.g. `/site/assets/x.png` → `/site/site/assets/…`).
|
|
41
|
-
return base.startsWith('/') ? `/${relative}` : relative;
|
|
42
|
-
}
|
|
9
|
+
* Resolves `ref` (a path read from a Tiled JSON file, e.g. a tileset
|
|
10
|
+
* `source` or an `image`) relative to `base` (the resolved location of the
|
|
11
|
+
* file that referenced it).
|
|
12
|
+
*
|
|
13
|
+
* - If `ref` is already absolute (has a scheme, is protocol- or
|
|
14
|
+
* root-relative, or is a `data:`/`blob:` URL), it is returned unchanged.
|
|
15
|
+
* - If `base` is an absolute URL, standard `new URL(ref, base)` resolution
|
|
16
|
+
* is used.
|
|
17
|
+
* - Otherwise both `ref` and `base` are relative ExoJS asset paths; `../`
|
|
18
|
+
* and `./` segments are collapsed via a synthetic origin and the result is
|
|
19
|
+
* returned relative again.
|
|
20
|
+
*
|
|
21
|
+
* Query strings and fragments on `ref` are preserved.
|
|
22
|
+
*
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
const resolveTiledUrl = (ref, base) => {
|
|
26
|
+
if (ABSOLUTE_REF.test(ref)) return ref;
|
|
27
|
+
if (ABSOLUTE_BASE.test(base)) return new URL(ref, base).href;
|
|
28
|
+
const relative = new URL(ref, SYNTHETIC_ORIGIN + base.replace(/^\/+/, "")).href.slice(22);
|
|
29
|
+
return base.startsWith("/") ? `/${relative}` : relative;
|
|
30
|
+
};
|
|
43
31
|
|
|
32
|
+
//#endregion
|
|
44
33
|
export { resolveTiledUrl };
|
|
45
|
-
//# sourceMappingURL=url.js.map
|
|
34
|
+
//# sourceMappingURL=url.js.map
|
package/dist/esm/url.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.js","sources":["
|
|
1
|
+
{"version":3,"file":"url.js","names":[],"sources":["../../src/url.ts"],"sourcesContent":["// Relative-path resolution for Tiled source references (TMJ → TSJ, TMJ/TSJ →\n// image). Tiled stores every cross-file reference as a path relative to the\n// file that contains it; ExoJS asset sources are themselves often relative\n// (resolved against an asset root configured outside the Loader), so plain\n// `new URL(ref, base)` cannot be used directly when `base` has no scheme.\n\n/** Matches references that are already absolute and must not be re-resolved: scheme:, protocol-relative `//`, root-relative `/`, and data/blob URLs. */\nconst ABSOLUTE_REF = /^(?:[a-z][a-z\\d+.-]*:|\\/\\/|\\/)/i;\n\n/** Matches a base that is itself an absolute URL with a scheme. */\nconst ABSOLUTE_BASE = /^[a-z][a-z\\d+.-]*:/i;\n\n/** Synthetic origin used to borrow `URL`'s `../`/`./` collapsing for relative bases. */\nconst SYNTHETIC_ORIGIN = 'https://exojs.invalid/';\n\n/**\n * Resolves `ref` (a path read from a Tiled JSON file, e.g. a tileset\n * `source` or an `image`) relative to `base` (the resolved location of the\n * file that referenced it).\n *\n * - If `ref` is already absolute (has a scheme, is protocol- or\n * root-relative, or is a `data:`/`blob:` URL), it is returned unchanged.\n * - If `base` is an absolute URL, standard `new URL(ref, base)` resolution\n * is used.\n * - Otherwise both `ref` and `base` are relative ExoJS asset paths; `../`\n * and `./` segments are collapsed via a synthetic origin and the result is\n * returned relative again.\n *\n * Query strings and fragments on `ref` are preserved.\n *\n * @internal\n */\nexport const resolveTiledUrl = (ref: string, base: string): string => {\n if (ABSOLUTE_REF.test(ref)) {\n return ref;\n }\n\n if (ABSOLUTE_BASE.test(base)) {\n return new URL(ref, base).href;\n }\n\n const resolved = new URL(ref, SYNTHETIC_ORIGIN + base.replace(/^\\/+/, ''));\n const relative = resolved.href.slice(SYNTHETIC_ORIGIN.length);\n\n // A root-relative base must produce a root-relative result again - dropping\n // the leading slash would make the browser re-resolve the reference against\n // the document base URL (e.g. `/site/assets/x.png` → `/site/site/assets/...`).\n return base.startsWith('/') ? `/${relative}` : relative;\n};\n"],"mappings":";;AAOA,MAAM,eAAe;;AAGrB,MAAM,gBAAgB;;AAGtB,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;AAmBzB,MAAa,mBAAmB,KAAa,SAAyB;CACpE,IAAI,aAAa,KAAK,GAAG,GACvB,OAAO;CAGT,IAAI,cAAc,KAAK,IAAI,GACzB,OAAO,IAAI,IAAI,KAAK,IAAI,CAAC,CAAC;CAI5B,MAAM,WAAW,IADI,IAAI,KAAK,mBAAmB,KAAK,QAAQ,QAAQ,EAAE,CAChD,CAAC,CAAC,KAAK,MAAM,EAAuB;CAK5D,OAAO,KAAK,WAAW,GAAG,IAAI,IAAI,aAAa;AACjD"}
|
package/dist/esm/validate.d.ts
CHANGED
|
@@ -11,39 +11,40 @@ export declare class TiledFormatError extends Error {
|
|
|
11
11
|
constructor(source: string, path: string, message: string);
|
|
12
12
|
}
|
|
13
13
|
/** @internal */
|
|
14
|
-
export declare
|
|
14
|
+
export declare const validateTiledPropertyData: (raw: unknown, source: string, path: string) => TiledPropertyData;
|
|
15
15
|
/** @internal */
|
|
16
|
-
export declare
|
|
16
|
+
export declare const validateTiledAnimationFrameData: (raw: unknown, source: string, path: string) => TiledAnimationFrameData;
|
|
17
17
|
/** @internal */
|
|
18
|
-
export declare
|
|
18
|
+
export declare const validateTiledObjectData: (raw: unknown, source: string, path: string) => TiledObjectData;
|
|
19
19
|
/** @internal */
|
|
20
|
-
export declare
|
|
20
|
+
export declare const validateTiledLayerData: (raw: unknown, source: string, path: string) => TiledLayerData;
|
|
21
21
|
/**
|
|
22
22
|
* Walks a layer tree and ensures every tile layer's `data`/`chunks` choice
|
|
23
23
|
* matches the map's `infinite` flag. Tiled itself is consistent across an
|
|
24
24
|
* entire map; a mismatch indicates a hand-edited or corrupt file.
|
|
25
25
|
* @internal
|
|
26
26
|
*/
|
|
27
|
-
export declare
|
|
27
|
+
export declare const checkTiledLayerInfiniteConsistency: (layers: readonly TiledLayerData[], infinite: boolean, source: string, path: string) => void;
|
|
28
28
|
/** @internal */
|
|
29
|
-
export declare
|
|
29
|
+
export declare const validateTiledTileData: (raw: unknown, source: string, path: string) => TiledTileData;
|
|
30
30
|
/** @internal */
|
|
31
|
-
export declare
|
|
31
|
+
export declare const validateTiledTilesetData: (obj: Record<string, unknown>, source: string, path: string) => TiledTilesetData;
|
|
32
32
|
/**
|
|
33
33
|
* Validates one entry of a map's `tilesets` array: either `{ firstgid,
|
|
34
34
|
* source }` (external `.tsj`) or `{ firstgid, ...embedded tileset fields }`.
|
|
35
35
|
* @internal
|
|
36
36
|
*/
|
|
37
|
-
export declare
|
|
37
|
+
export declare const validateTiledTilesetRefData: (raw: unknown, source: string, path: string) => TiledTilesetRefData;
|
|
38
38
|
/**
|
|
39
39
|
* Validates the root of a `.tmj` file. Throws {@link TiledFormatError} on
|
|
40
40
|
* any structural problem, including unsupported tile-layer encodings and
|
|
41
41
|
* `infinite`/`data`/`chunks` inconsistencies.
|
|
42
42
|
* @internal
|
|
43
43
|
*/
|
|
44
|
-
export declare
|
|
44
|
+
export declare const validateTiledMapData: (raw: unknown, source: string) => TiledMapData;
|
|
45
45
|
/**
|
|
46
46
|
* Validates a standalone `.tsj` tileset file's root object.
|
|
47
47
|
* @internal
|
|
48
48
|
*/
|
|
49
|
-
export declare
|
|
49
|
+
export declare const validateTiledTilesetFileData: (raw: unknown, source: string) => TiledTilesetData;
|
|
50
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/validate.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,uBAAuB,EAKvB,cAAc,EAEd,YAAY,EAEZ,eAAe,EAIf,iBAAiB,EAIjB,aAAa,EAEb,gBAAgB,EAChB,mBAAmB,EAIpB,MAAM,QAAQ,CAAC;AAGhB;;;;;GAKG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,SAAgB,MAAM,EAAE,MAAM,CAAC;IAC/B,SAAgB,IAAI,EAAE,MAAM,CAAC;gBAEV,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAMjE;AA+HD,gBAAgB;AAChB,eAAO,MAAM,yBAAyB,GAAI,KAAK,OAAO,EAAE,QAAQ,MAAM,EAAE,MAAM,MAAM,KAAG,iBAmCtF,CAAC;AAkBF,gBAAgB;AAChB,eAAO,MAAM,+BAA+B,GAAI,KAAK,OAAO,EAAE,QAAQ,MAAM,EAAE,MAAM,MAAM,KAAG,uBAM5F,CAAC;AA+CF,gBAAgB;AAChB,eAAO,MAAM,uBAAuB,GAAI,KAAK,OAAO,EAAE,QAAQ,MAAM,EAAE,MAAM,MAAM,KAAG,eA0BpF,CAAC;AAgHF,gBAAgB;AAChB,eAAO,MAAM,sBAAsB,GAAI,KAAK,OAAO,EAAE,QAAQ,MAAM,EAAE,MAAM,MAAM,KAAG,cAmBnF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,kCAAkC,GAAI,QAAQ,SAAS,cAAc,EAAE,EAAE,UAAU,OAAO,EAAE,QAAQ,MAAM,EAAE,MAAM,MAAM,KAAG,IAmBvI,CAAC;AAIF,gBAAgB;AAChB,eAAO,MAAM,qBAAqB,GAAI,KAAK,OAAO,EAAE,QAAQ,MAAM,EAAE,MAAM,MAAM,KAAG,aAyBlF,CAAC;AA2DF,gBAAgB;AAChB,eAAO,MAAM,wBAAwB,GAAI,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,MAAM,EAAE,MAAM,MAAM,KAAG,gBAmBpG,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,GAAI,KAAK,OAAO,EAAE,QAAQ,MAAM,EAAE,MAAM,MAAM,KAAG,mBASxF,CAAC;AAOF;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAAI,KAAK,OAAO,EAAE,QAAQ,MAAM,KAAG,YAiDnE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,4BAA4B,GAAI,KAAK,OAAO,EAAE,QAAQ,MAAM,KAAG,gBACP,CAAC"}
|