From a2c1c7d97dd6f7e1de3c66a6f2b2f86c008b8712 Mon Sep 17 00:00:00 2001 From: dbauszus-glx Date: Mon, 4 Mar 2024 14:02:27 +0000 Subject: [PATCH] warnings method --- lib/layer/styleParser.mjs | 44 ++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/lib/layer/styleParser.mjs b/lib/layer/styleParser.mjs index a22dddfed..cd83fdd4b 100644 --- a/lib/layer/styleParser.mjs +++ b/lib/layer/styleParser.mjs @@ -10,6 +10,8 @@ export default layer => { } } + warnings(layer) + if (layer.style?.theme) { parseTheme(layer.style.theme) } @@ -22,18 +24,6 @@ export default layer => { }) } - // Handle deprecated layer.style.hover and layer.style.hovers. - if (layer.style?.hovers && layer.style?.hover) { - console.warn(`Layer: ${layer.key}, cannot use both layer.style.hover and layer.style.hovers. Layer.style.hover has been deleted.`); - delete layer.style.hover; - } - - // Handle deprecated layer.style.label and layer.style.labels. - if (layer.style?.labels && layer.style?.label) { - console.warn(`Layer: ${layer.key}, cannot use both layer.style.label and layer.style.labels. Layer.style.label has been deleted.`); - delete layer.style.label; - } - // Handle multiple themes in layer style. if (layer.style?.themes) { Object.keys(layer.style.themes).forEach(key => { @@ -50,13 +40,6 @@ export default layer => { layer.style.label = layer.style.labels[layer.style.theme.setLabel]; } - // Handle deprecated layer.hover configuration. - if (layer.hover) { - console.warn(`Layer: ${layer.key}, layer.hover{} should be defined within layer.style{}.`); - layer.style.hover = layer.hover; - delete layer.hover; - } - // Handle setHover and hovers in layer style. if (layer.style?.theme?.setHover && layer.style?.hovers) { layer.style.hover = layer.style.hovers[layer.style.theme.setHover]; @@ -77,6 +60,29 @@ export default layer => { layer.style.label = typeof layer.style.label === 'object' ? layer.style.label : layer.style.labels[layer.style.label || Object.keys(layer.style.labels)[0]]; } + function warnings(layer) { + + // Handle deprecated layer.hover configuration. + if (layer.hover) { + console.warn(`Layer: ${layer.key}, layer.hover{} should be defined within layer.style{}.`); + layer.style.hover = layer.hover; + delete layer.hover; + } + + // Handle deprecated layer.style.hover and layer.style.hovers. + if (layer.style?.hovers && layer.style?.hover) { + console.warn(`Layer: ${layer.key}, cannot use both layer.style.hover and layer.style.hovers. Layer.style.hover has been deleted.`); + delete layer.style.hover; + } + + // Handle deprecated layer.style.label and layer.style.labels. + if (layer.style?.labels && layer.style?.label) { + console.warn(`Layer: ${layer.key}, cannot use both layer.style.label and layer.style.labels. Layer.style.label has been deleted.`); + delete layer.style.label; + } + + } + function parseTheme(theme) { if (theme?.cat) {