@cappa/plugin-storybook 0.4.7 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +41 -41
- package/dist/index.cjs.d.cts +12 -0
- package/dist/index.esm.d.ts +12 -0
- package/dist/index.js +41 -41
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -318,38 +318,46 @@ var cappaPluginStorybook = (options) => {
|
|
|
318
318
|
);
|
|
319
319
|
const toLocatorMask = (mask) => mask?.map((selector) => page.locator(selector));
|
|
320
320
|
const filename = buildFilename(story);
|
|
321
|
-
const variantsWithUrls =
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
|
|
321
|
+
const variantsWithUrls = [];
|
|
322
|
+
const variantExtrasEntries = [];
|
|
323
|
+
for (const variant of variantParameters) {
|
|
324
|
+
const variantFilename = variant.filename || screenshotTool.getVariantFilename(filename, {
|
|
325
|
+
id: variant.id,
|
|
326
|
+
label: variant.label,
|
|
327
|
+
filename: variant.filename
|
|
328
|
+
});
|
|
329
|
+
const mergedArgs = {
|
|
330
|
+
...defaultStorybookOptions?.args,
|
|
331
|
+
...variant.options?.args
|
|
332
|
+
};
|
|
333
|
+
variantsWithUrls.push({
|
|
334
|
+
id: variant.id,
|
|
335
|
+
label: variant.label,
|
|
336
|
+
filename: variantFilename,
|
|
337
|
+
url: buildStorybookIframeUrl({
|
|
338
|
+
baseUrl: options?.storybookUrl || "",
|
|
339
|
+
storyId: story.id,
|
|
340
|
+
viewMode: defaultStorybookOptions?.viewMode,
|
|
341
|
+
args: mergedArgs,
|
|
342
|
+
globals: defaultStorybookOptions?.globals,
|
|
343
|
+
query: defaultStorybookOptions?.query,
|
|
344
|
+
fullscreen: defaultStorybookOptions?.fullscreen,
|
|
345
|
+
singleStory: defaultStorybookOptions?.singleStory
|
|
346
|
+
}),
|
|
347
|
+
options: variant.options ? {
|
|
348
|
+
...variant.options,
|
|
349
|
+
mask: toLocatorMask(variant.options.mask)
|
|
350
|
+
} : void 0
|
|
351
|
+
});
|
|
352
|
+
variantExtrasEntries.push([
|
|
353
|
+
variant.id,
|
|
354
|
+
{
|
|
355
|
+
saveDiffImage: true,
|
|
356
|
+
diffImageFilename: variantFilename,
|
|
357
|
+
diff: variant.options?.diff
|
|
358
|
+
}
|
|
359
|
+
]);
|
|
360
|
+
}
|
|
353
361
|
const baseOptions = {
|
|
354
362
|
fullPage: storyParameters?.fullPage,
|
|
355
363
|
delay: storyParameters?.delay,
|
|
@@ -364,18 +372,10 @@ var cappaPluginStorybook = (options) => {
|
|
|
364
372
|
if (!variantFilename) continue;
|
|
365
373
|
variantFilenameMap.set(variant.id, variantFilename);
|
|
366
374
|
}
|
|
367
|
-
const variantExtrasEntries = variantsWithUrls.map(
|
|
368
|
-
(variant) => [
|
|
369
|
-
variant.id,
|
|
370
|
-
{
|
|
371
|
-
saveDiffImage: true,
|
|
372
|
-
diffImageFilename: variant.filename
|
|
373
|
-
}
|
|
374
|
-
]
|
|
375
|
-
);
|
|
376
375
|
const captureExtras = {
|
|
377
376
|
saveDiffImage: true,
|
|
378
377
|
diffImageFilename: filename,
|
|
378
|
+
diff: storyParameters?.diff,
|
|
379
379
|
variants: variantExtrasEntries.length ? Object.fromEntries(variantExtrasEntries) : void 0
|
|
380
380
|
};
|
|
381
381
|
const captureResult = await screenshotTool.captureWithVariants(
|
package/dist/index.cjs.d.cts
CHANGED
|
@@ -8,6 +8,13 @@ interface StorybookRenderOptions {
|
|
|
8
8
|
fullscreen?: boolean;
|
|
9
9
|
singleStory?: boolean;
|
|
10
10
|
}
|
|
11
|
+
interface DiffOptionsStorybook {
|
|
12
|
+
threshold?: number;
|
|
13
|
+
includeAA?: boolean;
|
|
14
|
+
fastBufferCheck?: boolean;
|
|
15
|
+
maxDiffPixels?: number;
|
|
16
|
+
maxDiffPercentage?: number;
|
|
17
|
+
}
|
|
11
18
|
interface ScreenshotVariantOverrideStorybook {
|
|
12
19
|
fullPage?: boolean;
|
|
13
20
|
delay?: number;
|
|
@@ -19,6 +26,11 @@ interface ScreenshotVariantOverrideStorybook {
|
|
|
19
26
|
height: number;
|
|
20
27
|
};
|
|
21
28
|
args?: Record<string, unknown>;
|
|
29
|
+
/**
|
|
30
|
+
* Optional diff settings override applied when comparing this screenshot.
|
|
31
|
+
* These map directly to Cappa's diff configuration options.
|
|
32
|
+
*/
|
|
33
|
+
diff?: DiffOptionsStorybook;
|
|
22
34
|
}
|
|
23
35
|
interface ScreenshotVariantOptionsStorybook {
|
|
24
36
|
id: string;
|
package/dist/index.esm.d.ts
CHANGED
|
@@ -8,6 +8,13 @@ interface StorybookRenderOptions {
|
|
|
8
8
|
fullscreen?: boolean;
|
|
9
9
|
singleStory?: boolean;
|
|
10
10
|
}
|
|
11
|
+
interface DiffOptionsStorybook {
|
|
12
|
+
threshold?: number;
|
|
13
|
+
includeAA?: boolean;
|
|
14
|
+
fastBufferCheck?: boolean;
|
|
15
|
+
maxDiffPixels?: number;
|
|
16
|
+
maxDiffPercentage?: number;
|
|
17
|
+
}
|
|
11
18
|
interface ScreenshotVariantOverrideStorybook {
|
|
12
19
|
fullPage?: boolean;
|
|
13
20
|
delay?: number;
|
|
@@ -19,6 +26,11 @@ interface ScreenshotVariantOverrideStorybook {
|
|
|
19
26
|
height: number;
|
|
20
27
|
};
|
|
21
28
|
args?: Record<string, unknown>;
|
|
29
|
+
/**
|
|
30
|
+
* Optional diff settings override applied when comparing this screenshot.
|
|
31
|
+
* These map directly to Cappa's diff configuration options.
|
|
32
|
+
*/
|
|
33
|
+
diff?: DiffOptionsStorybook;
|
|
22
34
|
}
|
|
23
35
|
interface ScreenshotVariantOptionsStorybook {
|
|
24
36
|
id: string;
|
package/dist/index.js
CHANGED
|
@@ -284,38 +284,46 @@ var cappaPluginStorybook = (options) => {
|
|
|
284
284
|
);
|
|
285
285
|
const toLocatorMask = (mask) => mask?.map((selector) => page.locator(selector));
|
|
286
286
|
const filename = buildFilename(story);
|
|
287
|
-
const variantsWithUrls =
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
|
|
287
|
+
const variantsWithUrls = [];
|
|
288
|
+
const variantExtrasEntries = [];
|
|
289
|
+
for (const variant of variantParameters) {
|
|
290
|
+
const variantFilename = variant.filename || screenshotTool.getVariantFilename(filename, {
|
|
291
|
+
id: variant.id,
|
|
292
|
+
label: variant.label,
|
|
293
|
+
filename: variant.filename
|
|
294
|
+
});
|
|
295
|
+
const mergedArgs = {
|
|
296
|
+
...defaultStorybookOptions?.args,
|
|
297
|
+
...variant.options?.args
|
|
298
|
+
};
|
|
299
|
+
variantsWithUrls.push({
|
|
300
|
+
id: variant.id,
|
|
301
|
+
label: variant.label,
|
|
302
|
+
filename: variantFilename,
|
|
303
|
+
url: buildStorybookIframeUrl({
|
|
304
|
+
baseUrl: options?.storybookUrl || "",
|
|
305
|
+
storyId: story.id,
|
|
306
|
+
viewMode: defaultStorybookOptions?.viewMode,
|
|
307
|
+
args: mergedArgs,
|
|
308
|
+
globals: defaultStorybookOptions?.globals,
|
|
309
|
+
query: defaultStorybookOptions?.query,
|
|
310
|
+
fullscreen: defaultStorybookOptions?.fullscreen,
|
|
311
|
+
singleStory: defaultStorybookOptions?.singleStory
|
|
312
|
+
}),
|
|
313
|
+
options: variant.options ? {
|
|
314
|
+
...variant.options,
|
|
315
|
+
mask: toLocatorMask(variant.options.mask)
|
|
316
|
+
} : void 0
|
|
317
|
+
});
|
|
318
|
+
variantExtrasEntries.push([
|
|
319
|
+
variant.id,
|
|
320
|
+
{
|
|
321
|
+
saveDiffImage: true,
|
|
322
|
+
diffImageFilename: variantFilename,
|
|
323
|
+
diff: variant.options?.diff
|
|
324
|
+
}
|
|
325
|
+
]);
|
|
326
|
+
}
|
|
319
327
|
const baseOptions = {
|
|
320
328
|
fullPage: storyParameters?.fullPage,
|
|
321
329
|
delay: storyParameters?.delay,
|
|
@@ -330,18 +338,10 @@ var cappaPluginStorybook = (options) => {
|
|
|
330
338
|
if (!variantFilename) continue;
|
|
331
339
|
variantFilenameMap.set(variant.id, variantFilename);
|
|
332
340
|
}
|
|
333
|
-
const variantExtrasEntries = variantsWithUrls.map(
|
|
334
|
-
(variant) => [
|
|
335
|
-
variant.id,
|
|
336
|
-
{
|
|
337
|
-
saveDiffImage: true,
|
|
338
|
-
diffImageFilename: variant.filename
|
|
339
|
-
}
|
|
340
|
-
]
|
|
341
|
-
);
|
|
342
341
|
const captureExtras = {
|
|
343
342
|
saveDiffImage: true,
|
|
344
343
|
diffImageFilename: filename,
|
|
344
|
+
diff: storyParameters?.diff,
|
|
345
345
|
variants: variantExtrasEntries.length ? Object.fromEntries(variantExtrasEntries) : void 0
|
|
346
346
|
};
|
|
347
347
|
const captureResult = await screenshotTool.captureWithVariants(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cappa/plugin-storybook",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Storybook plugin for Cappa - takes screenshots of Storybook stories",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"@swc/core": "^1.15.3",
|
|
60
60
|
"chalk": "^5.6.2",
|
|
61
61
|
"minimatch": "^10.1.1",
|
|
62
|
-
"@cappa/core": "0.
|
|
62
|
+
"@cappa/core": "0.5.0",
|
|
63
63
|
"@cappa/logger": "0.0.8"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|