@ahnseungchan/webviewkit 1.0.6 → 1.0.7

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.
@@ -13,21 +13,31 @@ export const useStackRouter = () => {
13
13
  return context;
14
14
  };
15
15
  const StackRouter = ({ maxWidth = "600px", Activities = [], initialActivity, ActivitysLayout, }) => {
16
- const [currentPath, setCurrentPath] = useState(history.getCurrentState().path);
16
+ // 실제 URL과 동기화된 초기 경로 설정
17
+ const getInitialPath = () => {
18
+ const currentUrlPath = window.location.pathname;
19
+ // Activities에서 현재 URL에 해당하는 액티비티가 있는지 확인
20
+ const matchingActivity = Activities.find((a) => a.path === currentUrlPath);
21
+ return matchingActivity ? currentUrlPath : initialActivity.path;
22
+ };
23
+ const [currentPath, setCurrentPath] = useState(getInitialPath());
17
24
  const [currentState, setCurrentState] = useState(history.getCurrentState());
18
25
  const [isTransitioning, setIsTransitioning] = useState(false);
19
26
  const [direction, setDirection] = useState(Direction.FORWARD);
20
27
  const [visiblePages, setVisiblePages] = useState([]);
21
- // initialize visible pages
28
+ // 초기 페이지 설정 - 실제 URL 기반으로 동기화
22
29
  useEffect(() => {
30
+ const initialPath = getInitialPath();
31
+ const initialActivityForPath = Activities.find((a) => a.path === initialPath) || initialActivity;
23
32
  setVisiblePages([
24
33
  {
25
- path: initialActivity.path,
26
- element: initialActivity.element,
34
+ path: initialPath,
35
+ element: initialActivityForPath.element,
27
36
  isEntering: true,
28
37
  },
29
38
  ]);
30
- }, [initialActivity]);
39
+ setCurrentPath(initialPath);
40
+ }, [initialActivity, Activities]);
31
41
  // listen to history changes
32
42
  useEffect(() => {
33
43
  const removeListener = history.addListener((state) => {
@@ -12,6 +12,8 @@ export interface StackRouterProviderProps {
12
12
  ActivitysLayout?: React.ComponentType<{
13
13
  children: React.ReactNode;
14
14
  }>;
15
+ onNavigate?: (path: string) => void;
16
+ currentPath?: string;
15
17
  }
16
18
  export interface VisiblePage {
17
19
  path: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ahnseungchan/webviewkit",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "Core WebView functionality for stack-based navigation",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",