@shopify/shop-minis-react 0.0.0-snapshot.20251219164319 → 0.0.0-snapshot.20251224113248
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 +8 -15
- package/dist/components/navigation/minis-router.js.map +1 -1
- package/dist/hooks/intents/useInvokeIntentAction.js +10 -0
- package/dist/hooks/intents/useInvokeIntentAction.js.map +1 -0
- package/dist/hooks/intents/useQueryIntents.js +10 -0
- package/dist/hooks/intents/useQueryIntents.js.map +1 -0
- package/dist/hooks/intents/useSelectProduct.js +21 -0
- package/dist/hooks/intents/useSelectProduct.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 +139 -132
- package/dist/index.js.map +1 -1
- package/dist/mocks.js +49 -15
- package/dist/mocks.js.map +1 -1
- package/dist/shop-minis-platform/src/actions/scopes.js +36 -0
- package/dist/shop-minis-platform/src/actions/scopes.js.map +1 -0
- package/package.json +2 -2
- package/src/components/navigation/minis-router.tsx +1 -9
- package/src/hooks/index.ts +3 -1
- package/src/hooks/intents/index.ts +38 -0
- package/src/hooks/intents/useInvokeIntentAction.ts +12 -0
- package/src/hooks/intents/useQueryIntents.ts +25 -0
- package/src/hooks/intents/useSelectProduct.ts +48 -0
- package/src/hooks/navigation/useNavigateWithTransition.test.ts +3 -17
- package/src/hooks/navigation/useNavigateWithTransition.ts +4 -9
- package/src/mocks.ts +35 -1
- package/dist/hooks/events/useOnNavigateBack.js +0 -14
- package/dist/hooks/events/useOnNavigateBack.js.map +0 -1
- package/dist/internal/navigation-manager.js +0 -28
- package/dist/internal/navigation-manager.js.map +0 -1
- package/src/hooks/events/useOnNavigateBack.ts +0 -16
- package/src/internal/navigation-manager.tsx +0 -41
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { useEffect as e } from "react";
|
|
2
|
-
import { useLocation as a } 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 { useOnNavigateBack as r } from "../hooks/events/useOnNavigateBack.js";
|
|
4
|
-
import { useNavigateWithTransition as s } from "../hooks/navigation/useNavigateWithTransition.js";
|
|
5
|
-
import { useShopActions as h } from "./useShopActions.js";
|
|
6
|
-
function u() {
|
|
7
|
-
const t = a(), i = s(), { reportNavigationState: o } = h();
|
|
8
|
-
return e(() => {
|
|
9
|
-
const n = {
|
|
10
|
-
location: {
|
|
11
|
-
pathname: t.pathname,
|
|
12
|
-
search: t.search,
|
|
13
|
-
hash: t.hash,
|
|
14
|
-
key: t.key,
|
|
15
|
-
state: t.state
|
|
16
|
-
},
|
|
17
|
-
historyLength: typeof window > "u" ? 0 : window.history.length,
|
|
18
|
-
historyIndex: typeof window > "u" || !window.history.state?.idx ? null : window.history.state.idx
|
|
19
|
-
};
|
|
20
|
-
o(n);
|
|
21
|
-
}, [t, o]), r(() => {
|
|
22
|
-
i(-1);
|
|
23
|
-
}), null;
|
|
24
|
-
}
|
|
25
|
-
export {
|
|
26
|
-
u as NavigationManager
|
|
27
|
-
};
|
|
28
|
-
//# sourceMappingURL=navigation-manager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"navigation-manager.js","sources":["../../src/internal/navigation-manager.tsx"],"sourcesContent":["import {useEffect} from 'react'\n\nimport {useLocation} from 'react-router'\n\nimport {useOnNavigateBack} from '../hooks/events/useOnNavigateBack'\nimport {useNavigateWithTransition} from '../hooks/navigation/useNavigateWithTransition'\n\nimport {useShopActions} from './useShopActions'\n\nexport function NavigationManager() {\n const location = useLocation()\n const navigate = useNavigateWithTransition()\n const {reportNavigationState} = useShopActions()\n\n // Report navigation state on location changes\n useEffect(() => {\n const navigationState = {\n location: {\n pathname: location.pathname,\n search: location.search,\n hash: location.hash,\n key: location.key,\n state: location.state,\n },\n historyLength: typeof window === 'undefined' ? 0 : window.history.length,\n historyIndex:\n typeof window === 'undefined' || !window.history.state?.idx\n ? null\n : window.history.state.idx,\n }\n\n reportNavigationState(navigationState)\n }, [location, reportNavigationState])\n\n // Handle native back button press\n useOnNavigateBack(() => {\n navigate(-1)\n })\n\n return null\n}\n"],"names":["NavigationManager","location","useLocation","navigate","useNavigateWithTransition","reportNavigationState","useShopActions","useEffect","navigationState","useOnNavigateBack"],"mappings":";;;;;AASO,SAASA,IAAoB;AAClC,QAAMC,IAAWC,EAAY,GACvBC,IAAWC,EAA0B,GACrC,EAAC,uBAAAC,EAAqB,IAAIC,EAAe;AAG/C,SAAAC,EAAU,MAAM;AACd,UAAMC,IAAkB;AAAA,MACtB,UAAU;AAAA,QACR,UAAUP,EAAS;AAAA,QACnB,QAAQA,EAAS;AAAA,QACjB,MAAMA,EAAS;AAAA,QACf,KAAKA,EAAS;AAAA,QACd,OAAOA,EAAS;AAAA,MAClB;AAAA,MACA,eAAe,OAAO,SAAW,MAAc,IAAI,OAAO,QAAQ;AAAA,MAClE,cACE,OAAO,SAAW,OAAe,CAAC,OAAO,QAAQ,OAAO,MACpD,OACA,OAAO,QAAQ,MAAM;AAAA,IAC7B;AAEA,IAAAI,EAAsBG,CAAe;AAAA,EAAA,GACpC,CAACP,GAAUI,CAAqB,CAAC,GAGpCI,EAAkB,MAAM;AACtB,IAAAN,EAAS,EAAE;AAAA,EAAA,CACZ,GAEM;AACT;"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import {useEffect, useRef} from 'react'
|
|
2
|
-
|
|
3
|
-
export function useOnNavigateBack(callback: () => void) {
|
|
4
|
-
// Using a ref allows the callback to be updated without triggering a re-render
|
|
5
|
-
// This makes the hook nicer to use because developers don't need useCallback
|
|
6
|
-
const callbackRef = useRef(callback)
|
|
7
|
-
callbackRef.current = callback
|
|
8
|
-
|
|
9
|
-
useEffect(() => {
|
|
10
|
-
const listenerId = window.minisEvents.on('NAVIGATE_BACK', () => {
|
|
11
|
-
callbackRef.current()
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
return () => window.minisEvents.off(listenerId)
|
|
15
|
-
}, [])
|
|
16
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import {useEffect} from 'react'
|
|
2
|
-
|
|
3
|
-
import {useLocation} from 'react-router'
|
|
4
|
-
|
|
5
|
-
import {useOnNavigateBack} from '../hooks/events/useOnNavigateBack'
|
|
6
|
-
import {useNavigateWithTransition} from '../hooks/navigation/useNavigateWithTransition'
|
|
7
|
-
|
|
8
|
-
import {useShopActions} from './useShopActions'
|
|
9
|
-
|
|
10
|
-
export function NavigationManager() {
|
|
11
|
-
const location = useLocation()
|
|
12
|
-
const navigate = useNavigateWithTransition()
|
|
13
|
-
const {reportNavigationState} = useShopActions()
|
|
14
|
-
|
|
15
|
-
// Report navigation state on location changes
|
|
16
|
-
useEffect(() => {
|
|
17
|
-
const navigationState = {
|
|
18
|
-
location: {
|
|
19
|
-
pathname: location.pathname,
|
|
20
|
-
search: location.search,
|
|
21
|
-
hash: location.hash,
|
|
22
|
-
key: location.key,
|
|
23
|
-
state: location.state,
|
|
24
|
-
},
|
|
25
|
-
historyLength: typeof window === 'undefined' ? 0 : window.history.length,
|
|
26
|
-
historyIndex:
|
|
27
|
-
typeof window === 'undefined' || !window.history.state?.idx
|
|
28
|
-
? null
|
|
29
|
-
: window.history.state.idx,
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
reportNavigationState(navigationState)
|
|
33
|
-
}, [location, reportNavigationState])
|
|
34
|
-
|
|
35
|
-
// Handle native back button press
|
|
36
|
-
useOnNavigateBack(() => {
|
|
37
|
-
navigate(-1)
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
return null
|
|
41
|
-
}
|