@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.
- package/customer-account.schema.json +37665 -0
- package/dist/browser-dev/CartProvider.mjs.map +1 -1
- package/dist/browser-dev/ExternalVideo.mjs +41 -34
- package/dist/browser-dev/ExternalVideo.mjs.map +1 -1
- package/dist/browser-dev/Image.mjs.map +1 -1
- package/dist/browser-dev/MediaFile.mjs.map +1 -1
- package/dist/browser-dev/ModelViewer.mjs +29 -94
- package/dist/browser-dev/ModelViewer.mjs.map +1 -1
- package/dist/browser-dev/Money.mjs.map +1 -1
- package/dist/browser-dev/ShopPayButton.mjs +22 -1
- package/dist/browser-dev/ShopPayButton.mjs.map +1 -1
- package/dist/browser-dev/Video.mjs +4 -3
- package/dist/browser-dev/Video.mjs.map +1 -1
- package/dist/browser-dev/codegen.helpers.mjs +9 -0
- package/dist/browser-dev/codegen.helpers.mjs.map +1 -1
- package/dist/browser-dev/index.mjs +2 -1
- package/dist/browser-dev/node_modules/@xstate/react/es/fsm.mjs +1 -1
- package/dist/browser-dev/node_modules/@xstate/react/es/fsm.mjs.map +1 -1
- package/dist/browser-dev/node_modules/use-sync-external-store/shim/index.mjs +1 -1
- package/dist/browser-dev/node_modules/use-sync-external-store/shim/index.mjs.map +1 -1
- package/dist/browser-dev/node_modules/use-sync-external-store/shim/with-selector.mjs +1 -1
- package/dist/browser-dev/node_modules/use-sync-external-store/shim/with-selector.mjs.map +1 -1
- package/dist/browser-dev/storefront-api-constants.mjs +1 -1
- package/dist/browser-dev/storefront-api-constants.mjs.map +1 -1
- package/dist/browser-dev/storefront-client.mjs +2 -2
- package/dist/browser-dev/storefront-client.mjs.map +1 -1
- package/dist/browser-dev/useCartAPIStateMachine.mjs.map +1 -1
- package/dist/browser-dev/useCartActions.mjs.map +1 -1
- package/dist/browser-prod/CartProvider.mjs.map +1 -1
- package/dist/browser-prod/ExternalVideo.mjs +41 -34
- package/dist/browser-prod/ExternalVideo.mjs.map +1 -1
- package/dist/browser-prod/Image.mjs.map +1 -1
- package/dist/browser-prod/MediaFile.mjs.map +1 -1
- package/dist/browser-prod/ModelViewer.mjs +29 -94
- package/dist/browser-prod/ModelViewer.mjs.map +1 -1
- package/dist/browser-prod/Money.mjs.map +1 -1
- package/dist/browser-prod/ShopPayButton.mjs +22 -1
- package/dist/browser-prod/ShopPayButton.mjs.map +1 -1
- package/dist/browser-prod/Video.mjs +4 -3
- package/dist/browser-prod/Video.mjs.map +1 -1
- package/dist/browser-prod/codegen.helpers.mjs +9 -0
- package/dist/browser-prod/codegen.helpers.mjs.map +1 -1
- package/dist/browser-prod/index.mjs +2 -1
- package/dist/browser-prod/node_modules/@xstate/react/es/fsm.mjs +1 -1
- package/dist/browser-prod/node_modules/@xstate/react/es/fsm.mjs.map +1 -1
- package/dist/browser-prod/node_modules/use-sync-external-store/shim/index.mjs +1 -1
- package/dist/browser-prod/node_modules/use-sync-external-store/shim/index.mjs.map +1 -1
- package/dist/browser-prod/node_modules/use-sync-external-store/shim/with-selector.mjs +1 -1
- package/dist/browser-prod/node_modules/use-sync-external-store/shim/with-selector.mjs.map +1 -1
- package/dist/browser-prod/storefront-api-constants.mjs +1 -1
- package/dist/browser-prod/storefront-api-constants.mjs.map +1 -1
- package/dist/browser-prod/storefront-client.mjs +1 -1
- package/dist/browser-prod/storefront-client.mjs.map +1 -1
- package/dist/browser-prod/useCartAPIStateMachine.mjs.map +1 -1
- package/dist/browser-prod/useCartActions.mjs.map +1 -1
- package/dist/node-dev/CartProvider.js.map +1 -1
- package/dist/node-dev/CartProvider.mjs.map +1 -1
- package/dist/node-dev/ExternalVideo.js +41 -34
- package/dist/node-dev/ExternalVideo.js.map +1 -1
- package/dist/node-dev/ExternalVideo.mjs +41 -34
- package/dist/node-dev/ExternalVideo.mjs.map +1 -1
- package/dist/node-dev/Image.js.map +1 -1
- package/dist/node-dev/Image.mjs.map +1 -1
- package/dist/node-dev/MediaFile.js.map +1 -1
- package/dist/node-dev/MediaFile.mjs.map +1 -1
- package/dist/node-dev/ModelViewer.js +29 -94
- package/dist/node-dev/ModelViewer.js.map +1 -1
- package/dist/node-dev/ModelViewer.mjs +29 -94
- package/dist/node-dev/ModelViewer.mjs.map +1 -1
- package/dist/node-dev/Money.js.map +1 -1
- package/dist/node-dev/Money.mjs.map +1 -1
- package/dist/node-dev/ShopPayButton.js +22 -1
- package/dist/node-dev/ShopPayButton.js.map +1 -1
- package/dist/node-dev/ShopPayButton.mjs +22 -1
- package/dist/node-dev/ShopPayButton.mjs.map +1 -1
- package/dist/node-dev/Video.js +3 -2
- package/dist/node-dev/Video.js.map +1 -1
- package/dist/node-dev/Video.mjs +4 -3
- package/dist/node-dev/Video.mjs.map +1 -1
- package/dist/node-dev/codegen.helpers.js +9 -0
- package/dist/node-dev/codegen.helpers.js.map +1 -1
- package/dist/node-dev/codegen.helpers.mjs +9 -0
- package/dist/node-dev/codegen.helpers.mjs.map +1 -1
- package/dist/node-dev/index.js +1 -0
- package/dist/node-dev/index.js.map +1 -1
- package/dist/node-dev/index.mjs +2 -1
- package/dist/node-dev/node_modules/@xstate/react/es/fsm.js +1 -1
- package/dist/node-dev/node_modules/@xstate/react/es/fsm.js.map +1 -1
- package/dist/node-dev/node_modules/@xstate/react/es/fsm.mjs +1 -1
- package/dist/node-dev/node_modules/@xstate/react/es/fsm.mjs.map +1 -1
- package/dist/node-dev/node_modules/use-sync-external-store/shim/index.js +1 -1
- package/dist/node-dev/node_modules/use-sync-external-store/shim/index.js.map +1 -1
- package/dist/node-dev/node_modules/use-sync-external-store/shim/index.mjs +1 -1
- package/dist/node-dev/node_modules/use-sync-external-store/shim/index.mjs.map +1 -1
- package/dist/node-dev/node_modules/use-sync-external-store/shim/with-selector.js +1 -1
- package/dist/node-dev/node_modules/use-sync-external-store/shim/with-selector.js.map +1 -1
- package/dist/node-dev/node_modules/use-sync-external-store/shim/with-selector.mjs +1 -1
- package/dist/node-dev/node_modules/use-sync-external-store/shim/with-selector.mjs.map +1 -1
- package/dist/node-dev/storefront-api-constants.js +1 -1
- package/dist/node-dev/storefront-api-constants.js.map +1 -1
- package/dist/node-dev/storefront-api-constants.mjs +1 -1
- package/dist/node-dev/storefront-api-constants.mjs.map +1 -1
- package/dist/node-dev/storefront-client.js +2 -2
- package/dist/node-dev/storefront-client.js.map +1 -1
- package/dist/node-dev/storefront-client.mjs +2 -2
- package/dist/node-dev/storefront-client.mjs.map +1 -1
- package/dist/node-dev/useCartAPIStateMachine.js.map +1 -1
- package/dist/node-dev/useCartAPIStateMachine.mjs.map +1 -1
- package/dist/node-dev/useCartActions.js.map +1 -1
- package/dist/node-dev/useCartActions.mjs.map +1 -1
- package/dist/node-prod/CartProvider.js.map +1 -1
- package/dist/node-prod/CartProvider.mjs.map +1 -1
- package/dist/node-prod/ExternalVideo.js +41 -34
- package/dist/node-prod/ExternalVideo.js.map +1 -1
- package/dist/node-prod/ExternalVideo.mjs +41 -34
- package/dist/node-prod/ExternalVideo.mjs.map +1 -1
- package/dist/node-prod/Image.js.map +1 -1
- package/dist/node-prod/Image.mjs.map +1 -1
- package/dist/node-prod/MediaFile.js.map +1 -1
- package/dist/node-prod/MediaFile.mjs.map +1 -1
- package/dist/node-prod/ModelViewer.js +29 -94
- package/dist/node-prod/ModelViewer.js.map +1 -1
- package/dist/node-prod/ModelViewer.mjs +29 -94
- package/dist/node-prod/ModelViewer.mjs.map +1 -1
- package/dist/node-prod/Money.js.map +1 -1
- package/dist/node-prod/Money.mjs.map +1 -1
- package/dist/node-prod/ShopPayButton.js +22 -1
- package/dist/node-prod/ShopPayButton.js.map +1 -1
- package/dist/node-prod/ShopPayButton.mjs +22 -1
- package/dist/node-prod/ShopPayButton.mjs.map +1 -1
- package/dist/node-prod/Video.js +3 -2
- package/dist/node-prod/Video.js.map +1 -1
- package/dist/node-prod/Video.mjs +4 -3
- package/dist/node-prod/Video.mjs.map +1 -1
- package/dist/node-prod/codegen.helpers.js +9 -0
- package/dist/node-prod/codegen.helpers.js.map +1 -1
- package/dist/node-prod/codegen.helpers.mjs +9 -0
- package/dist/node-prod/codegen.helpers.mjs.map +1 -1
- package/dist/node-prod/index.js +1 -0
- package/dist/node-prod/index.js.map +1 -1
- package/dist/node-prod/index.mjs +2 -1
- package/dist/node-prod/node_modules/@xstate/react/es/fsm.js +1 -1
- package/dist/node-prod/node_modules/@xstate/react/es/fsm.js.map +1 -1
- package/dist/node-prod/node_modules/@xstate/react/es/fsm.mjs +1 -1
- package/dist/node-prod/node_modules/@xstate/react/es/fsm.mjs.map +1 -1
- package/dist/node-prod/node_modules/use-sync-external-store/shim/index.js +1 -1
- package/dist/node-prod/node_modules/use-sync-external-store/shim/index.js.map +1 -1
- package/dist/node-prod/node_modules/use-sync-external-store/shim/index.mjs +1 -1
- package/dist/node-prod/node_modules/use-sync-external-store/shim/index.mjs.map +1 -1
- package/dist/node-prod/node_modules/use-sync-external-store/shim/with-selector.js +1 -1
- package/dist/node-prod/node_modules/use-sync-external-store/shim/with-selector.js.map +1 -1
- package/dist/node-prod/node_modules/use-sync-external-store/shim/with-selector.mjs +1 -1
- package/dist/node-prod/node_modules/use-sync-external-store/shim/with-selector.mjs.map +1 -1
- package/dist/node-prod/storefront-api-constants.js +1 -1
- package/dist/node-prod/storefront-api-constants.js.map +1 -1
- package/dist/node-prod/storefront-api-constants.mjs +1 -1
- package/dist/node-prod/storefront-api-constants.mjs.map +1 -1
- package/dist/node-prod/storefront-client.js +1 -1
- package/dist/node-prod/storefront-client.js.map +1 -1
- package/dist/node-prod/storefront-client.mjs +1 -1
- package/dist/node-prod/storefront-client.mjs.map +1 -1
- package/dist/node-prod/useCartAPIStateMachine.js.map +1 -1
- package/dist/node-prod/useCartAPIStateMachine.mjs.map +1 -1
- package/dist/node-prod/useCartActions.js.map +1 -1
- package/dist/node-prod/useCartActions.mjs.map +1 -1
- package/dist/types/CartProvider.d.ts +2 -2
- package/dist/types/ExternalVideo.d.ts +3 -2
- package/dist/types/Image.d.ts +1 -1
- package/dist/types/ModelViewer.d.ts +1 -1
- package/dist/types/Money.d.ts +1 -1
- package/dist/types/ShopPayButton.d.ts +8 -2
- package/dist/types/Video.d.ts +2 -2
- package/dist/types/codegen.helpers.d.ts +14 -1
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/storefront-api-constants.d.ts +1 -1
- package/dist/types/storefront-api-types.d.ts +64 -14
- package/dist/types/useCartAPIStateMachine.d.ts +2 -2
- package/dist/types/useCartActions.d.ts +2 -2
- package/dist/umd/hydrogen-react.dev.js +107 -136
- package/dist/umd/hydrogen-react.dev.js.map +1 -1
- package/dist/umd/hydrogen-react.prod.js +18 -18
- package/dist/umd/hydrogen-react.prod.js.map +1 -1
- package/package.json +11 -8
- package/storefront.schema.json +1 -1
|
@@ -405,7 +405,7 @@
|
|
|
405
405
|
}
|
|
406
406
|
return ref.current.v;
|
|
407
407
|
}
|
|
408
|
-
var __read =
|
|
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 = "
|
|
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
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
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
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
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(
|
|
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;
|