@weaverse/hydrogen 5.9.1 → 5.9.3

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.mjs CHANGED
@@ -297,7 +297,7 @@ var ThemeSettingsStore = class {
297
297
  schema;
298
298
  publicEnv;
299
299
  listeners = /* @__PURE__ */ new Set();
300
- MAX_LISTENERS = 100;
300
+ hasWarnedListenerCount = false;
301
301
  isDestroyed = false;
302
302
  constructor(data) {
303
303
  const { theme, schema: schema2, publicEnv } = data || {};
@@ -327,20 +327,21 @@ var ThemeSettingsStore = class {
327
327
  return () => {
328
328
  };
329
329
  }
330
- if (this.listeners.size >= this.MAX_LISTENERS) {
330
+ this.listeners.add(callback);
331
+ if (!this.hasWarnedListenerCount && this.listeners.size > 500) {
332
+ this.hasWarnedListenerCount = true;
331
333
  console.warn(
332
- `ThemeSettingsStore: Maximum listeners (${this.MAX_LISTENERS}) exceeded. Possible memory leak detected.`
334
+ `ThemeSettingsStore: ${this.listeners.size} listeners detected. This may indicate a performance issue. Consider using fewer useThemeSettings() calls.`
333
335
  );
334
- return () => {
335
- };
336
336
  }
337
- this.listeners.add(callback);
338
337
  return () => {
339
338
  this.listeners.delete(callback);
340
339
  };
341
340
  };
342
341
  emit = () => {
343
- if (this.isDestroyed) return;
342
+ if (this.isDestroyed) {
343
+ return;
344
+ }
344
345
  const currentListeners = Array.from(this.listeners);
345
346
  for (const listener of currentListeners) {
346
347
  try {
@@ -352,7 +353,9 @@ var ThemeSettingsStore = class {
352
353
  };
353
354
  // Method to properly clean up the store
354
355
  destroy = () => {
355
- if (this.isDestroyed) return;
356
+ if (this.isDestroyed) {
357
+ return;
358
+ }
356
359
  this.listeners.clear();
357
360
  this.isDestroyed = true;
358
361
  if (isBrowser && window.__weaverseThemeSettingsStore === this) {