@snap/valdi 1.0.11 → 1.1.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.
Files changed (74) hide show
  1. package/.metadata/.bazelrc.template +7 -6
  2. package/.metadata/MODULE.bazel.template +154 -0
  3. package/bundled-skills/registry.json +13 -2
  4. package/bundled-skills/skills/valdi-animations/skill.md +197 -0
  5. package/bundled-skills/skills/valdi-async/tests/src/reference.tsx +1 -1
  6. package/bundled-skills/skills/valdi-compiler/skill.md +4 -4
  7. package/bundled-skills/skills/valdi-component-dedup/skill.md +263 -0
  8. package/bundled-skills/skills/valdi-component-tests/tests/test/ProfileCardTest.spec.tsx +1 -1
  9. package/bundled-skills/skills/valdi-custom-view/skill.md +43 -1
  10. package/bundled-skills/skills/valdi-error-handling/skill.md +238 -0
  11. package/bundled-skills/skills/valdi-gestures/skill.md +198 -0
  12. package/bundled-skills/skills/valdi-inspect/skill.md +19 -1
  13. package/bundled-skills/skills/valdi-localization/skill.md +142 -0
  14. package/bundled-skills/skills/valdi-mock-breakdown/skill.md +327 -0
  15. package/bundled-skills/skills/valdi-mock-iterate/skill.md +216 -0
  16. package/bundled-skills/skills/valdi-mock-to-module/scripts/diff.py +392 -0
  17. package/bundled-skills/skills/valdi-mock-to-module/scripts/extract_colors.py +277 -0
  18. package/bundled-skills/skills/valdi-mock-to-module/scripts/find_icon.py +303 -0
  19. package/bundled-skills/skills/valdi-mock-to-module/scripts/snapshot-and-diff.sh +53 -0
  20. package/bundled-skills/skills/valdi-mock-to-module/scripts/test_diff.py +207 -0
  21. package/bundled-skills/skills/valdi-mock-to-module/scripts/test_extract_colors.py +167 -0
  22. package/bundled-skills/skills/valdi-mock-to-module/scripts/test_find_icon.py +188 -0
  23. package/bundled-skills/skills/valdi-mock-to-module/scripts/watch-and-diff.sh +181 -0
  24. package/bundled-skills/skills/valdi-mock-to-module/skill.md +451 -0
  25. package/bundled-skills/skills/valdi-navigation/skill.md +187 -0
  26. package/bundled-skills/skills/valdi-overview/skill.md +7 -4
  27. package/bundled-skills/skills/valdi-perf/skill.md +223 -0
  28. package/bundled-skills/skills/valdi-polyglot-module/skill.md +80 -0
  29. package/bundled-skills/skills/valdi-preview/skill.md +303 -0
  30. package/bundled-skills/skills/valdi-setup/skill.md +55 -5
  31. package/bundled-skills/skills/valdi-testing/skill.md +23 -7
  32. package/bundled-skills/skills/valdi-tsx/skill.md +69 -5
  33. package/bundled-skills/skills/valdi-tsx/tests/src/reference.tsx +29 -5
  34. package/dist/commands/agentCheck.js +184 -0
  35. package/dist/commands/analyze.js +16 -0
  36. package/dist/commands/analyze_commands/duplicates.js +134 -0
  37. package/dist/commands/bootstrap.js +57 -73
  38. package/dist/commands/build.js +6 -0
  39. package/dist/commands/doctor.js +42 -266
  40. package/dist/commands/hotreload.js +15 -0
  41. package/dist/commands/inspect_commands/snapshot.js +71 -6
  42. package/dist/commands/inspect_commands/snapshot.spec.js +105 -0
  43. package/dist/commands/install.js +6 -0
  44. package/dist/commands/preview.js +81 -0
  45. package/dist/commands/projectsync.js +9 -7
  46. package/dist/commands/skills_commands/install.js +6 -1
  47. package/dist/commands/skills_commands/update.js +2 -1
  48. package/dist/core/analyze/clusterer.js +150 -0
  49. package/dist/core/analyze/fingerprint.js +2 -0
  50. package/dist/core/analyze/knownPatterns.js +76 -0
  51. package/dist/core/analyze/parser.js +177 -0
  52. package/dist/core/analyze/reporter.js +83 -0
  53. package/dist/core/analyze/scanner.js +172 -0
  54. package/dist/core/analyze/similarity.js +56 -0
  55. package/dist/core/constants.js +6 -3
  56. package/dist/core/packageFiles.spec.js +1 -1
  57. package/dist/preview/previewGenerator.js +240 -0
  58. package/dist/preview/previewGenerator.spec.js +203 -0
  59. package/dist/preview/viewModelParser.js +86 -0
  60. package/dist/preview/viewModelParser.spec.js +171 -0
  61. package/dist/setup/DevSetupHelper.js +0 -54
  62. package/dist/setup/linuxSetup.js +0 -16
  63. package/dist/setup/macOSSetup.js +1 -5
  64. package/dist/utils/BazelClient.js +15 -0
  65. package/dist/utils/applicationUtils.js +15 -0
  66. package/dist/utils/daemonClient.js +3 -1
  67. package/dist/utils/linuxDistro.js +0 -21
  68. package/dist/utils/linuxDistro.spec.js +0 -48
  69. package/dist/utils/skillsAdapters.js +126 -19
  70. package/dist/utils/skillsAdapters.spec.js +141 -0
  71. package/dist/utils/skillsRegistry.js +8 -0
  72. package/package.json +16 -8
  73. package/.metadata/WORKSPACE.template +0 -57
  74. package/dist/setup/versions.js +0 -8
@@ -1,5 +1,6 @@
1
- # No bzlmod yet
2
- common --noenable_bzlmod
1
+ # Valdi custom Bazel registry (patched rules_swift, rules_kotlin, etc.)
2
+ common --registry=https://raw.githubusercontent.com/Snapchat/Valdi/{{VALDI_RELEASE_TAG}}/registry
3
+ common --registry=https://bcr.bazel.build
3
4
 
4
5
  common --bes_instance_name=client
5
6
  common --enable_platform_specific_config
@@ -16,7 +17,7 @@ common --incompatible_java_common_parameters=false
16
17
  # Flags for compilation
17
18
  common --define enable_web=true
18
19
 
19
- build --tool_java_language_version=11
20
+ build --tool_java_language_version=17
20
21
  build --java_language_version=11
21
22
 
22
23
  ## Disable sandboxing for macs, both laptops and in CI; the performance hit is much too high.
@@ -26,8 +27,10 @@ build:linux --sandbox_writable_path=/var/tmp
26
27
  # common cc configuration
27
28
  build --cxxopt=-std=c++20
28
29
  build --cxxopt=-Wno-ambiguous-reversed-operator
30
+ build --cxxopt=-Wno-nullability-extension
29
31
  build --cxxopt=-D_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS
30
32
  build --host_cxxopt=-std=c++20
33
+ build --host_cxxopt=-Wno-nullability-extension
31
34
 
32
35
  ## we need to disable this due to a bug in bazel
33
36
  ## see https://github.com/bazelbuild/bazel/issues/12381
@@ -61,10 +64,8 @@ build --define=android_standalone_dexing_tool=d8_compat_dx
61
64
  build --incremental_dexing
62
65
 
63
66
  # Disable 3rd party libs warnings
64
- build --per_file_copt=external/com_github_grpc_grpc/.*\$@-Wno-everything
65
- build --per_file_copt=external/snap_protobuf/.*\$@-Wno-everything
67
+ build --per_file_copt=external/com_google_protobuf/.*\$@-Wno-everything
66
68
  build --per_file_copt=external/boringssl/.*\$@-Wno-everything
67
- build --per_file_copt=external/com_github_google_flatbuffers/.*\$@-Wno-everything
68
69
 
69
70
  # Enable persistent worker for Valdi compilation
70
71
  build --strategy=ValdiCompile=worker
@@ -0,0 +1,154 @@
1
+ module(name = "{{WORKSPACE_NAME}}", version = "0.1")
2
+
3
+ # -- Valdi framework (https://github.com/Snapchat/Valdi) ---------------------
4
+ VALDI_TAG = "{{VALDI_RELEASE_TAG}}"
5
+ VALDI_URL = "https://github.com/Snapchat/Valdi/archive/" + VALDI_TAG + ".tar.gz"
6
+ VALDI_PREFIX = "Valdi-" + VALDI_TAG
7
+
8
+ bazel_dep(name = "valdi", version = "0.1")
9
+ archive_override(
10
+ module_name = "valdi",
11
+ urls = [VALDI_URL],
12
+ strip_prefix = VALDI_PREFIX,
13
+ )
14
+
15
+ # Valdi internal sub-modules: local_path_override in Valdi's own MODULE.bazel
16
+ # only takes effect when Valdi is the root module. Consumers must provide
17
+ # archive_override entries that point into the Valdi release archive.
18
+ bazel_dep(name = "android_macros")
19
+ archive_override(module_name = "android_macros", urls = [VALDI_URL], strip_prefix = VALDI_PREFIX + "/bzl/macros")
20
+
21
+ bazel_dep(name = "snap_macros")
22
+ archive_override(module_name = "snap_macros", urls = [VALDI_URL], strip_prefix = VALDI_PREFIX + "/bzl/valdi/snap_macros")
23
+
24
+ bazel_dep(name = "snap_client_toolchains")
25
+ archive_override(module_name = "snap_client_toolchains", urls = [VALDI_URL], strip_prefix = VALDI_PREFIX + "/bzl/toolchains")
26
+
27
+ bazel_dep(name = "snap_platforms")
28
+ archive_override(module_name = "snap_platforms", urls = [VALDI_URL], strip_prefix = VALDI_PREFIX + "/bzl/platforms")
29
+
30
+ bazel_dep(name = "skia_user_config")
31
+ archive_override(module_name = "skia_user_config", urls = [VALDI_URL], strip_prefix = VALDI_PREFIX + "/third-party/skia_user_config")
32
+
33
+ bazel_dep(name = "rules_hdrs")
34
+ archive_override(module_name = "rules_hdrs", urls = [VALDI_URL], strip_prefix = VALDI_PREFIX + "/third-party/rules_hdrs")
35
+
36
+ bazel_dep(name = "valdi_toolchain")
37
+ archive_override(module_name = "valdi_toolchain", urls = [VALDI_URL], strip_prefix = VALDI_PREFIX + "/bin")
38
+
39
+ bazel_dep(name = "resvg_libs")
40
+ archive_override(module_name = "resvg_libs", urls = [VALDI_URL], strip_prefix = VALDI_PREFIX + "/third-party/resvg/resvg_libs")
41
+
42
+ # -- Valdi Widgets (https://github.com/Snapchat/Valdi_Widgets) ---------------
43
+ WIDGETS_TAG = "{{VALDI_WIDGETS_RELEASE_TAG}}"
44
+
45
+ bazel_dep(name = "valdi_widgets")
46
+ archive_override(
47
+ module_name = "valdi_widgets",
48
+ urls = ["https://github.com/Snapchat/Valdi_Widgets/archive/" + WIDGETS_TAG + ".tar.gz"],
49
+ strip_prefix = "Valdi_Widgets-" + WIDGETS_TAG,
50
+ )
51
+
52
+ # -- C++ toolchains (Apple CC before LLVM for ObjC priority) ------------------
53
+ valdi_toolchains = use_extension("@valdi//bzl:valdi_toolchains.bzl", "valdi_toolchains")
54
+ use_repo(valdi_toolchains, "local_config_apple_cc_toolchains", "local_config_apple_cc", "llvm_toolchain", "llvm_toolchain_llvm")
55
+ register_toolchains("@local_config_apple_cc_toolchains//:all")
56
+ register_toolchains("@llvm_toolchain//:all")
57
+
58
+ # -- Android dependencies ----------------------------------------------------
59
+ bazel_dep(name = "rules_java", version = "7.4.0")
60
+ bazel_dep(name = "rules_android", version = "0.6.5")
61
+ bazel_dep(name = "rules_android_ndk", version = "0.1.3")
62
+
63
+ remote_android_extensions = use_extension(
64
+ "@rules_android//bzlmod_extensions:android_extensions.bzl",
65
+ "remote_android_tools_extensions",
66
+ )
67
+ use_repo(remote_android_extensions, "android_gmaven_r8", "android_tools")
68
+
69
+ hermetic_android_sdk_extension = use_extension("@valdi//bzl:hermetic_android_sdk.bzl", "hermetic_android_sdk_extension")
70
+ hermetic_android_sdk_extension.configure(
71
+ api_level = 36,
72
+ build_tools_version = "34.0.0",
73
+ )
74
+ use_repo(hermetic_android_sdk_extension, "androidsdk")
75
+
76
+ register_toolchains(
77
+ "@rules_android//toolchains/android:all",
78
+ "@rules_android//toolchains/android_sdk:all",
79
+ )
80
+ register_toolchains("@androidsdk//:sdk-toolchain", "@androidsdk//:all")
81
+
82
+ hermetic_ndk_extension = use_extension("@valdi//bzl:hermetic_ndk.bzl", "hermetic_ndk_extension")
83
+ use_repo(hermetic_ndk_extension, "androidndk")
84
+
85
+ register_toolchains("@androidndk//:all")
86
+
87
+ bazel_dep(name = "rules_kotlin", version = "1.9.0")
88
+ single_version_override(module_name = "rules_kotlin", version = "1.9.0")
89
+ bazel_dep(name = "rules_jvm_external", version = "6.2")
90
+
91
+ # -- Maven (Android) ---------------------------------------------------------
92
+ maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
93
+
94
+ maven.install(
95
+ name = "android_mvn",
96
+ artifacts = [
97
+ "androidx.annotation:annotation:1.1.0",
98
+ "androidx.appcompat:appcompat:1.2.0",
99
+ "androidx.appcompat:appcompat-resources:1.2.0",
100
+ "androidx.collection:collection:1.1.0",
101
+ "androidx.constraintlayout:constraintlayout:2.1.4",
102
+ "androidx.core:core:1.6.0",
103
+ "androidx.customview:customview:1.1.0",
104
+ "androidx.dynamicanimation:dynamicanimation:1.0.0",
105
+ "androidx.fragment:fragment:1.1.0",
106
+ "androidx.interpolator:interpolator:1.0.0",
107
+ "androidx.lifecycle:lifecycle-common:2.2.0",
108
+ "androidx.lifecycle:lifecycle-process:2.2.0",
109
+ "androidx.lifecycle:lifecycle-viewmodel:2.2.0",
110
+ "androidx.recyclerview:recyclerview:1.2.1",
111
+ "androidx.test:core:1.5.0",
112
+ "androidx.test.ext:junit:1.1.3",
113
+ "androidx.test:monitor:1.5.0",
114
+ "androidx.test:runner:1.5.0",
115
+ "com.google.android.material:material:1.2.0",
116
+ "com.google.code.findbugs:jsr305:3.0.2",
117
+ "com.google.code.gson:gson:2.8.6",
118
+ "com.google.protobuf.nano:protobuf-javanano:3.1.0",
119
+ "com.jakewharton.timber:timber:4.7.1",
120
+ "com.squareup.leakcanary:leakcanary-android:2.10",
121
+ "com.squareup.okhttp3:okhttp:4.9.0",
122
+ "com.squareup.okio:okio:2.10.0",
123
+ "io.reactivex.rxjava3:rxandroid:3.0.0",
124
+ "io.reactivex.rxjava3:rxjava:3.1.0",
125
+ "io.reactivex.rxjava3:rxkotlin:3.0.0",
126
+ "javax.inject:javax.inject:1",
127
+ "junit:junit:4.13.2",
128
+ "org.junit.jupiter:junit-jupiter-api:5.9.3",
129
+ "org.junit.jupiter:junit-jupiter-engine:5.9.3",
130
+ "org.junit.jupiter:junit-jupiter-params:5.9.3",
131
+ "org.junit.platform:junit-platform-console:1.9.2",
132
+ "org.junit.platform:junit-platform-launcher:1.9.2",
133
+ "org.junit.platform:junit-platform-reporting:1.9.2",
134
+ "org.junit.vintage:junit-vintage-engine:5.9.3",
135
+ "org.robolectric:android-all:10-robolectric-5803371",
136
+ "org.robolectric:annotations:4.10.3",
137
+ "org.robolectric:robolectric:4.10.3",
138
+ ],
139
+ repositories = [
140
+ "https://repo1.maven.org/maven2",
141
+ "https://maven.google.com",
142
+ ],
143
+ aar_import_bzl_label = "@rules_android//rules:rules.bzl",
144
+ use_starlark_android_rules = True,
145
+ version_conflict_policy = "pinned",
146
+ )
147
+
148
+ use_repo(maven, "android_mvn")
149
+
150
+ # -- Version pins (must match Valdi's MODULE.bazel) ---------------------------
151
+ single_version_override(module_name = "protobuf", version = "27.0")
152
+ single_version_override(module_name = "rules_apple", version = "4.0.0")
153
+ single_version_override(module_name = "rules_pkg", version = "0.9.1")
154
+ single_version_override(module_name = "zlib", version = "1.3.2")
@@ -12,10 +12,21 @@
12
12
  { "name": "valdi-custom-view", "description": "Valdi custom native view integration", "tags": ["custom-view", "native"], "path": "skills/valdi-custom-view/skill.md", "category": ["client"] },
13
13
  { "name": "valdi-overview", "description": "Valdi framework overview and project conventions", "tags": ["overview", "conventions"], "path": "skills/valdi-overview/skill.md", "category": ["client"] },
14
14
  { "name": "valdi-async", "description": "Valdi async lifecycle safety: CancelablePromise, registerDisposable, isDestroyed guards", "tags": ["async", "lifecycle", "http"], "path": "skills/valdi-async/skill.md", "category": ["client"] },
15
- { "name": "valdi-perf", "description": "Valdi performance: viewModel identity stability, createReusableCallback, layout vs view, Style interning", "tags": ["performance", "rendering"], "path": "skills/valdi-perf/skill.md", "category": ["client"] },
15
+ { "name": "valdi-perf", "description": "Valdi performance: viewModel identity stability, createReusableCallback, layout vs view, Style interning, deferring subscriptions to unblock first paint, lazy initialization with Lazy<T>, Provider<T>, dynamic import(), excessive setState calls and batching, caching expensive observables with cacheObservable to avoid switchMap re-subscription cost, when to offload heavy work to a Worker Service", "tags": ["performance", "rendering", "worker-service", "first-paint", "lazy", "deferred-init", "setState", "observables", "rxjs", "cacheObservable"], "path": "skills/valdi-perf/skill.md", "category": ["client"] },
16
16
  { "name": "valdi-component-tests", "description": "Valdi component test patterns: elementKeyFind, componentTypeFind, tapNodeWithKey, discriminated unions, arrays", "tags": ["testing", "components", "jasmine"], "path": "skills/valdi-component-tests/skill.md", "category": ["client"] },
17
17
  { "name": "valdi-setup", "description": "Valdi module setup: BUILD.bazel, valdi_module(), tsconfig, deps, ios_module_name, hot reload", "tags": ["setup", "bazel", "build"], "path": "skills/valdi-setup/skill.md", "category": ["client"] },
18
18
  { "name": "valdi-migrate", "description": "Migrate Flutter, React, or Jetpack Compose code to Valdi — component model, lifecycle, element mapping tables", "tags": ["migration", "flutter", "react", "compose"], "path": "skills/valdi-migrate/skill.md", "category": ["client"] },
19
- { "name": "valdi-inspect", "description": "Inspect a live Valdi app: contexts, component trees, screenshots, heap dumps via valdi inspect CLI", "tags": ["inspect", "debug", "runtime", "cli"], "path": "skills/valdi-inspect/skill.md", "category": ["client"] }
19
+ { "name": "valdi-inspect", "description": "Inspect a live Valdi app: contexts, component trees, screenshots, heap dumps via valdi inspect CLI", "tags": ["inspect", "debug", "runtime", "cli"], "path": "skills/valdi-inspect/skill.md", "category": ["client"] },
20
+ { "name": "valdi-preview", "description": "Preview a Valdi component: read its API, render it in the preview harness, inspect the view tree, and capture screenshots", "tags": ["preview", "inspect", "components", "widgets"], "path": "skills/valdi-preview/skill.md", "category": ["client"] },
21
+ { "name": "valdi-mock-breakdown", "description": "Generate Valdi TSX from a screenshot or design mock: analyze layout, decompose into components, produce code", "tags": ["mock", "codegen", "design", "screenshot", "ai"], "path": "skills/valdi-mock-breakdown/skill.md", "category": ["client"] },
22
+ { "name": "valdi-mock-iterate", "description": "Compare a design mock against a rendered Valdi screenshot and produce specific visual diff feedback", "tags": ["mock", "critique", "visual-diff", "iterate", "ai"], "path": "skills/valdi-mock-iterate/skill.md", "category": ["client"] },
23
+ { "name": "valdi-mock-to-module", "description": "Turn a screenshot into a running Valdi module: orchestrates breakdown, preview, and critic iteration loop", "tags": ["mock", "codegen", "pipeline", "orchestrator", "ai"], "path": "skills/valdi-mock-to-module/skill.md", "category": ["client"] },
24
+ { "name": "valdi-profile", "description": "Capture CPU profiles from a running Valdi app: diagnose slow renders, identify hot functions, understand JS thread activity", "tags": ["profile", "performance", "debug", "cli"], "path": "skills/valdi-profile/skill.md", "category": ["client"] },
25
+ { "name": "valdi-navigation", "description": "Multi-screen navigation: NavigationRoot, push/pop/present/dismiss, NavigationPageComponent, back button handling", "tags": ["navigation", "routing", "pages", "modal"], "path": "skills/valdi-navigation/skill.md", "category": ["client"] },
26
+ { "name": "valdi-animations", "description": "Imperative animation API: animate/animatePromise, AnimationOptions, spring physics, setStateAnimated", "tags": ["animation", "transitions", "spring"], "path": "skills/valdi-animations/skill.md", "category": ["client"] },
27
+ { "name": "valdi-gestures", "description": "Touch and gesture handling: onTap, onDrag, onPinch, onRotate, onLongPress, TouchEvent, gesture predicates", "tags": ["gestures", "touch", "input"], "path": "skills/valdi-gestures/skill.md", "category": ["client"] },
28
+ { "name": "valdi-localization", "description": "Internationalization: strings-en.json, Strings.d.ts generation, template variables, valdi projectsync", "tags": ["localization", "i18n", "strings"], "path": "skills/valdi-localization/skill.md", "category": ["client"] },
29
+ { "name": "valdi-error-handling", "description": "Error handling patterns: CancelablePromise safety, HTTPClient errors, isDestroyed guards, error UI states", "tags": ["errors", "async", "lifecycle", "safety"], "path": "skills/valdi-error-handling/skill.md", "category": ["client"] },
30
+ { "name": "valdi-component-dedup", "description": "Find and extract duplicated component patterns across Valdi modules into shared libraries", "tags": ["deduplication", "analysis", "refactoring", "ai"], "path": "skills/valdi-component-dedup/skill.md", "category": ["client"] }
20
31
  ]
21
32
  }
@@ -0,0 +1,197 @@
1
+ # Valdi Animations
2
+
3
+ Imperative animation API for animating element attributes and state changes.
4
+
5
+ ## When to use
6
+
7
+ When animating layout changes, view attributes, or state transitions. Almost all element attributes can be animated in Valdi.
8
+
9
+ ## Key concepts
10
+
11
+ Valdi uses an **imperative animation model** inspired by iOS's `animateWithDuration:animations:`. You call `this.animate()` or `this.animatePromise()` with options and a block of mutations — all changes inside the block are animated automatically.
12
+
13
+ **Not CSS transitions.** There is no `transition` property, no `@keyframes`, no `animation-duration`. Animations are triggered programmatically.
14
+
15
+ ## animate and animatePromise
16
+
17
+ Both methods are available on any `Component`:
18
+
19
+ ```tsx
20
+ // ✅ Fire-and-forget animation
21
+ this.animate({ duration: 0.3 }, () => {
22
+ this.myLabel.setAttribute('font', 'title');
23
+ this.myContainer.setAttribute('width', 200);
24
+ });
25
+
26
+ // ✅ Wait for animation to complete
27
+ await this.animatePromise({ duration: 0.5, curve: AnimationCurve.EaseOut }, () => {
28
+ this.setState({ expanded: true });
29
+ });
30
+ // Animation finished — safe to do next step
31
+ ```
32
+
33
+ ## AnimationOptions
34
+
35
+ Three curve types: preset, custom bezier, and spring.
36
+
37
+ ```tsx
38
+ import { AnimationCurve } from 'valdi_core/src/AnimationOptions';
39
+
40
+ // Preset curves
41
+ { duration: 0.3, curve: AnimationCurve.Linear }
42
+ { duration: 0.3, curve: AnimationCurve.EaseIn }
43
+ { duration: 0.3, curve: AnimationCurve.EaseOut }
44
+ { duration: 0.3, curve: AnimationCurve.EaseInOut } // default
45
+
46
+ // Custom bezier control points
47
+ { duration: 0.4, controlPoints: [0.25, 0.1, 0.25, 1.0] }
48
+
49
+ // Spring animation (no duration — spring physics determine timing)
50
+ { stiffness: 300, damping: 30 }
51
+
52
+ // Crossfade (alpha transition between old and new state)
53
+ { duration: 0.3, crossfade: true }
54
+
55
+ // Continue from current animation state
56
+ { duration: 0.3, beginFromCurrentState: true }
57
+
58
+ // Completion callback
59
+ { duration: 0.3, completion: (wasCancelled) => { /* done */ } }
60
+ ```
61
+
62
+ ## Animating element attributes via ElementRef
63
+
64
+ ```tsx
65
+ import { ElementRef } from 'valdi_core/src/ElementRef';
66
+
67
+ export class MyComponent extends Component {
68
+ private titleRef = new ElementRef();
69
+ private containerRef = new ElementRef();
70
+
71
+ onRender(): void {
72
+ <view ref={this.containerRef} width={100}>
73
+ <label ref={this.titleRef} value="Hello" font={systemFont(14)} />
74
+ </view>;
75
+ }
76
+
77
+ private expand = () => {
78
+ // ✅ Animate attribute changes via ElementRef
79
+ this.animate({ duration: 0.3 }, () => {
80
+ this.titleRef.setAttribute('font', systemBoldFont(17));
81
+ this.containerRef.setAttribute('width', 300);
82
+ });
83
+ };
84
+ }
85
+ ```
86
+
87
+ ## Animating state changes
88
+
89
+ ```tsx
90
+ interface State {
91
+ expanded: boolean;
92
+ text: string;
93
+ }
94
+
95
+ export class MyComponent extends StatefulComponent<{}, State> {
96
+ state = { expanded: false, text: 'Collapsed' };
97
+
98
+ onRender(): void {
99
+ <view width={this.state.expanded ? 300 : 100} height={this.state.expanded ? 200 : 50}>
100
+ <label value={this.state.text} />
101
+ </view>;
102
+ }
103
+
104
+ private toggle = () => {
105
+ // ✅ setStateAnimated — renders with new state, animates all resulting mutations
106
+ this.setStateAnimated(
107
+ { expanded: !this.state.expanded, text: this.state.expanded ? 'Collapsed' : 'Expanded' },
108
+ { duration: 0.3, curve: AnimationCurve.EaseInOut },
109
+ );
110
+ };
111
+ }
112
+ ```
113
+
114
+ ## Spring animations
115
+
116
+ ```tsx
117
+ // ✅ Bouncy spring — lower damping = more bounce
118
+ this.animate({ stiffness: 300, damping: 15 }, () => {
119
+ this.cardRef.setAttribute('scale', 1.0);
120
+ });
121
+
122
+ // ✅ Stiff spring — high damping = smooth settle
123
+ this.animate({ stiffness: 500, damping: 40 }, () => {
124
+ this.panelRef.setAttribute('translateY', 0);
125
+ });
126
+ ```
127
+
128
+ ## Common patterns
129
+
130
+ ### Show/hide with fade
131
+
132
+ ```tsx
133
+ private show = () => {
134
+ this.animate({ duration: 0.2 }, () => {
135
+ this.overlayRef.setAttribute('opacity', 1);
136
+ });
137
+ };
138
+
139
+ private hide = () => {
140
+ this.animate({ duration: 0.2 }, () => {
141
+ this.overlayRef.setAttribute('opacity', 0);
142
+ });
143
+ };
144
+ ```
145
+
146
+ ### Sequential animations
147
+
148
+ ```tsx
149
+ private async runSequence() {
150
+ await this.animatePromise({ duration: 0.2 }, () => {
151
+ this.step1Ref.setAttribute('opacity', 1);
152
+ });
153
+ await this.animatePromise({ duration: 0.3 }, () => {
154
+ this.step2Ref.setAttribute('translateY', 0);
155
+ });
156
+ }
157
+ ```
158
+
159
+ ## Common mistakes
160
+
161
+ ```tsx
162
+ // ❌ WRONG — CSS-style transitions don't exist
163
+ <view style={{ transition: 'all 0.3s ease' }} /> // ❌
164
+ <view className="animate-fade-in" /> // ❌
165
+
166
+ // ❌ WRONG — React-style animation libraries
167
+ import { animated, useSpring } from 'react-spring'; // ❌
168
+
169
+ // ❌ WRONG — Calling setState inside animate (use setStateAnimated instead)
170
+ this.animate({ duration: 0.3 }, () => {
171
+ this.setState({ expanded: true }); // ❌ Won't animate the re-render
172
+ });
173
+
174
+ // ✅ Correct — use setStateAnimated for state-driven animations
175
+ this.setStateAnimated({ expanded: true }, { duration: 0.3 });
176
+
177
+ // ❌ WRONG — Duration in milliseconds (it's seconds)
178
+ this.animate({ duration: 300 }, () => { ... }); // ❌ This is 300 seconds!
179
+
180
+ // ✅ Correct — Duration in seconds
181
+ this.animate({ duration: 0.3 }, () => { ... });
182
+ ```
183
+
184
+ ## CoreUI animation components
185
+
186
+ The `coreui` library includes pre-built animation components:
187
+
188
+ | Component | Purpose |
189
+ |-----------|---------|
190
+ | `AnimatableVisibilityView` | Animate show/hide transitions |
191
+ | `AnimationShimmer` | Loading shimmer effect |
192
+ | `AnimationSliding` | Slide in/out animations |
193
+ | `AnimationSquishy` | Press-and-squish feedback |
194
+ | `AnimationRotate` | Continuous rotation |
195
+ | `VerticallyOpenableComponent` | Expand/collapse vertically |
196
+
197
+ Import from `coreui/src/components/animation/`.
@@ -73,7 +73,7 @@ class LiveClock extends StatefulComponent<ClockViewModel, ClockState> {
73
73
  onCreate(): void {
74
74
  // ✅ Automatically cancelled on destroy — no onDestroy() needed
75
75
  const id = setInterval(() => this.tick(), 1000);
76
- this.registerDisposable({ cancel: () => clearInterval(id) });
76
+ this.registerDisposable({ unsubscribe: () => clearInterval(id) });
77
77
  }
78
78
 
79
79
  private tick = (): void => {
@@ -55,7 +55,7 @@ enum CompilerError: Error {
55
55
 
56
56
  ## Testing
57
57
 
58
- Tests are critical - add tests for new features and error cases. The `update_compiler.sh` script runs tests automatically.
58
+ Tests are critical - add tests for new features and error cases. Run the test suite with `bzl test //compiler/compiler/...` (the build script below does not run tests).
59
59
 
60
60
  ## Build
61
61
 
@@ -63,12 +63,12 @@ Tests are critical - add tests for new features and error cases. The `update_com
63
63
 
64
64
  ```bash
65
65
  cd compiler/compiler
66
- ./scripts/update_compiler.sh ../../bin/compiler
66
+ ./scripts/update_compiler_bazel.sh -o bin/compiler
67
67
  ```
68
68
 
69
69
  This script:
70
- - Runs `swift test` automatically
71
- - Builds the compiler for the correct architecture
70
+ - Builds the compiler with Bazel (`//compiler/compiler:local_valdi_compiler`); no Swift toolchain install is required
71
+ - Builds the compiler for the correct architecture (on macOS, lipos arm64 + x86_64 into a universal binary and codesigns it)
72
72
  - Copies the binary to `bin/compiler/macos/valdi_compiler` (or `linux/valdi_compiler`)
73
73
  - Handles platform differences (macOS vs Linux)
74
74