@cappa/plugin-storybook 0.7.1 → 0.8.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 +18 -3
- package/dist/index.js +18 -3
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -195,7 +195,7 @@ var cappaPluginStorybook = (options) => {
|
|
|
195
195
|
return {
|
|
196
196
|
name: "StorybookPlugin",
|
|
197
197
|
description: "Takes screenshots of Storybook stories with configurable options",
|
|
198
|
-
discover: async () => {
|
|
198
|
+
discover: async (screenshotTool) => {
|
|
199
199
|
if (!options) {
|
|
200
200
|
throw new Error("Storybook plugin options are required");
|
|
201
201
|
}
|
|
@@ -211,7 +211,22 @@ var cappaPluginStorybook = (options) => {
|
|
|
211
211
|
} = options;
|
|
212
212
|
const storiesUrl = `${storybookUrl}/index.json`;
|
|
213
213
|
logger.debug(`Fetching stories from: ${storiesUrl}`);
|
|
214
|
-
const
|
|
214
|
+
const timeout = screenshotTool.connectionTimeout;
|
|
215
|
+
let response;
|
|
216
|
+
try {
|
|
217
|
+
response = await fetch(storiesUrl, {
|
|
218
|
+
signal: AbortSignal.timeout(timeout)
|
|
219
|
+
});
|
|
220
|
+
} catch (error) {
|
|
221
|
+
if (error instanceof DOMException && error.name === "TimeoutError") {
|
|
222
|
+
throw new Error(
|
|
223
|
+
`Connection to Storybook at ${storybookUrl} timed out after ${timeout}ms. Make sure Storybook is running and accessible.`
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
throw new Error(
|
|
227
|
+
`Failed to connect to Storybook at ${storybookUrl}. Make sure Storybook is running and accessible. Error: ${error.message}`
|
|
228
|
+
);
|
|
229
|
+
}
|
|
215
230
|
if (!response.ok) {
|
|
216
231
|
throw new Error(
|
|
217
232
|
`Failed to fetch stories: ${response.status} ${response.statusText}`
|
|
@@ -281,7 +296,7 @@ var cappaPluginStorybook = (options) => {
|
|
|
281
296
|
const currentLatch = createLatch();
|
|
282
297
|
context.latchMap.set(story.id, currentLatch);
|
|
283
298
|
const captureStart = performance.now();
|
|
284
|
-
await page.goto(url);
|
|
299
|
+
await page.goto(url, { timeout: screenshotTool.connectionTimeout });
|
|
285
300
|
const storyParameters = await context.latchMap.get(story.id)?.p;
|
|
286
301
|
context.latchMap.delete(story.id);
|
|
287
302
|
const variantParameters = storyParameters?.variants ?? [];
|
package/dist/index.js
CHANGED
|
@@ -161,7 +161,7 @@ var cappaPluginStorybook = (options) => {
|
|
|
161
161
|
return {
|
|
162
162
|
name: "StorybookPlugin",
|
|
163
163
|
description: "Takes screenshots of Storybook stories with configurable options",
|
|
164
|
-
discover: async () => {
|
|
164
|
+
discover: async (screenshotTool) => {
|
|
165
165
|
if (!options) {
|
|
166
166
|
throw new Error("Storybook plugin options are required");
|
|
167
167
|
}
|
|
@@ -177,7 +177,22 @@ var cappaPluginStorybook = (options) => {
|
|
|
177
177
|
} = options;
|
|
178
178
|
const storiesUrl = `${storybookUrl}/index.json`;
|
|
179
179
|
logger.debug(`Fetching stories from: ${storiesUrl}`);
|
|
180
|
-
const
|
|
180
|
+
const timeout = screenshotTool.connectionTimeout;
|
|
181
|
+
let response;
|
|
182
|
+
try {
|
|
183
|
+
response = await fetch(storiesUrl, {
|
|
184
|
+
signal: AbortSignal.timeout(timeout)
|
|
185
|
+
});
|
|
186
|
+
} catch (error) {
|
|
187
|
+
if (error instanceof DOMException && error.name === "TimeoutError") {
|
|
188
|
+
throw new Error(
|
|
189
|
+
`Connection to Storybook at ${storybookUrl} timed out after ${timeout}ms. Make sure Storybook is running and accessible.`
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
throw new Error(
|
|
193
|
+
`Failed to connect to Storybook at ${storybookUrl}. Make sure Storybook is running and accessible. Error: ${error.message}`
|
|
194
|
+
);
|
|
195
|
+
}
|
|
181
196
|
if (!response.ok) {
|
|
182
197
|
throw new Error(
|
|
183
198
|
`Failed to fetch stories: ${response.status} ${response.statusText}`
|
|
@@ -247,7 +262,7 @@ var cappaPluginStorybook = (options) => {
|
|
|
247
262
|
const currentLatch = createLatch();
|
|
248
263
|
context.latchMap.set(story.id, currentLatch);
|
|
249
264
|
const captureStart = performance.now();
|
|
250
|
-
await page.goto(url);
|
|
265
|
+
await page.goto(url, { timeout: screenshotTool.connectionTimeout });
|
|
251
266
|
const storyParameters = await context.latchMap.get(story.id)?.p;
|
|
252
267
|
context.latchMap.delete(story.id);
|
|
253
268
|
const variantParameters = storyParameters?.variants ?? [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cappa/plugin-storybook",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Storybook plugin for Cappa - takes screenshots of Storybook stories",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -63,19 +63,19 @@
|
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"@swc/core": "^1.15.18",
|
|
65
65
|
"chalk": "^5.6.2",
|
|
66
|
-
"@cappa/core": "0.
|
|
66
|
+
"@cappa/core": "0.8.0",
|
|
67
67
|
"@cappa/logger": "0.0.10"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@arethetypeswrong/cli": "0.18.2",
|
|
71
71
|
"@types/node": "25.5.0",
|
|
72
|
-
"@vitest/coverage-v8": "4.1.
|
|
73
|
-
"@vitest/ui": "4.1.
|
|
72
|
+
"@vitest/coverage-v8": "4.1.2",
|
|
73
|
+
"@vitest/ui": "4.1.2",
|
|
74
74
|
"playwright-core": "^1.58.2",
|
|
75
75
|
"storybook": "^10.3.1",
|
|
76
76
|
"tsup": "8.5.1",
|
|
77
77
|
"typescript": "5.9.3",
|
|
78
|
-
"vitest": "4.1.
|
|
78
|
+
"vitest": "4.1.2"
|
|
79
79
|
},
|
|
80
80
|
"scripts": {
|
|
81
81
|
"test": "vitest",
|