@kood/claude-code 0.7.2 → 0.7.5

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.
@@ -21,6 +21,7 @@
21
21
  ---
22
22
 
23
23
  <instructions>
24
+ @docs/architecture.md
24
25
  @docs/library/tauri/index.md
25
26
  @docs/guides/getting-started.md
26
27
  @docs/guides/mobile.md
@@ -0,0 +1,300 @@
1
+ # Architecture
2
+
3
+ > Tauri v2 애플리케이션 아키텍처
4
+
5
+ <instructions>
6
+ @references/async-execution.md
7
+ @references/error-handling.md
8
+ @references/security-model.md
9
+ @references/state-management.md
10
+ @references/mobile-architecture.md
11
+ @references/data-flow.md
12
+ @references/tech-stack.md
13
+ @../guides/getting-started.md
14
+ @../guides/mobile.md
15
+ @../guides/distribution.md
16
+ @../library/tauri/index.md
17
+ </instructions>
18
+
19
+ ---
20
+
21
+ <forbidden>
22
+
23
+ | 분류 | 금지 |
24
+ |------|------|
25
+ | **IPC** | Rust 함수 직접 FFI 호출 (invoke 사용) |
26
+ | **IPC** | async command에 &str 인자 (String 변환 필수) |
27
+ | **보안** | Capabilities 없이 Command 노출 |
28
+ | **보안** | CSP 비활성화, `'unsafe-eval'` 무분별 사용 |
29
+ | **보안** | CDN에서 원격 스크립트 로드 |
30
+ | **상태** | State<T>에 Arc 래핑 (내부 처리) |
31
+ | **상태** | async에서 await 걸쳐 Mutex lock 유지 |
32
+ | **모바일** | iOS 개발을 macOS 외 플랫폼에서 시도 |
33
+ | **모바일** | Android 메인 스레드에서 블로킹 I/O |
34
+ | **v1 API** | allowlist 사용 (capabilities 사용) |
35
+ | **v1 API** | `@tauri-apps/api/tauri` import (core 사용) |
36
+ | **v1 API** | Window 타입 (WebviewWindow 사용) |
37
+
38
+ </forbidden>
39
+
40
+ ---
41
+
42
+ <required>
43
+
44
+ | 분류 | 필수 |
45
+ |------|------|
46
+ | **Command** | `#[tauri::command]` 어노테이션 |
47
+ | **Command** | `tauri::generate_handler![]` 등록 |
48
+ | **Command** | `Result<T, E>` 반환, E 직렬화 가능 |
49
+ | **Command** | `serde::Serialize/Deserialize` 인자/반환값 |
50
+ | **IPC** | `invoke()` from `@tauri-apps/api/core` |
51
+ | **IPC** | camelCase 인자 (Rust snake_case 자동 변환) |
52
+ | **보안** | Capabilities 파일 정의 (`src-tauri/capabilities/`) |
53
+ | **보안** | Plugin Permission 명시 |
54
+ | **보안** | CSP 설정 (`tauri.conf.json > app > security`) |
55
+ | **상태** | `app.manage()` + `State<'_, T>` 패턴 |
56
+ | **상태** | 가변 상태 → `Mutex<T>` |
57
+ | **모바일** | `lib.rs` 엔트리포인트 (라이브러리 로드) |
58
+ | **Config** | identifier 역도메인 형식 |
59
+
60
+ </required>
61
+
62
+ ---
63
+
64
+ <system_overview>
65
+
66
+ ## System Overview
67
+
68
+ ```
69
+ ┌─────────────────────────────────────────────────────────────────┐
70
+ │ Frontend (WebView) │
71
+ │ ┌────────────────┐ ┌────────────────┐ ┌───────────────┐ │
72
+ │ │ React/Vue │───▶│ @tauri-apps/ │───▶│ WebView │ │
73
+ │ │ Framework │◀───│ api/core │◀───│ Renderer │ │
74
+ │ └────────────────┘ └───────┬────────┘ └───────────────┘ │
75
+ │ │ invoke() / listen() │
76
+ └────────────────────────────────┼─────────────────────────────────┘
77
+
78
+ ┌─────────────────────────────────────────────────────────────────┐
79
+ │ IPC Bridge (Trust Boundary) │
80
+ │ ┌────────────────────────────────────────────────────────────┐ │
81
+ │ │ JSON-RPC Serialization | Capabilities Check | CSP Filter │ │
82
+ │ └────────────────────────────────────────────────────────────┘ │
83
+ └────────────────────────────────┼────────────────────────────────┘
84
+
85
+ ┌─────────────────────────────────────────────────────────────────┐
86
+ │ Tauri Core (Rust) │
87
+ │ ┌────────────────────────────────────────────────────────────┐ │
88
+ │ │ Commands | Events | Channels │ │
89
+ │ │ State<T> | Mutex<T> | app.manage() │ │
90
+ │ └────────────────────────────┬───────────────────────────────┘ │
91
+ │ ┌────────────────────────────▼───────────────────────────────┐ │
92
+ │ │ Plugins Layer │ │
93
+ │ │ shell | fs | dialog | http | store | notification │ │
94
+ │ └────────────────────────────┬───────────────────────────────┘ │
95
+ │ ┌────────────────────────────▼───────────────────────────────┐ │
96
+ │ │ tauri-runtime (TAO + WRY) │ │
97
+ │ │ Window Management (TAO) | WebView Rendering (WRY) │ │
98
+ │ └────────────────────────────┬───────────────────────────────┘ │
99
+ └───────────────────────────────┼──────────────────────────────────┘
100
+
101
+ ┌─────────────────────────────────────────────────────────────────┐
102
+ │ Operating System │
103
+ │ Windows (WebView2) | macOS (WKWebView) | Linux (webkitgtk) │
104
+ │ Android (WebView) | iOS (WKWebView) │
105
+ └─────────────────────────────────────────────────────────────────┘
106
+ ```
107
+
108
+ </system_overview>
109
+
110
+ ---
111
+
112
+ <folder_structure>
113
+
114
+ ## Folder Structure
115
+
116
+ ```
117
+ my-tauri-app/
118
+ ├── src/ # 프론트엔드 (React + TypeScript)
119
+ │ ├── main.tsx # React 엔트리
120
+ │ ├── App.tsx # 루트 컴포넌트
121
+ │ ├── components/ # UI 컴포넌트
122
+ │ ├── hooks/ # Custom Hooks
123
+ │ ├── stores/ # Zustand 스토어
124
+ │ └── lib/ # 유틸리티
125
+ ├── src-tauri/ # 백엔드 (Rust)
126
+ │ ├── src/
127
+ │ │ ├── main.rs # 데스크톱 엔트리
128
+ │ │ ├── lib.rs # 공유 로직 (모바일 지원)
129
+ │ │ ├── commands/ # Command 모듈
130
+ │ │ └── error.rs # 에러 타입 정의
131
+ │ ├── capabilities/ # 보안 Capabilities
132
+ │ ├── gen/ # 플랫폼 코드 (apple/, android/)
133
+ │ ├── Cargo.toml # Rust 의존성
134
+ │ ├── tauri.conf.json # Tauri 메인 설정
135
+ │ └── tauri.[platform].conf.json # 플랫폼별 설정
136
+ ├── package.json
137
+ └── vite.config.ts
138
+ ```
139
+
140
+ | 폴더 | 역할 |
141
+ |------|------|
142
+ | **src/** | 프론트엔드 UI |
143
+ | **src-tauri/src/commands/** | Rust Command 정의 |
144
+ | **src-tauri/capabilities/** | 보안 권한 설정 |
145
+ | **src-tauri/gen/** | 플랫폼별 생성 코드 |
146
+
147
+ </folder_structure>
148
+
149
+ ---
150
+
151
+ <process_model>
152
+
153
+ ## Process Model
154
+
155
+ > Tauri는 **Single-Process Multi-Thread Architecture** 사용 (Electron과 다름)
156
+
157
+ **Electron과의 차이:**
158
+ - Electron: Main Process + Renderer Process (별도 프로세스)
159
+ - Tauri: **단일 프로세스** 내에서 Rust Core와 WebView가 **별도 스레드**로 실행
160
+ - IPC는 프로세스 간 통신이 아닌 **스레드 간 통신** → 더 빠르고 메모리 효율적
161
+
162
+ ```
163
+ ┌─────────────────┐ ┌─────────────────┐
164
+ │ Main Thread │ │ WebView Thread │
165
+ │ (Full Trust) │◄───►│ (Sandboxed) │
166
+ │ │ IPC │ │
167
+ │ • System API │ │ • UI Only │
168
+ │ • File I/O │ │ • No Direct │
169
+ │ • Network │ │ System │
170
+ │ • State │ │ Access │
171
+ └─────────────────┘ └─────────────────┘
172
+ (Rust Core) (WebView)
173
+ ```
174
+
175
+ | 이점 | 설명 |
176
+ |------|------|
177
+ | **보안** | WebView Sandbox + CSP로 XSS → 시스템 접근 차단 |
178
+ | **성능** | 메모리 효율 (Electron 대비 1/10), 스레드 통신이 프로세스 통신보다 빠름 |
179
+ | **메모리** | 단일 프로세스로 중복 메모리 할당 없음 |
180
+
181
+ </process_model>
182
+
183
+ ---
184
+
185
+ <ipc_architecture>
186
+
187
+ ## IPC Architecture
188
+
189
+ | 원칙 | 설명 |
190
+ |------|------|
191
+ | **Asynchronous Message Passing** | 직접 함수 호출 대신 메시지 전달 |
192
+ | **JSON-RPC Serialization** | 모든 데이터 JSON 직렬화 |
193
+ | **Trust Boundary** | WebView → Core 요청은 Capabilities 검증 |
194
+
195
+ ### Commands (프론트엔드 → Rust)
196
+
197
+ ```
198
+ Frontend ──invoke()──▶ IPC Bridge ──handler──▶ Command ──▶ State/DB
199
+ ◀──Result<T>─────────────────────────────────────────────────┘
200
+ ```
201
+
202
+ ```typescript
203
+ const user = await invoke<User>('get_user', { id: 1 });
204
+ ```
205
+
206
+ ```rust
207
+ #[tauri::command]
208
+ async fn get_user(id: u32, state: State<'_, Db>) -> Result<User, AppError> {
209
+ state.find_user(id).await
210
+ }
211
+ ```
212
+
213
+ ### Events (양방향 통신)
214
+
215
+ - **Fire-and-forget**: 응답 없음, 단방향
216
+ - **Lifecycle/State 변경**: 진행률, 상태 업데이트
217
+ - **양방향**: Frontend ↔ Rust 모두 emit/listen 가능
218
+
219
+ ### Channels (고속 스트리밍)
220
+
221
+ - **대용량 데이터**: 파일 다운로드, 실시간 로그
222
+ - **단방향 스트림**: Rust → Frontend
223
+ - **고성능**: Events보다 빠름, 대량 메시지에 적합
224
+
225
+ **Details:** @references/async-execution.md, @references/error-handling.md
226
+
227
+ </ipc_architecture>
228
+
229
+ ---
230
+
231
+ <quick_patterns>
232
+
233
+ ## Quick Patterns
234
+
235
+ ```rust
236
+ // Command 정의
237
+ #[tauri::command]
238
+ async fn greet(name: String) -> Result<String, String> {
239
+ Ok(format!("Hello, {}!", name))
240
+ }
241
+
242
+ // State 사용
243
+ #[tauri::command]
244
+ async fn increment(state: State<'_, Mutex<AppState>>) -> Result<u32, String> {
245
+ let mut s = state.lock().unwrap();
246
+ s.counter += 1;
247
+ Ok(s.counter)
248
+ }
249
+
250
+ // main.rs
251
+ fn main() {
252
+ tauri::Builder::default()
253
+ .plugin(tauri_plugin_shell::init())
254
+ .setup(|app| {
255
+ app.manage(Mutex::new(AppState { counter: 0 }));
256
+ Ok(())
257
+ })
258
+ .invoke_handler(tauri::generate_handler![greet, increment])
259
+ .run(tauri::generate_context!())
260
+ .expect("error");
261
+ }
262
+ ```
263
+
264
+ ```typescript
265
+ // 프론트엔드
266
+ import { invoke } from '@tauri-apps/api/core';
267
+ const greeting = await invoke<string>('greet', { name: 'World' });
268
+
269
+ import { listen } from '@tauri-apps/api/event';
270
+ const unlisten = await listen<string>('download-progress', (e) => console.log(e.payload));
271
+ ```
272
+
273
+ ```json
274
+ // src-tauri/capabilities/default.json
275
+ {
276
+ "identifier": "default",
277
+ "windows": ["main"],
278
+ "permissions": ["core:default", "shell:allow-open"]
279
+ }
280
+ ```
281
+
282
+ </quick_patterns>
283
+
284
+ ---
285
+
286
+ <references_index>
287
+
288
+ ## References
289
+
290
+ | 문서 | 내용 |
291
+ |------|------|
292
+ | **@references/async-execution.md** | Tokio runtime, async vs sync command |
293
+ | **@references/error-handling.md** | 에러 타입, 전파 메커니즘 |
294
+ | **@references/security-model.md** | Trust Boundary, Capabilities, CSP |
295
+ | **@references/state-management.md** | Mutex 선택, await lock 패턴 |
296
+ | **@references/mobile-architecture.md** | 엔트리포인트, Plugin 구조 |
297
+ | **@references/data-flow.md** | Command/Event/Plugin 데이터 흐름 |
298
+ | **@references/tech-stack.md** | 기술 스택, WebView 엔진 |
299
+
300
+ </references_index>