@perses-dev/gauge-chart-plugin 0.13.0 → 0.14.0-beta.1

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.
Files changed (122) hide show
  1. package/__mf/js/{main.c44733a6.js → GaugeChart.666448e5.js} +4 -4
  2. package/__mf/js/async/121.a37557d3.js +2 -0
  3. package/__mf/js/async/192.1bece79a.js +1 -0
  4. package/__mf/js/async/2.e1c5abe4.js +1 -0
  5. package/__mf/js/async/208.a09e3946.js +83 -0
  6. package/__mf/js/async/235.25414f3a.js +1 -0
  7. package/__mf/js/async/244.f21ad375.js +7 -0
  8. package/__mf/js/async/{700.e028a93e.js.LICENSE.txt → 244.f21ad375.js.LICENSE.txt} +41 -1
  9. package/__mf/js/async/354.c398a3bf.js +4 -0
  10. package/__mf/js/async/354.c398a3bf.js.LICENSE.txt +9 -0
  11. package/__mf/js/async/356.d85a4e2e.js +1 -0
  12. package/__mf/js/async/373.0403e3b1.js +38 -0
  13. package/__mf/js/async/392.605cca25.js +2 -0
  14. package/__mf/js/async/458.501ed0da.js +1 -0
  15. package/__mf/js/async/470.a2c22a78.js +2 -0
  16. package/__mf/js/async/587.6f130e41.js +1 -0
  17. package/__mf/js/async/616.cecf44f8.js +1 -0
  18. package/__mf/js/async/663.97d3fd12.js +1 -0
  19. package/__mf/js/async/710.23542577.js +29 -0
  20. package/__mf/js/async/77.c33fcfb5.js +1 -0
  21. package/__mf/js/async/893.a44ef766.js +2 -0
  22. package/__mf/js/async/941.e909e334.js +2 -0
  23. package/__mf/js/async/963.caed232d.js +1 -0
  24. package/__mf/js/async/968.7d1ce389.js +1 -0
  25. package/__mf/js/async/__federation_expose_GaugeChart.1812e964.js +1 -0
  26. package/__mf/js/async/lib-router.005da842.js +2 -0
  27. package/__mf/js/main.9a8ce910.js +7 -0
  28. package/lib/GaugeChart.d.ts +3 -3
  29. package/lib/GaugeChart.d.ts.map +1 -1
  30. package/lib/GaugeChart.js +3 -3
  31. package/lib/GaugeChart.js.map +1 -1
  32. package/lib/GaugeChartBase.d.ts +3 -3
  33. package/lib/GaugeChartBase.d.ts.map +1 -1
  34. package/lib/GaugeChartBase.js +7 -7
  35. package/lib/GaugeChartBase.js.map +1 -1
  36. package/lib/GaugeChartOptionsEditorSettings.d.ts +2 -2
  37. package/lib/GaugeChartOptionsEditorSettings.d.ts.map +1 -1
  38. package/lib/GaugeChartOptionsEditorSettings.js +7 -7
  39. package/lib/GaugeChartOptionsEditorSettings.js.map +1 -1
  40. package/lib/GaugeChartPanel.d.ts +4 -4
  41. package/lib/GaugeChartPanel.d.ts.map +1 -1
  42. package/lib/GaugeChartPanel.js +8 -8
  43. package/lib/GaugeChartPanel.js.map +1 -1
  44. package/lib/bootstrap.js +2 -2
  45. package/lib/gauge-chart-model.d.ts +3 -3
  46. package/lib/gauge-chart-model.d.ts.map +1 -1
  47. package/lib/gauge-chart-model.js.map +1 -1
  48. package/lib/getPluginModule.d.ts +1 -1
  49. package/lib/getPluginModule.d.ts.map +1 -1
  50. package/lib/getPluginModule.js +3 -1
  51. package/lib/getPluginModule.js.map +1 -1
  52. package/lib/index-federation.js +1 -1
  53. package/lib/index.js +6 -6
  54. package/lib/index.js.map +1 -1
  55. package/lib/setup-tests.d.ts +1 -1
  56. package/lib/setup-tests.d.ts.map +1 -1
  57. package/lib/setup-tests.js +2 -2
  58. package/lib/setup-tests.js.map +1 -1
  59. package/lib/thresholds.d.ts +1 -1
  60. package/lib/thresholds.d.ts.map +1 -1
  61. package/lib/thresholds.js +1 -1
  62. package/lib/thresholds.js.map +1 -1
  63. package/mf-manifest.json +31 -97
  64. package/mf-stats.json +31 -109
  65. package/package.json +10 -10
  66. package/__mf/js/GaugeChart.7e331b64.js +0 -7
  67. package/__mf/js/async/121.4c5f5798.js +0 -2
  68. package/__mf/js/async/172.afec864d.js +0 -110
  69. package/__mf/js/async/177.2e554778.js +0 -1
  70. package/__mf/js/async/187.ba6fd686.js +0 -7
  71. package/__mf/js/async/187.ba6fd686.js.LICENSE.txt +0 -39
  72. package/__mf/js/async/192.fb5cd927.js +0 -1
  73. package/__mf/js/async/235.b918db36.js +0 -1
  74. package/__mf/js/async/274.9badab92.js +0 -2
  75. package/__mf/js/async/356.c7cf4f79.js +0 -1
  76. package/__mf/js/async/377.06309086.js +0 -1
  77. package/__mf/js/async/392.4807325b.js +0 -2
  78. package/__mf/js/async/403.9db35877.js +0 -2
  79. package/__mf/js/async/410.4043d582.js +0 -1
  80. package/__mf/js/async/458.0f5bc9ee.js +0 -1
  81. package/__mf/js/async/470.9e955be3.js +0 -2
  82. package/__mf/js/async/496.dc9e951b.js +0 -1
  83. package/__mf/js/async/546.7850a553.js +0 -24
  84. package/__mf/js/async/546.7850a553.js.LICENSE.txt +0 -19
  85. package/__mf/js/async/558.9e9f2911.js +0 -1
  86. package/__mf/js/async/587.2649e50b.js +0 -1
  87. package/__mf/js/async/588.f25e2591.js +0 -1
  88. package/__mf/js/async/616.0741833f.js +0 -1
  89. package/__mf/js/async/700.e028a93e.js +0 -30
  90. package/__mf/js/async/71.57cf30f3.js +0 -1
  91. package/__mf/js/async/756.cbb57779.js +0 -1
  92. package/__mf/js/async/77.629e7e49.js +0 -1
  93. package/__mf/js/async/823.488b0ae9.js +0 -10
  94. package/__mf/js/async/854.d052322d.js +0 -1
  95. package/__mf/js/async/873.650a20f9.js +0 -1
  96. package/__mf/js/async/941.c6518e38.js +0 -2
  97. package/__mf/js/async/963.ab063f73.js +0 -1
  98. package/__mf/js/async/968.5b4a4f18.js +0 -1
  99. package/__mf/js/async/978.8aa2a024.js +0 -1
  100. package/__mf/js/async/__federation_expose_GaugeChart.b9c57db4.js +0 -1
  101. package/__mf/js/async/lib-router.f8568e8a.js +0 -2
  102. package/lib/cjs/GaugeChart.js +0 -39
  103. package/lib/cjs/GaugeChartBase.js +0 -196
  104. package/lib/cjs/GaugeChartOptionsEditorSettings.js +0 -120
  105. package/lib/cjs/GaugeChartPanel.js +0 -195
  106. package/lib/cjs/bootstrap.js +0 -26
  107. package/lib/cjs/env.d.js +0 -14
  108. package/lib/cjs/gauge-chart-model.js +0 -57
  109. package/lib/cjs/getPluginModule.js +0 -39
  110. package/lib/cjs/index-federation.js +0 -55
  111. package/lib/cjs/index.js +0 -41
  112. package/lib/cjs/setup-tests.js +0 -19
  113. package/lib/cjs/thresholds.js +0 -77
  114. /package/__mf/css/async/{187.85c2cbf6.css → 244.85c2cbf6.css} +0 -0
  115. /package/__mf/js/async/{121.4c5f5798.js.LICENSE.txt → 121.a37557d3.js.LICENSE.txt} +0 -0
  116. /package/__mf/js/async/{823.488b0ae9.js.LICENSE.txt → 208.a09e3946.js.LICENSE.txt} +0 -0
  117. /package/__mf/js/async/{403.9db35877.js.LICENSE.txt → 373.0403e3b1.js.LICENSE.txt} +0 -0
  118. /package/__mf/js/async/{392.4807325b.js.LICENSE.txt → 392.605cca25.js.LICENSE.txt} +0 -0
  119. /package/__mf/js/async/{470.9e955be3.js.LICENSE.txt → 470.a2c22a78.js.LICENSE.txt} +0 -0
  120. /package/__mf/js/async/{274.9badab92.js.LICENSE.txt → 893.a44ef766.js.LICENSE.txt} +0 -0
  121. /package/__mf/js/async/{941.c6518e38.js.LICENSE.txt → 941.e909e334.js.LICENSE.txt} +0 -0
  122. /package/__mf/js/async/{lib-router.f8568e8a.js.LICENSE.txt → lib-router.005da842.js.LICENSE.txt} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/GaugeChartPanel.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box, Skeleton, Stack } from '@mui/material';\nimport { FormatOptions, formatValue, useChartsTheme } from '@perses-dev/components';\nimport { CalculationsMap, DEFAULT_CALCULATION, PanelProps } from '@perses-dev/plugin-system';\nimport type { GaugeSeriesOption } from 'echarts';\nimport merge from 'lodash/merge';\nimport { ReactElement, useMemo } from 'react';\nimport { TimeSeriesData } from '@perses-dev/spec';\nimport {\n DEFAULT_FORMAT,\n DEFAULT_MAX_PERCENT,\n DEFAULT_MAX_PERCENT_DECIMAL,\n GaugeChartOptions,\n} from './gauge-chart-model';\nimport { convertThresholds, defaultThresholdInput } from './thresholds';\nimport { GaugeChartBase, GaugeSeries } from './GaugeChartBase';\n\nconst EMPTY_GAUGE_SERIES: GaugeSeries = { label: '', value: undefined };\nconst GAUGE_MIN_WIDTH = 90;\nconst PANEL_PADDING_OFFSET = 20;\n\n/**\n * Calculate responsive progress width based on panel dimensions\n */\nfunction getResponsiveProgressWidth(width: number, height: number): number {\n const MIN_WIDTH = 10;\n const MAX_WIDTH = 48;\n const RATIO = 0.1; // 10% of the smaller dimension\n\n const minSize = Math.min(width, height);\n // Use RATIO of the smaller dimension as base, with reasonable min/max bounds\n return Math.max(MIN_WIDTH, Math.min(MAX_WIDTH, Math.round(minSize * RATIO)));\n}\n\n/**\n * Responsive font size depending on number of characters and panel dimensions.\n * Uses clamp to ensure the text never overflows and scales appropriately with panel size.\n * (Value refers to the main number value displayed inside the gauge)\n */\nfunction getResponsiveValueFontSize(\n value: number | null,\n format: FormatOptions,\n width: number,\n height: number\n): string {\n const MIN_SIZE = 8;\n const MAX_SIZE = 64;\n const formattedValue = typeof value === 'number' ? formatValue(value, format) : `${value}`;\n\n const valueTextLength = Math.max(formattedValue.length, 6); // Ensure a minimum length to avoid overly large text for short values\n const availableSpace = Math.min(width, height);\n const fontSize = availableSpace / valueTextLength;\n\n return `clamp(${MIN_SIZE}px, ${fontSize}px, ${MAX_SIZE}px)`;\n}\n\n/**\n * Calculate responsive title font size based on panel dimensions\n * (Title refers to the text displayed below the gauge as a legend)\n */\nfunction getResponsiveTitleFontSize(width: number, height: number): number {\n const MIN_SIZE = 10;\n const MAX_SIZE = 16;\n const RATIO = 0.06; // Use 6% of the smaller dimension as base\n\n const size = Math.round(Math.min(width, height) * RATIO);\n // Scale based on panel size, with reasonable min/max bounds\n return Math.max(MIN_SIZE, Math.min(MAX_SIZE, size));\n}\n\nexport type GaugeChartPanelProps = PanelProps<GaugeChartOptions, TimeSeriesData>;\n\nexport function GaugeChartPanel(props: GaugeChartPanelProps): ReactElement | null {\n const { spec: pluginSpec, contentDimensions, queryResults } = props;\n const { calculation, max, legend } = pluginSpec;\n\n const { thresholds: thresholdsColors } = useChartsTheme();\n\n /* Legend setting just added to the cue schema\n This line assures that if legend setting doesn't exist (for old gauge setting records),\n The legend shows normally as before. If it exists, then it checks the show property.\n */\n const showLegend = legend?.show ?? true;\n\n // ensures all default format properties set if undef\n const format = merge({}, DEFAULT_FORMAT, pluginSpec.format);\n\n const thresholds = pluginSpec.thresholds ?? defaultThresholdInput;\n\n const gaugeData = useMemo((): GaugeSeries[] => {\n const seriesData: GaugeSeries[] = [];\n\n if (!CalculationsMap[calculation]) {\n console.warn(`Invalid GaugeChart panel calculation ${calculation}, fallback to ${DEFAULT_CALCULATION}`);\n }\n\n const calculate = CalculationsMap[calculation] ?? CalculationsMap[DEFAULT_CALCULATION];\n\n for (const result of queryResults) {\n for (const timeSeries of result.data.series) {\n seriesData.push({\n value: calculate(timeSeries.values),\n label: showLegend ? (timeSeries.formattedName ?? '') : '',\n });\n }\n }\n return seriesData;\n }, [queryResults, calculation, showLegend]);\n\n if (!contentDimensions) return null;\n\n // needed for end value of last threshold color segment\n let thresholdMax = max;\n if (thresholdMax === undefined) {\n thresholdMax = format.unit === 'percent' ? DEFAULT_MAX_PERCENT : DEFAULT_MAX_PERCENT_DECIMAL;\n }\n const axisLineColors = convertThresholds(thresholds, format, thresholdMax, thresholdsColors);\n\n // accounts for showing a separate chart for each time series\n let chartWidth = contentDimensions.width / gaugeData.length - PANEL_PADDING_OFFSET;\n if (chartWidth < GAUGE_MIN_WIDTH && gaugeData.length > 1) {\n // enables horizontal scroll when charts overflow outside of panel\n chartWidth = GAUGE_MIN_WIDTH;\n }\n\n // Calculate responsive values based on chart dimensions\n const progressWidth = getResponsiveProgressWidth(chartWidth, contentDimensions.height);\n const axisLineWidth = Math.round(progressWidth * 0.2); // Axis line width is 20% of progress width\n const titleFontSize = getResponsiveTitleFontSize(chartWidth, contentDimensions.height);\n\n const axisLine: GaugeSeriesOption['axisLine'] = {\n show: true,\n lineStyle: {\n width: axisLineWidth,\n color: axisLineColors,\n },\n };\n\n // no data message handled inside chart component\n if (!gaugeData.length) {\n const emptyValueFontSize = getResponsiveValueFontSize(\n null,\n format,\n contentDimensions.width,\n contentDimensions.height\n );\n const emptyProgressWidth = getResponsiveProgressWidth(contentDimensions.width, contentDimensions.height);\n const emptyTitleFontSize = getResponsiveTitleFontSize(contentDimensions.width, contentDimensions.height);\n\n return (\n <GaugeChartBase\n width={contentDimensions.width}\n height={contentDimensions.height}\n data={EMPTY_GAUGE_SERIES}\n format={format}\n axisLine={axisLine}\n max={thresholdMax}\n valueFontSize={emptyValueFontSize}\n progressWidth={emptyProgressWidth}\n titleFontSize={emptyTitleFontSize}\n />\n );\n }\n\n const hasMultipleCharts = gaugeData.length > 1;\n\n return (\n <Stack\n direction=\"row\"\n spacing={hasMultipleCharts ? 2 : 0}\n justifyContent={hasMultipleCharts ? 'left' : 'center'}\n alignItems=\"center\"\n sx={{\n // so scrollbar only shows when necessary\n overflowX: gaugeData.length > 1 ? 'scroll' : 'auto',\n }}\n >\n {gaugeData.map((series, seriesIndex) => {\n const fontSize = getResponsiveValueFontSize(series.value ?? null, format, chartWidth, contentDimensions.height);\n\n return (\n <Box key={`gauge-series-${seriesIndex}`}>\n <GaugeChartBase\n width={chartWidth}\n height={contentDimensions.height}\n data={series}\n format={format}\n axisLine={axisLine}\n max={thresholdMax}\n valueFontSize={fontSize}\n progressWidth={progressWidth}\n titleFontSize={titleFontSize}\n />\n </Box>\n );\n })}\n </Stack>\n );\n}\n\nexport function GaugeChartLoading({ contentDimensions }: GaugeChartPanelProps): React.ReactElement | null {\n if (!contentDimensions) return null;\n return (\n <Skeleton\n sx={{ margin: '0 auto' }}\n variant=\"circular\"\n width={contentDimensions.width > contentDimensions.height ? contentDimensions.height : contentDimensions.width}\n height={contentDimensions.height}\n />\n );\n}\n"],"names":["Box","Skeleton","Stack","formatValue","useChartsTheme","CalculationsMap","DEFAULT_CALCULATION","merge","useMemo","DEFAULT_FORMAT","DEFAULT_MAX_PERCENT","DEFAULT_MAX_PERCENT_DECIMAL","convertThresholds","defaultThresholdInput","GaugeChartBase","EMPTY_GAUGE_SERIES","label","value","undefined","GAUGE_MIN_WIDTH","PANEL_PADDING_OFFSET","getResponsiveProgressWidth","width","height","MIN_WIDTH","MAX_WIDTH","RATIO","minSize","Math","min","max","round","getResponsiveValueFontSize","format","MIN_SIZE","MAX_SIZE","formattedValue","valueTextLength","length","availableSpace","fontSize","getResponsiveTitleFontSize","size","GaugeChartPanel","props","spec","pluginSpec","contentDimensions","queryResults","calculation","legend","thresholds","thresholdsColors","showLegend","show","gaugeData","seriesData","console","warn","calculate","result","timeSeries","data","series","push","values","formattedName","thresholdMax","unit","axisLineColors","chartWidth","progressWidth","axisLineWidth","titleFontSize","axisLine","lineStyle","color","emptyValueFontSize","emptyProgressWidth","emptyTitleFontSize","valueFontSize","hasMultipleCharts","direction","spacing","justifyContent","alignItems","sx","overflowX","map","seriesIndex","GaugeChartLoading","margin","variant"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,GAAG,EAAEC,QAAQ,EAAEC,KAAK,QAAQ,gBAAgB;AACrD,SAAwBC,WAAW,EAAEC,cAAc,QAAQ,yBAAyB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ACF,yCAAyC;YACzCC,WAAWhC,UAAUjB,MAAM,GAAG,IAAI,WAAW;QAC/C;kBAECiB,UAAUiC,GAAG,CAAC,CAACzB,QAAQ0B;YACtB,MAAMjD,WAAWR,2BAA2B+B,OAAO9C,KAAK,IAAI,MAAMgB,QAAQqC,YAAYvB,kBAAkBxB,MAAM;YAE9G,qBACE,KAACvB;0BACC,cAAA,KAACc;oBACCQ,OAAOgD;oBACP/C,QAAQwB,kBAAkBxB,MAAM;oBAChCuC,MAAMC;oBACN9B,QAAQA;oBACRyC,UAAUA;oBACV5C,KAAKqC;oBACLa,eAAexC;oBACf+B,eAAeA;oBACfE,eAAeA;;eAVT,CAAC,aAAa,EAAEgB,aAAa;QAc3C;;AAGN;AAEA,OAAO,SAASC,kBAAkB,EAAE3C,iBAAiB,EAAwB;IAC3E,IAAI,CAACA,mBAAmB,OAAO;IAC/B,qBACE,KAAC9C;QACCqF,IAAI;YAAEK,QAAQ;QAAS;QACvBC,SAAQ;QACRtE,OAAOyB,kBAAkBzB,KAAK,GAAGyB,kBAAkBxB,MAAM,GAAGwB,kBAAkBxB,MAAM,GAAGwB,kBAAkBzB,KAAK;QAC9GC,QAAQwB,kBAAkBxB,MAAM;;AAGtC"}
1
+ {"version":3,"sources":["../../src/GaugeChartPanel.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box, Skeleton, Stack } from '@mui/material';\nimport type { FormatOptions } from '@perses-dev/components';\nimport { formatValue, useChartsTheme } from '@perses-dev/components';\nimport type { PanelProps } from '@perses-dev/plugin-system';\nimport { CalculationsMap, DEFAULT_CALCULATION } from '@perses-dev/plugin-system';\nimport type { TimeSeriesData } from '@perses-dev/spec';\nimport type { GaugeSeriesOption } from 'echarts';\nimport merge from 'lodash/merge';\nimport type { ReactElement } from 'react';\nimport { useMemo } from 'react';\n\nimport type { GaugeChartOptions } from './gauge-chart-model';\nimport { DEFAULT_FORMAT, DEFAULT_MAX_PERCENT, DEFAULT_MAX_PERCENT_DECIMAL } from './gauge-chart-model';\nimport type { GaugeSeries } from './GaugeChartBase';\nimport { GaugeChartBase } from './GaugeChartBase';\nimport { convertThresholds, defaultThresholdInput } from './thresholds';\n\nconst EMPTY_GAUGE_SERIES: GaugeSeries = { label: '', value: undefined };\nconst GAUGE_MIN_WIDTH = 90;\nconst PANEL_PADDING_OFFSET = 20;\n\n/**\n * Calculate responsive progress width based on panel dimensions\n */\nfunction getResponsiveProgressWidth(width: number, height: number): number {\n const MIN_WIDTH = 10;\n const MAX_WIDTH = 48;\n const RATIO = 0.1; // 10% of the smaller dimension\n\n const minSize = Math.min(width, height);\n // Use RATIO of the smaller dimension as base, with reasonable min/max bounds\n return Math.max(MIN_WIDTH, Math.min(MAX_WIDTH, Math.round(minSize * RATIO)));\n}\n\n/**\n * Responsive font size depending on number of characters and panel dimensions.\n * Uses clamp to ensure the text never overflows and scales appropriately with panel size.\n * (Value refers to the main number value displayed inside the gauge)\n */\nfunction getResponsiveValueFontSize(\n value: number | null,\n format: FormatOptions,\n width: number,\n height: number,\n): string {\n const MIN_SIZE = 8;\n const MAX_SIZE = 64;\n const formattedValue = typeof value === 'number' ? formatValue(value, format) : `${value}`;\n\n const valueTextLength = Math.max(formattedValue.length, 6); // Ensure a minimum length to avoid overly large text for short values\n const availableSpace = Math.min(width, height);\n const fontSize = availableSpace / valueTextLength;\n\n return `clamp(${MIN_SIZE}px, ${fontSize}px, ${MAX_SIZE}px)`;\n}\n\n/**\n * Calculate responsive title font size based on panel dimensions\n * (Title refers to the text displayed below the gauge as a legend)\n */\nfunction getResponsiveTitleFontSize(width: number, height: number): number {\n const MIN_SIZE = 10;\n const MAX_SIZE = 16;\n const RATIO = 0.06; // Use 6% of the smaller dimension as base\n\n const size = Math.round(Math.min(width, height) * RATIO);\n // Scale based on panel size, with reasonable min/max bounds\n return Math.max(MIN_SIZE, Math.min(MAX_SIZE, size));\n}\n\nexport type GaugeChartPanelProps = PanelProps<GaugeChartOptions, TimeSeriesData>;\n\nexport function GaugeChartPanel(props: GaugeChartPanelProps): ReactElement | null {\n const { spec: pluginSpec, contentDimensions, queryResults } = props;\n const { calculation, max, legend } = pluginSpec;\n\n const { thresholds: thresholdsColors } = useChartsTheme();\n\n /* Legend setting just added to the cue schema\n This line assures that if legend setting doesn't exist (for old gauge setting records),\n The legend shows normally as before. If it exists, then it checks the show property.\n */\n const showLegend = legend?.show ?? true;\n\n // ensures all default format properties set if undef\n const format = merge({}, DEFAULT_FORMAT, pluginSpec.format);\n\n const thresholds = pluginSpec.thresholds ?? defaultThresholdInput;\n\n const gaugeData = useMemo((): GaugeSeries[] => {\n const seriesData: GaugeSeries[] = [];\n\n if (!CalculationsMap[calculation]) {\n console.warn(`Invalid GaugeChart panel calculation ${calculation}, fallback to ${DEFAULT_CALCULATION}`);\n }\n\n const calculate = CalculationsMap[calculation] ?? CalculationsMap[DEFAULT_CALCULATION];\n\n for (const result of queryResults) {\n for (const timeSeries of result.data.series) {\n seriesData.push({\n value: calculate(timeSeries.values),\n label: showLegend ? (timeSeries.formattedName ?? '') : '',\n });\n }\n }\n return seriesData;\n }, [queryResults, calculation, showLegend]);\n\n if (!contentDimensions) return null;\n\n // needed for end value of last threshold color segment\n let thresholdMax = max;\n if (thresholdMax === undefined) {\n thresholdMax = format.unit === 'percent' ? DEFAULT_MAX_PERCENT : DEFAULT_MAX_PERCENT_DECIMAL;\n }\n const axisLineColors = convertThresholds(thresholds, format, thresholdMax, thresholdsColors);\n\n // accounts for showing a separate chart for each time series\n let chartWidth = contentDimensions.width / gaugeData.length - PANEL_PADDING_OFFSET;\n if (chartWidth < GAUGE_MIN_WIDTH && gaugeData.length > 1) {\n // enables horizontal scroll when charts overflow outside of panel\n chartWidth = GAUGE_MIN_WIDTH;\n }\n\n // Calculate responsive values based on chart dimensions\n const progressWidth = getResponsiveProgressWidth(chartWidth, contentDimensions.height);\n const axisLineWidth = Math.round(progressWidth * 0.2); // Axis line width is 20% of progress width\n const titleFontSize = getResponsiveTitleFontSize(chartWidth, contentDimensions.height);\n\n const axisLine: GaugeSeriesOption['axisLine'] = {\n show: true,\n lineStyle: {\n width: axisLineWidth,\n color: axisLineColors,\n },\n };\n\n // no data message handled inside chart component\n if (!gaugeData.length) {\n const emptyValueFontSize = getResponsiveValueFontSize(\n null,\n format,\n contentDimensions.width,\n contentDimensions.height,\n );\n const emptyProgressWidth = getResponsiveProgressWidth(contentDimensions.width, contentDimensions.height);\n const emptyTitleFontSize = getResponsiveTitleFontSize(contentDimensions.width, contentDimensions.height);\n\n return (\n <GaugeChartBase\n width={contentDimensions.width}\n height={contentDimensions.height}\n data={EMPTY_GAUGE_SERIES}\n format={format}\n axisLine={axisLine}\n max={thresholdMax}\n valueFontSize={emptyValueFontSize}\n progressWidth={emptyProgressWidth}\n titleFontSize={emptyTitleFontSize}\n />\n );\n }\n\n const hasMultipleCharts = gaugeData.length > 1;\n\n return (\n <Stack\n direction=\"row\"\n spacing={hasMultipleCharts ? 2 : 0}\n justifyContent={hasMultipleCharts ? 'left' : 'center'}\n alignItems=\"center\"\n sx={{\n // so scrollbar only shows when necessary\n overflowX: gaugeData.length > 1 ? 'scroll' : 'auto',\n }}\n >\n {gaugeData.map((series, seriesIndex) => {\n const fontSize = getResponsiveValueFontSize(series.value ?? null, format, chartWidth, contentDimensions.height);\n\n return (\n <Box key={`gauge-series-${seriesIndex}`}>\n <GaugeChartBase\n width={chartWidth}\n height={contentDimensions.height}\n data={series}\n format={format}\n axisLine={axisLine}\n max={thresholdMax}\n valueFontSize={fontSize}\n progressWidth={progressWidth}\n titleFontSize={titleFontSize}\n />\n </Box>\n );\n })}\n </Stack>\n );\n}\n\nexport function GaugeChartLoading({ contentDimensions }: GaugeChartPanelProps): React.ReactElement | null {\n if (!contentDimensions) return null;\n return (\n <Skeleton\n sx={{ margin: '0 auto' }}\n variant=\"circular\"\n width={contentDimensions.width > contentDimensions.height ? contentDimensions.height : contentDimensions.width}\n height={contentDimensions.height}\n />\n );\n}\n"],"names":["Box","Skeleton","Stack","formatValue","useChartsTheme","CalculationsMap","DEFAULT_CALCULATION","merge","useMemo","DEFAULT_FORMAT","DEFAULT_MAX_PERCENT","DEFAULT_MAX_PERCENT_DECIMAL","GaugeChartBase","convertThresholds","defaultThresholdInput","EMPTY_GAUGE_SERIES","label","value","undefined","GAUGE_MIN_WIDTH","PANEL_PADDING_OFFSET","getResponsiveProgressWidth","width","height","MIN_WIDTH","MAX_WIDTH","RATIO","minSize","Math","min","max","round","getResponsiveValueFontSize","format","MIN_SIZE","MAX_SIZE","formattedValue","valueTextLength","length","availableSpace","fontSize","getResponsiveTitleFontSize","size","GaugeChartPanel","props","spec","pluginSpec","contentDimensions","queryResults","calculation","legend","thresholds","thresholdsColors","showLegend","show","gaugeData","seriesData","console","warn","calculate","result","timeSeries","data","series","push","values","formattedName","thresholdMax","unit","axisLineColors","chartWidth","progressWidth","axisLineWidth","titleFontSize","axisLine","lineStyle","color","emptyValueFontSize","emptyProgressWidth","emptyTitleFontSize","valueFontSize","hasMultipleCharts","direction","spacing","justifyContent","alignItems","sx","overflowX","map","seriesIndex","GaugeChartLoading","margin","variant"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,GAAG,EAAEC,QAAQ,EAAEC,KAAK,QAAQ,gBAAgB;AAErD,SAASC,WAAW,EAAEC,cAAc,QAAQ,yBAAyB;AAErE,SAASC,eAA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C,WAAWhC,UAAUjB,MAAM,GAAG,IAAI,WAAW;QAC/C;kBAECiB,UAAUiC,GAAG,CAAC,CAACzB,QAAQ0B;YACtB,MAAMjD,WAAWR,2BAA2B+B,OAAO9C,KAAK,IAAI,MAAMgB,QAAQqC,YAAYvB,kBAAkBxB,MAAM;YAE9G,qBACE,KAACvB;0BACC,cAAA,KAACY;oBACCU,OAAOgD;oBACP/C,QAAQwB,kBAAkBxB,MAAM;oBAChCuC,MAAMC;oBACN9B,QAAQA;oBACRyC,UAAUA;oBACV5C,KAAKqC;oBACLa,eAAexC;oBACf+B,eAAeA;oBACfE,eAAeA;;eAVT,CAAC,aAAa,EAAEgB,aAAa;QAc3C;;AAGN;AAEA,OAAO,SAASC,kBAAkB,EAAE3C,iBAAiB,EAAwB;IAC3E,IAAI,CAACA,mBAAmB,OAAO;IAC/B,qBACE,KAAC9C;QACCqF,IAAI;YAAEK,QAAQ;QAAS;QACvBC,SAAQ;QACRtE,OAAOyB,kBAAkBzB,KAAK,GAAGyB,kBAAkBxB,MAAM,GAAGwB,kBAAkBxB,MAAM,GAAGwB,kBAAkBzB,KAAK;QAC9GC,QAAQwB,kBAAkBxB,MAAM;;AAGtC"}
package/lib/bootstrap.js CHANGED
@@ -11,8 +11,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
11
11
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
- import React from 'react';
15
- import ReactDOM from 'react-dom/client';
14
+ import React from "react";
15
+ import ReactDOM from "react-dom/client";
16
16
  const root = ReactDOM.createRoot(document.getElementById('root'));
17
17
  root.render(/*#__PURE__*/ _jsx(React.StrictMode, {}));
18
18
 
@@ -1,6 +1,6 @@
1
- import { FormatOptions, ThresholdOptions } from '@perses-dev/components';
2
- import { CalculationType, OptionsEditorProps } from '@perses-dev/plugin-system';
3
- import { Definition } from '@perses-dev/spec';
1
+ import type { FormatOptions, ThresholdOptions } from '@perses-dev/components';
2
+ import type { CalculationType, OptionsEditorProps } from '@perses-dev/plugin-system';
3
+ import type { Definition } from '@perses-dev/spec';
4
4
  export declare const DEFAULT_FORMAT: FormatOptions;
5
5
  export declare const DEFAULT_MAX_PERCENT = 100;
6
6
  export declare const DEFAULT_MAX_PERCENT_DECIMAL = 1;
@@ -1 +1 @@
1
- {"version":3,"file":"gauge-chart-model.d.ts","sourceRoot":"","sources":["../../src/gauge-chart-model.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAChF,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,eAAO,MAAM,cAAc,EAAE,aAA2C,CAAC;AACzE,eAAO,MAAM,mBAAmB,MAAM,CAAC;AACvC,eAAO,MAAM,2BAA2B,IAAI,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,UAAU,CAAC,iBAAiB,CAAC;IACzE,IAAI,EAAE,YAAY,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,eAAe,CAAC;IAC7B,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;CAC7B;AAED,MAAM,MAAM,4BAA4B,GAAG,kBAAkB,CAAC,iBAAiB,CAAC,CAAC;AAEjF;;GAEG;AACH,wBAAgB,8BAA8B,IAAI,iBAAiB,CAelE"}
1
+ {"version":3,"file":"gauge-chart-model.d.ts","sourceRoot":"","sources":["../../src/gauge-chart-model.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC9E,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACrF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,eAAO,MAAM,cAAc,EAAE,aAA2C,CAAC;AACzE,eAAO,MAAM,mBAAmB,MAAM,CAAC;AACvC,eAAO,MAAM,2BAA2B,IAAI,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,UAAU,CAAC,iBAAiB,CAAC;IACzE,IAAI,EAAE,YAAY,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,eAAe,CAAC;IAC7B,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;CAC7B;AAED,MAAM,MAAM,4BAA4B,GAAG,kBAAkB,CAAC,iBAAiB,CAAC,CAAC;AAEjF;;GAEG;AACH,wBAAgB,8BAA8B,IAAI,iBAAiB,CAelE"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/gauge-chart-model.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { FormatOptions, ThresholdOptions } from '@perses-dev/components';\nimport { CalculationType, OptionsEditorProps } from '@perses-dev/plugin-system';\nimport { Definition } from '@perses-dev/spec';\n\nexport const DEFAULT_FORMAT: FormatOptions = { unit: 'percent-decimal' };\nexport const DEFAULT_MAX_PERCENT = 100;\nexport const DEFAULT_MAX_PERCENT_DECIMAL = 1;\n\n/**\n * The schema for a GaugeChart panel.\n */\nexport interface GaugeChartDefinition extends Definition<GaugeChartOptions> {\n kind: 'GaugeChart';\n}\n\n/**\n * The Options object type supported by the GaugeChart panel plugin.\n */\nexport interface GaugeChartOptions {\n calculation: CalculationType;\n format?: FormatOptions;\n thresholds?: ThresholdOptions;\n max?: number;\n legend?: { show?: boolean };\n}\n\nexport type GaugeChartOptionsEditorProps = OptionsEditorProps<GaugeChartOptions>;\n\n/**\n * Creates the initial/empty options for a GaugeChart panel.\n */\nexport function createInitialGaugeChartOptions(): GaugeChartOptions {\n return {\n calculation: 'last-number',\n format: DEFAULT_FORMAT,\n thresholds: {\n steps: [\n {\n value: 0.8,\n },\n {\n value: 0.9,\n },\n ],\n },\n };\n}\n"],"names":["DEFAULT_FORMAT","unit","DEFAULT_MAX_PERCENT","DEFAULT_MAX_PERCENT_DECIMAL","createInitialGaugeChartOptions","calculation","format","thresholds","steps","value"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAMjC,OAAO,MAAMA,iBAAgC;IAAEC,MAAM;AAAkB,EAAE;AACzE,OAAO,MAAMC,sBAAsB,IAAI;AACvC,OAAO,MAAMC,8BAA8B,EAAE;AAsB7C;;CAEC,GACD,OAAO,SAASC;IACd,OAAO;QACLC,aAAa;QACbC,QAAQN;QACRO,YAAY;YACVC,OAAO;gBACL;oBACEC,OAAO;gBACT;gBACA;oBACEA,OAAO;gBACT;aACD;QACH;IACF;AACF"}
1
+ {"version":3,"sources":["../../src/gauge-chart-model.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type { FormatOptions, ThresholdOptions } from '@perses-dev/components';\nimport type { CalculationType, OptionsEditorProps } from '@perses-dev/plugin-system';\nimport type { Definition } from '@perses-dev/spec';\n\nexport const DEFAULT_FORMAT: FormatOptions = { unit: 'percent-decimal' };\nexport const DEFAULT_MAX_PERCENT = 100;\nexport const DEFAULT_MAX_PERCENT_DECIMAL = 1;\n\n/**\n * The schema for a GaugeChart panel.\n */\nexport interface GaugeChartDefinition extends Definition<GaugeChartOptions> {\n kind: 'GaugeChart';\n}\n\n/**\n * The Options object type supported by the GaugeChart panel plugin.\n */\nexport interface GaugeChartOptions {\n calculation: CalculationType;\n format?: FormatOptions;\n thresholds?: ThresholdOptions;\n max?: number;\n legend?: { show?: boolean };\n}\n\nexport type GaugeChartOptionsEditorProps = OptionsEditorProps<GaugeChartOptions>;\n\n/**\n * Creates the initial/empty options for a GaugeChart panel.\n */\nexport function createInitialGaugeChartOptions(): GaugeChartOptions {\n return {\n calculation: 'last-number',\n format: DEFAULT_FORMAT,\n thresholds: {\n steps: [\n {\n value: 0.8,\n },\n {\n value: 0.9,\n },\n ],\n },\n };\n}\n"],"names":["DEFAULT_FORMAT","unit","DEFAULT_MAX_PERCENT","DEFAULT_MAX_PERCENT_DECIMAL","createInitialGaugeChartOptions","calculation","format","thresholds","steps","value"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAMjC,OAAO,MAAMA,iBAAgC;IAAEC,MAAM;AAAkB,EAAE;AACzE,OAAO,MAAMC,sBAAsB,IAAI;AACvC,OAAO,MAAMC,8BAA8B,EAAE;AAsB7C;;CAEC,GACD,OAAO,SAASC;IACd,OAAO;QACLC,aAAa;QACbC,QAAQN;QACRO,YAAY;YACVC,OAAO;gBACL;oBACEC,OAAO;gBACT;gBACA;oBACEA,OAAO;gBACT;aACD;QACH;IACF;AACF"}
@@ -1,4 +1,4 @@
1
- import { PluginModuleResource } from '@perses-dev/plugin-system';
1
+ import type { PluginModuleResource } from '@perses-dev/plugin-system';
2
2
  /**
3
3
  * Returns the plugin module information from package.json
4
4
  */
@@ -1 +1 @@
1
- {"version":3,"file":"getPluginModule.d.ts","sourceRoot":"","sources":["../../src/getPluginModule.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,oBAAoB,EAAoB,MAAM,2BAA2B,CAAC;AAGnF;;GAEG;AACH,wBAAgB,eAAe,IAAI,oBAAoB,CAUtD"}
1
+ {"version":3,"file":"getPluginModule.d.ts","sourceRoot":"","sources":["../../src/getPluginModule.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,oBAAoB,EAAoB,MAAM,2BAA2B,CAAC;AAIxF;;GAEG;AACH,wBAAgB,eAAe,IAAI,oBAAoB,CAUtD"}
@@ -10,7 +10,9 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
- import packageJson from '../package.json';
13
+ import packageJson from "../package.json" with {
14
+ type: 'json'
15
+ };
14
16
  /**
15
17
  * Returns the plugin module information from package.json
16
18
  */ export function getPluginModule() {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/getPluginModule.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \\\"AS IS\\\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system';\nimport packageJson from '../package.json';\n\n/**\n * Returns the plugin module information from package.json\n */\nexport function getPluginModule(): PluginModuleResource {\n const { name, version, perses } = packageJson;\n return {\n kind: 'PluginModule',\n metadata: {\n name,\n version,\n },\n spec: perses as PluginModuleSpec,\n };\n}\n"],"names":["packageJson","getPluginModule","name","version","perses","kind","metadata","spec"],"mappings":"AAAA,+BAA+B;AAC/B,oEAAoE;AACpE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,sEAAsE;AACtE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,OAAOA,iBAAiB,kBAAkB;AAE1C;;CAEC,GACD,OAAO,SAASC;IACd,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAEC,MAAM,EAAE,GAAGJ;IAClC,OAAO;QACLK,MAAM;QACNC,UAAU;YACRJ;YACAC;QACF;QACAI,MAAMH;IACR;AACF"}
1
+ {"version":3,"sources":["../../src/getPluginModule.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \\\"AS IS\\\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system';\n\nimport packageJson from '../package.json' with { type: 'json' };\n\n/**\n * Returns the plugin module information from package.json\n */\nexport function getPluginModule(): PluginModuleResource {\n const { name, version, perses } = packageJson;\n return {\n kind: 'PluginModule',\n metadata: {\n name,\n version,\n },\n spec: perses as PluginModuleSpec,\n };\n}\n"],"names":["packageJson","type","getPluginModule","name","version","perses","kind","metadata","spec"],"mappings":"AAAA,+BAA+B;AAC/B,oEAAoE;AACpE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,sEAAsE;AACtE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,OAAOA,iBAAiB,uBAAuB;IAAEC,MAAM;AAAO,EAAE;AAEhE;;CAEC,GACD,OAAO,SAASC;IACd,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAEC,MAAM,EAAE,GAAGL;IAClC,OAAO;QACLM,MAAM;QACNC,UAAU;YACRJ;YACAC;QACF;QACAI,MAAMH;IACR;AACF"}
@@ -10,6 +10,6 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
- import('./bootstrap');
13
+ import("./bootstrap.js");
14
14
 
15
15
  //# sourceMappingURL=index-federation.js.map
package/lib/index.js CHANGED
@@ -10,11 +10,11 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
- export * from './gauge-chart-model';
14
- export * from './GaugeChart';
15
- export * from './GaugeChartOptionsEditorSettings';
16
- export * from './GaugeChartPanel';
17
- export { getPluginModule } from './getPluginModule';
18
- export * from './thresholds';
13
+ export * from "./gauge-chart-model.js";
14
+ export * from "./GaugeChart.js";
15
+ export * from "./GaugeChartOptionsEditorSettings.js";
16
+ export * from "./GaugeChartPanel.js";
17
+ export { getPluginModule } from "./getPluginModule.js";
18
+ export * from "./thresholds.js";
19
19
 
20
20
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \\\"AS IS\\\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './gauge-chart-model';\nexport * from './GaugeChart';\nexport * from './GaugeChartOptionsEditorSettings';\nexport * from './GaugeChartPanel';\nexport { getPluginModule } from './getPluginModule';\nexport * from './thresholds';\n"],"names":["getPluginModule"],"mappings":"AAAA,+BAA+B;AAC/B,oEAAoE;AACpE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,sEAAsE;AACtE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,sBAAsB;AACpC,cAAc,eAAe;AAC7B,cAAc,oCAAoC;AAClD,cAAc,oBAAoB;AAClC,SAASA,eAAe,QAAQ,oBAAoB;AACpD,cAAc,eAAe"}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \\\"AS IS\\\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './gauge-chart-model';\nexport * from './GaugeChart';\nexport * from './GaugeChartOptionsEditorSettings';\nexport * from './GaugeChartPanel';\nexport { getPluginModule } from './getPluginModule';\nexport * from './thresholds';\n"],"names":["getPluginModule"],"mappings":"AAAA,+BAA+B;AAC/B,oEAAoE;AACpE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,sEAAsE;AACtE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,yBAAsB;AACpC,cAAc,kBAAe;AAC7B,cAAc,uCAAoC;AAClD,cAAc,uBAAoB;AAClC,SAASA,eAAe,QAAQ,uBAAoB;AACpD,cAAc,kBAAe"}
@@ -1,2 +1,2 @@
1
- import '@testing-library/jest-dom';
1
+ import '@testing-library/jest-dom/vitest';
2
2
  //# sourceMappingURL=setup-tests.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"setup-tests.d.ts","sourceRoot":"","sources":["../../src/setup-tests.ts"],"names":[],"mappings":"AAaA,OAAO,2BAA2B,CAAC"}
1
+ {"version":3,"file":"setup-tests.d.ts","sourceRoot":"","sources":["../../src/setup-tests.ts"],"names":[],"mappings":"AAaA,OAAO,kCAAkC,CAAC"}
@@ -10,8 +10,8 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
- import '@testing-library/jest-dom';
13
+ import "@testing-library/jest-dom/vitest";
14
14
  // Always mock e-charts during tests since we don't have a proper canvas in jsdom
15
- jest.mock('echarts/core');
15
+ vi.mock('echarts/core');
16
16
 
17
17
  //# sourceMappingURL=setup-tests.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/setup-tests.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport '@testing-library/jest-dom';\n\n// Always mock e-charts during tests since we don't have a proper canvas in jsdom\njest.mock('echarts/core');\n"],"names":["jest","mock"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,4BAA4B;AAEnC,iFAAiF;AACjFA,KAAKC,IAAI,CAAC"}
1
+ {"version":3,"sources":["../../src/setup-tests.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport '@testing-library/jest-dom/vitest';\n\n// Always mock e-charts during tests since we don't have a proper canvas in jsdom\nvi.mock('echarts/core');\n"],"names":["vi","mock"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,mCAAmC;AAE1C,iFAAiF;AACjFA,GAAGC,IAAI,CAAC"}
@@ -1,4 +1,4 @@
1
- import { FormatOptions, ThresholdColorPalette, ThresholdOptions } from '@perses-dev/components';
1
+ import type { FormatOptions, ThresholdColorPalette, ThresholdOptions } from '@perses-dev/components';
2
2
  export type GaugeColorStop = [number, string];
3
3
  export type EChartsAxisLineColors = GaugeColorStop[];
4
4
  export declare const defaultThresholdInput: ThresholdOptions;
@@ -1 +1 @@
1
- {"version":3,"file":"thresholds.d.ts","sourceRoot":"","sources":["../../src/thresholds.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,aAAa,EAAe,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG7G,MAAM,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE9C,MAAM,MAAM,qBAAqB,GAAG,cAAc,EAAE,CAAC;AAErD,eAAO,MAAM,qBAAqB,EAAE,gBAA4C,CAAC;AAEjF,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,gBAAgB,EAC5B,IAAI,EAAE,aAAa,EACnB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,qBAAqB,GAC7B,qBAAqB,CA4BvB"}
1
+ {"version":3,"file":"thresholds.d.ts","sourceRoot":"","sources":["../../src/thresholds.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,aAAa,EAAe,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAGlH,MAAM,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE9C,MAAM,MAAM,qBAAqB,GAAG,cAAc,EAAE,CAAC;AAErD,eAAO,MAAM,qBAAqB,EAAE,gBAA4C,CAAC;AAEjF,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,gBAAgB,EAC5B,IAAI,EAAE,aAAa,EACnB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,qBAAqB,GAC7B,qBAAqB,CA4BvB"}
package/lib/thresholds.js CHANGED
@@ -10,7 +10,7 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
- import zip from 'lodash/zip';
13
+ import zip from "lodash/zip";
14
14
  export const defaultThresholdInput = {
15
15
  steps: [
16
16
  {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/thresholds.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { FormatOptions, StepOptions, ThresholdColorPalette, ThresholdOptions } from '@perses-dev/components';\nimport zip from 'lodash/zip';\n\nexport type GaugeColorStop = [number, string];\n\nexport type EChartsAxisLineColors = GaugeColorStop[];\n\nexport const defaultThresholdInput: ThresholdOptions = { steps: [{ value: 0 }] };\n\nexport function convertThresholds(\n thresholds: ThresholdOptions,\n unit: FormatOptions,\n max: number,\n palette: ThresholdColorPalette\n): EChartsAxisLineColors {\n const defaultThresholdColor = thresholds.defaultColor ?? palette.defaultColor;\n const defaultThresholdSteps: EChartsAxisLineColors = [[0, defaultThresholdColor]];\n\n if (thresholds.steps !== undefined) {\n // https://echarts.apache.org/en/option.html#series-gauge.axisLine.lineStyle.color\n // color segments must be decimal between 0 and 1\n const segmentMax = 1;\n const valuesArr: number[] = thresholds.steps.map((step: StepOptions) => {\n if (thresholds.mode === 'percent') {\n return step.value / 100;\n }\n return step.value / max;\n });\n valuesArr.push(segmentMax);\n\n const colorsArr = thresholds.steps.map((step: StepOptions, index) => step.color ?? palette.palette[index]);\n colorsArr.unshift(defaultThresholdColor);\n\n const zippedArr = zip(valuesArr, colorsArr);\n return zippedArr.map((elem) => {\n const convertedValues = elem[0] ?? segmentMax;\n const convertedColors = elem[1] ?? defaultThresholdColor;\n return [convertedValues, convertedColors];\n });\n } else {\n return defaultThresholdSteps;\n }\n}\n"],"names":["zip","defaultThresholdInput","steps","value","convertThresholds","thresholds","unit","max","palette","defaultThresholdColor","defaultColor","defaultThresholdSteps","undefined","segmentMax","valuesArr","map","step","mode","push","colorsArr","index","color","unshift","zippedArr","elem","convertedValues","convertedColors"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,OAAOA,SAAS,aAAa;AAM7B,OAAO,MAAMC,wBAA0C;IAAEC,OAAO;QAAC;YAAEC,OAAO;QAAE;KAAE;AAAC,EAAE;AAEjF,OAAO,SAASC,kBACdC,UAA4B,EAC5BC,IAAmB,EACnBC,GAAW,EACXC,OAA8B;IAE9B,MAAMC,wBAAwBJ,WAAWK,YAAY,IAAIF,QAAQE,YAAY;IAC7E,MAAMC,wBAA+C;QAAC;YAAC;YAAGF;SAAsB;KAAC;IAEjF,IAAIJ,WAAWH,KAAK,KAAKU,WAAW;QAClC,kFAAkF;QAClF,iDAAiD;QACjD,MAAMC,aAAa;QACnB,MAAMC,YAAsBT,WAAWH,KAAK,CAACa,GAAG,CAAC,CAACC;YAChD,IAAIX,WAAWY,IAAI,KAAK,WAAW;gBACjC,OAAOD,KAAKb,KAAK,GAAG;YACtB;YACA,OAAOa,KAAKb,KAAK,GAAGI;QACtB;QACAO,UAAUI,IAAI,CAACL;QAEf,MAAMM,YAAYd,WAAWH,KAAK,CAACa,GAAG,CAAC,CAACC,MAAmBI,QAAUJ,KAAKK,KAAK,IAAIb,QAAQA,OAAO,CAACY,MAAM;QACzGD,UAAUG,OAAO,CAACb;QAElB,MAAMc,YAAYvB,IAAIc,WAAWK;QACjC,OAAOI,UAAUR,GAAG,CAAC,CAACS;YACpB,MAAMC,kBAAkBD,IAAI,CAAC,EAAE,IAAIX;YACnC,MAAMa,kBAAkBF,IAAI,CAAC,EAAE,IAAIf;YACnC,OAAO;gBAACgB;gBAAiBC;aAAgB;QAC3C;IACF,OAAO;QACL,OAAOf;IACT;AACF"}
1
+ {"version":3,"sources":["../../src/thresholds.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type { FormatOptions, StepOptions, ThresholdColorPalette, ThresholdOptions } from '@perses-dev/components';\nimport zip from 'lodash/zip';\n\nexport type GaugeColorStop = [number, string];\n\nexport type EChartsAxisLineColors = GaugeColorStop[];\n\nexport const defaultThresholdInput: ThresholdOptions = { steps: [{ value: 0 }] };\n\nexport function convertThresholds(\n thresholds: ThresholdOptions,\n unit: FormatOptions,\n max: number,\n palette: ThresholdColorPalette,\n): EChartsAxisLineColors {\n const defaultThresholdColor = thresholds.defaultColor ?? palette.defaultColor;\n const defaultThresholdSteps: EChartsAxisLineColors = [[0, defaultThresholdColor]];\n\n if (thresholds.steps !== undefined) {\n // https://echarts.apache.org/en/option.html#series-gauge.axisLine.lineStyle.color\n // color segments must be decimal between 0 and 1\n const segmentMax = 1;\n const valuesArr: number[] = thresholds.steps.map((step: StepOptions) => {\n if (thresholds.mode === 'percent') {\n return step.value / 100;\n }\n return step.value / max;\n });\n valuesArr.push(segmentMax);\n\n const colorsArr = thresholds.steps.map((step: StepOptions, index) => step.color ?? palette.palette[index]);\n colorsArr.unshift(defaultThresholdColor);\n\n const zippedArr = zip(valuesArr, colorsArr);\n return zippedArr.map((elem) => {\n const convertedValues = elem[0] ?? segmentMax;\n const convertedColors = elem[1] ?? defaultThresholdColor;\n return [convertedValues, convertedColors];\n });\n } else {\n return defaultThresholdSteps;\n }\n}\n"],"names":["zip","defaultThresholdInput","steps","value","convertThresholds","thresholds","unit","max","palette","defaultThresholdColor","defaultColor","defaultThresholdSteps","undefined","segmentMax","valuesArr","map","step","mode","push","colorsArr","index","color","unshift","zippedArr","elem","convertedValues","convertedColors"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,OAAOA,SAAS,aAAa;AAM7B,OAAO,MAAMC,wBAA0C;IAAEC,OAAO;QAAC;YAAEC,OAAO;QAAE;KAAE;AAAC,EAAE;AAEjF,OAAO,SAASC,kBACdC,UAA4B,EAC5BC,IAAmB,EACnBC,GAAW,EACXC,OAA8B;IAE9B,MAAMC,wBAAwBJ,WAAWK,YAAY,IAAIF,QAAQE,YAAY;IAC7E,MAAMC,wBAA+C;QAAC;YAAC;YAAGF;SAAsB;KAAC;IAEjF,IAAIJ,WAAWH,KAAK,KAAKU,WAAW;QAClC,kFAAkF;QAClF,iDAAiD;QACjD,MAAMC,aAAa;QACnB,MAAMC,YAAsBT,WAAWH,KAAK,CAACa,GAAG,CAAC,CAACC;YAChD,IAAIX,WAAWY,IAAI,KAAK,WAAW;gBACjC,OAAOD,KAAKb,KAAK,GAAG;YACtB;YACA,OAAOa,KAAKb,KAAK,GAAGI;QACtB;QACAO,UAAUI,IAAI,CAACL;QAEf,MAAMM,YAAYd,WAAWH,KAAK,CAACa,GAAG,CAAC,CAACC,MAAmBI,QAAUJ,KAAKK,KAAK,IAAIb,QAAQA,OAAO,CAACY,MAAM;QACzGD,UAAUG,OAAO,CAACb;QAElB,MAAMc,YAAYvB,IAAIc,WAAWK;QACjC,OAAOI,UAAUR,GAAG,CAAC,CAACS;YACpB,MAAMC,kBAAkBD,IAAI,CAAC,EAAE,IAAIX;YACnC,MAAMa,kBAAkBF,IAAI,CAAC,EAAE,IAAIf;YACnC,OAAO;gBAACgB;gBAAiBC;aAAgB;QAC3C;IACF,OAAO;QACL,OAAOf;IACT;AACF"}
package/mf-manifest.json CHANGED
@@ -5,11 +5,11 @@
5
5
  "name": "GaugeChart",
6
6
  "type": "app",
7
7
  "buildInfo": {
8
- "buildVersion": "0.13.0",
8
+ "buildVersion": "0.14.0-beta.1",
9
9
  "buildName": "@perses-dev/gauge-chart-plugin"
10
10
  },
11
11
  "remoteEntry": {
12
- "name": "__mf/js/GaugeChart.7e331b64.js",
12
+ "name": "__mf/js/GaugeChart.666448e5.js",
13
13
  "path": "",
14
14
  "type": "global"
15
15
  },
@@ -19,9 +19,9 @@
19
19
  "zip": "",
20
20
  "api": ""
21
21
  },
22
- "globalName": "GaugeChart",
22
+ "globalName": "GaugeChart_0_14_0_beta_1",
23
23
  "pluginVersion": "2.6.0",
24
- "getPublicPath": "function() { const prefix = window.PERSES_PLUGIN_ASSETS_PATH || window.PERSES_APP_CONFIG?.api_prefix || \"\"; return prefix + \"/plugins/GaugeChart/\"; }"
24
+ "getPublicPath": "function() { const prefix = window.PERSES_PLUGIN_ASSETS_PATH || window.PERSES_APP_CONFIG?.api_prefix || \"\"; return prefix + \"/plugins/GaugeChart~0.14.0-beta.1/\"; }"
25
25
  },
26
26
  "shared": [
27
27
  {
@@ -34,7 +34,7 @@
34
34
  "js": {
35
35
  "async": [],
36
36
  "sync": [
37
- "__mf/js/async/274.9badab92.js"
37
+ "__mf/js/async/893.a44ef766.js"
38
38
  ]
39
39
  },
40
40
  "css": {
@@ -54,9 +54,8 @@
54
54
  "js": {
55
55
  "async": [],
56
56
  "sync": [
57
- "__mf/js/async/235.b918db36.js",
58
- "__mf/js/async/616.0741833f.js",
59
- "__mf/js/async/854.d052322d.js"
57
+ "__mf/js/async/235.25414f3a.js",
58
+ "__mf/js/async/616.cecf44f8.js"
60
59
  ]
61
60
  },
62
61
  "css": {
@@ -76,8 +75,8 @@
76
75
  "js": {
77
76
  "async": [],
78
77
  "sync": [
79
- "__mf/js/async/587.2649e50b.js",
80
- "__mf/js/async/968.5b4a4f18.js"
78
+ "__mf/js/async/587.6f130e41.js",
79
+ "__mf/js/async/968.7d1ce389.js"
81
80
  ]
82
81
  },
83
82
  "css": {
@@ -90,20 +89,20 @@
90
89
  {
91
90
  "id": "GaugeChart:@perses-dev/components",
92
91
  "name": "@perses-dev/components",
93
- "version": "0.54.0",
92
+ "version": "0.55.0-beta.6",
94
93
  "singleton": true,
95
- "requiredVersion": "^0.54.0",
94
+ "requiredVersion": "^0.55.0-beta.6",
96
95
  "assets": {
97
96
  "js": {
98
97
  "async": [],
99
98
  "sync": [
100
- "__mf/js/async/187.ba6fd686.js"
99
+ "__mf/js/async/244.f21ad375.js"
101
100
  ]
102
101
  },
103
102
  "css": {
104
103
  "async": [],
105
104
  "sync": [
106
- "__mf/css/async/187.85c2cbf6.css"
105
+ "__mf/css/async/244.85c2cbf6.css"
107
106
  ]
108
107
  }
109
108
  },
@@ -112,14 +111,14 @@
112
111
  {
113
112
  "id": "GaugeChart:@perses-dev/plugin-system",
114
113
  "name": "@perses-dev/plugin-system",
115
- "version": "0.54.0",
114
+ "version": "0.55.0-beta.6",
116
115
  "singleton": true,
117
- "requiredVersion": "^0.54.0",
116
+ "requiredVersion": "^0.55.0-beta.6",
118
117
  "assets": {
119
118
  "js": {
120
119
  "async": [],
121
120
  "sync": [
122
- "__mf/js/async/546.7850a553.js"
121
+ "__mf/js/async/354.c398a3bf.js"
123
122
  ]
124
123
  },
125
124
  "css": {
@@ -139,27 +138,7 @@
139
138
  "js": {
140
139
  "async": [],
141
140
  "sync": [
142
- "__mf/js/async/192.fb5cd927.js"
143
- ]
144
- },
145
- "css": {
146
- "async": [],
147
- "sync": []
148
- }
149
- },
150
- "fallback": ""
151
- },
152
- {
153
- "id": "GaugeChart:echarts",
154
- "name": "echarts",
155
- "version": "5.5.0",
156
- "singleton": true,
157
- "requiredVersion": "^undefined",
158
- "assets": {
159
- "js": {
160
- "async": [],
161
- "sync": [
162
- "__mf/js/async/873.650a20f9.js"
141
+ "__mf/js/async/192.1bece79a.js"
163
142
  ]
164
143
  },
165
144
  "css": {
@@ -179,7 +158,7 @@
179
158
  "js": {
180
159
  "async": [],
181
160
  "sync": [
182
- "__mf/js/async/963.ab063f73.js"
161
+ "__mf/js/async/963.caed232d.js"
183
162
  ]
184
163
  },
185
164
  "css": {
@@ -199,27 +178,7 @@
199
178
  "js": {
200
179
  "async": [],
201
180
  "sync": [
202
- "__mf/js/async/392.4807325b.js"
203
- ]
204
- },
205
- "css": {
206
- "async": [],
207
- "sync": []
208
- }
209
- },
210
- "fallback": ""
211
- },
212
- {
213
- "id": "GaugeChart:mdi-material-ui",
214
- "name": "mdi-material-ui",
215
- "version": "7.9.4",
216
- "singleton": true,
217
- "requiredVersion": "7.4.0",
218
- "assets": {
219
- "js": {
220
- "async": [],
221
- "sync": [
222
- "__mf/js/async/496.dc9e951b.js"
181
+ "__mf/js/async/392.605cca25.js"
223
182
  ]
224
183
  },
225
184
  "css": {
@@ -239,7 +198,7 @@
239
198
  "js": {
240
199
  "async": [],
241
200
  "sync": [
242
- "__mf/js/async/470.9e955be3.js"
201
+ "__mf/js/async/470.a2c22a78.js"
243
202
  ]
244
203
  },
245
204
  "css": {
@@ -259,7 +218,7 @@
259
218
  "js": {
260
219
  "async": [],
261
220
  "sync": [
262
- "__mf/js/async/121.4c5f5798.js"
221
+ "__mf/js/async/121.a37557d3.js"
263
222
  ]
264
223
  },
265
224
  "css": {
@@ -279,28 +238,8 @@
279
238
  "js": {
280
239
  "async": [],
281
240
  "sync": [
282
- "__mf/js/async/458.0f5bc9ee.js",
283
- "__mf/js/async/77.629e7e49.js"
284
- ]
285
- },
286
- "css": {
287
- "async": [],
288
- "sync": []
289
- }
290
- },
291
- "fallback": ""
292
- },
293
- {
294
- "id": "GaugeChart:date-fns-tz",
295
- "name": "date-fns-tz",
296
- "version": "3.2.0",
297
- "singleton": true,
298
- "requiredVersion": "^3.2.0",
299
- "assets": {
300
- "js": {
301
- "async": [],
302
- "sync": [
303
- "__mf/js/async/978.8aa2a024.js"
241
+ "__mf/js/async/458.501ed0da.js",
242
+ "__mf/js/async/77.c33fcfb5.js"
304
243
  ]
305
244
  },
306
245
  "css": {
@@ -319,26 +258,21 @@
319
258
  "assets": {
320
259
  "js": {
321
260
  "sync": [
322
- "__mf/js/async/403.9db35877.js",
323
- "__mf/js/async/823.488b0ae9.js",
324
- "__mf/js/async/172.afec864d.js",
325
- "__mf/js/async/756.cbb57779.js",
326
- "__mf/js/async/__federation_expose_GaugeChart.b9c57db4.js"
261
+ "__mf/js/async/373.0403e3b1.js",
262
+ "__mf/js/async/208.a09e3946.js",
263
+ "__mf/js/async/__federation_expose_GaugeChart.1812e964.js"
327
264
  ],
328
265
  "async": [
329
- "__mf/js/async/588.f25e2591.js",
330
- "__mf/js/async/71.57cf30f3.js",
331
- "__mf/js/async/700.e028a93e.js",
332
- "__mf/js/async/410.4043d582.js",
333
- "__mf/js/async/lib-router.f8568e8a.js",
334
- "__mf/js/async/356.c7cf4f79.js",
335
- "__mf/js/async/177.2e554778.js"
266
+ "__mf/js/async/710.23542577.js",
267
+ "__mf/js/async/663.97d3fd12.js",
268
+ "__mf/js/async/lib-router.005da842.js",
269
+ "__mf/js/async/356.d85a4e2e.js"
336
270
  ]
337
271
  },
338
272
  "css": {
339
273
  "sync": [],
340
274
  "async": [
341
- "__mf/css/async/187.85c2cbf6.css"
275
+ "__mf/css/async/244.85c2cbf6.css"
342
276
  ]
343
277
  }
344
278
  },