happo 6.10.8 → 6.12.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/cli/cancelJob-3SOJDWVF.js +10 -0
- package/dist/cli/{chunk-RK77B2CV.js → chunk-6LZEMKE5.js} +2 -2
- package/dist/cli/{chunk-4LR77I43.js → chunk-KJAXUBWS.js} +2 -2
- package/dist/cli/{chunk-HCZZJ6R6.js → chunk-NAZ3MMJW.js} +4 -4
- package/dist/cli/{chunk-HCZZJ6R6.js.map → chunk-NAZ3MMJW.js.map} +2 -2
- package/dist/cli/{chunk-GD7KRJOO.js → chunk-SZM5DT7T.js} +2 -2
- package/dist/cli/{chunk-G7ULHRHU.js → chunk-TRVYVBOG.js} +2 -2
- package/dist/cli/{chunk-7HMFLTG3.js → chunk-UE2TDVXX.js} +3 -3
- package/dist/cli/createAsyncComparison-Z4CFUYI3.js +10 -0
- package/dist/cli/{createAsyncReport-2JPU7JD5.js → createAsyncReport-6NLFV67D.js} +4 -4
- package/dist/cli/{createExtendsReportSnapRequest-N6GXYNAC.js → createExtendsReportSnapRequest-NLOQRLLD.js} +4 -4
- package/dist/cli/{findBaselineReport-ELJYMYXD.js → findBaselineReport-Z3OCRSBZ.js} +4 -4
- package/dist/cli/{getFlakes-CBGWAHIU.js → getFlakes-XLUPRYOV.js} +4 -4
- package/dist/cli/main.js +38 -18
- package/dist/cli/main.js.map +2 -2
- package/dist/cli/package-KZLXYPVK.js +7 -0
- package/dist/cli/{prepareSnapRequests-LSGTNPWS.js → prepareSnapRequests-LEKHRAYP.js} +49 -23
- package/dist/cli/prepareSnapRequests-LEKHRAYP.js.map +7 -0
- package/dist/cli/startJob-I4XOEWJR.js +10 -0
- package/dist/cli/{wrapper-HH2NJLIH.js → wrapper-RZ37F2SC.js} +7 -7
- package/dist/config/RemoteBrowserTarget.d.ts +6 -1
- package/dist/config/RemoteBrowserTarget.d.ts.map +1 -1
- package/dist/config/index.d.ts +39 -2
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js.map +2 -2
- package/dist/config/loadConfig.d.ts.map +1 -1
- package/dist/cypress/task.js +22 -8
- package/dist/cypress/task.js.map +2 -2
- package/dist/e2e/controller.d.ts.map +1 -1
- package/dist/environment/index.d.ts.map +1 -1
- package/dist/network/prepareSnapRequests.d.ts.map +1 -1
- package/dist/playwright/index.js +22 -8
- package/dist/playwright/index.js.map +2 -2
- package/dist/storybook/index.d.ts.map +1 -1
- package/dist/storybook/index.js +23 -14
- package/dist/storybook/index.js.map +2 -2
- package/package.json +3 -3
- package/dist/cli/cancelJob-GENB4D2J.js +0 -10
- package/dist/cli/createAsyncComparison-ZQ6MUSVE.js +0 -10
- package/dist/cli/package-2XKSYS6F.js +0 -7
- package/dist/cli/prepareSnapRequests-LSGTNPWS.js.map +0 -7
- package/dist/cli/startJob-K5V7SAXF.js +0 -10
- /package/dist/cli/{cancelJob-GENB4D2J.js.map → cancelJob-3SOJDWVF.js.map} +0 -0
- /package/dist/cli/{chunk-RK77B2CV.js.map → chunk-6LZEMKE5.js.map} +0 -0
- /package/dist/cli/{chunk-4LR77I43.js.map → chunk-KJAXUBWS.js.map} +0 -0
- /package/dist/cli/{chunk-GD7KRJOO.js.map → chunk-SZM5DT7T.js.map} +0 -0
- /package/dist/cli/{chunk-G7ULHRHU.js.map → chunk-TRVYVBOG.js.map} +0 -0
- /package/dist/cli/{chunk-7HMFLTG3.js.map → chunk-UE2TDVXX.js.map} +0 -0
- /package/dist/cli/{createAsyncComparison-ZQ6MUSVE.js.map → createAsyncComparison-Z4CFUYI3.js.map} +0 -0
- /package/dist/cli/{createAsyncReport-2JPU7JD5.js.map → createAsyncReport-6NLFV67D.js.map} +0 -0
- /package/dist/cli/{createExtendsReportSnapRequest-N6GXYNAC.js.map → createExtendsReportSnapRequest-NLOQRLLD.js.map} +0 -0
- /package/dist/cli/{findBaselineReport-ELJYMYXD.js.map → findBaselineReport-Z3OCRSBZ.js.map} +0 -0
- /package/dist/cli/{getFlakes-CBGWAHIU.js.map → getFlakes-XLUPRYOV.js.map} +0 -0
- /package/dist/cli/{package-2XKSYS6F.js.map → package-KZLXYPVK.js.map} +0 -0
- /package/dist/cli/{startJob-K5V7SAXF.js.map → startJob-I4XOEWJR.js.map} +0 -0
- /package/dist/cli/{wrapper-HH2NJLIH.js.map → wrapper-RZ37F2SC.js.map} +0 -0
|
@@ -4,11 +4,11 @@ import {
|
|
|
4
4
|
} from "./chunk-ML3Z5Z22.js";
|
|
5
5
|
import {
|
|
6
6
|
makeHappoAPIRequest
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-KJAXUBWS.js";
|
|
8
8
|
import {
|
|
9
9
|
ErrorWithStatusCode
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
10
|
+
} from "./chunk-6LZEMKE5.js";
|
|
11
|
+
import "./chunk-NAZ3MMJW.js";
|
|
12
12
|
|
|
13
13
|
// src/network/prepareSnapRequests.ts
|
|
14
14
|
import fs5 from "node:fs";
|
|
@@ -54,7 +54,8 @@ function buildChunkItem({
|
|
|
54
54
|
globalCSS,
|
|
55
55
|
staticPackage,
|
|
56
56
|
assetsPackage,
|
|
57
|
-
targetName
|
|
57
|
+
targetName,
|
|
58
|
+
failOnWaitForTimeout
|
|
58
59
|
}) {
|
|
59
60
|
const payloadString = JSON.stringify({
|
|
60
61
|
viewport,
|
|
@@ -66,7 +67,8 @@ function buildChunkItem({
|
|
|
66
67
|
staticPackage,
|
|
67
68
|
assetsPackage,
|
|
68
69
|
pages: pageSlice,
|
|
69
|
-
extendsSha: pageSlice ? pageSlice.extendsSha : void 0
|
|
70
|
+
extendsSha: pageSlice ? pageSlice.extendsSha : void 0,
|
|
71
|
+
failOnWaitForTimeout
|
|
70
72
|
});
|
|
71
73
|
const payloadHash = createHash(payloadString + (pageSlice ? Math.random() : ""));
|
|
72
74
|
const type = pageSlice && pageSlice.extendsSha ? "extends-report" : `browser-${browserName}`;
|
|
@@ -144,7 +146,8 @@ var RemoteBrowserTarget = class {
|
|
|
144
146
|
snapPayloads,
|
|
145
147
|
pages,
|
|
146
148
|
targetName,
|
|
147
|
-
estimatedSnapsCount
|
|
149
|
+
estimatedSnapsCount,
|
|
150
|
+
failOnWaitForTimeout
|
|
148
151
|
}, config) {
|
|
149
152
|
const buildItemParams = {
|
|
150
153
|
browserName: this.browserName,
|
|
@@ -154,7 +157,8 @@ var RemoteBrowserTarget = class {
|
|
|
154
157
|
globalCSS,
|
|
155
158
|
staticPackage,
|
|
156
159
|
assetsPackage,
|
|
157
|
-
targetName
|
|
160
|
+
targetName,
|
|
161
|
+
failOnWaitForTimeout
|
|
158
162
|
};
|
|
159
163
|
const items = [];
|
|
160
164
|
if (staticPackage) {
|
|
@@ -509,24 +513,33 @@ async function buildStorybookPackage({
|
|
|
509
513
|
).length;
|
|
510
514
|
}
|
|
511
515
|
if (only !== void 0) {
|
|
512
|
-
|
|
513
|
-
({ component }) => ({ component })
|
|
514
|
-
);
|
|
515
|
-
if (resolvedOnly.length === 0) {
|
|
516
|
-
console.warn(
|
|
517
|
-
"[HAPPO] --only: no matching stories found in Storybook index. Generating a full report instead."
|
|
518
|
-
);
|
|
519
|
-
resolvedOnly = void 0;
|
|
520
|
-
} else {
|
|
521
|
-
const onlyComponents = new Set(resolvedOnly.map((item) => item.component));
|
|
522
|
-
estimatedSnapsCount = storyEntries.filter(
|
|
523
|
-
(e) => onlyComponents.has(e.title ?? "")
|
|
524
|
-
).length;
|
|
516
|
+
if (only.length === 0) {
|
|
525
517
|
const allComponents = /* @__PURE__ */ new Set();
|
|
526
518
|
for (const e of storyEntries) {
|
|
527
519
|
if (e.title) allComponents.add(e.title);
|
|
528
520
|
}
|
|
529
|
-
resolvedSkip = [...allComponents].
|
|
521
|
+
resolvedSkip = [...allComponents].map((component) => ({ component }));
|
|
522
|
+
estimatedSnapsCount = 0;
|
|
523
|
+
} else {
|
|
524
|
+
resolvedOnly = resolveStoryFileItems(only, entries).map(
|
|
525
|
+
({ component }) => ({ component })
|
|
526
|
+
);
|
|
527
|
+
if (resolvedOnly.length === 0) {
|
|
528
|
+
console.warn(
|
|
529
|
+
"[HAPPO] --only: no matching stories found in Storybook index. Generating a full report instead."
|
|
530
|
+
);
|
|
531
|
+
resolvedOnly = void 0;
|
|
532
|
+
} else {
|
|
533
|
+
const onlyComponents = new Set(resolvedOnly.map((item) => item.component));
|
|
534
|
+
estimatedSnapsCount = storyEntries.filter(
|
|
535
|
+
(e) => onlyComponents.has(e.title ?? "")
|
|
536
|
+
).length;
|
|
537
|
+
const allComponents = /* @__PURE__ */ new Set();
|
|
538
|
+
for (const e of storyEntries) {
|
|
539
|
+
if (e.title) allComponents.add(e.title);
|
|
540
|
+
}
|
|
541
|
+
resolvedSkip = [...allComponents].filter((c) => !onlyComponents.has(c)).map((component) => ({ component }));
|
|
542
|
+
}
|
|
530
543
|
}
|
|
531
544
|
}
|
|
532
545
|
} catch (error) {
|
|
@@ -986,6 +999,18 @@ async function preparePackage(config, logger, skip, only) {
|
|
|
986
999
|
}
|
|
987
1000
|
async function prepareSnapRequests(config, skip, only) {
|
|
988
1001
|
const logger = new Logger();
|
|
1002
|
+
if (only !== void 0 && only.length === 0) {
|
|
1003
|
+
if (config.integration.type === "pages") {
|
|
1004
|
+
throw new Error("--only is not supported for the pages integration");
|
|
1005
|
+
}
|
|
1006
|
+
const { resolvedSkip } = await buildPackage(config, logger, skip, only);
|
|
1007
|
+
if (!resolvedSkip || resolvedSkip.length === 0) {
|
|
1008
|
+
throw new Error(
|
|
1009
|
+
"Empty --only run could not enumerate any components from the build. An empty --only run requires a readable Storybook index.json (or equivalent) to know which components to borrow from the baseline."
|
|
1010
|
+
);
|
|
1011
|
+
}
|
|
1012
|
+
return { snapRequestIds: [], resolvedSkip };
|
|
1013
|
+
}
|
|
989
1014
|
const prepareResult = config.integration.type === "pages" ? null : await preparePackage(config, logger, skip, only);
|
|
990
1015
|
const targetNames = Object.keys(config.targets);
|
|
991
1016
|
const tl = targetNames.length;
|
|
@@ -1005,7 +1030,8 @@ async function prepareSnapRequests(config, skip, only) {
|
|
|
1005
1030
|
config.targets[name]
|
|
1006
1031
|
);
|
|
1007
1032
|
const targetParams = {
|
|
1008
|
-
targetName: name
|
|
1033
|
+
targetName: name,
|
|
1034
|
+
failOnWaitForTimeout: config.failOnWaitForTimeout
|
|
1009
1035
|
};
|
|
1010
1036
|
if (prepareResult) {
|
|
1011
1037
|
targetParams.staticPackage = prepareResult.packagePath;
|
|
@@ -1033,4 +1059,4 @@ async function prepareSnapRequests(config, skip, only) {
|
|
|
1033
1059
|
export {
|
|
1034
1060
|
prepareSnapRequests as default
|
|
1035
1061
|
};
|
|
1036
|
-
//# sourceMappingURL=prepareSnapRequests-
|
|
1062
|
+
//# sourceMappingURL=prepareSnapRequests-LEKHRAYP.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/network/prepareSnapRequests.ts", "../../src/utils/createHash.ts", "../../src/config/RemoteBrowserTarget.ts", "../../src/storybook/index.ts", "../../src/storybook/getStorybookBuildCommandParts.ts", "../../src/storybook/getStorybookVersionFromPackageJson.ts", "../../src/storybook/resolveStoryFileItems.ts", "../../src/utils/deterministicArchive.ts", "../../src/utils/validateArchive.ts", "../../src/utils/Logger.ts", "../../src/network/uploadAssets.ts"],
|
|
4
|
+
"sourcesContent": ["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport type { ConfigWithDefaults } from '../config/index.ts';\nimport RemoteBrowserTarget, {\n type ExecuteParams,\n} from '../config/RemoteBrowserTarget.ts';\nimport type { OnlyItem, SkipItem } from '../isomorphic/types.ts';\nimport buildStorybookPackage from '../storybook/index.ts';\nimport deterministicArchive from '../utils/deterministicArchive.ts';\nimport Logger, { logTag } from '../utils/Logger.ts';\nimport uploadAssets from './uploadAssets.ts';\n\nasync function fileExists(path: string): Promise<boolean> {\n try {\n await fs.promises.stat(path);\n return true;\n } catch (error) {\n if (error instanceof Error && 'code' in error && error.code === 'ENOENT') {\n return false;\n }\n\n throw error;\n }\n}\n\nasync function createIframeHTML(\n rootDir: string,\n entryPoint: string,\n logger: Logger,\n): Promise<void> {\n const iframePath = path.join(rootDir, 'iframe.html');\n\n if (await fileExists(iframePath)) {\n logger.info(`Using existing iframe.html at '${iframePath}'`);\n return;\n }\n\n const iframeContent = `<!DOCTYPE html>\n<html lang=\"en\" dir=\"ltr\">\n <head>\n <title>Happo</title>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n </head>\n <body>\n <script src=\"${entryPoint}\"></script>\n </body>\n</html>`;\n\n await fs.promises.mkdir(rootDir, { recursive: true });\n await fs.promises.writeFile(iframePath, iframeContent);\n}\n\ninterface BuildPackageResult {\n packageDir: string;\n estimatedSnapsCount?: number;\n resolvedSkip?: Array<{ component: string; variant?: string }>;\n}\n\nasync function injectSkippedIntoIframe(\n iframePath: string,\n skipped: Array<SkipItem>,\n): Promise<void> {\n const content = await fs.promises.readFile(iframePath, 'utf8');\n const skippedJson = JSON.stringify(skipped).replaceAll(/<\\/script>/gi, String.raw`<\\/script>`);\n const skippedScript = `<script type=\"application/json\" id=\"happo-skipped\">${skippedJson}</script>`;\n const injected = content.replace(/<head\\b[^>]*>/i, (match) => `${match}${skippedScript}`);\n if (injected === content) {\n throw new Error(\n `Failed to inject skipped examples into iframe.html at '${iframePath}': could not find an opening <head> tag`,\n );\n }\n await fs.promises.writeFile(iframePath, injected);\n}\n\nasync function buildPackage(\n { integration }: ConfigWithDefaults,\n logger: Logger,\n skip?: Array<SkipItem>,\n only?: Array<OnlyItem>,\n): Promise<BuildPackageResult> {\n if (integration.type === 'custom') {\n const { rootDir, entryPoint, estimatedSnapsCount } = await integration.build();\n await createIframeHTML(rootDir, entryPoint, logger);\n\n if (skip && skip.length > 0) {\n const iframePath = path.join(rootDir, 'iframe.html');\n await injectSkippedIntoIframe(iframePath, skip);\n }\n\n const result: BuildPackageResult = { packageDir: rootDir };\n if (estimatedSnapsCount != null) {\n result.estimatedSnapsCount = estimatedSnapsCount;\n }\n return result;\n }\n\n if (integration.type === 'storybook') {\n const result = await buildStorybookPackage({\n ...integration,\n ...(skip === undefined ? {} : { skip }),\n ...(only === undefined ? {} : { only }),\n });\n return result;\n }\n\n throw new Error(`Unsupported integration type: ${integration.type}`);\n}\n\nasync function validatePackage(packageDir: string): Promise<void> {\n const iframePath = path.join(packageDir, 'iframe.html');\n\n if (!(await fileExists(iframePath))) {\n throw new Error(\n `Could not find iframe.html in static package at '${iframePath}'`,\n );\n }\n}\n\ninterface PreparePackageResult {\n packagePath: string;\n estimatedSnapsCount?: number;\n resolvedSkip?: Array<{ component: string; variant?: string }>;\n}\n\nasync function preparePackage(\n config: ConfigWithDefaults,\n logger: Logger,\n skip?: Array<SkipItem>,\n only?: Array<OnlyItem>,\n): Promise<PreparePackageResult> {\n const { packageDir, estimatedSnapsCount, resolvedSkip } = await buildPackage(config, logger, skip, only);\n\n await validatePackage(packageDir);\n\n const { buffer, hash } = await deterministicArchive([packageDir]);\n const packagePath = await uploadAssets(\n buffer,\n {\n hash,\n logger,\n },\n config,\n );\n\n const result: PreparePackageResult = { packagePath };\n if (estimatedSnapsCount != null) {\n result.estimatedSnapsCount = estimatedSnapsCount;\n }\n if (resolvedSkip !== undefined) {\n result.resolvedSkip = resolvedSkip;\n }\n return result;\n}\n\nexport interface PrepareSnapRequestsResult {\n snapRequestIds: Array<number>;\n resolvedSkip?: Array<{ component: string; variant?: string }>;\n}\n\nexport default async function prepareSnapRequests(\n config: ConfigWithDefaults,\n skip?: Array<SkipItem>,\n only?: Array<OnlyItem>,\n): Promise<PrepareSnapRequestsResult> {\n const logger = new Logger();\n\n // An empty --only array means: render nothing locally and borrow the entire\n // report from the baseline via an extends-report. Build the package only to\n // enumerate components for the extends-report; skip upload and target\n // execution.\n if (only !== undefined && only.length === 0) {\n if (config.integration.type === 'pages') {\n throw new Error('--only is not supported for the pages integration');\n }\n const { resolvedSkip } = await buildPackage(config, logger, skip, only);\n if (!resolvedSkip || resolvedSkip.length === 0) {\n // Without a component list we can't construct a meaningful\n // extends-report, and the alternative would be an async report with\n // zero snap requests. Surface the failure instead.\n throw new Error(\n 'Empty --only run could not enumerate any components from the build. An empty --only run requires a readable Storybook index.json (or equivalent) to know which components to borrow from the baseline.',\n );\n }\n return { snapRequestIds: [], resolvedSkip };\n }\n\n const prepareResult =\n config.integration.type === 'pages'\n ? null\n : await preparePackage(config, logger, skip, only);\n\n const targetNames = Object.keys(config.targets);\n const tl = targetNames.length;\n logger.info(\n `${logTag(config.project)}Generating screenshots in ${tl} target${\n tl > 1 ? 's' : ''\n }...`,\n );\n const outerStartTime = Date.now();\n const snapRequestIds: Array<number> = [];\n await Promise.all(\n targetNames.map(async (name) => {\n const startTime = Date.now();\n\n if (!config.targets[name]) {\n throw new Error(`Target ${name} not found in config`);\n }\n\n const target = new RemoteBrowserTarget(\n config.targets[name].type,\n config.targets[name],\n );\n\n const targetParams: ExecuteParams = {\n targetName: name,\n failOnWaitForTimeout: config.failOnWaitForTimeout,\n };\n\n if (prepareResult) {\n targetParams.staticPackage = prepareResult.packagePath;\n\n if (prepareResult.estimatedSnapsCount != null) {\n targetParams.estimatedSnapsCount = prepareResult.estimatedSnapsCount;\n }\n }\n\n if (config.integration.type === 'pages') {\n targetParams.pages = config.integration.pages;\n }\n\n const ids = await target.execute(targetParams, config);\n logger.start(` - ${logTag(config.project)}${name}`, { startTime });\n logger.success();\n snapRequestIds.push(...ids);\n }),\n );\n logger.start(undefined, { startTime: outerStartTime });\n logger.success();\n const result: PrepareSnapRequestsResult = { snapRequestIds };\n if (prepareResult?.resolvedSkip !== undefined) {\n result.resolvedSkip = prepareResult.resolvedSkip;\n }\n return result;\n}\n", "import crypto from 'node:crypto';\n\n/**\n * Creates an MD5 hash of the input data\n * @param data - The data to hash (string, Buffer, or TypedArray)\n * @returns The MD5 hash as a hexadecimal string\n */\nexport default function createHash(\n data: string | Buffer | NodeJS.TypedArray,\n): string {\n return crypto.createHash('md5').update(data).digest('hex');\n}\n", "import { ErrorWithStatusCode } from '../network/fetchWithRetry.ts';\nimport makeHappoAPIRequest from '../network/makeHappoAPIRequest.ts';\nimport createHash from '../utils/createHash.ts';\nimport type {\n BrowserType,\n ConfigWithDefaults,\n Page,\n TargetWithDefaults,\n} from './index.ts';\n\nconst VIEWPORT_PATTERN = /^([0-9]+)x([0-9]+)$/;\n\n/**\n * Maximum number of chunk items sent in a single bulk request.\n * Keeps individual payloads bounded while still protecting against\n * arbitrarily large explicit `chunks` values exceeding server limits.\n */\nconst MAX_BULK_ITEMS_PER_REQUEST = 50;\n\n/**\n * Compute the number of chunks to use based on an estimated snapshot count.\n *\n * Aims for roughly 100 items per chunk, capped at 20. Returns 1 for\n * non-positive or non-finite inputs.\n */\nfunction computeDefaultChunks(estimatedSnapCount: number): number {\n if (!Number.isFinite(estimatedSnapCount) || estimatedSnapCount <= 0) {\n return 1;\n }\n\n return Math.min(20, Math.ceil(estimatedSnapCount / 100));\n}\n\n/**\n * PageSlice is an array of pages with the extra extendsSha property.\n */\ninterface PageSlice extends Array<Page> {\n extendsSha?: string;\n}\n\ninterface Chunk {\n index: number;\n total: number;\n}\n\ninterface ChunkItem {\n type: string;\n targetName: string | undefined;\n payloadString: string;\n payloadHash: string;\n extendsSha?: string;\n}\n\nexport interface CSSBlock {\n id: string;\n conditional: boolean;\n css: string;\n}\n\nexport interface ExecuteParams {\n globalCSS?: string | Array<CSSBlock>;\n\n /** Path to the assets package */\n assetsPackage?: string;\n\n /** Path to the static package */\n staticPackage?: string;\n\n snapPayloads?: Array<unknown>;\n pages?: Array<Page>;\n targetName?: string;\n\n /**\n * Total number of snapshots in the package. When provided for staticPackage\n * requests without explicit chunks, used to automatically determine the\n * optimal number of parallel chunks.\n */\n estimatedSnapsCount?: number;\n\n /**\n * When true, the worker fails the snap if `waitForContent` or\n * `waitForSelector` times out instead of silently warning.\n */\n failOnWaitForTimeout?: boolean;\n}\n\nfunction getPageSlices(pages: Array<Page>, chunks: number): Array<PageSlice> {\n const result: Array<PageSlice> = [];\n\n // First, split the raw pages into chunks\n const pagesPerChunk = Math.ceil(pages.length / chunks);\n for (let i = 0; i < chunks; i += 1) {\n const pageSlice = pages.slice(\n i * pagesPerChunk,\n i * pagesPerChunk + pagesPerChunk,\n );\n\n if (pageSlice.length > 0) {\n result.push(pageSlice);\n }\n }\n return result;\n}\n\nfunction buildChunkItem({\n slice,\n chunk,\n pageSlice,\n browserName,\n viewport,\n maxHeight,\n otherOptions,\n globalCSS,\n staticPackage,\n assetsPackage,\n targetName,\n failOnWaitForTimeout,\n}: {\n slice?: Array<unknown> | undefined;\n chunk?: Chunk | undefined;\n pageSlice?: PageSlice | undefined;\n browserName: BrowserType;\n viewport: string;\n maxHeight: number | undefined;\n otherOptions: Record<string, unknown>;\n globalCSS: string | Array<CSSBlock> | undefined;\n staticPackage: string | undefined;\n assetsPackage: string | undefined;\n targetName: string | undefined;\n failOnWaitForTimeout: boolean | undefined;\n}): ChunkItem {\n const payloadString = JSON.stringify({\n viewport,\n maxHeight,\n ...otherOptions,\n globalCSS,\n snapPayloads: slice,\n chunk,\n staticPackage,\n assetsPackage,\n pages: pageSlice,\n extendsSha: pageSlice ? pageSlice.extendsSha : undefined,\n failOnWaitForTimeout,\n });\n\n const payloadHash = createHash(payloadString + (pageSlice ? Math.random() : ''));\n\n const type =\n pageSlice && pageSlice.extendsSha ? 'extends-report' : `browser-${browserName}`;\n\n const item: ChunkItem = { type, targetName, payloadString, payloadHash };\n if (pageSlice?.extendsSha) {\n item.extendsSha = pageSlice.extendsSha;\n }\n return item;\n}\n\nasync function sendIndividualSnapRequest(\n item: ChunkItem,\n config: ConfigWithDefaults,\n): Promise<number> {\n const formData: Record<string, string | number | File | undefined> = {\n type: item.type,\n targetName: item.targetName,\n payloadHash: item.payloadHash,\n payload: new File([item.payloadString], 'payload.json', {\n type: 'application/json',\n }),\n };\n\n if (item.extendsSha) {\n formData.extendsSha = item.extendsSha;\n }\n\n // We `await` here inside the loop to avoid POSTing all payloads to the\n // server at the same time (thus reducing load a little).\n const requestResult = await makeHappoAPIRequest(\n {\n path: `/api/snap-requests?payloadHash=${item.payloadHash}`,\n method: 'POST',\n formData,\n },\n config,\n { retryCount: 5 },\n );\n\n if (!requestResult) {\n throw new Error('No requestResult');\n }\n\n if (!('requestId' in requestResult)) {\n throw new Error('No requestId in requestResult');\n }\n\n if (typeof requestResult.requestId !== 'number') {\n throw new TypeError('requestId is not a number');\n }\n\n return requestResult.requestId;\n}\n\nexport default class RemoteBrowserTarget {\n public readonly chunks: number | undefined;\n public readonly browserName: BrowserType;\n public readonly viewport: string;\n public readonly maxHeight: number | undefined;\n public readonly otherOptions: Record<string, unknown>;\n\n constructor(\n browserName: BrowserType,\n {\n viewport = '1024x768',\n chunks,\n maxHeight,\n ...otherOptions\n }: TargetWithDefaults,\n ) {\n if (!browserName) {\n throw new Error(\n `Invalid browser type: \"${browserName}\". Make sure the \"type\" field in your target configuration is set to a valid browser type.`,\n );\n }\n\n const viewportMatch = viewport.match(VIEWPORT_PATTERN);\n if (!viewportMatch) {\n throw new Error(\n `Invalid viewport \"${viewport}\". Here's an example of a valid one: \"1024x768\".`,\n );\n }\n\n this.chunks = chunks;\n this.browserName = browserName;\n this.viewport = viewport;\n this.maxHeight = maxHeight ?? undefined;\n this.otherOptions = otherOptions;\n }\n\n async execute(\n {\n globalCSS,\n assetsPackage,\n staticPackage,\n snapPayloads,\n pages,\n targetName,\n estimatedSnapsCount,\n failOnWaitForTimeout,\n }: ExecuteParams,\n config: ConfigWithDefaults,\n ): Promise<Array<number>> {\n const buildItemParams = {\n browserName: this.browserName,\n viewport: this.viewport,\n maxHeight: this.maxHeight,\n otherOptions: this.otherOptions,\n globalCSS,\n staticPackage,\n assetsPackage,\n targetName,\n failOnWaitForTimeout,\n };\n\n // Build all chunk items up front\n const items: Array<ChunkItem> = [];\n\n if (staticPackage) {\n const effectiveChunks =\n this.chunks ?? Math.max(1, computeDefaultChunks(estimatedSnapsCount ?? 0));\n for (let i = 0; i < effectiveChunks; i += 1) {\n items.push(\n buildChunkItem({\n ...buildItemParams,\n chunk:\n effectiveChunks > 1 ? { index: i, total: effectiveChunks } : undefined,\n }),\n );\n }\n } else if (pages) {\n for (const pageSlice of getPageSlices(pages, this.chunks ?? 1)) {\n items.push(buildChunkItem({ ...buildItemParams, pageSlice }));\n }\n } else {\n const effectiveChunks = this.chunks ?? 1;\n const snapsPerChunk = Math.ceil((snapPayloads?.length ?? 0) / effectiveChunks);\n for (let i = 0; i < effectiveChunks; i += 1) {\n const slice = snapPayloads?.slice(\n i * snapsPerChunk,\n i * snapsPerChunk + snapsPerChunk,\n );\n items.push(buildChunkItem({ ...buildItemParams, slice }));\n }\n }\n\n if (items.length === 0) {\n return [];\n }\n\n // Try the bulk endpoint first. If it is unavailable, fall back to individual\n // requests. If it responds with an unexpected payload shape, fail fast to\n // avoid creating duplicate snap-requests.\n //\n // Large item arrays are split into batches of MAX_BULK_ITEMS_PER_REQUEST\n // and sent as sequential bulk requests to keep individual payloads bounded.\n try {\n const requestIds: Array<number | undefined> = Array.from({\n length: items.length,\n });\n\n for (\n let batchStart = 0;\n batchStart < items.length;\n batchStart += MAX_BULK_ITEMS_PER_REQUEST\n ) {\n const batch = items.slice(\n batchStart,\n batchStart + MAX_BULK_ITEMS_PER_REQUEST,\n );\n\n const result = await makeHappoAPIRequest(\n {\n path: '/api/snap-requests/bulk',\n method: 'POST',\n body: { items: batch },\n },\n config,\n { retryCount: 5 },\n );\n\n if (\n result &&\n 'results' in result &&\n Array.isArray(result.results) &&\n result.results.length === batch.length\n ) {\n const bulkResults = result.results as Array<{\n requestId?: number;\n error?: string;\n }>;\n\n for (const [i, r] of bulkResults.entries()) {\n requestIds[batchStart + i] =\n typeof r.requestId === 'number' ? r.requestId : undefined;\n }\n } else {\n // The bulk endpoint responded with a 200 but an unexpected payload\n // shape. Fail fast instead of falling back to avoid potentially\n // creating duplicate snap-requests.\n throw new Error(\n 'Bulk snap-requests endpoint returned an unexpected payload shape; aborting to avoid duplicate snap-requests.',\n );\n }\n }\n\n // Retry any failed items individually (sequentially to reduce load)\n for (const [i, item] of items.entries()) {\n if (requestIds[i] === undefined) {\n requestIds[i] = await sendIndividualSnapRequest(item, config);\n }\n }\n\n return requestIds.map((id, index) => {\n if (id === undefined) {\n throw new Error(\n `Failed to obtain snap request ID for item at index ${index}`,\n );\n }\n\n return id;\n });\n } catch (error) {\n // Fall back to individual requests only when the server explicitly\n // reports that the bulk endpoint is missing or not implemented.\n if (\n !(\n error instanceof ErrorWithStatusCode &&\n (error.statusCode === 404 || error.statusCode === 501)\n )\n ) {\n throw error;\n }\n }\n\n // Fallback: sequential individual requests (for older happo deployments)\n const requestIds: Array<number> = [];\n\n for (const item of items) {\n requestIds.push(await sendIndividualSnapRequest(item, config));\n }\n\n return requestIds;\n }\n}\n", "import { spawn } from 'node:child_process';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport type { StorybookIntegration } from '../config/index.ts';\nimport { isInSkipSet, toSkipSet } from '../isomorphic/parseSkip.ts';\nimport type { OnlyItem, SkipItem } from '../isomorphic/types.ts';\nimport getStorybookBuildCommandParts from './getStorybookBuildCommandParts.ts';\nimport getStorybookVersionFromPackageJson from './getStorybookVersionFromPackageJson.ts';\nimport resolveStoryFileItems, { type StorybookIndexEntry } from './resolveStoryFileItems.ts';\n\nconst { HAPPO_DEBUG } = process.env;\n\nfunction resolveBuildCommandParts() {\n const version = getStorybookVersionFromPackageJson();\n\n if (version < 9) {\n throw new Error(\n `Storybook v${version} is not supported. Please update storybook to v9 or later.`,\n );\n }\n\n return getStorybookBuildCommandParts();\n}\n\nasync function buildStorybook({\n configDir,\n staticDir,\n outputDir,\n}: {\n configDir: string;\n staticDir?: string | undefined;\n outputDir: string;\n}): Promise<void> {\n await fs.promises.rm(outputDir, { recursive: true, force: true });\n\n const buildCommandParts = resolveBuildCommandParts();\n\n if (!buildCommandParts[0]) {\n throw new Error('Failed to resolve build command parts');\n }\n\n const params = [\n ...buildCommandParts,\n '--output-dir',\n outputDir,\n '--config-dir',\n configDir,\n ];\n\n if (staticDir) {\n params.push('--static-dir', staticDir);\n }\n\n let binary = fs.existsSync('yarn.lock') ? 'yarn' : 'npx';\n\n if (buildCommandParts[0].includes('node_modules')) {\n binary = buildCommandParts[0];\n params.shift(); // remove binary from params\n }\n\n if (HAPPO_DEBUG) {\n console.log(`[happo] Using build command \\`${binary} ${params.join(' ')}\\``);\n }\n\n return new Promise((resolve, reject) => {\n const spawned = spawn(binary, params, {\n stdio: 'inherit',\n shell: process.platform == 'win32',\n });\n\n spawned.on('exit', (code) => {\n if (code === 0) {\n try {\n fs.unlinkSync(path.join(outputDir, 'project.json'));\n } catch (error) {\n console.warn(\n `Ignoring error when attempting to remove project.json: ${error}`,\n );\n }\n resolve();\n } else {\n reject(new Error('Failed to build static storybook package'));\n }\n });\n });\n}\n\nexport interface BuildStorybookPackageResult {\n packageDir: string;\n estimatedSnapsCount?: number;\n resolvedSkip?: Array<{ component: string; variant?: string }>;\n}\n\nexport default async function buildStorybookPackage({\n configDir = '.storybook',\n staticDir,\n outputDir = '.out',\n usePrebuiltPackage = false,\n skip,\n only,\n}: Omit<StorybookIntegration, 'type'> & {\n skip?: Array<SkipItem>;\n only?: Array<OnlyItem>;\n}): Promise<BuildStorybookPackageResult> {\n if (!usePrebuiltPackage) {\n await buildStorybook({ configDir, staticDir, outputDir });\n }\n\n const iframePath = path.join(outputDir, 'iframe.html');\n if (!fs.existsSync(iframePath)) {\n throw new Error(\n 'Failed to build static storybook package (missing iframe.html)',\n );\n }\n\n try {\n const iframeContent = await fs.promises.readFile(iframePath, 'utf8');\n\n // Read index.json once to compute story count and resolve storyFile items.\n let estimatedSnapsCount: number | undefined;\n let resolvedSkip: Array<{ component: string; variant?: string }> | undefined;\n let resolvedOnly: Array<{ component: string }> | undefined;\n\n const indexPath = path.join(outputDir, 'index.json');\n try {\n const indexContent = await fs.promises.readFile(indexPath, 'utf8');\n const indexData = JSON.parse(indexContent) as {\n entries?: Record<string, StorybookIndexEntry>;\n stories?: Record<string, StorybookIndexEntry>;\n };\n const entries = indexData.entries ?? indexData.stories ?? {};\n\n const storyEntries = Object.values(entries).filter((e) => e.type === 'story');\n estimatedSnapsCount = storyEntries.length;\n\n if (skip !== undefined) {\n resolvedSkip = resolveStoryFileItems(skip, entries);\n // Adjust the count so auto-chunking reflects only the stories that\n // will actually be rendered (skipped examples don't need a chunk slot).\n const skipSet = toSkipSet(resolvedSkip);\n estimatedSnapsCount = storyEntries.filter(\n (e) => !isInSkipSet(skipSet, e.title ?? '', e.name ?? ''),\n ).length;\n }\n\n if (only !== undefined) {\n if (only.length === 0) {\n // Empty --only: nothing is rendered locally; every component is\n // borrowed from the baseline via an extends-report.\n const allComponents = new Set<string>();\n for (const e of storyEntries) {\n if (e.title) allComponents.add(e.title);\n }\n resolvedSkip = [...allComponents].map((component) => ({ component }));\n estimatedSnapsCount = 0;\n } else {\n resolvedOnly = resolveStoryFileItems(only as Array<SkipItem>, entries).map(\n ({ component }) => ({ component }),\n );\n if (resolvedOnly.length === 0) {\n console.warn(\n '[HAPPO] --only: no matching stories found in Storybook index. Generating a full report instead.',\n );\n resolvedOnly = undefined;\n } else {\n // Adjust the count so auto-chunking reflects only the stories that\n // will actually be rendered (only matching examples need a chunk slot).\n const onlyComponents = new Set(resolvedOnly.map((item) => item.component));\n estimatedSnapsCount = storyEntries.filter((e) =>\n onlyComponents.has(e.title ?? ''),\n ).length;\n\n // Compute the complement: all components NOT in the only list.\n // These will be borrowed from the baseline via an extends-report.\n const allComponents = new Set<string>();\n for (const e of storyEntries) {\n if (e.title) allComponents.add(e.title);\n }\n resolvedSkip = [...allComponents]\n .filter((c) => !onlyComponents.has(c))\n .map((component) => ({ component }));\n }\n }\n }\n } catch (error) {\n console.warn('[HAPPO] Failed to read Storybook index.json:', error);\n if (skip !== undefined) {\n // Fall back to passing through only component-based items\n resolvedSkip = skip.filter(\n (item): item is { component: string; variant?: string } => 'component' in item,\n );\n }\n if (only !== undefined) {\n // Fall back to component-only items; if none remain, leave resolvedOnly\n // undefined so the browser-side filtering is disabled and a full report\n // is generated rather than an empty one.\n const componentOnly = only.filter(\n (item): item is { component: string } => 'component' in item,\n );\n resolvedOnly = componentOnly.length > 0 ? componentOnly : undefined;\n }\n }\n\n await fs.promises.writeFile(\n iframePath,\n iframeContent.replace(\n '<head>',\n `<head>\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n <script type=\"text/javascript\">window.__IS_HAPPO_RUN = true;</script>\n <script type=\"text/javascript\">window.happoSkipped = ${JSON.stringify(resolvedSkip ?? []).replaceAll(/<\\/script>/gi, String.raw`<\\/script>`)};</script>\n <script type=\"text/javascript\">window.happoOnly = ${JSON.stringify(resolvedOnly ?? null).replaceAll(/<\\/script>/gi, String.raw`<\\/script>`)};</script>\n `,\n ),\n );\n\n const result: BuildStorybookPackageResult = { packageDir: outputDir };\n if (estimatedSnapsCount != null) {\n result.estimatedSnapsCount = estimatedSnapsCount;\n }\n if (resolvedSkip !== undefined) {\n result.resolvedSkip = resolvedSkip;\n }\n return result;\n } catch (e) {\n console.error(e);\n throw e;\n }\n}\n", "import fs from 'node:fs';\nimport path from 'node:path';\n\nconst { HAPPO_DEBUG } = process.env;\n\nexport default function getStorybookBuildCommandParts(\n packageJsonPath: string = path.join(process.cwd(), 'package.json'),\n): [string, string] {\n try {\n const data = fs.readFileSync(packageJsonPath, 'utf8');\n const packageJson = JSON.parse(data);\n\n if (packageJson.scripts.storybook) {\n if (HAPPO_DEBUG) {\n console.log(\n '[happo] Found `storybook` script in package.json. Will attempt to use binary found at `node_modules/.bin/storybook` instead',\n );\n }\n\n const pathToStorybookCommand = path.join(\n process.cwd(),\n 'node_modules',\n '.bin',\n 'storybook',\n );\n\n if (fs.existsSync(pathToStorybookCommand)) {\n return [pathToStorybookCommand, 'build'];\n }\n }\n } catch (e) {\n if (HAPPO_DEBUG) {\n console.log(\n '[happo] Caught error when resolving Storybook build command parts. Will use default.',\n e,\n );\n }\n }\n\n return ['storybook', 'build'];\n}\n", "import fs from 'node:fs';\nimport { createRequire } from 'node:module';\nimport path from 'node:path';\n\nimport * as walk from 'empathic/walk';\n\nfunction readVersionFrom(filePath: string): string | undefined {\n try {\n return JSON.parse(fs.readFileSync(filePath, 'utf8')).version;\n } catch {\n return undefined;\n }\n}\n\nfunction findPackageJsonForEntryPath(\n entryPath: string,\n pkgName: string,\n): string | undefined {\n // Walk up from a resolved entry file to the nearest package.json whose\n // `name` matches `pkgName`. Node's resolution always places the entry inside\n // the package's own tree (even under pnpm's .pnpm virtual store or Yarn\n // PnP's zipfs), so this reliably finds the correct root.\n for (const dir of walk.up(path.dirname(entryPath))) {\n const candidate = path.join(dir, 'package.json');\n try {\n const parsed = JSON.parse(fs.readFileSync(candidate, 'utf8'));\n if (parsed.name === pkgName) {\n return candidate;\n }\n } catch {\n // not a readable package.json here; keep walking up\n }\n }\n\n return undefined;\n}\n\nfunction readInstalledVersion(\n pkg: string,\n projectRoot: string,\n): string | undefined {\n // Prefer Node's module resolution so we work with every layout that Node\n // itself understands: flat node_modules (npm/yarn classic), pnpm's symlinked\n // tree, hoisted packages in parent node_modules, and Yarn Plug'n'Play when\n // the process has PnP hooks installed.\n const requireFromProject = createRequire(\n path.join(projectRoot, 'package.json'),\n );\n\n // Tier 1: resolve `${pkg}/package.json` directly. The happy path for most\n // packages regardless of layout.\n try {\n const version = readVersionFrom(\n requireFromProject.resolve(`${pkg}/package.json`),\n );\n if (version) {\n return version;\n }\n } catch {\n // Packages whose `exports` field does not list `./package.json` make\n // require.resolve throw `ERR_PACKAGE_PATH_NOT_EXPORTED` even when the\n // file exists. Fall through.\n }\n\n // Tier 2: resolve the package's main entry and walk up to its package.json.\n // Covers the combination of a restrictive `exports` field and a hoisted\n // install (parent node_modules, pnpm virtual store, Yarn PnP zipfs), where\n // neither tier 1 nor the direct lookup below would work.\n try {\n const entryPath = requireFromProject.resolve(pkg);\n const pkgJsonPath = findPackageJsonForEntryPath(entryPath, pkg);\n if (pkgJsonPath) {\n const version = readVersionFrom(pkgJsonPath);\n if (version) {\n return version;\n }\n }\n } catch {\n // Fall through to the direct node_modules lookup.\n }\n\n // Tier 3: read node_modules/<pkg>/package.json directly. Belt-and-suspenders\n // for cases where the file exists on disk but require.resolve cannot reach\n // it (e.g. both `.` and `./package.json` hidden behind a restrictive\n // exports map).\n return readVersionFrom(\n path.join(projectRoot, 'node_modules', pkg, 'package.json'),\n );\n}\n\nexport default function getStorybookVersionFromPackageJson(\n packageJsonPath: string = path.join(process.cwd(), 'package.json'),\n): number {\n const data = fs.readFileSync(packageJsonPath, 'utf8');\n const packageJson = JSON.parse(data);\n\n const combinedDependencies = {\n ...packageJson.dependencies,\n ...packageJson.devDependencies,\n };\n\n const storybookPackage = [\n 'storybook',\n '@storybook/react',\n '@storybook/angular',\n '@storybook/vue',\n ].find((pkg) => combinedDependencies[pkg]);\n\n if (!storybookPackage) {\n throw new Error('Storybook is not listed as a dependency in package.json');\n }\n\n const declaredVersion: string = combinedDependencies[storybookPackage];\n const declaredMatch = declaredVersion.match(/\\d+/);\n if (declaredMatch) {\n return Number.parseInt(declaredMatch[0], 10);\n }\n\n // The declared dependency is not a plain semver range. This happens with\n // pnpm catalogs (\"catalog:\", \"catalog:foo\"), workspace protocols\n // (\"workspace:*\"), and other non-semver specifiers (\"link:\", \"file:\", etc.).\n // Fall back to the version from the installed package in node_modules.\n const projectRoot = path.dirname(packageJsonPath);\n const installedVersion = readInstalledVersion(storybookPackage, projectRoot);\n const installedMatch = installedVersion?.match(/\\d+/);\n if (installedMatch) {\n return Number.parseInt(installedMatch[0], 10);\n }\n\n throw new Error(\n `Unable to determine installed version of ${storybookPackage} (found \"${declaredVersion}\" in ${packageJsonPath}). ` +\n `Tried resolving from ${projectRoot} and reading ${path.join(projectRoot, 'node_modules', storybookPackage, 'package.json')}. ` +\n `Ensure dependencies are installed and that ${storybookPackage} is resolvable from that project root.`,\n );\n}\n", "import path from 'node:path';\n\nimport type { SkipItem } from '../isomorphic/types.ts';\n\nexport interface StorybookIndexEntry {\n type: string;\n importPath?: string;\n title?: string;\n name?: string;\n}\n\n/**\n * Resolves `storyFile` skip items to component-based skip items using the\n * Storybook `index.json` entries. Items that already have a `component` are\n * passed through unchanged.\n *\n * Path matching is done by normalising both the `importPath` from the index\n * and the user-supplied `storyFile` (stripping a leading `./`), with an\n * absolute-path fallback via `path.resolve`.\n */\nexport default function resolveStoryFileItems(\n skip: Array<SkipItem>,\n entries: Record<string, StorybookIndexEntry>,\n): Array<{ component: string; variant?: string }> {\n const fileToComponents = new Map<string, Set<string>>();\n for (const entry of Object.values(entries)) {\n if (!entry.importPath || !entry.title) continue;\n const normalized = normalizeImportPath(entry.importPath);\n let set = fileToComponents.get(normalized);\n if (!set) {\n set = new Set();\n fileToComponents.set(normalized, set);\n }\n set.add(entry.title);\n }\n\n const resolved: Array<{ component: string; variant?: string }> = [];\n\n for (const item of skip) {\n if ('component' in item) {\n resolved.push(item);\n continue;\n }\n\n const normalizedFile = normalizeImportPath(item.storyFile);\n let components = fileToComponents.get(normalizedFile);\n\n if (!components) {\n // Fall back to absolute path comparison\n const resolvedFile = path.resolve(item.storyFile);\n for (const [normalizedImport, titles] of fileToComponents) {\n if (path.resolve(normalizedImport) === resolvedFile) {\n components = titles;\n break;\n }\n }\n }\n\n if (components) {\n for (const component of components) {\n resolved.push({ component });\n }\n } else {\n console.warn(\n `[HAPPO] Could not find any stories for storyFile '${item.storyFile}' in the Storybook index`,\n );\n }\n }\n\n return resolved;\n}\n\nfunction normalizeImportPath(p: string): string {\n return p.startsWith('./') ? p.slice(2) : p;\n}\n", "import fs from 'node:fs';\nimport path from 'node:path';\nimport { Readable } from 'node:stream';\n\nimport type { Zippable } from 'fflate';\nimport { zip } from 'fflate';\n\nimport createHash from './createHash.ts';\nimport validateArchive from './validateArchive.ts';\n\n// Normalize path separators to forward slashes for cross-platform consistency.\n// path.relative() returns backslashes on Windows; callers may also pass names\n// built with path.join() on Windows.\nfunction normalizeEntryName(name: string): string {\n return name.replaceAll('\\\\', '/');\n}\n\n// We're setting the creation date to the same for all files so that the zip\n// packages created for the same content ends up having the same fingerprint.\n// https://github.com/101arrowz/fflate/issues/219#issuecomment-2333945868\nconst FILE_CREATION_DATE = new Date(2019, 1, 8, 13, 31, 55);\n\n// Type definitions\ninterface FileEntry {\n name: string;\n stream: fs.ReadStream;\n}\n\nexport interface ArchiveContentEntry {\n name: string;\n content: string | Buffer | fs.ReadStream | Readable;\n}\n\ninterface ArchiveResult {\n buffer: Buffer<ArrayBuffer>;\n hash: string;\n}\n\ninterface ArchiveEntry {\n name: string;\n size: number;\n}\n\n/**\n * Resolves all files in a directory and all of its subdirectories\n *\n * @param dirOrFile - The directory or file path to resolve\n * @returns Promise resolving to an array of file entries\n */\nasync function resolveFilesRecursiveForDir(\n dirOrFile: string,\n): Promise<Array<FileEntry>> {\n const resolvedDirOrFile = path.resolve(dirOrFile);\n const isDir = (await fs.promises.lstat(resolvedDirOrFile)).isDirectory();\n\n if (isDir) {\n const fileEntries: Array<FileEntry> = [];\n\n for await (const fileType of fs.promises.glob('**/*', {\n cwd: resolvedDirOrFile,\n withFileTypes: true,\n })) {\n // Check if it's a file (not a directory)\n if (fileType.isFile()) {\n const fullPath = `${fileType.parentPath}/${fileType.name}`;\n\n fileEntries.push({\n name: normalizeEntryName(path.relative(resolvedDirOrFile, fullPath)),\n stream: fs.createReadStream(fullPath),\n });\n }\n }\n\n return fileEntries;\n }\n\n return [\n {\n name: normalizeEntryName(path.relative(process.cwd(), resolvedDirOrFile)),\n stream: fs.createReadStream(resolvedDirOrFile),\n },\n ];\n}\n\n/**\n * Resolves all files in all directories recursively\n *\n * @param dirsAndFiles - Variable number of directory and file paths\n * @returns Promise resolving to a flattened array of file entries\n */\nasync function resolveFilesRecursive(\n ...dirsAndFiles: Array<string>\n): Promise<Array<FileEntry>> {\n const files = await Promise.all(\n dirsAndFiles.map((dirOrFile) => resolveFilesRecursiveForDir(dirOrFile)),\n );\n\n return files.flat();\n}\n\n/**\n * Converts a stream to a Uint8Array\n */\nasync function streamToUint8Array(\n stream: fs.ReadStream | Readable,\n): Promise<Uint8Array> {\n const chunks: Array<Uint8Array> = [];\n for await (const chunk of stream) {\n chunks.push(chunk instanceof Uint8Array ? chunk : new Uint8Array(chunk));\n }\n const totalLength = chunks.reduce((sum, chunk) => sum + chunk.length, 0);\n const result = new Uint8Array(totalLength);\n let offset = 0;\n for (const chunk of chunks) {\n result.set(chunk, offset);\n offset += chunk.length;\n }\n return result;\n}\n\n/**\n * Converts content to Uint8Array\n */\nasync function contentToUint8Array(\n content: string | Buffer | fs.ReadStream | Readable,\n): Promise<Uint8Array> {\n if (typeof content === 'string') {\n return new TextEncoder().encode(content);\n }\n if (Buffer.isBuffer(content)) {\n return new Uint8Array(content);\n }\n return streamToUint8Array(content);\n}\n\n/**\n * Creates a deterministic archive of the given files\n *\n * @param dirsAndFiles - Array of directory and file paths to include\n * @param contentToArchive - Array of content entries to include in the archive\n * @returns Promise resolving to archive result with buffer and hash\n */\nexport default async function deterministicArchive(\n dirsAndFiles: Array<string>,\n contentToArchive: Array<ArchiveContentEntry> = [],\n): Promise<ArchiveResult> {\n const uniqueDirsAndFiles = Array.from(new Set(dirsAndFiles));\n\n // Sort by name to make the output deterministic\n // Use simple string comparison instead of localeCompare for cross-platform determinism\n const filesToArchiveSorted = (\n await resolveFilesRecursive(...uniqueDirsAndFiles)\n ).toSorted((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));\n\n const contentToArchiveSorted = contentToArchive.toSorted((a, b) =>\n a.name < b.name ? -1 : a.name > b.name ? 1 : 0,\n );\n\n const seenFiles = new Set<string>();\n const entries: Array<ArchiveEntry> = [];\n\n // Collect all entries with their data first\n interface EntryData {\n name: string;\n data: Uint8Array;\n }\n\n const entryDataList: Array<EntryData> = [];\n\n // Process files from disk\n for (const file of filesToArchiveSorted) {\n if (!seenFiles.has(file.name)) {\n const data = await streamToUint8Array(file.stream);\n entryDataList.push({ name: file.name, data });\n entries.push({ name: file.name, size: data.length });\n seenFiles.add(file.name);\n }\n }\n\n // Process in-memory content\n // Extract basename to match archiver's behavior with prefix: '' for content entries\n for (const file of contentToArchiveSorted) {\n const normalizedName = normalizeEntryName(file.name);\n if (!seenFiles.has(normalizedName)) {\n const data = await contentToUint8Array(file.content);\n entryDataList.push({ name: normalizedName, data });\n entries.push({ name: normalizedName, size: data.length });\n seenFiles.add(normalizedName);\n }\n }\n\n // Sort all entries by name to ensure deterministic order\n // Use simple string comparison instead of localeCompare for cross-platform determinism\n entryDataList.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));\n\n // Build zipData object in sorted order to ensure deterministic zip creation\n const zipData: Zippable = {};\n for (const entry of entryDataList) {\n zipData[entry.name] = [\n entry.data,\n {\n mtime: FILE_CREATION_DATE,\n level: 6,\n },\n ];\n }\n\n const zipBuffer = await new Promise<Uint8Array>((resolve, reject) => {\n zip(zipData, { level: 6 }, (err, data) => {\n if (err) {\n reject(err);\n } else {\n resolve(data);\n }\n });\n });\n const buffer = Buffer.from(zipBuffer);\n validateArchive(buffer.length, entries);\n const hash = createHash(buffer);\n\n return { buffer, hash };\n}\n", "/**\n * Validates that the archive was created successfully\n * @param totalBytes - The total bytes in the archive\n * @param entries - Array of archive entries\n */\nexport default function validateArchive(\n totalBytes: number,\n entries: Array<{ name: string; size: number }>,\n): void {\n const totalMegaBytes = Math.round(totalBytes / 1024 / 1024);\n\n if (totalMegaBytes < 30) {\n return;\n }\n\n const messageBits = [\n `Package size is ${totalMegaBytes} MB (${totalBytes} bytes), maximum is 60 MB.`,\n \"Here are the largest 20 files in the archive. Consider removing ones that aren't necessary.\",\n ];\n\n const fileSizes = entries.map((entry) => ({\n name: entry.name,\n size: entry.size || 0,\n }));\n\n for (const file of fileSizes.toSorted((a, b) => b.size - a.size).slice(0, 20)) {\n messageBits.push(\n `${file.name}: ${Math.round(file.size / 1024 / 1024)} MB (${file.size} bytes)`,\n );\n }\n\n if (totalMegaBytes > 60) {\n throw new Error(messageBits.join('\\n'));\n }\n\n console.warn(messageBits.join('\\n'));\n}\n", "import { styleText } from 'node:util';\n\ntype PrintFunction = (str: string) => void;\n\nconst red = (str: string) => styleText('red', str);\nconst green = (str: string) => styleText('green', str);\nconst dim = (str: string) => styleText('dim', str);\nconst underline = (str: string) => styleText('underline', str);\n\nexport function logTag(project?: string): string {\n return project ? `[${project}] ` : '';\n}\n\nfunction printDuration(print: PrintFunction, startTime?: number): void {\n if (startTime) {\n print(dim(` (${Date.now() - startTime}ms)`));\n }\n}\n\ninterface LoggerOptions {\n stderrPrint?: PrintFunction;\n print?: PrintFunction;\n}\n\ninterface StartOptions {\n startTime?: number;\n}\n\nexport default class Logger {\n private print: PrintFunction;\n private stderrPrint: PrintFunction;\n private startTime?: number | undefined;\n private startMsg?: string | undefined;\n\n constructor({\n stderrPrint = (str: string) => process.stderr.write(str),\n print = (str: string) => process.stdout.write(str),\n }: LoggerOptions = {}) {\n this.print = print;\n this.stderrPrint = stderrPrint;\n this.startTime = undefined;\n this.startMsg = undefined;\n }\n\n mute(): void {\n this.print = () => null;\n this.stderrPrint = () => null;\n }\n\n divider(): void {\n this.info('-----------------------------------------');\n }\n\n info(msg: string): void {\n this.print(`${msg}`.replaceAll(/https?:\\/\\/[^ ]+/g, underline));\n this.print('\\n');\n }\n\n start(msg?: string, { startTime }: StartOptions = {}): void {\n this.startTime = startTime || Date.now();\n this.startMsg = msg;\n if (msg) {\n this.print(`Starting: ${msg} `);\n this.print('\\n');\n }\n }\n\n success(msg?: string): void {\n this.print(green('\u2713'));\n\n if (this.startMsg) {\n this.print(green(` ${this.startMsg}:`));\n }\n\n if (msg) {\n this.print(green(` ${msg}`));\n }\n printDuration(this.print, this.startTime);\n this.print('\\n');\n\n this.startMsg = undefined;\n }\n\n fail(msg?: string): void {\n this.print(red('\u2717'));\n\n if (this.startMsg) {\n this.print(red(` ${this.startMsg}:`));\n }\n\n if (msg) {\n this.print(red(` ${msg}`));\n }\n printDuration(this.print, this.startTime);\n this.print('\\n');\n\n this.startMsg = undefined;\n }\n\n error(e: Error | string): void {\n let stack: string | undefined;\n if (typeof e === 'object' && e.stack) {\n stack = e.stack;\n if (stack) {\n stack = stack.split(`file://${process.cwd()}/`).join('');\n }\n }\n this.stderrPrint(\n red(stack || (typeof e === 'object' ? e.message : e) || String(e)),\n );\n this.stderrPrint('\\n');\n }\n\n warn(message: string): void {\n this.stderrPrint(red(message));\n this.stderrPrint('\\n');\n }\n}\n", "import { createHash } from 'node:crypto';\n\nimport retry from 'async-retry';\n\nimport type { ConfigWithDefaults } from '../config/index.ts';\nimport { logTag } from '../utils/Logger.ts';\nimport makeHappoAPIRequest from './makeHappoAPIRequest.ts';\n\n// Type definitions\ninterface Logger {\n info: (message: string) => void;\n warn: (message: string) => void;\n}\n\ninterface UploadAssetsOptions {\n hash: string;\n logger: Logger;\n}\n\nexport default async function uploadAssets(\n buffer: Buffer<ArrayBuffer>,\n options: UploadAssetsOptions,\n config: ConfigWithDefaults,\n): Promise<string> {\n const { project } = config;\n const { hash, logger } = options;\n\n // First we need to get the signed URL from Happo.\n const signedUrlRes = await makeHappoAPIRequest(\n {\n path: `/api/snap-requests/assets/${hash}/signed-url`,\n method: 'GET',\n },\n config,\n { retryCount: 3 },\n );\n\n if (!signedUrlRes) {\n throw new Error('Failed to get signed URL');\n }\n\n if ('path' in signedUrlRes) {\n // If the asset has already been uploaded the response will have a path and\n // we can return it now.\n const { path: signedUrlPath } = signedUrlRes;\n\n logger.info(`${logTag(project)}Reusing existing assets at ${signedUrlPath}`);\n return typeof signedUrlPath === 'string' ? signedUrlPath : String(signedUrlPath);\n }\n\n if (!('signedUrl' in signedUrlRes)) {\n throw new Error(\n `Signed URL response does not have path or signedUrl. Response: ${JSON.stringify(signedUrlRes, null, 2)}`,\n );\n }\n\n const { signedUrl } = signedUrlRes;\n\n // Upload the assets to the signed URL using node's built-in fetch with\n // retries\n await retry(\n async (bail: (error: Error) => void) => {\n const res = await fetch(String(signedUrl), {\n method: 'PUT',\n body: buffer,\n headers: {\n 'Content-Type': 'application/zip',\n },\n signal: AbortSignal.timeout(60_000),\n });\n\n if (!res.ok) {\n const error = new Error(\n `Failed to upload assets to S3 signed URL: ${res.status} ${res.statusText}`,\n );\n\n if (res.status < 500 || res.status >= 600) {\n // If it's not a 5xx error, bail immediately instead of retrying\n bail(error);\n return;\n }\n\n throw error;\n }\n\n // Verify the upload succeeded by checking the ETag header. S3 always\n // returns an ETag matching the MD5 of the uploaded content. A firewall\n // or transparent proxy returning a fake 200 will typically not include\n // a correct ETag, catching the case where the payload never reached S3.\n const etag = res.headers.get('etag');\n const expectedEtag = createHash('md5').update(buffer).digest('hex');\n if (!etag || !etag.includes(expectedEtag)) {\n const error = new Error(\n `S3 upload verification failed: expected ETag to include ${expectedEtag}, got ${etag ?? '(none)'}. ` +\n `A firewall may be intercepting the upload.`,\n );\n bail(error);\n return;\n }\n\n return res;\n },\n {\n retries: 3,\n onRetry: (error: Error, attempt: number) => {\n logger.warn(\n `${logTag(project)}PUT request attempt ${attempt} failed: ${error.message}. Retrying...`,\n );\n },\n },\n );\n\n // Finally, we need to tell Happo that we've uploaded the assets.\n const finalizeRes = await makeHappoAPIRequest(\n {\n path: `/api/snap-requests/assets/${hash}/signed-url/finalize`,\n method: 'POST',\n },\n config,\n { retryCount: 3 },\n );\n\n if (!finalizeRes) {\n throw new Error('Failed to finalize assets');\n }\n\n if (!('path' in finalizeRes)) {\n throw new Error('Finalize response is missing path');\n }\n\n const { path: finalizedPath } = finalizeRes;\n\n return typeof finalizedPath === 'string' ? finalizedPath : String(finalizedPath);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;AAAA,OAAOA,SAAQ;AACf,OAAOC,WAAU;;;ACDjB,OAAO,YAAY;AAOJ,SAAR,WACL,MACQ;AACR,SAAO,OAAO,WAAW,KAAK,EAAE,OAAO,IAA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G;AACzB,cAAM,IAAI,MAAM,UAAU,IAAI,sBAAsB;AAAA,MACtD;AAEA,YAAM,SAAS,IAAI;AAAA,QACjB,OAAO,QAAQ,IAAI,EAAE;AAAA,QACrB,OAAO,QAAQ,IAAI;AAAA,MACrB;AAEA,YAAM,eAA8B;AAAA,QAClC,YAAY;AAAA,QACZ,sBAAsB,OAAO;AAAA,MAC/B;AAEA,UAAI,eAAe;AACjB,qBAAa,gBAAgB,cAAc;AAE3C,YAAI,cAAc,uBAAuB,MAAM;AAC7C,uBAAa,sBAAsB,cAAc;AAAA,QACnD;AAAA,MACF;AAEA,UAAI,OAAO,YAAY,SAAS,SAAS;AACvC,qBAAa,QAAQ,OAAO,YAAY;AAAA,MAC1C;AAEA,YAAM,MAAM,MAAM,OAAO,QAAQ,cAAc,MAAM;AACrD,aAAO,MAAM,OAAO,OAAO,OAAO,OAAO,CAAC,GAAG,IAAI,IAAI,EAAE,UAAU,CAAC;AAClE,aAAO,QAAQ;AACf,qBAAe,KAAK,GAAG,GAAG;AAAA,IAC5B,CAAC;AAAA,EACH;AACA,SAAO,MAAM,QAAW,EAAE,WAAW,eAAe,CAAC;AACrD,SAAO,QAAQ;AACf,QAAM,SAAoC,EAAE,eAAe;AAC3D,MAAI,eAAe,iBAAiB,QAAW;AAC7C,WAAO,eAAe,cAAc;AAAA,EACtC;AACA,SAAO;AACT;",
|
|
6
|
+
"names": ["fs", "path", "requestIds", "fs", "path", "fs", "path", "path", "HAPPO_DEBUG", "fs", "path", "fs", "path", "path", "fs", "createHash", "createHash", "path", "fs"]
|
|
7
|
+
}
|
|
@@ -3,21 +3,21 @@ import {
|
|
|
3
3
|
} from "./chunk-X4TE2VNY.js";
|
|
4
4
|
import {
|
|
5
5
|
cancelJob
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-UE2TDVXX.js";
|
|
7
7
|
import {
|
|
8
8
|
startServer
|
|
9
9
|
} from "./chunk-JTRP4JVC.js";
|
|
10
10
|
import {
|
|
11
11
|
startJob
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-SZM5DT7T.js";
|
|
13
13
|
import {
|
|
14
14
|
createAsyncComparison
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-TRVYVBOG.js";
|
|
16
16
|
import {
|
|
17
17
|
makeHappoAPIRequest
|
|
18
|
-
} from "./chunk-
|
|
19
|
-
import "./chunk-
|
|
20
|
-
import "./chunk-
|
|
18
|
+
} from "./chunk-KJAXUBWS.js";
|
|
19
|
+
import "./chunk-6LZEMKE5.js";
|
|
20
|
+
import "./chunk-NAZ3MMJW.js";
|
|
21
21
|
|
|
22
22
|
// src/e2e/wrapper.ts
|
|
23
23
|
import { spawn } from "node:child_process";
|
|
@@ -235,4 +235,4 @@ export {
|
|
|
235
235
|
runWithWrapper as default,
|
|
236
236
|
finalizeAll
|
|
237
237
|
};
|
|
238
|
-
//# sourceMappingURL=wrapper-
|
|
238
|
+
//# sourceMappingURL=wrapper-RZ37F2SC.js.map
|
|
@@ -19,6 +19,11 @@ export interface ExecuteParams {
|
|
|
19
19
|
* optimal number of parallel chunks.
|
|
20
20
|
*/
|
|
21
21
|
estimatedSnapsCount?: number;
|
|
22
|
+
/**
|
|
23
|
+
* When true, the worker fails the snap if `waitForContent` or
|
|
24
|
+
* `waitForSelector` times out instead of silently warning.
|
|
25
|
+
*/
|
|
26
|
+
failOnWaitForTimeout?: boolean;
|
|
22
27
|
}
|
|
23
28
|
export default class RemoteBrowserTarget {
|
|
24
29
|
readonly chunks: number | undefined;
|
|
@@ -27,6 +32,6 @@ export default class RemoteBrowserTarget {
|
|
|
27
32
|
readonly maxHeight: number | undefined;
|
|
28
33
|
readonly otherOptions: Record<string, unknown>;
|
|
29
34
|
constructor(browserName: BrowserType, { viewport, chunks, maxHeight, ...otherOptions }: TargetWithDefaults);
|
|
30
|
-
execute({ globalCSS, assetsPackage, staticPackage, snapPayloads, pages, targetName, estimatedSnapsCount, }: ExecuteParams, config: ConfigWithDefaults): Promise<Array<number>>;
|
|
35
|
+
execute({ globalCSS, assetsPackage, staticPackage, snapPayloads, pages, targetName, estimatedSnapsCount, failOnWaitForTimeout, }: ExecuteParams, config: ConfigWithDefaults): Promise<Array<number>>;
|
|
31
36
|
}
|
|
32
37
|
//# sourceMappingURL=RemoteBrowserTarget.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RemoteBrowserTarget.d.ts","sourceRoot":"","sources":["../../src/config/RemoteBrowserTarget.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,WAAW,EACX,kBAAkB,EAClB,IAAI,EACJ,kBAAkB,EACnB,MAAM,YAAY,CAAC;AA6CpB,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,OAAO,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,aAAa;IAC5B,SAAS,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC;IAErC,iCAAiC;IACjC,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,iCAAiC;IACjC,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,YAAY,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IAC9B,KAAK,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"RemoteBrowserTarget.d.ts","sourceRoot":"","sources":["../../src/config/RemoteBrowserTarget.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,WAAW,EACX,kBAAkB,EAClB,IAAI,EACJ,kBAAkB,EACnB,MAAM,YAAY,CAAC;AA6CpB,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,OAAO,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,aAAa;IAC5B,SAAS,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC;IAErC,iCAAiC;IACjC,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,iCAAiC;IACjC,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,YAAY,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IAC9B,KAAK,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B;;;OAGG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAqHD,MAAM,CAAC,OAAO,OAAO,mBAAmB;IACtC,SAAgB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3C,SAAgB,WAAW,EAAE,WAAW,CAAC;IACzC,SAAgB,QAAQ,EAAE,MAAM,CAAC;IACjC,SAAgB,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9C,SAAgB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAGpD,WAAW,EAAE,WAAW,EACxB,EACE,QAAqB,EACrB,MAAM,EACN,SAAS,EACT,GAAG,YAAY,EAChB,EAAE,kBAAkB;IAsBjB,OAAO,CACX,EACE,SAAS,EACT,aAAa,EACb,aAAa,EACb,YAAY,EACZ,KAAK,EACL,UAAU,EACV,mBAAmB,EACnB,oBAAoB,GACrB,EAAE,aAAa,EAChB,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;CA8I1B"}
|
package/dist/config/index.d.ts
CHANGED
|
@@ -90,11 +90,27 @@ export interface Page {
|
|
|
90
90
|
*/
|
|
91
91
|
title: string;
|
|
92
92
|
/**
|
|
93
|
-
* Wait for the content to appear on the page before taking the
|
|
93
|
+
* Wait for the given text content to appear on the page before taking the
|
|
94
|
+
* screenshot.
|
|
95
|
+
*
|
|
96
|
+
* When the top-level `failOnWaitForTimeout` option is `true` (the
|
|
97
|
+
* default), the snap fails with a clear error if the content does not
|
|
98
|
+
* appear within the worker's timeout, so that stale content strings are
|
|
99
|
+
* surfaced immediately. When `failOnWaitForTimeout` is `false`, a
|
|
100
|
+
* timeout only emits a warning in the worker logs and the screenshot is
|
|
101
|
+
* taken anyway.
|
|
94
102
|
*/
|
|
95
103
|
waitForContent?: string;
|
|
96
104
|
/**
|
|
97
|
-
* Wait for
|
|
105
|
+
* Wait for an element matching the given selector to appear in the DOM
|
|
106
|
+
* before taking the screenshot.
|
|
107
|
+
*
|
|
108
|
+
* When the top-level `failOnWaitForTimeout` option is `true` (the
|
|
109
|
+
* default), the snap fails with a clear error if the selector is not
|
|
110
|
+
* found within the worker's timeout, so that stale selectors are
|
|
111
|
+
* surfaced immediately. When `failOnWaitForTimeout` is `false`, a
|
|
112
|
+
* timeout only emits a warning in the worker logs and the screenshot is
|
|
113
|
+
* taken anyway.
|
|
98
114
|
*/
|
|
99
115
|
waitForSelector?: string;
|
|
100
116
|
}
|
|
@@ -192,6 +208,26 @@ export interface Config {
|
|
|
192
208
|
* An object with settings for deep compare.
|
|
193
209
|
*/
|
|
194
210
|
deepCompare?: DeepCompareSettings;
|
|
211
|
+
/**
|
|
212
|
+
* Controls how a Happo worker handles a per-example or per-page
|
|
213
|
+
* `waitForContent` or `waitForSelector` that times out.
|
|
214
|
+
*
|
|
215
|
+
* When `true` (the default), the worker fails the snap with a clear error
|
|
216
|
+
* so that stale selectors and content strings (e.g. text that no longer
|
|
217
|
+
* renders after a copy change) are surfaced immediately instead of
|
|
218
|
+
* producing silent multi-second waits on every run.
|
|
219
|
+
*
|
|
220
|
+
* Set to `false` to restore the legacy behavior, where a timeout only
|
|
221
|
+
* emits a warning in the worker logs and the screenshot is taken anyway.
|
|
222
|
+
*
|
|
223
|
+
* It is recommended to always leave this set to `true`. If you encounter
|
|
224
|
+
* a failure, the preferred fix is to update the offending `waitForContent`
|
|
225
|
+
* or `waitForSelector` value so that it matches the rendered output.
|
|
226
|
+
* Setting this option to `false` should be a last resort.
|
|
227
|
+
*
|
|
228
|
+
* @default true
|
|
229
|
+
*/
|
|
230
|
+
failOnWaitForTimeout?: boolean;
|
|
195
231
|
}
|
|
196
232
|
type MobileSafariBrowserType = 'ios-safari' | 'ipad-safari';
|
|
197
233
|
type DesktopBrowserType = 'chrome' | 'firefox' | 'edge' | 'safari' | 'accessibility';
|
|
@@ -342,6 +378,7 @@ export interface ConfigWithDefaults extends Config {
|
|
|
342
378
|
endpoint: NonNullable<Config['endpoint']>;
|
|
343
379
|
githubApiUrl: NonNullable<Config['githubApiUrl']>;
|
|
344
380
|
targets: Record<string, TargetWithDefaults>;
|
|
381
|
+
failOnWaitForTimeout: NonNullable<Config['failOnWaitForTimeout']>;
|
|
345
382
|
}
|
|
346
383
|
export declare function defineConfig(config: Config): Config;
|
|
347
384
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,WAAW,CAAC;IAElB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,UAAU,kBAAkB;IAC1B;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B;;;;;;;;;;;;;;;;OAgBG;IACH,8BAA8B,CAAC,EAAE,OAAO,CAAC;CAC1C;AAED,UAAU,kBAAmB,SAAQ,kBAAkB;IACrD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,MAAM,IAAI,MAAM,EAAE,CAAC;IAEhC;;;OAGG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAE/B;;;;OAIG;IACH,sBAAsB,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACjE;AAED,MAAM,MAAM,MAAM,GAAG,kBAAkB,GAAG,aAAa,CAAC;AAExD,MAAM,WAAW,kBAAmB,SAAQ,UAAU;IACpD,QAAQ,EAAE,GAAG,MAAM,IAAI,MAAM,EAAE,CAAC;IAChC,SAAS,EAAE,OAAO,CAAC;IACnB,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED,MAAM,WAAW,kBAAmB,SAAQ,MAAM;IAChD,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;IACtC,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC;IAC5C,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC;IAChD,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;IAC1C,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC;IAClD,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAC5C,oBAAoB,EAAE,WAAW,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC,CAAC;CACnE;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEnD"}
|
package/dist/config/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/config/index.ts"],
|
|
4
|
-
"sourcesContent": ["export interface StorybookIntegration {\n type: 'storybook';\n\n /**\n * The directory containing the Storybook configuration\n */\n configDir?: string;\n\n /**\n * The directory containing the static files to serve\n */\n staticDir?: string;\n\n /**\n * The directory to output the static Storybook package to\n */\n outputDir?: string;\n\n /**\n * Whether to use a prebuilt Storybook package. If you use this option, make\n * sure that files are built to the outputDir.\n */\n usePrebuiltPackage?: boolean;\n}\n\ninterface BaseE2EIntegration {\n /**\n * Whether to allow failures.\n */\n allowFailures?: boolean;\n\n /**\n * Whether to download and include all assets in the asset package. If false\n * (default), only local assets will be included. When true, even external\n * assets will be included.\n */\n downloadAllAssets?: boolean;\n\n /**\n * When set to `true`, Happo automatically detects elements that are in\n * `:hover`, `:active`, or `:focus-visible` states at the moment a screenshot\n * is taken and adds the corresponding `data-happo-hover`,\n * `data-happo-active`, and `data-happo-focus-visible` attributes. It also\n * improves focus handling by traversing into shadow DOM to find the deepest\n * focused element so that `data-happo-focus` is applied reliably.\n *\n * Note: basic focus handling (`data-happo-focus` based on `activeElement`)\n * is always applied regardless of this option.\n *\n * This lets you write tests naturally (e.g. hover or focus an element) and\n * have Happo capture those states without any extra markup.\n *\n * Requires `applyPseudoClasses: true` on your targets for the attributes to\n * be rendered as CSS pseudo-class styles on Happo workers.\n */\n autoApplyPseudoStateAttributes?: boolean;\n}\n\ninterface CypressIntegration extends BaseE2EIntegration {\n type: 'cypress';\n}\n\ninterface PlaywrightIntegration extends BaseE2EIntegration {\n type: 'playwright';\n}\n\nexport type E2EIntegration = CypressIntegration | PlaywrightIntegration;\n\ninterface CustomIntegration {\n type: 'custom';\n\n /**\n * An async function that generates a custom package. Returns an object with\n * the path to the folder containing the custom files and the path to the\n * entry point file relative to the root directory.\n *\n * Optionally return `estimatedSnapsCount` to enable server-side auto-chunking,\n * which parallelizes rendering across multiple workers.\n *\n * @example\n * { rootDir: 'dist/custom', entryPoint: 'index.js', estimatedSnapsCount: 42 }\n */\n build: () => Promise<{\n rootDir: string;\n entryPoint: string;\n estimatedSnapsCount?: number;\n }>;\n}\n\nexport interface Page {\n /**\n * URL of the page to screenshot\n *\n * Note: The URLs to the website need to be publicly available, otherwise\n * Happo workers won't be able to access the pages.\n */\n url: string;\n\n /**\n * Title of the page to screenshot\n *\n * This is used as the \"component\" identifier in Happo reports, so ensure\n * it is unique for each page.\n */\n title: string;\n\n /**\n * Wait for the content to appear on the page before taking the screenshot.\n */\n waitForContent?: string;\n\n /**\n * Wait for a condition to be true before taking the screenshot.\n */\n waitForSelector?: string;\n}\n\ninterface PagesIntegration {\n type: 'pages';\n\n /**\n * A list of pages to screenshot.\n */\n pages: Array<Page>;\n}\n\n/**\n * Settings for deep compare functionality\n */\nexport interface DeepCompareSettings {\n /**\n * Threshold for comparing images with the given diff algorithm (float between\n * 0 and 1). 1 means all differences are allowed. 0 means no differences are\n * allowed. A good starting value is 0.03 for color-delta and 0.01 for ssim.\n */\n compareThreshold: number;\n\n /**\n * Algorithm to use for diff comparison. Must be \"color-delta\" or \"ssim\".\n * Defaults to \"color-delta\" if not provided. Note that \"ssim\" is experimental\n * and may be removed in the future.\n */\n diffAlgorithm?: 'color-delta' | 'ssim';\n\n /**\n * Threshold for ignoring individual pixel differences, side-stepping the\n * compare threshold. Used relatively to the image size. E.g. a value of 0.01\n * means 1% of the pixels can be above the compare threshold. Use this option\n * if your screenshots contain images or graphics with sharp noise. It is not\n * recommended to use this option for other types of diffs. (float\n * between 0 and 1).\n */\n ignoreThreshold?: number;\n\n /**\n * Whether to ignore whitespace in the diff. If true, whitespace differences\n * will not be considered when comparing images. Whitespace is defined as a\n * vertical section in a screenshot containing a single solid color.\n */\n ignoreWhitespace?: boolean;\n\n /**\n * Whether to apply blur to the diff. This can be used to smooth out subtle\n * differences that would otherwise be above the compare threshold. This\n * should mainly be used when your screenshots have a high contrast and you\n * want to smooth out some of the sharpness that can otherwise cause flakiness.\n */\n applyBlur?: boolean;\n}\n\nexport interface Config {\n /**\n * Key used to authenticate with the Happo API. Never store this in plain\n * text.\n */\n apiKey?: string;\n\n /**\n * Secret used to authenticate with the Happo API. Never store this in plain\n * text.\n */\n apiSecret?: string;\n\n /**\n * The endpoint to use for the happo run. Defaults to `https://happo.io`\n */\n endpoint?: string;\n\n /**\n * The name of the project to associate the Happo run with. If not provided,\n * the default project will be used.\n */\n project?: string;\n\n /**\n * Use this to post Happo statuses as comments to your PR. This can be useful\n * if the Happo server doesn't have access to your GitHub repository.\n *\n * The default is `'https://api.github.com'`. If you are using GitHub\n * Enterprise, enter the URL to your local GitHub API here, such as\n * `'https://ghe.mycompany.zone/api/v3'` (the default for GHE installation is\n * for the API to be located at `/api/v3`).\n */\n githubApiUrl?: string;\n\n /**\n * Browsers to use when generating snapshots\n */\n targets: Record<string, Target>;\n\n /**\n * Type of integration to use\n *\n * - 'storybook': Use Storybook to generate snapshots\n * - 'e2e': Use Playwright or Cypress to generate snapshots\n * - 'custom': Use a custom JS bundle to generate snapshots\n *\n * - 'pages': Use a list of pages to generate snapshots\n */\n integration?:\n | StorybookIntegration\n | CypressIntegration\n | PlaywrightIntegration\n | CustomIntegration\n | PagesIntegration;\n\n /**\n * An object with settings for deep compare.\n */\n deepCompare?: DeepCompareSettings;\n}\n\ntype MobileSafariBrowserType = 'ios-safari' | 'ipad-safari';\ntype DesktopBrowserType = 'chrome' | 'firefox' | 'edge' | 'safari' | 'accessibility';\nexport type BrowserType = MobileSafariBrowserType | DesktopBrowserType;\n\ninterface BaseTarget {\n type: BrowserType;\n\n /**\n * Split the target into chunks to be run on multiple workers in parallel\n *\n * This adds some overhead, so if your test suite isn't large, using more than\n * one chunk might actually slow things down.\n */\n chunks?: number;\n\n /**\n * Override the default maximum height (5000px) used by Happo workers\n *\n * This is useful when taking screenshots of tall components or pages.\n *\n * Note: The maximum width defaults to the maximum height, so if you set\n * `maxHeight`, you may also want to set `maxWidth` at the same time.\n */\n maxHeight?: number;\n\n /**\n * Override the default maximum width used by Happo workers (defaults to\n * `maxHeight`, which defaults to 5000 pixels)\n *\n * This is useful when taking screenshots of wide components or pages.\n */\n maxWidth?: number;\n\n /**\n * Controls how Happo handles elements with the `data-happo-hide` attribute.\n * By default, elements with this attribute are made invisible. Use the value\n * `'ignore'` to make the content appear in screenshots but exclude it from\n * comparison.\n */\n hideBehavior?: 'ignore';\n\n /**\n * When set to `true`, this option allows you to add `data-happo-hover`,\n * `data-happo-focus`, and `data-happo-active` attributes to your DOM elements\n * and have Happo apply the corresponding `:hover`, `:focus`, or `:active`\n * styles.\n *\n * For example, if you have this markup:\n *\n * ```html\n * <button>Hover me</button>\n * <style>\n * button:hover {\n * background-color: blue;\n * }\n * </style>\n * ```\n *\n * To apply the hover style before taking the screenshot (making the button\n * blue), change the markup to:\n *\n * ```html\n * <button data-happo-hover>Hover me</button>\n * <style>\n * button:hover {\n * background-color: blue;\n * }\n * </style>\n * ```\n *\n * Similarly, you can add focus to elements using `data-happo-focus`:\n *\n * ```html\n * <input type=\"text\" data-happo-focus />\n * ```\n *\n * And add `data-happo-active` to elements to simulate the `:active` state:\n *\n * ```html\n * <button data-happo-active>Click me</button>\n * <style>\n * button:active {\n * background-color: red;\n * }\n * </style>\n * ```\n */\n applyPseudoClasses?: boolean;\n\n /**\n * Set `prefersColorScheme: 'dark'` or `prefersColorScheme: 'light'` to set\n * the color scheme preference in the browser.\n */\n prefersColorScheme?: 'light' | 'dark';\n\n /**\n * Controls whether pointer events are allowed in the browser. Defaults to\n * `true`.\n *\n * When `true` (the default), Happo does not inject CSS to disable pointer\n * events, which allows mouse interaction in your tests (e.g., when using\n * Storybook interactive stories).\n *\n * Set `allowPointerEvents: false` to tell Happo to inject CSS that disables\n * pointer events. This can prevent spurious hover effects caused by the\n * system mouse pointer.\n *\n * If you're interested in testing `:hover`, `:focus`, and `:active` states\n * with Happo, you may also want to use the `applyPseudoClasses` option.\n */\n allowPointerEvents?: boolean;\n\n /**\n * Set `freezeAnimations: 'last-frame'` to freeze the animations at the last\n * frame. This is the default behavior.\n *\n * Set `freezeAnimations: 'first-frame'` to freeze the animations at the first\n * frame.\n */\n freezeAnimations?: 'last-frame' | 'first-frame';\n}\n\ninterface MobileSafariTarget extends BaseTarget {\n type: MobileSafariBrowserType;\n}\n\ninterface DesktopTarget extends BaseTarget {\n type: DesktopBrowserType;\n\n /**\n * Set the viewport size for the browser\n */\n viewport: `${number}x${number}`;\n\n /**\n * By default, Happo makes the browser prefer reduced motion when rendering\n * the UI. Set `prefersReducedMotion: false` to disable this behavior.\n */\n prefersReducedMotion?: boolean;\n\n /**\n * Add additional headers to the outgoing requests from the browser. This is\n * useful if you for instance need to tell a CDN that the request originates\n * from a Happo run.\n */\n outgoingRequestHeaders?: Array<{ name: string; value: string }>;\n}\n\nexport type Target = MobileSafariTarget | DesktopTarget;\n\nexport interface TargetWithDefaults extends BaseTarget {\n viewport: `${number}x${number}`;\n __dynamic: boolean;\n prefersReducedMotion?: boolean;\n}\n\nexport interface ConfigWithDefaults extends Config {\n apiKey: NonNullable<Config['apiKey']>;\n apiSecret: NonNullable<Config['apiSecret']>;\n integration: NonNullable<Config['integration']>;\n endpoint: NonNullable<Config['endpoint']>;\n githubApiUrl: NonNullable<Config['githubApiUrl']>;\n targets: Record<string, TargetWithDefaults>;\n}\n\nexport function defineConfig(config: Config): Config {\n return config;\n}\n"],
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["export interface StorybookIntegration {\n type: 'storybook';\n\n /**\n * The directory containing the Storybook configuration\n */\n configDir?: string;\n\n /**\n * The directory containing the static files to serve\n */\n staticDir?: string;\n\n /**\n * The directory to output the static Storybook package to\n */\n outputDir?: string;\n\n /**\n * Whether to use a prebuilt Storybook package. If you use this option, make\n * sure that files are built to the outputDir.\n */\n usePrebuiltPackage?: boolean;\n}\n\ninterface BaseE2EIntegration {\n /**\n * Whether to allow failures.\n */\n allowFailures?: boolean;\n\n /**\n * Whether to download and include all assets in the asset package. If false\n * (default), only local assets will be included. When true, even external\n * assets will be included.\n */\n downloadAllAssets?: boolean;\n\n /**\n * When set to `true`, Happo automatically detects elements that are in\n * `:hover`, `:active`, or `:focus-visible` states at the moment a screenshot\n * is taken and adds the corresponding `data-happo-hover`,\n * `data-happo-active`, and `data-happo-focus-visible` attributes. It also\n * improves focus handling by traversing into shadow DOM to find the deepest\n * focused element so that `data-happo-focus` is applied reliably.\n *\n * Note: basic focus handling (`data-happo-focus` based on `activeElement`)\n * is always applied regardless of this option.\n *\n * This lets you write tests naturally (e.g. hover or focus an element) and\n * have Happo capture those states without any extra markup.\n *\n * Requires `applyPseudoClasses: true` on your targets for the attributes to\n * be rendered as CSS pseudo-class styles on Happo workers.\n */\n autoApplyPseudoStateAttributes?: boolean;\n}\n\ninterface CypressIntegration extends BaseE2EIntegration {\n type: 'cypress';\n}\n\ninterface PlaywrightIntegration extends BaseE2EIntegration {\n type: 'playwright';\n}\n\nexport type E2EIntegration = CypressIntegration | PlaywrightIntegration;\n\ninterface CustomIntegration {\n type: 'custom';\n\n /**\n * An async function that generates a custom package. Returns an object with\n * the path to the folder containing the custom files and the path to the\n * entry point file relative to the root directory.\n *\n * Optionally return `estimatedSnapsCount` to enable server-side auto-chunking,\n * which parallelizes rendering across multiple workers.\n *\n * @example\n * { rootDir: 'dist/custom', entryPoint: 'index.js', estimatedSnapsCount: 42 }\n */\n build: () => Promise<{\n rootDir: string;\n entryPoint: string;\n estimatedSnapsCount?: number;\n }>;\n}\n\nexport interface Page {\n /**\n * URL of the page to screenshot\n *\n * Note: The URLs to the website need to be publicly available, otherwise\n * Happo workers won't be able to access the pages.\n */\n url: string;\n\n /**\n * Title of the page to screenshot\n *\n * This is used as the \"component\" identifier in Happo reports, so ensure\n * it is unique for each page.\n */\n title: string;\n\n /**\n * Wait for the given text content to appear on the page before taking the\n * screenshot.\n *\n * When the top-level `failOnWaitForTimeout` option is `true` (the\n * default), the snap fails with a clear error if the content does not\n * appear within the worker's timeout, so that stale content strings are\n * surfaced immediately. When `failOnWaitForTimeout` is `false`, a\n * timeout only emits a warning in the worker logs and the screenshot is\n * taken anyway.\n */\n waitForContent?: string;\n\n /**\n * Wait for an element matching the given selector to appear in the DOM\n * before taking the screenshot.\n *\n * When the top-level `failOnWaitForTimeout` option is `true` (the\n * default), the snap fails with a clear error if the selector is not\n * found within the worker's timeout, so that stale selectors are\n * surfaced immediately. When `failOnWaitForTimeout` is `false`, a\n * timeout only emits a warning in the worker logs and the screenshot is\n * taken anyway.\n */\n waitForSelector?: string;\n}\n\ninterface PagesIntegration {\n type: 'pages';\n\n /**\n * A list of pages to screenshot.\n */\n pages: Array<Page>;\n}\n\n/**\n * Settings for deep compare functionality\n */\nexport interface DeepCompareSettings {\n /**\n * Threshold for comparing images with the given diff algorithm (float between\n * 0 and 1). 1 means all differences are allowed. 0 means no differences are\n * allowed. A good starting value is 0.03 for color-delta and 0.01 for ssim.\n */\n compareThreshold: number;\n\n /**\n * Algorithm to use for diff comparison. Must be \"color-delta\" or \"ssim\".\n * Defaults to \"color-delta\" if not provided. Note that \"ssim\" is experimental\n * and may be removed in the future.\n */\n diffAlgorithm?: 'color-delta' | 'ssim';\n\n /**\n * Threshold for ignoring individual pixel differences, side-stepping the\n * compare threshold. Used relatively to the image size. E.g. a value of 0.01\n * means 1% of the pixels can be above the compare threshold. Use this option\n * if your screenshots contain images or graphics with sharp noise. It is not\n * recommended to use this option for other types of diffs. (float\n * between 0 and 1).\n */\n ignoreThreshold?: number;\n\n /**\n * Whether to ignore whitespace in the diff. If true, whitespace differences\n * will not be considered when comparing images. Whitespace is defined as a\n * vertical section in a screenshot containing a single solid color.\n */\n ignoreWhitespace?: boolean;\n\n /**\n * Whether to apply blur to the diff. This can be used to smooth out subtle\n * differences that would otherwise be above the compare threshold. This\n * should mainly be used when your screenshots have a high contrast and you\n * want to smooth out some of the sharpness that can otherwise cause flakiness.\n */\n applyBlur?: boolean;\n}\n\nexport interface Config {\n /**\n * Key used to authenticate with the Happo API. Never store this in plain\n * text.\n */\n apiKey?: string;\n\n /**\n * Secret used to authenticate with the Happo API. Never store this in plain\n * text.\n */\n apiSecret?: string;\n\n /**\n * The endpoint to use for the happo run. Defaults to `https://happo.io`\n */\n endpoint?: string;\n\n /**\n * The name of the project to associate the Happo run with. If not provided,\n * the default project will be used.\n */\n project?: string;\n\n /**\n * Use this to post Happo statuses as comments to your PR. This can be useful\n * if the Happo server doesn't have access to your GitHub repository.\n *\n * The default is `'https://api.github.com'`. If you are using GitHub\n * Enterprise, enter the URL to your local GitHub API here, such as\n * `'https://ghe.mycompany.zone/api/v3'` (the default for GHE installation is\n * for the API to be located at `/api/v3`).\n */\n githubApiUrl?: string;\n\n /**\n * Browsers to use when generating snapshots\n */\n targets: Record<string, Target>;\n\n /**\n * Type of integration to use\n *\n * - 'storybook': Use Storybook to generate snapshots\n * - 'e2e': Use Playwright or Cypress to generate snapshots\n * - 'custom': Use a custom JS bundle to generate snapshots\n *\n * - 'pages': Use a list of pages to generate snapshots\n */\n integration?:\n | StorybookIntegration\n | CypressIntegration\n | PlaywrightIntegration\n | CustomIntegration\n | PagesIntegration;\n\n /**\n * An object with settings for deep compare.\n */\n deepCompare?: DeepCompareSettings;\n\n /**\n * Controls how a Happo worker handles a per-example or per-page\n * `waitForContent` or `waitForSelector` that times out.\n *\n * When `true` (the default), the worker fails the snap with a clear error\n * so that stale selectors and content strings (e.g. text that no longer\n * renders after a copy change) are surfaced immediately instead of\n * producing silent multi-second waits on every run.\n *\n * Set to `false` to restore the legacy behavior, where a timeout only\n * emits a warning in the worker logs and the screenshot is taken anyway.\n *\n * It is recommended to always leave this set to `true`. If you encounter\n * a failure, the preferred fix is to update the offending `waitForContent`\n * or `waitForSelector` value so that it matches the rendered output.\n * Setting this option to `false` should be a last resort.\n *\n * @default true\n */\n failOnWaitForTimeout?: boolean;\n}\n\ntype MobileSafariBrowserType = 'ios-safari' | 'ipad-safari';\ntype DesktopBrowserType = 'chrome' | 'firefox' | 'edge' | 'safari' | 'accessibility';\nexport type BrowserType = MobileSafariBrowserType | DesktopBrowserType;\n\ninterface BaseTarget {\n type: BrowserType;\n\n /**\n * Split the target into chunks to be run on multiple workers in parallel\n *\n * This adds some overhead, so if your test suite isn't large, using more than\n * one chunk might actually slow things down.\n */\n chunks?: number;\n\n /**\n * Override the default maximum height (5000px) used by Happo workers\n *\n * This is useful when taking screenshots of tall components or pages.\n *\n * Note: The maximum width defaults to the maximum height, so if you set\n * `maxHeight`, you may also want to set `maxWidth` at the same time.\n */\n maxHeight?: number;\n\n /**\n * Override the default maximum width used by Happo workers (defaults to\n * `maxHeight`, which defaults to 5000 pixels)\n *\n * This is useful when taking screenshots of wide components or pages.\n */\n maxWidth?: number;\n\n /**\n * Controls how Happo handles elements with the `data-happo-hide` attribute.\n * By default, elements with this attribute are made invisible. Use the value\n * `'ignore'` to make the content appear in screenshots but exclude it from\n * comparison.\n */\n hideBehavior?: 'ignore';\n\n /**\n * When set to `true`, this option allows you to add `data-happo-hover`,\n * `data-happo-focus`, and `data-happo-active` attributes to your DOM elements\n * and have Happo apply the corresponding `:hover`, `:focus`, or `:active`\n * styles.\n *\n * For example, if you have this markup:\n *\n * ```html\n * <button>Hover me</button>\n * <style>\n * button:hover {\n * background-color: blue;\n * }\n * </style>\n * ```\n *\n * To apply the hover style before taking the screenshot (making the button\n * blue), change the markup to:\n *\n * ```html\n * <button data-happo-hover>Hover me</button>\n * <style>\n * button:hover {\n * background-color: blue;\n * }\n * </style>\n * ```\n *\n * Similarly, you can add focus to elements using `data-happo-focus`:\n *\n * ```html\n * <input type=\"text\" data-happo-focus />\n * ```\n *\n * And add `data-happo-active` to elements to simulate the `:active` state:\n *\n * ```html\n * <button data-happo-active>Click me</button>\n * <style>\n * button:active {\n * background-color: red;\n * }\n * </style>\n * ```\n */\n applyPseudoClasses?: boolean;\n\n /**\n * Set `prefersColorScheme: 'dark'` or `prefersColorScheme: 'light'` to set\n * the color scheme preference in the browser.\n */\n prefersColorScheme?: 'light' | 'dark';\n\n /**\n * Controls whether pointer events are allowed in the browser. Defaults to\n * `true`.\n *\n * When `true` (the default), Happo does not inject CSS to disable pointer\n * events, which allows mouse interaction in your tests (e.g., when using\n * Storybook interactive stories).\n *\n * Set `allowPointerEvents: false` to tell Happo to inject CSS that disables\n * pointer events. This can prevent spurious hover effects caused by the\n * system mouse pointer.\n *\n * If you're interested in testing `:hover`, `:focus`, and `:active` states\n * with Happo, you may also want to use the `applyPseudoClasses` option.\n */\n allowPointerEvents?: boolean;\n\n /**\n * Set `freezeAnimations: 'last-frame'` to freeze the animations at the last\n * frame. This is the default behavior.\n *\n * Set `freezeAnimations: 'first-frame'` to freeze the animations at the first\n * frame.\n */\n freezeAnimations?: 'last-frame' | 'first-frame';\n}\n\ninterface MobileSafariTarget extends BaseTarget {\n type: MobileSafariBrowserType;\n}\n\ninterface DesktopTarget extends BaseTarget {\n type: DesktopBrowserType;\n\n /**\n * Set the viewport size for the browser\n */\n viewport: `${number}x${number}`;\n\n /**\n * By default, Happo makes the browser prefer reduced motion when rendering\n * the UI. Set `prefersReducedMotion: false` to disable this behavior.\n */\n prefersReducedMotion?: boolean;\n\n /**\n * Add additional headers to the outgoing requests from the browser. This is\n * useful if you for instance need to tell a CDN that the request originates\n * from a Happo run.\n */\n outgoingRequestHeaders?: Array<{ name: string; value: string }>;\n}\n\nexport type Target = MobileSafariTarget | DesktopTarget;\n\nexport interface TargetWithDefaults extends BaseTarget {\n viewport: `${number}x${number}`;\n __dynamic: boolean;\n prefersReducedMotion?: boolean;\n}\n\nexport interface ConfigWithDefaults extends Config {\n apiKey: NonNullable<Config['apiKey']>;\n apiSecret: NonNullable<Config['apiSecret']>;\n integration: NonNullable<Config['integration']>;\n endpoint: NonNullable<Config['endpoint']>;\n githubApiUrl: NonNullable<Config['githubApiUrl']>;\n targets: Record<string, TargetWithDefaults>;\n failOnWaitForTimeout: NonNullable<Config['failOnWaitForTimeout']>;\n}\n\nexport function defineConfig(config: Config): Config {\n return config;\n}\n"],
|
|
5
|
+
"mappings": ";AAmbO,SAAS,aAAa,QAAwB;AACnD,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadConfig.d.ts","sourceRoot":"","sources":["../../src/config/loadConfig.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"loadConfig.d.ts","sourceRoot":"","sources":["../../src/config/loadConfig.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAGrD,OAAO,KAAK,EACV,kBAAkB,EAGnB,MAAM,YAAY,CAAC;AAapB,wBAAgB,cAAc,IAAI,MAAM,CAcvC;AA8ID,wBAAsB,cAAc,CAClC,cAAc,EAAE,MAAM,EACtB,WAAW,CAAC,EAAE,IAAI,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC,EACpD,MAAM,GAAE,MAAgB,GACvB,OAAO,CAAC,kBAAkB,CAAC,CAqJ7B"}
|