@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
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
# Valdi Debugger Frontend
|
|
2
|
+
|
|
3
|
+
This directory is the packaged browser UI served by `valdi debugger`.
|
|
4
|
+
It is intentionally local-only, dependency-free, and small enough to ship with
|
|
5
|
+
the CLI package.
|
|
6
|
+
|
|
7
|
+
## File Map
|
|
8
|
+
|
|
9
|
+
- `index.html`: static shell and DOM anchors for the debugger UI.
|
|
10
|
+
- `debugger.css`: themes, layout, controls, preview, inspector, and responsive styles.
|
|
11
|
+
- `debugger-state.js`: shared state, DOM references, constants, and action parameter helpers.
|
|
12
|
+
- `debugger-api.js`: fetch helpers, action stream, and development reload stream.
|
|
13
|
+
- `debugger-tree-model.js`: transport-neutral hierarchy identity, traversal, lookup, and path helpers shared by both frontends.
|
|
14
|
+
- `debugger-model.js`: snapshot normalization, bounds, issues, and standalone selection helpers.
|
|
15
|
+
- `debugger-preview-html.js`: inert HTML projection of the hot-reloaded snapshot tree.
|
|
16
|
+
- `debugger-render.js`: header, target list, tree, preview overlay, inspector, and export rendering.
|
|
17
|
+
- `debugger-runtime.js`: target discovery, snapshots, runtime log streaming, heap, and copy/export helpers.
|
|
18
|
+
- `debugger-performance.js`: renderer trace and Hermes CPU profile controls.
|
|
19
|
+
- `debugger-providers.js`: provider discovery plus read-only Storage and SQL inspector rendering.
|
|
20
|
+
- `debugger-settings.js`: published debug-setting discovery, rendering, validation, and mutation requests.
|
|
21
|
+
- `debugger-actions.js`: UI actions, command prompt handling, auto-refresh, and externally driven debugger actions.
|
|
22
|
+
- `debugger-session.js`: `sessionStorage` restore/persist for reload-friendly debugger state.
|
|
23
|
+
- `debugger-bootstrap.js`: DOM event wiring and boot sequence.
|
|
24
|
+
- `devtools-panel.html`, `devtools-panel.css`, and `devtools-panel.js`: the focused Chromium Elements, State, Console, and bounded Performance panel embedded by the generated extension.
|
|
25
|
+
|
|
26
|
+
Scripts are loaded as classic browser scripts in the order listed in
|
|
27
|
+
`index.html`. There is no module loader or bundler for this frontend; shared
|
|
28
|
+
functions and variables are intentionally global within the page.
|
|
29
|
+
|
|
30
|
+
## Server Contract
|
|
31
|
+
|
|
32
|
+
The local HTTP server lives in `../src/debugger/server.ts`. It serves these
|
|
33
|
+
assets and proxies debugger requests to Valdi daemon or Hermes endpoints.
|
|
34
|
+
|
|
35
|
+
Important routes:
|
|
36
|
+
|
|
37
|
+
- `/api/status`: preserves the legacy daemon-port and hot reload proxy status contract.
|
|
38
|
+
- `/api/snapshot`: fetches the selected target's view tree and preview data.
|
|
39
|
+
- `/api/runtime-logs` and `/api/runtime-logs/stream`: read and stream target logs.
|
|
40
|
+
- `/api/debugger/state`, `/api/debugger/events`, and `/api/debugger/actions`: keep the browser UI and external agents in sync.
|
|
41
|
+
- `/api/input`: validates and forwards bounded input requests to the selected Valdi target.
|
|
42
|
+
- `/api/performance/trace/*`: start, stop, capture, and export native renderer traces.
|
|
43
|
+
- `/api/debugger/providers` and `/api/debugger/providers/request`: discover and query target-owned debugger providers.
|
|
44
|
+
- `/api/debugger/settings`: discover and update target-published debug settings.
|
|
45
|
+
- `/api/performance/profile/*`: list Hermes contexts and capture CPU profiles.
|
|
46
|
+
- `/api/devtools/targets`: returns a fresh, bounded registry of native Valdi, explicit web-preview, and JavaScript-proxy targets.
|
|
47
|
+
- `/api/devtools/target`: resolves either one opaque native target ID or the exact configured inspected Chromium page identity.
|
|
48
|
+
- `/api/devtools/snapshot`, `/api/devtools/highlight`, and `/api/devtools/evaluate`: proxy the explicit web debugger bridge contract through loopback CDP.
|
|
49
|
+
- `/api/devtools/component-property`: applies one exact web-only scalar ViewModel property edit from a strict body-only identity and token tuple.
|
|
50
|
+
- `/api/devtools/performance/snapshot` and `/api/devtools/performance/trace/*`: sample the exact web preview and record one bounded global Chromium trace without changing the daemon/Hermes `/api/performance/*` routes.
|
|
51
|
+
|
|
52
|
+
Web preview targets advertise the independent `component-properties`
|
|
53
|
+
capability. Their Elements snapshots may include a `Valdi props` projection captured
|
|
54
|
+
from own enumerable data descriptors only; accessors, inherited fields, and
|
|
55
|
+
symbol keys are omitted. Component properties share a 64 KiB UTF-8 budget and
|
|
56
|
+
are discarded before the hierarchy if the complete snapshot reaches its
|
|
57
|
+
existing envelope limit. JavaScript has no resumable own-key iterator, so
|
|
58
|
+
reflecting a Proxy can execute its `ownKeys` and descriptor traps and may
|
|
59
|
+
materialize their complete key result before the cap is applied. A throwing or
|
|
60
|
+
revoked Proxy therefore causes that component's properties to be omitted while
|
|
61
|
+
preserving the hierarchy. Prototype traversal is not used, and property values
|
|
62
|
+
are never read through normal property access.
|
|
63
|
+
|
|
64
|
+
The same web hierarchy snapshot may include read-only component runtime state
|
|
65
|
+
without adding a route, capability, or renderer API. This is taken from the
|
|
66
|
+
exact component instance, not its ViewModel, and only from an own, enumerable
|
|
67
|
+
data descriptor named `state` whose value is a non-null object. Getters,
|
|
68
|
+
inherited fields, scalar state, and throwing reflection are omitted. The state
|
|
69
|
+
object is detached under the existing descriptor-only snapshot rules, encoded
|
|
70
|
+
as JSON, and admitted only when the exact escaped `component.state` wire string
|
|
71
|
+
fits the component snapshot's remaining 64 KiB UTF-8 budget after properties.
|
|
72
|
+
Detached and escaped-wire projection work is also bounded across the complete
|
|
73
|
+
hierarchy by separate byte, reflection, and attempt counters; indeterminate
|
|
74
|
+
nested reflection exhausts that State-only work budget without affecting
|
|
75
|
+
component properties or hierarchy capture. Own-key enumeration itself is not
|
|
76
|
+
resumable, so a Proxy may still materialize one complete key list. State checks
|
|
77
|
+
that list against its remaining reflection allowance before performing any
|
|
78
|
+
per-name descriptor lookup, and checks the allowance again before every nested
|
|
79
|
+
object or array descriptor lookup.
|
|
80
|
+
The pre-existing property-edit metadata is not debited from that counter and
|
|
81
|
+
remains bounded by the complete snapshot envelope. Topology revalidation binds
|
|
82
|
+
the same virtual node and component instance; an ineligible descriptor or
|
|
83
|
+
changed raw state identity removes only `component.state`, while ViewModel
|
|
84
|
+
replacement continues to remove only properties and edit metadata. If the
|
|
85
|
+
final hierarchy envelope is too large, runtime state is stripped and retried
|
|
86
|
+
before existing component properties and edit metadata are stripped.
|
|
87
|
+
|
|
88
|
+
Native detailed snapshots retain their existing human-readable
|
|
89
|
+
`IRenderedVirtualNodeData.state` string and are not changed by this web capture.
|
|
90
|
+
The State panel determines the serialization format from the target identity.
|
|
91
|
+
Inspected Chromium web snapshots accept strict JSON only. Native debug strings
|
|
92
|
+
do not escape keys, quoted contents, function names, error text, or marker text,
|
|
93
|
+
so every direct native snapshot is displayed as escaped raw text rather than
|
|
94
|
+
interpreted structurally. Raw display remains searchable. Input is capped at
|
|
95
|
+
65,536 characters; parsed web input is additionally capped at depth 12, tokens 2,000,
|
|
96
|
+
entries per container at 100, and keys at 1,024 characters. Parsed records have
|
|
97
|
+
null prototypes and are populated with data descriptors. Rendering is further
|
|
98
|
+
capped at 500 stateful components and 1,000 value rows. Main-panel search and
|
|
99
|
+
disclosures are independent from selected-component State details, and every
|
|
100
|
+
Inspect action is bound to the exact current snapshot node and render
|
|
101
|
+
generation.
|
|
102
|
+
|
|
103
|
+
An accepted web snapshot may additionally promote the separate
|
|
104
|
+
`component-property-edit` capability when both the renderer's dedicated
|
|
105
|
+
full-ViewModel mutation API and secure browser randomness are available. Static
|
|
106
|
+
target and registry responses do not claim this capability before the bridge
|
|
107
|
+
proves it. Editable strings, booleans, and finite numbers receive a 128-bit
|
|
108
|
+
lowercase hexadecimal token and a positive snapshot revision. Tokens bind the
|
|
109
|
+
exact component, virtual node, raw ViewModel identity, property name, data
|
|
110
|
+
descriptor, scalar type, and prior value. Tokens are single-use and expire
|
|
111
|
+
after 120 seconds. Each published snapshot replaces the current registry while
|
|
112
|
+
retaining only the immediately previous published revision, capped at 1,000
|
|
113
|
+
tokens per revision and 2,000 total, so a panel may safely discard one
|
|
114
|
+
already-requested poll without invalidating the snapshot it still displays.
|
|
115
|
+
Publishing another revision drops the older retained map; destruction,
|
|
116
|
+
secure-randomness failure, and expiry clear the associated object graphs.
|
|
117
|
+
Missing crypto, reflection failures, stale identity, invalid values, and
|
|
118
|
+
mutation failures fall back to the read-only property presentation with a
|
|
119
|
+
generic error. `children`, `prototype`,
|
|
120
|
+
`constructor`, and `__proto__` are never editable. ViewModels with a custom
|
|
121
|
+
prototype, more than 1,000 own keys, any accessor descriptor, or an own
|
|
122
|
+
function-valued data property remain read only. Plain and null-prototype
|
|
123
|
+
ViewModels may edit frozen scalar descriptors without mutating the source.
|
|
124
|
+
|
|
125
|
+
The renderer installs a read-only overlay Proxy over a stable shadow target
|
|
126
|
+
rather than using or mutating the exact prior ViewModel as the Proxy target. The
|
|
127
|
+
shadow snapshots the original prototype, complete descriptor set, own-key order, and
|
|
128
|
+
extensibility. Non-edited reads retain the exact source ViewModel as their
|
|
129
|
+
receiver, while repeated debugger edits flatten onto the same source without
|
|
130
|
+
depending on its later structural state. User Proxy `get` and `has` behavior
|
|
131
|
+
remains observable during fallback reads. If a Proxy `get` trap returns a
|
|
132
|
+
callable despite its data descriptor, the overlay returns a stable per-key
|
|
133
|
+
binding to the exact source ViewModel so method calls preserve receiver-private
|
|
134
|
+
state without invoking the trap during authorization. Inherited
|
|
135
|
+
`Object.prototype` members instead resolve against the shadow with the overlay
|
|
136
|
+
receiver, preserving their identity while routing legacy property mutators
|
|
137
|
+
through the overlay's rejection traps. Custom `ownKeys` behavior is captured
|
|
138
|
+
transactionally and served from the stable shadow after construction rather
|
|
139
|
+
than consulting the live source again.
|
|
140
|
+
Debugger writes, definitions, deletions, prototype changes, and
|
|
141
|
+
`preventExtensions` calls are rejected, while the dedicated full-ViewModel
|
|
142
|
+
rerender path receives the overlay. Native targets never advertise
|
|
143
|
+
`component-property-edit`, and the route cannot be reached through `targetId`,
|
|
144
|
+
the daemon protocol, the generic action bus, console evaluation, storage, or
|
|
145
|
+
telemetry.
|
|
146
|
+
|
|
147
|
+
Renderer tracing uses the runtime debugger protocol and the existing native
|
|
148
|
+
trace recorder. Captures are process-wide: the selected context is the capture
|
|
149
|
+
target used to reach the runtime, not the origin assigned to every event.
|
|
150
|
+
One-shot captures are limited to 15 seconds so the debugger handler can retain
|
|
151
|
+
the result before the native recorder's independent safety timeout, and
|
|
152
|
+
exported JSON can be opened in Perfetto. Native bounds report dropped event
|
|
153
|
+
counts, and retained timeout/retry results expire after one minute.
|
|
154
|
+
Hermes CPU profiling uses the existing inspector transport.
|
|
155
|
+
|
|
156
|
+
The native and synthetic previews forward capability, query, tap, focus, text,
|
|
157
|
+
key, and scroll requests through the selected target's bounded input contract.
|
|
158
|
+
Web-renderer inspection uses the first-party bridge exposed as
|
|
159
|
+
`window.__VALDI_WEB_DEBUGGER__` with `getSnapshot()`, `highlightNode()`,
|
|
160
|
+
`clearHighlight()`, and the synchronous exact `editComponentProperty()` path.
|
|
161
|
+
The DevTools panel proxies inspection through the exact configured loopback
|
|
162
|
+
Chromium target. Scalar controls remain read only unless the current snapshot
|
|
163
|
+
advertises both property capabilities and supplies valid edit metadata. While
|
|
164
|
+
an editor is focused or an edit owns its replacement snapshot refresh,
|
|
165
|
+
automatic refresh is paused; target, snapshot, selection, and operation
|
|
166
|
+
generations prevent stale completions from changing newer presentation.
|
|
167
|
+
Editable controls are hydrated with DOM APIs. Authorization tokens, component
|
|
168
|
+
identity, revisions, and the actionable binding stay out of serialized markup
|
|
169
|
+
in a private binding; the display property name is assigned only as safe DOM
|
|
170
|
+
text and an accessible name. String controls use a strict JSON string literal so
|
|
171
|
+
carriage returns, line feeds, NULs, quotes, unpaired surrogates, and unusual
|
|
172
|
+
nonblank property names round-trip exactly.
|
|
173
|
+
|
|
174
|
+
Web-preview performance requests require the exact `sessionId`, `inspectedUrl`,
|
|
175
|
+
and per-tab `targetNonce`; incomplete, stale, or cross-tab identities fail
|
|
176
|
+
closed. The recorder normalizes CDP events incrementally and retains at most
|
|
177
|
+
10,000 events with 2 KiB UTF-8 trace names. One-shot captures run for their
|
|
178
|
+
requested duration from 100 milliseconds through 15 seconds; manually started
|
|
179
|
+
recordings have a 15-second watchdog. An undelivered completed result is kept
|
|
180
|
+
for one minute. The complete response is limited
|
|
181
|
+
to 4 MiB and contains one normalized trace list plus export metadata—never a
|
|
182
|
+
duplicate raw or Perfetto event list. The panel shows at most 120 graph samples,
|
|
183
|
+
120 timeline rows, and 12 grouped summary rows. Its only trace filters are
|
|
184
|
+
Valdi, Browser, and All; Chrome Trace JSON is assembled only when exported.
|
|
185
|
+
|
|
186
|
+
Every `/api/devtools/targets` descriptor declares an `identityMode`.
|
|
187
|
+
`target-id` is used by native Valdi and waiting proxy records; only an
|
|
188
|
+
attachable `target-id` target using the `valdi-daemon` transport can be resolved
|
|
189
|
+
or snapshotted through `targetId`. `inspected-page` is reserved for the explicit
|
|
190
|
+
Chromium web preview, which must use the complete `inspectedUrl` plus
|
|
191
|
+
`targetNonce` identity for target resolution and the complete `sessionId`,
|
|
192
|
+
`inspectedUrl`, and `targetNonce` tuple for snapshots and performance. An
|
|
193
|
+
inspected-page target is never attachable through its public ID, and identity
|
|
194
|
+
modes cannot be mixed in one request.
|
|
195
|
+
|
|
196
|
+
Registry reads are snapshots, not leases: each list or target-ID resolution
|
|
197
|
+
rediscovers the current endpoints and rejects removed or replaced identities.
|
|
198
|
+
Discovery reads existing companion-owned ADB forwards and loopback proxy
|
|
199
|
+
metadata without creating or replacing forwarding state. It retains at most 8
|
|
200
|
+
ADB forwards, 10 daemon endpoints, 16 clients per endpoint, 64 contexts per
|
|
201
|
+
client, 128 proxy records, and 256 final targets; daemon fan-out is limited to
|
|
202
|
+
4 workers. Configured web-preview URLs are capped at 4,096 UTF-8 bytes and their
|
|
203
|
+
derived names at 256 bytes. Proxy responses are capped at 512 KiB and the final
|
|
204
|
+
serialized `/api/devtools/targets` response is independently capped at 512 KiB.
|
|
205
|
+
The legacy `/api/status` route intentionally keeps its prior port probing and
|
|
206
|
+
forwarding behavior and does not run registry discovery.
|
|
207
|
+
|
|
208
|
+
The DevTools panel has two mutually exclusive identity modes. An extension-opened
|
|
209
|
+
inspected page keeps using its exact `sessionId`, `inspectedUrl`, and
|
|
210
|
+
`targetNonce` tuple and never requests the target registry. A directly opened
|
|
211
|
+
panel receives one opaque `targetId`, discovers at most 256 registry entries,
|
|
212
|
+
and never falls back to the first, only, attached, or newly discovered target.
|
|
213
|
+
Only attachable `target-id` entries using the `valdi-daemon` transport and
|
|
214
|
+
advertising both `components` and `snapshot` can be selected. Inspected-page,
|
|
215
|
+
waiting, and unsupported entries remain visible with a disabled explanation.
|
|
216
|
+
Direct snapshot and capability-supported tool requests send only the selected
|
|
217
|
+
opaque `targetId`.
|
|
218
|
+
|
|
219
|
+
Target changes close the old Console stream before installing the replacement,
|
|
220
|
+
invalidate outstanding snapshot, highlight, Console, and Performance work, and
|
|
221
|
+
clear all target-owned presentation. Console and Performance tabs are enabled
|
|
222
|
+
only when the selected descriptor advertises their capability. A target change
|
|
223
|
+
is blocked while a Performance operation or recording owns the selected target;
|
|
224
|
+
if registry removal forces a detach, the exact previous Performance owner stays
|
|
225
|
+
available solely so the recording can be stopped and retrieved. Registry
|
|
226
|
+
removal never selects another target automatically.
|
|
227
|
+
|
|
228
|
+
The Data section discovers target-owned providers through a generic custom
|
|
229
|
+
message contract. The persistence module registers its bounded web snapshot as
|
|
230
|
+
the `persistent-store` Storage provider and reports it unavailable on platforms
|
|
231
|
+
whose native binding does not expose that inspector. SQL, Network, and
|
|
232
|
+
key-value integrations remain unavailable unless a runtime provider registers
|
|
233
|
+
them; the UI never synthesizes sample data.
|
|
234
|
+
|
|
235
|
+
Runtime adapters cross the provider boundary with an already serialized JSON
|
|
236
|
+
object document, not an arbitrary object graph. They should call
|
|
237
|
+
`createDebuggerProviderOwner(module, 'stable/adapter/module/key')`, register
|
|
238
|
+
their provider through that owner, and return
|
|
239
|
+
`createDebuggerProviderResult(JSON.stringify(snapshot))` from `handleRequest`.
|
|
240
|
+
Core caps action documents at 48 KiB of UTF-8, validates their depth,
|
|
241
|
+
collection sizes, strings, and total value count, and then enforces 128 KiB on
|
|
242
|
+
the complete serialized custom-response body including metadata. Owners bind
|
|
243
|
+
to the creating module object's hot-reload callback automatically, including
|
|
244
|
+
webpack modules where `module.path` is absent. Adapters call
|
|
245
|
+
`owner.dispose()` only when stopping before a reload. A newer registration for
|
|
246
|
+
an existing provider ID permanently invalidates the older registration. The
|
|
247
|
+
PersistentStore adapter projects known data properties into a deterministic
|
|
248
|
+
43 KiB document before calling this helper. On native runtimes the owner
|
|
249
|
+
observes `module.path`; the explicit stable key is replacement identity only.
|
|
250
|
+
Web runtimes fall back to observing that stable key because webpack does not
|
|
251
|
+
provide `module.path`.
|
|
252
|
+
|
|
253
|
+
Published settings are application-owned controls registered only in debug
|
|
254
|
+
runtimes. Values are limited to declared toggle, select, text, and number
|
|
255
|
+
settings; the server does not expose arbitrary runtime property mutation.
|
|
256
|
+
|
|
257
|
+
Detailed debugger snapshots explicitly opt in to component ViewModel and state
|
|
258
|
+
serialization. That data can be sensitive, is bounded by a per-field and
|
|
259
|
+
whole-tree character budget, and is never included in ordinary `valdi inspect
|
|
260
|
+
tree` requests. Component hierarchy snapshots also include developer-authored
|
|
261
|
+
component keys verbatim in `component.key` and stable node IDs, so keys must
|
|
262
|
+
not contain secrets, PII, or other user data. Auto-refresh starts disabled so
|
|
263
|
+
serialization remains a deliberate local debugging action. The server rejects non-loopback Host,
|
|
264
|
+
Origin, and cross-site browser API requests. It also generates a fresh
|
|
265
|
+
high-entropy API token for every server instance and rejects every `/api/*`
|
|
266
|
+
GET, POST, and event stream that does not present it. Browser and DevTools
|
|
267
|
+
pages receive the token in the served HTML bootstrap, use the
|
|
268
|
+
`X-Valdi-Debugger-Token` header for fetches, and add it only to same-origin
|
|
269
|
+
EventSource URLs (whose document has `Referrer-Policy: no-referrer`). The
|
|
270
|
+
ordinary CLI log and `VALDI_DEBUGGER_URL` never contain the token. Agents must
|
|
271
|
+
start the command with `--json`, treat the returned `apiToken` as a secret, and
|
|
272
|
+
send it using the returned `apiTokenHeader` name.
|
|
273
|
+
|
|
274
|
+
The UI listener and CLI target discovery use separate environment variables:
|
|
275
|
+
|
|
276
|
+
- `VALDI_DEBUGGER_UI_PORT` selects the browser HTTP port (default `8765`).
|
|
277
|
+
- `VALDI_DEBUGGER_SERVICE_PORT` tells target discovery which Valdi runtime
|
|
278
|
+
debugger service port to probe. Without it, discovery probes
|
|
279
|
+
the standalone and mobile defaults (`13591` and `13592`).
|
|
280
|
+
|
|
281
|
+
Both values must be decimal integers in the range 1–65535. The legacy
|
|
282
|
+
`VALDI_DEBUGGER_PORT` name is intentionally not used by the UI or service.
|
|
283
|
+
|
|
284
|
+
The normal debugger document and every other static asset use
|
|
285
|
+
`frame-ancestors 'none'` plus `X-Frame-Options: DENY`. Only
|
|
286
|
+
`/devtools-panel.html` permits a Chromium extension ancestor. The CLI generates
|
|
287
|
+
that unpacked extension in a fresh temporary directory without a stable manifest
|
|
288
|
+
key, so Chromium's extension ID is ephemeral and cannot be pinned in the CSP.
|
|
289
|
+
This framing rule is not an authorization boundary: executable DevTools routes
|
|
290
|
+
additionally require same-origin JSON requests and exact inspected-target URL,
|
|
291
|
+
session, and high-entropy nonce checks.
|
|
292
|
+
|
|
293
|
+
## Development Loop
|
|
294
|
+
|
|
295
|
+
For an installed CLI:
|
|
296
|
+
|
|
297
|
+
```bash
|
|
298
|
+
valdi debugger
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
For local CLI development, build the CLI, then run the built entrypoint:
|
|
302
|
+
|
|
303
|
+
```bash
|
|
304
|
+
cd npm_modules/cli
|
|
305
|
+
npm run build
|
|
306
|
+
node dist/index.js debugger --host 127.0.0.1 --port 8765
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
For a manually launched Owl/Chromium web preview:
|
|
310
|
+
|
|
311
|
+
```bash
|
|
312
|
+
node dist/index.js debugger \
|
|
313
|
+
--web-preview-url http://127.0.0.1:8080/index.html \
|
|
314
|
+
--chromium-debugging-port 9222
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
Start Owl/Chromium with the printed `--remote-debugging-port` and
|
|
318
|
+
`--load-extension` values, then open the exact opted-in preview URL printed by
|
|
319
|
+
the command. Target matching ignores the reserved development parameters
|
|
320
|
+
`valdiDebugger`, `valdiDevTools`, and the optional, explicitly requested
|
|
321
|
+
`valdiTrace` parameter, then requires the same origin, pathname, and remaining
|
|
322
|
+
query parameters. The debugger command does not enable tracing by default.
|
|
323
|
+
|
|
324
|
+
The synthetic native-tree preview never auto-loads projected HTTP(S) image,
|
|
325
|
+
video, CSS background, or WebView resources. Only `data:` and `blob:` media are
|
|
326
|
+
assigned; WebView contents are represented by an inert placeholder.
|
|
327
|
+
|
|
328
|
+
The debugger server watches `.html`, `.css`, and `.js` files in this directory
|
|
329
|
+
and emits `/api/dev-events`; the browser reloads itself when these files change.
|
|
330
|
+
If you add a new static asset type, update the server MIME map and watcher.
|
|
331
|
+
|
|
332
|
+
Session state is persisted in `sessionStorage` under
|
|
333
|
+
`valdi.debugger.session.v1`, so normal debugger refreshes should preserve the
|
|
334
|
+
active section, selected target/node, filters, expanded tree nodes, and capture
|
|
335
|
+
settings, plus the active provider and published-settings group. Provider and
|
|
336
|
+
settings payloads are cleared when the selected target changes.
|
|
337
|
+
|
|
338
|
+
## Validation
|
|
339
|
+
|
|
340
|
+
For frontend-only changes:
|
|
341
|
+
|
|
342
|
+
```bash
|
|
343
|
+
for file in npm_modules/cli/debugger/debugger*.js; do node -c "$file" || exit 1; done
|
|
344
|
+
git diff --check
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
For changes that touch the server or CLI TypeScript:
|
|
348
|
+
|
|
349
|
+
```bash
|
|
350
|
+
cd npm_modules/cli
|
|
351
|
+
npm run build
|
|
352
|
+
node_modules/.bin/tsc --noEmit --project tsconfig.dist.json
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
When validating the full ordered browser bundle, concatenate the scripts in the
|
|
356
|
+
same order as `index.html` and parse the result with `new Function(...)`.
|