Add check for sync-selection mode, fix personal theme by revoking it's special status from 'determine theme', fix #871

This commit is contained in:
Pieter Vander Vennet 2022-06-13 03:13:42 +02:00
parent 3b01e62fbe
commit 7c6e292013
9 changed files with 59 additions and 27 deletions

View file

@ -13,8 +13,6 @@ import PointRenderingConfigJson from "../Models/ThemeConfig/Json/PointRenderingC
import {PrepareLayer} from "../Models/ThemeConfig/Conversion/PrepareLayer";
import {PrepareTheme} from "../Models/ThemeConfig/Conversion/PrepareTheme";
import {DesugaringContext} from "../Models/ThemeConfig/Conversion/Conversion";
import LayerConfig from "../Models/ThemeConfig/LayerConfig";
import LayerConfigJsonJSC from "../Docs/Schemas/LayerConfigJsonJSC";
import {Utils} from "../Utils";
// This scripts scans 'assets/layers/*.json' for layer definition files and 'assets/themes/*.json' for theme definition files.
@ -190,7 +188,8 @@ class LayerOverviewUtils {
const sharedLayers = new Map<string, LayerConfigJson>()
const state: DesugaringContext = {
tagRenderings: sharedTagRenderings,
sharedLayers
sharedLayers,
publicLayers: new Set()
}
const prepLayer = new PrepareLayer(state);
for (const sharedLayerJson of layerFiles) {
@ -210,15 +209,43 @@ class LayerOverviewUtils {
}
return sharedLayers;
}
private static publicLayerIdsFrom(themefiles: LayoutConfigJson[]): Set<string>{
const publicLayers = [].concat(...themefiles
.filter(th => !th.hideFromOverview)
.map(th => th.layers))
const publicLayerIds = new Set<string>()
for (const publicLayer of publicLayers) {
if(typeof publicLayer === "string"){
publicLayerIds.add(publicLayer)
continue
}
if(publicLayer["builtin"] !== undefined){
const bi = publicLayer["builtin"]
if(typeof bi === "string"){
publicLayerIds.add(bi)
continue
}
bi.forEach(id=>publicLayerIds.add(id))
continue
}
publicLayerIds.add(publicLayer.id)
}
return publicLayerIds
}
private buildThemeIndex(knownImagePaths: Set<string>, sharedLayers: Map<string, LayerConfigJson>): Map<string, LayoutConfigJson> {
console.log(" ---------- VALIDATING BUILTIN THEMES ---------")
const themeFiles = ScriptUtils.getThemeFiles();
const fixed = new Map<string, LayoutConfigJson>();
const publicLayers = LayerOverviewUtils.publicLayerIdsFrom(themeFiles.map(th => th.parsed))
const convertState: DesugaringContext = {
sharedLayers,
tagRenderings: this.getSharedTagRenderings()
tagRenderings: this.getSharedTagRenderings(),
publicLayers
}
for (const themeInfo of themeFiles) {
let themeFile = themeInfo.parsed