@histoire/plugin-percy 0.17.16 → 0.17.17
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 +0 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -4
- package/package.json +8 -8
- package/src/index.ts +12 -12
- package/tsconfig.json +17 -17
package/README.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export interface PercySnapshotOptions {
|
|
|
22
22
|
userAgent: string;
|
|
23
23
|
}>;
|
|
24
24
|
}
|
|
25
|
-
export
|
|
25
|
+
export interface PagePayload {
|
|
26
26
|
file: string;
|
|
27
27
|
story: {
|
|
28
28
|
title: string;
|
|
@@ -31,7 +31,7 @@ export type PagePayload = {
|
|
|
31
31
|
id: string;
|
|
32
32
|
title: string;
|
|
33
33
|
};
|
|
34
|
-
}
|
|
34
|
+
}
|
|
35
35
|
type ContructorOption<T extends object | number> = T | ((payload: PagePayload) => T);
|
|
36
36
|
export interface PercyPluginOptions {
|
|
37
37
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { defu } from 'defu';
|
|
2
|
-
import path from 'pathe';
|
|
3
1
|
import { fileURLToPath } from 'node:url';
|
|
4
2
|
import { createRequire } from 'node:module';
|
|
5
|
-
import {
|
|
3
|
+
import { defu } from 'defu';
|
|
4
|
+
import path from 'pathe';
|
|
5
|
+
import { fetchPercyDOM, isPercyEnabled, postSnapshot } from '@percy/sdk-utils';
|
|
6
6
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
7
7
|
const require = createRequire(import.meta.url);
|
|
8
8
|
const defaultOptions = {
|
|
@@ -47,7 +47,7 @@ export function HstPercy(options = {}) {
|
|
|
47
47
|
const percyOptions = resolveOptions(finalOptions.percyOptions, payload);
|
|
48
48
|
const page = await browser.newPage();
|
|
49
49
|
await page.goto(url, pptrOptions);
|
|
50
|
-
await new Promise(
|
|
50
|
+
await new Promise(resolve => setTimeout(resolve, pptrWait));
|
|
51
51
|
if (finalOptions.beforeSnapshot) {
|
|
52
52
|
const result = await finalOptions.beforeSnapshot(page, payload);
|
|
53
53
|
if (result === false) {
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@histoire/plugin-percy",
|
|
3
|
-
"
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.17.17",
|
|
4
5
|
"description": "Histoire plugin to take screenshots with Percy for visual regression testing",
|
|
5
|
-
"license": "MIT",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Guillaume Chau"
|
|
8
8
|
},
|
|
9
|
+
"license": "MIT",
|
|
9
10
|
"repository": {
|
|
10
11
|
"url": "https://github.com/Akryum/histoire.git",
|
|
11
12
|
"type": "git",
|
|
@@ -14,7 +15,6 @@
|
|
|
14
15
|
"publishConfig": {
|
|
15
16
|
"access": "public"
|
|
16
17
|
},
|
|
17
|
-
"type": "module",
|
|
18
18
|
"exports": {
|
|
19
19
|
".": "./dist/index.js",
|
|
20
20
|
"./*": "./*"
|
|
@@ -22,6 +22,9 @@
|
|
|
22
22
|
"main": "./dist/index.js",
|
|
23
23
|
"module": "./dist/index.js",
|
|
24
24
|
"types": "./dist/index.d.ts",
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"histoire": "^0.17.17"
|
|
27
|
+
},
|
|
25
28
|
"dependencies": {
|
|
26
29
|
"@percy/sdk-utils": "^1.27.4",
|
|
27
30
|
"defu": "^6.1.3",
|
|
@@ -31,11 +34,8 @@
|
|
|
31
34
|
},
|
|
32
35
|
"devDependencies": {
|
|
33
36
|
"@types/node": "^18.11.9",
|
|
34
|
-
"typescript": "^4.
|
|
35
|
-
"histoire": "0.17.
|
|
36
|
-
},
|
|
37
|
-
"peerDependencies": {
|
|
38
|
-
"histoire": "^0.17.16"
|
|
37
|
+
"typescript": "^5.4.4",
|
|
38
|
+
"histoire": "0.17.17"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build": "rimraf dist && tsc -d",
|
package/src/index.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url'
|
|
2
|
+
import { createRequire } from 'node:module'
|
|
1
3
|
import type { Plugin } from 'histoire'
|
|
2
4
|
import { defu } from 'defu'
|
|
3
5
|
import path from 'pathe'
|
|
4
|
-
import {
|
|
5
|
-
import { createRequire } from 'node:module'
|
|
6
|
-
import { isPercyEnabled, fetchPercyDOM, postSnapshot } from '@percy/sdk-utils'
|
|
6
|
+
import { fetchPercyDOM, isPercyEnabled, postSnapshot } from '@percy/sdk-utils'
|
|
7
7
|
import type { JSONObject, Page, WaitForOptions } from 'puppeteer'
|
|
8
8
|
|
|
9
9
|
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
@@ -32,15 +32,15 @@ export interface PercySnapshotOptions {
|
|
|
32
32
|
}>
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
export
|
|
35
|
+
export interface PagePayload {
|
|
36
36
|
file: string
|
|
37
37
|
story: { title: string }
|
|
38
38
|
variant: { id: string, title: string }
|
|
39
|
-
}
|
|
39
|
+
}
|
|
40
40
|
|
|
41
41
|
type ContructorOption<T extends object | number> =
|
|
42
42
|
| T
|
|
43
|
-
| ((payload: PagePayload) => T)
|
|
43
|
+
| ((payload: PagePayload) => T)
|
|
44
44
|
|
|
45
45
|
export interface PercyPluginOptions {
|
|
46
46
|
/**
|
|
@@ -61,9 +61,9 @@ export interface PercyPluginOptions {
|
|
|
61
61
|
* Navigation Parameter
|
|
62
62
|
*/
|
|
63
63
|
pptrOptions?: ContructorOption<
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
WaitForOptions & {
|
|
65
|
+
referer?: string
|
|
66
|
+
}
|
|
67
67
|
>
|
|
68
68
|
|
|
69
69
|
/**
|
|
@@ -85,14 +85,14 @@ const defaultOptions: PercyPluginOptions = {
|
|
|
85
85
|
pptrOptions: {},
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
function resolveOptions<T extends object | number>
|
|
88
|
+
function resolveOptions<T extends object | number>(
|
|
89
89
|
option: ContructorOption<T>,
|
|
90
90
|
payload: PagePayload,
|
|
91
91
|
): T {
|
|
92
92
|
return typeof option === 'function' ? option(payload) : option
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
export function HstPercy
|
|
95
|
+
export function HstPercy(options: PercyPluginOptions = {}): Plugin {
|
|
96
96
|
const finalOptions: PercyPluginOptions = defu(options, defaultOptions)
|
|
97
97
|
return {
|
|
98
98
|
name: '@histoire/plugin-percy',
|
|
@@ -134,7 +134,7 @@ export function HstPercy (options: PercyPluginOptions = {}): Plugin {
|
|
|
134
134
|
const page = await browser.newPage()
|
|
135
135
|
await page.goto(url, pptrOptions)
|
|
136
136
|
|
|
137
|
-
await new Promise(
|
|
137
|
+
await new Promise(resolve => setTimeout(resolve, pptrWait))
|
|
138
138
|
|
|
139
139
|
if (finalOptions.beforeSnapshot) {
|
|
140
140
|
const result = await finalOptions.beforeSnapshot(page, payload)
|
package/tsconfig.json
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
"target": "ESNext",
|
|
4
|
+
// Volar
|
|
5
|
+
"jsx": "preserve",
|
|
6
|
+
"lib": [
|
|
7
|
+
"ESNext",
|
|
8
|
+
"DOM"
|
|
9
|
+
],
|
|
10
|
+
"rootDir": "src",
|
|
4
11
|
"module": "ESNext",
|
|
5
12
|
"moduleResolution": "node",
|
|
6
|
-
"outDir": "dist",
|
|
7
|
-
"rootDir": "src",
|
|
8
|
-
"allowSyntheticDefaultImports": true,
|
|
9
|
-
"esModuleInterop": true,
|
|
10
|
-
"removeComments": false,
|
|
11
13
|
"resolveJsonModule": true,
|
|
12
|
-
"skipLibCheck": true,
|
|
13
14
|
"types": [
|
|
14
15
|
"node"
|
|
15
16
|
],
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
],
|
|
20
|
-
"sourceMap": false,
|
|
21
|
-
"preserveWatchOutput": true,
|
|
17
|
+
"strictBindCallApply": true,
|
|
18
|
+
"strictFunctionTypes": true,
|
|
19
|
+
"alwaysStrict": true,
|
|
22
20
|
// Strict
|
|
23
21
|
"noImplicitAny": false,
|
|
24
22
|
"noImplicitThis": true,
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
"
|
|
23
|
+
"outDir": "dist",
|
|
24
|
+
"removeComments": false,
|
|
25
|
+
"sourceMap": false,
|
|
26
|
+
"allowSyntheticDefaultImports": true,
|
|
27
|
+
"esModuleInterop": true,
|
|
28
|
+
"skipLibCheck": true,
|
|
29
|
+
"preserveWatchOutput": true
|
|
30
30
|
},
|
|
31
31
|
"include": [
|
|
32
32
|
"src"
|