@shopify/hydrogen 2026.10.0-preview.2 → 2026.10.0-preview.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -1
- package/dist/cli/index.mjs +464 -73
- package/dist/core/cart/actions.mjs +2 -0
- package/dist/core/cart/actions.mjs.map +1 -1
- package/dist/core/cart/cart.mjs +16 -6
- package/dist/core/cart/cart.mjs.map +1 -1
- package/dist/core/product/form.d.mts +21 -2
- package/dist/core/product/form.mjs +13 -0
- package/dist/core/product/form.mjs.map +1 -1
- package/dist/core/product/index.d.mts +1 -1
- package/dist/core/request-context.d.mts +6 -0
- package/dist/core/request-context.mjs +6 -2
- package/dist/core/request-context.mjs.map +1 -1
- package/dist/core/request-routing/handle-shopify-routes.mjs +2 -0
- package/dist/core/request-routing/handle-shopify-routes.mjs.map +1 -1
- package/dist/core/request-routing/interceptors/checkout.mjs +4 -1
- package/dist/core/request-routing/interceptors/checkout.mjs.map +1 -1
- package/dist/core/request-routing/interceptors/proxy.mjs +19 -8
- package/dist/core/request-routing/interceptors/proxy.mjs.map +1 -1
- package/dist/core/request-routing/interceptors/ucp-mcp-proxy.mjs +35 -0
- package/dist/core/request-routing/interceptors/ucp-mcp-proxy.mjs.map +1 -0
- package/dist/core/shopify-scripts/analytics.mjs +1 -1
- package/dist/core/shopify-scripts/analytics.mjs.map +1 -1
- package/dist/core/shopify-scripts/constants.mjs +3 -1
- package/dist/core/shopify-scripts/constants.mjs.map +1 -1
- package/dist/core/shopify-scripts/deprecated-cookies.mjs +2 -1
- package/dist/core/shopify-scripts/deprecated-cookies.mjs.map +1 -1
- package/dist/core/shopify-scripts/global.mjs +5 -4
- package/dist/core/shopify-scripts/global.mjs.map +1 -1
- package/dist/core/shopify-scripts/index.d.mts +1 -0
- package/dist/core/shopify-scripts/index.mjs +14 -12
- package/dist/core/shopify-scripts/index.mjs.map +1 -1
- package/dist/core/shopify-scripts/types.d.mts +5 -0
- package/dist/core/url.mjs +2 -1
- package/dist/core/url.mjs.map +1 -1
- package/dist/customer-account/client.mjs +1 -1
- package/dist/customer-account/session.mjs +1 -1
- package/dist/development/core/cart/actions.mjs +2 -0
- package/dist/development/core/cart/actions.mjs.map +1 -1
- package/dist/development/core/cart/cart.mjs +16 -6
- package/dist/development/core/cart/cart.mjs.map +1 -1
- package/dist/development/core/cart/queries.d.mts +57 -57
- package/dist/development/core/predictive-search/queries.d.mts +2 -2
- package/dist/development/core/product/form.d.mts +21 -2
- package/dist/development/core/product/form.mjs +13 -0
- package/dist/development/core/product/form.mjs.map +1 -1
- package/dist/development/core/product/index.d.mts +1 -1
- package/dist/development/core/request-context.d.mts +6 -0
- package/dist/development/core/request-context.mjs +6 -2
- package/dist/development/core/request-context.mjs.map +1 -1
- package/dist/development/core/request-routing/handle-shopify-routes.mjs +2 -0
- package/dist/development/core/request-routing/handle-shopify-routes.mjs.map +1 -1
- package/dist/development/core/request-routing/interceptors/checkout.mjs +4 -1
- package/dist/development/core/request-routing/interceptors/checkout.mjs.map +1 -1
- package/dist/development/core/request-routing/interceptors/proxy.mjs +19 -8
- package/dist/development/core/request-routing/interceptors/proxy.mjs.map +1 -1
- package/dist/development/core/request-routing/interceptors/ucp-mcp-proxy.mjs +35 -0
- package/dist/development/core/request-routing/interceptors/ucp-mcp-proxy.mjs.map +1 -0
- package/dist/development/core/shopify-scripts/analytics.mjs +1 -1
- package/dist/development/core/shopify-scripts/analytics.mjs.map +1 -1
- package/dist/development/core/shopify-scripts/constants.mjs +3 -1
- package/dist/development/core/shopify-scripts/constants.mjs.map +1 -1
- package/dist/development/core/shopify-scripts/deprecated-cookies.mjs +2 -1
- package/dist/development/core/shopify-scripts/deprecated-cookies.mjs.map +1 -1
- package/dist/development/core/shopify-scripts/global.mjs +5 -4
- package/dist/development/core/shopify-scripts/global.mjs.map +1 -1
- package/dist/development/core/shopify-scripts/index.d.mts +1 -0
- package/dist/development/core/shopify-scripts/index.mjs +14 -12
- package/dist/development/core/shopify-scripts/index.mjs.map +1 -1
- package/dist/development/core/shopify-scripts/types.d.mts +5 -0
- package/dist/development/core/url.mjs +2 -1
- package/dist/development/core/url.mjs.map +1 -1
- package/dist/development/globals.d.mts +4 -1
- package/dist/development/react/index.d.mts +2 -2
- package/dist/development/vue/shopify-scripts.d.mts +9 -0
- package/dist/development/vue/shopify-scripts.mjs +5 -0
- package/dist/development/vue/shopify-scripts.mjs.map +1 -1
- package/dist/globals.d.mts +4 -1
- package/dist/react/index.d.mts +2 -2
- package/dist/vue/shopify-scripts.d.mts +10 -1
- package/dist/vue/shopify-scripts.mjs +5 -0
- package/dist/vue/shopify-scripts.mjs.map +1 -1
- package/package.json +1 -1
- package/skills/hydrogen-cart-metafields/SKILL.md +133 -0
- package/skills/hydrogen-cart-ui/SKILL.md +2 -1
- package/skills/hydrogen-setup/steps/11-verify.md +1 -0
- package/skills/hydrogen-setup/steps/2-scaffold.md +21 -0
- package/skills/hydrogen-storefront-client/SKILL.md +4 -0
- package/skills/hydrogen-variant-form/SKILL.md +10 -4
- package/dist/core/shopify-scripts/consent.mjs +0 -17
- package/dist/core/shopify-scripts/consent.mjs.map +0 -1
- package/dist/development/core/shopify-scripts/consent.mjs +0 -17
- package/dist/development/core/shopify-scripts/consent.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.mjs","names":[],"sources":["../../../../src/core/shopify-scripts/constants.ts"],"sourcesContent":["export const SHOPIFY_CDN_ORIGIN = \"https://cdn.shopify.com\";\nexport const SHOPIFY_SHOP_APP_ORIGIN = \"https://shop.app\";\nexport const SHOPIFY_STOREFRONT_STANDARD_ACTIONS_SCRIPT = `${SHOPIFY_CDN_ORIGIN}/storefront/standard-actions.js`;\nexport const SHOPIFY_STOREFRONT_STANDARD_EVENTS_SCRIPT = `${SHOPIFY_CDN_ORIGIN}/storefront/standard-events.js`;\nexport const SHOPIFY_STOREFRONT_STANDARD_EVENTS_INSPECTOR_SCRIPT = `${SHOPIFY_CDN_ORIGIN}/storefront/standard-events-inspector.js`;\nexport const SHOPIFY_STOREFRONT_WEBMCP_SCRIPT = `${SHOPIFY_CDN_ORIGIN}/storefront/webmcp.js`;\nexport const SHOPIFY_INBOX_SCRIPT = `${SHOPIFY_CDN_ORIGIN}/storefront/web-components/agent.js`;\n\nexport const SHOPIFY_STOREFRONT_ANALYTICS_SCRIPT = `${SHOPIFY_CDN_ORIGIN}/storefront/analytics/shopify.js`;\n\nexport const SHOPIFY_PERF_KIT_SCRIPT = `${SHOPIFY_CDN_ORIGIN}/shopifycloud/perf-kit/shopify-perf-kit-spa.min.js?v2`;\nexport const SHOPIFY_CONSENT_API_SCRIPT = `${SHOPIFY_CDN_ORIGIN}/shopifycloud/consent-tracking-api/v0.2/consent-tracking-api.js`;\nexport const SHOPIFY_PRIVACY_BANNER_SCRIPT = `${SHOPIFY_CDN_ORIGIN}/shopifycloud/privacy-banner/storefront-banner.js`;\n\nexport const SHOPIFY_CONSENT_SCRIPT_ID = \"shopify-consent\";\nexport const SHOPIFY_PERF_KIT_SCRIPT_ID = \"shopify-perfkit\";\n\nexport const VISITOR_CONSENT_COLLECTED_EVENT = \"visitorConsentCollected\";\n"],"mappings":";AAAA,MAAa,qBAAqB;AAClC,MAAa,0BAA0B;AACvC,MAAa,6CAA6C,GAAG,mBAAmB;AAChF,MAAa,4CAA4C,GAAG,mBAAmB;AAC/E,MAAa,sDAAsD,GAAG,mBAAmB;AACzF,MAAa,mCAAmC,GAAG,mBAAmB;AACtE,MAAa,uBAAuB,GAAG,mBAAmB;AAE1D,MAAa,sCAAsC,GAAG,mBAAmB;AAEzE,MAAa,0BAA0B,GAAG,mBAAmB;AAC7D,MAAa,6BAA6B,GAAG,mBAAmB;AAChE,MAAa,gCAAgC,GAAG,mBAAmB;AAEnE,MAAa,4BAA4B;AACzC,MAAa,6BAA6B;AAE1C,MAAa,kCAAkC"}
|
|
1
|
+
{"version":3,"file":"constants.mjs","names":[],"sources":["../../../../src/core/shopify-scripts/constants.ts"],"sourcesContent":["export const SHOPIFY_CDN_ORIGIN = \"https://cdn.shopify.com\";\nexport const SHOPIFY_SHOP_APP_ORIGIN = \"https://shop.app\";\nexport const SHOPIFY_STOREFRONT_STANDARD_ACTIONS_SCRIPT = `${SHOPIFY_CDN_ORIGIN}/storefront/standard-actions.js`;\nexport const SHOPIFY_STOREFRONT_STANDARD_EVENTS_SCRIPT = `${SHOPIFY_CDN_ORIGIN}/storefront/standard-events.js`;\nexport const SHOPIFY_STOREFRONT_STANDARD_EVENTS_INSPECTOR_SCRIPT = `${SHOPIFY_CDN_ORIGIN}/storefront/standard-events-inspector.js`;\nexport const SHOPIFY_STOREFRONT_WEBMCP_SCRIPT = `${SHOPIFY_CDN_ORIGIN}/storefront/webmcp.js`;\nexport const SHOPIFY_ACCOUNT_SCRIPT = `${SHOPIFY_CDN_ORIGIN}/storefront/web-components/account.js`;\nexport const SHOPIFY_INBOX_SCRIPT = `${SHOPIFY_CDN_ORIGIN}/storefront/web-components/agent.js`;\n\nexport const SHOPIFY_STOREFRONT_ANALYTICS_SCRIPT = `${SHOPIFY_CDN_ORIGIN}/storefront/analytics/shopify.js`;\n\nexport const SHOPIFY_PERF_KIT_SCRIPT = `${SHOPIFY_CDN_ORIGIN}/shopifycloud/perf-kit/shopify-perf-kit-spa.min.js?v2`;\nexport const SHOPIFY_CONSENT_API_SCRIPT = `${SHOPIFY_CDN_ORIGIN}/shopifycloud/consent-tracking-api/v0.2/consent-tracking-api.js`;\nexport const SHOPIFY_PRIVACY_BANNER_SCRIPT = `${SHOPIFY_CDN_ORIGIN}/shopifycloud/privacy-banner/storefront-banner.js`;\n\nexport const SHOPIFY_CONSENT_SCRIPT_ID = \"shopify-consent\";\nexport const SHOPIFY_PERF_KIT_SCRIPT_ID = \"shopify-perfkit\";\n\nexport const CONSENT_TRACKING_API_LOADED_EVENT = \"consentTrackingApiLoaded\";\nexport const VISITOR_CONSENT_COLLECTED_EVENT = \"visitorConsentCollected\";\n"],"mappings":";AAAA,MAAa,qBAAqB;AAClC,MAAa,0BAA0B;AACvC,MAAa,6CAA6C,GAAG,mBAAmB;AAChF,MAAa,4CAA4C,GAAG,mBAAmB;AAC/E,MAAa,sDAAsD,GAAG,mBAAmB;AACzF,MAAa,mCAAmC,GAAG,mBAAmB;AACtE,MAAa,yBAAyB,GAAG,mBAAmB;AAC5D,MAAa,uBAAuB,GAAG,mBAAmB;AAE1D,MAAa,sCAAsC,GAAG,mBAAmB;AAEzE,MAAa,0BAA0B,GAAG,mBAAmB;AAC7D,MAAa,6BAA6B,GAAG,mBAAmB;AAChE,MAAa,gCAAgC,GAAG,mBAAmB;AAEnE,MAAa,4BAA4B;AACzC,MAAa,6BAA6B;AAE1C,MAAa,oCAAoC;AACjD,MAAa,kCAAkC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { VISITOR_CONSENT_COLLECTED_EVENT } from "./constants.mjs";
|
|
1
|
+
import { CONSENT_TRACKING_API_LOADED_EVENT, VISITOR_CONSENT_COLLECTED_EVENT } from "./constants.mjs";
|
|
2
2
|
import { findWritableCookieDomain } from "./utils/cookie-domain.mjs";
|
|
3
3
|
import { getTrackingValues } from "./utils/tracking-values.mjs";
|
|
4
4
|
import { buildUUID } from "./utils/uuid.mjs";
|
|
@@ -77,6 +77,7 @@ function initializeDeprecatedCookies() {
|
|
|
77
77
|
const syncConsent = () => {
|
|
78
78
|
updateCookies(hasAnalyticsConsent(), domain);
|
|
79
79
|
};
|
|
80
|
+
document.addEventListener(CONSENT_TRACKING_API_LOADED_EVENT, syncConsent);
|
|
80
81
|
document.addEventListener(VISITOR_CONSENT_COLLECTED_EVENT, syncConsent);
|
|
81
82
|
if (isConsentLoaded()) syncConsent();
|
|
82
83
|
const syncPageView = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deprecated-cookies.mjs","names":[],"sources":["../../../../src/core/shopify-scripts/deprecated-cookies.ts"],"sourcesContent":["/**\n * @deprecated This module manages the legacy `_shopify_y` and `_shopify_s`\n * JavaScript-visible cookies. Modern Shopify storefronts use http-only cookies\n * set by the Storefront API via the SFAPI proxy. This module exists only for\n * backward compatibility with downstream systems that may still read these\n * JS cookies directly.\n *\n * To remove: delete this file and remove the ShopifyScripts startup call.\n */\n\nimport { VISITOR_CONSENT_COLLECTED_EVENT } from \"./constants\";\nimport { findWritableCookieDomain } from \"./utils/cookie-domain\";\nimport { getTrackingValues } from \"./utils/tracking-values\";\nimport { buildUUID } from \"./utils/uuid\";\n\nconst SHOPIFY_Y = \"_shopify_y\";\nconst SHOPIFY_S = \"_shopify_s\";\n\nconst LONG_TERM_EXPIRY_IN_SECONDS = 60 * 60 * 24 * 360;\nconst SHORT_TERM_EXPIRY_IN_SECONDS = 60 * 30;\n\n/**\n * Computes the cookie domain as the broadest wildcard domain the browser will\n * accept for the consent domain. Returns empty string for localhost or when\n * probing fails (cookies use current domain).\n *\n * @deprecated Part of legacy cookie management.\n */\nexport function computeCookieDomain(consentDomain?: string): string {\n if (typeof window === \"undefined\") return \"\";\n\n return findWritableCookieDomain(consentDomain || window.location.host);\n}\n\nfunction setCookie(name: string, value: string, maxAgeInSeconds: number, domain: string): void {\n const parts = [`${name}=${encodeURIComponent(value)}`];\n parts.push(`max-age=${maxAgeInSeconds}`);\n parts.push(\"path=/\");\n parts.push(\"SameSite=Lax\");\n if (domain) parts.push(`domain=${domain}`);\n document.cookie = parts.join(\"; \");\n}\n\n/**\n * @deprecated Sets or removes the legacy `_shopify_y` and `_shopify_s` cookies\n * based on the current consent state and tracking values.\n */\nfunction updateCookies(hasConsent: boolean, domain: string): void {\n if (hasConsent) {\n const trackingValues = getTrackingValues();\n const tokenValue = trackingValues.uniqueToken || trackingValues.visitToken || \"\";\n if (tokenValue.startsWith(\"00000000-\")) return;\n\n setCookie(\n SHOPIFY_Y,\n trackingValues.uniqueToken || buildUUID(),\n LONG_TERM_EXPIRY_IN_SECONDS,\n domain,\n );\n setCookie(\n SHOPIFY_S,\n trackingValues.visitToken || buildUUID(),\n SHORT_TERM_EXPIRY_IN_SECONDS,\n domain,\n );\n } else {\n setCookie(SHOPIFY_Y, \"\", 0, domain);\n setCookie(SHOPIFY_S, \"\", 0, domain);\n }\n}\n\nfunction hasAnalyticsConsent(): boolean {\n try {\n const privacy = window.Shopify?.customerPrivacy;\n return privacy?.analyticsProcessingAllowed?.() ?? false;\n } catch {\n return false;\n }\n}\n\nfunction isConsentLoaded(): boolean {\n return window.Shopify?.customerPrivacy?.consentStatus === \"loaded\";\n}\n\nfunction getConsentDomain(): string | undefined {\n return window.Shopify?.customerPrivacy?.config?.consentDomain;\n}\n\nlet didInitializeDeprecatedCookies = false;\nconst noOpCleanup = () => {};\n\n/**\n * @deprecated Starts page-lifetime legacy cookie management from ShopifyScripts.\n */\nexport function initializeDeprecatedCookies(): () => void {\n if (typeof window === \"undefined\" || typeof document === \"undefined\") return noOpCleanup;\n if (didInitializeDeprecatedCookies) return noOpCleanup;\n\n didInitializeDeprecatedCookies = true;\n const domain = computeCookieDomain(getConsentDomain());\n\n const syncConsent = () => {\n updateCookies(hasAnalyticsConsent(), domain);\n };\n\n document.addEventListener(VISITOR_CONSENT_COLLECTED_EVENT, syncConsent);\n if (isConsentLoaded()) syncConsent();\n\n const syncPageView = () => {\n if (hasAnalyticsConsent()) {\n updateCookies(true, domain);\n }\n };\n\n const subscribeToAnalytics = () => {\n const subscribe = window.Shopify?.analytics?.subscribe;\n if (typeof subscribe !== \"function\") return false;\n\n subscribe(\"page_viewed\", syncPageView);\n return true;\n };\n\n if (!subscribeToAnalytics() && document.readyState === \"loading\") {\n // The bus is inline today, but if it moves to a module/defer script it will\n // still be available before DOMContentLoaded.\n document.addEventListener(\"DOMContentLoaded\", subscribeToAnalytics, { once: true });\n }\n\n return noOpCleanup;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAM,YAAY;AAClB,MAAM,YAAY;AAElB,MAAM,8BAA8B,OAAU,KAAK;AACnD,MAAM,+BAA+B;;;;;;;;AASrC,SAAgB,oBAAoB,eAAgC;AAClE,KAAI,OAAO,WAAW,YAAa,QAAO;AAE1C,QAAO,yBAAyB,iBAAiB,OAAO,SAAS,KAAK;;AAGxE,SAAS,UAAU,MAAc,OAAe,iBAAyB,QAAsB;CAC7F,MAAM,QAAQ,CAAC,GAAG,KAAK,GAAG,mBAAmB,MAAM,GAAG;AACtD,OAAM,KAAK,WAAW,kBAAkB;AACxC,OAAM,KAAK,SAAS;AACpB,OAAM,KAAK,eAAe;AAC1B,KAAI,OAAQ,OAAM,KAAK,UAAU,SAAS;AAC1C,UAAS,SAAS,MAAM,KAAK,KAAK;;;;;;AAOpC,SAAS,cAAc,YAAqB,QAAsB;AAChE,KAAI,YAAY;EACd,MAAM,iBAAiB,mBAAmB;AAE1C,OADmB,eAAe,eAAe,eAAe,cAAc,IAC/D,WAAW,YAAY,CAAE;AAExC,YACE,WACA,eAAe,eAAe,WAAW,EACzC,6BACA,OACD;AACD,YACE,WACA,eAAe,cAAc,WAAW,EACxC,8BACA,OACD;QACI;AACL,YAAU,WAAW,IAAI,GAAG,OAAO;AACnC,YAAU,WAAW,IAAI,GAAG,OAAO;;;AAIvC,SAAS,sBAA+B;AACtC,KAAI;AAEF,UADgB,OAAO,SAAS,kBAChB,8BAA8B,IAAI;SAC5C;AACN,SAAO;;;AAIX,SAAS,kBAA2B;AAClC,QAAO,OAAO,SAAS,iBAAiB,kBAAkB;;AAG5D,SAAS,mBAAuC;AAC9C,QAAO,OAAO,SAAS,iBAAiB,QAAQ;;AAGlD,IAAI,iCAAiC;AACrC,MAAM,oBAAoB;;;;AAK1B,SAAgB,8BAA0C;AACxD,KAAI,OAAO,WAAW,eAAe,OAAO,aAAa,YAAa,QAAO;AAC7E,KAAI,+BAAgC,QAAO;AAE3C,kCAAiC;CACjC,MAAM,SAAS,oBAAoB,kBAAkB,CAAC;CAEtD,MAAM,oBAAoB;AACxB,gBAAc,qBAAqB,EAAE,OAAO;;AAG9C,UAAS,iBAAiB,iCAAiC,YAAY;AACvE,KAAI,iBAAiB,CAAE,cAAa;CAEpC,MAAM,qBAAqB;AACzB,MAAI,qBAAqB,CACvB,eAAc,MAAM,OAAO;;CAI/B,MAAM,6BAA6B;EACjC,MAAM,YAAY,OAAO,SAAS,WAAW;AAC7C,MAAI,OAAO,cAAc,WAAY,QAAO;AAE5C,YAAU,eAAe,aAAa;AACtC,SAAO;;AAGT,KAAI,CAAC,sBAAsB,IAAI,SAAS,eAAe,UAGrD,UAAS,iBAAiB,oBAAoB,sBAAsB,EAAE,MAAM,MAAM,CAAC;AAGrF,QAAO"}
|
|
1
|
+
{"version":3,"file":"deprecated-cookies.mjs","names":[],"sources":["../../../../src/core/shopify-scripts/deprecated-cookies.ts"],"sourcesContent":["/**\n * @deprecated This module manages the legacy `_shopify_y` and `_shopify_s`\n * JavaScript-visible cookies. Modern Shopify storefronts use http-only cookies\n * set by the Storefront API via the SFAPI proxy. This module exists only for\n * backward compatibility with downstream systems that may still read these\n * JS cookies directly.\n *\n * To remove: delete this file and remove the ShopifyScripts startup call.\n */\n\nimport { CONSENT_TRACKING_API_LOADED_EVENT, VISITOR_CONSENT_COLLECTED_EVENT } from \"./constants\";\nimport { findWritableCookieDomain } from \"./utils/cookie-domain\";\nimport { getTrackingValues } from \"./utils/tracking-values\";\nimport { buildUUID } from \"./utils/uuid\";\n\nconst SHOPIFY_Y = \"_shopify_y\";\nconst SHOPIFY_S = \"_shopify_s\";\n\nconst LONG_TERM_EXPIRY_IN_SECONDS = 60 * 60 * 24 * 360;\nconst SHORT_TERM_EXPIRY_IN_SECONDS = 60 * 30;\n\n/**\n * Computes the cookie domain as the broadest wildcard domain the browser will\n * accept for the consent domain. Returns empty string for localhost or when\n * probing fails (cookies use current domain).\n *\n * @deprecated Part of legacy cookie management.\n */\nexport function computeCookieDomain(consentDomain?: string): string {\n if (typeof window === \"undefined\") return \"\";\n\n return findWritableCookieDomain(consentDomain || window.location.host);\n}\n\nfunction setCookie(name: string, value: string, maxAgeInSeconds: number, domain: string): void {\n const parts = [`${name}=${encodeURIComponent(value)}`];\n parts.push(`max-age=${maxAgeInSeconds}`);\n parts.push(\"path=/\");\n parts.push(\"SameSite=Lax\");\n if (domain) parts.push(`domain=${domain}`);\n document.cookie = parts.join(\"; \");\n}\n\n/**\n * @deprecated Sets or removes the legacy `_shopify_y` and `_shopify_s` cookies\n * based on the current consent state and tracking values.\n */\nfunction updateCookies(hasConsent: boolean, domain: string): void {\n if (hasConsent) {\n const trackingValues = getTrackingValues();\n const tokenValue = trackingValues.uniqueToken || trackingValues.visitToken || \"\";\n if (tokenValue.startsWith(\"00000000-\")) return;\n\n setCookie(\n SHOPIFY_Y,\n trackingValues.uniqueToken || buildUUID(),\n LONG_TERM_EXPIRY_IN_SECONDS,\n domain,\n );\n setCookie(\n SHOPIFY_S,\n trackingValues.visitToken || buildUUID(),\n SHORT_TERM_EXPIRY_IN_SECONDS,\n domain,\n );\n } else {\n setCookie(SHOPIFY_Y, \"\", 0, domain);\n setCookie(SHOPIFY_S, \"\", 0, domain);\n }\n}\n\nfunction hasAnalyticsConsent(): boolean {\n try {\n const privacy = window.Shopify?.customerPrivacy;\n return privacy?.analyticsProcessingAllowed?.() ?? false;\n } catch {\n return false;\n }\n}\n\nfunction isConsentLoaded(): boolean {\n return window.Shopify?.customerPrivacy?.consentStatus === \"loaded\";\n}\n\nfunction getConsentDomain(): string | undefined {\n return window.Shopify?.customerPrivacy?.config?.consentDomain;\n}\n\nlet didInitializeDeprecatedCookies = false;\nconst noOpCleanup = () => {};\n\n/**\n * @deprecated Starts page-lifetime legacy cookie management from ShopifyScripts.\n */\nexport function initializeDeprecatedCookies(): () => void {\n if (typeof window === \"undefined\" || typeof document === \"undefined\") return noOpCleanup;\n if (didInitializeDeprecatedCookies) return noOpCleanup;\n\n didInitializeDeprecatedCookies = true;\n const domain = computeCookieDomain(getConsentDomain());\n\n const syncConsent = () => {\n updateCookies(hasAnalyticsConsent(), domain);\n };\n\n document.addEventListener(CONSENT_TRACKING_API_LOADED_EVENT, syncConsent);\n document.addEventListener(VISITOR_CONSENT_COLLECTED_EVENT, syncConsent);\n if (isConsentLoaded()) syncConsent();\n\n const syncPageView = () => {\n if (hasAnalyticsConsent()) {\n updateCookies(true, domain);\n }\n };\n\n const subscribeToAnalytics = () => {\n const subscribe = window.Shopify?.analytics?.subscribe;\n if (typeof subscribe !== \"function\") return false;\n\n subscribe(\"page_viewed\", syncPageView);\n return true;\n };\n\n if (!subscribeToAnalytics() && document.readyState === \"loading\") {\n // The bus is inline today, but if it moves to a module/defer script it will\n // still be available before DOMContentLoaded.\n document.addEventListener(\"DOMContentLoaded\", subscribeToAnalytics, { once: true });\n }\n\n return noOpCleanup;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAM,YAAY;AAClB,MAAM,YAAY;AAElB,MAAM,8BAA8B,OAAU,KAAK;AACnD,MAAM,+BAA+B;;;;;;;;AASrC,SAAgB,oBAAoB,eAAgC;AAClE,KAAI,OAAO,WAAW,YAAa,QAAO;AAE1C,QAAO,yBAAyB,iBAAiB,OAAO,SAAS,KAAK;;AAGxE,SAAS,UAAU,MAAc,OAAe,iBAAyB,QAAsB;CAC7F,MAAM,QAAQ,CAAC,GAAG,KAAK,GAAG,mBAAmB,MAAM,GAAG;AACtD,OAAM,KAAK,WAAW,kBAAkB;AACxC,OAAM,KAAK,SAAS;AACpB,OAAM,KAAK,eAAe;AAC1B,KAAI,OAAQ,OAAM,KAAK,UAAU,SAAS;AAC1C,UAAS,SAAS,MAAM,KAAK,KAAK;;;;;;AAOpC,SAAS,cAAc,YAAqB,QAAsB;AAChE,KAAI,YAAY;EACd,MAAM,iBAAiB,mBAAmB;AAE1C,OADmB,eAAe,eAAe,eAAe,cAAc,IAC/D,WAAW,YAAY,CAAE;AAExC,YACE,WACA,eAAe,eAAe,WAAW,EACzC,6BACA,OACD;AACD,YACE,WACA,eAAe,cAAc,WAAW,EACxC,8BACA,OACD;QACI;AACL,YAAU,WAAW,IAAI,GAAG,OAAO;AACnC,YAAU,WAAW,IAAI,GAAG,OAAO;;;AAIvC,SAAS,sBAA+B;AACtC,KAAI;AAEF,UADgB,OAAO,SAAS,kBAChB,8BAA8B,IAAI;SAC5C;AACN,SAAO;;;AAIX,SAAS,kBAA2B;AAClC,QAAO,OAAO,SAAS,iBAAiB,kBAAkB;;AAG5D,SAAS,mBAAuC;AAC9C,QAAO,OAAO,SAAS,iBAAiB,QAAQ;;AAGlD,IAAI,iCAAiC;AACrC,MAAM,oBAAoB;;;;AAK1B,SAAgB,8BAA0C;AACxD,KAAI,OAAO,WAAW,eAAe,OAAO,aAAa,YAAa,QAAO;AAC7E,KAAI,+BAAgC,QAAO;AAE3C,kCAAiC;CACjC,MAAM,SAAS,oBAAoB,kBAAkB,CAAC;CAEtD,MAAM,oBAAoB;AACxB,gBAAc,qBAAqB,EAAE,OAAO;;AAG9C,UAAS,iBAAiB,mCAAmC,YAAY;AACzE,UAAS,iBAAiB,iCAAiC,YAAY;AACvE,KAAI,iBAAiB,CAAE,cAAa;CAEpC,MAAM,qBAAqB;AACzB,MAAI,qBAAqB,CACvB,eAAc,MAAM,OAAO;;CAI/B,MAAM,6BAA6B;EACjC,MAAM,YAAY,OAAO,SAAS,WAAW;AAC7C,MAAI,OAAO,cAAc,WAAY,QAAO;AAE5C,YAAU,eAAe,aAAa;AACtC,SAAO;;AAGT,KAAI,CAAC,sBAAsB,IAAI,SAAS,eAAe,UAGrD,UAAS,iBAAiB,oBAAoB,sBAAsB,EAAE,MAAM,MAAM,CAAC;AAGrF,QAAO"}
|
|
@@ -73,10 +73,11 @@ function getShopifyGlobalBootstrapScript({ i18n, shop }) {
|
|
|
73
73
|
apiProxyPrefix: SHOPIFY_API_PROXY_PREFIX
|
|
74
74
|
},
|
|
75
75
|
shop: normalizeMyshopifyDomain(shop.myshopifyDomain),
|
|
76
|
-
customerPrivacy: {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
customerPrivacy: { config: {
|
|
77
|
+
isHeadless: true,
|
|
78
|
+
asyncConsent: true,
|
|
79
|
+
asyncVisitorState: true
|
|
80
|
+
} }
|
|
80
81
|
};
|
|
81
82
|
return asInlineScript(initializeShopifyGlobal)(config);
|
|
82
83
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"global.mjs","names":[],"sources":["../../../../src/core/shopify-scripts/global.ts"],"sourcesContent":["import type { ShopifyGlobal } from \"../../globals\";\nimport type { I18nConfig } from \"../request-context\";\nimport {\n matchStandardRouteUrl,\n resolveStandardRouteUrl,\n type ShopifyRouteTemplates,\n} from \"../standard-routes/index\";\nimport { SHOPIFY_API_PROXY_PREFIX, isHydrogenServerHandoffPath } from \"../url\";\nimport initializeShopifyGlobal from \"./global-script\" with { type: \"script\" };\nimport type { ShopifyScriptsI18n } from \"./types\";\nimport type { ShopifyScriptsShop } from \"./types\";\nimport { asInlineScript } from \"./utils/inline-script\";\n\nexport type ShopifyGlobalConfig = {\n country: I18nConfig[\"country\"];\n currency?: NonNullable<ShopifyGlobal[\"currency\"]>;\n locale: Lowercase<I18nConfig[\"language\"]>;\n customerPrivacy: {\n config: NonNullable<ShopifyGlobal[\"customerPrivacy\"][\"config\"]>;\n
|
|
1
|
+
{"version":3,"file":"global.mjs","names":[],"sources":["../../../../src/core/shopify-scripts/global.ts"],"sourcesContent":["import type { ShopifyGlobal } from \"../../globals\";\nimport type { I18nConfig } from \"../request-context\";\nimport {\n matchStandardRouteUrl,\n resolveStandardRouteUrl,\n type ShopifyRouteTemplates,\n} from \"../standard-routes/index\";\nimport { SHOPIFY_API_PROXY_PREFIX, isHydrogenServerHandoffPath } from \"../url\";\nimport initializeShopifyGlobal from \"./global-script\" with { type: \"script\" };\nimport type { ShopifyScriptsI18n } from \"./types\";\nimport type { ShopifyScriptsShop } from \"./types\";\nimport { asInlineScript } from \"./utils/inline-script\";\n\nexport type ShopifyGlobalConfig = {\n country: I18nConfig[\"country\"];\n currency?: NonNullable<ShopifyGlobal[\"currency\"]>;\n locale: Lowercase<I18nConfig[\"language\"]>;\n customerPrivacy: {\n config: NonNullable<ShopifyGlobal[\"customerPrivacy\"][\"config\"]>;\n };\n routes: {\n root: string;\n apiProxyPrefix: string;\n };\n shop: string;\n};\n\nexport type IncompleteCustomerPrivacy = Partial<\n Omit<ShopifyGlobal[\"customerPrivacy\"], \"config\">\n> & {\n config?: Partial<NonNullable<ShopifyGlobal[\"customerPrivacy\"][\"config\"]>>;\n};\n\nexport type IncompleteShopifyGlobal = Partial<Omit<ShopifyGlobal, \"customerPrivacy\" | \"routes\">> & {\n customerPrivacy?: IncompleteCustomerPrivacy;\n routes?: Partial<ShopifyGlobal[\"routes\"]> & Record<string, unknown>;\n [key: string]: unknown;\n};\n\nconst DEFAULT_COUNTRY: ShopifyGlobalConfig[\"country\"] = \"US\";\nconst DEFAULT_LOCALE: ShopifyGlobalConfig[\"locale\"] = \"en\";\nconst DEFAULT_ROUTES_ROOT: ShopifyGlobalConfig[\"routes\"][\"root\"] = \"/\";\n\n/**\n * Returns the browser's `window.Shopify` object, creating it when needed.\n *\n * This is SSR-safe and returns `undefined` outside the browser.\n */\nexport function getShopifyGlobal(): IncompleteShopifyGlobal | undefined {\n if (typeof window === \"undefined\") return undefined;\n\n const shopifyWindow: { Shopify?: IncompleteShopifyGlobal } = window;\n return (shopifyWindow.Shopify ??= {});\n}\n\n/**\n * Configures Shopify runtime routing hooks used by storefront scripts.\n *\n * This is SSR-safe and no-ops outside the browser.\n */\nexport function configureShopifyRouting({\n navigate,\n routes,\n}: {\n navigate?: ShopifyGlobal[\"routes\"][\"navigate\"];\n routes?: ShopifyRouteTemplates;\n}) {\n const shopify = getShopifyGlobal();\n if (!shopify) return;\n\n const getRouteOptions = (url: string) => ({\n baseUrl: window.location.href,\n pathPrefix: shopify.routes?.root,\n routeTemplates: routes ?? {},\n url,\n });\n\n shopify.routes ??= {};\n shopify.routes.match = (url) => matchStandardRouteUrl(getRouteOptions(url));\n shopify.routes.resolve = (url) => resolveStandardRouteUrl(getRouteOptions(url));\n\n const navigateTo = navigate ?? documentNavigate;\n shopify.routes.navigate = (url) => {\n if (shouldHandoff(url)) {\n return documentNavigate(url);\n }\n\n return navigateTo(shopify.routes?.resolve?.(url) ?? url);\n };\n // Deprecated, kept for temporary backwards compat with WebMCP\n shopify.navigate = shopify.routes.navigate;\n}\n\nfunction documentNavigate(url: string): void {\n window.location.assign(url);\n}\n\nfunction shouldHandoff(url: string): boolean {\n try {\n const parsedUrl = new URL(url, window.location.href);\n\n return (\n parsedUrl.origin === window.location.origin && isHydrogenServerHandoffPath(parsedUrl.pathname)\n );\n } catch {\n return false;\n }\n}\n\nfunction getShopifyRoutesRoot(pathPrefix: I18nConfig[\"pathPrefix\"]): string {\n const normalizedPathPrefix = pathPrefix?.trim().replace(/^\\/+/, \"\").replace(/\\/+$/, \"\") ?? \"\";\n\n return normalizedPathPrefix ? `/${normalizedPathPrefix}/` : DEFAULT_ROUTES_ROOT;\n}\n\nfunction normalizeMyshopifyDomain(domain: string): string {\n return domain\n .trim()\n .replace(/^https?:\\/\\//i, \"\")\n .replace(/\\/+$/, \"\");\n}\n\n/**\n * Builds the inline bootstrap script that initializes `window.Shopify` for storefront scripts.\n */\nexport function getShopifyGlobalBootstrapScript({\n i18n,\n shop,\n}: {\n i18n?: ShopifyScriptsI18n;\n shop: ShopifyScriptsShop;\n}): string {\n const config: ShopifyGlobalConfig = {\n country: i18n?.country ?? DEFAULT_COUNTRY,\n ...(i18n?.currency !== undefined ? { currency: { active: i18n.currency.toUpperCase() } } : {}),\n // oxlint-disable-next-line typescript/consistent-type-assertions\n locale: (i18n?.language ?? DEFAULT_LOCALE).toLowerCase() as Lowercase<\n ShopifyGlobalConfig[\"locale\"]\n >,\n routes: {\n root: getShopifyRoutesRoot(i18n?.pathPrefix),\n apiProxyPrefix: SHOPIFY_API_PROXY_PREFIX,\n },\n shop: normalizeMyshopifyDomain(shop.myshopifyDomain),\n customerPrivacy: {\n config: {\n isHeadless: true,\n asyncConsent: true,\n asyncVisitorState: true,\n },\n },\n };\n\n return asInlineScript(initializeShopifyGlobal)(config);\n}\n"],"mappings":";;;;;;AAQA,MAAM,2BAAyB,eAAe,mBAAsB,sUAAS,CAAA,QAAA,kCAAA,KAAA,UAAA,WAAA,IAAA,aAAA,QAAA,MAAA,UAAA,CAAA,QAAA,WAAA,UAAA,CAAA,QAAA,WAAA,UAAA,CAAA;AA+B7E,MAAM,kBAAkD;AACxD,MAAM,iBAAgD;AACtD,MAAM,sBAA6D;;;;;;AAOnE,SAAgB,mBAAwD;AACtE,KAAI,OAAO,WAAW,YAAa,QAAO;CAE1C,MAAM,gBAAuD;AAC7D,QAAQ,cAAc,YAAY,EAAE;;;;;;;AAQtC,SAAgB,wBAAwB,EACtC,UACA,UAIC;CACD,MAAM,UAAU,kBAAkB;AAClC,KAAI,CAAC,QAAS;CAEd,MAAM,mBAAmB,SAAiB;EACxC,SAAS,OAAO,SAAS;EACzB,YAAY,QAAQ,QAAQ;EAC5B,gBAAgB,UAAU,EAAE;EAC5B;EACD;AAED,SAAQ,WAAW,EAAE;AACrB,SAAQ,OAAO,SAAS,QAAQ,sBAAsB,gBAAgB,IAAI,CAAC;AAC3E,SAAQ,OAAO,WAAW,QAAQ,wBAAwB,gBAAgB,IAAI,CAAC;CAE/E,MAAM,aAAa,YAAY;AAC/B,SAAQ,OAAO,YAAY,QAAQ;AACjC,MAAI,cAAc,IAAI,CACpB,QAAO,iBAAiB,IAAI;AAG9B,SAAO,WAAW,QAAQ,QAAQ,UAAU,IAAI,IAAI,IAAI;;AAG1D,SAAQ,WAAW,QAAQ,OAAO;;AAGpC,SAAS,iBAAiB,KAAmB;AAC3C,QAAO,SAAS,OAAO,IAAI;;AAG7B,SAAS,cAAc,KAAsB;AAC3C,KAAI;EACF,MAAM,YAAY,IAAI,IAAI,KAAK,OAAO,SAAS,KAAK;AAEpD,SACE,UAAU,WAAW,OAAO,SAAS,UAAU,4BAA4B,UAAU,SAAQ;SAEzF;AACN,SAAO;;;AAIX,SAAS,qBAAqB,YAA8C;CAC1E,MAAM,uBAAuB,YAAY,MAAM,CAAC,QAAQ,QAAQ,GAAG,CAAC,QAAQ,QAAQ,GAAG,IAAI;AAE3F,QAAO,uBAAuB,IAAI,qBAAqB,KAAK;;AAG9D,SAAS,yBAAyB,QAAwB;AACxD,QAAO,OACJ,MAAK,CACL,QAAQ,iBAAiB,GAAE,CAC3B,QAAQ,QAAQ,GAAG;;;;;AAMxB,SAAgB,gCAAgC,EAC9C,MACA,QAIS;CACT,MAAM,SAA8B;EAClC,SAAS,MAAM,WAAW;EAC1B,GAAI,MAAM,aAAa,SAAY,EAAE,UAAU,EAAE,QAAQ,KAAK,SAAS,aAAa,EAAE,EAAE,GAAG,EAAE;EAE7F,SAAS,MAAM,YAAY,gBAAgB,aAAa;EAGxD,QAAQ;GACN,MAAM,qBAAqB,MAAM,WAAW;GAC5C,gBAAgB;GACjB;EACD,MAAM,yBAAyB,KAAK,gBAAgB;EACpD,iBAAiB,EACf,QAAQ;GACN,YAAY;GACZ,cAAc;GACd,mBAAmB;GACpB,EACF;EACF;AAED,QAAO,eAAe,wBAAwB,CAAC,OAAO"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { getShopifyAnalyticsBusScript, getShopifyAnalyticsConfig } from "./analytics.mjs";
|
|
2
|
-
import { SHOPIFY_CDN_ORIGIN, SHOPIFY_CONSENT_API_SCRIPT, SHOPIFY_CONSENT_SCRIPT_ID, SHOPIFY_INBOX_SCRIPT, SHOPIFY_PERF_KIT_SCRIPT, SHOPIFY_PRIVACY_BANNER_SCRIPT, SHOPIFY_SHOP_APP_ORIGIN, SHOPIFY_STOREFRONT_ANALYTICS_SCRIPT, SHOPIFY_STOREFRONT_STANDARD_ACTIONS_SCRIPT, SHOPIFY_STOREFRONT_STANDARD_EVENTS_INSPECTOR_SCRIPT, SHOPIFY_STOREFRONT_STANDARD_EVENTS_SCRIPT, SHOPIFY_STOREFRONT_WEBMCP_SCRIPT, VISITOR_CONSENT_COLLECTED_EVENT } from "./constants.mjs";
|
|
3
|
-
import { getShopifyConsentTrackingScript } from "./consent.mjs";
|
|
2
|
+
import { CONSENT_TRACKING_API_LOADED_EVENT, SHOPIFY_ACCOUNT_SCRIPT, SHOPIFY_CDN_ORIGIN, SHOPIFY_CONSENT_API_SCRIPT, SHOPIFY_CONSENT_SCRIPT_ID, SHOPIFY_INBOX_SCRIPT, SHOPIFY_PERF_KIT_SCRIPT, SHOPIFY_PRIVACY_BANNER_SCRIPT, SHOPIFY_SHOP_APP_ORIGIN, SHOPIFY_STOREFRONT_ANALYTICS_SCRIPT, SHOPIFY_STOREFRONT_STANDARD_ACTIONS_SCRIPT, SHOPIFY_STOREFRONT_STANDARD_EVENTS_INSPECTOR_SCRIPT, SHOPIFY_STOREFRONT_STANDARD_EVENTS_SCRIPT, SHOPIFY_STOREFRONT_WEBMCP_SCRIPT, VISITOR_CONSENT_COLLECTED_EVENT } from "./constants.mjs";
|
|
4
3
|
import { getShopifyGlobal, getShopifyGlobalBootstrapScript } from "./global.mjs";
|
|
5
4
|
import { getPerfKitScript } from "./perfkit.mjs";
|
|
6
5
|
import { renderShopifyScriptTag } from "./render.mjs";
|
|
@@ -14,7 +13,7 @@ import { initializeShopifyScripts } from "./initialize.mjs";
|
|
|
14
13
|
* component. Frameworks without a binding can render these descriptors during SSR and call
|
|
15
14
|
* `initializeShopifyScripts()` during browser hydration.
|
|
16
15
|
*/
|
|
17
|
-
function getShopifyScriptTags({ analytics, consent, debug, i18n, nonce, shop, shopifyAnalytics = true, inbox = false }) {
|
|
16
|
+
function getShopifyScriptTags({ account = false, analytics, consent, debug, i18n, nonce, shop, shopifyAnalytics = true, inbox = false }) {
|
|
18
17
|
const nonceAttributes = nonce !== void 0 ? { nonce } : void 0;
|
|
19
18
|
const analyticsConfig = getShopifyAnalyticsConfig({
|
|
20
19
|
analytics,
|
|
@@ -87,31 +86,34 @@ function getShopifyScriptTags({ analytics, consent, debug, i18n, nonce, shop, sh
|
|
|
87
86
|
src: SHOPIFY_INBOX_SCRIPT
|
|
88
87
|
}
|
|
89
88
|
});
|
|
90
|
-
scripts.push({
|
|
89
|
+
if (account) scripts.push({
|
|
91
90
|
tagName: "script",
|
|
92
91
|
attributes: {
|
|
93
|
-
id:
|
|
92
|
+
id: "shopify-account",
|
|
93
|
+
type: "module",
|
|
94
94
|
async: true,
|
|
95
95
|
crossorigin: "anonymous",
|
|
96
96
|
...nonceAttributes,
|
|
97
|
-
src:
|
|
97
|
+
src: SHOPIFY_ACCOUNT_SCRIPT
|
|
98
98
|
}
|
|
99
99
|
});
|
|
100
100
|
scripts.push({
|
|
101
101
|
tagName: "script",
|
|
102
102
|
attributes: {
|
|
103
|
-
id: "shopify-
|
|
103
|
+
id: "shopify-analytics-bus",
|
|
104
104
|
...nonceAttributes
|
|
105
105
|
},
|
|
106
|
-
innerHTML:
|
|
106
|
+
innerHTML: getShopifyAnalyticsBusScript(analyticsConfig)
|
|
107
107
|
});
|
|
108
108
|
scripts.push({
|
|
109
109
|
tagName: "script",
|
|
110
110
|
attributes: {
|
|
111
|
-
id:
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
111
|
+
id: SHOPIFY_CONSENT_SCRIPT_ID,
|
|
112
|
+
async: true,
|
|
113
|
+
crossorigin: "anonymous",
|
|
114
|
+
...nonceAttributes,
|
|
115
|
+
src: consent?.mode === "default-banner" ? SHOPIFY_PRIVACY_BANNER_SCRIPT : SHOPIFY_CONSENT_API_SCRIPT
|
|
116
|
+
}
|
|
115
117
|
});
|
|
116
118
|
if (shopifyAnalytics) scripts.push({
|
|
117
119
|
tagName: "script",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/core/shopify-scripts/index.ts"],"sourcesContent":["import { getShopifyAnalyticsBusScript, getShopifyAnalyticsConfig } from \"./analytics\";\nimport {
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/core/shopify-scripts/index.ts"],"sourcesContent":["import { getShopifyAnalyticsBusScript, getShopifyAnalyticsConfig } from \"./analytics\";\nimport {\n SHOPIFY_ACCOUNT_SCRIPT,\n SHOPIFY_CONSENT_API_SCRIPT,\n SHOPIFY_CDN_ORIGIN,\n SHOPIFY_CONSENT_SCRIPT_ID,\n SHOPIFY_PRIVACY_BANNER_SCRIPT,\n SHOPIFY_SHOP_APP_ORIGIN,\n SHOPIFY_INBOX_SCRIPT,\n SHOPIFY_STOREFRONT_ANALYTICS_SCRIPT,\n SHOPIFY_STOREFRONT_STANDARD_ACTIONS_SCRIPT,\n SHOPIFY_STOREFRONT_STANDARD_EVENTS_INSPECTOR_SCRIPT,\n SHOPIFY_STOREFRONT_STANDARD_EVENTS_SCRIPT,\n} from \"./constants\";\nimport { getShopifyGlobalBootstrapScript } from \"./global\";\nimport { getPerfKitScript } from \"./perfkit\";\nimport { renderShopifyScriptTag } from \"./render\";\nimport type {\n ShopifyLinkDescriptor,\n ShopifyScriptDescriptor,\n ShopifyScriptTagDescriptors,\n ShopifyScriptTagsOptions,\n} from \"./types\";\n\nexport {\n CONSENT_TRACKING_API_LOADED_EVENT,\n SHOPIFY_ACCOUNT_SCRIPT,\n SHOPIFY_CDN_ORIGIN,\n SHOPIFY_CONSENT_API_SCRIPT,\n SHOPIFY_PERF_KIT_SCRIPT,\n SHOPIFY_PRIVACY_BANNER_SCRIPT,\n SHOPIFY_SHOP_APP_ORIGIN,\n SHOPIFY_INBOX_SCRIPT,\n SHOPIFY_STOREFRONT_ANALYTICS_SCRIPT,\n SHOPIFY_STOREFRONT_STANDARD_ACTIONS_SCRIPT,\n SHOPIFY_STOREFRONT_STANDARD_EVENTS_SCRIPT,\n SHOPIFY_STOREFRONT_WEBMCP_SCRIPT,\n VISITOR_CONSENT_COLLECTED_EVENT,\n} from \"./constants\";\nexport { getShopifyGlobal, getShopifyGlobalBootstrapScript } from \"./global\";\nexport { initializeShopifyScripts } from \"./initialize\";\nexport { renderShopifyScriptTag } from \"./render\";\nexport type {\n ShopifyScriptsAnalyticsConfig,\n ShopifyRoutesOptions,\n ShopifyScriptTagDescriptor,\n ShopifyScriptTagDescriptors,\n ShopifyScriptTagsOptions,\n ShopifyScriptsOptions,\n ShopifyScriptsI18n,\n ShopifyScriptsShop,\n} from \"./types\";\n\n/**\n * Returns grouped Shopify storefront script/link descriptors for SSR frameworks and bindings.\n *\n * Framework bindings wrap this with `initializeShopifyScripts()` to form their `ShopifyScripts`\n * component. Frameworks without a binding can render these descriptors during SSR and call\n * `initializeShopifyScripts()` during browser hydration.\n */\n// oxlint-disable-next-line complexity -- ordered assembly of optional Shopify script tags; each flag adds one branch and splitting would obscure the required load order\nexport function getShopifyScriptTags({\n account = false,\n analytics,\n consent,\n debug,\n i18n,\n nonce,\n shop,\n shopifyAnalytics = true,\n inbox = false,\n}: ShopifyScriptTagsOptions): ShopifyScriptTagDescriptors {\n const nonceAttributes = nonce !== undefined ? { nonce } : undefined;\n const analyticsConfig = getShopifyAnalyticsConfig({ analytics, consent, shop });\n\n const links: ShopifyLinkDescriptor[] = [\n {\n tagName: \"link\",\n attributes: {\n rel: \"preconnect\",\n href: SHOPIFY_CDN_ORIGIN,\n },\n },\n {\n tagName: \"link\",\n attributes: {\n rel: \"preconnect\",\n href: SHOPIFY_SHOP_APP_ORIGIN,\n },\n },\n {\n tagName: \"link\",\n attributes: {\n rel: \"prefetch\",\n as: \"script\",\n href: SHOPIFY_STOREFRONT_STANDARD_EVENTS_SCRIPT,\n crossorigin: \"anonymous\",\n },\n },\n ];\n const scripts: ShopifyScriptDescriptor[] = [\n {\n tagName: \"script\",\n attributes: { id: \"shopify-global-bootstrap\", ...nonceAttributes },\n innerHTML: getShopifyGlobalBootstrapScript({ i18n, shop }),\n },\n {\n tagName: \"script\",\n attributes: {\n id: \"shopify-standard-actions\",\n type: \"module\",\n crossorigin: \"anonymous\",\n ...nonceAttributes,\n src: SHOPIFY_STOREFRONT_STANDARD_ACTIONS_SCRIPT,\n },\n },\n ];\n\n if (__DEV__ && debug?.standardEventsInspector) {\n scripts.push({\n tagName: \"script\",\n attributes: {\n id: \"shopify-standard-events-inspector\",\n defer: true,\n crossorigin: \"anonymous\",\n ...nonceAttributes,\n src: SHOPIFY_STOREFRONT_STANDARD_EVENTS_INSPECTOR_SCRIPT,\n },\n });\n }\n\n if (inbox) {\n scripts.push({\n tagName: \"script\",\n attributes: {\n id: \"shopify-inbox\",\n type: \"module\",\n async: true,\n crossorigin: \"anonymous\",\n ...nonceAttributes,\n src: SHOPIFY_INBOX_SCRIPT,\n },\n });\n }\n\n if (account) {\n scripts.push({\n tagName: \"script\",\n attributes: {\n id: \"shopify-account\",\n type: \"module\",\n async: true,\n crossorigin: \"anonymous\",\n ...nonceAttributes,\n src: SHOPIFY_ACCOUNT_SCRIPT,\n },\n });\n }\n\n // Install readiness listeners before loading the async consent library so a\n // cached script cannot finish initialization before Hydrogen starts listening.\n scripts.push({\n tagName: \"script\",\n attributes: { id: \"shopify-analytics-bus\", ...nonceAttributes },\n innerHTML: getShopifyAnalyticsBusScript(analyticsConfig),\n });\n\n scripts.push({\n tagName: \"script\",\n attributes: {\n id: SHOPIFY_CONSENT_SCRIPT_ID,\n async: true,\n crossorigin: \"anonymous\",\n ...nonceAttributes,\n src:\n consent?.mode === \"default-banner\"\n ? SHOPIFY_PRIVACY_BANNER_SCRIPT\n : SHOPIFY_CONSENT_API_SCRIPT,\n },\n });\n\n if (shopifyAnalytics) {\n scripts.push({\n tagName: \"script\",\n attributes: {\n id: \"shopify-storefront-analytics\",\n async: true,\n crossorigin: \"anonymous\",\n ...nonceAttributes,\n src: SHOPIFY_STOREFRONT_ANALYTICS_SCRIPT,\n },\n });\n }\n\n const perfKitScript = getPerfKitScript(shop, nonceAttributes);\n if (perfKitScript) {\n scripts.push(perfKitScript);\n }\n\n return {\n links,\n scripts,\n get tags() {\n return [...links, ...scripts];\n },\n };\n}\n\n/**\n * Renders all Shopify storefront script/link descriptors to HTML strings.\n */\nexport function renderShopifyScriptTags(options: ShopifyScriptTagsOptions): string[] {\n return getShopifyScriptTags(options).tags.map(renderShopifyScriptTag);\n}\n"],"mappings":";;;;;;;;;;;;;;;AA6DA,SAAgB,qBAAqB,EACnC,UAAU,OACV,WACA,SACA,OACA,MACA,OACA,MACA,mBAAmB,MACnB,QAAQ,SACgD;CACxD,MAAM,kBAAkB,UAAU,SAAY,EAAE,OAAO,GAAG;CAC1D,MAAM,kBAAkB,0BAA0B;EAAE;EAAW;EAAS;EAAM,CAAC;CAE/E,MAAM,QAAiC;EACrC;GACE,SAAS;GACT,YAAY;IACV,KAAK;IACL,MAAM;IACP;GACF;EACD;GACE,SAAS;GACT,YAAY;IACV,KAAK;IACL,MAAM;IACP;GACF;EACD;GACE,SAAS;GACT,YAAY;IACV,KAAK;IACL,IAAI;IACJ,MAAM;IACN,aAAa;IACd;GACF;EACF;CACD,MAAM,UAAqC,CACzC;EACE,SAAS;EACT,YAAY;GAAE,IAAI;GAA4B,GAAG;GAAiB;EAClE,WAAW,gCAAgC;GAAE;GAAM;GAAM,CAAC;EAC3D,EACD;EACE,SAAS;EACT,YAAY;GACV,IAAI;GACJ,MAAM;GACN,aAAa;GACb,GAAG;GACH,KAAK;GACN;EACF,CACF;AAED,KAAe,OAAO,wBACpB,SAAQ,KAAK;EACX,SAAS;EACT,YAAY;GACV,IAAI;GACJ,OAAO;GACP,aAAa;GACb,GAAG;GACH,KAAK;GACN;EACF,CAAC;AAGJ,KAAI,MACF,SAAQ,KAAK;EACX,SAAS;EACT,YAAY;GACV,IAAI;GACJ,MAAM;GACN,OAAO;GACP,aAAa;GACb,GAAG;GACH,KAAK;GACN;EACF,CAAC;AAGJ,KAAI,QACF,SAAQ,KAAK;EACX,SAAS;EACT,YAAY;GACV,IAAI;GACJ,MAAM;GACN,OAAO;GACP,aAAa;GACb,GAAG;GACH,KAAK;GACN;EACF,CAAC;AAKJ,SAAQ,KAAK;EACX,SAAS;EACT,YAAY;GAAE,IAAI;GAAyB,GAAG;GAAiB;EAC/D,WAAW,6BAA6B,gBAAgB;EACzD,CAAC;AAEF,SAAQ,KAAK;EACX,SAAS;EACT,YAAY;GACV,IAAI;GACJ,OAAO;GACP,aAAa;GACb,GAAG;GACH,KACE,SAAS,SAAS,mBACd,gCACA;GACP;EACF,CAAC;AAEF,KAAI,iBACF,SAAQ,KAAK;EACX,SAAS;EACT,YAAY;GACV,IAAI;GACJ,OAAO;GACP,aAAa;GACb,GAAG;GACH,KAAK;GACN;EACF,CAAC;CAGJ,MAAM,gBAAgB,iBAAiB,MAAM,gBAAgB;AAC7D,KAAI,cACF,SAAQ,KAAK,cAAc;AAG7B,QAAO;EACL;EACA;EACA,IAAI,OAAO;AACT,UAAO,CAAC,GAAG,OAAO,GAAG,QAAQ;;EAEhC;;;;;AAMH,SAAgB,wBAAwB,SAA6C;AACnF,QAAO,qBAAqB,QAAQ,CAAC,KAAK,IAAI,uBAAuB"}
|
|
@@ -52,6 +52,11 @@ type ShopifyScriptsShop = {
|
|
|
52
52
|
myshopifyDomain: string;
|
|
53
53
|
};
|
|
54
54
|
type ShopifyScriptTagsOptions = {
|
|
55
|
+
/**
|
|
56
|
+
* Loads the customer account component. Render `<shopify-account>` where you want the account UI to appear.
|
|
57
|
+
* @see {@link https://shopify.dev/docs/api/storefront-web-components/components/shopify-account | shopify-account}
|
|
58
|
+
*/
|
|
59
|
+
account?: boolean;
|
|
55
60
|
analytics?: ShopifyScriptsAnalyticsConfig;
|
|
56
61
|
consent?: ConsentConfig;
|
|
57
62
|
debug?: {
|
|
@@ -3,6 +3,7 @@ const SFAPI_RE = /^\/api\/(unstable|2\d{3}-\d{2})\/graphql\.json$/;
|
|
|
3
3
|
const SHOPIFY_API_PROXY_PREFIX = "/__shopify";
|
|
4
4
|
const SHOPIFY_API_PROXY_RE = /^\/__shopify(?:\/|$)/;
|
|
5
5
|
const MCP_RE = /^\/api\/mcp$/;
|
|
6
|
+
const UCP_MCP_RE = /^\/api\/ucp\/mcp$/;
|
|
6
7
|
const CHECKOUT_RE = /^\/checkout$/;
|
|
7
8
|
const CART_PERMALINK_RE = /^\/cart\/\d+:\d+(?:,\d+:\d+)*$/;
|
|
8
9
|
const CUSTOMER_ACCOUNT_PATHS = {
|
|
@@ -38,5 +39,5 @@ function normalizeStoreDomain(domain) {
|
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
//#endregion
|
|
41
|
-
export { AJAX_CART_RE, CHECKOUT_RE, CUSTOMER_ACCOUNT_PATHS, MCP_RE, SFAPI_RE, SHOPIFY_API_PROXY_PREFIX, SHOPIFY_API_PROXY_RE, WELL_KNOWN_RE, isHydrogenServerHandoffPath, normalizeStoreDomain };
|
|
42
|
+
export { AJAX_CART_RE, CHECKOUT_RE, CUSTOMER_ACCOUNT_PATHS, MCP_RE, SFAPI_RE, SHOPIFY_API_PROXY_PREFIX, SHOPIFY_API_PROXY_RE, UCP_MCP_RE, WELL_KNOWN_RE, isHydrogenServerHandoffPath, normalizeStoreDomain };
|
|
42
43
|
//# sourceMappingURL=url.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.mjs","names":[],"sources":["../../../src/core/url.ts"],"sourcesContent":["export const SFAPI_RE = /^\\/api\\/(unstable|2\\d{3}-\\d{2})\\/graphql\\.json$/;\nexport const SHOPIFY_API_PROXY_PREFIX = \"/__shopify\";\nexport const SHOPIFY_API_PROXY_RE = /^\\/__shopify(?:\\/|$)/;\nexport const MCP_RE = /^\\/api\\/mcp$/;\nexport const CHECKOUT_RE = /^\\/checkout$/;\nexport const CART_PERMALINK_RE = /^\\/cart\\/\\d+:\\d+(?:,\\d+:\\d+)*$/;\nexport const CUSTOMER_ACCOUNT_PATHS = {\n authorize: \"/account/authorize\",\n login: \"/account/login\",\n logout: \"/account/logout\",\n refresh: \"/account/refresh\",\n} as const;\n\nconst CUSTOMER_ACCOUNT_HANDOFF_PATHS: ReadonlySet<string> = new Set(\n Object.values(CUSTOMER_ACCOUNT_PATHS),\n);\n\n/**\n * Returns whether the pathname conventionally represents a Hydrogen document-level server handoff.\n *\n * Keep this aligned with the routes intercepted before framework routing. API and protocol\n * interceptors are intentionally excluded because they are not browser navigation destinations.\n */\nexport function isHydrogenServerHandoffPath(pathname: string): boolean {\n return (\n CHECKOUT_RE.test(pathname) ||\n CART_PERMALINK_RE.test(pathname) ||\n CUSTOMER_ACCOUNT_HANDOFF_PATHS.has(pathname)\n );\n}\n\n/**\n * Allowlisted `.well-known` resources proxied to the Online Store origin:\n * - `apple-developer-merchantid-domain-association` — Apple Pay domain verification.\n * - `shopify/fec/produce` — Frontend Event Collector ingress. On the Online\n * Store the myshopify.com edge forwards this first-party path to the\n * collector; headless storefronts have no such edge, so Hydrogen proxies it\n * to the same origin (used by WebMCP's Event Refinery client).\n */\nexport const WELL_KNOWN_RE =\n /^\\/\\.well-known\\/(?:apple-developer-merchantid-domain-association|shopify\\/fec\\/produce)$/;\nexport const AJAX_CART_RE =\n /^(?:\\/[a-z]{2}(?:-[a-z]{2})?)?\\/cart(?:\\.(?:js|json)|\\/(?:add|update|change|clear)(?:\\.(?:js|json))?)$/i;\n\nexport function normalizeStoreDomain(domain: string): string {\n if (!domain) {\n throw new Error(\"Storefront `storeDomain` is required.\");\n }\n\n if (domain.startsWith(\"http://\") || domain.startsWith(\"https://\")) {\n return domain.replace(/\\/+$/, \"\");\n }\n return `https://${domain}`.replace(/\\/+$/, \"\");\n}\n"],"mappings":";AAAA,MAAa,WAAW;AACxB,MAAa,2BAA2B;AACxC,MAAa,uBAAuB;AACpC,MAAa,SAAS;AACtB,MAAa,cAAc;AAC3B,MAAa,oBAAoB;AACjC,MAAa,yBAAyB;CACpC,WAAW;CACX,OAAO;CACP,QAAQ;CACR,SAAS;CACV;AAED,MAAM,iCAAsD,IAAI,IAC9D,OAAO,OAAO,uBAAuB,CACtC;;;;;;;AAQD,SAAgB,4BAA4B,UAA2B;AACrE,QACE,YAAY,KAAK,SAAS,IAC1B,kBAAkB,KAAK,SAAS,IAChC,+BAA+B,IAAI,SAAS;;;;;;;;;;AAYhD,MAAa,gBACX;AACF,MAAa,eACX;AAEF,SAAgB,qBAAqB,QAAwB;AAC3D,KAAI,CAAC,OACH,OAAM,IAAI,MAAM,wCAAwC;AAG1D,KAAI,OAAO,WAAW,UAAU,IAAI,OAAO,WAAW,WAAW,CAC/D,QAAO,OAAO,QAAQ,QAAQ,GAAG;AAEnC,QAAO,WAAW,SAAS,QAAQ,QAAQ,GAAG"}
|
|
1
|
+
{"version":3,"file":"url.mjs","names":[],"sources":["../../../src/core/url.ts"],"sourcesContent":["export const SFAPI_RE = /^\\/api\\/(unstable|2\\d{3}-\\d{2})\\/graphql\\.json$/;\nexport const SHOPIFY_API_PROXY_PREFIX = \"/__shopify\";\nexport const SHOPIFY_API_PROXY_RE = /^\\/__shopify(?:\\/|$)/;\nexport const MCP_RE = /^\\/api\\/mcp$/;\nexport const UCP_MCP_RE = /^\\/api\\/ucp\\/mcp$/;\nexport const CHECKOUT_RE = /^\\/checkout$/;\nexport const CART_PERMALINK_RE = /^\\/cart\\/\\d+:\\d+(?:,\\d+:\\d+)*$/;\nexport const CUSTOMER_ACCOUNT_PATHS = {\n authorize: \"/account/authorize\",\n login: \"/account/login\",\n logout: \"/account/logout\",\n refresh: \"/account/refresh\",\n} as const;\n\nconst CUSTOMER_ACCOUNT_HANDOFF_PATHS: ReadonlySet<string> = new Set(\n Object.values(CUSTOMER_ACCOUNT_PATHS),\n);\n\n/**\n * Returns whether the pathname conventionally represents a Hydrogen document-level server handoff.\n *\n * Keep this aligned with the routes intercepted before framework routing. API and protocol\n * interceptors are intentionally excluded because they are not browser navigation destinations.\n */\nexport function isHydrogenServerHandoffPath(pathname: string): boolean {\n return (\n CHECKOUT_RE.test(pathname) ||\n CART_PERMALINK_RE.test(pathname) ||\n CUSTOMER_ACCOUNT_HANDOFF_PATHS.has(pathname)\n );\n}\n\n/**\n * Allowlisted `.well-known` resources proxied to the Online Store origin:\n * - `apple-developer-merchantid-domain-association` — Apple Pay domain verification.\n * - `shopify/fec/produce` — Frontend Event Collector ingress. On the Online\n * Store the myshopify.com edge forwards this first-party path to the\n * collector; headless storefronts have no such edge, so Hydrogen proxies it\n * to the same origin (used by WebMCP's Event Refinery client).\n */\nexport const WELL_KNOWN_RE =\n /^\\/\\.well-known\\/(?:apple-developer-merchantid-domain-association|shopify\\/fec\\/produce)$/;\nexport const AJAX_CART_RE =\n /^(?:\\/[a-z]{2}(?:-[a-z]{2})?)?\\/cart(?:\\.(?:js|json)|\\/(?:add|update|change|clear)(?:\\.(?:js|json))?)$/i;\n\nexport function normalizeStoreDomain(domain: string): string {\n if (!domain) {\n throw new Error(\"Storefront `storeDomain` is required.\");\n }\n\n if (domain.startsWith(\"http://\") || domain.startsWith(\"https://\")) {\n return domain.replace(/\\/+$/, \"\");\n }\n return `https://${domain}`.replace(/\\/+$/, \"\");\n}\n"],"mappings":";AAAA,MAAa,WAAW;AACxB,MAAa,2BAA2B;AACxC,MAAa,uBAAuB;AACpC,MAAa,SAAS;AACtB,MAAa,aAAa;AAC1B,MAAa,cAAc;AAC3B,MAAa,oBAAoB;AACjC,MAAa,yBAAyB;CACpC,WAAW;CACX,OAAO;CACP,QAAQ;CACR,SAAS;CACV;AAED,MAAM,iCAAsD,IAAI,IAC9D,OAAO,OAAO,uBAAuB,CACtC;;;;;;;AAQD,SAAgB,4BAA4B,UAA2B;AACrE,QACE,YAAY,KAAK,SAAS,IAC1B,kBAAkB,KAAK,SAAS,IAChC,+BAA+B,IAAI,SAAS;;;;;;;;;;AAYhD,MAAa,gBACX;AACF,MAAa,eACX;AAEF,SAAgB,qBAAqB,QAAwB;AAC3D,KAAI,CAAC,OACH,OAAM,IAAI,MAAM,wCAAwC;AAG1D,KAAI,OAAO,WAAW,UAAU,IAAI,OAAO,WAAW,WAAW,CAC/D,QAAO,OAAO,QAAQ,QAAQ,GAAG;AAEnC,QAAO,WAAW,SAAS,QAAQ,QAAQ,GAAG"}
|
|
@@ -23,9 +23,11 @@ type ShopifyGlobal = {
|
|
|
23
23
|
customerPrivacy: {
|
|
24
24
|
config?: {
|
|
25
25
|
isHeadless?: boolean;
|
|
26
|
+
asyncConsent?: boolean;
|
|
27
|
+
asyncVisitorState?: boolean;
|
|
26
28
|
consentDomain?: string;
|
|
27
29
|
};
|
|
28
|
-
consentStatus?: "
|
|
30
|
+
consentStatus?: "loading" | "loaded";
|
|
29
31
|
currentVisitorConsent: () => Record<string, unknown>;
|
|
30
32
|
preferencesProcessingAllowed: () => boolean;
|
|
31
33
|
saleOfDataAllowed: () => boolean;
|
|
@@ -35,6 +37,7 @@ type ShopifyGlobal = {
|
|
|
35
37
|
error: string;
|
|
36
38
|
} | undefined) => void) => void | Promise<unknown>;
|
|
37
39
|
shouldShowBanner: () => boolean;
|
|
40
|
+
shouldShowGDPRBanner: () => boolean;
|
|
38
41
|
};
|
|
39
42
|
locale: Lowercase<I18nConfig["language"]> | string; /** @deprecated Use `Shopify.routes.navigate` instead. */
|
|
40
43
|
navigate?: (url: string) => void | Promise<void>;
|
|
@@ -3,11 +3,11 @@ import { ShopifyGlobal } from "../globals.mjs";
|
|
|
3
3
|
import { QuantityInputAttributes, SetButtonAttributes } from "../core/cart/form.mjs";
|
|
4
4
|
import { CollectionData } from "../core/collection/collection.mjs";
|
|
5
5
|
import { ValidProductSelectionResult } from "../core/product/product-form.mjs";
|
|
6
|
-
import { ProductAddToCartProps, ProductFormRegister, ProductMerchandiseIdProps, ProductOptionValueProps, ProductQuantityDefaultProps, ProductQuantityProps } from "../core/product/form.mjs";
|
|
6
|
+
import { ProductAddToCartProps, ProductAttributeDefaultValueProps, ProductAttributeValueProps, ProductFormRegister, ProductMerchandiseIdProps, ProductOptionValueProps, ProductQuantityDefaultProps, ProductQuantityProps } from "../core/product/form.mjs";
|
|
7
7
|
import { CartActions, CartProvider, createCartComponents, useCart, useCartActions, useCartAnalytics, useCartForm } from "./cart.mjs";
|
|
8
8
|
import { CollectionActions, CollectionProvider, CollectionProviderProps, useCollection, useCollectionActions, useCollectionForm } from "./collection.mjs";
|
|
9
9
|
import { PredictiveSearchActions, PredictiveSearchFormPropsOptions, PredictiveSearchFormRegister, PredictiveSearchFormResult, PredictiveSearchProvider, PredictiveSearchProviderProps, PredictiveSearchQueryInputPropsOptions, usePredictiveSearch, usePredictiveSearchActions, usePredictiveSearchForm } from "./predictive-search.mjs";
|
|
10
10
|
import { ProductProviderProps, UseProductFormOptions, UseProductFormResult, UseProductResult, createProductComponents, useProductForm } from "./product.mjs";
|
|
11
11
|
import { ShopPayButton, ShopPayButtonProps } from "./shop-pay.mjs";
|
|
12
12
|
import { ShopifyScripts, ShopifyScriptsProps } from "./shopify-scripts.mjs";
|
|
13
|
-
export { type CartActions, CartProvider, type CollectionActions, type CollectionData, CollectionProvider, type CollectionProviderProps, type PredictiveSearchActions, type PredictiveSearchFormPropsOptions, type PredictiveSearchFormRegister, type PredictiveSearchFormResult, PredictiveSearchProvider, type PredictiveSearchProviderProps, type PredictiveSearchQueryInputPropsOptions, type ProductAddToCartProps, type ProductFormRegister, type ProductMerchandiseIdProps, type ProductOptionValueProps, type ProductProviderProps, type ProductQuantityDefaultProps, type ProductQuantityProps, type QuantityInputAttributes, type SetButtonAttributes, ShopPayButton, type ShopPayButtonProps, type ShopifyGlobal, ShopifyScripts, type ShopifyScriptsProps, type ShopifyStandardActions, type UseProductFormOptions, type UseProductFormResult, type UseProductResult, type ValidProductSelectionResult, createCartComponents, createProductComponents, useCart, useCartActions, useCartAnalytics, useCartForm, useCollection, useCollectionActions, useCollectionForm, usePredictiveSearch, usePredictiveSearchActions, usePredictiveSearchForm, useProductForm };
|
|
13
|
+
export { type CartActions, CartProvider, type CollectionActions, type CollectionData, CollectionProvider, type CollectionProviderProps, type PredictiveSearchActions, type PredictiveSearchFormPropsOptions, type PredictiveSearchFormRegister, type PredictiveSearchFormResult, PredictiveSearchProvider, type PredictiveSearchProviderProps, type PredictiveSearchQueryInputPropsOptions, type ProductAddToCartProps, type ProductAttributeDefaultValueProps, type ProductAttributeValueProps, type ProductFormRegister, type ProductMerchandiseIdProps, type ProductOptionValueProps, type ProductProviderProps, type ProductQuantityDefaultProps, type ProductQuantityProps, type QuantityInputAttributes, type SetButtonAttributes, ShopPayButton, type ShopPayButtonProps, type ShopifyGlobal, ShopifyScripts, type ShopifyScriptsProps, type ShopifyStandardActions, type UseProductFormOptions, type UseProductFormResult, type UseProductResult, type ValidProductSelectionResult, createCartComponents, createProductComponents, useCart, useCartActions, useCartAnalytics, useCartForm, useCollection, useCollectionActions, useCollectionForm, usePredictiveSearch, usePredictiveSearchActions, usePredictiveSearchForm, useProductForm };
|
|
@@ -49,6 +49,10 @@ declare const ShopifyScripts: _$vue.DefineComponent<_$vue.ExtractPropTypes<{
|
|
|
49
49
|
type: () => boolean | undefined;
|
|
50
50
|
default: undefined;
|
|
51
51
|
};
|
|
52
|
+
account: {
|
|
53
|
+
type: () => boolean | undefined;
|
|
54
|
+
default: undefined;
|
|
55
|
+
};
|
|
52
56
|
shopifyAnalytics: {
|
|
53
57
|
type: BooleanConstructor;
|
|
54
58
|
default: undefined;
|
|
@@ -100,6 +104,10 @@ declare const ShopifyScripts: _$vue.DefineComponent<_$vue.ExtractPropTypes<{
|
|
|
100
104
|
type: () => boolean | undefined;
|
|
101
105
|
default: undefined;
|
|
102
106
|
};
|
|
107
|
+
account: {
|
|
108
|
+
type: () => boolean | undefined;
|
|
109
|
+
default: undefined;
|
|
110
|
+
};
|
|
103
111
|
shopifyAnalytics: {
|
|
104
112
|
type: BooleanConstructor;
|
|
105
113
|
default: undefined;
|
|
@@ -110,6 +118,7 @@ declare const ShopifyScripts: _$vue.DefineComponent<_$vue.ExtractPropTypes<{
|
|
|
110
118
|
};
|
|
111
119
|
}>> & Readonly<{}>, {
|
|
112
120
|
nonce: string;
|
|
121
|
+
account: boolean | undefined;
|
|
113
122
|
analytics: ShopifyScriptsAnalyticsConfig | undefined;
|
|
114
123
|
consent: ConsentConfig | undefined;
|
|
115
124
|
debug: {
|
|
@@ -11,6 +11,7 @@ const consentProp = Object;
|
|
|
11
11
|
const analyticsProp = Object;
|
|
12
12
|
const debugProp = Object;
|
|
13
13
|
const inboxProp = Boolean;
|
|
14
|
+
const accountProp = Boolean;
|
|
14
15
|
const ShopifyScripts = defineComponent({
|
|
15
16
|
name: "ShopifyScripts",
|
|
16
17
|
props: {
|
|
@@ -50,6 +51,10 @@ const ShopifyScripts = defineComponent({
|
|
|
50
51
|
type: inboxProp,
|
|
51
52
|
default: void 0
|
|
52
53
|
},
|
|
54
|
+
account: {
|
|
55
|
+
type: accountProp,
|
|
56
|
+
default: void 0
|
|
57
|
+
},
|
|
53
58
|
shopifyAnalytics: {
|
|
54
59
|
type: Boolean,
|
|
55
60
|
default: void 0
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shopify-scripts.mjs","names":[],"sources":["../../../src/vue/shopify-scripts.ts"],"sourcesContent":["import { defineComponent, h, onMounted, type PropType } from \"vue\";\n\nimport {\n getShopifyScriptTags,\n initializeShopifyScripts,\n type ShopifyScriptsShop,\n type ShopifyScriptsI18n,\n type ShopifyScriptTagsOptions,\n type ShopifyRoutesOptions,\n} from \"../core/shopify-scripts/index\";\n\nexport type ShopifyScriptsProps = ShopifyScriptTagsOptions & {\n navigate?: ShopifyRoutesOptions[\"navigate\"];\n routes?: ShopifyRoutesOptions[\"routes\"];\n webMcp?: boolean;\n};\n\ntype CompletePropOptions<T> = {\n [K in keyof T]-?: unknown;\n};\n\nconst i18nProp: PropType<ShopifyScriptsI18n> = Object;\nconst navigateProp: PropType<NonNullable<ShopifyRoutesOptions[\"navigate\"]>> | null = null;\nconst routesProp: PropType<NonNullable<ShopifyRoutesOptions[\"routes\"]>> | null = null;\nconst shopProp: PropType<ShopifyScriptsShop> = Object;\nconst consentProp: PropType<ShopifyScriptTagsOptions[\"consent\"]> = Object;\nconst analyticsProp: PropType<ShopifyScriptTagsOptions[\"analytics\"]> = Object;\nconst debugProp: PropType<ShopifyScriptTagsOptions[\"debug\"]> = Object;\nconst inboxProp: PropType<ShopifyScriptTagsOptions[\"inbox\"]> = Boolean;\n\nexport const ShopifyScripts = defineComponent({\n name: \"ShopifyScripts\",\n props: {\n i18n: {\n type: i18nProp,\n default: undefined,\n },\n nonce: {\n type: String,\n default: undefined,\n },\n routes: {\n type: routesProp,\n default: undefined,\n },\n navigate: {\n type: navigateProp,\n default: undefined,\n },\n consent: {\n type: consentProp,\n default: undefined,\n },\n analytics: {\n type: analyticsProp,\n default: undefined,\n },\n debug: {\n type: debugProp,\n default: undefined,\n },\n webMcp: {\n type: Boolean,\n default: undefined,\n },\n inbox: {\n type: inboxProp,\n default: undefined,\n },\n shopifyAnalytics: {\n type: Boolean,\n default: undefined,\n },\n shop: {\n type: shopProp,\n required: true as const,\n },\n } satisfies CompletePropOptions<ShopifyScriptsProps>,\n setup(props) {\n onMounted(() => {\n void initializeShopifyScripts({\n navigate: props.navigate,\n routes: props.routes,\n webMcp: props.webMcp !== false,\n });\n });\n\n return () =>\n getShopifyScriptTags(props).tags.map(({ tagName, attributes, innerHTML }) =>\n h(tagName, {\n ...attributes,\n ...(innerHTML ? { innerHTML } : {}),\n }),\n );\n },\n});\n"],"mappings":";;;;;AAqBA,MAAM,WAAyC;AAC/C,MAAM,eAA+E;AACrF,MAAM,aAA2E;AACjF,MAAM,WAAyC;AAC/C,MAAM,cAA6D;AACnE,MAAM,gBAAiE;AACvE,MAAM,YAAyD;AAC/D,MAAM,YAAyD;
|
|
1
|
+
{"version":3,"file":"shopify-scripts.mjs","names":[],"sources":["../../../src/vue/shopify-scripts.ts"],"sourcesContent":["import { defineComponent, h, onMounted, type PropType } from \"vue\";\n\nimport {\n getShopifyScriptTags,\n initializeShopifyScripts,\n type ShopifyScriptsShop,\n type ShopifyScriptsI18n,\n type ShopifyScriptTagsOptions,\n type ShopifyRoutesOptions,\n} from \"../core/shopify-scripts/index\";\n\nexport type ShopifyScriptsProps = ShopifyScriptTagsOptions & {\n navigate?: ShopifyRoutesOptions[\"navigate\"];\n routes?: ShopifyRoutesOptions[\"routes\"];\n webMcp?: boolean;\n};\n\ntype CompletePropOptions<T> = {\n [K in keyof T]-?: unknown;\n};\n\nconst i18nProp: PropType<ShopifyScriptsI18n> = Object;\nconst navigateProp: PropType<NonNullable<ShopifyRoutesOptions[\"navigate\"]>> | null = null;\nconst routesProp: PropType<NonNullable<ShopifyRoutesOptions[\"routes\"]>> | null = null;\nconst shopProp: PropType<ShopifyScriptsShop> = Object;\nconst consentProp: PropType<ShopifyScriptTagsOptions[\"consent\"]> = Object;\nconst analyticsProp: PropType<ShopifyScriptTagsOptions[\"analytics\"]> = Object;\nconst debugProp: PropType<ShopifyScriptTagsOptions[\"debug\"]> = Object;\nconst inboxProp: PropType<ShopifyScriptTagsOptions[\"inbox\"]> = Boolean;\nconst accountProp: PropType<ShopifyScriptTagsOptions[\"account\"]> = Boolean;\n\nexport const ShopifyScripts = defineComponent({\n name: \"ShopifyScripts\",\n props: {\n i18n: {\n type: i18nProp,\n default: undefined,\n },\n nonce: {\n type: String,\n default: undefined,\n },\n routes: {\n type: routesProp,\n default: undefined,\n },\n navigate: {\n type: navigateProp,\n default: undefined,\n },\n consent: {\n type: consentProp,\n default: undefined,\n },\n analytics: {\n type: analyticsProp,\n default: undefined,\n },\n debug: {\n type: debugProp,\n default: undefined,\n },\n webMcp: {\n type: Boolean,\n default: undefined,\n },\n inbox: {\n type: inboxProp,\n default: undefined,\n },\n account: {\n type: accountProp,\n default: undefined,\n },\n shopifyAnalytics: {\n type: Boolean,\n default: undefined,\n },\n shop: {\n type: shopProp,\n required: true as const,\n },\n } satisfies CompletePropOptions<ShopifyScriptsProps>,\n setup(props) {\n onMounted(() => {\n void initializeShopifyScripts({\n navigate: props.navigate,\n routes: props.routes,\n webMcp: props.webMcp !== false,\n });\n });\n\n return () =>\n getShopifyScriptTags(props).tags.map(({ tagName, attributes, innerHTML }) =>\n h(tagName, {\n ...attributes,\n ...(innerHTML ? { innerHTML } : {}),\n }),\n );\n },\n});\n"],"mappings":";;;;;AAqBA,MAAM,WAAyC;AAC/C,MAAM,eAA+E;AACrF,MAAM,aAA2E;AACjF,MAAM,WAAyC;AAC/C,MAAM,cAA6D;AACnE,MAAM,gBAAiE;AACvE,MAAM,YAAyD;AAC/D,MAAM,YAAyD;AAC/D,MAAM,cAA6D;AAEnE,MAAa,iBAAiB,gBAAgB;CAC5C,MAAM;CACN,OAAO;EACL,MAAM;GACJ,MAAM;GACN,SAAS;GACV;EACD,OAAO;GACL,MAAM;GACN,SAAS;GACV;EACD,QAAQ;GACN,MAAM;GACN,SAAS;GACV;EACD,UAAU;GACR,MAAM;GACN,SAAS;GACV;EACD,SAAS;GACP,MAAM;GACN,SAAS;GACV;EACD,WAAW;GACT,MAAM;GACN,SAAS;GACV;EACD,OAAO;GACL,MAAM;GACN,SAAS;GACV;EACD,QAAQ;GACN,MAAM;GACN,SAAS;GACV;EACD,OAAO;GACL,MAAM;GACN,SAAS;GACV;EACD,SAAS;GACP,MAAM;GACN,SAAS;GACV;EACD,kBAAkB;GAChB,MAAM;GACN,SAAS;GACV;EACD,MAAM;GACJ,MAAM;GACN,UAAU;GACX;EACF;CACD,MAAM,OAAO;AACX,kBAAgB;AACd,GAAK,yBAAyB;IAC5B,UAAU,MAAM;IAChB,QAAQ,MAAM;IACd,QAAQ,MAAM,WAAW;IAC1B,CAAC;IACF;AAEF,eACE,qBAAqB,MAAM,CAAC,KAAK,KAAK,EAAE,SAAS,YAAY,gBAC3D,EAAE,SAAS;GACT,GAAG;GACH,GAAI,YAAY,EAAE,WAAW,GAAG,EAAE;GACnC,CAAC,CACH;;CAEN,CAAC"}
|
package/dist/globals.d.mts
CHANGED
|
@@ -23,9 +23,11 @@ type ShopifyGlobal = {
|
|
|
23
23
|
customerPrivacy: {
|
|
24
24
|
config?: {
|
|
25
25
|
isHeadless?: boolean;
|
|
26
|
+
asyncConsent?: boolean;
|
|
27
|
+
asyncVisitorState?: boolean;
|
|
26
28
|
consentDomain?: string;
|
|
27
29
|
};
|
|
28
|
-
consentStatus?: "
|
|
30
|
+
consentStatus?: "loading" | "loaded";
|
|
29
31
|
currentVisitorConsent: () => Record<string, unknown>;
|
|
30
32
|
preferencesProcessingAllowed: () => boolean;
|
|
31
33
|
saleOfDataAllowed: () => boolean;
|
|
@@ -35,6 +37,7 @@ type ShopifyGlobal = {
|
|
|
35
37
|
error: string;
|
|
36
38
|
} | undefined) => void) => void | Promise<unknown>;
|
|
37
39
|
shouldShowBanner: () => boolean;
|
|
40
|
+
shouldShowGDPRBanner: () => boolean;
|
|
38
41
|
};
|
|
39
42
|
locale: Lowercase<I18nConfig["language"]> | string; /** @deprecated Use `Shopify.routes.navigate` instead. */
|
|
40
43
|
navigate?: (url: string) => void | Promise<void>;
|
package/dist/react/index.d.mts
CHANGED
|
@@ -3,11 +3,11 @@ import { ShopifyGlobal } from "../globals.mjs";
|
|
|
3
3
|
import { QuantityInputAttributes, SetButtonAttributes } from "../core/cart/form.mjs";
|
|
4
4
|
import { CollectionData } from "../core/collection/collection.mjs";
|
|
5
5
|
import { ValidProductSelectionResult } from "../core/product/product-form.mjs";
|
|
6
|
-
import { ProductAddToCartProps, ProductFormRegister, ProductMerchandiseIdProps, ProductOptionValueProps, ProductQuantityDefaultProps, ProductQuantityProps } from "../core/product/form.mjs";
|
|
6
|
+
import { ProductAddToCartProps, ProductAttributeDefaultValueProps, ProductAttributeValueProps, ProductFormRegister, ProductMerchandiseIdProps, ProductOptionValueProps, ProductQuantityDefaultProps, ProductQuantityProps } from "../core/product/form.mjs";
|
|
7
7
|
import { CartActions, CartProvider, createCartComponents, useCart, useCartActions, useCartAnalytics, useCartForm } from "./cart.mjs";
|
|
8
8
|
import { CollectionActions, CollectionProvider, CollectionProviderProps, useCollection, useCollectionActions, useCollectionForm } from "./collection.mjs";
|
|
9
9
|
import { PredictiveSearchActions, PredictiveSearchFormPropsOptions, PredictiveSearchFormRegister, PredictiveSearchFormResult, PredictiveSearchProvider, PredictiveSearchProviderProps, PredictiveSearchQueryInputPropsOptions, usePredictiveSearch, usePredictiveSearchActions, usePredictiveSearchForm } from "./predictive-search.mjs";
|
|
10
10
|
import { ProductProviderProps, UseProductFormOptions, UseProductFormResult, UseProductResult, createProductComponents, useProductForm } from "./product.mjs";
|
|
11
11
|
import { ShopPayButton, ShopPayButtonProps } from "./shop-pay.mjs";
|
|
12
12
|
import { ShopifyScripts, ShopifyScriptsProps } from "./shopify-scripts.mjs";
|
|
13
|
-
export { type CartActions, CartProvider, type CollectionActions, type CollectionData, CollectionProvider, type CollectionProviderProps, type PredictiveSearchActions, type PredictiveSearchFormPropsOptions, type PredictiveSearchFormRegister, type PredictiveSearchFormResult, PredictiveSearchProvider, type PredictiveSearchProviderProps, type PredictiveSearchQueryInputPropsOptions, type ProductAddToCartProps, type ProductFormRegister, type ProductMerchandiseIdProps, type ProductOptionValueProps, type ProductProviderProps, type ProductQuantityDefaultProps, type ProductQuantityProps, type QuantityInputAttributes, type SetButtonAttributes, ShopPayButton, type ShopPayButtonProps, type ShopifyGlobal, ShopifyScripts, type ShopifyScriptsProps, type ShopifyStandardActions, type UseProductFormOptions, type UseProductFormResult, type UseProductResult, type ValidProductSelectionResult, createCartComponents, createProductComponents, useCart, useCartActions, useCartAnalytics, useCartForm, useCollection, useCollectionActions, useCollectionForm, usePredictiveSearch, usePredictiveSearchActions, usePredictiveSearchForm, useProductForm };
|
|
13
|
+
export { type CartActions, CartProvider, type CollectionActions, type CollectionData, CollectionProvider, type CollectionProviderProps, type PredictiveSearchActions, type PredictiveSearchFormPropsOptions, type PredictiveSearchFormRegister, type PredictiveSearchFormResult, PredictiveSearchProvider, type PredictiveSearchProviderProps, type PredictiveSearchQueryInputPropsOptions, type ProductAddToCartProps, type ProductAttributeDefaultValueProps, type ProductAttributeValueProps, type ProductFormRegister, type ProductMerchandiseIdProps, type ProductOptionValueProps, type ProductProviderProps, type ProductQuantityDefaultProps, type ProductQuantityProps, type QuantityInputAttributes, type SetButtonAttributes, ShopPayButton, type ShopPayButtonProps, type ShopifyGlobal, ShopifyScripts, type ShopifyScriptsProps, type ShopifyStandardActions, type UseProductFormOptions, type UseProductFormResult, type UseProductResult, type ValidProductSelectionResult, createCartComponents, createProductComponents, useCart, useCartActions, useCartAnalytics, useCartForm, useCollection, useCollectionActions, useCollectionForm, usePredictiveSearch, usePredictiveSearchActions, usePredictiveSearchForm, useProductForm };
|
|
@@ -49,6 +49,10 @@ declare const ShopifyScripts: _$vue.DefineComponent<_$vue.ExtractPropTypes<{
|
|
|
49
49
|
type: () => boolean | undefined;
|
|
50
50
|
default: undefined;
|
|
51
51
|
};
|
|
52
|
+
account: {
|
|
53
|
+
type: () => boolean | undefined;
|
|
54
|
+
default: undefined;
|
|
55
|
+
};
|
|
52
56
|
shopifyAnalytics: {
|
|
53
57
|
type: BooleanConstructor;
|
|
54
58
|
default: undefined;
|
|
@@ -100,6 +104,10 @@ declare const ShopifyScripts: _$vue.DefineComponent<_$vue.ExtractPropTypes<{
|
|
|
100
104
|
type: () => boolean | undefined;
|
|
101
105
|
default: undefined;
|
|
102
106
|
};
|
|
107
|
+
account: {
|
|
108
|
+
type: () => boolean | undefined;
|
|
109
|
+
default: undefined;
|
|
110
|
+
};
|
|
103
111
|
shopifyAnalytics: {
|
|
104
112
|
type: BooleanConstructor;
|
|
105
113
|
default: undefined;
|
|
@@ -109,6 +117,8 @@ declare const ShopifyScripts: _$vue.DefineComponent<_$vue.ExtractPropTypes<{
|
|
|
109
117
|
required: true;
|
|
110
118
|
};
|
|
111
119
|
}>> & Readonly<{}>, {
|
|
120
|
+
nonce: string;
|
|
121
|
+
account: boolean | undefined;
|
|
112
122
|
analytics: ShopifyScriptsAnalyticsConfig | undefined;
|
|
113
123
|
consent: ConsentConfig | undefined;
|
|
114
124
|
debug: {
|
|
@@ -116,7 +126,6 @@ declare const ShopifyScripts: _$vue.DefineComponent<_$vue.ExtractPropTypes<{
|
|
|
116
126
|
} | undefined;
|
|
117
127
|
i18n: ShopifyScriptsI18n;
|
|
118
128
|
inbox: boolean | undefined;
|
|
119
|
-
nonce: string;
|
|
120
129
|
shopifyAnalytics: boolean;
|
|
121
130
|
navigate: any;
|
|
122
131
|
routes: any;
|
|
@@ -11,6 +11,7 @@ const consentProp = Object;
|
|
|
11
11
|
const analyticsProp = Object;
|
|
12
12
|
const debugProp = Object;
|
|
13
13
|
const inboxProp = Boolean;
|
|
14
|
+
const accountProp = Boolean;
|
|
14
15
|
const ShopifyScripts = defineComponent({
|
|
15
16
|
name: "ShopifyScripts",
|
|
16
17
|
props: {
|
|
@@ -50,6 +51,10 @@ const ShopifyScripts = defineComponent({
|
|
|
50
51
|
type: inboxProp,
|
|
51
52
|
default: void 0
|
|
52
53
|
},
|
|
54
|
+
account: {
|
|
55
|
+
type: accountProp,
|
|
56
|
+
default: void 0
|
|
57
|
+
},
|
|
53
58
|
shopifyAnalytics: {
|
|
54
59
|
type: Boolean,
|
|
55
60
|
default: void 0
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shopify-scripts.mjs","names":[],"sources":["../../src/vue/shopify-scripts.ts"],"sourcesContent":["import { defineComponent, h, onMounted, type PropType } from \"vue\";\n\nimport {\n getShopifyScriptTags,\n initializeShopifyScripts,\n type ShopifyScriptsShop,\n type ShopifyScriptsI18n,\n type ShopifyScriptTagsOptions,\n type ShopifyRoutesOptions,\n} from \"../core/shopify-scripts/index\";\n\nexport type ShopifyScriptsProps = ShopifyScriptTagsOptions & {\n navigate?: ShopifyRoutesOptions[\"navigate\"];\n routes?: ShopifyRoutesOptions[\"routes\"];\n webMcp?: boolean;\n};\n\ntype CompletePropOptions<T> = {\n [K in keyof T]-?: unknown;\n};\n\nconst i18nProp: PropType<ShopifyScriptsI18n> = Object;\nconst navigateProp: PropType<NonNullable<ShopifyRoutesOptions[\"navigate\"]>> | null = null;\nconst routesProp: PropType<NonNullable<ShopifyRoutesOptions[\"routes\"]>> | null = null;\nconst shopProp: PropType<ShopifyScriptsShop> = Object;\nconst consentProp: PropType<ShopifyScriptTagsOptions[\"consent\"]> = Object;\nconst analyticsProp: PropType<ShopifyScriptTagsOptions[\"analytics\"]> = Object;\nconst debugProp: PropType<ShopifyScriptTagsOptions[\"debug\"]> = Object;\nconst inboxProp: PropType<ShopifyScriptTagsOptions[\"inbox\"]> = Boolean;\n\nexport const ShopifyScripts = defineComponent({\n name: \"ShopifyScripts\",\n props: {\n i18n: {\n type: i18nProp,\n default: undefined,\n },\n nonce: {\n type: String,\n default: undefined,\n },\n routes: {\n type: routesProp,\n default: undefined,\n },\n navigate: {\n type: navigateProp,\n default: undefined,\n },\n consent: {\n type: consentProp,\n default: undefined,\n },\n analytics: {\n type: analyticsProp,\n default: undefined,\n },\n debug: {\n type: debugProp,\n default: undefined,\n },\n webMcp: {\n type: Boolean,\n default: undefined,\n },\n inbox: {\n type: inboxProp,\n default: undefined,\n },\n shopifyAnalytics: {\n type: Boolean,\n default: undefined,\n },\n shop: {\n type: shopProp,\n required: true as const,\n },\n } satisfies CompletePropOptions<ShopifyScriptsProps>,\n setup(props) {\n onMounted(() => {\n void initializeShopifyScripts({\n navigate: props.navigate,\n routes: props.routes,\n webMcp: props.webMcp !== false,\n });\n });\n\n return () =>\n getShopifyScriptTags(props).tags.map(({ tagName, attributes, innerHTML }) =>\n h(tagName, {\n ...attributes,\n ...(innerHTML ? { innerHTML } : {}),\n }),\n );\n },\n});\n"],"mappings":";;;;;AAqBA,MAAM,WAAyC;AAC/C,MAAM,eAA+E;AACrF,MAAM,aAA2E;AACjF,MAAM,WAAyC;AAC/C,MAAM,cAA6D;AACnE,MAAM,gBAAiE;AACvE,MAAM,YAAyD;AAC/D,MAAM,YAAyD;
|
|
1
|
+
{"version":3,"file":"shopify-scripts.mjs","names":[],"sources":["../../src/vue/shopify-scripts.ts"],"sourcesContent":["import { defineComponent, h, onMounted, type PropType } from \"vue\";\n\nimport {\n getShopifyScriptTags,\n initializeShopifyScripts,\n type ShopifyScriptsShop,\n type ShopifyScriptsI18n,\n type ShopifyScriptTagsOptions,\n type ShopifyRoutesOptions,\n} from \"../core/shopify-scripts/index\";\n\nexport type ShopifyScriptsProps = ShopifyScriptTagsOptions & {\n navigate?: ShopifyRoutesOptions[\"navigate\"];\n routes?: ShopifyRoutesOptions[\"routes\"];\n webMcp?: boolean;\n};\n\ntype CompletePropOptions<T> = {\n [K in keyof T]-?: unknown;\n};\n\nconst i18nProp: PropType<ShopifyScriptsI18n> = Object;\nconst navigateProp: PropType<NonNullable<ShopifyRoutesOptions[\"navigate\"]>> | null = null;\nconst routesProp: PropType<NonNullable<ShopifyRoutesOptions[\"routes\"]>> | null = null;\nconst shopProp: PropType<ShopifyScriptsShop> = Object;\nconst consentProp: PropType<ShopifyScriptTagsOptions[\"consent\"]> = Object;\nconst analyticsProp: PropType<ShopifyScriptTagsOptions[\"analytics\"]> = Object;\nconst debugProp: PropType<ShopifyScriptTagsOptions[\"debug\"]> = Object;\nconst inboxProp: PropType<ShopifyScriptTagsOptions[\"inbox\"]> = Boolean;\nconst accountProp: PropType<ShopifyScriptTagsOptions[\"account\"]> = Boolean;\n\nexport const ShopifyScripts = defineComponent({\n name: \"ShopifyScripts\",\n props: {\n i18n: {\n type: i18nProp,\n default: undefined,\n },\n nonce: {\n type: String,\n default: undefined,\n },\n routes: {\n type: routesProp,\n default: undefined,\n },\n navigate: {\n type: navigateProp,\n default: undefined,\n },\n consent: {\n type: consentProp,\n default: undefined,\n },\n analytics: {\n type: analyticsProp,\n default: undefined,\n },\n debug: {\n type: debugProp,\n default: undefined,\n },\n webMcp: {\n type: Boolean,\n default: undefined,\n },\n inbox: {\n type: inboxProp,\n default: undefined,\n },\n account: {\n type: accountProp,\n default: undefined,\n },\n shopifyAnalytics: {\n type: Boolean,\n default: undefined,\n },\n shop: {\n type: shopProp,\n required: true as const,\n },\n } satisfies CompletePropOptions<ShopifyScriptsProps>,\n setup(props) {\n onMounted(() => {\n void initializeShopifyScripts({\n navigate: props.navigate,\n routes: props.routes,\n webMcp: props.webMcp !== false,\n });\n });\n\n return () =>\n getShopifyScriptTags(props).tags.map(({ tagName, attributes, innerHTML }) =>\n h(tagName, {\n ...attributes,\n ...(innerHTML ? { innerHTML } : {}),\n }),\n );\n },\n});\n"],"mappings":";;;;;AAqBA,MAAM,WAAyC;AAC/C,MAAM,eAA+E;AACrF,MAAM,aAA2E;AACjF,MAAM,WAAyC;AAC/C,MAAM,cAA6D;AACnE,MAAM,gBAAiE;AACvE,MAAM,YAAyD;AAC/D,MAAM,YAAyD;AAC/D,MAAM,cAA6D;AAEnE,MAAa,iBAAiB,gBAAgB;CAC5C,MAAM;CACN,OAAO;EACL,MAAM;GACJ,MAAM;GACN,SAAS;GACV;EACD,OAAO;GACL,MAAM;GACN,SAAS;GACV;EACD,QAAQ;GACN,MAAM;GACN,SAAS;GACV;EACD,UAAU;GACR,MAAM;GACN,SAAS;GACV;EACD,SAAS;GACP,MAAM;GACN,SAAS;GACV;EACD,WAAW;GACT,MAAM;GACN,SAAS;GACV;EACD,OAAO;GACL,MAAM;GACN,SAAS;GACV;EACD,QAAQ;GACN,MAAM;GACN,SAAS;GACV;EACD,OAAO;GACL,MAAM;GACN,SAAS;GACV;EACD,SAAS;GACP,MAAM;GACN,SAAS;GACV;EACD,kBAAkB;GAChB,MAAM;GACN,SAAS;GACV;EACD,MAAM;GACJ,MAAM;GACN,UAAU;GACX;EACF;CACD,MAAM,OAAO;AACX,kBAAgB;AACd,GAAK,yBAAyB;IAC5B,UAAU,MAAM;IAChB,QAAQ,MAAM;IACd,QAAQ,MAAM,WAAW;IAC1B,CAAC;IACF;AAEF,eACE,qBAAqB,MAAM,CAAC,KAAK,KAAK,EAAE,SAAS,YAAY,gBAC3D,EAAE,SAAS;GACT,GAAG;GACH,GAAI,YAAY,EAAE,WAAW,GAAG,EAAE;GACnC,CAAC,CACH;;CAEN,CAAC"}
|