@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
package/dist/mocks.js CHANGED
@@ -11,7 +11,7 @@ const m = [
11
11
  r = (r << 5) - r + o.charCodeAt(t), r |= 0;
12
12
  return Math.abs(r);
13
13
  }, e = (o, r, t = "99.99", n) => {
14
- const s = P(o) % m.length, c = m[s];
14
+ const i = P(o) % m.length, c = m[i];
15
15
  return {
16
16
  id: o,
17
17
  title: r,
@@ -29,7 +29,7 @@ const m = [
29
29
  }
30
30
  };
31
31
  }, d = (o, r, t) => {
32
- const n = t?.themeType || "none", s = t?.withBrandSettings || n !== "none", c = t?.featuredImagesLimit || 3, u = Array.from({ length: c }, (C, l) => ({
32
+ const n = t?.themeType || "none", i = t?.withBrandSettings || n !== "none", c = t?.featuredImagesLimit || 3, u = Array.from({ length: c }, (C, l) => ({
33
33
  url: `https://picsum.photos/400/400?random=${o}-${l}`,
34
34
  sensitive: !1,
35
35
  altText: `${r} featured image ${l + 1}`
@@ -104,7 +104,7 @@ const m = [
104
104
  url: `https://picsum.photos/100/100?random=${o}`,
105
105
  sensitive: !1
106
106
  },
107
- brandSettings: s ? {
107
+ brandSettings: i ? {
108
108
  id: `brand-settings-${o}`,
109
109
  colors: {
110
110
  id: `colors-${o}`,
@@ -117,7 +117,7 @@ const m = [
117
117
  }, a = (o = !1) => ({
118
118
  hasNextPage: o,
119
119
  endCursor: o ? "cursor123" : null
120
- }), i = (o, r, t = []) => ({
120
+ }), s = (o, r, t = []) => ({
121
121
  id: o,
122
122
  publicId: `public-${o}`,
123
123
  name: r,
@@ -212,20 +212,20 @@ function I() {
212
212
  reportContentImpression: void 0,
213
213
  getProductLists: {
214
214
  data: [
215
- i("list-1", "Wishlist"),
216
- i("list-2", "Favorites")
215
+ s("list-1", "Wishlist"),
216
+ s("list-2", "Favorites")
217
217
  ],
218
218
  pageInfo: a()
219
219
  },
220
220
  getProductList: {
221
- data: i("list-1", "Wishlist", [
221
+ data: s("list-1", "Wishlist", [
222
222
  e("prod-1", "Sample Product")
223
223
  ]),
224
224
  pageInfo: a()
225
225
  },
226
- addProductList: i("list-3", "New List"),
226
+ addProductList: s("list-3", "New List"),
227
227
  removeProductList: void 0,
228
- renameProductList: i("list-1", "Updated Wishlist"),
228
+ renameProductList: s("list-1", "Updated Wishlist"),
229
229
  addProductListItem: void 0,
230
230
  removeProductListItem: void 0,
231
231
  getRecommendedProducts: {
@@ -449,8 +449,7 @@ function I() {
449
449
  granted: !0
450
450
  },
451
451
  reportError: void 0,
452
- reportFetch: void 0,
453
- reportNavigationState: void 0
452
+ reportFetch: void 0
454
453
  }, r = {};
455
454
  for (const t in o)
456
455
  Object.prototype.hasOwnProperty.call(o, t) && (r[t] = f(
package/dist/mocks.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mocks.js","sources":["../src/mocks.ts"],"sourcesContent":["import {\n Product,\n Gender,\n UserState,\n MinisContentStatus,\n} from '@shopify/shop-minis-platform'\nimport {ShopActions} from '@shopify/shop-minis-platform/actions'\n\nconst SAMPLE_IMAGE_NAMES = [\n 'garnished.jpeg',\n 'bath.jpeg',\n 'teapot.jpg',\n 'shoes.jpeg',\n]\n\n// Simple hash function to get a deterministic index from a string\nconst hashString = (str: string): number => {\n let hash = 0\n for (let i = 0; i < str.length; i++) {\n hash = (hash << 5) - hash + str.charCodeAt(i)\n hash |= 0\n }\n return Math.abs(hash)\n}\n\n// Helper functions for common data structures\nexport const createProduct = (\n id: string,\n title: string,\n price = '99.99',\n compareAtPrice?: string\n): Product => {\n const imageIndex = hashString(id) % SAMPLE_IMAGE_NAMES.length\n const imageName = SAMPLE_IMAGE_NAMES[imageIndex]\n\n return {\n id,\n title,\n price: {amount: price, currencyCode: 'USD'},\n ...(compareAtPrice && {\n compareAtPrice: {amount: compareAtPrice, currencyCode: 'USD'},\n }),\n reviewAnalytics: {averageRating: 4.5, reviewCount: 10},\n shop: createShop('shop1', 'Mock Shop'),\n defaultVariantId: `variant-${id}`,\n isFavorited: false,\n featuredImage: {\n url: `https://cdn.shopify.com/static/sample-images/${imageName}`,\n altText: title,\n },\n }\n}\n\nexport const createShop = (\n id: string,\n name: string,\n options?: {\n themeType?: 'coverImage' | 'brandColor' | 'logoColor' | 'none'\n withBrandSettings?: boolean\n primaryColor?: string\n logoDominantColor?: string\n logoAverageColor?: string\n coverDominantColor?: string\n wordmarkUrl?: string\n coverImageUrl?: string\n featuredImagesLimit?: number\n }\n) => {\n // Determine theme configuration\n const themeType = options?.themeType || 'none'\n const shouldHaveBrandSettings =\n options?.withBrandSettings || themeType !== 'none'\n\n // Generate featured images\n const featuredImagesCount = options?.featuredImagesLimit || 3\n const featuredImages = Array.from({length: featuredImagesCount}, (_, i) => ({\n url: `https://picsum.photos/400/400?random=${id}-${i}`,\n sensitive: false,\n altText: `${name} featured image ${i + 1}`,\n }))\n\n // Configure colors based on theme type\n const getThemeColors = () => {\n switch (themeType) {\n case 'coverImage':\n return {\n primary: options?.primaryColor,\n logoDominant: options?.logoDominantColor,\n logoAverage: options?.logoAverageColor,\n coverDominant: options?.coverDominantColor || '#FF6B35',\n }\n case 'brandColor':\n return {\n primary: options?.primaryColor || '#27AE60',\n logoDominant: options?.logoDominantColor,\n logoAverage: options?.logoAverageColor,\n coverDominant: options?.coverDominantColor,\n }\n case 'logoColor':\n return {\n primary: options?.primaryColor,\n logoDominant: options?.logoDominantColor || '#E74C3C',\n logoAverage: options?.logoAverageColor,\n coverDominant: options?.coverDominantColor,\n }\n default:\n return {\n primary: options?.primaryColor,\n logoDominant: options?.logoDominantColor,\n logoAverage: options?.logoAverageColor,\n coverDominant: options?.coverDominantColor,\n }\n }\n }\n\n // Configure header theme\n const createHeaderTheme = () => {\n if (themeType === 'coverImage' || options?.coverImageUrl) {\n return {\n id: `header-theme-${id}`,\n coverImage: {\n url:\n options?.coverImageUrl ||\n 'https://images.unsplash.com/photo-1441986300917-64674bd600d8?w=800&h=400&fit=crop',\n altText: `${name} cover image`,\n sensitive: false,\n thumbhash: 'k9oGHQRnh493V4dIeHeXh4h3iIeI',\n },\n wordmark:\n options?.wordmarkUrl || themeType === 'coverImage'\n ? {\n url:\n options?.wordmarkUrl ||\n 'https://merrypeople.com/cdn/shop/files/Transparent_Background_1.png?v=1696465429&width=1024',\n altText: `${name} wordmark`,\n sensitive: false,\n }\n : undefined,\n }\n }\n\n if (options?.wordmarkUrl) {\n return {\n id: `header-theme-${id}`,\n wordmark: {\n url: options.wordmarkUrl,\n altText: `${name} wordmark`,\n sensitive: false,\n },\n }\n }\n\n return undefined\n }\n\n return {\n id,\n name,\n primaryDomain: {\n url: `https://${name.toLowerCase().replace(/\\s+/g, '-')}.com`,\n },\n reviewAnalytics: {averageRating: 4.3, reviewCount: 50},\n visualTheme: {\n id: `visual-theme-${id}`,\n featuredImages,\n logoImage: {\n url: `https://picsum.photos/100/100?random=${id}`,\n sensitive: false,\n },\n brandSettings: shouldHaveBrandSettings\n ? {\n id: `brand-settings-${id}`,\n colors: {\n id: `colors-${id}`,\n ...getThemeColors(),\n },\n headerTheme: createHeaderTheme(),\n }\n : undefined,\n },\n }\n}\n\nconst createPagination = (hasNext = false) => ({\n hasNextPage: hasNext,\n endCursor: hasNext ? 'cursor123' : null,\n})\n\nconst createProductList = (id: string, name: string, products: any[] = []) => ({\n id,\n publicId: `public-${id}`,\n name,\n products,\n})\n\n// Helper type to extract the data type from a ShopAction\ntype ShopActionDataType<T> = T extends (\n ...args: any[]\n) => Promise<{ok: true; data: infer R} | {ok: false; error: any}>\n ? R\n : never\n\n// Use window._mockLogs instead of console.log so logs aren't stripped in production builds\n// This allows e2e tests to verify mock actions are being called\nexport interface MockLog {\n action: string\n params?: unknown\n}\n\ndeclare global {\n interface Window {\n _mockLogs?: MockLog[]\n }\n}\n\nfunction logMockAction(action: string, params?: unknown) {\n window._mockLogs = window._mockLogs || []\n window._mockLogs.push({action, params})\n}\n\nfunction makeMockMethod<K extends keyof ShopActions>(\n key: K,\n result: ShopActionDataType<ShopActions[K]>\n): ShopActions[K] {\n return ((params: Parameters<ShopActions[K]>[0]) => {\n logMockAction(String(key), params)\n return Promise.resolve({\n ok: true as const,\n data: result,\n mocked: true,\n })\n }) as ShopActions[K]\n}\n\nexport function makeMockActions(): ShopActions {\n const results: {\n [K in keyof ShopActions]: ShopActionDataType<ShopActions[K]>\n } = {\n translateContentUp: undefined,\n translateContentDown: undefined,\n followShop: true,\n unfollowShop: false,\n favorite: undefined,\n unfavorite: undefined,\n getShopAppInformation: {\n appVersion: '1.0.0',\n buildNumber: '12345',\n buildId: 'dev-build-123',\n },\n productRecommendationImpression: undefined,\n productRecommendationClick: undefined,\n closeMini: undefined,\n getAccountInformation: {\n status: 'available',\n value: 'user@example.com',\n },\n getCurrentUser: {\n data: {\n displayName: 'John Doe',\n avatarImage: {url: 'https://example.com/avatar.jpg'},\n },\n },\n createOrderAttribution: undefined,\n addToCart: undefined,\n buyProduct: undefined,\n buyProducts: undefined,\n showErrorScreen: undefined,\n showErrorToast: undefined,\n getDeeplinkPaths: {\n matchers: ['/products', '/collections', '/cart'],\n },\n navigateToDeeplink: undefined,\n navigateToShop: undefined,\n navigateToProduct: undefined,\n navigateToOrder: undefined,\n navigateToCheckout: undefined,\n createImageUploadLink: {\n // This action is mocked in the actual hook. See `useImageUpload` for more details.\n targets: [\n {\n url: 'https://example.com/upload',\n resourceUrl: 'https://example.com/resource',\n parameters: [{name: 'key', value: 'upload-123'}],\n },\n ],\n },\n completeImageUpload: {\n files: [\n {\n id: 'file-123',\n fileStatus: 'READY',\n image: {\n url: 'https://example.com/image.jpg',\n },\n },\n ],\n },\n getPersistedItem: null,\n setPersistedItem: undefined,\n removePersistedItem: undefined,\n getAllPersistedKeys: ['key1', 'key2', 'key3'],\n clearPersistedItems: undefined,\n getInternalPersistedItem: null,\n setInternalPersistedItem: undefined,\n removeInternalPersistedItem: undefined,\n getAllInternalPersistedKeys: ['internal-key1', 'internal-key2'],\n clearInternalPersistedItems: undefined,\n getSecret: 'secret-value',\n setSecret: undefined,\n removeSecret: undefined,\n reportInteraction: undefined,\n reportImpression: undefined,\n reportContentImpression: undefined,\n getProductLists: {\n data: [\n createProductList('list-1', 'Wishlist'),\n createProductList('list-2', 'Favorites'),\n ],\n pageInfo: createPagination(),\n },\n getProductList: {\n data: createProductList('list-1', 'Wishlist', [\n createProduct('prod-1', 'Sample Product'),\n ]),\n pageInfo: createPagination(),\n },\n addProductList: createProductList('list-3', 'New List'),\n removeProductList: undefined,\n renameProductList: createProductList('list-1', 'Updated Wishlist'),\n addProductListItem: undefined,\n removeProductListItem: undefined,\n getRecommendedProducts: {\n data: [\n createProduct('rec-1', 'Recommended Product 1', '79.99'),\n createProduct('rec-2', 'Recommended Product 2', '129.99'),\n createProduct('rec-3', 'Recommended Product 3', '129.99'),\n createProduct('rec-4', 'Recommended Product 4', '29.99'),\n createProduct('rec-5', 'Recommended Product 5', '39.99'),\n createProduct('rec-6', 'Recommended Product 6', '49.99'),\n createProduct('rec-7', 'Recommended Product 7', '59.99'),\n createProduct('rec-8', 'Recommended Product 8', '69.99'),\n createProduct('rec-9', 'Recommended Product 9', '129.99'),\n ],\n pageInfo: createPagination(),\n },\n getRecommendedShops: {\n data: [\n createShop('shop-1', 'Amazing Store'),\n createShop('shop-2', 'Best Deals Shop'),\n createShop('shop-3', 'Great Products'),\n createShop('shop-4', 'Top Brands'),\n createShop('shop-5', 'Exclusive Offers'),\n ],\n pageInfo: createPagination(),\n },\n searchProductsByShop: {\n data: [\n createProduct('search-1', 'Search Result 1', '59.99'),\n createProduct('search-2', 'Search Result 2', '89.99'),\n createProduct('search-3', 'Search Result 3', '119.99'),\n createProduct('search-4', 'Search Result 4', '149.99'),\n createProduct('search-5', 'Search Result 5', '179.99'),\n ],\n pageInfo: createPagination(),\n },\n getOrders: {\n data: [\n {\n id: 'order-1',\n name: '#1001',\n lineItems: [\n {\n productTitle: 'Sample Product',\n variantTitle: 'Medium',\n quantity: 2,\n product: null,\n },\n ],\n shop: createShop('shop-1', 'Sample Shop'),\n },\n ],\n pageInfo: createPagination(),\n },\n getBuyerAttributes: {\n data: {\n genderAffinity: 'NEUTRAL' as Gender,\n categoryAffinities: [\n {id: 'cat1', name: 'Electronics'},\n {id: 'cat2', name: 'Clothing'},\n ],\n },\n },\n showFeedbackSheet: undefined,\n getPopularProducts: {\n data: [\n createProduct('pop-1', 'The Hero Snowboard', '702.95'),\n createProduct('pop-2', 'Snow Jacket', '605.95', '702.00'),\n createProduct('pop-3', 'Winter Gloves', '89.95'),\n createProduct('pop-4', 'Summer Gloves', '89.95'),\n createProduct('pop-5', 'Spring Gloves', '89.95'),\n createProduct('pop-6', 'Playstation 5', '499.95'),\n createProduct('pop-7', 'Xbox Series X', '499.95'),\n createProduct('pop-8', 'Nintendo Switch', '299.95'),\n createProduct('pop-9', 'Playstation 4', '299.95'),\n createProduct('pop-10', 'Nintendo 3DS', '89.95'),\n ],\n pageInfo: createPagination(),\n },\n share: {\n message: 'Shared!',\n success: true,\n },\n shareSingle: {\n message: 'Shared!',\n success: true,\n },\n getCuratedProducts: {\n data: [\n createProduct('cur-1', 'Curated Product 1', '79.99'),\n createProduct('cur-2', 'Curated Product 2', '129.99'),\n ],\n pageInfo: createPagination(),\n },\n getSavedProducts: {\n data: [\n createProduct('saved-1', 'Saved Product 1', '49.99'),\n createProduct('saved-2', 'Saved Product 2', '59.99'),\n createProduct('saved-3', 'Saved Product 3', '69.99'),\n createProduct('saved-4', 'Saved Product 4', '79.99'),\n createProduct('saved-5', 'Saved Product 5', '89.99'),\n ],\n pageInfo: createPagination(),\n },\n getRecentProducts: {\n data: [\n createProduct('recent-1', 'Recent Product 1', '59.99'),\n createProduct('recent-2', 'Recent Product 2', '69.99'),\n createProduct('recent-3', 'Recent Product 3', '79.99'),\n createProduct('recent-4', 'Recent Product 4', '89.99'),\n createProduct('recent-5', 'Recent Product 5', '99.99'),\n ],\n pageInfo: createPagination(),\n },\n getProductSearch: {\n data: [\n createProduct('search-1', 'Search Product 1', '39.99'),\n createProduct('search-2', 'Search Product 2', '19.99'),\n createProduct('search-3', 'Search Product 3', '29.99'),\n createProduct('search-4', 'Search Product 4', '49.99'),\n createProduct('search-5', 'Search Product 5', '9.99'),\n ],\n pageInfo: createPagination(),\n },\n getProducts: {\n data: [\n createProduct('prod-1', 'Product 1', '9.99'),\n createProduct('prod-2', 'Product 2', '19.99'),\n createProduct('prod-3', 'Product 3', '29.99'),\n createProduct('prod-4', 'Product 4', '39.99'),\n createProduct('prod-5', 'Product 5', '49.99'),\n ],\n },\n getProduct: {data: createProduct('prod-1', 'Sample Product')},\n getProductVariants: {\n data: [\n {\n id: 'variant-1',\n title: 'Variant 1',\n isFavorited: false,\n image: {url: 'https://example.com/variant-1.jpg'},\n price: {amount: '19.99', currencyCode: 'USD'},\n compareAtPrice: {amount: '29.99', currencyCode: 'USD'},\n },\n ],\n pageInfo: createPagination(),\n },\n getProductMedia: {\n data: [\n {\n id: 'media-1',\n image: {url: 'https://example.com/media-1.jpg'},\n mediaContentType: 'IMAGE',\n alt: 'Sample product image',\n },\n ],\n pageInfo: createPagination(),\n },\n getShop: {\n data: createShop('shop-1', 'Sample Shop', {featuredImagesLimit: 4}),\n },\n getRecentShops: {\n data: [\n createShop('recent-shop-1', 'Recent Shop 1'),\n createShop('recent-shop-2', 'Recent Shop 2'),\n createShop('recent-shop-3', 'Recent Shop 3'),\n ],\n pageInfo: createPagination(),\n },\n getFollowedShops: {\n data: [\n createShop('followed-shop-1', 'Followed Shop 1'),\n createShop('followed-shop-2', 'Followed Shop 2'),\n createShop('followed-shop-3', 'Followed Shop 3'),\n ],\n pageInfo: createPagination(),\n },\n previewProductInAr: undefined,\n createContent: {\n data: {\n publicId: 'content-123',\n externalId: null,\n image: {\n id: 'img-123',\n url: 'https://cdn.shopify.com/s/files/1/0633/6574/2742/files/Namnlosdesign-47.png?v=1740438079',\n width: 800,\n height: 600,\n },\n title: 'Mock Content',\n description: 'This is a mock content item',\n visibility: ['DISCOVERABLE'],\n shareableUrl: 'https://example.com/content/123',\n products: null,\n },\n },\n getContent: {\n data: [\n {\n publicId: 'content-123',\n image: {\n id: 'img-123',\n url: 'https://cdn.shopify.com/s/files/1/0633/6574/2742/files/Namnlosdesign-47.png?v=1740438079',\n width: 800,\n height: 600,\n },\n title: 'Mock Content',\n visibility: ['DISCOVERABLE'],\n status: MinisContentStatus.READY,\n },\n ],\n },\n generateUserToken: {\n data: {\n token: 'user-token-123',\n expiresAt: '2025-01-01',\n userState: UserState.VERIFIED,\n },\n },\n navigateToCart: undefined,\n requestPermission: {\n granted: true,\n },\n reportError: undefined,\n reportFetch: undefined,\n reportNavigationState: undefined,\n } as const\n\n const mock: Partial<ShopActions> = {}\n for (const key in results) {\n if (Object.prototype.hasOwnProperty.call(results, key)) {\n // @ts-expect-error: dynamic assignment is safe due to exhaustive mapping\n mock[key] = makeMockMethod(\n key as keyof ShopActions,\n results[key as keyof typeof results]\n )\n }\n }\n return mock as ShopActions\n}\n\n// Detect if running on a mobile device\nconst isMobile = (): boolean => {\n const userAgent = navigator.userAgent.toLowerCase()\n const isIOS = /iphone|ipad|ipod/.test(userAgent)\n const isAndroid = /android/.test(userAgent)\n\n return isIOS || isAndroid\n}\n\nexport const injectMocks = ({force}: {force?: boolean} = {}) => {\n // Only inject mocks if we aren't on a mobile device or we force it\n if (isMobile() && !force) {\n return\n }\n\n if (!window.minisSDK) {\n window.minisSDK = makeMockActions()\n window.minisParams = {\n handle: 'mock-handle',\n initialUrl: '/',\n platform: 'web',\n }\n }\n}\n"],"names":["SAMPLE_IMAGE_NAMES","hashString","str","hash","i","createProduct","id","title","price","compareAtPrice","imageIndex","imageName","createShop","name","options","themeType","shouldHaveBrandSettings","featuredImagesCount","featuredImages","_","getThemeColors","createHeaderTheme","createPagination","hasNext","createProductList","products","logMockAction","action","params","makeMockMethod","key","result","makeMockActions","results","MinisContentStatus","UserState","mock","isMobile","userAgent","isIOS","isAndroid","injectMocks","force"],"mappings":";;AAQA,MAAMA,IAAqB;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAGMC,IAAa,CAACC,MAAwB;AAC1C,MAAIC,IAAO;AACX,WAASC,IAAI,GAAGA,IAAIF,EAAI,QAAQE;AAC9B,IAAAD,KAAQA,KAAQ,KAAKA,IAAOD,EAAI,WAAWE,CAAC,GACpCD,KAAA;AAEH,SAAA,KAAK,IAAIA,CAAI;AACtB,GAGaE,IAAgB,CAC3BC,GACAC,GACAC,IAAQ,SACRC,MACY;AACZ,QAAMC,IAAaT,EAAWK,CAAE,IAAIN,EAAmB,QACjDW,IAAYX,EAAmBU,CAAU;AAExC,SAAA;AAAA,IACL,IAAAJ;AAAA,IACA,OAAAC;AAAA,IACA,OAAO,EAAC,QAAQC,GAAO,cAAc,MAAK;AAAA,IAC1C,GAAIC,KAAkB;AAAA,MACpB,gBAAgB,EAAC,QAAQA,GAAgB,cAAc,MAAK;AAAA,IAC9D;AAAA,IACA,iBAAiB,EAAC,eAAe,KAAK,aAAa,GAAE;AAAA,IACrD,MAAMG,EAAW,SAAS,WAAW;AAAA,IACrC,kBAAkB,WAAWN,CAAE;AAAA,IAC/B,aAAa;AAAA,IACb,eAAe;AAAA,MACb,KAAK,gDAAgDK,CAAS;AAAA,MAC9D,SAASJ;AAAA,IAAA;AAAA,EAEb;AACF,GAEaK,IAAa,CACxBN,GACAO,GACAC,MAWG;AAEG,QAAAC,IAAYD,GAAS,aAAa,QAClCE,IACJF,GAAS,qBAAqBC,MAAc,QAGxCE,IAAsBH,GAAS,uBAAuB,GACtDI,IAAiB,MAAM,KAAK,EAA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AAID;AAAA,MACVC;AAAA,MACAG,EAAQH,CAA2B;AAAA,IACrC;AAGG,SAAAM;AACT;AAGA,MAAMC,IAAW,MAAe;AACxB,QAAAC,IAAY,UAAU,UAAU,YAAY,GAC5CC,IAAQ,mBAAmB,KAAKD,CAAS,GACzCE,IAAY,UAAU,KAAKF,CAAS;AAE1C,SAAOC,KAASC;AAClB,GAEaC,IAAc,CAAC,EAAC,OAAAC,EAAK,IAAuB,OAAO;AAE1D,EAAAL,EAAA,KAAc,CAACK,KAId,OAAO,aACV,OAAO,WAAWV,EAAgB,GAClC,OAAO,cAAc;AAAA,IACnB,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ,UAAU;AAAA,EACZ;AAEJ;"}
1
+ {"version":3,"file":"mocks.js","sources":["../src/mocks.ts"],"sourcesContent":["import {\n Product,\n Gender,\n UserState,\n MinisContentStatus,\n} from '@shopify/shop-minis-platform'\nimport {ShopActions} from '@shopify/shop-minis-platform/actions'\n\nconst SAMPLE_IMAGE_NAMES = [\n 'garnished.jpeg',\n 'bath.jpeg',\n 'teapot.jpg',\n 'shoes.jpeg',\n]\n\n// Simple hash function to get a deterministic index from a string\nconst hashString = (str: string): number => {\n let hash = 0\n for (let i = 0; i < str.length; i++) {\n hash = (hash << 5) - hash + str.charCodeAt(i)\n hash |= 0\n }\n return Math.abs(hash)\n}\n\n// Helper functions for common data structures\nexport const createProduct = (\n id: string,\n title: string,\n price = '99.99',\n compareAtPrice?: string\n): Product => {\n const imageIndex = hashString(id) % SAMPLE_IMAGE_NAMES.length\n const imageName = SAMPLE_IMAGE_NAMES[imageIndex]\n\n return {\n id,\n title,\n price: {amount: price, currencyCode: 'USD'},\n ...(compareAtPrice && {\n compareAtPrice: {amount: compareAtPrice, currencyCode: 'USD'},\n }),\n reviewAnalytics: {averageRating: 4.5, reviewCount: 10},\n shop: createShop('shop1', 'Mock Shop'),\n defaultVariantId: `variant-${id}`,\n isFavorited: false,\n featuredImage: {\n url: `https://cdn.shopify.com/static/sample-images/${imageName}`,\n altText: title,\n },\n }\n}\n\nexport const createShop = (\n id: string,\n name: string,\n options?: {\n themeType?: 'coverImage' | 'brandColor' | 'logoColor' | 'none'\n withBrandSettings?: boolean\n primaryColor?: string\n logoDominantColor?: string\n logoAverageColor?: string\n coverDominantColor?: string\n wordmarkUrl?: string\n coverImageUrl?: string\n featuredImagesLimit?: number\n }\n) => {\n // Determine theme configuration\n const themeType = options?.themeType || 'none'\n const shouldHaveBrandSettings =\n options?.withBrandSettings || themeType !== 'none'\n\n // Generate featured images\n const featuredImagesCount = options?.featuredImagesLimit || 3\n const featuredImages = Array.from({length: featuredImagesCount}, (_, i) => ({\n url: `https://picsum.photos/400/400?random=${id}-${i}`,\n sensitive: false,\n altText: `${name} featured image ${i + 1}`,\n }))\n\n // Configure colors based on theme type\n const getThemeColors = () => {\n switch (themeType) {\n case 'coverImage':\n return {\n primary: options?.primaryColor,\n logoDominant: options?.logoDominantColor,\n logoAverage: options?.logoAverageColor,\n coverDominant: options?.coverDominantColor || '#FF6B35',\n }\n case 'brandColor':\n return {\n primary: options?.primaryColor || '#27AE60',\n logoDominant: options?.logoDominantColor,\n logoAverage: options?.logoAverageColor,\n coverDominant: options?.coverDominantColor,\n }\n case 'logoColor':\n return {\n primary: options?.primaryColor,\n logoDominant: options?.logoDominantColor || '#E74C3C',\n logoAverage: options?.logoAverageColor,\n coverDominant: options?.coverDominantColor,\n }\n default:\n return {\n primary: options?.primaryColor,\n logoDominant: options?.logoDominantColor,\n logoAverage: options?.logoAverageColor,\n coverDominant: options?.coverDominantColor,\n }\n }\n }\n\n // Configure header theme\n const createHeaderTheme = () => {\n if (themeType === 'coverImage' || options?.coverImageUrl) {\n return {\n id: `header-theme-${id}`,\n coverImage: {\n url:\n options?.coverImageUrl ||\n 'https://images.unsplash.com/photo-1441986300917-64674bd600d8?w=800&h=400&fit=crop',\n altText: `${name} cover image`,\n sensitive: false,\n thumbhash: 'k9oGHQRnh493V4dIeHeXh4h3iIeI',\n },\n wordmark:\n options?.wordmarkUrl || themeType === 'coverImage'\n ? {\n url:\n options?.wordmarkUrl ||\n 'https://merrypeople.com/cdn/shop/files/Transparent_Background_1.png?v=1696465429&width=1024',\n altText: `${name} wordmark`,\n sensitive: false,\n }\n : undefined,\n }\n }\n\n if (options?.wordmarkUrl) {\n return {\n id: `header-theme-${id}`,\n wordmark: {\n url: options.wordmarkUrl,\n altText: `${name} wordmark`,\n sensitive: false,\n },\n }\n }\n\n return undefined\n }\n\n return {\n id,\n name,\n primaryDomain: {\n url: `https://${name.toLowerCase().replace(/\\s+/g, '-')}.com`,\n },\n reviewAnalytics: {averageRating: 4.3, reviewCount: 50},\n visualTheme: {\n id: `visual-theme-${id}`,\n featuredImages,\n logoImage: {\n url: `https://picsum.photos/100/100?random=${id}`,\n sensitive: false,\n },\n brandSettings: shouldHaveBrandSettings\n ? {\n id: `brand-settings-${id}`,\n colors: {\n id: `colors-${id}`,\n ...getThemeColors(),\n },\n headerTheme: createHeaderTheme(),\n }\n : undefined,\n },\n }\n}\n\nconst createPagination = (hasNext = false) => ({\n hasNextPage: hasNext,\n endCursor: hasNext ? 'cursor123' : null,\n})\n\nconst createProductList = (id: string, name: string, products: any[] = []) => ({\n id,\n publicId: `public-${id}`,\n name,\n products,\n})\n\n// Helper type to extract the data type from a ShopAction\ntype ShopActionDataType<T> = T extends (\n ...args: any[]\n) => Promise<{ok: true; data: infer R} | {ok: false; error: any}>\n ? R\n : never\n\n// Use window._mockLogs instead of console.log so logs aren't stripped in production builds\n// This allows e2e tests to verify mock actions are being called\nexport interface MockLog {\n action: string\n params?: unknown\n}\n\ndeclare global {\n interface Window {\n _mockLogs?: MockLog[]\n }\n}\n\nfunction logMockAction(action: string, params?: unknown) {\n window._mockLogs = window._mockLogs || []\n window._mockLogs.push({action, params})\n}\n\nfunction makeMockMethod<K extends keyof ShopActions>(\n key: K,\n result: ShopActionDataType<ShopActions[K]>\n): ShopActions[K] {\n return ((params: Parameters<ShopActions[K]>[0]) => {\n logMockAction(String(key), params)\n return Promise.resolve({\n ok: true as const,\n data: result,\n mocked: true,\n })\n }) as ShopActions[K]\n}\n\nexport function makeMockActions(): ShopActions {\n const results: {\n [K in keyof ShopActions]: ShopActionDataType<ShopActions[K]>\n } = {\n translateContentUp: undefined,\n translateContentDown: undefined,\n followShop: true,\n unfollowShop: false,\n favorite: undefined,\n unfavorite: undefined,\n getShopAppInformation: {\n appVersion: '1.0.0',\n buildNumber: '12345',\n buildId: 'dev-build-123',\n },\n productRecommendationImpression: undefined,\n productRecommendationClick: undefined,\n closeMini: undefined,\n getAccountInformation: {\n status: 'available',\n value: 'user@example.com',\n },\n getCurrentUser: {\n data: {\n displayName: 'John Doe',\n avatarImage: {url: 'https://example.com/avatar.jpg'},\n },\n },\n createOrderAttribution: undefined,\n addToCart: undefined,\n buyProduct: undefined,\n buyProducts: undefined,\n showErrorScreen: undefined,\n showErrorToast: undefined,\n getDeeplinkPaths: {\n matchers: ['/products', '/collections', '/cart'],\n },\n navigateToDeeplink: undefined,\n navigateToShop: undefined,\n navigateToProduct: undefined,\n navigateToOrder: undefined,\n navigateToCheckout: undefined,\n createImageUploadLink: {\n // This action is mocked in the actual hook. See `useImageUpload` for more details.\n targets: [\n {\n url: 'https://example.com/upload',\n resourceUrl: 'https://example.com/resource',\n parameters: [{name: 'key', value: 'upload-123'}],\n },\n ],\n },\n completeImageUpload: {\n files: [\n {\n id: 'file-123',\n fileStatus: 'READY',\n image: {\n url: 'https://example.com/image.jpg',\n },\n },\n ],\n },\n getPersistedItem: null,\n setPersistedItem: undefined,\n removePersistedItem: undefined,\n getAllPersistedKeys: ['key1', 'key2', 'key3'],\n clearPersistedItems: undefined,\n getInternalPersistedItem: null,\n setInternalPersistedItem: undefined,\n removeInternalPersistedItem: undefined,\n getAllInternalPersistedKeys: ['internal-key1', 'internal-key2'],\n clearInternalPersistedItems: undefined,\n getSecret: 'secret-value',\n setSecret: undefined,\n removeSecret: undefined,\n reportInteraction: undefined,\n reportImpression: undefined,\n reportContentImpression: undefined,\n getProductLists: {\n data: [\n createProductList('list-1', 'Wishlist'),\n createProductList('list-2', 'Favorites'),\n ],\n pageInfo: createPagination(),\n },\n getProductList: {\n data: createProductList('list-1', 'Wishlist', [\n createProduct('prod-1', 'Sample Product'),\n ]),\n pageInfo: createPagination(),\n },\n addProductList: createProductList('list-3', 'New List'),\n removeProductList: undefined,\n renameProductList: createProductList('list-1', 'Updated Wishlist'),\n addProductListItem: undefined,\n removeProductListItem: undefined,\n getRecommendedProducts: {\n data: [\n createProduct('rec-1', 'Recommended Product 1', '79.99'),\n createProduct('rec-2', 'Recommended Product 2', '129.99'),\n createProduct('rec-3', 'Recommended Product 3', '129.99'),\n createProduct('rec-4', 'Recommended Product 4', '29.99'),\n createProduct('rec-5', 'Recommended Product 5', '39.99'),\n createProduct('rec-6', 'Recommended Product 6', '49.99'),\n createProduct('rec-7', 'Recommended Product 7', '59.99'),\n createProduct('rec-8', 'Recommended Product 8', '69.99'),\n createProduct('rec-9', 'Recommended Product 9', '129.99'),\n ],\n pageInfo: createPagination(),\n },\n getRecommendedShops: {\n data: [\n createShop('shop-1', 'Amazing Store'),\n createShop('shop-2', 'Best Deals Shop'),\n createShop('shop-3', 'Great Products'),\n createShop('shop-4', 'Top Brands'),\n createShop('shop-5', 'Exclusive Offers'),\n ],\n pageInfo: createPagination(),\n },\n searchProductsByShop: {\n data: [\n createProduct('search-1', 'Search Result 1', '59.99'),\n createProduct('search-2', 'Search Result 2', '89.99'),\n createProduct('search-3', 'Search Result 3', '119.99'),\n createProduct('search-4', 'Search Result 4', '149.99'),\n createProduct('search-5', 'Search Result 5', '179.99'),\n ],\n pageInfo: createPagination(),\n },\n getOrders: {\n data: [\n {\n id: 'order-1',\n name: '#1001',\n lineItems: [\n {\n productTitle: 'Sample Product',\n variantTitle: 'Medium',\n quantity: 2,\n product: null,\n },\n ],\n shop: createShop('shop-1', 'Sample Shop'),\n },\n ],\n pageInfo: createPagination(),\n },\n getBuyerAttributes: {\n data: {\n genderAffinity: 'NEUTRAL' as Gender,\n categoryAffinities: [\n {id: 'cat1', name: 'Electronics'},\n {id: 'cat2', name: 'Clothing'},\n ],\n },\n },\n showFeedbackSheet: undefined,\n getPopularProducts: {\n data: [\n createProduct('pop-1', 'The Hero Snowboard', '702.95'),\n createProduct('pop-2', 'Snow Jacket', '605.95', '702.00'),\n createProduct('pop-3', 'Winter Gloves', '89.95'),\n createProduct('pop-4', 'Summer Gloves', '89.95'),\n createProduct('pop-5', 'Spring Gloves', '89.95'),\n createProduct('pop-6', 'Playstation 5', '499.95'),\n createProduct('pop-7', 'Xbox Series X', '499.95'),\n createProduct('pop-8', 'Nintendo Switch', '299.95'),\n createProduct('pop-9', 'Playstation 4', '299.95'),\n createProduct('pop-10', 'Nintendo 3DS', '89.95'),\n ],\n pageInfo: createPagination(),\n },\n share: {\n message: 'Shared!',\n success: true,\n },\n shareSingle: {\n message: 'Shared!',\n success: true,\n },\n getCuratedProducts: {\n data: [\n createProduct('cur-1', 'Curated Product 1', '79.99'),\n createProduct('cur-2', 'Curated Product 2', '129.99'),\n ],\n pageInfo: createPagination(),\n },\n getSavedProducts: {\n data: [\n createProduct('saved-1', 'Saved Product 1', '49.99'),\n createProduct('saved-2', 'Saved Product 2', '59.99'),\n createProduct('saved-3', 'Saved Product 3', '69.99'),\n createProduct('saved-4', 'Saved Product 4', '79.99'),\n createProduct('saved-5', 'Saved Product 5', '89.99'),\n ],\n pageInfo: createPagination(),\n },\n getRecentProducts: {\n data: [\n createProduct('recent-1', 'Recent Product 1', '59.99'),\n createProduct('recent-2', 'Recent Product 2', '69.99'),\n createProduct('recent-3', 'Recent Product 3', '79.99'),\n createProduct('recent-4', 'Recent Product 4', '89.99'),\n createProduct('recent-5', 'Recent Product 5', '99.99'),\n ],\n pageInfo: createPagination(),\n },\n getProductSearch: {\n data: [\n createProduct('search-1', 'Search Product 1', '39.99'),\n createProduct('search-2', 'Search Product 2', '19.99'),\n createProduct('search-3', 'Search Product 3', '29.99'),\n createProduct('search-4', 'Search Product 4', '49.99'),\n createProduct('search-5', 'Search Product 5', '9.99'),\n ],\n pageInfo: createPagination(),\n },\n getProducts: {\n data: [\n createProduct('prod-1', 'Product 1', '9.99'),\n createProduct('prod-2', 'Product 2', '19.99'),\n createProduct('prod-3', 'Product 3', '29.99'),\n createProduct('prod-4', 'Product 4', '39.99'),\n createProduct('prod-5', 'Product 5', '49.99'),\n ],\n },\n getProduct: {data: createProduct('prod-1', 'Sample Product')},\n getProductVariants: {\n data: [\n {\n id: 'variant-1',\n title: 'Variant 1',\n isFavorited: false,\n image: {url: 'https://example.com/variant-1.jpg'},\n price: {amount: '19.99', currencyCode: 'USD'},\n compareAtPrice: {amount: '29.99', currencyCode: 'USD'},\n },\n ],\n pageInfo: createPagination(),\n },\n getProductMedia: {\n data: [\n {\n id: 'media-1',\n image: {url: 'https://example.com/media-1.jpg'},\n mediaContentType: 'IMAGE',\n alt: 'Sample product image',\n },\n ],\n pageInfo: createPagination(),\n },\n getShop: {\n data: createShop('shop-1', 'Sample Shop', {featuredImagesLimit: 4}),\n },\n getRecentShops: {\n data: [\n createShop('recent-shop-1', 'Recent Shop 1'),\n createShop('recent-shop-2', 'Recent Shop 2'),\n createShop('recent-shop-3', 'Recent Shop 3'),\n ],\n pageInfo: createPagination(),\n },\n getFollowedShops: {\n data: [\n createShop('followed-shop-1', 'Followed Shop 1'),\n createShop('followed-shop-2', 'Followed Shop 2'),\n createShop('followed-shop-3', 'Followed Shop 3'),\n ],\n pageInfo: createPagination(),\n },\n previewProductInAr: undefined,\n createContent: {\n data: {\n publicId: 'content-123',\n externalId: null,\n image: {\n id: 'img-123',\n url: 'https://cdn.shopify.com/s/files/1/0633/6574/2742/files/Namnlosdesign-47.png?v=1740438079',\n width: 800,\n height: 600,\n },\n title: 'Mock Content',\n description: 'This is a mock content item',\n visibility: ['DISCOVERABLE'],\n shareableUrl: 'https://example.com/content/123',\n products: null,\n },\n },\n getContent: {\n data: [\n {\n publicId: 'content-123',\n image: {\n id: 'img-123',\n url: 'https://cdn.shopify.com/s/files/1/0633/6574/2742/files/Namnlosdesign-47.png?v=1740438079',\n width: 800,\n height: 600,\n },\n title: 'Mock Content',\n visibility: ['DISCOVERABLE'],\n status: MinisContentStatus.READY,\n },\n ],\n },\n generateUserToken: {\n data: {\n token: 'user-token-123',\n expiresAt: '2025-01-01',\n userState: UserState.VERIFIED,\n },\n },\n navigateToCart: undefined,\n requestPermission: {\n granted: true,\n },\n reportError: undefined,\n reportFetch: undefined,\n } as const\n\n const mock: Partial<ShopActions> = {}\n for (const key in results) {\n if (Object.prototype.hasOwnProperty.call(results, key)) {\n // @ts-expect-error: dynamic assignment is safe due to exhaustive mapping\n mock[key] = makeMockMethod(\n key as keyof ShopActions,\n results[key as keyof typeof results]\n )\n }\n }\n return mock as ShopActions\n}\n\n// Detect if running on a mobile device\nconst isMobile = (): boolean => {\n const userAgent = navigator.userAgent.toLowerCase()\n const isIOS = /iphone|ipad|ipod/.test(userAgent)\n const isAndroid = /android/.test(userAgent)\n\n return isIOS || isAndroid\n}\n\nexport const injectMocks = ({force}: {force?: boolean} = {}) => {\n // Only inject mocks if we aren't on a mobile device or we force it\n if (isMobile() && !force) {\n return\n }\n\n if (!window.minisSDK) {\n window.minisSDK = makeMockActions()\n window.minisParams = {\n handle: 'mock-handle',\n initialUrl: '/',\n platform: 'web',\n }\n }\n}\n"],"names":["SAMPLE_IMAGE_NAMES","hashString","str","hash","i","createProduct","id","title","price","compareAtPrice","imageIndex","imageName","createShop","name","options","themeType","shouldHaveBrandSettings","featuredImagesCount","featuredImages","_","getThemeColors","createHeaderTheme","createPagination","hasNext","createProductList","products","logMockAction","action","params","makeMockMethod","key","result","makeMockActions","results","MinisContentStatus","UserState","mock","isMobile","userAgent","isIOS","isAndroid","injectMocks","force"],"mappings":";;AAQA,MAAMA,IAAqB;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAGMC,IAAa,CAACC,MAAwB;AAC1C,MA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,OAAO,cAAc;AAAA,IACnB,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ,UAAU;AAAA,EACZ;AAEJ;"}
@@ -0,0 +1,19 @@
1
+ var e = /* @__PURE__ */ ((E) => (E.SUCCESS = "SUCCESS", E.CANCELLED = "CANCELLED", E.FAILED = "FAILED", E))(e || {});
2
+ function L(E, C) {
3
+ switch (E.resultCode) {
4
+ case "SUCCESS":
5
+ return C.SUCCESS(E.data);
6
+ case "CANCELLED":
7
+ return C.CANCELLED();
8
+ case "FAILED":
9
+ return C.FAILED(E.error);
10
+ default:
11
+ const r = E.resultCode;
12
+ throw new Error(`Unhandled result code: ${r}`);
13
+ }
14
+ }
15
+ export {
16
+ e as IntentResultCode,
17
+ L as handleIntentResult
18
+ };
19
+ //# sourceMappingURL=shared.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.js","sources":["../../../../../shop-minis-platform/src/intents/shared.ts"],"sourcesContent":["/**\n * Shared types for the Shop Minis Intent system\n *\n * Intents allow Minis to trigger interactive flows in the parent Shop app\n * (or other Minis in the future) and receive structured responses.\n */\n\n/**\n * Intent result codes, similar to Android's Activity result codes\n */\nexport enum IntentResultCode {\n /**\n * The intent completed successfully\n */\n SUCCESS = 'SUCCESS',\n\n /**\n * The intent was cancelled by the user\n * (e.g., user closed the modal, pressed back button)\n */\n CANCELLED = 'CANCELLED',\n\n /**\n * The intent failed due to an error\n */\n FAILED = 'FAILED',\n}\n\n/**\n * Common wrapper for all intent responses\n *\n * @template T - The type of the intent-specific response data\n */\nexport interface ShopIntentResult<T = void> {\n /**\n * Result code indicating success, cancellation, or failure\n */\n resultCode: IntentResultCode\n\n /**\n * Intent-specific response data\n * Only present when resultCode is SUCCESS\n */\n data?: T\n\n /**\n * Error information\n * Only present when resultCode is FAILED\n */\n error?: {\n /** Human-readable error message */\n message: string\n /** Optional error code for programmatic handling */\n code?: string\n }\n}\n\n/**\n * Generic type representing any intent handler\n *\n * @template P - The params type for the intent\n * @template R - The result data type for the intent\n *\n * Unlike actions which can reject, intents always resolve with a\n * ShopIntentResult that contains the result code and optional data/error\n */\nexport type ShopIntent<P, R> = (\n params: P\n) => Promise<ShopIntentResult<R>>\n\n/**\n * Utility type to convert SNAKE_CASE to camelCase\n * Example: 'SELECT_PRODUCT' -> 'selectProduct'\n */\nexport type SnakeToCamelCase<S extends string> =\n S extends `${infer Head}_${infer Tail}`\n ? `${Lowercase<Head>}${Capitalize<SnakeToCamelCase<Tail>>}`\n : Lowercase<S>\n\n/**\n * Helper type to ensure intent result codes are handled exhaustively\n */\nexport type IntentResultHandler<T, R> = {\n [IntentResultCode.SUCCESS]: (data: T) => R\n [IntentResultCode.CANCELLED]: () => R\n [IntentResultCode.FAILED]: (error: {message: string; code?: string}) => R\n}\n\n/**\n * Helper function to handle intent results in a type-safe way\n *\n * @example\n * const result = await minisIntents.selectProduct({...});\n * const products = handleIntentResult(result, {\n * SUCCESS: (data) => data.products,\n * CANCELLED: () => [],\n * FAILED: (error) => { console.error(error); return []; }\n * });\n */\nexport function handleIntentResult<T, R>(\n result: ShopIntentResult<T>,\n handlers: IntentResultHandler<T, R>\n): R {\n switch (result.resultCode) {\n case IntentResultCode.SUCCESS:\n return handlers[IntentResultCode.SUCCESS](result.data!)\n case IntentResultCode.CANCELLED:\n return handlers[IntentResultCode.CANCELLED]()\n case IntentResultCode.FAILED:\n return handlers[IntentResultCode.FAILED](result.error!)\n default:\n // Exhaustiveness check\n const _exhaustive: never = result.resultCode\n throw new Error(`Unhandled result code: ${_exhaustive}`)\n }\n}\n\n"],"names":["IntentResultCode","handleIntentResult","result","handlers","_exhaustive"],"mappings":"AAUY,IAAAA,sBAAAA,OAIVA,EAAA,UAAU,WAMVA,EAAA,YAAY,aAKZA,EAAA,SAAS,UAfCA,IAAAA,KAAA,CAAA,CAAA;AAyFI,SAAAC,EACdC,GACAC,GACG;AACH,UAAQD,EAAO,YAAY;AAAA,IACzB,KAAK;AACH,aAAOC,EAAS,QAA0BD,EAAO,IAAK;AAAA,IACxD,KAAK;AACI,aAAAC,EAAS,UAA4B;AAAA,IAC9C,KAAK;AACH,aAAOA,EAAS,OAAyBD,EAAO,KAAM;AAAA,IACxD;AAEE,YAAME,IAAqBF,EAAO;AAClC,YAAM,IAAI,MAAM,0BAA0BE,CAAW,EAAE;AAAA,EAAA;AAE7D;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@shopify/shop-minis-react",
3
3
  "license": "SEE LICENSE IN LICENSE.txt",
4
- "version": "0.0.0-snapshot.20251219160956",
4
+ "version": "0.0.0-snapshot.20251222174301",
5
5
  "sideEffects": false,
6
6
  "type": "module",
7
7
  "engines": {
@@ -46,7 +46,7 @@
46
46
  "typescript": ">=5.0.0"
47
47
  },
48
48
  "dependencies": {
49
- "@shopify/shop-minis-platform": "0.0.0-snapshot.20251219160956",
49
+ "@shopify/shop-minis-platform": "0.0.0-snapshot.20251222174301",
50
50
  "@tailwindcss/vite": "4.1.8",
51
51
  "@tanstack/react-query": "5.86.0",
52
52
  "@types/color": "3.0.6",
@@ -1,7 +1,5 @@
1
1
  import {BrowserRouter, BrowserRouterProps} from 'react-router'
2
2
 
3
- import {NavigationManager} from '../../internal/navigation-manager'
4
-
5
3
  import {TransitionContainer} from './transition-container'
6
4
 
7
5
  export interface MinisRouterProps extends BrowserRouterProps {
@@ -16,16 +14,10 @@ export function MinisRouter({
16
14
  if (viewTransitions) {
17
15
  return (
18
16
  <BrowserRouter {...props}>
19
- <NavigationManager />
20
17
  <TransitionContainer>{children}</TransitionContainer>
21
18
  </BrowserRouter>
22
19
  )
23
20
  }
24
21
 
25
- return (
26
- <BrowserRouter {...props}>
27
- <NavigationManager />
28
- {children}
29
- </BrowserRouter>
30
- )
22
+ return <BrowserRouter {...props}>{children}</BrowserRouter>
31
23
  }
@@ -41,6 +41,9 @@ export * from './shop/useRecommendedShops'
41
41
  // - Content Hooks
42
42
  export * from './content/useCreateImageContent'
43
43
 
44
+ // - Intent Hooks
45
+ export * from './intents'
46
+
44
47
  // - Utility Hooks
45
48
  export * from './util/useErrorToast'
46
49
  export * from './util/useErrorScreen'
@@ -54,4 +57,3 @@ export * from './events/useOnMiniFocus'
54
57
  export * from './events/useOnMiniBlur'
55
58
  export * from './events/useOnMiniClose'
56
59
  export * from './events/useOnAppStateChange'
57
- export * from './events/useOnNavigateBack'
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Shop Intents Hooks
3
+ *
4
+ * React hooks for triggering interactive flows in the Shop app.
5
+ * Each hook wraps an intent and provides a clean API for handling results.
6
+ *
7
+ * @example
8
+ * import { useProductSelection } from '@shopify/shop-minis-react'
9
+ *
10
+ * const MyComponent = () => {
11
+ * const selectProducts = useProductSelection({
12
+ * onCancel: () => console.log('User cancelled')
13
+ * })
14
+ *
15
+ * const handleSelect = async () => {
16
+ * const result = await selectProducts({ multiSelect: true })
17
+ * if (result) {
18
+ * console.log('Selected:', result.products)
19
+ * }
20
+ * }
21
+ *
22
+ * return <button onClick={handleSelect}>Select Products</button>
23
+ * }
24
+ */
25
+
26
+ export {useProductSelection} from './useProductSelection'
27
+ export type {ProductSelectionFunction} from './useProductSelection'
28
+
29
+ export {useImageCapture} from './useImageCapture'
30
+ export type {ImageCaptureFunction} from './useImageCapture'
31
+
32
+ export {useContentShare} from './useContentShare'
33
+ export type {ContentShareFunction} from './useContentShare'
34
+
35
+ export {useLocationSelection} from './useLocationSelection'
36
+ export type {LocationSelectionFunction} from './useLocationSelection'
37
+
38
+ export {useBarcodeScanner} from './useBarcodeScanner'
39
+ export type {BarcodeScannerFunction} from './useBarcodeScanner'
40
+
41
+ export {usePaymentRequest} from './usePaymentRequest'
42
+ export type {PaymentRequestFunction} from './usePaymentRequest'
@@ -0,0 +1,43 @@
1
+ import {
2
+ useHandleIntent,
3
+ HandleIntentOptions,
4
+ } from '../../internal/useHandleIntent'
5
+ import {useShopIntents} from '../../internal/useShopIntents'
6
+
7
+ import type {
8
+ ScanBarcodeIntentParams,
9
+ ScanBarcodeIntentResult,
10
+ } from '@shopify/shop-minis-platform'
11
+
12
+ /**
13
+ * Hook to scan barcodes or QR codes
14
+ *
15
+ * This intent opens the camera to scan barcodes or QR codes.
16
+ *
17
+ * @example
18
+ * const scanBarcode = useBarcodeScanner({
19
+ * onCancel: () => console.log('User cancelled'),
20
+ * })
21
+ *
22
+ * const result = await scanBarcode({
23
+ * types: ['qr', 'ean13'],
24
+ * instruction: 'Scan product barcode'
25
+ * })
26
+ *
27
+ * if (result) {
28
+ * console.log('Scanned:', result.barcodes)
29
+ * }
30
+ */
31
+ export const useBarcodeScanner = (
32
+ options?: HandleIntentOptions<ScanBarcodeIntentResult>
33
+ ) => {
34
+ const intents = useShopIntents()
35
+ return useHandleIntent(intents.scanBarcode, options)
36
+ }
37
+
38
+ /**
39
+ * Type helper for the barcode scanner function
40
+ */
41
+ export type BarcodeScannerFunction = (
42
+ params: ScanBarcodeIntentParams
43
+ ) => Promise<ScanBarcodeIntentResult | void>
@@ -0,0 +1,47 @@
1
+ import {
2
+ useHandleIntent,
3
+ HandleIntentOptions,
4
+ } from '../../internal/useHandleIntent'
5
+ import {useShopIntents} from '../../internal/useShopIntents'
6
+
7
+ import type {
8
+ ShareContentIntentParams,
9
+ ShareContentIntentResult,
10
+ } from '@shopify/shop-minis-platform'
11
+
12
+ /**
13
+ * Hook to share content via the Shop app's native share sheet
14
+ *
15
+ * This intent opens the native share sheet to let the user
16
+ * share content to various platforms.
17
+ *
18
+ * @example
19
+ * const shareContent = useContentShare({
20
+ * onCancel: () => console.log('User cancelled sharing'),
21
+ * })
22
+ *
23
+ * const result = await shareContent({
24
+ * type: 'product',
25
+ * content: {
26
+ * title: 'Check out this product!',
27
+ * url: 'https://shop.app/products/123'
28
+ * }
29
+ * })
30
+ *
31
+ * if (result?.shared) {
32
+ * console.log('Content shared to:', result.platform)
33
+ * }
34
+ */
35
+ export const useContentShare = (
36
+ options?: HandleIntentOptions<ShareContentIntentResult>
37
+ ) => {
38
+ const intents = useShopIntents()
39
+ return useHandleIntent(intents.shareContent, options)
40
+ }
41
+
42
+ /**
43
+ * Type helper for the content share function
44
+ */
45
+ export type ContentShareFunction = (
46
+ params: ShareContentIntentParams
47
+ ) => Promise<ShareContentIntentResult | void>
@@ -0,0 +1,45 @@
1
+ import {
2
+ useHandleIntent,
3
+ HandleIntentOptions,
4
+ } from '../../internal/useHandleIntent'
5
+ import {useShopIntents} from '../../internal/useShopIntents'
6
+
7
+ import type {
8
+ CaptureImageIntentParams,
9
+ CaptureImageIntentResult,
10
+ } from '@shopify/shop-minis-platform'
11
+
12
+ /**
13
+ * Hook to request user to capture or select images
14
+ *
15
+ * This intent opens the camera or photo gallery to let the user
16
+ * capture or select one or more images.
17
+ *
18
+ * @example
19
+ * const captureImage = useImageCapture({
20
+ * onCancel: () => console.log('User cancelled'),
21
+ * })
22
+ *
23
+ * const result = await captureImage({
24
+ * source: 'camera',
25
+ * quality: 0.8,
26
+ * maxWidth: 1920
27
+ * })
28
+ *
29
+ * if (result) {
30
+ * console.log('Captured images:', result.images)
31
+ * }
32
+ */
33
+ export const useImageCapture = (
34
+ options?: HandleIntentOptions<CaptureImageIntentResult>
35
+ ) => {
36
+ const intents = useShopIntents()
37
+ return useHandleIntent(intents.captureImage, options)
38
+ }
39
+
40
+ /**
41
+ * Type helper for the image capture function
42
+ */
43
+ export type ImageCaptureFunction = (
44
+ params: CaptureImageIntentParams
45
+ ) => Promise<CaptureImageIntentResult | void>
@@ -0,0 +1,45 @@
1
+ import {
2
+ useHandleIntent,
3
+ HandleIntentOptions,
4
+ } from '../../internal/useHandleIntent'
5
+ import {useShopIntents} from '../../internal/useShopIntents'
6
+
7
+ import type {
8
+ SelectLocationIntentParams,
9
+ SelectLocationIntentResult,
10
+ } from '@shopify/shop-minis-platform'
11
+
12
+ /**
13
+ * Hook to request user to select a location
14
+ *
15
+ * This intent shows a map interface where the user can select
16
+ * a location and optionally get address information.
17
+ *
18
+ * @example
19
+ * const selectLocation = useLocationSelection({
20
+ * onCancel: () => console.log('User cancelled'),
21
+ * })
22
+ *
23
+ * const result = await selectLocation({
24
+ * title: 'Select delivery location',
25
+ * locationType: 'address'
26
+ * })
27
+ *
28
+ * if (result) {
29
+ * console.log('Selected location:', result.coordinates)
30
+ * console.log('Address:', result.address?.formattedAddress)
31
+ * }
32
+ */
33
+ export const useLocationSelection = (
34
+ options?: HandleIntentOptions<SelectLocationIntentResult>
35
+ ) => {
36
+ const intents = useShopIntents()
37
+ return useHandleIntent(intents.selectLocation, options)
38
+ }
39
+
40
+ /**
41
+ * Type helper for the location selection function
42
+ */
43
+ export type LocationSelectionFunction = (
44
+ params: SelectLocationIntentParams
45
+ ) => Promise<SelectLocationIntentResult | void>
@@ -0,0 +1,47 @@
1
+ import {
2
+ useHandleIntent,
3
+ HandleIntentOptions,
4
+ } from '../../internal/useHandleIntent'
5
+ import {useShopIntents} from '../../internal/useShopIntents'
6
+
7
+ import type {
8
+ RequestPaymentIntentParams,
9
+ RequestPaymentIntentResult,
10
+ } from '@shopify/shop-minis-platform'
11
+
12
+ /**
13
+ * Hook to request payment from user
14
+ *
15
+ * This intent opens the Shop app's payment flow to process a payment.
16
+ *
17
+ * **Note:** This intent requires special permissions and may have rate limits.
18
+ *
19
+ * @example
20
+ * const requestPayment = usePaymentRequest({
21
+ * onCancel: () => console.log('User cancelled payment'),
22
+ * onError: (error) => console.error('Payment failed:', error)
23
+ * })
24
+ *
25
+ * const result = await requestPayment({
26
+ * amount: 999, // $9.99 in cents
27
+ * currency: 'USD',
28
+ * description: 'Premium subscription'
29
+ * })
30
+ *
31
+ * if (result) {
32
+ * console.log('Payment successful:', result.transactionId)
33
+ * }
34
+ */
35
+ export const usePaymentRequest = (
36
+ options?: HandleIntentOptions<RequestPaymentIntentResult>
37
+ ) => {
38
+ const intents = useShopIntents()
39
+ return useHandleIntent(intents.requestPayment, options)
40
+ }
41
+
42
+ /**
43
+ * Type helper for the payment request function
44
+ */
45
+ export type PaymentRequestFunction = (
46
+ params: RequestPaymentIntentParams
47
+ ) => Promise<RequestPaymentIntentResult | void>
@@ -0,0 +1,45 @@
1
+ import {
2
+ useHandleIntent,
3
+ HandleIntentOptions,
4
+ } from '../../internal/useHandleIntent'
5
+ import {useShopIntents} from '../../internal/useShopIntents'
6
+
7
+ import type {
8
+ SelectProductIntentParams,
9
+ SelectProductIntentResult,
10
+ } from '@shopify/shop-minis-platform'
11
+
12
+ /**
13
+ * Hook to request user to select products
14
+ *
15
+ * This intent shows a product selection screen where the user can browse
16
+ * and select one or more products from the Shop catalog.
17
+ *
18
+ * @example
19
+ * const selectProducts = useProductSelection({
20
+ * onCancel: () => console.log('User cancelled'),
21
+ * })
22
+ *
23
+ * const result = await selectProducts({
24
+ * multiSelect: true,
25
+ * maxSelections: 5,
26
+ * title: 'Choose your favorites'
27
+ * })
28
+ *
29
+ * if (result) {
30
+ * console.log('Selected products:', result.products)
31
+ * }
32
+ */
33
+ export const useProductSelection = (
34
+ options?: HandleIntentOptions<SelectProductIntentResult>
35
+ ) => {
36
+ const intents = useShopIntents()
37
+ return useHandleIntent(intents.selectProduct, options)
38
+ }
39
+
40
+ /**
41
+ * Type helper for the product selection function
42
+ */
43
+ export type ProductSelectionFunction = (
44
+ params: SelectProductIntentParams
45
+ ) => Promise<SelectProductIntentResult | void>