@deck.gl/widgets 9.2.6 → 9.2.7

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.
package/dist/dist.dev.js CHANGED
@@ -2648,13 +2648,11 @@ var __exports__ = (() => {
2648
2648
  };
2649
2649
  this._formatters = { ...DEFAULT_FORMATTERS };
2650
2650
  this._resetOnUpdate = { ...this.props.resetOnUpdate };
2651
- this._stats = this.props.stats;
2652
2651
  this.setProps(props);
2653
2652
  }
2654
2653
  setProps(props) {
2655
2654
  this.placement = props.placement ?? this.placement;
2656
2655
  this.viewId = props.viewId ?? this.viewId;
2657
- this._stats = this._getStats();
2658
2656
  if (props.formatters) {
2659
2657
  for (const name in props.formatters) {
2660
2658
  const f4 = props.formatters[name];
@@ -2667,17 +2665,16 @@ var __exports__ = (() => {
2667
2665
  super.setProps(props);
2668
2666
  }
2669
2667
  onAdd() {
2670
- this._stats = this._getStats();
2671
2668
  this.updateHTML();
2672
2669
  }
2673
2670
  onRenderHTML(rootElement) {
2674
- const stats = this._stats;
2671
+ const stats = this._getStats();
2675
2672
  const collapsed = this.collapsed;
2676
- const title = this.props.title || stats?.id || "Stats";
2673
+ const title = this.props.title || ("id" in stats ? stats.id : null) || "Stats";
2677
2674
  const items = [];
2678
2675
  if (!collapsed && stats) {
2679
2676
  stats.forEach((stat) => {
2680
- const lines = this._getLines(stat);
2677
+ const lines = this._getLines(stat).split("\n");
2681
2678
  if (this._resetOnUpdate && this._resetOnUpdate[stat.name]) {
2682
2679
  stat.reset();
2683
2680
  }
@@ -2711,20 +2708,20 @@ var __exports__ = (() => {
2711
2708
  onRedraw() {
2712
2709
  const framesPerUpdate = Math.max(1, this.props.framesPerUpdate || 1);
2713
2710
  if (this._counter++ % framesPerUpdate === 0) {
2714
- this._stats = this._getStats();
2715
2711
  this.updateHTML();
2716
2712
  }
2717
2713
  }
2718
2714
  _getStats() {
2719
2715
  switch (this.props.type) {
2720
2716
  case "deck":
2721
- return this.deck?.stats;
2717
+ const metrics = this.deck?.metrics ?? {};
2718
+ return Object.entries(metrics);
2722
2719
  case "luma":
2723
2720
  return Array.from(import_core21.luma.stats.stats.values())[0];
2724
2721
  case "device":
2725
2722
  const device = this.deck?.device;
2726
2723
  const stats = device?.statsManager.stats.values();
2727
- return stats ? Array.from(stats)[0] : void 0;
2724
+ return stats ? Array.from(stats)[0] : [];
2728
2725
  case "custom":
2729
2726
  return this.props.stats;
2730
2727
  default:
@@ -2732,8 +2729,13 @@ var __exports__ = (() => {
2732
2729
  }
2733
2730
  }
2734
2731
  _getLines(stat) {
2735
- const formatter = this._formatters[stat.name] || this._formatters[stat.type || ""] || DEFAULT_COUNT_FORMATTER;
2736
- return formatter(stat).split("\n");
2732
+ if ("count" in stat) {
2733
+ const formatter = this._formatters[stat.name] || this._formatters[stat.type || ""] || DEFAULT_COUNT_FORMATTER;
2734
+ return formatter(stat);
2735
+ }
2736
+ const [key, value] = stat;
2737
+ const formattedValue = key.endsWith("Memory") ? formatMemory(value) : key.includes("Time") ? formatTime(value) : `${value.toFixed(2)}`;
2738
+ return `${key}: ${formattedValue}`;
2737
2739
  }
2738
2740
  };
2739
2741
  StatsWidget.defaultProps = {
package/dist/index.cjs CHANGED
@@ -1748,13 +1748,11 @@ var StatsWidget = class extends import_core19.Widget {
1748
1748
  };
1749
1749
  this._formatters = { ...DEFAULT_FORMATTERS };
1750
1750
  this._resetOnUpdate = { ...this.props.resetOnUpdate };
1751
- this._stats = this.props.stats;
1752
1751
  this.setProps(props);
1753
1752
  }
1754
1753
  setProps(props) {
1755
1754
  this.placement = props.placement ?? this.placement;
1756
1755
  this.viewId = props.viewId ?? this.viewId;
1757
- this._stats = this._getStats();
1758
1756
  if (props.formatters) {
1759
1757
  for (const name in props.formatters) {
1760
1758
  const f = props.formatters[name];
@@ -1767,17 +1765,16 @@ var StatsWidget = class extends import_core19.Widget {
1767
1765
  super.setProps(props);
1768
1766
  }
1769
1767
  onAdd() {
1770
- this._stats = this._getStats();
1771
1768
  this.updateHTML();
1772
1769
  }
1773
1770
  onRenderHTML(rootElement) {
1774
- const stats = this._stats;
1771
+ const stats = this._getStats();
1775
1772
  const collapsed = this.collapsed;
1776
- const title = this.props.title || (stats == null ? void 0 : stats.id) || "Stats";
1773
+ const title = this.props.title || ("id" in stats ? stats.id : null) || "Stats";
1777
1774
  const items = [];
1778
1775
  if (!collapsed && stats) {
1779
1776
  stats.forEach((stat) => {
1780
- const lines = this._getLines(stat);
1777
+ const lines = this._getLines(stat).split("\n");
1781
1778
  if (this._resetOnUpdate && this._resetOnUpdate[stat.name]) {
1782
1779
  stat.reset();
1783
1780
  }
@@ -1791,7 +1788,6 @@ var StatsWidget = class extends import_core19.Widget {
1791
1788
  onRedraw() {
1792
1789
  const framesPerUpdate = Math.max(1, this.props.framesPerUpdate || 1);
1793
1790
  if (this._counter++ % framesPerUpdate === 0) {
1794
- this._stats = this._getStats();
1795
1791
  this.updateHTML();
1796
1792
  }
1797
1793
  }
@@ -1799,13 +1795,14 @@ var StatsWidget = class extends import_core19.Widget {
1799
1795
  var _a, _b;
1800
1796
  switch (this.props.type) {
1801
1797
  case "deck":
1802
- return (_a = this.deck) == null ? void 0 : _a.stats;
1798
+ const metrics = ((_a = this.deck) == null ? void 0 : _a.metrics) ?? {};
1799
+ return Object.entries(metrics);
1803
1800
  case "luma":
1804
1801
  return Array.from(import_core20.luma.stats.stats.values())[0];
1805
1802
  case "device":
1806
1803
  const device = (_b = this.deck) == null ? void 0 : _b.device;
1807
1804
  const stats = device == null ? void 0 : device.statsManager.stats.values();
1808
- return stats ? Array.from(stats)[0] : void 0;
1805
+ return stats ? Array.from(stats)[0] : [];
1809
1806
  case "custom":
1810
1807
  return this.props.stats;
1811
1808
  default:
@@ -1813,8 +1810,13 @@ var StatsWidget = class extends import_core19.Widget {
1813
1810
  }
1814
1811
  }
1815
1812
  _getLines(stat) {
1816
- const formatter = this._formatters[stat.name] || this._formatters[stat.type || ""] || DEFAULT_COUNT_FORMATTER;
1817
- return formatter(stat).split("\n");
1813
+ if ("count" in stat) {
1814
+ const formatter = this._formatters[stat.name] || this._formatters[stat.type || ""] || DEFAULT_COUNT_FORMATTER;
1815
+ return formatter(stat);
1816
+ }
1817
+ const [key, value] = stat;
1818
+ const formattedValue = key.endsWith("Memory") ? formatMemory(value) : key.includes("Time") ? formatTime(value) : `${value.toFixed(2)}`;
1819
+ return `${key}: ${formattedValue}`;
1818
1820
  }
1819
1821
  };
1820
1822
  StatsWidget.defaultProps = {