tribunal-kit 4.3.0 → 4.4.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/.agent/history/architecture-explorer.html +352 -0
- package/.agent/history/architecture-graph.yaml +109 -0
- package/.agent/history/graph-cache.json +215 -0
- package/.agent/history/snapshots/migrate_refs.js.json +11 -0
- package/.agent/history/snapshots/scripts__changelog.js.json +12 -0
- package/.agent/history/snapshots/scripts__sync-version.js.json +11 -0
- package/.agent/history/snapshots/scripts__validate-payload.js.json +11 -0
- package/.agent/history/snapshots/test__integration__bridges.test.js.json +13 -0
- package/.agent/history/snapshots/test__integration__init.test.js.json +13 -0
- package/.agent/history/snapshots/test__integration__routing.test.js.json +11 -0
- package/.agent/history/snapshots/test__integration__swarm_dispatcher.test.js.json +13 -0
- package/.agent/history/snapshots/test__integration__wave2.test.js.json +13 -0
- package/.agent/history/snapshots/test__unit__args.test.js.json +10 -0
- package/.agent/history/snapshots/test__unit__case_law_manager.test.js.json +10 -0
- package/.agent/history/snapshots/test__unit__copyDir.test.js.json +13 -0
- package/.agent/history/snapshots/test__unit__graph_tools.test.js.json +11 -0
- package/.agent/history/snapshots/test__unit__selfInstall.test.js.json +13 -0
- package/.agent/history/snapshots/test__unit__semver.test.js.json +10 -0
- package/.agent/history/snapshots/test__unit__swarm_dispatcher.test.js.json +11 -0
- package/.agent/scripts/case_law_manager.js +684 -684
- package/.agent/scripts/dependency_analyzer.js +1 -1
- package/.agent/scripts/graph_builder.js +311 -0
- package/.agent/scripts/graph_visualizer.js +384 -0
- package/.agent/scripts/graph_zoom.js +154 -0
- package/.agent/scripts/mutation_runner.js +280 -0
- package/.agent/skills/agent-organizer/SKILL.md +9 -1
- package/.agent/skills/agentic-patterns/SKILL.md +9 -1
- package/.agent/skills/ai-prompt-injection-defense/SKILL.md +9 -1
- package/.agent/skills/api-patterns/SKILL.md +206 -198
- package/.agent/skills/api-security-auditor/SKILL.md +9 -1
- package/.agent/skills/app-builder/SKILL.md +9 -1
- package/.agent/skills/app-builder/templates/SKILL.md +77 -69
- package/.agent/skills/appflow-wireframe/SKILL.md +9 -1
- package/.agent/skills/architecture/SKILL.md +9 -1
- package/.agent/skills/authentication-best-practices/SKILL.md +9 -1
- package/.agent/skills/bash-linux/SKILL.md +9 -1
- package/.agent/skills/behavioral-modes/SKILL.md +9 -1
- package/.agent/skills/brainstorming/SKILL.md +9 -1
- package/.agent/skills/building-native-ui/SKILL.md +9 -1
- package/.agent/skills/clean-code/SKILL.md +9 -1
- package/.agent/skills/code-review-checklist/SKILL.md +9 -1
- package/.agent/skills/config-validator/SKILL.md +9 -1
- package/.agent/skills/csharp-developer/SKILL.md +9 -1
- package/.agent/skills/data-validation-schemas/SKILL.md +287 -279
- package/.agent/skills/database-design/SKILL.md +199 -191
- package/.agent/skills/deployment-procedures/SKILL.md +9 -1
- package/.agent/skills/devops-engineer/SKILL.md +9 -1
- package/.agent/skills/devops-incident-responder/SKILL.md +9 -1
- package/.agent/skills/documentation-templates/SKILL.md +9 -1
- package/.agent/skills/edge-computing/SKILL.md +9 -1
- package/.agent/skills/error-resilience/SKILL.md +387 -379
- package/.agent/skills/extract-design-system/SKILL.md +9 -1
- package/.agent/skills/framer-motion-expert/SKILL.md +203 -195
- package/.agent/skills/frontend-design/SKILL.md +160 -152
- package/.agent/skills/game-design-expert/SKILL.md +9 -1
- package/.agent/skills/game-engineering-expert/SKILL.md +9 -1
- package/.agent/skills/geo-fundamentals/SKILL.md +9 -1
- package/.agent/skills/github-operations/SKILL.md +9 -1
- package/.agent/skills/gsap-core/SKILL.md +54 -46
- package/.agent/skills/gsap-frameworks/SKILL.md +54 -46
- package/.agent/skills/gsap-performance/SKILL.md +54 -46
- package/.agent/skills/gsap-plugins/SKILL.md +54 -46
- package/.agent/skills/gsap-react/SKILL.md +54 -46
- package/.agent/skills/gsap-scrolltrigger/SKILL.md +54 -46
- package/.agent/skills/gsap-timeline/SKILL.md +54 -46
- package/.agent/skills/gsap-utils/SKILL.md +54 -46
- package/.agent/skills/i18n-localization/SKILL.md +9 -1
- package/.agent/skills/intelligent-routing/SKILL.md +38 -30
- package/.agent/skills/knowledge-graph/SKILL.md +52 -0
- package/.agent/skills/lint-and-validate/SKILL.md +9 -1
- package/.agent/skills/llm-engineering/SKILL.md +9 -1
- package/.agent/skills/local-first/SKILL.md +9 -1
- package/.agent/skills/mcp-builder/SKILL.md +9 -1
- package/.agent/skills/mobile-design/SKILL.md +222 -214
- package/.agent/skills/monorepo-management/SKILL.md +293 -285
- package/.agent/skills/motion-engineering/SKILL.md +193 -185
- package/.agent/skills/nextjs-react-expert/SKILL.md +193 -185
- package/.agent/skills/nodejs-best-practices/SKILL.md +9 -1
- package/.agent/skills/observability/SKILL.md +9 -1
- package/.agent/skills/parallel-agents/SKILL.md +9 -1
- package/.agent/skills/performance-profiling/SKILL.md +9 -1
- package/.agent/skills/plan-writing/SKILL.md +9 -1
- package/.agent/skills/platform-engineer/SKILL.md +9 -1
- package/.agent/skills/playwright-best-practices/SKILL.md +9 -1
- package/.agent/skills/powershell-windows/SKILL.md +9 -1
- package/.agent/skills/project-idioms/SKILL.md +9 -1
- package/.agent/skills/python-patterns/SKILL.md +9 -1
- package/.agent/skills/python-pro/SKILL.md +282 -274
- package/.agent/skills/react-specialist/SKILL.md +236 -228
- package/.agent/skills/readme-builder/SKILL.md +9 -1
- package/.agent/skills/realtime-patterns/SKILL.md +9 -1
- package/.agent/skills/red-team-tactics/SKILL.md +9 -1
- package/.agent/skills/rust-pro/SKILL.md +9 -1
- package/.agent/skills/seo-fundamentals/SKILL.md +9 -1
- package/.agent/skills/server-management/SKILL.md +9 -1
- package/.agent/skills/shadcn-ui-expert/SKILL.md +9 -1
- package/.agent/skills/skill-creator/SKILL.md +9 -1
- package/.agent/skills/sql-pro/SKILL.md +9 -1
- package/.agent/skills/supabase-postgres-best-practices/SKILL.md +9 -1
- package/.agent/skills/swiftui-expert/SKILL.md +9 -1
- package/.agent/skills/systematic-debugging/SKILL.md +9 -1
- package/.agent/skills/tailwind-patterns/SKILL.md +9 -1
- package/.agent/skills/tdd-workflow/SKILL.md +9 -1
- package/.agent/skills/test-result-analyzer/SKILL.md +9 -1
- package/.agent/skills/testing-patterns/SKILL.md +28 -3
- package/.agent/skills/trend-researcher/SKILL.md +9 -1
- package/.agent/skills/typescript-advanced/SKILL.md +294 -286
- package/.agent/skills/ui-ux-pro-max/SKILL.md +561 -116
- package/.agent/skills/ui-ux-researcher/SKILL.md +9 -1
- package/.agent/skills/vue-expert/SKILL.md +234 -226
- package/.agent/skills/vulnerability-scanner/SKILL.md +9 -1
- package/.agent/skills/web-accessibility-auditor/SKILL.md +9 -1
- package/.agent/skills/web-design-guidelines/SKILL.md +9 -1
- package/.agent/skills/webapp-testing/SKILL.md +9 -1
- package/.agent/skills/whimsy-injector/SKILL.md +9 -1
- package/.agent/skills/workflow-optimizer/SKILL.md +9 -1
- package/README.md +242 -242
- package/bin/tribunal-kit.js +157 -21
- package/package.json +81 -80
- package/scripts/validate-payload.js +73 -0
|
@@ -1,216 +1,216 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: mobile-design
|
|
3
|
-
description: Mobile-first design for iOS, Android, Foldables, React Native, Flutter. Touch interaction, haptics, 120Hz performance, on-device AI, spatial UI, Reanimated 3. Use when building mobile UI, animations, or cross-platform apps.
|
|
4
|
-
allowed-tools: Read, Write, Edit, Glob, Grep
|
|
5
|
-
version: 3.1.0
|
|
6
|
-
last-updated: 2026-04-06
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
# Mobile Design — Dense Reference
|
|
10
|
-
|
|
11
|
-
## Hallucination Traps (Read First)
|
|
12
|
-
- ❌ `Animated.View` for any animation → ✅ `Reanimated 3` worklets (Animated API is legacy, runs on JS thread)
|
|
13
|
-
- ❌ `ScrollView` for lists → ✅ `FlashList` (Shopify) — ScrollView renders ALL items at once
|
|
14
|
-
- ❌ `estimatedItemSize` optional in FlashList → ✅ **REQUIRED** or you get 0-height items
|
|
15
|
-
- ❌ White backgrounds (`#FFFFFF`) → ✅ OLED: `#000000` true black; off-white: `#FAFAFA`
|
|
16
|
-
- ❌ Linear animations (`easing: linear`) → ✅ Spring physics (`stiffness`, `damping`)
|
|
17
|
-
- ❌ Touch targets < 48px → ✅ Min 48px hitbox (visual size can be smaller via padding)
|
|
18
|
-
- ❌ `useAnimatedStyle` in worklet without `'worklet'` directive → crashes on native thread
|
|
19
|
-
- ❌ iOS: `useSafeAreaInsets()` optional → ✅ Required — screen content goes under dynamic island/home indicator
|
|
20
|
-
- ❌ Android: hardcoded status bar height (24dp) → ✅ `StatusBar.currentHeight` (varies per device)
|
|
21
|
-
- ❌ Platform-specific code with `if (platform === 'ios')` scattered everywhere → ✅ centralize in platform/ files
|
|
22
|
-
- ❌ `console.log` in production → ✅ blocks JS thread — remove before release
|
|
23
|
-
|
|
24
|
-
---
|
|
25
|
-
|
|
26
|
-
## React Native Performance
|
|
27
|
-
|
|
28
|
-
### FlashList (Required for Lists)
|
|
29
|
-
```tsx
|
|
30
|
-
import { FlashList } from "@shopify/flash-list";
|
|
31
|
-
<FlashList
|
|
32
|
-
data={items}
|
|
33
|
-
renderItem={({ item }) => <ItemCard item={item} />}
|
|
34
|
-
estimatedItemSize={100} // REQUIRED — measure actual item height first
|
|
35
|
-
keyExtractor={(item) => item.id}
|
|
36
|
-
getItemType={(item) => item.type} // multi-type optimization
|
|
37
|
-
/>
|
|
38
|
-
// ❌ NEVER: <ScrollView>{items.map(...)}</ScrollView> for lists
|
|
39
|
-
// ❌ NEVER: <FlatList> for perf-critical lists — FlashList is 5-10x faster
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
### Reanimated 3 — Worklet Animations (Required for 120Hz)
|
|
43
|
-
```tsx
|
|
44
|
-
import { useSharedValue, useAnimatedStyle, withSpring, withTiming, runOnJS } from 'react-native-reanimated';
|
|
45
|
-
|
|
46
|
-
// Shared values run on the UI thread — never on JS thread
|
|
47
|
-
const scale = useSharedValue(1);
|
|
48
|
-
const opacity = useSharedValue(0);
|
|
49
|
-
|
|
50
|
-
// Animated style — computed on UI thread (no bridge crossing)
|
|
51
|
-
const animatedStyle = useAnimatedStyle(() => ({
|
|
52
|
-
transform: [{ scale: scale.value }],
|
|
53
|
-
opacity: opacity.value,
|
|
54
|
-
}));
|
|
55
|
-
|
|
56
|
-
// Triggers
|
|
57
|
-
const onPress = () => {
|
|
58
|
-
scale.value = withSpring(0.95, { stiffness: 400, damping: 15 });
|
|
59
|
-
opacity.value = withTiming(1, { duration: 200 });
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
// Call JS function from worklet
|
|
63
|
-
const onComplete = () => runOnJS(setVisible)(true);
|
|
64
|
-
scale.value = withSpring(1, {}, onComplete);
|
|
65
|
-
|
|
66
|
-
// ❌ TRAP: Accessing shared value with .value inside useAnimatedStyle is fine — but inside a gesture handler callback, you need runOnJS to call React setState
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
### 120Hz Animation Rules
|
|
70
|
-
- ✅ Animate ONLY: `transform` (translateX/Y, scale, rotate), `opacity` — all GPU composited
|
|
71
|
-
- ❌ Never animate: `width`, `height`, `margin`, `padding`, `top/left/bottom/right` — causes layout recalc at 60 times per second → janky, battery draining
|
|
72
|
-
- ✅ Use `withSpring` for all UI interactions (feel alive) — `withTiming` only for intentional timed animations
|
|
73
|
-
- ✅ `Gesture.Pan()` / `Gesture.Tap()` from `react-native-gesture-handler` v2 (not `PanResponder`)
|
|
74
|
-
|
|
75
|
-
---
|
|
76
|
-
|
|
77
|
-
## Haptics
|
|
78
|
-
```tsx
|
|
79
|
-
import * as Haptics from 'expo-haptics';
|
|
80
|
-
// light → switch toggle, tap feedback
|
|
81
|
-
// medium → selection change, confirm
|
|
82
|
-
// heavy → destructive action, strong confirm
|
|
83
|
-
// notificationAsync('success' | 'warning' | 'error') → operation outcomes
|
|
84
|
-
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light); // tap, toggle
|
|
85
|
-
Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success); // save complete
|
|
86
|
-
// ❌ Never overuse — haptics must mean something
|
|
87
|
-
// ❌ Haptics not supported on Android emulators — test on device
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
---
|
|
91
|
-
|
|
92
|
-
## Safe Areas & Platform Layout
|
|
93
|
-
```tsx
|
|
94
|
-
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
95
|
-
import { Platform, StatusBar } from 'react-native';
|
|
96
|
-
|
|
97
|
-
function Screen() {
|
|
98
|
-
const insets = useSafeAreaInsets();
|
|
99
|
-
return (
|
|
100
|
-
<View style={{ paddingTop: insets.top, paddingBottom: insets.bottom }}>
|
|
101
|
-
{/* Content safe from Dynamic Island, home indicator, status bar */}
|
|
102
|
-
</View>
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
// Android status bar
|
|
106
|
-
const STATUS_BAR_HEIGHT = Platform.OS === 'android' ? StatusBar.currentHeight ?? 24 : 0;
|
|
107
|
-
|
|
108
|
-
// Foldable/tablet — dual pane
|
|
109
|
-
import { useWindowDimensions } from 'react-native';
|
|
110
|
-
function AdaptiveLayout() {
|
|
111
|
-
const { width } = useWindowDimensions();
|
|
112
|
-
const isTablet = width >= 600;
|
|
113
|
-
return isTablet ? <TwoPaneView /> : <SinglePaneView />;
|
|
114
|
-
}
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
---
|
|
118
|
-
|
|
119
|
-
## Touch Psychology & Thumb Zones
|
|
120
|
-
- **Thumb zone**: Bottom 40% of screen = primary actions, FABs, CTAs
|
|
121
|
-
- **Dead zone**: Top 25% = destructive/rare actions only
|
|
122
|
-
- **48px minimum hitbox**: Visual icon can be 24px, padding expands hitbox to 48px
|
|
123
|
-
```tsx
|
|
124
|
-
// Magnetic padding — visually small, touch-friendly
|
|
125
|
-
<TouchableOpacity style={{ padding: 12, margin: -4 }}>
|
|
126
|
-
<Icon size={24} />
|
|
127
|
-
</TouchableOpacity>
|
|
128
|
-
```
|
|
129
|
-
- **Coyote time**: Allow 100–150ms buffer after button intent registers before processing — prevents mis-taps
|
|
130
|
-
|
|
131
|
-
---
|
|
132
|
-
|
|
133
|
-
## Navigation (Expo Router / React Navigation)
|
|
134
|
-
```tsx
|
|
135
|
-
// Expo Router v3+ (file-based, recommended)
|
|
136
|
-
// app/(tabs)/_layout.tsx — tab navigator
|
|
137
|
-
// app/[id].tsx — dynamic segment
|
|
138
|
-
// app/(modal)/settings.tsx — modal group
|
|
139
|
-
|
|
140
|
-
// Stack navigation with gesture
|
|
141
|
-
import { Stack } from 'expo-router';
|
|
142
|
-
<Stack screenOptions={{ headerShown: false, animation: 'slide_from_right' }}>
|
|
143
|
-
<Stack.Screen name="(tabs)" />
|
|
144
|
-
<Stack.Screen name="[id]" options={{ presentation: 'modal' }} />
|
|
145
|
-
</Stack>
|
|
146
|
-
|
|
147
|
-
// Deep linking (Expo Router handles automatically via app.json scheme)
|
|
148
|
-
// ❌ TRAP: Don't use react-navigation Link for deep links in Expo Router — use expo-router Link
|
|
149
|
-
import { Link, useRouter } from 'expo-router';
|
|
150
|
-
const router = useRouter();
|
|
151
|
-
router.push('/user/42');
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
---
|
|
155
|
-
|
|
156
|
-
## On-Device AI UX Patterns
|
|
157
|
-
- **Zero-wait illusion**: When model runs → immediately show contextual skeleton/partial tokens
|
|
158
|
-
- **Progressive disclosure**: Low confidence → softer UI, soft colors, require confirmation
|
|
159
|
-
- **Streaming UI**: `useEffect` + SSE or `StreamingText` component appending tokens
|
|
160
|
-
- **Local models** (MediaPipe, Core ML, ONNX): always wrap in try/catch — device capability varies
|
|
161
|
-
|
|
162
|
-
---
|
|
163
|
-
|
|
164
|
-
## Color & Typography
|
|
165
|
-
```tsx
|
|
166
|
-
// OLED-safe dark mode
|
|
167
|
-
const colors = {
|
|
168
|
-
background: '#000000', // true black — OLED pixel off
|
|
169
|
-
surface: '#0A0A0A', // cards
|
|
170
|
-
surfaceAlt: '#121212', // elevated surfaces
|
|
171
|
-
border: '#1F1F1F',
|
|
172
|
-
text: '#FFFFFF',
|
|
173
|
-
textMuted: '#8E8E93', // iOS system gray
|
|
174
|
-
};
|
|
175
|
-
// Dynamic type (iOS) — always use system font with scalesWithContentSizeCategory
|
|
176
|
-
import { Text } from 'react-native';
|
|
177
|
-
<Text style={{ fontSize: 16, fontFamily: Platform.OS === 'ios' ? 'System' : 'Roboto' }}>
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
---
|
|
181
|
-
|
|
182
|
-
## Performance Checklist
|
|
183
|
-
| Issue | Fix |
|
|
184
|
-
|-------|-----|
|
|
185
|
-
| JS thread jank | Move ALL animations to Reanimated worklets |
|
|
186
|
-
| Slow list | Replace ScrollView/FlatList with FlashList |
|
|
187
|
-
| Image flicker | `Image` from `expo-image` (faster cache, blurhash) |
|
|
188
|
-
| Re-render cascade | `React.memo` + stable callbacks + Zustand selectors |
|
|
189
|
-
| Large bundle | Dynamic imports + Metro tree shaking |
|
|
190
|
-
| Memory leak | `useEffect` cleanup + cancel animation on unmount |
|
|
191
|
-
|
|
192
|
-
```tsx
|
|
193
|
-
// Cancel animation on unmount
|
|
194
|
-
useEffect(() => {
|
|
195
|
-
opacity.value = withTiming(1);
|
|
196
|
-
return () => cancelAnimation(opacity); // ← critical
|
|
197
|
-
}, []);
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
---
|
|
201
|
-
|
|
202
|
-
## iOS-Specific
|
|
203
|
-
- **BlurView**: Use `@react-native-community/blur` for frosted glass nav bars/modals
|
|
204
|
-
- **SF Symbols**: Use `@expo/vector-icons/Ionicons` for system-native icons
|
|
205
|
-
- **Haptics**: `expo-haptics` — rich feedback on iOS, limited on Android
|
|
206
|
-
- **Dynamic Island**: Check `insets.top > 50` for Dynamic Island devices
|
|
207
|
-
- **Sheet presentations**: `presentation: 'formSheet'` in Expo Router for iOS bottom sheet native feel
|
|
208
|
-
|
|
209
|
-
## Android-Specific
|
|
210
|
-
- **Material You**: Use `react-native-paper` for M3 dynamic color theming
|
|
211
|
-
- **Edge-to-edge**: Set `android:windowLayoutInDisplayCutoutMode="shortEdges"` in AndroidManifest
|
|
212
|
-
- **Back gesture prediction**: Wrap routes in `GestureHandlerRootView` at root
|
|
213
|
-
- **Splash**: Use `expo-splash-screen` — never hardcode a delay
|
|
1
|
+
---
|
|
2
|
+
name: mobile-design
|
|
3
|
+
description: Mobile-first design for iOS, Android, Foldables, React Native, Flutter. Touch interaction, haptics, 120Hz performance, on-device AI, spatial UI, Reanimated 3. Use when building mobile UI, animations, or cross-platform apps.
|
|
4
|
+
allowed-tools: Read, Write, Edit, Glob, Grep
|
|
5
|
+
version: 3.1.0
|
|
6
|
+
last-updated: 2026-04-06
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Mobile Design — Dense Reference
|
|
10
|
+
|
|
11
|
+
## Hallucination Traps (Read First)
|
|
12
|
+
- ❌ `Animated.View` for any animation → ✅ `Reanimated 3` worklets (Animated API is legacy, runs on JS thread)
|
|
13
|
+
- ❌ `ScrollView` for lists → ✅ `FlashList` (Shopify) — ScrollView renders ALL items at once
|
|
14
|
+
- ❌ `estimatedItemSize` optional in FlashList → ✅ **REQUIRED** or you get 0-height items
|
|
15
|
+
- ❌ White backgrounds (`#FFFFFF`) → ✅ OLED: `#000000` true black; off-white: `#FAFAFA`
|
|
16
|
+
- ❌ Linear animations (`easing: linear`) → ✅ Spring physics (`stiffness`, `damping`)
|
|
17
|
+
- ❌ Touch targets < 48px → ✅ Min 48px hitbox (visual size can be smaller via padding)
|
|
18
|
+
- ❌ `useAnimatedStyle` in worklet without `'worklet'` directive → crashes on native thread
|
|
19
|
+
- ❌ iOS: `useSafeAreaInsets()` optional → ✅ Required — screen content goes under dynamic island/home indicator
|
|
20
|
+
- ❌ Android: hardcoded status bar height (24dp) → ✅ `StatusBar.currentHeight` (varies per device)
|
|
21
|
+
- ❌ Platform-specific code with `if (platform === 'ios')` scattered everywhere → ✅ centralize in platform/ files
|
|
22
|
+
- ❌ `console.log` in production → ✅ blocks JS thread — remove before release
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## React Native Performance
|
|
27
|
+
|
|
28
|
+
### FlashList (Required for Lists)
|
|
29
|
+
```tsx
|
|
30
|
+
import { FlashList } from "@shopify/flash-list";
|
|
31
|
+
<FlashList
|
|
32
|
+
data={items}
|
|
33
|
+
renderItem={({ item }) => <ItemCard item={item} />}
|
|
34
|
+
estimatedItemSize={100} // REQUIRED — measure actual item height first
|
|
35
|
+
keyExtractor={(item) => item.id}
|
|
36
|
+
getItemType={(item) => item.type} // multi-type optimization
|
|
37
|
+
/>
|
|
38
|
+
// ❌ NEVER: <ScrollView>{items.map(...)}</ScrollView> for lists
|
|
39
|
+
// ❌ NEVER: <FlatList> for perf-critical lists — FlashList is 5-10x faster
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Reanimated 3 — Worklet Animations (Required for 120Hz)
|
|
43
|
+
```tsx
|
|
44
|
+
import { useSharedValue, useAnimatedStyle, withSpring, withTiming, runOnJS } from 'react-native-reanimated';
|
|
45
|
+
|
|
46
|
+
// Shared values run on the UI thread — never on JS thread
|
|
47
|
+
const scale = useSharedValue(1);
|
|
48
|
+
const opacity = useSharedValue(0);
|
|
49
|
+
|
|
50
|
+
// Animated style — computed on UI thread (no bridge crossing)
|
|
51
|
+
const animatedStyle = useAnimatedStyle(() => ({
|
|
52
|
+
transform: [{ scale: scale.value }],
|
|
53
|
+
opacity: opacity.value,
|
|
54
|
+
}));
|
|
55
|
+
|
|
56
|
+
// Triggers
|
|
57
|
+
const onPress = () => {
|
|
58
|
+
scale.value = withSpring(0.95, { stiffness: 400, damping: 15 });
|
|
59
|
+
opacity.value = withTiming(1, { duration: 200 });
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
// Call JS function from worklet
|
|
63
|
+
const onComplete = () => runOnJS(setVisible)(true);
|
|
64
|
+
scale.value = withSpring(1, {}, onComplete);
|
|
65
|
+
|
|
66
|
+
// ❌ TRAP: Accessing shared value with .value inside useAnimatedStyle is fine — but inside a gesture handler callback, you need runOnJS to call React setState
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### 120Hz Animation Rules
|
|
70
|
+
- ✅ Animate ONLY: `transform` (translateX/Y, scale, rotate), `opacity` — all GPU composited
|
|
71
|
+
- ❌ Never animate: `width`, `height`, `margin`, `padding`, `top/left/bottom/right` — causes layout recalc at 60 times per second → janky, battery draining
|
|
72
|
+
- ✅ Use `withSpring` for all UI interactions (feel alive) — `withTiming` only for intentional timed animations
|
|
73
|
+
- ✅ `Gesture.Pan()` / `Gesture.Tap()` from `react-native-gesture-handler` v2 (not `PanResponder`)
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## Haptics
|
|
78
|
+
```tsx
|
|
79
|
+
import * as Haptics from 'expo-haptics';
|
|
80
|
+
// light → switch toggle, tap feedback
|
|
81
|
+
// medium → selection change, confirm
|
|
82
|
+
// heavy → destructive action, strong confirm
|
|
83
|
+
// notificationAsync('success' | 'warning' | 'error') → operation outcomes
|
|
84
|
+
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light); // tap, toggle
|
|
85
|
+
Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success); // save complete
|
|
86
|
+
// ❌ Never overuse — haptics must mean something
|
|
87
|
+
// ❌ Haptics not supported on Android emulators — test on device
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Safe Areas & Platform Layout
|
|
93
|
+
```tsx
|
|
94
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
95
|
+
import { Platform, StatusBar } from 'react-native';
|
|
96
|
+
|
|
97
|
+
function Screen() {
|
|
98
|
+
const insets = useSafeAreaInsets();
|
|
99
|
+
return (
|
|
100
|
+
<View style={{ paddingTop: insets.top, paddingBottom: insets.bottom }}>
|
|
101
|
+
{/* Content safe from Dynamic Island, home indicator, status bar */}
|
|
102
|
+
</View>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
// Android status bar
|
|
106
|
+
const STATUS_BAR_HEIGHT = Platform.OS === 'android' ? StatusBar.currentHeight ?? 24 : 0;
|
|
107
|
+
|
|
108
|
+
// Foldable/tablet — dual pane
|
|
109
|
+
import { useWindowDimensions } from 'react-native';
|
|
110
|
+
function AdaptiveLayout() {
|
|
111
|
+
const { width } = useWindowDimensions();
|
|
112
|
+
const isTablet = width >= 600;
|
|
113
|
+
return isTablet ? <TwoPaneView /> : <SinglePaneView />;
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## Touch Psychology & Thumb Zones
|
|
120
|
+
- **Thumb zone**: Bottom 40% of screen = primary actions, FABs, CTAs
|
|
121
|
+
- **Dead zone**: Top 25% = destructive/rare actions only
|
|
122
|
+
- **48px minimum hitbox**: Visual icon can be 24px, padding expands hitbox to 48px
|
|
123
|
+
```tsx
|
|
124
|
+
// Magnetic padding — visually small, touch-friendly
|
|
125
|
+
<TouchableOpacity style={{ padding: 12, margin: -4 }}>
|
|
126
|
+
<Icon size={24} />
|
|
127
|
+
</TouchableOpacity>
|
|
128
|
+
```
|
|
129
|
+
- **Coyote time**: Allow 100–150ms buffer after button intent registers before processing — prevents mis-taps
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## Navigation (Expo Router / React Navigation)
|
|
134
|
+
```tsx
|
|
135
|
+
// Expo Router v3+ (file-based, recommended)
|
|
136
|
+
// app/(tabs)/_layout.tsx — tab navigator
|
|
137
|
+
// app/[id].tsx — dynamic segment
|
|
138
|
+
// app/(modal)/settings.tsx — modal group
|
|
139
|
+
|
|
140
|
+
// Stack navigation with gesture
|
|
141
|
+
import { Stack } from 'expo-router';
|
|
142
|
+
<Stack screenOptions={{ headerShown: false, animation: 'slide_from_right' }}>
|
|
143
|
+
<Stack.Screen name="(tabs)" />
|
|
144
|
+
<Stack.Screen name="[id]" options={{ presentation: 'modal' }} />
|
|
145
|
+
</Stack>
|
|
146
|
+
|
|
147
|
+
// Deep linking (Expo Router handles automatically via app.json scheme)
|
|
148
|
+
// ❌ TRAP: Don't use react-navigation Link for deep links in Expo Router — use expo-router Link
|
|
149
|
+
import { Link, useRouter } from 'expo-router';
|
|
150
|
+
const router = useRouter();
|
|
151
|
+
router.push('/user/42');
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## On-Device AI UX Patterns
|
|
157
|
+
- **Zero-wait illusion**: When model runs → immediately show contextual skeleton/partial tokens
|
|
158
|
+
- **Progressive disclosure**: Low confidence → softer UI, soft colors, require confirmation
|
|
159
|
+
- **Streaming UI**: `useEffect` + SSE or `StreamingText` component appending tokens
|
|
160
|
+
- **Local models** (MediaPipe, Core ML, ONNX): always wrap in try/catch — device capability varies
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## Color & Typography
|
|
165
|
+
```tsx
|
|
166
|
+
// OLED-safe dark mode
|
|
167
|
+
const colors = {
|
|
168
|
+
background: '#000000', // true black — OLED pixel off
|
|
169
|
+
surface: '#0A0A0A', // cards
|
|
170
|
+
surfaceAlt: '#121212', // elevated surfaces
|
|
171
|
+
border: '#1F1F1F',
|
|
172
|
+
text: '#FFFFFF',
|
|
173
|
+
textMuted: '#8E8E93', // iOS system gray
|
|
174
|
+
};
|
|
175
|
+
// Dynamic type (iOS) — always use system font with scalesWithContentSizeCategory
|
|
176
|
+
import { Text } from 'react-native';
|
|
177
|
+
<Text style={{ fontSize: 16, fontFamily: Platform.OS === 'ios' ? 'System' : 'Roboto' }}>
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## Performance Checklist
|
|
183
|
+
| Issue | Fix |
|
|
184
|
+
|-------|-----|
|
|
185
|
+
| JS thread jank | Move ALL animations to Reanimated worklets |
|
|
186
|
+
| Slow list | Replace ScrollView/FlatList with FlashList |
|
|
187
|
+
| Image flicker | `Image` from `expo-image` (faster cache, blurhash) |
|
|
188
|
+
| Re-render cascade | `React.memo` + stable callbacks + Zustand selectors |
|
|
189
|
+
| Large bundle | Dynamic imports + Metro tree shaking |
|
|
190
|
+
| Memory leak | `useEffect` cleanup + cancel animation on unmount |
|
|
191
|
+
|
|
192
|
+
```tsx
|
|
193
|
+
// Cancel animation on unmount
|
|
194
|
+
useEffect(() => {
|
|
195
|
+
opacity.value = withTiming(1);
|
|
196
|
+
return () => cancelAnimation(opacity); // ← critical
|
|
197
|
+
}, []);
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
## iOS-Specific
|
|
203
|
+
- **BlurView**: Use `@react-native-community/blur` for frosted glass nav bars/modals
|
|
204
|
+
- **SF Symbols**: Use `@expo/vector-icons/Ionicons` for system-native icons
|
|
205
|
+
- **Haptics**: `expo-haptics` — rich feedback on iOS, limited on Android
|
|
206
|
+
- **Dynamic Island**: Check `insets.top > 50` for Dynamic Island devices
|
|
207
|
+
- **Sheet presentations**: `presentation: 'formSheet'` in Expo Router for iOS bottom sheet native feel
|
|
208
|
+
|
|
209
|
+
## Android-Specific
|
|
210
|
+
- **Material You**: Use `react-native-paper` for M3 dynamic color theming
|
|
211
|
+
- **Edge-to-edge**: Set `android:windowLayoutInDisplayCutoutMode="shortEdges"` in AndroidManifest
|
|
212
|
+
- **Back gesture prediction**: Wrap routes in `GestureHandlerRootView` at root
|
|
213
|
+
- **Splash**: Use `expo-splash-screen` — never hardcode a delay
|
|
214
214
|
|
|
215
215
|
|
|
216
216
|
---
|
|
@@ -252,4 +252,12 @@ Review these questions before confirming output:
|
|
|
252
252
|
|
|
253
253
|
**CRITICAL:** You must follow a strict "evidence-based closeout" state machine.
|
|
254
254
|
- ❌ **Forbidden:** Declaring a task complete because the output "looks correct."
|
|
255
|
-
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
255
|
+
- ✅ **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing tests, compile success, or equivalent proof) that your output works as intended.
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
## Pre-Flight Checklist
|
|
259
|
+
- [ ] Have I reviewed the user's specific constraints and requests?
|
|
260
|
+
- [ ] Have I checked the environment for relevant existing implementations?
|
|
261
|
+
|
|
262
|
+
## VBC Protocol (Verification-Before-Completion)
|
|
263
|
+
You MUST verify existing code signatures and variables before attempting to modify or call them. No hallucination is permitted.
|