@cappa/core 0.19.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +192 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +95 -1
- package/dist/index.d.mts +95 -1
- package/dist/index.mjs +189 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -240,6 +240,51 @@ export declare function removePlaywrightContainers(options: {
|
|
|
240
240
|
exec?: Exec;
|
|
241
241
|
}): Promise<string[]>;
|
|
242
242
|
//#endregion
|
|
243
|
+
//#region src/features/png/pixelRatio.d.ts
|
|
244
|
+
/**
|
|
245
|
+
* A screenshot's pixel ratio — image pixels per CSS pixel — stored in the PNG
|
|
246
|
+
* itself.
|
|
247
|
+
*
|
|
248
|
+
* Kept in the file rather than beside it because `approve` is a plain copy:
|
|
249
|
+
* the baseline carries the ratio it was captured at through approve, git and
|
|
250
|
+
* CI artifacts with no bookkeeping.
|
|
251
|
+
*
|
|
252
|
+
* Two chunks, both before the image data:
|
|
253
|
+
* - a `tEXt` chunk keyed `cappa:pixelRatio` — the source of truth. Only cappa
|
|
254
|
+
* writes it, so an image another tool stamped with a DPI is never misread.
|
|
255
|
+
* - a standard `pHYs` chunk, which image viewers read as DPI, so a 2×
|
|
256
|
+
* screenshot opens at its CSS size in tools that honour it.
|
|
257
|
+
*
|
|
258
|
+
* Only written for ratios other than 1. A PNG without the key is 1×, which is
|
|
259
|
+
* what every screenshot taken with `scale: "css"` is — so those stay
|
|
260
|
+
* byte-for-byte what they were, and `fastBufferCheck` keeps matching them.
|
|
261
|
+
*/
|
|
262
|
+
export declare const PIXEL_RATIO_KEY = "cappa:pixelRatio";
|
|
263
|
+
/**
|
|
264
|
+
* Return `buffer` stamped with `ratio`, replacing any ratio it carried.
|
|
265
|
+
*
|
|
266
|
+
* Ratio 1 removes cappa's chunks instead (see above); a `pHYs` some other tool
|
|
267
|
+
* wrote is left alone unless cappa is writing its own. Anything that is not a
|
|
268
|
+
* PNG comes back untouched. No pixel data is re-encoded.
|
|
269
|
+
*/
|
|
270
|
+
export declare function withPixelRatio(buffer: Buffer, ratio: number): Buffer;
|
|
271
|
+
/**
|
|
272
|
+
* The pixel ratio a screenshot was captured at: 1 when the PNG carries no
|
|
273
|
+
* ratio, and also when the file cannot be read — a missing ratio must never
|
|
274
|
+
* break listing or comparing screenshots.
|
|
275
|
+
*/
|
|
276
|
+
export declare function readPixelRatio(source: string | Buffer): Promise<number>;
|
|
277
|
+
/** The ratios of a baseline and the screenshot compared against it. */
|
|
278
|
+
type PixelRatioPair = {
|
|
279
|
+
expected: number;
|
|
280
|
+
actual: number;
|
|
281
|
+
};
|
|
282
|
+
/**
|
|
283
|
+
* Why a screenshot cannot match its baseline when the two were captured at
|
|
284
|
+
* different pixel ratios — `screenshot.scale` or `deviceScaleFactor` changed.
|
|
285
|
+
*/
|
|
286
|
+
export declare function describePixelRatioMismatch(expected: number, actual: number): string;
|
|
287
|
+
//#endregion
|
|
243
288
|
//#region src/filesystem.d.ts
|
|
244
289
|
/**
|
|
245
290
|
* Map a diff image path to its sidecar metadata path (`.png` -> `.json`).
|
|
@@ -675,6 +720,8 @@ declare class ScreenshotTool {
|
|
|
675
720
|
fullPage: boolean;
|
|
676
721
|
/** Default content crop; a screenshot's own `crop` overrides it. */
|
|
677
722
|
crop: CropSetting;
|
|
723
|
+
/** Default `scale`; a screenshot's own `scale` overrides it. */
|
|
724
|
+
scale: ScreenshotScale;
|
|
678
725
|
outputDir: string;
|
|
679
726
|
browser: Browser | null;
|
|
680
727
|
context: BrowserContext | null;
|
|
@@ -716,6 +763,7 @@ declare class ScreenshotTool {
|
|
|
716
763
|
};
|
|
717
764
|
fullPage?: boolean;
|
|
718
765
|
crop?: CropSetting;
|
|
766
|
+
scale?: ScreenshotScale;
|
|
719
767
|
outputDir?: string;
|
|
720
768
|
diff?: DiffOptions;
|
|
721
769
|
retries?: number;
|
|
@@ -803,6 +851,14 @@ declare class ScreenshotTool {
|
|
|
803
851
|
* the same render the screenshot does — and every retry measures afresh.
|
|
804
852
|
*/
|
|
805
853
|
private shoot;
|
|
854
|
+
/**
|
|
855
|
+
* Image pixels per CSS pixel for a screenshot taken with `options`: the
|
|
856
|
+
* context's `deviceScaleFactor` with `scale: "device"`, else 1.
|
|
857
|
+
*
|
|
858
|
+
* Stamped into every PNG (see `features/png/pixelRatio.ts`) so a baseline
|
|
859
|
+
* remembers the ratio it was captured at.
|
|
860
|
+
*/
|
|
861
|
+
pixelRatioFor(options: Pick<ScreenshotSettings, "scale">): number;
|
|
806
862
|
/**
|
|
807
863
|
* Sets the viewport size and executes the action, ensuring the original viewport is restored
|
|
808
864
|
* even if the action throws an error.
|
|
@@ -819,11 +875,17 @@ declare class ScreenshotTool {
|
|
|
819
875
|
screenshotPath: string;
|
|
820
876
|
comparisonResult: CompareResult$1 | CompareResult;
|
|
821
877
|
diffImagePath?: string;
|
|
878
|
+
/** Set when the baseline was captured at another pixel ratio. */
|
|
879
|
+
pixelRatio?: PixelRatioPair;
|
|
822
880
|
}>;
|
|
823
881
|
retryScreenshot(page: Page, referenceImage: string | Buffer, options: ScreenshotSettings, diffOverride?: DiffOptions): Promise<{
|
|
824
882
|
screenshotPath: Buffer<ArrayBufferLike>;
|
|
825
883
|
comparisonResult: CompareResult | CompareResult$1;
|
|
826
884
|
passed: boolean;
|
|
885
|
+
pixelRatio?: {
|
|
886
|
+
expected: number;
|
|
887
|
+
actual: number;
|
|
888
|
+
} | undefined;
|
|
827
889
|
} | {
|
|
828
890
|
screenshotPath: null;
|
|
829
891
|
comparisonResult: null;
|
|
@@ -1174,6 +1236,22 @@ type UserConfig = {
|
|
|
1174
1236
|
* @default false
|
|
1175
1237
|
*/
|
|
1176
1238
|
crop?: CropSetting;
|
|
1239
|
+
/**
|
|
1240
|
+
* How a screenshot's pixels map to the page's — Playwright's `scale`.
|
|
1241
|
+
*
|
|
1242
|
+
* - `"css"`: one image pixel per CSS pixel, whatever the context's
|
|
1243
|
+
* `deviceScaleFactor`. A 100×40 button is a 100×40 PNG.
|
|
1244
|
+
* - `"device"`: one image pixel per device pixel, so the PNG is
|
|
1245
|
+
* `deviceScaleFactor` times larger — sharp captures of small components.
|
|
1246
|
+
* Set `deviceScaleFactor` through `browser.provider`'s `contextOptions`.
|
|
1247
|
+
*
|
|
1248
|
+
* Changing it changes the size of every screenshot, so existing baselines
|
|
1249
|
+
* need re-approving. Pixel-count thresholds (`maxDiffPixels`) grow with
|
|
1250
|
+
* the square of the scale factor; `maxDiffPercentage` does not.
|
|
1251
|
+
* Plugins and per-screenshot options can override it.
|
|
1252
|
+
* @default "css"
|
|
1253
|
+
*/
|
|
1254
|
+
scale?: ScreenshotScale;
|
|
1177
1255
|
};
|
|
1178
1256
|
/**
|
|
1179
1257
|
* The browser screenshots are taken in. Shaped like Vitest browser mode's
|
|
@@ -1223,6 +1301,8 @@ type Viewport = {
|
|
|
1223
1301
|
width: number;
|
|
1224
1302
|
height: number;
|
|
1225
1303
|
};
|
|
1304
|
+
/** See `UserConfig.screenshot.scale`. */
|
|
1305
|
+
type ScreenshotScale = "css" | "device";
|
|
1226
1306
|
type ScreenshotSettings = {
|
|
1227
1307
|
fullPage?: boolean;
|
|
1228
1308
|
/**
|
|
@@ -1235,6 +1315,11 @@ type ScreenshotSettings = {
|
|
|
1235
1315
|
mask?: Locator[];
|
|
1236
1316
|
omitBackground?: boolean;
|
|
1237
1317
|
viewport?: Viewport;
|
|
1318
|
+
/**
|
|
1319
|
+
* `"css"` or `"device"` pixels — see `UserConfig.screenshot.scale`.
|
|
1320
|
+
* Overrides the global setting for this screenshot.
|
|
1321
|
+
*/
|
|
1322
|
+
scale?: ScreenshotScale;
|
|
1238
1323
|
};
|
|
1239
1324
|
type ScreenshotVariant = {
|
|
1240
1325
|
id: string;
|
|
@@ -1335,6 +1420,14 @@ type Screenshot = {
|
|
|
1335
1420
|
taskId?: string;
|
|
1336
1421
|
/** Plugin that owns `taskId`. Absent whenever `taskId` is. */
|
|
1337
1422
|
plugin?: string;
|
|
1423
|
+
/**
|
|
1424
|
+
* Image pixels per CSS pixel of the actual / expected PNG, as stamped at
|
|
1425
|
+
* capture (`screenshot.scale: "device"` → the `deviceScaleFactor`). Absent
|
|
1426
|
+
* means 1. Divide an image's size by it to show it at its CSS size; two
|
|
1427
|
+
* different ratios mean the baseline predates a scale change.
|
|
1428
|
+
*/
|
|
1429
|
+
actualPixelRatio?: number;
|
|
1430
|
+
expectedPixelRatio?: number;
|
|
1338
1431
|
} & (NewScreenshot | DeletedScreenshot | ChangedScreenshot | PassedScreenshot);
|
|
1339
1432
|
type FailedScreenshot = Screenshot & {
|
|
1340
1433
|
/**
|
|
@@ -2058,6 +2151,7 @@ type LocalEngineOptions = {
|
|
|
2058
2151
|
logConsoleEvents?: LogConsoleEvents;
|
|
2059
2152
|
fullPage?: boolean;
|
|
2060
2153
|
crop?: CropSetting;
|
|
2154
|
+
scale?: ScreenshotScale;
|
|
2061
2155
|
viewport?: Viewport;
|
|
2062
2156
|
connectionTimeout?: number;
|
|
2063
2157
|
/** Provider, headless mode and instance — see `UserConfig.browser`. */
|
|
@@ -2743,5 +2837,5 @@ export declare function findRefusedConnection(error: unknown): RefusedConnection
|
|
|
2743
2837
|
*/
|
|
2744
2838
|
export declare function sameServer(a: string, b: string): boolean;
|
|
2745
2839
|
//#endregion
|
|
2746
|
-
export { type AgentRegion, type AgentReport, type AgentReportEntry, type AgentReview, type AgentVerdictInput, type AppliedVerdict, type ApproveResult, type BrowserConfig, type BrowserInstance, type BrowserName, type BrowserProvider, type CaptureEngine, type CaptureManifest, type CaptureRunnerOptions, type ChangeInput, type ChangeRegion, type ChangedScreenshot, type ConfigEnv, type ConsoleLogLevel, type ContainerOptions, type ContentCropOptions, type CreateFileWatcher, type CropRect, type CropSetting, DEFAULT_CONTAINER_IMAGE, type DeletedScreenshot, type DiffConfig, type DiffConfigGMSD, type DiffMetadata, type DiffOptions, type DiffOptionsGMSD, type DiffOptionsPixel, type EmittableWatchEvent, type FailedScreenshot, type FileWatcher, type InterpretResult, type JudgmentPaths, type ListTargetsOptions, type LocalEngineOptions, type LogConsoleEvents, type NewScreenshot, type ParsedAgentVerdict, type PassedScreenshot, type PlaywrightContainer, type PlaywrightProviderOptions, type Plugin, type PluginCaptureResult, type PluginDef, type PluginFunction, type PluginInfo, type PluginTask, type PluginWatch, type PluginWatchResolve, type ProcessExit, type RefusedConnection, type ResolvedBrowserConfig, type ResolvedContainerOptions, type ResolvedWebServerConfig, type RunAgentCheckOptions, type RunDetail, type RunEvent, type RunEventListener, type RunEventType, type RunLogLevel, type RunState, type RunStoreOptions, type RunSummary, type RunTrigger, type RunnablePlugin, type Screenshot, type ScreenshotBucket, type ScreenshotCaptureDetails, type ScreenshotCaptureExtras, type ScreenshotCaptureResult, type ScreenshotCaptureSink, type ScreenshotOptions, type ScreenshotOrigin, type ScreenshotQuery, type ScreenshotSettings, type ScreenshotStore, ScreenshotTool, type ScreenshotVariant, type ScreenshotVariantCaptureDetails, type ScreenshotVariantWithUrl, type SerializedError, type ServerProcess, type SlimAgentReport, type SpawnServerOptions, type StartRunRequest, type StartWatchRequest, type SubscribeOptions, type Target, type TaskFailure, type TaskRecord, type TaskStatus, type TileOptions, type TileResult, type UserConfig, type Verdict, type VerdictAction, type VerdictLabel, type Viewport, type WaitForUrlOptions, type WaitForUrlResult, type WarmBrowserOptions, type WatchChange, type WatchEvent, type WatchEventType, type WatchScope, type WatchSessionOptions, type WatchStatus, type WebServerConfig, type WebServerLog, type WebServerLogLevel, type WebServerPoolOptions, playwright, resolveBrowserConfig, resolveContainerOptions };
|
|
2840
|
+
export { type AgentRegion, type AgentReport, type AgentReportEntry, type AgentReview, type AgentVerdictInput, type AppliedVerdict, type ApproveResult, type BrowserConfig, type BrowserInstance, type BrowserName, type BrowserProvider, type CaptureEngine, type CaptureManifest, type CaptureRunnerOptions, type ChangeInput, type ChangeRegion, type ChangedScreenshot, type ConfigEnv, type ConsoleLogLevel, type ContainerOptions, type ContentCropOptions, type CreateFileWatcher, type CropRect, type CropSetting, DEFAULT_CONTAINER_IMAGE, type DeletedScreenshot, type DiffConfig, type DiffConfigGMSD, type DiffMetadata, type DiffOptions, type DiffOptionsGMSD, type DiffOptionsPixel, type EmittableWatchEvent, type FailedScreenshot, type FileWatcher, type InterpretResult, type JudgmentPaths, type ListTargetsOptions, type LocalEngineOptions, type LogConsoleEvents, type NewScreenshot, type ParsedAgentVerdict, type PassedScreenshot, type PixelRatioPair, type PlaywrightContainer, type PlaywrightProviderOptions, type Plugin, type PluginCaptureResult, type PluginDef, type PluginFunction, type PluginInfo, type PluginTask, type PluginWatch, type PluginWatchResolve, type ProcessExit, type RefusedConnection, type ResolvedBrowserConfig, type ResolvedContainerOptions, type ResolvedWebServerConfig, type RunAgentCheckOptions, type RunDetail, type RunEvent, type RunEventListener, type RunEventType, type RunLogLevel, type RunState, type RunStoreOptions, type RunSummary, type RunTrigger, type RunnablePlugin, type Screenshot, type ScreenshotBucket, type ScreenshotCaptureDetails, type ScreenshotCaptureExtras, type ScreenshotCaptureResult, type ScreenshotCaptureSink, type ScreenshotOptions, type ScreenshotOrigin, type ScreenshotQuery, type ScreenshotScale, type ScreenshotSettings, type ScreenshotStore, ScreenshotTool, type ScreenshotVariant, type ScreenshotVariantCaptureDetails, type ScreenshotVariantWithUrl, type SerializedError, type ServerProcess, type SlimAgentReport, type SpawnServerOptions, type StartRunRequest, type StartWatchRequest, type SubscribeOptions, type Target, type TaskFailure, type TaskRecord, type TaskStatus, type TileOptions, type TileResult, type UserConfig, type Verdict, type VerdictAction, type VerdictLabel, type Viewport, type WaitForUrlOptions, type WaitForUrlResult, type WarmBrowserOptions, type WatchChange, type WatchEvent, type WatchEventType, type WatchScope, type WatchSessionOptions, type WatchStatus, type WebServerConfig, type WebServerLog, type WebServerLogLevel, type WebServerPoolOptions, playwright, resolveBrowserConfig, resolveContainerOptions };
|
|
2747
2841
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.mts
CHANGED
|
@@ -240,6 +240,51 @@ export declare function removePlaywrightContainers(options: {
|
|
|
240
240
|
exec?: Exec;
|
|
241
241
|
}): Promise<string[]>;
|
|
242
242
|
//#endregion
|
|
243
|
+
//#region src/features/png/pixelRatio.d.ts
|
|
244
|
+
/**
|
|
245
|
+
* A screenshot's pixel ratio — image pixels per CSS pixel — stored in the PNG
|
|
246
|
+
* itself.
|
|
247
|
+
*
|
|
248
|
+
* Kept in the file rather than beside it because `approve` is a plain copy:
|
|
249
|
+
* the baseline carries the ratio it was captured at through approve, git and
|
|
250
|
+
* CI artifacts with no bookkeeping.
|
|
251
|
+
*
|
|
252
|
+
* Two chunks, both before the image data:
|
|
253
|
+
* - a `tEXt` chunk keyed `cappa:pixelRatio` — the source of truth. Only cappa
|
|
254
|
+
* writes it, so an image another tool stamped with a DPI is never misread.
|
|
255
|
+
* - a standard `pHYs` chunk, which image viewers read as DPI, so a 2×
|
|
256
|
+
* screenshot opens at its CSS size in tools that honour it.
|
|
257
|
+
*
|
|
258
|
+
* Only written for ratios other than 1. A PNG without the key is 1×, which is
|
|
259
|
+
* what every screenshot taken with `scale: "css"` is — so those stay
|
|
260
|
+
* byte-for-byte what they were, and `fastBufferCheck` keeps matching them.
|
|
261
|
+
*/
|
|
262
|
+
export declare const PIXEL_RATIO_KEY = "cappa:pixelRatio";
|
|
263
|
+
/**
|
|
264
|
+
* Return `buffer` stamped with `ratio`, replacing any ratio it carried.
|
|
265
|
+
*
|
|
266
|
+
* Ratio 1 removes cappa's chunks instead (see above); a `pHYs` some other tool
|
|
267
|
+
* wrote is left alone unless cappa is writing its own. Anything that is not a
|
|
268
|
+
* PNG comes back untouched. No pixel data is re-encoded.
|
|
269
|
+
*/
|
|
270
|
+
export declare function withPixelRatio(buffer: Buffer, ratio: number): Buffer;
|
|
271
|
+
/**
|
|
272
|
+
* The pixel ratio a screenshot was captured at: 1 when the PNG carries no
|
|
273
|
+
* ratio, and also when the file cannot be read — a missing ratio must never
|
|
274
|
+
* break listing or comparing screenshots.
|
|
275
|
+
*/
|
|
276
|
+
export declare function readPixelRatio(source: string | Buffer): Promise<number>;
|
|
277
|
+
/** The ratios of a baseline and the screenshot compared against it. */
|
|
278
|
+
type PixelRatioPair = {
|
|
279
|
+
expected: number;
|
|
280
|
+
actual: number;
|
|
281
|
+
};
|
|
282
|
+
/**
|
|
283
|
+
* Why a screenshot cannot match its baseline when the two were captured at
|
|
284
|
+
* different pixel ratios — `screenshot.scale` or `deviceScaleFactor` changed.
|
|
285
|
+
*/
|
|
286
|
+
export declare function describePixelRatioMismatch(expected: number, actual: number): string;
|
|
287
|
+
//#endregion
|
|
243
288
|
//#region src/filesystem.d.ts
|
|
244
289
|
/**
|
|
245
290
|
* Map a diff image path to its sidecar metadata path (`.png` -> `.json`).
|
|
@@ -675,6 +720,8 @@ declare class ScreenshotTool {
|
|
|
675
720
|
fullPage: boolean;
|
|
676
721
|
/** Default content crop; a screenshot's own `crop` overrides it. */
|
|
677
722
|
crop: CropSetting;
|
|
723
|
+
/** Default `scale`; a screenshot's own `scale` overrides it. */
|
|
724
|
+
scale: ScreenshotScale;
|
|
678
725
|
outputDir: string;
|
|
679
726
|
browser: Browser | null;
|
|
680
727
|
context: BrowserContext | null;
|
|
@@ -716,6 +763,7 @@ declare class ScreenshotTool {
|
|
|
716
763
|
};
|
|
717
764
|
fullPage?: boolean;
|
|
718
765
|
crop?: CropSetting;
|
|
766
|
+
scale?: ScreenshotScale;
|
|
719
767
|
outputDir?: string;
|
|
720
768
|
diff?: DiffOptions;
|
|
721
769
|
retries?: number;
|
|
@@ -803,6 +851,14 @@ declare class ScreenshotTool {
|
|
|
803
851
|
* the same render the screenshot does — and every retry measures afresh.
|
|
804
852
|
*/
|
|
805
853
|
private shoot;
|
|
854
|
+
/**
|
|
855
|
+
* Image pixels per CSS pixel for a screenshot taken with `options`: the
|
|
856
|
+
* context's `deviceScaleFactor` with `scale: "device"`, else 1.
|
|
857
|
+
*
|
|
858
|
+
* Stamped into every PNG (see `features/png/pixelRatio.ts`) so a baseline
|
|
859
|
+
* remembers the ratio it was captured at.
|
|
860
|
+
*/
|
|
861
|
+
pixelRatioFor(options: Pick<ScreenshotSettings, "scale">): number;
|
|
806
862
|
/**
|
|
807
863
|
* Sets the viewport size and executes the action, ensuring the original viewport is restored
|
|
808
864
|
* even if the action throws an error.
|
|
@@ -819,11 +875,17 @@ declare class ScreenshotTool {
|
|
|
819
875
|
screenshotPath: string;
|
|
820
876
|
comparisonResult: CompareResult$1 | CompareResult;
|
|
821
877
|
diffImagePath?: string;
|
|
878
|
+
/** Set when the baseline was captured at another pixel ratio. */
|
|
879
|
+
pixelRatio?: PixelRatioPair;
|
|
822
880
|
}>;
|
|
823
881
|
retryScreenshot(page: Page, referenceImage: string | Buffer, options: ScreenshotSettings, diffOverride?: DiffOptions): Promise<{
|
|
824
882
|
screenshotPath: Buffer<ArrayBufferLike>;
|
|
825
883
|
comparisonResult: CompareResult | CompareResult$1;
|
|
826
884
|
passed: boolean;
|
|
885
|
+
pixelRatio?: {
|
|
886
|
+
expected: number;
|
|
887
|
+
actual: number;
|
|
888
|
+
} | undefined;
|
|
827
889
|
} | {
|
|
828
890
|
screenshotPath: null;
|
|
829
891
|
comparisonResult: null;
|
|
@@ -1174,6 +1236,22 @@ type UserConfig = {
|
|
|
1174
1236
|
* @default false
|
|
1175
1237
|
*/
|
|
1176
1238
|
crop?: CropSetting;
|
|
1239
|
+
/**
|
|
1240
|
+
* How a screenshot's pixels map to the page's — Playwright's `scale`.
|
|
1241
|
+
*
|
|
1242
|
+
* - `"css"`: one image pixel per CSS pixel, whatever the context's
|
|
1243
|
+
* `deviceScaleFactor`. A 100×40 button is a 100×40 PNG.
|
|
1244
|
+
* - `"device"`: one image pixel per device pixel, so the PNG is
|
|
1245
|
+
* `deviceScaleFactor` times larger — sharp captures of small components.
|
|
1246
|
+
* Set `deviceScaleFactor` through `browser.provider`'s `contextOptions`.
|
|
1247
|
+
*
|
|
1248
|
+
* Changing it changes the size of every screenshot, so existing baselines
|
|
1249
|
+
* need re-approving. Pixel-count thresholds (`maxDiffPixels`) grow with
|
|
1250
|
+
* the square of the scale factor; `maxDiffPercentage` does not.
|
|
1251
|
+
* Plugins and per-screenshot options can override it.
|
|
1252
|
+
* @default "css"
|
|
1253
|
+
*/
|
|
1254
|
+
scale?: ScreenshotScale;
|
|
1177
1255
|
};
|
|
1178
1256
|
/**
|
|
1179
1257
|
* The browser screenshots are taken in. Shaped like Vitest browser mode's
|
|
@@ -1223,6 +1301,8 @@ type Viewport = {
|
|
|
1223
1301
|
width: number;
|
|
1224
1302
|
height: number;
|
|
1225
1303
|
};
|
|
1304
|
+
/** See `UserConfig.screenshot.scale`. */
|
|
1305
|
+
type ScreenshotScale = "css" | "device";
|
|
1226
1306
|
type ScreenshotSettings = {
|
|
1227
1307
|
fullPage?: boolean;
|
|
1228
1308
|
/**
|
|
@@ -1235,6 +1315,11 @@ type ScreenshotSettings = {
|
|
|
1235
1315
|
mask?: Locator[];
|
|
1236
1316
|
omitBackground?: boolean;
|
|
1237
1317
|
viewport?: Viewport;
|
|
1318
|
+
/**
|
|
1319
|
+
* `"css"` or `"device"` pixels — see `UserConfig.screenshot.scale`.
|
|
1320
|
+
* Overrides the global setting for this screenshot.
|
|
1321
|
+
*/
|
|
1322
|
+
scale?: ScreenshotScale;
|
|
1238
1323
|
};
|
|
1239
1324
|
type ScreenshotVariant = {
|
|
1240
1325
|
id: string;
|
|
@@ -1335,6 +1420,14 @@ type Screenshot = {
|
|
|
1335
1420
|
taskId?: string;
|
|
1336
1421
|
/** Plugin that owns `taskId`. Absent whenever `taskId` is. */
|
|
1337
1422
|
plugin?: string;
|
|
1423
|
+
/**
|
|
1424
|
+
* Image pixels per CSS pixel of the actual / expected PNG, as stamped at
|
|
1425
|
+
* capture (`screenshot.scale: "device"` → the `deviceScaleFactor`). Absent
|
|
1426
|
+
* means 1. Divide an image's size by it to show it at its CSS size; two
|
|
1427
|
+
* different ratios mean the baseline predates a scale change.
|
|
1428
|
+
*/
|
|
1429
|
+
actualPixelRatio?: number;
|
|
1430
|
+
expectedPixelRatio?: number;
|
|
1338
1431
|
} & (NewScreenshot | DeletedScreenshot | ChangedScreenshot | PassedScreenshot);
|
|
1339
1432
|
type FailedScreenshot = Screenshot & {
|
|
1340
1433
|
/**
|
|
@@ -2058,6 +2151,7 @@ type LocalEngineOptions = {
|
|
|
2058
2151
|
logConsoleEvents?: LogConsoleEvents;
|
|
2059
2152
|
fullPage?: boolean;
|
|
2060
2153
|
crop?: CropSetting;
|
|
2154
|
+
scale?: ScreenshotScale;
|
|
2061
2155
|
viewport?: Viewport;
|
|
2062
2156
|
connectionTimeout?: number;
|
|
2063
2157
|
/** Provider, headless mode and instance — see `UserConfig.browser`. */
|
|
@@ -2743,5 +2837,5 @@ export declare function findRefusedConnection(error: unknown): RefusedConnection
|
|
|
2743
2837
|
*/
|
|
2744
2838
|
export declare function sameServer(a: string, b: string): boolean;
|
|
2745
2839
|
//#endregion
|
|
2746
|
-
export { type AgentRegion, type AgentReport, type AgentReportEntry, type AgentReview, type AgentVerdictInput, type AppliedVerdict, type ApproveResult, type BrowserConfig, type BrowserInstance, type BrowserName, type BrowserProvider, type CaptureEngine, type CaptureManifest, type CaptureRunnerOptions, type ChangeInput, type ChangeRegion, type ChangedScreenshot, type ConfigEnv, type ConsoleLogLevel, type ContainerOptions, type ContentCropOptions, type CreateFileWatcher, type CropRect, type CropSetting, DEFAULT_CONTAINER_IMAGE, type DeletedScreenshot, type DiffConfig, type DiffConfigGMSD, type DiffMetadata, type DiffOptions, type DiffOptionsGMSD, type DiffOptionsPixel, type EmittableWatchEvent, type FailedScreenshot, type FileWatcher, type InterpretResult, type JudgmentPaths, type ListTargetsOptions, type LocalEngineOptions, type LogConsoleEvents, type NewScreenshot, type ParsedAgentVerdict, type PassedScreenshot, type PlaywrightContainer, type PlaywrightProviderOptions, type Plugin, type PluginCaptureResult, type PluginDef, type PluginFunction, type PluginInfo, type PluginTask, type PluginWatch, type PluginWatchResolve, type ProcessExit, type RefusedConnection, type ResolvedBrowserConfig, type ResolvedContainerOptions, type ResolvedWebServerConfig, type RunAgentCheckOptions, type RunDetail, type RunEvent, type RunEventListener, type RunEventType, type RunLogLevel, type RunState, type RunStoreOptions, type RunSummary, type RunTrigger, type RunnablePlugin, type Screenshot, type ScreenshotBucket, type ScreenshotCaptureDetails, type ScreenshotCaptureExtras, type ScreenshotCaptureResult, type ScreenshotCaptureSink, type ScreenshotOptions, type ScreenshotOrigin, type ScreenshotQuery, type ScreenshotSettings, type ScreenshotStore, ScreenshotTool, type ScreenshotVariant, type ScreenshotVariantCaptureDetails, type ScreenshotVariantWithUrl, type SerializedError, type ServerProcess, type SlimAgentReport, type SpawnServerOptions, type StartRunRequest, type StartWatchRequest, type SubscribeOptions, type Target, type TaskFailure, type TaskRecord, type TaskStatus, type TileOptions, type TileResult, type UserConfig, type Verdict, type VerdictAction, type VerdictLabel, type Viewport, type WaitForUrlOptions, type WaitForUrlResult, type WarmBrowserOptions, type WatchChange, type WatchEvent, type WatchEventType, type WatchScope, type WatchSessionOptions, type WatchStatus, type WebServerConfig, type WebServerLog, type WebServerLogLevel, type WebServerPoolOptions, playwright, resolveBrowserConfig, resolveContainerOptions };
|
|
2840
|
+
export { type AgentRegion, type AgentReport, type AgentReportEntry, type AgentReview, type AgentVerdictInput, type AppliedVerdict, type ApproveResult, type BrowserConfig, type BrowserInstance, type BrowserName, type BrowserProvider, type CaptureEngine, type CaptureManifest, type CaptureRunnerOptions, type ChangeInput, type ChangeRegion, type ChangedScreenshot, type ConfigEnv, type ConsoleLogLevel, type ContainerOptions, type ContentCropOptions, type CreateFileWatcher, type CropRect, type CropSetting, DEFAULT_CONTAINER_IMAGE, type DeletedScreenshot, type DiffConfig, type DiffConfigGMSD, type DiffMetadata, type DiffOptions, type DiffOptionsGMSD, type DiffOptionsPixel, type EmittableWatchEvent, type FailedScreenshot, type FileWatcher, type InterpretResult, type JudgmentPaths, type ListTargetsOptions, type LocalEngineOptions, type LogConsoleEvents, type NewScreenshot, type ParsedAgentVerdict, type PassedScreenshot, type PixelRatioPair, type PlaywrightContainer, type PlaywrightProviderOptions, type Plugin, type PluginCaptureResult, type PluginDef, type PluginFunction, type PluginInfo, type PluginTask, type PluginWatch, type PluginWatchResolve, type ProcessExit, type RefusedConnection, type ResolvedBrowserConfig, type ResolvedContainerOptions, type ResolvedWebServerConfig, type RunAgentCheckOptions, type RunDetail, type RunEvent, type RunEventListener, type RunEventType, type RunLogLevel, type RunState, type RunStoreOptions, type RunSummary, type RunTrigger, type RunnablePlugin, type Screenshot, type ScreenshotBucket, type ScreenshotCaptureDetails, type ScreenshotCaptureExtras, type ScreenshotCaptureResult, type ScreenshotCaptureSink, type ScreenshotOptions, type ScreenshotOrigin, type ScreenshotQuery, type ScreenshotScale, type ScreenshotSettings, type ScreenshotStore, ScreenshotTool, type ScreenshotVariant, type ScreenshotVariantCaptureDetails, type ScreenshotVariantWithUrl, type SerializedError, type ServerProcess, type SlimAgentReport, type SpawnServerOptions, type StartRunRequest, type StartWatchRequest, type SubscribeOptions, type Target, type TaskFailure, type TaskRecord, type TaskStatus, type TileOptions, type TileResult, type UserConfig, type Verdict, type VerdictAction, type VerdictLabel, type Viewport, type WaitForUrlOptions, type WaitForUrlResult, type WarmBrowserOptions, type WatchChange, type WatchEvent, type WatchEventType, type WatchScope, type WatchSessionOptions, type WatchStatus, type WebServerConfig, type WebServerLog, type WebServerLogLevel, type WebServerPoolOptions, playwright, resolveBrowserConfig, resolveContainerOptions };
|
|
2747
2841
|
//# sourceMappingURL=index.d.mts.map
|