aframe-babia-components 1.3.3 → 1.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2008,22 +2008,30 @@ let generateLegend = (data, {
2008
2008
  const vcolor = safe(data?.[fcolor]);
2009
2009
 
2010
2010
  // Texto final
2011
- const finalText = isQuarter
2012
- ? name
2013
- : template
2014
- .replaceAll('{name}', name)
2015
- // nombres de los campos
2016
- .replaceAll('{fheight}', fheight)
2017
- .replaceAll('{farea}', farea)
2018
- .replaceAll('{fwidth}', fwidth)
2019
- .replaceAll('{fdepth}', fdepth)
2020
- .replaceAll('{fcolor}', fcolor)
2021
- // valores
2022
- .replaceAll('{height}', vheight)
2023
- .replaceAll('{area}', varea)
2024
- .replaceAll('{width}', vwidth)
2025
- .replaceAll('{depth}', vdepth)
2026
- .replaceAll('{color}', vcolor);
2011
+ let processedTemplate = isQuarter ? '{name}' : template;
2012
+
2013
+ processedTemplate = processedTemplate
2014
+ .replaceAll('{name}', name)
2015
+ .replaceAll('{height}', vheight)
2016
+ .replaceAll('{area}', varea)
2017
+ .replaceAll('{width}', vwidth)
2018
+ .replaceAll('{depth}', vdepth)
2019
+ .replaceAll('{color}', vcolor)
2020
+ .replaceAll('{fheight}', fheight)
2021
+ .replaceAll('{farea}', farea)
2022
+ .replaceAll('{fwidth}', fwidth)
2023
+ .replaceAll('{fdepth}', fdepth)
2024
+ .replaceAll('{fcolor}', fcolor);
2025
+
2026
+ const knownPlaceholders = new Set([
2027
+ 'name', 'height', 'area', 'width', 'depth', 'color',
2028
+ 'fheight', 'farea', 'fwidth', 'fdepth', 'fcolor'
2029
+ ]);
2030
+
2031
+ const finalText = processedTemplate.replace(/\{(\w+)\}/g, (match, variable) => {
2032
+ if (knownPlaceholders.has(variable)) return match; // ya procesado
2033
+ return safe(data?.[variable], match); // si existe en rawData, lo usamos
2034
+ });
2027
2035
 
2028
2036
  const lines = finalText.split('\n');
2029
2037
  const width = Math.max(...lines.map(line => line.length)) / 5;