@rind-ui/testing 0.2.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/{adapter-UPhu17S6.d.mts → adapter-B05M46SW.d.mts} +18 -1
- package/dist/{compose-DPLnCCnJ.mjs → compose-BpR_PG11.mjs} +34 -2
- package/dist/{dom-DZtl6G1E.mjs → dom-Bnnr_fg-.mjs} +377 -15
- package/dist/{dom-BxnIjEBk.d.mts → dom-Ur_VPlTe.d.mts} +12 -3
- package/dist/dom.d.mts +1 -1
- package/dist/dom.mjs +1 -1
- package/dist/index.d.mts +9487 -930
- package/dist/index.mjs +2745 -47
- package/dist/inpage.iife.js +7 -4
- package/dist/{playwright-CtIxjMKr.d.mts → playwright-By15MZsN.d.mts} +6 -3
- package/dist/{playwright-C2LKzGS_.mjs → playwright-C3Ue38p3.mjs} +300 -7
- package/dist/playwright.d.mts +1 -1
- package/dist/playwright.mjs +1 -1
- package/dist/setup.mjs +1 -1
- package/package.json +4 -3
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { a as navigationLog, i as interceptNativeNavigation, n as installErrorLog, o as installAnnouncementLog, r as fakeRouter, s as recordingAnnouncer, t as domEnv } from "./dom-
|
|
3
|
-
import { n as playwrightEnv, r as watchPageErrors, t as isPage } from "./playwright-
|
|
4
|
-
import { accordionContract, buttonContract, checkboxContract, checkboxGroupContract, collapsibleContract, createService, fieldContract, fieldsetContract, formContract, headingContract, labelContract, linkContract, platforms, platforms as platforms$1, quirkActive, radioGroupContract, segmentedControlContract, separatorContract, separatorContractFor, switchContract, tabsContract, textFieldContract, toggleContract, toggleGroupContract, toolbarContract, withEngine, withEngine as withEngine$1 } from "@rind-ui/core";
|
|
1
|
+
import { a as isEnvFactory, i as hostedPartName, n as UntilTimeout, o as mirror } from "./compose-BpR_PG11.mjs";
|
|
2
|
+
import { a as navigationLog, i as interceptNativeNavigation, n as installErrorLog, o as installAnnouncementLog, r as fakeRouter, s as recordingAnnouncer, t as domEnv } from "./dom-Bnnr_fg-.mjs";
|
|
3
|
+
import { n as playwrightEnv, r as watchPageErrors, t as isPage } from "./playwright-C3Ue38p3.mjs";
|
|
4
|
+
import { accordionContract, alertContract, alertDialogContract, avatarContract, badgeContract, breadcrumbsContract, buttonContract, calendarContract, checkboxContract, checkboxGroupContract, collapsibleContract, colorPickerContract, comboboxContract, contextMenuContract, createService, dialogContract, drawerContract, fieldContract, fieldsetContract, formContract, headingContract, hoverCardContract, imageContract, labelContract, linkContract, listboxContract, menuContract, meterContract, modalPopoverContract, modalTourContract, nonModalContextMenuContract, nonModalDialogContract, nonModalDrawerContract, nonModalMenuContract, numberInputContract, paginationContract, pinInputContract, platforms, platforms as platforms$1, popoverContract, progressContract, qrCodeContractWith, quirkActive, radioGroupContract, scrollAreaContract, segmentedControlContract, selectContract, separatorContract, separatorContractFor, skeletonContract, sliderContract, switchContract, tabsContract, tagsInputContract, textFieldContract, toastContract, toasterContract, toggleContract, toggleGroupContract, toolbarContract, tooltipContract, tourContract, withEngine, withEngine as withEngine$1 } from "@rind-ui/core";
|
|
5
|
+
import { parseQrPath } from "@rind-ui/core/qr";
|
|
6
|
+
import { colorAreaContract, colorChannelFieldContract, colorFieldContract, colorSliderContract, colorSwatchContract, colorSwatchPickerContract, pickSwatch } from "@rind-ui/core/internal";
|
|
5
7
|
//#region src/accordion-invariants.ts
|
|
6
8
|
const NAVIGATION_KEYS = /* @__PURE__ */ new Set([
|
|
7
9
|
"ArrowUp",
|
|
@@ -186,7 +188,7 @@ async function runAction(contract, env, name, args, checkDone = true) {
|
|
|
186
188
|
} catch (e) {
|
|
187
189
|
const seen = await observe(contract, env);
|
|
188
190
|
const expected = typeof done === "function" ? "its postcondition" : JSON.stringify(done);
|
|
189
|
-
throw new Error(`${contract.scope}.${name} [${modality}]: expected ${expected}, observed ${JSON.stringify(seen)}${e instanceof UntilTimeout ? "" : ` (${e instanceof Error ? e.message : String(e)})`}`);
|
|
191
|
+
throw new Error(`${contract.scope}.${name} [${modality}]: expected ${expected}, observed ${JSON.stringify(seen)}; focus on ${await describeFocus(env)}${e instanceof UntilTimeout ? "" : ` (${e instanceof Error ? e.message : String(e)})`}`);
|
|
190
192
|
}
|
|
191
193
|
}
|
|
192
194
|
const PREFERENCE = [
|
|
@@ -194,6 +196,19 @@ const PREFERENCE = [
|
|
|
194
196
|
"keyboard",
|
|
195
197
|
"touch"
|
|
196
198
|
];
|
|
199
|
+
/** Where focus is, for a failed postcondition: a tag, its rind-ui part and its name. */
|
|
200
|
+
async function describeFocus(env) {
|
|
201
|
+
try {
|
|
202
|
+
const f = env.focused();
|
|
203
|
+
if (!await f.exists()) return "nothing (body)";
|
|
204
|
+
const scope = await f.attr("data-scope");
|
|
205
|
+
const part = await f.attr("data-part");
|
|
206
|
+
const where = scope && part ? ` ${scope}.${part}` : "";
|
|
207
|
+
return `<${await f.tagName()}>${where} "${await f.accessibleName()}"`;
|
|
208
|
+
} catch {
|
|
209
|
+
return "unknown";
|
|
210
|
+
}
|
|
211
|
+
}
|
|
197
212
|
function make(contract, factory, anchor, options) {
|
|
198
213
|
const direction = options.direction ?? "ltr";
|
|
199
214
|
const envs = /* @__PURE__ */ new Map();
|
|
@@ -202,6 +217,7 @@ function make(contract, factory, anchor, options) {
|
|
|
202
217
|
if (!env) {
|
|
203
218
|
env = directed(factory.create({
|
|
204
219
|
scope: contract.scope,
|
|
220
|
+
...hostedPartName(contract),
|
|
205
221
|
anchor,
|
|
206
222
|
modality,
|
|
207
223
|
...options.platform ? { platform: options.platform } : {}
|
|
@@ -249,12 +265,67 @@ function getAccordion(target, anchor, options) {
|
|
|
249
265
|
return createDriverWith(accordionContract, target, [anchor], options);
|
|
250
266
|
}
|
|
251
267
|
//#endregion
|
|
268
|
+
//#region src/components/alert.ts
|
|
269
|
+
/**
|
|
270
|
+
* A driver for an Alert: the one whose Title's text is `title`, or the one alert inside
|
|
271
|
+
* `within` (a container element or a Playwright locator; default the target).
|
|
272
|
+
* `announcements()` lists what it announced since the driver was created.
|
|
273
|
+
*/
|
|
274
|
+
function getAlert(target, anchor = {}, options) {
|
|
275
|
+
const { within, title } = anchor;
|
|
276
|
+
return createDriverWith(alertContract, within ?? target, [title === void 0 ? {} : { title }], options);
|
|
277
|
+
}
|
|
278
|
+
//#endregion
|
|
279
|
+
//#region src/components/alert-dialog.ts
|
|
280
|
+
/**
|
|
281
|
+
* A driver for the Alert Dialog named `name`, located through its trigger (`trigger`,
|
|
282
|
+
* default `name`: a closed dialog has no content to find). It is always modal.
|
|
283
|
+
*/
|
|
284
|
+
function getAlertDialog(target, anchor, options) {
|
|
285
|
+
return createDriverWith(alertDialogContract, target, [anchor], options);
|
|
286
|
+
}
|
|
287
|
+
//#endregion
|
|
288
|
+
//#region src/components/avatar.ts
|
|
289
|
+
/**
|
|
290
|
+
* A driver for an Avatar: the one named `name` (role `img`), or, for a decorative avatar,
|
|
291
|
+
* the one avatar root inside `within` (a container element or a Playwright locator).
|
|
292
|
+
*/
|
|
293
|
+
function getAvatar(target, anchor = {}, options) {
|
|
294
|
+
const { within, name } = anchor;
|
|
295
|
+
return createDriverWith(avatarContract, within ?? target, [name === void 0 ? {} : { name }], options);
|
|
296
|
+
}
|
|
297
|
+
//#endregion
|
|
298
|
+
//#region src/components/badge.ts
|
|
299
|
+
/**
|
|
300
|
+
* A driver for a Badge: the one badge inside `within` (a container element or a Playwright
|
|
301
|
+
* locator; default the target). A badge has no role and no name; several matches fail
|
|
302
|
+
* listing every match.
|
|
303
|
+
*/
|
|
304
|
+
function getBadge(target, anchor = {}, options) {
|
|
305
|
+
return createDriverWith(badgeContract, anchor.within ?? target, [], options);
|
|
306
|
+
}
|
|
307
|
+
//#endregion
|
|
308
|
+
//#region src/components/breadcrumbs.ts
|
|
309
|
+
/**
|
|
310
|
+
* A driver for the Breadcrumbs landmark named `name`: `follow`, `openCollapsed`,
|
|
311
|
+
* `followCollapsed`, and the queries `items`, `current`, `collapsedCount`, `href`.
|
|
312
|
+
*/
|
|
313
|
+
function getBreadcrumbs(target, anchor, options) {
|
|
314
|
+
return createDriverWith(breadcrumbsContract, target, [anchor], options);
|
|
315
|
+
}
|
|
316
|
+
//#endregion
|
|
252
317
|
//#region src/components/button.ts
|
|
253
318
|
/** A driver for the Button named `name` (role `link` when rendered as a link). */
|
|
254
319
|
function getButton(target, anchor, options) {
|
|
255
320
|
return createDriverWith(buttonContract, target, [anchor], options);
|
|
256
321
|
}
|
|
257
322
|
//#endregion
|
|
323
|
+
//#region src/components/calendar.ts
|
|
324
|
+
/** A driver for the Calendar named `name`: select, focusDate, paging, queries. */
|
|
325
|
+
function getCalendar(target, anchor, options) {
|
|
326
|
+
return createDriverWith(calendarContract, target, [anchor], options);
|
|
327
|
+
}
|
|
328
|
+
//#endregion
|
|
258
329
|
//#region src/components/checkbox.ts
|
|
259
330
|
/** A driver for the Checkbox named `name`. */
|
|
260
331
|
function getCheckbox(target, anchor, options) {
|
|
@@ -273,6 +344,123 @@ function getCollapsible(target, anchor, options) {
|
|
|
273
344
|
return createDriverWith(collapsibleContract, target, [anchor], options);
|
|
274
345
|
}
|
|
275
346
|
//#endregion
|
|
347
|
+
//#region src/components/color-area.ts
|
|
348
|
+
/** A driver for the Color Area named `name` (its group). */
|
|
349
|
+
function getColorArea(target, anchor, options) {
|
|
350
|
+
return createDriverWith(colorAreaContract, target, [anchor], options);
|
|
351
|
+
}
|
|
352
|
+
//#endregion
|
|
353
|
+
//#region src/components/color-field.ts
|
|
354
|
+
/** A driver for the Color Field whose text input is named `name`. */
|
|
355
|
+
function getColorField(target, anchor, options) {
|
|
356
|
+
return createDriverWith(colorFieldContract, target, [anchor], options);
|
|
357
|
+
}
|
|
358
|
+
/** A driver for a Color Channel Field: Number Input's, plus `channel()` and `color()`. */
|
|
359
|
+
function getColorChannelField(target, anchor, options) {
|
|
360
|
+
return createDriverWith(colorChannelFieldContract, target, [anchor], options);
|
|
361
|
+
}
|
|
362
|
+
//#endregion
|
|
363
|
+
//#region src/components/color-slider.ts
|
|
364
|
+
/**
|
|
365
|
+
* A driver for the Color Slider whose group is `name` (its Label; an unlabelled slider's
|
|
366
|
+
* group has no name, so `name` matches its thumb's channel name): the Slider's driver plus the
|
|
367
|
+
* colour queries and `setChannel(value)` (`setValue(0, value)`).
|
|
368
|
+
*/
|
|
369
|
+
function getColorSlider(target, anchor, options) {
|
|
370
|
+
const driver = createDriverWith(colorSliderContract, target, [anchor], options);
|
|
371
|
+
return Object.assign(driver, {
|
|
372
|
+
/** Keyboard steps to the value (the pointer form is `setValue` in browser modes). */
|
|
373
|
+
setChannel: (value) => driver.via("keyboard").setValue(0, value) });
|
|
374
|
+
}
|
|
375
|
+
//#endregion
|
|
376
|
+
//#region src/components/color-swatch-picker.ts
|
|
377
|
+
/**
|
|
378
|
+
* A driver for the Color Swatch Picker named `name`: Radio Group's driver plus the colour
|
|
379
|
+
* queries, `pick(key | name | index)` and `move("next" | "previous")`.
|
|
380
|
+
*/
|
|
381
|
+
function getColorSwatchPicker(target, anchor, options) {
|
|
382
|
+
const driver = createDriverWith(colorSwatchPickerContract, target, [anchor], options);
|
|
383
|
+
return Object.assign(driver, {
|
|
384
|
+
pick: (swatch) => pickSwatch(driver.env, swatch),
|
|
385
|
+
move: async (direction) => {
|
|
386
|
+
await driver.env.focused().press(direction === "next" ? "ArrowRight" : "ArrowLeft");
|
|
387
|
+
}
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
//#endregion
|
|
391
|
+
//#region src/components/color-picker.ts
|
|
392
|
+
/** A swatch inside the picker: the swatch's contract under the picker's scope (`swatch`). */
|
|
393
|
+
const pickerSwatch = {
|
|
394
|
+
...colorSwatchContract,
|
|
395
|
+
scope: "color-picker",
|
|
396
|
+
partName: (part) => part === "root" ? "swatch" : part
|
|
397
|
+
};
|
|
398
|
+
/**
|
|
399
|
+
* A driver for the Color Picker named `name` (its Control, or its content when inline), with
|
|
400
|
+
* its parts' drivers (`area()`, `slider(channel)`, `input(channel)`, `swatches()`, `swatch(name)`) and
|
|
401
|
+
* `eyeDropper(result | "abort")`, which installs a fake `EyeDropper` on the page's window.
|
|
402
|
+
*/
|
|
403
|
+
function getColorPicker(target, anchor, options) {
|
|
404
|
+
const driver = createDriverWith(colorPickerContract, target, [anchor], options);
|
|
405
|
+
const names = (channel) => channel === "hex" ? "HEX" : channel === "css" ? "CSS" : channel[0]?.toUpperCase() + channel.slice(1);
|
|
406
|
+
return Object.assign(driver, {
|
|
407
|
+
area: (name = "Color area") => getColorArea(target, { name }, options),
|
|
408
|
+
slider: (channel) => getColorSlider(target, { name: names(channel) }, options),
|
|
409
|
+
input: (channel) => channel === "hex" || channel === "css" ? getColorField(target, { name: names(channel) }, options) : getColorChannelField(target, { name: names(channel) }, options),
|
|
410
|
+
swatches: (name = "Color swatches") => getColorSwatchPicker(target, { name }, options),
|
|
411
|
+
/** A `ColorPicker.Swatch`, by its colour name (or label). */
|
|
412
|
+
swatch: (name) => createDriverWith(pickerSwatch, target, [{ name }], options),
|
|
413
|
+
/** Installs a fake EyeDropper that resolves `result` (or rejects as dismissed). */
|
|
414
|
+
eyeDropper: (result, win = globalThis.window) => {
|
|
415
|
+
class FakeEyeDropper {
|
|
416
|
+
open() {
|
|
417
|
+
return result === "abort" ? Promise.reject(new DOMException("dismissed", "AbortError")) : Promise.resolve({ sRGBHex: result });
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
Object.assign(win, { EyeDropper: FakeEyeDropper });
|
|
421
|
+
return () => {
|
|
422
|
+
Reflect.deleteProperty(win, "EyeDropper");
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
//#endregion
|
|
428
|
+
//#region src/components/combobox.ts
|
|
429
|
+
/** A driver for the Combobox named `name`: type, compose, open, choose, clear, queries. */
|
|
430
|
+
function getCombobox(target, anchor, options) {
|
|
431
|
+
return createDriverWith(comboboxContract, target, [anchor], options);
|
|
432
|
+
}
|
|
433
|
+
//#endregion
|
|
434
|
+
//#region src/components/context-menu.ts
|
|
435
|
+
/**
|
|
436
|
+
* A driver for the Context Menu whose region contains `text` (a closed menu has no content
|
|
437
|
+
* to find). `modal: false` for a non-modal one.
|
|
438
|
+
*/
|
|
439
|
+
function getContextMenu(target, anchor, options) {
|
|
440
|
+
const { modal, ...locate } = anchor;
|
|
441
|
+
return createDriverWith(modal === false ? nonModalContextMenuContract : contextMenuContract, target, [locate], options);
|
|
442
|
+
}
|
|
443
|
+
//#endregion
|
|
444
|
+
//#region src/components/dialog.ts
|
|
445
|
+
/**
|
|
446
|
+
* A driver for the Dialog named `name`, located through its trigger (`trigger`, default
|
|
447
|
+
* `name`: a closed dialog has no content to find). `modal: false` for a non-modal dialog.
|
|
448
|
+
*/
|
|
449
|
+
function getDialog(target, anchor, options) {
|
|
450
|
+
const { modal, ...locate } = anchor;
|
|
451
|
+
return createDriverWith(modal === false ? nonModalDialogContract : dialogContract, target, [locate], options);
|
|
452
|
+
}
|
|
453
|
+
//#endregion
|
|
454
|
+
//#region src/components/drawer.ts
|
|
455
|
+
/**
|
|
456
|
+
* A driver for the Drawer opened by the trigger named `trigger` (default: `name`): open,
|
|
457
|
+
* close, swipe, pressHandle, pressEscape, queries.
|
|
458
|
+
*/
|
|
459
|
+
function getDrawer(target, anchor, options) {
|
|
460
|
+
const { modal, ...locate } = anchor;
|
|
461
|
+
return createDriverWith(modal === false ? nonModalDrawerContract : drawerContract, target, [locate], options);
|
|
462
|
+
}
|
|
463
|
+
//#endregion
|
|
276
464
|
//#region src/components/field.ts
|
|
277
465
|
/**
|
|
278
466
|
* A driver for the Field labelled `label`. `.control(getX)` builds the control's driver,
|
|
@@ -303,6 +491,23 @@ function getHeading(target, anchor, options) {
|
|
|
303
491
|
return createDriverWith(headingContract, target, [anchor], options);
|
|
304
492
|
}
|
|
305
493
|
//#endregion
|
|
494
|
+
//#region src/components/hover-card.ts
|
|
495
|
+
/** A driver for the Hover Card previewed by the link (or `role`) named `name`. */
|
|
496
|
+
function getHoverCard(target, anchor, options) {
|
|
497
|
+
return createDriverWith(hoverCardContract, target, [anchor], options);
|
|
498
|
+
}
|
|
499
|
+
//#endregion
|
|
500
|
+
//#region src/components/image.ts
|
|
501
|
+
/**
|
|
502
|
+
* A driver for an Image: the one named `name` (role `img`: the `<img>` while it loads, Root
|
|
503
|
+
* when there is no image to show; the same driver in every status), or, for a decorative
|
|
504
|
+
* image, the one image root inside `within` (a container element or a Playwright locator).
|
|
505
|
+
*/
|
|
506
|
+
function getImage(target, anchor = {}, options) {
|
|
507
|
+
const { within, name } = anchor;
|
|
508
|
+
return createDriverWith(imageContract, within ?? target, [name === void 0 ? {} : { name }], options);
|
|
509
|
+
}
|
|
510
|
+
//#endregion
|
|
306
511
|
//#region src/components/label.ts
|
|
307
512
|
/** A driver for the Label with exactly this text: `click`, `doubleClick` and queries. */
|
|
308
513
|
function getLabel(target, anchor, options) {
|
|
@@ -315,18 +520,1987 @@ function getLink(target, anchor, options) {
|
|
|
315
520
|
return createDriverWith(linkContract, target, [anchor], options);
|
|
316
521
|
}
|
|
317
522
|
//#endregion
|
|
523
|
+
//#region src/components/listbox.ts
|
|
524
|
+
/** A driver for the Listbox named `name`: choose, toggle, ranges, typeahead, act, queries. */
|
|
525
|
+
function getListbox(target, anchor, options) {
|
|
526
|
+
return createDriverWith(listboxContract, target, [anchor], options);
|
|
527
|
+
}
|
|
528
|
+
//#endregion
|
|
529
|
+
//#region src/components/menu.ts
|
|
530
|
+
/**
|
|
531
|
+
* A driver for the Menu opened by the trigger named `name` (a closed menu has no content
|
|
532
|
+
* to find). `modal: false` for a non-modal menu.
|
|
533
|
+
*/
|
|
534
|
+
function getMenu(target, anchor, options) {
|
|
535
|
+
const { modal, ...locate } = anchor;
|
|
536
|
+
return createDriverWith(modal === false ? nonModalMenuContract : menuContract, target, [locate], options);
|
|
537
|
+
}
|
|
538
|
+
//#endregion
|
|
539
|
+
//#region src/components/meter.ts
|
|
540
|
+
/** A driver for the Meter named `name` (role `meter`). */
|
|
541
|
+
function getMeter(target, anchor, options) {
|
|
542
|
+
return createDriverWith(meterContract, target, [anchor], options);
|
|
543
|
+
}
|
|
544
|
+
//#endregion
|
|
545
|
+
//#region src/components/number-input.ts
|
|
546
|
+
/** A driver for the Number Input named `name` (`role: "textbox"` under the iOS quirk). */
|
|
547
|
+
function getNumberInput(target, anchor, options) {
|
|
548
|
+
return createDriverWith(numberInputContract, target, [anchor], options);
|
|
549
|
+
}
|
|
550
|
+
//#endregion
|
|
551
|
+
//#region src/components/pagination.ts
|
|
552
|
+
/** A driver for the Pagination landmark named `name` (default name: "Pagination"). */
|
|
553
|
+
function getPagination(target, anchor, options) {
|
|
554
|
+
return createDriverWith(paginationContract, target, [anchor], options);
|
|
555
|
+
}
|
|
556
|
+
//#endregion
|
|
557
|
+
//#region src/components/pin-input.ts
|
|
558
|
+
/** A driver for the Pin Input named `name`: type, paste, fill, autofill, slots, queries. */
|
|
559
|
+
function getPinInput(target, anchor, options) {
|
|
560
|
+
return createDriverWith(pinInputContract, target, [anchor], options);
|
|
561
|
+
}
|
|
562
|
+
//#endregion
|
|
563
|
+
//#region src/components/popover.ts
|
|
564
|
+
/**
|
|
565
|
+
* A driver for the Popover opened by the trigger named `name` (a closed popover has no
|
|
566
|
+
* content to find). `modal: true` for a modal popover.
|
|
567
|
+
*/
|
|
568
|
+
function getPopover(target, anchor, options) {
|
|
569
|
+
const { modal, ...locate } = anchor;
|
|
570
|
+
return createDriverWith(modal === true ? modalPopoverContract : popoverContract, target, [locate], options);
|
|
571
|
+
}
|
|
572
|
+
//#endregion
|
|
573
|
+
//#region src/components/progress.ts
|
|
574
|
+
/**
|
|
575
|
+
* A driver for the Progress named `name` (role `progressbar`). `announcements()` lists what
|
|
576
|
+
* it announced since creation (the completion announcement).
|
|
577
|
+
*/
|
|
578
|
+
function getProgress(target, anchor, options) {
|
|
579
|
+
return createDriverWith(progressContract, target, [anchor], options);
|
|
580
|
+
}
|
|
581
|
+
//#endregion
|
|
582
|
+
//#region src/qr/decode.ts
|
|
583
|
+
var QrDecodeError = class extends Error {
|
|
584
|
+
name = "QrDecodeError";
|
|
585
|
+
};
|
|
586
|
+
const ALIGNMENT = [
|
|
587
|
+
[],
|
|
588
|
+
[],
|
|
589
|
+
[6, 18],
|
|
590
|
+
[6, 22],
|
|
591
|
+
[6, 26],
|
|
592
|
+
[6, 30],
|
|
593
|
+
[6, 34],
|
|
594
|
+
[
|
|
595
|
+
6,
|
|
596
|
+
22,
|
|
597
|
+
38
|
|
598
|
+
],
|
|
599
|
+
[
|
|
600
|
+
6,
|
|
601
|
+
24,
|
|
602
|
+
42
|
|
603
|
+
],
|
|
604
|
+
[
|
|
605
|
+
6,
|
|
606
|
+
26,
|
|
607
|
+
46
|
|
608
|
+
],
|
|
609
|
+
[
|
|
610
|
+
6,
|
|
611
|
+
28,
|
|
612
|
+
50
|
|
613
|
+
],
|
|
614
|
+
[
|
|
615
|
+
6,
|
|
616
|
+
30,
|
|
617
|
+
54
|
|
618
|
+
],
|
|
619
|
+
[
|
|
620
|
+
6,
|
|
621
|
+
32,
|
|
622
|
+
58
|
|
623
|
+
],
|
|
624
|
+
[
|
|
625
|
+
6,
|
|
626
|
+
34,
|
|
627
|
+
62
|
|
628
|
+
],
|
|
629
|
+
[
|
|
630
|
+
6,
|
|
631
|
+
26,
|
|
632
|
+
46,
|
|
633
|
+
66
|
|
634
|
+
],
|
|
635
|
+
[
|
|
636
|
+
6,
|
|
637
|
+
26,
|
|
638
|
+
48,
|
|
639
|
+
70
|
|
640
|
+
],
|
|
641
|
+
[
|
|
642
|
+
6,
|
|
643
|
+
26,
|
|
644
|
+
50,
|
|
645
|
+
74
|
|
646
|
+
],
|
|
647
|
+
[
|
|
648
|
+
6,
|
|
649
|
+
30,
|
|
650
|
+
54,
|
|
651
|
+
78
|
|
652
|
+
],
|
|
653
|
+
[
|
|
654
|
+
6,
|
|
655
|
+
30,
|
|
656
|
+
56,
|
|
657
|
+
82
|
|
658
|
+
],
|
|
659
|
+
[
|
|
660
|
+
6,
|
|
661
|
+
30,
|
|
662
|
+
58,
|
|
663
|
+
86
|
|
664
|
+
],
|
|
665
|
+
[
|
|
666
|
+
6,
|
|
667
|
+
34,
|
|
668
|
+
62,
|
|
669
|
+
90
|
|
670
|
+
],
|
|
671
|
+
[
|
|
672
|
+
6,
|
|
673
|
+
28,
|
|
674
|
+
50,
|
|
675
|
+
72,
|
|
676
|
+
94
|
|
677
|
+
],
|
|
678
|
+
[
|
|
679
|
+
6,
|
|
680
|
+
26,
|
|
681
|
+
50,
|
|
682
|
+
74,
|
|
683
|
+
98
|
|
684
|
+
],
|
|
685
|
+
[
|
|
686
|
+
6,
|
|
687
|
+
30,
|
|
688
|
+
54,
|
|
689
|
+
78,
|
|
690
|
+
102
|
|
691
|
+
],
|
|
692
|
+
[
|
|
693
|
+
6,
|
|
694
|
+
28,
|
|
695
|
+
54,
|
|
696
|
+
80,
|
|
697
|
+
106
|
|
698
|
+
],
|
|
699
|
+
[
|
|
700
|
+
6,
|
|
701
|
+
32,
|
|
702
|
+
58,
|
|
703
|
+
84,
|
|
704
|
+
110
|
|
705
|
+
],
|
|
706
|
+
[
|
|
707
|
+
6,
|
|
708
|
+
30,
|
|
709
|
+
58,
|
|
710
|
+
86,
|
|
711
|
+
114
|
|
712
|
+
],
|
|
713
|
+
[
|
|
714
|
+
6,
|
|
715
|
+
34,
|
|
716
|
+
62,
|
|
717
|
+
90,
|
|
718
|
+
118
|
|
719
|
+
],
|
|
720
|
+
[
|
|
721
|
+
6,
|
|
722
|
+
26,
|
|
723
|
+
50,
|
|
724
|
+
74,
|
|
725
|
+
98,
|
|
726
|
+
122
|
|
727
|
+
],
|
|
728
|
+
[
|
|
729
|
+
6,
|
|
730
|
+
30,
|
|
731
|
+
54,
|
|
732
|
+
78,
|
|
733
|
+
102,
|
|
734
|
+
126
|
|
735
|
+
],
|
|
736
|
+
[
|
|
737
|
+
6,
|
|
738
|
+
26,
|
|
739
|
+
52,
|
|
740
|
+
78,
|
|
741
|
+
104,
|
|
742
|
+
130
|
|
743
|
+
],
|
|
744
|
+
[
|
|
745
|
+
6,
|
|
746
|
+
30,
|
|
747
|
+
56,
|
|
748
|
+
82,
|
|
749
|
+
108,
|
|
750
|
+
134
|
|
751
|
+
],
|
|
752
|
+
[
|
|
753
|
+
6,
|
|
754
|
+
34,
|
|
755
|
+
60,
|
|
756
|
+
86,
|
|
757
|
+
112,
|
|
758
|
+
138
|
|
759
|
+
],
|
|
760
|
+
[
|
|
761
|
+
6,
|
|
762
|
+
30,
|
|
763
|
+
58,
|
|
764
|
+
86,
|
|
765
|
+
114,
|
|
766
|
+
142
|
|
767
|
+
],
|
|
768
|
+
[
|
|
769
|
+
6,
|
|
770
|
+
34,
|
|
771
|
+
62,
|
|
772
|
+
90,
|
|
773
|
+
118,
|
|
774
|
+
146
|
|
775
|
+
],
|
|
776
|
+
[
|
|
777
|
+
6,
|
|
778
|
+
30,
|
|
779
|
+
54,
|
|
780
|
+
78,
|
|
781
|
+
102,
|
|
782
|
+
126,
|
|
783
|
+
150
|
|
784
|
+
],
|
|
785
|
+
[
|
|
786
|
+
6,
|
|
787
|
+
24,
|
|
788
|
+
50,
|
|
789
|
+
76,
|
|
790
|
+
102,
|
|
791
|
+
128,
|
|
792
|
+
154
|
|
793
|
+
],
|
|
794
|
+
[
|
|
795
|
+
6,
|
|
796
|
+
28,
|
|
797
|
+
54,
|
|
798
|
+
80,
|
|
799
|
+
106,
|
|
800
|
+
132,
|
|
801
|
+
158
|
|
802
|
+
],
|
|
803
|
+
[
|
|
804
|
+
6,
|
|
805
|
+
32,
|
|
806
|
+
58,
|
|
807
|
+
84,
|
|
808
|
+
110,
|
|
809
|
+
136,
|
|
810
|
+
162
|
|
811
|
+
],
|
|
812
|
+
[
|
|
813
|
+
6,
|
|
814
|
+
26,
|
|
815
|
+
54,
|
|
816
|
+
82,
|
|
817
|
+
110,
|
|
818
|
+
138,
|
|
819
|
+
166
|
|
820
|
+
],
|
|
821
|
+
[
|
|
822
|
+
6,
|
|
823
|
+
30,
|
|
824
|
+
58,
|
|
825
|
+
86,
|
|
826
|
+
114,
|
|
827
|
+
142,
|
|
828
|
+
170
|
|
829
|
+
]
|
|
830
|
+
];
|
|
831
|
+
/** The standard's alignment centres for a version. */
|
|
832
|
+
const alignmentTable = (version) => ALIGNMENT[version] ?? [];
|
|
833
|
+
const BLOCKS = {
|
|
834
|
+
L: [
|
|
835
|
+
[],
|
|
836
|
+
[
|
|
837
|
+
7,
|
|
838
|
+
1,
|
|
839
|
+
26,
|
|
840
|
+
19
|
|
841
|
+
],
|
|
842
|
+
[
|
|
843
|
+
10,
|
|
844
|
+
1,
|
|
845
|
+
44,
|
|
846
|
+
34
|
|
847
|
+
],
|
|
848
|
+
[
|
|
849
|
+
15,
|
|
850
|
+
1,
|
|
851
|
+
70,
|
|
852
|
+
55
|
|
853
|
+
],
|
|
854
|
+
[
|
|
855
|
+
20,
|
|
856
|
+
1,
|
|
857
|
+
100,
|
|
858
|
+
80
|
|
859
|
+
],
|
|
860
|
+
[
|
|
861
|
+
26,
|
|
862
|
+
1,
|
|
863
|
+
134,
|
|
864
|
+
108
|
|
865
|
+
],
|
|
866
|
+
[
|
|
867
|
+
18,
|
|
868
|
+
2,
|
|
869
|
+
86,
|
|
870
|
+
68
|
|
871
|
+
],
|
|
872
|
+
[
|
|
873
|
+
20,
|
|
874
|
+
2,
|
|
875
|
+
98,
|
|
876
|
+
78
|
|
877
|
+
],
|
|
878
|
+
[
|
|
879
|
+
24,
|
|
880
|
+
2,
|
|
881
|
+
121,
|
|
882
|
+
97
|
|
883
|
+
],
|
|
884
|
+
[
|
|
885
|
+
30,
|
|
886
|
+
2,
|
|
887
|
+
146,
|
|
888
|
+
116
|
|
889
|
+
],
|
|
890
|
+
[
|
|
891
|
+
18,
|
|
892
|
+
2,
|
|
893
|
+
86,
|
|
894
|
+
68,
|
|
895
|
+
2,
|
|
896
|
+
87,
|
|
897
|
+
69
|
|
898
|
+
],
|
|
899
|
+
[
|
|
900
|
+
20,
|
|
901
|
+
4,
|
|
902
|
+
101,
|
|
903
|
+
81
|
|
904
|
+
],
|
|
905
|
+
[
|
|
906
|
+
24,
|
|
907
|
+
2,
|
|
908
|
+
116,
|
|
909
|
+
92,
|
|
910
|
+
2,
|
|
911
|
+
117,
|
|
912
|
+
93
|
|
913
|
+
],
|
|
914
|
+
[
|
|
915
|
+
26,
|
|
916
|
+
4,
|
|
917
|
+
133,
|
|
918
|
+
107
|
|
919
|
+
],
|
|
920
|
+
[
|
|
921
|
+
30,
|
|
922
|
+
3,
|
|
923
|
+
145,
|
|
924
|
+
115,
|
|
925
|
+
1,
|
|
926
|
+
146,
|
|
927
|
+
116
|
|
928
|
+
],
|
|
929
|
+
[
|
|
930
|
+
22,
|
|
931
|
+
5,
|
|
932
|
+
109,
|
|
933
|
+
87,
|
|
934
|
+
1,
|
|
935
|
+
110,
|
|
936
|
+
88
|
|
937
|
+
],
|
|
938
|
+
[
|
|
939
|
+
24,
|
|
940
|
+
5,
|
|
941
|
+
122,
|
|
942
|
+
98,
|
|
943
|
+
1,
|
|
944
|
+
123,
|
|
945
|
+
99
|
|
946
|
+
],
|
|
947
|
+
[
|
|
948
|
+
28,
|
|
949
|
+
1,
|
|
950
|
+
135,
|
|
951
|
+
107,
|
|
952
|
+
5,
|
|
953
|
+
136,
|
|
954
|
+
108
|
|
955
|
+
],
|
|
956
|
+
[
|
|
957
|
+
30,
|
|
958
|
+
5,
|
|
959
|
+
150,
|
|
960
|
+
120,
|
|
961
|
+
1,
|
|
962
|
+
151,
|
|
963
|
+
121
|
|
964
|
+
],
|
|
965
|
+
[
|
|
966
|
+
28,
|
|
967
|
+
3,
|
|
968
|
+
141,
|
|
969
|
+
113,
|
|
970
|
+
4,
|
|
971
|
+
142,
|
|
972
|
+
114
|
|
973
|
+
],
|
|
974
|
+
[
|
|
975
|
+
28,
|
|
976
|
+
3,
|
|
977
|
+
135,
|
|
978
|
+
107,
|
|
979
|
+
5,
|
|
980
|
+
136,
|
|
981
|
+
108
|
|
982
|
+
],
|
|
983
|
+
[
|
|
984
|
+
28,
|
|
985
|
+
4,
|
|
986
|
+
144,
|
|
987
|
+
116,
|
|
988
|
+
4,
|
|
989
|
+
145,
|
|
990
|
+
117
|
|
991
|
+
],
|
|
992
|
+
[
|
|
993
|
+
28,
|
|
994
|
+
2,
|
|
995
|
+
139,
|
|
996
|
+
111,
|
|
997
|
+
7,
|
|
998
|
+
140,
|
|
999
|
+
112
|
|
1000
|
+
],
|
|
1001
|
+
[
|
|
1002
|
+
30,
|
|
1003
|
+
4,
|
|
1004
|
+
151,
|
|
1005
|
+
121,
|
|
1006
|
+
5,
|
|
1007
|
+
152,
|
|
1008
|
+
122
|
|
1009
|
+
],
|
|
1010
|
+
[
|
|
1011
|
+
30,
|
|
1012
|
+
6,
|
|
1013
|
+
147,
|
|
1014
|
+
117,
|
|
1015
|
+
4,
|
|
1016
|
+
148,
|
|
1017
|
+
118
|
|
1018
|
+
],
|
|
1019
|
+
[
|
|
1020
|
+
26,
|
|
1021
|
+
8,
|
|
1022
|
+
132,
|
|
1023
|
+
106,
|
|
1024
|
+
4,
|
|
1025
|
+
133,
|
|
1026
|
+
107
|
|
1027
|
+
],
|
|
1028
|
+
[
|
|
1029
|
+
28,
|
|
1030
|
+
10,
|
|
1031
|
+
142,
|
|
1032
|
+
114,
|
|
1033
|
+
2,
|
|
1034
|
+
143,
|
|
1035
|
+
115
|
|
1036
|
+
],
|
|
1037
|
+
[
|
|
1038
|
+
30,
|
|
1039
|
+
8,
|
|
1040
|
+
152,
|
|
1041
|
+
122,
|
|
1042
|
+
4,
|
|
1043
|
+
153,
|
|
1044
|
+
123
|
|
1045
|
+
],
|
|
1046
|
+
[
|
|
1047
|
+
30,
|
|
1048
|
+
3,
|
|
1049
|
+
147,
|
|
1050
|
+
117,
|
|
1051
|
+
10,
|
|
1052
|
+
148,
|
|
1053
|
+
118
|
|
1054
|
+
],
|
|
1055
|
+
[
|
|
1056
|
+
30,
|
|
1057
|
+
7,
|
|
1058
|
+
146,
|
|
1059
|
+
116,
|
|
1060
|
+
7,
|
|
1061
|
+
147,
|
|
1062
|
+
117
|
|
1063
|
+
],
|
|
1064
|
+
[
|
|
1065
|
+
30,
|
|
1066
|
+
5,
|
|
1067
|
+
145,
|
|
1068
|
+
115,
|
|
1069
|
+
10,
|
|
1070
|
+
146,
|
|
1071
|
+
116
|
|
1072
|
+
],
|
|
1073
|
+
[
|
|
1074
|
+
30,
|
|
1075
|
+
13,
|
|
1076
|
+
145,
|
|
1077
|
+
115,
|
|
1078
|
+
3,
|
|
1079
|
+
146,
|
|
1080
|
+
116
|
|
1081
|
+
],
|
|
1082
|
+
[
|
|
1083
|
+
30,
|
|
1084
|
+
17,
|
|
1085
|
+
145,
|
|
1086
|
+
115
|
|
1087
|
+
],
|
|
1088
|
+
[
|
|
1089
|
+
30,
|
|
1090
|
+
17,
|
|
1091
|
+
145,
|
|
1092
|
+
115,
|
|
1093
|
+
1,
|
|
1094
|
+
146,
|
|
1095
|
+
116
|
|
1096
|
+
],
|
|
1097
|
+
[
|
|
1098
|
+
30,
|
|
1099
|
+
13,
|
|
1100
|
+
145,
|
|
1101
|
+
115,
|
|
1102
|
+
6,
|
|
1103
|
+
146,
|
|
1104
|
+
116
|
|
1105
|
+
],
|
|
1106
|
+
[
|
|
1107
|
+
30,
|
|
1108
|
+
12,
|
|
1109
|
+
151,
|
|
1110
|
+
121,
|
|
1111
|
+
7,
|
|
1112
|
+
152,
|
|
1113
|
+
122
|
|
1114
|
+
],
|
|
1115
|
+
[
|
|
1116
|
+
30,
|
|
1117
|
+
6,
|
|
1118
|
+
151,
|
|
1119
|
+
121,
|
|
1120
|
+
14,
|
|
1121
|
+
152,
|
|
1122
|
+
122
|
|
1123
|
+
],
|
|
1124
|
+
[
|
|
1125
|
+
30,
|
|
1126
|
+
17,
|
|
1127
|
+
152,
|
|
1128
|
+
122,
|
|
1129
|
+
4,
|
|
1130
|
+
153,
|
|
1131
|
+
123
|
|
1132
|
+
],
|
|
1133
|
+
[
|
|
1134
|
+
30,
|
|
1135
|
+
4,
|
|
1136
|
+
152,
|
|
1137
|
+
122,
|
|
1138
|
+
18,
|
|
1139
|
+
153,
|
|
1140
|
+
123
|
|
1141
|
+
],
|
|
1142
|
+
[
|
|
1143
|
+
30,
|
|
1144
|
+
20,
|
|
1145
|
+
147,
|
|
1146
|
+
117,
|
|
1147
|
+
4,
|
|
1148
|
+
148,
|
|
1149
|
+
118
|
|
1150
|
+
],
|
|
1151
|
+
[
|
|
1152
|
+
30,
|
|
1153
|
+
19,
|
|
1154
|
+
148,
|
|
1155
|
+
118,
|
|
1156
|
+
6,
|
|
1157
|
+
149,
|
|
1158
|
+
119
|
|
1159
|
+
]
|
|
1160
|
+
],
|
|
1161
|
+
M: [
|
|
1162
|
+
[],
|
|
1163
|
+
[
|
|
1164
|
+
10,
|
|
1165
|
+
1,
|
|
1166
|
+
26,
|
|
1167
|
+
16
|
|
1168
|
+
],
|
|
1169
|
+
[
|
|
1170
|
+
16,
|
|
1171
|
+
1,
|
|
1172
|
+
44,
|
|
1173
|
+
28
|
|
1174
|
+
],
|
|
1175
|
+
[
|
|
1176
|
+
26,
|
|
1177
|
+
1,
|
|
1178
|
+
70,
|
|
1179
|
+
44
|
|
1180
|
+
],
|
|
1181
|
+
[
|
|
1182
|
+
18,
|
|
1183
|
+
2,
|
|
1184
|
+
50,
|
|
1185
|
+
32
|
|
1186
|
+
],
|
|
1187
|
+
[
|
|
1188
|
+
24,
|
|
1189
|
+
2,
|
|
1190
|
+
67,
|
|
1191
|
+
43
|
|
1192
|
+
],
|
|
1193
|
+
[
|
|
1194
|
+
16,
|
|
1195
|
+
4,
|
|
1196
|
+
43,
|
|
1197
|
+
27
|
|
1198
|
+
],
|
|
1199
|
+
[
|
|
1200
|
+
18,
|
|
1201
|
+
4,
|
|
1202
|
+
49,
|
|
1203
|
+
31
|
|
1204
|
+
],
|
|
1205
|
+
[
|
|
1206
|
+
22,
|
|
1207
|
+
2,
|
|
1208
|
+
60,
|
|
1209
|
+
38,
|
|
1210
|
+
2,
|
|
1211
|
+
61,
|
|
1212
|
+
39
|
|
1213
|
+
],
|
|
1214
|
+
[
|
|
1215
|
+
22,
|
|
1216
|
+
3,
|
|
1217
|
+
58,
|
|
1218
|
+
36,
|
|
1219
|
+
2,
|
|
1220
|
+
59,
|
|
1221
|
+
37
|
|
1222
|
+
],
|
|
1223
|
+
[
|
|
1224
|
+
26,
|
|
1225
|
+
4,
|
|
1226
|
+
69,
|
|
1227
|
+
43,
|
|
1228
|
+
1,
|
|
1229
|
+
70,
|
|
1230
|
+
44
|
|
1231
|
+
],
|
|
1232
|
+
[
|
|
1233
|
+
30,
|
|
1234
|
+
1,
|
|
1235
|
+
80,
|
|
1236
|
+
50,
|
|
1237
|
+
4,
|
|
1238
|
+
81,
|
|
1239
|
+
51
|
|
1240
|
+
],
|
|
1241
|
+
[
|
|
1242
|
+
22,
|
|
1243
|
+
6,
|
|
1244
|
+
58,
|
|
1245
|
+
36,
|
|
1246
|
+
2,
|
|
1247
|
+
59,
|
|
1248
|
+
37
|
|
1249
|
+
],
|
|
1250
|
+
[
|
|
1251
|
+
22,
|
|
1252
|
+
8,
|
|
1253
|
+
59,
|
|
1254
|
+
37,
|
|
1255
|
+
1,
|
|
1256
|
+
60,
|
|
1257
|
+
38
|
|
1258
|
+
],
|
|
1259
|
+
[
|
|
1260
|
+
24,
|
|
1261
|
+
4,
|
|
1262
|
+
64,
|
|
1263
|
+
40,
|
|
1264
|
+
5,
|
|
1265
|
+
65,
|
|
1266
|
+
41
|
|
1267
|
+
],
|
|
1268
|
+
[
|
|
1269
|
+
24,
|
|
1270
|
+
5,
|
|
1271
|
+
65,
|
|
1272
|
+
41,
|
|
1273
|
+
5,
|
|
1274
|
+
66,
|
|
1275
|
+
42
|
|
1276
|
+
],
|
|
1277
|
+
[
|
|
1278
|
+
28,
|
|
1279
|
+
7,
|
|
1280
|
+
73,
|
|
1281
|
+
45,
|
|
1282
|
+
3,
|
|
1283
|
+
74,
|
|
1284
|
+
46
|
|
1285
|
+
],
|
|
1286
|
+
[
|
|
1287
|
+
28,
|
|
1288
|
+
10,
|
|
1289
|
+
74,
|
|
1290
|
+
46,
|
|
1291
|
+
1,
|
|
1292
|
+
75,
|
|
1293
|
+
47
|
|
1294
|
+
],
|
|
1295
|
+
[
|
|
1296
|
+
26,
|
|
1297
|
+
9,
|
|
1298
|
+
69,
|
|
1299
|
+
43,
|
|
1300
|
+
4,
|
|
1301
|
+
70,
|
|
1302
|
+
44
|
|
1303
|
+
],
|
|
1304
|
+
[
|
|
1305
|
+
26,
|
|
1306
|
+
3,
|
|
1307
|
+
70,
|
|
1308
|
+
44,
|
|
1309
|
+
11,
|
|
1310
|
+
71,
|
|
1311
|
+
45
|
|
1312
|
+
],
|
|
1313
|
+
[
|
|
1314
|
+
26,
|
|
1315
|
+
3,
|
|
1316
|
+
67,
|
|
1317
|
+
41,
|
|
1318
|
+
13,
|
|
1319
|
+
68,
|
|
1320
|
+
42
|
|
1321
|
+
],
|
|
1322
|
+
[
|
|
1323
|
+
26,
|
|
1324
|
+
17,
|
|
1325
|
+
68,
|
|
1326
|
+
42
|
|
1327
|
+
],
|
|
1328
|
+
[
|
|
1329
|
+
28,
|
|
1330
|
+
17,
|
|
1331
|
+
74,
|
|
1332
|
+
46
|
|
1333
|
+
],
|
|
1334
|
+
[
|
|
1335
|
+
28,
|
|
1336
|
+
4,
|
|
1337
|
+
75,
|
|
1338
|
+
47,
|
|
1339
|
+
14,
|
|
1340
|
+
76,
|
|
1341
|
+
48
|
|
1342
|
+
],
|
|
1343
|
+
[
|
|
1344
|
+
28,
|
|
1345
|
+
6,
|
|
1346
|
+
73,
|
|
1347
|
+
45,
|
|
1348
|
+
14,
|
|
1349
|
+
74,
|
|
1350
|
+
46
|
|
1351
|
+
],
|
|
1352
|
+
[
|
|
1353
|
+
28,
|
|
1354
|
+
8,
|
|
1355
|
+
75,
|
|
1356
|
+
47,
|
|
1357
|
+
13,
|
|
1358
|
+
76,
|
|
1359
|
+
48
|
|
1360
|
+
],
|
|
1361
|
+
[
|
|
1362
|
+
28,
|
|
1363
|
+
19,
|
|
1364
|
+
74,
|
|
1365
|
+
46,
|
|
1366
|
+
4,
|
|
1367
|
+
75,
|
|
1368
|
+
47
|
|
1369
|
+
],
|
|
1370
|
+
[
|
|
1371
|
+
28,
|
|
1372
|
+
22,
|
|
1373
|
+
73,
|
|
1374
|
+
45,
|
|
1375
|
+
3,
|
|
1376
|
+
74,
|
|
1377
|
+
46
|
|
1378
|
+
],
|
|
1379
|
+
[
|
|
1380
|
+
28,
|
|
1381
|
+
3,
|
|
1382
|
+
73,
|
|
1383
|
+
45,
|
|
1384
|
+
23,
|
|
1385
|
+
74,
|
|
1386
|
+
46
|
|
1387
|
+
],
|
|
1388
|
+
[
|
|
1389
|
+
28,
|
|
1390
|
+
21,
|
|
1391
|
+
73,
|
|
1392
|
+
45,
|
|
1393
|
+
7,
|
|
1394
|
+
74,
|
|
1395
|
+
46
|
|
1396
|
+
],
|
|
1397
|
+
[
|
|
1398
|
+
28,
|
|
1399
|
+
19,
|
|
1400
|
+
75,
|
|
1401
|
+
47,
|
|
1402
|
+
10,
|
|
1403
|
+
76,
|
|
1404
|
+
48
|
|
1405
|
+
],
|
|
1406
|
+
[
|
|
1407
|
+
28,
|
|
1408
|
+
2,
|
|
1409
|
+
74,
|
|
1410
|
+
46,
|
|
1411
|
+
29,
|
|
1412
|
+
75,
|
|
1413
|
+
47
|
|
1414
|
+
],
|
|
1415
|
+
[
|
|
1416
|
+
28,
|
|
1417
|
+
10,
|
|
1418
|
+
74,
|
|
1419
|
+
46,
|
|
1420
|
+
23,
|
|
1421
|
+
75,
|
|
1422
|
+
47
|
|
1423
|
+
],
|
|
1424
|
+
[
|
|
1425
|
+
28,
|
|
1426
|
+
14,
|
|
1427
|
+
74,
|
|
1428
|
+
46,
|
|
1429
|
+
21,
|
|
1430
|
+
75,
|
|
1431
|
+
47
|
|
1432
|
+
],
|
|
1433
|
+
[
|
|
1434
|
+
28,
|
|
1435
|
+
14,
|
|
1436
|
+
74,
|
|
1437
|
+
46,
|
|
1438
|
+
23,
|
|
1439
|
+
75,
|
|
1440
|
+
47
|
|
1441
|
+
],
|
|
1442
|
+
[
|
|
1443
|
+
28,
|
|
1444
|
+
12,
|
|
1445
|
+
75,
|
|
1446
|
+
47,
|
|
1447
|
+
26,
|
|
1448
|
+
76,
|
|
1449
|
+
48
|
|
1450
|
+
],
|
|
1451
|
+
[
|
|
1452
|
+
28,
|
|
1453
|
+
6,
|
|
1454
|
+
75,
|
|
1455
|
+
47,
|
|
1456
|
+
34,
|
|
1457
|
+
76,
|
|
1458
|
+
48
|
|
1459
|
+
],
|
|
1460
|
+
[
|
|
1461
|
+
28,
|
|
1462
|
+
29,
|
|
1463
|
+
74,
|
|
1464
|
+
46,
|
|
1465
|
+
14,
|
|
1466
|
+
75,
|
|
1467
|
+
47
|
|
1468
|
+
],
|
|
1469
|
+
[
|
|
1470
|
+
28,
|
|
1471
|
+
13,
|
|
1472
|
+
74,
|
|
1473
|
+
46,
|
|
1474
|
+
32,
|
|
1475
|
+
75,
|
|
1476
|
+
47
|
|
1477
|
+
],
|
|
1478
|
+
[
|
|
1479
|
+
28,
|
|
1480
|
+
40,
|
|
1481
|
+
75,
|
|
1482
|
+
47,
|
|
1483
|
+
7,
|
|
1484
|
+
76,
|
|
1485
|
+
48
|
|
1486
|
+
],
|
|
1487
|
+
[
|
|
1488
|
+
28,
|
|
1489
|
+
18,
|
|
1490
|
+
75,
|
|
1491
|
+
47,
|
|
1492
|
+
31,
|
|
1493
|
+
76,
|
|
1494
|
+
48
|
|
1495
|
+
]
|
|
1496
|
+
],
|
|
1497
|
+
Q: [
|
|
1498
|
+
[],
|
|
1499
|
+
[
|
|
1500
|
+
13,
|
|
1501
|
+
1,
|
|
1502
|
+
26,
|
|
1503
|
+
13
|
|
1504
|
+
],
|
|
1505
|
+
[
|
|
1506
|
+
22,
|
|
1507
|
+
1,
|
|
1508
|
+
44,
|
|
1509
|
+
22
|
|
1510
|
+
],
|
|
1511
|
+
[
|
|
1512
|
+
18,
|
|
1513
|
+
2,
|
|
1514
|
+
35,
|
|
1515
|
+
17
|
|
1516
|
+
],
|
|
1517
|
+
[
|
|
1518
|
+
26,
|
|
1519
|
+
2,
|
|
1520
|
+
50,
|
|
1521
|
+
24
|
|
1522
|
+
],
|
|
1523
|
+
[
|
|
1524
|
+
18,
|
|
1525
|
+
2,
|
|
1526
|
+
33,
|
|
1527
|
+
15,
|
|
1528
|
+
2,
|
|
1529
|
+
34,
|
|
1530
|
+
16
|
|
1531
|
+
],
|
|
1532
|
+
[
|
|
1533
|
+
24,
|
|
1534
|
+
4,
|
|
1535
|
+
43,
|
|
1536
|
+
19
|
|
1537
|
+
],
|
|
1538
|
+
[
|
|
1539
|
+
18,
|
|
1540
|
+
2,
|
|
1541
|
+
32,
|
|
1542
|
+
14,
|
|
1543
|
+
4,
|
|
1544
|
+
33,
|
|
1545
|
+
15
|
|
1546
|
+
],
|
|
1547
|
+
[
|
|
1548
|
+
22,
|
|
1549
|
+
4,
|
|
1550
|
+
40,
|
|
1551
|
+
18,
|
|
1552
|
+
2,
|
|
1553
|
+
41,
|
|
1554
|
+
19
|
|
1555
|
+
],
|
|
1556
|
+
[
|
|
1557
|
+
20,
|
|
1558
|
+
4,
|
|
1559
|
+
36,
|
|
1560
|
+
16,
|
|
1561
|
+
4,
|
|
1562
|
+
37,
|
|
1563
|
+
17
|
|
1564
|
+
],
|
|
1565
|
+
[
|
|
1566
|
+
24,
|
|
1567
|
+
6,
|
|
1568
|
+
43,
|
|
1569
|
+
19,
|
|
1570
|
+
2,
|
|
1571
|
+
44,
|
|
1572
|
+
20
|
|
1573
|
+
],
|
|
1574
|
+
[
|
|
1575
|
+
28,
|
|
1576
|
+
4,
|
|
1577
|
+
50,
|
|
1578
|
+
22,
|
|
1579
|
+
4,
|
|
1580
|
+
51,
|
|
1581
|
+
23
|
|
1582
|
+
],
|
|
1583
|
+
[
|
|
1584
|
+
26,
|
|
1585
|
+
4,
|
|
1586
|
+
46,
|
|
1587
|
+
20,
|
|
1588
|
+
6,
|
|
1589
|
+
47,
|
|
1590
|
+
21
|
|
1591
|
+
],
|
|
1592
|
+
[
|
|
1593
|
+
24,
|
|
1594
|
+
8,
|
|
1595
|
+
44,
|
|
1596
|
+
20,
|
|
1597
|
+
4,
|
|
1598
|
+
45,
|
|
1599
|
+
21
|
|
1600
|
+
],
|
|
1601
|
+
[
|
|
1602
|
+
20,
|
|
1603
|
+
11,
|
|
1604
|
+
36,
|
|
1605
|
+
16,
|
|
1606
|
+
5,
|
|
1607
|
+
37,
|
|
1608
|
+
17
|
|
1609
|
+
],
|
|
1610
|
+
[
|
|
1611
|
+
30,
|
|
1612
|
+
5,
|
|
1613
|
+
54,
|
|
1614
|
+
24,
|
|
1615
|
+
7,
|
|
1616
|
+
55,
|
|
1617
|
+
25
|
|
1618
|
+
],
|
|
1619
|
+
[
|
|
1620
|
+
24,
|
|
1621
|
+
15,
|
|
1622
|
+
43,
|
|
1623
|
+
19,
|
|
1624
|
+
2,
|
|
1625
|
+
44,
|
|
1626
|
+
20
|
|
1627
|
+
],
|
|
1628
|
+
[
|
|
1629
|
+
28,
|
|
1630
|
+
1,
|
|
1631
|
+
50,
|
|
1632
|
+
22,
|
|
1633
|
+
15,
|
|
1634
|
+
51,
|
|
1635
|
+
23
|
|
1636
|
+
],
|
|
1637
|
+
[
|
|
1638
|
+
28,
|
|
1639
|
+
17,
|
|
1640
|
+
50,
|
|
1641
|
+
22,
|
|
1642
|
+
1,
|
|
1643
|
+
51,
|
|
1644
|
+
23
|
|
1645
|
+
],
|
|
1646
|
+
[
|
|
1647
|
+
26,
|
|
1648
|
+
17,
|
|
1649
|
+
47,
|
|
1650
|
+
21,
|
|
1651
|
+
4,
|
|
1652
|
+
48,
|
|
1653
|
+
22
|
|
1654
|
+
],
|
|
1655
|
+
[
|
|
1656
|
+
30,
|
|
1657
|
+
15,
|
|
1658
|
+
54,
|
|
1659
|
+
24,
|
|
1660
|
+
5,
|
|
1661
|
+
55,
|
|
1662
|
+
25
|
|
1663
|
+
],
|
|
1664
|
+
[
|
|
1665
|
+
28,
|
|
1666
|
+
17,
|
|
1667
|
+
50,
|
|
1668
|
+
22,
|
|
1669
|
+
6,
|
|
1670
|
+
51,
|
|
1671
|
+
23
|
|
1672
|
+
],
|
|
1673
|
+
[
|
|
1674
|
+
30,
|
|
1675
|
+
7,
|
|
1676
|
+
54,
|
|
1677
|
+
24,
|
|
1678
|
+
16,
|
|
1679
|
+
55,
|
|
1680
|
+
25
|
|
1681
|
+
],
|
|
1682
|
+
[
|
|
1683
|
+
30,
|
|
1684
|
+
11,
|
|
1685
|
+
54,
|
|
1686
|
+
24,
|
|
1687
|
+
14,
|
|
1688
|
+
55,
|
|
1689
|
+
25
|
|
1690
|
+
],
|
|
1691
|
+
[
|
|
1692
|
+
30,
|
|
1693
|
+
11,
|
|
1694
|
+
54,
|
|
1695
|
+
24,
|
|
1696
|
+
16,
|
|
1697
|
+
55,
|
|
1698
|
+
25
|
|
1699
|
+
],
|
|
1700
|
+
[
|
|
1701
|
+
30,
|
|
1702
|
+
7,
|
|
1703
|
+
54,
|
|
1704
|
+
24,
|
|
1705
|
+
22,
|
|
1706
|
+
55,
|
|
1707
|
+
25
|
|
1708
|
+
],
|
|
1709
|
+
[
|
|
1710
|
+
28,
|
|
1711
|
+
28,
|
|
1712
|
+
50,
|
|
1713
|
+
22,
|
|
1714
|
+
6,
|
|
1715
|
+
51,
|
|
1716
|
+
23
|
|
1717
|
+
],
|
|
1718
|
+
[
|
|
1719
|
+
30,
|
|
1720
|
+
8,
|
|
1721
|
+
53,
|
|
1722
|
+
23,
|
|
1723
|
+
26,
|
|
1724
|
+
54,
|
|
1725
|
+
24
|
|
1726
|
+
],
|
|
1727
|
+
[
|
|
1728
|
+
30,
|
|
1729
|
+
4,
|
|
1730
|
+
54,
|
|
1731
|
+
24,
|
|
1732
|
+
31,
|
|
1733
|
+
55,
|
|
1734
|
+
25
|
|
1735
|
+
],
|
|
1736
|
+
[
|
|
1737
|
+
30,
|
|
1738
|
+
1,
|
|
1739
|
+
53,
|
|
1740
|
+
23,
|
|
1741
|
+
37,
|
|
1742
|
+
54,
|
|
1743
|
+
24
|
|
1744
|
+
],
|
|
1745
|
+
[
|
|
1746
|
+
30,
|
|
1747
|
+
15,
|
|
1748
|
+
54,
|
|
1749
|
+
24,
|
|
1750
|
+
25,
|
|
1751
|
+
55,
|
|
1752
|
+
25
|
|
1753
|
+
],
|
|
1754
|
+
[
|
|
1755
|
+
30,
|
|
1756
|
+
42,
|
|
1757
|
+
54,
|
|
1758
|
+
24,
|
|
1759
|
+
1,
|
|
1760
|
+
55,
|
|
1761
|
+
25
|
|
1762
|
+
],
|
|
1763
|
+
[
|
|
1764
|
+
30,
|
|
1765
|
+
10,
|
|
1766
|
+
54,
|
|
1767
|
+
24,
|
|
1768
|
+
35,
|
|
1769
|
+
55,
|
|
1770
|
+
25
|
|
1771
|
+
],
|
|
1772
|
+
[
|
|
1773
|
+
30,
|
|
1774
|
+
29,
|
|
1775
|
+
54,
|
|
1776
|
+
24,
|
|
1777
|
+
19,
|
|
1778
|
+
55,
|
|
1779
|
+
25
|
|
1780
|
+
],
|
|
1781
|
+
[
|
|
1782
|
+
30,
|
|
1783
|
+
44,
|
|
1784
|
+
54,
|
|
1785
|
+
24,
|
|
1786
|
+
7,
|
|
1787
|
+
55,
|
|
1788
|
+
25
|
|
1789
|
+
],
|
|
1790
|
+
[
|
|
1791
|
+
30,
|
|
1792
|
+
39,
|
|
1793
|
+
54,
|
|
1794
|
+
24,
|
|
1795
|
+
14,
|
|
1796
|
+
55,
|
|
1797
|
+
25
|
|
1798
|
+
],
|
|
1799
|
+
[
|
|
1800
|
+
30,
|
|
1801
|
+
46,
|
|
1802
|
+
54,
|
|
1803
|
+
24,
|
|
1804
|
+
10,
|
|
1805
|
+
55,
|
|
1806
|
+
25
|
|
1807
|
+
],
|
|
1808
|
+
[
|
|
1809
|
+
30,
|
|
1810
|
+
49,
|
|
1811
|
+
54,
|
|
1812
|
+
24,
|
|
1813
|
+
10,
|
|
1814
|
+
55,
|
|
1815
|
+
25
|
|
1816
|
+
],
|
|
1817
|
+
[
|
|
1818
|
+
30,
|
|
1819
|
+
48,
|
|
1820
|
+
54,
|
|
1821
|
+
24,
|
|
1822
|
+
14,
|
|
1823
|
+
55,
|
|
1824
|
+
25
|
|
1825
|
+
],
|
|
1826
|
+
[
|
|
1827
|
+
30,
|
|
1828
|
+
43,
|
|
1829
|
+
54,
|
|
1830
|
+
24,
|
|
1831
|
+
22,
|
|
1832
|
+
55,
|
|
1833
|
+
25
|
|
1834
|
+
],
|
|
1835
|
+
[
|
|
1836
|
+
30,
|
|
1837
|
+
34,
|
|
1838
|
+
54,
|
|
1839
|
+
24,
|
|
1840
|
+
34,
|
|
1841
|
+
55,
|
|
1842
|
+
25
|
|
1843
|
+
]
|
|
1844
|
+
],
|
|
1845
|
+
H: [
|
|
1846
|
+
[],
|
|
1847
|
+
[
|
|
1848
|
+
17,
|
|
1849
|
+
1,
|
|
1850
|
+
26,
|
|
1851
|
+
9
|
|
1852
|
+
],
|
|
1853
|
+
[
|
|
1854
|
+
28,
|
|
1855
|
+
1,
|
|
1856
|
+
44,
|
|
1857
|
+
16
|
|
1858
|
+
],
|
|
1859
|
+
[
|
|
1860
|
+
22,
|
|
1861
|
+
2,
|
|
1862
|
+
35,
|
|
1863
|
+
13
|
|
1864
|
+
],
|
|
1865
|
+
[
|
|
1866
|
+
16,
|
|
1867
|
+
4,
|
|
1868
|
+
25,
|
|
1869
|
+
9
|
|
1870
|
+
],
|
|
1871
|
+
[
|
|
1872
|
+
22,
|
|
1873
|
+
2,
|
|
1874
|
+
33,
|
|
1875
|
+
11,
|
|
1876
|
+
2,
|
|
1877
|
+
34,
|
|
1878
|
+
12
|
|
1879
|
+
],
|
|
1880
|
+
[
|
|
1881
|
+
28,
|
|
1882
|
+
4,
|
|
1883
|
+
43,
|
|
1884
|
+
15
|
|
1885
|
+
],
|
|
1886
|
+
[
|
|
1887
|
+
26,
|
|
1888
|
+
4,
|
|
1889
|
+
39,
|
|
1890
|
+
13,
|
|
1891
|
+
1,
|
|
1892
|
+
40,
|
|
1893
|
+
14
|
|
1894
|
+
],
|
|
1895
|
+
[
|
|
1896
|
+
26,
|
|
1897
|
+
4,
|
|
1898
|
+
40,
|
|
1899
|
+
14,
|
|
1900
|
+
2,
|
|
1901
|
+
41,
|
|
1902
|
+
15
|
|
1903
|
+
],
|
|
1904
|
+
[
|
|
1905
|
+
24,
|
|
1906
|
+
4,
|
|
1907
|
+
36,
|
|
1908
|
+
12,
|
|
1909
|
+
4,
|
|
1910
|
+
37,
|
|
1911
|
+
13
|
|
1912
|
+
],
|
|
1913
|
+
[
|
|
1914
|
+
28,
|
|
1915
|
+
6,
|
|
1916
|
+
43,
|
|
1917
|
+
15,
|
|
1918
|
+
2,
|
|
1919
|
+
44,
|
|
1920
|
+
16
|
|
1921
|
+
],
|
|
1922
|
+
[
|
|
1923
|
+
24,
|
|
1924
|
+
3,
|
|
1925
|
+
36,
|
|
1926
|
+
12,
|
|
1927
|
+
8,
|
|
1928
|
+
37,
|
|
1929
|
+
13
|
|
1930
|
+
],
|
|
1931
|
+
[
|
|
1932
|
+
28,
|
|
1933
|
+
7,
|
|
1934
|
+
42,
|
|
1935
|
+
14,
|
|
1936
|
+
4,
|
|
1937
|
+
43,
|
|
1938
|
+
15
|
|
1939
|
+
],
|
|
1940
|
+
[
|
|
1941
|
+
22,
|
|
1942
|
+
12,
|
|
1943
|
+
33,
|
|
1944
|
+
11,
|
|
1945
|
+
4,
|
|
1946
|
+
34,
|
|
1947
|
+
12
|
|
1948
|
+
],
|
|
1949
|
+
[
|
|
1950
|
+
24,
|
|
1951
|
+
11,
|
|
1952
|
+
36,
|
|
1953
|
+
12,
|
|
1954
|
+
5,
|
|
1955
|
+
37,
|
|
1956
|
+
13
|
|
1957
|
+
],
|
|
1958
|
+
[
|
|
1959
|
+
24,
|
|
1960
|
+
11,
|
|
1961
|
+
36,
|
|
1962
|
+
12,
|
|
1963
|
+
7,
|
|
1964
|
+
37,
|
|
1965
|
+
13
|
|
1966
|
+
],
|
|
1967
|
+
[
|
|
1968
|
+
30,
|
|
1969
|
+
3,
|
|
1970
|
+
45,
|
|
1971
|
+
15,
|
|
1972
|
+
13,
|
|
1973
|
+
46,
|
|
1974
|
+
16
|
|
1975
|
+
],
|
|
1976
|
+
[
|
|
1977
|
+
28,
|
|
1978
|
+
2,
|
|
1979
|
+
42,
|
|
1980
|
+
14,
|
|
1981
|
+
17,
|
|
1982
|
+
43,
|
|
1983
|
+
15
|
|
1984
|
+
],
|
|
1985
|
+
[
|
|
1986
|
+
28,
|
|
1987
|
+
2,
|
|
1988
|
+
42,
|
|
1989
|
+
14,
|
|
1990
|
+
19,
|
|
1991
|
+
43,
|
|
1992
|
+
15
|
|
1993
|
+
],
|
|
1994
|
+
[
|
|
1995
|
+
26,
|
|
1996
|
+
9,
|
|
1997
|
+
39,
|
|
1998
|
+
13,
|
|
1999
|
+
16,
|
|
2000
|
+
40,
|
|
2001
|
+
14
|
|
2002
|
+
],
|
|
2003
|
+
[
|
|
2004
|
+
28,
|
|
2005
|
+
15,
|
|
2006
|
+
43,
|
|
2007
|
+
15,
|
|
2008
|
+
10,
|
|
2009
|
+
44,
|
|
2010
|
+
16
|
|
2011
|
+
],
|
|
2012
|
+
[
|
|
2013
|
+
30,
|
|
2014
|
+
19,
|
|
2015
|
+
46,
|
|
2016
|
+
16,
|
|
2017
|
+
6,
|
|
2018
|
+
47,
|
|
2019
|
+
17
|
|
2020
|
+
],
|
|
2021
|
+
[
|
|
2022
|
+
24,
|
|
2023
|
+
34,
|
|
2024
|
+
37,
|
|
2025
|
+
13
|
|
2026
|
+
],
|
|
2027
|
+
[
|
|
2028
|
+
30,
|
|
2029
|
+
16,
|
|
2030
|
+
45,
|
|
2031
|
+
15,
|
|
2032
|
+
14,
|
|
2033
|
+
46,
|
|
2034
|
+
16
|
|
2035
|
+
],
|
|
2036
|
+
[
|
|
2037
|
+
30,
|
|
2038
|
+
30,
|
|
2039
|
+
46,
|
|
2040
|
+
16,
|
|
2041
|
+
2,
|
|
2042
|
+
47,
|
|
2043
|
+
17
|
|
2044
|
+
],
|
|
2045
|
+
[
|
|
2046
|
+
30,
|
|
2047
|
+
22,
|
|
2048
|
+
45,
|
|
2049
|
+
15,
|
|
2050
|
+
13,
|
|
2051
|
+
46,
|
|
2052
|
+
16
|
|
2053
|
+
],
|
|
2054
|
+
[
|
|
2055
|
+
30,
|
|
2056
|
+
33,
|
|
2057
|
+
46,
|
|
2058
|
+
16,
|
|
2059
|
+
4,
|
|
2060
|
+
47,
|
|
2061
|
+
17
|
|
2062
|
+
],
|
|
2063
|
+
[
|
|
2064
|
+
30,
|
|
2065
|
+
12,
|
|
2066
|
+
45,
|
|
2067
|
+
15,
|
|
2068
|
+
28,
|
|
2069
|
+
46,
|
|
2070
|
+
16
|
|
2071
|
+
],
|
|
2072
|
+
[
|
|
2073
|
+
30,
|
|
2074
|
+
11,
|
|
2075
|
+
45,
|
|
2076
|
+
15,
|
|
2077
|
+
31,
|
|
2078
|
+
46,
|
|
2079
|
+
16
|
|
2080
|
+
],
|
|
2081
|
+
[
|
|
2082
|
+
30,
|
|
2083
|
+
19,
|
|
2084
|
+
45,
|
|
2085
|
+
15,
|
|
2086
|
+
26,
|
|
2087
|
+
46,
|
|
2088
|
+
16
|
|
2089
|
+
],
|
|
2090
|
+
[
|
|
2091
|
+
30,
|
|
2092
|
+
23,
|
|
2093
|
+
45,
|
|
2094
|
+
15,
|
|
2095
|
+
25,
|
|
2096
|
+
46,
|
|
2097
|
+
16
|
|
2098
|
+
],
|
|
2099
|
+
[
|
|
2100
|
+
30,
|
|
2101
|
+
23,
|
|
2102
|
+
45,
|
|
2103
|
+
15,
|
|
2104
|
+
28,
|
|
2105
|
+
46,
|
|
2106
|
+
16
|
|
2107
|
+
],
|
|
2108
|
+
[
|
|
2109
|
+
30,
|
|
2110
|
+
19,
|
|
2111
|
+
45,
|
|
2112
|
+
15,
|
|
2113
|
+
35,
|
|
2114
|
+
46,
|
|
2115
|
+
16
|
|
2116
|
+
],
|
|
2117
|
+
[
|
|
2118
|
+
30,
|
|
2119
|
+
11,
|
|
2120
|
+
45,
|
|
2121
|
+
15,
|
|
2122
|
+
46,
|
|
2123
|
+
46,
|
|
2124
|
+
16
|
|
2125
|
+
],
|
|
2126
|
+
[
|
|
2127
|
+
30,
|
|
2128
|
+
59,
|
|
2129
|
+
46,
|
|
2130
|
+
16,
|
|
2131
|
+
1,
|
|
2132
|
+
47,
|
|
2133
|
+
17
|
|
2134
|
+
],
|
|
2135
|
+
[
|
|
2136
|
+
30,
|
|
2137
|
+
22,
|
|
2138
|
+
45,
|
|
2139
|
+
15,
|
|
2140
|
+
41,
|
|
2141
|
+
46,
|
|
2142
|
+
16
|
|
2143
|
+
],
|
|
2144
|
+
[
|
|
2145
|
+
30,
|
|
2146
|
+
2,
|
|
2147
|
+
45,
|
|
2148
|
+
15,
|
|
2149
|
+
64,
|
|
2150
|
+
46,
|
|
2151
|
+
16
|
|
2152
|
+
],
|
|
2153
|
+
[
|
|
2154
|
+
30,
|
|
2155
|
+
24,
|
|
2156
|
+
45,
|
|
2157
|
+
15,
|
|
2158
|
+
46,
|
|
2159
|
+
46,
|
|
2160
|
+
16
|
|
2161
|
+
],
|
|
2162
|
+
[
|
|
2163
|
+
30,
|
|
2164
|
+
42,
|
|
2165
|
+
45,
|
|
2166
|
+
15,
|
|
2167
|
+
32,
|
|
2168
|
+
46,
|
|
2169
|
+
16
|
|
2170
|
+
],
|
|
2171
|
+
[
|
|
2172
|
+
30,
|
|
2173
|
+
10,
|
|
2174
|
+
45,
|
|
2175
|
+
15,
|
|
2176
|
+
67,
|
|
2177
|
+
46,
|
|
2178
|
+
16
|
|
2179
|
+
],
|
|
2180
|
+
[
|
|
2181
|
+
30,
|
|
2182
|
+
20,
|
|
2183
|
+
45,
|
|
2184
|
+
15,
|
|
2185
|
+
61,
|
|
2186
|
+
46,
|
|
2187
|
+
16
|
|
2188
|
+
]
|
|
2189
|
+
]
|
|
2190
|
+
};
|
|
2191
|
+
const EXP = /* @__PURE__ */ new Uint8Array(512);
|
|
2192
|
+
const LOG = /* @__PURE__ */ new Uint8Array(256);
|
|
2193
|
+
{
|
|
2194
|
+
let x = 1;
|
|
2195
|
+
for (let i = 0; i < 255; i++) {
|
|
2196
|
+
EXP[i] = x;
|
|
2197
|
+
LOG[x] = i;
|
|
2198
|
+
x = x & 128 ? (x << 1 ^ 285) & 255 : x << 1;
|
|
2199
|
+
}
|
|
2200
|
+
for (let i = 255; i < 512; i++) EXP[i] = EXP[i - 255] ?? 0;
|
|
2201
|
+
}
|
|
2202
|
+
const mul = (a, b) => a && b ? EXP[(LOG[a] ?? 0) + (LOG[b] ?? 0)] ?? 0 : 0;
|
|
2203
|
+
const div = (a, b) => a ? EXP[(LOG[a] ?? 0) + 255 - (LOG[b] ?? 0)] ?? 0 : 0;
|
|
2204
|
+
const pow = (i) => EXP[(i % 255 + 255) % 255] ?? 0;
|
|
2205
|
+
/**
|
|
2206
|
+
* Corrects a block (data then ECC codewords, generator roots α⁰…α^(n−1)) in place.
|
|
2207
|
+
* Returns the number of corrected codewords; throws when the block is beyond repair.
|
|
2208
|
+
*/
|
|
2209
|
+
function correctBlock(block, eccLength) {
|
|
2210
|
+
const n = block.length;
|
|
2211
|
+
const evalAt = (x) => {
|
|
2212
|
+
let y = 0;
|
|
2213
|
+
for (const c of block) y = mul(y, x) ^ c;
|
|
2214
|
+
return y;
|
|
2215
|
+
};
|
|
2216
|
+
const syndromes = Array.from({ length: eccLength }, (_, i) => evalAt(pow(i)));
|
|
2217
|
+
if (syndromes.every((s) => s === 0)) return 0;
|
|
2218
|
+
let lambda = [1];
|
|
2219
|
+
let prev = [1];
|
|
2220
|
+
let l = 0;
|
|
2221
|
+
let m = 1;
|
|
2222
|
+
let b = 1;
|
|
2223
|
+
for (let r = 0; r < eccLength; r++) {
|
|
2224
|
+
let delta = syndromes[r] ?? 0;
|
|
2225
|
+
for (let i = 1; i <= l; i++) delta ^= mul(lambda[i] ?? 0, syndromes[r - i] ?? 0);
|
|
2226
|
+
if (delta === 0) {
|
|
2227
|
+
m++;
|
|
2228
|
+
continue;
|
|
2229
|
+
}
|
|
2230
|
+
const scale = div(delta, b);
|
|
2231
|
+
const next = lambda.slice();
|
|
2232
|
+
for (let i = 0; i < prev.length; i++) next[i + m] = (next[i + m] ?? 0) ^ mul(scale, prev[i] ?? 0);
|
|
2233
|
+
if (2 * l <= r) {
|
|
2234
|
+
prev = lambda;
|
|
2235
|
+
l = r + 1 - l;
|
|
2236
|
+
b = delta;
|
|
2237
|
+
m = 1;
|
|
2238
|
+
} else m++;
|
|
2239
|
+
lambda = next;
|
|
2240
|
+
}
|
|
2241
|
+
const positions = [];
|
|
2242
|
+
for (let p = 0; p < n; p++) {
|
|
2243
|
+
const x = pow(-p);
|
|
2244
|
+
let y = 0;
|
|
2245
|
+
for (let i = lambda.length - 1; i >= 0; i--) y = mul(y, x) ^ (lambda[i] ?? 0);
|
|
2246
|
+
if (y === 0) positions.push(p);
|
|
2247
|
+
}
|
|
2248
|
+
if (positions.length !== l || l * 2 > eccLength) throw new QrDecodeError("uncorrectable block");
|
|
2249
|
+
const omega = [];
|
|
2250
|
+
for (let i = 0; i < eccLength; i++) {
|
|
2251
|
+
let v = 0;
|
|
2252
|
+
for (let j = 0; j <= i; j++) v ^= mul(syndromes[j] ?? 0, lambda[i - j] ?? 0);
|
|
2253
|
+
omega.push(v);
|
|
2254
|
+
}
|
|
2255
|
+
for (const p of positions) {
|
|
2256
|
+
const xInv = pow(-p);
|
|
2257
|
+
let num = 0;
|
|
2258
|
+
for (let i = omega.length - 1; i >= 0; i--) num = mul(num, xInv) ^ (omega[i] ?? 0);
|
|
2259
|
+
let den = 0;
|
|
2260
|
+
for (let i = 1; i < lambda.length; i += 2) den ^= mul(lambda[i] ?? 0, pow(-p * (i - 1)));
|
|
2261
|
+
if (den === 0) throw new QrDecodeError("uncorrectable block");
|
|
2262
|
+
const magnitude = mul(pow(p), div(num, den));
|
|
2263
|
+
const k = n - 1 - p;
|
|
2264
|
+
block[k] = (block[k] ?? 0) ^ magnitude;
|
|
2265
|
+
}
|
|
2266
|
+
if (Array.from({ length: eccLength }, (_, i) => evalAt(pow(i))).some((s) => s !== 0)) throw new QrDecodeError("uncorrectable block");
|
|
2267
|
+
return positions.length;
|
|
2268
|
+
}
|
|
2269
|
+
const FORMAT_LEVELS = [
|
|
2270
|
+
"M",
|
|
2271
|
+
"L",
|
|
2272
|
+
"H",
|
|
2273
|
+
"Q"
|
|
2274
|
+
];
|
|
2275
|
+
function formatWord(data) {
|
|
2276
|
+
let rem = data;
|
|
2277
|
+
for (let i = 0; i < 10; i++) rem = rem << 1 ^ (rem >>> 9) * 1335;
|
|
2278
|
+
return (data << 10 | rem) ^ 21522;
|
|
2279
|
+
}
|
|
2280
|
+
const popcount = (v) => {
|
|
2281
|
+
let n = 0;
|
|
2282
|
+
for (let x = v; x; x &= x - 1) n++;
|
|
2283
|
+
return n;
|
|
2284
|
+
};
|
|
2285
|
+
/** Reads a format copy and returns the nearest valid word's level and mask. */
|
|
2286
|
+
function readFormat(bits) {
|
|
2287
|
+
let best = {
|
|
2288
|
+
ecc: "M",
|
|
2289
|
+
mask: 0,
|
|
2290
|
+
distance: 99
|
|
2291
|
+
};
|
|
2292
|
+
for (let data = 0; data < 32; data++) {
|
|
2293
|
+
const distance = popcount(formatWord(data) ^ bits);
|
|
2294
|
+
if (distance < best.distance) best = {
|
|
2295
|
+
ecc: FORMAT_LEVELS[data >> 3] ?? "M",
|
|
2296
|
+
mask: data & 7,
|
|
2297
|
+
distance
|
|
2298
|
+
};
|
|
2299
|
+
}
|
|
2300
|
+
return best;
|
|
2301
|
+
}
|
|
2302
|
+
const MASKS = [
|
|
2303
|
+
(x, y) => (x + y) % 2 === 0,
|
|
2304
|
+
(_, y) => y % 2 === 0,
|
|
2305
|
+
(x) => x % 3 === 0,
|
|
2306
|
+
(x, y) => (x + y) % 3 === 0,
|
|
2307
|
+
(x, y) => (Math.floor(x / 3) + Math.floor(y / 2)) % 2 === 0,
|
|
2308
|
+
(x, y) => x * y % 2 + x * y % 3 === 0,
|
|
2309
|
+
(x, y) => (x * y % 2 + x * y % 3) % 2 === 0,
|
|
2310
|
+
(x, y) => ((x + y) % 2 + x * y % 3) % 2 === 0
|
|
2311
|
+
];
|
|
2312
|
+
/** Which modules are function patterns, built from the standard's geometry. */
|
|
2313
|
+
function functionMap(version) {
|
|
2314
|
+
const size = version * 4 + 17;
|
|
2315
|
+
const f = Array.from({ length: size }, () => new Array(size).fill(false));
|
|
2316
|
+
const mark = (x0, y0, w, h) => {
|
|
2317
|
+
for (let y = Math.max(0, y0); y < Math.min(size, y0 + h); y++) for (let x = Math.max(0, x0); x < Math.min(size, x0 + w); x++) {
|
|
2318
|
+
const row = f[y];
|
|
2319
|
+
if (row) row[x] = true;
|
|
2320
|
+
}
|
|
2321
|
+
};
|
|
2322
|
+
mark(0, 0, 9, 9);
|
|
2323
|
+
mark(size - 8, 0, 8, 9);
|
|
2324
|
+
mark(0, size - 8, 9, 8);
|
|
2325
|
+
mark(6, 0, 1, size);
|
|
2326
|
+
mark(0, 6, size, 1);
|
|
2327
|
+
const centres = alignmentTable(version);
|
|
2328
|
+
for (const cy of centres) for (const cx of centres) if (!(cx === 6 && cy === 6 || cx === 6 && cy === size - 7 || cx === size - 7 && cy === 6)) mark(cx - 2, cy - 2, 5, 5);
|
|
2329
|
+
if (version >= 7) {
|
|
2330
|
+
mark(size - 11, 0, 3, 6);
|
|
2331
|
+
mark(0, size - 11, 6, 3);
|
|
2332
|
+
}
|
|
2333
|
+
return f;
|
|
2334
|
+
}
|
|
2335
|
+
/** Decodes a module matrix (row-major, `true` = dark, no quiet zone). Throws `QrDecodeError`. */
|
|
2336
|
+
function decodeQr(matrix) {
|
|
2337
|
+
const size = matrix.length;
|
|
2338
|
+
const version = (size - 17) / 4;
|
|
2339
|
+
if (!Number.isInteger(version) || version < 1 || version > 40) throw new QrDecodeError(`a ${size}-module side is no QR version`);
|
|
2340
|
+
const at = (x, y) => matrix[y]?.[x] === true ? 1 : 0;
|
|
2341
|
+
let copy1 = 0;
|
|
2342
|
+
for (let i = 0; i <= 5; i++) copy1 |= at(8, i) << i;
|
|
2343
|
+
copy1 |= at(8, 7) << 6;
|
|
2344
|
+
copy1 |= at(8, 8) << 7;
|
|
2345
|
+
copy1 |= at(7, 8) << 8;
|
|
2346
|
+
for (let i = 9; i < 15; i++) copy1 |= at(14 - i, 8) << i;
|
|
2347
|
+
let copy2 = 0;
|
|
2348
|
+
for (let i = 0; i < 8; i++) copy2 |= at(size - 1 - i, 8) << i;
|
|
2349
|
+
for (let i = 8; i < 15; i++) copy2 |= at(8, size - 15 + i) << i;
|
|
2350
|
+
const a = readFormat(copy1);
|
|
2351
|
+
const b = readFormat(copy2);
|
|
2352
|
+
const format = a.distance <= b.distance ? a : b;
|
|
2353
|
+
if (format.distance > 3) throw new QrDecodeError("unreadable format information");
|
|
2354
|
+
const fixed = functionMap(version);
|
|
2355
|
+
const unmask = MASKS[format.mask] ?? (() => false);
|
|
2356
|
+
const bits = [];
|
|
2357
|
+
for (let right = size - 1; right >= 1; right -= 2) {
|
|
2358
|
+
if (right === 6) right = 5;
|
|
2359
|
+
for (let vert = 0; vert < size; vert++) for (let j = 0; j < 2; j++) {
|
|
2360
|
+
const x = right - j;
|
|
2361
|
+
const y = (right + 1 & 2) === 0 ? size - 1 - vert : vert;
|
|
2362
|
+
if (fixed[y]?.[x]) continue;
|
|
2363
|
+
bits.push(at(x, y) ^ (unmask(x, y) ? 1 : 0));
|
|
2364
|
+
}
|
|
2365
|
+
}
|
|
2366
|
+
const codewords = new Uint8Array(Math.floor(bits.length / 8));
|
|
2367
|
+
for (let i = 0; i < codewords.length; i++) {
|
|
2368
|
+
let v = 0;
|
|
2369
|
+
for (let k = 0; k < 8; k++) v = v << 1 | (bits[i * 8 + k] ?? 0);
|
|
2370
|
+
codewords[i] = v;
|
|
2371
|
+
}
|
|
2372
|
+
const spec = BLOCKS[format.ecc][version] ?? [];
|
|
2373
|
+
const eccLength = spec[0] ?? 0;
|
|
2374
|
+
const groups = [];
|
|
2375
|
+
for (let i = 1; i < spec.length; i += 3) groups.push({
|
|
2376
|
+
count: spec[i] ?? 0,
|
|
2377
|
+
data: spec[i + 2] ?? 0
|
|
2378
|
+
});
|
|
2379
|
+
const blocks = [];
|
|
2380
|
+
for (const g of groups) for (let i = 0; i < g.count; i++) blocks.push({
|
|
2381
|
+
data: g.data,
|
|
2382
|
+
bytes: []
|
|
2383
|
+
});
|
|
2384
|
+
const maxData = Math.max(...blocks.map((bl) => bl.data));
|
|
2385
|
+
let k = 0;
|
|
2386
|
+
for (let i = 0; i < maxData; i++) for (const bl of blocks) if (i < bl.data) bl.bytes.push(codewords[k++] ?? 0);
|
|
2387
|
+
for (let i = 0; i < eccLength; i++) for (const bl of blocks) bl.bytes.push(codewords[k++] ?? 0);
|
|
2388
|
+
let corrected = 0;
|
|
2389
|
+
const data = [];
|
|
2390
|
+
for (const bl of blocks) {
|
|
2391
|
+
const block = Uint8Array.from(bl.bytes);
|
|
2392
|
+
corrected += correctBlock(block, eccLength);
|
|
2393
|
+
data.push(...block.subarray(0, bl.data));
|
|
2394
|
+
}
|
|
2395
|
+
return {
|
|
2396
|
+
version,
|
|
2397
|
+
ecc: format.ecc,
|
|
2398
|
+
mask: format.mask,
|
|
2399
|
+
corrected,
|
|
2400
|
+
...parseSegments(data, version)
|
|
2401
|
+
};
|
|
2402
|
+
}
|
|
2403
|
+
const ALPHANUMERIC = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
|
|
2404
|
+
function parseSegments(data, version) {
|
|
2405
|
+
let pos = 0;
|
|
2406
|
+
const total = data.length * 8;
|
|
2407
|
+
const read = (n) => {
|
|
2408
|
+
let v = 0;
|
|
2409
|
+
for (let i = 0; i < n; i++, pos++) v = v << 1 | (data[pos >> 3] ?? 0) >> 7 - (pos & 7) & 1;
|
|
2410
|
+
return v;
|
|
2411
|
+
};
|
|
2412
|
+
const width = (narrow, mid, wide) => version <= 9 ? narrow : version <= 26 ? mid : wide;
|
|
2413
|
+
const out = [];
|
|
2414
|
+
const segments = [];
|
|
2415
|
+
while (pos + 4 <= total) {
|
|
2416
|
+
const mode = read(4);
|
|
2417
|
+
if (mode === 0) break;
|
|
2418
|
+
if (mode === 7) {
|
|
2419
|
+
const first = read(8);
|
|
2420
|
+
const assignment = first & 128 ? first & 64 ? (first & 31) << 16 | read(16) : (first & 63) << 8 | read(8) : first;
|
|
2421
|
+
segments.push({
|
|
2422
|
+
mode: "eci",
|
|
2423
|
+
assignment
|
|
2424
|
+
});
|
|
2425
|
+
} else if (mode === 1) {
|
|
2426
|
+
let count = read(width(10, 12, 14));
|
|
2427
|
+
segments.push({
|
|
2428
|
+
mode: "numeric",
|
|
2429
|
+
chars: count
|
|
2430
|
+
});
|
|
2431
|
+
for (; count >= 3; count -= 3) out.push(...String(read(10)).padStart(3, "0").split("").map((c) => c.charCodeAt(0)));
|
|
2432
|
+
if (count === 2) out.push(...String(read(7)).padStart(2, "0").split("").map((c) => c.charCodeAt(0)));
|
|
2433
|
+
if (count === 1) out.push(...String(read(4)).split("").map((c) => c.charCodeAt(0)));
|
|
2434
|
+
} else if (mode === 2) {
|
|
2435
|
+
let count = read(width(9, 11, 13));
|
|
2436
|
+
segments.push({
|
|
2437
|
+
mode: "alphanumeric",
|
|
2438
|
+
chars: count
|
|
2439
|
+
});
|
|
2440
|
+
for (; count >= 2; count -= 2) {
|
|
2441
|
+
const v = read(11);
|
|
2442
|
+
out.push(ALPHANUMERIC.charCodeAt(Math.floor(v / 45)), ALPHANUMERIC.charCodeAt(v % 45));
|
|
2443
|
+
}
|
|
2444
|
+
if (count === 1) out.push(ALPHANUMERIC.charCodeAt(read(6)));
|
|
2445
|
+
} else if (mode === 4) {
|
|
2446
|
+
const count = read(width(8, 16, 16));
|
|
2447
|
+
segments.push({
|
|
2448
|
+
mode: "byte",
|
|
2449
|
+
chars: count
|
|
2450
|
+
});
|
|
2451
|
+
for (let i = 0; i < count; i++) out.push(read(8));
|
|
2452
|
+
} else throw new QrDecodeError(`unsupported mode ${mode.toString(2)}`);
|
|
2453
|
+
}
|
|
2454
|
+
const bytes = Uint8Array.from(out);
|
|
2455
|
+
return {
|
|
2456
|
+
bytes,
|
|
2457
|
+
text: new TextDecoder("utf-8").decode(bytes),
|
|
2458
|
+
segments
|
|
2459
|
+
};
|
|
2460
|
+
}
|
|
2461
|
+
//#endregion
|
|
2462
|
+
//#region src/components/qr-code.ts
|
|
2463
|
+
/**
|
|
2464
|
+
* The QR Code contract with the testing decoder: `decoded()` reads the rendered symbol back
|
|
2465
|
+
* and the decode invariant checks it against the value text.
|
|
2466
|
+
*/
|
|
2467
|
+
const qrCodeDecodingContract = qrCodeContractWith((modules) => decodeQr(modules).text);
|
|
2468
|
+
/**
|
|
2469
|
+
* A driver for the QR code whose frame is named `name` (default "QR code"), inside `within`
|
|
2470
|
+
* (a container element or a Playwright locator; default the target).
|
|
2471
|
+
*/
|
|
2472
|
+
function getQrCode(target, anchor = {}, options) {
|
|
2473
|
+
const { within, name } = anchor;
|
|
2474
|
+
return createDriverWith(qrCodeDecodingContract, within ?? target, [name === void 0 ? {} : { name }], options);
|
|
2475
|
+
}
|
|
2476
|
+
//#endregion
|
|
318
2477
|
//#region src/components/radio-group.ts
|
|
319
2478
|
/** A driver for the Radio Group named `name`. */
|
|
320
2479
|
function getRadioGroup(target, anchor, options) {
|
|
321
2480
|
return createDriverWith(radioGroupContract, target, [anchor], options);
|
|
322
2481
|
}
|
|
323
2482
|
//#endregion
|
|
2483
|
+
//#region src/components/scroll-area.ts
|
|
2484
|
+
/**
|
|
2485
|
+
* A driver for a Scroll Area: the one whose Viewport is the region named `name`, or the one
|
|
2486
|
+
* whose Content holds `text`.
|
|
2487
|
+
*/
|
|
2488
|
+
function getScrollArea(target, anchor, options) {
|
|
2489
|
+
return createDriverWith(scrollAreaContract, target, [anchor], options);
|
|
2490
|
+
}
|
|
2491
|
+
//#endregion
|
|
324
2492
|
//#region src/components/segmented-control.ts
|
|
325
2493
|
/** A driver for the Segmented Control named `name`. */
|
|
326
2494
|
function getSegmentedControl(target, anchor, options) {
|
|
327
2495
|
return createDriverWith(segmentedControlContract, target, [anchor], options);
|
|
328
2496
|
}
|
|
329
2497
|
//#endregion
|
|
2498
|
+
//#region src/components/select.ts
|
|
2499
|
+
/** A driver for the Select named `name`: open, choose, typeahead, form and value queries. */
|
|
2500
|
+
function getSelect(target, anchor, options) {
|
|
2501
|
+
return createDriverWith(selectContract, target, [anchor], options);
|
|
2502
|
+
}
|
|
2503
|
+
//#endregion
|
|
330
2504
|
//#region src/components/separator.ts
|
|
331
2505
|
/**
|
|
332
2506
|
* A driver for a Separator: the one named `name`, or the one separator part inside
|
|
@@ -338,6 +2512,21 @@ function getSeparator(target, anchor = {}, options) {
|
|
|
338
2512
|
return createDriverWith(host === void 0 ? separatorContract : separatorContractFor(host), within ?? target, [name === void 0 ? {} : { name }], options);
|
|
339
2513
|
}
|
|
340
2514
|
//#endregion
|
|
2515
|
+
//#region src/components/skeleton.ts
|
|
2516
|
+
/**
|
|
2517
|
+
* A driver for the one Skeleton inside `within` (a container element or a Playwright
|
|
2518
|
+
* locator; default the target). `announcements()` lists what it announced since creation.
|
|
2519
|
+
*/
|
|
2520
|
+
function getSkeleton(target, anchor = {}, options) {
|
|
2521
|
+
return createDriverWith(skeletonContract, anchor.within ?? target, [], options);
|
|
2522
|
+
}
|
|
2523
|
+
//#endregion
|
|
2524
|
+
//#region src/components/slider.ts
|
|
2525
|
+
/** A driver for the Slider whose Label is `name`. */
|
|
2526
|
+
function getSlider(target, anchor, options) {
|
|
2527
|
+
return createDriverWith(sliderContract, target, [anchor], options);
|
|
2528
|
+
}
|
|
2529
|
+
//#endregion
|
|
341
2530
|
//#region src/components/switch.ts
|
|
342
2531
|
/** A driver for the Switch named `name`. */
|
|
343
2532
|
function getSwitch(target, anchor, options) {
|
|
@@ -350,12 +2539,28 @@ function getTabs(target, anchor, options) {
|
|
|
350
2539
|
return createDriverWith(tabsContract, target, [anchor], options);
|
|
351
2540
|
}
|
|
352
2541
|
//#endregion
|
|
2542
|
+
//#region src/components/tags-input.ts
|
|
2543
|
+
/** A driver for the Tags Input named `name`: type, addTag, paste, editTag, removeTag, queries. */
|
|
2544
|
+
function getTagsInput(target, anchor, options) {
|
|
2545
|
+
return createDriverWith(tagsInputContract, target, [anchor], options);
|
|
2546
|
+
}
|
|
2547
|
+
//#endregion
|
|
353
2548
|
//#region src/components/text-field.ts
|
|
354
2549
|
/** A driver for the Text Field named `name`: type, fill, clear, compose, blur, queries. */
|
|
355
2550
|
function getTextField(target, anchor, options) {
|
|
356
2551
|
return createDriverWith(textFieldContract, target, [anchor], options);
|
|
357
2552
|
}
|
|
358
2553
|
//#endregion
|
|
2554
|
+
//#region src/components/toast.ts
|
|
2555
|
+
/** A driver for the toaster region named `name` ("Notifications (F6)"): enter, leave, queries. */
|
|
2556
|
+
function getToaster(target, anchor, options) {
|
|
2557
|
+
return createDriverWith(toasterContract, target, [anchor], options);
|
|
2558
|
+
}
|
|
2559
|
+
/** A driver for the toast titled `name`: dismiss, swipe, act, hover, waitForTimeout, queries. */
|
|
2560
|
+
function getToast(target, anchor, options) {
|
|
2561
|
+
return createDriverWith(toastContract, target, [anchor], options);
|
|
2562
|
+
}
|
|
2563
|
+
//#endregion
|
|
359
2564
|
//#region src/components/toggle.ts
|
|
360
2565
|
/** A driver for the Toggle named `name`. */
|
|
361
2566
|
function getToggle(target, anchor, options) {
|
|
@@ -374,6 +2579,122 @@ function getToolbar(target, anchor, options) {
|
|
|
374
2579
|
return createDriverWith(toolbarContract, target, [anchor], options);
|
|
375
2580
|
}
|
|
376
2581
|
//#endregion
|
|
2582
|
+
//#region src/components/tooltip.ts
|
|
2583
|
+
/**
|
|
2584
|
+
* A driver for the Tooltip of the trigger named `name` (role `button` unless `role` says
|
|
2585
|
+
* otherwise). With fake timers, pass `advanceTimers` to the adapter: `show()` and `hide()`
|
|
2586
|
+
* advance through the delays.
|
|
2587
|
+
*/
|
|
2588
|
+
function getTooltip(target, anchor, options) {
|
|
2589
|
+
return createDriverWith(tooltipContract, target, [anchor], options);
|
|
2590
|
+
}
|
|
2591
|
+
//#endregion
|
|
2592
|
+
//#region src/components/tour.ts
|
|
2593
|
+
/**
|
|
2594
|
+
* A driver for the Tour started by the trigger named `name` (an idle tour has no card to
|
|
2595
|
+
* find). `modal: true` for a tour with `modal`. `announcements()` lists what it announced
|
|
2596
|
+
* since the driver was created.
|
|
2597
|
+
*/
|
|
2598
|
+
function getTour(target, anchor, options) {
|
|
2599
|
+
const { modal, ...locate } = anchor;
|
|
2600
|
+
return createDriverWith(modal === true ? modalTourContract : tourContract, target, [locate], options);
|
|
2601
|
+
}
|
|
2602
|
+
//#endregion
|
|
2603
|
+
//#region src/date-clock.ts
|
|
2604
|
+
/** A clock frozen at `instant` (ISO, or epoch ms) in `timeZone` (default UTC). */
|
|
2605
|
+
function fixedDateClock(instant, timeZone = "UTC") {
|
|
2606
|
+
const ms = typeof instant === "number" ? instant : Date.parse(instant);
|
|
2607
|
+
return {
|
|
2608
|
+
now: () => ms,
|
|
2609
|
+
timeZone: () => timeZone
|
|
2610
|
+
};
|
|
2611
|
+
}
|
|
2612
|
+
//#endregion
|
|
2613
|
+
//#region src/delay-group.ts
|
|
2614
|
+
/** A delay group without timers: warm while a member is open or after `setWarm(true)`. */
|
|
2615
|
+
function fakeDelayGroup() {
|
|
2616
|
+
const members = /* @__PURE__ */ new Map();
|
|
2617
|
+
let open = null;
|
|
2618
|
+
let warm = false;
|
|
2619
|
+
return {
|
|
2620
|
+
get members() {
|
|
2621
|
+
return members;
|
|
2622
|
+
},
|
|
2623
|
+
get open() {
|
|
2624
|
+
return open;
|
|
2625
|
+
},
|
|
2626
|
+
setWarm: (w) => {
|
|
2627
|
+
warm = w;
|
|
2628
|
+
},
|
|
2629
|
+
join(id, member) {
|
|
2630
|
+
members.set(id, member);
|
|
2631
|
+
return () => {
|
|
2632
|
+
if (open === id) open = null;
|
|
2633
|
+
members.delete(id);
|
|
2634
|
+
};
|
|
2635
|
+
},
|
|
2636
|
+
isWarm: () => open !== null || warm,
|
|
2637
|
+
opened(id) {
|
|
2638
|
+
const previous = open;
|
|
2639
|
+
open = id;
|
|
2640
|
+
if (previous !== null && previous !== id) members.get(previous)?.replace();
|
|
2641
|
+
},
|
|
2642
|
+
closed(id, skipDelay) {
|
|
2643
|
+
if (open !== id) return;
|
|
2644
|
+
open = null;
|
|
2645
|
+
warm = skipDelay > 0;
|
|
2646
|
+
}
|
|
2647
|
+
};
|
|
2648
|
+
}
|
|
2649
|
+
function fakeHoverIntent() {
|
|
2650
|
+
const live = /* @__PURE__ */ new Set();
|
|
2651
|
+
return {
|
|
2652
|
+
inTransit: false,
|
|
2653
|
+
get tracked() {
|
|
2654
|
+
return [...live];
|
|
2655
|
+
},
|
|
2656
|
+
track(options) {
|
|
2657
|
+
live.add(options);
|
|
2658
|
+
return () => live.delete(options);
|
|
2659
|
+
},
|
|
2660
|
+
isInTransit() {
|
|
2661
|
+
return this.inTransit;
|
|
2662
|
+
},
|
|
2663
|
+
leave: () => {
|
|
2664
|
+
for (const o of [...live]) o.onLeave();
|
|
2665
|
+
},
|
|
2666
|
+
enter: () => {
|
|
2667
|
+
for (const o of [...live]) o.onEnter();
|
|
2668
|
+
},
|
|
2669
|
+
triggerProps: (send) => ({
|
|
2670
|
+
onPointerMove: (e) => {
|
|
2671
|
+
if (e.pointerType === "mouse" || e.pointerType === "pen") send({ type: "HOVER.START" });
|
|
2672
|
+
},
|
|
2673
|
+
onPointerLeave: (e) => {
|
|
2674
|
+
if (e.pointerType === "mouse" || e.pointerType === "pen") send({ type: "HOVER.END" });
|
|
2675
|
+
}
|
|
2676
|
+
})
|
|
2677
|
+
};
|
|
2678
|
+
}
|
|
2679
|
+
//#endregion
|
|
2680
|
+
//#region src/fake-visibility.ts
|
|
2681
|
+
function fakeVisibility(initiallyHidden = false) {
|
|
2682
|
+
let hidden = initiallyHidden;
|
|
2683
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
2684
|
+
return {
|
|
2685
|
+
hidden: () => hidden,
|
|
2686
|
+
subscribe(listener) {
|
|
2687
|
+
listeners.add(listener);
|
|
2688
|
+
return () => listeners.delete(listener);
|
|
2689
|
+
},
|
|
2690
|
+
set(next) {
|
|
2691
|
+
if (next === hidden) return;
|
|
2692
|
+
hidden = next;
|
|
2693
|
+
for (const l of listeners) l(hidden);
|
|
2694
|
+
}
|
|
2695
|
+
};
|
|
2696
|
+
}
|
|
2697
|
+
//#endregion
|
|
377
2698
|
//#region src/form-invariants.ts
|
|
378
2699
|
/**
|
|
379
2700
|
* - `form-focus-only-on-attempt`: a step that is not a submit attempt (Validate, Reset)
|
|
@@ -487,6 +2808,13 @@ function uncovered(graph, found) {
|
|
|
487
2808
|
}
|
|
488
2809
|
//#endregion
|
|
489
2810
|
//#region src/invariants.ts
|
|
2811
|
+
/** Roles that carry a value (`valued`): one element each. */
|
|
2812
|
+
const VALUED_ROLES = /* @__PURE__ */ new Set([
|
|
2813
|
+
"slider",
|
|
2814
|
+
"progressbar",
|
|
2815
|
+
"meter",
|
|
2816
|
+
"spinbutton"
|
|
2817
|
+
]);
|
|
490
2818
|
const NAME_REQUIRED = /* @__PURE__ */ new Set([
|
|
491
2819
|
"button",
|
|
492
2820
|
"link",
|
|
@@ -549,7 +2877,7 @@ function highlightChecks(f) {
|
|
|
549
2877
|
}
|
|
550
2878
|
return out;
|
|
551
2879
|
}
|
|
552
|
-
const anchor = (f) => f.anchorCount === 1 ? [] : [`exactly one element must match the anchor; found ${f.anchorCount}`];
|
|
2880
|
+
const anchor = (f) => f.absent ? f.anchorCount === 0 ? [] : [`no element may match the anchor in ${f.state} (absentIn); found ${f.anchorCount}`] : f.anchorCount === 1 ? [] : [`exactly one element must match the anchor; found ${f.anchorCount}`];
|
|
553
2881
|
const noErrors = (f) => f.errors.map((e) => `error during the step: ${e}`);
|
|
554
2882
|
/** Every part (items included) carries the data-state the contract declares for it. */
|
|
555
2883
|
const dataState = (f) => {
|
|
@@ -614,7 +2942,7 @@ const stateAttrs = (f) => {
|
|
|
614
2942
|
for (const [aria, data] of pairs) {
|
|
615
2943
|
if (el.attrs[aria] === void 0 && el.attrs[data] === void 0) continue;
|
|
616
2944
|
const on = isTrue(el.attrs[aria]) || aria === "aria-disabled" && el.attrs["disabled"] !== void 0;
|
|
617
|
-
const flagged = el.attrs[data] !== void 0;
|
|
2945
|
+
const flagged = el.attrs[data] !== void 0 || aria === "aria-disabled" && el.attrs["data-unavailable"] !== void 0;
|
|
618
2946
|
if (flagged && !on && !el.focusable) continue;
|
|
619
2947
|
if (aria === "aria-selected" && !SELECTABLE_ROLES.has(el.role ?? "")) continue;
|
|
620
2948
|
if (flagged && !on && aria === "aria-invalid" && el.role === "radio" && f.after.elements.some((g) => g.role === "radiogroup" && isTrue(g.attrs["aria-invalid"]) && g.id !== null && el.within.includes(g.id))) continue;
|
|
@@ -647,7 +2975,9 @@ const hiddenFocus = (f) => {
|
|
|
647
2975
|
* another element is leaving (Tab out) when the machine took a transition to another state
|
|
648
2976
|
* (focused → idle); without one, the component lost focus.
|
|
649
2977
|
*/
|
|
650
|
-
|
|
2978
|
+
/** A layer with no restore target part: focus returns to what had it when it opened. */
|
|
2979
|
+
const restoresToPrevious = (f) => f.semantics["finalFocus"] === void 0 && f.semantics["trigger"] === void 0;
|
|
2980
|
+
const focusKept = (f) => !(restoresToPrevious(f) && f.atInitial && f.baseline.focus.onBody && f.after.focus.onBody) && f.before?.focus.inInstance && !f.after.focus.inInstance && (f.after.focus.onBody || f.from === null || f.from === f.state) ? [`focus left the component (now ${f.after.focus.onBody ? "<body>" : f.after.focus.element?.describe})`] : [];
|
|
651
2981
|
/** (23) No live region of its own unless the contract declares `live-region`. */
|
|
652
2982
|
const liveRegions = (f) => f.traits.includes("live-region") ? [] : f.after.liveRegions.map((r) => `${r} is a live region; announce through the Announcer`);
|
|
653
2983
|
/**
|
|
@@ -728,16 +3058,21 @@ const traitInvariants = {
|
|
|
728
3058
|
const multiple = f.formInput.multiple === true;
|
|
729
3059
|
const inputs = f.after.formInputs.filter((i) => !i.inParent);
|
|
730
3060
|
if (!multiple && inputs.length !== 1) return [`${inputs.length} hidden inputs rendered; expected exactly one`];
|
|
731
|
-
for (const input of inputs) {
|
|
732
|
-
const want = f.formInput.expected(
|
|
3061
|
+
for (const [index, input] of inputs.entries()) {
|
|
3062
|
+
const want = f.formInput.expected({
|
|
3063
|
+
value: input.value,
|
|
3064
|
+
index
|
|
3065
|
+
});
|
|
733
3066
|
for (const key of [
|
|
734
3067
|
"checked",
|
|
735
3068
|
"indeterminate",
|
|
736
3069
|
"value"
|
|
737
3070
|
]) if (want[key] !== void 0 && input[key] !== want[key]) out.push(`${input.describe} ${key} is ${String(input[key])}, expected ${String(want[key])}`);
|
|
738
|
-
if (
|
|
739
|
-
|
|
740
|
-
|
|
3071
|
+
if (!f.formInput.accessible) {
|
|
3072
|
+
if (input.ariaHidden !== "true") out.push(`${input.describe} is not aria-hidden`);
|
|
3073
|
+
if (input.tabIndex !== -1) out.push(`${input.describe} has tabIndex ${input.tabIndex}`);
|
|
3074
|
+
if (input.focused) out.push(`${input.describe} has focus`);
|
|
3075
|
+
}
|
|
741
3076
|
if (input.clicks > 0) out.push(`${input.describe} received ${input.clicks} click events (a synthetic click reaches ancestors)`);
|
|
742
3077
|
}
|
|
743
3078
|
const sum = (list) => list.filter((i) => !i.inParent).reduce((n, i) => n + i.changes, 0);
|
|
@@ -800,12 +3135,18 @@ const traitInvariants = {
|
|
|
800
3135
|
}
|
|
801
3136
|
return out;
|
|
802
3137
|
},
|
|
803
|
-
/**
|
|
804
|
-
|
|
3138
|
+
/**
|
|
3139
|
+
* Focus is never lost to body while a layer is open. A layer that never takes focus (a
|
|
3140
|
+
* tooltip opened by hover while nothing had focus) leaves it where it was.
|
|
3141
|
+
*/
|
|
3142
|
+
layer: (f) => isOpen(f) && f.after.focus.onBody && f.before?.focus.onBody !== true ? ["focus is on <body> while the layer is open"] : [],
|
|
805
3143
|
/** (13) After closing, focus is on the trigger or the declared final-focus part. */
|
|
806
3144
|
"restores-focus": (f) => {
|
|
807
3145
|
const target = f.semantics["finalFocus"] ?? f.semantics["trigger"];
|
|
808
|
-
|
|
3146
|
+
const closed = f.from !== null && f.from !== f.state && !isOpen(f) && f.fromInitial !== true;
|
|
3147
|
+
if (restoresToPrevious(f)) return closed && f.after.focus.onBody && !f.baseline.focus.onBody ? ["after closing, focus is on <body>, though something had focus when it opened"] : [];
|
|
3148
|
+
if (f.context?.["closeReason"] === "tab-key") return [];
|
|
3149
|
+
return closed && f.after.focus.part !== target ? [`after closing, focus is on ${f.after.focus.element?.describe ?? "<body>"}, expected the ${target} part`] : [];
|
|
809
3150
|
},
|
|
810
3151
|
/**
|
|
811
3152
|
* While open: everything outside the layer that existed before (and is not kept visible by
|
|
@@ -988,25 +3329,45 @@ const traitInvariants = {
|
|
|
988
3329
|
return out;
|
|
989
3330
|
},
|
|
990
3331
|
/**
|
|
991
|
-
* aria-valuenow equals the
|
|
992
|
-
*
|
|
3332
|
+
* aria-valuenow equals the expected value in the same step, element by element in DOM order
|
|
3333
|
+
* (one per thumb); a `null` value carries neither aria-valuenow nor aria-valuetext; the
|
|
3334
|
+
* declared aria-valuetext, or else a plain-number one equals the value (a locale's "1.200"
|
|
3335
|
+
* is never read as 1.2); a single value's `value-text` part shows its aria-valuetext.
|
|
993
3336
|
*/
|
|
994
3337
|
valued: (f) => {
|
|
995
|
-
const
|
|
996
|
-
|
|
3338
|
+
const raw = f.values["value"];
|
|
3339
|
+
const expected = f.valued?.values ?? (typeof raw === "number" ? [raw] : Array.isArray(raw) && raw.every((v) => typeof v === "number" || v === null) ? raw : void 0);
|
|
3340
|
+
if (!expected) return [];
|
|
997
3341
|
const out = [];
|
|
998
|
-
|
|
999
|
-
|
|
3342
|
+
const valuedEls = f.after.elements.filter((el) => !el.inAriaHidden && (el.attrs["aria-valuenow"] !== void 0 || el.role !== null && VALUED_ROLES.has(el.role)));
|
|
3343
|
+
if (valuedEls.length !== expected.length) out.push(`${valuedEls.length} valued elements rendered, expected ${expected.length}`);
|
|
3344
|
+
const texts = [];
|
|
3345
|
+
for (const [i, el] of valuedEls.entries()) {
|
|
3346
|
+
const want = expected[i];
|
|
3347
|
+
if (want === void 0) continue;
|
|
1000
3348
|
const now = el.attrs["aria-valuenow"];
|
|
1001
|
-
if (now !== void 0 && Number(now) !== value) out.push(`${el.describe} aria-valuenow="${now}", machine value ${value}`);
|
|
1002
3349
|
const text = el.attrs["aria-valuetext"];
|
|
3350
|
+
if (want === null) {
|
|
3351
|
+
if (now !== void 0) out.push(`${el.describe} has aria-valuenow="${now}", expected none`);
|
|
3352
|
+
const declared = f.valued?.valueText?.(i);
|
|
3353
|
+
if (declared === void 0 && text !== void 0) out.push(`${el.describe} has aria-valuetext="${text}", expected none`);
|
|
3354
|
+
else if (declared !== void 0 && text !== declared) out.push(`${el.describe} aria-valuetext="${text}", expected "${declared}"`);
|
|
3355
|
+
continue;
|
|
3356
|
+
}
|
|
3357
|
+
if (now !== void 0 && Number(now) !== want) out.push(`${el.describe} aria-valuenow="${now}", machine value ${want}`);
|
|
1003
3358
|
if (text === void 0) continue;
|
|
1004
|
-
|
|
3359
|
+
texts.push(text);
|
|
3360
|
+
const declared = f.valued?.valueText?.(i);
|
|
1005
3361
|
if (text.trim() === "") out.push(`${el.describe} has an empty aria-valuetext`);
|
|
1006
|
-
else if (
|
|
3362
|
+
else if (declared !== void 0) {
|
|
3363
|
+
if (text !== declared) out.push(`${el.describe} aria-valuetext="${text}", expected "${declared}"`);
|
|
3364
|
+
} else if (/^-?\d+(\.\d+)?$/.test(text.trim()) && String(Number(text)) === text.trim()) {
|
|
3365
|
+
if (Number(text) !== want) out.push(`${el.describe} aria-valuetext="${text}", machine value ${want}`);
|
|
3366
|
+
}
|
|
1007
3367
|
}
|
|
1008
|
-
|
|
1009
|
-
|
|
3368
|
+
const single = expected.length === 1 ? expected[0] : void 0;
|
|
3369
|
+
if (typeof single === "number") for (const p of f.after.parts.filter((x) => x.part === "value-text" && exposed(x))) {
|
|
3370
|
+
const want = texts[0] ?? String(single);
|
|
1010
3371
|
if (!p.text.includes(want)) out.push(`${p.describe} shows "${p.text}", expected "${want}"`);
|
|
1011
3372
|
}
|
|
1012
3373
|
return out;
|
|
@@ -1222,6 +3583,28 @@ const oracleEnv = {
|
|
|
1222
3583
|
prepare: () => () => {},
|
|
1223
3584
|
cancel: () => {}
|
|
1224
3585
|
},
|
|
3586
|
+
position: {
|
|
3587
|
+
track: () => ({ stop: () => {} }),
|
|
3588
|
+
reposition: () => {}
|
|
3589
|
+
},
|
|
3590
|
+
menuTree: {
|
|
3591
|
+
register: () => () => {},
|
|
3592
|
+
openChild: () => {},
|
|
3593
|
+
childClosed: () => {},
|
|
3594
|
+
closeTree: () => {},
|
|
3595
|
+
openPath: () => [],
|
|
3596
|
+
rootTrigger: () => null,
|
|
3597
|
+
parentKind: () => null,
|
|
3598
|
+
parentElements: () => [],
|
|
3599
|
+
parentNavigate: () => {},
|
|
3600
|
+
parentPress: () => {}
|
|
3601
|
+
},
|
|
3602
|
+
delayGroup: {
|
|
3603
|
+
join: () => () => {},
|
|
3604
|
+
isWarm: () => false,
|
|
3605
|
+
opened: () => {},
|
|
3606
|
+
closed: () => {}
|
|
3607
|
+
},
|
|
1225
3608
|
modality: {
|
|
1226
3609
|
modality: () => "keyboard",
|
|
1227
3610
|
subscribe: () => () => {},
|
|
@@ -1366,6 +3749,10 @@ function testMachine(contract, options) {
|
|
|
1366
3749
|
if (missingProps.length > 0) options.test(`${contract.scope}: props read by guards`, async (..._) => {
|
|
1367
3750
|
throw new Error(missingProps.map((key) => `a guard reads prop "${key}": pass it in testMachine({ props })`).join("\n"));
|
|
1368
3751
|
});
|
|
3752
|
+
const reopenStats = {
|
|
3753
|
+
exercised: 0,
|
|
3754
|
+
skipped: 0
|
|
3755
|
+
};
|
|
1369
3756
|
const covered = /* @__PURE__ */ new Set();
|
|
1370
3757
|
/** Edges cut as not taken in some modality (reported only if no modality covers them). */
|
|
1371
3758
|
const notTaken = /* @__PURE__ */ new Set();
|
|
@@ -1394,12 +3781,17 @@ function testMachine(contract, options) {
|
|
|
1394
3781
|
platform,
|
|
1395
3782
|
locale: options.locale ?? "en",
|
|
1396
3783
|
direction,
|
|
1397
|
-
modality
|
|
3784
|
+
modality,
|
|
3785
|
+
reopen: reopenStats
|
|
1398
3786
|
};
|
|
1399
3787
|
options.test(name, (...args) => runPath(contract, graph, plannedPath, ctx, options, args, name));
|
|
1400
3788
|
}
|
|
1401
3789
|
}
|
|
1402
3790
|
});
|
|
3791
|
+
if (contract.traits.includes("presence")) options.test(`${contract.scope}: presence — reopen during exit exercised`, async (..._) => {
|
|
3792
|
+
console.info(`[rind-ui] ${contract.scope} presence: reopen during exit exercised ${reopenStats.exercised}, exit over before the hold ${reopenStats.skipped}`);
|
|
3793
|
+
if (reopenStats.exercised === 0 && reopenStats.skipped > 0) throw new Error(`${contract.scope}: reopen-during-exit never exercised: exit ended before hold (${reopenStats.skipped} closing steps)`);
|
|
3794
|
+
});
|
|
1403
3795
|
const failing = [];
|
|
1404
3796
|
const info = [];
|
|
1405
3797
|
for (const edge of graph.edges) {
|
|
@@ -1458,6 +3850,7 @@ function replayEnv(base, snapshot, mode) {
|
|
|
1458
3850
|
click: async () => {},
|
|
1459
3851
|
tap: async () => {},
|
|
1460
3852
|
focus: async () => {},
|
|
3853
|
+
focusWithTab: async () => {},
|
|
1461
3854
|
type: async (text) => {
|
|
1462
3855
|
if (mode !== "composing" || !isText(name) || text === "") return;
|
|
1463
3856
|
state.used = true;
|
|
@@ -1468,6 +3861,9 @@ function replayEnv(base, snapshot, mode) {
|
|
|
1468
3861
|
},
|
|
1469
3862
|
compose: async () => {},
|
|
1470
3863
|
pressAtPosition: async () => {},
|
|
3864
|
+
pointer: async () => {},
|
|
3865
|
+
drag: async () => {},
|
|
3866
|
+
fill: async () => {},
|
|
1471
3867
|
hover: async () => {
|
|
1472
3868
|
if (mode !== "touch-hover") return;
|
|
1473
3869
|
state.used = true;
|
|
@@ -1502,7 +3898,8 @@ function replayEnv(base, snapshot, mode) {
|
|
|
1502
3898
|
composing: true
|
|
1503
3899
|
});
|
|
1504
3900
|
},
|
|
1505
|
-
pointerOutside: async () => {}
|
|
3901
|
+
pointerOutside: async () => {},
|
|
3902
|
+
pointerAway: async () => {}
|
|
1506
3903
|
},
|
|
1507
3904
|
state
|
|
1508
3905
|
};
|
|
@@ -1522,6 +3919,7 @@ async function runPath(contract, graph, { path, notTaken }, ctx, options, args,
|
|
|
1522
3919
|
if (!env) {
|
|
1523
3920
|
env = directed(factory.create({
|
|
1524
3921
|
scope: contract.scope,
|
|
3922
|
+
...hostedPartName(contract),
|
|
1525
3923
|
anchor,
|
|
1526
3924
|
modality: m,
|
|
1527
3925
|
platform
|
|
@@ -1531,7 +3929,20 @@ async function runPath(contract, graph, { path, notTaken }, ctx, options, args,
|
|
|
1531
3929
|
return env;
|
|
1532
3930
|
};
|
|
1533
3931
|
const base = envFor(modality);
|
|
3932
|
+
/** The machines' delays: the virtual clock when the test gave one, else the adapter's time. */
|
|
3933
|
+
const elapse = async (ms) => {
|
|
3934
|
+
if (!options.clock) return base.advance(ms);
|
|
3935
|
+
options.clock.advance(ms);
|
|
3936
|
+
await base.advance(0);
|
|
3937
|
+
};
|
|
1534
3938
|
if (direction === "rtl") await base.setDirection("rtl");
|
|
3939
|
+
/** States the contract declares the component unmounted in (`absentIn`). */
|
|
3940
|
+
const absentIn = new Set(contract.absentIn ?? []);
|
|
3941
|
+
/**
|
|
3942
|
+
* The instance's snapshot. A contract with `absentIn` may have no anchor left (unmounted):
|
|
3943
|
+
* then only the document-wide fields. Without `absentIn`, unchanged (a missing anchor throws).
|
|
3944
|
+
*/
|
|
3945
|
+
const collect = async () => absentIn.size > 0 && await base.anchorCount() === 0 ? base.collectDocument() : base.collect();
|
|
1535
3946
|
const props = options.props ?? {};
|
|
1536
3947
|
const oracle = createOracle(contract, props);
|
|
1537
3948
|
/** Everything sent to the oracle, to replay "what if" events on a copy. */
|
|
@@ -1589,11 +4000,14 @@ async function runPath(contract, graph, { path, notTaken }, ctx, options, args,
|
|
|
1589
4000
|
return out;
|
|
1590
4001
|
};
|
|
1591
4002
|
const expectedFor = (state) => contract.states[state] ?? {};
|
|
1592
|
-
const matchesState = (state) => (seen) => Object.entries(expectedFor(state)).every(([k, v]) => Object.is(seen[k], v));
|
|
4003
|
+
const matchesState = (state) => (seen) => absentIn.has(state) || Object.entries(expectedFor(state)).every(([k, v]) => Object.is(seen[k], v));
|
|
1593
4004
|
/** The longest delay the machine can schedule under the current props. */
|
|
1594
4005
|
const longestDelay = () => Math.max(0, ...Object.values(impl.delays ?? {}).map((d) => {
|
|
1595
4006
|
try {
|
|
1596
|
-
return Number(d({
|
|
4007
|
+
return Number(d({
|
|
4008
|
+
props: oracle.props,
|
|
4009
|
+
context: oracle.service.getSnapshot().context
|
|
4010
|
+
})) || 0;
|
|
1597
4011
|
} catch {
|
|
1598
4012
|
return 0;
|
|
1599
4013
|
}
|
|
@@ -1604,7 +4018,7 @@ async function runPath(contract, graph, { path, notTaken }, ctx, options, args,
|
|
|
1604
4018
|
* delayed reaction (a tooltip's open delay) is seen.
|
|
1605
4019
|
*/
|
|
1606
4020
|
const unchanged = async (state, previous, wait = 16) => {
|
|
1607
|
-
await
|
|
4021
|
+
await elapse(wait);
|
|
1608
4022
|
const seen = await observe();
|
|
1609
4023
|
const changed = Object.keys(seen).filter((k) => JSON.stringify(seen[k]) !== JSON.stringify(previous[k]));
|
|
1610
4024
|
return {
|
|
@@ -1613,23 +4027,37 @@ async function runPath(contract, graph, { path, notTaken }, ctx, options, args,
|
|
|
1613
4027
|
changed
|
|
1614
4028
|
};
|
|
1615
4029
|
};
|
|
1616
|
-
const hoveredParts = async () => new Set((await
|
|
4030
|
+
const hoveredParts = async () => new Set((await collect()).parts.filter((p) => p.attrs["data-hover"] !== void 0).map((p) => p.describe));
|
|
1617
4031
|
/** The last step's facts: the base of the unmount-while-open check. */
|
|
1618
4032
|
/** Steps whose user action changed the value (form-associated: one `change` each). */
|
|
1619
4033
|
let userChanges = 0;
|
|
4034
|
+
/** The values the form carries, serialised (a user change compares them). */
|
|
4035
|
+
const formValues = () => {
|
|
4036
|
+
const values = oracle.service.view().values;
|
|
4037
|
+
const keys = contract.formInput?.values;
|
|
4038
|
+
return JSON.stringify(keys ? keys.map((k) => values[k]) : values);
|
|
4039
|
+
};
|
|
1620
4040
|
let lastFacts = null;
|
|
1621
4041
|
const verify = async (step, edge, before, from, baseline, stepModality, announcedBefore) => {
|
|
1622
4042
|
const state = oracle.service.getSnapshot().state;
|
|
1623
4043
|
const expected = expectedFor(state);
|
|
1624
4044
|
const matches = matchesState(state);
|
|
1625
|
-
const
|
|
4045
|
+
const absent = absentIn.has(state);
|
|
4046
|
+
const seen = absent ? await base.until(() => base.anchorCount(), (n) => n === 0).then(() => ({}), () => ({})) : await base.until(observe, matches).catch(async () => observe());
|
|
1626
4047
|
if (!matches(seen)) fail(step, edge, `${stepModality === "virtual" ? "virtual-parity: " : ""}expected ${state}: ${JSON.stringify(expected)}\n observed: ${JSON.stringify(seen)}`);
|
|
4048
|
+
if (contract.traits.includes("timed") && seen["isOpen"] === true) {
|
|
4049
|
+
const held = (await collect()).parts.filter((p) => p.attrs["data-hover"] !== void 0 || p.attrs["data-focus"] !== void 0);
|
|
4050
|
+
if (held.length > 0) {
|
|
4051
|
+
await elapse(longestDelay() + 16);
|
|
4052
|
+
if ((await observe())["isOpen"] !== true) fail(step, edge, `timed: closed by a timer while ${held.map((p) => p.describe).join(", ")} ${held.length === 1 ? "is" : "are"} hovered or focused (waited ${longestDelay() + 16} ms)`);
|
|
4053
|
+
}
|
|
4054
|
+
}
|
|
1627
4055
|
if (contract.traits.includes("presence")) {
|
|
1628
4056
|
const content = contract.semantics?.["content"];
|
|
1629
|
-
await base.until(async () => (await
|
|
4057
|
+
await base.until(async () => (await collect()).parts.filter((p) => p.part === content && p.animations > 0).length, (n) => n === 0).catch(() => {});
|
|
1630
4058
|
await base.advance(16);
|
|
1631
4059
|
}
|
|
1632
|
-
const after = await
|
|
4060
|
+
const after = await collect();
|
|
1633
4061
|
const facts = {
|
|
1634
4062
|
before,
|
|
1635
4063
|
after,
|
|
@@ -1637,8 +4065,10 @@ async function runPath(contract, graph, { path, notTaken }, ctx, options, args,
|
|
|
1637
4065
|
from,
|
|
1638
4066
|
state,
|
|
1639
4067
|
...expectations(contract, state, oracle.service.view()),
|
|
4068
|
+
fromInitial: from === graph.initial,
|
|
1640
4069
|
atInitial: state === graph.initial,
|
|
1641
4070
|
anchorCount: await base.anchorCount(),
|
|
4071
|
+
...absent ? { absent: true } : {},
|
|
1642
4072
|
errors: await base.takeErrors(),
|
|
1643
4073
|
traits: contract.traits,
|
|
1644
4074
|
semantics: { ...contract.semantics },
|
|
@@ -1650,8 +4080,13 @@ async function runPath(contract, graph, { path, notTaken }, ctx, options, args,
|
|
|
1650
4080
|
stepAnnouncements: (await base.announcements()).slice(announcedBefore),
|
|
1651
4081
|
observed: seen,
|
|
1652
4082
|
...contract.announcements ? { announcements: contract.announcements } : {},
|
|
4083
|
+
...contract.valued ? { valued: {
|
|
4084
|
+
values: contract.valued.values(oracle.service.view(), oracle.props),
|
|
4085
|
+
...contract.valued.valueText ? { valueText: (i) => contract.valued?.valueText?.(oracle.service.view(), i, oracle.props) ?? "" } : {}
|
|
4086
|
+
} } : {},
|
|
1653
4087
|
...contract.formInput ? { formInput: {
|
|
1654
4088
|
...contract.formInput.multiple ? { multiple: true } : {},
|
|
4089
|
+
...contract.formInput.accessible ? { accessible: true } : {},
|
|
1655
4090
|
expected: (input) => contract.formInput?.expected(oracle.service.view().values, input) ?? {},
|
|
1656
4091
|
userChanges
|
|
1657
4092
|
} } : {},
|
|
@@ -1666,12 +4101,13 @@ async function runPath(contract, graph, { path, notTaken }, ctx, options, args,
|
|
|
1666
4101
|
console.info(`[rind-ui] ${contract.scope}: Chromium accessibility-tree checks skipped (unavailable here)`);
|
|
1667
4102
|
}
|
|
1668
4103
|
} else if (chromium) problems.push(...chromium.map((p) => `chromium-tree: ${p}`));
|
|
1669
|
-
const own = [...contract.invariants ?? [], ...options.invariants ?? []];
|
|
4104
|
+
const own = [...absent ? [] : contract.invariants ?? [], ...options.invariants ?? []];
|
|
1670
4105
|
for (const inv of own) {
|
|
1671
4106
|
const result = await inv.check({
|
|
1672
4107
|
env: base,
|
|
1673
4108
|
state,
|
|
1674
4109
|
modality,
|
|
4110
|
+
stepModality,
|
|
1675
4111
|
props: oracle.props,
|
|
1676
4112
|
values: oracle.service.view().values
|
|
1677
4113
|
}).catch((e) => e instanceof Error ? e.message : String(e));
|
|
@@ -1708,15 +4144,24 @@ async function runPath(contract, graph, { path, notTaken }, ctx, options, args,
|
|
|
1708
4144
|
* reopened — the exiting element must come back, not a new one — and closed again by the
|
|
1709
4145
|
* same action, so the path goes on from the state it reached.
|
|
1710
4146
|
*/
|
|
1711
|
-
const reopenDuringExit = async (step, edge, close) => {
|
|
4147
|
+
const reopenDuringExit = async (step, edge, close, held) => {
|
|
4148
|
+
const { resume } = held;
|
|
1712
4149
|
const content = contract.semantics?.["content"];
|
|
1713
|
-
const exiting = (await
|
|
1714
|
-
if (!exiting)
|
|
4150
|
+
const exiting = (await collect()).parts.find((p) => p.part === content && p.animations > 0);
|
|
4151
|
+
if (!exiting) {
|
|
4152
|
+
if (held.animatedBefore && ctx.reopen) ctx.reopen.skipped += 1;
|
|
4153
|
+
await resume();
|
|
4154
|
+
return;
|
|
4155
|
+
}
|
|
4156
|
+
if (ctx.reopen) ctx.reopen.exercised += 1;
|
|
1715
4157
|
if (exiting.attrs["data-state"] !== "closed") fail(step, edge, `presence: ${exiting.describe} is exiting (running animations: ${exiting.animations}) without data-state="closed"`);
|
|
1716
4158
|
const state = oracle.service.getSnapshot().state;
|
|
1717
4159
|
const reopen = graph.edges.find((e) => e.source === state && e.target !== null && expectations(contract, e.target, null).open && mappingOf(contract, e)?.kind === "action");
|
|
1718
4160
|
const m = reopen ? mappingOf(contract, reopen) : void 0;
|
|
1719
|
-
if (!reopen || m?.kind !== "action")
|
|
4161
|
+
if (!reopen || m?.kind !== "action") {
|
|
4162
|
+
await resume();
|
|
4163
|
+
return;
|
|
4164
|
+
}
|
|
1720
4165
|
const action = contract.actions[m.action] ?? {};
|
|
1721
4166
|
const mod = stepModality(action, "keyboard");
|
|
1722
4167
|
const act = async (name, args, m) => {
|
|
@@ -1728,7 +4173,8 @@ async function runPath(contract, graph, { path, notTaken }, ctx, options, args,
|
|
|
1728
4173
|
};
|
|
1729
4174
|
send(reopen.event, { modality: mod });
|
|
1730
4175
|
await act(m.action, m.args?.(oracle.service.view()) ?? [], mod);
|
|
1731
|
-
const back = (await
|
|
4176
|
+
const back = (await collect()).parts.find((p) => p.part === content);
|
|
4177
|
+
await resume();
|
|
1732
4178
|
if (back?.node !== exiting.node) fail(step, edge, `presence: reopening during the exit (running animations: ${exiting.animations}) ${back ? `mounted a new ${back.describe}` : "left no content"}; the exiting element must be kept`);
|
|
1733
4179
|
send(edge.event, { modality: close.mod });
|
|
1734
4180
|
await act(close.action, close.args, close.mod);
|
|
@@ -1743,9 +4189,16 @@ async function runPath(contract, graph, { path, notTaken }, ctx, options, args,
|
|
|
1743
4189
|
const announcedBefore = (await base.announcements()).length;
|
|
1744
4190
|
let stepMod = null;
|
|
1745
4191
|
if (mapping?.kind === "delay") {
|
|
1746
|
-
const ms = impl.delays?.[edge.event.slice(6)]?.({
|
|
4192
|
+
const ms = impl.delays?.[edge.event.slice(6)]?.({
|
|
4193
|
+
props: oracle.props,
|
|
4194
|
+
context: oracle.service.getSnapshot().context
|
|
4195
|
+
}) ?? 0;
|
|
4196
|
+
const valuesBefore = formValues();
|
|
1747
4197
|
send(edge.event);
|
|
1748
|
-
|
|
4198
|
+
if (contract.formInput && formValues() !== valuesBefore && !contract.formInput.silentEvents?.includes(edge.event)) userChanges += 1;
|
|
4199
|
+
const firedBefore = options.clock?.fired() ?? 0;
|
|
4200
|
+
await elapse(ms);
|
|
4201
|
+
if (options.clock && options.clock.fired() === firedBefore) throw new Error(`${edge.event}: no timer fired on the virtual clock; pass clock.scheduler as RindProvider environment={{ scheduler }}`);
|
|
1749
4202
|
} else if (mapping?.kind === "props") {
|
|
1750
4203
|
const next = {
|
|
1751
4204
|
...oracle.props,
|
|
@@ -1767,17 +4220,26 @@ async function runPath(contract, graph, { path, notTaken }, ctx, options, args,
|
|
|
1767
4220
|
if (stepMod === "keyboard" && typeof keyboardImpl === "function") await replay(i + 1, edge, "composing", keyboardImpl, actionArgs, before, from);
|
|
1768
4221
|
const ownImpl = action[stepMod === "virtual" ? "pointer" : stepMod];
|
|
1769
4222
|
if (typeof ownImpl === "function") await replay(i + 1, edge, "touch-hover", ownImpl, actionArgs, before, from);
|
|
1770
|
-
const valuesBefore =
|
|
4223
|
+
const valuesBefore = formValues();
|
|
1771
4224
|
send(edge.event, {
|
|
1772
4225
|
...mapping.event?.(oracle.service.view()),
|
|
1773
4226
|
modality: stepMod
|
|
1774
4227
|
});
|
|
1775
|
-
if (
|
|
4228
|
+
if (contract.formInput?.nativeEvents?.includes(edge.event)) userChanges += 1;
|
|
4229
|
+
else if (formValues() !== valuesBefore && !contract.formInput?.silentEvents?.includes(edge.event)) userChanges += 1;
|
|
4230
|
+
const willClose = edge !== notTaken && edge.target !== null && expectations(contract, from, null).open && !expectations(contract, edge.target, null).open;
|
|
4231
|
+
if (contract.traits.includes("presence") && willClose) await base.armHold?.();
|
|
1776
4232
|
try {
|
|
1777
4233
|
await runAction(contract, envFor(stepMod), mapping.action, actionArgs, edge !== notTaken);
|
|
1778
4234
|
} catch (e) {
|
|
1779
4235
|
fail(i + 1, edge, e instanceof Error ? e.message : String(e));
|
|
1780
4236
|
}
|
|
4237
|
+
const closesNow = edge !== notTaken && edge.target !== null && expectations(contract, from, null).open && !expectations(contract, edge.target, null).open;
|
|
4238
|
+
const animatedBefore = before?.parts.some((p) => p.part === contract.semantics?.["content"] && p.motion) === true;
|
|
4239
|
+
const held = contract.traits.includes("presence") && closesNow && base.holdAnimations ? {
|
|
4240
|
+
resume: await base.holdAnimations(),
|
|
4241
|
+
animatedBefore
|
|
4242
|
+
} : void 0;
|
|
1781
4243
|
const closes = edge !== notTaken && edge.target !== null && expectations(contract, from, null).open && !expectations(contract, edge.target, null).open;
|
|
1782
4244
|
if (options.activations) {
|
|
1783
4245
|
const { action: name, count } = options.activations;
|
|
@@ -1792,7 +4254,11 @@ async function runPath(contract, graph, { path, notTaken }, ctx, options, args,
|
|
|
1792
4254
|
action: mapping.action,
|
|
1793
4255
|
args: actionArgs,
|
|
1794
4256
|
mod: stepMod
|
|
4257
|
+
}, held ?? {
|
|
4258
|
+
resume: async () => {},
|
|
4259
|
+
animatedBefore: false
|
|
1795
4260
|
});
|
|
4261
|
+
else await held?.resume();
|
|
1796
4262
|
} else fail(i + 1, edge, `no contract mapping for ${edge.event}`);
|
|
1797
4263
|
done.push(`${edge.event}→${oracle.service.getSnapshot().state}`);
|
|
1798
4264
|
before = await verify(i + 1, edge, before, from, baseline, stepMod, announcedBefore);
|
|
@@ -1837,6 +4303,63 @@ async function runPath(contract, graph, { path, notTaken }, ctx, options, args,
|
|
|
1837
4303
|
});
|
|
1838
4304
|
}
|
|
1839
4305
|
//#endregion
|
|
4306
|
+
//#region src/number-input-invariants.ts
|
|
4307
|
+
const ROOT = "[data-scope=\"number-input\"][data-part=\"root\"]";
|
|
4308
|
+
const TABBABLE = "a[href], button, input, select, textarea, [tabindex], [contenteditable=\"true\"]";
|
|
4309
|
+
/**
|
|
4310
|
+
* `changes` reads how often the page's `onValueChange` ran, `expectedChanges` the oracle's
|
|
4311
|
+
* (pass a counting `onValueChange` in the oracle's props).
|
|
4312
|
+
*/
|
|
4313
|
+
function numberInputStepInvariants(options = {}) {
|
|
4314
|
+
let lastActive;
|
|
4315
|
+
let pointerPressed = false;
|
|
4316
|
+
globalThis.document?.addEventListener("pointerdown", () => {
|
|
4317
|
+
pointerPressed = true;
|
|
4318
|
+
}, true);
|
|
4319
|
+
return {
|
|
4320
|
+
invariants: [
|
|
4321
|
+
{
|
|
4322
|
+
name: "number-input-one-tab-stop",
|
|
4323
|
+
check: async () => {
|
|
4324
|
+
const doc = globalThis.document;
|
|
4325
|
+
if (!doc) return void 0;
|
|
4326
|
+
for (const root of Array.from(doc.querySelectorAll(ROOT))) {
|
|
4327
|
+
const extra = Array.from(root.querySelectorAll(TABBABLE)).filter((el) => el.tabIndex >= 0 && !el.disabled).filter((el) => el.getAttribute("data-part") !== "input");
|
|
4328
|
+
if (extra.length > 0) return `parts in the tab order besides the input: ${extra.map((el) => el.getAttribute("data-part") ?? el.tagName).join(", ")}`;
|
|
4329
|
+
}
|
|
4330
|
+
}
|
|
4331
|
+
},
|
|
4332
|
+
{
|
|
4333
|
+
name: "number-input-touch-keeps-focus",
|
|
4334
|
+
check: async ({ stepModality: modality }) => {
|
|
4335
|
+
const active = globalThis.document?.activeElement ?? null;
|
|
4336
|
+
const before = lastActive;
|
|
4337
|
+
lastActive = active;
|
|
4338
|
+
const pressed = pointerPressed;
|
|
4339
|
+
pointerPressed = false;
|
|
4340
|
+
if (pressed && modality === "virtual") return void 0;
|
|
4341
|
+
if (before === void 0 || modality !== "touch" && modality !== "virtual") return void 0;
|
|
4342
|
+
if (active === before) return void 0;
|
|
4343
|
+
const moved = active?.closest?.(ROOT) ? active.getAttribute("data-part") : null;
|
|
4344
|
+
return moved ? `a ${modality} step moved focus to the ${moved}` : void 0;
|
|
4345
|
+
}
|
|
4346
|
+
},
|
|
4347
|
+
{
|
|
4348
|
+
name: "number-input-change-count",
|
|
4349
|
+
check: async () => {
|
|
4350
|
+
if (!options.changes || !options.expectedChanges) return void 0;
|
|
4351
|
+
const [have, want] = [options.changes(), options.expectedChanges()];
|
|
4352
|
+
return have === want ? void 0 : `onValueChange ran ${have} times, the oracle ${want}`;
|
|
4353
|
+
}
|
|
4354
|
+
}
|
|
4355
|
+
],
|
|
4356
|
+
reset() {
|
|
4357
|
+
lastActive = void 0;
|
|
4358
|
+
pointerPressed = false;
|
|
4359
|
+
}
|
|
4360
|
+
};
|
|
4361
|
+
}
|
|
4362
|
+
//#endregion
|
|
1840
4363
|
//#region src/positioning.ts
|
|
1841
4364
|
function fakePositioning() {
|
|
1842
4365
|
const live = /* @__PURE__ */ new Set();
|
|
@@ -1911,6 +4434,71 @@ function englishLeaks(defaults, texts) {
|
|
|
1911
4434
|
return Object.values(defaults).filter((v) => typeof v === "string").filter((e) => texts.some((t) => t.includes(e)));
|
|
1912
4435
|
}
|
|
1913
4436
|
//#endregion
|
|
4437
|
+
//#region src/slider-invariants.ts
|
|
4438
|
+
const FOCUSABLE = "a[href], button, input, select, textarea, [tabindex], [contenteditable=\"true\"], [role=\"slider\"]";
|
|
4439
|
+
/**
|
|
4440
|
+
* `commits` reads how often the page's `onValueCommit` ran; `expectedCommits` how often the
|
|
4441
|
+
* oracle's did (pass a spy as the oracle's `onValueCommit` prop).
|
|
4442
|
+
*/
|
|
4443
|
+
function sliderStepInvariants(options = {}) {
|
|
4444
|
+
const scope = options.naming?.scope ?? "slider";
|
|
4445
|
+
const name = (part) => options.naming?.part(part) ?? part;
|
|
4446
|
+
const THUMB_INPUT = `[data-scope="${scope}"][data-part="${name("hidden-input")}"]`;
|
|
4447
|
+
const ROOT = `[data-scope="${scope}"][data-part="${name("root")}"]`;
|
|
4448
|
+
let refocused = [];
|
|
4449
|
+
let inKey = false;
|
|
4450
|
+
const doc = globalThis.document;
|
|
4451
|
+
const onKeyDown = () => {
|
|
4452
|
+
inKey = true;
|
|
4453
|
+
setTimeout(() => {
|
|
4454
|
+
inKey = false;
|
|
4455
|
+
}, 0);
|
|
4456
|
+
};
|
|
4457
|
+
const onFocusChange = (e) => {
|
|
4458
|
+
const target = e.target;
|
|
4459
|
+
if (inKey && target?.matches?.(THUMB_INPUT)) refocused.push(`${e.type} on thumb input ${target.getAttribute("data-index")}`);
|
|
4460
|
+
};
|
|
4461
|
+
if (doc) {
|
|
4462
|
+
doc.addEventListener("keydown", onKeyDown, true);
|
|
4463
|
+
doc.addEventListener("focusin", onFocusChange, true);
|
|
4464
|
+
doc.addEventListener("focusout", onFocusChange, true);
|
|
4465
|
+
}
|
|
4466
|
+
return {
|
|
4467
|
+
invariants: [
|
|
4468
|
+
{
|
|
4469
|
+
name: "slider-no-refocus-on-key",
|
|
4470
|
+
check: async () => {
|
|
4471
|
+
const out = refocused;
|
|
4472
|
+
refocused = [];
|
|
4473
|
+
return out.length > 0 ? `focus moved during a key step: ${out.join(", ")}` : void 0;
|
|
4474
|
+
}
|
|
4475
|
+
},
|
|
4476
|
+
{
|
|
4477
|
+
name: "slider-only-thumb-inputs-focusable",
|
|
4478
|
+
check: async () => {
|
|
4479
|
+
if (!doc) return void 0;
|
|
4480
|
+
for (const root of Array.from(doc.querySelectorAll(ROOT))) {
|
|
4481
|
+
const extra = Array.from(root.querySelectorAll(FOCUSABLE)).filter((el) => !el.matches(THUMB_INPUT));
|
|
4482
|
+
if (extra.length > 0) return `elements other than the thumb inputs are focusable or sliders: ${extra.map((el) => el.outerHTML.slice(0, 80)).join(", ")}`;
|
|
4483
|
+
}
|
|
4484
|
+
}
|
|
4485
|
+
},
|
|
4486
|
+
{
|
|
4487
|
+
name: "slider-commit-count",
|
|
4488
|
+
check: async () => {
|
|
4489
|
+
if (!options.commits || !options.expectedCommits) return void 0;
|
|
4490
|
+
const [have, want] = [options.commits(), options.expectedCommits()];
|
|
4491
|
+
return have === want ? void 0 : `onValueCommit ran ${have} times, the oracle ${want}`;
|
|
4492
|
+
}
|
|
4493
|
+
}
|
|
4494
|
+
],
|
|
4495
|
+
reset() {
|
|
4496
|
+
refocused = [];
|
|
4497
|
+
inKey = false;
|
|
4498
|
+
}
|
|
4499
|
+
};
|
|
4500
|
+
}
|
|
4501
|
+
//#endregion
|
|
1914
4502
|
//#region src/state-stories.ts
|
|
1915
4503
|
/** States of `contract` with no state story (empty when covered). */
|
|
1916
4504
|
function missingStateStories(contract, stories, storyExports) {
|
|
@@ -1978,6 +4566,116 @@ function textFieldStepInvariants(options = {}) {
|
|
|
1978
4566
|
};
|
|
1979
4567
|
}
|
|
1980
4568
|
//#endregion
|
|
4569
|
+
//#region src/text-field-key-invariants.ts
|
|
4570
|
+
/**
|
|
4571
|
+
* - `text-field-escape-consumed`: an Escape on a non-empty editable field left focus in the
|
|
4572
|
+
* input and was prevented; on an empty one (or read-only, disabled) it was not, so an
|
|
4573
|
+
* enclosing layer gets it (react-spectrum#5480);
|
|
4574
|
+
* - `text-field-ime-keys`: an Escape or Enter marked composing neither cleared the value nor
|
|
4575
|
+
* searched (react-spectrum#10249, #6421). `submits` counts the story's `onSubmit` calls.
|
|
4576
|
+
*/
|
|
4577
|
+
function textFieldKeyStepInvariants(options = {}) {
|
|
4578
|
+
let keys = [];
|
|
4579
|
+
const submits = options.submits ?? (() => 0);
|
|
4580
|
+
const close = (k) => {
|
|
4581
|
+
if (k && !k.after) k.after = {
|
|
4582
|
+
value: k.input.value,
|
|
4583
|
+
submits: submits()
|
|
4584
|
+
};
|
|
4585
|
+
};
|
|
4586
|
+
const take = () => {
|
|
4587
|
+
close(keys.at(-1));
|
|
4588
|
+
const out = keys;
|
|
4589
|
+
keys = [];
|
|
4590
|
+
return out;
|
|
4591
|
+
};
|
|
4592
|
+
return {
|
|
4593
|
+
invariants: [{
|
|
4594
|
+
name: "text-field-escape-consumed",
|
|
4595
|
+
check: async () => {
|
|
4596
|
+
for (const k of keys) {
|
|
4597
|
+
if (k.event.key !== "Escape" || k.composing) continue;
|
|
4598
|
+
const handles = k.value !== "" && k.editable;
|
|
4599
|
+
if (handles && !k.event.defaultPrevented) return `Escape on "${k.value}" was not prevented (an enclosing layer would also close)`;
|
|
4600
|
+
if (handles && k.input.ownerDocument.activeElement !== k.input) return "Escape cleared the field but focus left the input";
|
|
4601
|
+
if (!handles && k.event.defaultPrevented) return `Escape on ${k.value === "" ? "an empty" : "a non-editable"} field was prevented (it belongs to the enclosing layer)`;
|
|
4602
|
+
}
|
|
4603
|
+
}
|
|
4604
|
+
}, {
|
|
4605
|
+
name: "text-field-ime-keys",
|
|
4606
|
+
check: async () => {
|
|
4607
|
+
for (const k of take()) {
|
|
4608
|
+
if (!k.composing) continue;
|
|
4609
|
+
if (k.event.key === "Escape" && k.value !== "" && k.after?.value === "") return "an Escape during a composition cleared the value";
|
|
4610
|
+
if (k.event.key === "Enter" && (k.after?.submits ?? 0) > k.submitsBefore) return "an Enter during a composition searched (onSubmit was called)";
|
|
4611
|
+
}
|
|
4612
|
+
}
|
|
4613
|
+
}],
|
|
4614
|
+
reset() {
|
|
4615
|
+
keys = [];
|
|
4616
|
+
const onKey = (event) => {
|
|
4617
|
+
const input = event.target;
|
|
4618
|
+
if (!(input instanceof HTMLInputElement) || input.type !== "search") return;
|
|
4619
|
+
if (event.key !== "Escape" && event.key !== "Enter") return;
|
|
4620
|
+
close(keys.at(-1));
|
|
4621
|
+
keys.push({
|
|
4622
|
+
event,
|
|
4623
|
+
input,
|
|
4624
|
+
value: input.value,
|
|
4625
|
+
editable: !input.disabled && !input.readOnly,
|
|
4626
|
+
composing: event.isComposing || event.keyCode === 229 || input.hasAttribute("data-composing"),
|
|
4627
|
+
submitsBefore: submits()
|
|
4628
|
+
});
|
|
4629
|
+
};
|
|
4630
|
+
window.addEventListener("keydown", onKey, true);
|
|
4631
|
+
return () => window.removeEventListener("keydown", onKey, true);
|
|
4632
|
+
}
|
|
4633
|
+
};
|
|
4634
|
+
}
|
|
4635
|
+
//#endregion
|
|
4636
|
+
//#region src/virtual-clock.ts
|
|
4637
|
+
function virtualClock() {
|
|
4638
|
+
let now = 0;
|
|
4639
|
+
let seq = 0;
|
|
4640
|
+
let fired = 0;
|
|
4641
|
+
const timers = /* @__PURE__ */ new Map();
|
|
4642
|
+
return {
|
|
4643
|
+
scheduler: {
|
|
4644
|
+
setTimeout: (callback, ms) => {
|
|
4645
|
+
const id = ++seq;
|
|
4646
|
+
timers.set(id, {
|
|
4647
|
+
at: now + Math.max(0, ms),
|
|
4648
|
+
callback
|
|
4649
|
+
});
|
|
4650
|
+
return id;
|
|
4651
|
+
},
|
|
4652
|
+
clearTimeout: (handle) => {
|
|
4653
|
+
timers.delete(handle);
|
|
4654
|
+
},
|
|
4655
|
+
requestAnimationFrame: (callback) => globalThis.requestAnimationFrame(() => callback()),
|
|
4656
|
+
cancelAnimationFrame: (handle) => globalThis.cancelAnimationFrame(handle)
|
|
4657
|
+
},
|
|
4658
|
+
advance(ms) {
|
|
4659
|
+
const end = now + ms;
|
|
4660
|
+
for (;;) {
|
|
4661
|
+
let next;
|
|
4662
|
+
for (const entry of timers) {
|
|
4663
|
+
if (entry[1].at > end) continue;
|
|
4664
|
+
if (!next || entry[1].at < next[1].at) next = entry;
|
|
4665
|
+
}
|
|
4666
|
+
if (!next) break;
|
|
4667
|
+
timers.delete(next[0]);
|
|
4668
|
+
now = next[1].at;
|
|
4669
|
+
fired += 1;
|
|
4670
|
+
next[1].callback();
|
|
4671
|
+
}
|
|
4672
|
+
now = end;
|
|
4673
|
+
},
|
|
4674
|
+
pending: () => timers.size,
|
|
4675
|
+
fired: () => fired
|
|
4676
|
+
};
|
|
4677
|
+
}
|
|
4678
|
+
//#endregion
|
|
1981
4679
|
//#region src/virtual-sr.ts
|
|
1982
4680
|
/**
|
|
1983
4681
|
* Starts the virtual screen reader on `container`, runs `run(virtual)` (move with
|
|
@@ -2004,4 +4702,4 @@ function liveAnnouncements(log) {
|
|
|
2004
4702
|
});
|
|
2005
4703
|
}
|
|
2006
4704
|
//#endregion
|
|
2007
|
-
export { accordionStepInvariants, checkGeneric, checkboxStepInvariants, createDriver, createDriverWith, currentRun, domEnv, englishLeaks, fakePositioning, fakeRouter, formStepInvariants, genericInvariants, getAccordion, getButton, getCheckbox, getCheckboxGroup, getCollapsible, getField, getFieldset, getForm, getHeading, getLabel, getLink, getRadioGroup, getSegmentedControl, getSeparator, getSwitch, getTabs, getTextField, getToggle, getToggleGroup, getToolbar, installAnnouncementLog, interceptNativeNavigation, layoutInvariant, liveAnnouncements, machinePaths, missingAriaLines, missingStateStories, navigationLog, paths, platforms, playwrightEnv, pseudo, pseudoMessages, recordingAnnouncer, runAction, spokenLog, switchStepInvariants, testMachine, textFieldStepInvariants, toGraph, traitInvariants, uncovered, withEngine };
|
|
4705
|
+
export { QrDecodeError, accordionStepInvariants, checkGeneric, checkboxStepInvariants, correctBlock, createDriver, createDriverWith, currentRun, decodeQr, domEnv, englishLeaks, fakeDelayGroup, fakeHoverIntent, fakePositioning, fakeRouter, fakeVisibility, fixedDateClock, formStepInvariants, genericInvariants, getAccordion, getAlert, getAlertDialog, getAvatar, getBadge, getBreadcrumbs, getButton, getCalendar, getCheckbox, getCheckboxGroup, getCollapsible, getColorPicker, getCombobox, getContextMenu, getDialog, getDrawer, getField, getFieldset, getForm, getHeading, getHoverCard, getImage, getLabel, getLink, getListbox, getMenu, getMeter, getNumberInput, getPagination, getPinInput, getPopover, getProgress, getQrCode, getRadioGroup, getScrollArea, getSegmentedControl, getSelect, getSeparator, getSkeleton, getSlider, getSwitch, getTabs, getTagsInput, getTextField, getToast, getToaster, getToggle, getToggleGroup, getToolbar, getTooltip, getTour, installAnnouncementLog, interceptNativeNavigation, layoutInvariant, liveAnnouncements, machinePaths, missingAriaLines, missingStateStories, navigationLog, numberInputStepInvariants, parseQrPath, paths, platforms, playwrightEnv, pseudo, pseudoMessages, qrCodeDecodingContract, recordingAnnouncer, runAction, sliderStepInvariants, spokenLog, switchStepInvariants, testMachine, textFieldKeyStepInvariants, textFieldStepInvariants, toGraph, traitInvariants, uncovered, virtualClock, withEngine };
|