@poveste/plugin-screenshot 0.14.0 → 0.16.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.
Files changed (2) hide show
  1. package/dist/index.js +10 -11
  2. package/package.json +11 -10
package/dist/index.js CHANGED
@@ -20,17 +20,13 @@ export function screenshotFileName(storyId, variantId, width, height) {
20
20
  }
21
21
  export function HstScreenshot(options = {}) {
22
22
  const finalOptions = defu(options, defaultOptions);
23
- if (!finalOptions.presets.length) {
24
- finalOptions.presets.push({
25
- width: 1280,
26
- height: 800,
27
- });
28
- }
23
+ const saveFolder = finalOptions.saveFolder ?? '.poveste/screenshots';
24
+ const presets = finalOptions.presets?.length ? finalOptions.presets : [{ width: 1280, height: 800 }];
29
25
  return {
30
26
  name: '@poveste/plugin-screenshot',
31
27
  onBuild: async (api) => {
32
28
  const { default: captureWebsite } = await import('capture-website');
33
- await fs.ensureDir(finalOptions.saveFolder);
29
+ await fs.ensureDir(saveFolder);
34
30
  api.onPreviewStory(async ({ file, story, variant, url }) => {
35
31
  if (finalOptions.ignored?.({
36
32
  file,
@@ -45,7 +41,10 @@ export function HstScreenshot(options = {}) {
45
41
  return;
46
42
  }
47
43
  console.log('Rendering screenshot for', file, 'title:', story.title, 'variant:', variant.id, 'title:', variant.title);
48
- for (const preset of finalOptions.presets) {
44
+ for (const preset of presets) {
45
+ // capture-website's own default viewport, which a preset without a size got.
46
+ const width = preset.width ?? 1280;
47
+ const height = preset.height ?? 800;
49
48
  const launchOptions = finalOptions.launchOptionsArgs
50
49
  ? {
51
50
  args: finalOptions.launchOptionsArgs,
@@ -53,12 +52,12 @@ export function HstScreenshot(options = {}) {
53
52
  : {};
54
53
  const captureWebsiteFileOptions = {
55
54
  overwrite: true,
56
- width: preset.width,
57
- height: preset.height,
55
+ width,
56
+ height,
58
57
  fullPage: true,
59
58
  launchOptions,
60
59
  };
61
- await captureWebsite.file(url, path.join(finalOptions.saveFolder, screenshotFileName(story.id, variant.id, preset.width, preset.height)), captureWebsiteFileOptions);
60
+ await captureWebsite.file(url, path.join(saveFolder, screenshotFileName(story.id, variant.id, width, height)), captureWebsiteFileOptions);
62
61
  }
63
62
  });
64
63
  },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@poveste/plugin-screenshot",
3
3
  "type": "module",
4
- "version": "0.14.0",
4
+ "version": "0.16.0",
5
5
  "description": "Poveste plugin to take screenshots for visual regression testing",
6
6
  "author": {
7
7
  "name": "Sorin Gitlan",
@@ -44,22 +44,23 @@
44
44
  "dist"
45
45
  ],
46
46
  "engines": {
47
- "node": "^22.22.2 || ^24.15.0 || >=26.0.0"
47
+ "node": ">=22.22.2"
48
48
  },
49
49
  "peerDependencies": {
50
- "poveste": "^0.14.0"
50
+ "poveste": "^0.16.0"
51
51
  },
52
52
  "dependencies": {
53
- "capture-website": "^4.2.0",
53
+ "capture-website": "^5.1.0",
54
54
  "defu": "^6.1.4",
55
- "fs-extra": "^11.2.0",
56
- "pathe": "^1.1.2"
55
+ "fs-extra": "^11.4.1",
56
+ "pathe": "^2.0.3"
57
57
  },
58
58
  "devDependencies": {
59
- "@types/node": "^22.10.1",
60
- "poveste": "0.14.0",
61
- "typescript": "5.6.3",
62
- "vitest": "^5.0.0"
59
+ "@types/fs-extra": "^11.0.4",
60
+ "@types/node": "^26.6.3",
61
+ "poveste": "0.16.0",
62
+ "typescript": "6.0.3",
63
+ "vitest": "^5.0.2"
63
64
  },
64
65
  "scripts": {
65
66
  "build": "rimraf dist && tsc -d",