From cec238031e848c8d709e2d039086895eb3946de5 Mon Sep 17 00:00:00 2001 From: Erik Onarheim Date: Fri, 4 Apr 2025 08:29:55 -0500 Subject: [PATCH 1/5] fix: [#618] Tampering with original value casing + configurable property matching --- src/resource/filter-util.ts | 48 ++++++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 9 deletions(-) diff --git a/src/resource/filter-util.ts b/src/resource/filter-util.ts index cb9db0d6..dd5daf71 100644 --- a/src/resource/filter-util.ts +++ b/src/resource/filter-util.ts @@ -1,6 +1,6 @@ export const byNameCaseInsensitive = (name?: string) => { - return (object: TObject) => { + return (object: TObject) => { if (object?.name && name) { return object.name.toLocaleLowerCase().localeCompare(name.toLocaleLowerCase()) === 0; } @@ -9,7 +9,7 @@ export const byNameCaseInsensitive = (name?: string) => { } export const byClassCaseInsensitive = (className?: string) => { - return (object: TObject) => { + return (object: TObject) => { if (object?.class && className) { return object.class.toLocaleLowerCase().localeCompare(className.toLocaleLowerCase()) === 0; } @@ -20,17 +20,13 @@ export const byClassCaseInsensitive = (className?: string) => { const copyPropsLowerCase = (properties: Map) => { const lowercase = new Map(); for (let [key, value] of properties) { - let normalizedValue = value; - if (typeof value === 'string') { - normalizedValue = value.toLocaleLowerCase(); - } - lowercase.set(key.toLocaleLowerCase(), normalizedValue); + lowercase.set(key.toLocaleLowerCase(), value); } return lowercase; } export const byPropertyCaseInsensitive = (propertyName: string, value?: any) => { - return }>(object: TObject) => { + return }>(object: TObject) => { const lowercase = copyPropsLowerCase(object.properties); if (value !== undefined) { @@ -39,9 +35,43 @@ export const byPropertyCaseInsensitive = (propertyName: string, value?: any) => normalizedValue = value.toLocaleLowerCase(); } + const maybeValue = lowercase.get(propertyName.toLocaleLowerCase()); + if (typeof maybeValue === 'string') { + return maybeValue.toLocaleLowerCase() === normalizedValue; + } + + return lowercase.get(propertyName.toLocaleLowerCase()) === normalizedValue; + } else { + return lowercase.has(propertyName.toLocaleLowerCase()); + } + } +} + +export const byProperty = (propertyName: string, value?: any, valueMatchInsensitve = true) => { + return }>(object: TObject) => { + const lowercase = copyPropsLowerCase(object.properties); + + if (value !== undefined) { + let normalizedValue = value; + if (typeof value === 'string') { + normalizedValue = valueMatchInsensitve ? value.toLocaleLowerCase() : value; + } + + const maybeValue = lowercase.get(propertyName.toLocaleLowerCase()); + if (typeof maybeValue === 'string') { + return (valueMatchInsensitve ? maybeValue.toLocaleLowerCase() : maybeValue) === normalizedValue; + } + return lowercase.get(propertyName.toLocaleLowerCase()) === normalizedValue; } else { return lowercase.has(propertyName.toLocaleLowerCase()); } } -} \ No newline at end of file +} + +export const byPropertyMatcher = (propertyName: string, matchValue: (val: any) => boolean) => { + return }>(object: TObject) => { + const lowercase = copyPropsLowerCase(object.properties); + return matchValue(lowercase.get(propertyName.toLocaleLowerCase())); + } +} From c3f0b4c69520cada842f9146446c477db0cc73c4 Mon Sep 17 00:00:00 2001 From: Erik Onarheim Date: Fri, 4 Apr 2025 08:45:44 -0500 Subject: [PATCH 2/5] add optional signature to enable sensitive value matches --- src/resource/iso-tile-layer.ts | 7 ++++--- src/resource/object-layer.ts | 7 ++++--- src/resource/tile-layer.ts | 7 ++++--- src/resource/tiled-resource.ts | 18 ++++++++++-------- src/resource/tileset.ts | 6 +++--- 5 files changed, 25 insertions(+), 20 deletions(-) diff --git a/src/resource/iso-tile-layer.ts b/src/resource/iso-tile-layer.ts index 9881021e..4d816a79 100644 --- a/src/resource/iso-tile-layer.ts +++ b/src/resource/iso-tile-layer.ts @@ -8,7 +8,7 @@ import { ExcaliburTiledProperties } from "./excalibur-properties"; import { TiledLayerDataComponent } from "./tiled-layer-component"; import { Layer } from "./layer"; import { Tile } from "./tileset"; -import { byClassCaseInsensitive, byPropertyCaseInsensitive } from "./filter-util"; +import { byClassCaseInsensitive, byProperty } from "./filter-util"; export interface IsometricTileInfo { /** @@ -96,12 +96,13 @@ export class IsoTileLayer implements Layer { * Returns the excalibur tiles that match a tiled property and optional value * @param name * @param value + * @param [valueMatchInsensitive=true] */ - getTilesByProperty(name: string, value?: any): IsometricTileInfo[] { + getTilesByProperty(name: string, value?: any, valueMatchInsensitive = true): IsometricTileInfo[] { const tiles = this.isometricMap.tiles.filter(t => { const maybeTiled = t.data.get(ExcaliburTiledProperties.TileData.Tiled) as Tile | undefined; if (maybeTiled) { - return byPropertyCaseInsensitive(name, value)(maybeTiled); + return byProperty(name, value, valueMatchInsensitive)(maybeTiled); } return false; }); diff --git a/src/resource/object-layer.ts b/src/resource/object-layer.ts index 275d000e..1bb873de 100644 --- a/src/resource/object-layer.ts +++ b/src/resource/object-layer.ts @@ -4,7 +4,7 @@ import { InsertedTile, PluginObject, TemplateObject, Text, Polygon, Rectangle, E import { TiledObjectLayer } from "../parser/tiled-parser"; import { FactoryProps, TiledResource } from "./tiled-resource"; import { mapProps } from "./properties"; -import { byClassCaseInsensitive, byNameCaseInsensitive, byPropertyCaseInsensitive } from "./filter-util"; +import { byClassCaseInsensitive, byNameCaseInsensitive, byProperty } from "./filter-util"; import { Tileset } from "./tileset"; import { ExcaliburTiledProperties } from "./excalibur-properties"; import { TiledDataComponent } from "./tiled-data-component"; @@ -55,11 +55,12 @@ export class ObjectLayer implements Layer { * Search for a tiled object that has a property name, and optionally specify a value * @param propertyName * @param value + * @param [valueMatchInsensitive=true] * @returns */ - getObjectsByProperty(propertyName: string, value?: any): PluginObject[] { + getObjectsByProperty(propertyName: string, value?: any, valueMatchInsensitive = true): PluginObject[] { if (!this._loaded) this._logLoadedWarning('getObjectsByProperty'); - return this.objects.filter(byPropertyCaseInsensitive(propertyName, value)); + return this.objects.filter(byProperty(propertyName, value, valueMatchInsensitive)); } /** * Search for actors that were created from tiled objects diff --git a/src/resource/tile-layer.ts b/src/resource/tile-layer.ts index 1c7d5d75..63b5f052 100644 --- a/src/resource/tile-layer.ts +++ b/src/resource/tile-layer.ts @@ -8,7 +8,7 @@ import { ExcaliburTiledProperties } from "./excalibur-properties"; import { TiledLayerDataComponent } from "./tiled-layer-component"; import { Layer } from "./layer"; import { Tile } from "./tileset"; -import { byClassCaseInsensitive, byPropertyCaseInsensitive } from "./filter-util"; +import { byClassCaseInsensitive, byProperty } from "./filter-util"; /** * Tile information for both excalibur and tiled tile representations @@ -93,12 +93,13 @@ export class TileLayer implements Layer { * Returns the excalibur tiles that match a tiled property and optional value * @param name * @param value + * @param [valueMatchInsensitive=true] */ - getTilesByProperty(name: string, value?: any): TileInfo[] { + getTilesByProperty(name: string, value?: any, valueMatchInsensitive = true): TileInfo[] { const tiles = this.tilemap.tiles.filter(t => { const maybeTiled = t.data.get(ExcaliburTiledProperties.TileData.Tiled) as Tile | undefined; if (maybeTiled) { - return byPropertyCaseInsensitive(name, value)(maybeTiled); + return byProperty(name, value, valueMatchInsensitive)(maybeTiled); } return false; }); diff --git a/src/resource/tiled-resource.ts b/src/resource/tiled-resource.ts index 2d16fae5..fca7ff10 100644 --- a/src/resource/tiled-resource.ts +++ b/src/resource/tiled-resource.ts @@ -12,7 +12,7 @@ import { compare } from "compare-versions"; import { getCanonicalGid } from "./gid-util"; import { PathMap, pathRelativeToBase } from "./path-util"; import { PluginObject } from "./objects"; -import { byClassCaseInsensitive, byNameCaseInsensitive, byPropertyCaseInsensitive } from "./filter-util"; +import { byClassCaseInsensitive, byNameCaseInsensitive, byProperty } from "./filter-util"; import { ExcaliburTiledProperties } from "./excalibur-properties"; import { FetchLoader, FileLoader } from './file-loader'; import { TilesetResource, TilesetResourceOptions } from "./tileset-resource"; @@ -322,11 +322,12 @@ export class TiledResource implements Loadable { /** * Queries for tilesets in the map by property and an optional value (case insensitive) * @param propertyName - * @param value + * @param value + * @param [valueMatchInsensitive=true] * @returns */ - getTilesetByProperty(propertyName: string, value?: any): Tileset[] { - return this.tilesets.filter(byPropertyCaseInsensitive(propertyName, value)); + getTilesetByProperty(propertyName: string, value?: any, valueMatchInsensitive = true): Tileset[] { + return this.tilesets.filter(byProperty(propertyName, value, valueMatchInsensitive)); } /** @@ -346,12 +347,13 @@ export class TiledResource implements Loadable { * Queries ALL tilesets tile data in the map for a specific property and an optional value (case insensitive) * @param name * @param value + * @param [valueMatchInsensitive=true] * @returns */ - getTileMetadataByProperty(name: string, value?: any): Tile[] { + getTileMetadataByProperty(name: string, value?: any, valueMatchInsensitive = true): Tile[] { let results: Tile[] = []; for (let tileset of this.tilesets) { - results = results.concat(tileset.tiles.filter(byPropertyCaseInsensitive(name, value))); + results = results.concat(tileset.tiles.filter(byProperty(name, value, valueMatchInsensitive))); } return results; } @@ -618,8 +620,8 @@ export class TiledResource implements Loadable { return this.layers.filter(byClassCaseInsensitive(className)); } - getLayersByProperty(propertyName: string, value?: any): Layer[] { - return this.layers.filter(byPropertyCaseInsensitive(propertyName, value)); + getLayersByProperty(propertyName: string, value?: any, valueMatchInsensitive = true): Layer[] { + return this.layers.filter(byProperty(propertyName, value, valueMatchInsensitive)); } private _parseMap(data: any) { diff --git a/src/resource/tileset.ts b/src/resource/tileset.ts index 318df3b4..536b1d8f 100644 --- a/src/resource/tileset.ts +++ b/src/resource/tileset.ts @@ -4,7 +4,7 @@ import { TiledTile, TiledTileset, isTiledTilesetCollectionOfImages, isTiledTiles import { Ellipse, Polygon, Rectangle, parseObjects } from "./objects"; import { Properties, mapProps } from "./properties"; import { PluginObject } from "./objects"; -import { byClassCaseInsensitive, byPropertyCaseInsensitive } from "./filter-util"; +import { byClassCaseInsensitive, byProperty } from "./filter-util"; export interface TileOptions { @@ -219,8 +219,8 @@ export class Tileset implements Properties { return this.tiles.filter(byClassCaseInsensitive(className)); } - getTilesByProperty(name: string, value?: any): Tile[] { - return this.tiles.filter(byPropertyCaseInsensitive(name, value)); + getTilesByProperty(name: string, value?: any, valueMatchInsensitive = true): Tile[] { + return this.tiles.filter(byProperty(name, value, valueMatchInsensitive)); } getSpriteForGid(gid: number): Sprite { From 1a555435170edaf5ba16d315277dcb5b65b0a871 Mon Sep 17 00:00:00 2001 From: Erik Onarheim Date: Fri, 4 Apr 2025 09:02:42 -0500 Subject: [PATCH 3/5] add requested method sig to add a matcher --- src/resource/filter-util.ts | 2 +- src/resource/iso-tile-layer.ts | 23 ++++++++++++++++++- src/resource/object-layer.ts | 24 +++++++++++++++++--- src/resource/tile-layer.ts | 22 ++++++++++++++++++- src/resource/tiled-resource.ts | 40 +++++++++++++++++++++++++++++++++- src/resource/tileset.ts | 17 ++++++++++++++- 6 files changed, 120 insertions(+), 8 deletions(-) diff --git a/src/resource/filter-util.ts b/src/resource/filter-util.ts index dd5daf71..65bdf2ee 100644 --- a/src/resource/filter-util.ts +++ b/src/resource/filter-util.ts @@ -69,7 +69,7 @@ export const byProperty = (propertyName: string, value?: any, valueMatchInsensit } } -export const byPropertyMatcher = (propertyName: string, matchValue: (val: any) => boolean) => { +export const byPropertyValueMatcher = (propertyName: string, matchValue: (val: any) => boolean) => { return }>(object: TObject) => { const lowercase = copyPropsLowerCase(object.properties); return matchValue(lowercase.get(propertyName.toLocaleLowerCase())); diff --git a/src/resource/iso-tile-layer.ts b/src/resource/iso-tile-layer.ts index 4d816a79..2ff611fa 100644 --- a/src/resource/iso-tile-layer.ts +++ b/src/resource/iso-tile-layer.ts @@ -8,7 +8,7 @@ import { ExcaliburTiledProperties } from "./excalibur-properties"; import { TiledLayerDataComponent } from "./tiled-layer-component"; import { Layer } from "./layer"; import { Tile } from "./tileset"; -import { byClassCaseInsensitive, byProperty } from "./filter-util"; +import { byClassCaseInsensitive, byProperty, byPropertyValueMatcher } from "./filter-util"; export interface IsometricTileInfo { /** @@ -113,6 +113,27 @@ export class IsoTileLayer implements Layer { })) } + /** + * Get the tiles that match the property name and the value matcher returns true + * @param name + * @param valueMatcher + */ + getTilesByPropertyValueMatcher(name: string, valueMatcher: (val: any) => boolean): IsometricTileInfo[] { + const tiles = this.isometricMap.tiles.filter(t => { + const maybeTiled = t.data.get(ExcaliburTiledProperties.TileData.Tiled) as Tile | undefined; + if (maybeTiled) { + return byPropertyValueMatcher(name, valueMatcher)(maybeTiled); + } + return false; + }); + + return tiles.map(t => ({ + exTile: t, + tiledTile: t.data.get(ExcaliburTiledProperties.TileData.Tiled) + })) + } + + getTileByPoint(worldPos: Vector): IsometricTileInfo | null { if (!this.isometricMap) { this.logger.warn('IsometricMap has not yet been loaded! getTileByPoint() will only return null'); diff --git a/src/resource/object-layer.ts b/src/resource/object-layer.ts index 1bb873de..bf637abc 100644 --- a/src/resource/object-layer.ts +++ b/src/resource/object-layer.ts @@ -4,7 +4,7 @@ import { InsertedTile, PluginObject, TemplateObject, Text, Polygon, Rectangle, E import { TiledObjectLayer } from "../parser/tiled-parser"; import { FactoryProps, TiledResource } from "./tiled-resource"; import { mapProps } from "./properties"; -import { byClassCaseInsensitive, byNameCaseInsensitive, byProperty } from "./filter-util"; +import { byClassCaseInsensitive, byNameCaseInsensitive, byProperty, byPropertyValueMatcher } from "./filter-util"; import { Tileset } from "./tileset"; import { ExcaliburTiledProperties } from "./excalibur-properties"; import { TiledDataComponent } from "./tiled-data-component"; @@ -62,15 +62,33 @@ export class ObjectLayer implements Layer { if (!this._loaded) this._logLoadedWarning('getObjectsByProperty'); return this.objects.filter(byProperty(propertyName, value, valueMatchInsensitive)); } + + /** + * Get the objects that match the property name and the value matcher returns true + * @param name + * @param valueMatcher + */ + getObjectsByPropertyValueMatcher(propertyName: string, valueMatcher: (val: any) => boolean): PluginObject[] { + if (!this._loaded) this._logLoadedWarning('getObjectsByPropertyValueMatcher'); + return this.objects.filter(byPropertyValueMatcher(propertyName, valueMatcher)); + } + + /** * Search for actors that were created from tiled objects * @returns */ - getEntitiesByProperty(propertyName: string, value?: any): Entity[] { + getEntitiesByProperty(propertyName: string, value?: any, valueMatchInsensitve = true): Entity[] { if (!this._loaded) this._logLoadedWarning('getEntitiesByProperty'); - return this.getObjectsByProperty(propertyName, value).map(o => this._objectToEntity.get(o)).filter(a => !!a) as Entity[]; + return this.getObjectsByProperty(propertyName, value, valueMatchInsensitve).map(o => this._objectToEntity.get(o)).filter(a => !!a) as Entity[]; + } + + getEntitiesByPropertyValueMatcher(propertyName: string, valueMatcher: (val: any) => boolean): Entity[] { + if (!this._loaded) this._logLoadedWarning('getEntitiesByPropertyValueMatcher'); + return this.getObjectsByProperty(propertyName, valueMatcher).map(o => this._objectToEntity.get(o)).filter(a => !!a) as Entity[]; } + /** * Search for an Tiled object by it's Tiled class name * @returns diff --git a/src/resource/tile-layer.ts b/src/resource/tile-layer.ts index 63b5f052..f79c6b3e 100644 --- a/src/resource/tile-layer.ts +++ b/src/resource/tile-layer.ts @@ -8,7 +8,7 @@ import { ExcaliburTiledProperties } from "./excalibur-properties"; import { TiledLayerDataComponent } from "./tiled-layer-component"; import { Layer } from "./layer"; import { Tile } from "./tileset"; -import { byClassCaseInsensitive, byProperty } from "./filter-util"; +import { byClassCaseInsensitive, byProperty, byPropertyValueMatcher } from "./filter-util"; /** * Tile information for both excalibur and tiled tile representations @@ -110,6 +110,26 @@ export class TileLayer implements Layer { })) } + /** + * Get the tiles that match the property name and the value matcher returns true + * @param name + * @param valueMatcher + */ + getTilesByPropertyValueMatcher(name: string, valueMatcher: (val: any) => any): TileInfo[] { + const tiles = this.tilemap.tiles.filter(t => { + const maybeTiled = t.data.get(ExcaliburTiledProperties.TileData.Tiled) as Tile | undefined; + if (maybeTiled) { + return byPropertyValueMatcher(name, valueMatcher)(maybeTiled); + } + return false; + }); + + return tiles.map(t => ({ + exTile: t, + tiledTile: t.data.get(ExcaliburTiledProperties.TileData.Tiled) + })) + } + getTileByPoint(worldPos: Vector): TileInfo | null { if (!this.tilemap) { this.logger.warn('Tilemap has not yet been loaded! getTileByPoint() will only return null'); diff --git a/src/resource/tiled-resource.ts b/src/resource/tiled-resource.ts index fca7ff10..350a24da 100644 --- a/src/resource/tiled-resource.ts +++ b/src/resource/tiled-resource.ts @@ -12,7 +12,7 @@ import { compare } from "compare-versions"; import { getCanonicalGid } from "./gid-util"; import { PathMap, pathRelativeToBase } from "./path-util"; import { PluginObject } from "./objects"; -import { byClassCaseInsensitive, byNameCaseInsensitive, byProperty } from "./filter-util"; +import { byClassCaseInsensitive, byNameCaseInsensitive, byProperty, byPropertyValueMatcher } from "./filter-util"; import { ExcaliburTiledProperties } from "./excalibur-properties"; import { FetchLoader, FileLoader } from './file-loader'; import { TilesetResource, TilesetResourceOptions } from "./tileset-resource"; @@ -330,6 +330,15 @@ export class TiledResource implements Loadable { return this.tilesets.filter(byProperty(propertyName, value, valueMatchInsensitive)); } + /** + * Get the tilesets that match the property name and the value matcher returns true + * @param name + * @param valueMatcher + */ + getTilesetByPropertyValueMatcher(propertyName: string, valueMatcher: (val: any) => boolean): Tileset[] { + return this.tilesets.filter(byPropertyValueMatcher(propertyName, valueMatcher)); + } + /** * Queries ALL tilesets tile data in the map for a specific class name (case insensitive) * @param className @@ -358,6 +367,19 @@ export class TiledResource implements Loadable { return results; } + /** + * Get the tile metadata that match the property name and the value matcher returns true + * @param name + * @param valueMatcher + */ + getTileMetadataByPropertyValueMatcher(name: string, valueMatcher: (val: any) => boolean): Tile[] { + let results: Tile[] = []; + for (let tileset of this.tilesets) { + results = results.concat(tileset.tiles.filter(byPropertyValueMatcher(name, valueMatcher))); + } + return results; + } + /** * Queries ALL tile layers tile instances in the map for a specific gid @@ -620,10 +642,26 @@ export class TiledResource implements Loadable { return this.layers.filter(byClassCaseInsensitive(className)); } + /** + * Get the layers that match the property name and the value + * @param name + * @param value + * @param [valueMatchInsensitive=true] + */ getLayersByProperty(propertyName: string, value?: any, valueMatchInsensitive = true): Layer[] { return this.layers.filter(byProperty(propertyName, value, valueMatchInsensitive)); } + /** + * Get the layers that match the property name and the value matcher returns true + * @param name + * @param valueMatcher + */ + getLayersByPropertyValueMatcher(propertyName: string, valueMatcher: (val: any) => boolean): Layer[] { + return this.layers.filter(byPropertyValueMatcher(propertyName, valueMatcher)); + } + + private _parseMap(data: any) { if (this.mapFormat === 'TMX') { return this.parser.parse(data, this.strict); diff --git a/src/resource/tileset.ts b/src/resource/tileset.ts index 536b1d8f..baee6046 100644 --- a/src/resource/tileset.ts +++ b/src/resource/tileset.ts @@ -4,7 +4,7 @@ import { TiledTile, TiledTileset, isTiledTilesetCollectionOfImages, isTiledTiles import { Ellipse, Polygon, Rectangle, parseObjects } from "./objects"; import { Properties, mapProps } from "./properties"; import { PluginObject } from "./objects"; -import { byClassCaseInsensitive, byProperty } from "./filter-util"; +import { byClassCaseInsensitive, byProperty, byPropertyValueMatcher } from "./filter-util"; export interface TileOptions { @@ -219,10 +219,25 @@ export class Tileset implements Properties { return this.tiles.filter(byClassCaseInsensitive(className)); } + /** + * Get the tiles that match the property name and the value + * @param name + * @param value + * @param [valueMatchInsensitive=true] + */ getTilesByProperty(name: string, value?: any, valueMatchInsensitive = true): Tile[] { return this.tiles.filter(byProperty(name, value, valueMatchInsensitive)); } + /** + * Get the tiles that match the property name and the value matcher returns true + * @param name + * @param valueMatcher + */ + getTilesByPropertyValueMatcher(name: string, valueMatcher: (val: any) => boolean): Tile[] { + return this.tiles.filter(byPropertyValueMatcher(name, valueMatcher)); + } + getSpriteForGid(gid: number): Sprite { const h = isFlippedHorizontally(gid); const v = isFlippedVertically(gid); From 9db021849f14f0df74a943afdf3b17fb0c8eac77 Mon Sep 17 00:00:00 2001 From: Erik Onarheim Date: Fri, 4 Apr 2025 09:03:46 -0500 Subject: [PATCH 4/5] delete removed code --- src/resource/filter-util.ts | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/src/resource/filter-util.ts b/src/resource/filter-util.ts index 65bdf2ee..8b3f077f 100644 --- a/src/resource/filter-util.ts +++ b/src/resource/filter-util.ts @@ -25,28 +25,6 @@ const copyPropsLowerCase = (properties: Map) return lowercase; } -export const byPropertyCaseInsensitive = (propertyName: string, value?: any) => { - return }>(object: TObject) => { - const lowercase = copyPropsLowerCase(object.properties); - - if (value !== undefined) { - let normalizedValue = value; - if (typeof value === 'string') { - normalizedValue = value.toLocaleLowerCase(); - } - - const maybeValue = lowercase.get(propertyName.toLocaleLowerCase()); - if (typeof maybeValue === 'string') { - return maybeValue.toLocaleLowerCase() === normalizedValue; - } - - return lowercase.get(propertyName.toLocaleLowerCase()) === normalizedValue; - } else { - return lowercase.has(propertyName.toLocaleLowerCase()); - } - } -} - export const byProperty = (propertyName: string, value?: any, valueMatchInsensitve = true) => { return }>(object: TObject) => { const lowercase = copyPropsLowerCase(object.properties); From b0d66d48cb22b1fb486b9000ff7d92ab07912b96 Mon Sep 17 00:00:00 2001 From: Erik Onarheim Date: Fri, 29 Aug 2025 14:26:28 -0500 Subject: [PATCH 5/5] fix build --- src/resource/tiled-resource.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/resource/tiled-resource.ts b/src/resource/tiled-resource.ts index 11cffee5..f3a316a5 100644 --- a/src/resource/tiled-resource.ts +++ b/src/resource/tiled-resource.ts @@ -12,7 +12,7 @@ import { compare } from "compare-versions"; import { getCanonicalGid } from "./gid-util"; import { PathMap, pathRelativeToBase } from "./path-util"; import { PluginObject } from "./objects"; -import { byClassCaseInsensitive, byNameCaseInsensitive, byProperty, byPropertyValueMatcher } from "./filter-util"; +import { byClassCaseInsensitive, byNameCaseInsensitive, byProperty } from "./filter-util"; import { ExcaliburTiledProperties } from "./excalibur-properties"; import { FetchLoader, FileLoader } from './file-loader'; import { TilesetResource, TilesetResourceOptions } from "./tileset-resource"; @@ -326,7 +326,7 @@ export class TiledResource implements Loadable { * @returns */ getTilesetByProperty(propertyName: string, value?: any): Tileset[] { - return this.tilesets.filter(byPropertyCaseInsensitive(propertyName, value)); + return this.tilesets.filter(byProperty(propertyName, value)); } /** @@ -351,7 +351,7 @@ export class TiledResource implements Loadable { getTileMetadataByProperty(name: string, value?: any): Tile[] { let results: Tile[] = []; for (let tileset of this.tilesets) { - results = results.concat(tileset.tiles.filter(byPropertyCaseInsensitive(name, value))); + results = results.concat(tileset.tiles.filter(byProperty(name, value))); } return results; } @@ -653,7 +653,7 @@ export class TiledResource implements Loadable { } getLayersByProperty(propertyName: string, value?: any): Layer[] { - return this.layers.filter(byPropertyCaseInsensitive(propertyName, value)); + return this.layers.filter(byProperty(propertyName, value)); } private _parseMap(data: any) {