@dloizides/game-e2e 0.0.0-stage → 1.0.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/index.js ADDED
@@ -0,0 +1,518 @@
1
+ 'use strict';
2
+
3
+ var test = require('@playwright/test');
4
+
5
+ // src/boxes.ts
6
+ var CONTROL_TEXT_CHARS = 12;
7
+ var OPEN_BAND = [-Infinity, Infinity];
8
+ function overlaps(a, b) {
9
+ return a.left < b.right && b.left < a.right && a.top < b.bottom && b.top < a.bottom;
10
+ }
11
+ function findOverlaps(a, b) {
12
+ const hits = [];
13
+ for (const x of a) {
14
+ for (const y of b) {
15
+ if (x !== y && overlaps(x, y)) {
16
+ hits.push([x, y]);
17
+ }
18
+ }
19
+ }
20
+ return hits;
21
+ }
22
+ function findOverlapsWithin(boxes) {
23
+ const hits = [];
24
+ boxes.forEach((x, i) => {
25
+ for (const y of boxes.slice(i + 1)) {
26
+ if (overlaps(x, y)) {
27
+ hits.push([x, y]);
28
+ }
29
+ }
30
+ });
31
+ return hits;
32
+ }
33
+ function canvasBoxToPage(frame, bounds, name, band = OPEN_BAND) {
34
+ const scale = frame.width / frame.logicalWidth;
35
+ const top = Math.max(bounds.y, band[0]);
36
+ const bottom = Math.min(bounds.y + bounds.height, band[1]);
37
+ if (bottom <= top) {
38
+ return null;
39
+ }
40
+ return {
41
+ name,
42
+ left: frame.left + bounds.x * scale,
43
+ top: frame.top + top * scale,
44
+ right: frame.left + (bounds.x + bounds.width) * scale,
45
+ bottom: frame.top + bottom * scale
46
+ };
47
+ }
48
+ function controlName(c) {
49
+ const firstClass = c.className.trim().split(/\s+/)[0] ?? "";
50
+ const id = c.id !== "" ? `#${c.id}` : `.${firstClass}`;
51
+ return `${c.tag.toLowerCase()}${id}:${c.text.trim().slice(0, CONTROL_TEXT_CHARS)}`;
52
+ }
53
+ var PHONE_DEVICE = "Galaxy S5";
54
+ var DESKTOP_DEVICE = "Desktop Chrome";
55
+ var PHONE_SIZE = { width: 360, height: 640 };
56
+ var DESKTOP_SIZE = { width: 1280, height: 720 };
57
+ function deviceDescriptor(name) {
58
+ const found = test.devices[name];
59
+ if (found === void 0) {
60
+ throw new Error(`Playwright has no device descriptor named "${name}"`);
61
+ }
62
+ const { defaultBrowserType: _browser, ...rest } = found;
63
+ return rest;
64
+ }
65
+ function phone(width = PHONE_SIZE.width, height = PHONE_SIZE.height, deviceScaleFactor) {
66
+ const base = deviceDescriptor(PHONE_DEVICE);
67
+ return { ...base, viewport: { width, height }, screen: { width, height }, deviceScaleFactor: deviceScaleFactor ?? base.deviceScaleFactor };
68
+ }
69
+ function desktop(width = DESKTOP_SIZE.width, height = DESKTOP_SIZE.height, deviceScaleFactor = 1) {
70
+ const base = deviceDescriptor(DESKTOP_DEVICE);
71
+ return { ...base, viewport: { width, height }, screen: { width, height }, deviceScaleFactor };
72
+ }
73
+ function gameProjects(options = {}) {
74
+ const p = options.phone ?? PHONE_SIZE;
75
+ const d = options.desktop ?? DESKTOP_SIZE;
76
+ return [
77
+ { name: options.phoneName ?? "phone", use: phone(p.width, p.height) },
78
+ { name: options.desktopName ?? "desktop", use: desktop(d.width, d.height) }
79
+ ];
80
+ }
81
+ var RELAYOUT_TIMEOUT_MS = 15e3;
82
+ async function armVisibleHeight(page) {
83
+ await page.addInitScript(() => {
84
+ if (!window.visualViewport) {
85
+ return;
86
+ }
87
+ const proto = Object.getPrototypeOf(window.visualViewport);
88
+ Object.defineProperty(proto, "height", {
89
+ configurable: true,
90
+ get: () => window.__gfVisibleHeight ?? window.innerHeight
91
+ });
92
+ });
93
+ }
94
+ async function shrinkVisibleHeight(page, height, options = {}) {
95
+ const key = options.relayoutGlobal ?? null;
96
+ const found = await page.evaluate(({ h, gameKey }) => {
97
+ const w = window;
98
+ let present = true;
99
+ if (gameKey !== null) {
100
+ const game = w[gameKey];
101
+ present = game !== void 0;
102
+ const relaid = {};
103
+ w.__gfRelaid = relaid;
104
+ for (const s of game?.scene.getScenes(true) ?? []) {
105
+ const sceneKey = s.sys.settings.key;
106
+ relaid[sceneKey] = false;
107
+ s.events.once("create", () => {
108
+ relaid[sceneKey] = true;
109
+ });
110
+ }
111
+ }
112
+ w.__gfVisibleHeight = h;
113
+ window.visualViewport?.dispatchEvent(new Event("resize"));
114
+ return present;
115
+ }, { h: height, gameKey: key });
116
+ if (key === null) {
117
+ return;
118
+ }
119
+ if (!found) {
120
+ throw new Error(`shrinkVisibleHeight: window.${key} is not defined, so no scene re-layout can be awaited`);
121
+ }
122
+ await test.expect.poll(() => page.evaluate(() => {
123
+ const relaid = window.__gfRelaid ?? {};
124
+ return Object.keys(relaid).filter((k) => !relaid[k]);
125
+ }), { message: "scenes still showing the layout of the old height", timeout: options.timeout ?? RELAYOUT_TIMEOUT_MS }).toEqual([]);
126
+ }
127
+ var GAME_SHELL_HEIGHT_VAR = "--gs-vh";
128
+ var DEFAULT_CANVAS_SELECTOR = "canvas";
129
+ var FIT_TIMEOUT_MS = 1e4;
130
+ var CANVAS_TIMEOUT_MS = 15e3;
131
+ var MISSING_BOTTOM = 1e9;
132
+ async function expectFitTo(page, height, options = {}) {
133
+ const cssVar = options.cssVar ?? GAME_SHELL_HEIGHT_VAR;
134
+ await test.expect.poll(
135
+ () => page.evaluate((v) => getComputedStyle(document.documentElement).getPropertyValue(v).trim(), cssVar),
136
+ { message: `${cssVar} never became ${String(height)}px (game-shell fit not running)`, timeout: options.timeout ?? FIT_TIMEOUT_MS }
137
+ ).toBe(`${String(height)}px`);
138
+ }
139
+ async function expectCanvasHeight(page, height, options = {}) {
140
+ const selector = options.canvasSelector ?? DEFAULT_CANVAS_SELECTOR;
141
+ await test.expect.poll(
142
+ () => page.evaluate((s) => Math.round(document.querySelector(s)?.getBoundingClientRect().height ?? -1), selector),
143
+ { message: `canvas ${selector} never re-fit to the ${String(height)}px visible height`, timeout: options.timeout ?? CANVAS_TIMEOUT_MS }
144
+ ).toBe(height);
145
+ }
146
+ async function expectCanvasInside(page, height, options = {}) {
147
+ const selector = options.canvasSelector ?? DEFAULT_CANVAS_SELECTOR;
148
+ await test.expect.poll(
149
+ () => page.evaluate(({ s, missing }) => Math.round(document.querySelector(s)?.getBoundingClientRect().bottom ?? missing), { s: selector, missing: MISSING_BOTTOM }),
150
+ { message: `canvas ${selector} never re-fit inside the ${String(height)}px visible height`, timeout: options.timeout ?? CANVAS_TIMEOUT_MS }
151
+ ).toBeLessThanOrEqual(height);
152
+ }
153
+
154
+ // src/dom-controls.ts
155
+ var CONTROL_SELECTOR = 'button, a[href], [role="button"]';
156
+ async function domControls(page, selector = CONTROL_SELECTOR) {
157
+ const records = await page.evaluate((sel) => Array.from(document.querySelectorAll(sel)).filter((el) => {
158
+ const s = getComputedStyle(el);
159
+ const b = el.getBoundingClientRect();
160
+ return s.display !== "none" && s.visibility !== "hidden" && b.width > 0 && b.height > 0;
161
+ }).map((el) => {
162
+ const b = el.getBoundingClientRect();
163
+ return { tag: el.tagName, id: el.id, className: el.getAttribute("class") ?? "", text: el.textContent ?? "", left: b.left, top: b.top, right: b.right, bottom: b.bottom };
164
+ }), selector);
165
+ return records.map((r) => ({ name: controlName(r), left: r.left, top: r.top, right: r.right, bottom: r.bottom }));
166
+ }
167
+
168
+ // src/pixel-diff-math.ts
169
+ var EXACT = 0;
170
+ var ANTI_ALIAS_TOLERANCE = 48;
171
+ var CHANNELS = 4;
172
+ function at(data, i) {
173
+ return data[i] ?? 0;
174
+ }
175
+ function channelDelta(a, b, i) {
176
+ return Math.max(Math.abs(at(a, i) - at(b, i)), Math.abs(at(a, i + 1) - at(b, i + 1)), Math.abs(at(a, i + 2) - at(b, i + 2)));
177
+ }
178
+ function countDiff(a, b, width, tolerance = EXACT) {
179
+ if (a.length !== b.length) {
180
+ throw new Error(`pixel buffers differ in length: ${String(a.length)} vs ${String(b.length)}`);
181
+ }
182
+ if (width <= 0 || a.length % (width * CHANNELS) !== 0) {
183
+ throw new Error(`pixel buffer of ${String(a.length)} bytes is not whole RGBA rows of width ${String(width)}`);
184
+ }
185
+ const total = a.length / CHANNELS;
186
+ let differing = 0;
187
+ let x0 = width;
188
+ let y0 = total / width;
189
+ let x1 = -1;
190
+ let y1 = -1;
191
+ for (let i = 0; i < a.length; i += CHANNELS) {
192
+ if (channelDelta(a, b, i) <= tolerance) {
193
+ continue;
194
+ }
195
+ differing += 1;
196
+ const p = i / CHANNELS;
197
+ const px = p % width;
198
+ const py = Math.floor(p / width);
199
+ x0 = Math.min(x0, px);
200
+ y0 = Math.min(y0, py);
201
+ x1 = Math.max(x1, px);
202
+ y1 = Math.max(y1, py);
203
+ }
204
+ const bbox = differing > 0 ? `${String(x0)},${String(y0)}-${String(x1)},${String(y1)}` : "none";
205
+ return { differing, total, ratio: total === 0 ? 0 : differing / total, bbox };
206
+ }
207
+
208
+ // src/pixel-diff.ts
209
+ async function diffPngs(factory, a, b, options = {}) {
210
+ const scratch = await factory.newPage();
211
+ try {
212
+ const decoded = await scratch.evaluate(async ({ pa, pb, ra, rb, w, h }) => {
213
+ const load = (src) => new Promise((resolve, reject) => {
214
+ const img = new Image();
215
+ img.onload = () => resolve(img);
216
+ img.onerror = () => reject(new Error("image did not decode"));
217
+ img.src = `data:image/png;base64,${src}`;
218
+ });
219
+ const [ia, ib] = await Promise.all([load(pa), load(pb)]);
220
+ const unscaled = w === null && h === null && ra === null && rb === null;
221
+ if (unscaled && (ia.naturalWidth !== ib.naturalWidth || ia.naturalHeight !== ib.naturalHeight)) {
222
+ throw new Error(`image sizes differ: ${String(ia.naturalWidth)}x${String(ia.naturalHeight)} vs ${String(ib.naturalWidth)}x${String(ib.naturalHeight)}`);
223
+ }
224
+ const width = Math.max(1, Math.round(w ?? ra?.w ?? ia.naturalWidth));
225
+ const height = Math.max(1, Math.round(h ?? ra?.h ?? ia.naturalHeight));
226
+ const chunk = 32768;
227
+ const toBase64 = (img, r) => {
228
+ const c = document.createElement("canvas");
229
+ c.width = width;
230
+ c.height = height;
231
+ const g = c.getContext("2d");
232
+ if (!g) {
233
+ throw new Error("no 2d context");
234
+ }
235
+ if (r) {
236
+ g.drawImage(img, r.x, r.y, r.w, r.h, 0, 0, width, height);
237
+ } else {
238
+ g.drawImage(img, 0, 0, width, height);
239
+ }
240
+ const data = g.getImageData(0, 0, width, height).data;
241
+ let s = "";
242
+ for (let i = 0; i < data.length; i += chunk) {
243
+ s += String.fromCharCode(...data.subarray(i, i + chunk));
244
+ }
245
+ return btoa(s);
246
+ };
247
+ return { width, a: toBase64(ia, ra), b: toBase64(ib, rb) };
248
+ }, {
249
+ pa: a.toString("base64"),
250
+ pb: b.toString("base64"),
251
+ ra: options.regionA ?? null,
252
+ rb: options.regionB ?? null,
253
+ w: options.width ?? null,
254
+ h: options.height ?? null
255
+ });
256
+ return countDiff(Buffer.from(decoded.a, "base64"), Buffer.from(decoded.b, "base64"), decoded.width, options.tolerance ?? EXACT);
257
+ } finally {
258
+ await scratch.close();
259
+ }
260
+ }
261
+ async function regionDiff(factory, a, b, options = {}) {
262
+ return diffPngs(factory, a.png, b.png, { ...options, regionA: a.region, regionB: b.region });
263
+ }
264
+
265
+ // src/touch-report.ts
266
+ var MIN_TARGET_PX = 44;
267
+ var MAX_REPORTED = 12;
268
+ function renderFindings(findings, alsoIn, alsoLabel) {
269
+ if (findings.length === 0) {
270
+ return "none";
271
+ }
272
+ const shown = findings.slice(0, MAX_REPORTED).map((f) => `${f.selector} ${String(f.width)}x${String(f.height)} via=${f.reason} name="${f.name}"` + (alsoIn.has(f.idx) ? ` [ALSO ${alsoLabel}]` : ""));
273
+ const rest = findings.length - shown.length;
274
+ return shown.join("; ") + (rest > 0 ? ` (+${String(rest)} more)` : "");
275
+ }
276
+ function renderRouteAudit({ route, audit }, minPx) {
277
+ if (audit.total === 0) {
278
+ return `
279
+ ${route}: PROBE FOUND NO INTERACTIVE TARGETS - the probe is broken, or the route loaded blank. NOT a clean route. [funnel: raw=${String(audit.probe.raw)} -> afterWrapper=${String(audit.probe.afterWrapper)} -> outermost=${String(audit.probe.kept)}]`;
280
+ }
281
+ const undersizedIdx = new Set(audit.undersized.map((f) => f.idx));
282
+ const unlabelledIdx = new Set(audit.unlabelled.map((f) => f.idx));
283
+ const both = audit.unlabelled.filter((f) => undersizedIdx.has(f.idx)).length;
284
+ return `
285
+ ${route}: ${String(audit.undersized.length)} of ${String(audit.total)} under ${String(minPx)}px; ${String(audit.unlabelled.length)} of ${String(audit.total)} with NO role and NO accessible name; ${String(both)} BOTH
286
+ UNDERSIZED (<${String(minPx)}px): ${renderFindings(audit.undersized, unlabelledIdx, "unlabelled")}
287
+ UNLABELLED (no role, no name): ${renderFindings(audit.unlabelled, undersizedIdx, "undersized")}`;
288
+ }
289
+ function routeProblems({ audit }) {
290
+ if (audit.total === 0) {
291
+ return 1;
292
+ }
293
+ return audit.undersized.length + audit.unlabelled.length;
294
+ }
295
+ function summariseTouchTargets(readings, portal, minPx = MIN_TARGET_PX) {
296
+ if (readings.length === 0) {
297
+ return { problems: 1, message: `${portal}: no routes were measured at all` };
298
+ }
299
+ const sum = (pick) => readings.reduce((n, r) => n + pick(r), 0);
300
+ const blank = readings.filter((r) => r.audit.total === 0).length;
301
+ const message = `${portal}: ${String(readings.length)} route(s), ${String(sum((r) => r.audit.total))} targets; ${String(sum((r) => r.audit.undersized.length))} under ${String(minPx)}px; ${String(sum((r) => r.audit.unlabelled.length))} with NO role and NO accessible name; ${String(blank)} route(s) read ZERO targets` + readings.map((r) => renderRouteAudit(r, minPx)).join("");
302
+ return { problems: sum(routeProblems), message };
303
+ }
304
+ async function auditTouchTargets(page, minPx = MIN_TARGET_PX) {
305
+ return page.evaluate((min) => {
306
+ const ROLE_SEL = 'a[href], button, input:not([type="hidden"]), select, textarea, summary, [role="button"], [role="link"], [role="checkbox"], [role="radio"], [role="switch"], [role="tab"], [role="menuitem"], [role="menuitemcheckbox"], [role="option"], [role="slider"]';
307
+ const unreachable = (el, cs) => {
308
+ if (el.closest('[aria-hidden="true"]')) {
309
+ return true;
310
+ }
311
+ if (el.closest("[inert]")) {
312
+ return true;
313
+ }
314
+ if (cs.pointerEvents === "none") {
315
+ return true;
316
+ }
317
+ if (el.getAttribute("aria-disabled") === "true") {
318
+ return true;
319
+ }
320
+ return el.disabled === true;
321
+ };
322
+ const why = (el, cs) => {
323
+ if (el instanceof SVGElement && !el.hasAttribute("role")) {
324
+ return null;
325
+ }
326
+ if (el.matches(ROLE_SEL)) {
327
+ return "role";
328
+ }
329
+ if (typeof el.onclick === "function") {
330
+ return "handler";
331
+ }
332
+ if (el.getAttribute("data-focusable") === "true") {
333
+ return "rnw-focusable";
334
+ }
335
+ const ti = el.getAttribute("tabindex");
336
+ if (ti !== null && Number(ti) >= 0) {
337
+ return "tabindex";
338
+ }
339
+ if (cs.cursor === "pointer") {
340
+ const parent = el.parentElement;
341
+ if (!parent || getComputedStyle(parent).cursor !== "pointer") {
342
+ return "cursor-origin";
343
+ }
344
+ }
345
+ return null;
346
+ };
347
+ const raw = [];
348
+ for (const el of Array.from(document.querySelectorAll("*"))) {
349
+ const cs = getComputedStyle(el);
350
+ if (unreachable(el, cs)) {
351
+ continue;
352
+ }
353
+ const reason = why(el, cs);
354
+ if (reason !== null) {
355
+ raw.push({ el, reason });
356
+ }
357
+ }
358
+ const members = new Set(raw.map((c) => c.el));
359
+ const afterWrapper = raw.filter(({ el, reason }) => reason === "role" || !Array.from(el.querySelectorAll(ROLE_SEL)).some((d) => members.has(d)));
360
+ const survivors = new Set(afterWrapper.map((c) => c.el));
361
+ const kept = afterWrapper.filter(({ el }) => {
362
+ for (let p = el.parentElement; p; p = p.parentElement) {
363
+ if (survivors.has(p)) {
364
+ return false;
365
+ }
366
+ }
367
+ return true;
368
+ });
369
+ const describe = (el) => {
370
+ const id = el.getAttribute("data-testid") ?? el.getAttribute("id") ?? "";
371
+ return `${el.tagName.toLowerCase()}${id ? `[${id}]` : ""}`.slice(0, 60);
372
+ };
373
+ const accName = (el) => {
374
+ const aria = el.getAttribute("aria-label");
375
+ if (aria && aria.trim()) {
376
+ return aria.trim();
377
+ }
378
+ const by = el.getAttribute("aria-labelledby");
379
+ if (by) {
380
+ const t = by.split(/\s+/).map((i) => document.getElementById(i)?.textContent ?? "").join(" ").trim();
381
+ if (t) {
382
+ return t;
383
+ }
384
+ }
385
+ const attr = el.getAttribute("title") ?? el.getAttribute("alt") ?? el.value ?? "";
386
+ if (attr && attr.trim()) {
387
+ return attr.trim();
388
+ }
389
+ return (el.textContent ?? "").trim();
390
+ };
391
+ const undersized = [];
392
+ const unlabelled = [];
393
+ let total = 0;
394
+ for (const { el, reason } of kept) {
395
+ const r = el.getBoundingClientRect();
396
+ if (r.width <= 0 || r.height <= 0 || getComputedStyle(el).visibility === "hidden") {
397
+ continue;
398
+ }
399
+ const f = { idx: total, selector: describe(el), width: Math.round(r.width), height: Math.round(r.height), reason, name: accName(el).slice(0, 40) };
400
+ total += 1;
401
+ if (r.width < min || r.height < min) {
402
+ undersized.push(f);
403
+ }
404
+ const hasRole = el.matches(ROLE_SEL) || (el.getAttribute("role") ?? "") !== "";
405
+ if (!hasRole && !f.name) {
406
+ unlabelled.push(f);
407
+ }
408
+ }
409
+ return { total, undersized, unlabelled, probe: { raw: raw.length, afterWrapper: afterWrapper.length, kept: kept.length } };
410
+ }, minPx);
411
+ }
412
+ async function auditRoute(page, route, minPx = MIN_TARGET_PX) {
413
+ return { route, audit: await auditTouchTargets(page, minPx) };
414
+ }
415
+ function expectTouchTargetsAcrossRoutes(readings, portal, minPx = MIN_TARGET_PX) {
416
+ const summary = summariseTouchTargets(readings, portal, minPx);
417
+ test.expect(summary.problems, summary.message).toBe(0);
418
+ }
419
+ async function expectTouchTargets(page, where, minPx = MIN_TARGET_PX) {
420
+ const reading = await auditRoute(page, where, minPx);
421
+ expectTouchTargetsAcrossRoutes([reading], where, minPx);
422
+ return reading.audit;
423
+ }
424
+
425
+ // src/overflow-report.ts
426
+ function toOverflowReading(m) {
427
+ const visual = Math.ceil(m.visualViewportWidth);
428
+ return { ...m, overflowPx: m.scrollWidth - Math.min(visual, m.clientWidth), layoutViewportDrift: m.innerWidth - visual };
429
+ }
430
+ function renderOverflow({ route, reading: r }) {
431
+ const head = r.overflowPx > 0 ? `OVERFLOWS by ${String(r.overflowPx)}px` : "ok";
432
+ return `
433
+ ${route}: ${head} - scrollWidth=${String(r.scrollWidth)} vs visualViewport=${String(Math.ceil(r.visualViewportWidth))} (innerWidth=${String(r.innerWidth)}, clientWidth=${String(r.clientWidth)}, layout-viewport drift=${String(r.layoutViewportDrift)}px)`;
434
+ }
435
+ function summariseOverflow(readings, portal) {
436
+ if (readings.length === 0) {
437
+ return { problems: 1, message: `${portal}: no routes were measured at all` };
438
+ }
439
+ const bad = readings.filter((r) => r.reading.overflowPx > 0);
440
+ const worst = readings.reduce((n, r) => Math.max(n, r.reading.overflowPx), 0);
441
+ const message = `${portal}: ${String(readings.length)} reading(s), ${String(bad.length)} scroll horizontally; worst overflow ${String(worst)}px` + readings.map(renderOverflow).join("");
442
+ return { problems: bad.length, message };
443
+ }
444
+ async function readHorizontalOverflow(page) {
445
+ const metrics = await page.evaluate(() => ({
446
+ scrollWidth: document.documentElement.scrollWidth,
447
+ visualViewportWidth: window.visualViewport ? window.visualViewport.width : window.innerWidth,
448
+ innerWidth: window.innerWidth,
449
+ clientWidth: document.documentElement.clientWidth
450
+ }));
451
+ return toOverflowReading(metrics);
452
+ }
453
+ async function measureHorizontalOverflow(page, route) {
454
+ return { route, reading: await readHorizontalOverflow(page) };
455
+ }
456
+ async function horizontalOverflowPx(page) {
457
+ return (await readHorizontalOverflow(page)).overflowPx;
458
+ }
459
+ function expectNoHorizontalOverflowAcrossRoutes(readings, portal) {
460
+ const summary = summariseOverflow(readings, portal);
461
+ test.expect(summary.problems, summary.message).toBe(0);
462
+ }
463
+ async function expectNoHorizontalOverflow(page, where) {
464
+ const r = await measureHorizontalOverflow(page, where);
465
+ expectNoHorizontalOverflowAcrossRoutes([r], where);
466
+ return r.reading;
467
+ }
468
+
469
+ exports.ANTI_ALIAS_TOLERANCE = ANTI_ALIAS_TOLERANCE;
470
+ exports.CANVAS_TIMEOUT_MS = CANVAS_TIMEOUT_MS;
471
+ exports.CONTROL_SELECTOR = CONTROL_SELECTOR;
472
+ exports.DEFAULT_CANVAS_SELECTOR = DEFAULT_CANVAS_SELECTOR;
473
+ exports.DESKTOP_DEVICE = DESKTOP_DEVICE;
474
+ exports.DESKTOP_SIZE = DESKTOP_SIZE;
475
+ exports.EXACT = EXACT;
476
+ exports.FIT_TIMEOUT_MS = FIT_TIMEOUT_MS;
477
+ exports.GAME_SHELL_HEIGHT_VAR = GAME_SHELL_HEIGHT_VAR;
478
+ exports.MAX_REPORTED = MAX_REPORTED;
479
+ exports.MIN_TARGET_PX = MIN_TARGET_PX;
480
+ exports.PHONE_DEVICE = PHONE_DEVICE;
481
+ exports.PHONE_SIZE = PHONE_SIZE;
482
+ exports.RELAYOUT_TIMEOUT_MS = RELAYOUT_TIMEOUT_MS;
483
+ exports.armVisibleHeight = armVisibleHeight;
484
+ exports.auditRoute = auditRoute;
485
+ exports.auditTouchTargets = auditTouchTargets;
486
+ exports.canvasBoxToPage = canvasBoxToPage;
487
+ exports.controlName = controlName;
488
+ exports.countDiff = countDiff;
489
+ exports.desktop = desktop;
490
+ exports.deviceDescriptor = deviceDescriptor;
491
+ exports.diffPngs = diffPngs;
492
+ exports.domControls = domControls;
493
+ exports.expectCanvasHeight = expectCanvasHeight;
494
+ exports.expectCanvasInside = expectCanvasInside;
495
+ exports.expectFitTo = expectFitTo;
496
+ exports.expectNoHorizontalOverflow = expectNoHorizontalOverflow;
497
+ exports.expectNoHorizontalOverflowAcrossRoutes = expectNoHorizontalOverflowAcrossRoutes;
498
+ exports.expectTouchTargets = expectTouchTargets;
499
+ exports.expectTouchTargetsAcrossRoutes = expectTouchTargetsAcrossRoutes;
500
+ exports.findOverlaps = findOverlaps;
501
+ exports.findOverlapsWithin = findOverlapsWithin;
502
+ exports.gameProjects = gameProjects;
503
+ exports.horizontalOverflowPx = horizontalOverflowPx;
504
+ exports.measureHorizontalOverflow = measureHorizontalOverflow;
505
+ exports.overlaps = overlaps;
506
+ exports.phone = phone;
507
+ exports.readHorizontalOverflow = readHorizontalOverflow;
508
+ exports.regionDiff = regionDiff;
509
+ exports.renderFindings = renderFindings;
510
+ exports.renderOverflow = renderOverflow;
511
+ exports.renderRouteAudit = renderRouteAudit;
512
+ exports.routeProblems = routeProblems;
513
+ exports.shrinkVisibleHeight = shrinkVisibleHeight;
514
+ exports.summariseOverflow = summariseOverflow;
515
+ exports.summariseTouchTargets = summariseTouchTargets;
516
+ exports.toOverflowReading = toOverflowReading;
517
+ //# sourceMappingURL=index.js.map
518
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/boxes.ts","../src/devices.ts","../src/visible-height.ts","../src/fit.ts","../src/dom-controls.ts","../src/pixel-diff-math.ts","../src/pixel-diff.ts","../src/touch-report.ts","../src/touch-targets.ts","../src/overflow-report.ts","../src/overflow.ts"],"names":["devices","expect"],"mappings":";;;;;AAkBA,IAAM,kBAAA,GAAqB,EAAA;AAC3B,IAAM,SAAA,GAAkB,CAAC,CAAA,QAAA,EAAW,QAAQ,CAAA;AAErC,SAAS,QAAA,CAAS,GAAQ,CAAA,EAAiB;AAChD,EAAA,OAAO,CAAA,CAAE,IAAA,GAAO,CAAA,CAAE,KAAA,IAAS,EAAE,IAAA,GAAO,CAAA,CAAE,KAAA,IAAS,CAAA,CAAE,GAAA,GAAM,CAAA,CAAE,MAAA,IAAU,CAAA,CAAE,MAAM,CAAA,CAAE,MAAA;AAC/E;AAGO,SAAS,YAAA,CAAa,GAAmB,CAAA,EAAsC;AACpF,EAAA,MAAM,OAA0B,EAAC;AACjC,EAAA,KAAA,MAAW,KAAK,CAAA,EAAG;AACjB,IAAA,KAAA,MAAW,KAAK,CAAA,EAAG;AACjB,MAAA,IAAI,CAAA,KAAM,CAAA,IAAK,QAAA,CAAS,CAAA,EAAG,CAAC,CAAA,EAAG;AAC7B,QAAA,IAA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O,cAAA,GAAiB,MAAA,CAAO,cAAA,CAAe,QAAQ,MAAA,CAAO,UAAA;AAAA,IAClF,YAAY,MAAA,CAAO,UAAA;AAAA,IACnB,WAAA,EAAa,SAAS,eAAA,CAAgB;AAAA,GACxC,CAAE,CAAA;AACF,EAAA,OAAO,kBAAkB,OAAO,CAAA;AAClC;AAGA,eAAsB,yBAAA,CAA0B,MAAY,KAAA,EAAuC;AACjG,EAAA,OAAO,EAAE,KAAA,EAAO,OAAA,EAAS,MAAM,sBAAA,CAAuB,IAAI,CAAA,EAAE;AAC9D;AAGA,eAAsB,qBAAqB,IAAA,EAA6B;AACtE,EAAA,OAAA,CAAQ,MAAM,sBAAA,CAAuB,IAAI,CAAA,EAAG,UAAA;AAC9C;AAGO,SAAS,sCAAA,CAAuC,UAAoC,MAAA,EAAsB;AAC/G,EAAA,MAAM,OAAA,GAAU,iBAAA,CAAkB,QAAA,EAAU,MAAM,CAAA;AAClD,EAAAA,YAAO,OAAA,CAAQ,QAAA,EAAU,QAAQ,OAAO,CAAA,CAAE,KAAK,CAAC,CAAA;AAClD;AAGA,eAAsB,0BAAA,CAA2B,MAAY,KAAA,EAAyC;AACpG,EAAA,MAAM,CAAA,GAAI,MAAM,yBAAA,CAA0B,IAAA,EAAM,KAAK,CAAA;AACrD,EAAA,sCAAA,CAAuC,CAAC,CAAC,CAAA,EAAG,KAAK,CAAA;AACjD,EAAA,OAAO,CAAA,CAAE,OAAA;AACX","file":"index.js","sourcesContent":["import type { Box, Rect } from './types';\n\nexport interface CanvasFrame {\n left: number;\n top: number;\n width: number;\n logicalWidth: number;\n}\n\nexport interface ControlIdentity {\n tag: string;\n id: string;\n className: string;\n text: string;\n}\n\nexport type Band = readonly [number, number];\n\nconst CONTROL_TEXT_CHARS = 12;\nconst OPEN_BAND: Band = [-Infinity, Infinity];\n\nexport function overlaps(a: Box, b: Box): boolean {\n return a.left < b.right && b.left < a.right && a.top < b.bottom && b.top < a.bottom;\n}\n\n/** Every overlapping (a, b) pair across two lists; an element never overlaps itself. */\nexport function findOverlaps(a: readonly Box[], b: readonly Box[]): Array<[Box, Box]> {\n const hits: Array<[Box, Box]> = [];\n for (const x of a) {\n for (const y of b) {\n if (x !== y && overlaps(x, y)) {\n hits.push([x, y]);\n }\n }\n }\n return hits;\n}\n\n/** Every overlapping pair inside one list, each pair reported once. */\nexport function findOverlapsWithin(boxes: readonly Box[]): Array<[Box, Box]> {\n const hits: Array<[Box, Box]> = [];\n boxes.forEach((x, i) => {\n for (const y of boxes.slice(i + 1)) {\n if (overlaps(x, y)) {\n hits.push([x, y]);\n }\n }\n });\n return hits;\n}\n\n/** Maps a game-space rect onto the page in CSS px, clipped to a scroll band; null when nothing is left. */\nexport function canvasBoxToPage(frame: CanvasFrame, bounds: Rect, name: string, band: Band = OPEN_BAND): Box | null {\n const scale = frame.width / frame.logicalWidth;\n const top = Math.max(bounds.y, band[0]);\n const bottom = Math.min(bounds.y + bounds.height, band[1]);\n if (bottom <= top) {\n return null;\n }\n return {\n name,\n left: frame.left + bounds.x * scale,\n top: frame.top + top * scale,\n right: frame.left + (bounds.x + bounds.width) * scale,\n bottom: frame.top + bottom * scale,\n };\n}\n\nexport function controlName(c: ControlIdentity): string {\n const firstClass = c.className.trim().split(/\\s+/)[0] ?? '';\n const id = c.id !== '' ? `#${c.id}` : `.${firstClass}`;\n return `${c.tag.toLowerCase()}${id}:${c.text.trim().slice(0, CONTROL_TEXT_CHARS)}`;\n}\n","import { type BrowserContextOptions, devices } from '@playwright/test';\n\nexport interface Size {\n width: number;\n height: number;\n}\n\nexport interface GameProject {\n name: string;\n use: BrowserContextOptions;\n}\n\nexport interface GameProjectsOptions {\n phone?: Size;\n desktop?: Size;\n phoneName?: string;\n desktopName?: string;\n}\n\nexport const PHONE_DEVICE = 'Galaxy S5';\nexport const DESKTOP_DEVICE = 'Desktop Chrome';\nexport const PHONE_SIZE: Size = { width: 360, height: 640 };\nexport const DESKTOP_SIZE: Size = { width: 1280, height: 720 };\n\n/** A Playwright device descriptor without `defaultBrowserType`, so it can sit inside any project's `use`. */\nexport function deviceDescriptor(name: string): BrowserContextOptions {\n const found = devices[name];\n if (found === undefined) {\n throw new Error(`Playwright has no device descriptor named \"${name}\"`);\n }\n const { defaultBrowserType: _browser, ...rest } = found;\n return rest;\n}\n\n/** A touch phone (Galaxy S5 descriptor: mobile UA, touch, isMobile) resized to width x height. */\nexport function phone(width = PHONE_SIZE.width, height = PHONE_SIZE.height, deviceScaleFactor?: number): BrowserContextOptions {\n const base = deviceDescriptor(PHONE_DEVICE);\n return { ...base, viewport: { width, height }, screen: { width, height }, deviceScaleFactor: deviceScaleFactor ?? base.deviceScaleFactor };\n}\n\n/** A Desktop Chrome descriptor resized to width x height, scale factor 1 unless given. */\nexport function desktop(width = DESKTOP_SIZE.width, height = DESKTOP_SIZE.height, deviceScaleFactor = 1): BrowserContextOptions {\n const base = deviceDescriptor(DESKTOP_DEVICE);\n return { ...base, viewport: { width, height }, screen: { width, height }, deviceScaleFactor };\n}\n\n/** The phone + desktop Playwright projects every game runs its specs under. */\nexport function gameProjects(options: GameProjectsOptions = {}): GameProject[] {\n const p = options.phone ?? PHONE_SIZE;\n const d = options.desktop ?? DESKTOP_SIZE;\n return [\n { name: options.phoneName ?? 'phone', use: phone(p.width, p.height) },\n { name: options.desktopName ?? 'desktop', use: desktop(d.width, d.height) },\n ];\n}\n","import { expect, type Page } from '@playwright/test';\n\nexport interface ShrinkOptions {\n relayoutGlobal?: string;\n timeout?: number;\n}\n\nexport const RELAYOUT_TIMEOUT_MS = 15_000;\n\n/** Replaces visualViewport.height before page scripts run: reads window.__gfVisibleHeight, else innerHeight. */\nexport async function armVisibleHeight(page: Page): Promise<void> {\n await page.addInitScript(() => {\n if (!window.visualViewport) {\n return;\n }\n const proto = Object.getPrototypeOf(window.visualViewport) as object;\n Object.defineProperty(proto, 'height', {\n configurable: true,\n get: () => (window as unknown as { __gfVisibleHeight?: number }).__gfVisibleHeight ?? window.innerHeight,\n });\n });\n}\n\n/** Drops the visible height and fires visualViewport resize; with `relayoutGlobal`, waits for every active Phaser scene to re-create. */\nexport async function shrinkVisibleHeight(page: Page, height: number, options: ShrinkOptions = {}): Promise<void> {\n const key = options.relayoutGlobal ?? null;\n const found = await page.evaluate(({ h, gameKey }) => {\n type Scene = { sys: { settings: { key: string } }; events: { once: (e: string, fn: () => void) => void } };\n type Game = { scene: { getScenes: (active: boolean) => Scene[] } };\n const w = window as unknown as Record<string, unknown> & { __gfVisibleHeight?: number; __gfRelaid?: Record<string, boolean> };\n let present = true;\n if (gameKey !== null) {\n const game = w[gameKey] as Game | undefined;\n present = game !== undefined;\n const relaid: Record<string, boolean> = {};\n w.__gfRelaid = relaid;\n for (const s of game?.scene.getScenes(true) ?? []) {\n const sceneKey = s.sys.settings.key;\n relaid[sceneKey] = false;\n s.events.once('create', () => {\n relaid[sceneKey] = true;\n });\n }\n }\n w.__gfVisibleHeight = h;\n window.visualViewport?.dispatchEvent(new Event('resize'));\n return present;\n }, { h: height, gameKey: key });\n if (key === null) {\n return;\n }\n if (!found) {\n throw new Error(`shrinkVisibleHeight: window.${key} is not defined, so no scene re-layout can be awaited`);\n }\n await expect.poll(() => page.evaluate(() => {\n const relaid = (window as unknown as { __gfRelaid?: Record<string, boolean> }).__gfRelaid ?? {};\n return Object.keys(relaid).filter((k) => !relaid[k]);\n }), { message: 'scenes still showing the layout of the old height', timeout: options.timeout ?? RELAYOUT_TIMEOUT_MS }).toEqual([]);\n}\n","import { expect, type Page } from '@playwright/test';\n\nexport interface FitOptions {\n cssVar?: string;\n timeout?: number;\n}\n\nexport interface CanvasOptions {\n canvasSelector?: string;\n timeout?: number;\n}\n\nexport const GAME_SHELL_HEIGHT_VAR = '--gs-vh';\nexport const DEFAULT_CANVAS_SELECTOR = 'canvas';\nexport const FIT_TIMEOUT_MS = 10_000;\nexport const CANVAS_TIMEOUT_MS = 15_000;\nconst MISSING_BOTTOM = 1e9;\n\n/** Waits until the game-shell height variable on :root equals `height` px. */\nexport async function expectFitTo(page: Page, height: number, options: FitOptions = {}): Promise<void> {\n const cssVar = options.cssVar ?? GAME_SHELL_HEIGHT_VAR;\n await expect.poll(() => page.evaluate((v) => getComputedStyle(document.documentElement).getPropertyValue(v).trim(), cssVar),\n { message: `${cssVar} never became ${String(height)}px (game-shell fit not running)`, timeout: options.timeout ?? FIT_TIMEOUT_MS })\n .toBe(`${String(height)}px`);\n}\n\n/** Waits for the canvas to follow its container to exactly `height` CSS px. */\nexport async function expectCanvasHeight(page: Page, height: number, options: CanvasOptions = {}): Promise<void> {\n const selector = options.canvasSelector ?? DEFAULT_CANVAS_SELECTOR;\n await expect.poll(() => page.evaluate((s) => Math.round(document.querySelector(s)?.getBoundingClientRect().height ?? -1), selector),\n { message: `canvas ${selector} never re-fit to the ${String(height)}px visible height`, timeout: options.timeout ?? CANVAS_TIMEOUT_MS })\n .toBe(height);\n}\n\n/** Waits until the canvas bottom sits inside the visible `height` (a FIT-scaled canvas may be shorter). */\nexport async function expectCanvasInside(page: Page, height: number, options: CanvasOptions = {}): Promise<void> {\n const selector = options.canvasSelector ?? DEFAULT_CANVAS_SELECTOR;\n await expect.poll(() => page.evaluate(({ s, missing }) => Math.round(document.querySelector(s)?.getBoundingClientRect().bottom ?? missing), { s: selector, missing: MISSING_BOTTOM }),\n { message: `canvas ${selector} never re-fit inside the ${String(height)}px visible height`, timeout: options.timeout ?? CANVAS_TIMEOUT_MS })\n .toBeLessThanOrEqual(height);\n}\n","import type { Page } from '@playwright/test';\nimport { controlName } from './boxes';\nimport type { Box } from './types';\n\nexport const CONTROL_SELECTOR = 'button, a[href], [role=\"button\"]';\n\n/** Visible, interactive DOM controls as CSS-px boxes, named tag#id or tag.class plus their text. */\nexport async function domControls(page: Page, selector = CONTROL_SELECTOR): Promise<Box[]> {\n const records = await page.evaluate((sel) => Array.from(document.querySelectorAll(sel))\n .filter((el) => {\n const s = getComputedStyle(el);\n const b = el.getBoundingClientRect();\n return s.display !== 'none' && s.visibility !== 'hidden' && b.width > 0 && b.height > 0;\n })\n .map((el) => {\n const b = el.getBoundingClientRect();\n return { tag: el.tagName, id: el.id, className: el.getAttribute('class') ?? '', text: el.textContent ?? '', left: b.left, top: b.top, right: b.right, bottom: b.bottom };\n }), selector);\n return records.map((r) => ({ name: controlName(r), left: r.left, top: r.top, right: r.right, bottom: r.bottom }));\n}\n","export const EXACT = 0;\nexport const ANTI_ALIAS_TOLERANCE = 48;\nconst CHANNELS = 4;\n\nexport interface DiffResult {\n differing: number;\n total: number;\n ratio: number;\n bbox: string;\n}\n\nfunction at(data: ArrayLike<number>, i: number): number {\n return data[i] ?? 0;\n}\n\nfunction channelDelta(a: ArrayLike<number>, b: ArrayLike<number>, i: number): number {\n return Math.max(Math.abs(at(a, i) - at(b, i)), Math.abs(at(a, i + 1) - at(b, i + 1)), Math.abs(at(a, i + 2) - at(b, i + 2)));\n}\n\n/** Counts RGBA pixels whose largest RGB channel delta exceeds `tolerance` (0 = any change), with their bounding box. */\nexport function countDiff(a: ArrayLike<number>, b: ArrayLike<number>, width: number, tolerance = EXACT): DiffResult {\n if (a.length !== b.length) {\n throw new Error(`pixel buffers differ in length: ${String(a.length)} vs ${String(b.length)}`);\n }\n if (width <= 0 || a.length % (width * CHANNELS) !== 0) {\n throw new Error(`pixel buffer of ${String(a.length)} bytes is not whole RGBA rows of width ${String(width)}`);\n }\n const total = a.length / CHANNELS;\n let differing = 0;\n let x0 = width;\n let y0 = total / width;\n let x1 = -1;\n let y1 = -1;\n for (let i = 0; i < a.length; i += CHANNELS) {\n if (channelDelta(a, b, i) <= tolerance) {\n continue;\n }\n differing += 1;\n const p = i / CHANNELS;\n const px = p % width;\n const py = Math.floor(p / width);\n x0 = Math.min(x0, px);\n y0 = Math.min(y0, py);\n x1 = Math.max(x1, px);\n y1 = Math.max(y1, py);\n }\n const bbox = differing > 0 ? `${String(x0)},${String(y0)}-${String(x1)},${String(y1)}` : 'none';\n return { differing, total, ratio: total === 0 ? 0 : differing / total, bbox };\n}\n","import { countDiff, EXACT, type DiffResult } from './pixel-diff-math';\nimport type { PageFactory, Region } from './types';\n\nexport interface DiffOptions {\n tolerance?: number;\n width?: number;\n height?: number;\n regionA?: Region | null;\n regionB?: Region | null;\n}\n\nexport interface RegionInput {\n png: Buffer;\n region: Region | null;\n}\n\n/** Decodes two PNGs in a scratch page and counts differing pixels; exact and same-size unless options say otherwise. */\nexport async function diffPngs(factory: PageFactory, a: Buffer, b: Buffer, options: DiffOptions = {}): Promise<DiffResult> {\n const scratch = await factory.newPage();\n try {\n const decoded = await scratch.evaluate(async ({ pa, pb, ra, rb, w, h }) => {\n const load = (src: string): Promise<HTMLImageElement> => new Promise((resolve, reject) => {\n const img = new Image();\n img.onload = (): void => resolve(img);\n img.onerror = (): void => reject(new Error('image did not decode'));\n img.src = `data:image/png;base64,${src}`;\n });\n const [ia, ib] = await Promise.all([load(pa), load(pb)]);\n const unscaled = w === null && h === null && ra === null && rb === null;\n if (unscaled && (ia.naturalWidth !== ib.naturalWidth || ia.naturalHeight !== ib.naturalHeight)) {\n throw new Error(`image sizes differ: ${String(ia.naturalWidth)}x${String(ia.naturalHeight)} vs ${String(ib.naturalWidth)}x${String(ib.naturalHeight)}`);\n }\n const width = Math.max(1, Math.round(w ?? ra?.w ?? ia.naturalWidth));\n const height = Math.max(1, Math.round(h ?? ra?.h ?? ia.naturalHeight));\n const chunk = 0x8000;\n const toBase64 = (img: HTMLImageElement, r: { x: number; y: number; w: number; h: number } | null): string => {\n const c = document.createElement('canvas');\n c.width = width;\n c.height = height;\n const g = c.getContext('2d');\n if (!g) {\n throw new Error('no 2d context');\n }\n if (r) {\n g.drawImage(img, r.x, r.y, r.w, r.h, 0, 0, width, height);\n } else {\n g.drawImage(img, 0, 0, width, height);\n }\n const data = g.getImageData(0, 0, width, height).data;\n let s = '';\n for (let i = 0; i < data.length; i += chunk) {\n s += String.fromCharCode(...data.subarray(i, i + chunk));\n }\n return btoa(s);\n };\n return { width, a: toBase64(ia, ra), b: toBase64(ib, rb) };\n }, {\n pa: a.toString('base64'),\n pb: b.toString('base64'),\n ra: options.regionA ?? null,\n rb: options.regionB ?? null,\n w: options.width ?? null,\n h: options.height ?? null,\n });\n return countDiff(Buffer.from(decoded.a, 'base64'), Buffer.from(decoded.b, 'base64'), decoded.width, options.tolerance ?? EXACT);\n } finally {\n await scratch.close();\n }\n}\n\n/** Diffs a region of PNG a against a region of PNG b (null = whole image), both drawn at the same size. */\nexport async function regionDiff(factory: PageFactory, a: RegionInput, b: RegionInput, options: Omit<DiffOptions, 'regionA' | 'regionB'> = {}): Promise<DiffResult> {\n return diffPngs(factory, a.png, b.png, { ...options, regionA: a.region, regionB: b.region });\n}\n","import type { GateSummary } from './types';\n\nexport const MIN_TARGET_PX = 44;\nexport const MAX_REPORTED = 12;\n\nexport interface TargetFinding {\n idx: number;\n selector: string;\n width: number;\n height: number;\n reason: string;\n name: string;\n}\n\nexport interface TargetProbeFunnel {\n raw: number;\n afterWrapper: number;\n kept: number;\n}\n\n/** One route's touch-target reading; `probe` makes a zero attributable (raw -> afterWrapper -> kept -> total). */\nexport interface TargetAudit {\n total: number;\n undersized: TargetFinding[];\n unlabelled: TargetFinding[];\n probe: TargetProbeFunnel;\n}\n\n/** One route's reading. `total === 0` is a broken probe for that route, never a clean route. */\nexport interface RouteAudit {\n route: string;\n audit: TargetAudit;\n}\n\nexport function renderFindings(findings: readonly TargetFinding[], alsoIn: ReadonlySet<number>, alsoLabel: string): string {\n if (findings.length === 0) {\n return 'none';\n }\n const shown = findings.slice(0, MAX_REPORTED)\n .map((f) => `${f.selector} ${String(f.width)}x${String(f.height)} via=${f.reason} name=\"${f.name}\"`\n + (alsoIn.has(f.idx) ? ` [ALSO ${alsoLabel}]` : ''));\n const rest = findings.length - shown.length;\n return shown.join('; ') + (rest > 0 ? ` (+${String(rest)} more)` : '');\n}\n\nexport function renderRouteAudit({ route, audit }: RouteAudit, minPx: number): string {\n if (audit.total === 0) {\n return `\\n ${route}: PROBE FOUND NO INTERACTIVE TARGETS - the probe is broken, or the route loaded blank.`\n + ' NOT a clean route.'\n + ` [funnel: raw=${String(audit.probe.raw)} -> afterWrapper=${String(audit.probe.afterWrapper)}`\n + ` -> outermost=${String(audit.probe.kept)}]`;\n }\n const undersizedIdx = new Set(audit.undersized.map((f) => f.idx));\n const unlabelledIdx = new Set(audit.unlabelled.map((f) => f.idx));\n const both = audit.unlabelled.filter((f) => undersizedIdx.has(f.idx)).length;\n return `\\n ${route}: ${String(audit.undersized.length)} of ${String(audit.total)} under ${String(minPx)}px`\n + `; ${String(audit.unlabelled.length)} of ${String(audit.total)} with NO role and NO accessible name`\n + `; ${String(both)} BOTH`\n + `\\n UNDERSIZED (<${String(minPx)}px): ${renderFindings(audit.undersized, unlabelledIdx, 'unlabelled')}`\n + `\\n UNLABELLED (no role, no name): ${renderFindings(audit.unlabelled, undersizedIdx, 'undersized')}`;\n}\n\nexport function routeProblems({ audit }: RouteAudit): number {\n if (audit.total === 0) {\n return 1;\n }\n return audit.undersized.length + audit.unlabelled.length;\n}\n\n/** Folds every route and both claims (size, label) into one tally; no routes at all is itself a problem. */\nexport function summariseTouchTargets(readings: readonly RouteAudit[], portal: string, minPx = MIN_TARGET_PX): GateSummary {\n if (readings.length === 0) {\n return { problems: 1, message: `${portal}: no routes were measured at all` };\n }\n const sum = (pick: (r: RouteAudit) => number): number => readings.reduce((n, r) => n + pick(r), 0);\n const blank = readings.filter((r) => r.audit.total === 0).length;\n const message = `${portal}: ${String(readings.length)} route(s), ${String(sum((r) => r.audit.total))} targets`\n + `; ${String(sum((r) => r.audit.undersized.length))} under ${String(minPx)}px`\n + `; ${String(sum((r) => r.audit.unlabelled.length))} with NO role and NO accessible name`\n + `; ${String(blank)} route(s) read ZERO targets`\n + readings.map((r) => renderRouteAudit(r, minPx)).join('');\n return { problems: sum(routeProblems), message };\n}\n","import { expect, type Page } from '@playwright/test';\nimport { MIN_TARGET_PX, summariseTouchTargets, type RouteAudit, type TargetAudit, type TargetFinding } from './touch-report';\n\n/** Measures every reachable pressable on the page (role OR handler OR own-origin pointer cursor, outermost wins) against `minPx`. */\nexport async function auditTouchTargets(page: Page, minPx = MIN_TARGET_PX): Promise<TargetAudit> {\n return page.evaluate((min) => {\n const ROLE_SEL = 'a[href], button, input:not([type=\"hidden\"]), select, textarea, summary,'\n + ' [role=\"button\"], [role=\"link\"], [role=\"checkbox\"], [role=\"radio\"], [role=\"switch\"],'\n + ' [role=\"tab\"], [role=\"menuitem\"], [role=\"menuitemcheckbox\"], [role=\"option\"], [role=\"slider\"]';\n const unreachable = (el: Element, cs: CSSStyleDeclaration): boolean => {\n if (el.closest('[aria-hidden=\"true\"]')) {\n return true;\n }\n if (el.closest('[inert]')) {\n return true;\n }\n if (cs.pointerEvents === 'none') {\n return true;\n }\n if (el.getAttribute('aria-disabled') === 'true') {\n return true;\n }\n return (el as HTMLButtonElement).disabled === true;\n };\n const why = (el: Element, cs: CSSStyleDeclaration): string | null => {\n if (el instanceof SVGElement && !el.hasAttribute('role')) {\n return null;\n }\n if (el.matches(ROLE_SEL)) {\n return 'role';\n }\n if (typeof (el as HTMLElement).onclick === 'function') {\n return 'handler';\n }\n if (el.getAttribute('data-focusable') === 'true') {\n return 'rnw-focusable';\n }\n const ti = el.getAttribute('tabindex');\n if (ti !== null && Number(ti) >= 0) {\n return 'tabindex';\n }\n if (cs.cursor === 'pointer') {\n const parent = el.parentElement;\n if (!parent || getComputedStyle(parent).cursor !== 'pointer') {\n return 'cursor-origin';\n }\n }\n return null;\n };\n const raw: { el: Element; reason: string }[] = [];\n for (const el of Array.from(document.querySelectorAll('*'))) {\n const cs = getComputedStyle(el);\n if (unreachable(el, cs)) {\n continue;\n }\n const reason = why(el, cs);\n if (reason !== null) {\n raw.push({ el, reason });\n }\n }\n const members = new Set(raw.map((c) => c.el));\n const afterWrapper = raw.filter(({ el, reason }) => reason === 'role'\n || !Array.from(el.querySelectorAll(ROLE_SEL)).some((d) => members.has(d)));\n const survivors = new Set(afterWrapper.map((c) => c.el));\n const kept = afterWrapper.filter(({ el }) => {\n for (let p = el.parentElement; p; p = p.parentElement) {\n if (survivors.has(p)) {\n return false;\n }\n }\n return true;\n });\n const describe = (el: Element): string => {\n const id = el.getAttribute('data-testid') ?? el.getAttribute('id') ?? '';\n return `${el.tagName.toLowerCase()}${id ? `[${id}]` : ''}`.slice(0, 60);\n };\n const accName = (el: Element): string => {\n const aria = el.getAttribute('aria-label');\n if (aria && aria.trim()) {\n return aria.trim();\n }\n const by = el.getAttribute('aria-labelledby');\n if (by) {\n const t = by.split(/\\s+/).map((i) => document.getElementById(i)?.textContent ?? '').join(' ').trim();\n if (t) {\n return t;\n }\n }\n const attr = el.getAttribute('title') ?? el.getAttribute('alt') ?? (el as HTMLInputElement).value ?? '';\n if (attr && attr.trim()) {\n return attr.trim();\n }\n return (el.textContent ?? '').trim();\n };\n const undersized: TargetFinding[] = [];\n const unlabelled: TargetFinding[] = [];\n let total = 0;\n for (const { el, reason } of kept) {\n const r = el.getBoundingClientRect();\n if (r.width <= 0 || r.height <= 0 || getComputedStyle(el).visibility === 'hidden') {\n continue;\n }\n const f: TargetFinding = { idx: total, selector: describe(el), width: Math.round(r.width), height: Math.round(r.height), reason, name: accName(el).slice(0, 40) };\n total += 1;\n if (r.width < min || r.height < min) {\n undersized.push(f);\n }\n const hasRole = el.matches(ROLE_SEL) || (el.getAttribute('role') ?? '') !== '';\n if (!hasRole && !f.name) {\n unlabelled.push(f);\n }\n }\n return { total, undersized, unlabelled, probe: { raw: raw.length, afterWrapper: afterWrapper.length, kept: kept.length } };\n }, minPx);\n}\n\n/** Measures one route and asserts nothing, so a route with findings cannot hide the routes after it. */\nexport async function auditRoute(page: Page, route: string, minPx = MIN_TARGET_PX): Promise<RouteAudit> {\n return { route, audit: await auditTouchTargets(page, minPx) };\n}\n\n/** ONE assertion per portal over every route and both claims (undersized, unlabelled); a zero-target route fails. */\nexport function expectTouchTargetsAcrossRoutes(readings: readonly RouteAudit[], portal: string, minPx = MIN_TARGET_PX): void {\n const summary = summariseTouchTargets(readings, portal, minPx);\n expect(summary.problems, summary.message).toBe(0);\n}\n\n/** Single-route convenience over `expectTouchTargetsAcrossRoutes`. */\nexport async function expectTouchTargets(page: Page, where: string, minPx = MIN_TARGET_PX): Promise<TargetAudit> {\n const reading = await auditRoute(page, where, minPx);\n expectTouchTargetsAcrossRoutes([reading], where, minPx);\n return reading.audit;\n}\n","import type { GateSummary } from './types';\n\nexport interface OverflowMetrics {\n scrollWidth: number;\n visualViewportWidth: number;\n innerWidth: number;\n clientWidth: number;\n}\n\n/** `layoutViewportDrift` (innerWidth above visualViewport) is the signature of a widened layout viewport. */\nexport interface OverflowReading extends OverflowMetrics {\n overflowPx: number;\n layoutViewportDrift: number;\n}\n\nexport interface RouteOverflow {\n route: string;\n reading: OverflowReading;\n}\n\n/** Overflow against the NARROWER of visualViewport width and clientWidth, never innerWidth (which widens with the defect). */\nexport function toOverflowReading(m: OverflowMetrics): OverflowReading {\n const visual = Math.ceil(m.visualViewportWidth);\n return { ...m, overflowPx: m.scrollWidth - Math.min(visual, m.clientWidth), layoutViewportDrift: m.innerWidth - visual };\n}\n\nexport function renderOverflow({ route, reading: r }: RouteOverflow): string {\n const head = r.overflowPx > 0 ? `OVERFLOWS by ${String(r.overflowPx)}px` : 'ok';\n return `\\n ${route}: ${head} - scrollWidth=${String(r.scrollWidth)}`\n + ` vs visualViewport=${String(Math.ceil(r.visualViewportWidth))}`\n + ` (innerWidth=${String(r.innerWidth)}, clientWidth=${String(r.clientWidth)}`\n + `, layout-viewport drift=${String(r.layoutViewportDrift)}px)`;\n}\n\n/** Folds every route into one tally of routes that scroll sideways; no routes at all is itself a problem. */\nexport function summariseOverflow(readings: readonly RouteOverflow[], portal: string): GateSummary {\n if (readings.length === 0) {\n return { problems: 1, message: `${portal}: no routes were measured at all` };\n }\n const bad = readings.filter((r) => r.reading.overflowPx > 0);\n const worst = readings.reduce((n, r) => Math.max(n, r.reading.overflowPx), 0);\n const message = `${portal}: ${String(readings.length)} reading(s), ${String(bad.length)} scroll horizontally`\n + `; worst overflow ${String(worst)}px`\n + readings.map(renderOverflow).join('');\n return { problems: bad.length, message };\n}\n","import { expect, type Page } from '@playwright/test';\nimport { summariseOverflow, toOverflowReading, type OverflowReading, type RouteOverflow } from './overflow-report';\n\nexport async function readHorizontalOverflow(page: Page): Promise<OverflowReading> {\n const metrics = await page.evaluate(() => ({\n scrollWidth: document.documentElement.scrollWidth,\n visualViewportWidth: window.visualViewport ? window.visualViewport.width : window.innerWidth,\n innerWidth: window.innerWidth,\n clientWidth: document.documentElement.clientWidth,\n }));\n return toOverflowReading(metrics);\n}\n\n/** Measures one route and asserts nothing. */\nexport async function measureHorizontalOverflow(page: Page, route: string): Promise<RouteOverflow> {\n return { route, reading: await readHorizontalOverflow(page) };\n}\n\n/** Pixels the document scrolls sideways past the visible width (<= 0 means no horizontal scroll). */\nexport async function horizontalOverflowPx(page: Page): Promise<number> {\n return (await readHorizontalOverflow(page)).overflowPx;\n}\n\n/** ONE assertion per portal over every route, so the first overflowing route cannot hide the rest. */\nexport function expectNoHorizontalOverflowAcrossRoutes(readings: readonly RouteOverflow[], portal: string): void {\n const summary = summariseOverflow(readings, portal);\n expect(summary.problems, summary.message).toBe(0);\n}\n\n/** Single-route convenience over `expectNoHorizontalOverflowAcrossRoutes`. */\nexport async function expectNoHorizontalOverflow(page: Page, where: string): Promise<OverflowReading> {\n const r = await measureHorizontalOverflow(page, where);\n expectNoHorizontalOverflowAcrossRoutes([r], where);\n return r.reading;\n}\n"]}