@unotest/web 0.49.0 → 0.49.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import { InjectedDomHelpers } from '@unotest/grounder-client/dom-walker';
2
2
  import { PickerMode } from '@unotest/protocol';
3
- import { E as ElementHint } from '../interfaces-CTMGjJIs.js';
3
+ import { E as ElementHint } from '../interfaces-D5ePwBX6.js';
4
4
  import '../config/schema.js';
5
5
  import 'zod';
6
6
 
@@ -434,6 +434,21 @@ declare function readComputedStyle(el: Element, property: string): string;
434
434
  * is not counted — waiting for it could only time out; neither is a
435
435
  * paused one, which ends only when the page resumes it. */
436
436
  declare function countRunningAnimations(el: Element): number;
437
+ /** What `getImageSize` reads off an element: its tag, whether the image
438
+ * has settled (`complete`: loaded, failed, or nothing to load), its
439
+ * natural size, and whether it is lazy — a lazy image outside the
440
+ * viewport never starts loading, which is the usual reason it never
441
+ * settles. */
442
+ interface ImageState {
443
+ tag: string;
444
+ complete: boolean;
445
+ width: number;
446
+ height: number;
447
+ lazy: boolean;
448
+ }
449
+ declare function readImageState(el: Element): ImageState;
450
+ /** Whether an `<img>` has settled — the predicate `getImageSize` waits on. */
451
+ declare function isImageComplete(el: Element): boolean;
437
452
  /** Write a localStorage item. Key and value travel as one array because
438
453
  * Playwright's `evaluate(fn, arg)` passes a SINGLE argument. */
439
454
  declare function writeLocalStorageItem([key, value]: [string, string]): void;
@@ -449,4 +464,4 @@ declare function inspectElementRaw(el: Element, args: {
449
464
  };
450
465
  }): ElementHintRaw;
451
466
 
452
- export { type ElementHintRaw, ariaSnapshotAlgorithm, countRunningAnimations, findElementAlgorithm, inspectElementRaw, outlineAlgorithm, pasteValue, pickerOverlayAlgorithm, readCheckedState, readComputedStyle, readDisabledState, readLocalStorageItem, semanticDomAlgorithm, serializeRuntimeDom, writeLocalStorageItem };
467
+ export { type ElementHintRaw, type ImageState, ariaSnapshotAlgorithm, countRunningAnimations, findElementAlgorithm, inspectElementRaw, isImageComplete, outlineAlgorithm, pasteValue, pickerOverlayAlgorithm, readCheckedState, readComputedStyle, readDisabledState, readImageState, readLocalStorageItem, semanticDomAlgorithm, serializeRuntimeDom, writeLocalStorageItem };
@@ -2801,6 +2801,25 @@ function countRunningAnimations(el) {
2801
2801
  return el.getAnimations({ subtree: true }).filter((a) => a.playState === "running" && a.effect?.getComputedTiming().iterations !== Infinity).length;
2802
2802
  }
2803
2803
  __name(countRunningAnimations, "countRunningAnimations");
2804
+ function readImageState(el) {
2805
+ globalThis.__name ??= (fn) => fn;
2806
+ const tag = el.tagName.toLowerCase();
2807
+ if (tag !== "img") return { tag, complete: true, width: 0, height: 0, lazy: false };
2808
+ const img = el;
2809
+ return {
2810
+ tag,
2811
+ complete: img.complete,
2812
+ width: img.naturalWidth,
2813
+ height: img.naturalHeight,
2814
+ lazy: img.loading === "lazy"
2815
+ };
2816
+ }
2817
+ __name(readImageState, "readImageState");
2818
+ function isImageComplete(el) {
2819
+ globalThis.__name ??= (fn) => fn;
2820
+ return el.complete;
2821
+ }
2822
+ __name(isImageComplete, "isImageComplete");
2804
2823
  function writeLocalStorageItem([key, value]) {
2805
2824
  globalThis.__name ??= (fn) => fn;
2806
2825
  localStorage.setItem(key, value);
@@ -3013,12 +3032,14 @@ export {
3013
3032
  countRunningAnimations,
3014
3033
  findElementAlgorithm,
3015
3034
  inspectElementRaw,
3035
+ isImageComplete,
3016
3036
  outlineAlgorithm,
3017
3037
  pasteValue,
3018
3038
  pickerOverlayAlgorithm,
3019
3039
  readCheckedState,
3020
3040
  readComputedStyle,
3021
3041
  readDisabledState,
3042
+ readImageState,
3022
3043
  readLocalStorageItem,
3023
3044
  semanticDomAlgorithm,
3024
3045
  serializeRuntimeDom,
@@ -654,6 +654,13 @@ interface DriverPage {
654
654
  * `getComputedStyle(el).getPropertyValue(property)` gives it — custom
655
655
  * properties (`--accent`) included; "" for one that is not set. */
656
656
  computedStyle(loc: LocatorValue, property: string): Promise<string>;
657
+ /** Natural size of the matched `<img>` once it has settled (loaded or
658
+ * failed), within the action timeout; `null` when it has no pixels —
659
+ * broken, or no src. The one query that waits: "still loading" is not
660
+ * an answer, and reading too early would report a good image as broken.
661
+ * A `LocatorError` for an element that is not an `<img>`, a
662
+ * `TimeoutError` for one that never settles. */
663
+ imageSize(loc: LocatorValue): Promise<ImageSize | null>;
657
664
  /** Wait for a DOM-presence state (`attached`/`detached`/`visible`/
658
665
  * `hidden`) or an interaction state (`enabled`/`disabled`). The latter
659
666
  * is polled against `isDisabled`, so `aria-disabled` widgets count. */
@@ -729,6 +736,11 @@ interface BoundingBox {
729
736
  width: number;
730
737
  height: number;
731
738
  }
739
+ /** An image's natural size, in its own pixels. */
740
+ interface ImageSize {
741
+ width: number;
742
+ height: number;
743
+ }
732
744
  /** How `inspectElement` reads the element's `readable` text. By default
733
745
  * whitespace folded and clipped to 200 — a hint. `whole` keeps the text as
734
746
  * it is, up to `limit` characters, for a refusal that quotes it (#256). */
@@ -857,4 +869,4 @@ interface PageConsole {
857
869
  errors: readonly PageErrorEntry[];
858
870
  }
859
871
 
860
- export { type AttachOptions as A, type BoundingBox as B, type CaptureFrame as C, type DriverContext as D, type ElementHint as E, type FillOptions as F, type GotoOptions as G, type HoverOptions as H, type LocatorValue as L, type NetworkEntry as N, type PageConsole as P, type ReloadOptions as R, type ScreenshotOptions as S, type Viewport as V, type WebDriver as W, type CaptureRect as a, type LaunchOptions as b, type ContextOptions as c, type ActionTimeout as d, type CheckOptions as e, type ClickOptions as f, type CookieOptions as g, type DriverPage as h, type NavigationOptions as i, type PressOptions as j, type SelectOptions as k, type ViewportSize as l, type WaitOptions as m, type WaitState as n, type DriverDownload as o, type LocatorStep as p, appendStep as q, describeLocator as r, isLocatorValue as s, rootedAt as t };
872
+ export { type AttachOptions as A, type BoundingBox as B, type CaptureFrame as C, type DriverContext as D, type ElementHint as E, type FillOptions as F, type GotoOptions as G, type HoverOptions as H, type ImageSize as I, type LocatorValue as L, type NetworkEntry as N, type PageConsole as P, type ReloadOptions as R, type ScreenshotOptions as S, type Viewport as V, type WebDriver as W, type CaptureRect as a, type LaunchOptions as b, type ContextOptions as c, type ActionTimeout as d, type CheckOptions as e, type ClickOptions as f, type CookieOptions as g, type DriverPage as h, type NavigationOptions as i, type PressOptions as j, type SelectOptions as k, type ViewportSize as l, type WaitOptions as m, type WaitState as n, type DriverDownload as o, type LocatorStep as p, appendStep as q, describeLocator as r, isLocatorValue as s, rootedAt as t };