@shopify/hydrogen-react 2023.10.0 → 2024.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. package/customer-account.schema.json +37665 -0
  2. package/dist/browser-dev/CartProvider.mjs.map +1 -1
  3. package/dist/browser-dev/ExternalVideo.mjs +41 -34
  4. package/dist/browser-dev/ExternalVideo.mjs.map +1 -1
  5. package/dist/browser-dev/Image.mjs.map +1 -1
  6. package/dist/browser-dev/MediaFile.mjs.map +1 -1
  7. package/dist/browser-dev/ModelViewer.mjs +29 -94
  8. package/dist/browser-dev/ModelViewer.mjs.map +1 -1
  9. package/dist/browser-dev/Money.mjs.map +1 -1
  10. package/dist/browser-dev/ShopPayButton.mjs +22 -1
  11. package/dist/browser-dev/ShopPayButton.mjs.map +1 -1
  12. package/dist/browser-dev/Video.mjs +4 -3
  13. package/dist/browser-dev/Video.mjs.map +1 -1
  14. package/dist/browser-dev/codegen.helpers.mjs +9 -0
  15. package/dist/browser-dev/codegen.helpers.mjs.map +1 -1
  16. package/dist/browser-dev/index.mjs +2 -1
  17. package/dist/browser-dev/node_modules/@xstate/react/es/fsm.mjs +1 -1
  18. package/dist/browser-dev/node_modules/@xstate/react/es/fsm.mjs.map +1 -1
  19. package/dist/browser-dev/node_modules/use-sync-external-store/shim/index.mjs +1 -1
  20. package/dist/browser-dev/node_modules/use-sync-external-store/shim/index.mjs.map +1 -1
  21. package/dist/browser-dev/node_modules/use-sync-external-store/shim/with-selector.mjs +1 -1
  22. package/dist/browser-dev/node_modules/use-sync-external-store/shim/with-selector.mjs.map +1 -1
  23. package/dist/browser-dev/storefront-api-constants.mjs +1 -1
  24. package/dist/browser-dev/storefront-api-constants.mjs.map +1 -1
  25. package/dist/browser-dev/storefront-client.mjs +2 -2
  26. package/dist/browser-dev/storefront-client.mjs.map +1 -1
  27. package/dist/browser-dev/useCartAPIStateMachine.mjs.map +1 -1
  28. package/dist/browser-dev/useCartActions.mjs.map +1 -1
  29. package/dist/browser-prod/CartProvider.mjs.map +1 -1
  30. package/dist/browser-prod/ExternalVideo.mjs +41 -34
  31. package/dist/browser-prod/ExternalVideo.mjs.map +1 -1
  32. package/dist/browser-prod/Image.mjs.map +1 -1
  33. package/dist/browser-prod/MediaFile.mjs.map +1 -1
  34. package/dist/browser-prod/ModelViewer.mjs +29 -94
  35. package/dist/browser-prod/ModelViewer.mjs.map +1 -1
  36. package/dist/browser-prod/Money.mjs.map +1 -1
  37. package/dist/browser-prod/ShopPayButton.mjs +22 -1
  38. package/dist/browser-prod/ShopPayButton.mjs.map +1 -1
  39. package/dist/browser-prod/Video.mjs +4 -3
  40. package/dist/browser-prod/Video.mjs.map +1 -1
  41. package/dist/browser-prod/codegen.helpers.mjs +9 -0
  42. package/dist/browser-prod/codegen.helpers.mjs.map +1 -1
  43. package/dist/browser-prod/index.mjs +2 -1
  44. package/dist/browser-prod/node_modules/@xstate/react/es/fsm.mjs +1 -1
  45. package/dist/browser-prod/node_modules/@xstate/react/es/fsm.mjs.map +1 -1
  46. package/dist/browser-prod/node_modules/use-sync-external-store/shim/index.mjs +1 -1
  47. package/dist/browser-prod/node_modules/use-sync-external-store/shim/index.mjs.map +1 -1
  48. package/dist/browser-prod/node_modules/use-sync-external-store/shim/with-selector.mjs +1 -1
  49. package/dist/browser-prod/node_modules/use-sync-external-store/shim/with-selector.mjs.map +1 -1
  50. package/dist/browser-prod/storefront-api-constants.mjs +1 -1
  51. package/dist/browser-prod/storefront-api-constants.mjs.map +1 -1
  52. package/dist/browser-prod/storefront-client.mjs +1 -1
  53. package/dist/browser-prod/storefront-client.mjs.map +1 -1
  54. package/dist/browser-prod/useCartAPIStateMachine.mjs.map +1 -1
  55. package/dist/browser-prod/useCartActions.mjs.map +1 -1
  56. package/dist/node-dev/CartProvider.js.map +1 -1
  57. package/dist/node-dev/CartProvider.mjs.map +1 -1
  58. package/dist/node-dev/ExternalVideo.js +41 -34
  59. package/dist/node-dev/ExternalVideo.js.map +1 -1
  60. package/dist/node-dev/ExternalVideo.mjs +41 -34
  61. package/dist/node-dev/ExternalVideo.mjs.map +1 -1
  62. package/dist/node-dev/Image.js.map +1 -1
  63. package/dist/node-dev/Image.mjs.map +1 -1
  64. package/dist/node-dev/MediaFile.js.map +1 -1
  65. package/dist/node-dev/MediaFile.mjs.map +1 -1
  66. package/dist/node-dev/ModelViewer.js +29 -94
  67. package/dist/node-dev/ModelViewer.js.map +1 -1
  68. package/dist/node-dev/ModelViewer.mjs +29 -94
  69. package/dist/node-dev/ModelViewer.mjs.map +1 -1
  70. package/dist/node-dev/Money.js.map +1 -1
  71. package/dist/node-dev/Money.mjs.map +1 -1
  72. package/dist/node-dev/ShopPayButton.js +22 -1
  73. package/dist/node-dev/ShopPayButton.js.map +1 -1
  74. package/dist/node-dev/ShopPayButton.mjs +22 -1
  75. package/dist/node-dev/ShopPayButton.mjs.map +1 -1
  76. package/dist/node-dev/Video.js +3 -2
  77. package/dist/node-dev/Video.js.map +1 -1
  78. package/dist/node-dev/Video.mjs +4 -3
  79. package/dist/node-dev/Video.mjs.map +1 -1
  80. package/dist/node-dev/codegen.helpers.js +9 -0
  81. package/dist/node-dev/codegen.helpers.js.map +1 -1
  82. package/dist/node-dev/codegen.helpers.mjs +9 -0
  83. package/dist/node-dev/codegen.helpers.mjs.map +1 -1
  84. package/dist/node-dev/index.js +1 -0
  85. package/dist/node-dev/index.js.map +1 -1
  86. package/dist/node-dev/index.mjs +2 -1
  87. package/dist/node-dev/node_modules/@xstate/react/es/fsm.js +1 -1
  88. package/dist/node-dev/node_modules/@xstate/react/es/fsm.js.map +1 -1
  89. package/dist/node-dev/node_modules/@xstate/react/es/fsm.mjs +1 -1
  90. package/dist/node-dev/node_modules/@xstate/react/es/fsm.mjs.map +1 -1
  91. package/dist/node-dev/node_modules/use-sync-external-store/shim/index.js +1 -1
  92. package/dist/node-dev/node_modules/use-sync-external-store/shim/index.js.map +1 -1
  93. package/dist/node-dev/node_modules/use-sync-external-store/shim/index.mjs +1 -1
  94. package/dist/node-dev/node_modules/use-sync-external-store/shim/index.mjs.map +1 -1
  95. package/dist/node-dev/node_modules/use-sync-external-store/shim/with-selector.js +1 -1
  96. package/dist/node-dev/node_modules/use-sync-external-store/shim/with-selector.js.map +1 -1
  97. package/dist/node-dev/node_modules/use-sync-external-store/shim/with-selector.mjs +1 -1
  98. package/dist/node-dev/node_modules/use-sync-external-store/shim/with-selector.mjs.map +1 -1
  99. package/dist/node-dev/storefront-api-constants.js +1 -1
  100. package/dist/node-dev/storefront-api-constants.js.map +1 -1
  101. package/dist/node-dev/storefront-api-constants.mjs +1 -1
  102. package/dist/node-dev/storefront-api-constants.mjs.map +1 -1
  103. package/dist/node-dev/storefront-client.js +2 -2
  104. package/dist/node-dev/storefront-client.js.map +1 -1
  105. package/dist/node-dev/storefront-client.mjs +2 -2
  106. package/dist/node-dev/storefront-client.mjs.map +1 -1
  107. package/dist/node-dev/useCartAPIStateMachine.js.map +1 -1
  108. package/dist/node-dev/useCartAPIStateMachine.mjs.map +1 -1
  109. package/dist/node-dev/useCartActions.js.map +1 -1
  110. package/dist/node-dev/useCartActions.mjs.map +1 -1
  111. package/dist/node-prod/CartProvider.js.map +1 -1
  112. package/dist/node-prod/CartProvider.mjs.map +1 -1
  113. package/dist/node-prod/ExternalVideo.js +41 -34
  114. package/dist/node-prod/ExternalVideo.js.map +1 -1
  115. package/dist/node-prod/ExternalVideo.mjs +41 -34
  116. package/dist/node-prod/ExternalVideo.mjs.map +1 -1
  117. package/dist/node-prod/Image.js.map +1 -1
  118. package/dist/node-prod/Image.mjs.map +1 -1
  119. package/dist/node-prod/MediaFile.js.map +1 -1
  120. package/dist/node-prod/MediaFile.mjs.map +1 -1
  121. package/dist/node-prod/ModelViewer.js +29 -94
  122. package/dist/node-prod/ModelViewer.js.map +1 -1
  123. package/dist/node-prod/ModelViewer.mjs +29 -94
  124. package/dist/node-prod/ModelViewer.mjs.map +1 -1
  125. package/dist/node-prod/Money.js.map +1 -1
  126. package/dist/node-prod/Money.mjs.map +1 -1
  127. package/dist/node-prod/ShopPayButton.js +22 -1
  128. package/dist/node-prod/ShopPayButton.js.map +1 -1
  129. package/dist/node-prod/ShopPayButton.mjs +22 -1
  130. package/dist/node-prod/ShopPayButton.mjs.map +1 -1
  131. package/dist/node-prod/Video.js +3 -2
  132. package/dist/node-prod/Video.js.map +1 -1
  133. package/dist/node-prod/Video.mjs +4 -3
  134. package/dist/node-prod/Video.mjs.map +1 -1
  135. package/dist/node-prod/codegen.helpers.js +9 -0
  136. package/dist/node-prod/codegen.helpers.js.map +1 -1
  137. package/dist/node-prod/codegen.helpers.mjs +9 -0
  138. package/dist/node-prod/codegen.helpers.mjs.map +1 -1
  139. package/dist/node-prod/index.js +1 -0
  140. package/dist/node-prod/index.js.map +1 -1
  141. package/dist/node-prod/index.mjs +2 -1
  142. package/dist/node-prod/node_modules/@xstate/react/es/fsm.js +1 -1
  143. package/dist/node-prod/node_modules/@xstate/react/es/fsm.js.map +1 -1
  144. package/dist/node-prod/node_modules/@xstate/react/es/fsm.mjs +1 -1
  145. package/dist/node-prod/node_modules/@xstate/react/es/fsm.mjs.map +1 -1
  146. package/dist/node-prod/node_modules/use-sync-external-store/shim/index.js +1 -1
  147. package/dist/node-prod/node_modules/use-sync-external-store/shim/index.js.map +1 -1
  148. package/dist/node-prod/node_modules/use-sync-external-store/shim/index.mjs +1 -1
  149. package/dist/node-prod/node_modules/use-sync-external-store/shim/index.mjs.map +1 -1
  150. package/dist/node-prod/node_modules/use-sync-external-store/shim/with-selector.js +1 -1
  151. package/dist/node-prod/node_modules/use-sync-external-store/shim/with-selector.js.map +1 -1
  152. package/dist/node-prod/node_modules/use-sync-external-store/shim/with-selector.mjs +1 -1
  153. package/dist/node-prod/node_modules/use-sync-external-store/shim/with-selector.mjs.map +1 -1
  154. package/dist/node-prod/storefront-api-constants.js +1 -1
  155. package/dist/node-prod/storefront-api-constants.js.map +1 -1
  156. package/dist/node-prod/storefront-api-constants.mjs +1 -1
  157. package/dist/node-prod/storefront-api-constants.mjs.map +1 -1
  158. package/dist/node-prod/storefront-client.js +1 -1
  159. package/dist/node-prod/storefront-client.js.map +1 -1
  160. package/dist/node-prod/storefront-client.mjs +1 -1
  161. package/dist/node-prod/storefront-client.mjs.map +1 -1
  162. package/dist/node-prod/useCartAPIStateMachine.js.map +1 -1
  163. package/dist/node-prod/useCartAPIStateMachine.mjs.map +1 -1
  164. package/dist/node-prod/useCartActions.js.map +1 -1
  165. package/dist/node-prod/useCartActions.mjs.map +1 -1
  166. package/dist/types/CartProvider.d.ts +2 -2
  167. package/dist/types/ExternalVideo.d.ts +3 -2
  168. package/dist/types/Image.d.ts +1 -1
  169. package/dist/types/ModelViewer.d.ts +1 -1
  170. package/dist/types/Money.d.ts +1 -1
  171. package/dist/types/ShopPayButton.d.ts +8 -2
  172. package/dist/types/Video.d.ts +2 -2
  173. package/dist/types/codegen.helpers.d.ts +14 -1
  174. package/dist/types/index.d.cts +1 -1
  175. package/dist/types/index.d.ts +1 -1
  176. package/dist/types/storefront-api-constants.d.ts +1 -1
  177. package/dist/types/storefront-api-types.d.ts +64 -14
  178. package/dist/types/useCartAPIStateMachine.d.ts +2 -2
  179. package/dist/types/useCartActions.d.ts +2 -2
  180. package/dist/umd/hydrogen-react.dev.js +107 -136
  181. package/dist/umd/hydrogen-react.dev.js.map +1 -1
  182. package/dist/umd/hydrogen-react.prod.js +18 -18
  183. package/dist/umd/hydrogen-react.prod.js.map +1 -1
  184. package/package.json +11 -8
  185. package/storefront.schema.json +1 -1
@@ -405,7 +405,7 @@
405
405
  }
406
406
  return ref.current.v;
407
407
  }
408
- var __read = globalThis && globalThis.__read || function(o2, n2) {
408
+ var __read = function(o2, n2) {
409
409
  var m = typeof Symbol === "function" && o2[Symbol.iterator];
410
410
  if (!m)
411
411
  return o2;
@@ -796,7 +796,8 @@
796
796
  }
797
797
  `
798
798
  );
799
- const SFAPI_VERSION = "2023-10";
799
+ const SFAPI_VERSION = "2024-01";
800
+ const isMockShop = (domain) => domain.includes("mock.shop");
800
801
  function createStorefrontClient(props) {
801
802
  const {
802
803
  storeDomain,
@@ -817,7 +818,7 @@ Received "${storeDomain}".`
817
818
  You may run into unexpected errors if these versions don't match. Received verion: "${storefrontApiVersion}"; expected version "${SFAPI_VERSION}"`
818
819
  );
819
820
  }
820
- if (!privateStorefrontToken && !globalThis.document) {
821
+ if (!privateStorefrontToken && !globalThis.document && !isMockShop(storeDomain)) {
821
822
  warnOnce(
822
823
  `Using a private storefront token is recommended for server environments.
823
824
  Refer to the authentication https://shopify.dev/api/storefront#authentication documentation for more details.`
@@ -828,7 +829,6 @@ Refer to the authentication https://shopify.dev/api/storefront#authentication do
828
829
  "You are attempting to use a private token in an environment where it can be easily accessed by anyone.\nThis is a security risk; please use the public token and the `publicStorefrontToken` prop"
829
830
  );
830
831
  }
831
- const isMockShop = (domain) => domain.includes("mock.shop");
832
832
  const getShopifyDomain = (overrideProps) => {
833
833
  const domain = (overrideProps == null ? void 0 : overrideProps.storeDomain) ?? storeDomain;
834
834
  return domain.includes("://") ? domain : `https://${domain}`;
@@ -2948,42 +2948,56 @@ Refer to the authentication https://shopify.dev/api/storefront#authentication do
2948
2948
  Color: "string",
2949
2949
  UnsignedInt64: "string"
2950
2950
  };
2951
- function ExternalVideo(props) {
2952
- const {
2953
- data,
2954
- options,
2955
- id = data.id,
2956
- frameBorder = "0",
2957
- allow = "accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture",
2958
- allowFullScreen = true,
2959
- loading = "lazy",
2960
- ...passthroughProps
2961
- } = props;
2962
- if (!data.embedUrl) {
2963
- throw new Error(`<ExternalVideo/> requires the 'embedUrl' property`);
2964
- }
2965
- let finalUrl = data.embedUrl;
2966
- if (options) {
2967
- const urlObject = new URL(data.embedUrl);
2968
- for (const key of Object.keys(options)) {
2969
- urlObject.searchParams.set(key, options[key]);
2951
+ const customerAccountApiCustomScalars = {
2952
+ DateTime: "string",
2953
+ Decimal: "string",
2954
+ HTML: "string",
2955
+ ISO8601DateTime: "string",
2956
+ URL: "string",
2957
+ UnsignedInt64: "string"
2958
+ };
2959
+ const ExternalVideo = React$1.forwardRef(
2960
+ (props, ref) => {
2961
+ const {
2962
+ data,
2963
+ options,
2964
+ id = data.id,
2965
+ frameBorder = "0",
2966
+ allow = "accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture",
2967
+ allowFullScreen = true,
2968
+ loading = "lazy",
2969
+ ...passthroughProps
2970
+ } = props;
2971
+ if (!data.embedUrl) {
2972
+ throw new Error(`<ExternalVideo/> requires the 'embedUrl' property`);
2973
+ }
2974
+ let finalUrl = data.embedUrl;
2975
+ if (options) {
2976
+ const urlObject = new URL(data.embedUrl);
2977
+ for (const [key, value] of Object.entries(options)) {
2978
+ if (typeof value === "undefined") {
2979
+ continue;
2980
+ }
2981
+ urlObject.searchParams.set(key, value.toString());
2982
+ }
2983
+ finalUrl = urlObject.toString();
2970
2984
  }
2971
- finalUrl = urlObject.toString();
2985
+ return /* @__PURE__ */ React.createElement(
2986
+ "iframe",
2987
+ {
2988
+ ...passthroughProps,
2989
+ id: id ?? data.embedUrl,
2990
+ title: data.alt ?? data.id ?? "external video",
2991
+ frameBorder,
2992
+ allow,
2993
+ allowFullScreen,
2994
+ src: finalUrl,
2995
+ loading,
2996
+ ref
2997
+ }
2998
+ );
2972
2999
  }
2973
- return /* @__PURE__ */ React.createElement(
2974
- "iframe",
2975
- {
2976
- ...passthroughProps,
2977
- id: id ?? data.embedUrl,
2978
- title: data.alt ?? data.id ?? "external video",
2979
- frameBorder,
2980
- allow,
2981
- allowFullScreen,
2982
- src: finalUrl,
2983
- loading
2984
- }
2985
- );
2986
- }
3000
+ );
2987
3001
  const IMAGE_FRAGMENT = `#graphql
2988
3002
  fragment Image on Image {
2989
3003
  altText
@@ -3375,7 +3389,7 @@ Refer to the authentication https://shopify.dev/api/storefront#authentication do
3375
3389
  }, [url, stringifiedOptions, options]);
3376
3390
  return status;
3377
3391
  }
3378
- function Video(props) {
3392
+ const Video = React$1.forwardRef((props, ref) => {
3379
3393
  var _a;
3380
3394
  const {
3381
3395
  data,
@@ -3402,7 +3416,8 @@ Refer to the authentication https://shopify.dev/api/storefront#authentication do
3402
3416
  id,
3403
3417
  playsInline,
3404
3418
  controls,
3405
- poster: posterUrl
3419
+ poster: posterUrl,
3420
+ ref
3406
3421
  },
3407
3422
  data.sources.map((source) => {
3408
3423
  if (!((source == null ? void 0 : source.url) && (source == null ? void 0 : source.mimeType))) {
@@ -3420,7 +3435,7 @@ Refer to the authentication https://shopify.dev/api/storefront#authentication do
3420
3435
  })
3421
3436
  )
3422
3437
  );
3423
- }
3438
+ });
3424
3439
  function ModelViewer(props) {
3425
3440
  var _a, _b, _c;
3426
3441
  const [modelViewer, setModelViewer] = React$1.useState(
@@ -3436,108 +3451,43 @@ Refer to the authentication https://shopify.dev/api/storefront#authentication do
3436
3451
  module: true
3437
3452
  }
3438
3453
  );
3454
+ const hydrogenEventListener = {
3455
+ error: passthroughProps.onError,
3456
+ load: passthroughProps.onLoad,
3457
+ preload: passthroughProps.onPreload,
3458
+ "model-visibility": passthroughProps.onModelVisibility,
3459
+ progress: passthroughProps.onProgress,
3460
+ "ar-status": passthroughProps.onArStatus,
3461
+ "ar-tracking": passthroughProps.onArTracking,
3462
+ "quick-look-button-tapped": passthroughProps.onQuickLookButtonTapped,
3463
+ "camera-change": passthroughProps.onCameraChange,
3464
+ "environment-change": passthroughProps.onEnvironmentChange,
3465
+ play: passthroughProps.onPlay,
3466
+ pause: passthroughProps.onPause,
3467
+ "scene-graph-ready": passthroughProps.onSceneGraphReady
3468
+ };
3439
3469
  React$1.useEffect(() => {
3440
3470
  if (!modelViewer) {
3441
3471
  return;
3442
3472
  }
3443
- if (passthroughProps.onError)
3444
- modelViewer.addEventListener("error", passthroughProps.onError);
3445
- if (passthroughProps.onLoad)
3446
- modelViewer.addEventListener("load", passthroughProps.onLoad);
3447
- if (passthroughProps.onPreload)
3448
- modelViewer.addEventListener("preload", passthroughProps.onPreload);
3449
- if (passthroughProps.onModelVisibility)
3450
- modelViewer.addEventListener(
3451
- "model-visibility",
3452
- passthroughProps.onModelVisibility
3453
- );
3454
- if (passthroughProps.onProgress)
3455
- modelViewer.addEventListener("progress", passthroughProps.onProgress);
3456
- if (passthroughProps.onArStatus)
3457
- modelViewer.addEventListener("ar-status", passthroughProps.onArStatus);
3458
- if (passthroughProps.onArTracking)
3459
- modelViewer.addEventListener(
3460
- "ar-tracking",
3461
- passthroughProps.onArTracking
3462
- );
3463
- if (passthroughProps.onQuickLookButtonTapped)
3464
- modelViewer.addEventListener(
3465
- "quick-look-button-tapped",
3466
- passthroughProps.onQuickLookButtonTapped
3467
- );
3468
- if (passthroughProps.onCameraChange)
3469
- modelViewer.addEventListener(
3470
- "camera-change",
3471
- passthroughProps.onCameraChange
3472
- );
3473
- if (passthroughProps.onEnvironmentChange)
3474
- modelViewer.addEventListener(
3475
- "environment-change",
3476
- passthroughProps.onEnvironmentChange
3477
- );
3478
- if (passthroughProps.onPlay)
3479
- modelViewer.addEventListener("play", passthroughProps.onPlay);
3480
- if (passthroughProps.onPause)
3481
- modelViewer.addEventListener("ar-status", passthroughProps.onPause);
3482
- if (passthroughProps.onSceneGraphReady)
3483
- modelViewer.addEventListener(
3484
- "scene-graph-ready",
3485
- passthroughProps.onSceneGraphReady
3486
- );
3473
+ Object.entries(hydrogenEventListener).forEach(
3474
+ ([eventName, callbackFunc]) => {
3475
+ if (callbackFunc) {
3476
+ modelViewer.addEventListener(eventName, callbackFunc);
3477
+ }
3478
+ }
3479
+ );
3487
3480
  return () => {
3488
3481
  if (modelViewer == null) {
3489
3482
  return;
3490
3483
  }
3491
- if (passthroughProps.onError)
3492
- modelViewer.removeEventListener("error", passthroughProps.onError);
3493
- if (passthroughProps.onLoad)
3494
- modelViewer.removeEventListener("load", passthroughProps.onLoad);
3495
- if (passthroughProps.onPreload)
3496
- modelViewer.removeEventListener("preload", passthroughProps.onPreload);
3497
- if (passthroughProps.onModelVisibility)
3498
- modelViewer.removeEventListener(
3499
- "model-visibility",
3500
- passthroughProps.onModelVisibility
3501
- );
3502
- if (passthroughProps.onProgress)
3503
- modelViewer.removeEventListener(
3504
- "progress",
3505
- passthroughProps.onProgress
3506
- );
3507
- if (passthroughProps.onArStatus)
3508
- modelViewer.removeEventListener(
3509
- "ar-status",
3510
- passthroughProps.onArStatus
3511
- );
3512
- if (passthroughProps.onArTracking)
3513
- modelViewer.removeEventListener(
3514
- "ar-tracking",
3515
- passthroughProps.onArTracking
3516
- );
3517
- if (passthroughProps.onQuickLookButtonTapped)
3518
- modelViewer.removeEventListener(
3519
- "quick-look-button-tapped",
3520
- passthroughProps.onQuickLookButtonTapped
3521
- );
3522
- if (passthroughProps.onCameraChange)
3523
- modelViewer.removeEventListener(
3524
- "camera-change",
3525
- passthroughProps.onCameraChange
3526
- );
3527
- if (passthroughProps.onEnvironmentChange)
3528
- modelViewer.removeEventListener(
3529
- "environment-change",
3530
- passthroughProps.onEnvironmentChange
3531
- );
3532
- if (passthroughProps.onPlay)
3533
- modelViewer.removeEventListener("play", passthroughProps.onPlay);
3534
- if (passthroughProps.onPause)
3535
- modelViewer.removeEventListener("ar-status", passthroughProps.onPause);
3536
- if (passthroughProps.onSceneGraphReady)
3537
- modelViewer.removeEventListener(
3538
- "scene-graph-ready",
3539
- passthroughProps.onSceneGraphReady
3540
- );
3484
+ Object.entries(hydrogenEventListener).forEach(
3485
+ ([eventName, callbackFunc]) => {
3486
+ if (callbackFunc) {
3487
+ modelViewer.removeEventListener(eventName, callbackFunc);
3488
+ }
3489
+ }
3490
+ );
3541
3491
  };
3542
3492
  }, [
3543
3493
  modelViewer,
@@ -3832,7 +3782,11 @@ Refer to the authentication https://shopify.dev/api/storefront#authentication do
3832
3782
  return /* @__PURE__ */ React.createElement(Money, { ...passthroughProps, data: price });
3833
3783
  }
3834
3784
  const SHOPJS_URL = "https://cdn.shopify.com/shopifycloud/shop-js/v1.0/client.js";
3785
+ function isChannel(channel) {
3786
+ return channel === "headless" || channel === "hydrogen";
3787
+ }
3835
3788
  function ShopPayButton({
3789
+ channel,
3836
3790
  variantIds,
3837
3791
  className,
3838
3792
  variantIdsAndQuantities,
@@ -3843,6 +3797,7 @@ Refer to the authentication https://shopify.dev/api/storefront#authentication do
3843
3797
  const storeDomain = _storeDomain || (shop == null ? void 0 : shop.storeDomain);
3844
3798
  const shopPayLoadedStatus = useLoadScript(SHOPJS_URL);
3845
3799
  let ids = [];
3800
+ let channelAttribution;
3846
3801
  if (!storeDomain || storeDomain === defaultShopifyContext.storeDomain) {
3847
3802
  throw new Error(MissingStoreDomainErrorMessage);
3848
3803
  }
@@ -3852,6 +3807,13 @@ Refer to the authentication https://shopify.dev/api/storefront#authentication do
3852
3807
  if (!variantIds && !variantIdsAndQuantities) {
3853
3808
  throw new Error(MissingPropsErrorMessage);
3854
3809
  }
3810
+ if (channel) {
3811
+ if (isChannel(channel)) {
3812
+ channelAttribution = channel;
3813
+ } else {
3814
+ throw new Error(InvalidChannelErrorMessage);
3815
+ }
3816
+ }
3855
3817
  if (variantIds) {
3856
3818
  ids = variantIds.reduce((prev, curr) => {
3857
3819
  const bareId = parseGid(curr).id;
@@ -3877,12 +3839,20 @@ Refer to the authentication https://shopify.dev/api/storefront#authentication do
3877
3839
  const style = width ? {
3878
3840
  "--shop-pay-button-width": width
3879
3841
  } : void 0;
3880
- return /* @__PURE__ */ React.createElement("div", { className, style }, shopPayLoadedStatus === "done" && /* @__PURE__ */ React.createElement("shop-pay-button", { "store-url": storeDomain, variants: ids.join(",") }));
3842
+ return /* @__PURE__ */ React.createElement("div", { className, style }, shopPayLoadedStatus === "done" && /* @__PURE__ */ React.createElement(
3843
+ "shop-pay-button",
3844
+ {
3845
+ ...channelAttribution ? { channel: channelAttribution } : {},
3846
+ "store-url": storeDomain,
3847
+ variants: ids.join(",")
3848
+ }
3849
+ ));
3881
3850
  }
3882
3851
  const MissingStoreDomainErrorMessage = 'You must pass a "storeDomain" prop to the "ShopPayButton" component, or wrap it in a "ShopifyProvider" component.';
3883
3852
  const InvalidPropsErrorMessage = `You must pass in "variantIds" in the form of ["gid://shopify/ProductVariant/1"]`;
3884
3853
  const MissingPropsErrorMessage = `You must pass in either "variantIds" or "variantIdsAndQuantities" to ShopPayButton`;
3885
3854
  const DoublePropsErrorMessage = `You must provide either a variantIds or variantIdsAndQuantities prop, but not both in the ShopPayButton component`;
3855
+ const InvalidChannelErrorMessage = `Invalid channel attribution value. Must be either "headless" or "hydrogen"`;
3886
3856
  const longTermLength = 60 * 60 * 24 * 360 * 1;
3887
3857
  const shortTermLength = 60 * 30;
3888
3858
  function useShopifyCookies(options) {
@@ -3944,6 +3914,7 @@ Refer to the authentication https://shopify.dev/api/storefront#authentication do
3944
3914
  exports2.ShopifySalesChannel = ShopifySalesChannel;
3945
3915
  exports2.Video = Video;
3946
3916
  exports2.createStorefrontClient = createStorefrontClient;
3917
+ exports2.customerAccountApiCustomScalars = customerAccountApiCustomScalars;
3947
3918
  exports2.flattenConnection = flattenConnection;
3948
3919
  exports2.getClientBrowserParameters = getClientBrowserParameters;
3949
3920
  exports2.getShopifyCookies = getShopifyCookies;