@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.
Files changed (84) hide show
  1. package/README.md +59 -66
  2. package/dist/esm/TiledLayer.d.ts +2 -1
  3. package/dist/esm/TiledLayer.d.ts.map +1 -0
  4. package/dist/esm/TiledLayer.js +106 -108
  5. package/dist/esm/TiledLayer.js.map +1 -1
  6. package/dist/esm/TiledMap.d.ts +35 -7
  7. package/dist/esm/TiledMap.d.ts.map +1 -0
  8. package/dist/esm/TiledMap.js +714 -589
  9. package/dist/esm/TiledMap.js.map +1 -1
  10. package/dist/esm/TiledObject.d.ts +7 -0
  11. package/dist/esm/TiledObject.d.ts.map +1 -0
  12. package/dist/esm/TiledObject.js +59 -51
  13. package/dist/esm/TiledObject.js.map +1 -1
  14. package/dist/esm/TiledTileset.d.ts +11 -4
  15. package/dist/esm/TiledTileset.d.ts.map +1 -0
  16. package/dist/esm/TiledTileset.js +81 -70
  17. package/dist/esm/TiledTileset.js.map +1 -1
  18. package/dist/esm/data.d.ts +25 -7
  19. package/dist/esm/data.d.ts.map +1 -0
  20. package/dist/esm/decodeLayerData.d.ts +2 -1
  21. package/dist/esm/decodeLayerData.d.ts.map +1 -0
  22. package/dist/esm/decodeLayerData.js +53 -92
  23. package/dist/esm/decodeLayerData.js.map +1 -1
  24. package/dist/esm/gid.d.ts +2 -1
  25. package/dist/esm/gid.d.ts.map +1 -0
  26. package/dist/esm/gid.js +15 -24
  27. package/dist/esm/gid.js.map +1 -1
  28. package/dist/esm/index.d.ts +1 -0
  29. package/dist/esm/index.d.ts.map +1 -0
  30. package/dist/esm/index.js +14 -12
  31. package/dist/esm/loadTiledMap.d.ts +11 -5
  32. package/dist/esm/loadTiledMap.d.ts.map +1 -0
  33. package/dist/esm/loadTiledMap.js +82 -91
  34. package/dist/esm/loadTiledMap.js.map +1 -1
  35. package/dist/esm/objectAlignment.d.ts +28 -0
  36. package/dist/esm/objectAlignment.d.ts.map +1 -0
  37. package/dist/esm/objectAlignment.js +79 -0
  38. package/dist/esm/objectAlignment.js.map +1 -0
  39. package/dist/esm/public.d.ts +17 -15
  40. package/dist/esm/public.d.ts.map +1 -0
  41. package/dist/esm/public.js +14 -0
  42. package/dist/esm/tileMapType.d.ts +31 -0
  43. package/dist/esm/tileMapType.d.ts.map +1 -0
  44. package/dist/esm/tileMapType.js +42 -0
  45. package/dist/esm/tileMapType.js.map +1 -0
  46. package/dist/esm/tiledBuildInfo.d.ts +1 -0
  47. package/dist/esm/tiledBuildInfo.d.ts.map +1 -0
  48. package/dist/esm/tiledBuildInfo.js +6 -4
  49. package/dist/esm/tiledBuildInfo.js.map +1 -1
  50. package/dist/esm/tiledExtension.d.ts +7 -6
  51. package/dist/esm/tiledExtension.d.ts.map +1 -0
  52. package/dist/esm/tiledExtension.js +23 -25
  53. package/dist/esm/tiledExtension.js.map +1 -1
  54. package/dist/esm/tiledOptions.d.ts +5 -4
  55. package/dist/esm/tiledOptions.d.ts.map +1 -0
  56. package/dist/esm/tiledOptions.js +11 -13
  57. package/dist/esm/tiledOptions.js.map +1 -1
  58. package/dist/esm/tiledSourceType.d.ts +24 -0
  59. package/dist/esm/tiledSourceType.d.ts.map +1 -0
  60. package/dist/esm/tiledSourceType.js +44 -0
  61. package/dist/esm/tiledSourceType.js.map +1 -0
  62. package/dist/esm/url.d.ts +2 -1
  63. package/dist/esm/url.d.ts.map +1 -0
  64. package/dist/esm/url.js +26 -37
  65. package/dist/esm/url.js.map +1 -1
  66. package/dist/esm/validate.d.ts +11 -10
  67. package/dist/esm/validate.d.ts.map +1 -0
  68. package/dist/esm/validate.js +485 -534
  69. package/dist/esm/validate.js.map +1 -1
  70. package/dist/esm/wangSets.d.ts +5 -4
  71. package/dist/esm/wangSets.d.ts.map +1 -0
  72. package/dist/esm/wangSets.js +90 -115
  73. package/dist/esm/wangSets.js.map +1 -1
  74. package/package.json +10 -18
  75. package/dist/esm/index.js.map +0 -1
  76. package/dist/esm/register.d.ts +0 -1
  77. package/dist/esm/register.js +0 -22
  78. package/dist/esm/register.js.map +0 -1
  79. package/dist/esm/tiledMapBinding.d.ts +0 -19
  80. package/dist/esm/tiledMapBinding.js +0 -31
  81. package/dist/esm/tiledMapBinding.js.map +0 -1
  82. package/dist/esm/tiledRuntimeMapBinding.d.ts +0 -29
  83. package/dist/esm/tiledRuntimeMapBinding.js +0 -42
  84. package/dist/esm/tiledRuntimeMapBinding.js.map +0 -1
@@ -1,31 +1,29 @@
1
- import { tilemapExtension } from '@codexo/exojs-tilemap';
2
- import { tiledMapBinding } from './tiledMapBinding.js';
3
- import { tiledRuntimeMapBinding } from './tiledRuntimeMapBinding.js';
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
- * Default immutable Tiled extension descriptor.
7
- *
8
- * Registers two asset bindings:
9
- * - {@link tiledRuntimeMapBinding} `loader.load(TileMap, 'world.tmj')`
10
- * returns a format-independent runtime {@link TileMap} (common case).
11
- * - {@link tiledMapBinding} `loader.load(TiledMap, 'world.tmj')`
12
- * returns the raw parsed {@link TiledMap} source model (advanced/diagnostic).
13
- *
14
- * Depends on {@link tilemapExtension} so that snapshot construction always
15
- * materialises the generic tilemap runtime before the Tiled adapter.
16
- *
17
- * Use with `ApplicationOptions.extensions` or call
18
- * `import '@codexo/exojs-tiled/register'` for global auto-registration.
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
- id: '@codexo/exojs-tiled',
22
- dependencies: [tilemapExtension],
23
- // Localized erasure cast: typed bindings (Options=TiledLoadOptions) meet the
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":["../../../src/tiledExtension.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAMA;;;;;;;;;;;;;;AAcG;AACI,MAAM,cAAc,GAAc,MAAM,CAAC,MAAM,CAAC;AACrD,IAAA,EAAE,EAAE,qBAAqB;IACzB,YAAY,EAAE,CAAC,gBAAgB,CAAC;;;;;AAKhC,IAAA,MAAM,EAAE,CAAC,sBAAsB,EAAE,eAAe,CAA8B;AAC/E,CAAA;;;;"}
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(TileMap, 'world.json', { format: 'tiled' })`. `'tiled'` is the
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 a permissive
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 function resolveTiledOptions(options: TiledLoadOptions | undefined): {
30
- format: 'tiled';
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"}
@@ -1,16 +1,14 @@
1
+ //#region src/tiledOptions.ts
1
2
  /**
2
- * Applies defaults and returns a normalized options object.
3
- *
4
- * Tiled parsing is unconditionally strict: {@link validateTiledMapData} throws
5
- * a `TiledFormatError` on any malformed *known* field and silently preserves
6
- * unknown fields. There is intentionally no `strict` toggle a permissive
7
- * parse mode is a potential v0.14 follow-up, not part of v0.13.
8
- */
9
- function resolveTiledOptions(options) {
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":["../../../src/tiledOptions.ts"],"sourcesContent":[null],"names":[],"mappings":"AAqBA;;;;;;;AAOG;AACG,SAAU,mBAAmB,CAAC,OAAqC,EAAA;IACvE,OAAO;AACL,QAAA,MAAM,EAAE,OAAO,EAAE,MAAM,IAAI,OAAO;KACnC;AACH;;;;"}
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
@@ -15,4 +15,5 @@
15
15
  *
16
16
  * @internal
17
17
  */
18
- export declare function resolveTiledUrl(ref: string, base: string): string;
18
+ export declare const resolveTiledUrl: (ref: string, base: string) => string;
19
+ //# sourceMappingURL=url.d.ts.map
@@ -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
- // Relative-path resolution for Tiled source references (TMJ → TSJ, TMJ/TSJ →
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 = 'https://exojs.invalid/';
7
+ const SYNTHETIC_ORIGIN = "https://exojs.invalid/";
12
8
  /**
13
- * Resolves `ref` (a path read from a Tiled JSON file, e.g. a tileset
14
- * `source` or an `image`) relative to `base` (the resolved location of the
15
- * file that referenced it).
16
- *
17
- * - If `ref` is already absolute (has a scheme, is protocol- or
18
- * root-relative, or is a `data:`/`blob:` URL), it is returned unchanged.
19
- * - If `base` is an absolute URL, standard `new URL(ref, base)` resolution
20
- * is used.
21
- * - Otherwise both `ref` and `base` are relative ExoJS asset paths; `../`
22
- * and `./` segments are collapsed via a synthetic origin and the result is
23
- * returned relative again.
24
- *
25
- * Query strings and fragments on `ref` are preserved.
26
- *
27
- * @internal
28
- */
29
- function resolveTiledUrl(ref, base) {
30
- if (ABSOLUTE_REF.test(ref)) {
31
- return ref;
32
- }
33
- if (ABSOLUTE_BASE.test(base)) {
34
- return new URL(ref, base).href;
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
@@ -1 +1 @@
1
- {"version":3,"file":"url.js","sources":["../../../src/url.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA;AACA,MAAM,YAAY,GAAG,iCAAiC;AAEtD;AACA,MAAM,aAAa,GAAG,qBAAqB;AAE3C;AACA,MAAM,gBAAgB,GAAG,wBAAwB;AAEjD;;;;;;;;;;;;;;;;AAgBG;AACG,SAAU,eAAe,CAAC,GAAW,EAAE,IAAY,EAAA;AACvD,IAAA,IAAI,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;AAC1B,QAAA,OAAO,GAAG;IACZ;AAEA,IAAA,IAAI,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QAC5B,OAAO,IAAI,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,IAAI;IAChC;AAEA,IAAA,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,GAAG,EAAE,gBAAgB,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAC1E,IAAA,MAAM,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,MAAM,CAAC;;;;AAK7D,IAAA,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAA,CAAA,EAAI,QAAQ,CAAA,CAAE,GAAG,QAAQ;AACzD;;;;"}
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"}
@@ -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 function validateTiledPropertyData(raw: unknown, source: string, path: string): TiledPropertyData;
14
+ export declare const validateTiledPropertyData: (raw: unknown, source: string, path: string) => TiledPropertyData;
15
15
  /** @internal */
16
- export declare function validateTiledAnimationFrameData(raw: unknown, source: string, path: string): TiledAnimationFrameData;
16
+ export declare const validateTiledAnimationFrameData: (raw: unknown, source: string, path: string) => TiledAnimationFrameData;
17
17
  /** @internal */
18
- export declare function validateTiledObjectData(raw: unknown, source: string, path: string): TiledObjectData;
18
+ export declare const validateTiledObjectData: (raw: unknown, source: string, path: string) => TiledObjectData;
19
19
  /** @internal */
20
- export declare function validateTiledLayerData(raw: unknown, source: string, path: string): TiledLayerData;
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 function checkTiledLayerInfiniteConsistency(layers: readonly TiledLayerData[], infinite: boolean, source: string, path: string): void;
27
+ export declare const checkTiledLayerInfiniteConsistency: (layers: readonly TiledLayerData[], infinite: boolean, source: string, path: string) => void;
28
28
  /** @internal */
29
- export declare function validateTiledTileData(raw: unknown, source: string, path: string): TiledTileData;
29
+ export declare const validateTiledTileData: (raw: unknown, source: string, path: string) => TiledTileData;
30
30
  /** @internal */
31
- export declare function validateTiledTilesetData(obj: Record<string, unknown>, source: string, path: string): TiledTilesetData;
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 function validateTiledTilesetRefData(raw: unknown, source: string, path: string): TiledTilesetRefData;
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 function validateTiledMapData(raw: unknown, source: string): TiledMapData;
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 function validateTiledTilesetFileData(raw: unknown, source: string): TiledTilesetData;
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"}