@codexo/exojs-ldtk 0.19.1 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/esm/LdtkData.d.ts +32 -2
- package/dist/esm/LdtkData.d.ts.map +1 -1
- package/dist/esm/LdtkData.js +1 -2
- package/dist/esm/LdtkData.js.map +1 -1
- package/dist/esm/LdtkMap.d.ts +4 -3
- package/dist/esm/LdtkMap.d.ts.map +1 -1
- package/dist/esm/LdtkMap.js +5 -5
- package/dist/esm/LdtkMap.js.map +1 -1
- package/dist/esm/LdtkProject.d.ts +12 -4
- package/dist/esm/LdtkProject.d.ts.map +1 -1
- package/dist/esm/LdtkProject.js +17 -8
- package/dist/esm/LdtkProject.js.map +1 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/ldtkExtension.d.ts +2 -2
- package/dist/esm/ldtkExtension.d.ts.map +1 -1
- package/dist/esm/ldtkExtension.js +4 -5
- package/dist/esm/ldtkExtension.js.map +1 -1
- package/dist/esm/ldtkLevelEntries.d.ts.map +1 -1
- package/dist/esm/ldtkLevelEntries.js +1 -2
- package/dist/esm/ldtkLevelEntries.js.map +1 -1
- package/dist/esm/ldtkParallax.d.ts.map +1 -1
- package/dist/esm/ldtkParallax.js +1 -2
- package/dist/esm/ldtkToMapWorld.d.ts +1 -1
- package/dist/esm/ldtkToMapWorld.d.ts.map +1 -1
- package/dist/esm/ldtkToMapWorld.js +2 -3
- package/dist/esm/ldtkToMapWorld.js.map +1 -1
- package/dist/esm/ldtkToTileMap.d.ts +9 -4
- package/dist/esm/ldtkToTileMap.d.ts.map +1 -1
- package/dist/esm/ldtkToTileMap.js +34 -14
- package/dist/esm/ldtkToTileMap.js.map +1 -1
- package/dist/esm/ldtkTypes.d.ts.map +1 -1
- package/dist/esm/ldtkTypes.js +1 -2
- package/dist/esm/loadLdtkMap.d.ts.map +1 -1
- package/dist/esm/loadLdtkMap.js +50 -9
- package/dist/esm/loadLdtkMap.js.map +1 -1
- package/dist/esm/loadLdtkProject.d.ts.map +1 -1
- package/dist/esm/loadLdtkProject.js +6 -5
- package/dist/esm/loadLdtkProject.js.map +1 -1
- package/dist/esm/public.d.ts +4 -4
- package/dist/esm/public.d.ts.map +1 -1
- package/dist/esm/public.js +1 -1
- package/dist/esm/url.d.ts.map +1 -1
- package/dist/esm/url.js +1 -2
- package/dist/esm/validate.d.ts.map +1 -1
- package/dist/esm/validate.js +18 -4
- package/dist/esm/validate.js.map +1 -1
- package/package.json +5 -7
package/dist/esm/public.d.ts
CHANGED
|
@@ -5,12 +5,12 @@ export type { LdtkRuntimeOptions } from './LdtkProject';
|
|
|
5
5
|
export { LdtkProject } from './LdtkProject';
|
|
6
6
|
export { ldtkToMapWorld } from './ldtkToMapWorld';
|
|
7
7
|
export type { LdtkToTileMapOptions } from './ldtkToTileMap';
|
|
8
|
-
export { createLdtkIntGridCellSource, getLdtkIntGridValueAt, ldtkIntGridCsvProperty, ldtkIntGridValuesProperty, ldtkToTileMap } from './ldtkToTileMap';
|
|
9
|
-
export type { LdtkData, LdtkDefs, LdtkEntityInstance, LdtkFieldEnumType, LdtkFieldInstance, LdtkIntGridValueDef, LdtkLayerDef, LdtkLayerInstance, LdtkLayerType, LdtkLevel, LdtkLevelNeighbour, LdtkTileData, LdtkTilesetDef, LdtkWorldData, LdtkWorldLayout, } from './LdtkData';
|
|
8
|
+
export { createLdtkIntGridCellSource, getLdtkIntGridValueAt, ldtkIntGridCsvProperty, ldtkIntGridValuesProperty, ldtkToTileMap, } from './ldtkToTileMap';
|
|
9
|
+
export type { LdtkData, LdtkDefs, LdtkEntityInstance, LdtkFieldEnumType, LdtkFieldInstance, LdtkIntGridValueDef, LdtkLayerDef, LdtkLayerInstance, LdtkLayerType, LdtkLevel, LdtkLevelNeighbour, LdtkTileCustomData, LdtkTileData, LdtkTileEnumTag, LdtkTilesetDef, LdtkWorldData, LdtkWorldLayout, } from './LdtkData';
|
|
10
10
|
export { isLdtkFieldEnumType, LDTK_FLIP_NONE, LDTK_FLIP_X, LDTK_FLIP_XY, LDTK_FLIP_Y } from './LdtkData';
|
|
11
11
|
export { LdtkFormatError } from './validate';
|
|
12
|
-
export type { ChunkCoord, EllipseObject, MapBounds, MapLevel, MapLevelCancelOptions, MapLevelLoadContext, MapLevelLoadOptions, MapLevelNeighbour, MapLevelProvider, MapObjectDescriptor, MapObjectFactories, MapObjectFactory, MapObjectSpawnerOptions, MapSpawnErrorReason, MapSpawnOptions, MapWorldOptions, MapWorldRuntimeOptions, ObjectLayerOptions, ObjectPoint, ObjectQuery, ObjectSchema, PackedTile, PointObject, PolygonObject, PolylineObject, ReadonlyTileChunk, RectangleObject, ResolvedTile, TileDefinition, TileLayerOptions, TileMapObject, TileMapObjectKind, TileMapOptions, TileMapViewOptions, TileObject, TileProperties, TilePropertyObjectRef, TilePropertyPoint, TilePropertyTileRef, TilePropertyValue, TileSetOptions, TileTransform, UnknownMapObjectPolicy, } from '@codexo/exojs
|
|
13
|
-
export { MapLevelRuntime, MapLevelSide, mapObjectDescriptor, mapObjectDescriptors, MapObjectSpawner, MapSpawnError, MapSpawnSession, MapWorld, MapWorldRuntime, ObjectKind, ObjectLayer, TILE_TRANSFORM_IDENTITY, TileLayer, TileMap, tilemapExtension, TileMapView, TilePropertyKind, TileSet, } from '@codexo/exojs
|
|
12
|
+
export type { ChunkCoord, EllipseObject, MapBounds, MapLevel, MapLevelCancelOptions, MapLevelLoadContext, MapLevelLoadOptions, MapLevelNeighbour, MapLevelProvider, MapObjectDescriptor, MapObjectFactories, MapObjectFactory, MapObjectSpawnerOptions, MapSpawnErrorReason, MapSpawnOptions, MapWorldOptions, MapWorldRuntimeOptions, ObjectLayerOptions, ObjectPoint, ObjectQuery, ObjectSchema, PackedTile, PointObject, PolygonObject, PolylineObject, ReadonlyTileChunk, RectangleObject, ResolvedTile, TileDefinition, TileLayerOptions, TileMapObject, TileMapObjectKind, TileMapOptions, TileMapViewOptions, TileObject, TileProperties, TilePropertyObjectRef, TilePropertyPoint, TilePropertyTileRef, TilePropertyValue, TileSetOptions, TileTransform, UnknownMapObjectPolicy, } from '@codexo/exojs/tilemap';
|
|
13
|
+
export { MapLevelRuntime, MapLevelSide, mapObjectDescriptor, mapObjectDescriptors, MapObjectSpawner, MapSpawnError, MapSpawnSession, MapWorld, MapWorldRuntime, ObjectKind, ObjectLayer, TILE_TRANSFORM_IDENTITY, TileLayer, TileMap, tilemapExtension, TileMapView, TilePropertyKind, TileSet, } from '@codexo/exojs/tilemap';
|
|
14
14
|
import type { LdtkMap } from './LdtkMap';
|
|
15
15
|
import type { LdtkProject } from './LdtkProject';
|
|
16
16
|
declare module '@codexo/exojs' {
|
package/dist/esm/public.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public.d.ts","
|
|
1
|
+
{"version":3,"file":"public.d.ts","sources":["../../src/public.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAGnG,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,YAAY,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,YAAY,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EACL,2BAA2B,EAC3B,qBAAqB,EACrB,sBAAsB,EACtB,yBAAyB,EACzB,aAAa,GACd,MAAM,iBAAiB,CAAC;AAGzB,YAAY,EACV,QAAQ,EACR,QAAQ,EACR,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,SAAS,EACT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AC;IAC7B,UAAU,gBAAgB;QACxB,+EAA+E;QAC/E,IAAI,EAAE,SAAS,CAAC;KACjB;IACD,UAAU,gBAAgB;QACxB,WAAW,EAAE;YACX,QAAQ,EAAE,WAAW,CAAC;YACtB,MAAM,EAAE;gBAAE,MAAM,EAAE,MAAM,CAAA;aAAE,CAAC;YAC3B,oEAAoE;YACpE,OAAO,EAAE,IAAI,CAAC;SACf,CAAC;QACF,OAAO,EAAE;YACP,QAAQ,EAAE,OAAO,CAAC;YAClB,MAAM,EAAE;gBAAE,MAAM,EAAE,MAAM,CAAA;aAAE,CAAC;YAG3B,OAAO,EAAE,IAAI,CAAC;SACf,CAAC;KACH;CACF"}
|
package/dist/esm/public.js
CHANGED
|
@@ -6,6 +6,6 @@ import { LdtkFormatError } from "./validate.js";
|
|
|
6
6
|
import { LdtkProject } from "./LdtkProject.js";
|
|
7
7
|
import { LdtkMapAssetType, LdtkProjectAssetType, ldtkMapType, ldtkProjectType } from "./ldtkTypes.js";
|
|
8
8
|
import { ldtkExtension } from "./ldtkExtension.js";
|
|
9
|
-
import { MapLevelRuntime, MapLevelSide as MapLevelSide$1, MapObjectSpawner, MapSpawnError, MapSpawnSession, MapWorld as MapWorld$1, MapWorldRuntime as MapWorldRuntime$1, ObjectKind, ObjectLayer as ObjectLayer$1, TILE_TRANSFORM_IDENTITY, TileLayer as TileLayer$1, TileMap as TileMap$1, TileMapView, TilePropertyKind as TilePropertyKind$1, TileSet as TileSet$1, mapObjectDescriptor, mapObjectDescriptors, tilemapExtension as tilemapExtension$1 } from "@codexo/exojs
|
|
9
|
+
import { MapLevelRuntime, MapLevelSide as MapLevelSide$1, MapObjectSpawner, MapSpawnError, MapSpawnSession, MapWorld as MapWorld$1, MapWorldRuntime as MapWorldRuntime$1, ObjectKind, ObjectLayer as ObjectLayer$1, TILE_TRANSFORM_IDENTITY, TileLayer as TileLayer$1, TileMap as TileMap$1, TileMapView, TilePropertyKind as TilePropertyKind$1, TileSet as TileSet$1, mapObjectDescriptor, mapObjectDescriptors, tilemapExtension as tilemapExtension$1 } from "@codexo/exojs/tilemap";
|
|
10
10
|
|
|
11
11
|
export { LDTK_FLIP_NONE, LDTK_FLIP_X, LDTK_FLIP_XY, LDTK_FLIP_Y, LdtkFormatError, LdtkMap, LdtkMapAssetType, LdtkProject, LdtkProjectAssetType, MapLevelRuntime, MapLevelSide$1 as MapLevelSide, MapObjectSpawner, MapSpawnError, MapSpawnSession, MapWorld$1 as MapWorld, MapWorldRuntime$1 as MapWorldRuntime, ObjectKind, ObjectLayer$1 as ObjectLayer, TILE_TRANSFORM_IDENTITY, TileLayer$1 as TileLayer, TileMap$1 as TileMap, TileMapView, TilePropertyKind$1 as TilePropertyKind, TileSet$1 as TileSet, createLdtkIntGridCellSource, getLdtkIntGridValueAt, isLdtkFieldEnumType, ldtkExtension, ldtkIntGridCsvProperty, ldtkIntGridValuesProperty, ldtkMapType, ldtkProjectType, ldtkToMapWorld, ldtkToTileMap, mapObjectDescriptor, mapObjectDescriptors, tilemapExtension$1 as tilemapExtension };
|
package/dist/esm/url.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.d.ts","
|
|
1
|
+
{"version":3,"file":"url.d.ts","sources":["../../src/url.ts"],"names":[],"mappings":""}
|
package/dist/esm/url.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/url.ts
|
|
2
2
|
/** Matches references that are already absolute and must not be re-resolved: scheme:, protocol-relative `//`, root-relative `/`, and data/blob URLs. */
|
|
3
3
|
const ABSOLUTE_REF = /^(?:[a-z][a-z\d+.-]*:|\/\/|\/)/i;
|
|
4
4
|
/** Matches a base that is itself an absolute URL with a scheme. */
|
|
@@ -26,6 +26,5 @@ const resolveLdtkUrl = (ref, base) => {
|
|
|
26
26
|
return base.startsWith("/") ? `/${relative}` : relative;
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
//#endregion
|
|
30
29
|
export { resolveLdtkUrl };
|
|
31
30
|
//# sourceMappingURL=url.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.ts","
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sources":["../../src/validate.ts"],"names":[],"mappings":"AAsBA;;;;;GAKG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IACxC,SAAgB,MAAM,EAAE,MAAM,CAAC;IAC/B,SAAgB,IAAI,EAAE,MAAM,CAAC;IAE7B,YAAmB,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAK/D;CACF"}
|
package/dist/esm/validate.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isLdtkFieldEnumType } from "./LdtkData.js";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// src/validate.ts
|
|
4
4
|
/**
|
|
5
5
|
* Thrown when an LDtk JSON document does not match the expected shape.
|
|
6
6
|
* `source` is the URL of the file being parsed; `path` is a JSON-path-like
|
|
@@ -120,6 +120,16 @@ const validateTilesetDef = (raw, source, path) => {
|
|
|
120
120
|
expectNonNegativeInteger(def.pxHei, source, joinPath(path, "pxHei"));
|
|
121
121
|
optionalNonNegativeInteger(def, "spacing", source, path);
|
|
122
122
|
optionalNonNegativeInteger(def, "padding", source, path);
|
|
123
|
+
if (def.customData !== void 0) eachEntry(def.customData, source, joinPath(path, "customData"), (item, itemPath) => {
|
|
124
|
+
const entry = expectObject(item, source, itemPath);
|
|
125
|
+
expectNonNegativeInteger(entry.tileId, source, joinPath(itemPath, "tileId"));
|
|
126
|
+
expectString(entry.data, source, joinPath(itemPath, "data"));
|
|
127
|
+
});
|
|
128
|
+
if (def.enumTags !== void 0) eachEntry(def.enumTags, source, joinPath(path, "enumTags"), (item, itemPath) => {
|
|
129
|
+
const entry = expectObject(item, source, itemPath);
|
|
130
|
+
expectString(entry.enumValueId, source, joinPath(itemPath, "enumValueId"));
|
|
131
|
+
eachEntry(entry.tileIds, source, joinPath(itemPath, "tileIds"), (id, idPath) => expectNonNegativeInteger(id, source, idPath));
|
|
132
|
+
});
|
|
123
133
|
};
|
|
124
134
|
const validateIntGridValueDef = (raw, source, path) => {
|
|
125
135
|
const value = expectObject(raw, source, path);
|
|
@@ -133,7 +143,8 @@ const validateLayerDef = (raw, source, path) => {
|
|
|
133
143
|
expectInteger(def.uid, source, joinPath(path, "uid"));
|
|
134
144
|
expectString(def.identifier, source, joinPath(path, "identifier"));
|
|
135
145
|
validateLayerType(def.type, source, joinPath(path, "type"));
|
|
136
|
-
expectNonNegativeInteger(def.gridSize, source, joinPath(path, "gridSize"));
|
|
146
|
+
if (def.type === "Entities") expectNonNegativeInteger(def.gridSize, source, joinPath(path, "gridSize"));
|
|
147
|
+
else expectPositiveInteger(def.gridSize, source, joinPath(path, "gridSize"));
|
|
137
148
|
optionalNumber(def, "pxOffsetX", source, path);
|
|
138
149
|
optionalNumber(def, "pxOffsetY", source, path);
|
|
139
150
|
optionalNumber(def, "parallaxFactorX", source, path);
|
|
@@ -249,6 +260,7 @@ const validateEntityInstance = (raw, source, path) => {
|
|
|
249
260
|
expectString(entity.iid, source, joinPath(path, "iid"));
|
|
250
261
|
expectInteger(entity.defUid, source, joinPath(path, "defUid"));
|
|
251
262
|
validateFieldInstances(entity.fieldInstances, source, joinPath(path, "fieldInstances"));
|
|
263
|
+
if (entity.__tags !== void 0) eachEntry(entity.__tags, source, joinPath(path, "__tags"), (item, itemPath) => expectString(item, source, itemPath));
|
|
252
264
|
};
|
|
253
265
|
const validateLayerInstance = (raw, source, path) => {
|
|
254
266
|
const layer = expectObject(raw, source, path);
|
|
@@ -256,7 +268,8 @@ const validateLayerInstance = (raw, source, path) => {
|
|
|
256
268
|
validateLayerType(layer.__type, source, joinPath(path, "__type"));
|
|
257
269
|
expectNonNegativeInteger(layer.__cWid, source, joinPath(path, "__cWid"));
|
|
258
270
|
expectNonNegativeInteger(layer.__cHei, source, joinPath(path, "__cHei"));
|
|
259
|
-
expectNonNegativeInteger(layer.__gridSize, source, joinPath(path, "__gridSize"));
|
|
271
|
+
if (layer.__type === "Entities") expectNonNegativeInteger(layer.__gridSize, source, joinPath(path, "__gridSize"));
|
|
272
|
+
else expectPositiveInteger(layer.__gridSize, source, joinPath(path, "__gridSize"));
|
|
260
273
|
expectInteger(layer.layerDefUid, source, joinPath(path, "layerDefUid"));
|
|
261
274
|
expectInteger(layer.levelId, source, joinPath(path, "levelId"));
|
|
262
275
|
expectBoolean(layer.visible, source, joinPath(path, "visible"));
|
|
@@ -280,6 +293,8 @@ const validateLevel = (raw, source, path) => {
|
|
|
280
293
|
expectNumber(level.pxWid, source, joinPath(path, "pxWid"));
|
|
281
294
|
expectNumber(level.pxHei, source, joinPath(path, "pxHei"));
|
|
282
295
|
nullableString(level, "externalRelPath", source, path);
|
|
296
|
+
nullableString(level, "bgColor", source, path);
|
|
297
|
+
nullableString(level, "__bgColor", source, path);
|
|
283
298
|
if (level.__neighbours !== void 0 && level.__neighbours !== null) eachEntry(level.__neighbours, source, joinPath(path, "__neighbours"), (item, itemPath) => {
|
|
284
299
|
const neighbour = expectObject(item, source, itemPath);
|
|
285
300
|
expectString(neighbour.levelIid, source, joinPath(itemPath, "levelIid"));
|
|
@@ -328,6 +343,5 @@ const validateLdtkLevelData = (raw, source) => {
|
|
|
328
343
|
return raw;
|
|
329
344
|
};
|
|
330
345
|
|
|
331
|
-
//#endregion
|
|
332
346
|
export { LdtkFormatError, validateLdtkData, validateLdtkLevelData };
|
|
333
347
|
//# sourceMappingURL=validate.js.map
|
package/dist/esm/validate.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.js","names":[],"sources":["../../src/validate.ts"],"sourcesContent":["// Runtime validation for LDtk JSON (`.ldtk` / `.ldtkl`) documents. Both entry\n// points take `unknown` (the result of `JSON.parse`) and either return the same\n// value typed as `LdtkData` / `LdtkLevel`, or throw an {@link LdtkFormatError}\n// carrying the source URL and a JSON-path-like pointer to the offending value.\n//\n// Deliberately leaner than the Tiled adapter's `validate.ts`: it checks the\n// fields declared as required by this package's `LdtkData` model plus the\n// optional ones the adapter actually reads, and nothing else. Field-instance\n// `__value`s are checked against the shape their `__type` declares, because the\n// conversion pass casts rather than probes; a `__type` this package does not\n// model is left alone so a future LDtk field type still loads.\n//\n// Unlike the Tiled validator, this one asserts in place and hands the caller\n// back the very object it was given rather than rebuilding a normalised copy.\n// That keeps `LdtkMap.data` byte-for-byte what LDtk wrote, matching the\n// \"unknown fields are not stripped at parse time\" contract documented on\n// `LdtkData`.\n\nimport type { LdtkData, LdtkLayerType, LdtkLevel, LdtkWorldLayout } from './LdtkData';\nimport { isLdtkFieldEnumType } from './LdtkData';\n\n/**\n * Thrown when an LDtk JSON document does not match the expected shape.\n * `source` is the URL of the file being parsed; `path` is a JSON-path-like\n * pointer (e.g. `levels[0].layerInstances[1].gridTiles[0].px`) to the\n * offending value, or `''` for the document root.\n */\nexport class LdtkFormatError extends Error {\n public readonly source: string;\n public readonly path: string;\n\n public constructor(source: string, path: string, message: string) {\n super(`Invalid LDtk data in \"${source}\" at ${path === '' ? '<root>' : path}: ${message}`);\n this.name = 'LdtkFormatError';\n this.source = source;\n this.path = path;\n }\n}\n\n// ── Primitive helpers ────────────────────────────────────────────────────────\n\nconst describeValue = (value: unknown): string => {\n if (value === null) return 'null';\n if (value === undefined) return 'undefined';\n if (Array.isArray(value)) return 'an array';\n return typeof value;\n};\n\nconst joinPath = (path: string, key: string | number): string => {\n if (typeof key === 'number') return `${path}[${key}]`;\n return path === '' ? key : `${path}.${key}`;\n};\n\nconst expectObject = (value: unknown, source: string, path: string): Record<string, unknown> => {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n throw new LdtkFormatError(source, path, `expected an object, got ${describeValue(value)}`);\n }\n return value as Record<string, unknown>;\n};\n\nconst expectArray = (value: unknown, source: string, path: string): readonly unknown[] => {\n if (!Array.isArray(value)) {\n throw new LdtkFormatError(source, path, `expected an array, got ${describeValue(value)}`);\n }\n return value as readonly unknown[];\n};\n\nconst expectString = (value: unknown, source: string, path: string): string => {\n if (typeof value !== 'string') {\n throw new LdtkFormatError(source, path, `expected a string, got ${describeValue(value)}`);\n }\n return value;\n};\n\nconst expectNumber = (value: unknown, source: string, path: string): number => {\n if (typeof value !== 'number' || !Number.isFinite(value)) {\n throw new LdtkFormatError(source, path, `expected a finite number, got ${describeValue(value)}`);\n }\n return value;\n};\n\nconst expectInteger = (value: unknown, source: string, path: string): number => {\n const n = expectNumber(value, source, path);\n if (!Number.isInteger(n)) {\n throw new LdtkFormatError(source, path, `expected an integer, got ${n}`);\n }\n return n;\n};\n\nconst expectNonNegativeInteger = (value: unknown, source: string, path: string): number => {\n const n = expectInteger(value, source, path);\n if (n < 0) {\n throw new LdtkFormatError(source, path, `expected a non-negative integer, got ${n}`);\n }\n return n;\n};\n\nconst expectPositiveInteger = (value: unknown, source: string, path: string): number => {\n const n = expectInteger(value, source, path);\n if (n <= 0) {\n throw new LdtkFormatError(source, path, `expected a positive integer, got ${n}`);\n }\n return n;\n};\n\nconst expectBoolean = (value: unknown, source: string, path: string): void => {\n if (typeof value !== 'boolean') {\n throw new LdtkFormatError(source, path, `expected a boolean, got ${describeValue(value)}`);\n }\n};\n\n/** `[x, y]` pixel/grid pairs (`px`, `src`, `__pivot`) are always two finite numbers. */\nconst expectNumberPair = (value: unknown, source: string, path: string): void => {\n const pair = expectArray(value, source, path);\n if (pair.length !== 2) {\n throw new LdtkFormatError(source, path, `expected a pair of numbers, got ${pair.length} entries`);\n }\n expectNumber(pair[0], source, joinPath(path, 0));\n expectNumber(pair[1], source, joinPath(path, 1));\n};\n\nconst optionalNumber = (obj: Record<string, unknown>, key: string, source: string, path: string): void => {\n if (obj[key] !== undefined) expectNumber(obj[key], source, joinPath(path, key));\n};\n\nconst optionalNonNegativeInteger = (obj: Record<string, unknown>, key: string, source: string, path: string): void => {\n if (obj[key] !== undefined) expectNonNegativeInteger(obj[key], source, joinPath(path, key));\n};\n\n/**\n * LDtk writes an unset optional as an explicit `null` rather than omitting the\n * key, so a validator that only tolerates `undefined` rejects the files the\n * editor actually produces.\n */\nconst nullableString = (obj: Record<string, unknown>, key: string, source: string, path: string): void => {\n if (obj[key] !== undefined && obj[key] !== null) expectString(obj[key], source, joinPath(path, key));\n};\n\n/** See {@link nullableString}. */\nconst nullableInteger = (obj: Record<string, unknown>, key: string, source: string, path: string): void => {\n if (obj[key] !== undefined && obj[key] !== null) expectInteger(obj[key], source, joinPath(path, key));\n};\n\nconst optionalBoolean = (obj: Record<string, unknown>, key: string, source: string, path: string): void => {\n if (obj[key] !== undefined) expectBoolean(obj[key], source, joinPath(path, key));\n};\n\nconst eachEntry = (value: unknown, source: string, path: string, visit: (item: unknown, itemPath: string) => void): void => {\n const array = expectArray(value, source, path);\n for (let i = 0; i < array.length; i++) {\n visit(array[i], joinPath(path, i));\n }\n};\n\n// ── Definitions ──────────────────────────────────────────────────────────────\n\nconst LAYER_TYPES: readonly LdtkLayerType[] = ['Tiles', 'IntGrid', 'Entities', 'AutoLayer'];\nconst WORLD_LAYOUTS: readonly LdtkWorldLayout[] = ['Free', 'GridVania', 'LinearHorizontal', 'LinearVertical'];\n\nconst validateLayerType = (value: unknown, source: string, path: string): void => {\n const type = expectString(value, source, path);\n if (!LAYER_TYPES.includes(type as LdtkLayerType)) {\n throw new LdtkFormatError(source, path, `unknown layer type \"${type}\" (expected one of ${LAYER_TYPES.join(', ')})`);\n }\n};\n\nconst validateTilesetDef = (raw: unknown, source: string, path: string): void => {\n const def = expectObject(raw, source, path);\n\n expectInteger(def.uid, source, joinPath(path, 'uid'));\n expectString(def.identifier, source, joinPath(path, 'identifier'));\n\n // `relPath` is null for an embedded (\"embed atlas\") tileset, which the loader\n // skips - anything other than a string or null is malformed.\n const relPathPath = joinPath(path, 'relPath');\n if (def.relPath !== null) expectString(def.relPath, source, relPathPath);\n\n // A zero or negative grid size would make the loader's column arithmetic\n // divide by zero and yield a non-finite tile count.\n expectPositiveInteger(def.tileGridSize, source, joinPath(path, 'tileGridSize'));\n expectNonNegativeInteger(def.pxWid, source, joinPath(path, 'pxWid'));\n expectNonNegativeInteger(def.pxHei, source, joinPath(path, 'pxHei'));\n optionalNonNegativeInteger(def, 'spacing', source, path);\n optionalNonNegativeInteger(def, 'padding', source, path);\n};\n\nconst validateIntGridValueDef = (raw: unknown, source: string, path: string): void => {\n const value = expectObject(raw, source, path);\n\n expectNumber(value.value, source, joinPath(path, 'value'));\n const identifierPath = joinPath(path, 'identifier');\n if (value.identifier !== null) expectString(value.identifier, source, identifierPath);\n expectString(value.color, source, joinPath(path, 'color'));\n};\n\nconst validateLayerDef = (raw: unknown, source: string, path: string): void => {\n const def = expectObject(raw, source, path);\n\n expectInteger(def.uid, source, joinPath(path, 'uid'));\n expectString(def.identifier, source, joinPath(path, 'identifier'));\n validateLayerType(def.type, source, joinPath(path, 'type'));\n expectNonNegativeInteger(def.gridSize, source, joinPath(path, 'gridSize'));\n optionalNumber(def, 'pxOffsetX', source, path);\n optionalNumber(def, 'pxOffsetY', source, path);\n optionalNumber(def, 'parallaxFactorX', source, path);\n optionalNumber(def, 'parallaxFactorY', source, path);\n optionalBoolean(def, 'parallaxScaling', source, path);\n\n if (def.intGridValues !== undefined) {\n eachEntry(def.intGridValues, source, joinPath(path, 'intGridValues'), (item, itemPath) => validateIntGridValueDef(item, source, itemPath));\n }\n};\n\nconst validateDefs = (raw: unknown, source: string, path: string): void => {\n const defs = expectObject(raw, source, path);\n\n eachEntry(defs.tilesets, source, joinPath(path, 'tilesets'), (item, itemPath) => validateTilesetDef(item, source, itemPath));\n eachEntry(defs.layers, source, joinPath(path, 'layers'), (item, itemPath) => validateLayerDef(item, source, itemPath));\n};\n\n// ── Instances ────────────────────────────────────────────────────────────────\n\n/**\n * Validate one field-instance `__value` against the shape its `__type` declares.\n *\n * `null` is LDtk's \"not set\" and always passes - the conversion drops the\n * property. Everything else is checked here because the conversion pass casts\n * rather than probes: a `Point` whose value is not `{cx, cy}` used to reach the\n * runtime as a point with `undefined` coordinates, indistinguishable from a\n * genuine one until something read it.\n *\n * A `__type` this package does not model (a future LDtk field type, or an\n * `Array<T>` element type of one) is left unchecked here: the conversion pass\n * is where an unsupported type is reported, and it names the type.\n */\nconst validateFieldValue = (typeName: string, value: unknown, source: string, path: string): void => {\n if (value === null || value === undefined) return;\n\n // `LocalEnum.X` / `ExternEnum.X` - the selected entry's identifier.\n if (isLdtkFieldEnumType(typeName)) {\n expectString(value, source, path);\n\n return;\n }\n\n switch (typeName) {\n case 'Int':\n expectInteger(value, source, path);\n return;\n\n case 'Float':\n expectNumber(value, source, path);\n return;\n\n case 'Bool':\n expectBoolean(value, source, path);\n return;\n\n case 'String':\n case 'Multilines':\n case 'Color':\n case 'FilePath':\n case 'Enum':\n expectString(value, source, path);\n return;\n\n case 'Point': {\n const point = expectObject(value, source, path);\n\n expectNumber(point.cx, source, joinPath(path, 'cx'));\n expectNumber(point.cy, source, joinPath(path, 'cy'));\n\n return;\n }\n\n case 'EntityRef': {\n const ref = expectObject(value, source, path);\n\n for (const key of ['entityIid', 'layerIid', 'levelIid', 'worldIid'] as const) {\n expectString(ref[key], source, joinPath(path, key));\n }\n\n return;\n }\n\n case 'Tile': {\n const tile = expectObject(value, source, path);\n\n expectInteger(tile.tilesetUid, source, joinPath(path, 'tilesetUid'));\n\n for (const key of ['x', 'y', 'w', 'h'] as const) {\n expectNumber(tile[key], source, joinPath(path, key));\n }\n\n return;\n }\n\n default:\n if (typeName.startsWith('Array<') && typeName.endsWith('>')) {\n const elementType = typeName.slice('Array<'.length, -1);\n\n eachEntry(value, source, path, (item, itemPath) => validateFieldValue(elementType, item, source, itemPath));\n }\n }\n};\n\n/**\n * A field instance is validated down to its identifier, declared type and the\n * shape of `__value` that type implies - see {@link validateFieldValue}.\n */\nconst validateFieldInstance = (raw: unknown, source: string, path: string): void => {\n const field = expectObject(raw, source, path);\n\n expectString(field.__identifier, source, joinPath(path, '__identifier'));\n\n const typeName = expectString(field.__type, source, joinPath(path, '__type'));\n\n validateFieldValue(typeName, field.__value, source, joinPath(path, '__value'));\n};\n\nconst validateFieldInstances = (value: unknown, source: string, path: string): void => {\n eachEntry(value, source, path, (item, itemPath) => validateFieldInstance(item, source, itemPath));\n};\n\nconst validateTile = (raw: unknown, source: string, path: string): void => {\n const tile = expectObject(raw, source, path);\n\n expectNumberPair(tile.px, source, joinPath(path, 'px'));\n expectNumberPair(tile.src, source, joinPath(path, 'src'));\n expectNumber(tile.f, source, joinPath(path, 'f'));\n expectNumber(tile.t, source, joinPath(path, 't'));\n};\n\nconst validateTiles = (value: unknown, source: string, path: string): void => {\n eachEntry(value, source, path, (item, itemPath) => validateTile(item, source, itemPath));\n};\n\nconst validateEntityInstance = (raw: unknown, source: string, path: string): void => {\n const entity = expectObject(raw, source, path);\n\n expectString(entity.__identifier, source, joinPath(path, '__identifier'));\n expectString(entity.__type, source, joinPath(path, '__type'));\n expectNumberPair(entity.px, source, joinPath(path, 'px'));\n expectNumber(entity.width, source, joinPath(path, 'width'));\n expectNumber(entity.height, source, joinPath(path, 'height'));\n expectNumberPair(entity.__pivot, source, joinPath(path, '__pivot'));\n expectString(entity.iid, source, joinPath(path, 'iid'));\n expectInteger(entity.defUid, source, joinPath(path, 'defUid'));\n validateFieldInstances(entity.fieldInstances, source, joinPath(path, 'fieldInstances'));\n};\n\nconst validateLayerInstance = (raw: unknown, source: string, path: string): void => {\n const layer = expectObject(raw, source, path);\n\n expectString(layer.__identifier, source, joinPath(path, '__identifier'));\n validateLayerType(layer.__type, source, joinPath(path, '__type'));\n expectNonNegativeInteger(layer.__cWid, source, joinPath(path, '__cWid'));\n expectNonNegativeInteger(layer.__cHei, source, joinPath(path, '__cHei'));\n expectNonNegativeInteger(layer.__gridSize, source, joinPath(path, '__gridSize'));\n expectInteger(layer.layerDefUid, source, joinPath(path, 'layerDefUid'));\n expectInteger(layer.levelId, source, joinPath(path, 'levelId'));\n expectBoolean(layer.visible, source, joinPath(path, 'visible'));\n expectString(layer.iid, source, joinPath(path, 'iid'));\n\n nullableInteger(layer, '__tilesetDefUid', source, path);\n if (layer.gridTiles !== undefined) {\n validateTiles(layer.gridTiles, source, joinPath(path, 'gridTiles'));\n }\n if (layer.autoLayerTiles !== undefined) {\n validateTiles(layer.autoLayerTiles, source, joinPath(path, 'autoLayerTiles'));\n }\n if (layer.entityInstances !== undefined) {\n eachEntry(layer.entityInstances, source, joinPath(path, 'entityInstances'), (item, itemPath) => validateEntityInstance(item, source, itemPath));\n }\n if (layer.intGridCsv !== undefined) {\n eachEntry(layer.intGridCsv, source, joinPath(path, 'intGridCsv'), (item, itemPath) => expectNumber(item, source, itemPath));\n }\n optionalNumber(layer, 'pxOffsetX', source, path);\n optionalNumber(layer, 'pxOffsetY', source, path);\n optionalNumber(layer, 'opacity', source, path);\n};\n\nconst validateLevel = (raw: unknown, source: string, path: string): void => {\n const level = expectObject(raw, source, path);\n\n expectString(level.identifier, source, joinPath(path, 'identifier'));\n expectInteger(level.uid, source, joinPath(path, 'uid'));\n expectString(level.iid, source, joinPath(path, 'iid'));\n expectNumber(level.worldX, source, joinPath(path, 'worldX'));\n expectNumber(level.worldY, source, joinPath(path, 'worldY'));\n expectNumber(level.pxWid, source, joinPath(path, 'pxWid'));\n expectNumber(level.pxHei, source, joinPath(path, 'pxHei'));\n nullableString(level, 'externalRelPath', source, path);\n\n // Same explicit-null rule as the fields above: an isolated level can arrive\n // with a null here rather than an empty array.\n if (level.__neighbours !== undefined && level.__neighbours !== null) {\n eachEntry(level.__neighbours, source, joinPath(path, '__neighbours'), (item, itemPath) => {\n const neighbour = expectObject(item, source, itemPath);\n expectString(neighbour.levelIid, source, joinPath(itemPath, 'levelIid'));\n expectString(neighbour.dir, source, joinPath(itemPath, 'dir'));\n });\n }\n\n if (level.fieldInstances !== undefined) {\n validateFieldInstances(level.fieldInstances, source, joinPath(path, 'fieldInstances'));\n }\n\n // `null` marks a level whose layers live in a separate `.ldtkl` file; the\n // loader resolves those before conversion.\n const layerInstancesPath = joinPath(path, 'layerInstances');\n if (level.layerInstances !== null) {\n eachEntry(level.layerInstances, source, layerInstancesPath, (item, itemPath) => validateLayerInstance(item, source, itemPath));\n }\n};\n\nconst validateWorld = (raw: unknown, source: string, path: string): void => {\n const world = expectObject(raw, source, path);\n\n expectString(world.identifier, source, joinPath(path, 'identifier'));\n expectString(world.iid, source, joinPath(path, 'iid'));\n expectNumber(world.worldGridWidth, source, joinPath(path, 'worldGridWidth'));\n expectNumber(world.worldGridHeight, source, joinPath(path, 'worldGridHeight'));\n\n const layoutPath = joinPath(path, 'worldLayout');\n if (world.worldLayout !== null) {\n const layout = expectString(world.worldLayout, source, layoutPath);\n if (!WORLD_LAYOUTS.includes(layout as LdtkWorldLayout)) {\n throw new LdtkFormatError(source, layoutPath, `unknown world layout \"${layout}\" (expected one of ${WORLD_LAYOUTS.join(', ')} or null)`);\n }\n }\n\n eachEntry(world.levels, source, joinPath(path, 'levels'), (item, itemPath) => validateLevel(item, source, itemPath));\n};\n\n// ── Entry points ─────────────────────────────────────────────────────────────\n\n/**\n * Validate the root of a `.ldtk` file and return it typed as {@link LdtkData}.\n * Throws {@link LdtkFormatError} on any structural problem, naming the source\n * URL and the property path of the offending value.\n * @internal\n */\nexport const validateLdtkData = (raw: unknown, source: string): LdtkData => {\n const root = expectObject(raw, source, '');\n\n expectString(root.jsonVersion, source, 'jsonVersion');\n optionalNumber(root, 'defaultGridSize', source, '');\n validateDefs(root.defs, source, 'defs');\n\n // Both root shapes carry `levels`: it holds every level in a single-world\n // document and is present-but-empty once `worlds[]` is used.\n eachEntry(root.levels, source, 'levels', (item, itemPath) => validateLevel(item, source, itemPath));\n\n if (root.worlds !== undefined) {\n eachEntry(root.worlds, source, 'worlds', (item, itemPath) => validateWorld(item, source, itemPath));\n }\n\n return raw as LdtkData;\n};\n\n/**\n * Validate an external `.ldtkl` payload and return it typed as\n * {@link LdtkLevel}. Paths in a thrown {@link LdtkFormatError} are relative to\n * the level object, since that object is the root of the `.ldtkl` file.\n * @internal\n */\nexport const validateLdtkLevelData = (raw: unknown, source: string): LdtkLevel => {\n validateLevel(raw, source, '');\n\n return raw as LdtkLevel;\n};\n"],"mappings":";;;;;;;;;AA2BA,IAAa,kBAAb,cAAqC,MAAM;CACzC,AAAgB;CAChB,AAAgB;CAEhB,AAAO,YAAY,QAAgB,MAAc,SAAiB;EAChE,MAAM,yBAAyB,OAAO,OAAO,SAAS,KAAK,WAAW,KAAK,IAAI,SAAS;EACxF,KAAK,OAAO;EACZ,KAAK,SAAS;EACd,KAAK,OAAO;CACd;AACF;AAIA,MAAM,iBAAiB,UAA2B;CAChD,IAAI,UAAU,MAAM,OAAO;CAC3B,IAAI,UAAU,QAAW,OAAO;CAChC,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO;CACjC,OAAO,OAAO;AAChB;AAEA,MAAM,YAAY,MAAc,QAAiC;CAC/D,IAAI,OAAO,QAAQ,UAAU,OAAO,GAAG,KAAK,GAAG,IAAI;CACnD,OAAO,SAAS,KAAK,MAAM,GAAG,KAAK,GAAG;AACxC;AAEA,MAAM,gBAAgB,OAAgB,QAAgB,SAA0C;CAC9F,IAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,MAAM,QAAQ,KAAK,GACpE,MAAM,IAAI,gBAAgB,QAAQ,MAAM,2BAA2B,cAAc,KAAK,GAAG;CAE3F,OAAO;AACT;AAEA,MAAM,eAAe,OAAgB,QAAgB,SAAqC;CACxF,IAAI,CAAC,MAAM,QAAQ,KAAK,GACtB,MAAM,IAAI,gBAAgB,QAAQ,MAAM,0BAA0B,cAAc,KAAK,GAAG;CAE1F,OAAO;AACT;AAEA,MAAM,gBAAgB,OAAgB,QAAgB,SAAyB;CAC7E,IAAI,OAAO,UAAU,UACnB,MAAM,IAAI,gBAAgB,QAAQ,MAAM,0BAA0B,cAAc,KAAK,GAAG;CAE1F,OAAO;AACT;AAEA,MAAM,gBAAgB,OAAgB,QAAgB,SAAyB;CAC7E,IAAI,OAAO,UAAU,YAAY,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oB,KAAc,WAA6B;CAC1E,MAAM,OAAO,aAAa,KAAK,QAAQ,EAAE;CAEzC,aAAa,KAAK,aAAa,QAAQ,aAAa;CACpD,eAAe,MAAM,mBAAmB,QAAQ,EAAE;CAClD,aAAa,KAAK,MAAM,QAAQ,MAAM;CAItC,UAAU,KAAK,QAAQ,QAAQ,WAAW,MAAM,aAAa,cAAc,MAAM,QAAQ,QAAQ,CAAC;CAElG,IAAI,KAAK,WAAW,QAClB,UAAU,KAAK,QAAQ,QAAQ,WAAW,MAAM,aAAa,cAAc,MAAM,QAAQ,QAAQ,CAAC;CAGpG,OAAO;AACT;;;;;;;AAQA,MAAa,yBAAyB,KAAc,WAA8B;CAChF,cAAc,KAAK,QAAQ,EAAE;CAE7B,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"validate.js","names":[],"sources":["../../src/validate.ts"],"sourcesContent":["// Runtime validation for LDtk JSON (`.ldtk` / `.ldtkl`) documents. Both entry\n// points take `unknown` (the result of `JSON.parse`) and either return the same\n// value typed as `LdtkData` / `LdtkLevel`, or throw an {@link LdtkFormatError}\n// carrying the source URL and a JSON-path-like pointer to the offending value.\n//\n// Deliberately leaner than the Tiled adapter's `validate.ts`: it checks the\n// fields declared as required by this package's `LdtkData` model plus the\n// optional ones the adapter actually reads, and nothing else. Field-instance\n// `__value`s are checked against the shape their `__type` declares, because the\n// conversion pass casts rather than probes; a `__type` this package does not\n// model is left unchecked here, and the conversion pass rejects it by name\n// when a non-null value of that type is converted.\n//\n// Unlike the Tiled validator, this one asserts in place and hands the caller\n// back the very object it was given rather than rebuilding a normalised copy.\n// That keeps `LdtkMap.data` byte-for-byte what LDtk wrote, matching the\n// \"unknown fields are not stripped at parse time\" contract documented on\n// `LdtkData`.\n\nimport type { LdtkData, LdtkLayerType, LdtkLevel, LdtkWorldLayout } from './LdtkData';\nimport { isLdtkFieldEnumType } from './LdtkData';\n\n/**\n * Thrown when an LDtk JSON document does not match the expected shape.\n * `source` is the URL of the file being parsed; `path` is a JSON-path-like\n * pointer (e.g. `levels[0].layerInstances[1].gridTiles[0].px`) to the\n * offending value, or `''` for the document root.\n */\nexport class LdtkFormatError extends Error {\n public readonly source: string;\n public readonly path: string;\n\n public constructor(source: string, path: string, message: string) {\n super(`Invalid LDtk data in \"${source}\" at ${path === '' ? '<root>' : path}: ${message}`);\n this.name = 'LdtkFormatError';\n this.source = source;\n this.path = path;\n }\n}\n\n// ── Primitive helpers ────────────────────────────────────────────────────────\n\nconst describeValue = (value: unknown): string => {\n if (value === null) {\n return 'null';\n }\n\n if (value === undefined) {\n return 'undefined';\n }\n\n if (Array.isArray(value)) {\n return 'an array';\n }\n\n return typeof value;\n};\n\nconst joinPath = (path: string, key: string | number): string => {\n if (typeof key === 'number') {\n return `${path}[${key}]`;\n }\n\n return path === '' ? key : `${path}.${key}`;\n};\n\nconst expectObject = (value: unknown, source: string, path: string): Record<string, unknown> => {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n throw new LdtkFormatError(source, path, `expected an object, got ${describeValue(value)}`);\n }\n\n return value as Record<string, unknown>;\n};\n\nconst expectArray = (value: unknown, source: string, path: string): readonly unknown[] => {\n if (!Array.isArray(value)) {\n throw new LdtkFormatError(source, path, `expected an array, got ${describeValue(value)}`);\n }\n\n return value as readonly unknown[];\n};\n\nconst expectString = (value: unknown, source: string, path: string): string => {\n if (typeof value !== 'string') {\n throw new LdtkFormatError(source, path, `expected a string, got ${describeValue(value)}`);\n }\n\n return value;\n};\n\nconst expectNumber = (value: unknown, source: string, path: string): number => {\n if (typeof value !== 'number' || !Number.isFinite(value)) {\n throw new LdtkFormatError(source, path, `expected a finite number, got ${describeValue(value)}`);\n }\n\n return value;\n};\n\nconst expectInteger = (value: unknown, source: string, path: string): number => {\n const n = expectNumber(value, source, path);\n\n if (!Number.isInteger(n)) {\n throw new LdtkFormatError(source, path, `expected an integer, got ${n}`);\n }\n\n return n;\n};\n\nconst expectNonNegativeInteger = (value: unknown, source: string, path: string): number => {\n const n = expectInteger(value, source, path);\n\n if (n < 0) {\n throw new LdtkFormatError(source, path, `expected a non-negative integer, got ${n}`);\n }\n\n return n;\n};\n\nconst expectPositiveInteger = (value: unknown, source: string, path: string): number => {\n const n = expectInteger(value, source, path);\n\n if (n <= 0) {\n throw new LdtkFormatError(source, path, `expected a positive integer, got ${n}`);\n }\n\n return n;\n};\n\nconst expectBoolean = (value: unknown, source: string, path: string): void => {\n if (typeof value !== 'boolean') {\n throw new LdtkFormatError(source, path, `expected a boolean, got ${describeValue(value)}`);\n }\n};\n\n/** `[x, y]` pixel/grid pairs (`px`, `src`, `__pivot`) are always two finite numbers. */\nconst expectNumberPair = (value: unknown, source: string, path: string): void => {\n const pair = expectArray(value, source, path);\n\n if (pair.length !== 2) {\n throw new LdtkFormatError(source, path, `expected a pair of numbers, got ${pair.length} entries`);\n }\n\n expectNumber(pair[0], source, joinPath(path, 0));\n expectNumber(pair[1], source, joinPath(path, 1));\n};\n\nconst optionalNumber = (obj: Record<string, unknown>, key: string, source: string, path: string): void => {\n if (obj[key] !== undefined) {\n expectNumber(obj[key], source, joinPath(path, key));\n }\n};\n\nconst optionalNonNegativeInteger = (obj: Record<string, unknown>, key: string, source: string, path: string): void => {\n if (obj[key] !== undefined) {\n expectNonNegativeInteger(obj[key], source, joinPath(path, key));\n }\n};\n\n/**\n * LDtk writes an unset optional as an explicit `null` rather than omitting the\n * key, so a validator that only tolerates `undefined` rejects the files the\n * editor actually produces.\n */\nconst nullableString = (obj: Record<string, unknown>, key: string, source: string, path: string): void => {\n if (obj[key] !== undefined && obj[key] !== null) {\n expectString(obj[key], source, joinPath(path, key));\n }\n};\n\n/** See {@link nullableString}. */\nconst nullableInteger = (obj: Record<string, unknown>, key: string, source: string, path: string): void => {\n if (obj[key] !== undefined && obj[key] !== null) {\n expectInteger(obj[key], source, joinPath(path, key));\n }\n};\n\nconst optionalBoolean = (obj: Record<string, unknown>, key: string, source: string, path: string): void => {\n if (obj[key] !== undefined) {\n expectBoolean(obj[key], source, joinPath(path, key));\n }\n};\n\nconst eachEntry = (value: unknown, source: string, path: string, visit: (item: unknown, itemPath: string) => void): void => {\n const array = expectArray(value, source, path);\n\n for (let i = 0; i < array.length; i++) {\n visit(array[i], joinPath(path, i));\n }\n};\n\n// ── Definitions ──────────────────────────────────────────────────────────────\n\nconst LAYER_TYPES: readonly LdtkLayerType[] = ['Tiles', 'IntGrid', 'Entities', 'AutoLayer'];\nconst WORLD_LAYOUTS: readonly LdtkWorldLayout[] = ['Free', 'GridVania', 'LinearHorizontal', 'LinearVertical'];\n\nconst validateLayerType = (value: unknown, source: string, path: string): void => {\n const type = expectString(value, source, path);\n\n if (!LAYER_TYPES.includes(type as LdtkLayerType)) {\n throw new LdtkFormatError(source, path, `unknown layer type \"${type}\" (expected one of ${LAYER_TYPES.join(', ')})`);\n }\n};\n\nconst validateTilesetDef = (raw: unknown, source: string, path: string): void => {\n const def = expectObject(raw, source, path);\n\n expectInteger(def.uid, source, joinPath(path, 'uid'));\n expectString(def.identifier, source, joinPath(path, 'identifier'));\n\n // `relPath` is null for an embedded (\"embed atlas\") tileset, which the loader\n // skips - anything other than a string or null is malformed.\n const relPathPath = joinPath(path, 'relPath');\n\n if (def.relPath !== null) {\n expectString(def.relPath, source, relPathPath);\n }\n\n // A zero or negative grid size would make the loader's column arithmetic\n // divide by zero and yield a non-finite tile count.\n expectPositiveInteger(def.tileGridSize, source, joinPath(path, 'tileGridSize'));\n expectNonNegativeInteger(def.pxWid, source, joinPath(path, 'pxWid'));\n expectNonNegativeInteger(def.pxHei, source, joinPath(path, 'pxHei'));\n optionalNonNegativeInteger(def, 'spacing', source, path);\n optionalNonNegativeInteger(def, 'padding', source, path);\n\n if (def.customData !== undefined) {\n eachEntry(def.customData, source, joinPath(path, 'customData'), (item, itemPath) => {\n const entry = expectObject(item, source, itemPath);\n expectNonNegativeInteger(entry.tileId, source, joinPath(itemPath, 'tileId'));\n expectString(entry.data, source, joinPath(itemPath, 'data'));\n });\n }\n\n if (def.enumTags !== undefined) {\n eachEntry(def.enumTags, source, joinPath(path, 'enumTags'), (item, itemPath) => {\n const entry = expectObject(item, source, itemPath);\n expectString(entry.enumValueId, source, joinPath(itemPath, 'enumValueId'));\n eachEntry(entry.tileIds, source, joinPath(itemPath, 'tileIds'), (id, idPath) => expectNonNegativeInteger(id, source, idPath));\n });\n }\n};\n\nconst validateIntGridValueDef = (raw: unknown, source: string, path: string): void => {\n const value = expectObject(raw, source, path);\n\n expectNumber(value.value, source, joinPath(path, 'value'));\n const identifierPath = joinPath(path, 'identifier');\n\n if (value.identifier !== null) {\n expectString(value.identifier, source, identifierPath);\n }\n\n expectString(value.color, source, joinPath(path, 'color'));\n};\n\nconst validateLayerDef = (raw: unknown, source: string, path: string): void => {\n const def = expectObject(raw, source, path);\n\n expectInteger(def.uid, source, joinPath(path, 'uid'));\n expectString(def.identifier, source, joinPath(path, 'identifier'));\n validateLayerType(def.type, source, joinPath(path, 'type'));\n\n // Entity layers never divide by the grid; every other layer type does.\n if (def.type === 'Entities') {\n expectNonNegativeInteger(def.gridSize, source, joinPath(path, 'gridSize'));\n } else {\n expectPositiveInteger(def.gridSize, source, joinPath(path, 'gridSize'));\n }\n\n optionalNumber(def, 'pxOffsetX', source, path);\n optionalNumber(def, 'pxOffsetY', source, path);\n optionalNumber(def, 'parallaxFactorX', source, path);\n optionalNumber(def, 'parallaxFactorY', source, path);\n optionalBoolean(def, 'parallaxScaling', source, path);\n\n if (def.intGridValues !== undefined) {\n eachEntry(def.intGridValues, source, joinPath(path, 'intGridValues'), (item, itemPath) =>\n validateIntGridValueDef(item, source, itemPath),\n );\n }\n};\n\nconst validateDefs = (raw: unknown, source: string, path: string): void => {\n const defs = expectObject(raw, source, path);\n\n eachEntry(defs.tilesets, source, joinPath(path, 'tilesets'), (item, itemPath) => validateTilesetDef(item, source, itemPath));\n eachEntry(defs.layers, source, joinPath(path, 'layers'), (item, itemPath) => validateLayerDef(item, source, itemPath));\n};\n\n// ── Instances ────────────────────────────────────────────────────────────────\n\n/**\n * Validate one field-instance `__value` against the shape its `__type` declares.\n *\n * `null` is LDtk's \"not set\" and always passes - the conversion drops the\n * property. Everything else is checked here because the conversion pass casts\n * rather than probes: a `Point` whose value is not `{cx, cy}` used to reach the\n * runtime as a point with `undefined` coordinates, indistinguishable from a\n * genuine one until something read it.\n *\n * A `__type` this package does not model (a future LDtk field type, or an\n * `Array<T>` element type of one) is left unchecked here: the conversion pass\n * is where an unsupported type is reported, and it names the type.\n */\nconst validateFieldValue = (typeName: string, value: unknown, source: string, path: string): void => {\n if (value === null || value === undefined) {\n return;\n }\n\n // `LocalEnum.X` / `ExternEnum.X` - the selected entry's identifier.\n if (isLdtkFieldEnumType(typeName)) {\n expectString(value, source, path);\n\n return;\n }\n\n switch (typeName) {\n case 'Int':\n expectInteger(value, source, path);\n\n return;\n\n case 'Float':\n expectNumber(value, source, path);\n\n return;\n\n case 'Bool':\n expectBoolean(value, source, path);\n\n return;\n\n case 'String':\n case 'Multilines':\n case 'Color':\n case 'FilePath':\n case 'Enum':\n expectString(value, source, path);\n\n return;\n\n case 'Point': {\n const point = expectObject(value, source, path);\n\n expectNumber(point.cx, source, joinPath(path, 'cx'));\n expectNumber(point.cy, source, joinPath(path, 'cy'));\n\n return;\n }\n\n case 'EntityRef': {\n const ref = expectObject(value, source, path);\n\n for (const key of ['entityIid', 'layerIid', 'levelIid', 'worldIid'] as const) {\n expectString(ref[key], source, joinPath(path, key));\n }\n\n return;\n }\n\n case 'Tile': {\n const tile = expectObject(value, source, path);\n\n expectInteger(tile.tilesetUid, source, joinPath(path, 'tilesetUid'));\n\n for (const key of ['x', 'y', 'w', 'h'] as const) {\n expectNumber(tile[key], source, joinPath(path, key));\n }\n\n return;\n }\n\n default:\n if (typeName.startsWith('Array<') && typeName.endsWith('>')) {\n const elementType = typeName.slice('Array<'.length, -1);\n\n eachEntry(value, source, path, (item, itemPath) => validateFieldValue(elementType, item, source, itemPath));\n }\n }\n};\n\n/**\n * A field instance is validated down to its identifier, declared type and the\n * shape of `__value` that type implies - see {@link validateFieldValue}.\n */\nconst validateFieldInstance = (raw: unknown, source: string, path: string): void => {\n const field = expectObject(raw, source, path);\n\n expectString(field.__identifier, source, joinPath(path, '__identifier'));\n\n const typeName = expectString(field.__type, source, joinPath(path, '__type'));\n\n validateFieldValue(typeName, field.__value, source, joinPath(path, '__value'));\n};\n\nconst validateFieldInstances = (value: unknown, source: string, path: string): void => {\n eachEntry(value, source, path, (item, itemPath) => validateFieldInstance(item, source, itemPath));\n};\n\nconst validateTile = (raw: unknown, source: string, path: string): void => {\n const tile = expectObject(raw, source, path);\n\n expectNumberPair(tile.px, source, joinPath(path, 'px'));\n expectNumberPair(tile.src, source, joinPath(path, 'src'));\n expectNumber(tile.f, source, joinPath(path, 'f'));\n expectNumber(tile.t, source, joinPath(path, 't'));\n};\n\nconst validateTiles = (value: unknown, source: string, path: string): void => {\n eachEntry(value, source, path, (item, itemPath) => validateTile(item, source, itemPath));\n};\n\nconst validateEntityInstance = (raw: unknown, source: string, path: string): void => {\n const entity = expectObject(raw, source, path);\n\n expectString(entity.__identifier, source, joinPath(path, '__identifier'));\n expectString(entity.__type, source, joinPath(path, '__type'));\n expectNumberPair(entity.px, source, joinPath(path, 'px'));\n expectNumber(entity.width, source, joinPath(path, 'width'));\n expectNumber(entity.height, source, joinPath(path, 'height'));\n expectNumberPair(entity.__pivot, source, joinPath(path, '__pivot'));\n expectString(entity.iid, source, joinPath(path, 'iid'));\n expectInteger(entity.defUid, source, joinPath(path, 'defUid'));\n validateFieldInstances(entity.fieldInstances, source, joinPath(path, 'fieldInstances'));\n\n if (entity.__tags !== undefined) {\n eachEntry(entity.__tags, source, joinPath(path, '__tags'), (item, itemPath) => expectString(item, source, itemPath));\n }\n};\n\nconst validateLayerInstance = (raw: unknown, source: string, path: string): void => {\n const layer = expectObject(raw, source, path);\n\n expectString(layer.__identifier, source, joinPath(path, '__identifier'));\n validateLayerType(layer.__type, source, joinPath(path, '__type'));\n expectNonNegativeInteger(layer.__cWid, source, joinPath(path, '__cWid'));\n expectNonNegativeInteger(layer.__cHei, source, joinPath(path, '__cHei'));\n\n // Entity layers never divide by the grid; every other layer type does.\n if (layer.__type === 'Entities') {\n expectNonNegativeInteger(layer.__gridSize, source, joinPath(path, '__gridSize'));\n } else {\n expectPositiveInteger(layer.__gridSize, source, joinPath(path, '__gridSize'));\n }\n\n expectInteger(layer.layerDefUid, source, joinPath(path, 'layerDefUid'));\n expectInteger(layer.levelId, source, joinPath(path, 'levelId'));\n expectBoolean(layer.visible, source, joinPath(path, 'visible'));\n expectString(layer.iid, source, joinPath(path, 'iid'));\n\n nullableInteger(layer, '__tilesetDefUid', source, path);\n\n if (layer.gridTiles !== undefined) {\n validateTiles(layer.gridTiles, source, joinPath(path, 'gridTiles'));\n }\n\n if (layer.autoLayerTiles !== undefined) {\n validateTiles(layer.autoLayerTiles, source, joinPath(path, 'autoLayerTiles'));\n }\n\n if (layer.entityInstances !== undefined) {\n eachEntry(layer.entityInstances, source, joinPath(path, 'entityInstances'), (item, itemPath) =>\n validateEntityInstance(item, source, itemPath),\n );\n }\n\n if (layer.intGridCsv !== undefined) {\n eachEntry(layer.intGridCsv, source, joinPath(path, 'intGridCsv'), (item, itemPath) => expectNumber(item, source, itemPath));\n }\n\n optionalNumber(layer, 'pxOffsetX', source, path);\n optionalNumber(layer, 'pxOffsetY', source, path);\n optionalNumber(layer, 'opacity', source, path);\n};\n\nconst validateLevel = (raw: unknown, source: string, path: string): void => {\n const level = expectObject(raw, source, path);\n\n expectString(level.identifier, source, joinPath(path, 'identifier'));\n expectInteger(level.uid, source, joinPath(path, 'uid'));\n expectString(level.iid, source, joinPath(path, 'iid'));\n expectNumber(level.worldX, source, joinPath(path, 'worldX'));\n expectNumber(level.worldY, source, joinPath(path, 'worldY'));\n expectNumber(level.pxWid, source, joinPath(path, 'pxWid'));\n expectNumber(level.pxHei, source, joinPath(path, 'pxHei'));\n nullableString(level, 'externalRelPath', source, path);\n nullableString(level, 'bgColor', source, path);\n nullableString(level, '__bgColor', source, path);\n\n // Same explicit-null rule as the fields above: an isolated level can arrive\n // with a null here rather than an empty array.\n if (level.__neighbours !== undefined && level.__neighbours !== null) {\n eachEntry(level.__neighbours, source, joinPath(path, '__neighbours'), (item, itemPath) => {\n const neighbour = expectObject(item, source, itemPath);\n expectString(neighbour.levelIid, source, joinPath(itemPath, 'levelIid'));\n expectString(neighbour.dir, source, joinPath(itemPath, 'dir'));\n });\n }\n\n if (level.fieldInstances !== undefined) {\n validateFieldInstances(level.fieldInstances, source, joinPath(path, 'fieldInstances'));\n }\n\n // `null` marks a level whose layers live in a separate `.ldtkl` file; the\n // loader resolves those before conversion.\n const layerInstancesPath = joinPath(path, 'layerInstances');\n\n if (level.layerInstances !== null) {\n eachEntry(level.layerInstances, source, layerInstancesPath, (item, itemPath) => validateLayerInstance(item, source, itemPath));\n }\n};\n\nconst validateWorld = (raw: unknown, source: string, path: string): void => {\n const world = expectObject(raw, source, path);\n\n expectString(world.identifier, source, joinPath(path, 'identifier'));\n expectString(world.iid, source, joinPath(path, 'iid'));\n expectNumber(world.worldGridWidth, source, joinPath(path, 'worldGridWidth'));\n expectNumber(world.worldGridHeight, source, joinPath(path, 'worldGridHeight'));\n\n const layoutPath = joinPath(path, 'worldLayout');\n\n if (world.worldLayout !== null) {\n const layout = expectString(world.worldLayout, source, layoutPath);\n\n if (!WORLD_LAYOUTS.includes(layout as LdtkWorldLayout)) {\n throw new LdtkFormatError(\n source,\n layoutPath,\n `unknown world layout \"${layout}\" (expected one of ${WORLD_LAYOUTS.join(', ')} or null)`,\n );\n }\n }\n\n eachEntry(world.levels, source, joinPath(path, 'levels'), (item, itemPath) => validateLevel(item, source, itemPath));\n};\n\n// ── Entry points ─────────────────────────────────────────────────────────────\n\n/**\n * Validate the root of a `.ldtk` file and return it typed as {@link LdtkData}.\n * Throws {@link LdtkFormatError} on any structural problem, naming the source\n * URL and the property path of the offending value.\n * @internal\n */\nexport const validateLdtkData = (raw: unknown, source: string): LdtkData => {\n const root = expectObject(raw, source, '');\n\n expectString(root.jsonVersion, source, 'jsonVersion');\n optionalNumber(root, 'defaultGridSize', source, '');\n validateDefs(root.defs, source, 'defs');\n\n // Both root shapes carry `levels`: it holds every level in a single-world\n // document and is present-but-empty once `worlds[]` is used.\n eachEntry(root.levels, source, 'levels', (item, itemPath) => validateLevel(item, source, itemPath));\n\n if (root.worlds !== undefined) {\n eachEntry(root.worlds, source, 'worlds', (item, itemPath) => validateWorld(item, source, itemPath));\n }\n\n return raw as LdtkData;\n};\n\n/**\n * Validate an external `.ldtkl` payload and return it typed as\n * {@link LdtkLevel}. Paths in a thrown {@link LdtkFormatError} are relative to\n * the level object, since that object is the root of the `.ldtkl` file.\n * @internal\n */\nexport const validateLdtkLevelData = (raw: unknown, source: string): LdtkLevel => {\n validateLevel(raw, source, '');\n\n return raw as LdtkLevel;\n};\n"],"mappings":";;;;;;;;;AA4BA,IAAa,kBAAb,cAAqC,MAAM;CACzC,AAAgB;CAChB,AAAgB;CAEhB,AAAO,YAAY,QAAgB,MAAc,SAAiB;EAChE,MAAM,yBAAyB,OAAO,OAAO,SAAS,KAAK,WAAW,KAAK,IAAI,SAAS;EACxF,KAAK,OAAO;EACZ,KAAK,SAAS;EACd,KAAK,OAAO;CACd;AACF;AAIA,MAAM,iBAAiB,UAA2B;CAChD,IAAI,UAAU,MACZ,OAAO;CAGT,IAAI,UAAU,QACZ,OAAO;CAGT,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO;CAGT,OAAO,OAAO;AAChB;AAEA,MAAM,YAAY,MAAc,QAAiC;CAC/D,IAAI,OAAO,QAAQ,UACjB,OAAO,GAAG,KAAK,GAAG,IAAI;CAGxB,OAAO,SAAS,KAAK,MAAM,GAAG,KAAK,GAAG;AACxC;AAEA,MAAM,gBAAgB,OAAgB,QAAgB,SAA0C;CAC9F,IAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,MAAM,QAAQ,KAAK,GACpE,MAAM,IAAI,gBAAgB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c,KAAK,IAAI,EAAE,UAChF;CAEJ;CAEA,UAAU,MAAM,QAAQ,QAAQ,SAAS,MAAM,QAAQ,IAAI,MAAM,aAAa,cAAc,MAAM,QAAQ,QAAQ,CAAC;AACrH;;;;;;;AAUA,MAAa,oBAAoB,KAAc,WAA6B;CAC1E,MAAM,OAAO,aAAa,KAAK,QAAQ,EAAE;CAEzC,aAAa,KAAK,aAAa,QAAQ,aAAa;CACpD,eAAe,MAAM,mBAAmB,QAAQ,EAAE;CAClD,aAAa,KAAK,MAAM,QAAQ,MAAM;CAItC,UAAU,KAAK,QAAQ,QAAQ,WAAW,MAAM,aAAa,cAAc,MAAM,QAAQ,QAAQ,CAAC;CAElG,IAAI,KAAK,WAAW,QAClB,UAAU,KAAK,QAAQ,QAAQ,WAAW,MAAM,aAAa,cAAc,MAAM,QAAQ,QAAQ,CAAC;CAGpG,OAAO;AACT;;;;;;;AAQA,MAAa,yBAAyB,KAAc,WAA8B;CAChF,cAAc,KAAK,QAAQ,EAAE;CAE7B,OAAO;AACT"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codexo/exojs-ldtk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "LDtk level format asset extension for ExoJS.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,20 +26,18 @@
|
|
|
26
26
|
"LICENSE"
|
|
27
27
|
],
|
|
28
28
|
"peerDependencies": {
|
|
29
|
-
"@codexo/exojs": "0.
|
|
30
|
-
"@codexo/exojs-tilemap": "0.19.x"
|
|
29
|
+
"@codexo/exojs": "0.20.x"
|
|
31
30
|
},
|
|
32
31
|
"devDependencies": {
|
|
33
|
-
"@codexo/exojs": "0.
|
|
34
|
-
"@codexo/exojs-config": "0.0.0"
|
|
35
|
-
"@codexo/exojs-tilemap": "0.19.1"
|
|
32
|
+
"@codexo/exojs": "0.20.0",
|
|
33
|
+
"@codexo/exojs-config": "0.0.0"
|
|
36
34
|
},
|
|
37
35
|
"license": "MIT",
|
|
38
36
|
"publishConfig": {
|
|
39
37
|
"access": "public"
|
|
40
38
|
},
|
|
41
39
|
"scripts": {
|
|
42
|
-
"build": "tsx ../../scripts/build-extension.ts",
|
|
40
|
+
"build": "node --import tsx ../../scripts/build-extension.ts",
|
|
43
41
|
"build:dev": "tsx ../../scripts/build-extension.ts --dev",
|
|
44
42
|
"typecheck": "exo-tsc --noEmit && exo-tsc --noEmit -p tsconfig.test.json",
|
|
45
43
|
"lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
|