viewev 0.0.0-stage → 0.1.0-beta.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/LICENSE +21 -0
- package/README.md +131 -2
- package/assets/logo/Logo-horizontal.png +0 -0
- package/dist/adapters/storybook/index.d.ts +5 -0
- package/dist/adapters/storybook/index.js +4 -0
- package/dist/adapters/storybook/index.js.map +1 -0
- package/dist/adapters/storybook/provider.d.ts +24 -0
- package/dist/adapters/storybook/provider.js +114 -0
- package/dist/adapters/storybook/provider.js.map +1 -0
- package/dist/adapters/storybook/scenarios.d.ts +30 -0
- package/dist/adapters/storybook/scenarios.js +64 -0
- package/dist/adapters/storybook/scenarios.js.map +1 -0
- package/dist/adapters/storybook/static-server.d.ts +10 -0
- package/dist/adapters/storybook/static-server.js +105 -0
- package/dist/adapters/storybook/static-server.js.map +1 -0
- package/dist/adapters/storybook/storybook-index.d.ts +32 -0
- package/dist/adapters/storybook/storybook-index.js +35 -0
- package/dist/adapters/storybook/storybook-index.js.map +1 -0
- package/dist/baselines/environment-check.d.ts +7 -0
- package/dist/baselines/environment-check.js +24 -0
- package/dist/baselines/environment-check.js.map +1 -0
- package/dist/baselines/environment-key.d.ts +8 -0
- package/dist/baselines/environment-key.js +12 -0
- package/dist/baselines/environment-key.js.map +1 -0
- package/dist/baselines/file-store.d.ts +12 -0
- package/dist/baselines/file-store.js +81 -0
- package/dist/baselines/file-store.js.map +1 -0
- package/dist/baselines/git-store.d.ts +16 -0
- package/dist/baselines/git-store.js +150 -0
- package/dist/baselines/git-store.js.map +1 -0
- package/dist/baselines/metadata.d.ts +16 -0
- package/dist/baselines/metadata.js +84 -0
- package/dist/baselines/metadata.js.map +1 -0
- package/dist/baselines/types.d.ts +33 -0
- package/dist/baselines/types.js +2 -0
- package/dist/baselines/types.js.map +1 -0
- package/dist/browser/playwright/capturer.d.ts +2 -0
- package/dist/browser/playwright/capturer.js +142 -0
- package/dist/browser/playwright/capturer.js.map +1 -0
- package/dist/browser/playwright/environment.d.ts +4 -0
- package/dist/browser/playwright/environment.js +36 -0
- package/dist/browser/playwright/environment.js.map +1 -0
- package/dist/browser/playwright/index.d.ts +1 -0
- package/dist/browser/playwright/index.js +2 -0
- package/dist/browser/playwright/index.js.map +1 -0
- package/dist/browser/types.d.ts +43 -0
- package/dist/browser/types.js +2 -0
- package/dist/browser/types.js.map +1 -0
- package/dist/ci/github-summary.d.ts +5 -0
- package/dist/ci/github-summary.js +95 -0
- package/dist/ci/github-summary.js.map +1 -0
- package/dist/cli/baseline-ref.d.ts +6 -0
- package/dist/cli/baseline-ref.js +11 -0
- package/dist/cli/baseline-ref.js.map +1 -0
- package/dist/cli/bin.d.ts +2 -0
- package/dist/cli/bin.js +13 -0
- package/dist/cli/bin.js.map +1 -0
- package/dist/cli/commands/baseline.d.ts +3 -0
- package/dist/cli/commands/baseline.js +90 -0
- package/dist/cli/commands/baseline.js.map +1 -0
- package/dist/cli/commands/capture.d.ts +3 -0
- package/dist/cli/commands/capture.js +42 -0
- package/dist/cli/commands/capture.js.map +1 -0
- package/dist/cli/commands/config.d.ts +3 -0
- package/dist/cli/commands/config.js +25 -0
- package/dist/cli/commands/config.js.map +1 -0
- package/dist/cli/commands/doctor.d.ts +3 -0
- package/dist/cli/commands/doctor.js +19 -0
- package/dist/cli/commands/doctor.js.map +1 -0
- package/dist/cli/commands/report.d.ts +3 -0
- package/dist/cli/commands/report.js +16 -0
- package/dist/cli/commands/report.js.map +1 -0
- package/dist/cli/commands/scenarios.d.ts +3 -0
- package/dist/cli/commands/scenarios.js +30 -0
- package/dist/cli/commands/scenarios.js.map +1 -0
- package/dist/cli/commands/test.d.ts +3 -0
- package/dist/cli/commands/test.js +123 -0
- package/dist/cli/commands/test.js.map +1 -0
- package/dist/cli/context.d.ts +21 -0
- package/dist/cli/context.js +22 -0
- package/dist/cli/context.js.map +1 -0
- package/dist/cli/doctor.d.ts +12 -0
- package/dist/cli/doctor.js +104 -0
- package/dist/cli/doctor.js.map +1 -0
- package/dist/cli/format.d.ts +17 -0
- package/dist/cli/format.js +106 -0
- package/dist/cli/format.js.map +1 -0
- package/dist/cli/impact.d.ts +13 -0
- package/dist/cli/impact.js +57 -0
- package/dist/cli/impact.js.map +1 -0
- package/dist/cli/program.d.ts +11 -0
- package/dist/cli/program.js +70 -0
- package/dist/cli/program.js.map +1 -0
- package/dist/cli/session.d.ts +27 -0
- package/dist/cli/session.js +53 -0
- package/dist/cli/session.js.map +1 -0
- package/dist/comparison/compare.d.ts +11 -0
- package/dist/comparison/compare.js +41 -0
- package/dist/comparison/compare.js.map +1 -0
- package/dist/comparison/types.d.ts +34 -0
- package/dist/comparison/types.js +2 -0
- package/dist/comparison/types.js.map +1 -0
- package/dist/config/load.d.ts +23 -0
- package/dist/config/load.js +93 -0
- package/dist/config/load.js.map +1 -0
- package/dist/config/schema.d.ts +299 -0
- package/dist/config/schema.js +134 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/core/artifacts.d.ts +6 -0
- package/dist/core/artifacts.js +2 -0
- package/dist/core/artifacts.js.map +1 -0
- package/dist/core/baseline-run.d.ts +37 -0
- package/dist/core/baseline-run.js +85 -0
- package/dist/core/baseline-run.js.map +1 -0
- package/dist/core/capture-settings.d.ts +6 -0
- package/dist/core/capture-settings.js +21 -0
- package/dist/core/capture-settings.js.map +1 -0
- package/dist/core/discovery.d.ts +3 -0
- package/dist/core/discovery.js +17 -0
- package/dist/core/discovery.js.map +1 -0
- package/dist/core/impact.d.ts +19 -0
- package/dist/core/impact.js +28 -0
- package/dist/core/impact.js.map +1 -0
- package/dist/core/pool.d.ts +5 -0
- package/dist/core/pool.js +21 -0
- package/dist/core/pool.js.map +1 -0
- package/dist/core/result.d.ts +111 -0
- package/dist/core/result.js +53 -0
- package/dist/core/result.js.map +1 -0
- package/dist/core/selection.d.ts +8 -0
- package/dist/core/selection.js +8 -0
- package/dist/core/selection.js.map +1 -0
- package/dist/core/test-run.d.ts +38 -0
- package/dist/core/test-run.js +140 -0
- package/dist/core/test-run.js.map +1 -0
- package/dist/impact/git.d.ts +17 -0
- package/dist/impact/git.js +55 -0
- package/dist/impact/git.js.map +1 -0
- package/dist/impact/types.d.ts +24 -0
- package/dist/impact/types.js +23 -0
- package/dist/impact/types.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/reporting/artifacts.d.ts +8 -0
- package/dist/reporting/artifacts.js +23 -0
- package/dist/reporting/artifacts.js.map +1 -0
- package/dist/reporting/html.d.ts +4 -0
- package/dist/reporting/html.js +244 -0
- package/dist/reporting/html.js.map +1 -0
- package/dist/reporting/report.d.ts +12 -0
- package/dist/reporting/report.js +55 -0
- package/dist/reporting/report.js.map +1 -0
- package/dist/reporting/results-json.d.ts +35 -0
- package/dist/reporting/results-json.js +37 -0
- package/dist/reporting/results-json.js.map +1 -0
- package/dist/scenarios/glob.d.ts +7 -0
- package/dist/scenarios/glob.js +21 -0
- package/dist/scenarios/glob.js.map +1 -0
- package/dist/scenarios/model.d.ts +61 -0
- package/dist/scenarios/model.js +31 -0
- package/dist/scenarios/model.js.map +1 -0
- package/dist/scenarios/schema.d.ts +8 -0
- package/dist/scenarios/schema.js +70 -0
- package/dist/scenarios/schema.js.map +1 -0
- package/dist/shared/environment.d.ts +23 -0
- package/dist/shared/environment.js +2 -0
- package/dist/shared/environment.js.map +1 -0
- package/dist/shared/errors.d.ts +23 -0
- package/dist/shared/errors.js +29 -0
- package/dist/shared/errors.js.map +1 -0
- package/dist/shared/png.d.ts +3 -0
- package/dist/shared/png.js +14 -0
- package/dist/shared/png.js.map +1 -0
- package/dist/shared/size.d.ts +4 -0
- package/dist/shared/size.js +2 -0
- package/dist/shared/size.js.map +1 -0
- package/docs/architecture.md +180 -0
- package/docs/ci.md +212 -0
- package/docs/impact.md +46 -0
- package/package.json +58 -4
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { CaptureSession } from '../browser/types.js';
|
|
2
|
+
import type { LoadedConfig } from '../config/load.js';
|
|
3
|
+
import type { SelectionInfo } from '../core/result.js';
|
|
4
|
+
import type { VisualScenario } from '../scenarios/model.js';
|
|
5
|
+
import type { CommandContext } from './context.js';
|
|
6
|
+
import type { ImpactRequest } from './impact.js';
|
|
7
|
+
export interface Discovery {
|
|
8
|
+
readonly loaded: LoadedConfig;
|
|
9
|
+
/** Every scenario the provider found, before filtering. */
|
|
10
|
+
readonly discovered: readonly VisualScenario[];
|
|
11
|
+
/**
|
|
12
|
+
* The scenarios to run: those that pass the include and exclude filters (or --filter) and,
|
|
13
|
+
* with --changed, that the change affects.
|
|
14
|
+
*/
|
|
15
|
+
readonly selected: readonly VisualScenario[];
|
|
16
|
+
/** Present when impact analysis took part in choosing `selected`. */
|
|
17
|
+
readonly impact?: SelectionInfo;
|
|
18
|
+
}
|
|
19
|
+
/** Loads the config, opens the Storybook, discovers and filters scenarios, then cleans up. */
|
|
20
|
+
export declare function withDiscovery<T>(context: CommandContext, filter: readonly string[] | undefined, action: (discovery: Discovery) => Promise<T>, impact?: ImpactRequest): Promise<T>;
|
|
21
|
+
/**
|
|
22
|
+
* Stops runs that would do nothing by mistake. With impact analysis an empty selection is a
|
|
23
|
+
* legitimate result ("this change affects no scenario"), unless the filters already left nothing.
|
|
24
|
+
*/
|
|
25
|
+
export declare function requireSelection(discovery: Discovery): void;
|
|
26
|
+
/** Opens a browser session, prints which environment it is, and always closes it. */
|
|
27
|
+
export declare function withSession<T>(context: CommandContext, discovery: Discovery, action: (session: CaptureSession) => Promise<T>): Promise<T>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { createPlaywrightCapturer } from '../browser/playwright/index.js';
|
|
2
|
+
import { captureEnvironmentFrom } from '../core/capture-settings.js';
|
|
3
|
+
import { discoverScenarios } from '../core/discovery.js';
|
|
4
|
+
import { selectScenarios } from '../core/selection.js';
|
|
5
|
+
import { ConfigError } from '../shared/errors.js';
|
|
6
|
+
import { loadConfigFor, openConfiguredStorybook } from './context.js';
|
|
7
|
+
import { formatEnvironment } from './format.js';
|
|
8
|
+
import { selectByImpact } from './impact.js';
|
|
9
|
+
/** Loads the config, opens the Storybook, discovers and filters scenarios, then cleans up. */
|
|
10
|
+
export async function withDiscovery(context, filter, action, impact) {
|
|
11
|
+
const loaded = await loadConfigFor(context);
|
|
12
|
+
const source = await openConfiguredStorybook(loaded);
|
|
13
|
+
try {
|
|
14
|
+
const discovered = await discoverScenarios(source.provider, {
|
|
15
|
+
signal: new AbortController().signal,
|
|
16
|
+
});
|
|
17
|
+
const filtered = selectScenarios(discovered, {
|
|
18
|
+
include: filter ?? loaded.config.include,
|
|
19
|
+
exclude: loaded.config.exclude,
|
|
20
|
+
});
|
|
21
|
+
if (impact === undefined) {
|
|
22
|
+
return await action({ loaded, discovered, selected: filtered });
|
|
23
|
+
}
|
|
24
|
+
const plan = await selectByImpact(loaded, discovered, filtered, impact);
|
|
25
|
+
return await action({ loaded, discovered, selected: plan.selected, impact: plan.info });
|
|
26
|
+
}
|
|
27
|
+
finally {
|
|
28
|
+
await source.close();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Stops runs that would do nothing by mistake. With impact analysis an empty selection is a
|
|
33
|
+
* legitimate result ("this change affects no scenario"), unless the filters already left nothing.
|
|
34
|
+
*/
|
|
35
|
+
export function requireSelection(discovery) {
|
|
36
|
+
const affectedNothing = discovery.impact !== undefined && discovery.impact.total > 0;
|
|
37
|
+
if (discovery.selected.length === 0 && !affectedNothing) {
|
|
38
|
+
throw new ConfigError(`No scenarios selected (${discovery.discovered.length} discovered). ` +
|
|
39
|
+
'Check --filter, include and exclude.');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/** Opens a browser session, prints which environment it is, and always closes it. */
|
|
43
|
+
export async function withSession(context, discovery, action) {
|
|
44
|
+
const session = await createPlaywrightCapturer().open(captureEnvironmentFrom(discovery.loaded.config));
|
|
45
|
+
try {
|
|
46
|
+
context.io.stdout(`${formatEnvironment(session.environment)}\n`);
|
|
47
|
+
return await action(session);
|
|
48
|
+
}
|
|
49
|
+
finally {
|
|
50
|
+
await session.close();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/cli/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAG1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAEtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAgB7C,8FAA8F;AAC9F,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,OAAuB,EACvB,MAAqC,EACrC,MAA4C,EAC5C,MAAsB;IAEtB,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,OAAO,CAAC,CAAC;IAC5C,MAAM,MAAM,GAAG,MAAM,uBAAuB,CAAC,MAAM,CAAC,CAAC;IACrD,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,MAAM,iBAAiB,CAAC,MAAM,CAAC,QAAQ,EAAE;YAC1D,MAAM,EAAE,IAAI,eAAe,EAAE,CAAC,MAAM;SACrC,CAAC,CAAC;QACH,MAAM,QAAQ,GAAG,eAAe,CAAC,UAAU,EAAE;YAC3C,OAAO,EAAE,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO;YACxC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO;SAC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,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;YAAS,CAAC;QACT,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ImageComparator } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Pixel-level comparison with Pixelmatch.
|
|
4
|
+
*
|
|
5
|
+
* - Images of different dimensions are a failure; nothing is resized or padded.
|
|
6
|
+
* - Anti-aliased pixels are counted, because screenshots come from one deterministic
|
|
7
|
+
* environment and every pixel is expected to match.
|
|
8
|
+
* - The comparison passes when the number of differing pixels is within the tolerance, which
|
|
9
|
+
* is the larger of `maxDiffPixels` and `maxDiffRatio` times the total pixel count.
|
|
10
|
+
*/
|
|
11
|
+
export declare const compareImages: ImageComparator;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import pixelmatch from 'pixelmatch';
|
|
2
|
+
import { PNG } from 'pngjs';
|
|
3
|
+
import { readPngSize } from '../shared/png.js';
|
|
4
|
+
function toBuffer(bytes) {
|
|
5
|
+
return Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Pixel-level comparison with Pixelmatch.
|
|
9
|
+
*
|
|
10
|
+
* - Images of different dimensions are a failure; nothing is resized or padded.
|
|
11
|
+
* - Anti-aliased pixels are counted, because screenshots come from one deterministic
|
|
12
|
+
* environment and every pixel is expected to match.
|
|
13
|
+
* - The comparison passes when the number of differing pixels is within the tolerance, which
|
|
14
|
+
* is the larger of `maxDiffPixels` and `maxDiffRatio` times the total pixel count.
|
|
15
|
+
*/
|
|
16
|
+
export const compareImages = (baseline, actual, options) => {
|
|
17
|
+
const expectedSize = readPngSize(baseline);
|
|
18
|
+
const actualSize = readPngSize(actual);
|
|
19
|
+
if (expectedSize.width !== actualSize.width || expectedSize.height !== actualSize.height) {
|
|
20
|
+
return { kind: 'mismatch', cause: 'dimensions', expected: expectedSize, actual: actualSize };
|
|
21
|
+
}
|
|
22
|
+
const expectedImage = PNG.sync.read(toBuffer(baseline));
|
|
23
|
+
const actualImage = PNG.sync.read(toBuffer(actual));
|
|
24
|
+
const { width, height } = expectedImage;
|
|
25
|
+
const diffImage = new PNG({ width, height });
|
|
26
|
+
const diffPixels = pixelmatch(expectedImage.data, actualImage.data, diffImage.data, width, height, {
|
|
27
|
+
threshold: options.colorThreshold,
|
|
28
|
+
includeAA: true,
|
|
29
|
+
});
|
|
30
|
+
const totalPixels = width * height;
|
|
31
|
+
const stats = {
|
|
32
|
+
diffPixels,
|
|
33
|
+
totalPixels,
|
|
34
|
+
diffRatio: totalPixels === 0 ? 0 : diffPixels / totalPixels,
|
|
35
|
+
};
|
|
36
|
+
const tolerance = Math.max(options.maxDiffPixels, options.maxDiffRatio === undefined ? 0 : Math.floor(options.maxDiffRatio * totalPixels));
|
|
37
|
+
if (diffPixels <= tolerance)
|
|
38
|
+
return { kind: 'match', stats };
|
|
39
|
+
return { kind: 'mismatch', cause: 'pixels', stats, diffPng: PNG.sync.write(diffImage) };
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=compare.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compare.js","sourceRoot":"","sources":["../../src/comparison/compare.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C,SAAS,QAAQ,CAAC,KAAiB;IACjC,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;AACvE,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,aAAa,GAAoB,CAC5C,QAAoB,EACpB,MAAkB,EAClB,OAA0B,EACR,EAAE;I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C,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,YAAY,GAAG,WAAW,CAAC,CACxF,CAAC;IACF,IAAI,UAAU,IAAI,SAAS;QAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAE7D,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;AAC1F,CAAC,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Size } from '../shared/size.js';
|
|
2
|
+
export interface ComparisonOptions {
|
|
3
|
+
/** Pixelmatch per-pixel perceptual (YIQ) distance, 0 (exact) to 1. */
|
|
4
|
+
readonly colorThreshold: number;
|
|
5
|
+
/** Number of differing pixels that is tolerated. */
|
|
6
|
+
readonly maxDiffPixels: number;
|
|
7
|
+
/**
|
|
8
|
+
* Ratio of differing pixels that is tolerated (0 to 1). The tolerance applied is the larger
|
|
9
|
+
* of `maxDiffPixels` and `maxDiffRatio` times the number of pixels.
|
|
10
|
+
*/
|
|
11
|
+
readonly maxDiffRatio?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface DiffStats {
|
|
14
|
+
readonly diffPixels: number;
|
|
15
|
+
readonly totalPixels: number;
|
|
16
|
+
/** diffPixels / totalPixels, between 0 and 1. */
|
|
17
|
+
readonly diffRatio: number;
|
|
18
|
+
}
|
|
19
|
+
export type ComparisonResult = {
|
|
20
|
+
readonly kind: 'match';
|
|
21
|
+
readonly stats: DiffStats;
|
|
22
|
+
} | {
|
|
23
|
+
readonly kind: 'mismatch';
|
|
24
|
+
readonly cause: 'pixels';
|
|
25
|
+
readonly stats: DiffStats;
|
|
26
|
+
readonly diffPng: Uint8Array;
|
|
27
|
+
} | {
|
|
28
|
+
readonly kind: 'mismatch';
|
|
29
|
+
readonly cause: 'dimensions';
|
|
30
|
+
readonly expected: Size;
|
|
31
|
+
readonly actual: Size;
|
|
32
|
+
};
|
|
33
|
+
/** Compares an approved baseline with a new screenshot. Pure: no I/O. */
|
|
34
|
+
export type ImageComparator = (baseline: Uint8Array, actual: Uint8Array, options: ComparisonOptions) => ComparisonResult;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/comparison/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ViewevConfig } from './schema.js';
|
|
2
|
+
export declare const CONFIG_FILE_NAMES: readonly ["viewev.config.mjs", "viewev.config.js", "viewev.config.json"];
|
|
3
|
+
export interface ResolvedPaths {
|
|
4
|
+
readonly baselines: string;
|
|
5
|
+
readonly report: string;
|
|
6
|
+
readonly storybookStaticDir?: string;
|
|
7
|
+
/** Absolute path of the impact analysis module, when impact analysis is configured. */
|
|
8
|
+
readonly impactModule?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface LoadedConfig {
|
|
11
|
+
/** Directory of the config file; all relative paths in the config resolve against it. */
|
|
12
|
+
readonly rootDir: string;
|
|
13
|
+
readonly configFile: string;
|
|
14
|
+
readonly config: ViewevConfig;
|
|
15
|
+
readonly paths: ResolvedPaths;
|
|
16
|
+
}
|
|
17
|
+
export interface LoadConfigOptions {
|
|
18
|
+
readonly cwd: string;
|
|
19
|
+
/** Explicit config file (absolute, or relative to cwd). Skips discovery. */
|
|
20
|
+
readonly configPath?: string;
|
|
21
|
+
}
|
|
22
|
+
export declare function parseConfig(raw: unknown, source?: string): ViewevConfig;
|
|
23
|
+
export declare function loadConfig(options: LoadConfigOptions): Promise<LoadedConfig>;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { access, readFile } from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { pathToFileURL } from 'node:url';
|
|
4
|
+
import { ConfigError } from '../shared/errors.js';
|
|
5
|
+
import { configSchema } from './schema.js';
|
|
6
|
+
export const CONFIG_FILE_NAMES = [
|
|
7
|
+
'viewev.config.mjs',
|
|
8
|
+
'viewev.config.js',
|
|
9
|
+
'viewev.config.json',
|
|
10
|
+
];
|
|
11
|
+
async function exists(file) {
|
|
12
|
+
try {
|
|
13
|
+
await access(file);
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
async function findConfigFile(options) {
|
|
21
|
+
if (options.configPath !== undefined) {
|
|
22
|
+
const explicit = path.resolve(options.cwd, options.configPath);
|
|
23
|
+
if (!(await exists(explicit))) {
|
|
24
|
+
throw new ConfigError(`Config file not found: ${explicit}`);
|
|
25
|
+
}
|
|
26
|
+
return explicit;
|
|
27
|
+
}
|
|
28
|
+
const found = [];
|
|
29
|
+
for (const name of CONFIG_FILE_NAMES) {
|
|
30
|
+
const candidate = path.join(options.cwd, name);
|
|
31
|
+
if (await exists(candidate))
|
|
32
|
+
found.push(candidate);
|
|
33
|
+
}
|
|
34
|
+
if (found.length === 0) {
|
|
35
|
+
throw new ConfigError(`No config file found in ${options.cwd}. Create one of: ${CONFIG_FILE_NAMES.join(', ')}.`);
|
|
36
|
+
}
|
|
37
|
+
if (found.length > 1) {
|
|
38
|
+
const names = found.map((file) => path.basename(file)).join(', ');
|
|
39
|
+
throw new ConfigError(`Multiple config files found (${names}). Keep only one.`);
|
|
40
|
+
}
|
|
41
|
+
return found[0];
|
|
42
|
+
}
|
|
43
|
+
async function readRawConfig(file) {
|
|
44
|
+
if (path.extname(file) === '.json') {
|
|
45
|
+
const text = await readFile(file, 'utf8');
|
|
46
|
+
try {
|
|
47
|
+
return JSON.parse(text);
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
throw new ConfigError(`Config file is not valid JSON: ${file}`, { cause: error });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
let module;
|
|
54
|
+
try {
|
|
55
|
+
module = (await import(/* @vite-ignore */ pathToFileURL(file).href));
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
59
|
+
throw new ConfigError(`Could not load config file ${file}: ${reason}`, { cause: error });
|
|
60
|
+
}
|
|
61
|
+
if (module.default === undefined) {
|
|
62
|
+
throw new ConfigError(`Config file must have a default export: ${file}`);
|
|
63
|
+
}
|
|
64
|
+
return module.default;
|
|
65
|
+
}
|
|
66
|
+
function formatIssues(error) {
|
|
67
|
+
return error.issues
|
|
68
|
+
.map((issue) => ` - ${issue.path.length > 0 ? issue.path.join('.') : '(root)'}: ${issue.message}`)
|
|
69
|
+
.join('\n');
|
|
70
|
+
}
|
|
71
|
+
export function parseConfig(raw, source = 'config') {
|
|
72
|
+
const parsed = configSchema.safeParse(raw);
|
|
73
|
+
if (!parsed.success) {
|
|
74
|
+
throw new ConfigError(`Invalid ${source}:\n${formatIssues(parsed.error)}`);
|
|
75
|
+
}
|
|
76
|
+
return parsed.data;
|
|
77
|
+
}
|
|
78
|
+
export async function loadConfig(options) {
|
|
79
|
+
const configFile = await findConfigFile(options);
|
|
80
|
+
const rootDir = path.dirname(configFile);
|
|
81
|
+
const raw = await readRawConfig(configFile);
|
|
82
|
+
const config = parseConfig(raw, `config (${path.basename(configFile)})`);
|
|
83
|
+
const staticDir = config.provider.staticDir;
|
|
84
|
+
const impactModule = config.impact?.module;
|
|
85
|
+
const paths = {
|
|
86
|
+
baselines: path.resolve(rootDir, config.baselines.dir),
|
|
87
|
+
report: path.resolve(rootDir, config.report.dir),
|
|
88
|
+
...(staticDir !== undefined ? { storybookStaticDir: path.resolve(rootDir, staticDir) } : {}),
|
|
89
|
+
...(impactModule !== undefined ? { impactModule: path.resolve(rootDir, impactModule) } : {}),
|
|
90
|
+
};
|
|
91
|
+
return { rootDir, configFile, config, paths };
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=load.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|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MAAM,aAAa,CAAC,UAAU,CAAC,CAAC;IAC5C,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,EAAE,WAAW,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IAEzE,MAAM,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC;IAC5C,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAC3C,MAAM,KAAK,GAAkB;QAC3B,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC;QACtD,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC;QAChD,GAAG,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,kBAAkB,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5F,GAAG,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,YAAY,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC7F,CAAC;IAEF,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;AAChD,CAAC"}
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const configSchema: z.ZodObject<{
|
|
3
|
+
provider: z.ZodEffects<z.ZodObject<{
|
|
4
|
+
type: z.ZodLiteral<"storybook">;
|
|
5
|
+
/** URL of a running Storybook (for example http://localhost:6006). */
|
|
6
|
+
url: z.ZodOptional<z.ZodString>;
|
|
7
|
+
/** Directory of a built Storybook (storybook build output), relative to the config file. */
|
|
8
|
+
staticDir: z.ZodOptional<z.ZodString>;
|
|
9
|
+
}, "strict", z.ZodTypeAny, {
|
|
10
|
+
type: "storybook";
|
|
11
|
+
url?: string | undefined;
|
|
12
|
+
staticDir?: string | undefined;
|
|
13
|
+
}, {
|
|
14
|
+
type: "storybook";
|
|
15
|
+
url?: string | undefined;
|
|
16
|
+
staticDir?: string | undefined;
|
|
17
|
+
}>, {
|
|
18
|
+
type: "storybook";
|
|
19
|
+
url?: string | undefined;
|
|
20
|
+
staticDir?: string | undefined;
|
|
21
|
+
}, {
|
|
22
|
+
type: "storybook";
|
|
23
|
+
url?: string | undefined;
|
|
24
|
+
staticDir?: string | undefined;
|
|
25
|
+
}>;
|
|
26
|
+
/** Glob patterns matched against scenario ids. Empty means every scenario. */
|
|
27
|
+
include: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
28
|
+
exclude: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
29
|
+
browser: z.ZodDefault<z.ZodObject<{
|
|
30
|
+
engine: z.ZodDefault<z.ZodLiteral<"chromium">>;
|
|
31
|
+
}, "strict", z.ZodTypeAny, {
|
|
32
|
+
engine: "chromium";
|
|
33
|
+
}, {
|
|
34
|
+
engine?: "chromium" | undefined;
|
|
35
|
+
}>>;
|
|
36
|
+
viewport: z.ZodDefault<z.ZodObject<{
|
|
37
|
+
width: z.ZodNumber;
|
|
38
|
+
height: z.ZodNumber;
|
|
39
|
+
}, "strict", z.ZodTypeAny, {
|
|
40
|
+
width: number;
|
|
41
|
+
height: number;
|
|
42
|
+
}, {
|
|
43
|
+
width: number;
|
|
44
|
+
height: number;
|
|
45
|
+
}>>;
|
|
46
|
+
capture: z.ZodDefault<z.ZodObject<{
|
|
47
|
+
deviceScaleFactor: z.ZodDefault<z.ZodNumber>;
|
|
48
|
+
locale: z.ZodDefault<z.ZodString>;
|
|
49
|
+
timezoneId: z.ZodDefault<z.ZodString>;
|
|
50
|
+
colorScheme: z.ZodDefault<z.ZodEnum<["light", "dark"]>>;
|
|
51
|
+
reducedMotion: z.ZodDefault<z.ZodBoolean>;
|
|
52
|
+
disableAnimations: z.ZodDefault<z.ZodBoolean>;
|
|
53
|
+
timeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
54
|
+
}, "strict", z.ZodTypeAny, {
|
|
55
|
+
deviceScaleFactor: number;
|
|
56
|
+
locale: string;
|
|
57
|
+
timezoneId: string;
|
|
58
|
+
colorScheme: "light" | "dark";
|
|
59
|
+
reducedMotion: boolean;
|
|
60
|
+
disableAnimations: boolean;
|
|
61
|
+
timeoutMs: number;
|
|
62
|
+
}, {
|
|
63
|
+
deviceScaleFactor?: number | undefined;
|
|
64
|
+
locale?: string | undefined;
|
|
65
|
+
timezoneId?: string | undefined;
|
|
66
|
+
colorScheme?: "light" | "dark" | undefined;
|
|
67
|
+
reducedMotion?: boolean | undefined;
|
|
68
|
+
disableAnimations?: boolean | undefined;
|
|
69
|
+
timeoutMs?: number | undefined;
|
|
70
|
+
}>>;
|
|
71
|
+
comparison: z.ZodDefault<z.ZodObject<{
|
|
72
|
+
colorThreshold: z.ZodDefault<z.ZodNumber>;
|
|
73
|
+
maxDiffPixels: z.ZodDefault<z.ZodNumber>;
|
|
74
|
+
maxDiffRatio: z.ZodOptional<z.ZodNumber>;
|
|
75
|
+
}, "strict", z.ZodTypeAny, {
|
|
76
|
+
colorThreshold: number;
|
|
77
|
+
maxDiffPixels: number;
|
|
78
|
+
maxDiffRatio?: number | undefined;
|
|
79
|
+
}, {
|
|
80
|
+
colorThreshold?: number | undefined;
|
|
81
|
+
maxDiffPixels?: number | undefined;
|
|
82
|
+
maxDiffRatio?: number | undefined;
|
|
83
|
+
}>>;
|
|
84
|
+
baselines: z.ZodDefault<z.ZodObject<{
|
|
85
|
+
dir: z.ZodDefault<z.ZodString>;
|
|
86
|
+
/** Approved baselines to compare with when no CLI or CI target ref is provided. */
|
|
87
|
+
baseRef: z.ZodOptional<z.ZodString>;
|
|
88
|
+
failOnObsolete: z.ZodDefault<z.ZodBoolean>;
|
|
89
|
+
strictEnvironment: z.ZodDefault<z.ZodBoolean>;
|
|
90
|
+
}, "strict", z.ZodTypeAny, {
|
|
91
|
+
dir: string;
|
|
92
|
+
failOnObsolete: boolean;
|
|
93
|
+
strictEnvironment: boolean;
|
|
94
|
+
baseRef?: string | undefined;
|
|
95
|
+
}, {
|
|
96
|
+
dir?: string | undefined;
|
|
97
|
+
baseRef?: string | undefined;
|
|
98
|
+
failOnObsolete?: boolean | undefined;
|
|
99
|
+
strictEnvironment?: boolean | undefined;
|
|
100
|
+
}>>;
|
|
101
|
+
report: z.ZodDefault<z.ZodObject<{
|
|
102
|
+
dir: z.ZodDefault<z.ZodString>;
|
|
103
|
+
}, "strict", z.ZodTypeAny, {
|
|
104
|
+
dir: string;
|
|
105
|
+
}, {
|
|
106
|
+
dir?: string | undefined;
|
|
107
|
+
}>>;
|
|
108
|
+
concurrency: z.ZodDefault<z.ZodNumber>;
|
|
109
|
+
/**
|
|
110
|
+
* Every story is captured once per variant, with ids like "button--primary@g100".
|
|
111
|
+
* Without variants, every story is captured once, with the default viewport.
|
|
112
|
+
*/
|
|
113
|
+
variants: z.ZodDefault<z.ZodEffects<z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
114
|
+
/** Becomes part of the scenario id after "@", so it must be file-name safe. */
|
|
115
|
+
name: z.ZodString;
|
|
116
|
+
/**
|
|
117
|
+
* Storybook globals to set for this variant, for example { 'backgrounds.value': 'g100' }.
|
|
118
|
+
* Written into the story URL as `globals=key:value;key:value`.
|
|
119
|
+
*/
|
|
120
|
+
globals: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
121
|
+
/** Overrides the default viewport for this variant. */
|
|
122
|
+
viewport: z.ZodOptional<z.ZodObject<{
|
|
123
|
+
width: z.ZodNumber;
|
|
124
|
+
height: z.ZodNumber;
|
|
125
|
+
}, "strict", z.ZodTypeAny, {
|
|
126
|
+
width: number;
|
|
127
|
+
height: number;
|
|
128
|
+
}, {
|
|
129
|
+
width: number;
|
|
130
|
+
height: number;
|
|
131
|
+
}>>;
|
|
132
|
+
}, "strict", z.ZodTypeAny, {
|
|
133
|
+
name: string;
|
|
134
|
+
globals?: Record<string, string> | undefined;
|
|
135
|
+
viewport?: {
|
|
136
|
+
width: number;
|
|
137
|
+
height: number;
|
|
138
|
+
} | undefined;
|
|
139
|
+
}, {
|
|
140
|
+
name: string;
|
|
141
|
+
globals?: Record<string, string> | undefined;
|
|
142
|
+
viewport?: {
|
|
143
|
+
width: number;
|
|
144
|
+
height: number;
|
|
145
|
+
} | undefined;
|
|
146
|
+
}>, {
|
|
147
|
+
name: string;
|
|
148
|
+
globals?: Record<string, string> | undefined;
|
|
149
|
+
viewport?: {
|
|
150
|
+
width: number;
|
|
151
|
+
height: number;
|
|
152
|
+
} | undefined;
|
|
153
|
+
}, {
|
|
154
|
+
name: string;
|
|
155
|
+
globals?: Record<string, string> | undefined;
|
|
156
|
+
viewport?: {
|
|
157
|
+
width: number;
|
|
158
|
+
height: number;
|
|
159
|
+
} | undefined;
|
|
160
|
+
}>, "many">, {
|
|
161
|
+
name: string;
|
|
162
|
+
globals?: Record<string, string> | undefined;
|
|
163
|
+
viewport?: {
|
|
164
|
+
width: number;
|
|
165
|
+
height: number;
|
|
166
|
+
} | undefined;
|
|
167
|
+
}[], {
|
|
168
|
+
name: string;
|
|
169
|
+
globals?: Record<string, string> | undefined;
|
|
170
|
+
viewport?: {
|
|
171
|
+
width: number;
|
|
172
|
+
height: number;
|
|
173
|
+
} | undefined;
|
|
174
|
+
}[]>>;
|
|
175
|
+
/** Optional: lets "viewev test --changed" run only the scenarios a change affects. */
|
|
176
|
+
impact: z.ZodOptional<z.ZodObject<{
|
|
177
|
+
/**
|
|
178
|
+
* A module (relative to the config file) whose default export maps changed files to
|
|
179
|
+
* scenarios. Viewev has no knowledge of how a repository relates files to UI.
|
|
180
|
+
*/
|
|
181
|
+
module: z.ZodString;
|
|
182
|
+
/** The branch or commit the change is compared with. */
|
|
183
|
+
baseRef: z.ZodDefault<z.ZodString>;
|
|
184
|
+
}, "strict", z.ZodTypeAny, {
|
|
185
|
+
baseRef: string;
|
|
186
|
+
module: string;
|
|
187
|
+
}, {
|
|
188
|
+
module: string;
|
|
189
|
+
baseRef?: string | undefined;
|
|
190
|
+
}>>;
|
|
191
|
+
}, "strict", z.ZodTypeAny, {
|
|
192
|
+
viewport: {
|
|
193
|
+
width: number;
|
|
194
|
+
height: number;
|
|
195
|
+
};
|
|
196
|
+
provider: {
|
|
197
|
+
type: "storybook";
|
|
198
|
+
url?: string | undefined;
|
|
199
|
+
staticDir?: string | undefined;
|
|
200
|
+
};
|
|
201
|
+
include: string[];
|
|
202
|
+
exclude: string[];
|
|
203
|
+
browser: {
|
|
204
|
+
engine: "chromium";
|
|
205
|
+
};
|
|
206
|
+
capture: {
|
|
207
|
+
deviceScaleFactor: number;
|
|
208
|
+
locale: string;
|
|
209
|
+
timezoneId: string;
|
|
210
|
+
colorScheme: "light" | "dark";
|
|
211
|
+
reducedMotion: boolean;
|
|
212
|
+
disableAnimations: boolean;
|
|
213
|
+
timeoutMs: number;
|
|
214
|
+
};
|
|
215
|
+
comparison: {
|
|
216
|
+
colorThreshold: number;
|
|
217
|
+
maxDiffPixels: number;
|
|
218
|
+
maxDiffRatio?: number | undefined;
|
|
219
|
+
};
|
|
220
|
+
baselines: {
|
|
221
|
+
dir: string;
|
|
222
|
+
failOnObsolete: boolean;
|
|
223
|
+
strictEnvironment: boolean;
|
|
224
|
+
baseRef?: string | undefined;
|
|
225
|
+
};
|
|
226
|
+
report: {
|
|
227
|
+
dir: string;
|
|
228
|
+
};
|
|
229
|
+
concurrency: number;
|
|
230
|
+
variants: {
|
|
231
|
+
name: string;
|
|
232
|
+
globals?: Record<string, string> | undefined;
|
|
233
|
+
viewport?: {
|
|
234
|
+
width: number;
|
|
235
|
+
height: number;
|
|
236
|
+
} | undefined;
|
|
237
|
+
}[];
|
|
238
|
+
impact?: {
|
|
239
|
+
baseRef: string;
|
|
240
|
+
module: string;
|
|
241
|
+
} | undefined;
|
|
242
|
+
}, {
|
|
243
|
+
provider: {
|
|
244
|
+
type: "storybook";
|
|
245
|
+
url?: string | undefined;
|
|
246
|
+
staticDir?: string | undefined;
|
|
247
|
+
};
|
|
248
|
+
viewport?: {
|
|
249
|
+
width: number;
|
|
250
|
+
height: number;
|
|
251
|
+
} | undefined;
|
|
252
|
+
include?: string[] | undefined;
|
|
253
|
+
exclude?: string[] | undefined;
|
|
254
|
+
browser?: {
|
|
255
|
+
engine?: "chromium" | undefined;
|
|
256
|
+
} | undefined;
|
|
257
|
+
capture?: {
|
|
258
|
+
deviceScaleFactor?: number | undefined;
|
|
259
|
+
locale?: string | undefined;
|
|
260
|
+
timezoneId?: string | undefined;
|
|
261
|
+
colorScheme?: "light" | "dark" | undefined;
|
|
262
|
+
reducedMotion?: boolean | undefined;
|
|
263
|
+
disableAnimations?: boolean | undefined;
|
|
264
|
+
timeoutMs?: number | undefined;
|
|
265
|
+
} | undefined;
|
|
266
|
+
comparison?: {
|
|
267
|
+
colorThreshold?: number | undefined;
|
|
268
|
+
maxDiffPixels?: number | undefined;
|
|
269
|
+
maxDiffRatio?: number | undefined;
|
|
270
|
+
} | undefined;
|
|
271
|
+
baselines?: {
|
|
272
|
+
dir?: string | undefined;
|
|
273
|
+
baseRef?: string | undefined;
|
|
274
|
+
failOnObsolete?: boolean | undefined;
|
|
275
|
+
strictEnvironment?: boolean | undefined;
|
|
276
|
+
} | undefined;
|
|
277
|
+
report?: {
|
|
278
|
+
dir?: string | undefined;
|
|
279
|
+
} | undefined;
|
|
280
|
+
concurrency?: number | undefined;
|
|
281
|
+
variants?: {
|
|
282
|
+
name: string;
|
|
283
|
+
globals?: Record<string, string> | undefined;
|
|
284
|
+
viewport?: {
|
|
285
|
+
width: number;
|
|
286
|
+
height: number;
|
|
287
|
+
} | undefined;
|
|
288
|
+
}[] | undefined;
|
|
289
|
+
impact?: {
|
|
290
|
+
module: string;
|
|
291
|
+
baseRef?: string | undefined;
|
|
292
|
+
} | undefined;
|
|
293
|
+
}>;
|
|
294
|
+
/** What a user writes in their config file. */
|
|
295
|
+
export type ViewevConfigInput = z.input<typeof configSchema>;
|
|
296
|
+
/** The validated configuration with every default applied. */
|
|
297
|
+
export type ViewevConfig = z.output<typeof configSchema>;
|
|
298
|
+
/** Identity helper that gives config files type checking and editor completion. */
|
|
299
|
+
export declare function defineConfig(config: ViewevConfigInput): ViewevConfigInput;
|