@snap/valdi 1.0.7 → 1.0.11

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.
Files changed (170) hide show
  1. package/.bootstrap/modules/{ios_android_bridge_module → polyglot_bridge_module}/BUILD.bazel.template +16 -1
  2. package/.bootstrap/modules/polyglot_bridge_module/web/Calculator.ts +11 -0
  3. package/.bootstrap/modules/polyglot_bridge_module/web/tsconfig.json +16 -0
  4. package/.bootstrap/modules/polyglot_view_module/BUILD.bazel.template +75 -0
  5. package/.bootstrap/modules/polyglot_view_module/android/PolyglotNativeView.kt.template +41 -0
  6. package/.bootstrap/modules/polyglot_view_module/android/PolyglotNativeViewAttributesBinder.kt.template +17 -0
  7. package/.bootstrap/modules/polyglot_view_module/ios/SCPolyglotView.h +8 -0
  8. package/.bootstrap/modules/polyglot_view_module/ios/SCPolyglotView.m +23 -0
  9. package/.bootstrap/modules/polyglot_view_module/macos/SCPolyglotView.h +8 -0
  10. package/.bootstrap/modules/polyglot_view_module/macos/SCPolyglotView.m +23 -0
  11. package/.bootstrap/modules/polyglot_view_module/src/PolyglotCustomView.tsx.template +23 -0
  12. package/.bootstrap/modules/polyglot_view_module/web/PolyglotWeb.ts.template +30 -0
  13. package/.bootstrap/modules/polyglot_view_module/web/tsconfig.json +16 -0
  14. package/.metadata/AGENTS.md.template +8 -274
  15. package/.metadata/skill-reference.tsx.template +8 -0
  16. package/.metadata/skill-tests-BUILD.bazel.template +21 -0
  17. package/.metadata/skill-tests-README.md.template +17 -0
  18. package/.metadata/skill.md.template +27 -0
  19. package/README.md +12 -3
  20. package/bundled-skills/CONTRIBUTING_SKILLS.md +74 -0
  21. package/bundled-skills/registry.json +21 -0
  22. package/bundled-skills/skills/valdi-android/skill.md +89 -0
  23. package/bundled-skills/skills/valdi-async/skill.md +246 -0
  24. package/bundled-skills/skills/valdi-async/tests/BUILD.bazel +19 -0
  25. package/bundled-skills/skills/valdi-async/tests/README.md +25 -0
  26. package/bundled-skills/skills/valdi-async/tests/src/reference.tsx +210 -0
  27. package/bundled-skills/skills/valdi-async/tests/tsconfig.json +1 -0
  28. package/bundled-skills/skills/valdi-bazel/skill.md +141 -0
  29. package/bundled-skills/skills/valdi-compiler/skill.md +108 -0
  30. package/bundled-skills/skills/valdi-component-tests/skill.md +430 -0
  31. package/bundled-skills/skills/valdi-component-tests/tests/BUILD.bazel +24 -0
  32. package/bundled-skills/skills/valdi-component-tests/tests/README.md +35 -0
  33. package/bundled-skills/skills/valdi-component-tests/tests/src/ProfileCard.tsx +38 -0
  34. package/bundled-skills/skills/valdi-component-tests/tests/test/ProfileCardTest.spec.tsx +107 -0
  35. package/bundled-skills/skills/valdi-component-tests/tests/tsconfig.json +1 -0
  36. package/bundled-skills/skills/valdi-cpp-runtime/skill.md +103 -0
  37. package/bundled-skills/skills/valdi-custom-view/skill.md +64 -0
  38. package/bundled-skills/skills/valdi-inspect/skill.md +199 -0
  39. package/bundled-skills/skills/valdi-ios/skill.md +93 -0
  40. package/bundled-skills/skills/valdi-migrate/skill.md +175 -0
  41. package/bundled-skills/skills/valdi-migrate/tests/BUILD.bazel +23 -0
  42. package/bundled-skills/skills/valdi-migrate/tests/README.md +70 -0
  43. package/bundled-skills/skills/valdi-migrate/tests/check_antipatterns.py +89 -0
  44. package/bundled-skills/skills/valdi-migrate/tests/compose_example.kt +94 -0
  45. package/bundled-skills/skills/valdi-migrate/tests/flutter_example.dart +129 -0
  46. package/bundled-skills/skills/valdi-migrate/tests/react_example.tsx +98 -0
  47. package/bundled-skills/skills/valdi-migrate/tests/src/expected_valdi.tsx +267 -0
  48. package/bundled-skills/skills/valdi-migrate/tests/tsconfig.json +3 -0
  49. package/bundled-skills/skills/valdi-overview/skill.md +63 -0
  50. package/bundled-skills/skills/valdi-perf/skill.md +197 -0
  51. package/bundled-skills/skills/valdi-perf/tests/BUILD.bazel +19 -0
  52. package/bundled-skills/skills/valdi-perf/tests/README.md +26 -0
  53. package/bundled-skills/skills/valdi-perf/tests/src/reference.tsx +202 -0
  54. package/bundled-skills/skills/valdi-perf/tests/tsconfig.json +1 -0
  55. package/bundled-skills/skills/valdi-polyglot-module/skill.md +124 -0
  56. package/bundled-skills/skills/valdi-profile/skill.md +126 -0
  57. package/bundled-skills/skills/valdi-setup/skill.md +129 -0
  58. package/bundled-skills/skills/valdi-testing/skill.md +65 -0
  59. package/bundled-skills/skills/valdi-tsx/skill.md +385 -0
  60. package/bundled-skills/skills/valdi-tsx/tests/BUILD.bazel +19 -0
  61. package/bundled-skills/skills/valdi-tsx/tests/README.md +29 -0
  62. package/bundled-skills/skills/valdi-tsx/tests/src/reference.tsx +173 -0
  63. package/bundled-skills/skills/valdi-tsx/tests/tsconfig.json +1 -0
  64. package/dist/commands/bootstrap.js +0 -7
  65. package/dist/commands/inspect.js +16 -0
  66. package/dist/commands/inspect_commands/contexts.js +55 -0
  67. package/dist/commands/inspect_commands/devices.js +53 -0
  68. package/dist/commands/inspect_commands/heap.js +59 -0
  69. package/dist/commands/inspect_commands/select.js +43 -0
  70. package/dist/commands/inspect_commands/snapshot.js +64 -0
  71. package/dist/commands/inspect_commands/status.js +68 -0
  72. package/dist/commands/inspect_commands/tree.js +86 -0
  73. package/dist/commands/newModule.js +10 -14
  74. package/dist/commands/profile.js +16 -0
  75. package/dist/commands/profile_commands/capture.js +106 -0
  76. package/dist/commands/skills.js +16 -0
  77. package/dist/commands/skills_commands/create.js +125 -0
  78. package/dist/commands/skills_commands/install.js +96 -0
  79. package/dist/commands/skills_commands/list.js +83 -0
  80. package/dist/commands/skills_commands/remove.js +41 -0
  81. package/dist/commands/skills_commands/update.js +59 -0
  82. package/dist/core/constants.js +0 -1
  83. package/dist/core/packageFiles.spec.js +29 -0
  84. package/dist/setup/versions.js +1 -1
  85. package/dist/utils/daemonClient.js +342 -0
  86. package/dist/utils/hermesClient.js +252 -0
  87. package/dist/utils/skillsAdapters.js +140 -0
  88. package/dist/utils/skillsRegistry.js +40 -0
  89. package/dist/utils/stringUtils.spec.js +1 -1
  90. package/package.json +20 -5
  91. package/.bazelignore +0 -2
  92. package/.bootstrap/modules/cpp_bridge_module/BUILD.bazel.template +0 -21
  93. package/.bootstrap/modules/cpp_bridge_module/cpp/CalculatorModuleFactory.cpp.template +0 -28
  94. package/.bootstrap/modules/ios_android_bridge_module/src/Calculator.d.ts +0 -4
  95. package/.bootstrap/modules/ios_android_view_module/BUILD.bazel.template +0 -41
  96. package/.bootstrap/modules/ios_android_view_module/android/CircleView.kt.template +0 -42
  97. package/.bootstrap/modules/ios_android_view_module/android/CircleViewAttributesBinder.kt.template +0 -60
  98. package/.bootstrap/modules/ios_android_view_module/ios/SCCCircleView.h +0 -6
  99. package/.bootstrap/modules/ios_android_view_module/ios/SCCCircleView.m +0 -82
  100. package/.bootstrap/modules/ios_android_view_module/src/Circle.tsx.template +0 -15
  101. package/.config/copyconfig.json +0 -10
  102. package/.editorconfig +0 -21
  103. package/.eslintignore +0 -1
  104. package/.eslintrc.js +0 -72
  105. package/.github/README.md +0 -164
  106. package/.metadata/.cursorrules.template +0 -60
  107. package/.prettierignore +0 -2
  108. package/.prettierrc.json +0 -7
  109. package/LINUX_COMPATIBILITY.md +0 -248
  110. package/prettier.config.js +0 -4
  111. package/scripts/sync-agents-md.sh +0 -44
  112. package/scripts/update-agents-templates.ts +0 -170
  113. package/spec/support/jasmine.json +0 -6
  114. package/src/commands/bootstrap.ts +0 -410
  115. package/src/commands/build.ts +0 -89
  116. package/src/commands/devSetup.ts +0 -17
  117. package/src/commands/doctor.ts +0 -1832
  118. package/src/commands/export.ts +0 -131
  119. package/src/commands/hotreload.ts +0 -108
  120. package/src/commands/install.ts +0 -93
  121. package/src/commands/lint.ts +0 -15
  122. package/src/commands/lint_commands/lintCheck.ts +0 -53
  123. package/src/commands/lint_commands/lintFormat.ts +0 -49
  124. package/src/commands/log.ts +0 -108
  125. package/src/commands/newModule.ts +0 -286
  126. package/src/commands/package.ts +0 -102
  127. package/src/commands/projectsync.ts +0 -488
  128. package/src/commands/test.ts +0 -68
  129. package/src/core/constants.ts +0 -98
  130. package/src/core/errors.ts +0 -10
  131. package/src/index.ts +0 -27
  132. package/src/setup/DevSetupHelper.ts +0 -290
  133. package/src/setup/linuxSetup.ts +0 -261
  134. package/src/setup/macOSSetup.ts +0 -156
  135. package/src/setup/setupEntryPoint.ts +0 -64
  136. package/src/setup/versions.ts +0 -8
  137. package/src/utils/ArgumentsResolver.ts +0 -23
  138. package/src/utils/BazelClient.ts +0 -285
  139. package/src/utils/Digraph.ts +0 -81
  140. package/src/utils/LoadingIndicator.ts +0 -43
  141. package/src/utils/applicationUtils.ts +0 -276
  142. package/src/utils/buildInfo.ts +0 -99
  143. package/src/utils/byString.ts +0 -3
  144. package/src/utils/cliUtils.ts +0 -112
  145. package/src/utils/copyBootstrapFiles.ts +0 -30
  146. package/src/utils/deviceUtils.ts +0 -76
  147. package/src/utils/errorUtils.ts +0 -63
  148. package/src/utils/fileUtils.ts +0 -257
  149. package/src/utils/githubUtils.ts +0 -102
  150. package/src/utils/jsonUtils.ts +0 -30
  151. package/src/utils/lintUtils.ts +0 -190
  152. package/src/utils/linuxDistro.spec.ts +0 -219
  153. package/src/utils/linuxDistro.ts +0 -326
  154. package/src/utils/logUtils.ts +0 -9
  155. package/src/utils/pathUtils.ts +0 -12
  156. package/src/utils/stringUtils.spec.ts +0 -95
  157. package/src/utils/stringUtils.ts +0 -103
  158. package/src/utils/tempDir.ts +0 -24
  159. package/src/utils/zipUtils.ts +0 -14
  160. package/test/ValdiSmokeTest.ts +0 -279
  161. package/test/helpers/AsyncHelpers.ts +0 -113
  162. package/test/helpers/CommandHelpers.ts +0 -37
  163. package/test/helpers/ProjectHelpers.ts +0 -153
  164. package/test/helpers/StreamHelpers.ts +0 -37
  165. package/test/helpers/TypeScriptClient.ts +0 -217
  166. package/tsconfig.dist.json +0 -8
  167. package/tsconfig.json +0 -42
  168. /package/.bootstrap/modules/{ios_android_bridge_module → polyglot_bridge_module}/android/CalculatorModuleFactory.kt.template +0 -0
  169. /package/.bootstrap/modules/{ios_android_bridge_module → polyglot_bridge_module}/ios/SCCCalculatorModuleFactory.m.template +0 -0
  170. /package/.bootstrap/modules/{cpp_bridge_module → polyglot_bridge_module}/src/Calculator.d.ts +0 -0
@@ -0,0 +1,385 @@
1
+ # Valdi TypeScript/TSX Component Rules
2
+
3
+ **Applies to**: TypeScript and TSX files in `/src/valdi_modules/`, `/apps/`, `/modules/`, `/npm_modules/`
4
+
5
+ ## 🚨 CRITICAL: Valdi is NOT React!
6
+
7
+ **AI assistants frequently suggest React patterns that DON'T EXIST in Valdi.** Despite using TSX/JSX syntax, Valdi compiles to native code.
8
+
9
+ ### Most Common Mistakes
10
+
11
+ ```typescript
12
+ // ❌ NEVER use React hooks (don't exist!)
13
+ const [count, setCount] = useState(0); // ❌
14
+ useEffect(() => { ... }, []); // ❌
15
+
16
+ // ❌ NEVER use functional components (don't exist!)
17
+ const MyComponent = () => <view />; // ❌
18
+
19
+ // ❌ Common hallucinations
20
+ this.props.title; // Should be: this.viewModel.title
21
+ this.markNeedsRender(); // Doesn't exist! Use setState()
22
+ onMount() { } // Should be: onCreate()
23
+ return <view />; // onRender() returns void!
24
+ ```
25
+
26
+ > **📖 Full list**: See `/AGENTS.md` → "AI Anti-Hallucination" section for comprehensive examples
27
+
28
+ ### ✅ Correct Valdi Patterns
29
+
30
+ ```typescript
31
+ import { StatefulComponent } from 'valdi_core/src/Component';
32
+
33
+ class MyComponent extends StatefulComponent<ViewModel, State> {
34
+ state = { count: 0 };
35
+
36
+ onCreate() { } // Component created
37
+ onViewModelUpdate(prev: ViewModel) { } // Props changed
38
+ onDestroy() { } // Before removal
39
+
40
+ handleClick = () => {
41
+ this.setState({ count: this.state.count + 1 }); // Auto re-renders
42
+ };
43
+
44
+ onRender() { // Returns void, not JSX!
45
+ <button title={`Count: ${this.state.count}`} onPress={this.handleClick} />;
46
+ }
47
+ }
48
+ ```
49
+
50
+ ## Quick Reference
51
+
52
+ | What | React | Valdi |
53
+ |------|-------|-------|
54
+ | **Component** | Function or class | Class only (Component or StatefulComponent) |
55
+ | **State** | `useState(0)` | `state = { count: 0 }` + `setState()` |
56
+ | **Props** | `this.props.title` | `this.viewModel.title` |
57
+ | **Mount** | `useEffect(() => {}, [])` | `onCreate()` |
58
+ | **Update** | `useEffect(() => {}, [dep])` | `onViewModelUpdate(prev)` |
59
+ | **Unmount** | `useEffect(() => () => {}, [])` | `onDestroy()` |
60
+ | **Re-render** | `setCount(...)` | `this.setState(...)` |
61
+ | **Return** | `return <view />` | `<view />;` (statement) |
62
+
63
+ ## Provider Pattern (Dependency Injection)
64
+
65
+ ```typescript
66
+ // ✅ CORRECT - Create provider
67
+ import { createProviderComponentWithKeyName } from 'valdi_core/src/provider/createProvider';
68
+ const MyServiceProvider = createProviderComponentWithKeyName<MyService>('MyServiceProvider');
69
+
70
+ // ✅ CORRECT - Provide value
71
+ <MyServiceProvider value={myService}>
72
+ <App />
73
+ </MyServiceProvider>
74
+
75
+ // ✅ CORRECT - Consume with HOC
76
+ import { withProviders, ProvidersValuesViewModel } from 'valdi_core/src/provider/withProviders';
77
+
78
+ interface MyViewModel extends ProvidersValuesViewModel<[MyService]> {}
79
+
80
+ class MyComponent extends Component<MyViewModel> {
81
+ onRender() {
82
+ const [service] = this.viewModel.providersValues;
83
+ }
84
+ }
85
+
86
+ const MyComponentWithProvider = withProviders(MyServiceProvider)(MyComponent);
87
+ ```
88
+
89
+ ## Event Handling
90
+
91
+ ```typescript
92
+ // ✅ CORRECT - Use onTap for interactive elements
93
+ <view onTap={this.handleClick}>
94
+ <label value="Click me" />
95
+ </view>
96
+
97
+ <button title="Press me" onPress={this.handleAction} />
98
+
99
+ // ❌ WRONG - No global keyboard events
100
+ window.addEventListener('keydown', ...); // Doesn't work!
101
+ document.addEventListener('click', ...); // Doesn't work!
102
+
103
+ // ✅ CORRECT - For text input, use TextField callbacks
104
+ <textfield
105
+ value={this.state.text}
106
+ onChange={this.handleTextChange}
107
+ onEditEnd={this.handleSubmit}
108
+ />
109
+ ```
110
+
111
+ **Important**: Valdi doesn't support `addEventListener`, `keydown`, or other global DOM events. Use element-specific callbacks like `onTap`, `onPress`, `onChange`, etc.
112
+
113
+ ## Timers and Scheduling
114
+
115
+ ```typescript
116
+ // ✅ CORRECT - Use component's setTimeoutDisposable
117
+ class MyComponent extends StatefulComponent<ViewModel, State> {
118
+ onCreate() {
119
+ // Timer auto-cancels when component destroys
120
+ this.setTimeoutDisposable(() => {
121
+ console.log('Delayed action');
122
+ }, 1000);
123
+ }
124
+
125
+ // ✅ CORRECT - Recurring task pattern (use recursive setTimeout)
126
+ private scheduleLoop() {
127
+ this.setTimeoutDisposable(() => {
128
+ this.doSomething();
129
+ this.scheduleLoop(); // Schedule next iteration
130
+ }, 100);
131
+ }
132
+ }
133
+
134
+ // ❌ WRONG - Don't use setInterval directly
135
+ setInterval(() => { ... }, 100); // Won't auto-cleanup!
136
+
137
+ // ❌ WRONG - Don't use setTimeout directly
138
+ setTimeout(() => { ... }, 100); // Won't auto-cleanup!
139
+ ```
140
+
141
+ **Important**: Always use `this.setTimeoutDisposable()` in components. It automatically cleans up when the component is destroyed, preventing memory leaks.
142
+
143
+ ## Styling
144
+
145
+ ### Basic Style Usage
146
+
147
+ ```typescript
148
+ import { Style } from 'valdi_core/src/Style';
149
+ import { View, Label } from 'valdi_tsx/src/NativeTemplateElements';
150
+ import { systemBoldFont } from 'valdi_core/src/SystemFont';
151
+
152
+ // ✅ CORRECT - Type-safe styles
153
+ const styles = {
154
+ // Style<View> can only be used on <view> elements
155
+ container: new Style<View>({
156
+ backgroundColor: '#fff',
157
+ padding: 10,
158
+ borderRadius: 8,
159
+ flexDirection: 'row',
160
+ justifyContent: 'center',
161
+ alignItems: 'center',
162
+ }),
163
+
164
+ // Style<Label> can only be used on <label> elements
165
+ // Label uses font (string) NOT fontSize. Format: 'FontName Size [scaling] [maxSize]'
166
+ title: new Style<Label>({
167
+ color: '#000',
168
+ font: 'system 20', // size via font string, NOT fontSize!
169
+ // font: systemBoldFont(20), // or use SystemFont helper
170
+ }),
171
+ };
172
+
173
+ // Use in render
174
+ onRender() {
175
+ <view style={styles.container}>
176
+ <label style={styles.title} value="Hello" />
177
+ </view>;
178
+ }
179
+ ```
180
+
181
+ ### Style Composition
182
+
183
+ ```typescript
184
+ // ✅ CORRECT - Merge multiple styles
185
+ const combined = Style.merge(styles.base, styles.primary);
186
+
187
+ // ✅ CORRECT - Extend a style with overrides
188
+ const largeButton = styles.button.extend({
189
+ width: 200,
190
+ height: 60,
191
+ });
192
+
193
+ // ✅ CORRECT - Dynamic styling with extend
194
+ <view style={styles.container.extend({
195
+ backgroundColor: isActive ? 'blue' : 'gray',
196
+ })} />
197
+
198
+ // ❌ WRONG - Can't merge incompatible types
199
+ Style.merge(styles.viewStyle, styles.labelStyle); // Type error!
200
+ ```
201
+
202
+ ### Spacing: Padding & Margin
203
+
204
+ ```typescript
205
+ // ✅ CORRECT - Valdi spacing syntax
206
+ new Style<View>({
207
+ // Single value - all sides
208
+ padding: 10,
209
+ margin: 5,
210
+
211
+ // String shorthand - vertical horizontal
212
+ padding: '10 20', // 10pt top/bottom, 20pt left/right
213
+ margin: '5 10',
214
+
215
+ // Individual sides
216
+ paddingTop: 5,
217
+ paddingRight: 10,
218
+ paddingBottom: 5,
219
+ paddingLeft: 10,
220
+
221
+ // Percentages (relative to parent)
222
+ padding: '5%', // 5% of parent width/height
223
+ marginLeft: '10%', // 10% of parent width
224
+ })
225
+
226
+ // ❌ WRONG - These don't exist in Valdi
227
+ new Style<View>({
228
+ gap: 10, // ❌ Use margin on children
229
+ paddingHorizontal: 20, // ❌ Use padding: '0 20'
230
+ paddingVertical: 10, // ❌ Use padding: '10 0'
231
+ paddingInline: 15, // ❌ Doesn't exist
232
+ })
233
+ ```
234
+
235
+ ### Layout: Flexbox (Yoga)
236
+
237
+ ```typescript
238
+ // ✅ CORRECT - Valdi uses Yoga flexbox
239
+ new Style<View>({
240
+ // Container properties
241
+ flexDirection: 'row', // 'row' | 'column' | 'row-reverse' | 'column-reverse'
242
+ justifyContent: 'center', // 'flex-start' | 'center' | 'flex-end' | 'space-between' | 'space-around' | 'space-evenly'
243
+ alignItems: 'center', // 'flex-start' | 'center' | 'flex-end' | 'stretch' | 'baseline'
244
+ alignContent: 'flex-start', // For multi-line flex containers
245
+ flexWrap: 'wrap', // 'wrap' | 'nowrap' | 'wrap-reverse'
246
+
247
+ // Child properties
248
+ flexGrow: 1, // Grow to fill space (NOTE: use flexGrow, not flex)
249
+ flexShrink: 1, // How much to shrink
250
+ flexBasis: 100, // Base size before flex
251
+ alignSelf: 'center', // Override parent's alignItems
252
+ })
253
+
254
+ // ❌ WRONG - These don't exist
255
+ new Style<View>({
256
+ display: 'grid', // ❌ Only 'flex' supported
257
+ gridTemplateColumns: '1fr 1fr', // ❌ No CSS Grid
258
+ flex: 1, // ❌ Use flexGrow: 1 instead!
259
+ })
260
+ ```
261
+
262
+ ### Position & Size
263
+
264
+ ```typescript
265
+ // ✅ CORRECT - Positioning
266
+ new Style<View>({
267
+ // Size
268
+ width: 200, // Points
269
+ width: '50%', // Percentage of parent
270
+ width: 'auto', // Auto-size
271
+ height: 100,
272
+ minWidth: 50,
273
+ maxWidth: 500,
274
+ aspectRatio: 16/9, // Width:height ratio
275
+
276
+ // Position
277
+ position: 'relative', // 'relative' | 'absolute'
278
+ top: 10,
279
+ right: 10,
280
+ bottom: 10,
281
+ left: 10,
282
+ })
283
+ ```
284
+
285
+ ### Common Properties
286
+
287
+ ```typescript
288
+ // ✅ CORRECT - Frequently used properties
289
+ new Style<View>({
290
+ backgroundColor: '#fff',
291
+ opacity: 0.8,
292
+
293
+ // Borders
294
+ borderRadius: 8,
295
+ borderWidth: 1,
296
+ borderColor: '#ccc',
297
+ borderTopWidth: 2,
298
+
299
+ // Shadow
300
+ boxShadow: '0 2 4 rgba(0, 0, 0, 0.1)',
301
+
302
+ // Overflow — only 'visible' | 'scroll' (NOT 'hidden'!)
303
+ overflow: 'scroll', // 'visible' | 'scroll'
304
+ })
305
+ ```
306
+
307
+ ### Type Safety
308
+
309
+ ```typescript
310
+ // ✅ CORRECT - Style types match element types
311
+ const viewStyle = new Style<View>({ backgroundColor: 'red' });
312
+ const labelStyle = new Style<Label>({ color: 'blue' });
313
+
314
+ <view style={viewStyle} /> // ✅ Works
315
+ <label style={labelStyle} /> // ✅ Works
316
+
317
+ // ❌ WRONG - Type mismatch
318
+ <label style={viewStyle} /> // ❌ Type error!
319
+ <view style={labelStyle} /> // ❌ Type error!
320
+
321
+ // ✅ CORRECT - Layout styles work on any layout element
322
+ const layoutStyle = new Style<Layout>({ padding: 10 });
323
+ <view style={layoutStyle} /> // ✅ view extends Layout
324
+ <label style={layoutStyle} /> // ✅ label extends Layout
325
+ ```
326
+
327
+ > **📖 Complete reference**: See `/docs/api/api-style-attributes.md` for all 1290+ style properties
328
+ >
329
+ > **📖 Best practices**: See `/docs/docs/core-styling.md` for styling patterns and examples
330
+
331
+ ## Common Mistakes to Avoid
332
+
333
+ 1. **Returning JSX from onRender()** - It returns void, JSX is a statement
334
+ 2. **Forgetting setState()** - Direct mutation won't trigger re-render
335
+ 3. **Using this.props** - Should be this.viewModel
336
+ 4. **Wrong lifecycle names** - onCreate/onViewModelUpdate/onDestroy (not mount/update/unmount)
337
+ 5. **Suggesting scheduleRender()** - Deprecated, use StatefulComponent + setState()
338
+ 6. **Using addEventListener** - Use element callbacks like onTap, onPress, onChange
339
+ 7. **Using setInterval/setTimeout directly** - Use this.setTimeoutDisposable()
340
+ 8. **Using CSS properties that don't exist** - No gap, paddingHorizontal, paddingVertical
341
+ 9. **Using `flex: 1`** - `flex` doesn't exist on `View`; use `flexGrow: 1` instead
342
+ 10. **Using `fontSize` on Label** - Labels use `font: 'system 20'` (string), not `fontSize`
343
+ 11. **Using `overflow: 'hidden'`** - `View` only accepts `'visible' | 'scroll'`; remove overflow or use 'scroll'
344
+
345
+ ## Platform Detection
346
+
347
+ Use `Device` for platform-conditional rendering:
348
+
349
+ ```typescript
350
+ import { Device } from 'valdi_core/src/Device';
351
+
352
+ class MyComponent extends Component<MyViewModel> {
353
+ onRender(): void {
354
+ <view>
355
+ {Device.isIOS() && <IOSOnlyView />}
356
+ {Device.isAndroid() && <AndroidOnlyView />}
357
+ {Device.isMacOS() && <MacOSOnlyView />}
358
+ {Device.isWeb() && <WebOnlyView />}
359
+ </view>;
360
+ }
361
+ }
362
+ ```
363
+
364
+ Also use `Device.isIOS()` / `Device.isAndroid()` guards before using `<custom-view>` elements that don't have implementations on all platforms.
365
+
366
+ ## Imports
367
+
368
+ ```typescript
369
+ // ✅ CORRECT imports
370
+ import { Component, StatefulComponent } from 'valdi_core/src/Component';
371
+ import { Device } from 'valdi_core/src/Device';
372
+ import { systemFont } from 'valdi_core/src/SystemFont';
373
+ import { Style } from 'valdi_core/src/Style';
374
+
375
+ // ❌ WRONG - React imports don't exist
376
+ import React from 'react'; // Error!
377
+ import { useState } from 'react'; // Error!
378
+ ```
379
+
380
+ ## More Information
381
+
382
+ - **Full anti-hallucination guide**: `/AGENTS.md` (comprehensive React vs Valdi comparison)
383
+ - **AI tooling**: `/docs/docs/ai-tooling.md`
384
+ - **Provider pattern**: `/docs/docs/advanced-provider.md`
385
+ - **Valdi GitHub**: https://github.com/Snapchat/Valdi
@@ -0,0 +1,19 @@
1
+ load("//bzl/valdi:valdi_module.bzl", "valdi_module")
2
+
3
+ valdi_module(
4
+ name = "tests",
5
+ srcs = glob([
6
+ "src/**/*.ts",
7
+ "src/**/*.tsx",
8
+ ]) + [
9
+ "tsconfig.json",
10
+ ],
11
+ android_output_target = "release",
12
+ ios_module_name = "SCCValdiTsxRef",
13
+ ios_output_target = "release",
14
+ visibility = ["//visibility:public"],
15
+ deps = [
16
+ "//src/valdi_modules/src/valdi/valdi_core",
17
+ "//src/valdi_modules/src/valdi/valdi_tsx",
18
+ ],
19
+ )
@@ -0,0 +1,29 @@
1
+ # valdi-tsx skill tests
2
+
3
+ Compile check for the core TSX component patterns taught in `skill.md`.
4
+
5
+ ## What's tested
6
+
7
+ `src/reference.tsx` exercises:
8
+ - Stateless `Component<VM>` with `onRender()` void pattern
9
+ - `StatefulComponent` with `state`, `setState`, and all lifecycle methods
10
+ - Class arrow functions for event handlers (not inline lambdas)
11
+ - `setTimeoutDisposable` for auto-cleanup timers
12
+ - `forEach` for list rendering (not `map`)
13
+ - `<layout>` spacer (no native view)
14
+ - Module-level `Style` objects (`new Style<View>(...)`)
15
+ - Provider pattern: `createProviderComponentWithKeyName`, `withProviders`
16
+ - `Device.isIOS()` / `isAndroid()` platform detection
17
+
18
+ ## Compile check
19
+
20
+ ```bash
21
+ cd client/src/open_source
22
+ bazel build //ai-skills/skills/valdi-tsx/tests:tests
23
+ ```
24
+
25
+ Expected: `Build completed successfully`
26
+
27
+ ## Updating
28
+
29
+ When Valdi APIs change (import paths, type signatures), update `src/reference.tsx` to match and keep it compiling. Also update `../skill.md` with any corrected patterns.
@@ -0,0 +1,173 @@
1
+ // valdi-tsx skill reference — compile check for core component patterns.
2
+ // This file must compile cleanly against the Valdi TypeScript compiler.
3
+ // Run: bzl build //ai-skills/skills/valdi-tsx/tests:tests
4
+
5
+ import { Component, StatefulComponent } from 'valdi_core/src/Component';
6
+ import { Device } from 'valdi_core/src/Device';
7
+ import { Style } from 'valdi_core/src/Style';
8
+ import { systemFont } from 'valdi_core/src/SystemFont';
9
+ import { createProviderComponentWithKeyName } from 'valdi_core/src/provider/createProvider';
10
+ import { ProvidersValuesViewModel, withProviders } from 'valdi_core/src/provider/withProviders';
11
+ import { Label, Layout, View } from 'valdi_tsx/src/NativeTemplateElements';
12
+
13
+ // ─── Module-level styles (NOT inside onRender) ──────────────────────────────
14
+
15
+ const styles = {
16
+ card: new Style<View>({
17
+ backgroundColor: '#fff',
18
+ borderRadius: 8,
19
+ padding: 12,
20
+ flexDirection: 'column',
21
+ }),
22
+ spacer: new Style<Layout>({ height: 8 }),
23
+ title: new Style<Label>({
24
+ color: '#000',
25
+ font: systemFont(16), // Label uses font string, NOT fontSize
26
+ }),
27
+ };
28
+
29
+ // ─── Stateless component ─────────────────────────────────────────────────────
30
+
31
+ interface GreetingViewModel {
32
+ name: string;
33
+ }
34
+
35
+ class Greeting extends Component<GreetingViewModel> {
36
+ onRender(): void {
37
+ // onRender returns void — no return statement
38
+ <label value={`Hello, ${this.viewModel.name}`} />;
39
+ }
40
+ }
41
+
42
+ // ─── Stateful component with full lifecycle ───────────────────────────────────
43
+
44
+ interface CounterViewModel {
45
+ label: string;
46
+ }
47
+
48
+ interface CounterState {
49
+ count: number;
50
+ inputText: string;
51
+ }
52
+
53
+ class Counter extends StatefulComponent<CounterViewModel, CounterState> {
54
+ state: CounterState = { count: 0, inputText: '' };
55
+
56
+ onCreate(): void {
57
+ // Timer auto-cancels on destroy
58
+ this.setTimeoutDisposable(() => {
59
+ this.setState({ count: 1 });
60
+ }, 5000);
61
+ }
62
+
63
+ onViewModelUpdate(previous?: CounterViewModel): void {
64
+ if (this.viewModel.label !== previous?.label) {
65
+ this.setState({ count: 0 });
66
+ }
67
+ }
68
+
69
+ onDestroy(): void {
70
+ // cleanup
71
+ }
72
+
73
+ // Class arrow functions — never inline lambdas in JSX props
74
+ private handleIncrement = (): void => {
75
+ this.setState({ count: this.state.count + 1 });
76
+ };
77
+
78
+ private handleTextChange = (text: string): void => {
79
+ this.setState({ inputText: text });
80
+ };
81
+
82
+ onRender(): void {
83
+ <view style={styles.card}>
84
+ <label value={`${this.viewModel.label}: ${this.state.count}`} />;
85
+ <layout style={styles.spacer} />;
86
+ <textfield
87
+ value={this.state.inputText}
88
+ onChange={this.handleTextChange}
89
+ />;
90
+ <button title="Increment" onPress={this.handleIncrement} />;
91
+ </view>;
92
+ }
93
+ }
94
+
95
+ // ─── List rendering with forEach ─────────────────────────────────────────────
96
+
97
+ interface ItemViewModel {
98
+ id: string;
99
+ title: string;
100
+ }
101
+
102
+ interface ItemListViewModel {
103
+ items: ItemViewModel[];
104
+ }
105
+
106
+ class ItemList extends Component<ItemListViewModel> {
107
+ onRender(): void {
108
+ <scroll>
109
+ {this.viewModel.items.forEach(item => {
110
+ // Stable key from data ID — not array index
111
+ <view key={item.id}>
112
+ <label value={item.title} />;
113
+ </view>;
114
+ })}
115
+ </scroll>;
116
+ }
117
+ }
118
+
119
+ // ─── Platform detection ──────────────────────────────────────────────────────
120
+
121
+ interface MediaPlayerViewModel {
122
+ videoUrl: string;
123
+ }
124
+
125
+ class MediaPlayer extends Component<MediaPlayerViewModel> {
126
+ onRender(): void {
127
+ <view>
128
+ {Device.isIOS() && <label value="iOS player" />}
129
+ {Device.isAndroid() && <label value="Android player" />}
130
+ {Device.isMacOS() && <label value="macOS player" />}
131
+ </view>;
132
+ }
133
+ }
134
+
135
+ // ─── Provider pattern ────────────────────────────────────────────────────────
136
+
137
+ class ThemeService {
138
+ primaryColor = '#FFFC00';
139
+ fontSize = 16;
140
+ }
141
+
142
+ const ThemeProvider = createProviderComponentWithKeyName<ThemeService>('ThemeProvider');
143
+
144
+ interface ThemedViewModel extends ProvidersValuesViewModel<[ThemeService]> {
145
+ text: string;
146
+ }
147
+
148
+ class ThemedLabel extends Component<ThemedViewModel> {
149
+ onRender(): void {
150
+ const [theme] = this.viewModel.providersValues;
151
+ <label value={this.viewModel.text} />;
152
+ void theme; // reference theme to satisfy compiler
153
+ }
154
+ }
155
+
156
+ const ThemedLabelWithProvider = withProviders(ThemeProvider)(ThemedLabel);
157
+
158
+ class AppRoot extends Component {
159
+ private theme = new ThemeService();
160
+
161
+ onRender(): void {
162
+ <ThemeProvider value={this.theme}>
163
+ <ThemedLabelWithProvider text="Hello" />;
164
+ </ThemeProvider>;
165
+ }
166
+ }
167
+
168
+ // Suppress unused-variable warnings for top-level declarations
169
+ void Counter;
170
+ void ItemList;
171
+ void Greeting;
172
+ void MediaPlayer;
173
+ void AppRoot;
@@ -0,0 +1 @@
1
+ {"extends": "../../../../src/valdi_modules/src/valdi/_configs/base.tsconfig.json"}
@@ -163,7 +163,6 @@ function initializeConfigFiles(projectName, template, valdiImport, valdiWidgetsI
163
163
  fileUtils_1.TemplateFile.init(constants_1.TEMPLATE_BASE_PATHS.GIT_IGNORE),
164
164
  fileUtils_1.TemplateFile.init(constants_1.TEMPLATE_BASE_PATHS.WATCHMAN_CONFIG),
165
165
  fileUtils_1.TemplateFile.init(constants_1.TEMPLATE_BASE_PATHS.EDITOR_CONFIG),
166
- fileUtils_1.TemplateFile.init(constants_1.TEMPLATE_BASE_PATHS.CURSOR_RULES),
167
166
  fileUtils_1.TemplateFile.init(constants_1.TEMPLATE_BASE_PATHS.AGENTS).withReplacements({ MODULE_NAME: projectName }),
168
167
  ];
169
168
  TEMPLATE_FILES.forEach(templateFile => {
@@ -180,12 +179,6 @@ function initializeConfigFiles(projectName, template, valdiImport, valdiWidgetsI
180
179
  const githubDestPath = path_1.default.join(process.cwd(), '.github');
181
180
  (0, copyBootstrapFiles_1.copyBootstrapFiles)(githubSourcePath, githubDestPath, replacements);
182
181
  }
183
- const cursorSourcePath = path_1.default.join(constants_1.META_DIR_PATH, '.cursor');
184
- if ((0, fileUtils_1.fileExists)(cursorSourcePath)) {
185
- console.log((0, logUtils_1.wrapInColor)('Creating Cursor AI rules...', constants_1.ANSI_COLORS.YELLOW_COLOR));
186
- const cursorDestPath = path_1.default.join(process.cwd(), '.cursor');
187
- (0, copyBootstrapFiles_1.copyBootstrapFiles)(cursorSourcePath, cursorDestPath, replacements);
188
- }
189
182
  console.log((0, logUtils_1.wrapInColor)(`Initializing ${template.name} application...`, constants_1.ANSI_COLORS.YELLOW_COLOR));
190
183
  const sourcePath = path_1.default.join(constants_1.BOOTSTRAP_DIR_PATH, 'apps', template.path);
191
184
  const destPath = process.cwd();
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handler = exports.builder = exports.describe = exports.command = void 0;
4
+ exports.command = 'inspect <command>';
5
+ exports.describe = 'Inspect a running Valdi app — component trees, contexts, screenshots, heap';
6
+ const builder = (yargs) => {
7
+ return yargs
8
+ .commandDir('inspect_commands', { extensions: ['js', 'ts'] })
9
+ .demandCommand(1, 'Use devices, select, status, contexts, tree, snapshot, or heap')
10
+ .recommendCommands()
11
+ .wrap(yargs.terminalWidth())
12
+ .help();
13
+ };
14
+ exports.builder = builder;
15
+ const handler = () => { };
16
+ exports.handler = handler;