@iyulab/router 0.9.3 → 0.10.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.
@@ -0,0 +1,52 @@
1
+ import { FallbackRouteConfig, RouteConfig } from './RouteConfig';
2
+ import { RouteContext } from './RouteContext';
3
+ /**
4
+ * 라우터 설정
5
+ */
6
+ export interface RouterConfig {
7
+ /**
8
+ * 라우터가 연결될 최상위 엘리먼트
9
+ */
10
+ root: HTMLElement;
11
+ /**
12
+ * 라우터의 기본 경로
13
+ * - 라우터의 기본 경로는 URL의 시작점입니다.
14
+ * - URLPattern을 사용하여 경로를 탐색합니다.
15
+ * @default '/'
16
+ */
17
+ basepath?: string;
18
+ /**
19
+ * 라우트 설정
20
+ * - 라우트는 URLPattern을 사용하여 경로를 탐색합니다.
21
+ * - 라우트는 렌더링할 엘리먼트 또는 컴포넌트를 지정합니다.
22
+ */
23
+ routes?: RouteConfig[];
24
+ /**
25
+ * 모든 라우트 전환 전에 호출되는 글로벌 enter 함수입니다.
26
+ * - `string` 반환: 해당 경로로 redirect
27
+ * - `false` 반환: 네비게이션 취소
28
+ * - `true` 반환: 통과
29
+ * @example
30
+ * ```typescript
31
+ * enter: async (ctx) => {
32
+ * if (!isAuthenticated() && ctx.pathname !== '/login') return '/login';
33
+ * }
34
+ * ```
35
+ */
36
+ enter?: (ctx: RouteContext) => Promise<string | boolean> | string | boolean;
37
+ /**
38
+ * 라우트 매칭 실패 또는 오류 발생 시 대체 라우트 설정
39
+ * - 지정된 설정이 없을 경우, 기본 오류 페이지가 렌더링됩니다.
40
+ */
41
+ fallback?: FallbackRouteConfig;
42
+ /**
43
+ * `a` 태그 클릭 시 클라이언트 라우팅을 수행할지 여부를 설정합니다.
44
+ * @default true
45
+ */
46
+ useIntercept?: boolean;
47
+ /**
48
+ * 초기 로드 시 현재 URL로 라우팅을 자동으로 수행할지 여부를 설정합니다.
49
+ * @default true
50
+ */
51
+ initialLoad?: boolean;
52
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iyulab/router",
3
- "version": "0.9.3",
3
+ "version": "0.10.0",
4
4
  "description": "A modern client-side router for web applications with support for Lit and React components",
5
5
  "keywords": [
6
6
  "lit",
@@ -38,12 +38,13 @@
38
38
  }
39
39
  },
40
40
  "scripts": {
41
- "test": "vite",
42
- "build": "vite build"
41
+ "test": "vitest run",
42
+ "build": "vite build",
43
+ "test:watch": "vitest"
43
44
  },
44
45
  "dependencies": {
45
- "lit": "^3.3.2",
46
- "@lit/react": "^1.0.8"
46
+ "@lit/react": "^1.0.8",
47
+ "lit": "^3.3.3"
47
48
  },
48
49
  "peerDependencies": {
49
50
  "react": ">=18.0.0",
@@ -58,11 +59,13 @@
58
59
  }
59
60
  },
60
61
  "devDependencies": {
61
- "@types/node": "^25.6.0",
62
+ "@types/node": "^25.8.0",
62
63
  "@types/react": "^19.2.14",
63
64
  "@types/react-dom": "^19.2.3",
65
+ "happy-dom": "^20.10.2",
64
66
  "typescript": "^5.9.3",
65
- "vite": "^8.0.8",
66
- "vite-plugin-dts": "^4.5.4"
67
+ "vite": "^8.0.13",
68
+ "vite-plugin-dts": "^5.0.0",
69
+ "vitest": "^4.1.8"
67
70
  }
68
71
  }