Skip to content

Commit c1e50ae

Browse files
committed
style: collapse multi-line comments to single lines
1 parent 69f3d45 commit c1e50ae

6 files changed

Lines changed: 30 additions & 114 deletions

File tree

packages/cli/src/commands/layout-audit.browser.js

Lines changed: 8 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,10 +1233,7 @@
12331233
const mapped = point.matrixTransform(matrix);
12341234
return { x: mapped.x, y: mapped.y };
12351235
};
1236-
// getPointAtLength can still throw on a degenerate/malformed path even after
1237-
// getTotalLength succeeded. This sampler runs once PER seeked frame, so one
1238-
// bad path must degrade to "no endpoints" (skip this path), not abort the
1239-
// whole check for every remaining path and frame.
1236+
// getPointAtLength can throw on a degenerate path even after getTotalLength; skip that path instead of aborting the whole per-frame check.
12401237
try {
12411238
return {
12421239
start: toScreen(path.getPointAtLength(0)),
@@ -1743,34 +1740,20 @@
17431740
return samples;
17441741
};
17451742

1746-
// connector_motion_detached sampling. Per seeked frame, report every diagram
1747-
// connector's two screen-space endpoints AND every plausible node/box bbox.
1748-
// Node accumulates these across the grid and flags an endpoint that stays
1749-
// anchored to a node while the other endpoint sits in empty space on the held
1750-
// frames — a connector whose coordinates were frozen (wrong rotation pivot, or
1751-
// measured once at build) while its target kept moving. Icon-sized SVGs and
1752-
// short strokes are filtered out so only real diagram connectors count.
1743+
// connector_motion_detached sampling: per frame, report each connector's screen endpoints and every node bbox; icon-sized SVGs and short strokes are filtered out.
17531744
const CONNECTOR_MIN_SVG_PX = 100;
17541745
const CONNECTOR_MIN_LEN_PX = 60;
1755-
// Gauge needles/pointers/ticks are one-end-anchored indicators, not node-to-node
1756-
// connectors — a separate (gauge) check owns them. Skip by id/class of the line
1757-
// or any group ancestor up to the SVG.
1746+
// Gauge needles/pointers/ticks are one-end-anchored indicators owned by a separate check; skip by id/class of the line or any group ancestor.
17581747
const CONNECTOR_INDICATOR_NAME = /needle|pointer|gauge|tick|indicator/i;
17591748
const CONNECTOR_NODE_MIN_AREA = 400;
17601749
// SVG dots/markers are small; keep the floor low but above sub-pixel decoration.
17611750
const CONNECTOR_NODE_MIN_DOT_AREA = 16;
17621751
const CONNECTOR_NODE_CAP = 300;
1763-
// A stroke-drawn dial/hub ring may be an <path> arc (M...A...), not a <circle>.
1764-
// Recognize near-circular stroke paths as ring nodes so connectors attaching
1765-
// to them aren't false-flagged as detached, and so the gauge-indicator geometry
1766-
// exclusion (which keys on ring nodes) can see arc-drawn dials too.
1752+
// Recognize near-circular stroke <path> arcs as ring nodes so connectors attaching to them aren't false-flagged and the gauge exclusion sees arc-drawn dials.
17671753
const CONNECTOR_RING_MIN_LEN = 120;
17681754
const CONNECTOR_RING_MIN_RADIUS = 20;
17691755
const CONNECTOR_RING_MAX_RESIDUAL_FRAC = 0.15;
1770-
// Phantom-radius guard: a real ring/hub's fitted diameter tracks its bounding
1771-
// box (full circle 1x, quarter arc ~2x). A shallow-curvature arc fits an
1772-
// enormous circle with a tiny normalized residual, so the diameter runs many×
1773-
// the box — reject beyond this factor.
1756+
// Phantom-radius guard: a shallow arc fits an enormous circle with a tiny residual, so reject when the fitted diameter runs past this factor of the bbox.
17741757
const CONNECTOR_RING_MAX_DIAMETER_BBOX_FRAC = 3;
17751758

17761759
function isIndicatorConnector(line, svg) {
@@ -1799,13 +1782,7 @@
17991782
};
18001783
}
18011784

1802-
// Node/box candidates a connector could anchor to: sized, opaque or text-
1803-
// bearing HTML elements plus SVG hub/ring/dot shapes. A shape drawn stroke-only
1804-
// (fill:none) is a ring — the connector attaches to its stroke, so it is marked
1805-
// `ring` and matched by perimeter, not hollow interior (see pointToNodeGap).
1806-
// A near-circular stroke <path> read as a ring/hub node. Returns a node box
1807-
// (ring flag from fill) or null when the path is not a resolvable circular hub.
1808-
// getPointAtLength is guarded — one malformed path must not abort the sampler.
1785+
// Read a near-circular stroke <path> as a ring/hub node box (ring flag from fill), or null if not a resolvable hub; getPointAtLength is guarded so one bad path can't abort the sampler.
18091786
function ringPathBox(path, rootRect) {
18101787
if (typeof path.getTotalLength !== "function" || typeof path.getPointAtLength !== "function") {
18111788
return null;
@@ -1830,18 +1807,12 @@
18301807
if (!fit || fit.radius < CONNECTOR_RING_MIN_RADIUS) return null;
18311808
if (fit.residual > CONNECTOR_RING_MAX_RESIDUAL_FRAC * fit.radius) return null;
18321809
const rect = toRect(path.getBoundingClientRect());
1833-
// Reject the shallow-curvature phantom fit: normalized residual is small at
1834-
// any radius, so a nearly-straight arc masquerades as a huge ring. The
1835-
// fitted diameter must stay within a sane factor of the drawn bounding box.
1810+
// Reject the shallow-curvature phantom fit: a nearly-straight arc masquerades as a huge ring, so the fitted diameter must stay within a sane factor of the bbox.
18361811
const bboxSpan = Math.max(rect.width, rect.height);
18371812
if (bboxSpan <= 0 || fit.radius * 2 > CONNECTOR_RING_MAX_DIAMETER_BBOX_FRAC * bboxSpan) {
18381813
return null;
18391814
}
1840-
// Scoped-known seams (left as-is — narrow and not phantom-radius): a short
1841-
// genuine partial arc under-samples its parent circle's box so a real hub
1842-
// drawn as a sliver can still miss the span gate; and a curved connector
1843-
// that is itself near-circular can be read as its own ring node. Both are
1844-
// rare vs. the shallow-curvature false ring this gate closes.
1815+
// Known narrow seams left as-is: a sliver partial arc can miss the span gate, and a near-circular connector can read as its own ring node — both rare vs. the false ring this gate closes.
18451816
const area = rectArea(rect);
18461817
if (area < CONNECTOR_NODE_MIN_DOT_AREA || area >= rectArea(rootRect) * 0.5) return null;
18471818
const fill = getComputedStyle(path).fill;

packages/cli/src/commands/layout-audit.browser.test.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -887,9 +887,7 @@ describe("layout-audit.browser coordinate-frame findings", () => {
887887
</svg>
888888
</div>
889889
`;
890-
// A near-full circle (diameter tracks its bbox) vs a shallow arc on a huge
891-
// circle: the arc's Kåsa residual normalized by its enormous radius is tiny
892-
// (passes the residual gate) yet its fitted diameter is ~10x its drawn box.
890+
// Shallow arc on a huge circle passes the residual gate yet its fitted diameter is ~10x its drawn box — the phantom-radius case, vs a genuine near-full circle.
893891
const genuine = { cx: 500, cy: 500, radius: 100, startDeg: 0, endDeg: 360 };
894892
const shallow = { cx: 500, cy: 2500, radius: 2000, startDeg: 264, endDeg: 276 };
895893
installGeometry(
@@ -2053,8 +2051,7 @@ function arcBBox(spec: ArcSpec): DOMRect {
20532051
return rect({ left, top, width: Math.max(...xs) - left, height: Math.max(...ys) - top });
20542052
}
20552053

2056-
// happy-dom has no SVG path geometry: mock getTotalLength/getPointAtLength so
2057-
// ringPathBox samples the given circular arc in local user units.
2054+
// happy-dom has no SVG path geometry: mock getTotalLength/getPointAtLength so ringPathBox can sample the given arc.
20582055
function installArcSampling(pathId: string, spec: ArcSpec): void {
20592056
const path = document.getElementById(pathId);
20602057
if (!path) throw new Error(`no path #${pathId}`);

packages/cli/src/utils/checkPipeline.connectorMotionDetached.test.ts

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ function frame(
3030
return { time, connectors: [connector], nodes };
3131
}
3232

33-
/** A dangling connector: end A stays on the hub, end B sits ~180px from every
34-
* node across all held frames — the half-attached signature (fuzz011). */
33+
/** A dangling connector: end A stays on the hub, end B sits ~180px from every node across held frames — the half-attached signature (fuzz011). */
3534
function danglingFrames(): ConnectorFrame[] {
3635
return [0, 2, 4, 6, 8].map((time) =>
3736
frame(time, { selector: "#spoke", ax: 500, ay: 500, bx: 640, by: 500 }, [HUB, SATELLITE]),
@@ -88,10 +87,7 @@ describe("detectConnectorMotionDetached", () => {
8887
});
8988

9089
it("flags a loose end that only touches a node in ONE held frame then detaches the rest", () => {
91-
// End A stays pinned to the hub; end B lands on the satellite for a single
92-
// held frame (t=4) then dangles ~120px away for the rest of the held window.
93-
// A lone graze is NOT sustained attachment, so B must read as dangling and
94-
// the connector must be flagged — not cleared by the single touch.
90+
// A lone graze (B touches the satellite once at t=4, dangles the rest) is not sustained attachment, so B must still read as dangling and the connector be flagged.
9591
const held: ConnectorFrame[] = [0, 2, 4, 5, 6, 7, 8].map((time) => {
9692
const bx = time === 4 ? 820 : 640; // on satellite once, dangling otherwise
9793
return frame(time, { selector: "#spoke", ax: 500, ay: 500, bx, by: 500 }, [HUB, SATELLITE]);
@@ -102,9 +98,7 @@ describe("detectConnectorMotionDetached", () => {
10298
});
10399

104100
it("keeps an endpoint anchored when it stays within tolerance across the held window", () => {
105-
// The mirror case: B sits on the satellite for every held frame but one — a
106-
// single-frame graze OFF a node does not turn a sustained anchor into a
107-
// dangle, so nothing fires.
101+
// Mirror case: a single-frame graze OFF a node doesn't turn a sustained anchor into a dangle, so nothing fires.
108102
const held: ConnectorFrame[] = [0, 2, 4, 5, 6, 7, 8].map((time) => {
109103
const bx = time === 6 ? 640 : 820; // off-node once, on the satellite otherwise
110104
return frame(time, { selector: "#spoke", ax: 500, ay: 500, bx, by: 500 }, [HUB, SATELLITE]);
@@ -131,8 +125,7 @@ describe("detectConnectorMotionDetached", () => {
131125
});
132126

133127
it("does not fire on a gauge needle: anchored at the arc centre, loose end radially outward", () => {
134-
// Arc ring centred at 900,500; needle base on the hub near centre, tip out
135-
// past the arc — a pointer, not a broken connector.
128+
// Arc ring at 900,500 with the needle base near centre and tip past the arc — a pointer, not a broken connector.
136129
const hub: ConnectorNodeBox = {
137130
selector: "#hub",
138131
left: 890,
@@ -156,8 +149,7 @@ describe("detectConnectorMotionDetached", () => {
156149
});
157150

158151
it("still fires on a radial connector drifting toward the centre (not outward)", () => {
159-
// Anchored on a peripheral node; loose end drifts inward to empty space near
160-
// a ring centre — the fuzz011 shape, opposite of a gauge pointer.
152+
// Anchored on a peripheral node with the loose end drifting inward to empty space near a ring centre — the fuzz011 shape, opposite of a gauge pointer.
161153
const peripheral: ConnectorNodeBox = {
162154
selector: "#panel",
163155
left: 120,

packages/cli/src/utils/checkPipeline.ts

Lines changed: 11 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,7 @@ interface GridSamples {
201201
* material-point geometry + dial hub per layout sample; flattened by selector
202202
* to detect off_pivot_rotation. */
203203
indicatorFrames: OffPivotFrame[];
204-
/** Connector endpoints + node boxes at each layout sample; correlated after
205-
* the run to detect connector_motion_detached. */
204+
/** Connector endpoints + node boxes per layout sample; correlated after the run to detect connector_motion_detached. */
206205
connectorFrames: ConnectorFrame[];
207206
}
208207

@@ -985,27 +984,19 @@ export function detectOffPivotRotation(frames: OffPivotFrame[]): AnchoredLayoutI
985984
return selectHubFindings(candidates);
986985
}
987986

988-
// connector_motion_detached thresholds. Corpus timings: entrances settle by
989-
// ~2s of a 7-8s composition, so held/steady state starts well before half.
987+
// connector_motion_detached thresholds.
990988
const CONNECTOR_MIN_FRAMES = 4;
991989
// An endpoint within this of a node counts as anchored (well under a node's size).
992990
const CONNECTOR_ATTACH_PX = 24;
993-
// The dangling end must clear this to flag. Set high, and measured against a
994-
// dense node-candidate set, so only an endpoint sitting in genuinely empty space
995-
// fires — a slow drift that still lands near a box, or a snug residual gap, does
996-
// not. Corpus: fuzz011's detached spokes dangle ~185-190px from every node;
997-
// legitimate lead-lines to a nearby label stay well under this.
991+
// Detach floor: set high and measured against a dense node set, so only an endpoint in genuinely empty space fires (not a snug gap or lead-line).
998992
const CONNECTOR_DETACH_FLOOR_PX = 80;
999993
const CONNECTOR_DETACH_VIEWPORT_FRACTION = 0.06;
1000994
// Held/steady frames begin at this fraction of the timeline (past entrances).
1001995
const CONNECTOR_HELD_START_FRAC = 0.45;
1002996
const CONNECTOR_MIN_HELD_FRAMES = 2;
1003997
// Fraction of held frames on which the loose end must be detached to flag.
1004998
const CONNECTOR_HELD_DETACH_FRAC = 0.8;
1005-
// Fraction of held frames an endpoint must stay within attach tolerance to
1006-
// count as ANCHORED. A single-frame graze is not attachment: a genuinely
1007-
// detached endpoint that merely touches a node once must not read as anchored
1008-
// (else its dangling partner escapes the finding). Sustained, not instantaneous.
999+
// Fraction of held frames within attach tolerance to count as anchored — sustained, so a single-frame graze doesn't let a dangling partner escape.
10091000
const CONNECTOR_HELD_ATTACH_FRAC = 0.8;
10101001

10111002
interface ConnectorObservation {
@@ -1021,8 +1012,7 @@ function pointToNodeGap(x: number, y: number, node: ConnectorNodeBox): number {
10211012
const dx = Math.max(node.left - x, 0, x - node.right);
10221013
const dy = Math.max(node.top - y, 0, y - node.bottom);
10231014
if (dx > 0 || dy > 0) return Math.hypot(dx, dy);
1024-
// Inside the bbox: a solid node anchors anywhere; a hollow ring only near its
1025-
// stroke, so measure distance to the bbox perimeter (its hole is not attached).
1015+
// Inside the bbox: a solid node anchors anywhere; a hollow ring only near its stroke, so measure distance to the perimeter.
10261016
if (!node.ring) return 0;
10271017
return Math.min(x - node.left, node.right - x, y - node.top, node.bottom - y);
10281018
}
@@ -1033,9 +1023,7 @@ function nearestNodeGap(x: number, y: number, nodes: ConnectorNodeBox[]): number
10331023
return min;
10341024
}
10351025

1036-
/** Group observations by connector selector, dropping any selector that maps to
1037-
* more than one connector in a single frame — those endpoints can't be tracked
1038-
* across seeks without aliasing (the false-association risk). */
1026+
/** Group observations by connector selector, dropping any selector that aliases multiple connectors in one frame (untrackable across seeks). */
10391027
function groupConnectorsBySelector(frames: ConnectorFrame[]): Map<string, ConnectorObservation[]> {
10401028
const bySelector = new Map<string, ConnectorObservation[]>();
10411029
const ambiguous = new Set<string>();
@@ -1067,10 +1055,7 @@ interface EndpointHeldGaps {
10671055
danglingGap: number;
10681056
}
10691057

1070-
/** Per-endpoint held-frame gap summary: the fraction of held frames it sits
1071-
* within attach tolerance of a node (sustained attachment, not a lone graze),
1072-
* the fraction it sits beyond the detach threshold, and the gap it settles at
1073-
* when detached. */
1058+
/** Per-endpoint held-frame gap summary: fractions within attach tolerance and beyond the detach threshold, plus the settled dangling gap. */
10741059
function endpointHeldGaps(
10751060
group: ConnectorObservation[],
10761061
pick: (o: ConnectorObservation) => { x: number; y: number },
@@ -1101,11 +1086,7 @@ function isDangling(gaps: EndpointHeldGaps): boolean {
11011086
return gaps.detachedFraction >= CONNECTOR_HELD_DETACH_FRAC;
11021087
}
11031088

1104-
// Gauge-indicator geometry: the anchored end pivots near a ring/arc centre and
1105-
// the loose end extends radially outward. That is a needle/pointer (owned by a
1106-
// separate gauge check), not a broken node connector. A defective radial
1107-
// connector points the other way — anchored on a peripheral node, loose end
1108-
// drifting toward the centre — so this only excludes true centre-pivot pointers.
1089+
// Gauge indicator: anchored end pivots near a ring centre, loose end extends outward — a needle (owned by a separate gauge check), so exclude only true centre-pivot pointers.
11091090
const GAUGE_HUB_CENTRE_FRACTION = 0.25;
11101091

11111092
function isGaugeIndicator(
@@ -1154,32 +1135,14 @@ function connectorDetachFinding(
11541135
};
11551136
}
11561137

1157-
/**
1158-
* connector_motion_detached: a connector (SVG <line>/<path>) that stays anchored
1159-
* to a node at ONE endpoint while its OTHER endpoint sits in empty space — far
1160-
* from every node — across the held (steady) frames. This is the sibling of the
1161-
* per-frame `connector_detached` check, which requires BOTH endpoints far from
1162-
* anchors on a single frame and so deliberately ignores the half-attached case.
1163-
* But that half-attached case is the dominant real failure under motion: a
1164-
* spoke/edge whose one end stays pinned (e.g. at a hub) while the other drifts
1165-
* off a node that kept moving — rotated about a wrong pivot, or with a path
1166-
* measured once at build then never updated as the target animated.
1167-
*
1168-
* FP-guarded, deliberately strict: one endpoint must be genuinely anchored
1169-
* (structural, not a name match); the loose end must clear a high detach
1170-
* threshold on ~all held frames (measured against a dense node-candidate set, so
1171-
* only an endpoint in truly empty space fires — snug residual gaps and lead
1172-
* lines to a nearby label do not); and a selector that aliases multiple
1173-
* connectors in one frame is dropped.
1174-
*/
1138+
/** connector_motion_detached: the half-attached case connector_detached ignores — one endpoint pinned while the other drifts into empty space across held frames (wrong pivot, or coords measured once at build). Strict + FP-guarded. */
11751139
interface DanglePick {
11761140
anchored: { x: number; y: number };
11771141
dangling: { x: number; y: number };
11781142
gap: number;
11791143
}
11801144

1181-
/** If exactly one endpoint is anchored and the other persistently dangles, name
1182-
* the anchored/dangling points and the dangling gap; else null. */
1145+
/** If exactly one endpoint is anchored and the other persistently dangles, name the anchored/dangling points and the gap; else null. */
11831146
function danglingEndpoint(
11841147
last: ConnectorObservation,
11851148
gapsA: EndpointHeldGaps,
@@ -1196,9 +1159,7 @@ function danglingEndpoint(
11961159
return null;
11971160
}
11981161

1199-
/** One connector's held trajectory → a finding, or null. A finding needs one
1200-
* endpoint anchored to a node and the other persistently in empty space, and is
1201-
* suppressed for gauge-indicator geometry (see isGaugeIndicator). */
1162+
/** One connector's held trajectory → a finding, or null; needs one anchored endpoint and one persistently in empty space, suppressed for gauge-indicator geometry. */
12021163
function connectorGroupFinding(
12031164
selector: string,
12041165
group: ConnectorObservation[],

packages/cli/src/utils/checkTypes.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,7 @@ export interface ConnectorLineSample {
170170
by: number;
171171
}
172172

173-
/** Screen bbox of one plausible node/box a connector could anchor to. `ring`
174-
* marks a stroke-only SVG shape matched by perimeter, not hollow interior. */
173+
/** Screen bbox of a node a connector could anchor to; `ring` marks a stroke-only SVG shape matched by perimeter, not hollow interior. */
175174
export interface ConnectorNodeBox {
176175
selector: string;
177176
left: number;
@@ -181,9 +180,7 @@ export interface ConnectorNodeBox {
181180
ring: boolean;
182181
}
183182

184-
/** All connectors + node boxes at one seeked sample, produced by
185-
* `__hyperframesConnectorSample` and accumulated across the grid to detect
186-
* `connector_motion_detached`. */
183+
/** All connectors + node boxes at one seeked sample, accumulated across the grid to detect connector_motion_detached. */
187184
export interface ConnectorFrame {
188185
time: number;
189186
connectors: ConnectorLineSample[];
@@ -218,8 +215,7 @@ export interface CheckAuditDriver {
218215
* geometry + resolved dial hub at the current seeked state, as a time-hoisted
219216
* frame envelope. */
220217
collectOffPivotRotationSample(time: number): Promise<OffPivotFrame>;
221-
/** connector_motion_detached: every connector's endpoints + every node bbox
222-
* at the current seeked state. Accumulated across the grid — see checkPipeline. */
218+
/** connector_motion_detached: every connector's endpoints + every node bbox at the current seeked state, accumulated across the grid. */
223219
collectConnectorSample(time: number): Promise<ConnectorFrame>;
224220
collectGeometryCandidates(
225221
time: number,

0 commit comments

Comments
 (0)