docs(10_Wiki): 위키 전체 재구성 — Topic_* 폴더를 4개 카테고리로 통합 + 대규모 중복 제거
Topic_Agent/Topic_Blog/Topics/Topics_Biz/Topics_Meeting/Topics_Rag의 마크다운 지식 문서를 Topic_General/Topic_Programming/Topic_Graphic/Topic_Business 4개 카테고리로 재분류. - 중복 제거: frontmatter의 status:duplicate/merged + duplicate_of/redirect_to 필드로 자기 자신을 중복으로 선언한 리다이렉트 stub 1032개 제거, 완전 동일 내용 파일 472개 제거, 동일 파일명·다른 내용 충돌 시 더 큰(완전한) 버전만 유지(162개 제거) — 총 1639개 중복 제거. - 분류: 폴더 단위로 명확한 항목(AI_and_ML/Coding/Architecture 등 → Programming, Comfyui/Visual_Effects → Graphic, Topics_Biz/Topics_Meeting/사업 등 → Business, Poetic_Blog_Writing/창의성/Game_Design 등 → General)은 폴더 우선순위로, 나머지 혼재 폴더(Topic_Agent/Topic_Blog/Topics 루트/Thinking & Reasoning/Other/UI_UX_Assets)는 title/tags 키워드 스코어링으로 파일 단위 분류(불명확한 경우 General로 폴백). 원본 폴더명은 "From_*" 서브폴더로 보존해 추적 가능성 유지. - 최종 배치: Programming 2784 / General 1608 / Graphic 285 / Business 249 = 4926개 문서. - 에이전트 운영 상태(.astra/.agent/.obsidian/sessions/memory/_company/docs/lessons/_shared/src)는 지식 콘텐츠가 아니므로 재분류 대상에서 제외하고 원위치 유지. - Topics/Topic_email(상위 보호 폴더 Topic_email과 파일명 100% 중복) 삭제 — 보호 폴더 자체는 미변경. - 완전히 비게 된 Topic_Agent/Topic_Blog/Topics_Biz/Topics_Rag 폴더 제거.
This commit is contained in:
@@ -0,0 +1,170 @@
|
||||
---
|
||||
id: wiki-2026-0508-turbomodules
|
||||
title: TurboModules
|
||||
category: 10_Wiki/Topics
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [React Native TurboModules, RN New Architecture Modules]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.9
|
||||
verification_status: applied
|
||||
tags: [react-native, jsi, native-modules, new-architecture]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
tech_stack:
|
||||
language: typescript
|
||||
framework: react-native
|
||||
---
|
||||
|
||||
# TurboModules
|
||||
|
||||
## 매 한 줄
|
||||
> **"매 JSI-direct 의 type-safe native module"**. TurboModules 의 React Native 의 New Architecture 의 native-side API 의 JS 의 expose, 매 legacy bridge (JSON serialize) 의 X 의 JSI 의 direct C++ call, 매 codegen 의 type safety. 매 2026: RN 0.76+ 의 New Architecture 의 default — TurboModules + Fabric 의 baseline.
|
||||
|
||||
## 매 핵심
|
||||
|
||||
### 매 legacy NativeModule 의 차이
|
||||
- **Legacy**: async-only, JSON serialize, 매 batched message queue, runtime type check.
|
||||
- **TurboModule**: sync 또는 async, JSI direct call, lazy load, codegen-typed (Flow/TS spec).
|
||||
- **Perf**: 매 startup 의 lazy load 의 win, 매 call 의 serialize overhead 의 zero.
|
||||
|
||||
### 매 codegen flow
|
||||
1. JS spec file (`Native<Name>.ts`) 의 author — 매 TurboModule interface.
|
||||
2. `react-native codegen` 의 ObjC++ / Java header 의 generate.
|
||||
3. Native impl 의 generated header 의 conform.
|
||||
4. JS 의 `TurboModuleRegistry.getEnforcing<Spec>('Name')` 의 access.
|
||||
|
||||
### 매 응용
|
||||
1. Custom native sensor / Bluetooth API.
|
||||
2. Heavy native compute (image filter, ML preprocess) 의 JSI sync 의 expose.
|
||||
3. Vendor SDK wrapping (payment, analytics).
|
||||
4. Library author 의 RN 0.76+ 의 publish.
|
||||
|
||||
## 💻 패턴
|
||||
|
||||
### Spec file (TS)
|
||||
```typescript
|
||||
// specs/NativeMathLib.ts
|
||||
import type { TurboModule } from 'react-native';
|
||||
import { TurboModuleRegistry } from 'react-native';
|
||||
|
||||
export interface Spec extends TurboModule {
|
||||
add(a: number, b: number): number;
|
||||
multiplyAsync(a: number, b: number): Promise<number>;
|
||||
getDeviceInfo(): { model: string; os: string };
|
||||
}
|
||||
|
||||
export default TurboModuleRegistry.getEnforcing<Spec>('MathLib');
|
||||
```
|
||||
|
||||
### Codegen config (package.json)
|
||||
```json
|
||||
{
|
||||
"name": "react-native-mathlib",
|
||||
"codegenConfig": {
|
||||
"name": "RNMathLibSpec",
|
||||
"type": "modules",
|
||||
"jsSrcsDir": "specs",
|
||||
"android": { "javaPackageName": "com.mathlib" }
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### iOS impl (ObjC++)
|
||||
```objcpp
|
||||
// MathLib.mm
|
||||
#import "MathLib.h"
|
||||
#import <RNMathLibSpec/RNMathLibSpec.h>
|
||||
|
||||
@implementation MathLib
|
||||
RCT_EXPORT_MODULE()
|
||||
|
||||
- (NSNumber *)add:(double)a b:(double)b {
|
||||
return @(a + b);
|
||||
}
|
||||
|
||||
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
||||
(const facebook::react::ObjCTurboModule::InitParams &)params {
|
||||
return std::make_shared<facebook::react::NativeMathLibSpecJSI>(params);
|
||||
}
|
||||
@end
|
||||
```
|
||||
|
||||
### Android impl (Kotlin)
|
||||
```kotlin
|
||||
class MathLibModule(reactContext: ReactApplicationContext) :
|
||||
NativeMathLibSpec(reactContext) {
|
||||
|
||||
override fun getName() = "MathLib"
|
||||
|
||||
override fun add(a: Double, b: Double): Double = a + b
|
||||
|
||||
override fun multiplyAsync(a: Double, b: Double, promise: Promise) {
|
||||
promise.resolve(a * b)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### JS consumption
|
||||
```typescript
|
||||
import MathLib from './specs/NativeMathLib';
|
||||
|
||||
const sum = MathLib.add(2, 3); // 매 sync — 매 JSI direct
|
||||
const product = await MathLib.multiplyAsync(4, 5);
|
||||
```
|
||||
|
||||
### Enable New Architecture
|
||||
```bash
|
||||
# 매 RN 0.76+ default — 매 0.74 의 opt-in
|
||||
# iOS:
|
||||
RCT_NEW_ARCH_ENABLED=1 pod install
|
||||
# Android: gradle.properties
|
||||
newArchEnabled=true
|
||||
```
|
||||
|
||||
### Lazy access guard
|
||||
```typescript
|
||||
const MathLib = TurboModuleRegistry.get<Spec>('MathLib');
|
||||
if (MathLib == null) {
|
||||
throw new Error('MathLib not linked');
|
||||
}
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
| 상황 | Approach |
|
||||
|---|---|
|
||||
| 신규 RN library (2026) | TurboModule + codegen |
|
||||
| Legacy 0.68 below 의 maintain | NativeModule (deprecated path) |
|
||||
| Sync native call 의 require | TurboModule (legacy 의 X) |
|
||||
| UI component (not API) | Fabric component (sibling 의 New Arch) |
|
||||
| Cross-platform native | TurboModule + shared C++ via JSI |
|
||||
|
||||
**기본값**: 매 RN 0.76+ 의 모든 native module 의 TurboModule.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[React Native]] · [[React Native New Architecture]]
|
||||
- 변형: [[Fabric Renderer]] · [[JSI]]
|
||||
- Adjacent: [[Codegen]] · [[Hermes]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: 매 RN 0.76+ 의 native module 의 author 또는 migrate.
|
||||
**언제 X**: 매 expo-managed app — 매 prebuild 또는 config plugin 의 prefer.
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **Spec file 의 codegen 의 skip 의 manual header**: 매 type drift — 매 always codegen.
|
||||
- **Sync TurboModule 의 long-running task**: 매 JS thread block — 매 async 의 use.
|
||||
- **Bridge module 의 New Arch 의 mix**: 매 deprecation warning + perf loss.
|
||||
- **`getEnforcing` 없 의 unchecked access**: 매 null reference 의 silent fail.
|
||||
- **C++ TurboModule 의 type 의 manual marshal**: 매 codegen 의 auto-handle 의 ignore.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (RN 0.76+ docs, reactnative.dev/docs/the-new-architecture).
|
||||
- 신뢰도 A.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — codegen, JSI direct, iOS/Android impl |
|
||||
Reference in New Issue
Block a user