@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 CHANGED
@@ -22,7 +22,7 @@ declare class ThemeSettingsStore {
22
22
  schema?: HydrogenThemeSchema;
23
23
  publicEnv?: PublicEnv;
24
24
  private listeners;
25
- private readonly MAX_LISTENERS;
25
+ private hasWarnedListenerCount;
26
26
  private isDestroyed;
27
27
  constructor(data: WeaverseThemeData);
28
28
  updateThemeSettings: (newSettings: HydrogenThemeSettings) => void;
@@ -309,15 +309,15 @@ interface RouteLoaderArgs extends LoaderFunctionArgs {
309
309
  }
310
310
  type ComponentDataValue = string | number | boolean | undefined | null;
311
311
  interface HydrogenComponentData extends ElementData {
312
- id: string;
313
- type: string;
314
- data?: Record<string, ComponentDataValue | Record<string, unknown>>;
315
312
  children?: {
316
313
  id: string;
317
314
  }[];
318
315
  createdAt?: string;
319
- updatedAt?: string;
316
+ data?: Record<string, ComponentDataValue | Record<string, unknown>>;
320
317
  deletedAt?: string;
318
+ id: string;
319
+ type: string;
320
+ updatedAt?: string;
321
321
  }
322
322
  /**
323
323
  * Optimized: Use Zod-inferred SchemaType directly instead of extending
@@ -325,9 +325,9 @@ interface HydrogenComponentData extends ElementData {
325
325
  */
326
326
  type HydrogenComponentSchema = SchemaType;
327
327
  interface HydrogenComponentProps<L = any> extends WeaverseElement {
328
+ children?: React$1.JSX.Element[];
328
329
  className?: string;
329
330
  loaderData?: L;
330
- children?: React$1.JSX.Element[];
331
331
  }
332
332
  type WeaverseLoaderRequestInfo = {
333
333
  search: string;
@@ -366,19 +366,19 @@ type HydrogenElement = {
366
366
  };
367
367
  interface WeaverseHydrogenParams extends Omit<WeaverseCoreParams, 'ItemConstructor'> {
368
368
  data: HydrogenPageData;
369
- pageId: string;
369
+ dataContext?: Record<string, unknown> | null;
370
370
  internal: Partial<WeaverseInternal>;
371
- requestInfo: WeaverseLoaderRequestInfo;
372
- projectId: string;
373
- weaverseHost: string;
374
- weaverseApiBase: string;
375
- weaverseApiKey: string;
376
- weaverseVersion?: string;
377
371
  isDesignMode?: boolean;
378
372
  isPreviewMode?: boolean;
379
373
  isRevisionPreview?: boolean;
374
+ pageId: string;
375
+ projectId: string;
376
+ requestInfo: WeaverseLoaderRequestInfo;
380
377
  sectionType?: string;
381
- dataContext?: Record<string, unknown> | null;
378
+ weaverseApiBase: string;
379
+ weaverseApiKey: string;
380
+ weaverseHost: string;
381
+ weaverseVersion?: string;
382
382
  }
383
383
  type HydrogenComponent<T extends HydrogenComponentProps = any> = {
384
384
  default: ForwardRefExoticComponent<T> | ((props: T) => React$1.JSX.Element);
@@ -431,10 +431,10 @@ type WeaverseLoaderData = {
431
431
  pageAssignment?: HydrogenPageAssignment;
432
432
  };
433
433
  interface HydrogenPageData extends WeaverseProjectDataType {
434
+ __cacheId?: string;
434
435
  id: string;
435
- name: string;
436
436
  items: HydrogenComponentData[];
437
- __cacheId?: string;
437
+ name: string;
438
438
  [key: string]: any;
439
439
  }
440
440
  type WeaverseI18n = I18nBase & {
@@ -711,20 +711,20 @@ declare module '@shopify/remix-oxygen' {
711
711
  }
712
712
  declare module '@shopify/hydrogen' {
713
713
  interface HydrogenEnv {
714
- WEAVERSE_PROJECT_ID: string;
715
- WEAVERSE_HOST?: string;
716
- WEAVERSE_API_BASE?: string;
717
- WEAVERSE_API_KEY: string;
718
- PUBLIC_STORE_DOMAIN: string;
719
- PUBLIC_STOREFRONT_API_TOKEN: string;
720
- PUBLIC_GOOGLE_GTM_ID: string;
721
- JUDGEME_PRIVATE_API_TOKEN: string;
722
714
  CUSTOM_COLLECTION_BANNER_METAFIELD: string;
723
- METAOBJECT_COLORS_TYPE: string;
715
+ JUDGEME_PRIVATE_API_TOKEN: string;
716
+ KLAVIYO_PRIVATE_API_TOKEN: string;
724
717
  METAOBJECT_COLOR_NAME_KEY: string;
725
718
  METAOBJECT_COLOR_VALUE_KEY: string;
726
- KLAVIYO_PRIVATE_API_TOKEN: string;
719
+ METAOBJECT_COLORS_TYPE: string;
720
+ PUBLIC_GOOGLE_GTM_ID: string;
727
721
  PUBLIC_SHOPIFY_INBOX_SHOP_ID: string;
722
+ PUBLIC_STORE_DOMAIN: string;
723
+ PUBLIC_STOREFRONT_API_TOKEN: string;
724
+ WEAVERSE_API_BASE?: string;
725
+ WEAVERSE_API_KEY: string;
726
+ WEAVERSE_HOST?: string;
727
+ WEAVERSE_PROJECT_ID: string;
728
728
  }
729
729
  }
730
730
  /**
package/dist/index.d.ts CHANGED
@@ -22,7 +22,7 @@ declare class ThemeSettingsStore {
22
22
  schema?: HydrogenThemeSchema;
23
23
  publicEnv?: PublicEnv;
24
24
  private listeners;
25
- private readonly MAX_LISTENERS;
25
+ private hasWarnedListenerCount;
26
26
  private isDestroyed;
27
27
  constructor(data: WeaverseThemeData);
28
28
  updateThemeSettings: (newSettings: HydrogenThemeSettings) => void;
@@ -309,15 +309,15 @@ interface RouteLoaderArgs extends LoaderFunctionArgs {
309
309
  }
310
310
  type ComponentDataValue = string | number | boolean | undefined | null;
311
311
  interface HydrogenComponentData extends ElementData {
312
- id: string;
313
- type: string;
314
- data?: Record<string, ComponentDataValue | Record<string, unknown>>;
315
312
  children?: {
316
313
  id: string;
317
314
  }[];
318
315
  createdAt?: string;
319
- updatedAt?: string;
316
+ data?: Record<string, ComponentDataValue | Record<string, unknown>>;
320
317
  deletedAt?: string;
318
+ id: string;
319
+ type: string;
320
+ updatedAt?: string;
321
321
  }
322
322
  /**
323
323
  * Optimized: Use Zod-inferred SchemaType directly instead of extending
@@ -325,9 +325,9 @@ interface HydrogenComponentData extends ElementData {
325
325
  */
326
326
  type HydrogenComponentSchema = SchemaType;
327
327
  interface HydrogenComponentProps<L = any> extends WeaverseElement {
328
+ children?: React$1.JSX.Element[];
328
329
  className?: string;
329
330
  loaderData?: L;
330
- children?: React$1.JSX.Element[];
331
331
  }
332
332
  type WeaverseLoaderRequestInfo = {
333
333
  search: string;
@@ -366,19 +366,19 @@ type HydrogenElement = {
366
366
  };
367
367
  interface WeaverseHydrogenParams extends Omit<WeaverseCoreParams, 'ItemConstructor'> {
368
368
  data: HydrogenPageData;
369
- pageId: string;
369
+ dataContext?: Record<string, unknown> | null;
370
370
  internal: Partial<WeaverseInternal>;
371
- requestInfo: WeaverseLoaderRequestInfo;
372
- projectId: string;
373
- weaverseHost: string;
374
- weaverseApiBase: string;
375
- weaverseApiKey: string;
376
- weaverseVersion?: string;
377
371
  isDesignMode?: boolean;
378
372
  isPreviewMode?: boolean;
379
373
  isRevisionPreview?: boolean;
374
+ pageId: string;
375
+ projectId: string;
376
+ requestInfo: WeaverseLoaderRequestInfo;
380
377
  sectionType?: string;
381
- dataContext?: Record<string, unknown> | null;
378
+ weaverseApiBase: string;
379
+ weaverseApiKey: string;
380
+ weaverseHost: string;
381
+ weaverseVersion?: string;
382
382
  }
383
383
  type HydrogenComponent<T extends HydrogenComponentProps = any> = {
384
384
  default: ForwardRefExoticComponent<T> | ((props: T) => React$1.JSX.Element);
@@ -431,10 +431,10 @@ type WeaverseLoaderData = {
431
431
  pageAssignment?: HydrogenPageAssignment;
432
432
  };
433
433
  interface HydrogenPageData extends WeaverseProjectDataType {
434
+ __cacheId?: string;
434
435
  id: string;
435
- name: string;
436
436
  items: HydrogenComponentData[];
437
- __cacheId?: string;
437
+ name: string;
438
438
  [key: string]: any;
439
439
  }
440
440
  type WeaverseI18n = I18nBase & {
@@ -711,20 +711,20 @@ declare module '@shopify/remix-oxygen' {
711
711
  }
712
712
  declare module '@shopify/hydrogen' {
713
713
  interface HydrogenEnv {
714
- WEAVERSE_PROJECT_ID: string;
715
- WEAVERSE_HOST?: string;
716
- WEAVERSE_API_BASE?: string;
717
- WEAVERSE_API_KEY: string;
718
- PUBLIC_STORE_DOMAIN: string;
719
- PUBLIC_STOREFRONT_API_TOKEN: string;
720
- PUBLIC_GOOGLE_GTM_ID: string;
721
- JUDGEME_PRIVATE_API_TOKEN: string;
722
714
  CUSTOM_COLLECTION_BANNER_METAFIELD: string;
723
- METAOBJECT_COLORS_TYPE: string;
715
+ JUDGEME_PRIVATE_API_TOKEN: string;
716
+ KLAVIYO_PRIVATE_API_TOKEN: string;
724
717
  METAOBJECT_COLOR_NAME_KEY: string;
725
718
  METAOBJECT_COLOR_VALUE_KEY: string;
726
- KLAVIYO_PRIVATE_API_TOKEN: string;
719
+ METAOBJECT_COLORS_TYPE: string;
720
+ PUBLIC_GOOGLE_GTM_ID: string;
727
721
  PUBLIC_SHOPIFY_INBOX_SHOP_ID: string;
722
+ PUBLIC_STORE_DOMAIN: string;
723
+ PUBLIC_STOREFRONT_API_TOKEN: string;
724
+ WEAVERSE_API_BASE?: string;
725
+ WEAVERSE_API_KEY: string;
726
+ WEAVERSE_HOST?: string;
727
+ WEAVERSE_PROJECT_ID: string;
728
728
  }
729
729
  }
730
730
  /**
package/dist/index.js 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 (react.isBrowser && window.__weaverseThemeSettingsStore === this) {