@hueest/xray 0.2.0 → 0.4.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.
@@ -1,143 +0,0 @@
1
- import { n as MergedPlate, s as ViewCapture, t as LeafKind } from "./plate-Bv6W-GkA.js";
2
-
3
- //#region src/serialize.d.ts
4
- /**
5
- * Browser-side capture: walk a live rendered subtree into a Plate — one node
6
- * tree plus one self-contained, scoped CSS string (ADR 0003). The CSS is
7
- * lifted from the author rules that matched each node, rewritten to
8
- * plate-local selectors — it carries `@media` for free and keeps layout live
9
- * (the M1 bake-off winner; ADR 0005).
10
- */
11
- interface CaptureOptions {
12
- /** Plate name; comes from the virtual-module specifier. */
13
- name: string;
14
- /**
15
- * Optional programmable capture walker (ADR 0018). The declarative `data-xr-*`
16
- * annotations cover the 90%; this is the escape hatch for the 10% a markup
17
- * attribute cannot express. Capture-only: it shapes the resulting `PlateNode`
18
- * tree but is never persisted into the Plate, and the production adapter never
19
- * captures so it ignores this entirely.
20
- */
21
- walker?: XrayCaptureWalker;
22
- /**
23
- * Whether the top-level capture roots ARE this plate's own boundary, so the
24
- * stitch guard must be SKIPPED for them (ADR 0006/0014, finding #6). True ONLY
25
- * for a MANUAL root: there `site.el` is the consumer's own element and its
26
- * `data-xr-boundary` marks the boundary of THIS plate, so the root must be
27
- * serialized as a real Entry (its box/classes/padding/border) rather than a
28
- * stitch-to-itself. Defaults to `false` — the auto path, where the top-level
29
- * roots are the wrapper's CHILDREN and any boundary marker on a direct-child
30
- * root is a NESTED `<Skeleton>` that MUST stitch (the capture-leak guard).
31
- */
32
- captureRootIsBoundary?: boolean;
33
- }
34
- declare const WALKER_RESULT: unique symbol;
35
- /**
36
- * A capture-walk decision. Obtainable ONLY from `ctx.ignore()/bone()/walk()` or
37
- * `next()` — a consumer cannot hand-build one, so arbitrary `PlateNode`s can
38
- * never cross the capture boundary (ADR 0018: helpers expose decisions, never
39
- * raw `PlateNode`s, so xray keeps ownership of the Plate format). Opaque by
40
- * design: it wraps the internal `PlateNode | null` with zero runtime cost and is
41
- * unwrapped only inside the engine.
42
- */
43
- interface WalkerResult {
44
- readonly [WALKER_RESULT]: true;
45
- }
46
- /**
47
- * The context handed to a capture walker's `element` hook (ADR 0018). Every
48
- * member is a HELPER that returns an opaque `WalkerResult` decision — a walker
49
- * NEVER hand-builds a `PlateNode`. `el` is the element under consideration; the
50
- * helpers either drop it, collapse it to one measured Bone, or defer to the
51
- * built-in walk.
52
- */
53
- interface CaptureWalkerContext {
54
- /** The element currently being classified. */
55
- el: Element;
56
- /** Drop this element and its entire subtree (no bone). */
57
- ignore: () => WalkerResult;
58
- /**
59
- * Collapse this element's subtree into ONE measured Bone leaf. `kind` omitted
60
- * shares the default classifier's kind-inference heuristic (ADR 0018, Q4).
61
- */
62
- bone: (opts?: {
63
- kind?: LeafKind;
64
- }) => WalkerResult;
65
- /**
66
- * Run the built-in walk for this element: the annotation walker, then the
67
- * default classifier (and recurse into the subtree). The decision `next()`
68
- * would produce if the walker deferred without inspecting it.
69
- */
70
- walk: () => WalkerResult;
71
- }
72
- /**
73
- * The programmable capture walker (ADR 0018), v1. `element` is the ONLY hook
74
- * implemented in v1; `text`/`declarations`/`media`/`list` are RESERVED in the
75
- * type for future versions and intentionally unimplemented — declaring them now
76
- * keeps a later addition non-breaking. `next()` runs the downstream decision
77
- * (annotation walker, then default classifier) and RETURNS it as an opaque
78
- * `WalkerResult`, which a walker returns verbatim to defer (ADR 0018, Q3).
79
- */
80
- interface XrayCaptureWalker {
81
- /**
82
- * Called for every non-boundary element (the stitch guard runs first and is
83
- * unreachable here, ADR 0006). Return one of `ctx.ignore()`, `ctx.bone()`,
84
- * `ctx.walk()`, or the `next()` result — the `WalkerResult` type makes a
85
- * hand-built `PlateNode` a compile error.
86
- */
87
- element?: (ctx: CaptureWalkerContext, next: () => WalkerResult) => WalkerResult;
88
- /** RESERVED for a future version; not honored in v1. */
89
- text?: never;
90
- /** RESERVED for a future version; not honored in v1. */
91
- declarations?: never;
92
- /** RESERVED for a future version; not honored in v1. */
93
- media?: never;
94
- /** RESERVED for a future version; not honored in v1. */
95
- list?: never;
96
- }
97
- /**
98
- * Typed identity wrapper for authoring a capture walker (ADR 0018) — the
99
- * `defineConfig` pattern. It returns its argument unchanged at runtime; its only
100
- * job is to infer and check the `XrayCaptureWalker` shape at the call site so an
101
- * author gets completion and a typo in a hook name is caught.
102
- */
103
- declare function defineXrayCaptureWalker(walker: XrayCaptureWalker): XrayCaptureWalker;
104
- /**
105
- * Capture the rendered subtree(s) under a Skeleton into a Plate. `roots` are
106
- * the component's top-level elements (the children of the layout-neutral
107
- * wrapper); the synthetic root node (id 0) stands in for the wrapper itself.
108
- */
109
- declare function capture(roots: readonly Element[], options: CaptureOptions): MergedPlate;
110
- /**
111
- * Thrown when a subtree has more nodes than the capture limit — almost always
112
- * a `<Skeleton>` sitting too high in the tree. Raised after the cheap walk and
113
- * before the O(rules × nodes) CSS extraction, so an oversized capture is
114
- * refused without freezing the main thread on it.
115
- */
116
- declare class CaptureTooLargeError extends Error {
117
- readonly nodeCount: number;
118
- /** Folds the oversized-capture warning into the shared diagnostics vocabulary (diagnostics.ts). */
119
- readonly code: "too-large";
120
- constructor(nodeCount: number);
121
- }
122
- interface CaptureRegimeOptions {
123
- /** Refuse (throw `CaptureTooLargeError`) before CSS extraction if the walk exceeds this. */
124
- maxNodes?: number;
125
- /** Optional programmable capture walker (ADR 0018); capture-only, never persisted. */
126
- walker?: XrayCaptureWalker;
127
- /**
128
- * Whether the top-level roots ARE this plate's own boundary, so the stitch
129
- * guard is skipped for them (ADR 0006/0014, finding #6). True ONLY for a
130
- * MANUAL root; defaults to `false`, the auto path where a boundary marker on a
131
- * direct-child root is a NESTED `<Skeleton>` that MUST stitch. See `walkAll`.
132
- */
133
- captureRootIsBoundary?: boolean;
134
- }
135
- /**
136
- * Capture one view's worth of a component: the tree plus id-form rules,
137
- * with the viewport width it was taken at. The caller (the dev client)
138
- * derives the view interval and ships it off; `capture` is the
139
- * single-view convenience on top.
140
- */
141
- declare function captureRegime(roots: readonly Element[], options?: CaptureRegimeOptions): ViewCapture;
142
- //#endregion
143
- export { WalkerResult as a, captureRegime as c, CaptureWalkerContext as i, defineXrayCaptureWalker as l, CaptureRegimeOptions as n, XrayCaptureWalker as o, CaptureTooLargeError as r, capture as s, CaptureOptions as t };