myio-js-library 0.1.526 → 0.1.527

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/index.cjs CHANGED
@@ -768,7 +768,7 @@ module.exports = __toCommonJS(src_exports);
768
768
  // package.json
769
769
  var package_default = {
770
770
  name: "myio-js-library",
771
- version: "0.1.526",
771
+ version: "0.1.527",
772
772
  description: "A clean, standalone JS SDK for MYIO projects",
773
773
  license: "MIT",
774
774
  repository: "github:gh-myio/myio-js-library",
@@ -86061,10 +86061,17 @@ function _applyTheme(root) {
86061
86061
  }
86062
86062
  function _formatValue(value, domain) {
86063
86063
  const cfg = DOMAIN_CFG[domain] || DOMAIN_CFG.energy;
86064
- const dec = domain === "temperature" ? 1 : 2;
86064
+ const U = typeof window !== "undefined" ? window.MyIOUtils : void 0;
86065
+ if (domain === "energy" && typeof U?.formatEnergyWithSettings === "function") {
86066
+ return U.formatEnergyWithSettings(value);
86067
+ }
86068
+ if (domain === "water" && typeof U?.formatWaterWithSettings === "function") {
86069
+ return U.formatWaterWithSettings(value);
86070
+ }
86071
+ const dec = domain === "temperature" ? 1 : 3;
86065
86072
  const ptBR = (v, d) => v.toLocaleString("pt-BR", { minimumFractionDigits: d, maximumFractionDigits: d });
86066
86073
  if (cfg.threshold && cfg.unitLarge && Math.abs(value) >= cfg.threshold) {
86067
- return `${ptBR(value / cfg.threshold, 2)} ${cfg.unitLarge}`;
86074
+ return `${ptBR(value / cfg.threshold, 3)} ${cfg.unitLarge}`;
86068
86075
  }
86069
86076
  return `${ptBR(value, dec)} ${cfg.unit}`;
86070
86077
  }
@@ -86199,7 +86206,7 @@ async function _fetchSeriesTotals(domain, boundaries, viewGran, fetchGran) {
86199
86206
  async function _fetchDayData(domain) {
86200
86207
  const boundaries = _buildDayBoundaries(_periodStart, _periodEnd);
86201
86208
  const labels = boundaries.map((b) => b.label);
86202
- const totals = await _fetchSeriesTotals(domain, boundaries, "1d", "1d") ?? await _fetchTotalsThrottled(domain, boundaries, "1d");
86209
+ const totals = await _fetchSeriesTotals(domain, boundaries, "1h", "1h") ?? await _fetchTotalsThrottled(domain, boundaries, "1d");
86203
86210
  return { labels, totals };
86204
86211
  }
86205
86212
  async function _fetchHourData(domain, dateISO) {
@@ -86247,7 +86254,9 @@ async function _fetchPrevYearTotals(domain, gran, boundaries) {
86247
86254
  pe.setFullYear(pe.getFullYear() - 1);
86248
86255
  return { ...b, startTs: ps.getTime(), endTs: pe.getTime() };
86249
86256
  });
86250
- const viaSeries = await _fetchSeriesTotals(domain, prevBoundaries, gran, gran === "1M" ? "1d" : gran);
86257
+ const seriesViewGran = gran === "1d" ? "1h" : gran;
86258
+ const seriesFetchGran = gran === "1M" ? "1d" : gran === "1d" ? "1h" : gran;
86259
+ const viaSeries = await _fetchSeriesTotals(domain, prevBoundaries, seriesViewGran, seriesFetchGran);
86251
86260
  if (viaSeries) return viaSeries;
86252
86261
  const fetchFn = _options.fetchConsumption;
86253
86262
  const totals = new Array(prevBoundaries.length).fill(0);
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  // package.json
11
11
  var package_default = {
12
12
  name: "myio-js-library",
13
- version: "0.1.526",
13
+ version: "0.1.527",
14
14
  description: "A clean, standalone JS SDK for MYIO projects",
15
15
  license: "MIT",
16
16
  repository: "github:gh-myio/myio-js-library",
@@ -83379,10 +83379,17 @@ function _applyTheme(root) {
83379
83379
  }
83380
83380
  function _formatValue(value, domain) {
83381
83381
  const cfg = DOMAIN_CFG[domain] || DOMAIN_CFG.energy;
83382
- const dec = domain === "temperature" ? 1 : 2;
83382
+ const U = typeof window !== "undefined" ? window.MyIOUtils : void 0;
83383
+ if (domain === "energy" && typeof U?.formatEnergyWithSettings === "function") {
83384
+ return U.formatEnergyWithSettings(value);
83385
+ }
83386
+ if (domain === "water" && typeof U?.formatWaterWithSettings === "function") {
83387
+ return U.formatWaterWithSettings(value);
83388
+ }
83389
+ const dec = domain === "temperature" ? 1 : 3;
83383
83390
  const ptBR = (v, d) => v.toLocaleString("pt-BR", { minimumFractionDigits: d, maximumFractionDigits: d });
83384
83391
  if (cfg.threshold && cfg.unitLarge && Math.abs(value) >= cfg.threshold) {
83385
- return `${ptBR(value / cfg.threshold, 2)} ${cfg.unitLarge}`;
83392
+ return `${ptBR(value / cfg.threshold, 3)} ${cfg.unitLarge}`;
83386
83393
  }
83387
83394
  return `${ptBR(value, dec)} ${cfg.unit}`;
83388
83395
  }
@@ -83517,7 +83524,7 @@ async function _fetchSeriesTotals(domain, boundaries, viewGran, fetchGran) {
83517
83524
  async function _fetchDayData(domain) {
83518
83525
  const boundaries = _buildDayBoundaries(_periodStart, _periodEnd);
83519
83526
  const labels = boundaries.map((b) => b.label);
83520
- const totals = await _fetchSeriesTotals(domain, boundaries, "1d", "1d") ?? await _fetchTotalsThrottled(domain, boundaries, "1d");
83527
+ const totals = await _fetchSeriesTotals(domain, boundaries, "1h", "1h") ?? await _fetchTotalsThrottled(domain, boundaries, "1d");
83521
83528
  return { labels, totals };
83522
83529
  }
83523
83530
  async function _fetchHourData(domain, dateISO) {
@@ -83565,7 +83572,9 @@ async function _fetchPrevYearTotals(domain, gran, boundaries) {
83565
83572
  pe.setFullYear(pe.getFullYear() - 1);
83566
83573
  return { ...b, startTs: ps.getTime(), endTs: pe.getTime() };
83567
83574
  });
83568
- const viaSeries = await _fetchSeriesTotals(domain, prevBoundaries, gran, gran === "1M" ? "1d" : gran);
83575
+ const seriesViewGran = gran === "1d" ? "1h" : gran;
83576
+ const seriesFetchGran = gran === "1M" ? "1d" : gran === "1d" ? "1h" : gran;
83577
+ const viaSeries = await _fetchSeriesTotals(domain, prevBoundaries, seriesViewGran, seriesFetchGran);
83569
83578
  if (viaSeries) return viaSeries;
83570
83579
  const fetchFn = _options.fetchConsumption;
83571
83580
  const totals = new Array(prevBoundaries.length).fill(0);
@@ -5455,7 +5455,7 @@
5455
5455
 
5456
5456
  // package.json
5457
5457
  var package_default = {
5458
- version: "0.1.526"};
5458
+ version: "0.1.527"};
5459
5459
 
5460
5460
  // src/utils/format/energy.ts
5461
5461
  function formatPower(value, decimals = 2) {
@@ -88504,10 +88504,17 @@ ${state5.year}-03-15T08,15`)}">${esc3(state5.csv)}</textarea>
88504
88504
  }
88505
88505
  function _formatValue(value, domain) {
88506
88506
  const cfg = DOMAIN_CFG[domain] || DOMAIN_CFG.energy;
88507
- const dec = domain === "temperature" ? 1 : 2;
88507
+ const U = typeof window !== "undefined" ? window.MyIOUtils : void 0;
88508
+ if (domain === "energy" && typeof U?.formatEnergyWithSettings === "function") {
88509
+ return U.formatEnergyWithSettings(value);
88510
+ }
88511
+ if (domain === "water" && typeof U?.formatWaterWithSettings === "function") {
88512
+ return U.formatWaterWithSettings(value);
88513
+ }
88514
+ const dec = domain === "temperature" ? 1 : 3;
88508
88515
  const ptBR = (v, d) => v.toLocaleString("pt-BR", { minimumFractionDigits: d, maximumFractionDigits: d });
88509
88516
  if (cfg.threshold && cfg.unitLarge && Math.abs(value) >= cfg.threshold) {
88510
- return `${ptBR(value / cfg.threshold, 2)} ${cfg.unitLarge}`;
88517
+ return `${ptBR(value / cfg.threshold, 3)} ${cfg.unitLarge}`;
88511
88518
  }
88512
88519
  return `${ptBR(value, dec)} ${cfg.unit}`;
88513
88520
  }
@@ -88642,7 +88649,7 @@ ${state5.year}-03-15T08,15`)}">${esc3(state5.csv)}</textarea>
88642
88649
  async function _fetchDayData(domain) {
88643
88650
  const boundaries = _buildDayBoundaries(_periodStart, _periodEnd);
88644
88651
  const labels = boundaries.map((b) => b.label);
88645
- const totals = await _fetchSeriesTotals(domain, boundaries, "1d", "1d") ?? await _fetchTotalsThrottled(domain, boundaries, "1d");
88652
+ const totals = await _fetchSeriesTotals(domain, boundaries, "1h", "1h") ?? await _fetchTotalsThrottled(domain, boundaries, "1d");
88646
88653
  return { labels, totals };
88647
88654
  }
88648
88655
  async function _fetchHourData(domain, dateISO) {
@@ -88690,7 +88697,9 @@ ${state5.year}-03-15T08,15`)}">${esc3(state5.csv)}</textarea>
88690
88697
  pe.setFullYear(pe.getFullYear() - 1);
88691
88698
  return { ...b, startTs: ps.getTime(), endTs: pe.getTime() };
88692
88699
  });
88693
- const viaSeries = await _fetchSeriesTotals(domain, prevBoundaries, gran, gran === "1M" ? "1d" : gran);
88700
+ const seriesViewGran = gran === "1d" ? "1h" : gran;
88701
+ const seriesFetchGran = gran === "1M" ? "1d" : gran === "1d" ? "1h" : gran;
88702
+ const viaSeries = await _fetchSeriesTotals(domain, prevBoundaries, seriesViewGran, seriesFetchGran);
88694
88703
  if (viaSeries) return viaSeries;
88695
88704
  const fetchFn = _options.fetchConsumption;
88696
88705
  const totals = new Array(prevBoundaries.length).fill(0);