@ahnseungchan/webviewkit 1.0.8 → 1.2.0
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/README.md +57 -112
- package/dist/constants.d.ts +3 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +5 -0
- package/dist/{packages/core/src/history.d.ts → history.d.ts} +3 -2
- package/dist/history.d.ts.map +1 -0
- package/dist/history.js +91 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/stack-dev/stack-dev-roadmap.d.ts +15 -0
- package/dist/stack-dev/stack-dev-roadmap.d.ts.map +1 -0
- package/dist/stack-dev/stack-dev-roadmap.js +66 -0
- package/dist/stack-router/_components/back-router.d.ts +3 -0
- package/dist/stack-router/_components/back-router.d.ts.map +1 -0
- package/dist/stack-router/_components/back-router.js +39 -0
- package/dist/stack-router/_components/header.d.ts +3 -0
- package/dist/stack-router/_components/header.d.ts.map +1 -0
- package/dist/stack-router/_components/header.js +42 -0
- package/dist/{packages/core/src/stack-router → stack-router}/stack-router-provider.d.ts +4 -5
- package/dist/stack-router/stack-router-provider.d.ts.map +1 -0
- package/dist/stack-router/stack-router-provider.js +227 -0
- package/dist/{packages/core/src/type.d.ts → type.d.ts} +3 -5
- package/dist/type.d.ts.map +1 -0
- package/dist/type.js +14 -0
- package/package.json +22 -26
- package/dist/packages/core/src/__tests__/back-router.test.d.ts +0 -0
- package/dist/packages/core/src/__tests__/back-router.test.js +0 -62
- package/dist/packages/core/src/__tests__/history.test.d.ts +0 -1
- package/dist/packages/core/src/__tests__/history.test.js +0 -114
- package/dist/packages/core/src/__tests__/stack-router.test.d.ts +0 -0
- package/dist/packages/core/src/__tests__/stack-router.test.js +0 -185
- package/dist/packages/core/src/history.js +0 -82
- package/dist/packages/core/src/index.d.ts +0 -5
- package/dist/packages/core/src/index.js +0 -6
- package/dist/packages/core/src/stack-router/__tests__/stack-router.test.d.ts +0 -0
- package/dist/packages/core/src/stack-router/__tests__/stack-router.test.js +0 -153
- package/dist/packages/core/src/stack-router/_components/back-router.d.ts +0 -2
- package/dist/packages/core/src/stack-router/_components/back-router.js +0 -34
- package/dist/packages/core/src/stack-router/_components/header.d.ts +0 -2
- package/dist/packages/core/src/stack-router/_components/header.js +0 -36
- package/dist/packages/core/src/stack-router/stack-router-provider.js +0 -211
- package/dist/packages/core/src/type.js +0 -11
package/README.md
CHANGED
|
@@ -1,149 +1,94 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @ahnseungchan/webviewkit
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
React **WebView·하이브리드 앱**용 스택(push/back) 네비게이션 라이브러리입니다.
|
|
4
|
+
`history.pushState`와 CSS 슬라이드 전환으로 네이티브 앱에 가까운 화면 이동을 구현합니다.
|
|
4
5
|
|
|
5
|
-
##
|
|
6
|
+
## 설치
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
- 🔧 **TypeScript Support**: Full TypeScript support with comprehensive type definitions
|
|
11
|
-
- 🎯 **Flexible**: Customizable animations, layouts, and navigation behavior
|
|
8
|
+
```bash
|
|
9
|
+
npm install @ahnseungchan/webviewkit
|
|
10
|
+
```
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
**Peer dependencies** (프로젝트에 직접 설치):
|
|
14
13
|
|
|
15
14
|
```bash
|
|
16
|
-
npm install @
|
|
17
|
-
# or
|
|
18
|
-
yarn add @webviewkit
|
|
19
|
-
# or
|
|
20
|
-
pnpm add @webviewkit
|
|
15
|
+
npm install react react-dom @emotion/react @emotion/styled
|
|
21
16
|
```
|
|
22
17
|
|
|
23
18
|
## Quick Start
|
|
24
19
|
|
|
25
20
|
```tsx
|
|
26
|
-
import
|
|
27
|
-
|
|
21
|
+
import { StackRouterProvider, useStackRouter } from "@ahnseungchan/webviewkit";
|
|
22
|
+
|
|
23
|
+
function Home() {
|
|
24
|
+
const { push } = useStackRouter();
|
|
25
|
+
return <button onClick={() => push("/about")}>About</button>;
|
|
26
|
+
}
|
|
28
27
|
|
|
29
|
-
function
|
|
28
|
+
function About() {
|
|
29
|
+
const { back } = useStackRouter();
|
|
30
|
+
return <button onClick={back}>Back</button>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default function App() {
|
|
30
34
|
return (
|
|
31
35
|
<StackRouterProvider
|
|
32
36
|
maxWidth="600px"
|
|
37
|
+
enableDevTools
|
|
33
38
|
Activities={[
|
|
34
|
-
{
|
|
35
|
-
|
|
36
|
-
element: <HomePage />,
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
path: "/about",
|
|
40
|
-
element: <AboutPage />,
|
|
41
|
-
},
|
|
39
|
+
{ path: "/", element: <Home /> },
|
|
40
|
+
{ path: "/about", element: <About /> },
|
|
42
41
|
]}
|
|
43
|
-
initialActivity={{ path: "/", element: <
|
|
42
|
+
initialActivity={{ path: "/", element: <Home /> }}
|
|
44
43
|
/>
|
|
45
44
|
);
|
|
46
45
|
}
|
|
47
46
|
```
|
|
48
47
|
|
|
49
|
-
##
|
|
48
|
+
## Dev Stack Roadmap (1.2.0)
|
|
50
49
|
|
|
51
|
-
|
|
50
|
+
개발 모드에서 스택이 몇 장 쌓였는지 **눈으로** 확인할 수 있습니다.
|
|
52
51
|
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
| 옵션 | 동작 |
|
|
53
|
+
|------|------|
|
|
54
|
+
| `enableDevTools={true}` | 우하단 로드맵 항상 표시 |
|
|
55
|
+
| `enableDevTools={false}` | 숨김 |
|
|
56
|
+
| 생략 | `development`에서만 표시, production에서는 숨김 |
|
|
55
57
|
|
|
56
|
-
|
|
57
|
-
const { push, back } = useStackRouter();
|
|
58
|
+
로드맵에 표시되는 정보:
|
|
58
59
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
<button onClick={() => push("/about")}>Go to About</button>
|
|
63
|
-
<button onClick={back}>Back</button>
|
|
64
|
-
</div>
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
### History Management
|
|
60
|
+
- **stack × N** — 현재 스택 깊이
|
|
61
|
+
- **점→선** — 쌓인 페이지 순서
|
|
62
|
+
- **경로 목록** — 각 `path`, 최상단에 `← top`
|
|
70
63
|
|
|
71
64
|
```tsx
|
|
72
|
-
import {
|
|
73
|
-
|
|
74
|
-
// Navigate to a new page
|
|
75
|
-
await history.push("/new-page", { data: "some data" });
|
|
76
|
-
|
|
77
|
-
// Replace current page
|
|
78
|
-
await history.replace("/replacement-page", { data: "replacement data" });
|
|
79
|
-
|
|
80
|
-
// Go back
|
|
81
|
-
await history.back();
|
|
65
|
+
import { StackDevRoadmap } from "@ahnseungchan/webviewkit";
|
|
82
66
|
|
|
83
|
-
//
|
|
84
|
-
|
|
67
|
+
// StackRouterProvider 없이 디버그 UI만 쓸 때
|
|
68
|
+
<StackDevRoadmap
|
|
69
|
+
pages={[{ path: "/" }, { path: "/detail" }]}
|
|
70
|
+
currentPath="/detail"
|
|
71
|
+
/>
|
|
85
72
|
```
|
|
86
73
|
|
|
87
|
-
## API
|
|
74
|
+
## API
|
|
88
75
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
|
92
|
-
|
|
|
93
|
-
| `
|
|
94
|
-
| `
|
|
95
|
-
| `
|
|
96
|
-
| `
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
Returns an object with navigation methods:
|
|
101
|
-
|
|
102
|
-
- `currentPath`: Current active path
|
|
103
|
-
- `currentState`: Current history state
|
|
104
|
-
- `push(path, data?)`: Navigate to a new page
|
|
105
|
-
- `replace(path, data?)`: Replace current page
|
|
106
|
-
- `back()`: Go back to previous page
|
|
107
|
-
- `forward()`: Go forward to next page
|
|
108
|
-
|
|
109
|
-
### History API
|
|
110
|
-
|
|
111
|
-
- `history.push(path, data?)`: Add new history entry
|
|
112
|
-
- `history.replace(path, data?)`: Replace current history entry
|
|
113
|
-
- `history.back()`: Go back to previous entry
|
|
114
|
-
- `history.forward()`: Go forward to next entry
|
|
115
|
-
- `history.go(delta)`: Go to specific history entry
|
|
116
|
-
- `history.getCurrentState()`: Get current history state
|
|
117
|
-
- `history.addListener(listener)`: Add history change listener
|
|
118
|
-
|
|
119
|
-
## Examples
|
|
120
|
-
|
|
121
|
-
See the `packages/browser` directory for complete examples.
|
|
122
|
-
|
|
123
|
-
## Development
|
|
124
|
-
|
|
125
|
-
```bash
|
|
126
|
-
# Install dependencies
|
|
127
|
-
pnpm install
|
|
128
|
-
|
|
129
|
-
# Build all packages
|
|
130
|
-
pnpm build
|
|
131
|
-
|
|
132
|
-
# Run tests
|
|
133
|
-
pnpm test
|
|
134
|
-
|
|
135
|
-
# Run linting
|
|
136
|
-
pnpm lint
|
|
137
|
-
```
|
|
76
|
+
| Export | 설명 |
|
|
77
|
+
|--------|------|
|
|
78
|
+
| `StackRouterProvider` | 스택 라우터 루트 |
|
|
79
|
+
| `useStackRouter` | `push`, `back`, `replace`, `forward`, `visiblePages` |
|
|
80
|
+
| `history` | `pushState` / `popstate` 래퍼 (SSR-safe) |
|
|
81
|
+
| `BackRouter` | 뒤로가기 버튼 |
|
|
82
|
+
| `StackHeader` | 경로 표시 헤더 |
|
|
83
|
+
| `StackDevRoadmap` | 스택 로드맵 오버레이 |
|
|
84
|
+
| `STACK_TRANSITION_MS` | 전환 ms 상수 (`500`) |
|
|
85
|
+
| `Direction`, `HistoryAction` | 타입·enum |
|
|
138
86
|
|
|
139
|
-
##
|
|
87
|
+
## 골디 앱 연동 참고
|
|
140
88
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
|
|
144
|
-
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
145
|
-
5. Open a Pull Request
|
|
89
|
+
B2C WebView에서는 앱 브릿지(`stackRouterBridge`)와 함께 쓰는 경우가 많습니다.
|
|
90
|
+
이 패키지는 **웹 단독 스택 UI**이며, RN 브릿지와는 별도 레이어입니다.
|
|
146
91
|
|
|
147
92
|
## License
|
|
148
93
|
|
|
149
|
-
|
|
94
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,eAAO,MAAM,mBAAmB,MAAM,CAAC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { HistoryListener, HistoryState } from "./type";
|
|
2
2
|
export declare const history: {
|
|
3
|
-
push: (path: string, data?:
|
|
4
|
-
replace: (path: string, data
|
|
3
|
+
push: (path: string, data?: unknown) => Promise<void>;
|
|
4
|
+
replace: (path: string, data?: unknown) => Promise<void>;
|
|
5
5
|
back: () => Promise<void>;
|
|
6
6
|
forward: () => Promise<void>;
|
|
7
7
|
go: (delta: number) => Promise<void>;
|
|
8
8
|
getCurrentState: () => HistoryState;
|
|
9
9
|
addListener: (listener: HistoryListener) => () => boolean;
|
|
10
10
|
};
|
|
11
|
+
//# sourceMappingURL=history.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../src/history.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,eAAe,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAqBtE,eAAO,MAAM,OAAO;iBACC,MAAM,SAAS,OAAO;oBAYnB,MAAM,SAAS,OAAO;;;gBAwC1B,MAAM;2BAUH,YAAY;4BAWT,eAAe;CAIxC,CAAC"}
|
package/dist/history.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.history = void 0;
|
|
4
|
+
const type_1 = require("./type");
|
|
5
|
+
const constants_1 = require("./constants");
|
|
6
|
+
const isBrowser = typeof window !== "undefined";
|
|
7
|
+
const listeners = new Set();
|
|
8
|
+
const notifyListeners = (state) => {
|
|
9
|
+
listeners.forEach((listener) => listener(state));
|
|
10
|
+
};
|
|
11
|
+
if (isBrowser) {
|
|
12
|
+
window.addEventListener("popstate", (event) => {
|
|
13
|
+
const state = event.state;
|
|
14
|
+
notifyListeners(state);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
const delay = () => new Promise((resolve) => setTimeout(resolve, constants_1.STACK_TRANSITION_MS * 0.6));
|
|
18
|
+
exports.history = {
|
|
19
|
+
push: async (path, data) => {
|
|
20
|
+
if (!isBrowser)
|
|
21
|
+
return;
|
|
22
|
+
const state = {
|
|
23
|
+
path,
|
|
24
|
+
data,
|
|
25
|
+
action: type_1.HistoryAction.PUSH,
|
|
26
|
+
};
|
|
27
|
+
window.history.pushState(state, "", path);
|
|
28
|
+
await delay();
|
|
29
|
+
notifyListeners(state);
|
|
30
|
+
},
|
|
31
|
+
replace: async (path, data) => {
|
|
32
|
+
if (!isBrowser)
|
|
33
|
+
return;
|
|
34
|
+
const state = {
|
|
35
|
+
path,
|
|
36
|
+
data,
|
|
37
|
+
action: type_1.HistoryAction.REPLACE,
|
|
38
|
+
};
|
|
39
|
+
window.history.replaceState(state, "", path);
|
|
40
|
+
await delay();
|
|
41
|
+
notifyListeners(state);
|
|
42
|
+
},
|
|
43
|
+
back: async () => {
|
|
44
|
+
if (!isBrowser)
|
|
45
|
+
return;
|
|
46
|
+
window.history.back();
|
|
47
|
+
await new Promise((resolve) => {
|
|
48
|
+
const onPop = () => {
|
|
49
|
+
window.removeEventListener("popstate", onPop);
|
|
50
|
+
resolve();
|
|
51
|
+
};
|
|
52
|
+
window.addEventListener("popstate", onPop);
|
|
53
|
+
});
|
|
54
|
+
notifyListeners({
|
|
55
|
+
path: window.location.pathname,
|
|
56
|
+
action: type_1.HistoryAction.POP,
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
forward: async () => {
|
|
60
|
+
if (!isBrowser)
|
|
61
|
+
return;
|
|
62
|
+
window.history.forward();
|
|
63
|
+
await delay();
|
|
64
|
+
notifyListeners({
|
|
65
|
+
path: window.location.pathname,
|
|
66
|
+
action: type_1.HistoryAction.PUSH,
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
go: async (delta) => {
|
|
70
|
+
if (!isBrowser)
|
|
71
|
+
return;
|
|
72
|
+
window.history.go(delta);
|
|
73
|
+
await delay();
|
|
74
|
+
notifyListeners({
|
|
75
|
+
path: window.location.pathname,
|
|
76
|
+
action: type_1.HistoryAction.PUSH,
|
|
77
|
+
});
|
|
78
|
+
},
|
|
79
|
+
getCurrentState: () => {
|
|
80
|
+
if (!isBrowser) {
|
|
81
|
+
return { path: "/" };
|
|
82
|
+
}
|
|
83
|
+
return (window.history.state || {
|
|
84
|
+
path: window.location.pathname,
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
|
+
addListener: (listener) => {
|
|
88
|
+
listeners.add(listener);
|
|
89
|
+
return () => listeners.delete(listener);
|
|
90
|
+
},
|
|
91
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { STACK_TRANSITION_MS } from "./constants";
|
|
2
|
+
export { Direction, HistoryAction } from "./type";
|
|
3
|
+
export type { StackRouterProviderProps, VisiblePage, HistoryState, HistoryListener, DirectionType, } from "./type";
|
|
4
|
+
export { history } from "./history";
|
|
5
|
+
export { default as StackRouterProvider, useStackRouter, } from "./stack-router/stack-router-provider";
|
|
6
|
+
export { default as BackRouter } from "./stack-router/_components/back-router";
|
|
7
|
+
export { default as StackHeader } from "./stack-router/_components/header";
|
|
8
|
+
export { StackDevRoadmap } from "./stack-dev/stack-dev-roadmap";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAClD,YAAY,EACV,wBAAwB,EACxB,WAAW,EACX,YAAY,EACZ,eAAe,EACf,aAAa,GACd,MAAM,QAAQ,CAAC;AAEhB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,OAAO,IAAI,mBAAmB,EAC9B,cAAc,GACf,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,wCAAwC,CAAC;AAC/E,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.StackDevRoadmap = exports.StackHeader = exports.BackRouter = exports.useStackRouter = exports.StackRouterProvider = exports.history = exports.HistoryAction = exports.Direction = exports.STACK_TRANSITION_MS = void 0;
|
|
7
|
+
var constants_1 = require("./constants");
|
|
8
|
+
Object.defineProperty(exports, "STACK_TRANSITION_MS", { enumerable: true, get: function () { return constants_1.STACK_TRANSITION_MS; } });
|
|
9
|
+
var type_1 = require("./type");
|
|
10
|
+
Object.defineProperty(exports, "Direction", { enumerable: true, get: function () { return type_1.Direction; } });
|
|
11
|
+
Object.defineProperty(exports, "HistoryAction", { enumerable: true, get: function () { return type_1.HistoryAction; } });
|
|
12
|
+
var history_1 = require("./history");
|
|
13
|
+
Object.defineProperty(exports, "history", { enumerable: true, get: function () { return history_1.history; } });
|
|
14
|
+
var stack_router_provider_1 = require("./stack-router/stack-router-provider");
|
|
15
|
+
Object.defineProperty(exports, "StackRouterProvider", { enumerable: true, get: function () { return __importDefault(stack_router_provider_1).default; } });
|
|
16
|
+
Object.defineProperty(exports, "useStackRouter", { enumerable: true, get: function () { return stack_router_provider_1.useStackRouter; } });
|
|
17
|
+
var back_router_1 = require("./stack-router/_components/back-router");
|
|
18
|
+
Object.defineProperty(exports, "BackRouter", { enumerable: true, get: function () { return __importDefault(back_router_1).default; } });
|
|
19
|
+
var header_1 = require("./stack-router/_components/header");
|
|
20
|
+
Object.defineProperty(exports, "StackHeader", { enumerable: true, get: function () { return __importDefault(header_1).default; } });
|
|
21
|
+
var stack_dev_roadmap_1 = require("./stack-dev/stack-dev-roadmap");
|
|
22
|
+
Object.defineProperty(exports, "StackDevRoadmap", { enumerable: true, get: function () { return stack_dev_roadmap_1.StackDevRoadmap; } });
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface StackDevRoadmapProps {
|
|
2
|
+
/** 스택에 쌓인 페이지 경로 (아래 → 위 순) */
|
|
3
|
+
pages: {
|
|
4
|
+
path: string;
|
|
5
|
+
}[];
|
|
6
|
+
currentPath: string;
|
|
7
|
+
/** false면 렌더하지 않음 */
|
|
8
|
+
visible?: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* 개발 환경에서 스택 깊이·경로를 눈으로 확인하는 로드맵 오버레이.
|
|
12
|
+
* StackRouterProvider `enableDevTools` 와 함께 사용합니다.
|
|
13
|
+
*/
|
|
14
|
+
export declare function StackDevRoadmap({ pages, currentPath, visible, }: StackDevRoadmapProps): import("@emotion/react/jsx-runtime").JSX.Element | null;
|
|
15
|
+
//# sourceMappingURL=stack-dev-roadmap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stack-dev-roadmap.d.ts","sourceRoot":"","sources":["../../src/stack-dev/stack-dev-roadmap.tsx"],"names":[],"mappings":"AAEA,MAAM,WAAW,oBAAoB;IACnC,+BAA+B;IAC/B,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,qBAAqB;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,EAC9B,KAAK,EACL,WAAW,EACX,OAAc,GACf,EAAE,oBAAoB,2DAkGtB"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.StackDevRoadmap = StackDevRoadmap;
|
|
7
|
+
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
/**
|
|
10
|
+
* 개발 환경에서 스택 깊이·경로를 눈으로 확인하는 로드맵 오버레이.
|
|
11
|
+
* StackRouterProvider `enableDevTools` 와 함께 사용합니다.
|
|
12
|
+
*/
|
|
13
|
+
function StackDevRoadmap({ pages, currentPath, visible = true, }) {
|
|
14
|
+
if (!visible || pages.length === 0)
|
|
15
|
+
return null;
|
|
16
|
+
const depth = pages.length;
|
|
17
|
+
return ((0, jsx_runtime_1.jsxs)("div", { role: "status", "aria-live": "polite", "aria-label": `WebViewKit stack depth ${depth}`, style: {
|
|
18
|
+
position: "fixed",
|
|
19
|
+
bottom: 12,
|
|
20
|
+
right: 12,
|
|
21
|
+
zIndex: 2147483646,
|
|
22
|
+
minWidth: 200,
|
|
23
|
+
maxWidth: 320,
|
|
24
|
+
padding: "10px 12px",
|
|
25
|
+
borderRadius: 10,
|
|
26
|
+
background: "rgba(7, 11, 18, 0.92)",
|
|
27
|
+
border: "1px solid rgba(0, 232, 184, 0.35)",
|
|
28
|
+
color: "#e8eef4",
|
|
29
|
+
fontFamily: 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace',
|
|
30
|
+
fontSize: 11,
|
|
31
|
+
lineHeight: 1.45,
|
|
32
|
+
boxShadow: "0 8px 24px rgba(0,0,0,0.35)",
|
|
33
|
+
pointerEvents: "none",
|
|
34
|
+
}, children: [(0, jsx_runtime_1.jsxs)("div", { style: { display: "flex", justifyContent: "space-between", gap: 8 }, children: [(0, jsx_runtime_1.jsx)("span", { style: { color: "#00e8b8", fontWeight: 700 }, children: "WebViewKit" }), (0, jsx_runtime_1.jsxs)("span", { style: { color: "#94a3b8" }, children: ["stack \u00D7 ", depth] })] }), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
35
|
+
display: "flex",
|
|
36
|
+
alignItems: "center",
|
|
37
|
+
gap: 0,
|
|
38
|
+
marginTop: 10,
|
|
39
|
+
padding: "4px 0",
|
|
40
|
+
}, children: pages.map((page, index) => {
|
|
41
|
+
const isCurrent = page.path === currentPath;
|
|
42
|
+
const isLast = index === pages.length - 1;
|
|
43
|
+
return ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [index > 0 && ((0, jsx_runtime_1.jsx)("span", { style: {
|
|
44
|
+
width: 14,
|
|
45
|
+
height: 2,
|
|
46
|
+
background: isLast
|
|
47
|
+
? "linear-gradient(90deg,#334155,#00e8b8)"
|
|
48
|
+
: "#334155",
|
|
49
|
+
flexShrink: 0,
|
|
50
|
+
} })), (0, jsx_runtime_1.jsx)("span", { title: page.path, style: {
|
|
51
|
+
width: isCurrent ? 12 : 8,
|
|
52
|
+
height: isCurrent ? 12 : 8,
|
|
53
|
+
borderRadius: "50%",
|
|
54
|
+
flexShrink: 0,
|
|
55
|
+
background: isCurrent ? "#00e8b8" : "#475569",
|
|
56
|
+
boxShadow: isCurrent ? "0 0 10px rgba(0,232,184,0.85)" : "none",
|
|
57
|
+
transition: "all 0.2s ease",
|
|
58
|
+
} })] }, `${page.path}-${index}`));
|
|
59
|
+
}) }), (0, jsx_runtime_1.jsx)("ol", { style: { margin: "8px 0 0", paddingLeft: 18, color: "#cbd5e1" }, children: pages.map((page, index) => {
|
|
60
|
+
const isCurrent = index === pages.length - 1;
|
|
61
|
+
return ((0, jsx_runtime_1.jsxs)("li", { style: {
|
|
62
|
+
fontWeight: isCurrent ? 600 : 400,
|
|
63
|
+
color: isCurrent ? "#00e8b8" : "#94a3b8",
|
|
64
|
+
}, children: [page.path, isCurrent ? " ← top" : ""] }, `${page.path}-${index}`));
|
|
65
|
+
}) })] }));
|
|
66
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"back-router.d.ts","sourceRoot":"","sources":["../../../src/stack-router/_components/back-router.tsx"],"names":[],"mappings":"AAIA,QAAA,MAAM,UAAU,wDAOf,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
7
|
+
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
8
|
+
const stack_router_provider_1 = require("../stack-router-provider");
|
|
9
|
+
const BackRouter = () => {
|
|
10
|
+
const { back } = (0, stack_router_provider_1.useStackRouter)();
|
|
11
|
+
return ((0, jsx_runtime_1.jsx)(BackButton, { onClick: back, children: (0, jsx_runtime_1.jsx)(BackIcon, {}) }));
|
|
12
|
+
};
|
|
13
|
+
exports.default = BackRouter;
|
|
14
|
+
/**
|
|
15
|
+
styles
|
|
16
|
+
*/
|
|
17
|
+
const BackButton = styled_1.default.button `
|
|
18
|
+
display: flex;
|
|
19
|
+
align-items: center;
|
|
20
|
+
justify-content: center;
|
|
21
|
+
width: 40px;
|
|
22
|
+
height: 40px;
|
|
23
|
+
border: none;
|
|
24
|
+
background: none;
|
|
25
|
+
cursor: pointer;
|
|
26
|
+
padding: 8px;
|
|
27
|
+
border-radius: 50%;
|
|
28
|
+
transition: all 0.2s;
|
|
29
|
+
color: #000000;
|
|
30
|
+
|
|
31
|
+
&:hover {
|
|
32
|
+
color: #666666;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
&:active {
|
|
36
|
+
color: #999999;
|
|
37
|
+
}
|
|
38
|
+
`;
|
|
39
|
+
const BackIcon = () => ((0, jsx_runtime_1.jsx)("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: (0, jsx_runtime_1.jsx)("path", { d: "M12 20L4 12L12 4", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header.d.ts","sourceRoot":"","sources":["../../../src/stack-router/_components/header.tsx"],"names":[],"mappings":"AAMA,QAAA,MAAM,MAAM,wDAmBX,CAAC;AAsBF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
9
|
+
const back_router_1 = __importDefault(require("./back-router"));
|
|
10
|
+
const stack_router_provider_1 = require("../stack-router-provider");
|
|
11
|
+
const constants_1 = require("../../constants");
|
|
12
|
+
const Header = () => {
|
|
13
|
+
const { currentPath, visiblePages } = (0, stack_router_provider_1.useStackRouter)();
|
|
14
|
+
const [displayPath, setDisplayPath] = (0, react_1.useState)(currentPath);
|
|
15
|
+
const [isVisible, setIsVisible] = (0, react_1.useState)(visiblePages.length > 1);
|
|
16
|
+
(0, react_1.useEffect)(() => {
|
|
17
|
+
const timer = setTimeout(() => {
|
|
18
|
+
setDisplayPath(currentPath);
|
|
19
|
+
setIsVisible(visiblePages.length > 1);
|
|
20
|
+
}, constants_1.STACK_TRANSITION_MS);
|
|
21
|
+
return () => clearTimeout(timer);
|
|
22
|
+
}, [currentPath, visiblePages]);
|
|
23
|
+
return ((0, jsx_runtime_1.jsxs)(StyledHeader, { children: [isVisible && (0, jsx_runtime_1.jsx)(back_router_1.default, {}), (0, jsx_runtime_1.jsx)(StyledTitle, { children: displayPath })] }));
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
styles
|
|
27
|
+
*/
|
|
28
|
+
const StyledHeader = styled_1.default.header `
|
|
29
|
+
width: 100%;
|
|
30
|
+
height: 64px;
|
|
31
|
+
background-color: white;
|
|
32
|
+
border-bottom: 1px solid #e5e7eb;
|
|
33
|
+
display: flex;
|
|
34
|
+
align-items: center;
|
|
35
|
+
padding: 0 1rem;
|
|
36
|
+
`;
|
|
37
|
+
const StyledTitle = styled_1.default.h1 `
|
|
38
|
+
font-size: 1.25rem;
|
|
39
|
+
font-weight: 600;
|
|
40
|
+
color: #111827;
|
|
41
|
+
`;
|
|
42
|
+
exports.default = Header;
|
|
@@ -19,10 +19,9 @@ interface StackRouterContextProps {
|
|
|
19
19
|
path: string;
|
|
20
20
|
element: React.ReactNode;
|
|
21
21
|
}[];
|
|
22
|
-
ActivitysLayout?: React.ComponentType<{
|
|
23
|
-
children: React.ReactNode;
|
|
24
|
-
}>;
|
|
25
22
|
}
|
|
26
23
|
export declare const useStackRouter: () => StackRouterContextProps;
|
|
27
|
-
declare const
|
|
28
|
-
export default
|
|
24
|
+
declare const StackRouterProvider: ({ maxWidth, Activities, initialActivity, enableDevTools, }: StackRouterProviderProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
25
|
+
export default StackRouterProvider;
|
|
26
|
+
export { StackRouterProvider };
|
|
27
|
+
//# sourceMappingURL=stack-router-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stack-router-provider.d.ts","sourceRoot":"","sources":["../../src/stack-router/stack-router-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkE,MAAM,OAAO,CAAC;AAMvF,OAAO,EAEL,YAAY,EAGZ,wBAAwB,EAEzB,MAAM,SAAS,CAAC;AAEjB,UAAU,uBAAuB;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,YAAY,CAAC;IAC3B,UAAU,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,KAAK,CAAC,SAAS,CAAA;KAAE,EAAE,CAAC;IACzD,eAAe,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,KAAK,CAAC,SAAS,CAAA;KAAE,CAAC;IAC5D,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IACzC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IAC5C,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,YAAY,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,KAAK,CAAC,SAAS,CAAA;KAAE,EAAE,CAAC;CAC5D;AAID,eAAO,MAAM,cAAc,+BAM1B,CAAC;AAEF,QAAA,MAAM,mBAAmB,GAAI,4DAK1B,wBAAwB,qDAiI1B,CAAC;AAEF,eAAe,mBAAmB,CAAC;AACnC,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
|