@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.d.mts +26 -26
- package/dist/index.d.ts +26 -26
- package/dist/index.js +11 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -7
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
|
-
|
|
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
|
-
|
|
330
|
+
this.listeners.add(callback);
|
|
331
|
+
if (!this.hasWarnedListenerCount && this.listeners.size > 500) {
|
|
332
|
+
this.hasWarnedListenerCount = true;
|
|
331
333
|
console.warn(
|
|
332
|
-
`ThemeSettingsStore:
|
|
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)
|
|
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)
|
|
356
|
+
if (this.isDestroyed) {
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
356
359
|
this.listeners.clear();
|
|
357
360
|
this.isDestroyed = true;
|
|
358
361
|
if (isBrowser && window.__weaverseThemeSettingsStore === this) {
|