import { Story, StorybookConnection, StoryPreviewBrowser } from '@prantlf/storycrawler'; import { MainOptions, RunMode } from './types.js'; import { VariantKey } from '../shared/types.js'; import { Logger } from './logger.js'; import { FileSystem } from './file.js'; /** * * Represents screenshot result. * * @remarks * * - If user's screenshot option has `skip: true`,`buffer` gets null and `succeeded` gets `true` * - `variantKeysToPush` is set an empty array if the capturing process is set not default variant key. It makes sense for only default variant. * - `defaultVariantSuffix` makes sense for only default variant too. It's set non-null value when user specifies multiple viewports. * **/ interface ScreenshotResult { buffer: Buffer | null; succeeded: boolean; variantKeysToPush: VariantKey[]; defaultVariantSuffix?: string; } /** * * A worker to capture screenshot images. * **/ export declare class CapturingBrowser extends StoryPreviewBrowser { protected connection: StorybookConnection; protected opt: MainOptions; private mode; private currentStoryRetryCount; private viewport?; private emitter; private readonly processedStories; private baseScreenshotOptions; private currentRequestId; private currentVariantKey; private touched; private resourceWatcher; /** * * @override * * @param opt - Options for Storycap. * @param mode - Indicates this worker runs as managed mode or simple mode. * @param idx - Worker id. * **/ constructor(connection: StorybookConnection, opt: MainOptions, mode: RunMode, idx: number); /** * * @override * **/ boot(): Promise; private addStyles; private expose; private reload; private waitIfTouched; private resetIfTouched; private subscribeScreenshotOptions; private waitForOptionsFromBrowser; private setViewport; private warnIfTargetElementNotFound; private setHover; private setFocus; private setClick; private waitForResources; private waitBrowserMetricsStable; private logInvalidVariantKeysReason; /** * Captures screenshot as a PNG image buffer from a story. * * @param requestId - Represents an identifier for the screenshot * @param variantKey - Variant identifier for the screenshot * @param retryCount - The number which represents how many attempting to capture this story and variant * @param logger - Logger instance * @param forwardConsoleLogs - Whether to forward logs from the page to the user's console * @param trace - Whether to record a CPU trace per screenshot * * @returns PNG buffer, whether the capturing process is succeeded or not, additional variant keys if they are emitted, and file name suffix for default the default variant. * * @remarks * * - Throws an error if `retryCount` is equal to `opt.captureMaxRetryCount` and this capturing process is failed * **/ screenshot(requestId: string, story: Story, variantKey: VariantKey, retryCount: number, logger: Logger, forwardConsoleLogs: boolean, trace: boolean, fileSystem: FileSystem): Promise; } export {};