Attempt to fix build
This commit is contained in:
parent
259d4d7fdf
commit
42a87d2611
5 changed files with 592 additions and 110 deletions
|
@ -13,6 +13,7 @@ import { TagConfigJson } from "../src/Models/ThemeConfig/Json/TagConfigJson"
|
|||
import { TagUtils } from "../src/Logic/Tags/TagUtils"
|
||||
import { TagRenderingConfigJson } from "../src/Models/ThemeConfig/Json/TagRenderingConfigJson"
|
||||
import { Translatable } from "../src/Models/ThemeConfig/Json/Translatable"
|
||||
import Icon from "../src/UI/Map/Icon.svelte"
|
||||
|
||||
export class GenerateFavouritesLayer extends Script {
|
||||
private readonly layers: LayerConfigJson[] = []
|
||||
|
@ -164,6 +165,27 @@ export class GenerateFavouritesLayer extends Script {
|
|||
}
|
||||
|
||||
private addTitleIcons(proto: LayerConfigJson) {
|
||||
let iconsLibrary: Map<string, TagRenderingConfigJson[]> = new Map<
|
||||
string,
|
||||
TagRenderingConfigJson[]
|
||||
>()
|
||||
const path = "./src/assets/generated/layers/icons.json"
|
||||
if (existsSync(path)) {
|
||||
const config = <LayerConfigJson>JSON.parse(readFileSync(path, "utf8"))
|
||||
for (const tagRendering of config.tagRenderings) {
|
||||
const qtr = <QuestionableTagRenderingConfigJson>tagRendering
|
||||
const id = qtr.id
|
||||
if (id) {
|
||||
iconsLibrary.set(id, [qtr])
|
||||
}
|
||||
for (const label of tagRendering["labels"] ?? []) {
|
||||
if (!iconsLibrary.has(label)) {
|
||||
iconsLibrary.set(label, [])
|
||||
}
|
||||
iconsLibrary.get(label).push(qtr)
|
||||
}
|
||||
}
|
||||
}
|
||||
proto.titleIcons = []
|
||||
const seenTitleIcons = new Set<string>()
|
||||
for (const layer of this.layers) {
|
||||
|
@ -176,7 +198,7 @@ export class GenerateFavouritesLayer extends Script {
|
|||
}
|
||||
if (titleIcon.id === "rating") {
|
||||
if (!seenTitleIcons.has("rating")) {
|
||||
proto.titleIcons.unshift("icons.rating")
|
||||
proto.titleIcons.unshift(...iconsLibrary.get("rating"))
|
||||
seenTitleIcons.add("rating")
|
||||
}
|
||||
continue
|
||||
|
@ -189,7 +211,7 @@ export class GenerateFavouritesLayer extends Script {
|
|||
proto.titleIcons.push(titleIcon)
|
||||
}
|
||||
}
|
||||
proto.titleIcons.push("icons.defaults")
|
||||
proto.titleIcons.push(...(iconsLibrary.get("defaults") ?? []))
|
||||
}
|
||||
|
||||
private addTitle(proto: LayerConfigJson) {
|
||||
|
|
|
@ -722,7 +722,9 @@ class LayerOverviewUtils extends Script {
|
|||
ConversionContext.construct([themePath], ["PrepareLayer"])
|
||||
)
|
||||
try {
|
||||
themeFile = new PrepareTheme(convertState).convertStrict(
|
||||
themeFile = new PrepareTheme(convertState, {
|
||||
skipDefaultLayers: true,
|
||||
}).convertStrict(
|
||||
themeFile,
|
||||
ConversionContext.construct([themePath], ["PrepareLayer"])
|
||||
)
|
||||
|
|
|
@ -19,7 +19,7 @@ import ValidationUtils from "../src/Models/ThemeConfig/Conversion/ValidationUtil
|
|||
|
||||
const sharp = require("sharp")
|
||||
const template = readFileSync("theme.html", "utf8")
|
||||
const codeTemplate = readFileSync("src/index_theme.ts.template", "utf8")
|
||||
let codeTemplate = readFileSync("src/index_theme.ts.template", "utf8")
|
||||
|
||||
function enc(str: string): string {
|
||||
return encodeURIComponent(str.toLowerCase())
|
||||
|
@ -487,8 +487,19 @@ async function createIndexFor(theme: LayoutConfig) {
|
|||
`import layout from "./src/assets/generated/themes/${theme.id}.json"`,
|
||||
`import { ThemeMetaTagging } from "./src/assets/generated/metatagging/${theme.id}"`,
|
||||
]
|
||||
for (const layerName of Constants.added_by_default) {
|
||||
imports.push(`import ${layerName} from "./src/assets/generated/layers/${layerName}.json"`)
|
||||
}
|
||||
writeFileSync(filename, imports.join("\n") + "\n")
|
||||
|
||||
const addLayers = []
|
||||
|
||||
for (const layerName of Constants.added_by_default) {
|
||||
addLayers.push(` layout.layers.push(<any> ${layerName})`)
|
||||
}
|
||||
|
||||
codeTemplate = codeTemplate.replace(" // LAYOUT.ADD_LAYERS", addLayers.join("\n"))
|
||||
|
||||
appendFileSync(filename, codeTemplate)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue