From 35cbaa7c3334a704729cbba3c27fda9c77196eff Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Sat, 11 Jan 2025 02:39:08 +0100 Subject: [PATCH] Chore: small cleanups, formatting --- src/Customizations/AllKnownLayouts.ts | 1 - src/Logic/State/UserSettingsMetaTagging.ts | 48 ++++--------------- .../ThemeConfig/Conversion/Conversion.ts | 4 +- .../ThemeConfig/Conversion/PrepareLayer.ts | 7 +++ .../ThemeConfig/Conversion/PrepareTheme.ts | 2 +- src/UI/Popup/AutoApplyButton.ts | 3 ++ src/assets/bing.json | 2 +- 7 files changed, 24 insertions(+), 43 deletions(-) diff --git a/src/Customizations/AllKnownLayouts.ts b/src/Customizations/AllKnownLayouts.ts index 9d71643f0..01dea27f7 100644 --- a/src/Customizations/AllKnownLayouts.ts +++ b/src/Customizations/AllKnownLayouts.ts @@ -28,7 +28,6 @@ export class AllKnownLayoutsLazy { } const defaultLayer = AllSharedLayers.getSharedLayersConfigs().get(layerId) if (defaultLayer === undefined) { - console.error("Could not find builtin layer", layerId) continue } themeConfigJson.layers.push(defaultLayer) diff --git a/src/Logic/State/UserSettingsMetaTagging.ts b/src/Logic/State/UserSettingsMetaTagging.ts index 6e568c5c3..33a5ae85b 100644 --- a/src/Logic/State/UserSettingsMetaTagging.ts +++ b/src/Logic/State/UserSettingsMetaTagging.ts @@ -1,42 +1,14 @@ import { Utils } from "../../Utils" /** This code is autogenerated - do not edit. Edit ./assets/layers/usersettings/usersettings.json instead */ export class ThemeMetaTagging { - public static readonly themeName = "usersettings" + public static readonly themeName = "usersettings" - public metaTaggging_for_usersettings(feat: { properties: Record }) { - Utils.AddLazyProperty(feat.properties, "_mastodon_candidate_md", () => - feat.properties._description - .match(/\[[^\]]*\]\((.*(mastodon|en.osm.town).*)\).*/) - ?.at(1) - ) - Utils.AddLazyProperty( - feat.properties, - "_d", - () => feat.properties._description?.replace(/</g, "<")?.replace(/>/g, ">") ?? "" - ) - Utils.AddLazyProperty(feat.properties, "_mastodon_candidate_a", () => - ((feat) => { - const e = document.createElement("div") - e.innerHTML = feat.properties._d - return Array.from(e.getElementsByTagName("a")).filter( - (a) => a.href.match(/mastodon|en.osm.town/) !== null - )[0]?.href - })(feat) - ) - Utils.AddLazyProperty(feat.properties, "_mastodon_link", () => - ((feat) => { - const e = document.createElement("div") - e.innerHTML = feat.properties._d - return Array.from(e.getElementsByTagName("a")).filter( - (a) => a.getAttribute("rel")?.indexOf("me") >= 0 - )[0]?.href - })(feat) - ) - Utils.AddLazyProperty( - feat.properties, - "_mastodon_candidate", - () => feat.properties._mastodon_candidate_md ?? feat.properties._mastodon_candidate_a - ) - feat.properties["__current_backgroun"] = "initial_value" - } -} + public metaTaggging_for_usersettings(feat: {properties: Record}) { + Utils.AddLazyProperty(feat.properties, '_mastodon_candidate_md', () => feat.properties._description.match(/\[[^\]]*\]\((.*(mastodon|en.osm.town).*)\).*/)?.at(1) ) + Utils.AddLazyProperty(feat.properties, '_d', () => feat.properties._description?.replace(/</g,'<')?.replace(/>/g,'>') ?? '' ) + Utils.AddLazyProperty(feat.properties, '_mastodon_candidate_a', () => (feat => {const e = document.createElement('div');e.innerHTML = feat.properties._d;return Array.from(e.getElementsByTagName("a")).filter(a => a.href.match(/mastodon|en.osm.town/) !== null)[0]?.href }) (feat) ) + Utils.AddLazyProperty(feat.properties, '_mastodon_link', () => (feat => {const e = document.createElement('div');e.innerHTML = feat.properties._d;return Array.from(e.getElementsByTagName("a")).filter(a => a.getAttribute("rel")?.indexOf('me') >= 0)[0]?.href})(feat) ) + Utils.AddLazyProperty(feat.properties, '_mastodon_candidate', () => feat.properties._mastodon_candidate_md ?? feat.properties._mastodon_candidate_a ) + feat.properties['__current_backgroun'] = 'initial_value' + } +} \ No newline at end of file diff --git a/src/Models/ThemeConfig/Conversion/Conversion.ts b/src/Models/ThemeConfig/Conversion/Conversion.ts index d19519de1..cfd6a3a50 100644 --- a/src/Models/ThemeConfig/Conversion/Conversion.ts +++ b/src/Models/ThemeConfig/Conversion/Conversion.ts @@ -32,7 +32,7 @@ export abstract class Conversion { this.name = name } - public convertStrict(json: TIn, context?: ConversionContext): TOut { + public convertStrict(json: NonNullable, context?: ConversionContext): TOut { context ??= ConversionContext.construct([], []) context = context.inOperation(this.name) @@ -276,7 +276,7 @@ export class Fuse extends DesugaringStep { "This fused pipeline of the following steps: " + steps.map((s) => s.name).join(", "), Utils.Dedup([].concat(...steps.map((step) => step.modifiedAttributes))), - "Fuse(" + steps.map((s) => s.name).join(", ") + ")" + "Fuse" ) this.steps = Utils.NoNull(steps) } diff --git a/src/Models/ThemeConfig/Conversion/PrepareLayer.ts b/src/Models/ThemeConfig/Conversion/PrepareLayer.ts index 8fe4f327c..513ba803c 100644 --- a/src/Models/ThemeConfig/Conversion/PrepareLayer.ts +++ b/src/Models/ThemeConfig/Conversion/PrepareLayer.ts @@ -1000,4 +1000,11 @@ export class PrepareLayer extends Fuse { new PruneFilters() ) } + + convert(json: LayerConfigJson, context: ConversionContext): LayerConfigJson { + if(json === undefined || json === null){ + throw "Error: prepareLayer got null" + } + return super.convert(json, context) + } } diff --git a/src/Models/ThemeConfig/Conversion/PrepareTheme.ts b/src/Models/ThemeConfig/Conversion/PrepareTheme.ts index f1081cbd6..7428e321b 100644 --- a/src/Models/ThemeConfig/Conversion/PrepareTheme.ts +++ b/src/Models/ThemeConfig/Conversion/PrepareTheme.ts @@ -472,7 +472,7 @@ class PreparePersonalTheme extends DesugaringStep { class WarnForUnsubstitutedLayersInTheme extends DesugaringStep { constructor() { super( - "Generates a warning if a theme uses an unsubstituted layer", + "Generates a warning if a theme uses an inline layer; we recommend splitting of all layers in separate files", ["layers"], "WarnForUnsubstitutedLayersInTheme" ) diff --git a/src/UI/Popup/AutoApplyButton.ts b/src/UI/Popup/AutoApplyButton.ts index 204475f24..9137faa0c 100644 --- a/src/UI/Popup/AutoApplyButton.ts +++ b/src/UI/Popup/AutoApplyButton.ts @@ -41,6 +41,9 @@ export interface AutoAction extends SpecialVisualization { ): Promise } +/** + * @deprecated + */ class ApplyButton extends UIElement { private readonly icon: string private readonly text: string diff --git a/src/assets/bing.json b/src/assets/bing.json index fe2d35230..6c948ca5f 100644 --- a/src/assets/bing.json +++ b/src/assets/bing.json @@ -1 +1 @@ -{"properties":{"name":"Bing Maps Aerial","id":"Bing","url":"https://ecn.t0.tiles.virtualearth.net/tiles/a{quadkey}.jpeg?g=14875&pr=odbl&n=f","type":"bing","category":"photo","min_zoom":1,"max_zoom":22},"type":"Feature","geometry":null} \ No newline at end of file +{"properties":{"name":"Bing Maps Aerial","id":"Bing","url":"https://ecn.t2.tiles.virtualearth.net/tiles/a{quadkey}.jpeg?g=14880&pr=odbl&n=f","type":"bing","category":"photo","min_zoom":1,"max_zoom":22},"type":"Feature","geometry":null} \ No newline at end of file