@shopify/hydrogen-react 0.0.0-next-ea3e88e → 0.0.0-next-9bff83c

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 (45) hide show
  1. package/dist/browser-dev/ShopPayButton.mjs +1 -1
  2. package/dist/browser-dev/ShopPayButton.mjs.map +1 -1
  3. package/dist/browser-dev/ShopifyProvider.mjs +2 -11
  4. package/dist/browser-dev/ShopifyProvider.mjs.map +1 -1
  5. package/dist/browser-dev/cart-queries.mjs +0 -8
  6. package/dist/browser-dev/cart-queries.mjs.map +1 -1
  7. package/dist/browser-prod/ShopPayButton.mjs +1 -1
  8. package/dist/browser-prod/ShopPayButton.mjs.map +1 -1
  9. package/dist/browser-prod/ShopifyProvider.mjs +2 -8
  10. package/dist/browser-prod/ShopifyProvider.mjs.map +1 -1
  11. package/dist/browser-prod/cart-queries.mjs +0 -8
  12. package/dist/browser-prod/cart-queries.mjs.map +1 -1
  13. package/dist/node-dev/ShopPayButton.js +1 -1
  14. package/dist/node-dev/ShopPayButton.js.map +1 -1
  15. package/dist/node-dev/ShopPayButton.mjs +1 -1
  16. package/dist/node-dev/ShopPayButton.mjs.map +1 -1
  17. package/dist/node-dev/ShopifyProvider.js +2 -11
  18. package/dist/node-dev/ShopifyProvider.js.map +1 -1
  19. package/dist/node-dev/ShopifyProvider.mjs +2 -11
  20. package/dist/node-dev/ShopifyProvider.mjs.map +1 -1
  21. package/dist/node-dev/cart-queries.js +0 -8
  22. package/dist/node-dev/cart-queries.js.map +1 -1
  23. package/dist/node-dev/cart-queries.mjs +0 -8
  24. package/dist/node-dev/cart-queries.mjs.map +1 -1
  25. package/dist/node-prod/ShopPayButton.js +1 -1
  26. package/dist/node-prod/ShopPayButton.js.map +1 -1
  27. package/dist/node-prod/ShopPayButton.mjs +1 -1
  28. package/dist/node-prod/ShopPayButton.mjs.map +1 -1
  29. package/dist/node-prod/ShopifyProvider.js +2 -8
  30. package/dist/node-prod/ShopifyProvider.js.map +1 -1
  31. package/dist/node-prod/ShopifyProvider.mjs +2 -8
  32. package/dist/node-prod/ShopifyProvider.mjs.map +1 -1
  33. package/dist/node-prod/cart-queries.js +0 -8
  34. package/dist/node-prod/cart-queries.js.map +1 -1
  35. package/dist/node-prod/cart-queries.mjs +0 -8
  36. package/dist/node-prod/cart-queries.mjs.map +1 -1
  37. package/dist/types/ShopifyProvider.d.ts +1 -1
  38. package/dist/types/cart-queries.d.ts +1 -1
  39. package/dist/types/storefront-api-types.d.ts +121 -2
  40. package/dist/umd/hydrogen-react.dev.js +4 -21
  41. package/dist/umd/hydrogen-react.dev.js.map +1 -1
  42. package/dist/umd/hydrogen-react.prod.js +10 -18
  43. package/dist/umd/hydrogen-react.prod.js.map +1 -1
  44. package/package.json +1 -1
  45. package/storefront.schema.json +1 -1
@@ -43,7 +43,7 @@ function ShopPayButton({
43
43
  className,
44
44
  style,
45
45
  children: shopPayLoadedStatus === "done" && /* @__PURE__ */ jsx("shop-pay-button", {
46
- "store-url": `https://${storeDomain}`,
46
+ "store-url": storeDomain,
47
47
  variants: ids.join(",")
48
48
  })
49
49
  });
@@ -1 +1 @@
1
- {"version":3,"file":"ShopPayButton.mjs","sources":["../../src/ShopPayButton.tsx"],"sourcesContent":["import {useShop} from './ShopifyProvider.js';\nimport {useLoadScript} from './load-script.js';\n\n// By using 'never' in the \"or\" cases below, it makes these props \"exclusive\" and means that you cannot pass both of them; you must pass either one OR the other.\ntype ShopPayButtonProps = {\n /** A string of classes to apply to the `div` that wraps the Shop Pay button. */\n className?: string;\n /** A string that's applied to the [CSS custom property (variable)](https://developer.mozilla.org/en-US/docs/Web/CSS/--*) `--shop-pay-button-width` for the [Buy with Shop Pay component](https://shopify.dev/custom-storefronts/tools/web-components#buy-with-shop-pay-component). */\n width?: string;\n} & (\n | {\n /** An array of IDs of the variants to purchase with Shop Pay. This will only ever have a quantity of 1 for each variant. If you want to use other quantities, then use 'variantIdsAndQuantities'. */\n variantIds: string[];\n /** An array of variant IDs and quantities to purchase with Shop Pay. */\n variantIdsAndQuantities?: never;\n }\n | {\n /** An array of IDs of the variants to purchase with Shop Pay. This will only ever have a quantity of 1 for each variant. If you want to use other quantities, then use 'variantIdsAndQuantities'. */\n variantIds?: never;\n /** An array of variant IDs and quantities to purchase with Shop Pay. */\n variantIdsAndQuantities: Array<{\n id: string;\n quantity: number;\n }>;\n }\n);\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace JSX {\n interface IntrinsicElements {\n 'shop-pay-button': {\n variants: string;\n 'store-url': string;\n };\n }\n }\n}\n\nconst SHOPJS_URL =\n 'https://cdn.shopify.com/shopifycloud/shop-js/v1.0/client.js';\n\n/**\n * The `ShopPayButton` component renders a button that redirects to the Shop Pay checkout.\n * It renders a [`<shop-pay-button>`](https://shopify.dev/custom-storefronts/tools/web-components) custom element, for which it will lazy-load the source code automatically.\n * It relies on the `<ShopProvider>` context provider.\n */\nexport function ShopPayButton({\n variantIds,\n className,\n variantIdsAndQuantities,\n width,\n}: ShopPayButtonProps) {\n const {storeDomain} = useShop();\n const shopPayLoadedStatus = useLoadScript(SHOPJS_URL);\n\n let ids: string[];\n\n if (variantIds && variantIdsAndQuantities) {\n throw new Error(DoublePropsErrorMessage);\n }\n\n if (variantIds) {\n ids = variantIds.reduce<string[]>((prev, curr) => {\n const bareId = getIdFromGid(curr);\n if (bareId) {\n prev.push(bareId);\n }\n return prev;\n }, []);\n } else if (variantIdsAndQuantities) {\n ids = variantIdsAndQuantities.reduce<string[]>((prev, curr) => {\n const bareId = getIdFromGid(curr?.id);\n if (bareId) {\n prev.push(`${bareId}:${curr?.quantity ?? 1}`);\n }\n return prev;\n }, []);\n } else {\n throw new Error(MissingPropsErrorMessage);\n }\n\n const style = width\n ? ({\n '--shop-pay-button-width': width,\n } as React.CSSProperties)\n : undefined;\n\n return (\n <div className={className} style={style}>\n {shopPayLoadedStatus === 'done' && (\n <shop-pay-button\n store-url={`https://${storeDomain}`}\n variants={ids.join(',')}\n />\n )}\n </div>\n );\n}\n\n/**\n * Takes a string in the format of \"gid://shopify/ProductVariant/41007289630776\" and returns a string of the ID part at the end: \"41007289630776\"\n */\nexport function getIdFromGid(id?: string) {\n if (!id) return;\n return id.split('/').pop();\n}\n\nexport const MissingPropsErrorMessage = `You must pass in either \"variantIds\" or \"variantIdsAndQuantities\" to ShopPayButton`;\nexport const DoublePropsErrorMessage = `You must provide either a variantIds or variantIdsAndQuantities prop, but not both in the ShopPayButton component`;\n"],"names":["SHOPJS_URL","ShopPayButton","variantIds","className","variantIdsAndQuantities","width","storeDomain","useShop","shopPayLoadedStatus","useLoadScript","ids","Error","DoublePropsErrorMessage","reduce","prev","curr","bareId","getIdFromGid","push","id","quantity","MissingPropsErrorMessage","style","undefined","_jsx","join","split","pop"],"mappings":";;;AAuCA,MAAMA,aACJ;AAOK,SAASC,cAAc;AAAA,EAC5BC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AACkB,GAAG;AACf,QAAA;AAAA,IAACC;AAAAA,MAAeC,QAAS;AACzBC,QAAAA,sBAAsBC,cAAcT,UAAU;AAEhDU,MAAAA;AAEJ,MAAIR,cAAcE,yBAAyB;AACnC,UAAA,IAAIO,MAAMC,uBAAuB;AAAA,EACzC;AAEA,MAAIV,YAAY;AACdQ,UAAMR,WAAWW,OAAiB,CAACC,MAAMC,SAAS;AAC1CC,YAAAA,SAASC,aAAaF,IAAI;AAChC,UAAIC,QAAQ;AACVF,aAAKI,KAAKF,MAAM;AAAA,MAClB;AACOF,aAAAA;AAAAA,IACT,GAAG,CAAE,CAAA;AAAA,aACIV,yBAAyB;AAClCM,UAAMN,wBAAwBS,OAAiB,CAACC,MAAMC,SAAS;;AACvDC,YAAAA,SAASC,aAAaF,6BAAMI,EAAE;AACpC,UAAIH,QAAQ;AACVF,aAAKI,KAAM,GAAEF,WAAUD,kCAAMK,aAANL,YAAkB,GAAG;AAAA,MAC9C;AACOD,aAAAA;AAAAA,IACT,GAAG,CAAE,CAAA;AAAA,EAAA,OACA;AACC,UAAA,IAAIH,MAAMU,wBAAwB;AAAA,EAC1C;AAEA,QAAMC,QAAQjB,QACT;AAAA,IACC,2BAA2BA;AAAAA,EAE7BkB,IAAAA;AAEJ,6BACE,OAAA;AAAA,IAAK;AAAA,IAAsB;AAAA,IAAa,UACrCf,wBAAwB,UACvBgB,oBAAA,mBAAA;AAAA,MACE,aAAY,WAAUlB;AAAAA,MACtB,UAAUI,IAAIe,KAAK,GAAG;AAAA,IAAA,CAAE;AAAA,EAAA,CAGxB;AAEV;AAKO,SAASR,aAAaE,IAAa;AACxC,MAAI,CAACA;AAAI;AACT,SAAOA,GAAGO,MAAM,GAAG,EAAEC,IAAK;AAC5B;AAEO,MAAMN,2BAA4B;AAClC,MAAMT,0BAA2B;"}
1
+ {"version":3,"file":"ShopPayButton.mjs","sources":["../../src/ShopPayButton.tsx"],"sourcesContent":["import {useShop} from './ShopifyProvider.js';\nimport {useLoadScript} from './load-script.js';\n\n// By using 'never' in the \"or\" cases below, it makes these props \"exclusive\" and means that you cannot pass both of them; you must pass either one OR the other.\ntype ShopPayButtonProps = {\n /** A string of classes to apply to the `div` that wraps the Shop Pay button. */\n className?: string;\n /** A string that's applied to the [CSS custom property (variable)](https://developer.mozilla.org/en-US/docs/Web/CSS/--*) `--shop-pay-button-width` for the [Buy with Shop Pay component](https://shopify.dev/custom-storefronts/tools/web-components#buy-with-shop-pay-component). */\n width?: string;\n} & (\n | {\n /** An array of IDs of the variants to purchase with Shop Pay. This will only ever have a quantity of 1 for each variant. If you want to use other quantities, then use 'variantIdsAndQuantities'. */\n variantIds: string[];\n /** An array of variant IDs and quantities to purchase with Shop Pay. */\n variantIdsAndQuantities?: never;\n }\n | {\n /** An array of IDs of the variants to purchase with Shop Pay. This will only ever have a quantity of 1 for each variant. If you want to use other quantities, then use 'variantIdsAndQuantities'. */\n variantIds?: never;\n /** An array of variant IDs and quantities to purchase with Shop Pay. */\n variantIdsAndQuantities: Array<{\n id: string;\n quantity: number;\n }>;\n }\n);\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace JSX {\n interface IntrinsicElements {\n 'shop-pay-button': {\n variants: string;\n 'store-url': string;\n };\n }\n }\n}\n\nconst SHOPJS_URL =\n 'https://cdn.shopify.com/shopifycloud/shop-js/v1.0/client.js';\n\n/**\n * The `ShopPayButton` component renders a button that redirects to the Shop Pay checkout.\n * It renders a [`<shop-pay-button>`](https://shopify.dev/custom-storefronts/tools/web-components) custom element, for which it will lazy-load the source code automatically.\n * It relies on the `<ShopProvider>` context provider.\n */\nexport function ShopPayButton({\n variantIds,\n className,\n variantIdsAndQuantities,\n width,\n}: ShopPayButtonProps) {\n const {storeDomain} = useShop();\n const shopPayLoadedStatus = useLoadScript(SHOPJS_URL);\n\n let ids: string[];\n\n if (variantIds && variantIdsAndQuantities) {\n throw new Error(DoublePropsErrorMessage);\n }\n\n if (variantIds) {\n ids = variantIds.reduce<string[]>((prev, curr) => {\n const bareId = getIdFromGid(curr);\n if (bareId) {\n prev.push(bareId);\n }\n return prev;\n }, []);\n } else if (variantIdsAndQuantities) {\n ids = variantIdsAndQuantities.reduce<string[]>((prev, curr) => {\n const bareId = getIdFromGid(curr?.id);\n if (bareId) {\n prev.push(`${bareId}:${curr?.quantity ?? 1}`);\n }\n return prev;\n }, []);\n } else {\n throw new Error(MissingPropsErrorMessage);\n }\n\n const style = width\n ? ({\n '--shop-pay-button-width': width,\n } as React.CSSProperties)\n : undefined;\n\n return (\n <div className={className} style={style}>\n {shopPayLoadedStatus === 'done' && (\n <shop-pay-button store-url={storeDomain} variants={ids.join(',')} />\n )}\n </div>\n );\n}\n\n/**\n * Takes a string in the format of \"gid://shopify/ProductVariant/41007289630776\" and returns a string of the ID part at the end: \"41007289630776\"\n */\nexport function getIdFromGid(id?: string) {\n if (!id) return;\n return id.split('/').pop();\n}\n\nexport const MissingPropsErrorMessage = `You must pass in either \"variantIds\" or \"variantIdsAndQuantities\" to ShopPayButton`;\nexport const DoublePropsErrorMessage = `You must provide either a variantIds or variantIdsAndQuantities prop, but not both in the ShopPayButton component`;\n"],"names":["SHOPJS_URL","ShopPayButton","variantIds","className","variantIdsAndQuantities","width","storeDomain","useShop","shopPayLoadedStatus","useLoadScript","ids","Error","DoublePropsErrorMessage","reduce","prev","curr","bareId","getIdFromGid","push","id","quantity","MissingPropsErrorMessage","style","undefined","_jsx","join","split","pop"],"mappings":";;;AAuCA,MAAMA,aACJ;AAOK,SAASC,cAAc;AAAA,EAC5BC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AACkB,GAAG;AACf,QAAA;AAAA,IAACC;AAAAA,MAAeC,QAAS;AACzBC,QAAAA,sBAAsBC,cAAcT,UAAU;AAEhDU,MAAAA;AAEJ,MAAIR,cAAcE,yBAAyB;AACnC,UAAA,IAAIO,MAAMC,uBAAuB;AAAA,EACzC;AAEA,MAAIV,YAAY;AACdQ,UAAMR,WAAWW,OAAiB,CAACC,MAAMC,SAAS;AAC1CC,YAAAA,SAASC,aAAaF,IAAI;AAChC,UAAIC,QAAQ;AACVF,aAAKI,KAAKF,MAAM;AAAA,MAClB;AACOF,aAAAA;AAAAA,IACT,GAAG,CAAE,CAAA;AAAA,aACIV,yBAAyB;AAClCM,UAAMN,wBAAwBS,OAAiB,CAACC,MAAMC,SAAS;;AACvDC,YAAAA,SAASC,aAAaF,6BAAMI,EAAE;AACpC,UAAIH,QAAQ;AACVF,aAAKI,KAAM,GAAEF,WAAUD,kCAAMK,aAANL,YAAkB,GAAG;AAAA,MAC9C;AACOD,aAAAA;AAAAA,IACT,GAAG,CAAE,CAAA;AAAA,EAAA,OACA;AACC,UAAA,IAAIH,MAAMU,wBAAwB;AAAA,EAC1C;AAEA,QAAMC,QAAQjB,QACT;AAAA,IACC,2BAA2BA;AAAAA,EAE7BkB,IAAAA;AAEJ,6BACE,OAAA;AAAA,IAAK;AAAA,IAAsB;AAAA,IAAa,UACrCf,wBAAwB,UACvBgB,oBAAA,mBAAA;AAAA,MAAiB,aAAWlB;AAAAA,MAAa,UAAUI,IAAIe,KAAK,GAAG;AAAA,IAAA,CAAE;AAAA,EAAA,CAE/D;AAEV;AAKO,SAASR,aAAaE,IAAa;AACxC,MAAI,CAACA;AAAI;AACT,SAAOA,GAAGO,MAAM,GAAG,EAAEC,IAAK;AAC5B;AAEO,MAAMN,2BAA4B;AAClC,MAAMT,0BAA2B;"}
@@ -34,21 +34,12 @@ function ShopifyProvider({
34
34
  console.warn(`<ShopifyProvider/>: This version of Hydrogen-UI 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-UI and the Storefront API.`);
35
35
  }
36
36
  const finalConfig = useMemo(() => {
37
- const storeDomain = shopifyConfig.storeDomain.replace(/^https?:\/\//, "");
38
- if (storeDomain.includes(".myshopify.com")) {
39
- {
40
- console.warn(`<ShopifyProvider/>: passing a 'storeDomain' prop that includes '.myshopify.com' will be unsupported in the future. Passing only the subdomain (for example, if the URL is 'test.myshopify.com', passing in 'test') will be the supported way going forward.`);
41
- }
42
- }
43
37
  function getShopifyDomain(overrideProps) {
44
38
  var _a;
45
- let subDomain = (_a = overrideProps == null ? void 0 : overrideProps.storeDomain) != null ? _a : storeDomain;
46
- subDomain = subDomain.replace(".myshopify.com", "");
47
- return `https://${subDomain}.myshopify.com`;
39
+ return (_a = overrideProps == null ? void 0 : overrideProps.storeDomain) != null ? _a : shopifyConfig.storeDomain;
48
40
  }
49
41
  return {
50
42
  ...shopifyConfig,
51
- storeDomain,
52
43
  getPublicTokenHeaders(overrideProps) {
53
44
  var _a;
54
45
  return getPublicTokenHeadersRaw(overrideProps.contentType, shopifyConfig.storefrontApiVersion, (_a = overrideProps.storefrontToken) != null ? _a : shopifyConfig.storefrontToken);
@@ -62,7 +53,7 @@ function ShopifyProvider({
62
53
  }
63
54
  }
64
55
  return `${getShopifyDomain({
65
- storeDomain: (_b = overrideProps == null ? void 0 : overrideProps.storeDomain) != null ? _b : storeDomain
56
+ storeDomain: (_b = overrideProps == null ? void 0 : overrideProps.storeDomain) != null ? _b : shopifyConfig.storeDomain
66
57
  })}/api/${(_c = overrideProps == null ? void 0 : overrideProps.storefrontApiVersion) != null ? _c : shopifyConfig.storefrontApiVersion}/graphql.json`;
67
58
  }
68
59
  };
@@ -1 +1 @@
1
- {"version":3,"file":"ShopifyProvider.mjs","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\nconst ShopifyContext = createContext<ShopifyContextValue>({\n storeDomain: 'test',\n storefrontToken: 'abc123',\n storefrontApiVersion: SFAPI_VERSION,\n country: {\n isoCode: 'US',\n },\n language: {\n isoCode: 'EN',\n },\n locale: 'EN-US',\n getStorefrontApiUrl() {\n return '';\n },\n getPublicTokenHeaders() {\n return {};\n },\n getShopifyDomain() {\n return '';\n },\n});\n\n/**\n * The `<ShopifyProvider/>` component enables use of the `useShop()` hook. The component should wrap your app.\n */\nexport function ShopifyProvider({\n children,\n shopifyConfig,\n}: {\n children: ReactNode;\n shopifyConfig: ShopifyContextProps;\n}) {\n if (!shopifyConfig) {\n throw new Error(\n `The 'shopifyConfig' prop must be passed to '<ShopifyProvider/>'`\n );\n }\n\n if (shopifyConfig.storefrontApiVersion !== SFAPI_VERSION) {\n console.warn(\n `<ShopifyProvider/>: This version of Hydrogen-UI 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-UI and the Storefront API.`\n );\n }\n\n const finalConfig = useMemo<ShopifyContextValue>(() => {\n const storeDomain = shopifyConfig.storeDomain.replace(/^https?:\\/\\//, '');\n\n // @deprecated remove the ability to pass in '.myshopify.com' strings in the future\n if (storeDomain.includes('.myshopify.com')) {\n if (__HYDROGEN_DEV__) {\n console.warn(\n `<ShopifyProvider/>: passing a 'storeDomain' prop that includes '.myshopify.com' will be unsupported in the future. Passing only the subdomain (for example, if the URL is 'test.myshopify.com', passing in 'test') will be the supported way going forward.`\n );\n }\n }\n\n function getShopifyDomain(overrideProps?: {storeDomain?: string}) {\n let subDomain = overrideProps?.storeDomain ?? storeDomain;\n subDomain = subDomain.replace('.myshopify.com', '');\n\n return `https://${subDomain}.myshopify.com`;\n }\n\n return {\n ...shopifyConfig,\n storeDomain,\n getPublicTokenHeaders(overrideProps) {\n return getPublicTokenHeadersRaw(\n overrideProps.contentType,\n shopifyConfig.storefrontApiVersion,\n overrideProps.storefrontToken ?? shopifyConfig.storefrontToken\n );\n },\n getShopifyDomain,\n getStorefrontApiUrl(overrideProps) {\n if (overrideProps?.storeDomain?.includes('.myshopify.com')) {\n if (__HYDROGEN_DEV__) {\n console.warn(\n `<ShopifyProvider/>: passing a 'storeDomain' prop that includes '.myshopify.com' will be unsupported in the future. Passing only the subdomain (for example, if the URL is 'test.myshopify.com', passing in 'test') will be the supported way going forward.`\n );\n }\n }\n return `${getShopifyDomain({\n storeDomain: overrideProps?.storeDomain ?? storeDomain,\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 */\nexport function useShop() {\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\n/**\n * Shopify-specific values that are used in various Hydrogen-UI components and hooks.\n */\nexport type ShopifyContextProps = {\n /** The globally-unique identifier for the Shop */\n storefrontId?: string;\n /** The subdomain of your Shopify storefront URL (eg: `{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-UI was built for. Learn more about Shopify [API versioning](https://shopify.dev/api/usage/versioning) for more details. */\n storefrontApiVersion: string;\n country?: {\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 isoCode: CountryCode;\n };\n language?: {\n /**\n * `ISO 369` language codes supported by Shopify.\n */\n isoCode: LanguageCode;\n };\n /**\n * The locale string based on `country` and `language`.\n */\n locale?: string;\n};\n\nexport type ShopifyContextValue = ShopifyContextProps & {\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?: {\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 }) => 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: (props: {\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 }) => 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?: {storeDomain?: string}) => string;\n};\n"],"names":["ShopifyContext","createContext","storeDomain","storefrontToken","storefrontApiVersion","SFAPI_VERSION","country","isoCode","language","locale","getStorefrontApiUrl","getPublicTokenHeaders","getShopifyDomain","ShopifyProvider","children","shopifyConfig","Error","console","warn","finalConfig","useMemo","replace","includes","overrideProps","subDomain","getPublicTokenHeadersRaw","contentType","_jsx","useShop","shopContext","useContext"],"mappings":";;;;AAKA,MAAMA,iBAAiBC,cAAmC;AAAA,EACxDC,aAAa;AAAA,EACbC,iBAAiB;AAAA,EACjBC,sBAAsBC;AAAAA,EACtBC,SAAS;AAAA,IACPC,SAAS;AAAA,EACX;AAAA,EACAC,UAAU;AAAA,IACRD,SAAS;AAAA,EACX;AAAA,EACAE,QAAQ;AAAA,EACRC,sBAAsB;AACb,WAAA;AAAA,EACT;AAAA,EACAC,wBAAwB;AACtB,WAAO;EACT;AAAA,EACAC,mBAAmB;AACV,WAAA;AAAA,EACT;AACF,CAAC;AAKM,SAASC,gBAAgB;AAAA,EAC9BC;AAAAA,EACAC;AAIF,GAAG;AACD,MAAI,CAACA,eAAe;AACZ,UAAA,IAAIC,MACP,iEAAgE;AAAA,EAErE;AAEID,MAAAA,cAAcX,yBAAyBC,eAAe;AACxDY,YAAQC,KACL,iGAAgGb,yDAAyDU,cAAcX,0HAA0H;AAAA,EAEtS;AAEMe,QAAAA,cAAcC,QAA6B,MAAM;AACrD,UAAMlB,cAAca,cAAcb,YAAYmB,QAAQ,gBAAgB,EAAE;AAGpEnB,QAAAA,YAAYoB,SAAS,gBAAgB,GAAG;AACpB;AACpBL,gBAAQC,KACL,6PAA4P;AAAA,MAEjQ;AAAA,IACF;AAEA,aAASN,iBAAiBW,eAAwC;;AAC5DC,UAAAA,aAAYD,oDAAerB,gBAAfqB,YAA8BrB;AAClCsB,kBAAAA,UAAUH,QAAQ,kBAAkB,EAAE;AAElD,aAAQ,WAAUG;AAAAA,IACpB;AAEO,WAAA;AAAA,MACL,GAAGT;AAAAA,MACHb;AAAAA,MACAS,sBAAsBY,eAAe;;AAC5BE,eAAAA,yBACLF,cAAcG,aACdX,cAAcX,uBACdmB,mBAAcpB,oBAAdoB,YAAiCR,cAAcZ,eAAe;AAAA,MAElE;AAAA,MACAS;AAAAA,MACAF,oBAAoBa,eAAe;;AACjC,aAAIA,oDAAerB,gBAAfqB,mBAA4BD,SAAS,mBAAmB;AACpC;AACpBL,oBAAQC,KACL,6PAA4P;AAAA,UAEjQ;AAAA,QACF;AACA,eAAQ,GAAEN,iBAAiB;AAAA,UACzBV,cAAaqB,oDAAerB,gBAAfqB,YAA8BrB;AAAAA,QAAAA,CAC5C,UACCqB,oDAAenB,yBAAfmB,YACAR,cAAcX;AAAAA,MAElB;AAAA,IAAA;AAAA,EACF,GACC,CAACW,aAAa,CAAC;AAGhB,SAAAY,oBAAC,eAAe,UAAQ;AAAA,IAAC,OAAOR;AAAAA,IAAY;AAAA,EAAA,CAElB;AAE9B;AAKO,SAASS,UAAU;AAClBC,QAAAA,cAAcC,WAAW9B,cAAc;AAC7C,MAAI,CAAC6B,aAAa;AACV,UAAA,IAAIb,MAAO,wDAAuD;AAAA,EAC1E;AACOa,SAAAA;AACT;"}
1
+ {"version":3,"file":"ShopifyProvider.mjs","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\nconst ShopifyContext = createContext<ShopifyContextValue>({\n storeDomain: 'test',\n storefrontToken: 'abc123',\n storefrontApiVersion: SFAPI_VERSION,\n country: {\n isoCode: 'US',\n },\n language: {\n isoCode: 'EN',\n },\n locale: 'EN-US',\n getStorefrontApiUrl() {\n return '';\n },\n getPublicTokenHeaders() {\n return {};\n },\n getShopifyDomain() {\n return '';\n },\n});\n\n/**\n * The `<ShopifyProvider/>` component enables use of the `useShop()` hook. The component should wrap your app.\n */\nexport function ShopifyProvider({\n children,\n shopifyConfig,\n}: {\n children: ReactNode;\n shopifyConfig: ShopifyContextProps;\n}) {\n if (!shopifyConfig) {\n throw new Error(\n `The 'shopifyConfig' prop must be passed to '<ShopifyProvider/>'`\n );\n }\n\n if (shopifyConfig.storefrontApiVersion !== SFAPI_VERSION) {\n console.warn(\n `<ShopifyProvider/>: This version of Hydrogen-UI 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-UI and the Storefront API.`\n );\n }\n\n const finalConfig = useMemo<ShopifyContextValue>(() => {\n function getShopifyDomain(overrideProps?: {storeDomain?: string}) {\n return overrideProps?.storeDomain ?? shopifyConfig.storeDomain;\n }\n\n return {\n ...shopifyConfig,\n getPublicTokenHeaders(overrideProps) {\n return getPublicTokenHeadersRaw(\n overrideProps.contentType,\n shopifyConfig.storefrontApiVersion,\n overrideProps.storefrontToken ?? shopifyConfig.storefrontToken\n );\n },\n getShopifyDomain,\n getStorefrontApiUrl(overrideProps) {\n if (overrideProps?.storeDomain?.includes('.myshopify.com')) {\n if (__HYDROGEN_DEV__) {\n console.warn(\n `<ShopifyProvider/>: passing a 'storeDomain' prop that includes '.myshopify.com' will be unsupported in the future. Passing only the subdomain (for example, if the URL is 'test.myshopify.com', passing in 'test') will be the supported way going forward.`\n );\n }\n }\n return `${getShopifyDomain({\n storeDomain: overrideProps?.storeDomain ?? shopifyConfig.storeDomain,\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 */\nexport function useShop() {\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\n/**\n * Shopify-specific values that are used in various Hydrogen-UI components and hooks.\n */\nexport type ShopifyContextProps = {\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-UI was built for. Learn more about Shopify [API versioning](https://shopify.dev/api/usage/versioning) for more details. */\n storefrontApiVersion: string;\n country?: {\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 isoCode: CountryCode;\n };\n language?: {\n /**\n * `ISO 369` language codes supported by Shopify.\n */\n isoCode: LanguageCode;\n };\n /**\n * The locale string based on `country` and `language`.\n */\n locale?: string;\n};\n\nexport type ShopifyContextValue = ShopifyContextProps & {\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?: {\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 }) => 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: (props: {\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 }) => 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?: {storeDomain?: string}) => string;\n};\n"],"names":["ShopifyContext","createContext","storeDomain","storefrontToken","storefrontApiVersion","SFAPI_VERSION","country","isoCode","language","locale","getStorefrontApiUrl","getPublicTokenHeaders","getShopifyDomain","ShopifyProvider","children","shopifyConfig","Error","console","warn","finalConfig","useMemo","overrideProps","getPublicTokenHeadersRaw","contentType","includes","_jsx","useShop","shopContext","useContext"],"mappings":";;;;AAKA,MAAMA,iBAAiBC,cAAmC;AAAA,EACxDC,aAAa;AAAA,EACbC,iBAAiB;AAAA,EACjBC,sBAAsBC;AAAAA,EACtBC,SAAS;AAAA,IACPC,SAAS;AAAA,EACX;AAAA,EACAC,UAAU;AAAA,IACRD,SAAS;AAAA,EACX;AAAA,EACAE,QAAQ;AAAA,EACRC,sBAAsB;AACb,WAAA;AAAA,EACT;AAAA,EACAC,wBAAwB;AACtB,WAAO;EACT;AAAA,EACAC,mBAAmB;AACV,WAAA;AAAA,EACT;AACF,CAAC;AAKM,SAASC,gBAAgB;AAAA,EAC9BC;AAAAA,EACAC;AAIF,GAAG;AACD,MAAI,CAACA,eAAe;AACZ,UAAA,IAAIC,MACP,iEAAgE;AAAA,EAErE;AAEID,MAAAA,cAAcX,yBAAyBC,eAAe;AACxDY,YAAQC,KACL,iGAAgGb,yDAAyDU,cAAcX,0HAA0H;AAAA,EAEtS;AAEMe,QAAAA,cAAcC,QAA6B,MAAM;AACrD,aAASR,iBAAiBS,eAAwC;;AACzDA,cAAAA,oDAAenB,gBAAfmB,YAA8BN,cAAcb;AAAAA,IACrD;AAEO,WAAA;AAAA,MACL,GAAGa;AAAAA,MACHJ,sBAAsBU,eAAe;;AAC5BC,eAAAA,yBACLD,cAAcE,aACdR,cAAcX,uBACdiB,mBAAclB,oBAAdkB,YAAiCN,cAAcZ,eAAe;AAAA,MAElE;AAAA,MACAS;AAAAA,MACAF,oBAAoBW,eAAe;;AACjC,aAAIA,oDAAenB,gBAAfmB,mBAA4BG,SAAS,mBAAmB;AACpC;AACpBP,oBAAQC,KACL,6PAA4P;AAAA,UAEjQ;AAAA,QACF;AACA,eAAQ,GAAEN,iBAAiB;AAAA,UACzBV,cAAamB,oDAAenB,gBAAfmB,YAA8BN,cAAcb;AAAAA,QAAAA,CAC1D,UACCmB,oDAAejB,yBAAfiB,YACAN,cAAcX;AAAAA,MAElB;AAAA,IAAA;AAAA,EACF,GACC,CAACW,aAAa,CAAC;AAGhB,SAAAU,oBAAC,eAAe,UAAQ;AAAA,IAAC,OAAON;AAAAA,IAAY;AAAA,EAAA,CAElB;AAE9B;AAKO,SAASO,UAAU;AAClBC,QAAAA,cAAcC,WAAW5B,cAAc;AAC7C,MAAI,CAAC2B,aAAa;AACV,UAAA,IAAIX,MAAO,wDAAuD;AAAA,EAC1E;AACOW,SAAAA;AACT;"}
@@ -181,17 +181,9 @@ const defaultCartFragment = `
181
181
  compareAtPrice {
182
182
  ...MoneyFragment
183
183
  }
184
- # @deprecated remove in next major
185
- compareAtPriceV2 {
186
- ...MoneyFragment
187
- }
188
184
  price {
189
185
  ...MoneyFragment
190
186
  }
191
- # @deprecated remove in next major
192
- priceV2 {
193
- ...MoneyFragment
194
- }
195
187
  requiresShipping
196
188
  title
197
189
  image {
@@ -1 +1 @@
1
- {"version":3,"file":"cart-queries.mjs","sources":["../../src/cart-queries.ts"],"sourcesContent":["export const CartLineAdd = (cartFragment: string) => /* GraphQL */ `\n mutation CartLineAdd(\n $cartId: ID!\n $lines: [CartLineInput!]!\n $numCartLines: Int = 250\n $country: CountryCode = ZZ\n ) @inContext(country: $country) {\n cartLinesAdd(cartId: $cartId, lines: $lines) {\n cart {\n ...CartFragment\n }\n }\n }\n\n ${cartFragment}\n`;\n\nexport const CartCreate = (cartFragment: string) => /* GraphQL */ `\n mutation CartCreate(\n $input: CartInput!\n $numCartLines: Int = 250\n $country: CountryCode = ZZ\n ) @inContext(country: $country) {\n cartCreate(input: $input) {\n cart {\n ...CartFragment\n }\n }\n }\n\n ${cartFragment}\n`;\n\nexport const CartLineRemove = (cartFragment: string) => /* GraphQL */ `\n mutation CartLineRemove(\n $cartId: ID!\n $lines: [ID!]!\n $numCartLines: Int = 250\n $country: CountryCode = ZZ\n ) @inContext(country: $country) {\n cartLinesRemove(cartId: $cartId, lineIds: $lines) {\n cart {\n ...CartFragment\n }\n }\n }\n\n ${cartFragment}\n`;\n\nexport const CartLineUpdate = (cartFragment: string) => /* GraphQL */ `\n mutation CartLineUpdate(\n $cartId: ID!\n $lines: [CartLineUpdateInput!]!\n $numCartLines: Int = 250\n $country: CountryCode = ZZ\n ) @inContext(country: $country) {\n cartLinesUpdate(cartId: $cartId, lines: $lines) {\n cart {\n ...CartFragment\n }\n }\n }\n\n ${cartFragment}\n`;\n\nexport const CartNoteUpdate = (cartFragment: string) => /* GraphQL */ `\n mutation CartNoteUpdate(\n $cartId: ID!\n $note: String\n $numCartLines: Int = 250\n $country: CountryCode = ZZ\n ) @inContext(country: $country) {\n cartNoteUpdate(cartId: $cartId, note: $note) {\n cart {\n ...CartFragment\n }\n }\n }\n\n ${cartFragment}\n`;\n\nexport const CartBuyerIdentityUpdate = (cartFragment: string) => /* GraphQL */ `\n mutation CartBuyerIdentityUpdate(\n $cartId: ID!\n $buyerIdentity: CartBuyerIdentityInput!\n $numCartLines: Int = 250\n $country: CountryCode = ZZ\n ) @inContext(country: $country) {\n cartBuyerIdentityUpdate(cartId: $cartId, buyerIdentity: $buyerIdentity) {\n cart {\n ...CartFragment\n }\n }\n }\n\n ${cartFragment}\n`;\n\nexport const CartAttributesUpdate = (cartFragment: string) => /* GraphQL */ `\n mutation CartAttributesUpdate(\n $attributes: [AttributeInput!]!\n $cartId: ID!\n $numCartLines: Int = 250\n $country: CountryCode = ZZ\n ) @inContext(country: $country) {\n cartAttributesUpdate(attributes: $attributes, cartId: $cartId) {\n cart {\n ...CartFragment\n }\n }\n }\n\n ${cartFragment}\n`;\n\nexport const CartDiscountCodesUpdate = (cartFragment: string) => /* GraphQL */ `\n mutation CartDiscountCodesUpdate(\n $cartId: ID!\n $discountCodes: [String!]\n $numCartLines: Int = 250\n $country: CountryCode = ZZ\n ) @inContext(country: $country) {\n cartDiscountCodesUpdate(cartId: $cartId, discountCodes: $discountCodes) {\n cart {\n ...CartFragment\n }\n }\n }\n\n ${cartFragment}\n`;\n\nexport const CartQuery = (cartFragment: string) => /* GraphQL */ `\n query CartQuery(\n $id: ID!\n $numCartLines: Int = 250\n $country: CountryCode = ZZ\n ) @inContext(country: $country) {\n cart(id: $id) {\n ...CartFragment\n }\n }\n\n ${cartFragment}\n`;\n\nexport const defaultCartFragment = /* GraphQL */ `\n fragment CartFragment on Cart {\n id\n checkoutUrl\n totalQuantity\n buyerIdentity {\n countryCode\n customer {\n id\n email\n firstName\n lastName\n displayName\n }\n email\n phone\n }\n lines(first: $numCartLines) {\n edges {\n node {\n id\n quantity\n attributes {\n key\n value\n }\n cost {\n totalAmount {\n amount\n currencyCode\n }\n compareAtAmountPerQuantity {\n amount\n currencyCode\n }\n }\n merchandise {\n ... on ProductVariant {\n id\n availableForSale\n compareAtPrice {\n ...MoneyFragment\n }\n # @deprecated remove in next major\n compareAtPriceV2 {\n ...MoneyFragment\n }\n price {\n ...MoneyFragment\n }\n # @deprecated remove in next major\n priceV2 {\n ...MoneyFragment\n }\n requiresShipping\n title\n image {\n ...ImageFragment\n }\n product {\n handle\n title\n id\n }\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n }\n cost {\n subtotalAmount {\n ...MoneyFragment\n }\n totalAmount {\n ...MoneyFragment\n }\n totalDutyAmount {\n ...MoneyFragment\n }\n totalTaxAmount {\n ...MoneyFragment\n }\n }\n note\n attributes {\n key\n value\n }\n discountCodes {\n code\n }\n }\n\n fragment MoneyFragment on MoneyV2 {\n currencyCode\n amount\n }\n fragment ImageFragment on Image {\n id\n url\n altText\n width\n height\n }\n`;\n"],"names":[],"mappings":"AAAa,MAAA,cAAc,CAAC,iBAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAc/D;AAAA;AAGS,MAAA,aAAa,CAAC,iBAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAa9D;AAAA;AAGS,MAAA,iBAAiB,CAAC,iBAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAclE;AAAA;AAGS,MAAA,iBAAiB,CAAC,iBAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAclE;AAAA;AAGS,MAAA,iBAAiB,CAAC,iBAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAclE;AAAA;AAGS,MAAA,0BAA0B,CAAC,iBAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAc3E;AAAA;AAGS,MAAA,uBAAuB,CAAC,iBAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAcxE;AAAA;AAGS,MAAA,0BAA0B,CAAC,iBAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAc3E;AAAA;AAGS,MAAA,YAAY,CAAC,iBAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAW7D;AAAA;AAGG,MAAM,sBAAoC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;"}
1
+ {"version":3,"file":"cart-queries.mjs","sources":["../../src/cart-queries.ts"],"sourcesContent":["export const CartLineAdd = (cartFragment: string) => /* GraphQL */ `\n mutation CartLineAdd(\n $cartId: ID!\n $lines: [CartLineInput!]!\n $numCartLines: Int = 250\n $country: CountryCode = ZZ\n ) @inContext(country: $country) {\n cartLinesAdd(cartId: $cartId, lines: $lines) {\n cart {\n ...CartFragment\n }\n }\n }\n\n ${cartFragment}\n`;\n\nexport const CartCreate = (cartFragment: string) => /* GraphQL */ `\n mutation CartCreate(\n $input: CartInput!\n $numCartLines: Int = 250\n $country: CountryCode = ZZ\n ) @inContext(country: $country) {\n cartCreate(input: $input) {\n cart {\n ...CartFragment\n }\n }\n }\n\n ${cartFragment}\n`;\n\nexport const CartLineRemove = (cartFragment: string) => /* GraphQL */ `\n mutation CartLineRemove(\n $cartId: ID!\n $lines: [ID!]!\n $numCartLines: Int = 250\n $country: CountryCode = ZZ\n ) @inContext(country: $country) {\n cartLinesRemove(cartId: $cartId, lineIds: $lines) {\n cart {\n ...CartFragment\n }\n }\n }\n\n ${cartFragment}\n`;\n\nexport const CartLineUpdate = (cartFragment: string) => /* GraphQL */ `\n mutation CartLineUpdate(\n $cartId: ID!\n $lines: [CartLineUpdateInput!]!\n $numCartLines: Int = 250\n $country: CountryCode = ZZ\n ) @inContext(country: $country) {\n cartLinesUpdate(cartId: $cartId, lines: $lines) {\n cart {\n ...CartFragment\n }\n }\n }\n\n ${cartFragment}\n`;\n\nexport const CartNoteUpdate = (cartFragment: string) => /* GraphQL */ `\n mutation CartNoteUpdate(\n $cartId: ID!\n $note: String\n $numCartLines: Int = 250\n $country: CountryCode = ZZ\n ) @inContext(country: $country) {\n cartNoteUpdate(cartId: $cartId, note: $note) {\n cart {\n ...CartFragment\n }\n }\n }\n\n ${cartFragment}\n`;\n\nexport const CartBuyerIdentityUpdate = (cartFragment: string) => /* GraphQL */ `\n mutation CartBuyerIdentityUpdate(\n $cartId: ID!\n $buyerIdentity: CartBuyerIdentityInput!\n $numCartLines: Int = 250\n $country: CountryCode = ZZ\n ) @inContext(country: $country) {\n cartBuyerIdentityUpdate(cartId: $cartId, buyerIdentity: $buyerIdentity) {\n cart {\n ...CartFragment\n }\n }\n }\n\n ${cartFragment}\n`;\n\nexport const CartAttributesUpdate = (cartFragment: string) => /* GraphQL */ `\n mutation CartAttributesUpdate(\n $attributes: [AttributeInput!]!\n $cartId: ID!\n $numCartLines: Int = 250\n $country: CountryCode = ZZ\n ) @inContext(country: $country) {\n cartAttributesUpdate(attributes: $attributes, cartId: $cartId) {\n cart {\n ...CartFragment\n }\n }\n }\n\n ${cartFragment}\n`;\n\nexport const CartDiscountCodesUpdate = (cartFragment: string) => /* GraphQL */ `\n mutation CartDiscountCodesUpdate(\n $cartId: ID!\n $discountCodes: [String!]\n $numCartLines: Int = 250\n $country: CountryCode = ZZ\n ) @inContext(country: $country) {\n cartDiscountCodesUpdate(cartId: $cartId, discountCodes: $discountCodes) {\n cart {\n ...CartFragment\n }\n }\n }\n\n ${cartFragment}\n`;\n\nexport const CartQuery = (cartFragment: string) => /* GraphQL */ `\n query CartQuery(\n $id: ID!\n $numCartLines: Int = 250\n $country: CountryCode = ZZ\n ) @inContext(country: $country) {\n cart(id: $id) {\n ...CartFragment\n }\n }\n\n ${cartFragment}\n`;\n\nexport const defaultCartFragment = /* GraphQL */ `\n fragment CartFragment on Cart {\n id\n checkoutUrl\n totalQuantity\n buyerIdentity {\n countryCode\n customer {\n id\n email\n firstName\n lastName\n displayName\n }\n email\n phone\n }\n lines(first: $numCartLines) {\n edges {\n node {\n id\n quantity\n attributes {\n key\n value\n }\n cost {\n totalAmount {\n amount\n currencyCode\n }\n compareAtAmountPerQuantity {\n amount\n currencyCode\n }\n }\n merchandise {\n ... on ProductVariant {\n id\n availableForSale\n compareAtPrice {\n ...MoneyFragment\n }\n price {\n ...MoneyFragment\n }\n requiresShipping\n title\n image {\n ...ImageFragment\n }\n product {\n handle\n title\n id\n }\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n }\n cost {\n subtotalAmount {\n ...MoneyFragment\n }\n totalAmount {\n ...MoneyFragment\n }\n totalDutyAmount {\n ...MoneyFragment\n }\n totalTaxAmount {\n ...MoneyFragment\n }\n }\n note\n attributes {\n key\n value\n }\n discountCodes {\n code\n }\n }\n\n fragment MoneyFragment on MoneyV2 {\n currencyCode\n amount\n }\n fragment ImageFragment on Image {\n id\n url\n altText\n width\n height\n }\n`;\n"],"names":[],"mappings":"AAAa,MAAA,cAAc,CAAC,iBAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAc/D;AAAA;AAGS,MAAA,aAAa,CAAC,iBAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAa9D;AAAA;AAGS,MAAA,iBAAiB,CAAC,iBAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAclE;AAAA;AAGS,MAAA,iBAAiB,CAAC,iBAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAclE;AAAA;AAGS,MAAA,iBAAiB,CAAC,iBAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAclE;AAAA;AAGS,MAAA,0BAA0B,CAAC,iBAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAc3E;AAAA;AAGS,MAAA,uBAAuB,CAAC,iBAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAcxE;AAAA;AAGS,MAAA,0BAA0B,CAAC,iBAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAc3E;AAAA;AAGS,MAAA,YAAY,CAAC,iBAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAW7D;AAAA;AAGG,MAAM,sBAAoC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;"}
@@ -43,7 +43,7 @@ function ShopPayButton({
43
43
  className,
44
44
  style,
45
45
  children: shopPayLoadedStatus === "done" && /* @__PURE__ */ jsx("shop-pay-button", {
46
- "store-url": `https://${storeDomain}`,
46
+ "store-url": storeDomain,
47
47
  variants: ids.join(",")
48
48
  })
49
49
  });
@@ -1 +1 @@
1
- {"version":3,"file":"ShopPayButton.mjs","sources":["../../src/ShopPayButton.tsx"],"sourcesContent":["import {useShop} from './ShopifyProvider.js';\nimport {useLoadScript} from './load-script.js';\n\n// By using 'never' in the \"or\" cases below, it makes these props \"exclusive\" and means that you cannot pass both of them; you must pass either one OR the other.\ntype ShopPayButtonProps = {\n /** A string of classes to apply to the `div` that wraps the Shop Pay button. */\n className?: string;\n /** A string that's applied to the [CSS custom property (variable)](https://developer.mozilla.org/en-US/docs/Web/CSS/--*) `--shop-pay-button-width` for the [Buy with Shop Pay component](https://shopify.dev/custom-storefronts/tools/web-components#buy-with-shop-pay-component). */\n width?: string;\n} & (\n | {\n /** An array of IDs of the variants to purchase with Shop Pay. This will only ever have a quantity of 1 for each variant. If you want to use other quantities, then use 'variantIdsAndQuantities'. */\n variantIds: string[];\n /** An array of variant IDs and quantities to purchase with Shop Pay. */\n variantIdsAndQuantities?: never;\n }\n | {\n /** An array of IDs of the variants to purchase with Shop Pay. This will only ever have a quantity of 1 for each variant. If you want to use other quantities, then use 'variantIdsAndQuantities'. */\n variantIds?: never;\n /** An array of variant IDs and quantities to purchase with Shop Pay. */\n variantIdsAndQuantities: Array<{\n id: string;\n quantity: number;\n }>;\n }\n);\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace JSX {\n interface IntrinsicElements {\n 'shop-pay-button': {\n variants: string;\n 'store-url': string;\n };\n }\n }\n}\n\nconst SHOPJS_URL =\n 'https://cdn.shopify.com/shopifycloud/shop-js/v1.0/client.js';\n\n/**\n * The `ShopPayButton` component renders a button that redirects to the Shop Pay checkout.\n * It renders a [`<shop-pay-button>`](https://shopify.dev/custom-storefronts/tools/web-components) custom element, for which it will lazy-load the source code automatically.\n * It relies on the `<ShopProvider>` context provider.\n */\nexport function ShopPayButton({\n variantIds,\n className,\n variantIdsAndQuantities,\n width,\n}: ShopPayButtonProps) {\n const {storeDomain} = useShop();\n const shopPayLoadedStatus = useLoadScript(SHOPJS_URL);\n\n let ids: string[];\n\n if (variantIds && variantIdsAndQuantities) {\n throw new Error(DoublePropsErrorMessage);\n }\n\n if (variantIds) {\n ids = variantIds.reduce<string[]>((prev, curr) => {\n const bareId = getIdFromGid(curr);\n if (bareId) {\n prev.push(bareId);\n }\n return prev;\n }, []);\n } else if (variantIdsAndQuantities) {\n ids = variantIdsAndQuantities.reduce<string[]>((prev, curr) => {\n const bareId = getIdFromGid(curr?.id);\n if (bareId) {\n prev.push(`${bareId}:${curr?.quantity ?? 1}`);\n }\n return prev;\n }, []);\n } else {\n throw new Error(MissingPropsErrorMessage);\n }\n\n const style = width\n ? ({\n '--shop-pay-button-width': width,\n } as React.CSSProperties)\n : undefined;\n\n return (\n <div className={className} style={style}>\n {shopPayLoadedStatus === 'done' && (\n <shop-pay-button\n store-url={`https://${storeDomain}`}\n variants={ids.join(',')}\n />\n )}\n </div>\n );\n}\n\n/**\n * Takes a string in the format of \"gid://shopify/ProductVariant/41007289630776\" and returns a string of the ID part at the end: \"41007289630776\"\n */\nexport function getIdFromGid(id?: string) {\n if (!id) return;\n return id.split('/').pop();\n}\n\nexport const MissingPropsErrorMessage = `You must pass in either \"variantIds\" or \"variantIdsAndQuantities\" to ShopPayButton`;\nexport const DoublePropsErrorMessage = `You must provide either a variantIds or variantIdsAndQuantities prop, but not both in the ShopPayButton component`;\n"],"names":["SHOPJS_URL","ShopPayButton","variantIds","className","variantIdsAndQuantities","width","storeDomain","useShop","shopPayLoadedStatus","useLoadScript","ids","Error","DoublePropsErrorMessage","reduce","prev","curr","bareId","getIdFromGid","push","id","quantity","MissingPropsErrorMessage","style","undefined","_jsx","join","split","pop"],"mappings":";;;AAuCA,MAAMA,aACJ;AAOK,SAASC,cAAc;AAAA,EAC5BC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AACkB,GAAG;AACf,QAAA;AAAA,IAACC;AAAAA,MAAeC,QAAS;AACzBC,QAAAA,sBAAsBC,cAAcT,UAAU;AAEhDU,MAAAA;AAEJ,MAAIR,cAAcE,yBAAyB;AACnC,UAAA,IAAIO,MAAMC,uBAAuB;AAAA,EACzC;AAEA,MAAIV,YAAY;AACdQ,UAAMR,WAAWW,OAAiB,CAACC,MAAMC,SAAS;AAC1CC,YAAAA,SAASC,aAAaF,IAAI;AAChC,UAAIC,QAAQ;AACVF,aAAKI,KAAKF,MAAM;AAAA,MAClB;AACOF,aAAAA;AAAAA,IACT,GAAG,CAAE,CAAA;AAAA,aACIV,yBAAyB;AAClCM,UAAMN,wBAAwBS,OAAiB,CAACC,MAAMC,SAAS;;AACvDC,YAAAA,SAASC,aAAaF,6BAAMI,EAAE;AACpC,UAAIH,QAAQ;AACVF,aAAKI,KAAM,GAAEF,WAAUD,kCAAMK,aAANL,YAAkB,GAAG;AAAA,MAC9C;AACOD,aAAAA;AAAAA,IACT,GAAG,CAAE,CAAA;AAAA,EAAA,OACA;AACC,UAAA,IAAIH,MAAMU,wBAAwB;AAAA,EAC1C;AAEA,QAAMC,QAAQjB,QACT;AAAA,IACC,2BAA2BA;AAAAA,EAE7BkB,IAAAA;AAEJ,6BACE,OAAA;AAAA,IAAK;AAAA,IAAsB;AAAA,IAAa,UACrCf,wBAAwB,UACvBgB,oBAAA,mBAAA;AAAA,MACE,aAAY,WAAUlB;AAAAA,MACtB,UAAUI,IAAIe,KAAK,GAAG;AAAA,IAAA,CAAE;AAAA,EAAA,CAGxB;AAEV;AAKO,SAASR,aAAaE,IAAa;AACxC,MAAI,CAACA;AAAI;AACT,SAAOA,GAAGO,MAAM,GAAG,EAAEC,IAAK;AAC5B;AAEO,MAAMN,2BAA4B;AAClC,MAAMT,0BAA2B;"}
1
+ {"version":3,"file":"ShopPayButton.mjs","sources":["../../src/ShopPayButton.tsx"],"sourcesContent":["import {useShop} from './ShopifyProvider.js';\nimport {useLoadScript} from './load-script.js';\n\n// By using 'never' in the \"or\" cases below, it makes these props \"exclusive\" and means that you cannot pass both of them; you must pass either one OR the other.\ntype ShopPayButtonProps = {\n /** A string of classes to apply to the `div` that wraps the Shop Pay button. */\n className?: string;\n /** A string that's applied to the [CSS custom property (variable)](https://developer.mozilla.org/en-US/docs/Web/CSS/--*) `--shop-pay-button-width` for the [Buy with Shop Pay component](https://shopify.dev/custom-storefronts/tools/web-components#buy-with-shop-pay-component). */\n width?: string;\n} & (\n | {\n /** An array of IDs of the variants to purchase with Shop Pay. This will only ever have a quantity of 1 for each variant. If you want to use other quantities, then use 'variantIdsAndQuantities'. */\n variantIds: string[];\n /** An array of variant IDs and quantities to purchase with Shop Pay. */\n variantIdsAndQuantities?: never;\n }\n | {\n /** An array of IDs of the variants to purchase with Shop Pay. This will only ever have a quantity of 1 for each variant. If you want to use other quantities, then use 'variantIdsAndQuantities'. */\n variantIds?: never;\n /** An array of variant IDs and quantities to purchase with Shop Pay. */\n variantIdsAndQuantities: Array<{\n id: string;\n quantity: number;\n }>;\n }\n);\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace JSX {\n interface IntrinsicElements {\n 'shop-pay-button': {\n variants: string;\n 'store-url': string;\n };\n }\n }\n}\n\nconst SHOPJS_URL =\n 'https://cdn.shopify.com/shopifycloud/shop-js/v1.0/client.js';\n\n/**\n * The `ShopPayButton` component renders a button that redirects to the Shop Pay checkout.\n * It renders a [`<shop-pay-button>`](https://shopify.dev/custom-storefronts/tools/web-components) custom element, for which it will lazy-load the source code automatically.\n * It relies on the `<ShopProvider>` context provider.\n */\nexport function ShopPayButton({\n variantIds,\n className,\n variantIdsAndQuantities,\n width,\n}: ShopPayButtonProps) {\n const {storeDomain} = useShop();\n const shopPayLoadedStatus = useLoadScript(SHOPJS_URL);\n\n let ids: string[];\n\n if (variantIds && variantIdsAndQuantities) {\n throw new Error(DoublePropsErrorMessage);\n }\n\n if (variantIds) {\n ids = variantIds.reduce<string[]>((prev, curr) => {\n const bareId = getIdFromGid(curr);\n if (bareId) {\n prev.push(bareId);\n }\n return prev;\n }, []);\n } else if (variantIdsAndQuantities) {\n ids = variantIdsAndQuantities.reduce<string[]>((prev, curr) => {\n const bareId = getIdFromGid(curr?.id);\n if (bareId) {\n prev.push(`${bareId}:${curr?.quantity ?? 1}`);\n }\n return prev;\n }, []);\n } else {\n throw new Error(MissingPropsErrorMessage);\n }\n\n const style = width\n ? ({\n '--shop-pay-button-width': width,\n } as React.CSSProperties)\n : undefined;\n\n return (\n <div className={className} style={style}>\n {shopPayLoadedStatus === 'done' && (\n <shop-pay-button store-url={storeDomain} variants={ids.join(',')} />\n )}\n </div>\n );\n}\n\n/**\n * Takes a string in the format of \"gid://shopify/ProductVariant/41007289630776\" and returns a string of the ID part at the end: \"41007289630776\"\n */\nexport function getIdFromGid(id?: string) {\n if (!id) return;\n return id.split('/').pop();\n}\n\nexport const MissingPropsErrorMessage = `You must pass in either \"variantIds\" or \"variantIdsAndQuantities\" to ShopPayButton`;\nexport const DoublePropsErrorMessage = `You must provide either a variantIds or variantIdsAndQuantities prop, but not both in the ShopPayButton component`;\n"],"names":["SHOPJS_URL","ShopPayButton","variantIds","className","variantIdsAndQuantities","width","storeDomain","useShop","shopPayLoadedStatus","useLoadScript","ids","Error","DoublePropsErrorMessage","reduce","prev","curr","bareId","getIdFromGid","push","id","quantity","MissingPropsErrorMessage","style","undefined","_jsx","join","split","pop"],"mappings":";;;AAuCA,MAAMA,aACJ;AAOK,SAASC,cAAc;AAAA,EAC5BC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AACkB,GAAG;AACf,QAAA;AAAA,IAACC;AAAAA,MAAeC,QAAS;AACzBC,QAAAA,sBAAsBC,cAAcT,UAAU;AAEhDU,MAAAA;AAEJ,MAAIR,cAAcE,yBAAyB;AACnC,UAAA,IAAIO,MAAMC,uBAAuB;AAAA,EACzC;AAEA,MAAIV,YAAY;AACdQ,UAAMR,WAAWW,OAAiB,CAACC,MAAMC,SAAS;AAC1CC,YAAAA,SAASC,aAAaF,IAAI;AAChC,UAAIC,QAAQ;AACVF,aAAKI,KAAKF,MAAM;AAAA,MAClB;AACOF,aAAAA;AAAAA,IACT,GAAG,CAAE,CAAA;AAAA,aACIV,yBAAyB;AAClCM,UAAMN,wBAAwBS,OAAiB,CAACC,MAAMC,SAAS;;AACvDC,YAAAA,SAASC,aAAaF,6BAAMI,EAAE;AACpC,UAAIH,QAAQ;AACVF,aAAKI,KAAM,GAAEF,WAAUD,kCAAMK,aAANL,YAAkB,GAAG;AAAA,MAC9C;AACOD,aAAAA;AAAAA,IACT,GAAG,CAAE,CAAA;AAAA,EAAA,OACA;AACC,UAAA,IAAIH,MAAMU,wBAAwB;AAAA,EAC1C;AAEA,QAAMC,QAAQjB,QACT;AAAA,IACC,2BAA2BA;AAAAA,EAE7BkB,IAAAA;AAEJ,6BACE,OAAA;AAAA,IAAK;AAAA,IAAsB;AAAA,IAAa,UACrCf,wBAAwB,UACvBgB,oBAAA,mBAAA;AAAA,MAAiB,aAAWlB;AAAAA,MAAa,UAAUI,IAAIe,KAAK,GAAG;AAAA,IAAA,CAAE;AAAA,EAAA,CAE/D;AAEV;AAKO,SAASR,aAAaE,IAAa;AACxC,MAAI,CAACA;AAAI;AACT,SAAOA,GAAGO,MAAM,GAAG,EAAEC,IAAK;AAC5B;AAEO,MAAMN,2BAA4B;AAClC,MAAMT,0BAA2B;"}
@@ -34,18 +34,12 @@ function ShopifyProvider({
34
34
  console.warn(`<ShopifyProvider/>: This version of Hydrogen-UI 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-UI and the Storefront API.`);
35
35
  }
36
36
  const finalConfig = useMemo(() => {
37
- const storeDomain = shopifyConfig.storeDomain.replace(/^https?:\/\//, "");
38
- if (storeDomain.includes(".myshopify.com"))
39
- ;
40
37
  function getShopifyDomain(overrideProps) {
41
38
  var _a;
42
- let subDomain = (_a = overrideProps == null ? void 0 : overrideProps.storeDomain) != null ? _a : storeDomain;
43
- subDomain = subDomain.replace(".myshopify.com", "");
44
- return `https://${subDomain}.myshopify.com`;
39
+ return (_a = overrideProps == null ? void 0 : overrideProps.storeDomain) != null ? _a : shopifyConfig.storeDomain;
45
40
  }
46
41
  return {
47
42
  ...shopifyConfig,
48
- storeDomain,
49
43
  getPublicTokenHeaders(overrideProps) {
50
44
  var _a;
51
45
  return getPublicTokenHeadersRaw(overrideProps.contentType, shopifyConfig.storefrontApiVersion, (_a = overrideProps.storefrontToken) != null ? _a : shopifyConfig.storefrontToken);
@@ -56,7 +50,7 @@ function ShopifyProvider({
56
50
  if ((_a = overrideProps == null ? void 0 : overrideProps.storeDomain) == null ? void 0 : _a.includes(".myshopify.com"))
57
51
  ;
58
52
  return `${getShopifyDomain({
59
- storeDomain: (_b = overrideProps == null ? void 0 : overrideProps.storeDomain) != null ? _b : storeDomain
53
+ storeDomain: (_b = overrideProps == null ? void 0 : overrideProps.storeDomain) != null ? _b : shopifyConfig.storeDomain
60
54
  })}/api/${(_c = overrideProps == null ? void 0 : overrideProps.storefrontApiVersion) != null ? _c : shopifyConfig.storefrontApiVersion}/graphql.json`;
61
55
  }
62
56
  };
@@ -1 +1 @@
1
- {"version":3,"file":"ShopifyProvider.mjs","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\nconst ShopifyContext = createContext<ShopifyContextValue>({\n storeDomain: 'test',\n storefrontToken: 'abc123',\n storefrontApiVersion: SFAPI_VERSION,\n country: {\n isoCode: 'US',\n },\n language: {\n isoCode: 'EN',\n },\n locale: 'EN-US',\n getStorefrontApiUrl() {\n return '';\n },\n getPublicTokenHeaders() {\n return {};\n },\n getShopifyDomain() {\n return '';\n },\n});\n\n/**\n * The `<ShopifyProvider/>` component enables use of the `useShop()` hook. The component should wrap your app.\n */\nexport function ShopifyProvider({\n children,\n shopifyConfig,\n}: {\n children: ReactNode;\n shopifyConfig: ShopifyContextProps;\n}) {\n if (!shopifyConfig) {\n throw new Error(\n `The 'shopifyConfig' prop must be passed to '<ShopifyProvider/>'`\n );\n }\n\n if (shopifyConfig.storefrontApiVersion !== SFAPI_VERSION) {\n console.warn(\n `<ShopifyProvider/>: This version of Hydrogen-UI 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-UI and the Storefront API.`\n );\n }\n\n const finalConfig = useMemo<ShopifyContextValue>(() => {\n const storeDomain = shopifyConfig.storeDomain.replace(/^https?:\\/\\//, '');\n\n // @deprecated remove the ability to pass in '.myshopify.com' strings in the future\n if (storeDomain.includes('.myshopify.com')) {\n if (__HYDROGEN_DEV__) {\n console.warn(\n `<ShopifyProvider/>: passing a 'storeDomain' prop that includes '.myshopify.com' will be unsupported in the future. Passing only the subdomain (for example, if the URL is 'test.myshopify.com', passing in 'test') will be the supported way going forward.`\n );\n }\n }\n\n function getShopifyDomain(overrideProps?: {storeDomain?: string}) {\n let subDomain = overrideProps?.storeDomain ?? storeDomain;\n subDomain = subDomain.replace('.myshopify.com', '');\n\n return `https://${subDomain}.myshopify.com`;\n }\n\n return {\n ...shopifyConfig,\n storeDomain,\n getPublicTokenHeaders(overrideProps) {\n return getPublicTokenHeadersRaw(\n overrideProps.contentType,\n shopifyConfig.storefrontApiVersion,\n overrideProps.storefrontToken ?? shopifyConfig.storefrontToken\n );\n },\n getShopifyDomain,\n getStorefrontApiUrl(overrideProps) {\n if (overrideProps?.storeDomain?.includes('.myshopify.com')) {\n if (__HYDROGEN_DEV__) {\n console.warn(\n `<ShopifyProvider/>: passing a 'storeDomain' prop that includes '.myshopify.com' will be unsupported in the future. Passing only the subdomain (for example, if the URL is 'test.myshopify.com', passing in 'test') will be the supported way going forward.`\n );\n }\n }\n return `${getShopifyDomain({\n storeDomain: overrideProps?.storeDomain ?? storeDomain,\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 */\nexport function useShop() {\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\n/**\n * Shopify-specific values that are used in various Hydrogen-UI components and hooks.\n */\nexport type ShopifyContextProps = {\n /** The globally-unique identifier for the Shop */\n storefrontId?: string;\n /** The subdomain of your Shopify storefront URL (eg: `{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-UI was built for. Learn more about Shopify [API versioning](https://shopify.dev/api/usage/versioning) for more details. */\n storefrontApiVersion: string;\n country?: {\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 isoCode: CountryCode;\n };\n language?: {\n /**\n * `ISO 369` language codes supported by Shopify.\n */\n isoCode: LanguageCode;\n };\n /**\n * The locale string based on `country` and `language`.\n */\n locale?: string;\n};\n\nexport type ShopifyContextValue = ShopifyContextProps & {\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?: {\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 }) => 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: (props: {\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 }) => 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?: {storeDomain?: string}) => string;\n};\n"],"names":["ShopifyContext","createContext","storeDomain","storefrontToken","storefrontApiVersion","SFAPI_VERSION","country","isoCode","language","locale","getStorefrontApiUrl","getPublicTokenHeaders","getShopifyDomain","ShopifyProvider","children","shopifyConfig","Error","console","warn","finalConfig","useMemo","replace","includes","overrideProps","subDomain","getPublicTokenHeadersRaw","contentType","_jsx","useShop","shopContext","useContext"],"mappings":";;;;AAKA,MAAMA,iBAAiBC,cAAmC;AAAA,EACxDC,aAAa;AAAA,EACbC,iBAAiB;AAAA,EACjBC,sBAAsBC;AAAAA,EACtBC,SAAS;AAAA,IACPC,SAAS;AAAA,EACX;AAAA,EACAC,UAAU;AAAA,IACRD,SAAS;AAAA,EACX;AAAA,EACAE,QAAQ;AAAA,EACRC,sBAAsB;AACb,WAAA;AAAA,EACT;AAAA,EACAC,wBAAwB;AACtB,WAAO;EACT;AAAA,EACAC,mBAAmB;AACV,WAAA;AAAA,EACT;AACF,CAAC;AAKM,SAASC,gBAAgB;AAAA,EAC9BC;AAAAA,EACAC;AAIF,GAAG;AACD,MAAI,CAACA,eAAe;AACZ,UAAA,IAAIC,MACP,iEAAgE;AAAA,EAErE;AAEID,MAAAA,cAAcX,yBAAyBC,eAAe;AACxDY,YAAQC,KACL,iGAAgGb,yDAAyDU,cAAcX,0HAA0H;AAAA,EAEtS;AAEMe,QAAAA,cAAcC,QAA6B,MAAM;AACrD,UAAMlB,cAAca,cAAcb,YAAYmB,QAAQ,gBAAgB,EAAE;AAGpEnB,QAAAA,YAAYoB,SAAS,gBAAgB;AAAG;AAQ5C,aAASV,iBAAiBW,eAAwC;;AAC5DC,UAAAA,aAAYD,oDAAerB,gBAAfqB,YAA8BrB;AAClCsB,kBAAAA,UAAUH,QAAQ,kBAAkB,EAAE;AAElD,aAAQ,WAAUG;AAAAA,IACpB;AAEO,WAAA;AAAA,MACL,GAAGT;AAAAA,MACHb;AAAAA,MACAS,sBAAsBY,eAAe;;AAC5BE,eAAAA,yBACLF,cAAcG,aACdX,cAAcX,uBACdmB,mBAAcpB,oBAAdoB,YAAiCR,cAAcZ,eAAe;AAAA,MAElE;AAAA,MACAS;AAAAA,MACAF,oBAAoBa,eAAe;;AACjC,aAAIA,oDAAerB,gBAAfqB,mBAA4BD,SAAS;AAAmB;AAO5D,eAAQ,GAAEV,iBAAiB;AAAA,UACzBV,cAAaqB,oDAAerB,gBAAfqB,YAA8BrB;AAAAA,QAAAA,CAC5C,UACCqB,oDAAenB,yBAAfmB,YACAR,cAAcX;AAAAA,MAElB;AAAA,IAAA;AAAA,EACF,GACC,CAACW,aAAa,CAAC;AAGhB,SAAAY,oBAAC,eAAe,UAAQ;AAAA,IAAC,OAAOR;AAAAA,IAAY;AAAA,EAAA,CAElB;AAE9B;AAKO,SAASS,UAAU;AAClBC,QAAAA,cAAcC,WAAW9B,cAAc;AAC7C,MAAI,CAAC6B,aAAa;AACV,UAAA,IAAIb,MAAO,wDAAuD;AAAA,EAC1E;AACOa,SAAAA;AACT;"}
1
+ {"version":3,"file":"ShopifyProvider.mjs","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\nconst ShopifyContext = createContext<ShopifyContextValue>({\n storeDomain: 'test',\n storefrontToken: 'abc123',\n storefrontApiVersion: SFAPI_VERSION,\n country: {\n isoCode: 'US',\n },\n language: {\n isoCode: 'EN',\n },\n locale: 'EN-US',\n getStorefrontApiUrl() {\n return '';\n },\n getPublicTokenHeaders() {\n return {};\n },\n getShopifyDomain() {\n return '';\n },\n});\n\n/**\n * The `<ShopifyProvider/>` component enables use of the `useShop()` hook. The component should wrap your app.\n */\nexport function ShopifyProvider({\n children,\n shopifyConfig,\n}: {\n children: ReactNode;\n shopifyConfig: ShopifyContextProps;\n}) {\n if (!shopifyConfig) {\n throw new Error(\n `The 'shopifyConfig' prop must be passed to '<ShopifyProvider/>'`\n );\n }\n\n if (shopifyConfig.storefrontApiVersion !== SFAPI_VERSION) {\n console.warn(\n `<ShopifyProvider/>: This version of Hydrogen-UI 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-UI and the Storefront API.`\n );\n }\n\n const finalConfig = useMemo<ShopifyContextValue>(() => {\n function getShopifyDomain(overrideProps?: {storeDomain?: string}) {\n return overrideProps?.storeDomain ?? shopifyConfig.storeDomain;\n }\n\n return {\n ...shopifyConfig,\n getPublicTokenHeaders(overrideProps) {\n return getPublicTokenHeadersRaw(\n overrideProps.contentType,\n shopifyConfig.storefrontApiVersion,\n overrideProps.storefrontToken ?? shopifyConfig.storefrontToken\n );\n },\n getShopifyDomain,\n getStorefrontApiUrl(overrideProps) {\n if (overrideProps?.storeDomain?.includes('.myshopify.com')) {\n if (__HYDROGEN_DEV__) {\n console.warn(\n `<ShopifyProvider/>: passing a 'storeDomain' prop that includes '.myshopify.com' will be unsupported in the future. Passing only the subdomain (for example, if the URL is 'test.myshopify.com', passing in 'test') will be the supported way going forward.`\n );\n }\n }\n return `${getShopifyDomain({\n storeDomain: overrideProps?.storeDomain ?? shopifyConfig.storeDomain,\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 */\nexport function useShop() {\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\n/**\n * Shopify-specific values that are used in various Hydrogen-UI components and hooks.\n */\nexport type ShopifyContextProps = {\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-UI was built for. Learn more about Shopify [API versioning](https://shopify.dev/api/usage/versioning) for more details. */\n storefrontApiVersion: string;\n country?: {\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 isoCode: CountryCode;\n };\n language?: {\n /**\n * `ISO 369` language codes supported by Shopify.\n */\n isoCode: LanguageCode;\n };\n /**\n * The locale string based on `country` and `language`.\n */\n locale?: string;\n};\n\nexport type ShopifyContextValue = ShopifyContextProps & {\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?: {\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 }) => 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: (props: {\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 }) => 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?: {storeDomain?: string}) => string;\n};\n"],"names":["ShopifyContext","createContext","storeDomain","storefrontToken","storefrontApiVersion","SFAPI_VERSION","country","isoCode","language","locale","getStorefrontApiUrl","getPublicTokenHeaders","getShopifyDomain","ShopifyProvider","children","shopifyConfig","Error","console","warn","finalConfig","useMemo","overrideProps","getPublicTokenHeadersRaw","contentType","includes","_jsx","useShop","shopContext","useContext"],"mappings":";;;;AAKA,MAAMA,iBAAiBC,cAAmC;AAAA,EACxDC,aAAa;AAAA,EACbC,iBAAiB;AAAA,EACjBC,sBAAsBC;AAAAA,EACtBC,SAAS;AAAA,IACPC,SAAS;AAAA,EACX;AAAA,EACAC,UAAU;AAAA,IACRD,SAAS;AAAA,EACX;AAAA,EACAE,QAAQ;AAAA,EACRC,sBAAsB;AACb,WAAA;AAAA,EACT;AAAA,EACAC,wBAAwB;AACtB,WAAO;EACT;AAAA,EACAC,mBAAmB;AACV,WAAA;AAAA,EACT;AACF,CAAC;AAKM,SAASC,gBAAgB;AAAA,EAC9BC;AAAAA,EACAC;AAIF,GAAG;AACD,MAAI,CAACA,eAAe;AACZ,UAAA,IAAIC,MACP,iEAAgE;AAAA,EAErE;AAEID,MAAAA,cAAcX,yBAAyBC,eAAe;AACxDY,YAAQC,KACL,iGAAgGb,yDAAyDU,cAAcX,0HAA0H;AAAA,EAEtS;AAEMe,QAAAA,cAAcC,QAA6B,MAAM;AACrD,aAASR,iBAAiBS,eAAwC;;AACzDA,cAAAA,oDAAenB,gBAAfmB,YAA8BN,cAAcb;AAAAA,IACrD;AAEO,WAAA;AAAA,MACL,GAAGa;AAAAA,MACHJ,sBAAsBU,eAAe;;AAC5BC,eAAAA,yBACLD,cAAcE,aACdR,cAAcX,uBACdiB,mBAAclB,oBAAdkB,YAAiCN,cAAcZ,eAAe;AAAA,MAElE;AAAA,MACAS;AAAAA,MACAF,oBAAoBW,eAAe;;AACjC,aAAIA,oDAAenB,gBAAfmB,mBAA4BG,SAAS;AAAmB;AAO5D,eAAQ,GAAEZ,iBAAiB;AAAA,UACzBV,cAAamB,oDAAenB,gBAAfmB,YAA8BN,cAAcb;AAAAA,QAAAA,CAC1D,UACCmB,oDAAejB,yBAAfiB,YACAN,cAAcX;AAAAA,MAElB;AAAA,IAAA;AAAA,EACF,GACC,CAACW,aAAa,CAAC;AAGhB,SAAAU,oBAAC,eAAe,UAAQ;AAAA,IAAC,OAAON;AAAAA,IAAY;AAAA,EAAA,CAElB;AAE9B;AAKO,SAASO,UAAU;AAClBC,QAAAA,cAAcC,WAAW5B,cAAc;AAC7C,MAAI,CAAC2B,aAAa;AACV,UAAA,IAAIX,MAAO,wDAAuD;AAAA,EAC1E;AACOW,SAAAA;AACT;"}
@@ -181,17 +181,9 @@ const defaultCartFragment = `
181
181
  compareAtPrice {
182
182
  ...MoneyFragment
183
183
  }
184
- # @deprecated remove in next major
185
- compareAtPriceV2 {
186
- ...MoneyFragment
187
- }
188
184
  price {
189
185
  ...MoneyFragment
190
186
  }
191
- # @deprecated remove in next major
192
- priceV2 {
193
- ...MoneyFragment
194
- }
195
187
  requiresShipping
196
188
  title
197
189
  image {
@@ -1 +1 @@
1
- {"version":3,"file":"cart-queries.mjs","sources":["../../src/cart-queries.ts"],"sourcesContent":["export const CartLineAdd = (cartFragment: string) => /* GraphQL */ `\n mutation CartLineAdd(\n $cartId: ID!\n $lines: [CartLineInput!]!\n $numCartLines: Int = 250\n $country: CountryCode = ZZ\n ) @inContext(country: $country) {\n cartLinesAdd(cartId: $cartId, lines: $lines) {\n cart {\n ...CartFragment\n }\n }\n }\n\n ${cartFragment}\n`;\n\nexport const CartCreate = (cartFragment: string) => /* GraphQL */ `\n mutation CartCreate(\n $input: CartInput!\n $numCartLines: Int = 250\n $country: CountryCode = ZZ\n ) @inContext(country: $country) {\n cartCreate(input: $input) {\n cart {\n ...CartFragment\n }\n }\n }\n\n ${cartFragment}\n`;\n\nexport const CartLineRemove = (cartFragment: string) => /* GraphQL */ `\n mutation CartLineRemove(\n $cartId: ID!\n $lines: [ID!]!\n $numCartLines: Int = 250\n $country: CountryCode = ZZ\n ) @inContext(country: $country) {\n cartLinesRemove(cartId: $cartId, lineIds: $lines) {\n cart {\n ...CartFragment\n }\n }\n }\n\n ${cartFragment}\n`;\n\nexport const CartLineUpdate = (cartFragment: string) => /* GraphQL */ `\n mutation CartLineUpdate(\n $cartId: ID!\n $lines: [CartLineUpdateInput!]!\n $numCartLines: Int = 250\n $country: CountryCode = ZZ\n ) @inContext(country: $country) {\n cartLinesUpdate(cartId: $cartId, lines: $lines) {\n cart {\n ...CartFragment\n }\n }\n }\n\n ${cartFragment}\n`;\n\nexport const CartNoteUpdate = (cartFragment: string) => /* GraphQL */ `\n mutation CartNoteUpdate(\n $cartId: ID!\n $note: String\n $numCartLines: Int = 250\n $country: CountryCode = ZZ\n ) @inContext(country: $country) {\n cartNoteUpdate(cartId: $cartId, note: $note) {\n cart {\n ...CartFragment\n }\n }\n }\n\n ${cartFragment}\n`;\n\nexport const CartBuyerIdentityUpdate = (cartFragment: string) => /* GraphQL */ `\n mutation CartBuyerIdentityUpdate(\n $cartId: ID!\n $buyerIdentity: CartBuyerIdentityInput!\n $numCartLines: Int = 250\n $country: CountryCode = ZZ\n ) @inContext(country: $country) {\n cartBuyerIdentityUpdate(cartId: $cartId, buyerIdentity: $buyerIdentity) {\n cart {\n ...CartFragment\n }\n }\n }\n\n ${cartFragment}\n`;\n\nexport const CartAttributesUpdate = (cartFragment: string) => /* GraphQL */ `\n mutation CartAttributesUpdate(\n $attributes: [AttributeInput!]!\n $cartId: ID!\n $numCartLines: Int = 250\n $country: CountryCode = ZZ\n ) @inContext(country: $country) {\n cartAttributesUpdate(attributes: $attributes, cartId: $cartId) {\n cart {\n ...CartFragment\n }\n }\n }\n\n ${cartFragment}\n`;\n\nexport const CartDiscountCodesUpdate = (cartFragment: string) => /* GraphQL */ `\n mutation CartDiscountCodesUpdate(\n $cartId: ID!\n $discountCodes: [String!]\n $numCartLines: Int = 250\n $country: CountryCode = ZZ\n ) @inContext(country: $country) {\n cartDiscountCodesUpdate(cartId: $cartId, discountCodes: $discountCodes) {\n cart {\n ...CartFragment\n }\n }\n }\n\n ${cartFragment}\n`;\n\nexport const CartQuery = (cartFragment: string) => /* GraphQL */ `\n query CartQuery(\n $id: ID!\n $numCartLines: Int = 250\n $country: CountryCode = ZZ\n ) @inContext(country: $country) {\n cart(id: $id) {\n ...CartFragment\n }\n }\n\n ${cartFragment}\n`;\n\nexport const defaultCartFragment = /* GraphQL */ `\n fragment CartFragment on Cart {\n id\n checkoutUrl\n totalQuantity\n buyerIdentity {\n countryCode\n customer {\n id\n email\n firstName\n lastName\n displayName\n }\n email\n phone\n }\n lines(first: $numCartLines) {\n edges {\n node {\n id\n quantity\n attributes {\n key\n value\n }\n cost {\n totalAmount {\n amount\n currencyCode\n }\n compareAtAmountPerQuantity {\n amount\n currencyCode\n }\n }\n merchandise {\n ... on ProductVariant {\n id\n availableForSale\n compareAtPrice {\n ...MoneyFragment\n }\n # @deprecated remove in next major\n compareAtPriceV2 {\n ...MoneyFragment\n }\n price {\n ...MoneyFragment\n }\n # @deprecated remove in next major\n priceV2 {\n ...MoneyFragment\n }\n requiresShipping\n title\n image {\n ...ImageFragment\n }\n product {\n handle\n title\n id\n }\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n }\n cost {\n subtotalAmount {\n ...MoneyFragment\n }\n totalAmount {\n ...MoneyFragment\n }\n totalDutyAmount {\n ...MoneyFragment\n }\n totalTaxAmount {\n ...MoneyFragment\n }\n }\n note\n attributes {\n key\n value\n }\n discountCodes {\n code\n }\n }\n\n fragment MoneyFragment on MoneyV2 {\n currencyCode\n amount\n }\n fragment ImageFragment on Image {\n id\n url\n altText\n width\n height\n }\n`;\n"],"names":[],"mappings":"AAAa,MAAA,cAAc,CAAC,iBAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAc/D;AAAA;AAGS,MAAA,aAAa,CAAC,iBAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAa9D;AAAA;AAGS,MAAA,iBAAiB,CAAC,iBAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAclE;AAAA;AAGS,MAAA,iBAAiB,CAAC,iBAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAclE;AAAA;AAGS,MAAA,iBAAiB,CAAC,iBAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAclE;AAAA;AAGS,MAAA,0BAA0B,CAAC,iBAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAc3E;AAAA;AAGS,MAAA,uBAAuB,CAAC,iBAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAcxE;AAAA;AAGS,MAAA,0BAA0B,CAAC,iBAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAc3E;AAAA;AAGS,MAAA,YAAY,CAAC,iBAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAW7D;AAAA;AAGG,MAAM,sBAAoC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;"}
1
+ {"version":3,"file":"cart-queries.mjs","sources":["../../src/cart-queries.ts"],"sourcesContent":["export const CartLineAdd = (cartFragment: string) => /* GraphQL */ `\n mutation CartLineAdd(\n $cartId: ID!\n $lines: [CartLineInput!]!\n $numCartLines: Int = 250\n $country: CountryCode = ZZ\n ) @inContext(country: $country) {\n cartLinesAdd(cartId: $cartId, lines: $lines) {\n cart {\n ...CartFragment\n }\n }\n }\n\n ${cartFragment}\n`;\n\nexport const CartCreate = (cartFragment: string) => /* GraphQL */ `\n mutation CartCreate(\n $input: CartInput!\n $numCartLines: Int = 250\n $country: CountryCode = ZZ\n ) @inContext(country: $country) {\n cartCreate(input: $input) {\n cart {\n ...CartFragment\n }\n }\n }\n\n ${cartFragment}\n`;\n\nexport const CartLineRemove = (cartFragment: string) => /* GraphQL */ `\n mutation CartLineRemove(\n $cartId: ID!\n $lines: [ID!]!\n $numCartLines: Int = 250\n $country: CountryCode = ZZ\n ) @inContext(country: $country) {\n cartLinesRemove(cartId: $cartId, lineIds: $lines) {\n cart {\n ...CartFragment\n }\n }\n }\n\n ${cartFragment}\n`;\n\nexport const CartLineUpdate = (cartFragment: string) => /* GraphQL */ `\n mutation CartLineUpdate(\n $cartId: ID!\n $lines: [CartLineUpdateInput!]!\n $numCartLines: Int = 250\n $country: CountryCode = ZZ\n ) @inContext(country: $country) {\n cartLinesUpdate(cartId: $cartId, lines: $lines) {\n cart {\n ...CartFragment\n }\n }\n }\n\n ${cartFragment}\n`;\n\nexport const CartNoteUpdate = (cartFragment: string) => /* GraphQL */ `\n mutation CartNoteUpdate(\n $cartId: ID!\n $note: String\n $numCartLines: Int = 250\n $country: CountryCode = ZZ\n ) @inContext(country: $country) {\n cartNoteUpdate(cartId: $cartId, note: $note) {\n cart {\n ...CartFragment\n }\n }\n }\n\n ${cartFragment}\n`;\n\nexport const CartBuyerIdentityUpdate = (cartFragment: string) => /* GraphQL */ `\n mutation CartBuyerIdentityUpdate(\n $cartId: ID!\n $buyerIdentity: CartBuyerIdentityInput!\n $numCartLines: Int = 250\n $country: CountryCode = ZZ\n ) @inContext(country: $country) {\n cartBuyerIdentityUpdate(cartId: $cartId, buyerIdentity: $buyerIdentity) {\n cart {\n ...CartFragment\n }\n }\n }\n\n ${cartFragment}\n`;\n\nexport const CartAttributesUpdate = (cartFragment: string) => /* GraphQL */ `\n mutation CartAttributesUpdate(\n $attributes: [AttributeInput!]!\n $cartId: ID!\n $numCartLines: Int = 250\n $country: CountryCode = ZZ\n ) @inContext(country: $country) {\n cartAttributesUpdate(attributes: $attributes, cartId: $cartId) {\n cart {\n ...CartFragment\n }\n }\n }\n\n ${cartFragment}\n`;\n\nexport const CartDiscountCodesUpdate = (cartFragment: string) => /* GraphQL */ `\n mutation CartDiscountCodesUpdate(\n $cartId: ID!\n $discountCodes: [String!]\n $numCartLines: Int = 250\n $country: CountryCode = ZZ\n ) @inContext(country: $country) {\n cartDiscountCodesUpdate(cartId: $cartId, discountCodes: $discountCodes) {\n cart {\n ...CartFragment\n }\n }\n }\n\n ${cartFragment}\n`;\n\nexport const CartQuery = (cartFragment: string) => /* GraphQL */ `\n query CartQuery(\n $id: ID!\n $numCartLines: Int = 250\n $country: CountryCode = ZZ\n ) @inContext(country: $country) {\n cart(id: $id) {\n ...CartFragment\n }\n }\n\n ${cartFragment}\n`;\n\nexport const defaultCartFragment = /* GraphQL */ `\n fragment CartFragment on Cart {\n id\n checkoutUrl\n totalQuantity\n buyerIdentity {\n countryCode\n customer {\n id\n email\n firstName\n lastName\n displayName\n }\n email\n phone\n }\n lines(first: $numCartLines) {\n edges {\n node {\n id\n quantity\n attributes {\n key\n value\n }\n cost {\n totalAmount {\n amount\n currencyCode\n }\n compareAtAmountPerQuantity {\n amount\n currencyCode\n }\n }\n merchandise {\n ... on ProductVariant {\n id\n availableForSale\n compareAtPrice {\n ...MoneyFragment\n }\n price {\n ...MoneyFragment\n }\n requiresShipping\n title\n image {\n ...ImageFragment\n }\n product {\n handle\n title\n id\n }\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n }\n cost {\n subtotalAmount {\n ...MoneyFragment\n }\n totalAmount {\n ...MoneyFragment\n }\n totalDutyAmount {\n ...MoneyFragment\n }\n totalTaxAmount {\n ...MoneyFragment\n }\n }\n note\n attributes {\n key\n value\n }\n discountCodes {\n code\n }\n }\n\n fragment MoneyFragment on MoneyV2 {\n currencyCode\n amount\n }\n fragment ImageFragment on Image {\n id\n url\n altText\n width\n height\n }\n`;\n"],"names":[],"mappings":"AAAa,MAAA,cAAc,CAAC,iBAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAc/D;AAAA;AAGS,MAAA,aAAa,CAAC,iBAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAa9D;AAAA;AAGS,MAAA,iBAAiB,CAAC,iBAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAclE;AAAA;AAGS,MAAA,iBAAiB,CAAC,iBAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAclE;AAAA;AAGS,MAAA,iBAAiB,CAAC,iBAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAclE;AAAA;AAGS,MAAA,0BAA0B,CAAC,iBAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAc3E;AAAA;AAGS,MAAA,uBAAuB,CAAC,iBAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAcxE;AAAA;AAGS,MAAA,0BAA0B,CAAC,iBAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAc3E;AAAA;AAGS,MAAA,YAAY,CAAC,iBAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAW7D;AAAA;AAGG,MAAM,sBAAoC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;"}
@@ -45,7 +45,7 @@ function ShopPayButton({
45
45
  className,
46
46
  style,
47
47
  children: shopPayLoadedStatus === "done" && /* @__PURE__ */ jsxRuntime.jsx("shop-pay-button", {
48
- "store-url": `https://${storeDomain}`,
48
+ "store-url": storeDomain,
49
49
  variants: ids.join(",")
50
50
  })
51
51
  });
@@ -1 +1 @@
1
- {"version":3,"file":"ShopPayButton.js","sources":["../../src/ShopPayButton.tsx"],"sourcesContent":["import {useShop} from './ShopifyProvider.js';\nimport {useLoadScript} from './load-script.js';\n\n// By using 'never' in the \"or\" cases below, it makes these props \"exclusive\" and means that you cannot pass both of them; you must pass either one OR the other.\ntype ShopPayButtonProps = {\n /** A string of classes to apply to the `div` that wraps the Shop Pay button. */\n className?: string;\n /** A string that's applied to the [CSS custom property (variable)](https://developer.mozilla.org/en-US/docs/Web/CSS/--*) `--shop-pay-button-width` for the [Buy with Shop Pay component](https://shopify.dev/custom-storefronts/tools/web-components#buy-with-shop-pay-component). */\n width?: string;\n} & (\n | {\n /** An array of IDs of the variants to purchase with Shop Pay. This will only ever have a quantity of 1 for each variant. If you want to use other quantities, then use 'variantIdsAndQuantities'. */\n variantIds: string[];\n /** An array of variant IDs and quantities to purchase with Shop Pay. */\n variantIdsAndQuantities?: never;\n }\n | {\n /** An array of IDs of the variants to purchase with Shop Pay. This will only ever have a quantity of 1 for each variant. If you want to use other quantities, then use 'variantIdsAndQuantities'. */\n variantIds?: never;\n /** An array of variant IDs and quantities to purchase with Shop Pay. */\n variantIdsAndQuantities: Array<{\n id: string;\n quantity: number;\n }>;\n }\n);\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace JSX {\n interface IntrinsicElements {\n 'shop-pay-button': {\n variants: string;\n 'store-url': string;\n };\n }\n }\n}\n\nconst SHOPJS_URL =\n 'https://cdn.shopify.com/shopifycloud/shop-js/v1.0/client.js';\n\n/**\n * The `ShopPayButton` component renders a button that redirects to the Shop Pay checkout.\n * It renders a [`<shop-pay-button>`](https://shopify.dev/custom-storefronts/tools/web-components) custom element, for which it will lazy-load the source code automatically.\n * It relies on the `<ShopProvider>` context provider.\n */\nexport function ShopPayButton({\n variantIds,\n className,\n variantIdsAndQuantities,\n width,\n}: ShopPayButtonProps) {\n const {storeDomain} = useShop();\n const shopPayLoadedStatus = useLoadScript(SHOPJS_URL);\n\n let ids: string[];\n\n if (variantIds && variantIdsAndQuantities) {\n throw new Error(DoublePropsErrorMessage);\n }\n\n if (variantIds) {\n ids = variantIds.reduce<string[]>((prev, curr) => {\n const bareId = getIdFromGid(curr);\n if (bareId) {\n prev.push(bareId);\n }\n return prev;\n }, []);\n } else if (variantIdsAndQuantities) {\n ids = variantIdsAndQuantities.reduce<string[]>((prev, curr) => {\n const bareId = getIdFromGid(curr?.id);\n if (bareId) {\n prev.push(`${bareId}:${curr?.quantity ?? 1}`);\n }\n return prev;\n }, []);\n } else {\n throw new Error(MissingPropsErrorMessage);\n }\n\n const style = width\n ? ({\n '--shop-pay-button-width': width,\n } as React.CSSProperties)\n : undefined;\n\n return (\n <div className={className} style={style}>\n {shopPayLoadedStatus === 'done' && (\n <shop-pay-button\n store-url={`https://${storeDomain}`}\n variants={ids.join(',')}\n />\n )}\n </div>\n );\n}\n\n/**\n * Takes a string in the format of \"gid://shopify/ProductVariant/41007289630776\" and returns a string of the ID part at the end: \"41007289630776\"\n */\nexport function getIdFromGid(id?: string) {\n if (!id) return;\n return id.split('/').pop();\n}\n\nexport const MissingPropsErrorMessage = `You must pass in either \"variantIds\" or \"variantIdsAndQuantities\" to ShopPayButton`;\nexport const DoublePropsErrorMessage = `You must provide either a variantIds or variantIdsAndQuantities prop, but not both in the ShopPayButton component`;\n"],"names":["SHOPJS_URL","ShopPayButton","variantIds","className","variantIdsAndQuantities","width","storeDomain","useShop","shopPayLoadedStatus","useLoadScript","ids","Error","DoublePropsErrorMessage","reduce","prev","curr","bareId","getIdFromGid","push","id","quantity","MissingPropsErrorMessage","style","undefined","_jsx","join","split","pop"],"mappings":";;;;;AAuCA,MAAMA,aACJ;AAOK,SAASC,cAAc;AAAA,EAC5BC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AACkB,GAAG;AACf,QAAA;AAAA,IAACC;AAAAA,MAAeC,gBAAS,QAAA;AACzBC,QAAAA,sBAAsBC,yBAAcT,UAAU;AAEhDU,MAAAA;AAEJ,MAAIR,cAAcE,yBAAyB;AACnC,UAAA,IAAIO,MAAMC,uBAAuB;AAAA,EACzC;AAEA,MAAIV,YAAY;AACdQ,UAAMR,WAAWW,OAAiB,CAACC,MAAMC,SAAS;AAC1CC,YAAAA,SAASC,aAAaF,IAAI;AAChC,UAAIC,QAAQ;AACVF,aAAKI,KAAKF,MAAM;AAAA,MAClB;AACOF,aAAAA;AAAAA,IACT,GAAG,CAAE,CAAA;AAAA,aACIV,yBAAyB;AAClCM,UAAMN,wBAAwBS,OAAiB,CAACC,MAAMC,SAAS;;AACvDC,YAAAA,SAASC,aAAaF,6BAAMI,EAAE;AACpC,UAAIH,QAAQ;AACVF,aAAKI,KAAM,GAAEF,WAAUD,kCAAMK,aAANL,YAAkB,GAAG;AAAA,MAC9C;AACOD,aAAAA;AAAAA,IACT,GAAG,CAAE,CAAA;AAAA,EAAA,OACA;AACC,UAAA,IAAIH,MAAMU,wBAAwB;AAAA,EAC1C;AAEA,QAAMC,QAAQjB,QACT;AAAA,IACC,2BAA2BA;AAAAA,EAE7BkB,IAAAA;AAEJ,wCACE,OAAA;AAAA,IAAK;AAAA,IAAsB;AAAA,IAAa,UACrCf,wBAAwB,UACvBgB,2BAAAA,IAAA,mBAAA;AAAA,MACE,aAAY,WAAUlB;AAAAA,MACtB,UAAUI,IAAIe,KAAK,GAAG;AAAA,IAAA,CAAE;AAAA,EAAA,CAGxB;AAEV;AAKO,SAASR,aAAaE,IAAa;AACxC,MAAI,CAACA;AAAI;AACT,SAAOA,GAAGO,MAAM,GAAG,EAAEC,IAAK;AAC5B;AAEO,MAAMN,2BAA4B;AAClC,MAAMT,0BAA2B;;;;;"}
1
+ {"version":3,"file":"ShopPayButton.js","sources":["../../src/ShopPayButton.tsx"],"sourcesContent":["import {useShop} from './ShopifyProvider.js';\nimport {useLoadScript} from './load-script.js';\n\n// By using 'never' in the \"or\" cases below, it makes these props \"exclusive\" and means that you cannot pass both of them; you must pass either one OR the other.\ntype ShopPayButtonProps = {\n /** A string of classes to apply to the `div` that wraps the Shop Pay button. */\n className?: string;\n /** A string that's applied to the [CSS custom property (variable)](https://developer.mozilla.org/en-US/docs/Web/CSS/--*) `--shop-pay-button-width` for the [Buy with Shop Pay component](https://shopify.dev/custom-storefronts/tools/web-components#buy-with-shop-pay-component). */\n width?: string;\n} & (\n | {\n /** An array of IDs of the variants to purchase with Shop Pay. This will only ever have a quantity of 1 for each variant. If you want to use other quantities, then use 'variantIdsAndQuantities'. */\n variantIds: string[];\n /** An array of variant IDs and quantities to purchase with Shop Pay. */\n variantIdsAndQuantities?: never;\n }\n | {\n /** An array of IDs of the variants to purchase with Shop Pay. This will only ever have a quantity of 1 for each variant. If you want to use other quantities, then use 'variantIdsAndQuantities'. */\n variantIds?: never;\n /** An array of variant IDs and quantities to purchase with Shop Pay. */\n variantIdsAndQuantities: Array<{\n id: string;\n quantity: number;\n }>;\n }\n);\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace JSX {\n interface IntrinsicElements {\n 'shop-pay-button': {\n variants: string;\n 'store-url': string;\n };\n }\n }\n}\n\nconst SHOPJS_URL =\n 'https://cdn.shopify.com/shopifycloud/shop-js/v1.0/client.js';\n\n/**\n * The `ShopPayButton` component renders a button that redirects to the Shop Pay checkout.\n * It renders a [`<shop-pay-button>`](https://shopify.dev/custom-storefronts/tools/web-components) custom element, for which it will lazy-load the source code automatically.\n * It relies on the `<ShopProvider>` context provider.\n */\nexport function ShopPayButton({\n variantIds,\n className,\n variantIdsAndQuantities,\n width,\n}: ShopPayButtonProps) {\n const {storeDomain} = useShop();\n const shopPayLoadedStatus = useLoadScript(SHOPJS_URL);\n\n let ids: string[];\n\n if (variantIds && variantIdsAndQuantities) {\n throw new Error(DoublePropsErrorMessage);\n }\n\n if (variantIds) {\n ids = variantIds.reduce<string[]>((prev, curr) => {\n const bareId = getIdFromGid(curr);\n if (bareId) {\n prev.push(bareId);\n }\n return prev;\n }, []);\n } else if (variantIdsAndQuantities) {\n ids = variantIdsAndQuantities.reduce<string[]>((prev, curr) => {\n const bareId = getIdFromGid(curr?.id);\n if (bareId) {\n prev.push(`${bareId}:${curr?.quantity ?? 1}`);\n }\n return prev;\n }, []);\n } else {\n throw new Error(MissingPropsErrorMessage);\n }\n\n const style = width\n ? ({\n '--shop-pay-button-width': width,\n } as React.CSSProperties)\n : undefined;\n\n return (\n <div className={className} style={style}>\n {shopPayLoadedStatus === 'done' && (\n <shop-pay-button store-url={storeDomain} variants={ids.join(',')} />\n )}\n </div>\n );\n}\n\n/**\n * Takes a string in the format of \"gid://shopify/ProductVariant/41007289630776\" and returns a string of the ID part at the end: \"41007289630776\"\n */\nexport function getIdFromGid(id?: string) {\n if (!id) return;\n return id.split('/').pop();\n}\n\nexport const MissingPropsErrorMessage = `You must pass in either \"variantIds\" or \"variantIdsAndQuantities\" to ShopPayButton`;\nexport const DoublePropsErrorMessage = `You must provide either a variantIds or variantIdsAndQuantities prop, but not both in the ShopPayButton component`;\n"],"names":["SHOPJS_URL","ShopPayButton","variantIds","className","variantIdsAndQuantities","width","storeDomain","useShop","shopPayLoadedStatus","useLoadScript","ids","Error","DoublePropsErrorMessage","reduce","prev","curr","bareId","getIdFromGid","push","id","quantity","MissingPropsErrorMessage","style","undefined","_jsx","join","split","pop"],"mappings":";;;;;AAuCA,MAAMA,aACJ;AAOK,SAASC,cAAc;AAAA,EAC5BC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AACkB,GAAG;AACf,QAAA;AAAA,IAACC;AAAAA,MAAeC,gBAAS,QAAA;AACzBC,QAAAA,sBAAsBC,yBAAcT,UAAU;AAEhDU,MAAAA;AAEJ,MAAIR,cAAcE,yBAAyB;AACnC,UAAA,IAAIO,MAAMC,uBAAuB;AAAA,EACzC;AAEA,MAAIV,YAAY;AACdQ,UAAMR,WAAWW,OAAiB,CAACC,MAAMC,SAAS;AAC1CC,YAAAA,SAASC,aAAaF,IAAI;AAChC,UAAIC,QAAQ;AACVF,aAAKI,KAAKF,MAAM;AAAA,MAClB;AACOF,aAAAA;AAAAA,IACT,GAAG,CAAE,CAAA;AAAA,aACIV,yBAAyB;AAClCM,UAAMN,wBAAwBS,OAAiB,CAACC,MAAMC,SAAS;;AACvDC,YAAAA,SAASC,aAAaF,6BAAMI,EAAE;AACpC,UAAIH,QAAQ;AACVF,aAAKI,KAAM,GAAEF,WAAUD,kCAAMK,aAANL,YAAkB,GAAG;AAAA,MAC9C;AACOD,aAAAA;AAAAA,IACT,GAAG,CAAE,CAAA;AAAA,EAAA,OACA;AACC,UAAA,IAAIH,MAAMU,wBAAwB;AAAA,EAC1C;AAEA,QAAMC,QAAQjB,QACT;AAAA,IACC,2BAA2BA;AAAAA,EAE7BkB,IAAAA;AAEJ,wCACE,OAAA;AAAA,IAAK;AAAA,IAAsB;AAAA,IAAa,UACrCf,wBAAwB,UACvBgB,2BAAAA,IAAA,mBAAA;AAAA,MAAiB,aAAWlB;AAAAA,MAAa,UAAUI,IAAIe,KAAK,GAAG;AAAA,IAAA,CAAE;AAAA,EAAA,CAE/D;AAEV;AAKO,SAASR,aAAaE,IAAa;AACxC,MAAI,CAACA;AAAI;AACT,SAAOA,GAAGO,MAAM,GAAG,EAAEC,IAAK;AAC5B;AAEO,MAAMN,2BAA4B;AAClC,MAAMT,0BAA2B;;;;;"}
@@ -43,7 +43,7 @@ function ShopPayButton({
43
43
  className,
44
44
  style,
45
45
  children: shopPayLoadedStatus === "done" && /* @__PURE__ */ jsx("shop-pay-button", {
46
- "store-url": `https://${storeDomain}`,
46
+ "store-url": storeDomain,
47
47
  variants: ids.join(",")
48
48
  })
49
49
  });
@@ -1 +1 @@
1
- {"version":3,"file":"ShopPayButton.mjs","sources":["../../src/ShopPayButton.tsx"],"sourcesContent":["import {useShop} from './ShopifyProvider.js';\nimport {useLoadScript} from './load-script.js';\n\n// By using 'never' in the \"or\" cases below, it makes these props \"exclusive\" and means that you cannot pass both of them; you must pass either one OR the other.\ntype ShopPayButtonProps = {\n /** A string of classes to apply to the `div` that wraps the Shop Pay button. */\n className?: string;\n /** A string that's applied to the [CSS custom property (variable)](https://developer.mozilla.org/en-US/docs/Web/CSS/--*) `--shop-pay-button-width` for the [Buy with Shop Pay component](https://shopify.dev/custom-storefronts/tools/web-components#buy-with-shop-pay-component). */\n width?: string;\n} & (\n | {\n /** An array of IDs of the variants to purchase with Shop Pay. This will only ever have a quantity of 1 for each variant. If you want to use other quantities, then use 'variantIdsAndQuantities'. */\n variantIds: string[];\n /** An array of variant IDs and quantities to purchase with Shop Pay. */\n variantIdsAndQuantities?: never;\n }\n | {\n /** An array of IDs of the variants to purchase with Shop Pay. This will only ever have a quantity of 1 for each variant. If you want to use other quantities, then use 'variantIdsAndQuantities'. */\n variantIds?: never;\n /** An array of variant IDs and quantities to purchase with Shop Pay. */\n variantIdsAndQuantities: Array<{\n id: string;\n quantity: number;\n }>;\n }\n);\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace JSX {\n interface IntrinsicElements {\n 'shop-pay-button': {\n variants: string;\n 'store-url': string;\n };\n }\n }\n}\n\nconst SHOPJS_URL =\n 'https://cdn.shopify.com/shopifycloud/shop-js/v1.0/client.js';\n\n/**\n * The `ShopPayButton` component renders a button that redirects to the Shop Pay checkout.\n * It renders a [`<shop-pay-button>`](https://shopify.dev/custom-storefronts/tools/web-components) custom element, for which it will lazy-load the source code automatically.\n * It relies on the `<ShopProvider>` context provider.\n */\nexport function ShopPayButton({\n variantIds,\n className,\n variantIdsAndQuantities,\n width,\n}: ShopPayButtonProps) {\n const {storeDomain} = useShop();\n const shopPayLoadedStatus = useLoadScript(SHOPJS_URL);\n\n let ids: string[];\n\n if (variantIds && variantIdsAndQuantities) {\n throw new Error(DoublePropsErrorMessage);\n }\n\n if (variantIds) {\n ids = variantIds.reduce<string[]>((prev, curr) => {\n const bareId = getIdFromGid(curr);\n if (bareId) {\n prev.push(bareId);\n }\n return prev;\n }, []);\n } else if (variantIdsAndQuantities) {\n ids = variantIdsAndQuantities.reduce<string[]>((prev, curr) => {\n const bareId = getIdFromGid(curr?.id);\n if (bareId) {\n prev.push(`${bareId}:${curr?.quantity ?? 1}`);\n }\n return prev;\n }, []);\n } else {\n throw new Error(MissingPropsErrorMessage);\n }\n\n const style = width\n ? ({\n '--shop-pay-button-width': width,\n } as React.CSSProperties)\n : undefined;\n\n return (\n <div className={className} style={style}>\n {shopPayLoadedStatus === 'done' && (\n <shop-pay-button\n store-url={`https://${storeDomain}`}\n variants={ids.join(',')}\n />\n )}\n </div>\n );\n}\n\n/**\n * Takes a string in the format of \"gid://shopify/ProductVariant/41007289630776\" and returns a string of the ID part at the end: \"41007289630776\"\n */\nexport function getIdFromGid(id?: string) {\n if (!id) return;\n return id.split('/').pop();\n}\n\nexport const MissingPropsErrorMessage = `You must pass in either \"variantIds\" or \"variantIdsAndQuantities\" to ShopPayButton`;\nexport const DoublePropsErrorMessage = `You must provide either a variantIds or variantIdsAndQuantities prop, but not both in the ShopPayButton component`;\n"],"names":["SHOPJS_URL","ShopPayButton","variantIds","className","variantIdsAndQuantities","width","storeDomain","useShop","shopPayLoadedStatus","useLoadScript","ids","Error","DoublePropsErrorMessage","reduce","prev","curr","bareId","getIdFromGid","push","id","quantity","MissingPropsErrorMessage","style","undefined","_jsx","join","split","pop"],"mappings":";;;AAuCA,MAAMA,aACJ;AAOK,SAASC,cAAc;AAAA,EAC5BC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AACkB,GAAG;AACf,QAAA;AAAA,IAACC;AAAAA,MAAeC,QAAS;AACzBC,QAAAA,sBAAsBC,cAAcT,UAAU;AAEhDU,MAAAA;AAEJ,MAAIR,cAAcE,yBAAyB;AACnC,UAAA,IAAIO,MAAMC,uBAAuB;AAAA,EACzC;AAEA,MAAIV,YAAY;AACdQ,UAAMR,WAAWW,OAAiB,CAACC,MAAMC,SAAS;AAC1CC,YAAAA,SAASC,aAAaF,IAAI;AAChC,UAAIC,QAAQ;AACVF,aAAKI,KAAKF,MAAM;AAAA,MAClB;AACOF,aAAAA;AAAAA,IACT,GAAG,CAAE,CAAA;AAAA,aACIV,yBAAyB;AAClCM,UAAMN,wBAAwBS,OAAiB,CAACC,MAAMC,SAAS;;AACvDC,YAAAA,SAASC,aAAaF,6BAAMI,EAAE;AACpC,UAAIH,QAAQ;AACVF,aAAKI,KAAM,GAAEF,WAAUD,kCAAMK,aAANL,YAAkB,GAAG;AAAA,MAC9C;AACOD,aAAAA;AAAAA,IACT,GAAG,CAAE,CAAA;AAAA,EAAA,OACA;AACC,UAAA,IAAIH,MAAMU,wBAAwB;AAAA,EAC1C;AAEA,QAAMC,QAAQjB,QACT;AAAA,IACC,2BAA2BA;AAAAA,EAE7BkB,IAAAA;AAEJ,6BACE,OAAA;AAAA,IAAK;AAAA,IAAsB;AAAA,IAAa,UACrCf,wBAAwB,UACvBgB,oBAAA,mBAAA;AAAA,MACE,aAAY,WAAUlB;AAAAA,MACtB,UAAUI,IAAIe,KAAK,GAAG;AAAA,IAAA,CAAE;AAAA,EAAA,CAGxB;AAEV;AAKO,SAASR,aAAaE,IAAa;AACxC,MAAI,CAACA;AAAI;AACT,SAAOA,GAAGO,MAAM,GAAG,EAAEC,IAAK;AAC5B;AAEO,MAAMN,2BAA4B;AAClC,MAAMT,0BAA2B;"}
1
+ {"version":3,"file":"ShopPayButton.mjs","sources":["../../src/ShopPayButton.tsx"],"sourcesContent":["import {useShop} from './ShopifyProvider.js';\nimport {useLoadScript} from './load-script.js';\n\n// By using 'never' in the \"or\" cases below, it makes these props \"exclusive\" and means that you cannot pass both of them; you must pass either one OR the other.\ntype ShopPayButtonProps = {\n /** A string of classes to apply to the `div` that wraps the Shop Pay button. */\n className?: string;\n /** A string that's applied to the [CSS custom property (variable)](https://developer.mozilla.org/en-US/docs/Web/CSS/--*) `--shop-pay-button-width` for the [Buy with Shop Pay component](https://shopify.dev/custom-storefronts/tools/web-components#buy-with-shop-pay-component). */\n width?: string;\n} & (\n | {\n /** An array of IDs of the variants to purchase with Shop Pay. This will only ever have a quantity of 1 for each variant. If you want to use other quantities, then use 'variantIdsAndQuantities'. */\n variantIds: string[];\n /** An array of variant IDs and quantities to purchase with Shop Pay. */\n variantIdsAndQuantities?: never;\n }\n | {\n /** An array of IDs of the variants to purchase with Shop Pay. This will only ever have a quantity of 1 for each variant. If you want to use other quantities, then use 'variantIdsAndQuantities'. */\n variantIds?: never;\n /** An array of variant IDs and quantities to purchase with Shop Pay. */\n variantIdsAndQuantities: Array<{\n id: string;\n quantity: number;\n }>;\n }\n);\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace JSX {\n interface IntrinsicElements {\n 'shop-pay-button': {\n variants: string;\n 'store-url': string;\n };\n }\n }\n}\n\nconst SHOPJS_URL =\n 'https://cdn.shopify.com/shopifycloud/shop-js/v1.0/client.js';\n\n/**\n * The `ShopPayButton` component renders a button that redirects to the Shop Pay checkout.\n * It renders a [`<shop-pay-button>`](https://shopify.dev/custom-storefronts/tools/web-components) custom element, for which it will lazy-load the source code automatically.\n * It relies on the `<ShopProvider>` context provider.\n */\nexport function ShopPayButton({\n variantIds,\n className,\n variantIdsAndQuantities,\n width,\n}: ShopPayButtonProps) {\n const {storeDomain} = useShop();\n const shopPayLoadedStatus = useLoadScript(SHOPJS_URL);\n\n let ids: string[];\n\n if (variantIds && variantIdsAndQuantities) {\n throw new Error(DoublePropsErrorMessage);\n }\n\n if (variantIds) {\n ids = variantIds.reduce<string[]>((prev, curr) => {\n const bareId = getIdFromGid(curr);\n if (bareId) {\n prev.push(bareId);\n }\n return prev;\n }, []);\n } else if (variantIdsAndQuantities) {\n ids = variantIdsAndQuantities.reduce<string[]>((prev, curr) => {\n const bareId = getIdFromGid(curr?.id);\n if (bareId) {\n prev.push(`${bareId}:${curr?.quantity ?? 1}`);\n }\n return prev;\n }, []);\n } else {\n throw new Error(MissingPropsErrorMessage);\n }\n\n const style = width\n ? ({\n '--shop-pay-button-width': width,\n } as React.CSSProperties)\n : undefined;\n\n return (\n <div className={className} style={style}>\n {shopPayLoadedStatus === 'done' && (\n <shop-pay-button store-url={storeDomain} variants={ids.join(',')} />\n )}\n </div>\n );\n}\n\n/**\n * Takes a string in the format of \"gid://shopify/ProductVariant/41007289630776\" and returns a string of the ID part at the end: \"41007289630776\"\n */\nexport function getIdFromGid(id?: string) {\n if (!id) return;\n return id.split('/').pop();\n}\n\nexport const MissingPropsErrorMessage = `You must pass in either \"variantIds\" or \"variantIdsAndQuantities\" to ShopPayButton`;\nexport const DoublePropsErrorMessage = `You must provide either a variantIds or variantIdsAndQuantities prop, but not both in the ShopPayButton component`;\n"],"names":["SHOPJS_URL","ShopPayButton","variantIds","className","variantIdsAndQuantities","width","storeDomain","useShop","shopPayLoadedStatus","useLoadScript","ids","Error","DoublePropsErrorMessage","reduce","prev","curr","bareId","getIdFromGid","push","id","quantity","MissingPropsErrorMessage","style","undefined","_jsx","join","split","pop"],"mappings":";;;AAuCA,MAAMA,aACJ;AAOK,SAASC,cAAc;AAAA,EAC5BC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AACkB,GAAG;AACf,QAAA;AAAA,IAACC;AAAAA,MAAeC,QAAS;AACzBC,QAAAA,sBAAsBC,cAAcT,UAAU;AAEhDU,MAAAA;AAEJ,MAAIR,cAAcE,yBAAyB;AACnC,UAAA,IAAIO,MAAMC,uBAAuB;AAAA,EACzC;AAEA,MAAIV,YAAY;AACdQ,UAAMR,WAAWW,OAAiB,CAACC,MAAMC,SAAS;AAC1CC,YAAAA,SAASC,aAAaF,IAAI;AAChC,UAAIC,QAAQ;AACVF,aAAKI,KAAKF,MAAM;AAAA,MAClB;AACOF,aAAAA;AAAAA,IACT,GAAG,CAAE,CAAA;AAAA,aACIV,yBAAyB;AAClCM,UAAMN,wBAAwBS,OAAiB,CAACC,MAAMC,SAAS;;AACvDC,YAAAA,SAASC,aAAaF,6BAAMI,EAAE;AACpC,UAAIH,QAAQ;AACVF,aAAKI,KAAM,GAAEF,WAAUD,kCAAMK,aAANL,YAAkB,GAAG;AAAA,MAC9C;AACOD,aAAAA;AAAAA,IACT,GAAG,CAAE,CAAA;AAAA,EAAA,OACA;AACC,UAAA,IAAIH,MAAMU,wBAAwB;AAAA,EAC1C;AAEA,QAAMC,QAAQjB,QACT;AAAA,IACC,2BAA2BA;AAAAA,EAE7BkB,IAAAA;AAEJ,6BACE,OAAA;AAAA,IAAK;AAAA,IAAsB;AAAA,IAAa,UACrCf,wBAAwB,UACvBgB,oBAAA,mBAAA;AAAA,MAAiB,aAAWlB;AAAAA,MAAa,UAAUI,IAAIe,KAAK,GAAG;AAAA,IAAA,CAAE;AAAA,EAAA,CAE/D;AAEV;AAKO,SAASR,aAAaE,IAAa;AACxC,MAAI,CAACA;AAAI;AACT,SAAOA,GAAGO,MAAM,GAAG,EAAEC,IAAK;AAC5B;AAEO,MAAMN,2BAA4B;AAClC,MAAMT,0BAA2B;"}
@@ -36,21 +36,12 @@ function ShopifyProvider({
36
36
  console.warn(`<ShopifyProvider/>: This version of Hydrogen-UI is built for Shopify's Storefront API version ${storefrontApiConstants.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-UI and the Storefront API.`);
37
37
  }
38
38
  const finalConfig = require$$0.useMemo(() => {
39
- const storeDomain = shopifyConfig.storeDomain.replace(/^https?:\/\//, "");
40
- if (storeDomain.includes(".myshopify.com")) {
41
- {
42
- console.warn(`<ShopifyProvider/>: passing a 'storeDomain' prop that includes '.myshopify.com' will be unsupported in the future. Passing only the subdomain (for example, if the URL is 'test.myshopify.com', passing in 'test') will be the supported way going forward.`);
43
- }
44
- }
45
39
  function getShopifyDomain(overrideProps) {
46
40
  var _a;
47
- let subDomain = (_a = overrideProps == null ? void 0 : overrideProps.storeDomain) != null ? _a : storeDomain;
48
- subDomain = subDomain.replace(".myshopify.com", "");
49
- return `https://${subDomain}.myshopify.com`;
41
+ return (_a = overrideProps == null ? void 0 : overrideProps.storeDomain) != null ? _a : shopifyConfig.storeDomain;
50
42
  }
51
43
  return {
52
44
  ...shopifyConfig,
53
- storeDomain,
54
45
  getPublicTokenHeaders(overrideProps) {
55
46
  var _a;
56
47
  return storefrontClient.getPublicTokenHeadersRaw(overrideProps.contentType, shopifyConfig.storefrontApiVersion, (_a = overrideProps.storefrontToken) != null ? _a : shopifyConfig.storefrontToken);
@@ -64,7 +55,7 @@ function ShopifyProvider({
64
55
  }
65
56
  }
66
57
  return `${getShopifyDomain({
67
- storeDomain: (_b = overrideProps == null ? void 0 : overrideProps.storeDomain) != null ? _b : storeDomain
58
+ storeDomain: (_b = overrideProps == null ? void 0 : overrideProps.storeDomain) != null ? _b : shopifyConfig.storeDomain
68
59
  })}/api/${(_c = overrideProps == null ? void 0 : overrideProps.storefrontApiVersion) != null ? _c : shopifyConfig.storefrontApiVersion}/graphql.json`;
69
60
  }
70
61
  };
@@ -1 +1 @@
1
- {"version":3,"file":"ShopifyProvider.js","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\nconst ShopifyContext = createContext<ShopifyContextValue>({\n storeDomain: 'test',\n storefrontToken: 'abc123',\n storefrontApiVersion: SFAPI_VERSION,\n country: {\n isoCode: 'US',\n },\n language: {\n isoCode: 'EN',\n },\n locale: 'EN-US',\n getStorefrontApiUrl() {\n return '';\n },\n getPublicTokenHeaders() {\n return {};\n },\n getShopifyDomain() {\n return '';\n },\n});\n\n/**\n * The `<ShopifyProvider/>` component enables use of the `useShop()` hook. The component should wrap your app.\n */\nexport function ShopifyProvider({\n children,\n shopifyConfig,\n}: {\n children: ReactNode;\n shopifyConfig: ShopifyContextProps;\n}) {\n if (!shopifyConfig) {\n throw new Error(\n `The 'shopifyConfig' prop must be passed to '<ShopifyProvider/>'`\n );\n }\n\n if (shopifyConfig.storefrontApiVersion !== SFAPI_VERSION) {\n console.warn(\n `<ShopifyProvider/>: This version of Hydrogen-UI 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-UI and the Storefront API.`\n );\n }\n\n const finalConfig = useMemo<ShopifyContextValue>(() => {\n const storeDomain = shopifyConfig.storeDomain.replace(/^https?:\\/\\//, '');\n\n // @deprecated remove the ability to pass in '.myshopify.com' strings in the future\n if (storeDomain.includes('.myshopify.com')) {\n if (__HYDROGEN_DEV__) {\n console.warn(\n `<ShopifyProvider/>: passing a 'storeDomain' prop that includes '.myshopify.com' will be unsupported in the future. Passing only the subdomain (for example, if the URL is 'test.myshopify.com', passing in 'test') will be the supported way going forward.`\n );\n }\n }\n\n function getShopifyDomain(overrideProps?: {storeDomain?: string}) {\n let subDomain = overrideProps?.storeDomain ?? storeDomain;\n subDomain = subDomain.replace('.myshopify.com', '');\n\n return `https://${subDomain}.myshopify.com`;\n }\n\n return {\n ...shopifyConfig,\n storeDomain,\n getPublicTokenHeaders(overrideProps) {\n return getPublicTokenHeadersRaw(\n overrideProps.contentType,\n shopifyConfig.storefrontApiVersion,\n overrideProps.storefrontToken ?? shopifyConfig.storefrontToken\n );\n },\n getShopifyDomain,\n getStorefrontApiUrl(overrideProps) {\n if (overrideProps?.storeDomain?.includes('.myshopify.com')) {\n if (__HYDROGEN_DEV__) {\n console.warn(\n `<ShopifyProvider/>: passing a 'storeDomain' prop that includes '.myshopify.com' will be unsupported in the future. Passing only the subdomain (for example, if the URL is 'test.myshopify.com', passing in 'test') will be the supported way going forward.`\n );\n }\n }\n return `${getShopifyDomain({\n storeDomain: overrideProps?.storeDomain ?? storeDomain,\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 */\nexport function useShop() {\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\n/**\n * Shopify-specific values that are used in various Hydrogen-UI components and hooks.\n */\nexport type ShopifyContextProps = {\n /** The globally-unique identifier for the Shop */\n storefrontId?: string;\n /** The subdomain of your Shopify storefront URL (eg: `{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-UI was built for. Learn more about Shopify [API versioning](https://shopify.dev/api/usage/versioning) for more details. */\n storefrontApiVersion: string;\n country?: {\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 isoCode: CountryCode;\n };\n language?: {\n /**\n * `ISO 369` language codes supported by Shopify.\n */\n isoCode: LanguageCode;\n };\n /**\n * The locale string based on `country` and `language`.\n */\n locale?: string;\n};\n\nexport type ShopifyContextValue = ShopifyContextProps & {\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?: {\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 }) => 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: (props: {\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 }) => 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?: {storeDomain?: string}) => string;\n};\n"],"names":["ShopifyContext","createContext","storeDomain","storefrontToken","storefrontApiVersion","SFAPI_VERSION","country","isoCode","language","locale","getStorefrontApiUrl","getPublicTokenHeaders","getShopifyDomain","ShopifyProvider","children","shopifyConfig","Error","console","warn","finalConfig","useMemo","replace","includes","overrideProps","subDomain","getPublicTokenHeadersRaw","contentType","_jsx","useShop","shopContext","useContext"],"mappings":";;;;;;AAKA,MAAMA,iBAAiBC,WAAAA,cAAmC;AAAA,EACxDC,aAAa;AAAA,EACbC,iBAAiB;AAAA,EACjBC,sBAAsBC,uBAAAA;AAAAA,EACtBC,SAAS;AAAA,IACPC,SAAS;AAAA,EACX;AAAA,EACAC,UAAU;AAAA,IACRD,SAAS;AAAA,EACX;AAAA,EACAE,QAAQ;AAAA,EACRC,sBAAsB;AACb,WAAA;AAAA,EACT;AAAA,EACAC,wBAAwB;AACtB,WAAO;EACT;AAAA,EACAC,mBAAmB;AACV,WAAA;AAAA,EACT;AACF,CAAC;AAKM,SAASC,gBAAgB;AAAA,EAC9BC;AAAAA,EACAC;AAIF,GAAG;AACD,MAAI,CAACA,eAAe;AACZ,UAAA,IAAIC,MACP,iEAAgE;AAAA,EAErE;AAEID,MAAAA,cAAcX,yBAAyBC,sCAAe;AACxDY,YAAQC,KACL,iGAAgGb,uBAAyDU,yDAAAA,cAAcX,0HAA0H;AAAA,EAEtS;AAEMe,QAAAA,cAAcC,WAAAA,QAA6B,MAAM;AACrD,UAAMlB,cAAca,cAAcb,YAAYmB,QAAQ,gBAAgB,EAAE;AAGpEnB,QAAAA,YAAYoB,SAAS,gBAAgB,GAAG;AACpB;AACpBL,gBAAQC,KACL,6PAA4P;AAAA,MAEjQ;AAAA,IACF;AAEA,aAASN,iBAAiBW,eAAwC;;AAC5DC,UAAAA,aAAYD,oDAAerB,gBAAfqB,YAA8BrB;AAClCsB,kBAAAA,UAAUH,QAAQ,kBAAkB,EAAE;AAElD,aAAQ,WAAUG;AAAAA,IACpB;AAEO,WAAA;AAAA,MACL,GAAGT;AAAAA,MACHb;AAAAA,MACAS,sBAAsBY,eAAe;;AAC5BE,eAAAA,iBAAAA,yBACLF,cAAcG,aACdX,cAAcX,uBACdmB,mBAAcpB,oBAAdoB,YAAiCR,cAAcZ,eAAe;AAAA,MAElE;AAAA,MACAS;AAAAA,MACAF,oBAAoBa,eAAe;;AACjC,aAAIA,oDAAerB,gBAAfqB,mBAA4BD,SAAS,mBAAmB;AACpC;AACpBL,oBAAQC,KACL,6PAA4P;AAAA,UAEjQ;AAAA,QACF;AACA,eAAQ,GAAEN,iBAAiB;AAAA,UACzBV,cAAaqB,oDAAerB,gBAAfqB,YAA8BrB;AAAAA,QAAAA,CAC5C,UACCqB,oDAAenB,yBAAfmB,YACAR,cAAcX;AAAAA,MAElB;AAAA,IAAA;AAAA,EACF,GACC,CAACW,aAAa,CAAC;AAGhB,SAAAY,2BAAA,IAAC,eAAe,UAAQ;AAAA,IAAC,OAAOR;AAAAA,IAAY;AAAA,EAAA,CAElB;AAE9B;AAKO,SAASS,UAAU;AAClBC,QAAAA,cAAcC,sBAAW9B,cAAc;AAC7C,MAAI,CAAC6B,aAAa;AACV,UAAA,IAAIb,MAAO,wDAAuD;AAAA,EAC1E;AACOa,SAAAA;AACT;;;"}
1
+ {"version":3,"file":"ShopifyProvider.js","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\nconst ShopifyContext = createContext<ShopifyContextValue>({\n storeDomain: 'test',\n storefrontToken: 'abc123',\n storefrontApiVersion: SFAPI_VERSION,\n country: {\n isoCode: 'US',\n },\n language: {\n isoCode: 'EN',\n },\n locale: 'EN-US',\n getStorefrontApiUrl() {\n return '';\n },\n getPublicTokenHeaders() {\n return {};\n },\n getShopifyDomain() {\n return '';\n },\n});\n\n/**\n * The `<ShopifyProvider/>` component enables use of the `useShop()` hook. The component should wrap your app.\n */\nexport function ShopifyProvider({\n children,\n shopifyConfig,\n}: {\n children: ReactNode;\n shopifyConfig: ShopifyContextProps;\n}) {\n if (!shopifyConfig) {\n throw new Error(\n `The 'shopifyConfig' prop must be passed to '<ShopifyProvider/>'`\n );\n }\n\n if (shopifyConfig.storefrontApiVersion !== SFAPI_VERSION) {\n console.warn(\n `<ShopifyProvider/>: This version of Hydrogen-UI 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-UI and the Storefront API.`\n );\n }\n\n const finalConfig = useMemo<ShopifyContextValue>(() => {\n function getShopifyDomain(overrideProps?: {storeDomain?: string}) {\n return overrideProps?.storeDomain ?? shopifyConfig.storeDomain;\n }\n\n return {\n ...shopifyConfig,\n getPublicTokenHeaders(overrideProps) {\n return getPublicTokenHeadersRaw(\n overrideProps.contentType,\n shopifyConfig.storefrontApiVersion,\n overrideProps.storefrontToken ?? shopifyConfig.storefrontToken\n );\n },\n getShopifyDomain,\n getStorefrontApiUrl(overrideProps) {\n if (overrideProps?.storeDomain?.includes('.myshopify.com')) {\n if (__HYDROGEN_DEV__) {\n console.warn(\n `<ShopifyProvider/>: passing a 'storeDomain' prop that includes '.myshopify.com' will be unsupported in the future. Passing only the subdomain (for example, if the URL is 'test.myshopify.com', passing in 'test') will be the supported way going forward.`\n );\n }\n }\n return `${getShopifyDomain({\n storeDomain: overrideProps?.storeDomain ?? shopifyConfig.storeDomain,\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 */\nexport function useShop() {\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\n/**\n * Shopify-specific values that are used in various Hydrogen-UI components and hooks.\n */\nexport type ShopifyContextProps = {\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-UI was built for. Learn more about Shopify [API versioning](https://shopify.dev/api/usage/versioning) for more details. */\n storefrontApiVersion: string;\n country?: {\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 isoCode: CountryCode;\n };\n language?: {\n /**\n * `ISO 369` language codes supported by Shopify.\n */\n isoCode: LanguageCode;\n };\n /**\n * The locale string based on `country` and `language`.\n */\n locale?: string;\n};\n\nexport type ShopifyContextValue = ShopifyContextProps & {\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?: {\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 }) => 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: (props: {\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 }) => 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?: {storeDomain?: string}) => string;\n};\n"],"names":["ShopifyContext","createContext","storeDomain","storefrontToken","storefrontApiVersion","SFAPI_VERSION","country","isoCode","language","locale","getStorefrontApiUrl","getPublicTokenHeaders","getShopifyDomain","ShopifyProvider","children","shopifyConfig","Error","console","warn","finalConfig","useMemo","overrideProps","getPublicTokenHeadersRaw","contentType","includes","_jsx","useShop","shopContext","useContext"],"mappings":";;;;;;AAKA,MAAMA,iBAAiBC,WAAAA,cAAmC;AAAA,EACxDC,aAAa;AAAA,EACbC,iBAAiB;AAAA,EACjBC,sBAAsBC,uBAAAA;AAAAA,EACtBC,SAAS;AAAA,IACPC,SAAS;AAAA,EACX;AAAA,EACAC,UAAU;AAAA,IACRD,SAAS;AAAA,EACX;AAAA,EACAE,QAAQ;AAAA,EACRC,sBAAsB;AACb,WAAA;AAAA,EACT;AAAA,EACAC,wBAAwB;AACtB,WAAO;EACT;AAAA,EACAC,mBAAmB;AACV,WAAA;AAAA,EACT;AACF,CAAC;AAKM,SAASC,gBAAgB;AAAA,EAC9BC;AAAAA,EACAC;AAIF,GAAG;AACD,MAAI,CAACA,eAAe;AACZ,UAAA,IAAIC,MACP,iEAAgE;AAAA,EAErE;AAEID,MAAAA,cAAcX,yBAAyBC,sCAAe;AACxDY,YAAQC,KACL,iGAAgGb,uBAAyDU,yDAAAA,cAAcX,0HAA0H;AAAA,EAEtS;AAEMe,QAAAA,cAAcC,WAAAA,QAA6B,MAAM;AACrD,aAASR,iBAAiBS,eAAwC;;AACzDA,cAAAA,oDAAenB,gBAAfmB,YAA8BN,cAAcb;AAAAA,IACrD;AAEO,WAAA;AAAA,MACL,GAAGa;AAAAA,MACHJ,sBAAsBU,eAAe;;AAC5BC,eAAAA,iBAAAA,yBACLD,cAAcE,aACdR,cAAcX,uBACdiB,mBAAclB,oBAAdkB,YAAiCN,cAAcZ,eAAe;AAAA,MAElE;AAAA,MACAS;AAAAA,MACAF,oBAAoBW,eAAe;;AACjC,aAAIA,oDAAenB,gBAAfmB,mBAA4BG,SAAS,mBAAmB;AACpC;AACpBP,oBAAQC,KACL,6PAA4P;AAAA,UAEjQ;AAAA,QACF;AACA,eAAQ,GAAEN,iBAAiB;AAAA,UACzBV,cAAamB,oDAAenB,gBAAfmB,YAA8BN,cAAcb;AAAAA,QAAAA,CAC1D,UACCmB,oDAAejB,yBAAfiB,YACAN,cAAcX;AAAAA,MAElB;AAAA,IAAA;AAAA,EACF,GACC,CAACW,aAAa,CAAC;AAGhB,SAAAU,2BAAA,IAAC,eAAe,UAAQ;AAAA,IAAC,OAAON;AAAAA,IAAY;AAAA,EAAA,CAElB;AAE9B;AAKO,SAASO,UAAU;AAClBC,QAAAA,cAAcC,sBAAW5B,cAAc;AAC7C,MAAI,CAAC2B,aAAa;AACV,UAAA,IAAIX,MAAO,wDAAuD;AAAA,EAC1E;AACOW,SAAAA;AACT;;;"}
@@ -34,21 +34,12 @@ function ShopifyProvider({
34
34
  console.warn(`<ShopifyProvider/>: This version of Hydrogen-UI 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-UI and the Storefront API.`);
35
35
  }
36
36
  const finalConfig = useMemo(() => {
37
- const storeDomain = shopifyConfig.storeDomain.replace(/^https?:\/\//, "");
38
- if (storeDomain.includes(".myshopify.com")) {
39
- {
40
- console.warn(`<ShopifyProvider/>: passing a 'storeDomain' prop that includes '.myshopify.com' will be unsupported in the future. Passing only the subdomain (for example, if the URL is 'test.myshopify.com', passing in 'test') will be the supported way going forward.`);
41
- }
42
- }
43
37
  function getShopifyDomain(overrideProps) {
44
38
  var _a;
45
- let subDomain = (_a = overrideProps == null ? void 0 : overrideProps.storeDomain) != null ? _a : storeDomain;
46
- subDomain = subDomain.replace(".myshopify.com", "");
47
- return `https://${subDomain}.myshopify.com`;
39
+ return (_a = overrideProps == null ? void 0 : overrideProps.storeDomain) != null ? _a : shopifyConfig.storeDomain;
48
40
  }
49
41
  return {
50
42
  ...shopifyConfig,
51
- storeDomain,
52
43
  getPublicTokenHeaders(overrideProps) {
53
44
  var _a;
54
45
  return getPublicTokenHeadersRaw(overrideProps.contentType, shopifyConfig.storefrontApiVersion, (_a = overrideProps.storefrontToken) != null ? _a : shopifyConfig.storefrontToken);
@@ -62,7 +53,7 @@ function ShopifyProvider({
62
53
  }
63
54
  }
64
55
  return `${getShopifyDomain({
65
- storeDomain: (_b = overrideProps == null ? void 0 : overrideProps.storeDomain) != null ? _b : storeDomain
56
+ storeDomain: (_b = overrideProps == null ? void 0 : overrideProps.storeDomain) != null ? _b : shopifyConfig.storeDomain
66
57
  })}/api/${(_c = overrideProps == null ? void 0 : overrideProps.storefrontApiVersion) != null ? _c : shopifyConfig.storefrontApiVersion}/graphql.json`;
67
58
  }
68
59
  };