@cappa/plugin-storybook 0.11.1 → 0.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/index.cjs.cjs +3 -2
- package/dist/index.cjs.d.cts +17 -1
- package/dist/index.esm.d.mts +17 -1
- package/dist/index.esm.mjs +3 -2
- package/package.json +2 -2
package/dist/index.cjs.cjs
CHANGED
|
@@ -216,8 +216,8 @@ const cappaPluginStorybook = (options) => {
|
|
|
216
216
|
try {
|
|
217
217
|
response = await fetch(storiesUrl, { signal: AbortSignal.timeout(timeout) });
|
|
218
218
|
} catch (error) {
|
|
219
|
-
if (error instanceof DOMException && error.name === "TimeoutError") throw new Error(`Connection to Storybook at ${storybookUrl} timed out after ${timeout}ms. Make sure Storybook is running and accessible
|
|
220
|
-
throw new Error(`Failed to connect to Storybook at ${storybookUrl}. Make sure Storybook is running and accessible. Error: ${error.message}
|
|
219
|
+
if (error instanceof DOMException && error.name === "TimeoutError") throw new Error(`Connection to Storybook at ${storybookUrl} timed out after ${timeout}ms. Make sure Storybook is running and accessible.`, { cause: error });
|
|
220
|
+
throw new Error(`Failed to connect to Storybook at ${storybookUrl}. Make sure Storybook is running and accessible. Error: ${error.message}`, { cause: error });
|
|
221
221
|
}
|
|
222
222
|
if (!response.ok) throw new Error(`Failed to fetch stories: ${response.status} ${response.statusText}`);
|
|
223
223
|
const data = await response.json();
|
|
@@ -355,6 +355,7 @@ const cappaPluginStorybook = (options) => {
|
|
|
355
355
|
}
|
|
356
356
|
const baseOptions = {
|
|
357
357
|
fullPage: storyParameters?.fullPage,
|
|
358
|
+
crop: storyParameters?.crop ?? options?.crop,
|
|
358
359
|
delay: storyParameters?.delay,
|
|
359
360
|
omitBackground: storyParameters?.omitBackground,
|
|
360
361
|
skip: storyParameters?.skip,
|
package/dist/index.cjs.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DiffOptions, Plugin } from "@cappa/core";
|
|
1
|
+
import { CropSetting, DiffOptions, Plugin } from "@cappa/core";
|
|
2
2
|
//#region src/types.d.ts
|
|
3
3
|
interface StorybookRenderOptions {
|
|
4
4
|
viewMode?: "story" | "docs";
|
|
@@ -11,6 +11,12 @@ interface StorybookRenderOptions {
|
|
|
11
11
|
type DiffOptionsStorybook = DiffOptions;
|
|
12
12
|
interface ScreenshotVariantOverrideStorybook {
|
|
13
13
|
fullPage?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Crop the screenshot to what the story renders instead of the whole
|
|
16
|
+
* viewport. `true` crops with 8px of padding; `{ padding }` changes it.
|
|
17
|
+
* Overrides the plugin's and the config's `crop`.
|
|
18
|
+
*/
|
|
19
|
+
crop?: CropSetting;
|
|
14
20
|
delay?: number;
|
|
15
21
|
skip?: boolean;
|
|
16
22
|
mask?: string[];
|
|
@@ -85,6 +91,16 @@ interface StorybookPluginOptions {
|
|
|
85
91
|
waitForSelector?: string;
|
|
86
92
|
waitForTimeout?: number;
|
|
87
93
|
storybook?: StorybookRenderOptions;
|
|
94
|
+
/**
|
|
95
|
+
* Crop every story's screenshot to the content it renders instead of the
|
|
96
|
+
* whole viewport — see `screenshot.crop` in the cappa config, which this
|
|
97
|
+
* overrides for this plugin. A story or variant can override it in turn
|
|
98
|
+
* with its own `crop` parameter.
|
|
99
|
+
*
|
|
100
|
+
* The viewport stays what the story is laid out at, so responsive styles
|
|
101
|
+
* are unaffected; it becomes the most a screenshot can cover.
|
|
102
|
+
*/
|
|
103
|
+
crop?: CropSetting;
|
|
88
104
|
/**
|
|
89
105
|
* Globs, relative to the working directory, that watch mode should watch on
|
|
90
106
|
* top of the project sources it watches anyway.
|
package/dist/index.esm.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DiffOptions, Plugin } from "@cappa/core";
|
|
1
|
+
import { CropSetting, DiffOptions, Plugin } from "@cappa/core";
|
|
2
2
|
//#region src/types.d.ts
|
|
3
3
|
interface StorybookRenderOptions {
|
|
4
4
|
viewMode?: "story" | "docs";
|
|
@@ -11,6 +11,12 @@ interface StorybookRenderOptions {
|
|
|
11
11
|
type DiffOptionsStorybook = DiffOptions;
|
|
12
12
|
interface ScreenshotVariantOverrideStorybook {
|
|
13
13
|
fullPage?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Crop the screenshot to what the story renders instead of the whole
|
|
16
|
+
* viewport. `true` crops with 8px of padding; `{ padding }` changes it.
|
|
17
|
+
* Overrides the plugin's and the config's `crop`.
|
|
18
|
+
*/
|
|
19
|
+
crop?: CropSetting;
|
|
14
20
|
delay?: number;
|
|
15
21
|
skip?: boolean;
|
|
16
22
|
mask?: string[];
|
|
@@ -85,6 +91,16 @@ interface StorybookPluginOptions {
|
|
|
85
91
|
waitForSelector?: string;
|
|
86
92
|
waitForTimeout?: number;
|
|
87
93
|
storybook?: StorybookRenderOptions;
|
|
94
|
+
/**
|
|
95
|
+
* Crop every story's screenshot to the content it renders instead of the
|
|
96
|
+
* whole viewport — see `screenshot.crop` in the cappa config, which this
|
|
97
|
+
* overrides for this plugin. A story or variant can override it in turn
|
|
98
|
+
* with its own `crop` parameter.
|
|
99
|
+
*
|
|
100
|
+
* The viewport stays what the story is laid out at, so responsive styles
|
|
101
|
+
* are unaffected; it becomes the most a screenshot can cover.
|
|
102
|
+
*/
|
|
103
|
+
crop?: CropSetting;
|
|
88
104
|
/**
|
|
89
105
|
* Globs, relative to the working directory, that watch mode should watch on
|
|
90
106
|
* top of the project sources it watches anyway.
|
package/dist/index.esm.mjs
CHANGED
|
@@ -216,8 +216,8 @@ const cappaPluginStorybook = (options) => {
|
|
|
216
216
|
try {
|
|
217
217
|
response = await fetch(storiesUrl, { signal: AbortSignal.timeout(timeout) });
|
|
218
218
|
} catch (error) {
|
|
219
|
-
if (error instanceof DOMException && error.name === "TimeoutError") throw new Error(`Connection to Storybook at ${storybookUrl} timed out after ${timeout}ms. Make sure Storybook is running and accessible
|
|
220
|
-
throw new Error(`Failed to connect to Storybook at ${storybookUrl}. Make sure Storybook is running and accessible. Error: ${error.message}
|
|
219
|
+
if (error instanceof DOMException && error.name === "TimeoutError") throw new Error(`Connection to Storybook at ${storybookUrl} timed out after ${timeout}ms. Make sure Storybook is running and accessible.`, { cause: error });
|
|
220
|
+
throw new Error(`Failed to connect to Storybook at ${storybookUrl}. Make sure Storybook is running and accessible. Error: ${error.message}`, { cause: error });
|
|
221
221
|
}
|
|
222
222
|
if (!response.ok) throw new Error(`Failed to fetch stories: ${response.status} ${response.statusText}`);
|
|
223
223
|
const data = await response.json();
|
|
@@ -355,6 +355,7 @@ const cappaPluginStorybook = (options) => {
|
|
|
355
355
|
}
|
|
356
356
|
const baseOptions = {
|
|
357
357
|
fullPage: storyParameters?.fullPage,
|
|
358
|
+
crop: storyParameters?.crop ?? options?.crop,
|
|
358
359
|
delay: storyParameters?.delay,
|
|
359
360
|
omitBackground: storyParameters?.omitBackground,
|
|
360
361
|
skip: storyParameters?.skip,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cappa/plugin-storybook",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "Storybook plugin for Cappa - takes screenshots of Storybook stories",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
}
|
|
77
77
|
},
|
|
78
78
|
"dependencies": {
|
|
79
|
-
"@cappa/core": "0.
|
|
79
|
+
"@cappa/core": "0.17.0",
|
|
80
80
|
"@cappa/logger": "0.0.12",
|
|
81
81
|
"@swc/core": "^1.16.2",
|
|
82
82
|
"chalk": "^6.0.0"
|