@shopify/hydrogen-react 2024.10.0 → 2024.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-dev/AddToCartButton.mjs.map +1 -1
- package/dist/browser-dev/BuyNowButton.mjs.map +1 -1
- package/dist/browser-dev/CartCost.mjs.map +1 -1
- package/dist/browser-dev/CartProvider.mjs.map +1 -1
- package/dist/browser-dev/ExternalVideo.mjs.map +1 -1
- package/dist/browser-dev/ProductPrice.mjs.map +1 -1
- package/dist/browser-dev/RichText.mjs.map +1 -1
- package/dist/browser-dev/ShopifyProvider.mjs +19 -1
- package/dist/browser-dev/ShopifyProvider.mjs.map +1 -1
- package/dist/browser-dev/analytics.mjs +4 -5
- package/dist/browser-dev/analytics.mjs.map +1 -1
- package/dist/browser-dev/cart-hooks.mjs +25 -7
- package/dist/browser-dev/cart-hooks.mjs.map +1 -1
- package/dist/browser-dev/cookies-utils.mjs +4 -4
- package/dist/browser-dev/cookies-utils.mjs.map +1 -1
- package/dist/browser-dev/getProductOptions.mjs +239 -0
- package/dist/browser-dev/getProductOptions.mjs.map +1 -0
- package/dist/browser-dev/index.mjs +10 -0
- package/dist/browser-dev/index.mjs.map +1 -1
- package/dist/browser-dev/packages/hydrogen-react/package.json.mjs +1 -1
- package/dist/browser-dev/tracking-utils.mjs +92 -0
- package/dist/browser-dev/tracking-utils.mjs.map +1 -0
- package/dist/browser-dev/useSelectedOptionInUrlParam.mjs +30 -0
- package/dist/browser-dev/useSelectedOptionInUrlParam.mjs.map +1 -0
- package/dist/browser-dev/useShopifyCookies.mjs +98 -9
- package/dist/browser-dev/useShopifyCookies.mjs.map +1 -1
- package/dist/browser-prod/AddToCartButton.mjs.map +1 -1
- package/dist/browser-prod/BuyNowButton.mjs.map +1 -1
- package/dist/browser-prod/CartCost.mjs.map +1 -1
- package/dist/browser-prod/CartProvider.mjs.map +1 -1
- package/dist/browser-prod/ExternalVideo.mjs.map +1 -1
- package/dist/browser-prod/ProductPrice.mjs.map +1 -1
- package/dist/browser-prod/RichText.mjs.map +1 -1
- package/dist/browser-prod/ShopifyProvider.mjs +19 -1
- package/dist/browser-prod/ShopifyProvider.mjs.map +1 -1
- package/dist/browser-prod/analytics.mjs +4 -5
- package/dist/browser-prod/analytics.mjs.map +1 -1
- package/dist/browser-prod/cart-hooks.mjs +25 -7
- package/dist/browser-prod/cart-hooks.mjs.map +1 -1
- package/dist/browser-prod/cookies-utils.mjs +4 -4
- package/dist/browser-prod/cookies-utils.mjs.map +1 -1
- package/dist/browser-prod/getProductOptions.mjs +239 -0
- package/dist/browser-prod/getProductOptions.mjs.map +1 -0
- package/dist/browser-prod/index.mjs +10 -0
- package/dist/browser-prod/index.mjs.map +1 -1
- package/dist/browser-prod/packages/hydrogen-react/package.json.mjs +1 -1
- package/dist/browser-prod/tracking-utils.mjs +92 -0
- package/dist/browser-prod/tracking-utils.mjs.map +1 -0
- package/dist/browser-prod/useSelectedOptionInUrlParam.mjs +30 -0
- package/dist/browser-prod/useSelectedOptionInUrlParam.mjs.map +1 -0
- package/dist/browser-prod/useShopifyCookies.mjs +98 -9
- package/dist/browser-prod/useShopifyCookies.mjs.map +1 -1
- package/dist/node-dev/AddToCartButton.js.map +1 -1
- package/dist/node-dev/AddToCartButton.mjs.map +1 -1
- package/dist/node-dev/BuyNowButton.js.map +1 -1
- package/dist/node-dev/BuyNowButton.mjs.map +1 -1
- package/dist/node-dev/CartCost.js.map +1 -1
- package/dist/node-dev/CartCost.mjs.map +1 -1
- package/dist/node-dev/CartProvider.js.map +1 -1
- package/dist/node-dev/CartProvider.mjs.map +1 -1
- package/dist/node-dev/ExternalVideo.js.map +1 -1
- package/dist/node-dev/ExternalVideo.mjs.map +1 -1
- package/dist/node-dev/ProductPrice.js.map +1 -1
- package/dist/node-dev/ProductPrice.mjs.map +1 -1
- package/dist/node-dev/RichText.js.map +1 -1
- package/dist/node-dev/RichText.mjs.map +1 -1
- package/dist/node-dev/ShopifyProvider.js +19 -1
- package/dist/node-dev/ShopifyProvider.js.map +1 -1
- package/dist/node-dev/ShopifyProvider.mjs +19 -1
- package/dist/node-dev/ShopifyProvider.mjs.map +1 -1
- package/dist/node-dev/analytics.js +4 -5
- package/dist/node-dev/analytics.js.map +1 -1
- package/dist/node-dev/analytics.mjs +4 -5
- package/dist/node-dev/analytics.mjs.map +1 -1
- package/dist/node-dev/cart-hooks.js +24 -6
- package/dist/node-dev/cart-hooks.js.map +1 -1
- package/dist/node-dev/cart-hooks.mjs +25 -7
- package/dist/node-dev/cart-hooks.mjs.map +1 -1
- package/dist/node-dev/cookies-utils.js +4 -4
- package/dist/node-dev/cookies-utils.js.map +1 -1
- package/dist/node-dev/cookies-utils.mjs +4 -4
- package/dist/node-dev/cookies-utils.mjs.map +1 -1
- package/dist/node-dev/getProductOptions.js +239 -0
- package/dist/node-dev/getProductOptions.js.map +1 -0
- package/dist/node-dev/getProductOptions.mjs +239 -0
- package/dist/node-dev/getProductOptions.mjs.map +1 -0
- package/dist/node-dev/index.js +10 -0
- package/dist/node-dev/index.js.map +1 -1
- package/dist/node-dev/index.mjs +10 -0
- package/dist/node-dev/index.mjs.map +1 -1
- package/dist/node-dev/packages/hydrogen-react/package.json.js +1 -1
- package/dist/node-dev/packages/hydrogen-react/package.json.mjs +1 -1
- package/dist/node-dev/tracking-utils.js +92 -0
- package/dist/node-dev/tracking-utils.js.map +1 -0
- package/dist/node-dev/tracking-utils.mjs +92 -0
- package/dist/node-dev/tracking-utils.mjs.map +1 -0
- package/dist/node-dev/useSelectedOptionInUrlParam.js +30 -0
- package/dist/node-dev/useSelectedOptionInUrlParam.js.map +1 -0
- package/dist/node-dev/useSelectedOptionInUrlParam.mjs +30 -0
- package/dist/node-dev/useSelectedOptionInUrlParam.mjs.map +1 -0
- package/dist/node-dev/useShopifyCookies.js +96 -7
- package/dist/node-dev/useShopifyCookies.js.map +1 -1
- package/dist/node-dev/useShopifyCookies.mjs +98 -9
- package/dist/node-dev/useShopifyCookies.mjs.map +1 -1
- package/dist/node-prod/AddToCartButton.js.map +1 -1
- package/dist/node-prod/AddToCartButton.mjs.map +1 -1
- package/dist/node-prod/BuyNowButton.js.map +1 -1
- package/dist/node-prod/BuyNowButton.mjs.map +1 -1
- package/dist/node-prod/CartCost.js.map +1 -1
- package/dist/node-prod/CartCost.mjs.map +1 -1
- package/dist/node-prod/CartProvider.js.map +1 -1
- package/dist/node-prod/CartProvider.mjs.map +1 -1
- package/dist/node-prod/ExternalVideo.js.map +1 -1
- package/dist/node-prod/ExternalVideo.mjs.map +1 -1
- package/dist/node-prod/ProductPrice.js.map +1 -1
- package/dist/node-prod/ProductPrice.mjs.map +1 -1
- package/dist/node-prod/RichText.js.map +1 -1
- package/dist/node-prod/RichText.mjs.map +1 -1
- package/dist/node-prod/ShopifyProvider.js +19 -1
- package/dist/node-prod/ShopifyProvider.js.map +1 -1
- package/dist/node-prod/ShopifyProvider.mjs +19 -1
- package/dist/node-prod/ShopifyProvider.mjs.map +1 -1
- package/dist/node-prod/analytics.js +4 -5
- package/dist/node-prod/analytics.js.map +1 -1
- package/dist/node-prod/analytics.mjs +4 -5
- package/dist/node-prod/analytics.mjs.map +1 -1
- package/dist/node-prod/cart-hooks.js +24 -6
- package/dist/node-prod/cart-hooks.js.map +1 -1
- package/dist/node-prod/cart-hooks.mjs +25 -7
- package/dist/node-prod/cart-hooks.mjs.map +1 -1
- package/dist/node-prod/cookies-utils.js +4 -4
- package/dist/node-prod/cookies-utils.js.map +1 -1
- package/dist/node-prod/cookies-utils.mjs +4 -4
- package/dist/node-prod/cookies-utils.mjs.map +1 -1
- package/dist/node-prod/getProductOptions.js +239 -0
- package/dist/node-prod/getProductOptions.js.map +1 -0
- package/dist/node-prod/getProductOptions.mjs +239 -0
- package/dist/node-prod/getProductOptions.mjs.map +1 -0
- package/dist/node-prod/index.js +10 -0
- package/dist/node-prod/index.js.map +1 -1
- package/dist/node-prod/index.mjs +10 -0
- package/dist/node-prod/index.mjs.map +1 -1
- package/dist/node-prod/packages/hydrogen-react/package.json.js +1 -1
- package/dist/node-prod/packages/hydrogen-react/package.json.mjs +1 -1
- package/dist/node-prod/tracking-utils.js +92 -0
- package/dist/node-prod/tracking-utils.js.map +1 -0
- package/dist/node-prod/tracking-utils.mjs +92 -0
- package/dist/node-prod/tracking-utils.mjs.map +1 -0
- package/dist/node-prod/useSelectedOptionInUrlParam.js +30 -0
- package/dist/node-prod/useSelectedOptionInUrlParam.js.map +1 -0
- package/dist/node-prod/useSelectedOptionInUrlParam.mjs +30 -0
- package/dist/node-prod/useSelectedOptionInUrlParam.mjs.map +1 -0
- package/dist/node-prod/useShopifyCookies.js +96 -7
- package/dist/node-prod/useShopifyCookies.js.map +1 -1
- package/dist/node-prod/useShopifyCookies.mjs +98 -9
- package/dist/node-prod/useShopifyCookies.mjs.map +1 -1
- package/dist/types/CartProvider.d.ts +4 -3
- package/dist/types/ShopifyProvider.d.ts +5 -0
- package/dist/types/cookies-utils.d.ts +4 -0
- package/dist/types/getProductOptions.d.ts +49 -0
- package/dist/types/index.d.cts +3 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/storefront-api-response.types.d.ts +5 -5
- package/dist/types/tracking-utils.d.ts +22 -0
- package/dist/types/useSelectedOptionInUrlParam.d.ts +2 -0
- package/dist/types/useShopifyCookies.d.ts +28 -2
- package/dist/umd/hydrogen-react.dev.js +623 -175
- package/dist/umd/hydrogen-react.dev.js.map +1 -1
- package/dist/umd/hydrogen-react.prod.js +18 -18
- package/dist/umd/hydrogen-react.prod.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useShopifyCookies.mjs","sources":["../../src/useShopifyCookies.tsx"],"sourcesContent":["import {useEffect} from 'react';\nimport {stringify} from 'worktop/cookie';\nimport {SHOPIFY_Y, SHOPIFY_S} from './cart-constants.js';\nimport {buildUUID, getShopifyCookies} from './cookies-utils.js';\n\nconst longTermLength = 60 * 60 * 24 * 360 * 1; // ~1 year expiry\nconst shortTermLength = 60 * 30; // 30 mins\n\ntype UseShopifyCookiesOptions = {\n /**\n * If set to `false`, Shopify cookies will be removed.\n * If set to `true`, Shopify unique user token cookie will have cookie expiry of 1 year.\n * Defaults to false.\n **/\n hasUserConsent?: boolean;\n /**\n * The domain scope of the cookie. Defaults to empty string.\n **/\n domain?: string;\n /**\n * The checkout domain of the shop. Defaults to empty string. If set, the cookie domain will check if it can be set with the checkout domain.\n */\n checkoutDomain?: string;\n};\n\nexport function useShopifyCookies(options?: UseShopifyCookiesOptions): void {\n const {\n hasUserConsent = false,\n domain = '',\n checkoutDomain = '',\n } = options || {};\n useEffect(() => {\n const cookies = getShopifyCookies(document.cookie);\n\n /**\n * Setting cookie with domain\n *\n * If no domain is provided, the cookie will be set for the current host.\n * For Shopify, we need to ensure this domain is set with a leading dot.\n */\n\n // Use override domain or current host\n let currentDomain = domain || window.document.location.host;\n\n if (checkoutDomain) {\n const checkoutDomainParts = checkoutDomain.split('.').reverse();\n const currentDomainParts = currentDomain.split('.').reverse();\n const sameDomainParts: Array<string> = [];\n checkoutDomainParts.forEach((part, index) => {\n if (part === currentDomainParts[index]) {\n sameDomainParts.push(part);\n }\n });\n\n currentDomain = sameDomainParts.reverse().join('.');\n }\n\n // Reset domain if localhost\n if (/^localhost/.test(currentDomain)) currentDomain = '';\n\n // Shopify checkout only consumes cookies set with leading dot domain\n const domainWithLeadingDot = currentDomain\n ? /^\\./.test(currentDomain)\n ? currentDomain\n : `.${currentDomain}`\n : '';\n\n /**\n * Set user and session cookies and refresh the expiry time\n */\n if (hasUserConsent) {\n setCookie(\n SHOPIFY_Y,\n cookies[SHOPIFY_Y] || buildUUID(),\n longTermLength,\n domainWithLeadingDot,\n );\n setCookie(\n SHOPIFY_S,\n cookies[SHOPIFY_S] || buildUUID(),\n shortTermLength,\n domainWithLeadingDot,\n );\n } else {\n setCookie(SHOPIFY_Y, '', 0, domainWithLeadingDot);\n setCookie(SHOPIFY_S, '', 0, domainWithLeadingDot);\n }\n }, [options, hasUserConsent, domain, checkoutDomain]);\n}\n\nfunction setCookie(\n name: string,\n value: string,\n maxage: number,\n domain: string,\n): void {\n document.cookie = stringify(name, value, {\n maxage,\n domain,\n samesite: 'Lax',\n path: '/',\n });\n}\n"],"names":[],"mappings":";;;;AAKA,MAAM,iBAAiB,KAAK,KAAK,KAAK,MAAM;AAC5C,MAAM,kBAAkB,KAAK;AAmBtB,SAAS,kBAAkB,SAA0C;AACpE,QAAA;AAAA,IACJ,iBAAiB;AAAA,IACjB,SAAS;AAAA,IACT,iBAAiB;AAAA,EAAA,IACf,WAAW,CAAA;AACf,YAAU,MAAM;AACR,UAAA,UAAU,kBAAkB,SAAS,MAAM;AAUjD,QAAI,gBAAgB,UAAU,OAAO,SAAS,SAAS;AAEvD,QAAI,gBAAgB;AAClB,YAAM,sBAAsB,eAAe,MAAM,GAAG,EAAE,QAAQ;AAC9D,YAAM,qBAAqB,cAAc,MAAM,GAAG,EAAE,QAAQ;AAC5D,YAAM,kBAAiC,CAAA;AACnB,0BAAA,QAAQ,CAAC,MAAM,UAAU;AACvC,YAAA,SAAS,mBAAmB,KAAK,GAAG;AACtC,0BAAgB,KAAK,IAAI;AAAA,QAC3B;AAAA,MAAA,CACD;AAED,sBAAgB,gBAAgB,QAAU,EAAA,KAAK,GAAG;AAAA,IACpD;AAGI,QAAA,aAAa,KAAK,aAAa;AAAmB,sBAAA;AAGhD,UAAA,uBAAuB,gBACzB,MAAM,KAAK,aAAa,IACtB,gBACA,IAAI,aAAa,KACnB;AAKJ,QAAI,gBAAgB;AAClB;AAAA,QACE;AAAA,QACA,QAAQ,SAAS,KAAK,UAAU;AAAA,QAChC;AAAA,QACA;AAAA,MAAA;AAEF;AAAA,QACE;AAAA,QACA,QAAQ,SAAS,KAAK,UAAU;AAAA,QAChC;AAAA,QACA;AAAA,MAAA;AAAA,IACF,OACK;AACK,gBAAA,WAAW,IAAI,GAAG,oBAAoB;AACtC,gBAAA,WAAW,IAAI,GAAG,oBAAoB;AAAA,IAClD;AAAA,KACC,CAAC,SAAS,gBAAgB,QAAQ,cAAc,CAAC;AACtD;AAEA,SAAS,UACP,MACA,OACA,QACA,QACM;AACG,WAAA,SAAS,UAAU,MAAM,OAAO;AAAA,IACvC;AAAA,IACA;AAAA,IACA,UAAU;AAAA,IACV,MAAM;AAAA,EAAA,CACP;AACH;"}
|
|
1
|
+
{"version":3,"file":"useShopifyCookies.mjs","sources":["../../src/useShopifyCookies.tsx"],"sourcesContent":["import {useEffect, useRef, useState} from 'react';\nimport {stringify} from 'worktop/cookie';\nimport {SHOPIFY_Y, SHOPIFY_S} from './cart-constants.js';\nimport {buildUUID} from './cookies-utils.js';\nimport {\n getTrackingValues,\n SHOPIFY_UNIQUE_TOKEN_HEADER,\n SHOPIFY_VISIT_TOKEN_HEADER,\n} from './tracking-utils.js';\n\nconst longTermLength = 60 * 60 * 24 * 360 * 1; // ~1 year expiry\nconst shortTermLength = 60 * 30; // 30 mins\n\ntype UseShopifyCookiesOptions = CoreShopifyCookiesOptions & {\n /**\n * If set to `false`, Shopify cookies will be removed.\n * If set to `true`, Shopify unique user token cookie will have cookie expiry of 1 year.\n * Defaults to false.\n **/\n hasUserConsent?: boolean;\n /**\n * The domain scope of the cookie. Defaults to empty string.\n **/\n domain?: string;\n /**\n * The checkout domain of the shop. Defaults to empty string. If set, the cookie domain will check if it can be set with the checkout domain.\n */\n checkoutDomain?: string;\n /**\n * If set to `true`, it skips modifying the deprecated shopify_y and shopify_s cookies.\n */\n ignoreDeprecatedCookies?: boolean;\n};\n\n/**\n * Sets the `shopify_y` and `shopify_s` cookies in the browser based on user consent\n * for backward compatibility support.\n *\n * If `fetchTrackingValues` is true, it makes a request to Storefront API\n * to fetch or refresh Shopiy analytics and marketing cookies and tracking values.\n * Generally speaking, this should only be needed if you're not using Hydrogen's\n * built-in analytics components and hooks that already handle this automatically.\n * For example, set it to `true` if you are using `hydrogen-react` only with\n * a different framework and still need to make a same-domain request to\n * Storefront API to set cookies.\n *\n * If `ignoreDeprecatedCookies` is true, it skips setting the deprecated cookies entirely.\n * Useful when you only want to use the newer tracking values and not rely on the deprecated ones.\n *\n * @returns `true` when cookies are set and ready.\n */\nexport function useShopifyCookies(options?: UseShopifyCookiesOptions): boolean {\n const {\n hasUserConsent,\n domain = '',\n checkoutDomain = '',\n storefrontAccessToken,\n fetchTrackingValues,\n ignoreDeprecatedCookies = false,\n } = options || {};\n\n const coreCookiesReady = useCoreShopifyCookies({\n storefrontAccessToken,\n fetchTrackingValues,\n checkoutDomain,\n });\n\n useEffect(() => {\n // Skip setting JS cookies until http-only cookies and server-timing\n // are ready so that we have values synced in JS and http-only cookies.\n if (ignoreDeprecatedCookies || !coreCookiesReady) return;\n\n /**\n * Setting cookie with domain\n *\n * If no domain is provided, the cookie will be set for the current host.\n * For Shopify, we need to ensure this domain is set with a leading dot.\n */\n\n // Use override domain or current host\n let currentDomain = domain || window.location.host;\n\n if (checkoutDomain) {\n const checkoutDomainParts = checkoutDomain.split('.').reverse();\n const currentDomainParts = currentDomain.split('.').reverse();\n const sameDomainParts: Array<string> = [];\n checkoutDomainParts.forEach((part, index) => {\n if (part === currentDomainParts[index]) {\n sameDomainParts.push(part);\n }\n });\n\n currentDomain = sameDomainParts.reverse().join('.');\n }\n\n // Reset domain if localhost\n if (/^localhost/.test(currentDomain)) currentDomain = '';\n\n // Shopify checkout only consumes cookies set with leading dot domain\n const domainWithLeadingDot = currentDomain\n ? /^\\./.test(currentDomain)\n ? currentDomain\n : `.${currentDomain}`\n : '';\n\n /**\n * Set user and session cookies and refresh the expiry time\n */\n if (hasUserConsent) {\n const trackingValues = getTrackingValues();\n if (\n (\n trackingValues.uniqueToken ||\n trackingValues.visitToken ||\n ''\n ).startsWith('00000000-')\n ) {\n // Skip writing cookies when tracking values signal we don't have consent yet\n return;\n }\n\n setCookie(\n SHOPIFY_Y,\n trackingValues.uniqueToken || buildUUID(),\n longTermLength,\n domainWithLeadingDot,\n );\n setCookie(\n SHOPIFY_S,\n trackingValues.visitToken || buildUUID(),\n shortTermLength,\n domainWithLeadingDot,\n );\n } else {\n setCookie(SHOPIFY_Y, '', 0, domainWithLeadingDot);\n setCookie(SHOPIFY_S, '', 0, domainWithLeadingDot);\n }\n }, [\n coreCookiesReady,\n hasUserConsent,\n domain,\n checkoutDomain,\n ignoreDeprecatedCookies,\n ]);\n\n return coreCookiesReady;\n}\n\nfunction setCookie(\n name: string,\n value: string,\n maxage: number,\n domain: string,\n): void {\n document.cookie = stringify(name, value, {\n maxage,\n domain,\n samesite: 'Lax',\n path: '/',\n });\n}\n\nasync function fetchTrackingValuesFromBrowser(\n storefrontAccessToken?: string,\n storefrontApiDomain = '',\n): Promise<void> {\n // These values might come from server-timing or old cookies.\n // If consent cannot be initially assumed, these tokens\n // will be dropped in SFAPI and it will return a mock token\n // starting with '00000000-'.\n // However, if consent can be assumed initially, these tokens\n // will be used to create proper cookies and continue our flow.\n const {uniqueToken, visitToken} = getTrackingValues();\n\n const response = await fetch(\n // TODO: update this endpoint when it becomes stable\n `${storefrontApiDomain.replace(/\\/+$/, '')}/api/unstable/graphql.json`,\n {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n ...(storefrontAccessToken && {\n 'X-Shopify-Storefront-Access-Token': storefrontAccessToken,\n }),\n ...(visitToken || uniqueToken\n ? {\n [SHOPIFY_VISIT_TOKEN_HEADER]: visitToken,\n [SHOPIFY_UNIQUE_TOKEN_HEADER]: uniqueToken,\n }\n : undefined),\n },\n body: JSON.stringify({\n query:\n // This query ensures we get _cmp (consent) server-timing header, which is not available in other queries.\n // This value can be passed later to consent-tracking-api and privacy-banner scripts to avoid extra requests.\n 'query ensureCookies { consentManagement { cookies(visitorConsent:{}) { cookieDomain } } }',\n }),\n },\n );\n\n if (!response.ok) {\n throw new Error(\n `Failed to fetch consent from browser: ${response.status} ${response.statusText}`,\n );\n }\n\n // Consume the body to complete the request and\n // ensure server-timing is available in performance API\n await response.json();\n\n // Ensure we cache the latest tracking values from resources timing\n getTrackingValues();\n}\n\ntype CoreShopifyCookiesOptions = {\n storefrontAccessToken?: string;\n fetchTrackingValues?: boolean;\n checkoutDomain?: string;\n};\n\n/**\n * Gets http-only cookies from Storefront API via same-origin fetch request.\n * Falls back to checkout domain if provided to at least obtain the tracking\n * values via server-timing headers.\n */\nfunction useCoreShopifyCookies({\n checkoutDomain,\n storefrontAccessToken,\n fetchTrackingValues = false,\n}: CoreShopifyCookiesOptions): boolean {\n const [cookiesReady, setCookiesReady] = useState(!fetchTrackingValues);\n const hasFetchedTrackingValues = useRef(false);\n\n useEffect(() => {\n if (!fetchTrackingValues) {\n // Backend did the work, or proxy is disabled.\n setCookiesReady(true);\n return;\n }\n\n // React runs effects twice in dev mode, avoid double fetching\n if (hasFetchedTrackingValues.current) return;\n hasFetchedTrackingValues.current = true;\n\n // Fetch consent from browser via proxy\n fetchTrackingValuesFromBrowser(storefrontAccessToken)\n .catch((error) =>\n checkoutDomain\n ? // Retry with checkout domain if available to at least\n // get the server-timing values for tracking.\n fetchTrackingValuesFromBrowser(\n storefrontAccessToken,\n checkoutDomain,\n )\n : Promise.reject(error),\n )\n .catch((error) => {\n console.warn(\n '[h2:warn:useShopifyCookies] Failed to fetch tracking values from browser: ' +\n (error instanceof Error ? error.message : String(error)),\n );\n })\n .finally(() => {\n // Proceed even on errors, degraded tracking is better than no app\n setCookiesReady(true);\n });\n }, [checkoutDomain, fetchTrackingValues, storefrontAccessToken]);\n\n return cookiesReady;\n}\n"],"names":[],"mappings":"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"}
|
|
@@ -53,7 +53,7 @@ type CartProviderProps = {
|
|
|
53
53
|
customerAccessToken?: CartBuyerIdentityInput['customerAccessToken'];
|
|
54
54
|
/** The ISO country code for i18n. */
|
|
55
55
|
countryCode?: CountryCode;
|
|
56
|
-
/** The ISO
|
|
56
|
+
/** The ISO language code for i18n. */
|
|
57
57
|
languageCode?: LanguageCode;
|
|
58
58
|
};
|
|
59
59
|
/**
|
|
@@ -67,8 +67,9 @@ type CartProviderProps = {
|
|
|
67
67
|
* The `CartProvider` component must be a descendant of the `ShopifyProvider` component.
|
|
68
68
|
*/
|
|
69
69
|
export declare function CartProvider({ children, numCartLines, onCreate, onLineAdd, onLineRemove, onLineUpdate, onNoteUpdate, onBuyerIdentityUpdate, onAttributesUpdate, onDiscountCodesUpdate, onCreateComplete, onLineAddComplete, onLineRemoveComplete, onLineUpdateComplete, onNoteUpdateComplete, onBuyerIdentityUpdateComplete, onAttributesUpdateComplete, onDiscountCodesUpdateComplete, data: cart, cartFragment, customerAccessToken, countryCode, languageCode, }: CartProviderProps): JSX.Element;
|
|
70
|
-
/**
|
|
71
|
-
*
|
|
70
|
+
/**
|
|
71
|
+
* Check for storage availability function obtained from
|
|
72
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API/Using_the_Web_Storage_API
|
|
72
73
|
*/
|
|
73
74
|
export declare function storageAvailable(type: 'localStorage' | 'sessionStorage'): boolean;
|
|
74
75
|
export {};
|
|
@@ -26,6 +26,11 @@ export interface ShopifyProviderBase {
|
|
|
26
26
|
* `ISO 369` language codes supported by Shopify.
|
|
27
27
|
*/
|
|
28
28
|
languageIsoCode: LanguageCode;
|
|
29
|
+
/**
|
|
30
|
+
* Uses the current window.location.origin for Storefront API requests.
|
|
31
|
+
* This requires setting up a proxy for Storefront API requests in your domain.
|
|
32
|
+
*/
|
|
33
|
+
sameDomainForStorefrontApi?: boolean;
|
|
29
34
|
}
|
|
30
35
|
/**
|
|
31
36
|
* Shopify-specific values that are used in various Hydrogen React components and hooks.
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { ShopifyCookies } from './analytics-types.js';
|
|
2
2
|
export declare function buildUUID(): string;
|
|
3
3
|
export declare function hexTime(): string;
|
|
4
|
+
/**
|
|
5
|
+
* Gets the values of _shopify_y and _shopify_s cookies from the provided cookie string.
|
|
6
|
+
* @deprecated Use getTrackingValues instead.
|
|
7
|
+
*/
|
|
4
8
|
export declare function getShopifyCookies(cookies: string): ShopifyCookies;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Product, ProductOption, ProductOptionValue, ProductVariant, SelectedOption } from './storefront-api-types';
|
|
2
|
+
export type RecursivePartial<T> = {
|
|
3
|
+
[P in keyof T]?: RecursivePartial<T[P]>;
|
|
4
|
+
};
|
|
5
|
+
type ProductOptionValueState = {
|
|
6
|
+
variant: ProductVariant;
|
|
7
|
+
handle: string;
|
|
8
|
+
variantUriQuery: string;
|
|
9
|
+
selected: boolean;
|
|
10
|
+
exists: boolean;
|
|
11
|
+
available: boolean;
|
|
12
|
+
isDifferentProduct: boolean;
|
|
13
|
+
};
|
|
14
|
+
type MappedProductOptionValue = ProductOptionValue & ProductOptionValueState;
|
|
15
|
+
/**
|
|
16
|
+
* Converts the product option into an Object\<key, value\> for building query params
|
|
17
|
+
* For example, a selected product option of
|
|
18
|
+
* [
|
|
19
|
+
* \{
|
|
20
|
+
* name: 'Color',
|
|
21
|
+
* value: 'Red',
|
|
22
|
+
* \},
|
|
23
|
+
* \{
|
|
24
|
+
* name: 'Size',
|
|
25
|
+
* value: 'Medium',
|
|
26
|
+
* \}
|
|
27
|
+
* ]
|
|
28
|
+
* Would return
|
|
29
|
+
* \{
|
|
30
|
+
* Color: 'Red',
|
|
31
|
+
* Size: 'Medium',
|
|
32
|
+
* \}
|
|
33
|
+
*/
|
|
34
|
+
export declare function mapSelectedProductOptionToObject(options: Pick<SelectedOption, 'name' | 'value'>[]): Record<string, string>;
|
|
35
|
+
export type MappedProductOptions = Omit<ProductOption, 'optionValues'> & {
|
|
36
|
+
optionValues: MappedProductOptionValue[];
|
|
37
|
+
};
|
|
38
|
+
export declare function checkProductParam(product: RecursivePartial<Product>, checkAll?: boolean): Product;
|
|
39
|
+
/**
|
|
40
|
+
* Finds all the variants provided by adjacentVariants, options.optionValues.firstAvailableVariant,
|
|
41
|
+
* and selectedOrFirstAvailableVariant and return them in a single array
|
|
42
|
+
*/
|
|
43
|
+
export declare function getAdjacentAndFirstAvailableVariants(product: RecursivePartial<Product>): ProductVariant[];
|
|
44
|
+
/**
|
|
45
|
+
* Returns a product options array with its relevant information
|
|
46
|
+
* about the variant
|
|
47
|
+
*/
|
|
48
|
+
export declare function getProductOptions(product: RecursivePartial<Product>): MappedProductOptions[];
|
|
49
|
+
export {};
|
package/dist/types/index.d.cts
CHANGED
|
@@ -16,6 +16,7 @@ export { customerAccountApiCustomScalars, storefrontApiCustomScalars, } from './
|
|
|
16
16
|
export { getShopifyCookies } from './cookies-utils.js';
|
|
17
17
|
export { ExternalVideo } from './ExternalVideo.js';
|
|
18
18
|
export { flattenConnection } from './flatten-connection.js';
|
|
19
|
+
export { getAdjacentAndFirstAvailableVariants, getProductOptions, type MappedProductOptions, mapSelectedProductOptionToObject, } from './getProductOptions.js';
|
|
19
20
|
export { Image, IMAGE_FRAGMENT } from './Image.js';
|
|
20
21
|
export { useLoadScript } from './load-script.js';
|
|
21
22
|
export { MediaFile } from './MediaFile.js';
|
|
@@ -31,6 +32,8 @@ export { ShopPayButton } from './ShopPayButton.js';
|
|
|
31
32
|
export type { StorefrontApiResponse, StorefrontApiResponseError, StorefrontApiResponseOk, StorefrontApiResponseOkPartial, StorefrontApiResponsePartial, } from './storefront-api-response.types.js';
|
|
32
33
|
export type { StorefrontClientProps } from './storefront-client.js';
|
|
33
34
|
export { createStorefrontClient } from './storefront-client.js';
|
|
35
|
+
export { getTrackingValues, SHOPIFY_UNIQUE_TOKEN_HEADER, SHOPIFY_VISIT_TOKEN_HEADER, type TrackingValues, } from './tracking-utils.js';
|
|
34
36
|
export { useMoney } from './useMoney.js';
|
|
37
|
+
export { useSelectedOptionInUrlParam } from './useSelectedOptionInUrlParam.js';
|
|
35
38
|
export { useShopifyCookies } from './useShopifyCookies.js';
|
|
36
39
|
export { Video } from './Video.js';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export { customerAccountApiCustomScalars, storefrontApiCustomScalars, } from './
|
|
|
16
16
|
export { getShopifyCookies } from './cookies-utils.js';
|
|
17
17
|
export { ExternalVideo } from './ExternalVideo.js';
|
|
18
18
|
export { flattenConnection } from './flatten-connection.js';
|
|
19
|
+
export { getAdjacentAndFirstAvailableVariants, getProductOptions, type MappedProductOptions, mapSelectedProductOptionToObject, } from './getProductOptions.js';
|
|
19
20
|
export { Image, IMAGE_FRAGMENT } from './Image.js';
|
|
20
21
|
export { useLoadScript } from './load-script.js';
|
|
21
22
|
export { MediaFile } from './MediaFile.js';
|
|
@@ -31,6 +32,8 @@ export { ShopPayButton } from './ShopPayButton.js';
|
|
|
31
32
|
export type { StorefrontApiResponse, StorefrontApiResponseError, StorefrontApiResponseOk, StorefrontApiResponseOkPartial, StorefrontApiResponsePartial, } from './storefront-api-response.types.js';
|
|
32
33
|
export type { StorefrontClientProps } from './storefront-client.js';
|
|
33
34
|
export { createStorefrontClient } from './storefront-client.js';
|
|
35
|
+
export { getTrackingValues, SHOPIFY_UNIQUE_TOKEN_HEADER, SHOPIFY_VISIT_TOKEN_HEADER, type TrackingValues, } from './tracking-utils.js';
|
|
34
36
|
export { useMoney } from './useMoney.js';
|
|
37
|
+
export { useSelectedOptionInUrlParam } from './useSelectedOptionInUrlParam.js';
|
|
35
38
|
export { useShopifyCookies } from './useShopifyCookies.js';
|
|
36
39
|
export { Video } from './Video.js';
|
|
@@ -7,14 +7,14 @@ import type { PartialDeep } from 'type-fest';
|
|
|
7
7
|
type StorefrontApiExtensions = {
|
|
8
8
|
/**
|
|
9
9
|
* Shows error codes common to Shopify. Additional error codes may also be shown.
|
|
10
|
-
* https://shopify.dev/api/storefront#status_and_error_codes
|
|
10
|
+
* @see https://shopify.dev/api/storefront#status_and_error_codes
|
|
11
11
|
*/
|
|
12
12
|
code?: 'THROTTLED' | 'ACCESS_DENIED' | 'SHOP_INACTIVE' | 'INTERNAL_SERVER_ERROR' | (string & {});
|
|
13
13
|
};
|
|
14
14
|
/**
|
|
15
15
|
* The Storefront API can return a 200 OK response code when the query succeeds, and will populate the `data` property. The generic you pass in through type parameters will be the shape of the `data` object if successful. If you prefer a "deeply-partial" version of that generic object, consider using `StorefrontApiResponseOkPartial` instead.
|
|
16
16
|
*
|
|
17
|
-
* The Storefront API can also return a 200 OK response code in cases that would typically produce 4xx errors in REST. This will
|
|
17
|
+
* The Storefront API can also return a 200 OK response code in cases that would typically produce 4xx errors in REST. This will populate the `errors` property.
|
|
18
18
|
*
|
|
19
19
|
* Refer to https://shopify.dev/api/storefront#status_and_error_codes for more information.
|
|
20
20
|
*/
|
|
@@ -22,7 +22,7 @@ export type StorefrontApiResponseOk<DataGeneric> = FormattedExecutionResult<Data
|
|
|
22
22
|
/**
|
|
23
23
|
* The Storefront API can return a 200 OK response code when the query succeeds, and will populate the `data` property. The generic you pass in through type parameters will be the shape of the `data` object, with `Partial` deeply-applied to all nested objects and properties, if successful. If you prefer not using this "deeply-partial" generic data object, consider using `StorefrontApiResponseOk` instead.
|
|
24
24
|
*
|
|
25
|
-
* The Storefront API can also return a 200 OK response code in cases that would typically produce 4xx errors in REST. This will
|
|
25
|
+
* The Storefront API can also return a 200 OK response code in cases that would typically produce 4xx errors in REST. This will populate the `errors` property.
|
|
26
26
|
*
|
|
27
27
|
* Refer to https://shopify.dev/api/storefront#status_and_error_codes for more information.
|
|
28
28
|
*/
|
|
@@ -48,7 +48,7 @@ export type StorefrontApiResponseError = string | {
|
|
|
48
48
|
/**
|
|
49
49
|
* The Storefront API can return a 200 OK response code when the query succeeds, and will populate the `data` property. The generic you pass in through type parameters will be the shape of the `data` object if successful. If you prefer a "deeply-partial" version of that generic object, consider using `StorefrontApiResponseOkPartial` instead.
|
|
50
50
|
*
|
|
51
|
-
* The Storefront API can also return a 200 OK response code in cases that would typically produce 4xx errors in REST. This will
|
|
51
|
+
* The Storefront API can also return a 200 OK response code in cases that would typically produce 4xx errors in REST. This will populate the `errors` property.
|
|
52
52
|
*
|
|
53
53
|
* 4xx and 5xx errors occur infrequently. They are often related to network communications, your account, or an issue with Shopify’s services. Commonly the response is a `JSON.parse`-able string, but in rare occasions may also return HTML which is not `JSON.parse()`-able.
|
|
54
54
|
*
|
|
@@ -58,7 +58,7 @@ export type StorefrontApiResponse<DataGeneric> = StorefrontApiResponseOk<DataGen
|
|
|
58
58
|
/**
|
|
59
59
|
* The Storefront API can return a 200 OK response code when the query succeeds, and will populate the `data` property. The generic you pass in through type parameters will be the shape of the `data` object, with `Partial` deeply-applied to all nested objects and properties, if successful. If you prefer not using this "deeply-partial" generic data object, consider using `StorefrontApiResponseOk` instead.
|
|
60
60
|
*
|
|
61
|
-
* The Storefront API can also return a 200 OK response code in cases that would typically produce 4xx errors in REST. This will
|
|
61
|
+
* The Storefront API can also return a 200 OK response code in cases that would typically produce 4xx errors in REST. This will populate the `errors` property.
|
|
62
62
|
*
|
|
63
63
|
* 4xx and 5xx errors occur infrequently. They are often related to network communications, your account, or an issue with Shopify’s services. Commonly the response is a `JSON.parse`-able string, but in rare occasions may also return HTML which is not `JSON.parse()`-able.
|
|
64
64
|
*
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Storefront API header for VisitToken */
|
|
2
|
+
export declare const SHOPIFY_VISIT_TOKEN_HEADER = "X-Shopify-VisitToken";
|
|
3
|
+
/** Storefront API header for UniqueToken */
|
|
4
|
+
export declare const SHOPIFY_UNIQUE_TOKEN_HEADER = "X-Shopify-UniqueToken";
|
|
5
|
+
export type TrackingValues = {
|
|
6
|
+
/** Identifier for the unique user. Equivalent to the deprecated _shopify_y cookie */
|
|
7
|
+
uniqueToken: string;
|
|
8
|
+
/** Identifier for the current visit. Equivalent to the deprecated _shopify_s cookie */
|
|
9
|
+
visitToken: string;
|
|
10
|
+
/** Represents the consent given by the user or the default region consent configured in Admin */
|
|
11
|
+
consent: string;
|
|
12
|
+
};
|
|
13
|
+
export declare const cachedTrackingValues: {
|
|
14
|
+
current: null | TrackingValues;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Retrieves user session tracking values for analytics
|
|
18
|
+
* and marketing from the browser environment.
|
|
19
|
+
* @param cookieString - Optional cookie string to parse for deprecated cookie fallback.
|
|
20
|
+
* Used internally by getShopifyCookies for backward compatibility.
|
|
21
|
+
*/
|
|
22
|
+
export declare function getTrackingValues(cookieString?: string): TrackingValues;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
type UseShopifyCookiesOptions = {
|
|
1
|
+
type UseShopifyCookiesOptions = CoreShopifyCookiesOptions & {
|
|
2
2
|
/**
|
|
3
3
|
* If set to `false`, Shopify cookies will be removed.
|
|
4
4
|
* If set to `true`, Shopify unique user token cookie will have cookie expiry of 1 year.
|
|
@@ -13,6 +13,32 @@ type UseShopifyCookiesOptions = {
|
|
|
13
13
|
* The checkout domain of the shop. Defaults to empty string. If set, the cookie domain will check if it can be set with the checkout domain.
|
|
14
14
|
*/
|
|
15
15
|
checkoutDomain?: string;
|
|
16
|
+
/**
|
|
17
|
+
* If set to `true`, it skips modifying the deprecated shopify_y and shopify_s cookies.
|
|
18
|
+
*/
|
|
19
|
+
ignoreDeprecatedCookies?: boolean;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Sets the `shopify_y` and `shopify_s` cookies in the browser based on user consent
|
|
23
|
+
* for backward compatibility support.
|
|
24
|
+
*
|
|
25
|
+
* If `fetchTrackingValues` is true, it makes a request to Storefront API
|
|
26
|
+
* to fetch or refresh Shopiy analytics and marketing cookies and tracking values.
|
|
27
|
+
* Generally speaking, this should only be needed if you're not using Hydrogen's
|
|
28
|
+
* built-in analytics components and hooks that already handle this automatically.
|
|
29
|
+
* For example, set it to `true` if you are using `hydrogen-react` only with
|
|
30
|
+
* a different framework and still need to make a same-domain request to
|
|
31
|
+
* Storefront API to set cookies.
|
|
32
|
+
*
|
|
33
|
+
* If `ignoreDeprecatedCookies` is true, it skips setting the deprecated cookies entirely.
|
|
34
|
+
* Useful when you only want to use the newer tracking values and not rely on the deprecated ones.
|
|
35
|
+
*
|
|
36
|
+
* @returns `true` when cookies are set and ready.
|
|
37
|
+
*/
|
|
38
|
+
export declare function useShopifyCookies(options?: UseShopifyCookiesOptions): boolean;
|
|
39
|
+
type CoreShopifyCookiesOptions = {
|
|
40
|
+
storefrontAccessToken?: string;
|
|
41
|
+
fetchTrackingValues?: boolean;
|
|
42
|
+
checkoutDomain?: string;
|
|
16
43
|
};
|
|
17
|
-
export declare function useShopifyCookies(options?: UseShopifyCookiesOptions): void;
|
|
18
44
|
export {};
|