@snap/valdi 1.0.6 → 1.0.7

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.
@@ -45,6 +45,13 @@ valdi install ios # Build & install iOS app
45
45
  valdi hotreload # Start hot reload
46
46
  ```
47
47
 
48
+ ## Exported library / host apps
49
+
50
+ When integrating an exported AAR or xcframework into a host app:
51
+
52
+ - **Android:** Generated view classes use package **`com.snap.modules.<module_name>`** (e.g. `com.snap.modules.test_test.App`), not `com.snap.valdi.modules`. `System.loadLibrary(...)` must use the exact `valdi_exported_library()` target name (e.g. `test_test_export`).
53
+ - **iOS:** Root view class is **`<module_name><RootComponentName>`** where `module_name` is the Valdi **module name** from `valdi_module()` (snake_case, e.g. `test_test` → `test_testApp`), not `ios_bundle_name`. For export use **`--library test_test_export_ios`** (platform-suffixed target). Embed the xcframework into the app's **Frameworks** folder (Embed Frameworks phase → destination **Frameworks**, not PlugIns), or the app crashes at launch with "Library not loaded: @rpath/...framework/...".
54
+
48
55
  ## More Information
49
56
 
50
57
  - **Comprehensive guide**: `/AGENTS.md` (621 lines)
@@ -144,6 +144,11 @@ bazel build //modules/{{MODULE_NAME}}:{{MODULE_NAME}}
144
144
  bazel test //modules/{{MODULE_NAME}}:tests
145
145
  ```
146
146
 
147
+ ### Exporting and host apps (AAR / xcframework)
148
+
149
+ - **Android host:** Use `com.snap.modules.<module_name>.<RootComponent>` for the generated view class (e.g. `com.snap.modules.{{MODULE_NAME}}.App`), not `com.snap.valdi.modules`. `System.loadLibrary(...)` = exact `valdi_exported_library()` target name. See `android_app/README.md`.
150
+ - **iOS host:** Root view class = **`<module_name><RootComponentName>`** (Valdi module name from `valdi_module()`, snake_case, e.g. `{{MODULE_NAME}}App`), not `ios_bundle_name`. Export with `--library {{MODULE_NAME}}_export_ios`. Embed the xcframework into the app's **Frameworks** folder (Build Phases → Embed Frameworks → destination **Frameworks**; `dstSubfolderSpec = 10`), not PlugIns, or the app crashes at launch with "Library not loaded: @rpath/...framework/...".
151
+
147
152
  ## Valdi Component Basics
148
153
 
149
154
  Components use a class-based pattern with lifecycle methods:
@@ -275,4 +280,3 @@ See Valdi documentation at `/docs/docs/workflow-hermes-debugger.md` for detailed
275
280
  ---
276
281
 
277
282
  *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
-
package/README.md CHANGED
@@ -47,6 +47,7 @@ Now you can edit your TypeScript files and see changes instantly on your device!
47
47
  For complete documentation, see:
48
48
  - [Command Line Reference](https://github.com/Snapchat/Valdi/blob/main/docs/docs/command-line-references.md)
49
49
  - [Installation Guide](https://github.com/Snapchat/Valdi/blob/main/docs/INSTALL.md)
50
+ - [Troubleshooting](https://github.com/Snapchat/Valdi/blob/main/docs/TROUBLESHOOTING.md) — run `valdi doctor` to diagnose issues, or ask on [Discord](https://discord.gg/uJyNEeYX2U)
50
51
 
51
52
  ### Key Commands
52
53
 
@@ -71,6 +72,7 @@ For complete documentation, see:
71
72
  - Creates a new Valdi project in the current directory
72
73
  - Sets up BUILD.bazel, WORKSPACE, package.json, and source files
73
74
  - Supports multiple application templates (Hello World, Counter, etc.)
75
+ - Options: `-y` (skip confirmation), `-n` (project name), `-t` (application type), `-l` (local Valdi path), `-c` (clean directory first). Run `valdi bootstrap --help` for all options.
74
76
 
75
77
  **`valdi install <platform>`** - Build and install
76
78
  - Builds and installs app to connected device/simulator
@@ -80,6 +82,8 @@ For complete documentation, see:
80
82
  - Enables instant hot reload during development
81
83
  - Watches for file changes and updates app in milliseconds
82
84
 
85
+ **Other commands:** `valdi build <platform>` (build without installing), `valdi package <platform>` (create distributable app), `valdi export <platform>` (export library for native apps), `valdi test` (run tests), `valdi lint check` / `valdi lint format` (lint and format code), `valdi log` (stream device logs), `valdi projectsync` (sync VS Code project and native bindings), `valdi completion` (shell autocomplete setup). Use `valdi <command> --help` for options.
86
+
83
87
  For complete command documentation, see [Command Line Reference](https://github.com/Snapchat/Valdi/blob/main/docs/docs/command-line-references.md).
84
88
 
85
89
  ### Creating New Modules
@@ -87,8 +91,8 @@ For complete command documentation, see [Command Line Reference](https://github.
87
91
  ```sh
88
92
  valdi new_module
89
93
 
90
- # Create module without prompts
91
- valdi new_module my_new_module --skip-checks --android-class-path='com.example.my_module' --ios-module-name='XYZMyModule'
94
+ # Create module without prompts (specify template to skip the prompt)
95
+ valdi new_module my_new_module --skip-checks --template=ui_component
92
96
 
93
97
  # Help
94
98
  $ valdi new_module --help
@@ -132,12 +136,11 @@ Positionals:
132
136
  module-name Name of the Valdi module.
133
137
 
134
138
  Options:
135
- --debug Run with debug logging [boolean] [default: false]
136
- --version Show version number [boolean]
137
- --help Show help [boolean]
138
- --skip-checks Skips confirmation prompts. [boolean]
139
- --android-class-path Android class path to use for generated Android sources. [string]
140
- --ios-module-name iOS class prefix to use for generated iOS sources. [string]
139
+ --debug Run with debug logging [boolean] [default: false]
140
+ --version Show version number [boolean]
141
+ --help Show help [boolean]
142
+ --skip-checks Skips confirmation prompts. [boolean]
143
+ --template Module template to use (skips the prompt). One of: ui_component, ios_android_bridge_module, cpp_bridge_module, ios_android_view_module [string]
141
144
  ```
142
145
 
143
146
  ## For Contributors
@@ -29,8 +29,8 @@ const ALL_APPLICATION_TEMPLATES = [
29
29
  ];
30
30
  const VALDI_GIT_URL = 'https://github.com/Snapchat/Valdi';
31
31
  const VALDI_WIDGETS_GIT_URL = 'https://github.com/Snapchat/Valdi_Widgets';
32
- const DEFAULT_VALDI_RELEASE_TAG = 'beta-0.0.2';
33
- const DEFAULT_VALDI_WIDGETS_RELEASE_TAG = 'beta-0.0.2';
32
+ const DEFAULT_VALDI_RELEASE_TAG = 'beta-0.0.3';
33
+ const DEFAULT_VALDI_WIDGETS_RELEASE_TAG = 'beta-0.0.3';
34
34
  const DEFAULT_VALDI_IMPORT = `
35
35
  http_archive(
36
36
  name = "valdi",
@@ -164,6 +164,7 @@ function initializeConfigFiles(projectName, template, valdiImport, valdiWidgetsI
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
166
  fileUtils_1.TemplateFile.init(constants_1.TEMPLATE_BASE_PATHS.CURSOR_RULES),
167
+ fileUtils_1.TemplateFile.init(constants_1.TEMPLATE_BASE_PATHS.AGENTS).withReplacements({ MODULE_NAME: projectName }),
167
168
  ];
168
169
  TEMPLATE_FILES.forEach(templateFile => {
169
170
  console.log((0, logUtils_1.wrapInColor)(`Creating ${templateFile.baseName} in ${templateFile.outputPath}...`, constants_1.ANSI_COLORS.YELLOW_COLOR));
@@ -43,6 +43,7 @@ var TEMPLATE_BASE_PATHS;
43
43
  TEMPLATE_BASE_PATHS["GIT_IGNORE"] = ".gitignore.template";
44
44
  TEMPLATE_BASE_PATHS["EDITOR_CONFIG"] = ".editorconfig.template";
45
45
  TEMPLATE_BASE_PATHS["CURSOR_RULES"] = ".cursorrules.template";
46
+ TEMPLATE_BASE_PATHS["AGENTS"] = "AGENTS.md.template";
46
47
  })(TEMPLATE_BASE_PATHS || (exports.TEMPLATE_BASE_PATHS = TEMPLATE_BASE_PATHS = {}));
47
48
  exports.VALID_PLATFORMS = [PLATFORM.ANDROID, PLATFORM.IOS, PLATFORM.MACOS, PLATFORM.CLI];
48
49
  exports.IOS_BAZEL_APPLICATION_TAG = 'valdi_ios_application';
package/dist/index.js CHANGED
@@ -14,6 +14,11 @@ function main() {
14
14
  .demandCommand(1, 'Need at least one command to execute')
15
15
  .recommendCommands()
16
16
  .strict()
17
+ .option('debug', {
18
+ describe: 'Run with debug logging',
19
+ type: 'boolean',
20
+ default: false,
21
+ })
17
22
  .version('version', 'Show version number', package_json_1.version)
18
23
  .scriptName('valdi')
19
24
  .wrap(yargs_1.default.terminalWidth())
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snap/valdi",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "Valdi CLI tools for developers",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -58,9 +58,9 @@ const VALDI_GIT_URL = 'https://github.com/Snapchat/Valdi';
58
58
  const VALDI_WIDGETS_GIT_URL = 'https://github.com/Snapchat/Valdi_Widgets';
59
59
 
60
60
  /** Pinned Valdi release used by default for reproducible bootstraps. Bump when cutting a new Valdi release. */
61
- const DEFAULT_VALDI_RELEASE_TAG = 'beta-0.0.2';
61
+ const DEFAULT_VALDI_RELEASE_TAG = 'beta-0.0.3';
62
62
  /** Pinned Valdi_Widgets release used by default. Should match the Valdi release cycle. */
63
- const DEFAULT_VALDI_WIDGETS_RELEASE_TAG = 'beta-0.0.2';
63
+ const DEFAULT_VALDI_WIDGETS_RELEASE_TAG = 'beta-0.0.3';
64
64
 
65
65
  const DEFAULT_VALDI_IMPORT = `
66
66
  http_archive(
@@ -232,6 +232,7 @@ function initializeConfigFiles(
232
232
  TemplateFile.init(TEMPLATE_BASE_PATHS.WATCHMAN_CONFIG),
233
233
  TemplateFile.init(TEMPLATE_BASE_PATHS.EDITOR_CONFIG),
234
234
  TemplateFile.init(TEMPLATE_BASE_PATHS.CURSOR_RULES),
235
+ TemplateFile.init(TEMPLATE_BASE_PATHS.AGENTS).withReplacements({ MODULE_NAME: projectName }),
235
236
  ];
236
237
 
237
238
  TEMPLATE_FILES.forEach(templateFile => {
@@ -43,6 +43,7 @@ export enum TEMPLATE_BASE_PATHS {
43
43
  GIT_IGNORE = '.gitignore.template',
44
44
  EDITOR_CONFIG = '.editorconfig.template',
45
45
  CURSOR_RULES = '.cursorrules.template',
46
+ AGENTS = 'AGENTS.md.template',
46
47
  }
47
48
 
48
49
  export const VALID_PLATFORMS: string[] = [PLATFORM.ANDROID, PLATFORM.IOS, PLATFORM.MACOS, PLATFORM.CLI];
package/src/index.ts CHANGED
@@ -13,6 +13,11 @@ function main() {
13
13
  .demandCommand(1, 'Need at least one command to execute')
14
14
  .recommendCommands()
15
15
  .strict()
16
+ .option('debug', {
17
+ describe: 'Run with debug logging',
18
+ type: 'boolean',
19
+ default: false,
20
+ })
16
21
  .version('version', 'Show version number', version)
17
22
  .scriptName('valdi')
18
23
  .wrap(yargs.terminalWidth())
@@ -1,291 +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 CLI application.
4
-
5
- ## Overview
6
-
7
- This is a Valdi command-line application that runs in a terminal. Valdi compiles TypeScript to native code, enabling you to write performant CLI tools in TypeScript with access to native platform APIs.
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 source files
89
- - `BUILD.bazel` files define how modules are built
90
- - `src/` contains your application 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** - Framework that compiles TypeScript to native code
98
- - **TypeScript** - Primary development language
99
- - **Bazel** - Build system (note: `bzl` is an alias for `bazel`)
100
-
101
- ## Development Workflow
102
-
103
- ### Initial Setup
104
-
105
- ```bash
106
- # Install Valdi CLI (if not already installed)
107
- cd path/to/valdi/npm_modules/cli
108
- npm run cli:install
109
-
110
- # Setup development environment
111
- valdi dev_setup
112
-
113
- # Sync project (run after changing dependencies or config)
114
- valdi projectsync
115
- ```
116
-
117
- ### Building and Running
118
-
119
- ```bash
120
- # Build the CLI application
121
- bazel build //modules/{{MODULE_NAME}}:{{MODULE_NAME}}
122
-
123
- # Run the application
124
- bazel run //modules/{{MODULE_NAME}}:{{MODULE_NAME}}
125
-
126
- # Build and run with arguments
127
- bazel run //modules/{{MODULE_NAME}}:{{MODULE_NAME}} -- --your-args-here
128
- ```
129
-
130
- ### Common Commands
131
-
132
- ```bash
133
- # Sync project configuration
134
- valdi projectsync
135
-
136
- # Build specific targets
137
- bazel build //modules/{{MODULE_NAME}}:{{MODULE_NAME}}
138
-
139
- # Run tests
140
- bazel test //modules/{{MODULE_NAME}}:tests
141
-
142
- # Clean build cache
143
- bazel clean
144
- ```
145
-
146
- ## TypeScript Development
147
-
148
- ### Entry Point
149
-
150
- Your CLI application typically has an entry point file (e.g., `index.ts`):
151
-
152
- ```typescript
153
- // Example CLI application entry point
154
- function main(args: string[]) {
155
- console.log('Hello from Valdi CLI!');
156
- console.log('Arguments:', args);
157
-
158
- // Your application logic here
159
- }
160
-
161
- // Entry point
162
- main(process.argv.slice(2));
163
- ```
164
-
165
- ### Using Standard Library Modules
166
-
167
- ```typescript
168
- // HTTP requests
169
- import { HTTPClient } from 'valdi_http/src/HTTPClient';
170
-
171
- // Utilities
172
- import { Base64 } from 'coreutils/src/Base64';
173
- import { UUID } from 'coreutils/src/uuidUtils';
174
-
175
- // File system operations
176
- import { FileSystem } from 'file_system/src/FileSystem';
177
-
178
- // Persistence
179
- import { PersistentStorage } from 'persistence/src/PersistentStorage';
180
- ```
181
-
182
- ## Available Standard Library Modules
183
-
184
- - `valdi_core` - Core runtime APIs
185
- - `valdi_http` - Promise-based HTTP client for network requests
186
- - `valdi_rxjs` - RxJS integration for reactive programming
187
- - `persistence` - Key-value storage with encryption and TTL support
188
- - `file_system` - Low-level file I/O operations
189
- - `foundation`, `coreutils` - Common utilities (arrays, Base64, LRU cache, UUID, etc.)
190
- - `worker` - Worker service support for background execution
191
-
192
- ## Debugging
193
-
194
- - **VSCode Integration** - Set breakpoints and debug TypeScript code
195
- - **Console logging** - Use `console.log()`, `console.error()`, etc.
196
- - **Command line arguments** - Pass arguments after `--` in bazel run
197
-
198
- ## Common Patterns
199
-
200
- ### Command Line Arguments
201
-
202
- ```typescript
203
- interface CliArgs {
204
- input?: string;
205
- output?: string;
206
- verbose?: boolean;
207
- }
208
-
209
- function parseArgs(args: string[]): CliArgs {
210
- const parsed: CliArgs = {};
211
-
212
- for (let i = 0; i < args.length; i++) {
213
- if (args[i] === '--input' && i + 1 < args.length) {
214
- parsed.input = args[i + 1];
215
- i++;
216
- } else if (args[i] === '--output' && i + 1 < args.length) {
217
- parsed.output = args[i + 1];
218
- i++;
219
- } else if (args[i] === '--verbose') {
220
- parsed.verbose = true;
221
- }
222
- }
223
-
224
- return parsed;
225
- }
226
- ```
227
-
228
- ### Async Operations
229
-
230
- ```typescript
231
- async function fetchData(url: string): Promise<void> {
232
- try {
233
- const client = new HTTPClient();
234
- const response = await client.get(url);
235
- console.log('Response:', response);
236
- } catch (error) {
237
- console.error('Error fetching data:', error);
238
- }
239
- }
240
- ```
241
-
242
- ### File Operations
243
-
244
- ```typescript
245
- import { FileSystem } from 'file_system/src/FileSystem';
246
-
247
- function readConfigFile(path: string): string {
248
- try {
249
- const fs = FileSystem.getInstance();
250
- return fs.readFileSync(path, 'utf8');
251
- } catch (error) {
252
- console.error('Error reading file:', error);
253
- return '';
254
- }
255
- }
256
- ```
257
-
258
- ## Common Pitfalls
259
-
260
- 1. **Always run `valdi projectsync`** after changing dependencies or config files
261
- 2. **Use async/await** for asynchronous operations
262
- 3. **Error handling** - Always handle errors gracefully in CLI applications
263
- 4. **Build cache** - If builds seem stuck, try `bazel clean`
264
- 5. **Arguments** - Remember to use `--` before passing arguments to your CLI app
265
-
266
- ## Important Files
267
-
268
- - **`config.yaml`** - Project configuration (dependencies, settings)
269
- - **`WORKSPACE`** - Bazel workspace and external dependencies
270
- - **`BUILD.bazel`** - Build rules for each module
271
- - **`.bazelrc`** - Bazel build flags and configuration
272
-
273
- ## Getting Help
274
-
275
- - **Documentation** - Valdi docs in the framework repository at `/docs/`
276
- - **Discord** - Join the [Valdi Discord community](https://discord.gg/uJyNEeYX2U)
277
- - **Examples** - Check `/apps/` directory in Valdi repository for examples
278
- - **CLI Documentation** - See `/docs/docs/workflow-cli-application.md`
279
-
280
- ## Key Points for AI Assistants
281
-
282
- 1. **This is a CLI application** - No UI components, terminal-based
283
- 2. **TypeScript compiles to native** - Performant native executable
284
- 3. **Use Bazel commands** - Primary tool for building and running CLI apps
285
- 4. **Standard library available** - Access to HTTP, file system, persistence, etc.
286
- 5. **Cross-platform** - Can build for Linux, macOS, and potentially other platforms
287
-
288
- ---
289
-
290
- *This document is intended for AI coding assistants to quickly understand this Valdi CLI application. For comprehensive Valdi framework documentation, refer to the main Valdi repository at https://github.com/Snapchat/Valdi*
291
-