@percy/core 1.27.4-beta.1 → 1.27.4-beta.3
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/api.js +10 -1
- package/dist/config.js +18 -0
- package/dist/discovery.js +9 -0
- package/dist/page.js +4 -2
- package/dist/utils.js +34 -0
- package/package.json +7 -7
- package/types/index.d.ts +3 -0
package/dist/api.js
CHANGED
|
@@ -3,7 +3,7 @@ import path from 'path';
|
|
|
3
3
|
import { createRequire } from 'module';
|
|
4
4
|
import logger from '@percy/logger';
|
|
5
5
|
import { normalize } from '@percy/config/utils';
|
|
6
|
-
import { getPackageJSON, Server, percyAutomateRequestHandler } from './utils.js';
|
|
6
|
+
import { getPackageJSON, Server, percyAutomateRequestHandler, percyBuildEventHandler } from './utils.js';
|
|
7
7
|
import WebdriverUtils from '@percy/webdriver-utils';
|
|
8
8
|
// need require.resolve until import.meta.resolve can be transpiled
|
|
9
9
|
export const PERCY_DOM = createRequire(import.meta.url).resolve('@percy/dom');
|
|
@@ -144,6 +144,15 @@ export function createPercyServer(percy, port) {
|
|
|
144
144
|
success: true
|
|
145
145
|
});
|
|
146
146
|
})
|
|
147
|
+
// Recieves events from sdk's.
|
|
148
|
+
.route('post', '/percy/events', async (req, res) => {
|
|
149
|
+
var _percy$build2;
|
|
150
|
+
const body = percyBuildEventHandler(req, pkg.version);
|
|
151
|
+
await percy.client.sendBuildEvents((_percy$build2 = percy.build) === null || _percy$build2 === void 0 ? void 0 : _percy$build2.id, body);
|
|
152
|
+
res.json(200, {
|
|
153
|
+
success: true
|
|
154
|
+
});
|
|
155
|
+
})
|
|
147
156
|
// stops percy at the end of the current event loop
|
|
148
157
|
.route('/percy/stop', (req, res) => {
|
|
149
158
|
setImmediate(() => percy.stop());
|
package/dist/config.js
CHANGED
|
@@ -47,9 +47,15 @@ export const configSchema = {
|
|
|
47
47
|
type: 'boolean',
|
|
48
48
|
default: false
|
|
49
49
|
},
|
|
50
|
+
enableLayout: {
|
|
51
|
+
type: 'boolean'
|
|
52
|
+
},
|
|
50
53
|
domTransformation: {
|
|
51
54
|
type: 'string'
|
|
52
55
|
},
|
|
56
|
+
reshuffleInvalidTags: {
|
|
57
|
+
type: 'boolean'
|
|
58
|
+
},
|
|
53
59
|
scope: {
|
|
54
60
|
type: 'string'
|
|
55
61
|
},
|
|
@@ -280,6 +286,12 @@ export const snapshotSchema = {
|
|
|
280
286
|
domTransformation: {
|
|
281
287
|
$ref: '/config/snapshot#/properties/domTransformation'
|
|
282
288
|
},
|
|
289
|
+
enableLayout: {
|
|
290
|
+
$ref: '/config/snapshot#/properties/enableLayout'
|
|
291
|
+
},
|
|
292
|
+
reshuffleInvalidTags: {
|
|
293
|
+
$ref: '/config/snapshot#/properties/reshuffleInvalidTags'
|
|
294
|
+
},
|
|
283
295
|
discovery: {
|
|
284
296
|
type: 'object',
|
|
285
297
|
additionalProperties: false,
|
|
@@ -524,6 +536,12 @@ export const snapshotSchema = {
|
|
|
524
536
|
}
|
|
525
537
|
}
|
|
526
538
|
}
|
|
539
|
+
},
|
|
540
|
+
hints: {
|
|
541
|
+
type: 'array',
|
|
542
|
+
items: {
|
|
543
|
+
type: 'string'
|
|
544
|
+
}
|
|
527
545
|
}
|
|
528
546
|
}
|
|
529
547
|
}]
|
package/dist/discovery.js
CHANGED
|
@@ -26,6 +26,9 @@ function debugSnapshotOptions(snapshot) {
|
|
|
26
26
|
debugProp(snapshot, 'enableJavaScript');
|
|
27
27
|
debugProp(snapshot, 'cliEnableJavaScript');
|
|
28
28
|
debugProp(snapshot, 'disableShadowDOM');
|
|
29
|
+
debugProp(snapshot, 'enableLayout');
|
|
30
|
+
debugProp(snapshot, 'domTransformation');
|
|
31
|
+
debugProp(snapshot, 'reshuffleInvalidTags');
|
|
29
32
|
debugProp(snapshot, 'deviceScaleFactor');
|
|
30
33
|
debugProp(snapshot, 'waitForTimeout');
|
|
31
34
|
debugProp(snapshot, 'waitForSelector');
|
|
@@ -101,6 +104,7 @@ function processSnapshotResources({
|
|
|
101
104
|
...snapshot
|
|
102
105
|
}) {
|
|
103
106
|
var _resources;
|
|
107
|
+
let log = logger('core:snapshot');
|
|
104
108
|
resources = [...(((_resources = resources) === null || _resources === void 0 ? void 0 : _resources.values()) ?? [])];
|
|
105
109
|
|
|
106
110
|
// find any root resource matching the provided dom snapshot
|
|
@@ -119,6 +123,11 @@ function processSnapshotResources({
|
|
|
119
123
|
|
|
120
124
|
// inject Percy CSS
|
|
121
125
|
if (snapshot.percyCSS) {
|
|
126
|
+
// check @percy/dom/serialize-dom.js
|
|
127
|
+
let domSnapshotHints = (domSnapshot === null || domSnapshot === void 0 ? void 0 : domSnapshot.hints) ?? [];
|
|
128
|
+
if (domSnapshotHints.includes('DOM elements found outside </body>')) {
|
|
129
|
+
log.warn('DOM elements found outside </body>, percyCSS might not work');
|
|
130
|
+
}
|
|
122
131
|
let css = createPercyCSSResource(root.url, snapshot.percyCSS);
|
|
123
132
|
resources.push(css);
|
|
124
133
|
|
package/dist/page.js
CHANGED
|
@@ -146,7 +146,8 @@ export class Page {
|
|
|
146
146
|
width,
|
|
147
147
|
enableJavaScript,
|
|
148
148
|
disableShadowDOM,
|
|
149
|
-
domTransformation
|
|
149
|
+
domTransformation,
|
|
150
|
+
reshuffleInvalidTags
|
|
150
151
|
} = snapshot;
|
|
151
152
|
this.log.debug(`Taking snapshot: ${name}${width ? ` @${width}px` : ''}`, this.meta);
|
|
152
153
|
|
|
@@ -191,7 +192,8 @@ export class Page {
|
|
|
191
192
|
}), {
|
|
192
193
|
enableJavaScript,
|
|
193
194
|
disableShadowDOM,
|
|
194
|
-
domTransformation
|
|
195
|
+
domTransformation,
|
|
196
|
+
reshuffleInvalidTags
|
|
195
197
|
});
|
|
196
198
|
return {
|
|
197
199
|
...snapshot,
|
package/dist/utils.js
CHANGED
|
@@ -55,6 +55,40 @@ export function percyAutomateRequestHandler(req, percy) {
|
|
|
55
55
|
req.body.buildInfo = percy.build;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
// Returns the body for sendEvent structure
|
|
59
|
+
export function percyBuildEventHandler(req, cliVersion) {
|
|
60
|
+
if (Array.isArray(req.body)) {
|
|
61
|
+
return req.body.map(item => processSendEventData(item, cliVersion));
|
|
62
|
+
} else {
|
|
63
|
+
// Treat the input as an object and perform instructions
|
|
64
|
+
return processSendEventData(req.body, cliVersion);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Process sendEvent object
|
|
69
|
+
function processSendEventData(input, cliVersion) {
|
|
70
|
+
// Add Properties here to send to eventData
|
|
71
|
+
const allowedEventProperties = ['message', 'cliVersion', 'clientInfo', 'errorKind', 'extra'];
|
|
72
|
+
const extractedData = {};
|
|
73
|
+
for (const property of allowedEventProperties) {
|
|
74
|
+
if (Object.prototype.hasOwnProperty.call(input, property)) {
|
|
75
|
+
extractedData[property] = input[property];
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (extractedData.clientInfo) {
|
|
79
|
+
const [client, clientVersion] = extractedData.clientInfo.split('/');
|
|
80
|
+
|
|
81
|
+
// Add the client and clientVersion fields to the object
|
|
82
|
+
extractedData.client = client;
|
|
83
|
+
extractedData.clientVersion = clientVersion;
|
|
84
|
+
delete extractedData.clientInfo;
|
|
85
|
+
}
|
|
86
|
+
if (!input.cliVersion) {
|
|
87
|
+
extractedData.cliVersion = cliVersion;
|
|
88
|
+
}
|
|
89
|
+
return extractedData;
|
|
90
|
+
}
|
|
91
|
+
|
|
58
92
|
// Creates a local resource object containing the resource URL, mimetype, content, sha, and any
|
|
59
93
|
// other additional resources attributes.
|
|
60
94
|
export function createResource(url, content, mimetype, attrs) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@percy/core",
|
|
3
|
-
"version": "1.27.4-beta.
|
|
3
|
+
"version": "1.27.4-beta.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
"test:types": "tsd"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@percy/client": "1.27.4-beta.
|
|
47
|
-
"@percy/config": "1.27.4-beta.
|
|
48
|
-
"@percy/dom": "1.27.4-beta.
|
|
49
|
-
"@percy/logger": "1.27.4-beta.
|
|
50
|
-
"@percy/webdriver-utils": "1.27.4-beta.
|
|
46
|
+
"@percy/client": "1.27.4-beta.3",
|
|
47
|
+
"@percy/config": "1.27.4-beta.3",
|
|
48
|
+
"@percy/dom": "1.27.4-beta.3",
|
|
49
|
+
"@percy/logger": "1.27.4-beta.3",
|
|
50
|
+
"@percy/webdriver-utils": "1.27.4-beta.3",
|
|
51
51
|
"content-disposition": "^0.5.4",
|
|
52
52
|
"cross-spawn": "^7.0.3",
|
|
53
53
|
"extract-zip": "^2.0.1",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"rimraf": "^3.0.2",
|
|
59
59
|
"ws": "^8.0.0"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "e560f5df1637d30722f8d1d7e6eae9cf99ede2dd"
|
|
62
62
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -39,6 +39,9 @@ interface CommonSnapshotOptions {
|
|
|
39
39
|
percyCSS?: string;
|
|
40
40
|
enableJavaScript?: boolean;
|
|
41
41
|
disableShadowDOM?: boolean;
|
|
42
|
+
enableLayout?: boolean;
|
|
43
|
+
domTransformation?: string;
|
|
44
|
+
reshuffleInvalidTags?: boolean;
|
|
42
45
|
devicePixelRatio?: number;
|
|
43
46
|
scope?: string;
|
|
44
47
|
}
|