@mandujs/core 0.12.2 → 0.13.1

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.
@@ -1,278 +1,270 @@
1
- /**
2
- * FS Routes Types
3
- *
4
- * 파일 시스템 기반 라우팅 타입 정의
5
- *
6
- * @module router/fs-types
7
- */
8
-
9
- import type { RouteKind, HydrationConfig, HttpMethod } from "../spec/schema";
10
-
11
- // ═══════════════════════════════════════════════════════════════════════════
12
- // Segment Types
13
- // ═══════════════════════════════════════════════════════════════════════════
14
-
15
- /**
16
- * 라우트 세그먼트 타입
17
- */
18
- export type SegmentType =
19
- | "static" // 정적 세그먼트 (예: "blog")
20
- | "dynamic" // 동적 세그먼트 (예: "[slug]")
21
- | "catchAll" // Catch-all 세그먼트 (예: "[...path]")
22
- | "optionalCatchAll" // Optional catch-all (예: "[[...path]]")
23
- | "group"; // 라우트 그룹 (예: "(marketing)")
24
-
25
- /**
26
- * 파싱된 라우트 세그먼트
27
- */
28
- export interface RouteSegment {
29
- /** 원본 세그먼트 이름 */
30
- raw: string;
31
-
32
- /** 세그먼트 타입 */
33
- type: SegmentType;
34
-
35
- /** 파라미터 이름 (동적 세그먼트의 경우) */
36
- paramName?: string;
37
- }
38
-
39
- // ═══════════════════════════════════════════════════════════════════════════
40
- // File Types
41
- // ═══════════════════════════════════════════════════════════════════════════
42
-
43
- /**
44
- * 스캔된 파일 타입
45
- */
46
- export type ScannedFileType =
47
- | "page" // page.tsx - 페이지 컴포넌트
48
- | "layout" // layout.tsx - 레이아웃
49
- | "route" // route.ts - API 핸들러
50
- | "loading" // loading.tsx - 로딩 UI
51
- | "error" // error.tsx - 에러 UI
52
- | "not-found" // not-found.tsx - 404 UI
53
- | "island"; // *.island.tsx - Island 컴포넌트
54
-
55
- /**
56
- * 스캔된 파일 정보
57
- */
58
- export interface ScannedFile {
59
- /** 절대 경로 */
60
- absolutePath: string;
61
-
62
- /** 라우트 루트 기준 상대 경로 */
63
- relativePath: string;
64
-
65
- /** 파일 타입 */
66
- type: ScannedFileType;
67
-
68
- /** 파싱된 경로 세그먼트 */
69
- segments: RouteSegment[];
70
-
71
- /** 파일 확장자 */
72
- extension: string;
73
- }
74
-
75
- // ═══════════════════════════════════════════════════════════════════════════
76
- // Route Config Types
77
- // ═══════════════════════════════════════════════════════════════════════════
78
-
79
- /**
80
- * FS Routes에서 생성된 라우트 설정
81
- */
82
- export interface FSRouteConfig {
83
- /** 라우트 ID (자동 생성) */
84
- id: string;
85
-
86
- /** 파싱된 경로 세그먼트 */
87
- segments: RouteSegment[];
88
-
89
- /** URL 패턴 (예: "/blog/:slug") */
90
- pattern: string;
91
-
92
- /** 라우트 종류 */
93
- kind: RouteKind;
94
-
95
- /** HTTP 메서드 (API 라우트용) */
96
- methods?: HttpMethod[];
97
-
98
- /** 페이지 컴포넌트 모듈 경로 */
99
- componentModule?: string;
100
-
101
- /** API 핸들러 모듈 경로 */
102
- module: string;
103
-
104
- /** Island 컴포넌트 모듈 경로 */
105
- clientModule?: string;
106
-
107
- /** 적용할 레이아웃 체인 */
108
- layoutChain: string[];
109
-
110
- /** 로딩 UI 모듈 경로 */
111
- loadingModule?: string;
112
-
113
- /** 에러 UI 모듈 경로 */
114
- errorModule?: string;
115
-
116
- /** Hydration 설정 */
117
- hydration?: HydrationConfig;
118
-
119
- /** 원본 파일 경로 */
120
- sourceFile: string;
121
- }
122
-
123
- // ═══════════════════════════════════════════════════════════════════════════
124
- // Scanner Config Types
125
- // ═══════════════════════════════════════════════════════════════════════════
126
-
127
- /**
128
- * FS Routes 스캐너 설정
129
- */
130
- export interface FSScannerConfig {
131
- /** 라우트 루트 디렉토리 (기본: "app") */
132
- routesDir: string;
133
-
134
- /** 지원 확장자 (기본: [".tsx", ".ts", ".jsx", ".js"]) */
135
- extensions: string[];
136
-
137
- /** 제외 패턴 (glob) */
138
- exclude: string[];
139
-
140
- /** Island 파일 접미사 (기본: ".island") */
141
- islandSuffix: string;
142
-
143
- /** 레거시 매니페스트 경로 (병합용) */
144
- legacyManifestPath?: string;
145
-
146
- /** 레거시 매니페스트와 병합 여부 */
147
- mergeWithLegacy: boolean;
148
- }
149
-
150
- /**
151
- * 기본 스캐너 설정
152
- */
153
- export const DEFAULT_SCANNER_CONFIG: FSScannerConfig = {
154
- routesDir: "app",
155
- extensions: [".tsx", ".ts", ".jsx", ".js"],
156
- exclude: [
157
- "**/*.test.ts",
158
- "**/*.test.tsx",
159
- "**/*.spec.ts",
160
- "**/*.spec.tsx",
161
- "**/_*/**", // 비공개 폴더
162
- "**/node_modules/**",
163
- ],
164
- islandSuffix: ".island",
165
- legacyManifestPath: "spec/routes.manifest.json",
166
- mergeWithLegacy: true,
167
- };
168
-
169
- // ═══════════════════════════════════════════════════════════════════════════
170
- // Scan Result Types
171
- // ═══════════════════════════════════════════════════════════════════════════
172
-
173
- /**
174
- * 디렉토리 스캔 결과
175
- */
176
- export interface ScanResult {
177
- /** 스캔된 파일 목록 */
178
- files: ScannedFile[];
179
-
180
- /** 생성된 라우트 설정 */
181
- routes: FSRouteConfig[];
182
-
183
- /** 에러 목록 */
184
- errors: ScanError[];
185
-
186
- /** 스캔 통계 */
187
- stats: ScanStats;
188
- }
189
-
190
- /**
191
- * 스캔 에러
192
- */
193
- export interface ScanError {
194
- /** 에러 타입 */
195
- type: "invalid_segment" | "duplicate_route" | "file_read_error" | "pattern_conflict";
196
-
197
- /** 에러 메시지 */
198
- message: string;
199
-
200
- /** 관련 파일 경로 */
201
- filePath?: string;
202
-
203
- /** 충돌하는 파일 경로 (duplicate_route의 경우) */
204
- conflictsWith?: string;
205
- }
206
-
207
- /**
208
- * 스캔 통계
209
- */
210
- export interface ScanStats {
211
- /** 총 스캔 파일 수 */
212
- totalFiles: number;
213
-
214
- /** 페이지 수 */
215
- pageCount: number;
216
-
217
- /** API 라우트 수 */
218
- apiCount: number;
219
-
220
- /** 레이아웃 수 */
221
- layoutCount: number;
222
-
223
- /** Island 수 */
224
- islandCount: number;
225
-
226
- /** 스캔 소요 시간 (ms) */
227
- scanTime: number;
228
- }
229
-
230
- // ═══════════════════════════════════════════════════════════════════════════
231
- // Pattern Constants
232
- // ═══════════════════════════════════════════════════════════════════════════
233
-
234
- /**
235
- * 파일명 패턴
236
- */
237
- export const FILE_PATTERNS = {
238
- /** 페이지 파일 */
239
- page: /^page\.(tsx?|jsx?)$/,
240
-
241
- /** 레이아웃 파일 */
242
- layout: /^layout\.(tsx?|jsx?)$/,
243
-
244
- /** API 라우트 파일 */
245
- route: /^route\.(ts|js)$/,
246
-
247
- /** 로딩 UI 파일 */
248
- loading: /^loading\.(tsx?|jsx?)$/,
249
-
250
- /** 에러 UI 파일 */
251
- error: /^error\.(tsx?|jsx?)$/,
252
-
253
- /** 404 파일 */
254
- notFound: /^not-found\.(tsx?|jsx?)$/,
255
-
256
- /** Island 파일 */
257
- island: /\.island\.(tsx?|jsx?)$/,
258
- } as const;
259
-
260
- /**
261
- * 세그먼트 패턴
262
- */
263
- export const SEGMENT_PATTERNS = {
264
- /** 동적 세그먼트: [param] */
265
- dynamic: /^\[([^\[\]\.]+)\]$/,
266
-
267
- /** Catch-all: [...param] */
268
- catchAll: /^\[\.\.\.([^\[\]]+)\]$/,
269
-
270
- /** Optional catch-all: [[...param]] */
271
- optionalCatchAll: /^\[\[\.\.\.([^\[\]]+)\]\]$/,
272
-
273
- /** 라우트 그룹: (name) */
274
- group: /^\(([^()]+)\)$/,
275
-
276
- /** 비공개 폴더: _name */
277
- private: /^_/,
278
- } as const;
1
+ /**
2
+ * FS Routes Types
3
+ *
4
+ * 파일 시스템 기반 라우팅 타입 정의
5
+ *
6
+ * @module router/fs-types
7
+ */
8
+
9
+ import type { RouteKind, HydrationConfig, HttpMethod } from "../spec/schema";
10
+
11
+ // ═══════════════════════════════════════════════════════════════════════════
12
+ // Segment Types
13
+ // ═══════════════════════════════════════════════════════════════════════════
14
+
15
+ /**
16
+ * 라우트 세그먼트 타입
17
+ */
18
+ export type SegmentType =
19
+ | "static" // 정적 세그먼트 (예: "blog")
20
+ | "dynamic" // 동적 세그먼트 (예: "[slug]")
21
+ | "catchAll" // Catch-all 세그먼트 (예: "[...path]")
22
+ | "optionalCatchAll" // Optional catch-all (예: "[[...path]]")
23
+ | "group"; // 라우트 그룹 (예: "(marketing)")
24
+
25
+ /**
26
+ * 파싱된 라우트 세그먼트
27
+ */
28
+ export interface RouteSegment {
29
+ /** 원본 세그먼트 이름 */
30
+ raw: string;
31
+
32
+ /** 세그먼트 타입 */
33
+ type: SegmentType;
34
+
35
+ /** 파라미터 이름 (동적 세그먼트의 경우) */
36
+ paramName?: string;
37
+ }
38
+
39
+ // ═══════════════════════════════════════════════════════════════════════════
40
+ // File Types
41
+ // ═══════════════════════════════════════════════════════════════════════════
42
+
43
+ /**
44
+ * 스캔된 파일 타입
45
+ */
46
+ export type ScannedFileType =
47
+ | "page" // page.tsx - 페이지 컴포넌트
48
+ | "layout" // layout.tsx - 레이아웃
49
+ | "route" // route.ts - API 핸들러
50
+ | "loading" // loading.tsx - 로딩 UI
51
+ | "error" // error.tsx - 에러 UI
52
+ | "not-found" // not-found.tsx - 404 UI
53
+ | "island"; // *.island.tsx - Island 컴포넌트
54
+
55
+ /**
56
+ * 스캔된 파일 정보
57
+ */
58
+ export interface ScannedFile {
59
+ /** 절대 경로 */
60
+ absolutePath: string;
61
+
62
+ /** 라우트 루트 기준 상대 경로 */
63
+ relativePath: string;
64
+
65
+ /** 파일 타입 */
66
+ type: ScannedFileType;
67
+
68
+ /** 파싱된 경로 세그먼트 */
69
+ segments: RouteSegment[];
70
+
71
+ /** 파일 확장자 */
72
+ extension: string;
73
+ }
74
+
75
+ // ═══════════════════════════════════════════════════════════════════════════
76
+ // Route Config Types
77
+ // ═══════════════════════════════════════════════════════════════════════════
78
+
79
+ /**
80
+ * FS Routes에서 생성된 라우트 설정
81
+ */
82
+ export interface FSRouteConfig {
83
+ /** 라우트 ID (자동 생성) */
84
+ id: string;
85
+
86
+ /** 파싱된 경로 세그먼트 */
87
+ segments: RouteSegment[];
88
+
89
+ /** URL 패턴 (예: "/blog/:slug") */
90
+ pattern: string;
91
+
92
+ /** 라우트 종류 */
93
+ kind: RouteKind;
94
+
95
+ /** HTTP 메서드 (API 라우트용) */
96
+ methods?: HttpMethod[];
97
+
98
+ /** 페이지 컴포넌트 모듈 경로 */
99
+ componentModule?: string;
100
+
101
+ /** API 핸들러 모듈 경로 */
102
+ module: string;
103
+
104
+ /** Island 컴포넌트 모듈 경로 */
105
+ clientModule?: string;
106
+
107
+ /** 적용할 레이아웃 체인 */
108
+ layoutChain: string[];
109
+
110
+ /** 로딩 UI 모듈 경로 */
111
+ loadingModule?: string;
112
+
113
+ /** 에러 UI 모듈 경로 */
114
+ errorModule?: string;
115
+
116
+ /** Hydration 설정 */
117
+ hydration?: HydrationConfig;
118
+
119
+ /** 원본 파일 경로 */
120
+ sourceFile: string;
121
+ }
122
+
123
+ // ═══════════════════════════════════════════════════════════════════════════
124
+ // Scanner Config Types
125
+ // ═══════════════════════════════════════════════════════════════════════════
126
+
127
+ /**
128
+ * FS Routes 스캐너 설정
129
+ */
130
+ export interface FSScannerConfig {
131
+ /** 라우트 루트 디렉토리 (기본: "app") */
132
+ routesDir: string;
133
+
134
+ /** 지원 확장자 (기본: [".tsx", ".ts", ".jsx", ".js"]) */
135
+ extensions: string[];
136
+
137
+ /** 제외 패턴 (glob) */
138
+ exclude: string[];
139
+
140
+ /** Island 파일 접미사 (기본: ".island") */
141
+ islandSuffix: string;
142
+ }
143
+
144
+ /**
145
+ * 기본 스캐너 설정
146
+ */
147
+ export const DEFAULT_SCANNER_CONFIG: FSScannerConfig = {
148
+ routesDir: "app",
149
+ extensions: [".tsx", ".ts", ".jsx", ".js"],
150
+ exclude: [
151
+ "**/*.test.ts",
152
+ "**/*.test.tsx",
153
+ "**/*.spec.ts",
154
+ "**/*.spec.tsx",
155
+ "**/_*/**", // 비공개 폴더
156
+ "**/node_modules/**",
157
+ ],
158
+ islandSuffix: ".island",
159
+ };
160
+
161
+ // ═══════════════════════════════════════════════════════════════════════════
162
+ // Scan Result Types
163
+ // ═══════════════════════════════════════════════════════════════════════════
164
+
165
+ /**
166
+ * 디렉토리 스캔 결과
167
+ */
168
+ export interface ScanResult {
169
+ /** 스캔된 파일 목록 */
170
+ files: ScannedFile[];
171
+
172
+ /** 생성된 라우트 설정 */
173
+ routes: FSRouteConfig[];
174
+
175
+ /** 에러 목록 */
176
+ errors: ScanError[];
177
+
178
+ /** 스캔 통계 */
179
+ stats: ScanStats;
180
+ }
181
+
182
+ /**
183
+ * 스캔 에러
184
+ */
185
+ export interface ScanError {
186
+ /** 에러 타입 */
187
+ type: "invalid_segment" | "duplicate_route" | "file_read_error" | "pattern_conflict";
188
+
189
+ /** 에러 메시지 */
190
+ message: string;
191
+
192
+ /** 관련 파일 경로 */
193
+ filePath?: string;
194
+
195
+ /** 충돌하는 파일 경로 (duplicate_route 경우) */
196
+ conflictsWith?: string;
197
+ }
198
+
199
+ /**
200
+ * 스캔 통계
201
+ */
202
+ export interface ScanStats {
203
+ /** 스캔 파일 */
204
+ totalFiles: number;
205
+
206
+ /** 페이지 수 */
207
+ pageCount: number;
208
+
209
+ /** API 라우트 수 */
210
+ apiCount: number;
211
+
212
+ /** 레이아웃 수 */
213
+ layoutCount: number;
214
+
215
+ /** Island 수 */
216
+ islandCount: number;
217
+
218
+ /** 스캔 소요 시간 (ms) */
219
+ scanTime: number;
220
+ }
221
+
222
+ // ═══════════════════════════════════════════════════════════════════════════
223
+ // Pattern Constants
224
+ // ═══════════════════════════════════════════════════════════════════════════
225
+
226
+ /**
227
+ * 파일명 패턴
228
+ */
229
+ export const FILE_PATTERNS = {
230
+ /** 페이지 파일 */
231
+ page: /^page\.(tsx?|jsx?)$/,
232
+
233
+ /** 레이아웃 파일 */
234
+ layout: /^layout\.(tsx?|jsx?)$/,
235
+
236
+ /** API 라우트 파일 */
237
+ route: /^route\.(ts|js)$/,
238
+
239
+ /** 로딩 UI 파일 */
240
+ loading: /^loading\.(tsx?|jsx?)$/,
241
+
242
+ /** 에러 UI 파일 */
243
+ error: /^error\.(tsx?|jsx?)$/,
244
+
245
+ /** 404 파일 */
246
+ notFound: /^not-found\.(tsx?|jsx?)$/,
247
+
248
+ /** Island 파일 */
249
+ island: /\.island\.(tsx?|jsx?)$/,
250
+ } as const;
251
+
252
+ /**
253
+ * 세그먼트 패턴
254
+ */
255
+ export const SEGMENT_PATTERNS = {
256
+ /** 동적 세그먼트: [param] */
257
+ dynamic: /^\[([^\[\]\.]+)\]$/,
258
+
259
+ /** Catch-all: [...param] */
260
+ catchAll: /^\[\.\.\.([^\[\]]+)\]$/,
261
+
262
+ /** Optional catch-all: [[...param]] */
263
+ optionalCatchAll: /^\[\[\.\.\.([^\[\]]+)\]\]$/,
264
+
265
+ /** 라우트 그룹: (name) */
266
+ group: /^\(([^()]+)\)$/,
267
+
268
+ /** 비공개 폴더: _name */
269
+ private: /^_/,
270
+ } as const;