myio-js-library 0.1.83 → 0.1.85

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
@@ -1913,6 +1913,8 @@ init_template_card();
1913
1913
  // src/components/SelectionStore.js
1914
1914
  var MyIOSelectionStoreClass = class {
1915
1915
  constructor() {
1916
+ console.log("[SelectionStore] \u{1F3D7}\uFE0F NEW INSTANCE CREATED at:", (/* @__PURE__ */ new Date()).toISOString());
1917
+ console.trace("[SelectionStore] Constructor called from:");
1916
1918
  this.state = { selectedDevice: null };
1917
1919
  this.selectedIds = /* @__PURE__ */ new Set();
1918
1920
  this.entities = /* @__PURE__ */ new Map();
@@ -2058,11 +2060,17 @@ var MyIOSelectionStoreClass = class {
2058
2060
  }
2059
2061
  // Event System
2060
2062
  on(event, callback) {
2061
- if (typeof event !== "string" || typeof callback !== "function") return;
2063
+ console.log(`[SelectionStore] \u{1F4DD} Registering listener for event: ${event}`);
2064
+ if (typeof event !== "string" || typeof callback !== "function") {
2065
+ console.error(`[SelectionStore] \u274C Invalid registration: event=${typeof event}, callback=${typeof callback}`);
2066
+ return;
2067
+ }
2062
2068
  if (!this.eventListeners.has(event)) {
2069
+ console.log(`[SelectionStore] \u{1F195} Creating new listener array for: ${event}`);
2063
2070
  this.eventListeners.set(event, []);
2064
2071
  }
2065
2072
  this.eventListeners.get(event).push(callback);
2073
+ console.log(`[SelectionStore] \u2705 Listener registered! Total for ${event}: ${this.eventListeners.get(event).length}`);
2066
2074
  }
2067
2075
  off(event, callback) {
2068
2076
  if (!this.eventListeners.has(event)) return;
@@ -2170,12 +2178,22 @@ var MyIOSelectionStoreClass = class {
2170
2178
  });
2171
2179
  }
2172
2180
  _emit(event, data) {
2173
- if (!this.eventListeners.has(event)) return;
2174
- this.eventListeners.get(event).forEach((callback) => {
2181
+ console.log(`[SelectionStore] \u{1F514} Emitting event: ${event}, listeners: ${this.eventListeners.get(event)?.length || 0}`);
2182
+ console.log(`[SelectionStore] \u{1F4E6} Event data:`, data);
2183
+ if (!this.eventListeners.has(event)) {
2184
+ console.warn(`[SelectionStore] \u26A0\uFE0F No listener map for event: ${event}`);
2185
+ return;
2186
+ }
2187
+ const listeners = this.eventListeners.get(event);
2188
+ if (listeners.length === 0) {
2189
+ console.warn(`[SelectionStore] \u26A0\uFE0F No listeners registered for event: ${event}`);
2190
+ }
2191
+ listeners.forEach((callback, index) => {
2192
+ console.log(`[SelectionStore] \u{1F3AF} Calling listener #${index} for ${event}`);
2175
2193
  try {
2176
2194
  callback(data);
2177
2195
  } catch (error) {
2178
- console.error(`Error in ${event} listener:`, error);
2196
+ console.error(`[SelectionStore] \u274C Error in ${event} listener #${index}:`, error);
2179
2197
  }
2180
2198
  });
2181
2199
  }
@@ -2224,10 +2242,19 @@ var MyIOSelectionStoreClass = class {
2224
2242
  return data;
2225
2243
  }
2226
2244
  };
2227
- var MyIOSelectionStore = new MyIOSelectionStoreClass();
2245
+ var MyIOSelectionStore;
2228
2246
  if (typeof globalThis !== "undefined" && typeof globalThis.window !== "undefined") {
2229
- globalThis.window.MyIOSelectionStore = MyIOSelectionStore;
2247
+ if (globalThis.window.MyIOSelectionStore) {
2248
+ console.log("[SelectionStore] \u{1F504} REUSING existing global instance");
2249
+ MyIOSelectionStore = globalThis.window.MyIOSelectionStore;
2250
+ } else {
2251
+ console.log("[SelectionStore] \u{1F195} Creating new global singleton instance");
2252
+ MyIOSelectionStore = new MyIOSelectionStoreClass();
2253
+ globalThis.window.MyIOSelectionStore = MyIOSelectionStore;
2254
+ }
2230
2255
  globalThis.window.MyIOSelectionStoreClass = MyIOSelectionStoreClass;
2256
+ } else {
2257
+ MyIOSelectionStore = new MyIOSelectionStoreClass();
2231
2258
  }
2232
2259
  if (typeof module !== "undefined" && module.exports) {
2233
2260
  module.exports = { MyIOSelectionStore, MyIOSelectionStoreClass };
package/dist/index.d.cts CHANGED
@@ -767,7 +767,7 @@ declare function renderCardComponentHeadOffice(containerEl: any, params: any): {
767
767
  getRoot(): HTMLDivElement;
768
768
  };
769
769
 
770
- declare const MyIOSelectionStore: MyIOSelectionStoreClass;
770
+ declare let MyIOSelectionStore: any;
771
771
  /**
772
772
  * MYIO SelectionStore Component
773
773
  * Global singleton for managing selection state, multi-unit totals, time-series data, and analytics
package/dist/index.js CHANGED
@@ -1825,6 +1825,8 @@ init_template_card();
1825
1825
  // src/components/SelectionStore.js
1826
1826
  var MyIOSelectionStoreClass = class {
1827
1827
  constructor() {
1828
+ console.log("[SelectionStore] \u{1F3D7}\uFE0F NEW INSTANCE CREATED at:", (/* @__PURE__ */ new Date()).toISOString());
1829
+ console.trace("[SelectionStore] Constructor called from:");
1828
1830
  this.state = { selectedDevice: null };
1829
1831
  this.selectedIds = /* @__PURE__ */ new Set();
1830
1832
  this.entities = /* @__PURE__ */ new Map();
@@ -1970,11 +1972,17 @@ var MyIOSelectionStoreClass = class {
1970
1972
  }
1971
1973
  // Event System
1972
1974
  on(event, callback) {
1973
- if (typeof event !== "string" || typeof callback !== "function") return;
1975
+ console.log(`[SelectionStore] \u{1F4DD} Registering listener for event: ${event}`);
1976
+ if (typeof event !== "string" || typeof callback !== "function") {
1977
+ console.error(`[SelectionStore] \u274C Invalid registration: event=${typeof event}, callback=${typeof callback}`);
1978
+ return;
1979
+ }
1974
1980
  if (!this.eventListeners.has(event)) {
1981
+ console.log(`[SelectionStore] \u{1F195} Creating new listener array for: ${event}`);
1975
1982
  this.eventListeners.set(event, []);
1976
1983
  }
1977
1984
  this.eventListeners.get(event).push(callback);
1985
+ console.log(`[SelectionStore] \u2705 Listener registered! Total for ${event}: ${this.eventListeners.get(event).length}`);
1978
1986
  }
1979
1987
  off(event, callback) {
1980
1988
  if (!this.eventListeners.has(event)) return;
@@ -2082,12 +2090,22 @@ var MyIOSelectionStoreClass = class {
2082
2090
  });
2083
2091
  }
2084
2092
  _emit(event, data) {
2085
- if (!this.eventListeners.has(event)) return;
2086
- this.eventListeners.get(event).forEach((callback) => {
2093
+ console.log(`[SelectionStore] \u{1F514} Emitting event: ${event}, listeners: ${this.eventListeners.get(event)?.length || 0}`);
2094
+ console.log(`[SelectionStore] \u{1F4E6} Event data:`, data);
2095
+ if (!this.eventListeners.has(event)) {
2096
+ console.warn(`[SelectionStore] \u26A0\uFE0F No listener map for event: ${event}`);
2097
+ return;
2098
+ }
2099
+ const listeners = this.eventListeners.get(event);
2100
+ if (listeners.length === 0) {
2101
+ console.warn(`[SelectionStore] \u26A0\uFE0F No listeners registered for event: ${event}`);
2102
+ }
2103
+ listeners.forEach((callback, index) => {
2104
+ console.log(`[SelectionStore] \u{1F3AF} Calling listener #${index} for ${event}`);
2087
2105
  try {
2088
2106
  callback(data);
2089
2107
  } catch (error) {
2090
- console.error(`Error in ${event} listener:`, error);
2108
+ console.error(`[SelectionStore] \u274C Error in ${event} listener #${index}:`, error);
2091
2109
  }
2092
2110
  });
2093
2111
  }
@@ -2136,10 +2154,19 @@ var MyIOSelectionStoreClass = class {
2136
2154
  return data;
2137
2155
  }
2138
2156
  };
2139
- var MyIOSelectionStore = new MyIOSelectionStoreClass();
2157
+ var MyIOSelectionStore;
2140
2158
  if (typeof globalThis !== "undefined" && typeof globalThis.window !== "undefined") {
2141
- globalThis.window.MyIOSelectionStore = MyIOSelectionStore;
2159
+ if (globalThis.window.MyIOSelectionStore) {
2160
+ console.log("[SelectionStore] \u{1F504} REUSING existing global instance");
2161
+ MyIOSelectionStore = globalThis.window.MyIOSelectionStore;
2162
+ } else {
2163
+ console.log("[SelectionStore] \u{1F195} Creating new global singleton instance");
2164
+ MyIOSelectionStore = new MyIOSelectionStoreClass();
2165
+ globalThis.window.MyIOSelectionStore = MyIOSelectionStore;
2166
+ }
2142
2167
  globalThis.window.MyIOSelectionStoreClass = MyIOSelectionStoreClass;
2168
+ } else {
2169
+ MyIOSelectionStore = new MyIOSelectionStoreClass();
2143
2170
  }
2144
2171
  if (typeof module !== "undefined" && module.exports) {
2145
2172
  module.exports = { MyIOSelectionStore, MyIOSelectionStoreClass };
@@ -1831,6 +1831,8 @@
1831
1831
  // src/components/SelectionStore.js
1832
1832
  var MyIOSelectionStoreClass = class {
1833
1833
  constructor() {
1834
+ console.log("[SelectionStore] \u{1F3D7}\uFE0F NEW INSTANCE CREATED at:", (/* @__PURE__ */ new Date()).toISOString());
1835
+ console.trace("[SelectionStore] Constructor called from:");
1834
1836
  this.state = { selectedDevice: null };
1835
1837
  this.selectedIds = /* @__PURE__ */ new Set();
1836
1838
  this.entities = /* @__PURE__ */ new Map();
@@ -1976,11 +1978,17 @@
1976
1978
  }
1977
1979
  // Event System
1978
1980
  on(event, callback) {
1979
- if (typeof event !== "string" || typeof callback !== "function") return;
1981
+ console.log(`[SelectionStore] \u{1F4DD} Registering listener for event: ${event}`);
1982
+ if (typeof event !== "string" || typeof callback !== "function") {
1983
+ console.error(`[SelectionStore] \u274C Invalid registration: event=${typeof event}, callback=${typeof callback}`);
1984
+ return;
1985
+ }
1980
1986
  if (!this.eventListeners.has(event)) {
1987
+ console.log(`[SelectionStore] \u{1F195} Creating new listener array for: ${event}`);
1981
1988
  this.eventListeners.set(event, []);
1982
1989
  }
1983
1990
  this.eventListeners.get(event).push(callback);
1991
+ console.log(`[SelectionStore] \u2705 Listener registered! Total for ${event}: ${this.eventListeners.get(event).length}`);
1984
1992
  }
1985
1993
  off(event, callback) {
1986
1994
  if (!this.eventListeners.has(event)) return;
@@ -2088,12 +2096,22 @@
2088
2096
  });
2089
2097
  }
2090
2098
  _emit(event, data) {
2091
- if (!this.eventListeners.has(event)) return;
2092
- this.eventListeners.get(event).forEach((callback) => {
2099
+ console.log(`[SelectionStore] \u{1F514} Emitting event: ${event}, listeners: ${this.eventListeners.get(event)?.length || 0}`);
2100
+ console.log(`[SelectionStore] \u{1F4E6} Event data:`, data);
2101
+ if (!this.eventListeners.has(event)) {
2102
+ console.warn(`[SelectionStore] \u26A0\uFE0F No listener map for event: ${event}`);
2103
+ return;
2104
+ }
2105
+ const listeners = this.eventListeners.get(event);
2106
+ if (listeners.length === 0) {
2107
+ console.warn(`[SelectionStore] \u26A0\uFE0F No listeners registered for event: ${event}`);
2108
+ }
2109
+ listeners.forEach((callback, index) => {
2110
+ console.log(`[SelectionStore] \u{1F3AF} Calling listener #${index} for ${event}`);
2093
2111
  try {
2094
2112
  callback(data);
2095
2113
  } catch (error) {
2096
- console.error(`Error in ${event} listener:`, error);
2114
+ console.error(`[SelectionStore] \u274C Error in ${event} listener #${index}:`, error);
2097
2115
  }
2098
2116
  });
2099
2117
  }
@@ -2142,13 +2160,22 @@
2142
2160
  return data;
2143
2161
  }
2144
2162
  };
2145
- var MyIOSelectionStore = new MyIOSelectionStoreClass();
2163
+ exports.MyIOSelectionStore = void 0;
2146
2164
  if (typeof globalThis !== "undefined" && typeof globalThis.window !== "undefined") {
2147
- globalThis.window.MyIOSelectionStore = MyIOSelectionStore;
2165
+ if (globalThis.window.MyIOSelectionStore) {
2166
+ console.log("[SelectionStore] \u{1F504} REUSING existing global instance");
2167
+ exports.MyIOSelectionStore = globalThis.window.MyIOSelectionStore;
2168
+ } else {
2169
+ console.log("[SelectionStore] \u{1F195} Creating new global singleton instance");
2170
+ exports.MyIOSelectionStore = new MyIOSelectionStoreClass();
2171
+ globalThis.window.MyIOSelectionStore = exports.MyIOSelectionStore;
2172
+ }
2148
2173
  globalThis.window.MyIOSelectionStoreClass = MyIOSelectionStoreClass;
2174
+ } else {
2175
+ exports.MyIOSelectionStore = new MyIOSelectionStoreClass();
2149
2176
  }
2150
2177
  if (typeof module !== "undefined" && module.exports) {
2151
- module.exports = { MyIOSelectionStore, MyIOSelectionStoreClass };
2178
+ module.exports = { MyIOSelectionStore: exports.MyIOSelectionStore, MyIOSelectionStoreClass };
2152
2179
  }
2153
2180
 
2154
2181
  // src/components/DraggableCard.js
@@ -2667,8 +2694,8 @@
2667
2694
  unit: determineUnit(deviceType),
2668
2695
  status: mapDeviceStatusToCardStatus(deviceStatus)
2669
2696
  };
2670
- if (enableSelection && MyIOSelectionStore) {
2671
- MyIOSelectionStore.registerEntity(cardEntity);
2697
+ if (enableSelection && exports.MyIOSelectionStore) {
2698
+ exports.MyIOSelectionStore.registerEntity(cardEntity);
2672
2699
  }
2673
2700
  const container = document.createElement("div");
2674
2701
  container.className = "myio-enhanced-card-container";
@@ -3426,14 +3453,14 @@
3426
3453
  if (enhancedCardElement && actionsContainer.children.length > 0) {
3427
3454
  enhancedCardElement.insertBefore(actionsContainer, enhancedCardElement.firstChild);
3428
3455
  }
3429
- if (enableSelection && MyIOSelectionStore) {
3456
+ if (enableSelection && exports.MyIOSelectionStore) {
3430
3457
  const checkbox = enhancedCardElement.querySelector(".card-checkbox");
3431
3458
  if (checkbox) {
3432
3459
  checkbox.addEventListener("change", (e) => {
3433
3460
  e.stopPropagation();
3434
3461
  if (e.target.checked) {
3435
- const currentCount = MyIOSelectionStore.getSelectedEntities().length;
3436
- const selectedEntityes = MyIOSelectionStore.getSelectedEntities();
3462
+ const currentCount = exports.MyIOSelectionStore.getSelectedEntities().length;
3463
+ const selectedEntityes = exports.MyIOSelectionStore.getSelectedEntities();
3437
3464
  console.log("selectedEntityes", selectedEntityes);
3438
3465
  const isTryingToAdd = e.target.checked;
3439
3466
  if (isTryingToAdd && currentCount >= 6) {
@@ -3465,14 +3492,14 @@
3465
3492
  }
3466
3493
  enhancedCardElement.classList.toggle("selected", isSelected);
3467
3494
  };
3468
- MyIOSelectionStore.on("selection:change", handleSelectionChange);
3469
- const isInitiallySelected = MyIOSelectionStore.isSelected(entityId);
3495
+ exports.MyIOSelectionStore.on("selection:change", handleSelectionChange);
3496
+ const isInitiallySelected = exports.MyIOSelectionStore.isSelected(entityId);
3470
3497
  if (checkbox) {
3471
3498
  checkbox.checked = isInitiallySelected;
3472
3499
  }
3473
3500
  enhancedCardElement.classList.toggle("selected", isInitiallySelected);
3474
3501
  container._cleanup = () => {
3475
- MyIOSelectionStore.off("selection:change", handleSelectionChange);
3502
+ exports.MyIOSelectionStore.off("selection:change", handleSelectionChange);
3476
3503
  };
3477
3504
  }
3478
3505
  if (enableDragDrop) {
@@ -3481,8 +3508,8 @@
3481
3508
  e.dataTransfer.setData("application/json", JSON.stringify(entityObject));
3482
3509
  e.dataTransfer.setData("text/myio-name", entityObject.labelOrName);
3483
3510
  e.dataTransfer.effectAllowed = "copy";
3484
- if (MyIOSelectionStore) {
3485
- MyIOSelectionStore.startDrag(entityId);
3511
+ if (exports.MyIOSelectionStore) {
3512
+ exports.MyIOSelectionStore.startDrag(entityId);
3486
3513
  }
3487
3514
  });
3488
3515
  enhancedCardElement.addEventListener("dragend", () => {
@@ -3537,7 +3564,7 @@
3537
3564
  return renderCardComponent3(options);
3538
3565
  }
3539
3566
  function renderCardComponent2(options) {
3540
- const useNewComponents = options.useNewComponents !== false && typeof MyIOSelectionStore !== "undefined" && typeof MyIODraggableCard !== "undefined";
3567
+ const useNewComponents = options.useNewComponents !== false && typeof exports.MyIOSelectionStore !== "undefined" && typeof MyIODraggableCard !== "undefined";
3541
3568
  if (useNewComponents) {
3542
3569
  return renderCardComponentV2(options);
3543
3570
  } else {
@@ -12329,7 +12356,6 @@
12329
12356
  exports.DeviceStatusType = DeviceStatusType;
12330
12357
  exports.MyIOChartModal = MyIOChartModal;
12331
12358
  exports.MyIODraggableCard = MyIODraggableCard;
12332
- exports.MyIOSelectionStore = MyIOSelectionStore;
12333
12359
  exports.MyIOSelectionStoreClass = MyIOSelectionStoreClass;
12334
12360
  exports.addDetectionContext = addDetectionContext;
12335
12361
  exports.addNamespace = addNamespace;