@shopify/shop-minis-react 0.0.0-snapshot.20251219160956 → 0.0.0-snapshot.20251222174301

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 (43) hide show
  1. package/dist/components/navigation/minis-router.js +8 -15
  2. package/dist/components/navigation/minis-router.js.map +1 -1
  3. package/dist/hooks/intents/useBarcodeScanner.js +10 -0
  4. package/dist/hooks/intents/useBarcodeScanner.js.map +1 -0
  5. package/dist/hooks/intents/useContentShare.js +10 -0
  6. package/dist/hooks/intents/useContentShare.js.map +1 -0
  7. package/dist/hooks/intents/useImageCapture.js +10 -0
  8. package/dist/hooks/intents/useImageCapture.js.map +1 -0
  9. package/dist/hooks/intents/useLocationSelection.js +10 -0
  10. package/dist/hooks/intents/useLocationSelection.js.map +1 -0
  11. package/dist/hooks/intents/usePaymentRequest.js +10 -0
  12. package/dist/hooks/intents/usePaymentRequest.js.map +1 -0
  13. package/dist/hooks/intents/useProductSelection.js +10 -0
  14. package/dist/hooks/intents/useProductSelection.js.map +1 -0
  15. package/dist/index.js +131 -118
  16. package/dist/index.js.map +1 -1
  17. package/dist/internal/useHandleIntent.js +26 -0
  18. package/dist/internal/useHandleIntent.js.map +1 -0
  19. package/dist/internal/useShopIntents.js +7 -0
  20. package/dist/internal/useShopIntents.js.map +1 -0
  21. package/dist/mocks.js +10 -11
  22. package/dist/mocks.js.map +1 -1
  23. package/dist/shop-minis-platform/src/intents/shared.js +19 -0
  24. package/dist/shop-minis-platform/src/intents/shared.js.map +1 -0
  25. package/package.json +2 -2
  26. package/src/components/navigation/minis-router.tsx +1 -9
  27. package/src/hooks/index.ts +3 -1
  28. package/src/hooks/intents/index.ts +42 -0
  29. package/src/hooks/intents/useBarcodeScanner.ts +43 -0
  30. package/src/hooks/intents/useContentShare.ts +47 -0
  31. package/src/hooks/intents/useImageCapture.ts +45 -0
  32. package/src/hooks/intents/useLocationSelection.ts +45 -0
  33. package/src/hooks/intents/usePaymentRequest.ts +47 -0
  34. package/src/hooks/intents/useProductSelection.ts +45 -0
  35. package/src/internal/useHandleIntent.ts +101 -0
  36. package/src/internal/useShopIntents.ts +13 -0
  37. package/src/mocks.ts +0 -1
  38. package/dist/hooks/events/useOnNavigateBack.js +0 -14
  39. package/dist/hooks/events/useOnNavigateBack.js.map +0 -1
  40. package/dist/internal/navigation-manager.js +0 -28
  41. package/dist/internal/navigation-manager.js.map +0 -1
  42. package/src/hooks/events/useOnNavigateBack.ts +0 -16
  43. package/src/internal/navigation-manager.tsx +0 -41
@@ -1,21 +1,14 @@
1
- import { jsxs as t, jsx as r } from "react/jsx-runtime";
2
- import { BrowserRouter as n } from "../../shop-minis-react/node_modules/.pnpm/react-router@7.7.0_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/react-router/dist/development/chunk-EF7DTUVF.js";
3
- import { NavigationManager as e } from "../../internal/navigation-manager.js";
4
- import { TransitionContainer as a } from "./transition-container.js";
5
- function x({
1
+ import { jsx as r } from "react/jsx-runtime";
2
+ import { BrowserRouter as i } from "../../shop-minis-react/node_modules/.pnpm/react-router@7.7.0_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/react-router/dist/development/chunk-EF7DTUVF.js";
3
+ import { TransitionContainer as e } from "./transition-container.js";
4
+ function s({
6
5
  children: o,
7
- viewTransitions: m = !1,
8
- ...i
6
+ viewTransitions: n = !1,
7
+ ...t
9
8
  }) {
10
- return m ? /* @__PURE__ */ t(n, { ...i, children: [
11
- /* @__PURE__ */ r(e, {}),
12
- /* @__PURE__ */ r(a, { children: o })
13
- ] }) : /* @__PURE__ */ t(n, { ...i, children: [
14
- /* @__PURE__ */ r(e, {}),
15
- o
16
- ] });
9
+ return n ? /* @__PURE__ */ r(i, { ...t, children: /* @__PURE__ */ r(e, { children: o }) }) : /* @__PURE__ */ r(i, { ...t, children: o });
17
10
  }
18
11
  export {
19
- x as MinisRouter
12
+ s as MinisRouter
20
13
  };
21
14
  //# sourceMappingURL=minis-router.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"minis-router.js","sources":["../../../src/components/navigation/minis-router.tsx"],"sourcesContent":["import {BrowserRouter, BrowserRouterProps} from 'react-router'\n\nimport {NavigationManager} from '../../internal/navigation-manager'\n\nimport {TransitionContainer} from './transition-container'\n\nexport interface MinisRouterProps extends BrowserRouterProps {\n viewTransitions?: boolean\n}\n\nexport function MinisRouter({\n children,\n viewTransitions = false,\n ...props\n}: MinisRouterProps) {\n if (viewTransitions) {\n return (\n <BrowserRouter {...props}>\n <NavigationManager />\n <TransitionContainer>{children}</TransitionContainer>\n </BrowserRouter>\n )\n }\n\n return (\n <BrowserRouter {...props}>\n <NavigationManager />\n {children}\n </BrowserRouter>\n )\n}\n"],"names":["MinisRouter","children","viewTransitions","props","jsxs","BrowserRouter","jsx","NavigationManager","TransitionContainer"],"mappings":";;;;AAUO,SAASA,EAAY;AAAA,EAC1B,UAAAC;AAAA,EACA,iBAAAC,IAAkB;AAAA,EAClB,GAAGC;AACL,GAAqB;AACnB,SAAID,IAEA,gBAAAE,EAACC,GAAe,EAAA,GAAGF,GACjB,UAAA;AAAA,IAAA,gBAAAG,EAACC,GAAkB,EAAA;AAAA,IACnB,gBAAAD,EAACE,KAAqB,UAAAP,EAAS,CAAA;AAAA,EAAA,GACjC,IAKF,gBAAAG,EAACC,GAAe,EAAA,GAAGF,GACjB,UAAA;AAAA,IAAA,gBAAAG,EAACC,GAAkB,EAAA;AAAA,IAClBN;AAAA,EAAA,GACH;AAEJ;"}
1
+ {"version":3,"file":"minis-router.js","sources":["../../../src/components/navigation/minis-router.tsx"],"sourcesContent":["import {BrowserRouter, BrowserRouterProps} from 'react-router'\n\nimport {TransitionContainer} from './transition-container'\n\nexport interface MinisRouterProps extends BrowserRouterProps {\n viewTransitions?: boolean\n}\n\nexport function MinisRouter({\n children,\n viewTransitions = false,\n ...props\n}: MinisRouterProps) {\n if (viewTransitions) {\n return (\n <BrowserRouter {...props}>\n <TransitionContainer>{children}</TransitionContainer>\n </BrowserRouter>\n )\n }\n\n return <BrowserRouter {...props}>{children}</BrowserRouter>\n}\n"],"names":["MinisRouter","children","viewTransitions","props","BrowserRouter","jsx","TransitionContainer"],"mappings":";;;AAQO,SAASA,EAAY;AAAA,EAC1B,UAAAC;AAAA,EACA,iBAAAC,IAAkB;AAAA,EAClB,GAAGC;AACL,GAAqB;AACnB,SAAID,sBAECE,GAAe,EAAA,GAAGD,GACjB,UAAC,gBAAAE,EAAAC,GAAA,EAAqB,UAAAL,EAAS,CAAA,GACjC,IAII,gBAAAI,EAAAD,GAAA,EAAe,GAAGD,GAAQ,UAAAF,EAAS,CAAA;AAC7C;"}
@@ -0,0 +1,10 @@
1
+ import { useHandleIntent as t } from "../../internal/useHandleIntent.js";
2
+ import { useShopIntents as o } from "../../internal/useShopIntents.js";
3
+ const c = (n) => {
4
+ const e = o();
5
+ return t(e.scanBarcode, n);
6
+ };
7
+ export {
8
+ c as useBarcodeScanner
9
+ };
10
+ //# sourceMappingURL=useBarcodeScanner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useBarcodeScanner.js","sources":["../../../src/hooks/intents/useBarcodeScanner.ts"],"sourcesContent":["import {\n useHandleIntent,\n HandleIntentOptions,\n} from '../../internal/useHandleIntent'\nimport {useShopIntents} from '../../internal/useShopIntents'\n\nimport type {\n ScanBarcodeIntentParams,\n ScanBarcodeIntentResult,\n} from '@shopify/shop-minis-platform'\n\n/**\n * Hook to scan barcodes or QR codes\n *\n * This intent opens the camera to scan barcodes or QR codes.\n *\n * @example\n * const scanBarcode = useBarcodeScanner({\n * onCancel: () => console.log('User cancelled'),\n * })\n *\n * const result = await scanBarcode({\n * types: ['qr', 'ean13'],\n * instruction: 'Scan product barcode'\n * })\n *\n * if (result) {\n * console.log('Scanned:', result.barcodes)\n * }\n */\nexport const useBarcodeScanner = (\n options?: HandleIntentOptions<ScanBarcodeIntentResult>\n) => {\n const intents = useShopIntents()\n return useHandleIntent(intents.scanBarcode, options)\n}\n\n/**\n * Type helper for the barcode scanner function\n */\nexport type BarcodeScannerFunction = (\n params: ScanBarcodeIntentParams\n) => Promise<ScanBarcodeIntentResult | void>\n"],"names":["useBarcodeScanner","options","intents","useShopIntents","useHandleIntent"],"mappings":";;AA8Ba,MAAAA,IAAoB,CAC/BC,MACG;AACH,QAAMC,IAAUC,EAAe;AACxB,SAAAC,EAAgBF,EAAQ,aAAaD,CAAO;AACrD;"}
@@ -0,0 +1,10 @@
1
+ import { useHandleIntent as e } from "../../internal/useHandleIntent.js";
2
+ import { useShopIntents as o } from "../../internal/useShopIntents.js";
3
+ const m = (t) => {
4
+ const n = o();
5
+ return e(n.shareContent, t);
6
+ };
7
+ export {
8
+ m as useContentShare
9
+ };
10
+ //# sourceMappingURL=useContentShare.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useContentShare.js","sources":["../../../src/hooks/intents/useContentShare.ts"],"sourcesContent":["import {\n useHandleIntent,\n HandleIntentOptions,\n} from '../../internal/useHandleIntent'\nimport {useShopIntents} from '../../internal/useShopIntents'\n\nimport type {\n ShareContentIntentParams,\n ShareContentIntentResult,\n} from '@shopify/shop-minis-platform'\n\n/**\n * Hook to share content via the Shop app's native share sheet\n *\n * This intent opens the native share sheet to let the user\n * share content to various platforms.\n *\n * @example\n * const shareContent = useContentShare({\n * onCancel: () => console.log('User cancelled sharing'),\n * })\n *\n * const result = await shareContent({\n * type: 'product',\n * content: {\n * title: 'Check out this product!',\n * url: 'https://shop.app/products/123'\n * }\n * })\n *\n * if (result?.shared) {\n * console.log('Content shared to:', result.platform)\n * }\n */\nexport const useContentShare = (\n options?: HandleIntentOptions<ShareContentIntentResult>\n) => {\n const intents = useShopIntents()\n return useHandleIntent(intents.shareContent, options)\n}\n\n/**\n * Type helper for the content share function\n */\nexport type ContentShareFunction = (\n params: ShareContentIntentParams\n) => Promise<ShareContentIntentResult | void>\n"],"names":["useContentShare","options","intents","useShopIntents","useHandleIntent"],"mappings":";;AAkCa,MAAAA,IAAkB,CAC7BC,MACG;AACH,QAAMC,IAAUC,EAAe;AACxB,SAAAC,EAAgBF,EAAQ,cAAcD,CAAO;AACtD;"}
@@ -0,0 +1,10 @@
1
+ import { useHandleIntent as n } from "../../internal/useHandleIntent.js";
2
+ import { useShopIntents as r } from "../../internal/useShopIntents.js";
3
+ const m = (t) => {
4
+ const e = r();
5
+ return n(e.captureImage, t);
6
+ };
7
+ export {
8
+ m as useImageCapture
9
+ };
10
+ //# sourceMappingURL=useImageCapture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useImageCapture.js","sources":["../../../src/hooks/intents/useImageCapture.ts"],"sourcesContent":["import {\n useHandleIntent,\n HandleIntentOptions,\n} from '../../internal/useHandleIntent'\nimport {useShopIntents} from '../../internal/useShopIntents'\n\nimport type {\n CaptureImageIntentParams,\n CaptureImageIntentResult,\n} from '@shopify/shop-minis-platform'\n\n/**\n * Hook to request user to capture or select images\n *\n * This intent opens the camera or photo gallery to let the user\n * capture or select one or more images.\n *\n * @example\n * const captureImage = useImageCapture({\n * onCancel: () => console.log('User cancelled'),\n * })\n *\n * const result = await captureImage({\n * source: 'camera',\n * quality: 0.8,\n * maxWidth: 1920\n * })\n *\n * if (result) {\n * console.log('Captured images:', result.images)\n * }\n */\nexport const useImageCapture = (\n options?: HandleIntentOptions<CaptureImageIntentResult>\n) => {\n const intents = useShopIntents()\n return useHandleIntent(intents.captureImage, options)\n}\n\n/**\n * Type helper for the image capture function\n */\nexport type ImageCaptureFunction = (\n params: CaptureImageIntentParams\n) => Promise<CaptureImageIntentResult | void>\n"],"names":["useImageCapture","options","intents","useShopIntents","useHandleIntent"],"mappings":";;AAgCa,MAAAA,IAAkB,CAC7BC,MACG;AACH,QAAMC,IAAUC,EAAe;AACxB,SAAAC,EAAgBF,EAAQ,cAAcD,CAAO;AACtD;"}
@@ -0,0 +1,10 @@
1
+ import { useHandleIntent as n } from "../../internal/useHandleIntent.js";
2
+ import { useShopIntents as o } from "../../internal/useShopIntents.js";
3
+ const c = (t) => {
4
+ const e = o();
5
+ return n(e.selectLocation, t);
6
+ };
7
+ export {
8
+ c as useLocationSelection
9
+ };
10
+ //# sourceMappingURL=useLocationSelection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLocationSelection.js","sources":["../../../src/hooks/intents/useLocationSelection.ts"],"sourcesContent":["import {\n useHandleIntent,\n HandleIntentOptions,\n} from '../../internal/useHandleIntent'\nimport {useShopIntents} from '../../internal/useShopIntents'\n\nimport type {\n SelectLocationIntentParams,\n SelectLocationIntentResult,\n} from '@shopify/shop-minis-platform'\n\n/**\n * Hook to request user to select a location\n *\n * This intent shows a map interface where the user can select\n * a location and optionally get address information.\n *\n * @example\n * const selectLocation = useLocationSelection({\n * onCancel: () => console.log('User cancelled'),\n * })\n *\n * const result = await selectLocation({\n * title: 'Select delivery location',\n * locationType: 'address'\n * })\n *\n * if (result) {\n * console.log('Selected location:', result.coordinates)\n * console.log('Address:', result.address?.formattedAddress)\n * }\n */\nexport const useLocationSelection = (\n options?: HandleIntentOptions<SelectLocationIntentResult>\n) => {\n const intents = useShopIntents()\n return useHandleIntent(intents.selectLocation, options)\n}\n\n/**\n * Type helper for the location selection function\n */\nexport type LocationSelectionFunction = (\n params: SelectLocationIntentParams\n) => Promise<SelectLocationIntentResult | void>\n"],"names":["useLocationSelection","options","intents","useShopIntents","useHandleIntent"],"mappings":";;AAgCa,MAAAA,IAAuB,CAClCC,MACG;AACH,QAAMC,IAAUC,EAAe;AACxB,SAAAC,EAAgBF,EAAQ,gBAAgBD,CAAO;AACxD;"}
@@ -0,0 +1,10 @@
1
+ import { useHandleIntent as n } from "../../internal/useHandleIntent.js";
2
+ import { useShopIntents as s } from "../../internal/useShopIntents.js";
3
+ const m = (t) => {
4
+ const e = s();
5
+ return n(e.requestPayment, t);
6
+ };
7
+ export {
8
+ m as usePaymentRequest
9
+ };
10
+ //# sourceMappingURL=usePaymentRequest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePaymentRequest.js","sources":["../../../src/hooks/intents/usePaymentRequest.ts"],"sourcesContent":["import {\n useHandleIntent,\n HandleIntentOptions,\n} from '../../internal/useHandleIntent'\nimport {useShopIntents} from '../../internal/useShopIntents'\n\nimport type {\n RequestPaymentIntentParams,\n RequestPaymentIntentResult,\n} from '@shopify/shop-minis-platform'\n\n/**\n * Hook to request payment from user\n *\n * This intent opens the Shop app's payment flow to process a payment.\n *\n * **Note:** This intent requires special permissions and may have rate limits.\n *\n * @example\n * const requestPayment = usePaymentRequest({\n * onCancel: () => console.log('User cancelled payment'),\n * onError: (error) => console.error('Payment failed:', error)\n * })\n *\n * const result = await requestPayment({\n * amount: 999, // $9.99 in cents\n * currency: 'USD',\n * description: 'Premium subscription'\n * })\n *\n * if (result) {\n * console.log('Payment successful:', result.transactionId)\n * }\n */\nexport const usePaymentRequest = (\n options?: HandleIntentOptions<RequestPaymentIntentResult>\n) => {\n const intents = useShopIntents()\n return useHandleIntent(intents.requestPayment, options)\n}\n\n/**\n * Type helper for the payment request function\n */\nexport type PaymentRequestFunction = (\n params: RequestPaymentIntentParams\n) => Promise<RequestPaymentIntentResult | void>\n"],"names":["usePaymentRequest","options","intents","useShopIntents","useHandleIntent"],"mappings":";;AAkCa,MAAAA,IAAoB,CAC/BC,MACG;AACH,QAAMC,IAAUC,EAAe;AACxB,SAAAC,EAAgBF,EAAQ,gBAAgBD,CAAO;AACxD;"}
@@ -0,0 +1,10 @@
1
+ import { useHandleIntent as n } from "../../internal/useHandleIntent.js";
2
+ import { useShopIntents as o } from "../../internal/useShopIntents.js";
3
+ const c = (t) => {
4
+ const e = o();
5
+ return n(e.selectProduct, t);
6
+ };
7
+ export {
8
+ c as useProductSelection
9
+ };
10
+ //# sourceMappingURL=useProductSelection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useProductSelection.js","sources":["../../../src/hooks/intents/useProductSelection.ts"],"sourcesContent":["import {\n useHandleIntent,\n HandleIntentOptions,\n} from '../../internal/useHandleIntent'\nimport {useShopIntents} from '../../internal/useShopIntents'\n\nimport type {\n SelectProductIntentParams,\n SelectProductIntentResult,\n} from '@shopify/shop-minis-platform'\n\n/**\n * Hook to request user to select products\n *\n * This intent shows a product selection screen where the user can browse\n * and select one or more products from the Shop catalog.\n *\n * @example\n * const selectProducts = useProductSelection({\n * onCancel: () => console.log('User cancelled'),\n * })\n *\n * const result = await selectProducts({\n * multiSelect: true,\n * maxSelections: 5,\n * title: 'Choose your favorites'\n * })\n *\n * if (result) {\n * console.log('Selected products:', result.products)\n * }\n */\nexport const useProductSelection = (\n options?: HandleIntentOptions<SelectProductIntentResult>\n) => {\n const intents = useShopIntents()\n return useHandleIntent(intents.selectProduct, options)\n}\n\n/**\n * Type helper for the product selection function\n */\nexport type ProductSelectionFunction = (\n params: SelectProductIntentParams\n) => Promise<SelectProductIntentResult | void>\n"],"names":["useProductSelection","options","intents","useShopIntents","useHandleIntent"],"mappings":";;AAgCa,MAAAA,IAAsB,CACjCC,MACG;AACH,QAAMC,IAAUC,EAAe;AACxB,SAAAC,EAAgBF,EAAQ,eAAeD,CAAO;AACvD;"}
package/dist/index.js CHANGED
@@ -1,14 +1,14 @@
1
1
  import { DATA_NAVIGATION_TYPE_ATTRIBUTE as o, NAVIGATION_TYPES as t } from "./types/index.js";
2
- import { MinisContainer as i } from "./components/MinisContainer.js";
3
- import { AddToCartButton as n } from "./components/commerce/add-to-cart.js";
2
+ import { MinisContainer as n } from "./components/MinisContainer.js";
3
+ import { AddToCartButton as m } from "./components/commerce/add-to-cart.js";
4
4
  import { BuyNowButton as s } from "./components/commerce/buy-now.js";
5
- import { ProductCard as u, ProductCardBadge as f, ProductCardContainer as x, ProductCardFavoriteButton as c, ProductCardImage as d, ProductCardImageContainer as C, ProductCardInfo as g, ProductCardPrice as S, ProductCardReviewStars as A, ProductCardTitle as D } from "./components/commerce/product-card.js";
5
+ import { ProductCard as l, ProductCardBadge as f, ProductCardContainer as x, ProductCardFavoriteButton as c, ProductCardImage as d, ProductCardImageContainer as C, ProductCardInfo as g, ProductCardPrice as S, ProductCardReviewStars as A, ProductCardTitle as D } from "./components/commerce/product-card.js";
6
6
  import { ProductLink as T } from "./components/commerce/product-link.js";
7
- import { MerchantCard as I, MerchantCardContainer as R, MerchantCardHeader as B, MerchantCardInfo as E, MerchantCardName as M, MerchantCardRating as v } from "./components/commerce/merchant-card.js";
8
- import { ProductCardSkeleton as F } from "./components/commerce/product-card-skeleton.js";
9
- import { MerchantCardSkeleton as L } from "./components/commerce/merchant-card-skeleton.js";
7
+ import { MerchantCard as I, MerchantCardContainer as R, MerchantCardHeader as B, MerchantCardInfo as E, MerchantCardName as M, MerchantCardRating as w } from "./components/commerce/merchant-card.js";
8
+ import { ProductCardSkeleton as v } from "./components/commerce/product-card-skeleton.js";
9
+ import { MerchantCardSkeleton as U } from "./components/commerce/merchant-card-skeleton.js";
10
10
  import { QuantitySelector as N } from "./components/commerce/quantity-selector.js";
11
- import { Search as O, SearchInput as _, SearchProvider as y, SearchResultsList as G } from "./components/commerce/search.js";
11
+ import { Search as y, SearchInput as _, SearchProvider as G, SearchResultsList as O } from "./components/commerce/search.js";
12
12
  import { FavoriteButton as V } from "./components/commerce/favorite-button.js";
13
13
  import { ImageContentWrapper as W } from "./components/content/image-content-wrapper.js";
14
14
  import { MinisRouter as q } from "./components/navigation/minis-router.js";
@@ -19,30 +19,30 @@ import { Image as rr } from "./components/atoms/image.js";
19
19
  import { Touchable as or } from "./components/atoms/touchable.js";
20
20
  import { LongPressDetector as ar } from "./components/atoms/long-press-detector.js";
21
21
  import { AlertDialogAtom as pr } from "./components/atoms/alert-dialog.js";
22
- import { List as mr } from "./components/atoms/list.js";
23
- import { VideoPlayer as lr } from "./components/atoms/video-player.js";
22
+ import { List as ir } from "./components/atoms/list.js";
23
+ import { VideoPlayer as ur } from "./components/atoms/video-player.js";
24
24
  import { TextInput as fr } from "./components/atoms/text-input.js";
25
25
  import { ContentWrapper as cr } from "./components/atoms/content-wrapper.js";
26
26
  import { ProductVariantPrice as Cr } from "./components/atoms/product-variant-price.js";
27
27
  import { Accordion as Sr, AccordionContent as Ar, AccordionItem as Dr, AccordionTrigger as Pr } from "./components/ui/accordion.js";
28
28
  import { Alert as hr, AlertDescription as Ir, AlertTitle as Rr } from "./components/ui/alert.js";
29
- import { AlertDialog as Er, AlertDialogAction as Mr, AlertDialogCancel as vr, AlertDialogContent as wr, AlertDialogDescription as Fr, AlertDialogFooter as Ur, AlertDialogHeader as Lr, AlertDialogOverlay as br, AlertDialogPortal as Nr, AlertDialogTitle as kr, AlertDialogTrigger as Or } from "./components/ui/alert-dialog.js";
30
- import { Avatar as yr, AvatarFallback as Gr, AvatarImage as Hr } from "./components/ui/avatar.js";
29
+ import { AlertDialog as Er, AlertDialogAction as Mr, AlertDialogCancel as wr, AlertDialogContent as Fr, AlertDialogDescription as vr, AlertDialogFooter as Lr, AlertDialogHeader as Ur, AlertDialogOverlay as br, AlertDialogPortal as Nr, AlertDialogTitle as kr, AlertDialogTrigger as yr } from "./components/ui/alert-dialog.js";
30
+ import { Avatar as Gr, AvatarFallback as Or, AvatarImage as Hr } from "./components/ui/avatar.js";
31
31
  import { Badge as zr, badgeVariants as Wr } from "./components/ui/badge.js";
32
32
  import { Card as qr, CardAction as Kr, CardContent as Qr, CardDescription as Zr, CardFooter as jr, CardHeader as Jr, CardTitle as Xr } from "./components/ui/card.js";
33
33
  import { Carousel as re, CarouselContent as ee, CarouselItem as oe, CarouselNext as te, CarouselPrevious as ae } from "./components/ui/carousel.js";
34
34
  import { Checkbox as pe } from "./components/ui/checkbox.js";
35
- import { Dialog as me, DialogClose as se, DialogContent as le, DialogDescription as ue, DialogFooter as fe, DialogHeader as xe, DialogOverlay as ce, DialogPortal as de, DialogTitle as Ce, DialogTrigger as ge } from "./components/ui/dialog.js";
35
+ import { Dialog as ie, DialogClose as se, DialogContent as ue, DialogDescription as le, DialogFooter as fe, DialogHeader as xe, DialogOverlay as ce, DialogPortal as de, DialogTitle as Ce, DialogTrigger as ge } from "./components/ui/dialog.js";
36
36
  import { Drawer as Ae, DrawerClose as De, DrawerContent as Pe, DrawerDescription as Te, DrawerFooter as he, DrawerHeader as Ie, DrawerOverlay as Re, DrawerPortal as Be, DrawerTitle as Ee, DrawerTrigger as Me } from "./components/ui/drawer.js";
37
- import { Input as we } from "./components/ui/input.js";
38
- import { Label as Ue } from "./components/ui/label.js";
37
+ import { Input as Fe } from "./components/ui/input.js";
38
+ import { Label as Le } from "./components/ui/label.js";
39
39
  import { Progress as be } from "./components/ui/progress.js";
40
- import { RadioGroup as ke, RadioGroupItem as Oe } from "./components/ui/radio-group.js";
41
- import { ResizableHandle as ye, ResizablePanel as Ge, ResizablePanelGroup as He } from "./components/ui/resizable.js";
40
+ import { RadioGroup as ke, RadioGroupItem as ye } from "./components/ui/radio-group.js";
41
+ import { ResizableHandle as Ge, ResizablePanel as Oe, ResizablePanelGroup as He } from "./components/ui/resizable.js";
42
42
  import { ScrollArea as ze, ScrollBar as We } from "./components/ui/scroll-area.js";
43
43
  import { Select as qe, SelectContent as Ke, SelectGroup as Qe, SelectItem as Ze, SelectLabel as je, SelectScrollDownButton as Je, SelectScrollUpButton as Xe, SelectSeparator as $e, SelectTrigger as ro, SelectValue as eo } from "./components/ui/select.js";
44
44
  import { Separator as to } from "./components/ui/separator.js";
45
- import { Sheet as io, SheetClose as po, SheetContent as no, SheetDescription as mo, SheetFooter as so, SheetHeader as lo, SheetTitle as uo, SheetTrigger as fo } from "./components/ui/sheet.js";
45
+ import { Sheet as no, SheetClose as po, SheetContent as mo, SheetDescription as io, SheetFooter as so, SheetHeader as uo, SheetTitle as lo, SheetTrigger as fo } from "./components/ui/sheet.js";
46
46
  import { Toaster as co } from "./components/ui/sonner.js";
47
47
  import { toast as go } from "./shop-minis-react/node_modules/.pnpm/sonner@2.0.5_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/sonner/dist/index.js";
48
48
  import { Skeleton as Ao } from "./components/ui/skeleton.js";
@@ -50,12 +50,12 @@ import { useRecentProducts as Po } from "./hooks/user/useRecentProducts.js";
50
50
  import { useRecentShops as ho } from "./hooks/user/useRecentShops.js";
51
51
  import { useSavedProducts as Ro } from "./hooks/user/useSavedProducts.js";
52
52
  import { useSavedProductsActions as Eo } from "./hooks/user/useSavedProductsActions.js";
53
- import { useFollowedShops as vo } from "./hooks/user/useFollowedShops.js";
54
- import { useFollowedShopsActions as Fo } from "./hooks/user/useFollowedShopsActions.js";
55
- import { useCurrentUser as Lo } from "./hooks/user/useCurrentUser.js";
53
+ import { useFollowedShops as wo } from "./hooks/user/useFollowedShops.js";
54
+ import { useFollowedShopsActions as vo } from "./hooks/user/useFollowedShopsActions.js";
55
+ import { useCurrentUser as Uo } from "./hooks/user/useCurrentUser.js";
56
56
  import { useOrders as No } from "./hooks/user/useOrders.js";
57
- import { useBuyerAttributes as Oo } from "./hooks/user/useBuyerAttributes.js";
58
- import { useGenerateUserToken as yo } from "./hooks/user/useGenerateUserToken.js";
57
+ import { useBuyerAttributes as yo } from "./hooks/user/useBuyerAttributes.js";
58
+ import { useGenerateUserToken as Go } from "./hooks/user/useGenerateUserToken.js";
59
59
  import { useProductListActions as Ho } from "./hooks/product/useProductListActions.js";
60
60
  import { useProductLists as zo } from "./hooks/product/useProductLists.js";
61
61
  import { useProductList as Yo } from "./hooks/product/useProductList.js";
@@ -65,10 +65,10 @@ import { useProductVariants as Jo } from "./hooks/product/useProductVariants.js"
65
65
  import { useProductMedia as $o } from "./hooks/product/useProductMedia.js";
66
66
  import { useProductSearch as et } from "./hooks/product/useProductSearch.js";
67
67
  import { useRecommendedProducts as tt } from "./hooks/product/useRecommendedProducts.js";
68
- import { usePopularProducts as it } from "./hooks/product/usePopularProducts.js";
69
- import { useCuratedProducts as nt } from "./hooks/product/useCuratedProducts.js";
68
+ import { usePopularProducts as nt } from "./hooks/product/usePopularProducts.js";
69
+ import { useCuratedProducts as mt } from "./hooks/product/useCuratedProducts.js";
70
70
  import { useAsyncStorage as st } from "./hooks/storage/useAsyncStorage.js";
71
- import { useSecureStorage as ut } from "./hooks/storage/useSecureStorage.js";
71
+ import { useSecureStorage as lt } from "./hooks/storage/useSecureStorage.js";
72
72
  import { useImageUpload as xt } from "./hooks/storage/useImageUpload.js";
73
73
  import { useShopNavigation as dt } from "./hooks/navigation/useShopNavigation.js";
74
74
  import { useCloseMini as gt } from "./hooks/navigation/useCloseMini.js";
@@ -77,49 +77,55 @@ import { useNavigateWithTransition as Pt } from "./hooks/navigation/useNavigateW
77
77
  import { useShop as ht } from "./hooks/shop/useShop.js";
78
78
  import { useRecommendedShops as Rt } from "./hooks/shop/useRecommendedShops.js";
79
79
  import { useCreateImageContent as Et } from "./hooks/content/useCreateImageContent.js";
80
- import { useErrorToast as vt } from "./hooks/util/useErrorToast.js";
81
- import { useErrorScreen as Ft } from "./hooks/util/useErrorScreen.js";
82
- import { useShare as Lt } from "./hooks/util/useShare.js";
83
- import { useImagePicker as Nt } from "./hooks/util/useImagePicker.js";
84
- import { useKeyboardAvoidingView as Ot } from "./hooks/util/useKeyboardAvoidingView.js";
85
- import { useRequestPermissions as yt } from "./hooks/util/useRequestPermissions.js";
86
- import { useOnMiniFocus as Ht } from "./hooks/events/useOnMiniFocus.js";
87
- import { useOnMiniBlur as zt } from "./hooks/events/useOnMiniBlur.js";
88
- import { useOnMiniClose as Yt } from "./hooks/events/useOnMiniClose.js";
89
- import { useOnAppStateChange as Kt } from "./hooks/events/useOnAppStateChange.js";
90
- import { useOnNavigateBack as Zt } from "./hooks/events/useOnNavigateBack.js";
91
- import { MiniEntityNotFoundError as Jt, MiniError as Xt, MiniNetworkError as $t, formatError as ra } from "./utils/errors.js";
92
- import { extractBrandTheme as oa, formatReviewCount as ta, getFeaturedImages as aa, normalizeRating as ia } from "./utils/merchant-card.js";
93
- import { parseUrl as na } from "./utils/parseUrl.js";
94
- import { dataURLToBlob as sa, fileToDataUri as la, getResizedImageUrl as ua, getThumbhashBlobURL as fa, getThumbhashDataURL as xa } from "./utils/image.js";
95
- import { formatMoney as da } from "./utils/formatMoney.js";
96
- import { UserState as ga, UserTokenGenerateUserErrorCode as Sa } from "./shop-minis-platform/src/types/user.js";
97
- import { ContentCreateUserErrorCode as Da, MinisContentStatus as Pa } from "./shop-minis-platform/src/types/content.js";
98
- import { Social as ha } from "./shop-minis-platform/src/types/share.js";
99
- import { DATA_FETCHING_DEFAULT_FETCH_POLICY as Ra, DATA_FETCHING_DEFAULT_PAGE_SIZE as Ba } from "./shop-minis-platform/src/constants.js";
80
+ import { useProductSelection as wt } from "./hooks/intents/useProductSelection.js";
81
+ import { useImageCapture as vt } from "./hooks/intents/useImageCapture.js";
82
+ import { useContentShare as Ut } from "./hooks/intents/useContentShare.js";
83
+ import { useLocationSelection as Nt } from "./hooks/intents/useLocationSelection.js";
84
+ import { useBarcodeScanner as yt } from "./hooks/intents/useBarcodeScanner.js";
85
+ import { usePaymentRequest as Gt } from "./hooks/intents/usePaymentRequest.js";
86
+ import { useErrorToast as Ht } from "./hooks/util/useErrorToast.js";
87
+ import { useErrorScreen as zt } from "./hooks/util/useErrorScreen.js";
88
+ import { useShare as Yt } from "./hooks/util/useShare.js";
89
+ import { useImagePicker as Kt } from "./hooks/util/useImagePicker.js";
90
+ import { useKeyboardAvoidingView as Zt } from "./hooks/util/useKeyboardAvoidingView.js";
91
+ import { useRequestPermissions as Jt } from "./hooks/util/useRequestPermissions.js";
92
+ import { useOnMiniFocus as $t } from "./hooks/events/useOnMiniFocus.js";
93
+ import { useOnMiniBlur as ea } from "./hooks/events/useOnMiniBlur.js";
94
+ import { useOnMiniClose as ta } from "./hooks/events/useOnMiniClose.js";
95
+ import { useOnAppStateChange as na } from "./hooks/events/useOnAppStateChange.js";
96
+ import { MiniEntityNotFoundError as ma, MiniError as ia, MiniNetworkError as sa, formatError as ua } from "./utils/errors.js";
97
+ import { extractBrandTheme as fa, formatReviewCount as xa, getFeaturedImages as ca, normalizeRating as da } from "./utils/merchant-card.js";
98
+ import { parseUrl as ga } from "./utils/parseUrl.js";
99
+ import { dataURLToBlob as Aa, fileToDataUri as Da, getResizedImageUrl as Pa, getThumbhashBlobURL as Ta, getThumbhashDataURL as ha } from "./utils/image.js";
100
+ import { formatMoney as Ra } from "./utils/formatMoney.js";
101
+ import { UserState as Ea, UserTokenGenerateUserErrorCode as Ma } from "./shop-minis-platform/src/types/user.js";
102
+ import { ContentCreateUserErrorCode as Fa, MinisContentStatus as va } from "./shop-minis-platform/src/types/content.js";
103
+ import { Social as Ua } from "./shop-minis-platform/src/types/share.js";
104
+ import { DATA_FETCHING_DEFAULT_FETCH_POLICY as Na, DATA_FETCHING_DEFAULT_PAGE_SIZE as ka } from "./shop-minis-platform/src/constants.js";
105
+ import { IntentResultCode as _a, handleIntentResult as Ga } from "./shop-minis-platform/src/intents/shared.js";
100
106
  export {
101
107
  Sr as Accordion,
102
108
  Ar as AccordionContent,
103
109
  Dr as AccordionItem,
104
110
  Pr as AccordionTrigger,
105
- n as AddToCartButton,
111
+ m as AddToCartButton,
106
112
  hr as Alert,
107
113
  Ir as AlertDescription,
108
114
  Er as AlertDialog,
109
115
  Mr as AlertDialogAction,
110
116
  pr as AlertDialogAtom,
111
- vr as AlertDialogCancel,
112
- wr as AlertDialogContent,
113
- Fr as AlertDialogDescription,
114
- Ur as AlertDialogFooter,
115
- Lr as AlertDialogHeader,
117
+ wr as AlertDialogCancel,
118
+ Fr as AlertDialogContent,
119
+ vr as AlertDialogDescription,
120
+ Lr as AlertDialogFooter,
121
+ Ur as AlertDialogHeader,
116
122
  br as AlertDialogOverlay,
117
123
  Nr as AlertDialogPortal,
118
124
  kr as AlertDialogTitle,
119
- Or as AlertDialogTrigger,
125
+ yr as AlertDialogTrigger,
120
126
  Rr as AlertTitle,
121
- yr as Avatar,
122
- Gr as AvatarFallback,
127
+ Gr as Avatar,
128
+ Or as AvatarFallback,
123
129
  Hr as AvatarImage,
124
130
  zr as Badge,
125
131
  j as Button,
@@ -137,15 +143,15 @@ export {
137
143
  te as CarouselNext,
138
144
  ae as CarouselPrevious,
139
145
  pe as Checkbox,
140
- Da as ContentCreateUserErrorCode,
146
+ Fa as ContentCreateUserErrorCode,
141
147
  cr as ContentWrapper,
142
- Ra as DATA_FETCHING_DEFAULT_FETCH_POLICY,
143
- Ba as DATA_FETCHING_DEFAULT_PAGE_SIZE,
148
+ Na as DATA_FETCHING_DEFAULT_FETCH_POLICY,
149
+ ka as DATA_FETCHING_DEFAULT_PAGE_SIZE,
144
150
  o as DATA_NAVIGATION_TYPE_ATTRIBUTE,
145
- me as Dialog,
151
+ ie as Dialog,
146
152
  se as DialogClose,
147
- le as DialogContent,
148
- ue as DialogDescription,
153
+ ue as DialogContent,
154
+ le as DialogDescription,
149
155
  fe as DialogFooter,
150
156
  xe as DialogHeader,
151
157
  ce as DialogOverlay,
@@ -166,25 +172,26 @@ export {
166
172
  X as IconButton,
167
173
  rr as Image,
168
174
  W as ImageContentWrapper,
169
- we as Input,
170
- Ue as Label,
171
- mr as List,
175
+ Fe as Input,
176
+ _a as IntentResultCode,
177
+ Le as Label,
178
+ ir as List,
172
179
  ar as LongPressDetector,
173
180
  I as MerchantCard,
174
181
  R as MerchantCardContainer,
175
182
  B as MerchantCardHeader,
176
183
  E as MerchantCardInfo,
177
184
  M as MerchantCardName,
178
- v as MerchantCardRating,
179
- L as MerchantCardSkeleton,
180
- Jt as MiniEntityNotFoundError,
181
- Xt as MiniError,
182
- $t as MiniNetworkError,
183
- i as MinisContainer,
184
- Pa as MinisContentStatus,
185
+ w as MerchantCardRating,
186
+ U as MerchantCardSkeleton,
187
+ ma as MiniEntityNotFoundError,
188
+ ia as MiniError,
189
+ sa as MiniNetworkError,
190
+ n as MinisContainer,
191
+ va as MinisContentStatus,
185
192
  q as MinisRouter,
186
193
  t as NAVIGATION_TYPES,
187
- u as ProductCard,
194
+ l as ProductCard,
188
195
  f as ProductCardBadge,
189
196
  x as ProductCardContainer,
190
197
  c as ProductCardFavoriteButton,
@@ -193,23 +200,23 @@ export {
193
200
  g as ProductCardInfo,
194
201
  S as ProductCardPrice,
195
202
  A as ProductCardReviewStars,
196
- F as ProductCardSkeleton,
203
+ v as ProductCardSkeleton,
197
204
  D as ProductCardTitle,
198
205
  T as ProductLink,
199
206
  Cr as ProductVariantPrice,
200
207
  be as Progress,
201
208
  N as QuantitySelector,
202
209
  ke as RadioGroup,
203
- Oe as RadioGroupItem,
204
- ye as ResizableHandle,
205
- Ge as ResizablePanel,
210
+ ye as RadioGroupItem,
211
+ Ge as ResizableHandle,
212
+ Oe as ResizablePanel,
206
213
  He as ResizablePanelGroup,
207
214
  ze as ScrollArea,
208
215
  We as ScrollBar,
209
- O as Search,
216
+ y as Search,
210
217
  _ as SearchInput,
211
- y as SearchProvider,
212
- G as SearchResultsList,
218
+ G as SearchProvider,
219
+ O as SearchResultsList,
213
220
  qe as Select,
214
221
  Ke as SelectContent,
215
222
  Qe as SelectGroup,
@@ -221,77 +228,83 @@ export {
221
228
  ro as SelectTrigger,
222
229
  eo as SelectValue,
223
230
  to as Separator,
224
- io as Sheet,
231
+ no as Sheet,
225
232
  po as SheetClose,
226
- no as SheetContent,
227
- mo as SheetDescription,
233
+ mo as SheetContent,
234
+ io as SheetDescription,
228
235
  so as SheetFooter,
229
- lo as SheetHeader,
230
- uo as SheetTitle,
236
+ uo as SheetHeader,
237
+ lo as SheetTitle,
231
238
  fo as SheetTrigger,
232
239
  Ao as Skeleton,
233
- ha as Social,
240
+ Ua as Social,
234
241
  fr as TextInput,
235
242
  co as Toaster,
236
243
  or as Touchable,
237
244
  Q as TransitionLink,
238
- ga as UserState,
239
- Sa as UserTokenGenerateUserErrorCode,
240
- lr as VideoPlayer,
245
+ Ea as UserState,
246
+ Ma as UserTokenGenerateUserErrorCode,
247
+ ur as VideoPlayer,
241
248
  Wr as badgeVariants,
242
- sa as dataURLToBlob,
243
- oa as extractBrandTheme,
244
- la as fileToDataUri,
245
- ra as formatError,
246
- da as formatMoney,
247
- ta as formatReviewCount,
248
- aa as getFeaturedImages,
249
- ua as getResizedImageUrl,
250
- fa as getThumbhashBlobURL,
251
- xa as getThumbhashDataURL,
252
- ia as normalizeRating,
253
- na as parseUrl,
249
+ Aa as dataURLToBlob,
250
+ fa as extractBrandTheme,
251
+ Da as fileToDataUri,
252
+ ua as formatError,
253
+ Ra as formatMoney,
254
+ xa as formatReviewCount,
255
+ ca as getFeaturedImages,
256
+ Pa as getResizedImageUrl,
257
+ Ta as getThumbhashBlobURL,
258
+ ha as getThumbhashDataURL,
259
+ Ga as handleIntentResult,
260
+ da as normalizeRating,
261
+ ga as parseUrl,
254
262
  go as toast,
255
263
  st as useAsyncStorage,
256
- Oo as useBuyerAttributes,
264
+ yt as useBarcodeScanner,
265
+ yo as useBuyerAttributes,
257
266
  gt as useCloseMini,
267
+ Ut as useContentShare,
258
268
  Et as useCreateImageContent,
259
- nt as useCuratedProducts,
260
- Lo as useCurrentUser,
269
+ mt as useCuratedProducts,
270
+ Uo as useCurrentUser,
261
271
  At as useDeeplink,
262
- Ft as useErrorScreen,
263
- vt as useErrorToast,
264
- vo as useFollowedShops,
265
- Fo as useFollowedShopsActions,
266
- yo as useGenerateUserToken,
267
- Nt as useImagePicker,
272
+ zt as useErrorScreen,
273
+ Ht as useErrorToast,
274
+ wo as useFollowedShops,
275
+ vo as useFollowedShopsActions,
276
+ Go as useGenerateUserToken,
277
+ vt as useImageCapture,
278
+ Kt as useImagePicker,
268
279
  xt as useImageUpload,
269
- Ot as useKeyboardAvoidingView,
280
+ Zt as useKeyboardAvoidingView,
281
+ Nt as useLocationSelection,
270
282
  Pt as useNavigateWithTransition,
271
- Kt as useOnAppStateChange,
272
- zt as useOnMiniBlur,
273
- Yt as useOnMiniClose,
274
- Ht as useOnMiniFocus,
275
- Zt as useOnNavigateBack,
283
+ na as useOnAppStateChange,
284
+ ea as useOnMiniBlur,
285
+ ta as useOnMiniClose,
286
+ $t as useOnMiniFocus,
276
287
  No as useOrders,
277
- it as usePopularProducts,
288
+ Gt as usePaymentRequest,
289
+ nt as usePopularProducts,
278
290
  Ko as useProduct,
279
291
  Yo as useProductList,
280
292
  Ho as useProductListActions,
281
293
  zo as useProductLists,
282
294
  $o as useProductMedia,
283
295
  et as useProductSearch,
296
+ wt as useProductSelection,
284
297
  Jo as useProductVariants,
285
298
  Zo as useProducts,
286
299
  Po as useRecentProducts,
287
300
  ho as useRecentShops,
288
301
  tt as useRecommendedProducts,
289
302
  Rt as useRecommendedShops,
290
- yt as useRequestPermissions,
303
+ Jt as useRequestPermissions,
291
304
  Ro as useSavedProducts,
292
305
  Eo as useSavedProductsActions,
293
- ut as useSecureStorage,
294
- Lt as useShare,
306
+ lt as useSecureStorage,
307
+ Yt as useShare,
295
308
  ht as useShop,
296
309
  dt as useShopNavigation
297
310
  };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,26 @@
1
+ import { useCallback as s } from "react";
2
+ import { IntentResultCode as t } from "../shop-minis-platform/src/intents/shared.js";
3
+ const c = (n, r) => s(
4
+ async (...a) => {
5
+ const e = await n(...a);
6
+ switch (e.resultCode) {
7
+ case t.SUCCESS:
8
+ return e.data;
9
+ case t.CANCELLED:
10
+ return r?.onCancel ? r.onCancel() : void 0;
11
+ case t.FAILED:
12
+ if (r?.onError)
13
+ return r.onError(e.error);
14
+ throw new Error(e.error?.message || "Intent failed");
15
+ default: {
16
+ const o = e.resultCode;
17
+ throw new Error(`Unhandled result code: ${o}`);
18
+ }
19
+ }
20
+ },
21
+ [n, r]
22
+ );
23
+ export {
24
+ c as useHandleIntent
25
+ };
26
+ //# sourceMappingURL=useHandleIntent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useHandleIntent.js","sources":["../../src/internal/useHandleIntent.ts"],"sourcesContent":["import {useCallback} from 'react'\n\nimport {IntentResultCode} from '@shopify/shop-minis-platform'\n\nimport type {ShopIntentResult} from '@shopify/shop-minis-platform'\n\n/**\n * Options for handling intent results\n */\nexport interface HandleIntentOptions<T> {\n /**\n * Handler called when user cancels the intent\n * If not provided, cancellation is treated as a no-op (returns undefined)\n */\n onCancel?: () => T | void\n /**\n * Handler called when intent fails\n * If not provided, throws the error\n */\n onError?: (error: {message: string; code?: string}) => T | void\n}\n\n/**\n * Wrapper to handle intent results\n *\n * Unlike actions which can reject, intents ALWAYS resolve with a result code.\n * This hook provides a cleaner API for handling intent results:\n *\n * - SUCCESS: Returns the data\n * - CANCELLED: Calls onCancel or returns undefined\n * - FAILED: Calls onError or throws the error\n *\n * @example\n * const selectProduct = useHandleIntent(intents.selectProduct, {\n * onCancel: () => console.log('User cancelled'),\n * onError: (error) => console.error('Selection failed:', error)\n * })\n *\n * const result = await selectProduct({multiSelect: true})\n * // result is the data, or undefined if cancelled\n */\nexport const useHandleIntent = <T, Args extends unknown[]>(\n intent: (...args: Args) => Promise<ShopIntentResult<T>>,\n options?: HandleIntentOptions<T>\n) => {\n return useCallback(\n async (...args: Args): Promise<T | void> => {\n const result = await intent(...args)\n\n switch (result.resultCode) {\n case IntentResultCode.SUCCESS:\n return result.data!\n\n case IntentResultCode.CANCELLED:\n if (options?.onCancel) {\n return options.onCancel()\n }\n return undefined\n\n case IntentResultCode.FAILED:\n if (options?.onError) {\n return options.onError(result.error!)\n }\n\n throw new Error(result.error?.message || 'Intent failed')\n\n default: {\n // Exhaustiveness check\n const _exhaustive: never = result.resultCode\n throw new Error(`Unhandled result code: ${_exhaustive}`)\n }\n }\n },\n [intent, options]\n )\n}\n\n/**\n * Alternative: Manual result handling without throwing\n *\n * Use this when you want to handle all result codes explicitly\n * without throwing errors.\n *\n * @example\n * const selectProduct = useHandleIntentManual(intents.selectProduct)\n *\n * const result = await selectProduct({multiSelect: true})\n * if (result.resultCode === 'SUCCESS') {\n * console.log(result.data)\n * }\n */\nexport const useHandleIntentManual = <T, Args extends unknown[]>(\n intent: (...args: Args) => Promise<ShopIntentResult<T>>\n) => {\n return useCallback(\n (...args: Args) => {\n return intent(...args)\n },\n [intent]\n )\n}\n"],"names":["useHandleIntent","intent","options","useCallback","args","result","IntentResultCode","_exhaustive"],"mappings":";;AAyCa,MAAAA,IAAkB,CAC7BC,GACAC,MAEOC;AAAA,EACL,UAAUC,MAAkC;AAC1C,UAAMC,IAAS,MAAMJ,EAAO,GAAGG,CAAI;AAEnC,YAAQC,EAAO,YAAY;AAAA,MACzB,KAAKC,EAAiB;AACpB,eAAOD,EAAO;AAAA,MAEhB,KAAKC,EAAiB;AACpB,eAAIJ,GAAS,WACJA,EAAQ,SAAS,IAEnB;AAAA,MAET,KAAKI,EAAiB;AACpB,YAAIJ,GAAS;AACJ,iBAAAA,EAAQ,QAAQG,EAAO,KAAM;AAGtC,cAAM,IAAI,MAAMA,EAAO,OAAO,WAAW,eAAe;AAAA,MAE1D,SAAS;AAEP,cAAME,IAAqBF,EAAO;AAClC,cAAM,IAAI,MAAM,0BAA0BE,CAAW,EAAE;AAAA,MAAA;AAAA,IACzD;AAAA,EAEJ;AAAA,EACA,CAACN,GAAQC,CAAO;AAClB;"}
@@ -0,0 +1,7 @@
1
+ function n() {
2
+ return window.minisIntents;
3
+ }
4
+ export {
5
+ n as useShopIntents
6
+ };
7
+ //# sourceMappingURL=useShopIntents.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useShopIntents.js","sources":["../../src/internal/useShopIntents.ts"],"sourcesContent":["import type {ShopIntents} from '@shopify/shop-minis-platform'\n\n/**\n * Internal hook to access Shop Intents\n *\n * This provides direct access to window.minisIntents\n * Use specific intent hooks (like useProductSelection) instead of this hook directly\n *\n * @internal\n */\nexport function useShopIntents(): ShopIntents {\n return window.minisIntents\n}\n"],"names":["useShopIntents"],"mappings":"AAUO,SAASA,IAA8B;AAC5C,SAAO,OAAO;AAChB;"}