@poveste/plugin-screenshot 0.6.1 → 0.7.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/package.json CHANGED
@@ -1,17 +1,34 @@
1
1
  {
2
2
  "name": "@poveste/plugin-screenshot",
3
3
  "type": "module",
4
- "version": "0.6.1",
4
+ "version": "0.7.0",
5
5
  "description": "Poveste plugin to take screenshots for visual regression testing",
6
6
  "author": {
7
7
  "name": "Sorin Gitlan"
8
8
  },
9
9
  "license": "MIT",
10
+ "homepage": "https://poveste.dev",
10
11
  "repository": {
11
12
  "url": "https://github.com/poveste-dev/poveste.git",
12
13
  "type": "git",
13
14
  "directory": "packages/poveste-plugin-screenshot"
14
15
  },
16
+ "bugs": "https://github.com/poveste-dev/poveste/issues",
17
+ "keywords": [
18
+ "poveste",
19
+ "histoire",
20
+ "storybook",
21
+ "component-playground",
22
+ "component-explorer",
23
+ "stories",
24
+ "styleguide",
25
+ "design-system",
26
+ "vite",
27
+ "screenshot",
28
+ "visual-regression",
29
+ "testing",
30
+ "plugin"
31
+ ],
15
32
  "publishConfig": {
16
33
  "access": "public"
17
34
  },
@@ -22,8 +39,14 @@
22
39
  "main": "./dist/index.js",
23
40
  "module": "./dist/index.js",
24
41
  "types": "./dist/index.d.ts",
42
+ "files": [
43
+ "dist"
44
+ ],
45
+ "engines": {
46
+ "node": "^22.22.2 || ^24.15.0 || >=26.0.0"
47
+ },
25
48
  "peerDependencies": {
26
- "poveste": "^0.6.1"
49
+ "poveste": "^0.7.0"
27
50
  },
28
51
  "dependencies": {
29
52
  "capture-website": "^4.2.0",
@@ -34,7 +57,7 @@
34
57
  "devDependencies": {
35
58
  "@types/node": "^22.10.1",
36
59
  "typescript": "5.6.3",
37
- "poveste": "0.6.1"
60
+ "poveste": "0.7.0"
38
61
  },
39
62
  "scripts": {
40
63
  "build": "rimraf dist && tsc -d",
package/src/index.ts DELETED
@@ -1,89 +0,0 @@
1
- import type { FileOptions } from 'capture-website'
2
- import type { Plugin } from 'poveste'
3
- import { defu } from 'defu'
4
- import fs from 'fs-extra'
5
- import path from 'pathe'
6
-
7
- interface ScreenshotPresets {
8
- /**
9
- * Screenshot width.
10
- */
11
- width?: number
12
- /**
13
- * Screenshot height.
14
- */
15
- height?: number
16
- }
17
-
18
- export interface ScreenshotPluginOptions {
19
- /**
20
- * Folder were screenshots will be saved.
21
- */
22
- saveFolder?: string
23
- /**
24
- * Ignored stories.
25
- */
26
- ignored?: (payload: { file: string, story: { title: string }, variant: { id: string, title: string } }) => boolean
27
- /**
28
- * Presets for each screenshot.
29
- */
30
- presets?: ScreenshotPresets[]
31
- /**
32
- * Args for puppeteer
33
- */
34
- launchOptionsArgs?: string[]
35
- }
36
-
37
- const defaultOptions: ScreenshotPluginOptions = {
38
- saveFolder: '.poveste/screenshots',
39
- presets: [],
40
- }
41
-
42
- export function HstScreenshot(options: ScreenshotPluginOptions = {}): Plugin {
43
- const finalOptions: ScreenshotPluginOptions = defu(options, defaultOptions)
44
- if (!finalOptions.presets.length) {
45
- finalOptions.presets.push({
46
- width: 1280,
47
- height: 800,
48
- })
49
- }
50
- return {
51
- name: '@poveste/plugin-screenshot',
52
-
53
- onBuild: async (api) => {
54
- const { default: captureWebsite } = await import('capture-website')
55
- await fs.ensureDir(finalOptions.saveFolder)
56
-
57
- api.onPreviewStory(async ({ file, story, variant, url }) => {
58
- if (finalOptions.ignored?.({
59
- file,
60
- story: {
61
- title: story.title,
62
- },
63
- variant: {
64
- id: variant.id,
65
- title: variant.title,
66
- },
67
- })) {
68
- return
69
- }
70
- console.log('Rendering screenshot for', file, 'title:', story.title, 'variant:', variant.id, 'title:', variant.title)
71
- for (const preset of finalOptions.presets) {
72
- const launchOptions = finalOptions.launchOptionsArgs
73
- ? {
74
- args: finalOptions.launchOptionsArgs,
75
- }
76
- : {}
77
- const captureWebsiteFileOptions: FileOptions = {
78
- overwrite: true,
79
- width: preset.width,
80
- height: preset.height,
81
- fullPage: true,
82
- launchOptions,
83
- }
84
- await captureWebsite.file(url, path.join(finalOptions.saveFolder, `${story.id}-${variant.id}-${preset.width}x${preset.height}.png`), captureWebsiteFileOptions)
85
- }
86
- })
87
- },
88
- }
89
- }
package/tsconfig.json DELETED
@@ -1,40 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ESNext",
4
- // Volar
5
- "jsx": "preserve",
6
- "lib": [
7
- "ESNext",
8
- "DOM"
9
- ],
10
- "rootDir": "src",
11
- "module": "ESNext",
12
- "moduleResolution": "bundler",
13
- "resolveJsonModule": true,
14
- "types": [
15
- "node"
16
- ],
17
- "strictBindCallApply": true,
18
- "strictFunctionTypes": true,
19
- "alwaysStrict": true,
20
- // Strict
21
- "noImplicitAny": false,
22
- "noImplicitThis": true,
23
- "outDir": "dist",
24
- "removeComments": false,
25
- "sourceMap": false,
26
- "allowSyntheticDefaultImports": true,
27
- "esModuleInterop": true,
28
- "skipLibCheck": true,
29
- "preserveWatchOutput": true
30
- },
31
- "include": [
32
- "src"
33
- ],
34
- "exclude": [
35
- "node_modules",
36
- "generated/**/*",
37
- "dist/**/*",
38
- "src/**/*.spec.ts"
39
- ]
40
- }