@shopify/shop-minis-react 0.3.4 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/index3.js +2 -5
- package/dist/_virtual/index3.js.map +1 -1
- package/dist/_virtual/index4.js +5 -2
- package/dist/_virtual/index4.js.map +1 -1
- package/dist/components/MinisContainer.js +11 -10
- package/dist/components/MinisContainer.js.map +1 -1
- package/dist/hooks/content/useContent.js +12 -18
- package/dist/hooks/content/useContent.js.map +1 -1
- package/dist/hooks/product/useCuratedProducts.js +9 -11
- package/dist/hooks/product/useCuratedProducts.js.map +1 -1
- package/dist/hooks/product/usePopularProducts.js +9 -11
- package/dist/hooks/product/usePopularProducts.js.map +1 -1
- package/dist/hooks/product/useProduct.js +11 -17
- package/dist/hooks/product/useProduct.js.map +1 -1
- package/dist/hooks/product/useProductList.js +10 -21
- package/dist/hooks/product/useProductList.js.map +1 -1
- package/dist/hooks/product/useProductLists.js +11 -13
- package/dist/hooks/product/useProductLists.js.map +1 -1
- package/dist/hooks/product/useProductMedia.js +12 -18
- package/dist/hooks/product/useProductMedia.js.map +1 -1
- package/dist/hooks/product/useProductSearch.js +34 -27
- package/dist/hooks/product/useProductSearch.js.map +1 -1
- package/dist/hooks/product/useProductVariants.js +11 -14
- package/dist/hooks/product/useProductVariants.js.map +1 -1
- package/dist/hooks/product/useProducts.js +12 -11
- package/dist/hooks/product/useProducts.js.map +1 -1
- package/dist/hooks/product/useRecommendedProducts.js +11 -13
- package/dist/hooks/product/useRecommendedProducts.js.map +1 -1
- package/dist/hooks/shop/useRecommendedShops.js +11 -13
- package/dist/hooks/shop/useRecommendedShops.js.map +1 -1
- package/dist/hooks/shop/useShop.js +12 -11
- package/dist/hooks/shop/useShop.js.map +1 -1
- package/dist/hooks/user/useBuyerAttributes.js +8 -10
- package/dist/hooks/user/useBuyerAttributes.js.map +1 -1
- package/dist/hooks/user/useCurrentUser.js +7 -9
- package/dist/hooks/user/useCurrentUser.js.map +1 -1
- package/dist/hooks/user/useFollowedShops.js +11 -14
- package/dist/hooks/user/useFollowedShops.js.map +1 -1
- package/dist/hooks/user/useOrders.js +7 -9
- package/dist/hooks/user/useOrders.js.map +1 -1
- package/dist/hooks/user/useRecentProducts.js +11 -13
- package/dist/hooks/user/useRecentProducts.js.map +1 -1
- package/dist/hooks/user/useRecentShops.js +10 -13
- package/dist/hooks/user/useRecentShops.js.map +1 -1
- package/dist/hooks/user/useSavedProducts.js +10 -13
- package/dist/hooks/user/useSavedProducts.js.map +1 -1
- package/dist/hooks/util/useImagePicker.js +13 -6
- package/dist/hooks/util/useImagePicker.js.map +1 -1
- package/dist/internal/reactQuery/MinisQueryProvider.js +11 -0
- package/dist/internal/reactQuery/MinisQueryProvider.js.map +1 -0
- package/dist/internal/reactQuery/queryClient.js +33 -0
- package/dist/internal/reactQuery/queryClient.js.map +1 -0
- package/dist/internal/reactQuery/useShopActionInfiniteQuery.js +52 -0
- package/dist/internal/reactQuery/useShopActionInfiniteQuery.js.map +1 -0
- package/dist/internal/reactQuery/useShopActionQuery.js +37 -0
- package/dist/internal/reactQuery/useShopActionQuery.js.map +1 -0
- package/dist/internal/utils/resizeImage.js +61 -0
- package/dist/internal/utils/resizeImage.js.map +1 -0
- package/dist/providers/ImagePickerProvider.js +123 -102
- package/dist/providers/ImagePickerProvider.js.map +1 -1
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/focusManager.js +45 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/focusManager.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/infiniteQueryBehavior.js +89 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/infiniteQueryBehavior.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/infiniteQueryObserver.js +55 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/infiniteQueryObserver.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/mutation.js +198 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/mutation.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/mutationCache.js +99 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/mutationCache.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/notifyManager.js +67 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/notifyManager.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/onlineManager.js +39 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/onlineManager.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/query.js +299 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/query.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/queryCache.js +80 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/queryCache.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/queryClient.js +215 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/queryClient.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/queryObserver.js +300 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/queryObserver.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/removable.js +25 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/removable.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/retryer.js +76 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/retryer.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/subscribable.js +21 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/subscribable.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/thenable.js +26 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/thenable.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/utils.js +176 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_query-core@5.86.0/node_modules/@tanstack/query-core/build/modern/utils.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/IsRestoringProvider.js +7 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/IsRestoringProvider.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js +17 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/QueryErrorResetBoundary.js +19 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/QueryErrorResetBoundary.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js +21 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/suspense.js +18 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/suspense.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/useBaseQuery.js +64 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/useBaseQuery.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/useInfiniteQuery.js +13 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/useInfiniteQuery.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/useQuery.js +9 -0
- package/dist/shop-minis-react/node_modules/.pnpm/@tanstack_react-query@5.86.0_react@19.1.0/node_modules/@tanstack/react-query/build/modern/useQuery.js.map +1 -0
- package/dist/shop-minis-react/node_modules/.pnpm/querystringify@2.2.0/node_modules/querystringify/index.js +1 -1
- package/dist/shop-minis-react/node_modules/.pnpm/video.js@8.23.3/node_modules/video.js/dist/video.es.js +1 -1
- package/package.json +2 -7
- package/src/components/MinisContainer.tsx +6 -3
- package/src/hooks/content/useContent.ts +6 -17
- package/src/hooks/product/useCuratedProducts.ts +4 -6
- package/src/hooks/product/usePopularProducts.ts +4 -6
- package/src/hooks/product/useProduct.ts +6 -17
- package/src/hooks/product/useProductList.ts +4 -19
- package/src/hooks/product/useProductLists.ts +4 -6
- package/src/hooks/product/useProductMedia.ts +6 -17
- package/src/hooks/product/useProductSearch.ts +19 -15
- package/src/hooks/product/useProductVariants.ts +5 -13
- package/src/hooks/product/useProducts.ts +8 -12
- package/src/hooks/product/useRecommendedProducts.ts +4 -6
- package/src/hooks/shop/useRecommendedShops.ts +4 -6
- package/src/hooks/shop/useShop.ts +8 -12
- package/src/hooks/user/useBuyerAttributes.ts +4 -6
- package/src/hooks/user/useCurrentUser.ts +4 -6
- package/src/hooks/user/useFollowedShops.ts +5 -13
- package/src/hooks/user/useOrders.ts +4 -6
- package/src/hooks/user/useRecentProducts.ts +4 -6
- package/src/hooks/user/useRecentShops.ts +5 -13
- package/src/hooks/user/useSavedProducts.ts +5 -13
- package/src/hooks/util/useImagePicker.test.tsx +193 -0
- package/src/hooks/util/useImagePicker.ts +24 -5
- package/src/internal/reactQuery/MinisQueryProvider.test.tsx +38 -0
- package/src/internal/reactQuery/MinisQueryProvider.tsx +16 -0
- package/src/internal/reactQuery/index.ts +8 -0
- package/src/internal/reactQuery/queryClient.test.tsx +91 -0
- package/src/internal/reactQuery/queryClient.ts +43 -0
- package/src/internal/reactQuery/useShopActionInfiniteQuery.test.tsx +357 -0
- package/src/internal/reactQuery/useShopActionInfiniteQuery.ts +129 -0
- package/src/internal/reactQuery/useShopActionQuery.test.tsx +184 -0
- package/src/internal/reactQuery/useShopActionQuery.ts +74 -0
- package/src/internal/utils/resizeImage.test.ts +314 -0
- package/src/internal/utils/resizeImage.ts +108 -0
- package/src/providers/ImagePickerProvider.test.tsx +32 -1
- package/src/providers/ImagePickerProvider.tsx +108 -65
- package/dist/internal/useShopActionsDataFetching.js +0 -79
- package/dist/internal/useShopActionsDataFetching.js.map +0 -1
- package/dist/internal/useShopActionsPaginatedDataFetching.js +0 -96
- package/dist/internal/useShopActionsPaginatedDataFetching.js.map +0 -1
- package/src/hooks/product/useProductSearch.test.ts +0 -470
- package/src/internal/useShopActionsDataFetching.test.ts +0 -465
- package/src/internal/useShopActionsDataFetching.ts +0 -150
- package/src/internal/useShopActionsPaginatedDataFetching.ts +0 -188
- package/src/stories/Accordion.stories.tsx +0 -124
- package/src/stories/AddToCart.stories.tsx +0 -251
- package/src/stories/Alert.stories.tsx +0 -38
- package/src/stories/AlertDialog.stories.tsx +0 -48
- package/src/stories/Avatar.stories.tsx +0 -29
- package/src/stories/Badge.stories.tsx +0 -46
- package/src/stories/Button.stories.tsx +0 -81
- package/src/stories/Card.stories.tsx +0 -40
- package/src/stories/Checkbox.stories.tsx +0 -44
- package/src/stories/FavoriteButton.stories.tsx +0 -58
- package/src/stories/IconButton.stories.tsx +0 -68
- package/src/stories/ImageContentWrapper.stories.tsx +0 -65
- package/src/stories/Input.stories.tsx +0 -44
- package/src/stories/Label.stories.tsx +0 -19
- package/src/stories/List.stories.tsx +0 -64
- package/src/stories/MerchantCard.stories.tsx +0 -127
- package/src/stories/ProductCard.stories.tsx +0 -92
- package/src/stories/ProductLink.stories.tsx +0 -46
- package/src/stories/ProductVariantPrice.stories.tsx +0 -70
- package/src/stories/Progress.stories.tsx +0 -30
- package/src/stories/PullToRefreshList.stories.tsx +0 -122
- package/src/stories/QuantitySelector.stories.tsx +0 -78
- package/src/stories/RadioGroup.stories.tsx +0 -51
- package/src/stories/Search.stories.tsx +0 -37
- package/src/stories/Select.stories.tsx +0 -85
- package/src/stories/Skeleton.stories.tsx +0 -19
- package/src/stories/TextInput.stories.tsx +0 -26
- package/src/stories/Toaster.stories.tsx +0 -46
- package/src/stories/Touchable.stories.tsx +0 -40
- package/src/stories/VideoPlayer.stories.tsx +0 -129
package/dist/_virtual/index3.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import { __require as o } from "../shop-minis-react/node_modules/.pnpm/@videojs_xhr@2.7.0/node_modules/@videojs/xhr/lib/index.js";
|
|
3
|
-
var t = o();
|
|
4
|
-
const a = /* @__PURE__ */ r(t);
|
|
1
|
+
var r = {};
|
|
5
2
|
export {
|
|
6
|
-
|
|
3
|
+
r as __exports
|
|
7
4
|
};
|
|
8
5
|
//# sourceMappingURL=index3.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index3.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index3.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
package/dist/_virtual/index4.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import { getDefaultExportFromCjs as r } from "./_commonjsHelpers.js";
|
|
2
|
+
import { __require as o } from "../shop-minis-react/node_modules/.pnpm/@videojs_xhr@2.7.0/node_modules/@videojs/xhr/lib/index.js";
|
|
3
|
+
var t = o();
|
|
4
|
+
const a = /* @__PURE__ */ r(t);
|
|
2
5
|
export {
|
|
3
|
-
|
|
6
|
+
a as default
|
|
4
7
|
};
|
|
5
8
|
//# sourceMappingURL=index4.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index4.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index4.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
@@ -4,12 +4,13 @@ import { useShopActions as v } from "../internal/useShopActions.js";
|
|
|
4
4
|
import { injectMocks as y } from "../mocks.js";
|
|
5
5
|
import { ImagePickerProvider as h } from "../providers/ImagePickerProvider.js";
|
|
6
6
|
import { ErrorBoundary as E } from "./ErrorBoundary.js";
|
|
7
|
+
import { MinisQueryProvider as g } from "../internal/reactQuery/MinisQueryProvider.js";
|
|
7
8
|
y();
|
|
8
|
-
function
|
|
9
|
-
const [i,
|
|
10
|
-
async (
|
|
9
|
+
function N({ children: a }) {
|
|
10
|
+
const [i, n] = u(!1), t = v(), c = f(
|
|
11
|
+
async (o) => {
|
|
11
12
|
try {
|
|
12
|
-
t && t.reportError && await t.reportError(
|
|
13
|
+
t && t.reportError && await t.reportError(o);
|
|
13
14
|
} catch (e) {
|
|
14
15
|
console.error("Failed to report error to app:", e);
|
|
15
16
|
}
|
|
@@ -17,26 +18,26 @@ function b({ children: a }) {
|
|
|
17
18
|
[t]
|
|
18
19
|
);
|
|
19
20
|
return p(() => {
|
|
20
|
-
const
|
|
21
|
-
if (
|
|
21
|
+
const o = () => window.minisSDK ? (n(!0), !0) : !1;
|
|
22
|
+
if (o())
|
|
22
23
|
return;
|
|
23
24
|
const e = (d) => {
|
|
24
25
|
const { type: m } = JSON.parse(d.data);
|
|
25
|
-
m === "MINIS_SDK_READY" &&
|
|
26
|
+
m === "MINIS_SDK_READY" && n(!0);
|
|
26
27
|
};
|
|
27
28
|
window.addEventListener("message", e), document.addEventListener("message", e);
|
|
28
29
|
const s = setInterval(() => {
|
|
29
|
-
|
|
30
|
+
o() && clearInterval(s);
|
|
30
31
|
}, 100);
|
|
31
32
|
return () => {
|
|
32
33
|
clearInterval(s), window.removeEventListener("message", e), document.removeEventListener("message", e);
|
|
33
34
|
};
|
|
34
|
-
}, []), i ? /* @__PURE__ */ r(E, { onError: c, children: /* @__PURE__ */ r(h, { children: a }) }) : /* @__PURE__ */ r("div", { className: "h-screen bg-gray-50 flex items-center justify-center", children: /* @__PURE__ */ l("div", { className: "text-center", children: [
|
|
35
|
+
}, []), i ? /* @__PURE__ */ r(g, { children: /* @__PURE__ */ r(E, { onError: c, children: /* @__PURE__ */ r(h, { children: a }) }) }) : /* @__PURE__ */ r("div", { className: "h-screen bg-gray-50 flex items-center justify-center", children: /* @__PURE__ */ l("div", { className: "text-center", children: [
|
|
35
36
|
/* @__PURE__ */ r("div", { className: "animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900 mx-auto mb-4" }),
|
|
36
37
|
/* @__PURE__ */ r("p", { className: "text-gray-600", children: "Loading..." })
|
|
37
38
|
] }) });
|
|
38
39
|
}
|
|
39
40
|
export {
|
|
40
|
-
|
|
41
|
+
N as MinisContainer
|
|
41
42
|
};
|
|
42
43
|
//# sourceMappingURL=MinisContainer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MinisContainer.js","sources":["../../src/components/MinisContainer.tsx"],"sourcesContent":["import React, {useCallback, useEffect, useState} from 'react'\n\nimport {ReportErrorParams} from '@shopify/shop-minis-platform/actions'\n\nimport {useShopActions} from '../internal/useShopActions'\nimport {injectMocks} from '../mocks'\nimport {ImagePickerProvider} from '../providers/ImagePickerProvider'\n\nimport {ErrorBoundary} from './ErrorBoundary'\n\ninjectMocks()\n\nexport function MinisContainer({children}: {children: React.ReactNode}) {\n const [isSDKReady, setIsSDKReady] = useState(false)\n const actions = useShopActions()\n\n const handleError = useCallback(\n async (params: ReportErrorParams) => {\n try {\n if (actions && actions.reportError) {\n await actions.reportError(params)\n }\n } catch (error) {\n // If reporting fails, at least log to console\n console.error('Failed to report error to app:', error)\n }\n },\n [actions]\n )\n\n useEffect(() => {\n // Function to check if SDK is ready\n const checkSDKReady = () => {\n if (window.minisSDK) {\n setIsSDKReady(true)\n return true\n }\n return false\n }\n\n // Check immediately\n if (checkSDKReady()) {\n return\n }\n\n // If not ready, set up a listener for the MINIS_SDK_READY event\n const handleSDKReady = (event: any) => {\n const {type} = JSON.parse(event.data)\n\n if (type === 'MINIS_SDK_READY') {\n setIsSDKReady(true)\n }\n }\n\n // Listen for the MINIS_SDK_READY event\n window.addEventListener('message', handleSDKReady)\n document.addEventListener('message', handleSDKReady)\n\n // Also poll for SDK availability as a fallback\n const pollInterval = setInterval(() => {\n if (checkSDKReady()) {\n clearInterval(pollInterval)\n }\n }, 100)\n\n // Cleanup\n return () => {\n clearInterval(pollInterval)\n window.removeEventListener('message', handleSDKReady)\n document.removeEventListener('message', handleSDKReady)\n }\n }, [])\n\n // Don't render anything until SDK is ready\n if (!isSDKReady) {\n return (\n <div className=\"h-screen bg-gray-50 flex items-center justify-center\">\n <div className=\"text-center\">\n <div className=\"animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900 mx-auto mb-4\" />\n <p className=\"text-gray-600\">Loading...</p>\n </div>\n </div>\n )\n }\n\n return (\n <ErrorBoundary onError={handleError}>\n
|
|
1
|
+
{"version":3,"file":"MinisContainer.js","sources":["../../src/components/MinisContainer.tsx"],"sourcesContent":["import React, {useCallback, useEffect, useState} from 'react'\n\nimport {ReportErrorParams} from '@shopify/shop-minis-platform/actions'\n\nimport {MinisQueryProvider} from '../internal/reactQuery'\nimport {useShopActions} from '../internal/useShopActions'\nimport {injectMocks} from '../mocks'\nimport {ImagePickerProvider} from '../providers/ImagePickerProvider'\n\nimport {ErrorBoundary} from './ErrorBoundary'\n\ninjectMocks()\n\nexport function MinisContainer({children}: {children: React.ReactNode}) {\n const [isSDKReady, setIsSDKReady] = useState(false)\n const actions = useShopActions()\n\n const handleError = useCallback(\n async (params: ReportErrorParams) => {\n try {\n if (actions && actions.reportError) {\n await actions.reportError(params)\n }\n } catch (error) {\n // If reporting fails, at least log to console\n console.error('Failed to report error to app:', error)\n }\n },\n [actions]\n )\n\n useEffect(() => {\n // Function to check if SDK is ready\n const checkSDKReady = () => {\n if (window.minisSDK) {\n setIsSDKReady(true)\n return true\n }\n return false\n }\n\n // Check immediately\n if (checkSDKReady()) {\n return\n }\n\n // If not ready, set up a listener for the MINIS_SDK_READY event\n const handleSDKReady = (event: any) => {\n const {type} = JSON.parse(event.data)\n\n if (type === 'MINIS_SDK_READY') {\n setIsSDKReady(true)\n }\n }\n\n // Listen for the MINIS_SDK_READY event\n window.addEventListener('message', handleSDKReady)\n document.addEventListener('message', handleSDKReady)\n\n // Also poll for SDK availability as a fallback\n const pollInterval = setInterval(() => {\n if (checkSDKReady()) {\n clearInterval(pollInterval)\n }\n }, 100)\n\n // Cleanup\n return () => {\n clearInterval(pollInterval)\n window.removeEventListener('message', handleSDKReady)\n document.removeEventListener('message', handleSDKReady)\n }\n }, [])\n\n // Don't render anything until SDK is ready\n if (!isSDKReady) {\n return (\n <div className=\"h-screen bg-gray-50 flex items-center justify-center\">\n <div className=\"text-center\">\n <div className=\"animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900 mx-auto mb-4\" />\n <p className=\"text-gray-600\">Loading...</p>\n </div>\n </div>\n )\n }\n\n return (\n <MinisQueryProvider>\n <ErrorBoundary onError={handleError}>\n <ImagePickerProvider>{children}</ImagePickerProvider>\n </ErrorBoundary>\n </MinisQueryProvider>\n )\n}\n"],"names":["injectMocks","MinisContainer","children","isSDKReady","setIsSDKReady","useState","actions","useShopActions","handleError","useCallback","params","error","useEffect","checkSDKReady","handleSDKReady","event","type","pollInterval","jsx","MinisQueryProvider","ErrorBoundary","ImagePickerProvider","jsxs"],"mappings":";;;;;;;AAWAA,EAAY;AAEI,SAAAC,EAAe,EAAC,UAAAC,KAAwC;AACtE,QAAM,CAACC,GAAYC,CAAa,IAAIC,EAAS,EAAK,GAC5CC,IAAUC,EAAe,GAEzBC,IAAcC;AAAA,IAClB,OAAOC,MAA8B;AAC/B,UAAA;AACE,QAAAJ,KAAWA,EAAQ,eACf,MAAAA,EAAQ,YAAYI,CAAM;AAAA,eAE3BC,GAAO;AAEN,gBAAA,MAAM,kCAAkCA,CAAK;AAAA,MAAA;AAAA,IAEzD;AAAA,IACA,CAACL,CAAO;AAAA,EACV;AA8CA,SA5CAM,EAAU,MAAM;AAEd,UAAMC,IAAgB,MAChB,OAAO,YACTT,EAAc,EAAI,GACX,MAEF;AAIT,QAAIS;AACF;AAII,UAAAC,IAAiB,CAACC,MAAe;AACrC,YAAM,EAAC,MAAAC,EAAI,IAAI,KAAK,MAAMD,EAAM,IAAI;AAEpC,MAAIC,MAAS,qBACXZ,EAAc,EAAI;AAAA,IAEtB;AAGO,WAAA,iBAAiB,WAAWU,CAAc,GACxC,SAAA,iBAAiB,WAAWA,CAAc;AAG7C,UAAAG,IAAe,YAAY,MAAM;AACrC,MAAIJ,OACF,cAAcI,CAAY;AAAA,OAE3B,GAAG;AAGN,WAAO,MAAM;AACX,oBAAcA,CAAY,GACnB,OAAA,oBAAoB,WAAWH,CAAc,GAC3C,SAAA,oBAAoB,WAAWA,CAAc;AAAA,IACxD;AAAA,EACF,GAAG,EAAE,GAGAX,IAYH,gBAAAe,EAACC,GACC,EAAA,UAAA,gBAAAD,EAACE,GAAc,EAAA,SAASZ,GACtB,UAAC,gBAAAU,EAAAG,GAAA,EAAqB,UAAAnB,EAAS,CAAA,EACjC,CAAA,GACF,sBAdG,OAAI,EAAA,WAAU,wDACb,UAAC,gBAAAoB,EAAA,OAAA,EAAI,WAAU,eACb,UAAA;AAAA,IAAC,gBAAAJ,EAAA,OAAA,EAAI,WAAU,4EAA4E,CAAA;AAAA,IAC1F,gBAAAA,EAAA,KAAA,EAAE,WAAU,iBAAgB,UAAU,aAAA,CAAA;AAAA,EAAA,EAAA,CACzC,EACF,CAAA;AAWN;"}
|
|
@@ -1,24 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
{
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
skip: s,
|
|
13
|
-
hook: "useContent"
|
|
14
|
-
}
|
|
15
|
-
), c = m(() => t ?? null, [t]);
|
|
1
|
+
import { useShopActions as i } from "../../internal/useShopActions.js";
|
|
2
|
+
import { useShopActionQuery as p } from "../../internal/reactQuery/useShopActionQuery.js";
|
|
3
|
+
const u = (e) => {
|
|
4
|
+
const { getContent: n } = i(), { identifiers: t, skip: s = !1, ...o } = e, { data: r, ...c } = p(
|
|
5
|
+
["content", t, o],
|
|
6
|
+
n,
|
|
7
|
+
{ identifiers: t, ...o },
|
|
8
|
+
{ skip: s }
|
|
9
|
+
);
|
|
16
10
|
return {
|
|
17
|
-
...
|
|
18
|
-
content:
|
|
11
|
+
...c,
|
|
12
|
+
content: r
|
|
19
13
|
};
|
|
20
14
|
};
|
|
21
15
|
export {
|
|
22
|
-
|
|
16
|
+
u as useContent
|
|
23
17
|
};
|
|
24
18
|
//# sourceMappingURL=useContent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useContent.js","sources":["../../../src/hooks/content/useContent.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"useContent.js","sources":["../../../src/hooks/content/useContent.ts"],"sourcesContent":["import {useShopActionQuery} from '../../internal/reactQuery'\nimport {useShopActions} from '../../internal/useShopActions'\nimport {\n Content,\n ContentIdentifierInput,\n DataHookOptionsBase,\n DataHookReturnsBase,\n} from '../../types'\n\nexport interface UseContentParams extends DataHookOptionsBase {\n /**\n * The identifiers of the content to fetch.\n */\n identifiers: ContentIdentifierInput | ContentIdentifierInput[]\n}\n\ninterface UseContentReturns extends DataHookReturnsBase {\n /**\n * The content returned from the query.\n */\n content: Content[] | null\n}\n\nexport const useContent = (params: UseContentParams): UseContentReturns => {\n const {getContent} = useShopActions()\n const {identifiers, skip = false, ...restParams} = params\n\n const {data, ...rest} = useShopActionQuery(\n ['content', identifiers, restParams],\n getContent,\n {identifiers, ...restParams},\n {skip}\n )\n\n return {\n ...rest,\n content: data,\n }\n}\n"],"names":["useContent","params","getContent","useShopActions","identifiers","skip","restParams","data","rest","useShopActionQuery"],"mappings":";;AAuBa,MAAAA,IAAa,CAACC,MAAgD;AACnE,QAAA,EAAC,YAAAC,EAAU,IAAIC,EAAe,GAC9B,EAAC,aAAAC,GAAa,MAAAC,IAAO,IAAO,GAAGC,EAAc,IAAAL,GAE7C,EAAC,MAAAM,GAAM,GAAGC,EAAA,IAAQC;AAAA,IACtB,CAAC,WAAWL,GAAaE,CAAU;AAAA,IACnCJ;AAAA,IACA,EAAC,aAAAE,GAAa,GAAGE,EAAU;AAAA,IAC3B,EAAC,MAAAD,EAAI;AAAA,EACP;AAEO,SAAA;AAAA,IACL,GAAGG;AAAA,IACH,SAASD;AAAA,EACX;AACF;"}
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
import { useShopActions as u } from "../../internal/useShopActions.js";
|
|
2
|
-
import {
|
|
3
|
-
const
|
|
4
|
-
const { getCuratedProducts:
|
|
5
|
-
|
|
2
|
+
import { useShopActionInfiniteQuery as n } from "../../internal/reactQuery/useShopActionInfiniteQuery.js";
|
|
3
|
+
const p = (o) => {
|
|
4
|
+
const { getCuratedProducts: r } = u(), { skip: s, ...t } = o ?? {}, { data: c, ...e } = n(
|
|
5
|
+
["curatedProducts", t],
|
|
6
6
|
r,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
hook: "useCuratedProducts"
|
|
10
|
-
}
|
|
7
|
+
t,
|
|
8
|
+
{ skip: s }
|
|
11
9
|
);
|
|
12
10
|
return {
|
|
13
|
-
...
|
|
14
|
-
products:
|
|
11
|
+
...e,
|
|
12
|
+
products: c
|
|
15
13
|
};
|
|
16
14
|
};
|
|
17
15
|
export {
|
|
18
|
-
|
|
16
|
+
p as useCuratedProducts
|
|
19
17
|
};
|
|
20
18
|
//# sourceMappingURL=useCuratedProducts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCuratedProducts.js","sources":["../../../src/hooks/product/useCuratedProducts.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"useCuratedProducts.js","sources":["../../../src/hooks/product/useCuratedProducts.ts"],"sourcesContent":["import {useShopActionInfiniteQuery} from '../../internal/reactQuery'\nimport {useShopActions} from '../../internal/useShopActions'\nimport {\n Product,\n PaginatedDataHookOptionsBase,\n PaginatedDataHookReturnsBase,\n} from '../../types'\n\ninterface UseCuratedProductsParams extends PaginatedDataHookOptionsBase {\n handle: string\n requiredTags?: string[]\n anyOfTags?: string[]\n}\n\ninterface UseCuratedProductsReturns extends PaginatedDataHookReturnsBase {\n products: Product[] | null\n}\n\n/**\n * @param options - The options for the query\n */\nexport const useCuratedProducts = (\n params: UseCuratedProductsParams\n): UseCuratedProductsReturns => {\n const {getCuratedProducts} = useShopActions()\n const {skip, ...shopActionParams} = params ?? {}\n\n const {data, ...rest} = useShopActionInfiniteQuery(\n ['curatedProducts', shopActionParams],\n getCuratedProducts,\n shopActionParams,\n {skip}\n )\n\n return {\n ...rest,\n products: data,\n }\n}\n"],"names":["useCuratedProducts","params","getCuratedProducts","useShopActions","skip","shopActionParams","data","rest","useShopActionInfiniteQuery"],"mappings":";;AAqBa,MAAAA,IAAqB,CAChCC,MAC8B;AACxB,QAAA,EAAC,oBAAAC,EAAkB,IAAIC,EAAe,GACtC,EAAC,MAAAC,GAAM,GAAGC,EAAgB,IAAIJ,KAAU,CAAC,GAEzC,EAAC,MAAAK,GAAM,GAAGC,EAAA,IAAQC;AAAA,IACtB,CAAC,mBAAmBH,CAAgB;AAAA,IACpCH;AAAA,IACAG;AAAA,IACA,EAAC,MAAAD,EAAI;AAAA,EACP;AAEO,SAAA;AAAA,IACL,GAAGG;AAAA,IACH,UAAUD;AAAA,EACZ;AACF;"}
|
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import { useShopActions as
|
|
2
|
-
import {
|
|
3
|
-
const
|
|
4
|
-
const { getPopularProducts:
|
|
5
|
-
|
|
1
|
+
import { useShopActions as c } from "../../internal/useShopActions.js";
|
|
2
|
+
import { useShopActionInfiniteQuery as n } from "../../internal/reactQuery/useShopActionInfiniteQuery.js";
|
|
3
|
+
const a = (t) => {
|
|
4
|
+
const { getPopularProducts: r } = c(), { skip: s, ...o } = t ?? {}, { data: p, ...u } = n(
|
|
5
|
+
["popularProducts", o],
|
|
6
6
|
r,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
hook: "usePopularProducts"
|
|
10
|
-
}
|
|
7
|
+
o,
|
|
8
|
+
{ skip: s }
|
|
11
9
|
);
|
|
12
10
|
return {
|
|
13
11
|
...u,
|
|
14
|
-
products:
|
|
12
|
+
products: p
|
|
15
13
|
};
|
|
16
14
|
};
|
|
17
15
|
export {
|
|
18
|
-
|
|
16
|
+
a as usePopularProducts
|
|
19
17
|
};
|
|
20
18
|
//# sourceMappingURL=usePopularProducts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePopularProducts.js","sources":["../../../src/hooks/product/usePopularProducts.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"usePopularProducts.js","sources":["../../../src/hooks/product/usePopularProducts.ts"],"sourcesContent":["import {useShopActionInfiniteQuery} from '../../internal/reactQuery'\nimport {useShopActions} from '../../internal/useShopActions'\nimport {\n Product,\n PaginatedDataHookOptionsBase,\n PaginatedDataHookReturnsBase,\n} from '../../types'\n\ninterface UsePopularProductsParams extends PaginatedDataHookOptionsBase {}\n\ninterface UsePopularProductsReturns extends PaginatedDataHookReturnsBase {\n products: Product[] | null\n}\n\n/**\n * @param options - The options for the query\n */\nexport const usePopularProducts = (\n params?: UsePopularProductsParams\n): UsePopularProductsReturns => {\n const {getPopularProducts} = useShopActions()\n const {skip, ...shopActionParams} = params ?? {}\n\n const {data, ...rest} = useShopActionInfiniteQuery(\n ['popularProducts', shopActionParams],\n getPopularProducts,\n shopActionParams,\n {skip}\n )\n\n return {\n ...rest,\n products: data,\n }\n}\n"],"names":["usePopularProducts","params","getPopularProducts","useShopActions","skip","shopActionParams","data","rest","useShopActionInfiniteQuery"],"mappings":";;AAiBa,MAAAA,IAAqB,CAChCC,MAC8B;AACxB,QAAA,EAAC,oBAAAC,EAAkB,IAAIC,EAAe,GACtC,EAAC,MAAAC,GAAM,GAAGC,EAAgB,IAAIJ,KAAU,CAAC,GAEzC,EAAC,MAAAK,GAAM,GAAGC,EAAA,IAAQC;AAAA,IACtB,CAAC,mBAAmBH,CAAgB;AAAA,IACpCH;AAAA,IACAG;AAAA,IACA,EAAC,MAAAD,EAAI;AAAA,EACP;AAEO,SAAA;AAAA,IACL,GAAGG;AAAA,IACH,UAAUD;AAAA,EACZ;AACF;"}
|
|
@@ -1,24 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
{
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
skip: e,
|
|
13
|
-
hook: "useProduct"
|
|
14
|
-
}
|
|
15
|
-
), n = i(() => o ?? null, [o]);
|
|
1
|
+
import { useShopActions as p } from "../../internal/useShopActions.js";
|
|
2
|
+
import { useShopActionQuery as n } from "../../internal/reactQuery/useShopActionQuery.js";
|
|
3
|
+
const a = (r) => {
|
|
4
|
+
const { getProduct: s } = p(), { id: t, skip: c = !1, ...o } = r, { data: e, ...u } = n(
|
|
5
|
+
["product", t, o],
|
|
6
|
+
s,
|
|
7
|
+
{ id: t, ...o },
|
|
8
|
+
{ skip: c }
|
|
9
|
+
);
|
|
16
10
|
return {
|
|
17
11
|
...u,
|
|
18
|
-
product:
|
|
12
|
+
product: e
|
|
19
13
|
};
|
|
20
14
|
};
|
|
21
15
|
export {
|
|
22
|
-
|
|
16
|
+
a as useProduct
|
|
23
17
|
};
|
|
24
18
|
//# sourceMappingURL=useProduct.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useProduct.js","sources":["../../../src/hooks/product/useProduct.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"useProduct.js","sources":["../../../src/hooks/product/useProduct.ts"],"sourcesContent":["import {useShopActionQuery} from '../../internal/reactQuery'\nimport {useShopActions} from '../../internal/useShopActions'\nimport {DataHookOptionsBase, DataHookReturnsBase, Product} from '../../types'\n\nexport interface UseProductParams extends DataHookOptionsBase {\n /**\n * The product ID to fetch.\n */\n id: string\n}\n\ninterface UseProductReturns extends DataHookReturnsBase {\n /**\n * The product returned from the query.\n */\n product: Product | null\n}\n\nexport const useProduct = (params: UseProductParams): UseProductReturns => {\n const {getProduct} = useShopActions()\n const {id, skip = false, ...restParams} = params\n\n const {data, ...rest} = useShopActionQuery(\n ['product', id, restParams],\n getProduct,\n {id, ...restParams},\n {skip}\n )\n\n return {\n ...rest,\n product: data,\n }\n}\n"],"names":["useProduct","params","getProduct","useShopActions","id","skip","restParams","data","rest","useShopActionQuery"],"mappings":";;AAkBa,MAAAA,IAAa,CAACC,MAAgD;AACnE,QAAA,EAAC,YAAAC,EAAU,IAAIC,EAAe,GAC9B,EAAC,IAAAC,GAAI,MAAAC,IAAO,IAAO,GAAGC,EAAc,IAAAL,GAEpC,EAAC,MAAAM,GAAM,GAAGC,EAAA,IAAQC;AAAA,IACtB,CAAC,WAAWL,GAAIE,CAAU;AAAA,IAC1BJ;AAAA,IACA,EAAC,IAAAE,GAAI,GAAGE,EAAU;AAAA,IAClB,EAAC,MAAAD,EAAI;AAAA,EACP;AAEO,SAAA;AAAA,IACL,GAAGG;AAAA,IACH,SAASD;AAAA,EACX;AACF;"}
|
|
@@ -1,29 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
hook: "useProductList",
|
|
10
|
-
message: "Product list not found"
|
|
11
|
-
});
|
|
12
|
-
}, []), { data: n, ...c } = d(
|
|
13
|
-
o,
|
|
14
|
-
r,
|
|
15
|
-
{
|
|
16
|
-
skip: s,
|
|
17
|
-
hook: "useProductList",
|
|
18
|
-
validator: i
|
|
19
|
-
}
|
|
1
|
+
import { useShopActions as n } from "../../internal/useShopActions.js";
|
|
2
|
+
import { useShopActionInfiniteQuery as e } from "../../internal/reactQuery/useShopActionInfiniteQuery.js";
|
|
3
|
+
const d = (o) => {
|
|
4
|
+
const { getProductList: s } = n(), { skip: r, ...t } = o ?? {}, { data: i, ...c } = e(
|
|
5
|
+
["productList", t],
|
|
6
|
+
s,
|
|
7
|
+
t,
|
|
8
|
+
{ skip: r }
|
|
20
9
|
);
|
|
21
10
|
return {
|
|
22
11
|
...c,
|
|
23
|
-
productList:
|
|
12
|
+
productList: i
|
|
24
13
|
};
|
|
25
14
|
};
|
|
26
15
|
export {
|
|
27
|
-
|
|
16
|
+
d as useProductList
|
|
28
17
|
};
|
|
29
18
|
//# sourceMappingURL=useProductList.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useProductList.js","sources":["../../../src/hooks/product/useProductList.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"useProductList.js","sources":["../../../src/hooks/product/useProductList.ts"],"sourcesContent":["import {useShopActionInfiniteQuery} from '../../internal/reactQuery'\nimport {useShopActions} from '../../internal/useShopActions'\nimport {\n ProductList,\n PaginatedDataHookOptionsBase,\n PaginatedDataHookReturnsBase,\n} from '../../types'\n\ninterface UseProductListParams extends PaginatedDataHookOptionsBase {\n /**\n * The GID of the product list. E.g. `gid://shopapp/ProductList/123`.\n */\n id?: string\n /**\n * The public ID of the product list.\n */\n publicId?: string\n}\n\ninterface UseProductListResult extends PaginatedDataHookReturnsBase {\n productList: ProductList | null\n}\n\nexport const useProductList = (\n params?: UseProductListParams\n): UseProductListResult => {\n const {getProductList} = useShopActions()\n const {skip, ...shopActionParams} = params ?? {}\n\n const {data, ...rest} = useShopActionInfiniteQuery(\n ['productList', shopActionParams],\n getProductList,\n shopActionParams,\n {skip}\n )\n\n return {\n ...rest,\n productList: data,\n }\n}\n"],"names":["useProductList","params","getProductList","useShopActions","skip","shopActionParams","data","rest","useShopActionInfiniteQuery"],"mappings":";;AAuBa,MAAAA,IAAiB,CAC5BC,MACyB;AACnB,QAAA,EAAC,gBAAAC,EAAc,IAAIC,EAAe,GAClC,EAAC,MAAAC,GAAM,GAAGC,EAAgB,IAAIJ,KAAU,CAAC,GAEzC,EAAC,MAAAK,GAAM,GAAGC,EAAA,IAAQC;AAAA,IACtB,CAAC,eAAeH,CAAgB;AAAA,IAChCH;AAAA,IACAG;AAAA,IACA,EAAC,MAAAD,EAAI;AAAA,EACP;AAEO,SAAA;AAAA,IACL,GAAGG;AAAA,IACH,aAAaD;AAAA,EACf;AACF;"}
|
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import { useShopActions as
|
|
2
|
-
import {
|
|
3
|
-
const
|
|
4
|
-
const { getProductLists:
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
hook: "useProductLists"
|
|
10
|
-
}
|
|
1
|
+
import { useShopActions as n } from "../../internal/useShopActions.js";
|
|
2
|
+
import { useShopActionInfiniteQuery as e } from "../../internal/reactQuery/useShopActionInfiniteQuery.js";
|
|
3
|
+
const d = (s) => {
|
|
4
|
+
const { getProductLists: o } = n(), { skip: r, ...t } = s ?? {}, { data: i, ...c } = e(
|
|
5
|
+
["productLists", t],
|
|
6
|
+
o,
|
|
7
|
+
t,
|
|
8
|
+
{ skip: r }
|
|
11
9
|
);
|
|
12
10
|
return {
|
|
13
|
-
...
|
|
14
|
-
productLists:
|
|
11
|
+
...c,
|
|
12
|
+
productLists: i
|
|
15
13
|
};
|
|
16
14
|
};
|
|
17
15
|
export {
|
|
18
|
-
|
|
16
|
+
d as useProductLists
|
|
19
17
|
};
|
|
20
18
|
//# sourceMappingURL=useProductLists.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useProductLists.js","sources":["../../../src/hooks/product/useProductLists.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"useProductLists.js","sources":["../../../src/hooks/product/useProductLists.ts"],"sourcesContent":["import {useShopActionInfiniteQuery} from '../../internal/reactQuery'\nimport {useShopActions} from '../../internal/useShopActions'\nimport {\n PaginatedDataHookOptionsBase,\n PaginatedDataHookReturnsBase,\n ProductList,\n} from '../../types'\n\ninterface UseProductListsParams extends PaginatedDataHookOptionsBase {\n /**\n * The number of products to fetch per product list.\n */\n itemsFirst?: number\n}\n\ninterface UseProductListsResult extends PaginatedDataHookReturnsBase {\n productLists: ProductList[] | null\n}\n\nexport const useProductLists = (\n params?: UseProductListsParams\n): UseProductListsResult => {\n const {getProductLists} = useShopActions()\n const {skip, ...shopActionParams} = params ?? {}\n\n const {data, ...rest} = useShopActionInfiniteQuery(\n ['productLists', shopActionParams],\n getProductLists,\n shopActionParams,\n {skip}\n )\n\n return {\n ...rest,\n productLists: data,\n }\n}\n"],"names":["useProductLists","params","getProductLists","useShopActions","skip","shopActionParams","data","rest","useShopActionInfiniteQuery"],"mappings":";;AAmBa,MAAAA,IAAkB,CAC7BC,MAC0B;AACpB,QAAA,EAAC,iBAAAC,EAAe,IAAIC,EAAe,GACnC,EAAC,MAAAC,GAAM,GAAGC,EAAgB,IAAIJ,KAAU,CAAC,GAEzC,EAAC,MAAAK,GAAM,GAAGC,EAAA,IAAQC;AAAA,IACtB,CAAC,gBAAgBH,CAAgB;AAAA,IACjCH;AAAA,IACAG;AAAA,IACA,EAAC,MAAAD,EAAI;AAAA,EACP;AAEO,SAAA;AAAA,IACL,GAAGG;AAAA,IACH,cAAcD;AAAA,EAChB;AACF;"}
|
|
@@ -1,24 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
{
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
skip: s,
|
|
13
|
-
hook: "useProductMedia"
|
|
14
|
-
}
|
|
15
|
-
), n = c(() => t ?? null, [t]);
|
|
1
|
+
import { useShopActions as c } from "../../internal/useShopActions.js";
|
|
2
|
+
import { useShopActionInfiniteQuery as d } from "../../internal/reactQuery/useShopActionInfiniteQuery.js";
|
|
3
|
+
const p = (e) => {
|
|
4
|
+
const { getProductMedia: r } = c(), { id: t, skip: s = !1, ...o } = e, { data: i, ...a } = d(
|
|
5
|
+
["productMedia", t, o],
|
|
6
|
+
r,
|
|
7
|
+
{ id: t, ...o },
|
|
8
|
+
{ skip: s }
|
|
9
|
+
);
|
|
16
10
|
return {
|
|
17
|
-
...
|
|
18
|
-
media:
|
|
11
|
+
...a,
|
|
12
|
+
media: i
|
|
19
13
|
};
|
|
20
14
|
};
|
|
21
15
|
export {
|
|
22
|
-
|
|
16
|
+
p as useProductMedia
|
|
23
17
|
};
|
|
24
18
|
//# sourceMappingURL=useProductMedia.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useProductMedia.js","sources":["../../../src/hooks/product/useProductMedia.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"useProductMedia.js","sources":["../../../src/hooks/product/useProductMedia.ts"],"sourcesContent":["import {useShopActionInfiniteQuery} from '../../internal/reactQuery'\nimport {useShopActions} from '../../internal/useShopActions'\nimport {\n PaginatedDataHookOptionsBase,\n PaginatedDataHookReturnsBase,\n ProductMedia,\n} from '../../types'\n\nexport interface UseProductMediaParams extends PaginatedDataHookOptionsBase {\n /**\n * The product ID to fetch media for.\n */\n id: string\n}\n\ninterface UseProductMediaReturns extends PaginatedDataHookReturnsBase {\n /**\n * The product media returned from the query.\n */\n media: ProductMedia[] | null\n}\n\nexport const useProductMedia = (\n params: UseProductMediaParams\n): UseProductMediaReturns => {\n const {getProductMedia} = useShopActions()\n const {id, skip = false, ...restParams} = params\n\n const {data, ...rest} = useShopActionInfiniteQuery(\n ['productMedia', id, restParams],\n getProductMedia,\n {id, ...restParams},\n {skip}\n )\n\n return {\n ...rest,\n media: data,\n }\n}\n"],"names":["useProductMedia","params","getProductMedia","useShopActions","id","skip","restParams","data","rest","useShopActionInfiniteQuery"],"mappings":";;AAsBa,MAAAA,IAAkB,CAC7BC,MAC2B;AACrB,QAAA,EAAC,iBAAAC,EAAe,IAAIC,EAAe,GACnC,EAAC,IAAAC,GAAI,MAAAC,IAAO,IAAO,GAAGC,EAAc,IAAAL,GAEpC,EAAC,MAAAM,GAAM,GAAGC,EAAA,IAAQC;AAAA,IACtB,CAAC,gBAAgBL,GAAIE,CAAU;AAAA,IAC/BJ;AAAA,IACA,EAAC,IAAAE,GAAI,GAAGE,EAAU;AAAA,IAClB,EAAC,MAAAD,EAAI;AAAA,EACP;AAEO,SAAA;AAAA,IACL,GAAGG;AAAA,IACH,OAAOD;AAAA,EACT;AACF;"}
|
|
@@ -1,45 +1,52 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
import
|
|
3
|
-
import { useShopActions as
|
|
4
|
-
import {
|
|
5
|
-
const
|
|
6
|
-
const { getProductSearch:
|
|
1
|
+
import { useState as S, useCallback as y, useEffect as h } from "react";
|
|
2
|
+
import b from "../../_virtual/debounce.js";
|
|
3
|
+
import { useShopActions as g } from "../../internal/useShopActions.js";
|
|
4
|
+
import { useShopActionInfiniteQuery as k } from "../../internal/reactQuery/useShopActionInfiniteQuery.js";
|
|
5
|
+
const x = (a) => {
|
|
6
|
+
const { getProductSearch: d } = g(), {
|
|
7
7
|
query: e,
|
|
8
|
-
filters:
|
|
9
|
-
sortBy:
|
|
10
|
-
includeSensitive:
|
|
11
|
-
skip:
|
|
12
|
-
...
|
|
13
|
-
} =
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
filters: o,
|
|
9
|
+
sortBy: s,
|
|
10
|
+
includeSensitive: c = !1,
|
|
11
|
+
skip: f = !1,
|
|
12
|
+
...u
|
|
13
|
+
} = a ?? {}, [t, p] = S(e), r = y(
|
|
14
|
+
b((n) => {
|
|
15
|
+
p((i) => i === n ? i : n);
|
|
16
16
|
}, 300),
|
|
17
17
|
[]
|
|
18
18
|
);
|
|
19
|
-
|
|
19
|
+
h(() => (r(e), () => {
|
|
20
20
|
r.cancel();
|
|
21
21
|
}), [e, r]);
|
|
22
|
-
const { data:
|
|
23
|
-
|
|
22
|
+
const { data: m, ...l } = k(
|
|
23
|
+
[
|
|
24
|
+
"productSearch",
|
|
25
|
+
t,
|
|
26
|
+
o,
|
|
27
|
+
s,
|
|
28
|
+
c,
|
|
29
|
+
u
|
|
30
|
+
],
|
|
31
|
+
d,
|
|
24
32
|
{
|
|
25
33
|
query: t,
|
|
26
|
-
filters:
|
|
27
|
-
sortBy:
|
|
28
|
-
includeSensitive:
|
|
29
|
-
...
|
|
34
|
+
filters: o,
|
|
35
|
+
sortBy: s,
|
|
36
|
+
includeSensitive: c,
|
|
37
|
+
...u
|
|
30
38
|
},
|
|
31
39
|
{
|
|
32
|
-
skip:
|
|
33
|
-
hook: "useProductSearch"
|
|
40
|
+
skip: f || t.trim().length === 0
|
|
34
41
|
}
|
|
35
|
-
)
|
|
42
|
+
);
|
|
36
43
|
return {
|
|
37
|
-
...
|
|
38
|
-
products:
|
|
44
|
+
...l,
|
|
45
|
+
products: m,
|
|
39
46
|
isTyping: t !== e
|
|
40
47
|
};
|
|
41
48
|
};
|
|
42
49
|
export {
|
|
43
|
-
|
|
50
|
+
x as useProductSearch
|
|
44
51
|
};
|
|
45
52
|
//# sourceMappingURL=useProductSearch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useProductSearch.js","sources":["../../../src/hooks/product/useProductSearch.ts"],"sourcesContent":["import {useCallback, useEffect,
|
|
1
|
+
{"version":3,"file":"useProductSearch.js","sources":["../../../src/hooks/product/useProductSearch.ts"],"sourcesContent":["import {useCallback, useEffect, useState} from 'react'\n\nimport debounce from 'lodash/debounce'\n\nimport {useShopActionInfiniteQuery} from '../../internal/reactQuery'\nimport {useShopActions} from '../../internal/useShopActions'\nimport {\n PaginatedDataHookOptionsBase,\n PaginatedDataHookReturnsBase,\n Product,\n ProductFilters,\n ProductSearchSortBy,\n} from '../../types'\n\nexport interface UseProductSearchParams extends PaginatedDataHookOptionsBase {\n /**\n * The search query.\n */\n query: string\n /**\n * The filters to apply to the search.\n */\n filters?: ProductFilters\n /**\n * The sort order of the results.\n */\n sortBy?: ProductSearchSortBy\n /**\n * Whether to include sensitive products.\n */\n includeSensitive?: boolean\n}\n\ninterface UseProductSearchReturns extends PaginatedDataHookReturnsBase {\n /**\n * The products returned from the query.\n */\n products: Product[] | null\n /**\n * Whether the user is typing.\n */\n isTyping: boolean\n}\n\nexport const useProductSearch = (\n params: UseProductSearchParams\n): UseProductSearchReturns => {\n const {getProductSearch} = useShopActions()\n const {\n query,\n filters,\n sortBy,\n includeSensitive = false,\n skip = false,\n ...restParams\n } = params ?? {}\n\n const [debouncedQuery, setDebouncedQuery] = useState<string>(query)\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const debouncedSetQuery = useCallback(\n debounce((newQuery: string) => {\n setDebouncedQuery(prev => {\n // Only update if the query actually changed\n if (prev === newQuery) return prev\n return newQuery\n })\n }, 300),\n []\n )\n\n useEffect(() => {\n debouncedSetQuery(query)\n\n return () => {\n debouncedSetQuery.cancel()\n }\n }, [query, debouncedSetQuery])\n\n // Use our Shop Action infinite query helper\n const {data, ...rest} = useShopActionInfiniteQuery(\n [\n 'productSearch',\n debouncedQuery,\n filters,\n sortBy,\n includeSensitive,\n restParams,\n ],\n getProductSearch,\n {\n query: debouncedQuery,\n filters,\n sortBy,\n includeSensitive,\n ...restParams,\n },\n {\n skip: skip || debouncedQuery.trim().length === 0,\n }\n )\n\n return {\n ...rest,\n products: data,\n isTyping: debouncedQuery !== query,\n }\n}\n"],"names":["useProductSearch","params","getProductSearch","useShopActions","query","filters","sortBy","includeSensitive","skip","restParams","debouncedQuery","setDebouncedQuery","useState","debouncedSetQuery","useCallback","debounce","newQuery","prev","useEffect","data","rest","useShopActionInfiniteQuery"],"mappings":";;;;AA4Ca,MAAAA,IAAmB,CAC9BC,MAC4B;AACtB,QAAA,EAAC,kBAAAC,EAAgB,IAAIC,EAAe,GACpC;AAAA,IACJ,OAAAC;AAAA,IACA,SAAAC;AAAA,IACA,QAAAC;AAAA,IACA,kBAAAC,IAAmB;AAAA,IACnB,MAAAC,IAAO;AAAA,IACP,GAAGC;AAAA,EACL,IAAIR,KAAU,CAAC,GAET,CAACS,GAAgBC,CAAiB,IAAIC,EAAiBR,CAAK,GAG5DS,IAAoBC;AAAA,IACxBC,EAAS,CAACC,MAAqB;AAC7B,MAAAL,EAAkB,CAAQM,MAEpBA,MAASD,IAAiBC,IACvBD,CACR;AAAA,OACA,GAAG;AAAA,IACN,CAAA;AAAA,EACF;AAEA,EAAAE,EAAU,OACRL,EAAkBT,CAAK,GAEhB,MAAM;AACX,IAAAS,EAAkB,OAAO;AAAA,EAC3B,IACC,CAACT,GAAOS,CAAiB,CAAC;AAG7B,QAAM,EAAC,MAAAM,GAAM,GAAGC,EAAA,IAAQC;AAAA,IACtB;AAAA,MACE;AAAA,MACAX;AAAA,MACAL;AAAA,MACAC;AAAA,MACAC;AAAA,MACAE;AAAA,IACF;AAAA,IACAP;AAAA,IACA;AAAA,MACE,OAAOQ;AAAA,MACP,SAAAL;AAAA,MACA,QAAAC;AAAA,MACA,kBAAAC;AAAA,MACA,GAAGE;AAAA,IACL;AAAA,IACA;AAAA,MACE,MAAMD,KAAQE,EAAe,KAAA,EAAO,WAAW;AAAA,IAAA;AAAA,EAEnD;AAEO,SAAA;AAAA,IACL,GAAGU;AAAA,IACH,UAAUD;AAAA,IACV,UAAUT,MAAmBN;AAAA,EAC/B;AACF;"}
|
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
{
|
|
9
|
-
|
|
10
|
-
hook: "useProductVariants"
|
|
11
|
-
}
|
|
12
|
-
), e = i(() => t ?? null, [t]);
|
|
1
|
+
import { useShopActions as e } from "../../internal/useShopActions.js";
|
|
2
|
+
import { useShopActionInfiniteQuery as i } from "../../internal/reactQuery/useShopActionInfiniteQuery.js";
|
|
3
|
+
const p = (r) => {
|
|
4
|
+
const { getProductVariants: s } = e(), { skip: o = !1, ...t } = r, { data: a, ...n } = i(
|
|
5
|
+
["productVariants", t],
|
|
6
|
+
s,
|
|
7
|
+
t,
|
|
8
|
+
{ skip: o }
|
|
9
|
+
);
|
|
13
10
|
return {
|
|
14
11
|
...n,
|
|
15
|
-
variants:
|
|
12
|
+
variants: a
|
|
16
13
|
};
|
|
17
14
|
};
|
|
18
15
|
export {
|
|
19
|
-
|
|
16
|
+
p as useProductVariants
|
|
20
17
|
};
|
|
21
18
|
//# sourceMappingURL=useProductVariants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useProductVariants.js","sources":["../../../src/hooks/product/useProductVariants.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"useProductVariants.js","sources":["../../../src/hooks/product/useProductVariants.ts"],"sourcesContent":["import {useShopActionInfiniteQuery} from '../../internal/reactQuery'\nimport {useShopActions} from '../../internal/useShopActions'\nimport {\n PaginatedDataHookOptionsBase,\n PaginatedDataHookReturnsBase,\n ProductVariant,\n} from '../../types'\n\nexport interface UseProductVariantsParams extends PaginatedDataHookOptionsBase {\n /**\n * The product ID to fetch variants for.\n */\n id: string\n}\n\ninterface UseProductVariantsReturns extends PaginatedDataHookReturnsBase {\n /**\n * The product variants returned from the query.\n */\n variants: ProductVariant[] | null\n}\n\nexport const useProductVariants = (\n params: UseProductVariantsParams\n): UseProductVariantsReturns => {\n const {getProductVariants} = useShopActions()\n const {skip = false, ...restParams} = params\n\n const {data, ...rest} = useShopActionInfiniteQuery(\n ['productVariants', restParams],\n getProductVariants,\n restParams,\n {skip}\n )\n\n return {\n ...rest,\n variants: data,\n }\n}\n"],"names":["useProductVariants","params","getProductVariants","useShopActions","skip","restParams","data","rest","useShopActionInfiniteQuery"],"mappings":";;AAsBa,MAAAA,IAAqB,CAChCC,MAC8B;AACxB,QAAA,EAAC,oBAAAC,EAAkB,IAAIC,EAAe,GACtC,EAAC,MAAAC,IAAO,IAAO,GAAGC,EAAc,IAAAJ,GAEhC,EAAC,MAAAK,GAAM,GAAGC,EAAA,IAAQC;AAAA,IACtB,CAAC,mBAAmBH,CAAU;AAAA,IAC9BH;AAAA,IACAG;AAAA,IACA,EAAC,MAAAD,EAAI;AAAA,EACP;AAEO,SAAA;AAAA,IACL,GAAGG;AAAA,IACH,UAAUD;AAAA,EACZ;AACF;"}
|