@ranimontagna/agent-toolkit 0.1.5 → 0.1.6
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/README.md +42 -8
- package/package.json +1 -1
- package/skills/frontend/react/react-patterns/LICENSE +21 -0
- package/skills/frontend/react/react-patterns/NOTICE.md +11 -0
- package/skills/frontend/react/react-patterns/SKILL.md +341 -0
- package/skills/frontend/react/react-performance/LICENSE +21 -0
- package/skills/frontend/react/react-performance/NOTICE.md +11 -0
- package/skills/frontend/react/react-performance/SKILL.md +574 -0
- package/skills/frontend/react/react-testing/LICENSE +21 -0
- package/skills/frontend/react/react-testing/NOTICE.md +11 -0
- package/skills/frontend/react/react-testing/SKILL.md +423 -0
- package/skills/frontend/react-native/react-native-expert/LICENSE +21 -0
- package/skills/frontend/react-native/react-native-expert/NOTICE.md +11 -0
- package/skills/frontend/react-native/react-native-expert/SKILL.md +187 -0
- package/skills/frontend/react-native/react-native-expert/references/expo-router.md +187 -0
- package/skills/frontend/react-native/react-native-expert/references/list-optimization.md +204 -0
- package/skills/frontend/react-native/react-native-expert/references/platform-handling.md +188 -0
- package/skills/frontend/react-native/react-native-expert/references/project-structure.md +171 -0
- package/skills/frontend/react-native/react-native-expert/references/storage-hooks.md +173 -0
- package/skills/frontend/react-native/react-native-unistyles-v3/LICENSE +21 -0
- package/skills/frontend/react-native/react-native-unistyles-v3/NOTICE.md +11 -0
- package/skills/frontend/react-native/react-native-unistyles-v3/SKILL.md +159 -0
- package/skills/frontend/react-native/react-native-unistyles-v3/references/api-reference.md +495 -0
- package/skills/frontend/react-native/react-native-unistyles-v3/references/common-issues.md +389 -0
- package/skills/frontend/react-native/react-native-unistyles-v3/references/setup-guide.md +217 -0
- package/skills/frontend/react-native/react-native-unistyles-v3/references/styling-patterns.md +705 -0
- package/skills/frontend/react-native/react-native-unistyles-v3/references/third-party-integration.md +318 -0
package/skills/frontend/react-native/react-native-unistyles-v3/references/third-party-integration.md
ADDED
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
# Third-Party Integration
|
|
2
|
+
|
|
3
|
+
How to integrate Unistyles v3 with third-party libraries, custom components, and build tools.
|
|
4
|
+
|
|
5
|
+
## withUnistyles HOC
|
|
6
|
+
|
|
7
|
+
For third-party components that need theme-derived **non-style props** (e.g., `color`, `size`, `tintColor`).
|
|
8
|
+
|
|
9
|
+
### Basic wrapping
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import { withUnistyles } from 'react-native-unistyles'
|
|
13
|
+
import { Button } from 'some-ui-library'
|
|
14
|
+
|
|
15
|
+
const UniButton = withUnistyles(Button, (theme, rt) => ({
|
|
16
|
+
color: theme.colors.primary,
|
|
17
|
+
size: rt.screen.width > 400 ? 'large' : 'small',
|
|
18
|
+
}))
|
|
19
|
+
|
|
20
|
+
// Usage — mapped props are applied automatically, can be overridden
|
|
21
|
+
<UniButton title="Press me" />
|
|
22
|
+
<UniButton title="Override" color="red" /> // overrides mapped color
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Static mappings vs uniProps
|
|
26
|
+
|
|
27
|
+
The second argument to `withUnistyles` maps theme/runtime values to props. These are applied as **defaults** — the consumer can override them:
|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
const UniIcon = withUnistyles(Icon, (theme) => ({
|
|
31
|
+
color: theme.colors.icon,
|
|
32
|
+
size: 24,
|
|
33
|
+
}))
|
|
34
|
+
|
|
35
|
+
// theme.colors.icon is used by default
|
|
36
|
+
<UniIcon name="home" />
|
|
37
|
+
|
|
38
|
+
// Consumer overrides color
|
|
39
|
+
<UniIcon name="home" color="red" />
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Ref forwarding
|
|
43
|
+
|
|
44
|
+
Refs are forwarded automatically:
|
|
45
|
+
|
|
46
|
+
```tsx
|
|
47
|
+
const UniInput = withUnistyles(TextInput, (theme) => ({
|
|
48
|
+
placeholderTextColor: theme.colors.placeholder,
|
|
49
|
+
selectionColor: theme.colors.primary,
|
|
50
|
+
}))
|
|
51
|
+
|
|
52
|
+
const inputRef = useRef<TextInput>(null)
|
|
53
|
+
<UniInput ref={inputRef} placeholder="Type here" />
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### style and contentContainerStyle auto-processing
|
|
57
|
+
|
|
58
|
+
`withUnistyles` automatically processes `style` and `contentContainerStyle` props. You can pass Unistyles styles directly:
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
const UniScrollView = withUnistyles(ScrollView)
|
|
62
|
+
|
|
63
|
+
<UniScrollView
|
|
64
|
+
style={styles.scroll}
|
|
65
|
+
contentContainerStyle={styles.content}
|
|
66
|
+
/>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Babel Plugin: autoProcessPaths
|
|
72
|
+
|
|
73
|
+
By default, the Babel plugin only processes files inside the `root` directory. For files outside `root` (e.g., shared packages in a monorepo), add their paths:
|
|
74
|
+
|
|
75
|
+
```js
|
|
76
|
+
// babel.config.js
|
|
77
|
+
module.exports = {
|
|
78
|
+
plugins: [
|
|
79
|
+
['react-native-unistyles/plugin', {
|
|
80
|
+
root: 'src',
|
|
81
|
+
autoProcessPaths: [
|
|
82
|
+
'../packages/shared-ui/src',
|
|
83
|
+
'../packages/design-system/src',
|
|
84
|
+
],
|
|
85
|
+
}]
|
|
86
|
+
]
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**Important:** Paths are relative to the project root (where babel.config.js lives).
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## Babel Plugin: autoProcessImports
|
|
95
|
+
|
|
96
|
+
Process files that import from custom package names (useful for internal packages that re-export components):
|
|
97
|
+
|
|
98
|
+
```js
|
|
99
|
+
// babel.config.js
|
|
100
|
+
module.exports = {
|
|
101
|
+
plugins: [
|
|
102
|
+
['react-native-unistyles/plugin', {
|
|
103
|
+
root: 'src',
|
|
104
|
+
autoProcessImports: ['@myorg/ui', '@myorg/shared-components'],
|
|
105
|
+
}]
|
|
106
|
+
]
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
This tells the plugin: "If a file imports from `@myorg/ui`, process the components in that file the same way as standard React Native components."
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## Babel Plugin: autoRemapImports
|
|
115
|
+
|
|
116
|
+
Map exotic component imports to Unistyles component factories. Useful when a library exports components with non-standard names that the plugin can't detect:
|
|
117
|
+
|
|
118
|
+
```js
|
|
119
|
+
// babel.config.js
|
|
120
|
+
module.exports = {
|
|
121
|
+
plugins: [
|
|
122
|
+
['react-native-unistyles/plugin', {
|
|
123
|
+
root: 'src',
|
|
124
|
+
autoRemapImports: {
|
|
125
|
+
'@expo/vector-icons': {
|
|
126
|
+
'MaterialIcons': 'Text', // treat as Text factory
|
|
127
|
+
'FontAwesome': 'Text',
|
|
128
|
+
},
|
|
129
|
+
'react-native-svg': {
|
|
130
|
+
'Svg': 'View', // treat as View factory
|
|
131
|
+
'Circle': 'View',
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
}]
|
|
135
|
+
]
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## React Compiler
|
|
142
|
+
|
|
143
|
+
### Plugin ordering
|
|
144
|
+
|
|
145
|
+
The Unistyles Babel plugin **MUST come BEFORE** React Compiler:
|
|
146
|
+
|
|
147
|
+
```js
|
|
148
|
+
// babel.config.js
|
|
149
|
+
module.exports = {
|
|
150
|
+
plugins: [
|
|
151
|
+
['react-native-unistyles/plugin', { root: 'src' }], // FIRST
|
|
152
|
+
'babel-plugin-react-compiler', // SECOND
|
|
153
|
+
]
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### useVariants incompatibility
|
|
158
|
+
|
|
159
|
+
`styles.useVariants()` may break with React Compiler's `panicThreshold: 'all_errors'` setting ([#1002](https://github.com/jpudysz/react-native-unistyles/issues/1002)). This is a known issue planned for fix in v4.
|
|
160
|
+
|
|
161
|
+
**Workaround:** Use `panicThreshold: 'none'` (default) or `'critical_errors'` instead of `'all_errors'`.
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## Reanimated
|
|
166
|
+
|
|
167
|
+
### Version requirements
|
|
168
|
+
|
|
169
|
+
- `react-native-reanimated` 3.17.3+ **or** 4.0.0-beta.3+
|
|
170
|
+
|
|
171
|
+
### CSS transitions workaround
|
|
172
|
+
|
|
173
|
+
When using Reanimated's CSS transitions, theme-dependent colors may become stale after theme changes. Force re-mount with `key`:
|
|
174
|
+
|
|
175
|
+
```tsx
|
|
176
|
+
const { rt } = useUnistyles()
|
|
177
|
+
|
|
178
|
+
// key forces re-mount when theme changes, refreshing CSS transitions
|
|
179
|
+
<Animated.View
|
|
180
|
+
key={rt.themeName}
|
|
181
|
+
style={[styles.card, { transition: [{ property: 'backgroundColor', duration: 300 }] }]}
|
|
182
|
+
/>
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
See [#1007](https://github.com/jpudysz/react-native-unistyles/issues/1007).
|
|
186
|
+
|
|
187
|
+
### Array syntax for combining styles
|
|
188
|
+
|
|
189
|
+
When combining Reanimated animated styles with Unistyles styles, always use array syntax:
|
|
190
|
+
|
|
191
|
+
```tsx
|
|
192
|
+
const animatedStyle = useAnimatedStyle(() => ({
|
|
193
|
+
transform: [{ translateY: offset.value }],
|
|
194
|
+
}))
|
|
195
|
+
|
|
196
|
+
// CORRECT
|
|
197
|
+
<Animated.View style={[styles.container, animatedStyle]} />
|
|
198
|
+
|
|
199
|
+
// WRONG — breaks proxy binding
|
|
200
|
+
<Animated.View style={{ ...styles.container, ...animatedStyle }} />
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
## react-native-edge-to-edge
|
|
206
|
+
|
|
207
|
+
Required for Android to get proper inset values. Install and use `rt.insets` in styles:
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
npm install react-native-edge-to-edge
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
```tsx
|
|
214
|
+
const styles = StyleSheet.create((theme, rt) => ({
|
|
215
|
+
header: {
|
|
216
|
+
paddingTop: rt.insets.top,
|
|
217
|
+
},
|
|
218
|
+
bottomBar: {
|
|
219
|
+
paddingBottom: rt.insets.bottom,
|
|
220
|
+
},
|
|
221
|
+
}))
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
This replaces `react-native-safe-area-context` for most use cases. No `<SafeAreaProvider>` or `useSafeAreaInsets()` needed.
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
## FlatList Alternatives
|
|
229
|
+
|
|
230
|
+
`FlatList` has a known crash on orientation change ([#803](https://github.com/jpudysz/react-native-unistyles/issues/803)) — this is a React Native core issue, not Unistyles-specific.
|
|
231
|
+
|
|
232
|
+
**Recommended alternatives:**
|
|
233
|
+
- [FlashList](https://github.com/Shopify/flash-list) by Shopify
|
|
234
|
+
- [Legend List](https://github.com/LegendApp/legend-list) by LegendApp
|
|
235
|
+
|
|
236
|
+
Both work correctly with Unistyles orientation changes.
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
## react-native-safe-area-context
|
|
241
|
+
|
|
242
|
+
Mostly **replaced** by Unistyles' built-in `rt.insets`:
|
|
243
|
+
|
|
244
|
+
| Before (safe-area-context) | After (Unistyles v3) |
|
|
245
|
+
|---------------------------|----------------------|
|
|
246
|
+
| `<SafeAreaProvider>` | Not needed |
|
|
247
|
+
| `useSafeAreaInsets()` | `rt.insets` in StyleSheet.create |
|
|
248
|
+
| `<SafeAreaView>` | Use `rt.insets.top` / `rt.insets.bottom` in styles |
|
|
249
|
+
|
|
250
|
+
```tsx
|
|
251
|
+
// Before
|
|
252
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
253
|
+
const Component = () => {
|
|
254
|
+
const insets = useSafeAreaInsets()
|
|
255
|
+
return <View style={{ paddingTop: insets.top }} />
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// After
|
|
259
|
+
const styles = StyleSheet.create((theme, rt) => ({
|
|
260
|
+
container: { paddingTop: rt.insets.top }
|
|
261
|
+
}))
|
|
262
|
+
const Component = () => <View style={styles.container} />
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
## Design System Libraries
|
|
268
|
+
|
|
269
|
+
For design system libraries (Paper, Tamagui, NativeBase, etc.) that have their own theming:
|
|
270
|
+
|
|
271
|
+
### Approach 1: Sync themes
|
|
272
|
+
|
|
273
|
+
Keep the library's theme in sync with Unistyles:
|
|
274
|
+
|
|
275
|
+
```tsx
|
|
276
|
+
import { UnistylesRuntime, StyleSheet } from 'react-native-unistyles'
|
|
277
|
+
|
|
278
|
+
// Listen for Unistyles theme changes and sync
|
|
279
|
+
StyleSheet.addChangeListener((deps) => {
|
|
280
|
+
if (deps.includes(UnistyleDependency.Theme)) {
|
|
281
|
+
const theme = UnistylesRuntime.getTheme()
|
|
282
|
+
// Update external library's theme
|
|
283
|
+
externalLibrary.setTheme(mapToExternalTheme(theme))
|
|
284
|
+
}
|
|
285
|
+
})
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### Approach 2: withUnistyles wrapper
|
|
289
|
+
|
|
290
|
+
Wrap library components that need theme-derived props:
|
|
291
|
+
|
|
292
|
+
```tsx
|
|
293
|
+
import { withUnistyles } from 'react-native-unistyles'
|
|
294
|
+
import { Button as PaperButton } from 'react-native-paper'
|
|
295
|
+
|
|
296
|
+
const UniPaperButton = withUnistyles(PaperButton, (theme) => ({
|
|
297
|
+
buttonColor: theme.colors.primary,
|
|
298
|
+
textColor: theme.colors.onPrimary,
|
|
299
|
+
}))
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
### Approach 3: useUnistyles for complex cases
|
|
303
|
+
|
|
304
|
+
When you need full control:
|
|
305
|
+
|
|
306
|
+
```tsx
|
|
307
|
+
import { useUnistyles } from 'react-native-unistyles'
|
|
308
|
+
|
|
309
|
+
const MyScreen = () => {
|
|
310
|
+
const { theme } = useUnistyles()
|
|
311
|
+
|
|
312
|
+
return (
|
|
313
|
+
<ExternalProvider theme={mapToExternal(theme)}>
|
|
314
|
+
<Content />
|
|
315
|
+
</ExternalProvider>
|
|
316
|
+
)
|
|
317
|
+
}
|
|
318
|
+
```
|