@snap/valdi 1.1.7 → 1.2.1
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.
- package/.metadata/.bazelrc.template +9 -7
- package/.metadata/AGENTS.md.template +7 -0
- package/.metadata/MODULE.bazel.template +47 -3
- package/.metadata/README.md.template +2 -2
- package/.metadata/bzl/patches/rules_python/1.9.0/BUILD.bazel.template +1 -0
- package/.metadata/bzl/patches/rules_python/1.9.0/remove_setuptools_spaces.patch.template +96 -0
- package/.metadata/skill-tests-README.md.template +1 -1
- package/README.md +47 -14
- package/bundled-skills/registry.json +2 -1
- package/bundled-skills/skills/valdi-animations/skill.md +49 -0
- package/bundled-skills/skills/valdi-async/skill.md +3 -2
- package/bundled-skills/skills/valdi-async/tests/README.md +1 -1
- package/bundled-skills/skills/valdi-bazel/skill.md +2 -6
- package/bundled-skills/skills/valdi-component-tests/tests/README.md +1 -1
- package/bundled-skills/skills/valdi-cpp-runtime/skill.md +18 -0
- package/bundled-skills/skills/valdi-custom-view/skill.md +1 -1
- package/bundled-skills/skills/valdi-error-handling/skill.md +1 -1
- package/bundled-skills/skills/valdi-gestures/skill.md +3 -3
- package/bundled-skills/skills/valdi-migrate/skill.md +2 -1
- package/bundled-skills/skills/valdi-migrate/tests/README.md +2 -2
- package/bundled-skills/skills/valdi-mock-breakdown/skill.md +4 -4
- package/bundled-skills/skills/valdi-mock-to-module/skill.md +9 -6
- package/bundled-skills/skills/valdi-overview/skill.md +2 -1
- package/bundled-skills/skills/valdi-perf/skill.md +121 -5
- package/bundled-skills/skills/valdi-perf/tests/README.md +1 -1
- package/bundled-skills/skills/valdi-pr-review/skill.md +189 -0
- package/bundled-skills/skills/valdi-profile/skill.md +5 -3
- package/bundled-skills/skills/valdi-setup/skill.md +3 -6
- package/bundled-skills/skills/valdi-testing/skill.md +1 -1
- package/bundled-skills/skills/valdi-tsx/skill.md +47 -11
- package/bundled-skills/skills/valdi-tsx/tests/README.md +1 -1
- package/debugger/README.md +356 -0
- package/debugger/debugger-actions.js +373 -0
- package/debugger/debugger-api.js +225 -0
- package/debugger/debugger-bootstrap.js +295 -0
- package/debugger/debugger-model.js +790 -0
- package/debugger/debugger-performance.js +573 -0
- package/debugger/debugger-preview-html.js +676 -0
- package/debugger/debugger-providers.js +389 -0
- package/debugger/debugger-render.js +529 -0
- package/debugger/debugger-runtime.js +387 -0
- package/debugger/debugger-session.js +188 -0
- package/debugger/debugger-settings.js +209 -0
- package/debugger/debugger-state.js +221 -0
- package/debugger/debugger-tree-model.js +539 -0
- package/debugger/debugger.css +1865 -0
- package/debugger/devtools-panel.css +1318 -0
- package/debugger/devtools-panel.html +273 -0
- package/debugger/devtools-panel.js +3329 -0
- package/debugger/index.html +279 -0
- package/dist/commands/bootstrap.js +7 -6
- package/dist/commands/build.js +7 -1
- package/dist/commands/debugger.js +163 -0
- package/dist/commands/doctor.js +3 -62
- package/dist/commands/export.js +47 -16
- package/dist/commands/hotreload.js +247 -27
- package/dist/commands/inspect.js +5 -2
- package/dist/commands/inspect_commands/input.js +176 -0
- package/dist/commands/inspect_commands/snapshot.js +1 -1
- package/dist/commands/inspect_commands/tree.js +1 -1
- package/dist/commands/install.js +79 -2
- package/dist/commands/projectsync.js +15 -0
- package/dist/commands/webHotreload.js +31 -0
- package/dist/core/constants.js +34 -7
- package/dist/debugger/chromiumConsole.js +279 -0
- package/dist/debugger/inputClient.js +473 -0
- package/dist/debugger/server.js +3801 -0
- package/dist/debugger/targetRegistry.js +436 -0
- package/dist/debugger/webPreviewPerformance.js +864 -0
- package/dist/index.js +0 -0
- package/dist/utils/BazelClient.js +34 -5
- package/dist/utils/applicationUtils.js +20 -2
- package/dist/utils/buildInfo.js +5 -1
- package/dist/utils/chromiumDevToolsClient.js +350 -0
- package/dist/utils/cliUtils.js +2 -2
- package/dist/utils/daemonClient.js +364 -44
- package/dist/utils/directorySync.js +153 -0
- package/dist/utils/githubUtils.js +1 -1
- package/dist/utils/hermesClient.js +82 -176
- package/dist/utils/loopbackHost.js +14 -0
- package/dist/utils/owlCdpClient.js +282 -0
- package/dist/utils/owlDevToolsExtension.js +142 -0
- package/dist/utils/processUtils.js +14 -0
- package/dist/utils/stringUtils.js +13 -1
- package/dist/utils/webApplicationSession.js +58 -0
- package/dist/utils/webHotReloadSession.js +212 -0
- package/dist/utils/webServerUtils.js +195 -0
- package/dist/utils/zipUtils.js +20 -2
- package/package.json +4 -2
- package/dist/commands/inspect_commands/snapshot.spec.js +0 -105
- package/dist/core/packageFiles.spec.js +0 -29
- package/dist/preview/previewGenerator.spec.js +0 -203
- package/dist/preview/viewModelParser.spec.js +0 -171
- package/dist/utils/linuxDistro.spec.js +0 -122
- package/dist/utils/skillsAdapters.spec.js +0 -141
- package/dist/utils/stringUtils.spec.js +0 -81
|
@@ -214,9 +214,12 @@ opacity: '0.3' // WRONG — TypeScript error
|
|
|
214
214
|
overflow: 'visible' // CORRECT
|
|
215
215
|
overflow: 'hidden' // WRONG — only 'visible' or 'scroll'
|
|
216
216
|
|
|
217
|
-
//
|
|
217
|
+
// Font weights: system, system-medium, system-semibold,
|
|
218
|
+
// system-bold, + italic variants all render. Prefer the SystemFont helpers.
|
|
218
219
|
font: 'system-bold 16' // CORRECT
|
|
219
|
-
font: 'system-semibold 16' //
|
|
220
|
+
font: 'system-semibold 16' // CORRECT (systemSemiboldFont(16))
|
|
221
|
+
font: 'system-medium 14' // CORRECT (systemMediumFont(14))
|
|
222
|
+
font: 'system-light 14' // WRONG — system-light does not exist
|
|
220
223
|
|
|
221
224
|
// flexGrow is a number
|
|
222
225
|
flexGrow: 1 // CORRECT
|
|
@@ -245,9 +248,9 @@ import { Image } from 'valdi_tsx/src/NativeTemplateElements';
|
|
|
245
248
|
// CORRECT: <image> is a JSX intrinsic, not an importable class
|
|
246
249
|
// Use Style<View> for image container styles
|
|
247
250
|
|
|
248
|
-
//
|
|
249
|
-
new Style<View>({ flexDirection: 'row', gap:
|
|
250
|
-
//
|
|
251
|
+
// OK: gap / rowGap / columnGap now exist on View/Layout (Yoga layout props)
|
|
252
|
+
new Style<View>({ flexDirection: 'row', gap: 8 })
|
|
253
|
+
// margins still work and remain the common convention:
|
|
251
254
|
// In JSX: <view marginRight={8}> or margin="0 8 0 0"
|
|
252
255
|
|
|
253
256
|
// WRONG: icon typed as string
|
|
@@ -432,7 +435,7 @@ The pixel diff misses small semantic differences (e.g., gray icon vs blue badge)
|
|
|
432
435
|
|
|
433
436
|
**`overflow: 'hidden'` error** -- Only `'visible'` or `'scroll'` supported.
|
|
434
437
|
|
|
435
|
-
|
|
438
|
+
**Font weights** -- `system`, `system-medium`, `system-semibold`, and `system-bold` (plus italic variants) all render; prefer the `SystemFont` helpers (`systemSemiboldFont(16)`). Only `system-light` does not exist.
|
|
436
439
|
|
|
437
440
|
**Pixel diff shows stretched layout** -- Missing 390px phone frame in PreviewRoot.
|
|
438
441
|
|
|
@@ -63,4 +63,5 @@ valdi agent-check --module X --quick --json # Quick check with machine-readab
|
|
|
63
63
|
- **Comprehensive guide**: `/AGENTS.md`
|
|
64
64
|
- **AI tooling**: `/docs/docs/ai-tooling.md`
|
|
65
65
|
- **Support**: `/SUPPORT.md`
|
|
66
|
-
- **
|
|
66
|
+
- **Discussions**: https://github.com/Snapchat/Valdi/discussions
|
|
67
|
+
- **Issues**: https://github.com/Snapchat/Valdi/issues
|
|
@@ -167,20 +167,58 @@ onRender(): void {
|
|
|
167
167
|
}
|
|
168
168
|
```
|
|
169
169
|
|
|
170
|
+
## Renderer memoization with `remember`
|
|
171
|
+
|
|
172
|
+
`remember(factory, ...keys)` (from `valdi_core/src/Remember.ts`)
|
|
173
|
+
caches the result of `factory()` across renders and only recomputes it when one of
|
|
174
|
+
the trailing keys changes; otherwise it returns the cached value. Reach for it when
|
|
175
|
+
a value is expensive to derive inside `onRender()` but depends on just a few inputs.
|
|
176
|
+
|
|
177
|
+
```typescript
|
|
178
|
+
import { remember } from 'valdi_core/src/Remember';
|
|
179
|
+
|
|
180
|
+
// ❌ Rebuilds the index every render
|
|
181
|
+
onRender(): void {
|
|
182
|
+
const index = buildIndex(this.viewModel.items);
|
|
183
|
+
<SearchResults index={index} />;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// ✅ Rebuilt only when `items` changes; cached otherwise
|
|
187
|
+
onRender(): void {
|
|
188
|
+
const index = remember(() => buildIndex(this.viewModel.items), this.viewModel.items);
|
|
189
|
+
<SearchResults index={index} />;
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
How it relates to the other primitives here:
|
|
194
|
+
- **vs. pre-computing derived viewModels in `onViewModelUpdate`** — same goal (recompute
|
|
195
|
+
only on real input changes), but `remember` keeps the derivation inline in `onRender()`
|
|
196
|
+
keyed by its dependencies, instead of hoisting it into a lifecycle method plus a guarded
|
|
197
|
+
field. Use `remember` for render-local values; keep the `onViewModelUpdate` pattern when
|
|
198
|
+
the result is a child viewModel whose *reference identity* must stay stable to avoid
|
|
199
|
+
re-rendering the child.
|
|
200
|
+
- **vs. `createReusableCallback`** — `createReusableCallback` stabilises a *function's*
|
|
201
|
+
identity across renders; `remember` caches a computed *value*.
|
|
202
|
+
- **vs. `cacheObservable`** — `cacheObservable` shares one subscription across a producer
|
|
203
|
+
chain; `remember` is synchronous, render-scoped memoization with no Observable involved.
|
|
204
|
+
|
|
170
205
|
## Style Objects at Module Level
|
|
171
206
|
|
|
172
|
-
`
|
|
173
|
-
|
|
174
|
-
|
|
207
|
+
Create each `Style<T>` **once at module level and reuse the instance**. A `Style` is
|
|
208
|
+
not value-interned — two `new Style({...})` calls with identical properties are still
|
|
209
|
+
two distinct objects. What a `Style` caches is its own native serialization:
|
|
210
|
+
`toNative()` is memoized per instance. So a module-level `Style` pays that marshalling
|
|
211
|
+
cost once and reuses it, while a `Style` constructed inside `onRender()` re-allocates
|
|
212
|
+
and re-serializes on every render.
|
|
175
213
|
|
|
176
214
|
```typescript
|
|
177
|
-
// ❌
|
|
215
|
+
// ❌ New allocation + re-serialization every render
|
|
178
216
|
onRender(): void {
|
|
179
217
|
const s = new Style<View>({ backgroundColor: '#fff', borderRadius: 8 });
|
|
180
218
|
<view style={s} />;
|
|
181
219
|
}
|
|
182
220
|
|
|
183
|
-
// ✅
|
|
221
|
+
// ✅ Constructed once at module level; native serialization cached on the instance
|
|
184
222
|
import { View } from 'valdi_tsx/src/NativeTemplateElements';
|
|
185
223
|
|
|
186
224
|
const styles = {
|
|
@@ -268,6 +306,30 @@ A service is declared by a `WorkerServiceEntryPoint` subclass annotated with
|
|
|
268
306
|
Always call `dispose()` on the returned client; the service otherwise stays in
|
|
269
307
|
memory.
|
|
270
308
|
|
|
309
|
+
**Structured messaging with `MessageChannel` (recent).** For richer
|
|
310
|
+
host↔worker communication than one-shot request/response, the runtime installs the
|
|
311
|
+
web-standard, native-backed `MessageChannel` / `MessagePort` globals. `new
|
|
312
|
+
MessageChannel()` gives a linked `port1` / `port2` pair; hand one port to the worker
|
|
313
|
+
and keep the other. Each port has `postMessage<T>(data, transfer?)` and an `onmessage`
|
|
314
|
+
handler; messages queue in FIFO order until the receiving port is started (assigning
|
|
315
|
+
`onmessage` or calling `start()`). Ports are themselves transferable — pass them in
|
|
316
|
+
the `transfer` array to move a channel across an existing port. Reach for this when a
|
|
317
|
+
feature needs multiple independent, long-lived message streams to a worker rather than
|
|
318
|
+
the single promise-based call surface above.
|
|
319
|
+
|
|
320
|
+
```typescript
|
|
321
|
+
const channel = new MessageChannel();
|
|
322
|
+
channel.port1.onmessage = (event) => this.handle(event.data);
|
|
323
|
+
worker.postMessage({ cmd: 'attach' }, [channel.port2]); // transfer port2 to the worker
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
**Idle workers are now torn down aggressively.** The runtime reclaims
|
|
327
|
+
resources by terminating idle Worker Services, so a worker may be gone between uses and
|
|
328
|
+
re-spun on the next call. Factor the (re)spin-up cost into the offloading tradeoff:
|
|
329
|
+
infrequent, bursty work now pays a cold-start penalty each time, weakening the case for
|
|
330
|
+
a worker versus keeping cheap work on the host thread. Steady, frequent workloads keep
|
|
331
|
+
the worker warm and still win.
|
|
332
|
+
|
|
271
333
|
## Deferring construction until it's needed
|
|
272
334
|
|
|
273
335
|
Three Valdi-supported ways to push work past startup, from a single field to
|
|
@@ -347,6 +409,27 @@ users never hit it.
|
|
|
347
409
|
**Skip when:** the module is needed on the initial render path (dynamic import
|
|
348
410
|
adds an async tick) or the module is tiny (savings are negligible).
|
|
349
411
|
|
|
412
|
+
### Whole modules, synchronously: `lazyImport` (recently added)
|
|
413
|
+
|
|
414
|
+
When you want to defer a module's parse/init cost but can't afford the async tick
|
|
415
|
+
of `import()`, use `lazyImport` from `valdi_core/src/LazyImport`.
|
|
416
|
+
It returns a `LazyImport<TModule>` whose `.get` synchronously requires the module on
|
|
417
|
+
first access and caches it thereafter — no `await`, no render-path tick.
|
|
418
|
+
|
|
419
|
+
```typescript
|
|
420
|
+
import { lazyImport } from 'valdi_core/src/LazyImport';
|
|
421
|
+
|
|
422
|
+
// Pass the current module's `require` so the relative path resolves from here.
|
|
423
|
+
const heavy = lazyImport<typeof import('./HeavyUtil')>(require, './HeavyUtil');
|
|
424
|
+
|
|
425
|
+
// First `.get` parses + initialises the module; later reads are cached.
|
|
426
|
+
heavy.get.doWork();
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
**Prefer over `import()`** when the consumer is synchronous (can't await) but the
|
|
430
|
+
module is still only needed conditionally. **Prefer `import()`** when you genuinely
|
|
431
|
+
want the module off the startup bundle / loaded asynchronously.
|
|
432
|
+
|
|
350
433
|
## Excessive `setState` calls
|
|
351
434
|
|
|
352
435
|
`setState` runs synchronously: each call merges state and immediately
|
|
@@ -418,3 +501,36 @@ class FriendSearcher {
|
|
|
418
501
|
Smell: a `switchMap` whose inner observable does HTTP or expensive computation
|
|
419
502
|
with no caching upstream. Each switch tears down the previous subscription
|
|
420
503
|
and starts a fresh producer chain.
|
|
504
|
+
|
|
505
|
+
## Native sticky headers (experimental)
|
|
506
|
+
|
|
507
|
+
Sticky headers implemented in JS lag the scroll: the scroll offset round-trips to
|
|
508
|
+
the JS thread, the header position is recomputed, and the update lands a frame or
|
|
509
|
+
more behind the gesture. Native sticky headers reposition the header in the native
|
|
510
|
+
scroll pass — the same VSYNC as the scroll gesture — eliminating that round-trip.
|
|
511
|
+
|
|
512
|
+
Enable it on the `<scroll>` element and tag the descendant that should pin:
|
|
513
|
+
|
|
514
|
+
```typescript
|
|
515
|
+
// ✅ Repositioning happens natively, in sync with the gesture
|
|
516
|
+
<scroll nativeStickyEnabled={true}>
|
|
517
|
+
<layout>
|
|
518
|
+
<view stickyPosition="top">...header...</view>
|
|
519
|
+
...section content...
|
|
520
|
+
</layout>
|
|
521
|
+
</scroll>
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
- `nativeStickyEnabled` (default `false`) — turns on native repositioning for the
|
|
525
|
+
scroll view.
|
|
526
|
+
- `stickyPosition` (`'none' | 'top'`, default `'none'`) — tags a descendant as a
|
|
527
|
+
sticky header within the nearest `nativeStickyEnabled` scroll view.
|
|
528
|
+
- `nativeStickyCover` (default `0`) — pixels of visual overhang above sticky headers,
|
|
529
|
+
extending the effective header height so a bar rendered above the header does not
|
|
530
|
+
overlap the next section's header.
|
|
531
|
+
- `nativeStickyOffset` (default `0`) — pixels below the viewport top where headers
|
|
532
|
+
pin (matches CSS `position: sticky; top: N`); use when a floating page header has a
|
|
533
|
+
visual footprint extending below its Yoga bounds.
|
|
534
|
+
|
|
535
|
+
All four attributes are `@experimental` (may change). Prefer this over a JS-side
|
|
536
|
+
sticky implementation on scroll-heavy screens where header lag is visible.
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# Valdi PR Review
|
|
2
|
+
|
|
3
|
+
Review guidance for Valdi changes, focused on **regression risk, gating, and
|
|
4
|
+
blast radius** — the lens a framework maintainer applies on top of ordinary
|
|
5
|
+
correctness review. These are heuristics for what to surface; they never gate on
|
|
6
|
+
PR size, title, or structure.
|
|
7
|
+
|
|
8
|
+
When flagging, use a `snake_case` category: `regression` for ungated changes,
|
|
9
|
+
`thread_safety` for JS↔native boundary races, `performance` for hot-path or
|
|
10
|
+
allocation cost, `resource_leak` for missing cleanup, and `platform_parity` for
|
|
11
|
+
one-sided native changes. Use `lint` and `format` for pre-gate tooling failures
|
|
12
|
+
(see below).
|
|
13
|
+
|
|
14
|
+
## When to use
|
|
15
|
+
|
|
16
|
+
Reviewing a Valdi PR that touches the runtime, renderer, native backends, or
|
|
17
|
+
framework modules. Complements correctness review, it doesn't replace it.
|
|
18
|
+
|
|
19
|
+
## Lint and formatting pre-gate
|
|
20
|
+
|
|
21
|
+
Before applying the review lens below, run the project's configured linter and
|
|
22
|
+
formatter on the changed files and surface any failures as findings — agents routinely
|
|
23
|
+
miss these and only discover them when CI rejects the PR.
|
|
24
|
+
|
|
25
|
+
- **Discover the commands from the repo; do not assume a tool.** Check `AGENTS.md`,
|
|
26
|
+
`README`, `package.json` scripts, `.pre-commit-config.yaml`, and the CI config for
|
|
27
|
+
the linter and formatter this project runs, then run them against the changed files.
|
|
28
|
+
These are often a **single command** (e.g. ESLint running Prettier via a plugin), not
|
|
29
|
+
two separate tools — run whatever the repo defines rather than assuming a standalone
|
|
30
|
+
`prettier`.
|
|
31
|
+
- Report a failing formatter as a `format` finding and a failing linter as a `lint`
|
|
32
|
+
finding, quoting the rule and file. These block like a correctness issue would — a
|
|
33
|
+
clean local build with lint failures still fails CI.
|
|
34
|
+
- Scan the diff for newly added suppressions (`eslint-disable`, `// prettier-ignore`,
|
|
35
|
+
`nolint`, and equivalents) and flag any not justified by a comment.
|
|
36
|
+
|
|
37
|
+
This pre-gate runs the tools; it is **not** the "style, naming, or organization pass"
|
|
38
|
+
the review lens deliberately avoids (see Material secondary checks). Keep the two
|
|
39
|
+
separate — run lint here, review for regression risk below.
|
|
40
|
+
|
|
41
|
+
## Gating: does the change run for existing consumers?
|
|
42
|
+
|
|
43
|
+
The primary regression question: does new or changed code run for **existing
|
|
44
|
+
consumers**, and if so, is it gated? A gate is any condition that keeps existing
|
|
45
|
+
call sites on their prior behavior — a feature flag, an `if (newProperty != null)`
|
|
46
|
+
check, or a `hasFeatureData()` predicate.
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
// ❌ Ungated: the new clause runs for every existing caller of this setter
|
|
50
|
+
set value(v) {
|
|
51
|
+
if (v instanceof AttributedText || this.parseNeeded(v)) { /* parse work */ }
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// ✅ Gated: the new work only runs when the feature's data is present
|
|
55
|
+
set value(v) {
|
|
56
|
+
if (this.featureEnabled && v instanceof AttributedText) { /* parse work */ }
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Flag when:
|
|
61
|
+
|
|
62
|
+
- A new clause or branch is added to an existing setter, hot method, or shared
|
|
63
|
+
utility (a text converter, an equality check, an attributed-text parser) that
|
|
64
|
+
runs for existing consumers without such a gate.
|
|
65
|
+
- A flag gates feature *data* at one layer, but a shared lower-layer path still
|
|
66
|
+
runs for non-feature callers. A data-layer flag doesn't gate code that executes
|
|
67
|
+
regardless of whether the data is present.
|
|
68
|
+
- A condition, exclusion check, fast path, or short-circuit is removed or relaxed
|
|
69
|
+
in a shared or hot method. Audit both perf (every call site now pays) and
|
|
70
|
+
correctness (the condition may have guarded a real bug — a null-deref or a
|
|
71
|
+
double-render, not just the new feature). Trace why it was there before it goes.
|
|
72
|
+
- A bypass is removed, making previously unreachable code newly reachable for
|
|
73
|
+
existing callers. Flag missing null checks or unhandled edge cases on the newly
|
|
74
|
+
reachable path, as if it were new code.
|
|
75
|
+
|
|
76
|
+
## Blast radius
|
|
77
|
+
|
|
78
|
+
Weight findings by where the change lands.
|
|
79
|
+
|
|
80
|
+
- **App-wide (highest bar):** the runtime — ViewNode, the renderer diff, and
|
|
81
|
+
marshalling under `valdi/src/valdi/runtime` — and the JS-engine integrations
|
|
82
|
+
(`valdi/src/valdi/jscore`, `quickjs`, `hermes`, `v8`), plus the core TS modules
|
|
83
|
+
every module depends on. The diff/render path is extremely allocation-sensitive:
|
|
84
|
+
one new object allocation there can add hundreds of ms across thousands of nodes.
|
|
85
|
+
- **Scoped (trace consumers first):** shared component libraries, navigation,
|
|
86
|
+
dependency injection, module loading, protobuf, sqlite bindings. Flag a change
|
|
87
|
+
to an exported symbol or a native view type here, and note that its direct and
|
|
88
|
+
transitive consumers — wrappers down to the leaf modules — need a breakage
|
|
89
|
+
check; a native view change carries risk through the TS element name it maps to.
|
|
90
|
+
- **Developer tooling (lowest bar, no user impact):** debugger, inspector,
|
|
91
|
+
playground, benchmarking/profiling, hot reloader.
|
|
92
|
+
|
|
93
|
+
## Native review checks
|
|
94
|
+
|
|
95
|
+
### C++ runtime and the JS ↔ native boundary
|
|
96
|
+
|
|
97
|
+
Paths: `valdi/src/valdi/{runtime,jscore,quickjs,hermes,v8,snap_drawing}` and
|
|
98
|
+
marshalling.
|
|
99
|
+
|
|
100
|
+
- Operations dispatch between the JS thread and the main/UI thread. Flag missing
|
|
101
|
+
locks, synchronous cross-thread dispatch (deadlock risk), and concurrent access
|
|
102
|
+
to shared state.
|
|
103
|
+
- Reference/view types that cross the boundary (e.g. a bytes view) must have
|
|
104
|
+
caller-managed lifetime. Flag a reference held past the caller's scope.
|
|
105
|
+
- Flag count-based throttling introduced where time-based throttling would bound
|
|
106
|
+
cost better.
|
|
107
|
+
- Flag code that uses `std::function` instead of `Function`, `std::unordered_map`
|
|
108
|
+
instead of a flat map, or fails to use `std::move` for non-trivial types. Also
|
|
109
|
+
flag error paths that return an empty result instead of using `Result<T>`.
|
|
110
|
+
- SnapDrawing is an allocation-sensitive render path; flag a new synchronous API
|
|
111
|
+
that races the main thread against draw calls, as it can deadlock.
|
|
112
|
+
|
|
113
|
+
### Android
|
|
114
|
+
|
|
115
|
+
Paths: `valdi/src/valdi/android`, `valdi/src/java/com/snap/valdi/views`.
|
|
116
|
+
|
|
117
|
+
- Tests ≠ perf-safe: JVM/Robolectric tests can't measure JNI roundtrip cost, real
|
|
118
|
+
`onDraw` frame time, native allocation pressure, bitmap accumulation, or
|
|
119
|
+
low-end-device behavior. Flag new perf-critical Android code (per-frame
|
|
120
|
+
`onDraw`, JNI in a hot path, render-path allocation) to note that green CI's
|
|
121
|
+
JVM tests haven't validated its cost — a feature flag is the practical safety net.
|
|
122
|
+
- Per-frame predicate cost: when new `onDraw` code calls a predicate to decide
|
|
123
|
+
whether to run feature logic, the predicate cost itself is ungated — every
|
|
124
|
+
frame, every consumer. Cache it at bind time.
|
|
125
|
+
|
|
126
|
+
```kotlin
|
|
127
|
+
// ❌ predicate runs every frame for every consumer
|
|
128
|
+
override fun onDraw(canvas: Canvas) {
|
|
129
|
+
if (attributedText.hasAnimationTransform()) { /* ... */ } // O(N JNI) per frame
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// ✅ computed once at bind time; onDraw reads a cached field
|
|
133
|
+
fun setAttributedText(text: AttributedText) {
|
|
134
|
+
this.hasAnimationTransform = text.hasAnimationTransform()
|
|
135
|
+
}
|
|
136
|
+
override fun onDraw(canvas: Canvas) {
|
|
137
|
+
if (hasAnimationTransform) { /* ... */ }
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
- Attributed-text predicates (`hasAnimationTransform()`,
|
|
142
|
+
`hasActiveAnimationTransform()`, `hasRenderableAnimationTransform()`,
|
|
143
|
+
`hasOutline()`, and similar) iterate every part with at least one JNI call per
|
|
144
|
+
part — they look O(1) but are O(N JNI). In `onDraw` or any per-frame entry
|
|
145
|
+
point, flag them unless the result is cached at bind time. A 5-part caption at
|
|
146
|
+
60fps costs ~600 JNI crossings/second per consumer.
|
|
147
|
+
- Per-frame / per-flush allocation: in `onDraw`/animation-tick and view-operation
|
|
148
|
+
flush entry points, flag allocations (StringBuilder, String concat, ArrayList,
|
|
149
|
+
lambda) and tree walks — including those in directly-called helpers — that fire
|
|
150
|
+
N times per flush.
|
|
151
|
+
- Diagnostic on a hot path: when telemetry, crash metadata, or tracing is added to
|
|
152
|
+
a hot path, flag when the prep feeding the slow/failure branch runs eagerly
|
|
153
|
+
rather than behind the threshold. Hold refs plus an index and stringify lazily;
|
|
154
|
+
the shape to push toward is `if (elapsedMs > THRESHOLD) { /* capture */ }`.
|
|
155
|
+
Verify author cost claims by reading the diff, not the description.
|
|
156
|
+
- Flag UI touches in `finalize()` (runs on the finalizer thread). Flag use of
|
|
157
|
+
`LinkedList` in favor of array-backed lists (GC pressure). Flag singleton →
|
|
158
|
+
per-call allocation changes that compound across every view transaction.
|
|
159
|
+
|
|
160
|
+
### iOS
|
|
161
|
+
|
|
162
|
+
Paths: `valdi/src/valdi/ios`.
|
|
163
|
+
|
|
164
|
+
- UIKit is main-thread-only. `@synchronized` plus synchronous dispatch to another
|
|
165
|
+
thread is a known deadlock pattern that has caused production ANRs. Flag code
|
|
166
|
+
called from background contexts (timers, reporters, observers) that contends
|
|
167
|
+
with the main thread.
|
|
168
|
+
- `auto &` in an ObjC++ block does not retain — flag a captured reference that
|
|
169
|
+
must be copied.
|
|
170
|
+
- Flag a missing `isKindOfClass:` check before casting (`NSNull` is truthy).
|
|
171
|
+
- Flag `@synchronized` around immutable state set in the initializer (unnecessary).
|
|
172
|
+
|
|
173
|
+
## Material secondary checks
|
|
174
|
+
|
|
175
|
+
Include only when material — a regression and performance lens, not a style,
|
|
176
|
+
naming, or organization pass.
|
|
177
|
+
|
|
178
|
+
- **Lazy over eager:** flag eager static initializers, eager schema registration
|
|
179
|
+
on startup, or eager asset preloading where lazy initialization would work.
|
|
180
|
+
- **Resource lifecycle:** when a PR adds a cache or pool of OS-managed resources
|
|
181
|
+
(bitmaps, file handles, native pointers, listeners), flag a missing cleanup path
|
|
182
|
+
(`recycle`/`close`/`dispose`/`clear`).
|
|
183
|
+
- **Cross-platform parity:** when a PR changes only one platform's native
|
|
184
|
+
implementation, flag that implementation to ask whether the other platform needs
|
|
185
|
+
an equivalent update. Doesn't apply to platform-specific DI wiring or the shared
|
|
186
|
+
C++ runtime.
|
|
187
|
+
- **Runtime isolation:** keep the core runtime free of host-application
|
|
188
|
+
dependencies; flag a new direct dependency from runtime code into app-specific
|
|
189
|
+
modules.
|
|
@@ -29,10 +29,12 @@ Hermes debug socket not found on port 13595.
|
|
|
29
29
|
The app must be **running on a connected device or emulator**, and the **hot-reloader must be running from the project directory**:
|
|
30
30
|
|
|
31
31
|
```
|
|
32
|
-
valdi hotreload
|
|
33
|
-
valdi hotreload ios
|
|
32
|
+
valdi hotreload
|
|
34
33
|
```
|
|
35
34
|
|
|
35
|
+
`hotreload` auto-resolves the app target for the running platform (it prompts if
|
|
36
|
+
several exist); pass `--target` to pick one explicitly.
|
|
37
|
+
|
|
36
38
|
The hot-reloader creates the `port 13595` tunnel to the Hermes debug server (which starts on a random port inside the app). Without it, port 13595 is not reachable.
|
|
37
39
|
|
|
38
40
|
> **Note**: The hot-reloader does not need to compile successfully. Even if it prints TypeScript errors, it still sets up the port-13595 tunnel and the profile command will work.
|
|
@@ -72,7 +74,7 @@ The `.cpuprofile` file is standard Chrome DevTools CPU profile format.
|
|
|
72
74
|
|
|
73
75
|
### "Profile a slow render"
|
|
74
76
|
|
|
75
|
-
1. Start the app and run `valdi hotreload
|
|
77
|
+
1. Start the app and run `valdi hotreload`
|
|
76
78
|
2. Navigate to the screen in the app
|
|
77
79
|
3. Run: `valdi profile capture --duration 5`
|
|
78
80
|
4. Trigger the slow interaction during the 5-second window
|
|
@@ -133,12 +133,9 @@ valdi hotreload
|
|
|
133
133
|
```
|
|
134
134
|
|
|
135
135
|
Run from your module directory. The CLI watches for file changes, recompiles, and
|
|
136
|
-
pushes the updated module to a connected simulator or device
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
```bash
|
|
140
|
-
valdi hotreload --network # Discover device over Wi-Fi instead of USB
|
|
141
|
-
```
|
|
136
|
+
pushes the updated module to a connected simulator or device. It takes optional
|
|
137
|
+
`--module` and `--target` flags to disambiguate when the module or app target
|
|
138
|
+
can't be inferred.
|
|
142
139
|
|
|
143
140
|
If hot reload stops reflecting changes, stop with `Ctrl+C` and restart — the CLI
|
|
144
141
|
will clean stale build artifacts automatically.
|
|
@@ -59,7 +59,7 @@ valdi_module(
|
|
|
59
59
|
"//src/valdi_modules/src/valdi/valdi_core",
|
|
60
60
|
"//src/valdi_modules/src/valdi/valdi_tsx",
|
|
61
61
|
"//src/valdi_modules/src/valdi/valdi_test",
|
|
62
|
-
"//src/valdi_modules/src/valdi/foundation
|
|
62
|
+
"//src/valdi_modules/src/valdi/foundation",
|
|
63
63
|
],
|
|
64
64
|
)
|
|
65
65
|
```
|
|
@@ -188,11 +188,19 @@ onRender() {
|
|
|
188
188
|
|
|
189
189
|
### Font weights
|
|
190
190
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
- `'system-bold 16'` — bold weight
|
|
191
|
+
The system font now exposes medium, semibold,
|
|
192
|
+
and italic variants in addition to regular and bold:
|
|
194
193
|
|
|
195
|
-
|
|
194
|
+
- `'system 16'` / `systemFont(16)` — regular
|
|
195
|
+
- `'system-medium 16'` / `systemMediumFont(16)` — medium
|
|
196
|
+
- `'system-semibold 16'` / `systemSemiboldFont(16)` — semibold
|
|
197
|
+
- `'system-bold 16'` / `systemBoldFont(16)` — bold
|
|
198
|
+
- italic variants: `'system-italic'`, `'system-medium-italic'`, `'system-semibold-italic'`,
|
|
199
|
+
`'system-bold-italic'` (helpers: `systemItalicFont`, `systemMediumItalicFont`, …)
|
|
200
|
+
|
|
201
|
+
Prefer the helper functions from `valdi_core/src/SystemFont` over raw strings. **`system-light`
|
|
202
|
+
still does not exist** — there is no light weight. (Older guidance said only `system` and
|
|
203
|
+
`system-bold` were available and to substitute `system-bold` for semibold — that is no longer true.)
|
|
196
204
|
|
|
197
205
|
### ScrollView restrictions
|
|
198
206
|
|
|
@@ -253,16 +261,19 @@ new Style<View>({
|
|
|
253
261
|
|
|
254
262
|
// ❌ WRONG - These don't exist in Valdi
|
|
255
263
|
new Style<View>({
|
|
256
|
-
gap: 10, // ❌ Use margin on children
|
|
257
264
|
paddingHorizontal: 20, // ❌ Use padding: '0 20'
|
|
258
265
|
paddingVertical: 10, // ❌ Use padding: '10 0'
|
|
259
266
|
paddingInline: 15, // ❌ Doesn't exist
|
|
260
267
|
})
|
|
261
268
|
|
|
262
|
-
//
|
|
263
|
-
|
|
264
|
-
//
|
|
265
|
-
|
|
269
|
+
// ✅ Flexbox gap — NOW SUPPORTED (Yoga upgrade)
|
|
270
|
+
// gap / rowGap / columnGap are valid on any layout element (View, Layout, …),
|
|
271
|
+
// both as a JSX attribute and inside a Style object.
|
|
272
|
+
new Style<View>({ flexDirection: 'row', gap: 8 }) // ✅ works
|
|
273
|
+
// In JSX: <view flexDirection="row" gap={8}>
|
|
274
|
+
// NOTE: most existing composer_modules code still spaces children with margin
|
|
275
|
+
// (`marginRight={8}` / `margin="0 8 0 0"`) — `gap` is newly available, not yet
|
|
276
|
+
// the prevailing convention, so match the surrounding file.
|
|
266
277
|
```
|
|
267
278
|
|
|
268
279
|
### Layout: Flexbox (Yoga)
|
|
@@ -276,6 +287,9 @@ new Style<View>({
|
|
|
276
287
|
alignItems: 'center', // 'flex-start' | 'center' | 'flex-end' | 'stretch' | 'baseline'
|
|
277
288
|
alignContent: 'flex-start', // For multi-line flex containers
|
|
278
289
|
flexWrap: 'wrap', // 'wrap' | 'nowrap' | 'wrap-reverse'
|
|
290
|
+
gap: 8, // spacing between children, both axes (Yoga)
|
|
291
|
+
rowGap: 8, // spacing between flex rows
|
|
292
|
+
columnGap: 8, // spacing between flex columns
|
|
279
293
|
|
|
280
294
|
// Child properties
|
|
281
295
|
flexGrow: 1, // Grow to fill space (NOTE: use flexGrow, not flex)
|
|
@@ -361,6 +375,28 @@ const layoutStyle = new Style<Layout>({ padding: 10 });
|
|
|
361
375
|
>
|
|
362
376
|
> **📖 Best practices**: See `/docs/docs/core-styling.md` for styling patterns and examples
|
|
363
377
|
|
|
378
|
+
## Recently added elements & attributes
|
|
379
|
+
|
|
380
|
+
New framework surface landed via public Valdi imports (PRs #98, #107, and the Liquid
|
|
381
|
+
Glass work). Signatures live in `valdi_tsx/src/NativeTemplateElements.d.ts`.
|
|
382
|
+
|
|
383
|
+
- **`<glass>` (GlassView)** — Apple "Liquid Glass" material, **iOS 26+ only**. Attrs:
|
|
384
|
+
`glassStyle` (`'regular' | 'clear'`), `glassTintColor`, `interactive`, `glassAppearance`
|
|
385
|
+
(`'light' | 'dark'`). Android and iOS < 26 fall back automatically (plain view / blur —
|
|
386
|
+
no caller change, no crash), mirroring `<blur>`. Tint with `glassTintColor`, **not**
|
|
387
|
+
`backgroundColor` (an opaque background muddies the glass).
|
|
388
|
+
- **`<textanimationgroup>` (TextAnimationGroup)** — container that gives its descendant
|
|
389
|
+
text/attributed-text a single shared animation timeline. See the `valdi-animations` skill.
|
|
390
|
+
- **Native sticky headers (experimental)** — `<scroll>` gains `nativeStickyEnabled` /
|
|
391
|
+
`nativeStickyCover` / `nativeStickyOffset`; tag a descendant with `stickyPosition="top"`.
|
|
392
|
+
Repositions in the native scroll pass (skips the laggy JS round-trip). See `valdi-perf`.
|
|
393
|
+
- **Text elements** — `<label>` and `<textview>` are now containers and gained
|
|
394
|
+
`selectable`, `selection`, `onSelectionChange`, `lineHeightAbsolute`, `customUnderlineStyle`,
|
|
395
|
+
and iOS `onTextSelectionMenu` / `onTextSelectionMenuAction`. `<textfield>` gained
|
|
396
|
+
`adjustsFontSizeToFitWidth` + `minimumScaleFactor`. `<textview>` also gained `numberOfLines`
|
|
397
|
+
and `textOverflow`. `textDecoration` now also accepts `'dashed-underline'` and
|
|
398
|
+
`'dotted-underline'` (in addition to `'none' | 'strikethrough' | 'underline'`).
|
|
399
|
+
|
|
364
400
|
## @ExportModel ViewModel Restrictions
|
|
365
401
|
|
|
366
402
|
Interfaces annotated with `@ViewModel @ExportModel` are exported to native code. The Valdi compiler can only export **primitive types** (`string`, `number`, `boolean`) and other `@ExportModel`-annotated interfaces. Custom type aliases (e.g. `type Direction = 'UP' | 'DOWN'`) are **not supported** in exported ViewModels.
|
|
@@ -392,7 +428,7 @@ interface GameState {
|
|
|
392
428
|
5. **Suggesting scheduleRender()** - Deprecated, use StatefulComponent + setState()
|
|
393
429
|
6. **Using addEventListener** - Use element callbacks like onTap, onPress, onChange
|
|
394
430
|
7. **Using setInterval/setTimeout directly** - Use this.setTimeoutDisposable()
|
|
395
|
-
8. **Using CSS properties that don't exist** - No
|
|
431
|
+
8. **Using CSS properties that don't exist** - No paddingHorizontal, paddingVertical, paddingInline. (`gap`/`rowGap`/`columnGap` DO now exist (Yoga upgrade), though margins remain the common way children are spaced in existing code.)
|
|
396
432
|
9. **Using `flex: 1`** - `flex` doesn't exist on `View`; use `flexGrow: 1` instead
|
|
397
433
|
10. **Using `fontSize` on Label** - Labels use `font: 'system 20'` (string), not `fontSize`
|
|
398
434
|
11. **Typing SIGIcon values as `string`** - `SIGIcon.cameraStroke` etc. return `Asset`, not `string`; use `import { Asset } from 'valdi_core/src/Asset'` for ViewModel fields that store icon references
|
|
@@ -400,7 +436,7 @@ interface GameState {
|
|
|
400
436
|
13. **Using type aliases in `@ExportModel` ViewModels** - Only primitives and other `@ExportModel` types are allowed
|
|
401
437
|
14. **Importing `Shape` instead of `ShapeView`** - `Shape` is not exported; use `import { ShapeView } from 'valdi_tsx/src/NativeTemplateElements'` and `new Style<ShapeView>({...})`
|
|
402
438
|
15. **Using per-side border properties** - No `borderRight`, `borderRightWidth`, etc. Only `borderWidth`, `borderColor`, `borderRadius` exist. Use a thin `<view>` as a divider instead.
|
|
403
|
-
16. **
|
|
439
|
+
16. **Assuming only `system`/`system-bold` exist** - `system-medium`, `system-semibold`, and italic variants are available too (prefer the `SystemFont` helpers). Only `system-light` is still absent.
|
|
404
440
|
17. **ViewModel/Context name collisions** - When a module has multiple components, each exported `ViewModel` and `ComponentContext` must have a unique name (e.g. `WeatherCardViewModel` not just `ViewModel`), or the compiler will emit conflicting platform types.
|
|
405
441
|
18. **Using `flexDirection` on ScrollView** - ScrollView doesn't support flexDirection; it scrolls vertically by default
|
|
406
442
|
|