@poveste/plugin-screenshot 0.6.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/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # Poveste Screenshot visual regression testing
2
2
 
3
- ```
3
+ ```bash
4
4
  pnpm add -D @poveste/plugin-screenshot
5
5
  ```
6
6
 
7
- Add the plugin in histoire config:
7
+ Add the plugin in your Poveste config:
8
8
 
9
9
  ```js
10
10
  import { HstScreenshot } from '@poveste/plugin-screenshot'
@@ -21,14 +21,13 @@ export default defineConfig({
21
21
 
22
22
  ## Setting Up Chrome Linux Sandbox
23
23
 
24
- If you get an error like No usable sandbox! or Running as root without --no-sandbox is not supported, you need to properly set up sandboxing on your Linux instance.
25
- Alternatively, if you completely trust the content, you can disable sandboxing (strongly discouraged):
26
-
27
- ref. https://github.com/sindresorhus/capture-website#faq
24
+ If you get `No usable sandbox!` or `Running as root without --no-sandbox is not
25
+ supported`, set up sandboxing properly on your Linux instance. Alternatively, if you
26
+ completely trust the content being captured, you can disable it (strongly discouraged):
28
27
 
29
- ```
30
- import { defineConfig } from 'poveste'
28
+ ```js
31
29
  import { HstScreenshot } from '@poveste/plugin-screenshot'
30
+ import { defineConfig } from 'poveste'
32
31
 
33
32
  export default defineConfig({
34
33
  plugins: [
@@ -38,3 +37,5 @@ export default defineConfig({
38
37
  ],
39
38
  })
40
39
  ```
40
+
41
+ [Documentation](https://poveste.dev)
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.8.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.8.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.8.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
- }