@snap/valdi 1.0.6 → 1.0.8

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 (161) hide show
  1. package/README.md +22 -10
  2. package/bundled-skills/CONTRIBUTING_SKILLS.md +74 -0
  3. package/bundled-skills/registry.json +20 -0
  4. package/bundled-skills/skills/valdi-android/skill.md +89 -0
  5. package/bundled-skills/skills/valdi-async/skill.md +246 -0
  6. package/bundled-skills/skills/valdi-async/tests/BUILD.bazel +19 -0
  7. package/bundled-skills/skills/valdi-async/tests/README.md +25 -0
  8. package/bundled-skills/skills/valdi-async/tests/src/reference.tsx +210 -0
  9. package/bundled-skills/skills/valdi-async/tests/tsconfig.json +1 -0
  10. package/bundled-skills/skills/valdi-bazel/skill.md +122 -0
  11. package/bundled-skills/skills/valdi-compiler/skill.md +108 -0
  12. package/bundled-skills/skills/valdi-component-tests/skill.md +430 -0
  13. package/bundled-skills/skills/valdi-component-tests/tests/BUILD.bazel +24 -0
  14. package/bundled-skills/skills/valdi-component-tests/tests/README.md +35 -0
  15. package/bundled-skills/skills/valdi-component-tests/tests/src/ProfileCard.tsx +38 -0
  16. package/bundled-skills/skills/valdi-component-tests/tests/test/ProfileCardTest.spec.tsx +107 -0
  17. package/bundled-skills/skills/valdi-component-tests/tests/tsconfig.json +1 -0
  18. package/bundled-skills/skills/valdi-cpp-runtime/skill.md +103 -0
  19. package/bundled-skills/skills/valdi-custom-view/skill.md +62 -0
  20. package/bundled-skills/skills/valdi-ios/skill.md +93 -0
  21. package/bundled-skills/skills/valdi-migrate/skill.md +175 -0
  22. package/bundled-skills/skills/valdi-migrate/tests/BUILD.bazel +23 -0
  23. package/bundled-skills/skills/valdi-migrate/tests/README.md +70 -0
  24. package/bundled-skills/skills/valdi-migrate/tests/check_antipatterns.py +89 -0
  25. package/bundled-skills/skills/valdi-migrate/tests/compose_example.kt +94 -0
  26. package/bundled-skills/skills/valdi-migrate/tests/flutter_example.dart +129 -0
  27. package/bundled-skills/skills/valdi-migrate/tests/react_example.tsx +98 -0
  28. package/bundled-skills/skills/valdi-migrate/tests/src/expected_valdi.tsx +267 -0
  29. package/bundled-skills/skills/valdi-migrate/tests/tsconfig.json +3 -0
  30. package/{.metadata/.cursorrules.template → bundled-skills/skills/valdi-overview/skill.md} +23 -13
  31. package/bundled-skills/skills/valdi-perf/skill.md +197 -0
  32. package/bundled-skills/skills/valdi-perf/tests/BUILD.bazel +19 -0
  33. package/bundled-skills/skills/valdi-perf/tests/README.md +26 -0
  34. package/bundled-skills/skills/valdi-perf/tests/src/reference.tsx +202 -0
  35. package/bundled-skills/skills/valdi-perf/tests/tsconfig.json +1 -0
  36. package/bundled-skills/skills/valdi-polyglot-module/skill.md +85 -0
  37. package/bundled-skills/skills/valdi-setup/skill.md +129 -0
  38. package/bundled-skills/skills/valdi-testing/skill.md +65 -0
  39. package/bundled-skills/skills/valdi-tsx/skill.md +385 -0
  40. package/bundled-skills/skills/valdi-tsx/tests/BUILD.bazel +19 -0
  41. package/bundled-skills/skills/valdi-tsx/tests/README.md +29 -0
  42. package/bundled-skills/skills/valdi-tsx/tests/src/reference.tsx +173 -0
  43. package/bundled-skills/skills/valdi-tsx/tests/tsconfig.json +1 -0
  44. package/dist/commands/bootstrap.js +3 -9
  45. package/dist/commands/newModule.js +10 -14
  46. package/dist/commands/skills.js +16 -0
  47. package/dist/commands/skills_commands/create.js +125 -0
  48. package/dist/commands/skills_commands/install.js +96 -0
  49. package/dist/commands/skills_commands/list.js +83 -0
  50. package/dist/commands/skills_commands/remove.js +41 -0
  51. package/dist/commands/skills_commands/update.js +59 -0
  52. package/dist/core/constants.js +1 -1
  53. package/dist/index.js +5 -0
  54. package/dist/setup/versions.js +1 -1
  55. package/dist/utils/skillsAdapters.js +140 -0
  56. package/dist/utils/skillsRegistry.js +40 -0
  57. package/package.json +6 -1
  58. package/.bazelignore +0 -2
  59. package/.bootstrap/apps/cli_application/AGENTS.md.template +0 -291
  60. package/.bootstrap/apps/cli_application/BUILD.bazel.template +0 -7
  61. package/.bootstrap/apps/cli_application/modules/{{MODULE_NAME}}/BUILD.bazel.template +0 -11
  62. package/.bootstrap/apps/cli_application/modules/{{MODULE_NAME}}/src/index.ts +0 -1
  63. package/.bootstrap/apps/ui_application/.eslint.rc +0 -27
  64. package/.bootstrap/apps/ui_application/AGENTS.md.template +0 -278
  65. package/.bootstrap/apps/ui_application/BUILD.bazel.template +0 -19
  66. package/.bootstrap/apps/ui_application/modules/{{MODULE_NAME}}/BUILD.bazel.template +0 -21
  67. package/.bootstrap/apps/ui_application/modules/{{MODULE_NAME}}/res/valdi@3x.png +0 -0
  68. package/.bootstrap/apps/ui_application/modules/{{MODULE_NAME}}/src/App.tsx +0 -133
  69. package/.bootstrap/apps/ui_application/package.json +0 -24
  70. package/.bootstrap/modules/cpp_bridge_module/BUILD.bazel.template +0 -21
  71. package/.bootstrap/modules/cpp_bridge_module/cpp/CalculatorModuleFactory.cpp.template +0 -28
  72. package/.bootstrap/modules/cpp_bridge_module/src/Calculator.d.ts +0 -4
  73. package/.bootstrap/modules/ios_android_bridge_module/BUILD.bazel.template +0 -39
  74. package/.bootstrap/modules/ios_android_bridge_module/android/CalculatorModuleFactory.kt.template +0 -18
  75. package/.bootstrap/modules/ios_android_bridge_module/ios/SCCCalculatorModuleFactory.m.template +0 -31
  76. package/.bootstrap/modules/ios_android_bridge_module/src/Calculator.d.ts +0 -4
  77. package/.bootstrap/modules/ios_android_view_module/BUILD.bazel.template +0 -41
  78. package/.bootstrap/modules/ios_android_view_module/android/CircleView.kt.template +0 -42
  79. package/.bootstrap/modules/ios_android_view_module/android/CircleViewAttributesBinder.kt.template +0 -60
  80. package/.bootstrap/modules/ios_android_view_module/ios/SCCCircleView.h +0 -6
  81. package/.bootstrap/modules/ios_android_view_module/ios/SCCCircleView.m +0 -82
  82. package/.bootstrap/modules/ios_android_view_module/src/Circle.tsx.template +0 -15
  83. package/.bootstrap/modules/ui_component/BUILD.bazel.template +0 -34
  84. package/.bootstrap/modules/ui_component/src/NewModuleComponent.tsx +0 -45
  85. package/.config/copyconfig.json +0 -10
  86. package/.editorconfig +0 -21
  87. package/.eslintignore +0 -1
  88. package/.eslintrc.js +0 -72
  89. package/.github/README.md +0 -164
  90. package/.metadata/.bazelrc.template +0 -91
  91. package/.metadata/.bazelversion.template +0 -1
  92. package/.metadata/.editorconfig.template +0 -37
  93. package/.metadata/.eslintrc.js.template +0 -27
  94. package/.metadata/.gitignore.template +0 -4
  95. package/.metadata/.prettierrc.json.template +0 -7
  96. package/.metadata/.watchmanconfig.template +0 -8
  97. package/.metadata/README.md.template +0 -31
  98. package/.metadata/WORKSPACE.template +0 -57
  99. package/.metadata/config.yaml.template +0 -1
  100. package/.metadata/package.json.template +0 -23
  101. package/.prettierignore +0 -2
  102. package/.prettierrc.json +0 -7
  103. package/LINUX_COMPATIBILITY.md +0 -248
  104. package/prettier.config.js +0 -4
  105. package/scripts/sync-agents-md.sh +0 -44
  106. package/scripts/update-agents-templates.ts +0 -170
  107. package/spec/support/jasmine.json +0 -6
  108. package/src/commands/bootstrap.ts +0 -409
  109. package/src/commands/build.ts +0 -89
  110. package/src/commands/devSetup.ts +0 -17
  111. package/src/commands/doctor.ts +0 -1832
  112. package/src/commands/export.ts +0 -131
  113. package/src/commands/hotreload.ts +0 -108
  114. package/src/commands/install.ts +0 -93
  115. package/src/commands/lint.ts +0 -15
  116. package/src/commands/lint_commands/lintCheck.ts +0 -53
  117. package/src/commands/lint_commands/lintFormat.ts +0 -49
  118. package/src/commands/log.ts +0 -108
  119. package/src/commands/newModule.ts +0 -286
  120. package/src/commands/package.ts +0 -102
  121. package/src/commands/projectsync.ts +0 -488
  122. package/src/commands/test.ts +0 -68
  123. package/src/core/constants.ts +0 -97
  124. package/src/core/errors.ts +0 -10
  125. package/src/index.ts +0 -22
  126. package/src/setup/DevSetupHelper.ts +0 -290
  127. package/src/setup/linuxSetup.ts +0 -261
  128. package/src/setup/macOSSetup.ts +0 -156
  129. package/src/setup/setupEntryPoint.ts +0 -64
  130. package/src/setup/versions.ts +0 -8
  131. package/src/utils/ArgumentsResolver.ts +0 -23
  132. package/src/utils/BazelClient.ts +0 -285
  133. package/src/utils/Digraph.ts +0 -81
  134. package/src/utils/LoadingIndicator.ts +0 -43
  135. package/src/utils/applicationUtils.ts +0 -276
  136. package/src/utils/buildInfo.ts +0 -99
  137. package/src/utils/byString.ts +0 -3
  138. package/src/utils/cliUtils.ts +0 -112
  139. package/src/utils/copyBootstrapFiles.ts +0 -30
  140. package/src/utils/deviceUtils.ts +0 -76
  141. package/src/utils/errorUtils.ts +0 -63
  142. package/src/utils/fileUtils.ts +0 -257
  143. package/src/utils/githubUtils.ts +0 -102
  144. package/src/utils/jsonUtils.ts +0 -30
  145. package/src/utils/lintUtils.ts +0 -190
  146. package/src/utils/linuxDistro.spec.ts +0 -219
  147. package/src/utils/linuxDistro.ts +0 -326
  148. package/src/utils/logUtils.ts +0 -9
  149. package/src/utils/pathUtils.ts +0 -12
  150. package/src/utils/stringUtils.spec.ts +0 -95
  151. package/src/utils/stringUtils.ts +0 -103
  152. package/src/utils/tempDir.ts +0 -24
  153. package/src/utils/zipUtils.ts +0 -14
  154. package/test/ValdiSmokeTest.ts +0 -279
  155. package/test/helpers/AsyncHelpers.ts +0 -113
  156. package/test/helpers/CommandHelpers.ts +0 -37
  157. package/test/helpers/ProjectHelpers.ts +0 -153
  158. package/test/helpers/StreamHelpers.ts +0 -37
  159. package/test/helpers/TypeScriptClient.ts +0 -217
  160. package/tsconfig.dist.json +0 -8
  161. package/tsconfig.json +0 -42
@@ -1,278 +0,0 @@
1
- # AGENTS.md - Guide for AI Coding Assistants
2
-
3
- This document provides context and guidelines for AI coding assistants working on this Valdi application.
4
-
5
- ## Overview
6
-
7
- This is a Valdi application that runs natively on iOS, Android, and macOS. Valdi is a cross-platform UI framework that compiles declarative TypeScript components to native views - no web views, no JavaScript bridges.
8
-
9
-
10
- ## 🚨 CRITICAL: Valdi is NOT React!
11
-
12
- **AI assistants often suggest React patterns that DON'T EXIST in Valdi.** This is because TSX/JSX syntax looks like React, but Valdi compiles to native code.
13
-
14
- ### ❌ FORBIDDEN Patterns (Don't exist in Valdi)
15
-
16
- ```typescript
17
- // ❌ WRONG - React hooks don't exist
18
- const [count, setCount] = useState(0);
19
- useEffect(() => { ... }, []);
20
-
21
- // ❌ WRONG - Functional components don't exist
22
- const MyComponent = () => <view />;
23
-
24
- // ❌ WRONG - Common AI mistakes
25
- this.markNeedsRender(); // Doesn't exist!
26
- this.props.title; // Should be: this.viewModel.title
27
- onMount() { } // Should be: onCreate()
28
- onUpdate() { } // Should be: onViewModelUpdate()
29
- onUnmount() { } // Should be: onDestroy()
30
- this.context.get(Service); // Wrong pattern, use withProviders()
31
- ```
32
-
33
- ### ✅ CORRECT Valdi Patterns
34
-
35
- ```typescript
36
- // ✅ Stateful component with state
37
- import { StatefulComponent } from 'valdi_core/src/Component';
38
-
39
- class MyComponent extends StatefulComponent<ViewModel, State> {
40
- state = { count: 0 };
41
-
42
- // Lifecycle methods
43
- onCreate() { } // Component created
44
- onViewModelUpdate(prev: ViewModel) { } // Props changed
45
- onDestroy() { } // Before removal
46
-
47
- // State updates
48
- handleClick() {
49
- this.setState({ count: this.state.count + 1 }); // Auto re-renders
50
- }
51
-
52
- // Render (returns void, JSX is statement)
53
- onRender() {
54
- <button
55
- title={`Count: ${this.state.count}`}
56
- onPress={this.handleClick}
57
- />;
58
- }
59
- }
60
-
61
- // ✅ Stateless component (props only)
62
- import { Component } from 'valdi_core/src/Component';
63
-
64
- class SimpleComponent extends Component<ViewModel> {
65
- onRender() {
66
- <label value={this.viewModel.title} />; // viewModel, not props!
67
- }
68
- }
69
- ```
70
-
71
- ### Key Differences from React
72
-
73
- | Concept | React | Valdi |
74
- |---------|-------|-------|
75
- | **Components** | Functions or classes | Classes only (Component or StatefulComponent) |
76
- | **State** | `useState` hook | `state = { }` + `setState()` |
77
- | **Props** | `this.props` | `this.viewModel` |
78
- | **Lifecycle** | `useEffect` | `onCreate`, `onViewModelUpdate`, `onDestroy` |
79
- | **Re-render** | `setCount(...)` | `this.setState(...)` |
80
- | **Return** | `return <view />` | `<view />;` (statement, returns void) |
81
-
82
- For complete framework documentation, see: https://github.com/Snapchat/Valdi
83
-
84
-
85
- ## Project Structure
86
-
87
- - **`modules/`** - Your application modules
88
- - Each module contains TypeScript/TSX source files
89
- - `BUILD.bazel` files define how modules are built
90
- - `src/` contains your component and business logic code
91
- - **`WORKSPACE`** - Bazel workspace configuration
92
- - **`config.yaml`** - Valdi project configuration
93
- - **`.bazelrc`** - Bazel build settings
94
-
95
- ## Key Technologies
96
-
97
- - **Valdi** - Cross-platform UI framework that compiles to native code
98
- - **TypeScript/TSX** - React-like syntax for declarative UI (but compiles to native, not React)
99
- - **Bazel** - Build system (note: `bzl` is an alias for `bazel`)
100
- - **Flexbox** - Layout system with automatic RTL support
101
-
102
- ## Development Workflow
103
-
104
- ### Initial Setup
105
-
106
- ```bash
107
- # Install Valdi CLI (if not already installed)
108
- cd path/to/valdi/npm_modules/cli
109
- npm run cli:install
110
-
111
- # Setup development environment
112
- valdi dev_setup
113
-
114
- # Sync project (run after changing dependencies or config)
115
- valdi projectsync
116
- ```
117
-
118
- ### Building and Running
119
-
120
- ```bash
121
- # Install and run on iOS
122
- valdi install ios
123
-
124
- # Install and run on Android
125
- valdi install android
126
-
127
- # Install and run on macOS
128
- valdi install macos
129
-
130
- # Start hot reload (for instant updates while developing)
131
- valdi hotreload
132
- ```
133
-
134
- ### Common Commands
135
-
136
- ```bash
137
- # Sync project configuration and generate IDE files
138
- valdi projectsync
139
-
140
- # Build specific targets with Bazel
141
- bazel build //modules/{{MODULE_NAME}}:{{MODULE_NAME}}
142
-
143
- # Run tests
144
- bazel test //modules/{{MODULE_NAME}}:tests
145
- ```
146
-
147
- ## Valdi Component Basics
148
-
149
- Components use a class-based pattern with lifecycle methods:
150
-
151
- ```typescript
152
- import { Component } from 'valdi_core/src/Component';
153
-
154
- class MyComponent extends Component {
155
- // Required: Render the component's UI
156
- onRender() {
157
- <view backgroundColor="#FFFC00" padding={30}>
158
- <label value="Hello World" color="black" />
159
- </view>;
160
- }
161
-
162
- // Optional lifecycle methods:
163
- // onCreate() - Called when component is first created
164
- // onDestroy() - Called before component is removed
165
- // onViewModelUpdate(previousViewModel) - Called when viewModel updates
166
- }
167
- ```
168
-
169
- ### Key Concepts
170
-
171
- - **TSX/JSX Syntax** - Similar to React but compiles to native views
172
- - **State Management** - Use component properties and setState
173
- - **Flexbox Layout** - Use flexbox properties for layout
174
- - **Event Handlers** - Handle user interactions with callbacks
175
- - **Provider Pattern** - Dependency injection for passing services down the component tree
176
-
177
- ## Common Patterns
178
-
179
- ### Styling Components
180
-
181
- ```typescript
182
- <view
183
- backgroundColor="#FFFFFF"
184
- padding={20}
185
- flexDirection="column"
186
- alignItems="center"
187
- >
188
- <label value="Styled text" fontSize={16} color="#000000" />
189
- </view>
190
- ```
191
-
192
- ### Handling Events
193
-
194
- ```typescript
195
- class MyButton extends Component {
196
- private handlePress() {
197
- console.log('Button pressed!');
198
- }
199
-
200
- onRender() {
201
- <view onPress={() => this.handlePress()}>
202
- <label value="Click Me" />
203
- </view>;
204
- }
205
- }
206
- ```
207
-
208
- ### Using Providers
209
-
210
- ```typescript
211
- import { Provider } from 'valdi_core/src/Provider';
212
-
213
- class App extends Component {
214
- onRender() {
215
- const myService = new MyService();
216
-
217
- <Provider value={myService}>
218
- <MyChildComponent />
219
- </Provider>;
220
- }
221
- }
222
- ```
223
-
224
- ## Available Standard Library Modules
225
-
226
- - `valdi_core` - Core component and runtime APIs
227
- - `valdi_http` - Promise-based HTTP client for network requests
228
- - `valdi_navigation` - Navigation utilities
229
- - `valdi_rxjs` - RxJS integration for reactive programming
230
- - `persistence` - Key-value storage with encryption and TTL support
231
- - `foundation`, `coreutils` - Common utilities (arrays, Base64, LRU cache, UUID, etc.)
232
- - `worker` - Worker service support for background JavaScript execution
233
-
234
- ## Debugging
235
-
236
- - **VSCode Integration** - Set breakpoints and debug TypeScript code
237
- - **Hermes Debugger** - Use Chrome DevTools for JavaScript debugging
238
- - **Hot Reload** - See changes instantly without rebuilding
239
- - **Native Debugging** - Use Xcode or Android Studio for platform-specific issues
240
-
241
- See Valdi documentation at `/docs/docs/workflow-hermes-debugger.md` for detailed debugging instructions.
242
-
243
- ## Common Pitfalls
244
-
245
- 1. **Always run `valdi projectsync`** after changing dependencies or config files
246
- 2. **Use hot reload during development** - Much faster than rebuilding
247
- 3. **Flexbox layout** - Valdi uses flexbox, not native iOS/Android layout
248
- 4. **Component state** - Remember to call `setState()` to trigger re-renders
249
- 5. **Build cache** - If builds seem stuck, try `bazel clean`
250
-
251
- ## Important Files
252
-
253
- - **`config.yaml`** - Project configuration (dependencies, settings)
254
- - **`WORKSPACE`** - Bazel workspace and external dependencies
255
- - **`BUILD.bazel`** - Build rules for each module
256
- - **`.bazelrc`** - Bazel build flags and configuration
257
-
258
- ## Getting Help
259
-
260
- - **Documentation** - Valdi docs in the framework repository at `/docs/`
261
- - **Discord** - Join the [Valdi Discord community](https://discord.gg/uJyNEeYX2U)
262
- - **Examples** - Check `/apps/` directory in Valdi repository for examples
263
- - **API Reference** - See `/docs/api/` for comprehensive API documentation
264
- - **Codelabs** - Step-by-step tutorials at `/docs/codelabs/`
265
-
266
- ## Key Points for AI Assistants
267
-
268
- 1. **This is a Valdi application** - Not React, React Native, or web-based
269
- 2. **TSX compiles to native** - No JavaScript runtime on device, components are compiled
270
- 3. **Use `valdi` CLI commands** - Primary tool for building and running
271
- 4. **Hot reload is fast** - Encourage using it for rapid iteration
272
- 5. **Bazel is the build system** - Direct bazel commands available but CLI preferred
273
- 6. **Cross-platform by default** - Code runs on iOS, Android, and macOS
274
-
275
- ---
276
-
277
- *This document is intended for AI coding assistants to quickly understand this Valdi application. For comprehensive Valdi framework documentation, refer to the main Valdi repository at https://github.com/Snapchat/Valdi*
278
-
@@ -1,19 +0,0 @@
1
- load("@valdi//bzl/valdi:valdi_application.bzl", "valdi_application")
2
- load("@valdi//bzl/valdi:valdi_exported_library.bzl", "valdi_exported_library")
3
-
4
- valdi_application(
5
- name = "{{MODULE_NAME}}_app",
6
- ios_bundle_id = "com.website.{{MODULE_NAME}}",
7
- ios_families = ["iphone"],
8
- root_component_path = "App@{{MODULE_NAME}}/src/App",
9
- title = "{{MODULE_NAME}}",
10
- version = "1.0.0",
11
- deps = ["//modules/{{MODULE_NAME}}"],
12
- )
13
-
14
- valdi_exported_library(
15
- name = "{{MODULE_NAME}}_export",
16
- ios_bundle_id = "com.website.{{MODULE_NAME}}.lib",
17
- ios_bundle_name = "{{MODULE_NAME_PASCAL_CASED}}",
18
- deps = ["//modules/{{MODULE_NAME}}"],
19
- )
@@ -1,21 +0,0 @@
1
- load("@valdi//bzl/valdi:valdi_module.bzl", "valdi_module")
2
-
3
- valdi_module(
4
- name = "{{MODULE_NAME}}",
5
- srcs = glob([
6
- "src/**/*.ts",
7
- "src/**/*.tsx",
8
- ]),
9
- res = glob([
10
- "res/**/*.jpeg",
11
- "res/**/*.jpg",
12
- "res/**/*.png",
13
- "res/**/*.svg",
14
- "res/**/*.webp",
15
- ]),
16
- visibility = ["//visibility:public"],
17
- deps = [
18
- "@valdi//src/valdi_modules/src/valdi/valdi_core",
19
- "@valdi//src/valdi_modules/src/valdi/valdi_tsx",
20
- ],
21
- )
@@ -1,133 +0,0 @@
1
- import { StatefulComponent } from 'valdi_core/src/Component';
2
- import { ImageView, Label, View } from 'valdi_tsx/src/NativeTemplateElements';
3
- import { Style } from 'valdi_core/src/Style';
4
- import { systemBoldFont, systemFont } from 'valdi_core/src/SystemFont';
5
- import { AttributedText } from 'valdi_tsx/src/AttributedText';
6
- import { AttributedTextBuilder } from 'valdi_core/src/utils/AttributedTextBuilder';
7
- import { Device } from 'valdi_core/src/Device';
8
- import { getDaemonClientManager } from 'valdi_core/src/debugging/DaemonClientManagerResolver';
9
- import { IDaemonClientManagerListener } from 'valdi_core/src/debugging/DaemonClientManager';
10
- import res from '../res';
11
-
12
- /**
13
- * @ViewModel
14
- * @ExportModel
15
- */
16
- export interface AppViewModel {}
17
-
18
- /**
19
- * @Context
20
- * @ExportModel
21
- */
22
- export interface AppComponentContext {}
23
-
24
- interface State {
25
- hotReloaderConnected: boolean;
26
- }
27
-
28
- /**
29
- * @Component
30
- * @ExportModel
31
- */
32
- export class App extends StatefulComponent<AppViewModel, AppComponentContext> implements IDaemonClientManagerListener {
33
- state: State = { hotReloaderConnected: false };
34
-
35
- onCreate(): void {
36
- console.log('On App create!');
37
- getDaemonClientManager().addListener(this);
38
- }
39
-
40
- onDestroy(): void {
41
- console.log('On App destroy!');
42
- getDaemonClientManager().removeListener(this);
43
- }
44
-
45
- onAvailabilityChanged(available: boolean): void {
46
- this.setState({ hotReloaderConnected: available });
47
- }
48
-
49
- onRender(): void {
50
- console.log('On App render!');
51
- <view style={styles.main}>
52
- <image style={styles.logo} src={res.valdi} />
53
- <layout padding={20}>
54
- <label style={styles.title} value={`Welcome to Valdi!`} />
55
- </layout>
56
- <label style={styles.subtitle} value={this.renderLabel()} />
57
- </view>;
58
- }
59
-
60
- private renderLabel(): AttributedText {
61
- const textBuilder = new AttributedTextBuilder();
62
-
63
- textBuilder.appendText('This is currently running on ');
64
- textBuilder.appendStyled({
65
- content: this.getPlatformString(),
66
- attributes: {
67
- color: 'red',
68
- font: systemBoldFont(20),
69
- },
70
- });
71
-
72
- textBuilder.appendText('\nHot reloader ');
73
- if (this.state.hotReloaderConnected) {
74
- textBuilder.appendStyled({
75
- content: 'connected',
76
- attributes: {
77
- color: 'green',
78
- font: systemBoldFont(20),
79
- },
80
- });
81
- } else {
82
- textBuilder.appendStyled({
83
- content: 'disconnected',
84
- attributes: {
85
- color: 'red',
86
- font: systemBoldFont(20),
87
- },
88
- });
89
- }
90
-
91
- return textBuilder.build();
92
- }
93
-
94
- private getPlatformString(): string {
95
- if (Device.isDesktop()) {
96
- return 'Desktop';
97
- } else if (Device.isIOS()) {
98
- return 'iOS';
99
- } else if (Device.isAndroid()) {
100
- return 'Android';
101
- } else {
102
- return 'Unknown';
103
- }
104
- }
105
- }
106
-
107
- const styles = {
108
- main: new Style<View>({
109
- backgroundColor: 'white',
110
- justifyContent: 'center',
111
- }),
112
- logo: new Style<ImageView>({
113
- width: 80,
114
- height: 80,
115
- alignSelf: 'center',
116
- borderRadius: 16,
117
- boxShadow: '0 0 3 rgba(0, 0, 0, 0.15)',
118
- }),
119
- title: new Style<Label>({
120
- color: 'black',
121
- font: systemBoldFont(24),
122
- accessibilityCategory: 'header',
123
- alignSelf: 'center',
124
- }),
125
-
126
- subtitle: new Style<Label>({
127
- alignSelf: 'center',
128
- color: 'black',
129
- font: systemFont(20),
130
- numberOfLines: 0,
131
- textAlign: 'center',
132
- }),
133
- };
@@ -1,24 +0,0 @@
1
- {
2
- "name": "hello_world",
3
- "version": "1.0.0",
4
- "description": "Valdi Helloworld app",
5
- "license": "ISC",
6
- "devDependencies": {
7
- "@snap/eslint-plugin-valdi": "1.0.2",
8
- "@types/eslint": "^9.6.1",
9
- "@types/jasmine": "^5.1.7",
10
- "@typescript-eslint/eslint-plugin": "^6.21.0",
11
- "@typescript-eslint/parser": "^6.21.0",
12
- "@typescript-eslint/utils": "^6.21.0",
13
- "eslint": "^8.27.0",
14
- "eslint-config-prettier": "^8.5.0",
15
- "eslint-plugin-import": "^2.26.0",
16
- "eslint-plugin-prettier": "^4.2.1",
17
- "eslint-plugin-rxjs": "^5.0.2",
18
- "eslint-plugin-unused-imports": "^3.2.0",
19
- "jasmine": "^5.6.0",
20
- "ts-node": "^10.9.2",
21
- "typescript": "5.3.3"
22
- }
23
- }
24
-
@@ -1,21 +0,0 @@
1
- load("@valdi//bzl/valdi:valdi_module.bzl", "valdi_module")
2
-
3
- cc_library(
4
- name = "{{MODULE_NAME}}_cpp_impl",
5
- srcs = glob(["cpp/**/*.cpp"]),
6
- hdrs = glob(["cpp/**/*.hpp"]),
7
- includes = [],
8
- deps = [":{{MODULE_NAME}}_cpp"],
9
- alwayslink = 1,
10
- )
11
-
12
- valdi_module(
13
- name = "{{MODULE_NAME}}",
14
- srcs = glob([
15
- "src/**/*.ts",
16
- "src/**/*.tsx",
17
- ]),
18
- native_deps = [":{{MODULE_NAME}}_cpp_impl"],
19
- visibility = ["//visibility:public"],
20
- deps = [],
21
- )
@@ -1,28 +0,0 @@
1
- #include "valdi_modules/{{MODULE_NAME}}/{{MODULE_NAME}}.hpp"
2
-
3
- using namespace Valdi;
4
-
5
- namespace snap::valdi_modules::{{MODULE_NAME}} {
6
-
7
- class CalculatorModuleFactoryImpl : public CalculatorModuleFactory {
8
- public:
9
- CalculatorModuleFactoryImpl() = default;
10
-
11
- Ref<CalculatorModule> onLoadModule() final {
12
- class CalculatorModuleImpl : public CalculatorModule {
13
- public:
14
- CalculatorModuleImpl() = default;
15
- ~CalculatorModuleImpl() override = default;
16
-
17
- double multiply(double left, double right) final {
18
- return left * right;
19
- }
20
- };
21
-
22
- return makeShared<CalculatorModuleImpl>();
23
- }
24
- };
25
-
26
- static auto registerCalculatorModuleFactory = RegisterModuleFactory::registerTyped<CalculatorModuleFactoryImpl>();
27
-
28
- } // namespace snap::valdi_modules::{{MODULE_NAME}}
@@ -1,4 +0,0 @@
1
- /**
2
- * @ExportModule
3
- */
4
- export declare function multiply(left: number, right: number): number;
@@ -1,39 +0,0 @@
1
- load("@valdi//bzl/valdi:valdi_module.bzl", "valdi_module")
2
- load("@valdi//bzl/valdi:valdi_android_library.bzl", "valdi_android_library")
3
-
4
- valdi_android_library(
5
- name = "android_impl",
6
- srcs = glob([
7
- "android/**/*.kt",
8
- ]),
9
- deps = [
10
- ":{{MODULE_NAME}}_api_kt",
11
- ],
12
- )
13
-
14
- objc_library(
15
- name = "ios_impl",
16
- srcs = glob([
17
- "ios/**/*.m",
18
- ]),
19
- hdrs = glob([
20
- "ios/**/*.h",
21
- ]),
22
- copts = ["-I."],
23
- deps = [
24
- ":{{MODULE_NAME}}_api_objc",
25
- ],
26
- )
27
-
28
- valdi_module(
29
- name = "{{MODULE_NAME}}",
30
- srcs = glob([
31
- "src/**/*.ts",
32
- "src/**/*.tsx",
33
- ]),
34
- android_deps = [":android_impl"],
35
- ios_deps = [":ios_impl"],
36
- ios_module_name = "{{MODULE_NAME_PASCAL_CASED}}",
37
- visibility = ["//visibility:public"],
38
- deps = [],
39
- )
@@ -1,18 +0,0 @@
1
- package com.snap.modules.{{MODULE_NAME}}
2
-
3
- import com.snapchat.client.valdi_core.ModuleFactory
4
- import com.snap.valdi.modules.RegisterValdiModule
5
- import com.snap.modules.{{MODULE_NAME}}.CalculatorModuleFactory
6
- import com.snap.modules.{{MODULE_NAME}}.CalculatorModule
7
-
8
- @RegisterValdiModule
9
- class CalculatorModuleFactoryImpl: CalculatorModuleFactory() {
10
-
11
- override fun onLoadModule(): CalculatorModule {
12
- return object: CalculatorModule {
13
- override fun multiply(left: Double, right: Double): Double {
14
- return left * right
15
- }
16
- }
17
- }
18
- }
@@ -1,31 +0,0 @@
1
- #import "valdi_core/SCValdiModuleFactoryRegistry.h"
2
- #import <{{MODULE_NAME_PASCAL_CASED}}Types/{{MODULE_NAME_PASCAL_CASED}}Types.h>
3
- #import <Foundation/Foundation.h>
4
-
5
- @interface SCCCalculatorModule: NSObject<{{MODULE_NAME_PASCAL_CASED}}CalculatorModule>
6
-
7
- @end
8
-
9
- @implementation SCCCalculatorModule
10
-
11
- - (double)multiplyWithLeft:(double)left right:(double)right
12
- {
13
- return left * right;
14
- }
15
-
16
- @end
17
-
18
- @interface SCCCalculatorModuleFactoryImpl : {{MODULE_NAME_PASCAL_CASED}}CalculatorModuleFactory
19
-
20
- @end
21
-
22
- @implementation SCCCalculatorModuleFactoryImpl
23
-
24
- VALDI_REGISTER_MODULE()
25
-
26
- - (id<{{MODULE_NAME_PASCAL_CASED}}CalculatorModule>)onLoadModule
27
- {
28
- return [SCCCalculatorModule new];
29
- }
30
-
31
- @end
@@ -1,4 +0,0 @@
1
- /**
2
- * @ExportModule
3
- */
4
- export declare function multiply(left: number, right: number): number;
@@ -1,41 +0,0 @@
1
- load("@valdi//bzl/valdi:valdi_module.bzl", "valdi_module")
2
- load("@valdi//bzl/valdi:valdi_android_library.bzl", "valdi_android_library")
3
-
4
- valdi_android_library(
5
- name = "android_impl",
6
- srcs = glob([
7
- "android/**/*.kt",
8
- ]),
9
- deps = [
10
- "@valdi//valdi:valdi_java",
11
- ],
12
- )
13
-
14
- objc_library(
15
- name = "ios_impl",
16
- srcs = glob([
17
- "ios/**/*.m",
18
- ]),
19
- hdrs = glob([
20
- "ios/**/*.h",
21
- ]),
22
- copts = ["-I."],
23
- deps = [
24
- "@valdi//valdi_core",
25
- ],
26
- )
27
-
28
- valdi_module(
29
- name = "{{MODULE_NAME}}",
30
- srcs = glob([
31
- "src/**/*.ts",
32
- "src/**/*.tsx",
33
- ]),
34
- android_deps = [":android_impl"],
35
- ios_deps = [":ios_impl"],
36
- ios_module_name = "{{MODULE_NAME_PASCAL_CASED}}",
37
- visibility = ["//visibility:public"],
38
- deps = [
39
- "@valdi//src/valdi_modules/src/valdi/valdi_tsx",
40
- ],
41
- )