@shopify/hydrogen-react 2026.4.2 → 2026.4.4

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.
Files changed (77) hide show
  1. package/dist/browser-dev/Image.mjs +4 -3
  2. package/dist/browser-dev/Image.mjs.map +1 -1
  3. package/dist/browser-dev/ShopifyProvider.mjs.map +1 -1
  4. package/dist/browser-dev/analytics-schema-custom-storefront-customer-tracking.mjs +1 -1
  5. package/dist/browser-dev/load-script.mjs +1 -1
  6. package/dist/browser-dev/packages/hydrogen-react/package.mjs +1 -1
  7. package/dist/browser-dev/packages/hydrogen-react/package.mjs.map +1 -1
  8. package/dist/browser-dev/tracking-utils.mjs +17 -58
  9. package/dist/browser-dev/tracking-utils.mjs.map +1 -1
  10. package/dist/browser-dev/useShopifyCookies.mjs +34 -97
  11. package/dist/browser-dev/useShopifyCookies.mjs.map +1 -1
  12. package/dist/browser-prod/Image.mjs +4 -3
  13. package/dist/browser-prod/Image.mjs.map +1 -1
  14. package/dist/browser-prod/ShopifyProvider.mjs.map +1 -1
  15. package/dist/browser-prod/analytics-schema-custom-storefront-customer-tracking.mjs +1 -1
  16. package/dist/browser-prod/load-script.mjs +1 -1
  17. package/dist/browser-prod/packages/hydrogen-react/package.mjs +1 -1
  18. package/dist/browser-prod/packages/hydrogen-react/package.mjs.map +1 -1
  19. package/dist/browser-prod/tracking-utils.mjs +17 -58
  20. package/dist/browser-prod/tracking-utils.mjs.map +1 -1
  21. package/dist/browser-prod/useShopifyCookies.mjs +34 -97
  22. package/dist/browser-prod/useShopifyCookies.mjs.map +1 -1
  23. package/dist/node-dev/Image.js +4 -3
  24. package/dist/node-dev/Image.js.map +1 -1
  25. package/dist/node-dev/Image.mjs +4 -3
  26. package/dist/node-dev/Image.mjs.map +1 -1
  27. package/dist/node-dev/ShopifyProvider.js.map +1 -1
  28. package/dist/node-dev/ShopifyProvider.mjs.map +1 -1
  29. package/dist/node-dev/analytics-schema-custom-storefront-customer-tracking.js +1 -1
  30. package/dist/node-dev/analytics-schema-custom-storefront-customer-tracking.mjs +1 -1
  31. package/dist/node-dev/load-script.js +2 -0
  32. package/dist/node-dev/load-script.js.map +1 -1
  33. package/dist/node-dev/load-script.mjs +1 -1
  34. package/dist/node-dev/packages/hydrogen-react/package.js +1 -1
  35. package/dist/node-dev/packages/hydrogen-react/package.js.map +1 -1
  36. package/dist/node-dev/packages/hydrogen-react/package.mjs +1 -1
  37. package/dist/node-dev/packages/hydrogen-react/package.mjs.map +1 -1
  38. package/dist/node-dev/tracking-utils.js +17 -58
  39. package/dist/node-dev/tracking-utils.js.map +1 -1
  40. package/dist/node-dev/tracking-utils.mjs +17 -58
  41. package/dist/node-dev/tracking-utils.mjs.map +1 -1
  42. package/dist/node-dev/useShopifyCookies.js +34 -97
  43. package/dist/node-dev/useShopifyCookies.js.map +1 -1
  44. package/dist/node-dev/useShopifyCookies.mjs +34 -97
  45. package/dist/node-dev/useShopifyCookies.mjs.map +1 -1
  46. package/dist/node-prod/Image.js +4 -3
  47. package/dist/node-prod/Image.js.map +1 -1
  48. package/dist/node-prod/Image.mjs +4 -3
  49. package/dist/node-prod/Image.mjs.map +1 -1
  50. package/dist/node-prod/ShopifyProvider.js.map +1 -1
  51. package/dist/node-prod/ShopifyProvider.mjs.map +1 -1
  52. package/dist/node-prod/analytics-schema-custom-storefront-customer-tracking.js +1 -1
  53. package/dist/node-prod/analytics-schema-custom-storefront-customer-tracking.mjs +1 -1
  54. package/dist/node-prod/load-script.js +2 -0
  55. package/dist/node-prod/load-script.js.map +1 -1
  56. package/dist/node-prod/load-script.mjs +1 -1
  57. package/dist/node-prod/packages/hydrogen-react/package.js +1 -1
  58. package/dist/node-prod/packages/hydrogen-react/package.js.map +1 -1
  59. package/dist/node-prod/packages/hydrogen-react/package.mjs +1 -1
  60. package/dist/node-prod/packages/hydrogen-react/package.mjs.map +1 -1
  61. package/dist/node-prod/tracking-utils.js +17 -58
  62. package/dist/node-prod/tracking-utils.js.map +1 -1
  63. package/dist/node-prod/tracking-utils.mjs +17 -58
  64. package/dist/node-prod/tracking-utils.mjs.map +1 -1
  65. package/dist/node-prod/useShopifyCookies.js +34 -97
  66. package/dist/node-prod/useShopifyCookies.js.map +1 -1
  67. package/dist/node-prod/useShopifyCookies.mjs +34 -97
  68. package/dist/node-prod/useShopifyCookies.mjs.map +1 -1
  69. package/dist/types/Image.d.ts +2 -1
  70. package/dist/types/ShopifyProvider.d.ts +3 -0
  71. package/dist/types/tracking-utils.d.ts +5 -4
  72. package/dist/types/useShopifyCookies.d.ts +14 -33
  73. package/dist/umd/hydrogen-react.dev.js +59 -165
  74. package/dist/umd/hydrogen-react.dev.js.map +1 -1
  75. package/dist/umd/hydrogen-react.prod.js +4 -4
  76. package/dist/umd/hydrogen-react.prod.js.map +1 -1
  77. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"ShopifyProvider.mjs","names":[],"sources":["../../src/ShopifyProvider.tsx"],"sourcesContent":["import {createContext, useContext, useMemo, type ReactNode} from 'react';\nimport type {LanguageCode, CountryCode} from './storefront-api-types.js';\nimport {SFAPI_VERSION} from './storefront-api-constants.js';\nimport {getPublicTokenHeadersRaw} from './storefront-client.js';\n\nexport const defaultShopifyContext: ShopifyContextValue = {\n storeDomain: 'test',\n storefrontToken: 'abc123',\n storefrontApiVersion: SFAPI_VERSION,\n countryIsoCode: 'US',\n languageIsoCode: 'EN',\n getStorefrontApiUrl() {\n return '';\n },\n getPublicTokenHeaders() {\n return {};\n },\n getShopifyDomain() {\n return '';\n },\n};\n\nconst ShopifyContext = createContext<ShopifyContextValue>(\n defaultShopifyContext,\n);\n\n/**\n * Hydrogen server sets this server timing key when the SFAPI proxy is enabled.\n * Read it automatically in the browser for apps using frontend cart in full-stack Hydrogen,\n * but don't export this utility yet since we don't want to make this a public convention.\n */\nfunction isSfapiProxyEnabled() {\n if (typeof window === 'undefined') return false;\n\n try {\n const navigationEntry = window.performance?.getEntriesByType?.(\n 'navigation',\n )[0] as PerformanceNavigationTiming;\n\n return !!navigationEntry?.serverTiming?.some(\n (entry) => entry.name === '_sfapi_proxy',\n );\n } catch (e) {\n return false;\n }\n}\n\n/**\n * The `<ShopifyProvider/>` component enables use of the `useShop()` hook. The component should wrap your app.\n * @publicDocs\n */\nexport function ShopifyProvider({\n children,\n ...shopifyConfig\n}: ShopifyProviderProps): JSX.Element {\n if (\n !shopifyConfig.countryIsoCode ||\n !shopifyConfig.languageIsoCode ||\n !shopifyConfig.storeDomain ||\n !shopifyConfig.storefrontToken ||\n !shopifyConfig.storefrontApiVersion\n ) {\n throw new Error(\n `Please provide the necessary props to '<ShopifyProvider/>'`,\n );\n }\n\n if (shopifyConfig.storefrontApiVersion !== SFAPI_VERSION) {\n console.warn(\n `<ShopifyProvider/>: This version of Hydrogen React is built for Shopify's Storefront API version ${SFAPI_VERSION}, but it looks like you're using version ${shopifyConfig.storefrontApiVersion}. There may be issues or bugs if you use a mismatched version of Hydrogen React and the Storefront API.`,\n );\n }\n\n const finalConfig = useMemo<ShopifyContextValue>(() => {\n const sameDomainForStorefrontApi =\n shopifyConfig.sameDomainForStorefrontApi ?? isSfapiProxyEnabled();\n\n function getShopifyDomain(overrideProps?: {storeDomain?: string}): string {\n const domain = overrideProps?.storeDomain ?? shopifyConfig.storeDomain;\n return domain.includes('://') ? domain : `https://${domain}`;\n }\n\n return {\n ...shopifyConfig,\n sameDomainForStorefrontApi,\n getPublicTokenHeaders(overrideProps): Record<string, string> {\n return getPublicTokenHeadersRaw(\n overrideProps.contentType,\n shopifyConfig.storefrontApiVersion,\n overrideProps.storefrontToken ?? shopifyConfig.storefrontToken,\n );\n },\n getShopifyDomain,\n getStorefrontApiUrl(overrideProps): string {\n const finalDomainUrl =\n sameDomainForStorefrontApi && typeof window !== 'undefined'\n ? window.location.origin\n : getShopifyDomain({\n storeDomain:\n overrideProps?.storeDomain ?? shopifyConfig.storeDomain,\n });\n\n return `${finalDomainUrl}${\n finalDomainUrl.endsWith('/') ? '' : '/'\n }api/${\n overrideProps?.storefrontApiVersion ??\n shopifyConfig.storefrontApiVersion\n }/graphql.json`;\n },\n };\n }, [shopifyConfig]);\n\n return (\n <ShopifyContext.Provider value={finalConfig}>\n {children}\n </ShopifyContext.Provider>\n );\n}\n\n/**\n * Provides access to the `shopifyConfig` prop of `<ShopifyProvider/>`. Must be a descendent of `<ShopifyProvider/>`.\n * @publicDocs\n */\nexport function useShop(): ShopifyContextValue {\n const shopContext = useContext(ShopifyContext);\n if (!shopContext) {\n throw new Error(`'useShop()' must be a descendent of <ShopifyProvider/>`);\n }\n return shopContext;\n}\n\nexport interface ShopifyProviderBase {\n /** The globally-unique identifier for the Shop */\n storefrontId?: string;\n /** The full domain of your Shopify storefront URL (eg: the complete string of `{subdomain}.myshopify.com`). */\n storeDomain: string;\n /** The Storefront API public access token. Refer to the [authentication](https://shopify.dev/api/storefront#authentication) documentation for more details. */\n storefrontToken: string;\n /** The Storefront API version. This should almost always be the same as the version Hydrogen React was built for. Learn more about Shopify [API versioning](https://shopify.dev/api/usage/versioning) for more details. */\n storefrontApiVersion: string;\n /**\n * The code designating a country, which generally follows ISO 3166-1 alpha-2 guidelines. If a territory doesn't have a country code value in the `CountryCode` enum, it might be considered a subdivision of another country. For example, the territories associated with Spain are represented by the country code `ES`, and the territories associated with the United States of America are represented by the country code `US`.\n */\n countryIsoCode: CountryCode;\n /**\n * `ISO 369` language codes supported by Shopify.\n */\n languageIsoCode: LanguageCode;\n /**\n * Uses the current window.location.origin for Storefront API requests.\n * This requires setting up a proxy for Storefront API requests in your domain.\n */\n sameDomainForStorefrontApi?: boolean;\n}\n\n/**\n * Shopify-specific values that are used in various Hydrogen React components and hooks.\n */\nexport interface ShopifyProviderProps extends ShopifyProviderBase {\n /** React children to render. */\n children?: ReactNode;\n}\n\nexport interface ShopifyContextValue\n extends ShopifyProviderBase, ShopifyContextReturn {}\n\ntype ShopifyContextReturn = {\n /**\n * Creates the fully-qualified URL to your store's GraphQL endpoint.\n *\n * By default, it will use the config you passed in when creating `<ShopifyProvider/>`. However, you can override the following settings on each invocation of `getStorefrontApiUrl({...})`:\n *\n * - `storeDomain`\n * - `storefrontApiVersion`\n */\n getStorefrontApiUrl: (props?: GetStorefrontApiUrlProps) => string;\n /**\n * Returns an object that contains headers that are needed for each query to Storefront API GraphQL endpoint. This uses the public Storefront API token.\n *\n * By default, it will use the config you passed in when creating `<ShopifyProvider/>`. However, you can override the following settings on each invocation of `getPublicTokenHeaders({...})`:\n *\n * - `contentType`\n * - `storefrontToken`\n *\n */\n getPublicTokenHeaders: (\n props: GetPublicTokenHeadersProps,\n ) => Record<string, string>;\n /**\n * Creates the fully-qualified URL to your myshopify.com domain.\n *\n * By default, it will use the config you passed in when calling `<ShopifyProvider/>`. However, you can override the following settings on each invocation of `getShopifyDomain({...})`:\n *\n * - `storeDomain`\n */\n getShopifyDomain: (props?: GetShopifyDomainProps) => string;\n};\n\ntype GetStorefrontApiUrlProps = {\n /** The host name of the domain (eg: `{shop}.myshopify.com`). */\n storeDomain?: string;\n /** The Storefront API version. This should almost always be the same as the version Hydrogen-UI was built for. Learn more about Shopify [API versioning](https://shopify.dev/api/usage/versioning) for more details. */\n storefrontApiVersion?: string;\n};\n\ntype GetPublicTokenHeadersProps = {\n /**\n * Customizes which `\"content-type\"` header is added when using `getPrivateTokenHeaders()` and `getPublicTokenHeaders()`. When fetching with a `JSON.stringify()`-ed `body`, use `\"json\"`. When fetching with a `body` that is a plain string, use `\"graphql\"`. Defaults to `\"json\"`\n */\n contentType: 'json' | 'graphql';\n /** The Storefront API access token. Refer to the [authentication](https://shopify.dev/api/storefront#authentication) documentation for more details. */\n storefrontToken?: string;\n};\n\ntype GetShopifyDomainProps = {storeDomain?: string};\n"],"mappings":";;;;;AAKA,IAAa,wBAA6C;CACxD,aAAa;CACb,iBAAiB;CACjB,sBAAsB;CACtB,gBAAgB;CAChB,iBAAiB;CACjB,sBAAsB;AACpB,SAAO;;CAET,wBAAwB;AACtB,SAAO,EAAE;;CAEX,mBAAmB;AACjB,SAAO;;CAEV;AAED,IAAM,iBAAiB,cACrB,sBACD;;;;;;AAOD,SAAS,sBAAsB;AAC7B,KAAI,OAAO,WAAW,YAAa,QAAO;AAE1C,KAAI;AAKF,SAAO,CAAC,EAJgB,OAAO,aAAa,mBAC1C,aACD,CAAC,KAEwB,cAAc,MACrC,UAAU,MAAM,SAAS,eAC3B;UACM,GAAG;AACV,SAAO;;;;;;;AAQX,SAAgB,gBAAgB,EAC9B,UACA,GAAG,iBACiC;AACpC,KACE,CAAC,cAAc,kBACf,CAAC,cAAc,mBACf,CAAC,cAAc,eACf,CAAC,cAAc,mBACf,CAAC,cAAc,qBAEf,OAAM,IAAI,MACR,6DACD;AAGH,KAAI,cAAc,yBAAA,UAChB,SAAQ,KACN,oGAAoG,cAAc,2CAA2C,cAAc,qBAAqB,yGACjM;CAGH,MAAM,cAAc,cAAmC;EACrD,MAAM,6BACJ,cAAc,8BAA8B,qBAAqB;EAEnE,SAAS,iBAAiB,eAAgD;GACxE,MAAM,SAAS,eAAe,eAAe,cAAc;AAC3D,UAAO,OAAO,SAAS,MAAM,GAAG,SAAS,WAAW;;AAGtD,SAAO;GACL,GAAG;GACH;GACA,sBAAsB,eAAuC;AAC3D,WAAO,yBACL,cAAc,aACd,cAAc,sBACd,cAAc,mBAAmB,cAAc,gBAChD;;GAEH;GACA,oBAAoB,eAAuB;IACzC,MAAM,iBACJ,8BAA8B,OAAO,WAAW,cAC5C,OAAO,SAAS,SAChB,iBAAiB,EACf,aACE,eAAe,eAAe,cAAc,aAC/C,CAAC;AAER,WAAO,GAAG,iBACR,eAAe,SAAS,IAAI,GAAG,KAAK,IACrC,MACC,eAAe,wBACf,cAAc,qBACf;;GAEJ;IACA,CAAC,cAAc,CAAC;AAEnB,QACE,oBAAC,eAAe,UAAhB;EAAyB,OAAO;EAC7B;EACuB,CAAA;;;;;;AAQ9B,SAAgB,UAA+B;CAC7C,MAAM,cAAc,WAAW,eAAe;AAC9C,KAAI,CAAC,YACH,OAAM,IAAI,MAAM,yDAAyD;AAE3E,QAAO"}
1
+ {"version":3,"file":"ShopifyProvider.mjs","names":[],"sources":["../../src/ShopifyProvider.tsx"],"sourcesContent":["import {createContext, useContext, useMemo, type ReactNode} from 'react';\nimport type {LanguageCode, CountryCode} from './storefront-api-types.js';\nimport {SFAPI_VERSION} from './storefront-api-constants.js';\nimport {getPublicTokenHeadersRaw} from './storefront-client.js';\n\nexport const defaultShopifyContext: ShopifyContextValue = {\n storeDomain: 'test',\n storefrontToken: 'abc123',\n storefrontApiVersion: SFAPI_VERSION,\n countryIsoCode: 'US',\n languageIsoCode: 'EN',\n getStorefrontApiUrl() {\n return '';\n },\n getPublicTokenHeaders() {\n return {};\n },\n getShopifyDomain() {\n return '';\n },\n};\n\nconst ShopifyContext = createContext<ShopifyContextValue>(\n defaultShopifyContext,\n);\n\n/**\n * Hydrogen server sets this server timing key when the SFAPI proxy is enabled.\n * Read it automatically in the browser for apps using frontend cart in full-stack Hydrogen,\n * but don't export this utility yet since we don't want to make this a public convention.\n */\nfunction isSfapiProxyEnabled() {\n if (typeof window === 'undefined') return false;\n\n try {\n const navigationEntry = window.performance?.getEntriesByType?.(\n 'navigation',\n )[0] as PerformanceNavigationTiming;\n\n return !!navigationEntry?.serverTiming?.some(\n (entry) => entry.name === '_sfapi_proxy',\n );\n } catch (e) {\n return false;\n }\n}\n\n/**\n * The `<ShopifyProvider/>` component enables use of the `useShop()` hook. The component should wrap your app.\n * @publicDocs\n */\nexport function ShopifyProvider({\n children,\n ...shopifyConfig\n}: ShopifyProviderProps): JSX.Element {\n if (\n !shopifyConfig.countryIsoCode ||\n !shopifyConfig.languageIsoCode ||\n !shopifyConfig.storeDomain ||\n !shopifyConfig.storefrontToken ||\n !shopifyConfig.storefrontApiVersion\n ) {\n throw new Error(\n `Please provide the necessary props to '<ShopifyProvider/>'`,\n );\n }\n\n if (shopifyConfig.storefrontApiVersion !== SFAPI_VERSION) {\n console.warn(\n `<ShopifyProvider/>: This version of Hydrogen React is built for Shopify's Storefront API version ${SFAPI_VERSION}, but it looks like you're using version ${shopifyConfig.storefrontApiVersion}. There may be issues or bugs if you use a mismatched version of Hydrogen React and the Storefront API.`,\n );\n }\n\n const finalConfig = useMemo<ShopifyContextValue>(() => {\n const sameDomainForStorefrontApi =\n shopifyConfig.sameDomainForStorefrontApi ?? isSfapiProxyEnabled();\n\n function getShopifyDomain(overrideProps?: {storeDomain?: string}): string {\n const domain = overrideProps?.storeDomain ?? shopifyConfig.storeDomain;\n return domain.includes('://') ? domain : `https://${domain}`;\n }\n\n return {\n ...shopifyConfig,\n sameDomainForStorefrontApi,\n getPublicTokenHeaders(overrideProps): Record<string, string> {\n return getPublicTokenHeadersRaw(\n overrideProps.contentType,\n shopifyConfig.storefrontApiVersion,\n overrideProps.storefrontToken ?? shopifyConfig.storefrontToken,\n );\n },\n getShopifyDomain,\n getStorefrontApiUrl(overrideProps): string {\n const finalDomainUrl =\n sameDomainForStorefrontApi && typeof window !== 'undefined'\n ? window.location.origin\n : getShopifyDomain({\n storeDomain:\n overrideProps?.storeDomain ?? shopifyConfig.storeDomain,\n });\n\n return `${finalDomainUrl}${\n finalDomainUrl.endsWith('/') ? '' : '/'\n }api/${\n overrideProps?.storefrontApiVersion ??\n shopifyConfig.storefrontApiVersion\n }/graphql.json`;\n },\n };\n }, [shopifyConfig]);\n\n return (\n <ShopifyContext.Provider value={finalConfig}>\n {children}\n </ShopifyContext.Provider>\n );\n}\n\n/**\n * Provides access to the `shopifyConfig` prop of `<ShopifyProvider/>`. Must be a descendent of `<ShopifyProvider/>`.\n * @publicDocs\n */\nexport function useShop(): ShopifyContextValue {\n const shopContext = useContext(ShopifyContext);\n if (!shopContext) {\n throw new Error(`'useShop()' must be a descendent of <ShopifyProvider/>`);\n }\n return shopContext;\n}\n\nexport interface ShopifyProviderBase {\n /** The globally-unique identifier for the Shop */\n storefrontId?: string;\n /** The full domain of your Shopify storefront URL (eg: the complete string of `{subdomain}.myshopify.com`). */\n storeDomain: string;\n /** The Storefront API public access token. Refer to the [authentication](https://shopify.dev/api/storefront#authentication) documentation for more details. */\n storefrontToken: string;\n /** The Storefront API version. This should almost always be the same as the version Hydrogen React was built for. Learn more about Shopify [API versioning](https://shopify.dev/api/usage/versioning) for more details. */\n storefrontApiVersion: string;\n /**\n * The code designating a country, which generally follows ISO 3166-1 alpha-2 guidelines. If a territory doesn't have a country code value in the `CountryCode` enum, it might be considered a subdivision of another country. For example, the territories associated with Spain are represented by the country code `ES`, and the territories associated with the United States of America are represented by the country code `US`.\n */\n countryIsoCode: CountryCode;\n /**\n * `ISO 369` language codes supported by Shopify.\n */\n languageIsoCode: LanguageCode;\n /**\n * Uses the current window.location.origin for Storefront API requests.\n * This requires setting up a proxy for Storefront API requests in your domain.\n * Without the proxy, cart requests still work, but visitor analytics and\n * session attribution do not,\n * [notice](https://shopify.dev/changelog/posts/tracking-cookie-deprecation-hydrogen).\n */\n sameDomainForStorefrontApi?: boolean;\n}\n\n/**\n * Shopify-specific values that are used in various Hydrogen React components and hooks.\n */\nexport interface ShopifyProviderProps extends ShopifyProviderBase {\n /** React children to render. */\n children?: ReactNode;\n}\n\nexport interface ShopifyContextValue\n extends ShopifyProviderBase, ShopifyContextReturn {}\n\ntype ShopifyContextReturn = {\n /**\n * Creates the fully-qualified URL to your store's GraphQL endpoint.\n *\n * By default, it will use the config you passed in when creating `<ShopifyProvider/>`. However, you can override the following settings on each invocation of `getStorefrontApiUrl({...})`:\n *\n * - `storeDomain`\n * - `storefrontApiVersion`\n */\n getStorefrontApiUrl: (props?: GetStorefrontApiUrlProps) => string;\n /**\n * Returns an object that contains headers that are needed for each query to Storefront API GraphQL endpoint. This uses the public Storefront API token.\n *\n * By default, it will use the config you passed in when creating `<ShopifyProvider/>`. However, you can override the following settings on each invocation of `getPublicTokenHeaders({...})`:\n *\n * - `contentType`\n * - `storefrontToken`\n *\n */\n getPublicTokenHeaders: (\n props: GetPublicTokenHeadersProps,\n ) => Record<string, string>;\n /**\n * Creates the fully-qualified URL to your myshopify.com domain.\n *\n * By default, it will use the config you passed in when calling `<ShopifyProvider/>`. However, you can override the following settings on each invocation of `getShopifyDomain({...})`:\n *\n * - `storeDomain`\n */\n getShopifyDomain: (props?: GetShopifyDomainProps) => string;\n};\n\ntype GetStorefrontApiUrlProps = {\n /** The host name of the domain (eg: `{shop}.myshopify.com`). */\n storeDomain?: string;\n /** The Storefront API version. This should almost always be the same as the version Hydrogen-UI was built for. Learn more about Shopify [API versioning](https://shopify.dev/api/usage/versioning) for more details. */\n storefrontApiVersion?: string;\n};\n\ntype GetPublicTokenHeadersProps = {\n /**\n * Customizes which `\"content-type\"` header is added when using `getPrivateTokenHeaders()` and `getPublicTokenHeaders()`. When fetching with a `JSON.stringify()`-ed `body`, use `\"json\"`. When fetching with a `body` that is a plain string, use `\"graphql\"`. Defaults to `\"json\"`\n */\n contentType: 'json' | 'graphql';\n /** The Storefront API access token. Refer to the [authentication](https://shopify.dev/api/storefront#authentication) documentation for more details. */\n storefrontToken?: string;\n};\n\ntype GetShopifyDomainProps = {storeDomain?: string};\n"],"mappings":";;;;;AAKA,IAAa,wBAA6C;CACxD,aAAa;CACb,iBAAiB;CACjB,sBAAsB;CACtB,gBAAgB;CAChB,iBAAiB;CACjB,sBAAsB;AACpB,SAAO;;CAET,wBAAwB;AACtB,SAAO,EAAE;;CAEX,mBAAmB;AACjB,SAAO;;CAEV;AAED,IAAM,iBAAiB,cACrB,sBACD;;;;;;AAOD,SAAS,sBAAsB;AAC7B,KAAI,OAAO,WAAW,YAAa,QAAO;AAE1C,KAAI;AAKF,SAAO,CAAC,EAJgB,OAAO,aAAa,mBAC1C,aACD,CAAC,KAEwB,cAAc,MACrC,UAAU,MAAM,SAAS,eAC3B;UACM,GAAG;AACV,SAAO;;;;;;;AAQX,SAAgB,gBAAgB,EAC9B,UACA,GAAG,iBACiC;AACpC,KACE,CAAC,cAAc,kBACf,CAAC,cAAc,mBACf,CAAC,cAAc,eACf,CAAC,cAAc,mBACf,CAAC,cAAc,qBAEf,OAAM,IAAI,MACR,6DACD;AAGH,KAAI,cAAc,yBAAA,UAChB,SAAQ,KACN,oGAAoG,cAAc,2CAA2C,cAAc,qBAAqB,yGACjM;CAGH,MAAM,cAAc,cAAmC;EACrD,MAAM,6BACJ,cAAc,8BAA8B,qBAAqB;EAEnE,SAAS,iBAAiB,eAAgD;GACxE,MAAM,SAAS,eAAe,eAAe,cAAc;AAC3D,UAAO,OAAO,SAAS,MAAM,GAAG,SAAS,WAAW;;AAGtD,SAAO;GACL,GAAG;GACH;GACA,sBAAsB,eAAuC;AAC3D,WAAO,yBACL,cAAc,aACd,cAAc,sBACd,cAAc,mBAAmB,cAAc,gBAChD;;GAEH;GACA,oBAAoB,eAAuB;IACzC,MAAM,iBACJ,8BAA8B,OAAO,WAAW,cAC5C,OAAO,SAAS,SAChB,iBAAiB,EACf,aACE,eAAe,eAAe,cAAc,aAC/C,CAAC;AAER,WAAO,GAAG,iBACR,eAAe,SAAS,IAAI,GAAG,KAAK,IACrC,MACC,eAAe,wBACf,cAAc,qBACf;;GAEJ;IACA,CAAC,cAAc,CAAC;AAEnB,QACE,oBAAC,eAAe,UAAhB;EAAyB,OAAO;EAC7B;EACuB,CAAA;;;;;;AAQ9B,SAAgB,UAA+B;CAC7C,MAAM,cAAc,WAAW,eAAe;AAC9C,KAAI,CAAC,YACH,OAAM,IAAI,MAAM,yDAAyD;AAE3E,QAAO"}
@@ -100,7 +100,7 @@ function formatPayload(payload) {
100
100
  const payloadWithPrivacy = payload;
101
101
  return {
102
102
  source: payload.shopifySalesChannel || require_analytics_constants.ShopifySalesChannel.headless,
103
- asset_version_id: payload.assetVersionId || "2026.4.2",
103
+ asset_version_id: payload.assetVersionId || "2026.4.4",
104
104
  hydrogenSubchannelId: payload.storefrontId || payload.hydrogenSubchannelId || "0",
105
105
  is_persistent_cookie: payload.hasUserConsent,
106
106
  deprecated_visit_token: payload.visitToken,
@@ -100,7 +100,7 @@ function formatPayload(payload) {
100
100
  const payloadWithPrivacy = payload;
101
101
  return {
102
102
  source: payload.shopifySalesChannel || ShopifySalesChannel.headless,
103
- asset_version_id: payload.assetVersionId || "2026.4.2",
103
+ asset_version_id: payload.assetVersionId || "2026.4.4",
104
104
  hydrogenSubchannelId: payload.storefrontId || payload.hydrogenSubchannelId || "0",
105
105
  is_persistent_cookie: payload.hasUserConsent,
106
106
  deprecated_visit_token: payload.visitToken,
@@ -1,3 +1,4 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
1
2
  require("./_virtual/_rolldown/runtime.js");
2
3
  let react = require("react");
3
4
  //#region src/load-script.tsx
@@ -38,6 +39,7 @@ function useLoadScript(url, options) {
38
39
  return status;
39
40
  }
40
41
  //#endregion
42
+ exports.loadScript = loadScript;
41
43
  exports.useLoadScript = useLoadScript;
42
44
 
43
45
  //# sourceMappingURL=load-script.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"load-script.js","names":[],"sources":["../../src/load-script.tsx"],"sourcesContent":["import {useState, useEffect} from 'react';\n\nconst SCRIPTS_LOADED: Record<string, Promise<boolean>> = {};\n\ntype LoadScriptOptions = {\n module?: boolean;\n in?: 'head' | 'body';\n attributes?: Record<string, string>;\n};\n\nexport function loadScript(\n src: string,\n options?: LoadScriptOptions,\n): Promise<boolean> {\n const isScriptLoaded = SCRIPTS_LOADED[src];\n\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n if (isScriptLoaded) {\n return isScriptLoaded;\n }\n\n const promise = new Promise<boolean>((resolve, reject) => {\n const script = document.createElement('script');\n if (options?.module) {\n script.type = 'module';\n } else {\n script.type = 'text/javascript';\n }\n script.src = src;\n script.onload = (): void => {\n resolve(true);\n };\n script.onerror = (): void => {\n reject(false);\n };\n if (options?.in === 'head') {\n document.head.appendChild(script);\n } else {\n document.body.appendChild(script);\n }\n\n const attributes = options?.attributes;\n if (attributes) {\n Object.keys(attributes).forEach((key) => {\n script.setAttribute(key, attributes[key]);\n });\n }\n });\n\n SCRIPTS_LOADED[src] = promise;\n\n return promise;\n}\n\n/** @publicDocs */\nexport type LoadScriptParams = Parameters<typeof loadScript>;\n\n/**\n * The `useLoadScript` hook loads an external script tag in the browser. It allows React components to lazy-load large third-party dependencies.\n * @publicDocs\n */\nexport function useLoadScript(\n url: LoadScriptParams[0],\n options?: LoadScriptParams[1],\n): ScriptState {\n const [status, setStatus] = useState<ScriptState>('loading');\n\n useEffect(\n () => {\n loadScript(url, options)\n .then(() => setStatus('done'))\n .catch(() => setStatus('error'));\n },\n // Ignore options changes since it won't trigger a new load.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [url],\n );\n\n return status;\n}\n\ntype ScriptState = 'loading' | 'done' | 'error';\n"],"mappings":";;;AAEA,IAAM,iBAAmD,EAAE;AAQ3D,SAAgB,WACd,KACA,SACkB;CAClB,MAAM,iBAAiB,eAAe;AAGtC,KAAI,eACF,QAAO;CAGT,MAAM,UAAU,IAAI,SAAkB,SAAS,WAAW;EACxD,MAAM,SAAS,SAAS,cAAc,SAAS;AAC/C,MAAI,SAAS,OACX,QAAO,OAAO;MAEd,QAAO,OAAO;AAEhB,SAAO,MAAM;AACb,SAAO,eAAqB;AAC1B,WAAQ,KAAK;;AAEf,SAAO,gBAAsB;AAC3B,UAAO,MAAM;;AAEf,MAAI,SAAS,OAAO,OAClB,UAAS,KAAK,YAAY,OAAO;MAEjC,UAAS,KAAK,YAAY,OAAO;EAGnC,MAAM,aAAa,SAAS;AAC5B,MAAI,WACF,QAAO,KAAK,WAAW,CAAC,SAAS,QAAQ;AACvC,UAAO,aAAa,KAAK,WAAW,KAAK;IACzC;GAEJ;AAEF,gBAAe,OAAO;AAEtB,QAAO;;;;;;AAUT,SAAgB,cACd,KACA,SACa;CACb,MAAM,CAAC,QAAQ,cAAA,GAAA,MAAA,UAAmC,UAAU;AAE5D,EAAA,GAAA,MAAA,iBACQ;AACJ,aAAW,KAAK,QAAQ,CACrB,WAAW,UAAU,OAAO,CAAC,CAC7B,YAAY,UAAU,QAAQ,CAAC;IAIpC,CAAC,IAAI,CACN;AAED,QAAO"}
1
+ {"version":3,"file":"load-script.js","names":[],"sources":["../../src/load-script.tsx"],"sourcesContent":["import {useState, useEffect} from 'react';\n\nconst SCRIPTS_LOADED: Record<string, Promise<boolean>> = {};\n\ntype LoadScriptOptions = {\n module?: boolean;\n in?: 'head' | 'body';\n attributes?: Record<string, string>;\n};\n\nexport function loadScript(\n src: string,\n options?: LoadScriptOptions,\n): Promise<boolean> {\n const isScriptLoaded = SCRIPTS_LOADED[src];\n\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n if (isScriptLoaded) {\n return isScriptLoaded;\n }\n\n const promise = new Promise<boolean>((resolve, reject) => {\n const script = document.createElement('script');\n if (options?.module) {\n script.type = 'module';\n } else {\n script.type = 'text/javascript';\n }\n script.src = src;\n script.onload = (): void => {\n resolve(true);\n };\n script.onerror = (): void => {\n reject(false);\n };\n if (options?.in === 'head') {\n document.head.appendChild(script);\n } else {\n document.body.appendChild(script);\n }\n\n const attributes = options?.attributes;\n if (attributes) {\n Object.keys(attributes).forEach((key) => {\n script.setAttribute(key, attributes[key]);\n });\n }\n });\n\n SCRIPTS_LOADED[src] = promise;\n\n return promise;\n}\n\n/** @publicDocs */\nexport type LoadScriptParams = Parameters<typeof loadScript>;\n\n/**\n * The `useLoadScript` hook loads an external script tag in the browser. It allows React components to lazy-load large third-party dependencies.\n * @publicDocs\n */\nexport function useLoadScript(\n url: LoadScriptParams[0],\n options?: LoadScriptParams[1],\n): ScriptState {\n const [status, setStatus] = useState<ScriptState>('loading');\n\n useEffect(\n () => {\n loadScript(url, options)\n .then(() => setStatus('done'))\n .catch(() => setStatus('error'));\n },\n // Ignore options changes since it won't trigger a new load.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [url],\n );\n\n return status;\n}\n\ntype ScriptState = 'loading' | 'done' | 'error';\n"],"mappings":";;;;AAEA,IAAM,iBAAmD,EAAE;AAQ3D,SAAgB,WACd,KACA,SACkB;CAClB,MAAM,iBAAiB,eAAe;AAGtC,KAAI,eACF,QAAO;CAGT,MAAM,UAAU,IAAI,SAAkB,SAAS,WAAW;EACxD,MAAM,SAAS,SAAS,cAAc,SAAS;AAC/C,MAAI,SAAS,OACX,QAAO,OAAO;MAEd,QAAO,OAAO;AAEhB,SAAO,MAAM;AACb,SAAO,eAAqB;AAC1B,WAAQ,KAAK;;AAEf,SAAO,gBAAsB;AAC3B,UAAO,MAAM;;AAEf,MAAI,SAAS,OAAO,OAClB,UAAS,KAAK,YAAY,OAAO;MAEjC,UAAS,KAAK,YAAY,OAAO;EAGnC,MAAM,aAAa,SAAS;AAC5B,MAAI,WACF,QAAO,KAAK,WAAW,CAAC,SAAS,QAAQ;AACvC,UAAO,aAAa,KAAK,WAAW,KAAK;IACzC;GAEJ;AAEF,gBAAe,OAAO;AAEtB,QAAO;;;;;;AAUT,SAAgB,cACd,KACA,SACa;CACb,MAAM,CAAC,QAAQ,cAAA,GAAA,MAAA,UAAmC,UAAU;AAE5D,EAAA,GAAA,MAAA,iBACQ;AACJ,aAAW,KAAK,QAAQ,CACrB,WAAW,UAAU,OAAO,CAAC,CAC7B,YAAY,UAAU,QAAQ,CAAC;IAIpC,CAAC,IAAI,CACN;AAED,QAAO"}
@@ -37,6 +37,6 @@ function useLoadScript(url, options) {
37
37
  return status;
38
38
  }
39
39
  //#endregion
40
- export { useLoadScript };
40
+ export { loadScript, useLoadScript };
41
41
 
42
42
  //# sourceMappingURL=load-script.mjs.map
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "2026.4.2";
2
+ var version = "2026.4.4";
3
3
  //#endregion
4
4
  exports.version = version;
5
5
 
@@ -1 +1 @@
1
- {"version":3,"file":"package.js","names":[],"sources":["../../../../package.json"],"sourcesContent":["{\n \"name\": \"@shopify/hydrogen-react\",\n \"version\": \"2026.4.2\",\n \"description\": \"React components, hooks, and utilities for creating custom Shopify storefronts\",\n \"homepage\": \"https://github.com/Shopify/hydrogen/tree/main/packages/hydrogen-react\",\n \"license\": \"MIT\",\n \"publishConfig\": {\n \"access\": \"public\",\n \"@shopify:registry\": \"https://registry.npmjs.org\"\n },\n \"files\": [\n \"dist\",\n \"storefront.schema.json\",\n \"customer-account.schema.json\"\n ],\n \"type\": \"commonjs\",\n \"exports\": {\n \".\": {\n \"node\": {\n \"require\": {\n \"types\": \"./dist/types/index.d.cts\",\n \"development\": \"./dist/node-dev/index.js\",\n \"default\": \"./dist/node-prod/index.js\"\n },\n \"import\": {\n \"types\": \"./dist/types/index.d.ts\",\n \"development\": \"./dist/node-dev/index.mjs\",\n \"default\": \"./dist/node-prod/index.mjs\"\n },\n \"default\": \"./dist/node-prod/index.js\"\n },\n \"module\": {\n \"types\": \"./dist/types/index.d.ts\",\n \"development\": \"./dist/browser-dev/index.mjs\",\n \"default\": \"./dist/browser-prod/index.mjs\"\n },\n \"import\": {\n \"types\": \"./dist/types/index.d.ts\",\n \"development\": \"./dist/browser-dev/index.mjs\",\n \"default\": \"./dist/browser-prod/index.mjs\"\n },\n \"require\": {\n \"types\": \"./dist/types/index.d.cts\",\n \"development\": \"./dist/node-dev/index.js\",\n \"default\": \"./dist/node-prod/index.js\"\n },\n \"default\": \"./dist/browser-prod/index.mjs\"\n },\n \"./storefront-api-types\": \"./dist/types/storefront-api-types.d.ts\",\n \"./storefront.schema.json\": \"./storefront.schema.json\",\n \"./customer-account.schema.json\": \"./customer-account.schema.json\",\n \"./customer-account-api-types\": \"./dist/types/customer-account-api-types.d.ts\",\n \"./package.json\": \"./package.json\",\n \"./*\": {\n \"node\": {\n \"require\": {\n \"types\": \"./dist/types/*.d.cts\",\n \"development\": \"./dist/node-dev/*.js\",\n \"default\": \"./dist/node-prod/*.js\"\n },\n \"import\": {\n \"types\": \"./dist/types/*.d.ts\",\n \"development\": \"./dist/node-dev/*.mjs\",\n \"default\": \"./dist/node-prod/*.mjs\"\n },\n \"default\": \"./dist/node-prod/*.js\"\n },\n \"module\": {\n \"types\": \"./dist/types/*.d.ts\",\n \"development\": \"./dist/browser-dev/*.mjs\",\n \"default\": \"./dist/browser-prod/*.mjs\"\n },\n \"import\": {\n \"types\": \"./dist/types/*.d.ts\",\n \"development\": \"./dist/browser-dev/*.mjs\",\n \"default\": \"./dist/browser-prod/*.mjs\"\n },\n \"require\": {\n \"types\": \"./dist/types/*.d.cts\",\n \"development\": \"./dist/node-dev/*.js\",\n \"default\": \"./dist/node-prod/*.js\"\n },\n \"default\": \"./dist/browser-prod/*.mjs\"\n }\n },\n \"typesVersions\": {\n \"*\": {\n \"storefront-api-types\": [\n \"./dist/types/storefront-api-types.d.ts\"\n ]\n }\n },\n \"main\": \"./dist/node-prod/index.js\",\n \"module\": \"./dist/node-prod/index.mjs\",\n \"browser\": \"./dist/browser-prod/index.mjs\",\n \"types\": \"./dist/types/index.d.ts\",\n \"unpkg\": \"./dist/umd/hydrogen-react.prod.js\",\n \"jsdelivr\": \"./dist/umd/hydrogen-react.prod.js\",\n \"sideEffects\": false,\n \"scripts\": {\n \"build-docs\": \"sh ./docs/build-docs.sh && pnpm run format\",\n \"clean-dist\": \"rimraf ./dist\",\n \"dev\": \"run-s dev:demo\",\n \"dev:story\": \"ladle serve\",\n \"dev:demo\": \"run-p dev:demo:* copy-api-types\",\n \"dev:demo:browser-dev\": \"vite build --watch --emptyOutDir false --clearScreen false --mode devbuild\",\n \"dev:demo:ts\": \"tsc --watch --emitDeclarationOnly\",\n \"build\": \"npm-run-all --sequential clean-dist --parallel build:vite:* build:tsc:es --parallel build:tsc:cjs copy-api-types\",\n \"build:vite:browser-dev\": \"vite build --mode devbuild\",\n \"build:vite:browser-prod\": \"vite build\",\n \"build:vite:node-dev\": \"vite build --mode devbuild --ssr\",\n \"build:vite:node-prod\": \"vite build --ssr\",\n \"build:vite:umddev\": \"vite build --mode umdbuilddev\",\n \"build:vite:umdprod\": \"vite build --mode umdbuild\",\n \"build:tsc:cjs\": \"cpy ./dist/types/index.d.ts ./dist/types/ --rename=index.d.cts --flat\",\n \"build:tsc:es\": \"tsc --emitDeclarationOnly --project tsconfig.typeoutput.json\",\n \"copy-api-types\": \"cpy ./src/storefront-api-types.d.ts ./src/customer-account-api-types.d.ts ./dist/types/ --flat\",\n \"format\": \"prettier --write \\\"{src,docs}/**/*\\\" --ignore-unknown\",\n \"graphql-types\": \"graphql-codegen --config codegen.ts && pnpm run format\",\n \"test\": \"vitest run --coverage\",\n \"test:watch\": \"vitest\",\n \"typecheck\": \"run-p typecheck:*\",\n \"typecheck:code\": \"tsc --noEmit\",\n \"typecheck:examples\": \"tsc --noEmit --project tsconfig.examples.json\",\n \"preview-docs\": \"pnpm --dir ../../docs/preview run dev\"\n },\n \"devDependencies\": {\n \"@faker-js/faker\": \"^9.4.0\",\n \"@graphql-codegen/add\": \"^5.0.3\",\n \"@graphql-codegen/cli\": \"^5.0.4\",\n \"@graphql-codegen/introspection\": \"^4.0.3\",\n \"@graphql-codegen/typescript\": \"^4.1.3\",\n \"@ladle/react\": \"^5.0.1\",\n \"@shopify/generate-docs\": \"catalog:\",\n \"@testing-library/jest-dom\": \"^6.6.3\",\n \"@testing-library/react\": \"^14.0.0\",\n \"@testing-library/user-event\": \"^14.6.1\",\n \"@types/react\": \"catalog:\",\n \"@types/react-dom\": \"catalog:\",\n \"@vitejs/plugin-react\": \"^6.0.1\",\n \"@vitest/coverage-v8\": \"^3.2.4\",\n \"cpy-cli\": \"^5.0.0\",\n \"eslint\": \"9.19.0\",\n \"eslint-config-prettier\": \"10.0.1\",\n \"eslint-import-resolver-typescript\": \"3.7.0\",\n \"eslint-plugin-eslint-comments\": \"3.2.0\",\n \"eslint-plugin-import\": \"2.31.0\",\n \"eslint-plugin-jest\": \"28.11.0\",\n \"eslint-plugin-jsx-a11y\": \"6.10.2\",\n \"eslint-plugin-node\": \"11.1.0\",\n \"eslint-plugin-prettier\": \"4.2.1\",\n \"eslint-plugin-react\": \"7.37.4\",\n \"eslint-plugin-react-hooks\": \"5.1.0\",\n \"eslint-plugin-simple-import-sort\": \"12.1.1\",\n \"eslint-plugin-tsdoc\": \"0.2.14\",\n \"happy-dom\": \"^20.8.9\",\n \"npm-run-all\": \"^4.1.5\",\n \"react\": \"catalog:\",\n \"react-dom\": \"catalog:\",\n \"rimraf\": \"^6.0.1\",\n \"ts-expect\": \"^1.3.0\",\n \"typescript\": \"5.9.2\",\n \"vite\": \"^8.0.1\",\n \"vitest\": \"^3.2.4\"\n },\n \"peerDependencies\": {\n \"react\": \"^18.3.1 || ~19.0.3 || ~19.1.4 || ^19.2.3\",\n \"react-dom\": \"^18.3.1 || ~19.0.3 || ~19.1.4 || ^19.2.3\",\n \"vite\": \"^5.1.0 || ^6.2.1 || ^7.0.0 || ^8.0.0\"\n },\n \"dependencies\": {\n \"@google/model-viewer\": \"^4.0.0\",\n \"@xstate/fsm\": \"2.0.0\",\n \"ast-v8-to-istanbul\": \"^0.3.11\",\n \"graphql\": \"^16.10.0\",\n \"type-fest\": \"^4.33.0\",\n \"worktop\": \"^0.7.3\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/Shopify/hydrogen.git\",\n \"directory\": \"packages/hydrogen-react\"\n },\n \"bugs\": \"https://github.com/shopify/hydrogen/issues\"\n}\n"],"mappings":""}
1
+ {"version":3,"file":"package.js","names":[],"sources":["../../../../package.json"],"sourcesContent":["{\n \"name\": \"@shopify/hydrogen-react\",\n \"version\": \"2026.4.4\",\n \"description\": \"React components, hooks, and utilities for creating custom Shopify storefronts\",\n \"homepage\": \"https://github.com/Shopify/hydrogen/tree/main/packages/hydrogen-react\",\n \"license\": \"MIT\",\n \"publishConfig\": {\n \"access\": \"public\",\n \"@shopify:registry\": \"https://registry.npmjs.org\"\n },\n \"files\": [\n \"dist\",\n \"storefront.schema.json\",\n \"customer-account.schema.json\"\n ],\n \"type\": \"commonjs\",\n \"exports\": {\n \".\": {\n \"node\": {\n \"require\": {\n \"types\": \"./dist/types/index.d.cts\",\n \"development\": \"./dist/node-dev/index.js\",\n \"default\": \"./dist/node-prod/index.js\"\n },\n \"import\": {\n \"types\": \"./dist/types/index.d.ts\",\n \"development\": \"./dist/node-dev/index.mjs\",\n \"default\": \"./dist/node-prod/index.mjs\"\n },\n \"default\": \"./dist/node-prod/index.js\"\n },\n \"module\": {\n \"types\": \"./dist/types/index.d.ts\",\n \"development\": \"./dist/browser-dev/index.mjs\",\n \"default\": \"./dist/browser-prod/index.mjs\"\n },\n \"import\": {\n \"types\": \"./dist/types/index.d.ts\",\n \"development\": \"./dist/browser-dev/index.mjs\",\n \"default\": \"./dist/browser-prod/index.mjs\"\n },\n \"require\": {\n \"types\": \"./dist/types/index.d.cts\",\n \"development\": \"./dist/node-dev/index.js\",\n \"default\": \"./dist/node-prod/index.js\"\n },\n \"default\": \"./dist/browser-prod/index.mjs\"\n },\n \"./storefront-api-types\": \"./dist/types/storefront-api-types.d.ts\",\n \"./storefront.schema.json\": \"./storefront.schema.json\",\n \"./customer-account.schema.json\": \"./customer-account.schema.json\",\n \"./customer-account-api-types\": \"./dist/types/customer-account-api-types.d.ts\",\n \"./package.json\": \"./package.json\",\n \"./*\": {\n \"node\": {\n \"require\": {\n \"types\": \"./dist/types/*.d.cts\",\n \"development\": \"./dist/node-dev/*.js\",\n \"default\": \"./dist/node-prod/*.js\"\n },\n \"import\": {\n \"types\": \"./dist/types/*.d.ts\",\n \"development\": \"./dist/node-dev/*.mjs\",\n \"default\": \"./dist/node-prod/*.mjs\"\n },\n \"default\": \"./dist/node-prod/*.js\"\n },\n \"module\": {\n \"types\": \"./dist/types/*.d.ts\",\n \"development\": \"./dist/browser-dev/*.mjs\",\n \"default\": \"./dist/browser-prod/*.mjs\"\n },\n \"import\": {\n \"types\": \"./dist/types/*.d.ts\",\n \"development\": \"./dist/browser-dev/*.mjs\",\n \"default\": \"./dist/browser-prod/*.mjs\"\n },\n \"require\": {\n \"types\": \"./dist/types/*.d.cts\",\n \"development\": \"./dist/node-dev/*.js\",\n \"default\": \"./dist/node-prod/*.js\"\n },\n \"default\": \"./dist/browser-prod/*.mjs\"\n }\n },\n \"typesVersions\": {\n \"*\": {\n \"storefront-api-types\": [\n \"./dist/types/storefront-api-types.d.ts\"\n ]\n }\n },\n \"main\": \"./dist/node-prod/index.js\",\n \"module\": \"./dist/node-prod/index.mjs\",\n \"browser\": \"./dist/browser-prod/index.mjs\",\n \"types\": \"./dist/types/index.d.ts\",\n \"unpkg\": \"./dist/umd/hydrogen-react.prod.js\",\n \"jsdelivr\": \"./dist/umd/hydrogen-react.prod.js\",\n \"sideEffects\": false,\n \"scripts\": {\n \"build-docs\": \"sh ./docs/build-docs.sh && pnpm run format\",\n \"clean-dist\": \"rimraf ./dist\",\n \"dev\": \"run-s dev:demo\",\n \"dev:story\": \"ladle serve\",\n \"dev:demo\": \"run-p dev:demo:* copy-api-types\",\n \"dev:demo:browser-dev\": \"vite build --watch --emptyOutDir false --clearScreen false --mode devbuild\",\n \"dev:demo:ts\": \"tsc --watch --emitDeclarationOnly\",\n \"build\": \"npm-run-all --sequential clean-dist --parallel build:vite:* build:tsc:es --parallel build:tsc:cjs copy-api-types\",\n \"build:vite:browser-dev\": \"vite build --mode devbuild\",\n \"build:vite:browser-prod\": \"vite build\",\n \"build:vite:node-dev\": \"vite build --mode devbuild --ssr\",\n \"build:vite:node-prod\": \"vite build --ssr\",\n \"build:vite:umddev\": \"vite build --mode umdbuilddev\",\n \"build:vite:umdprod\": \"vite build --mode umdbuild\",\n \"build:tsc:cjs\": \"cpy ./dist/types/index.d.ts ./dist/types/ --rename=index.d.cts --flat\",\n \"build:tsc:es\": \"tsc --emitDeclarationOnly --project tsconfig.typeoutput.json\",\n \"copy-api-types\": \"cpy ./src/storefront-api-types.d.ts ./src/customer-account-api-types.d.ts ./dist/types/ --flat\",\n \"format\": \"prettier --write \\\"{src,docs}/**/*\\\" --ignore-unknown\",\n \"graphql-types\": \"graphql-codegen --config codegen.ts && pnpm run format\",\n \"test\": \"vitest run --coverage\",\n \"test:watch\": \"vitest\",\n \"typecheck\": \"run-p typecheck:*\",\n \"typecheck:code\": \"tsc --noEmit\",\n \"typecheck:examples\": \"tsc --noEmit --project tsconfig.examples.json\",\n \"preview-docs\": \"pnpm --dir ../../docs/preview run dev\"\n },\n \"devDependencies\": {\n \"@faker-js/faker\": \"^9.4.0\",\n \"@graphql-codegen/add\": \"^5.0.3\",\n \"@graphql-codegen/cli\": \"^5.0.4\",\n \"@graphql-codegen/introspection\": \"^4.0.3\",\n \"@graphql-codegen/typescript\": \"^4.1.3\",\n \"@ladle/react\": \"^5.0.1\",\n \"@shopify/generate-docs\": \"catalog:\",\n \"@testing-library/jest-dom\": \"^6.6.3\",\n \"@testing-library/react\": \"^14.0.0\",\n \"@testing-library/user-event\": \"^14.6.1\",\n \"@types/react\": \"catalog:\",\n \"@types/react-dom\": \"catalog:\",\n \"@vitejs/plugin-react\": \"^6.0.1\",\n \"@vitest/coverage-v8\": \"^3.2.4\",\n \"cpy-cli\": \"^5.0.0\",\n \"eslint\": \"9.19.0\",\n \"eslint-config-prettier\": \"10.0.1\",\n \"eslint-import-resolver-typescript\": \"3.7.0\",\n \"eslint-plugin-eslint-comments\": \"3.2.0\",\n \"eslint-plugin-import\": \"2.31.0\",\n \"eslint-plugin-jest\": \"28.11.0\",\n \"eslint-plugin-jsx-a11y\": \"6.10.2\",\n \"eslint-plugin-node\": \"11.1.0\",\n \"eslint-plugin-prettier\": \"4.2.1\",\n \"eslint-plugin-react\": \"7.37.4\",\n \"eslint-plugin-react-hooks\": \"5.1.0\",\n \"eslint-plugin-simple-import-sort\": \"12.1.1\",\n \"eslint-plugin-tsdoc\": \"0.2.14\",\n \"happy-dom\": \"^20.8.9\",\n \"npm-run-all\": \"^4.1.5\",\n \"react\": \"catalog:\",\n \"react-dom\": \"catalog:\",\n \"rimraf\": \"^6.0.1\",\n \"ts-expect\": \"^1.3.0\",\n \"typescript\": \"5.9.2\",\n \"vite\": \"^8.0.1\",\n \"vitest\": \"^3.2.4\"\n },\n \"peerDependencies\": {\n \"react\": \"^18.3.1 || ~19.0.3 || ~19.1.4 || ^19.2.3\",\n \"react-dom\": \"^18.3.1 || ~19.0.3 || ~19.1.4 || ^19.2.3\",\n \"vite\": \"^5.1.0 || ^6.2.1 || ^7.0.0 || ^8.0.0\"\n },\n \"dependencies\": {\n \"@google/model-viewer\": \"^4.0.0\",\n \"@xstate/fsm\": \"2.0.0\",\n \"ast-v8-to-istanbul\": \"^0.3.11\",\n \"graphql\": \"^16.10.0\",\n \"type-fest\": \"^4.33.0\",\n \"worktop\": \"^0.7.3\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/Shopify/hydrogen.git\",\n \"directory\": \"packages/hydrogen-react\"\n },\n \"bugs\": \"https://github.com/shopify/hydrogen/issues\"\n}\n"],"mappings":""}
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "2026.4.2";
2
+ var version = "2026.4.4";
3
3
  //#endregion
4
4
  export { version };
5
5
 
@@ -1 +1 @@
1
- {"version":3,"file":"package.mjs","names":[],"sources":["../../../../package.json"],"sourcesContent":["{\n \"name\": \"@shopify/hydrogen-react\",\n \"version\": \"2026.4.2\",\n \"description\": \"React components, hooks, and utilities for creating custom Shopify storefronts\",\n \"homepage\": \"https://github.com/Shopify/hydrogen/tree/main/packages/hydrogen-react\",\n \"license\": \"MIT\",\n \"publishConfig\": {\n \"access\": \"public\",\n \"@shopify:registry\": \"https://registry.npmjs.org\"\n },\n \"files\": [\n \"dist\",\n \"storefront.schema.json\",\n \"customer-account.schema.json\"\n ],\n \"type\": \"commonjs\",\n \"exports\": {\n \".\": {\n \"node\": {\n \"require\": {\n \"types\": \"./dist/types/index.d.cts\",\n \"development\": \"./dist/node-dev/index.js\",\n \"default\": \"./dist/node-prod/index.js\"\n },\n \"import\": {\n \"types\": \"./dist/types/index.d.ts\",\n \"development\": \"./dist/node-dev/index.mjs\",\n \"default\": \"./dist/node-prod/index.mjs\"\n },\n \"default\": \"./dist/node-prod/index.js\"\n },\n \"module\": {\n \"types\": \"./dist/types/index.d.ts\",\n \"development\": \"./dist/browser-dev/index.mjs\",\n \"default\": \"./dist/browser-prod/index.mjs\"\n },\n \"import\": {\n \"types\": \"./dist/types/index.d.ts\",\n \"development\": \"./dist/browser-dev/index.mjs\",\n \"default\": \"./dist/browser-prod/index.mjs\"\n },\n \"require\": {\n \"types\": \"./dist/types/index.d.cts\",\n \"development\": \"./dist/node-dev/index.js\",\n \"default\": \"./dist/node-prod/index.js\"\n },\n \"default\": \"./dist/browser-prod/index.mjs\"\n },\n \"./storefront-api-types\": \"./dist/types/storefront-api-types.d.ts\",\n \"./storefront.schema.json\": \"./storefront.schema.json\",\n \"./customer-account.schema.json\": \"./customer-account.schema.json\",\n \"./customer-account-api-types\": \"./dist/types/customer-account-api-types.d.ts\",\n \"./package.json\": \"./package.json\",\n \"./*\": {\n \"node\": {\n \"require\": {\n \"types\": \"./dist/types/*.d.cts\",\n \"development\": \"./dist/node-dev/*.js\",\n \"default\": \"./dist/node-prod/*.js\"\n },\n \"import\": {\n \"types\": \"./dist/types/*.d.ts\",\n \"development\": \"./dist/node-dev/*.mjs\",\n \"default\": \"./dist/node-prod/*.mjs\"\n },\n \"default\": \"./dist/node-prod/*.js\"\n },\n \"module\": {\n \"types\": \"./dist/types/*.d.ts\",\n \"development\": \"./dist/browser-dev/*.mjs\",\n \"default\": \"./dist/browser-prod/*.mjs\"\n },\n \"import\": {\n \"types\": \"./dist/types/*.d.ts\",\n \"development\": \"./dist/browser-dev/*.mjs\",\n \"default\": \"./dist/browser-prod/*.mjs\"\n },\n \"require\": {\n \"types\": \"./dist/types/*.d.cts\",\n \"development\": \"./dist/node-dev/*.js\",\n \"default\": \"./dist/node-prod/*.js\"\n },\n \"default\": \"./dist/browser-prod/*.mjs\"\n }\n },\n \"typesVersions\": {\n \"*\": {\n \"storefront-api-types\": [\n \"./dist/types/storefront-api-types.d.ts\"\n ]\n }\n },\n \"main\": \"./dist/node-prod/index.js\",\n \"module\": \"./dist/node-prod/index.mjs\",\n \"browser\": \"./dist/browser-prod/index.mjs\",\n \"types\": \"./dist/types/index.d.ts\",\n \"unpkg\": \"./dist/umd/hydrogen-react.prod.js\",\n \"jsdelivr\": \"./dist/umd/hydrogen-react.prod.js\",\n \"sideEffects\": false,\n \"scripts\": {\n \"build-docs\": \"sh ./docs/build-docs.sh && pnpm run format\",\n \"clean-dist\": \"rimraf ./dist\",\n \"dev\": \"run-s dev:demo\",\n \"dev:story\": \"ladle serve\",\n \"dev:demo\": \"run-p dev:demo:* copy-api-types\",\n \"dev:demo:browser-dev\": \"vite build --watch --emptyOutDir false --clearScreen false --mode devbuild\",\n \"dev:demo:ts\": \"tsc --watch --emitDeclarationOnly\",\n \"build\": \"npm-run-all --sequential clean-dist --parallel build:vite:* build:tsc:es --parallel build:tsc:cjs copy-api-types\",\n \"build:vite:browser-dev\": \"vite build --mode devbuild\",\n \"build:vite:browser-prod\": \"vite build\",\n \"build:vite:node-dev\": \"vite build --mode devbuild --ssr\",\n \"build:vite:node-prod\": \"vite build --ssr\",\n \"build:vite:umddev\": \"vite build --mode umdbuilddev\",\n \"build:vite:umdprod\": \"vite build --mode umdbuild\",\n \"build:tsc:cjs\": \"cpy ./dist/types/index.d.ts ./dist/types/ --rename=index.d.cts --flat\",\n \"build:tsc:es\": \"tsc --emitDeclarationOnly --project tsconfig.typeoutput.json\",\n \"copy-api-types\": \"cpy ./src/storefront-api-types.d.ts ./src/customer-account-api-types.d.ts ./dist/types/ --flat\",\n \"format\": \"prettier --write \\\"{src,docs}/**/*\\\" --ignore-unknown\",\n \"graphql-types\": \"graphql-codegen --config codegen.ts && pnpm run format\",\n \"test\": \"vitest run --coverage\",\n \"test:watch\": \"vitest\",\n \"typecheck\": \"run-p typecheck:*\",\n \"typecheck:code\": \"tsc --noEmit\",\n \"typecheck:examples\": \"tsc --noEmit --project tsconfig.examples.json\",\n \"preview-docs\": \"pnpm --dir ../../docs/preview run dev\"\n },\n \"devDependencies\": {\n \"@faker-js/faker\": \"^9.4.0\",\n \"@graphql-codegen/add\": \"^5.0.3\",\n \"@graphql-codegen/cli\": \"^5.0.4\",\n \"@graphql-codegen/introspection\": \"^4.0.3\",\n \"@graphql-codegen/typescript\": \"^4.1.3\",\n \"@ladle/react\": \"^5.0.1\",\n \"@shopify/generate-docs\": \"catalog:\",\n \"@testing-library/jest-dom\": \"^6.6.3\",\n \"@testing-library/react\": \"^14.0.0\",\n \"@testing-library/user-event\": \"^14.6.1\",\n \"@types/react\": \"catalog:\",\n \"@types/react-dom\": \"catalog:\",\n \"@vitejs/plugin-react\": \"^6.0.1\",\n \"@vitest/coverage-v8\": \"^3.2.4\",\n \"cpy-cli\": \"^5.0.0\",\n \"eslint\": \"9.19.0\",\n \"eslint-config-prettier\": \"10.0.1\",\n \"eslint-import-resolver-typescript\": \"3.7.0\",\n \"eslint-plugin-eslint-comments\": \"3.2.0\",\n \"eslint-plugin-import\": \"2.31.0\",\n \"eslint-plugin-jest\": \"28.11.0\",\n \"eslint-plugin-jsx-a11y\": \"6.10.2\",\n \"eslint-plugin-node\": \"11.1.0\",\n \"eslint-plugin-prettier\": \"4.2.1\",\n \"eslint-plugin-react\": \"7.37.4\",\n \"eslint-plugin-react-hooks\": \"5.1.0\",\n \"eslint-plugin-simple-import-sort\": \"12.1.1\",\n \"eslint-plugin-tsdoc\": \"0.2.14\",\n \"happy-dom\": \"^20.8.9\",\n \"npm-run-all\": \"^4.1.5\",\n \"react\": \"catalog:\",\n \"react-dom\": \"catalog:\",\n \"rimraf\": \"^6.0.1\",\n \"ts-expect\": \"^1.3.0\",\n \"typescript\": \"5.9.2\",\n \"vite\": \"^8.0.1\",\n \"vitest\": \"^3.2.4\"\n },\n \"peerDependencies\": {\n \"react\": \"^18.3.1 || ~19.0.3 || ~19.1.4 || ^19.2.3\",\n \"react-dom\": \"^18.3.1 || ~19.0.3 || ~19.1.4 || ^19.2.3\",\n \"vite\": \"^5.1.0 || ^6.2.1 || ^7.0.0 || ^8.0.0\"\n },\n \"dependencies\": {\n \"@google/model-viewer\": \"^4.0.0\",\n \"@xstate/fsm\": \"2.0.0\",\n \"ast-v8-to-istanbul\": \"^0.3.11\",\n \"graphql\": \"^16.10.0\",\n \"type-fest\": \"^4.33.0\",\n \"worktop\": \"^0.7.3\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/Shopify/hydrogen.git\",\n \"directory\": \"packages/hydrogen-react\"\n },\n \"bugs\": \"https://github.com/shopify/hydrogen/issues\"\n}\n"],"mappings":""}
1
+ {"version":3,"file":"package.mjs","names":[],"sources":["../../../../package.json"],"sourcesContent":["{\n \"name\": \"@shopify/hydrogen-react\",\n \"version\": \"2026.4.4\",\n \"description\": \"React components, hooks, and utilities for creating custom Shopify storefronts\",\n \"homepage\": \"https://github.com/Shopify/hydrogen/tree/main/packages/hydrogen-react\",\n \"license\": \"MIT\",\n \"publishConfig\": {\n \"access\": \"public\",\n \"@shopify:registry\": \"https://registry.npmjs.org\"\n },\n \"files\": [\n \"dist\",\n \"storefront.schema.json\",\n \"customer-account.schema.json\"\n ],\n \"type\": \"commonjs\",\n \"exports\": {\n \".\": {\n \"node\": {\n \"require\": {\n \"types\": \"./dist/types/index.d.cts\",\n \"development\": \"./dist/node-dev/index.js\",\n \"default\": \"./dist/node-prod/index.js\"\n },\n \"import\": {\n \"types\": \"./dist/types/index.d.ts\",\n \"development\": \"./dist/node-dev/index.mjs\",\n \"default\": \"./dist/node-prod/index.mjs\"\n },\n \"default\": \"./dist/node-prod/index.js\"\n },\n \"module\": {\n \"types\": \"./dist/types/index.d.ts\",\n \"development\": \"./dist/browser-dev/index.mjs\",\n \"default\": \"./dist/browser-prod/index.mjs\"\n },\n \"import\": {\n \"types\": \"./dist/types/index.d.ts\",\n \"development\": \"./dist/browser-dev/index.mjs\",\n \"default\": \"./dist/browser-prod/index.mjs\"\n },\n \"require\": {\n \"types\": \"./dist/types/index.d.cts\",\n \"development\": \"./dist/node-dev/index.js\",\n \"default\": \"./dist/node-prod/index.js\"\n },\n \"default\": \"./dist/browser-prod/index.mjs\"\n },\n \"./storefront-api-types\": \"./dist/types/storefront-api-types.d.ts\",\n \"./storefront.schema.json\": \"./storefront.schema.json\",\n \"./customer-account.schema.json\": \"./customer-account.schema.json\",\n \"./customer-account-api-types\": \"./dist/types/customer-account-api-types.d.ts\",\n \"./package.json\": \"./package.json\",\n \"./*\": {\n \"node\": {\n \"require\": {\n \"types\": \"./dist/types/*.d.cts\",\n \"development\": \"./dist/node-dev/*.js\",\n \"default\": \"./dist/node-prod/*.js\"\n },\n \"import\": {\n \"types\": \"./dist/types/*.d.ts\",\n \"development\": \"./dist/node-dev/*.mjs\",\n \"default\": \"./dist/node-prod/*.mjs\"\n },\n \"default\": \"./dist/node-prod/*.js\"\n },\n \"module\": {\n \"types\": \"./dist/types/*.d.ts\",\n \"development\": \"./dist/browser-dev/*.mjs\",\n \"default\": \"./dist/browser-prod/*.mjs\"\n },\n \"import\": {\n \"types\": \"./dist/types/*.d.ts\",\n \"development\": \"./dist/browser-dev/*.mjs\",\n \"default\": \"./dist/browser-prod/*.mjs\"\n },\n \"require\": {\n \"types\": \"./dist/types/*.d.cts\",\n \"development\": \"./dist/node-dev/*.js\",\n \"default\": \"./dist/node-prod/*.js\"\n },\n \"default\": \"./dist/browser-prod/*.mjs\"\n }\n },\n \"typesVersions\": {\n \"*\": {\n \"storefront-api-types\": [\n \"./dist/types/storefront-api-types.d.ts\"\n ]\n }\n },\n \"main\": \"./dist/node-prod/index.js\",\n \"module\": \"./dist/node-prod/index.mjs\",\n \"browser\": \"./dist/browser-prod/index.mjs\",\n \"types\": \"./dist/types/index.d.ts\",\n \"unpkg\": \"./dist/umd/hydrogen-react.prod.js\",\n \"jsdelivr\": \"./dist/umd/hydrogen-react.prod.js\",\n \"sideEffects\": false,\n \"scripts\": {\n \"build-docs\": \"sh ./docs/build-docs.sh && pnpm run format\",\n \"clean-dist\": \"rimraf ./dist\",\n \"dev\": \"run-s dev:demo\",\n \"dev:story\": \"ladle serve\",\n \"dev:demo\": \"run-p dev:demo:* copy-api-types\",\n \"dev:demo:browser-dev\": \"vite build --watch --emptyOutDir false --clearScreen false --mode devbuild\",\n \"dev:demo:ts\": \"tsc --watch --emitDeclarationOnly\",\n \"build\": \"npm-run-all --sequential clean-dist --parallel build:vite:* build:tsc:es --parallel build:tsc:cjs copy-api-types\",\n \"build:vite:browser-dev\": \"vite build --mode devbuild\",\n \"build:vite:browser-prod\": \"vite build\",\n \"build:vite:node-dev\": \"vite build --mode devbuild --ssr\",\n \"build:vite:node-prod\": \"vite build --ssr\",\n \"build:vite:umddev\": \"vite build --mode umdbuilddev\",\n \"build:vite:umdprod\": \"vite build --mode umdbuild\",\n \"build:tsc:cjs\": \"cpy ./dist/types/index.d.ts ./dist/types/ --rename=index.d.cts --flat\",\n \"build:tsc:es\": \"tsc --emitDeclarationOnly --project tsconfig.typeoutput.json\",\n \"copy-api-types\": \"cpy ./src/storefront-api-types.d.ts ./src/customer-account-api-types.d.ts ./dist/types/ --flat\",\n \"format\": \"prettier --write \\\"{src,docs}/**/*\\\" --ignore-unknown\",\n \"graphql-types\": \"graphql-codegen --config codegen.ts && pnpm run format\",\n \"test\": \"vitest run --coverage\",\n \"test:watch\": \"vitest\",\n \"typecheck\": \"run-p typecheck:*\",\n \"typecheck:code\": \"tsc --noEmit\",\n \"typecheck:examples\": \"tsc --noEmit --project tsconfig.examples.json\",\n \"preview-docs\": \"pnpm --dir ../../docs/preview run dev\"\n },\n \"devDependencies\": {\n \"@faker-js/faker\": \"^9.4.0\",\n \"@graphql-codegen/add\": \"^5.0.3\",\n \"@graphql-codegen/cli\": \"^5.0.4\",\n \"@graphql-codegen/introspection\": \"^4.0.3\",\n \"@graphql-codegen/typescript\": \"^4.1.3\",\n \"@ladle/react\": \"^5.0.1\",\n \"@shopify/generate-docs\": \"catalog:\",\n \"@testing-library/jest-dom\": \"^6.6.3\",\n \"@testing-library/react\": \"^14.0.0\",\n \"@testing-library/user-event\": \"^14.6.1\",\n \"@types/react\": \"catalog:\",\n \"@types/react-dom\": \"catalog:\",\n \"@vitejs/plugin-react\": \"^6.0.1\",\n \"@vitest/coverage-v8\": \"^3.2.4\",\n \"cpy-cli\": \"^5.0.0\",\n \"eslint\": \"9.19.0\",\n \"eslint-config-prettier\": \"10.0.1\",\n \"eslint-import-resolver-typescript\": \"3.7.0\",\n \"eslint-plugin-eslint-comments\": \"3.2.0\",\n \"eslint-plugin-import\": \"2.31.0\",\n \"eslint-plugin-jest\": \"28.11.0\",\n \"eslint-plugin-jsx-a11y\": \"6.10.2\",\n \"eslint-plugin-node\": \"11.1.0\",\n \"eslint-plugin-prettier\": \"4.2.1\",\n \"eslint-plugin-react\": \"7.37.4\",\n \"eslint-plugin-react-hooks\": \"5.1.0\",\n \"eslint-plugin-simple-import-sort\": \"12.1.1\",\n \"eslint-plugin-tsdoc\": \"0.2.14\",\n \"happy-dom\": \"^20.8.9\",\n \"npm-run-all\": \"^4.1.5\",\n \"react\": \"catalog:\",\n \"react-dom\": \"catalog:\",\n \"rimraf\": \"^6.0.1\",\n \"ts-expect\": \"^1.3.0\",\n \"typescript\": \"5.9.2\",\n \"vite\": \"^8.0.1\",\n \"vitest\": \"^3.2.4\"\n },\n \"peerDependencies\": {\n \"react\": \"^18.3.1 || ~19.0.3 || ~19.1.4 || ^19.2.3\",\n \"react-dom\": \"^18.3.1 || ~19.0.3 || ~19.1.4 || ^19.2.3\",\n \"vite\": \"^5.1.0 || ^6.2.1 || ^7.0.0 || ^8.0.0\"\n },\n \"dependencies\": {\n \"@google/model-viewer\": \"^4.0.0\",\n \"@xstate/fsm\": \"2.0.0\",\n \"ast-v8-to-istanbul\": \"^0.3.11\",\n \"graphql\": \"^16.10.0\",\n \"type-fest\": \"^4.33.0\",\n \"worktop\": \"^0.7.3\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/Shopify/hydrogen.git\",\n \"directory\": \"packages/hydrogen-react\"\n },\n \"bugs\": \"https://github.com/shopify/hydrogen/issues\"\n}\n"],"mappings":""}
@@ -3,68 +3,27 @@
3
3
  var SHOPIFY_VISIT_TOKEN_HEADER = "X-Shopify-VisitToken";
4
4
  /** Storefront API header for UniqueToken */
5
5
  var SHOPIFY_UNIQUE_TOKEN_HEADER = "X-Shopify-UniqueToken";
6
- var cachedTrackingValues = { current: null };
7
6
  /**
8
- * Retrieves user session tracking values for analytics and marketing from the browser environment.
7
+ * Retrieves user session tracking values for analytics and marketing from the
8
+ * browser environment. Customer Privacy API token readers are authoritative
9
+ * when available, including when consent denies tracking. Deprecated
10
+ * `_shopify_y`/`_shopify_s` cookies are read only without an API token reader.
11
+ * Consent comes from CTA's cache or the legacy `_tracking_consent` cookie.
9
12
  * @publicDocs
10
13
  */
11
14
  function getTrackingValues() {
12
- let trackingValues;
13
- if (typeof window !== "undefined" && typeof window.performance !== "undefined") try {
14
- const resourceRE = /^https?:\/\/([^/]+)(\/api\/(?:unstable|2\d{3}-\d{2})\/graphql\.json(?=$|\?))?/;
15
- const entries = performance.getEntriesByType("resource");
16
- let matchedValues;
17
- for (let i = entries.length - 1; i >= 0; i--) {
18
- const entry = entries[i];
19
- if (entry.initiatorType !== "fetch") continue;
20
- const currentHost = window.location.host;
21
- const match = entry.name.match(resourceRE);
22
- if (!match) continue;
23
- const [, matchedHost, sfapiPath] = match;
24
- if (matchedHost === currentHost || sfapiPath && matchedHost?.endsWith(`.${currentHost}`)) {
25
- const values = extractFromPerformanceEntry(entry);
26
- if (values) {
27
- matchedValues = values;
28
- break;
29
- }
30
- }
31
- }
32
- if (matchedValues) trackingValues = matchedValues;
33
- if (trackingValues) cachedTrackingValues.current = trackingValues;
34
- else if (cachedTrackingValues.current) trackingValues = cachedTrackingValues.current;
35
- if (!trackingValues) {
36
- const navigationEntries = performance.getEntriesByType("navigation")[0];
37
- trackingValues = extractFromPerformanceEntry(navigationEntries, false);
38
- }
39
- } catch {}
40
- if (!trackingValues) {
41
- const cookie = typeof arguments[0] === "string" ? arguments[0] : typeof document !== "undefined" ? document.cookie : "";
42
- trackingValues = {
43
- uniqueToken: cookie.match(/\b_shopify_y=([^;]+)/)?.[1] || "",
44
- visitToken: cookie.match(/\b_shopify_s=([^;]+)/)?.[1] || "",
45
- consent: cookie.match(/\b_tracking_consent=([^;]+)/)?.[1] || ""
46
- };
47
- }
48
- return trackingValues;
49
- }
50
- function extractFromPerformanceEntry(entry, isConsentRequired = true) {
51
- let uniqueToken = "";
52
- let visitToken = "";
53
- let consent = "";
54
- const serverTiming = entry.serverTiming;
55
- if (serverTiming && serverTiming.length >= 3) for (let i = serverTiming.length - 1; i >= 0; i--) {
56
- const { name, description } = serverTiming[i];
57
- if (!name || !description) continue;
58
- if (name === "_y") uniqueToken = description;
59
- else if (name === "_s") visitToken = description;
60
- else if (name === "_cmp") consent = description;
61
- if (uniqueToken && visitToken && consent) break;
62
- }
63
- return uniqueToken && visitToken && (isConsentRequired ? consent : true) ? {
64
- uniqueToken,
65
- visitToken,
66
- consent
67
- } : void 0;
15
+ const cookie = typeof arguments[0] === "string" ? arguments[0] : typeof document !== "undefined" ? document.cookie : "";
16
+ const customerPrivacy = typeof window === "undefined" ? void 0 : window.Shopify?.customerPrivacy;
17
+ const internal = customerPrivacy?.__internal;
18
+ const tokenOptions = {
19
+ generateFallback: customerPrivacy?.config?.asyncConsent === true,
20
+ tag: "hydrogen:classic"
21
+ };
22
+ return {
23
+ uniqueToken: internal?.uniqueToken ? internal.uniqueToken(tokenOptions) ?? "" : cookie.match(/\b_shopify_y=([^;]+)/)?.[1] ?? "",
24
+ visitToken: internal?.visitToken ? internal.visitToken(tokenOptions) ?? "" : cookie.match(/\b_shopify_s=([^;]+)/)?.[1] ?? "",
25
+ consent: customerPrivacy?.cachedConsent ?? cookie.match(/\b_tracking_consent=([^;]+)/)?.[1] ?? ""
26
+ };
68
27
  }
69
28
  //#endregion
70
29
  exports.SHOPIFY_UNIQUE_TOKEN_HEADER = SHOPIFY_UNIQUE_TOKEN_HEADER;
@@ -1 +1 @@
1
- {"version":3,"file":"tracking-utils.js","names":[],"sources":["../../src/tracking-utils.ts"],"sourcesContent":["/** Storefront API header for VisitToken */\nexport const SHOPIFY_VISIT_TOKEN_HEADER = 'X-Shopify-VisitToken';\n/** Storefront API header for UniqueToken */\nexport const SHOPIFY_UNIQUE_TOKEN_HEADER = 'X-Shopify-UniqueToken';\n\ntype TrackingValues = {\n /** Identifier for the unique user. Equivalent to the deprecated _shopify_y cookie */\n uniqueToken: string;\n /** Identifier for the current visit. Equivalent to the deprecated _shopify_s cookie */\n visitToken: string;\n /** Represents the consent given by the user or the default region consent configured in Admin */\n consent: string;\n};\n\n// Cache values to avoid losing them when performance\n// entries are cleared from the buffer over time.\nexport const cachedTrackingValues: {\n current: null | TrackingValues;\n} = {current: null};\n\n/**\n * Retrieves user session tracking values for analytics and marketing from the browser environment.\n * @publicDocs\n */\nexport function getTrackingValues(): TrackingValues {\n // Overall behavior: Tracking values are returned in Server-Timing headers from\n // Storefront API responses, and we want to find and return these tracking values.\n //\n // Search recent fetches for SFAPI requests matching either: same origin (proxy case)\n // or a subdomain of the current host (eg: checkout subdomain, if there is no proxy).\n // We consider SF API-like endpoints (/api/.../graphql.json) on subdomains, as well as\n // any same-origin request. The reason for the latter is that Hydrogen server collects\n // tracking values and returns them in any non-cached response, not just direct SF API\n // responses. For example, a cart mutation in a server action could return tracking values.\n //\n // If we didn't find tracking values in fetch requests, we fall back to checking cached values,\n // then the initial page navigation entry, and finally the deprecated `_shopify_s` and `_shopify_y`.\n\n let trackingValues: TrackingValues | undefined;\n\n if (\n typeof window !== 'undefined' &&\n typeof window.performance !== 'undefined'\n ) {\n try {\n // RE to extract host and optionally match SFAPI pathname.\n // Group 1: host (e.g. \"checkout.mystore.com\")\n // Group 2: SFAPI path if present (e.g. \"/api/2024-01/graphql.json\")\n const resourceRE =\n /^https?:\\/\\/([^/]+)(\\/api\\/(?:unstable|2\\d{3}-\\d{2})\\/graphql\\.json(?=$|\\?))?/;\n\n // Search backwards through resource entries to find the most recent match.\n // Match criteria (first one with _y and _s values wins):\n // - Same origin (exact host match) with tracking values, OR\n // - Subdomain + SFAPI pathname with tracking values\n const entries = performance.getEntriesByType(\n 'resource',\n ) as PerformanceResourceTiming[];\n\n let matchedValues: ReturnType<typeof extractFromPerformanceEntry>;\n\n for (let i = entries.length - 1; i >= 0; i--) {\n const entry = entries[i];\n\n if (entry.initiatorType !== 'fetch') continue;\n\n const currentHost = window.location.host;\n const match = entry.name.match(resourceRE);\n if (!match) continue;\n\n const [, matchedHost, sfapiPath] = match;\n\n const isMatch =\n // Same origin (exact host match)\n matchedHost === currentHost ||\n // Subdomain with SFAPI path\n (sfapiPath && matchedHost?.endsWith(`.${currentHost}`));\n\n if (isMatch) {\n const values = extractFromPerformanceEntry(entry);\n if (values) {\n matchedValues = values;\n break;\n }\n }\n }\n\n if (matchedValues) {\n trackingValues = matchedValues;\n }\n\n // Resource entries have a limited buffer and are removed over time.\n // Cache the latest values for future calls if we find them.\n // A cached resource entry is always newer than a navigation entry.\n if (trackingValues) {\n cachedTrackingValues.current = trackingValues;\n } else if (cachedTrackingValues.current) {\n // Fallback to cached values from previous calls:\n trackingValues = cachedTrackingValues.current;\n }\n\n if (!trackingValues) {\n // Fallback to navigation entry from full page rendering load:\n const navigationEntries = performance.getEntriesByType(\n 'navigation',\n )[0] as PerformanceNavigationTiming;\n\n // Navigation entries might omit consent when the Hydrogen server generates it.\n // In this case, we skip consent requirement and only extract _y and _s values.\n trackingValues = extractFromPerformanceEntry(navigationEntries, false);\n }\n } catch {}\n }\n\n // Fallback to deprecated cookies to support transitioning:\n if (!trackingValues) {\n const cookie =\n // Read from arguments to avoid declaring parameters in this function signature.\n // This logic is only used internally from `getShopifyCookies` and will be deprecated.\n typeof arguments[0] === 'string'\n ? arguments[0]\n : typeof document !== 'undefined'\n ? document.cookie\n : '';\n\n trackingValues = {\n uniqueToken: cookie.match(/\\b_shopify_y=([^;]+)/)?.[1] || '',\n visitToken: cookie.match(/\\b_shopify_s=([^;]+)/)?.[1] || '',\n consent: cookie.match(/\\b_tracking_consent=([^;]+)/)?.[1] || '',\n };\n }\n\n return trackingValues;\n}\n\nfunction extractFromPerformanceEntry(\n entry: PerformanceNavigationTiming | PerformanceResourceTiming,\n isConsentRequired = true,\n): TrackingValues | undefined {\n let uniqueToken = '';\n let visitToken = '';\n let consent = '';\n\n const serverTiming = entry.serverTiming;\n // Quick check: we need at least 3 entries (_y, _s, _cmp)\n if (serverTiming && serverTiming.length >= 3) {\n // Iterate backwards since our headers are typically at the end\n for (let i = serverTiming.length - 1; i >= 0; i--) {\n const {name, description} = serverTiming[i];\n if (!name || !description) continue;\n\n if (name === '_y') {\n uniqueToken = description;\n } else if (name === '_s') {\n visitToken = description;\n } else if (name === '_cmp') {\n // _cmp (consent management platform) holds the consent value\n // used by consent-tracking-api and privacy-banner scripts.\n consent = description;\n }\n\n if (uniqueToken && visitToken && consent) break;\n }\n }\n\n return uniqueToken && visitToken && (isConsentRequired ? consent : true)\n ? {uniqueToken, visitToken, consent}\n : undefined;\n}\n"],"mappings":";;AACA,IAAa,6BAA6B;;AAE1C,IAAa,8BAA8B;AAa3C,IAAa,uBAET,EAAC,SAAS,MAAK;;;;;AAMnB,SAAgB,oBAAoC;CAclD,IAAI;AAEJ,KACE,OAAO,WAAW,eAClB,OAAO,OAAO,gBAAgB,YAE9B,KAAI;EAIF,MAAM,aACJ;EAMF,MAAM,UAAU,YAAY,iBAC1B,WACD;EAED,IAAI;AAEJ,OAAK,IAAI,IAAI,QAAQ,SAAS,GAAG,KAAK,GAAG,KAAK;GAC5C,MAAM,QAAQ,QAAQ;AAEtB,OAAI,MAAM,kBAAkB,QAAS;GAErC,MAAM,cAAc,OAAO,SAAS;GACpC,MAAM,QAAQ,MAAM,KAAK,MAAM,WAAW;AAC1C,OAAI,CAAC,MAAO;GAEZ,MAAM,GAAG,aAAa,aAAa;AAQnC,OAJE,gBAAgB,eAEf,aAAa,aAAa,SAAS,IAAI,cAAc,EAE3C;IACX,MAAM,SAAS,4BAA4B,MAAM;AACjD,QAAI,QAAQ;AACV,qBAAgB;AAChB;;;;AAKN,MAAI,cACF,kBAAiB;AAMnB,MAAI,eACF,sBAAqB,UAAU;WACtB,qBAAqB,QAE9B,kBAAiB,qBAAqB;AAGxC,MAAI,CAAC,gBAAgB;GAEnB,MAAM,oBAAoB,YAAY,iBACpC,aACD,CAAC;AAIF,oBAAiB,4BAA4B,mBAAmB,MAAM;;SAElE;AAIV,KAAI,CAAC,gBAAgB;EACnB,MAAM,SAGJ,OAAO,UAAU,OAAO,WACpB,UAAU,KACV,OAAO,aAAa,cAClB,SAAS,SACT;AAER,mBAAiB;GACf,aAAa,OAAO,MAAM,uBAAuB,GAAG,MAAM;GAC1D,YAAY,OAAO,MAAM,uBAAuB,GAAG,MAAM;GACzD,SAAS,OAAO,MAAM,8BAA8B,GAAG,MAAM;GAC9D;;AAGH,QAAO;;AAGT,SAAS,4BACP,OACA,oBAAoB,MACQ;CAC5B,IAAI,cAAc;CAClB,IAAI,aAAa;CACjB,IAAI,UAAU;CAEd,MAAM,eAAe,MAAM;AAE3B,KAAI,gBAAgB,aAAa,UAAU,EAEzC,MAAK,IAAI,IAAI,aAAa,SAAS,GAAG,KAAK,GAAG,KAAK;EACjD,MAAM,EAAC,MAAM,gBAAe,aAAa;AACzC,MAAI,CAAC,QAAQ,CAAC,YAAa;AAE3B,MAAI,SAAS,KACX,eAAc;WACL,SAAS,KAClB,cAAa;WACJ,SAAS,OAGlB,WAAU;AAGZ,MAAI,eAAe,cAAc,QAAS;;AAI9C,QAAO,eAAe,eAAe,oBAAoB,UAAU,QAC/D;EAAC;EAAa;EAAY;EAAQ,GAClC,KAAA"}
1
+ {"version":3,"file":"tracking-utils.js","names":[],"sources":["../../src/tracking-utils.ts"],"sourcesContent":["/** Storefront API header for VisitToken */\nexport const SHOPIFY_VISIT_TOKEN_HEADER = 'X-Shopify-VisitToken';\n/** Storefront API header for UniqueToken */\nexport const SHOPIFY_UNIQUE_TOKEN_HEADER = 'X-Shopify-UniqueToken';\n\ntype TrackingValues = {\n /** Identifier for the unique user. Equivalent to the deprecated _shopify_y cookie */\n uniqueToken: string;\n /** Identifier for the current visit. Equivalent to the deprecated _shopify_s cookie */\n visitToken: string;\n /** Represents the consent given by the user or the default region consent configured in Admin */\n consent: string;\n};\n\n// Keep the consent-tracking-api token interface out of Hydrogen's public\n// global types since it could change in the future.\ntype CustomerPrivacyWithTracking = {\n config?: {asyncConsent?: boolean};\n cachedConsent?: string;\n __internal?: {\n uniqueToken?: (options?: {\n generateFallback?: boolean;\n tag?: string;\n }) => string | undefined;\n visitToken?: (options?: {\n generateFallback?: boolean;\n tag?: string;\n }) => string | undefined;\n };\n};\n\n/**\n * Retrieves user session tracking values for analytics and marketing from the\n * browser environment. Customer Privacy API token readers are authoritative\n * when available, including when consent denies tracking. Deprecated\n * `_shopify_y`/`_shopify_s` cookies are read only without an API token reader.\n * Consent comes from CTA's cache or the legacy `_tracking_consent` cookie.\n * @publicDocs\n */\nexport function getTrackingValues(): TrackingValues {\n const cookie =\n // Read from arguments to avoid declaring parameters in this function signature.\n // This logic is only used internally from `getShopifyCookies` and will be deprecated.\n typeof arguments[0] === 'string'\n ? arguments[0]\n : typeof document !== 'undefined'\n ? document.cookie\n : '';\n\n const customerPrivacy =\n typeof window === 'undefined'\n ? undefined\n : (window as {Shopify?: {customerPrivacy?: CustomerPrivacyWithTracking}})\n .Shopify?.customerPrivacy;\n\n const internal = customerPrivacy?.__internal;\n // Async consent owns initialization and suppresses fallback generation until\n // it is loaded. Afterwards CTA can refresh expired tokens, as in preview.\n // Standalone hydrogen-react's explicit consent fetch keeps its previous policy.\n const tokenOptions = {\n generateFallback: customerPrivacy?.config?.asyncConsent === true,\n tag: 'hydrogen:classic',\n };\n\n return {\n // An installed CTA reader is authoritative, including undefined on denial.\n // Falling through to a legacy cookie could restore a disallowed token.\n uniqueToken: internal?.uniqueToken\n ? (internal.uniqueToken(tokenOptions) ?? '')\n : (cookie.match(/\\b_shopify_y=([^;]+)/)?.[1] ?? ''),\n visitToken: internal?.visitToken\n ? (internal.visitToken(tokenOptions) ?? '')\n : (cookie.match(/\\b_shopify_s=([^;]+)/)?.[1] ?? ''),\n consent:\n customerPrivacy?.cachedConsent ??\n cookie.match(/\\b_tracking_consent=([^;]+)/)?.[1] ??\n '',\n };\n}\n"],"mappings":";;AACA,IAAa,6BAA6B;;AAE1C,IAAa,8BAA8B;;;;;;;;;AAoC3C,SAAgB,oBAAoC;CAClD,MAAM,SAGJ,OAAO,UAAU,OAAO,WACpB,UAAU,KACV,OAAO,aAAa,cAClB,SAAS,SACT;CAER,MAAM,kBACJ,OAAO,WAAW,cACd,KAAA,IACC,OACE,SAAS;CAElB,MAAM,WAAW,iBAAiB;CAIlC,MAAM,eAAe;EACnB,kBAAkB,iBAAiB,QAAQ,iBAAiB;EAC5D,KAAK;EACN;AAED,QAAO;EAGL,aAAa,UAAU,cAClB,SAAS,YAAY,aAAa,IAAI,KACtC,OAAO,MAAM,uBAAuB,GAAG,MAAM;EAClD,YAAY,UAAU,aACjB,SAAS,WAAW,aAAa,IAAI,KACrC,OAAO,MAAM,uBAAuB,GAAG,MAAM;EAClD,SACE,iBAAiB,iBACjB,OAAO,MAAM,8BAA8B,GAAG,MAC9C;EACH"}
@@ -3,68 +3,27 @@
3
3
  var SHOPIFY_VISIT_TOKEN_HEADER = "X-Shopify-VisitToken";
4
4
  /** Storefront API header for UniqueToken */
5
5
  var SHOPIFY_UNIQUE_TOKEN_HEADER = "X-Shopify-UniqueToken";
6
- var cachedTrackingValues = { current: null };
7
6
  /**
8
- * Retrieves user session tracking values for analytics and marketing from the browser environment.
7
+ * Retrieves user session tracking values for analytics and marketing from the
8
+ * browser environment. Customer Privacy API token readers are authoritative
9
+ * when available, including when consent denies tracking. Deprecated
10
+ * `_shopify_y`/`_shopify_s` cookies are read only without an API token reader.
11
+ * Consent comes from CTA's cache or the legacy `_tracking_consent` cookie.
9
12
  * @publicDocs
10
13
  */
11
14
  function getTrackingValues() {
12
- let trackingValues;
13
- if (typeof window !== "undefined" && typeof window.performance !== "undefined") try {
14
- const resourceRE = /^https?:\/\/([^/]+)(\/api\/(?:unstable|2\d{3}-\d{2})\/graphql\.json(?=$|\?))?/;
15
- const entries = performance.getEntriesByType("resource");
16
- let matchedValues;
17
- for (let i = entries.length - 1; i >= 0; i--) {
18
- const entry = entries[i];
19
- if (entry.initiatorType !== "fetch") continue;
20
- const currentHost = window.location.host;
21
- const match = entry.name.match(resourceRE);
22
- if (!match) continue;
23
- const [, matchedHost, sfapiPath] = match;
24
- if (matchedHost === currentHost || sfapiPath && matchedHost?.endsWith(`.${currentHost}`)) {
25
- const values = extractFromPerformanceEntry(entry);
26
- if (values) {
27
- matchedValues = values;
28
- break;
29
- }
30
- }
31
- }
32
- if (matchedValues) trackingValues = matchedValues;
33
- if (trackingValues) cachedTrackingValues.current = trackingValues;
34
- else if (cachedTrackingValues.current) trackingValues = cachedTrackingValues.current;
35
- if (!trackingValues) {
36
- const navigationEntries = performance.getEntriesByType("navigation")[0];
37
- trackingValues = extractFromPerformanceEntry(navigationEntries, false);
38
- }
39
- } catch {}
40
- if (!trackingValues) {
41
- const cookie = typeof arguments[0] === "string" ? arguments[0] : typeof document !== "undefined" ? document.cookie : "";
42
- trackingValues = {
43
- uniqueToken: cookie.match(/\b_shopify_y=([^;]+)/)?.[1] || "",
44
- visitToken: cookie.match(/\b_shopify_s=([^;]+)/)?.[1] || "",
45
- consent: cookie.match(/\b_tracking_consent=([^;]+)/)?.[1] || ""
46
- };
47
- }
48
- return trackingValues;
49
- }
50
- function extractFromPerformanceEntry(entry, isConsentRequired = true) {
51
- let uniqueToken = "";
52
- let visitToken = "";
53
- let consent = "";
54
- const serverTiming = entry.serverTiming;
55
- if (serverTiming && serverTiming.length >= 3) for (let i = serverTiming.length - 1; i >= 0; i--) {
56
- const { name, description } = serverTiming[i];
57
- if (!name || !description) continue;
58
- if (name === "_y") uniqueToken = description;
59
- else if (name === "_s") visitToken = description;
60
- else if (name === "_cmp") consent = description;
61
- if (uniqueToken && visitToken && consent) break;
62
- }
63
- return uniqueToken && visitToken && (isConsentRequired ? consent : true) ? {
64
- uniqueToken,
65
- visitToken,
66
- consent
67
- } : void 0;
15
+ const cookie = typeof arguments[0] === "string" ? arguments[0] : typeof document !== "undefined" ? document.cookie : "";
16
+ const customerPrivacy = typeof window === "undefined" ? void 0 : window.Shopify?.customerPrivacy;
17
+ const internal = customerPrivacy?.__internal;
18
+ const tokenOptions = {
19
+ generateFallback: customerPrivacy?.config?.asyncConsent === true,
20
+ tag: "hydrogen:classic"
21
+ };
22
+ return {
23
+ uniqueToken: internal?.uniqueToken ? internal.uniqueToken(tokenOptions) ?? "" : cookie.match(/\b_shopify_y=([^;]+)/)?.[1] ?? "",
24
+ visitToken: internal?.visitToken ? internal.visitToken(tokenOptions) ?? "" : cookie.match(/\b_shopify_s=([^;]+)/)?.[1] ?? "",
25
+ consent: customerPrivacy?.cachedConsent ?? cookie.match(/\b_tracking_consent=([^;]+)/)?.[1] ?? ""
26
+ };
68
27
  }
69
28
  //#endregion
70
29
  export { SHOPIFY_UNIQUE_TOKEN_HEADER, SHOPIFY_VISIT_TOKEN_HEADER, getTrackingValues };
@@ -1 +1 @@
1
- {"version":3,"file":"tracking-utils.mjs","names":[],"sources":["../../src/tracking-utils.ts"],"sourcesContent":["/** Storefront API header for VisitToken */\nexport const SHOPIFY_VISIT_TOKEN_HEADER = 'X-Shopify-VisitToken';\n/** Storefront API header for UniqueToken */\nexport const SHOPIFY_UNIQUE_TOKEN_HEADER = 'X-Shopify-UniqueToken';\n\ntype TrackingValues = {\n /** Identifier for the unique user. Equivalent to the deprecated _shopify_y cookie */\n uniqueToken: string;\n /** Identifier for the current visit. Equivalent to the deprecated _shopify_s cookie */\n visitToken: string;\n /** Represents the consent given by the user or the default region consent configured in Admin */\n consent: string;\n};\n\n// Cache values to avoid losing them when performance\n// entries are cleared from the buffer over time.\nexport const cachedTrackingValues: {\n current: null | TrackingValues;\n} = {current: null};\n\n/**\n * Retrieves user session tracking values for analytics and marketing from the browser environment.\n * @publicDocs\n */\nexport function getTrackingValues(): TrackingValues {\n // Overall behavior: Tracking values are returned in Server-Timing headers from\n // Storefront API responses, and we want to find and return these tracking values.\n //\n // Search recent fetches for SFAPI requests matching either: same origin (proxy case)\n // or a subdomain of the current host (eg: checkout subdomain, if there is no proxy).\n // We consider SF API-like endpoints (/api/.../graphql.json) on subdomains, as well as\n // any same-origin request. The reason for the latter is that Hydrogen server collects\n // tracking values and returns them in any non-cached response, not just direct SF API\n // responses. For example, a cart mutation in a server action could return tracking values.\n //\n // If we didn't find tracking values in fetch requests, we fall back to checking cached values,\n // then the initial page navigation entry, and finally the deprecated `_shopify_s` and `_shopify_y`.\n\n let trackingValues: TrackingValues | undefined;\n\n if (\n typeof window !== 'undefined' &&\n typeof window.performance !== 'undefined'\n ) {\n try {\n // RE to extract host and optionally match SFAPI pathname.\n // Group 1: host (e.g. \"checkout.mystore.com\")\n // Group 2: SFAPI path if present (e.g. \"/api/2024-01/graphql.json\")\n const resourceRE =\n /^https?:\\/\\/([^/]+)(\\/api\\/(?:unstable|2\\d{3}-\\d{2})\\/graphql\\.json(?=$|\\?))?/;\n\n // Search backwards through resource entries to find the most recent match.\n // Match criteria (first one with _y and _s values wins):\n // - Same origin (exact host match) with tracking values, OR\n // - Subdomain + SFAPI pathname with tracking values\n const entries = performance.getEntriesByType(\n 'resource',\n ) as PerformanceResourceTiming[];\n\n let matchedValues: ReturnType<typeof extractFromPerformanceEntry>;\n\n for (let i = entries.length - 1; i >= 0; i--) {\n const entry = entries[i];\n\n if (entry.initiatorType !== 'fetch') continue;\n\n const currentHost = window.location.host;\n const match = entry.name.match(resourceRE);\n if (!match) continue;\n\n const [, matchedHost, sfapiPath] = match;\n\n const isMatch =\n // Same origin (exact host match)\n matchedHost === currentHost ||\n // Subdomain with SFAPI path\n (sfapiPath && matchedHost?.endsWith(`.${currentHost}`));\n\n if (isMatch) {\n const values = extractFromPerformanceEntry(entry);\n if (values) {\n matchedValues = values;\n break;\n }\n }\n }\n\n if (matchedValues) {\n trackingValues = matchedValues;\n }\n\n // Resource entries have a limited buffer and are removed over time.\n // Cache the latest values for future calls if we find them.\n // A cached resource entry is always newer than a navigation entry.\n if (trackingValues) {\n cachedTrackingValues.current = trackingValues;\n } else if (cachedTrackingValues.current) {\n // Fallback to cached values from previous calls:\n trackingValues = cachedTrackingValues.current;\n }\n\n if (!trackingValues) {\n // Fallback to navigation entry from full page rendering load:\n const navigationEntries = performance.getEntriesByType(\n 'navigation',\n )[0] as PerformanceNavigationTiming;\n\n // Navigation entries might omit consent when the Hydrogen server generates it.\n // In this case, we skip consent requirement and only extract _y and _s values.\n trackingValues = extractFromPerformanceEntry(navigationEntries, false);\n }\n } catch {}\n }\n\n // Fallback to deprecated cookies to support transitioning:\n if (!trackingValues) {\n const cookie =\n // Read from arguments to avoid declaring parameters in this function signature.\n // This logic is only used internally from `getShopifyCookies` and will be deprecated.\n typeof arguments[0] === 'string'\n ? arguments[0]\n : typeof document !== 'undefined'\n ? document.cookie\n : '';\n\n trackingValues = {\n uniqueToken: cookie.match(/\\b_shopify_y=([^;]+)/)?.[1] || '',\n visitToken: cookie.match(/\\b_shopify_s=([^;]+)/)?.[1] || '',\n consent: cookie.match(/\\b_tracking_consent=([^;]+)/)?.[1] || '',\n };\n }\n\n return trackingValues;\n}\n\nfunction extractFromPerformanceEntry(\n entry: PerformanceNavigationTiming | PerformanceResourceTiming,\n isConsentRequired = true,\n): TrackingValues | undefined {\n let uniqueToken = '';\n let visitToken = '';\n let consent = '';\n\n const serverTiming = entry.serverTiming;\n // Quick check: we need at least 3 entries (_y, _s, _cmp)\n if (serverTiming && serverTiming.length >= 3) {\n // Iterate backwards since our headers are typically at the end\n for (let i = serverTiming.length - 1; i >= 0; i--) {\n const {name, description} = serverTiming[i];\n if (!name || !description) continue;\n\n if (name === '_y') {\n uniqueToken = description;\n } else if (name === '_s') {\n visitToken = description;\n } else if (name === '_cmp') {\n // _cmp (consent management platform) holds the consent value\n // used by consent-tracking-api and privacy-banner scripts.\n consent = description;\n }\n\n if (uniqueToken && visitToken && consent) break;\n }\n }\n\n return uniqueToken && visitToken && (isConsentRequired ? consent : true)\n ? {uniqueToken, visitToken, consent}\n : undefined;\n}\n"],"mappings":";;AACA,IAAa,6BAA6B;;AAE1C,IAAa,8BAA8B;AAa3C,IAAa,uBAET,EAAC,SAAS,MAAK;;;;;AAMnB,SAAgB,oBAAoC;CAclD,IAAI;AAEJ,KACE,OAAO,WAAW,eAClB,OAAO,OAAO,gBAAgB,YAE9B,KAAI;EAIF,MAAM,aACJ;EAMF,MAAM,UAAU,YAAY,iBAC1B,WACD;EAED,IAAI;AAEJ,OAAK,IAAI,IAAI,QAAQ,SAAS,GAAG,KAAK,GAAG,KAAK;GAC5C,MAAM,QAAQ,QAAQ;AAEtB,OAAI,MAAM,kBAAkB,QAAS;GAErC,MAAM,cAAc,OAAO,SAAS;GACpC,MAAM,QAAQ,MAAM,KAAK,MAAM,WAAW;AAC1C,OAAI,CAAC,MAAO;GAEZ,MAAM,GAAG,aAAa,aAAa;AAQnC,OAJE,gBAAgB,eAEf,aAAa,aAAa,SAAS,IAAI,cAAc,EAE3C;IACX,MAAM,SAAS,4BAA4B,MAAM;AACjD,QAAI,QAAQ;AACV,qBAAgB;AAChB;;;;AAKN,MAAI,cACF,kBAAiB;AAMnB,MAAI,eACF,sBAAqB,UAAU;WACtB,qBAAqB,QAE9B,kBAAiB,qBAAqB;AAGxC,MAAI,CAAC,gBAAgB;GAEnB,MAAM,oBAAoB,YAAY,iBACpC,aACD,CAAC;AAIF,oBAAiB,4BAA4B,mBAAmB,MAAM;;SAElE;AAIV,KAAI,CAAC,gBAAgB;EACnB,MAAM,SAGJ,OAAO,UAAU,OAAO,WACpB,UAAU,KACV,OAAO,aAAa,cAClB,SAAS,SACT;AAER,mBAAiB;GACf,aAAa,OAAO,MAAM,uBAAuB,GAAG,MAAM;GAC1D,YAAY,OAAO,MAAM,uBAAuB,GAAG,MAAM;GACzD,SAAS,OAAO,MAAM,8BAA8B,GAAG,MAAM;GAC9D;;AAGH,QAAO;;AAGT,SAAS,4BACP,OACA,oBAAoB,MACQ;CAC5B,IAAI,cAAc;CAClB,IAAI,aAAa;CACjB,IAAI,UAAU;CAEd,MAAM,eAAe,MAAM;AAE3B,KAAI,gBAAgB,aAAa,UAAU,EAEzC,MAAK,IAAI,IAAI,aAAa,SAAS,GAAG,KAAK,GAAG,KAAK;EACjD,MAAM,EAAC,MAAM,gBAAe,aAAa;AACzC,MAAI,CAAC,QAAQ,CAAC,YAAa;AAE3B,MAAI,SAAS,KACX,eAAc;WACL,SAAS,KAClB,cAAa;WACJ,SAAS,OAGlB,WAAU;AAGZ,MAAI,eAAe,cAAc,QAAS;;AAI9C,QAAO,eAAe,eAAe,oBAAoB,UAAU,QAC/D;EAAC;EAAa;EAAY;EAAQ,GAClC,KAAA"}
1
+ {"version":3,"file":"tracking-utils.mjs","names":[],"sources":["../../src/tracking-utils.ts"],"sourcesContent":["/** Storefront API header for VisitToken */\nexport const SHOPIFY_VISIT_TOKEN_HEADER = 'X-Shopify-VisitToken';\n/** Storefront API header for UniqueToken */\nexport const SHOPIFY_UNIQUE_TOKEN_HEADER = 'X-Shopify-UniqueToken';\n\ntype TrackingValues = {\n /** Identifier for the unique user. Equivalent to the deprecated _shopify_y cookie */\n uniqueToken: string;\n /** Identifier for the current visit. Equivalent to the deprecated _shopify_s cookie */\n visitToken: string;\n /** Represents the consent given by the user or the default region consent configured in Admin */\n consent: string;\n};\n\n// Keep the consent-tracking-api token interface out of Hydrogen's public\n// global types since it could change in the future.\ntype CustomerPrivacyWithTracking = {\n config?: {asyncConsent?: boolean};\n cachedConsent?: string;\n __internal?: {\n uniqueToken?: (options?: {\n generateFallback?: boolean;\n tag?: string;\n }) => string | undefined;\n visitToken?: (options?: {\n generateFallback?: boolean;\n tag?: string;\n }) => string | undefined;\n };\n};\n\n/**\n * Retrieves user session tracking values for analytics and marketing from the\n * browser environment. Customer Privacy API token readers are authoritative\n * when available, including when consent denies tracking. Deprecated\n * `_shopify_y`/`_shopify_s` cookies are read only without an API token reader.\n * Consent comes from CTA's cache or the legacy `_tracking_consent` cookie.\n * @publicDocs\n */\nexport function getTrackingValues(): TrackingValues {\n const cookie =\n // Read from arguments to avoid declaring parameters in this function signature.\n // This logic is only used internally from `getShopifyCookies` and will be deprecated.\n typeof arguments[0] === 'string'\n ? arguments[0]\n : typeof document !== 'undefined'\n ? document.cookie\n : '';\n\n const customerPrivacy =\n typeof window === 'undefined'\n ? undefined\n : (window as {Shopify?: {customerPrivacy?: CustomerPrivacyWithTracking}})\n .Shopify?.customerPrivacy;\n\n const internal = customerPrivacy?.__internal;\n // Async consent owns initialization and suppresses fallback generation until\n // it is loaded. Afterwards CTA can refresh expired tokens, as in preview.\n // Standalone hydrogen-react's explicit consent fetch keeps its previous policy.\n const tokenOptions = {\n generateFallback: customerPrivacy?.config?.asyncConsent === true,\n tag: 'hydrogen:classic',\n };\n\n return {\n // An installed CTA reader is authoritative, including undefined on denial.\n // Falling through to a legacy cookie could restore a disallowed token.\n uniqueToken: internal?.uniqueToken\n ? (internal.uniqueToken(tokenOptions) ?? '')\n : (cookie.match(/\\b_shopify_y=([^;]+)/)?.[1] ?? ''),\n visitToken: internal?.visitToken\n ? (internal.visitToken(tokenOptions) ?? '')\n : (cookie.match(/\\b_shopify_s=([^;]+)/)?.[1] ?? ''),\n consent:\n customerPrivacy?.cachedConsent ??\n cookie.match(/\\b_tracking_consent=([^;]+)/)?.[1] ??\n '',\n };\n}\n"],"mappings":";;AACA,IAAa,6BAA6B;;AAE1C,IAAa,8BAA8B;;;;;;;;;AAoC3C,SAAgB,oBAAoC;CAClD,MAAM,SAGJ,OAAO,UAAU,OAAO,WACpB,UAAU,KACV,OAAO,aAAa,cAClB,SAAS,SACT;CAER,MAAM,kBACJ,OAAO,WAAW,cACd,KAAA,IACC,OACE,SAAS;CAElB,MAAM,WAAW,iBAAiB;CAIlC,MAAM,eAAe;EACnB,kBAAkB,iBAAiB,QAAQ,iBAAiB;EAC5D,KAAK;EACN;AAED,QAAO;EAGL,aAAa,UAAU,cAClB,SAAS,YAAY,aAAa,IAAI,KACtC,OAAO,MAAM,uBAAuB,GAAG,MAAM;EAClD,YAAY,UAAU,aACjB,SAAS,WAAW,aAAa,IAAI,KACrC,OAAO,MAAM,uBAAuB,GAAG,MAAM;EAClD,SACE,iBAAiB,iBACjB,OAAO,MAAM,8BAA8B,GAAG,MAC9C;EACH"}