testplane
Version:
Tests framework based on mocha and wdio
71 lines (70 loc) • 4.28 kB
TypeScript
import { Image } from "../../../image";
import { YBand, Rect } from "../../isomorphic/geometry";
import type { CaptureSpec } from "../../client-scripts/screen-shooter/types";
export declare class CompositeImage {
private _captureAreaSize;
private _compositeChunks;
private _debugTmpDir;
/** Creates a composite renderer instance while preserving subclass construction. */
static create(...args: ConstructorParameters<typeof CompositeImage>): CompositeImage;
/** Initializes chunk storage and an optional debug-output directory. */
constructor();
/**
* Registers a viewport image with corresponding safe area, capture bounding rects and ignore bounding rects, all relative to the viewport.
* The order of registration can be arbitrary, viewport height can change between chunks, gaps will be handled gracefully.
* Expects finite integer coords and sizes, otherwise behavior is undefined.
* @throws {Error} if capture area size is zero or negative
*/
registerViewportImageAtOffset(viewportImage: Image, safeArea: YBand<"viewport", "device">, captureSpecs: CaptureSpec<"viewport", "device">[], ignoreBoundingRects: Rect<"viewport", "device">[], anchorShift?: number | null): Promise<void>;
/**
* Renders a composite image from the registered chunks.
* @throws {Error} if trying to render with zero chunks registered
* @throws {Error} if any of the chunks contain malformed PNG data
*/
render(): Promise<Image>;
/**
* Computes anchor tops for all chunks.
*
* The reference chunk is the one with the highest captureSpec covering-rect top (= the first
* scroll position, which has the most positive viewport-space top).
*
* For each non-reference chunk the base anchorTop is computed from captureSpec deltas (same as
* before). When per-chunk correction data is available, the anchor is additionally corrected.
*
* anchorTop_corrected = anchorTop_from_specs + (chunkAnchorShift - referenceAnchorShift)
*
* In the stable case correction values are 0 for all chunks.
*/
private _computeAnchoredChunks;
/** Checks whether a capture spec contributes visible pixels in the current chunk. */
private _isRenderableCaptureSpec;
/** Returns the bounding rect that covers all visible capture-spec parts for a chunk. */
private _getVisibleCoveringRect;
/** Builds a segment candidate, listing all possible options, e.g. strictly follow safe area, relax top/bottom edges, ignore safe area at all. */
private _buildCandidate;
/** Computes a usable vertical band for a specific mode: e.g. what if we expand the top edge of the safe area? */
private _getYBandForMode;
/** Chooses the best vertical band per chunk, relaxing edges only where needed to avoid gaps. */
private _chooseBestCandidates;
/** Expansion for cases when capture elements are far apart and not fit one viewport. */
private _expandCandidatesToFullArea;
/** Checks whether visible capture-spec pixels cover the complete requested capture area. */
private _doesVisibleAreaCoverFullArea;
/** Given a list of best possible segments, builds a list of image pieces, inserting gaps when needed,
* ensuring resulting array is a vertically continuous sequence of pieces. */
private _buildRenderPieces;
/** Fills an uncovered capture-area gap with usable chunk areas or black fallback slices. */
private _buildGapPieces;
/** Returns the horizontal viewport band occupied by visible capture-spec pixels. */
private _getChunkHorizontalArea;
/** Computes a shared horizontal crop band when chunks cannot safely use the original width. */
private _computeCommonHorizontalAreaIfNeeded;
/** Selects the horizontal band that should be used for a candidate chunk. */
private _getCandidateHorizontalArea;
/** Computes a horizontal band for expanded chunks using requested full rects and clip bounds. */
private _getExpandedChunkHorizontalArea;
/** Crops one viewport chunk into a render piece after clearing ignored regions. */
private _createChunkPiece;
/** Creates a black fallback image piece for areas that no chunk can provide. */
private _createBlackPiece;
}