@shopify/shop-minis-react 0.0.0-snapshot.20251224113248 → 0.0.0-snapshot.20260109162751
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/navigation/minis-router.js +15 -8
- package/dist/components/navigation/minis-router.js.map +1 -1
- package/dist/hooks/events/useOnNavigateBack.js +14 -0
- package/dist/hooks/events/useOnNavigateBack.js.map +1 -0
- package/dist/hooks/navigation/useNavigateWithTransition.js +6 -6
- package/dist/hooks/navigation/useNavigateWithTransition.js.map +1 -1
- package/dist/index.js +132 -139
- package/dist/index.js.map +1 -1
- package/dist/internal/navigation-manager.js +12 -0
- package/dist/internal/navigation-manager.js.map +1 -0
- package/dist/mocks.js +15 -49
- package/dist/mocks.js.map +1 -1
- package/eslint/config.cjs +1 -0
- package/eslint/index.cjs +2 -0
- package/eslint/rules/no-javascript-files.cjs +44 -0
- package/package.json +2 -2
- package/src/components/navigation/minis-router.tsx +9 -1
- package/src/hooks/events/useOnNavigateBack.ts +16 -0
- package/src/hooks/index.ts +1 -3
- package/src/hooks/navigation/useNavigateWithTransition.test.ts +17 -3
- package/src/hooks/navigation/useNavigateWithTransition.ts +9 -4
- package/src/internal/navigation-manager.tsx +13 -0
- package/src/mocks.ts +1 -35
- package/dist/hooks/intents/useInvokeIntentAction.js +0 -10
- package/dist/hooks/intents/useInvokeIntentAction.js.map +0 -1
- package/dist/hooks/intents/useQueryIntents.js +0 -10
- package/dist/hooks/intents/useQueryIntents.js.map +0 -1
- package/dist/hooks/intents/useSelectProduct.js +0 -21
- package/dist/hooks/intents/useSelectProduct.js.map +0 -1
- package/dist/shop-minis-platform/src/actions/scopes.js +0 -36
- package/dist/shop-minis-platform/src/actions/scopes.js.map +0 -1
- package/src/hooks/intents/index.ts +0 -38
- package/src/hooks/intents/useInvokeIntentAction.ts +0 -12
- package/src/hooks/intents/useQueryIntents.ts +0 -25
- package/src/hooks/intents/useSelectProduct.ts +0 -48
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
var E = /* @__PURE__ */ ((_) => (_.OPENID = "openid", _.USER_SETTINGS_READ = "user_settings:read", _.PROFILE = "profile", _.PRODUCTS_RECENT_READ = "products:recent:read", _.PRODUCTS_RECOMMENDATIONS_READ = "products:recommendations:read", _.SHOPS_RECENT_READ = "shops:recent:read", _.SHOPS_FOLLOWS = "shops:follows", _.SHOPS_FOLLOWS_READ = "shops:follows:read", _.SHOPS_FOLLOWS_WRITE = "shops:follows:write", _.SHOPS_RECOMMENDATIONS_READ = "shops:recommendations:read", _.ORDERS = "orders", _.PRODUCT_LIST = "product_list", _.PRODUCT_LIST_READ = "product_list:read", _.PRODUCT_LIST_WRITE = "product_list:write", _.PRODUCT_LIST_ITEM_WRITE = "product_list_item:write", _))(E || {});
|
|
2
|
-
const r = {
|
|
3
|
-
// User
|
|
4
|
-
GENERATE_USER_TOKEN: "openid",
|
|
5
|
-
GET_ACCOUNT_INFORMATION: "profile",
|
|
6
|
-
GET_BUYER_ATTRIBUTES: "profile",
|
|
7
|
-
GET_CURRENT_USER: "user_settings:read",
|
|
8
|
-
// Shops
|
|
9
|
-
GET_FOLLOWED_SHOPS: "shops:follows:read",
|
|
10
|
-
GET_RECENT_SHOPS: "shops:recent:read",
|
|
11
|
-
GET_RECOMMENDED_SHOPS: "shops:recommendations:read",
|
|
12
|
-
FOLLOW_SHOP: "shops:follows:write",
|
|
13
|
-
UNFOLLOW_SHOP: "shops:follows:write",
|
|
14
|
-
// Products
|
|
15
|
-
GET_RECENT_PRODUCTS: "products:recent:read",
|
|
16
|
-
GET_RECOMMENDED_PRODUCTS: "products:recommendations:read",
|
|
17
|
-
// Orders
|
|
18
|
-
GET_ORDERS: "orders",
|
|
19
|
-
// Product lists
|
|
20
|
-
ADD_PRODUCT_LIST: "product_list:write",
|
|
21
|
-
ADD_PRODUCT_LIST_ITEM: "product_list_item:write",
|
|
22
|
-
FAVORITE: "product_list:write",
|
|
23
|
-
UNFAVORITE: "product_list:write",
|
|
24
|
-
REMOVE_PRODUCT_LIST: "product_list:write",
|
|
25
|
-
REMOVE_PRODUCT_LIST_ITEM: "product_list_item:write",
|
|
26
|
-
RENAME_PRODUCT_LIST: "product_list:write",
|
|
27
|
-
GET_SAVED_PRODUCTS: "product_list:read",
|
|
28
|
-
GET_PRODUCT_LIST: "product_list:read",
|
|
29
|
-
GET_PRODUCT_LISTS: "product_list:read"
|
|
30
|
-
/* PRODUCT_LIST_READ */
|
|
31
|
-
};
|
|
32
|
-
export {
|
|
33
|
-
r as ActionToScopesMapping,
|
|
34
|
-
E as Scope
|
|
35
|
-
};
|
|
36
|
-
//# sourceMappingURL=scopes.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scopes.js","sources":["../../../../../shop-minis-platform/src/actions/scopes.ts"],"sourcesContent":["import {ShopActionEvents} from '@shopify/shop-minis-platform/actions'\n\n// This enum should always match `MiniScopeEnum` in `shop-types`\n/* eslint-disable @shopify/typescript/prefer-pascal-case-enums */\nexport enum Scope {\n // User\n OPENID = 'openid',\n USER_SETTINGS_READ = 'user_settings:read',\n PROFILE = 'profile',\n\n // Products\n PRODUCTS_RECENT_READ = 'products:recent:read',\n PRODUCTS_RECOMMENDATIONS_READ = 'products:recommendations:read',\n\n // Shops\n SHOPS_RECENT_READ = 'shops:recent:read',\n SHOPS_FOLLOWS = 'shops:follows',\n SHOPS_FOLLOWS_READ = 'shops:follows:read',\n SHOPS_FOLLOWS_WRITE = 'shops:follows:write',\n SHOPS_RECOMMENDATIONS_READ = 'shops:recommendations:read',\n\n // Orders\n ORDERS = 'orders',\n\n // Product lists\n PRODUCT_LIST = 'product_list',\n PRODUCT_LIST_READ = 'product_list:read',\n PRODUCT_LIST_WRITE = 'product_list:write',\n PRODUCT_LIST_ITEM_WRITE = 'product_list_item:write',\n}\n/* eslint-enable @shopify/typescript/prefer-pascal-case-enums */\n\nexport const ActionToScopesMapping: {\n [key in keyof ShopActionEvents]?: Scope\n} = {\n // User\n GENERATE_USER_TOKEN: Scope.OPENID,\n GET_ACCOUNT_INFORMATION: Scope.PROFILE,\n GET_BUYER_ATTRIBUTES: Scope.PROFILE,\n GET_CURRENT_USER: Scope.USER_SETTINGS_READ,\n\n // Shops\n GET_FOLLOWED_SHOPS: Scope.SHOPS_FOLLOWS_READ,\n GET_RECENT_SHOPS: Scope.SHOPS_RECENT_READ,\n GET_RECOMMENDED_SHOPS: Scope.SHOPS_RECOMMENDATIONS_READ,\n FOLLOW_SHOP: Scope.SHOPS_FOLLOWS_WRITE,\n UNFOLLOW_SHOP: Scope.SHOPS_FOLLOWS_WRITE,\n\n // Products\n GET_RECENT_PRODUCTS: Scope.PRODUCTS_RECENT_READ,\n GET_RECOMMENDED_PRODUCTS: Scope.PRODUCTS_RECOMMENDATIONS_READ,\n\n // Orders\n GET_ORDERS: Scope.ORDERS,\n\n // Product lists\n ADD_PRODUCT_LIST: Scope.PRODUCT_LIST_WRITE,\n ADD_PRODUCT_LIST_ITEM: Scope.PRODUCT_LIST_ITEM_WRITE,\n FAVORITE: Scope.PRODUCT_LIST_WRITE,\n UNFAVORITE: Scope.PRODUCT_LIST_WRITE,\n REMOVE_PRODUCT_LIST: Scope.PRODUCT_LIST_WRITE,\n REMOVE_PRODUCT_LIST_ITEM: Scope.PRODUCT_LIST_ITEM_WRITE,\n RENAME_PRODUCT_LIST: Scope.PRODUCT_LIST_WRITE,\n GET_SAVED_PRODUCTS: Scope.PRODUCT_LIST_READ,\n GET_PRODUCT_LIST: Scope.PRODUCT_LIST_READ,\n GET_PRODUCT_LISTS: Scope.PRODUCT_LIST_READ,\n} as const\n"],"names":["Scope","ActionToScopesMapping"],"mappings":"AAIY,IAAAA,sBAAAA,OAEVA,EAAA,SAAS,UACTA,EAAA,qBAAqB,sBACrBA,EAAA,UAAU,WAGVA,EAAA,uBAAuB,wBACvBA,EAAA,gCAAgC,iCAGhCA,EAAA,oBAAoB,qBACpBA,EAAA,gBAAgB,iBAChBA,EAAA,qBAAqB,sBACrBA,EAAA,sBAAsB,uBACtBA,EAAA,6BAA6B,8BAG7BA,EAAA,SAAS,UAGTA,EAAA,eAAe,gBACfA,EAAA,oBAAoB,qBACpBA,EAAA,qBAAqB,sBACrBA,EAAA,0BAA0B,2BAxBhBA,IAAAA,KAAA,CAAA,CAAA;AA4BL,MAAMC,IAET;AAAA;AAAA,EAEF,qBAAqB;AAAA,EACrB,yBAAyB;AAAA,EACzB,sBAAsB;AAAA,EACtB,kBAAkB;AAAA;AAAA,EAGlB,oBAAoB;AAAA,EACpB,kBAAkB;AAAA,EAClB,uBAAuB;AAAA,EACvB,aAAa;AAAA,EACb,eAAe;AAAA;AAAA,EAGf,qBAAqB;AAAA,EACrB,0BAA0B;AAAA;AAAA,EAG1B,YAAY;AAAA;AAAA,EAGZ,kBAAkB;AAAA,EAClB,uBAAuB;AAAA,EACvB,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,qBAAqB;AAAA,EACrB,0BAA0B;AAAA,EAC1B,qBAAqB;AAAA,EACrB,oBAAoB;AAAA,EACpB,kBAAkB;AAAA,EAClB,mBAAmB;AAAA;AACrB;"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shop Intents Hooks
|
|
3
|
-
*
|
|
4
|
-
* React hooks for discovering and invoking intents.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* import { useQueryIntents, useInvokeIntentAction } from '@shopify/shop-minis-react'
|
|
8
|
-
*
|
|
9
|
-
* const MyComponent = () => {
|
|
10
|
-
* const queryIntents = useQueryIntents()
|
|
11
|
-
* const invokeIntent = useInvokeIntentAction()
|
|
12
|
-
*
|
|
13
|
-
* const handleSelect = async () => {
|
|
14
|
-
* // Query available intents
|
|
15
|
-
* const intents = await queryIntents({category: 'commerce'})
|
|
16
|
-
*
|
|
17
|
-
* // Invoke intent
|
|
18
|
-
* const result = await invokeIntent({
|
|
19
|
-
* provider: 'shop',
|
|
20
|
-
* intentType: 'select:shopify/Product',
|
|
21
|
-
* input: {multiSelect: true}
|
|
22
|
-
* })
|
|
23
|
-
*
|
|
24
|
-
* if (result.resultCode === 'SUCCESS') {
|
|
25
|
-
* console.log('Selected:', result.output.ids)
|
|
26
|
-
* }
|
|
27
|
-
* }
|
|
28
|
-
*
|
|
29
|
-
* return <button onClick={handleSelect}>Select Products</button>
|
|
30
|
-
* }
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
// Core intent actions
|
|
34
|
-
export {useQueryIntents} from './useQueryIntents'
|
|
35
|
-
export {useInvokeIntentAction} from './useInvokeIntentAction'
|
|
36
|
-
|
|
37
|
-
// Convenience hooks (wrap invokeIntent with specific intent types)
|
|
38
|
-
export {useSelectProduct} from './useSelectProduct'
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import {useHandleAction} from '../../internal/useHandleAction'
|
|
2
|
-
import {useShopActions} from '../../internal/useShopActions'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Hook to invoke an intent
|
|
6
|
-
*
|
|
7
|
-
* Unified API for invoking intents.
|
|
8
|
-
*/
|
|
9
|
-
export const useInvokeIntentAction = () => {
|
|
10
|
-
const actions = useShopActions()
|
|
11
|
-
return useHandleAction(actions.invokeIntent)
|
|
12
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import {useHandleAction} from '../../internal/useHandleAction'
|
|
2
|
-
import {useShopActions} from '../../internal/useShopActions'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Hook to query available intents
|
|
6
|
-
*
|
|
7
|
-
* Returns intents that match the query criteria.
|
|
8
|
-
* Works for both first-party Shop intents and third-party Mini intents.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* const queryIntents = useQueryIntents()
|
|
12
|
-
*
|
|
13
|
-
* // Get all intents
|
|
14
|
-
* const allIntents = await queryIntents()
|
|
15
|
-
*
|
|
16
|
-
* // Filter by category
|
|
17
|
-
* const mediaIntents = await queryIntents({category: 'media'})
|
|
18
|
-
*
|
|
19
|
-
* // Search
|
|
20
|
-
* const results = await queryIntents({search: 'product'})
|
|
21
|
-
*/
|
|
22
|
-
export const useQueryIntents = () => {
|
|
23
|
-
const actions = useShopActions()
|
|
24
|
-
return useHandleAction(actions.queryIntents)
|
|
25
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import {useCallback} from 'react'
|
|
2
|
-
|
|
3
|
-
import {useInvokeIntentAction} from './useInvokeIntentAction'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Convenience hook for selecting products
|
|
7
|
-
*
|
|
8
|
-
* Wraps the unified invokeIntent action with product-specific defaults.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* const selectProduct = useSelectProduct()
|
|
12
|
-
*
|
|
13
|
-
* const result = await selectProduct({
|
|
14
|
-
* multiSelect: true,
|
|
15
|
-
* maxSelections: 5
|
|
16
|
-
* })
|
|
17
|
-
*
|
|
18
|
-
* if (result) {
|
|
19
|
-
* console.log('Selected IDs:', result.ids)
|
|
20
|
-
* }
|
|
21
|
-
*/
|
|
22
|
-
export const useSelectProduct = () => {
|
|
23
|
-
const invokeIntent = useInvokeIntentAction()
|
|
24
|
-
|
|
25
|
-
return useCallback(
|
|
26
|
-
async (input: {
|
|
27
|
-
multiSelect?: boolean
|
|
28
|
-
maxSelections?: number
|
|
29
|
-
title?: string
|
|
30
|
-
subtitle?: string
|
|
31
|
-
shopId?: string
|
|
32
|
-
categories?: string[]
|
|
33
|
-
}) => {
|
|
34
|
-
const result = await invokeIntent({
|
|
35
|
-
provider: 'shop',
|
|
36
|
-
intentType: 'select:shopify/Product',
|
|
37
|
-
input,
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
if (result.resultCode === 'SUCCESS') {
|
|
41
|
-
return result.output as {type: 'product'; ids: string[]}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return undefined
|
|
45
|
-
},
|
|
46
|
-
[invokeIntent]
|
|
47
|
-
)
|
|
48
|
-
}
|