@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
@@ -1,5 +1,6 @@
1
- load("@valdi//bzl/valdi:valdi_module.bzl", "valdi_module")
1
+ load("@aspect_rules_ts//ts:defs.bzl", "ts_project")
2
2
  load("@valdi//bzl/valdi:valdi_android_library.bzl", "valdi_android_library")
3
+ load("@valdi//bzl/valdi:valdi_module.bzl", "valdi_module")
3
4
 
4
5
  valdi_android_library(
5
6
  name = "android_impl",
@@ -25,6 +26,19 @@ objc_library(
25
26
  ],
26
27
  )
27
28
 
29
+ ts_project(
30
+ name = "{{MODULE_NAME}}_web",
31
+ srcs = glob([
32
+ "web/**/*.ts",
33
+ "web/**/*.d.ts",
34
+ ]),
35
+ allow_js = True,
36
+ composite = False,
37
+ transpiler = "tsc",
38
+ tsconfig = "web/tsconfig.json",
39
+ visibility = ["//visibility:public"],
40
+ )
41
+
28
42
  valdi_module(
29
43
  name = "{{MODULE_NAME}}",
30
44
  srcs = glob([
@@ -35,5 +49,6 @@ valdi_module(
35
49
  ios_deps = [":ios_impl"],
36
50
  ios_module_name = "{{MODULE_NAME_PASCAL_CASED}}",
37
51
  visibility = ["//visibility:public"],
52
+ web_deps = [":{{MODULE_NAME}}_web"],
38
53
  deps = [],
39
54
  )
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Web implementation of the Calculator bridge module.
3
+ *
4
+ * Registered automatically by RegisterNativeModules.js via moduleLoader.
5
+ */
6
+
7
+ function multiply(left: number, right: number): number {
8
+ return left * right;
9
+ }
10
+
11
+ export = { multiply };
@@ -0,0 +1,16 @@
1
+ {
2
+ "compilerOptions": {
3
+ "baseUrl": ".",
4
+ "lib": ["DOM", "ES2020"],
5
+ "module": "commonjs",
6
+ "moduleResolution": "node",
7
+ "strict": true,
8
+ "skipLibCheck": true,
9
+ "composite": false,
10
+ "allowJs": true
11
+ },
12
+ "include": [
13
+ "./**/*.ts",
14
+ "./**/*.d.ts"
15
+ ]
16
+ }
@@ -0,0 +1,75 @@
1
+ load("@aspect_rules_ts//ts:defs.bzl", "ts_project")
2
+ load("@valdi//bzl/valdi:valdi_android_library.bzl", "valdi_android_library")
3
+ load("@valdi//bzl/valdi:valdi_module.bzl", "valdi_module")
4
+
5
+ valdi_android_library(
6
+ name = "android_impl",
7
+ srcs = glob([
8
+ "android/**/*.kt",
9
+ ]),
10
+ visibility = ["//visibility:public"],
11
+ deps = [
12
+ ":{{MODULE_NAME}}_api_kt",
13
+ "@valdi//valdi:valdi_java",
14
+ ],
15
+ )
16
+
17
+ objc_library(
18
+ name = "ios_impl",
19
+ srcs = glob([
20
+ "ios/**/*.m",
21
+ ]),
22
+ hdrs = glob([
23
+ "ios/**/*.h",
24
+ ]),
25
+ copts = ["-I."],
26
+ visibility = ["//visibility:public"],
27
+ deps = [
28
+ ":{{MODULE_NAME}}_api_objc",
29
+ ],
30
+ )
31
+
32
+ objc_library(
33
+ name = "macos_impl",
34
+ srcs = glob([
35
+ "macos/**/*.m",
36
+ ]),
37
+ hdrs = glob([
38
+ "macos/**/*.h",
39
+ ]),
40
+ copts = ["-I."],
41
+ sdk_frameworks = ["AppKit"],
42
+ visibility = ["//visibility:public"],
43
+ )
44
+
45
+ ts_project(
46
+ name = "{{MODULE_NAME}}_web",
47
+ srcs = glob([
48
+ "web/**/*.ts",
49
+ "web/**/*.d.ts",
50
+ ]),
51
+ allow_js = True,
52
+ composite = False,
53
+ transpiler = "tsc",
54
+ tsconfig = "web/tsconfig.json",
55
+ visibility = ["//visibility:public"],
56
+ )
57
+
58
+ valdi_module(
59
+ name = "{{MODULE_NAME}}",
60
+ srcs = glob([
61
+ "src/**/*.ts",
62
+ "src/**/*.tsx",
63
+ ]),
64
+ android_deps = [":android_impl"],
65
+ ios_deps = [":ios_impl"],
66
+ ios_module_name = "SCC{{MODULE_NAME_PASCAL_CASED}}",
67
+ macos_deps = [":macos_impl"],
68
+ visibility = ["//visibility:public"],
69
+ web_deps = [":{{MODULE_NAME}}_web"],
70
+ deps = [
71
+ "@valdi//src/valdi_modules/src/valdi/foundation",
72
+ "@valdi//src/valdi_modules/src/valdi/valdi_core",
73
+ "@valdi//src/valdi_modules/src/valdi/valdi_tsx",
74
+ ],
75
+ )
@@ -0,0 +1,41 @@
1
+ package com.snap.modules.{{MODULE_NAME}}
2
+
3
+ import android.content.Context
4
+ import android.graphics.Color
5
+ import android.view.MotionEvent
6
+ import android.view.ViewGroup
7
+ import android.widget.LinearLayout
8
+ import android.widget.TextView
9
+ import com.snap.valdi.views.ValdiTouchEventResult
10
+ import com.snap.valdi.views.ValdiTouchTarget
11
+
12
+ /**
13
+ * Android native view for the {{MODULE_NAME}} polyglot module.
14
+ * ReflectionViewFactory requires a single-arg (Context) constructor.
15
+ */
16
+ class PolyglotNativeView(context: Context) : LinearLayout(context), ValdiTouchTarget {
17
+
18
+ init {
19
+ orientation = VERTICAL
20
+ layoutParams = ViewGroup.LayoutParams(
21
+ ViewGroup.LayoutParams.MATCH_PARENT,
22
+ ViewGroup.LayoutParams.MATCH_PARENT
23
+ )
24
+ setBackgroundColor(Color.parseColor("#E8E8E8"))
25
+
26
+ val label = TextView(context).apply {
27
+ text = "Hello from Android ({{MODULE_NAME}})"
28
+ setPadding(32, 32, 32, 16)
29
+ }
30
+ addView(label)
31
+ }
32
+
33
+ override fun processTouchEvent(event: MotionEvent): ValdiTouchEventResult {
34
+ val consumed = dispatchTouchEvent(event)
35
+ return if (consumed) {
36
+ ValdiTouchEventResult.ConsumeEventAndCancelOtherGestures
37
+ } else {
38
+ ValdiTouchEventResult.IgnoreEvent
39
+ }
40
+ }
41
+ }
@@ -0,0 +1,17 @@
1
+ package com.snap.modules.{{MODULE_NAME}}
2
+
3
+ import android.content.Context
4
+ import com.snap.valdi.attributes.AttributesBinder
5
+ import com.snap.valdi.attributes.AttributesBindingContext
6
+ import com.snap.valdi.attributes.RegisterAttributesBinder
7
+
8
+ @RegisterAttributesBinder
9
+ class PolyglotNativeViewAttributesBinder constructor(private val context: Context) : AttributesBinder<PolyglotNativeView> {
10
+
11
+ override val viewClass: Class<PolyglotNativeView>
12
+ get() = PolyglotNativeView::class.java
13
+
14
+ override fun bindAttributes(attributesBindingContext: AttributesBindingContext<PolyglotNativeView>) {
15
+ // Add custom attribute bindings here.
16
+ }
17
+ }
@@ -0,0 +1,8 @@
1
+ #import <UIKit/UIKit.h>
2
+
3
+ NS_ASSUME_NONNULL_BEGIN
4
+
5
+ @interface SCPolyglotView : UIView
6
+ @end
7
+
8
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,23 @@
1
+ #import "SCPolyglotView.h"
2
+
3
+ @implementation SCPolyglotView
4
+
5
+ - (instancetype)initWithFrame:(CGRect)frame {
6
+ self = [super initWithFrame:frame];
7
+ if (self) {
8
+ self.backgroundColor = [UIColor colorWithWhite:0.95 alpha:1];
9
+
10
+ UILabel *label = [[UILabel alloc] init];
11
+ label.text = @"Hello from iOS";
12
+ label.translatesAutoresizingMaskIntoConstraints = NO;
13
+ [self addSubview:label];
14
+
15
+ [NSLayoutConstraint activateConstraints:@[
16
+ [label.centerXAnchor constraintEqualToAnchor:self.centerXAnchor],
17
+ [label.centerYAnchor constraintEqualToAnchor:self.centerYAnchor],
18
+ ]];
19
+ }
20
+ return self;
21
+ }
22
+
23
+ @end
@@ -0,0 +1,8 @@
1
+ #import <AppKit/AppKit.h>
2
+
3
+ NS_ASSUME_NONNULL_BEGIN
4
+
5
+ @interface SCPolyglotView : NSView
6
+ @end
7
+
8
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,23 @@
1
+ #import "SCPolyglotView.h"
2
+
3
+ @implementation SCPolyglotView
4
+
5
+ - (instancetype)initWithFrame:(NSRect)frameRect {
6
+ self = [super initWithFrame:frameRect];
7
+ if (self) {
8
+ self.wantsLayer = YES;
9
+ self.layer.backgroundColor = [[NSColor colorWithWhite:0.93 alpha:1] CGColor];
10
+
11
+ NSTextField *label = [NSTextField labelWithString:@"Hello from macOS"];
12
+ label.translatesAutoresizingMaskIntoConstraints = NO;
13
+ [self addSubview:label];
14
+
15
+ [NSLayoutConstraint activateConstraints:@[
16
+ [label.centerXAnchor constraintEqualToAnchor:self.centerXAnchor],
17
+ [label.centerYAnchor constraintEqualToAnchor:self.centerYAnchor],
18
+ ]];
19
+ }
20
+ return self;
21
+ }
22
+
23
+ @end
@@ -0,0 +1,23 @@
1
+ import 'valdi_tsx/src/JSX';
2
+ import { View } from 'valdi_tsx/src/NativeTemplateElements';
3
+
4
+ export interface PolyglotCustomViewModel extends View {}
5
+
6
+ /**
7
+ * Polyglot custom-view wrapper.
8
+ *
9
+ * Each platform resolves the view by class name:
10
+ * - Android: ReflectionViewFactory creates PolyglotNativeView(context)
11
+ * - iOS: ObjC class linked via ios_deps
12
+ * - macOS: NSClassFromString() linked via macos_deps
13
+ * - Web: webPolyglotViews factory in web/ auto-registered at bundle time
14
+ */
15
+ export function PolyglotCustomView(viewModel: PolyglotCustomViewModel) {
16
+ <custom-view
17
+ androidClass={'com.snap.modules.{{MODULE_NAME}}.PolyglotNativeView'}
18
+ iosClass={'SCPolyglotView'}
19
+ macosClass={'SCPolyglotView'}
20
+ webClass={'{{MODULE_NAME_PASCAL_CASED}}WebView'}
21
+ {...viewModel}
22
+ />;
23
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Web polyglot entry for {{MODULE_NAME}}.
3
+ *
4
+ * Exports view factories that are auto-registered with the WebViewClassRegistry
5
+ * by the build-generated RegisterNativeModules.js.
6
+ */
7
+
8
+ function createWebViewFactory(): (container: HTMLElement) => void {
9
+ return (container: HTMLElement) => {
10
+ container.style.display = 'flex';
11
+ container.style.alignItems = 'center';
12
+ container.style.justifyContent = 'center';
13
+ container.style.padding = '12px';
14
+ container.style.backgroundColor = '#f8f9fa';
15
+ container.style.borderRadius = '8px';
16
+ container.style.border = '1px solid #ccc';
17
+ container.style.minHeight = '80px';
18
+
19
+ const label = document.createElement('span');
20
+ label.textContent = 'Hello from Web ({{MODULE_NAME}})';
21
+ label.style.fontSize = '14px';
22
+ label.style.fontWeight = '500';
23
+ container.appendChild(label);
24
+ };
25
+ }
26
+
27
+ export const webPolyglotViews: Record<string, (container: HTMLElement) => void> = {
28
+ // eslint-disable-next-line @typescript-eslint/naming-convention
29
+ {{MODULE_NAME_PASCAL_CASED}}WebView: createWebViewFactory(),
30
+ };
@@ -0,0 +1,16 @@
1
+ {
2
+ "compilerOptions": {
3
+ "baseUrl": ".",
4
+ "lib": ["DOM", "ES2020"],
5
+ "module": "commonjs",
6
+ "moduleResolution": "node",
7
+ "strict": true,
8
+ "skipLibCheck": true,
9
+ "composite": false,
10
+ "allowJs": true
11
+ },
12
+ "include": [
13
+ "./**/*.ts",
14
+ "./**/*.d.ts"
15
+ ]
16
+ }
@@ -1,282 +1,16 @@
1
- # AGENTS.md - Guide for AI Coding Assistants
1
+ # AI Assistant Context
2
2
 
3
- This document provides context and guidelines for AI coding assistants working on this Valdi application.
3
+ This is a Valdi application. Valdi compiles TypeScript/TSX to native iOS, Android, and macOS views — it is **not React**.
4
4
 
5
- ## Overview
5
+ ## Get AI Skills
6
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
7
+ Install context files so your AI tool generates correct Valdi code instead of React patterns:
135
8
 
136
9
  ```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
- ### 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
-
152
- ## Valdi Component Basics
153
-
154
- Components use a class-based pattern with lifecycle methods:
155
-
156
- ```typescript
157
- import { Component } from 'valdi_core/src/Component';
158
-
159
- class MyComponent extends Component {
160
- // Required: Render the component's UI
161
- onRender() {
162
- <view backgroundColor="#FFFC00" padding={30}>
163
- <label value="Hello World" color="black" />
164
- </view>;
165
- }
166
-
167
- // Optional lifecycle methods:
168
- // onCreate() - Called when component is first created
169
- // onDestroy() - Called before component is removed
170
- // onViewModelUpdate(previousViewModel) - Called when viewModel updates
171
- }
172
- ```
173
-
174
- ### Key Concepts
175
-
176
- - **TSX/JSX Syntax** - Similar to React but compiles to native views
177
- - **State Management** - Use component properties and setState
178
- - **Flexbox Layout** - Use flexbox properties for layout
179
- - **Event Handlers** - Handle user interactions with callbacks
180
- - **Provider Pattern** - Dependency injection for passing services down the component tree
181
-
182
- ## Common Patterns
183
-
184
- ### Styling Components
185
-
186
- ```typescript
187
- <view
188
- backgroundColor="#FFFFFF"
189
- padding={20}
190
- flexDirection="column"
191
- alignItems="center"
192
- >
193
- <label value="Styled text" fontSize={16} color="#000000" />
194
- </view>
195
- ```
196
-
197
- ### Handling Events
198
-
199
- ```typescript
200
- class MyButton extends Component {
201
- private handlePress() {
202
- console.log('Button pressed!');
203
- }
204
-
205
- onRender() {
206
- <view onPress={() => this.handlePress()}>
207
- <label value="Click Me" />
208
- </view>;
209
- }
210
- }
211
- ```
212
-
213
- ### Using Providers
214
-
215
- ```typescript
216
- import { Provider } from 'valdi_core/src/Provider';
217
-
218
- class App extends Component {
219
- onRender() {
220
- const myService = new MyService();
221
-
222
- <Provider value={myService}>
223
- <MyChildComponent />
224
- </Provider>;
225
- }
226
- }
10
+ npm install -g @snap/valdi
11
+ valdi skills install # installs skills for Claude Code, Cursor, or Copilot
227
12
  ```
228
13
 
229
- ## Available Standard Library Modules
230
-
231
- - `valdi_core` - Core component and runtime APIs
232
- - `valdi_http` - Promise-based HTTP client for network requests
233
- - `valdi_navigation` - Navigation utilities
234
- - `valdi_rxjs` - RxJS integration for reactive programming
235
- - `persistence` - Key-value storage with encryption and TTL support
236
- - `foundation`, `coreutils` - Common utilities (arrays, Base64, LRU cache, UUID, etc.)
237
- - `worker` - Worker service support for background JavaScript execution
238
-
239
- ## Debugging
240
-
241
- - **VSCode Integration** - Set breakpoints and debug TypeScript code
242
- - **Hermes Debugger** - Use Chrome DevTools for JavaScript debugging
243
- - **Hot Reload** - See changes instantly without rebuilding
244
- - **Native Debugging** - Use Xcode or Android Studio for platform-specific issues
245
-
246
- See Valdi documentation at `/docs/docs/workflow-hermes-debugger.md` for detailed debugging instructions.
247
-
248
- ## Common Pitfalls
249
-
250
- 1. **Always run `valdi projectsync`** after changing dependencies or config files
251
- 2. **Use hot reload during development** - Much faster than rebuilding
252
- 3. **Flexbox layout** - Valdi uses flexbox, not native iOS/Android layout
253
- 4. **Component state** - Remember to call `setState()` to trigger re-renders
254
- 5. **Build cache** - If builds seem stuck, try `bazel clean`
255
-
256
- ## Important Files
257
-
258
- - **`config.yaml`** - Project configuration (dependencies, settings)
259
- - **`WORKSPACE`** - Bazel workspace and external dependencies
260
- - **`BUILD.bazel`** - Build rules for each module
261
- - **`.bazelrc`** - Bazel build flags and configuration
262
-
263
- ## Getting Help
264
-
265
- - **Documentation** - Valdi docs in the framework repository at `/docs/`
266
- - **Discord** - Join the [Valdi Discord community](https://discord.gg/uJyNEeYX2U)
267
- - **Examples** - Check `/apps/` directory in Valdi repository for examples
268
- - **API Reference** - See `/docs/api/` for comprehensive API documentation
269
- - **Codelabs** - Step-by-step tutorials at `/docs/codelabs/`
270
-
271
- ## Key Points for AI Assistants
272
-
273
- 1. **This is a Valdi application** - Not React, React Native, or web-based
274
- 2. **TSX compiles to native** - No JavaScript runtime on device, components are compiled
275
- 3. **Use `valdi` CLI commands** - Primary tool for building and running
276
- 4. **Hot reload is fast** - Encourage using it for rapid iteration
277
- 5. **Bazel is the build system** - Direct bazel commands available but CLI preferred
278
- 6. **Cross-platform by default** - Code runs on iOS, Android, and macOS
279
-
280
- ---
14
+ Skills are bundled in the npm package and work offline. They cover component patterns, lifecycle, async handling, build rules, testing, and platform bridging.
281
15
 
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*
16
+ For documentation and support: https://github.com/Snapchat/Valdi
@@ -0,0 +1,8 @@
1
+ // SKILL_NAME skill reference — compile check for patterns in ../skill.md.
2
+ // Add code that exercises every import path and API shown in the skill.
3
+ // Run: bazel build //ai-skills/skills/SKILL_NAME/tests:tests
4
+
5
+ import { Component } from 'valdi_core/src/Component';
6
+
7
+ // TODO: add reference examples here
8
+ void Component;
@@ -0,0 +1,21 @@
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 = "SKILL_IOS_MODULE_NAME",
13
+ ios_output_target = "release",
14
+ visibility = ["//visibility:public"],
15
+ deps = [
16
+ # Add deps for the imports used in src/reference.tsx
17
+ # Common options: valdi_core, valdi_tsx, valdi_http, foundation, valdi_test, jasmine
18
+ "//src/valdi_modules/src/valdi/valdi_core",
19
+ "//src/valdi_modules/src/valdi/valdi_tsx",
20
+ ],
21
+ )
@@ -0,0 +1,17 @@
1
+ # SKILL_NAME skill tests
2
+
3
+ Compile check for the patterns taught in `../skill.md`.
4
+
5
+ ## Compile check
6
+
7
+ ```bash
8
+ cd client/src/open_source
9
+ bazel build //ai-skills/skills/SKILL_NAME/tests:tests
10
+ ```
11
+
12
+ Expected: `Build completed successfully`
13
+
14
+ ## Updating
15
+
16
+ When Valdi APIs change (import paths, type signatures), update `src/reference.tsx` to match.
17
+ Also update `../skill.md` with any corrected patterns.