@hueest/xray 0.1.0 → 0.3.0

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/dist/client.d.ts CHANGED
@@ -1,19 +1,29 @@
1
- import { s as ViewCapture } from "./plate-DboxMKg-.js";
1
+ import { l as CaptureDiagnostic, o as StoredPlate } from "./plate-BIr62u7l.js";
2
2
 
3
3
  //#region src/client.d.ts
4
4
  /**
5
5
  * The dev capture client (M2). Runs in the browser during dev only: installs
6
- * the `__XRAY__` hook `<Skeleton>` calls when content becomes ready,
7
- * settles, serializes the subtree into a view capture, and hands it to the
8
- * sink (the plugin's POST endpoint in M3). Re-captures when the viewport
6
+ * the `__XRAY__` hook `<Skeleton>` calls when content becomes ready, settles,
7
+ * measures the subtree into a per-Plate `PlateIR`, projects it to the structured
8
+ * `StoredPlate` in the browser (the ADR 0022 in-browser Serialize), and hands the
9
+ * envelope to the sink (the plugin's POST endpoint). Re-captures when the viewport
9
10
  * crosses into another view while a site is still mounted.
11
+ *
12
+ * Two paths produce a Plate. BROWSE-TIME is a RECORDING SESSION (the Capture toggle):
13
+ * while on, each capture accumulates a View into a name-keyed `PlateIR` buffer
14
+ * (deduped per breakpoint band) and live-previews it in-memory; toggling off writes
15
+ * each accumulated Plate to the sink ONCE. The capture-all SWEEP threads ONE `PlateIR`
16
+ * through every emulated width (one View each) and posts the projected StoredPlate once.
10
17
  */
11
- interface CapturePayload {
12
- name: string;
13
- /** This capture, view interval already derived. */
14
- capture: ViewCapture;
15
- /** Width thresholds derived for this plate (rules' @media + matchMedia queries). */
16
- breakpoints: number[];
18
+ /**
19
+ * The `/__xray` POST envelope (ADR 0022 cutover). `plate` is the finished,
20
+ * in-browser-projected `StoredPlate` written to disk as-is; `diagnostics` is a
21
+ * SIBLING dev-only field the server logs and drops — it NEVER reaches the stored
22
+ * artifact (ADR 0008).
23
+ */
24
+ interface CaptureEnvelope {
25
+ plate: StoredPlate;
26
+ diagnostics?: CaptureDiagnostic[];
17
27
  }
18
28
  interface ClientOptions {
19
29
  /** Settle delay (ms) once the subtree goes quiet. Default 200. */
@@ -29,14 +39,52 @@ interface ClientOptions {
29
39
  */
30
40
  maxNodes?: number;
31
41
  /**
32
- * Initial state of the capture toggle: whether browsing re-captures plates.
33
- * A per-tab override (sessionStorage / `?xray-capture`) wins over it.
34
- * Defaults to `true` — the plugin passes its own (off-by-default) policy.
42
+ * Initial state of the capture toggle: whether the recording session is active
43
+ * at boot. A per-tab override (sessionStorage / `?xray-capture`) wins over it.
44
+ * Defaults to `false` — recording is explicit opt-in (turn it on, browse/resize to
45
+ * accumulate Views, turn it off to write), so normal browsing never accumulates and
46
+ * an HMR/close can't drop an unsaved recording. The plugin passes the same
47
+ * off-by-default policy; a direct caller can pass `true` to capture on boot.
35
48
  */
36
49
  capture?: boolean;
37
- /** Where finished captures go. */
38
- sink: (payload: CapturePayload) => void;
50
+ /**
51
+ * Where finished captures go. May be synchronous (fire-and-forget) or return
52
+ * a promise that resolves once the write is server-confirmed. Browse-time
53
+ * capture ignores the return value; the capture-all sweep awaits it so it
54
+ * does not advance to the next emulated width until the current writes have
55
+ * been accepted by the dev server (backpressure — capture-all-backpressure plan).
56
+ */
57
+ sink: (envelope: CaptureEnvelope) => void | Promise<void>;
58
+ /**
59
+ * Re-pull the on-disk per-plate coverage and feed it into the coverage store.
60
+ * The capture-all sweep calls this after each pass so the next `sweepWidths()`
61
+ * sees the breakpoints just written by that pass, rather than racing the
62
+ * async `xray:plate` HMR event (coverage freshness — capture-all-backpressure
63
+ * plan). Optional: browse-time capture never needs it, and the unit tests
64
+ * drive coverage directly through the store.
65
+ */
66
+ refreshCoverage?: () => void | Promise<void>;
67
+ /**
68
+ * Fixtures boot state (ADR 0015). `record` is when to write the live `data` to a
69
+ * sidecar (`'manual'` — HUD button only, the default; `'first-ready'`; or
70
+ * `'always'`); `replay` is whether to substitute a recorded Fixture for live
71
+ * `data` (`false`, `'prefer'`, or `'missing-only'`). The HUD overrides the
72
+ * replay toggle per tab. Absent ≡ defaults (`'manual'` / `false`).
73
+ */
74
+ record?: 'manual' | 'first-ready' | 'always';
75
+ replay?: false | 'prefer' | 'missing-only';
76
+ /**
77
+ * Where a recorded Fixture's OPAQUE devalue string is POSTed (the sidecar write
78
+ * endpoint). The client owns the devalue stringify; this only ships the bytes.
79
+ * Resolves once the write is server-confirmed, rejects on a non-2xx so the HUD
80
+ * Record button can surface a failed write. Absent ≡ Record is a no-op (the
81
+ * unit tests inject their own).
82
+ */
83
+ recordFixtureSink?: (payload: {
84
+ name: string;
85
+ data: string;
86
+ }) => void | Promise<void>;
39
87
  }
40
88
  declare function installXrayClient(options: ClientOptions): () => void;
41
89
  //#endregion
42
- export { CapturePayload, ClientOptions, installXrayClient };
90
+ export { CaptureEnvelope, ClientOptions, installXrayClient };