@percy/core 1.2.1 → 1.4.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/dist/api.js +6 -11
- package/dist/browser.js +2 -1
- package/dist/config.js +6 -0
- package/dist/server.js +15 -1
- package/dist/snapshot.js +1 -0
- package/dist/utils.js +2 -1
- package/package.json +6 -6
package/dist/api.js
CHANGED
|
@@ -2,14 +2,13 @@ import fs from 'fs';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { createRequire } from 'module';
|
|
4
4
|
import logger from '@percy/logger';
|
|
5
|
-
import { getPackageJSON } from './utils.js';
|
|
6
|
-
import Server from './server.js'; // need require.resolve until import.meta.resolve can be transpiled
|
|
5
|
+
import { getPackageJSON, Server } from './utils.js'; // need require.resolve until import.meta.resolve can be transpiled
|
|
7
6
|
|
|
8
7
|
export const PERCY_DOM = createRequire(import.meta.url).resolve('@percy/dom'); // Create a Percy CLI API server instance
|
|
9
8
|
|
|
10
9
|
export function createPercyServer(percy, port) {
|
|
11
10
|
let pkg = getPackageJSON(import.meta.url);
|
|
12
|
-
return
|
|
11
|
+
return Server.createServer({
|
|
13
12
|
port
|
|
14
13
|
}) // facilitate logger websocket connections
|
|
15
14
|
.websocket('/(logger)?', ws => {
|
|
@@ -83,14 +82,10 @@ export function createPercyServer(percy, port) {
|
|
|
83
82
|
|
|
84
83
|
export function createStaticServer(options) {
|
|
85
84
|
let {
|
|
86
|
-
serve,
|
|
87
|
-
|
|
88
|
-
baseUrl = '/',
|
|
89
|
-
...opts
|
|
85
|
+
serve: dir,
|
|
86
|
+
baseUrl = '/'
|
|
90
87
|
} = options;
|
|
91
|
-
let server =
|
|
92
|
-
port
|
|
93
|
-
}).serve(baseUrl, serve, opts); // used when generating an automatic sitemap
|
|
88
|
+
let server = Server.createServer(options); // used when generating an automatic sitemap
|
|
94
89
|
|
|
95
90
|
let toURL = Server.createRewriter( // reverse rewrites' src, dest, & order
|
|
96
91
|
Object.entries((options === null || options === void 0 ? void 0 : options.rewrites) ?? {}).reduce((acc, rw) => [rw.reverse(), ...acc], []), (filename, rewrite) => new URL(path.posix.join(baseUrl, // cleanUrls will trim trailing .html/index.html from paths
|
|
@@ -101,7 +96,7 @@ export function createStaticServer(options) {
|
|
|
101
96
|
default: glob
|
|
102
97
|
} = await import('fast-glob');
|
|
103
98
|
let files = await glob('**/*.html', {
|
|
104
|
-
cwd:
|
|
99
|
+
cwd: dir,
|
|
105
100
|
fs
|
|
106
101
|
});
|
|
107
102
|
return res.send(200, 'application/xml', ['<?xml version="1.0" encoding="UTF-8"?>', '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">', ...files.map(name => ` <url><loc>${toURL(name)}</loc></url>`), '</urlset>'].join('\n'));
|
package/dist/browser.js
CHANGED
|
@@ -58,7 +58,8 @@ export class Browser extends EventEmitter {
|
|
|
58
58
|
headless = true,
|
|
59
59
|
args = [],
|
|
60
60
|
timeout
|
|
61
|
-
} = launchOptions;
|
|
61
|
+
} = launchOptions;
|
|
62
|
+
executable ?? (executable = process.env.PERCY_BROWSER_EXECUTABLE); // transform cookies object to an array of cookie params
|
|
62
63
|
|
|
63
64
|
this.cookies = Array.isArray(cookies) ? cookies : Object.entries(cookies).map(([name, value]) => ({
|
|
64
65
|
name,
|
package/dist/config.js
CHANGED
|
@@ -25,6 +25,9 @@ export const configSchema = {
|
|
|
25
25
|
},
|
|
26
26
|
enableJavaScript: {
|
|
27
27
|
type: 'boolean'
|
|
28
|
+
},
|
|
29
|
+
scope: {
|
|
30
|
+
type: 'string'
|
|
28
31
|
}
|
|
29
32
|
}
|
|
30
33
|
},
|
|
@@ -162,6 +165,9 @@ export const snapshotSchema = {
|
|
|
162
165
|
widths: {
|
|
163
166
|
$ref: '/config/snapshot#/properties/widths'
|
|
164
167
|
},
|
|
168
|
+
scope: {
|
|
169
|
+
$ref: '/config/snapshot#/properties/scope'
|
|
170
|
+
},
|
|
165
171
|
minHeight: {
|
|
166
172
|
$ref: '/config/snapshot#/properties/minHeight'
|
|
167
173
|
},
|
package/dist/server.js
CHANGED
|
@@ -422,9 +422,23 @@ function parseByteRange(range, size) {
|
|
|
422
422
|
start,
|
|
423
423
|
end
|
|
424
424
|
};
|
|
425
|
-
} //
|
|
425
|
+
} // shorthand function for creating a new server with specific options
|
|
426
426
|
|
|
427
427
|
|
|
428
|
+
export function createServer(options = {}) {
|
|
429
|
+
let {
|
|
430
|
+
serve,
|
|
431
|
+
port,
|
|
432
|
+
baseUrl = '/',
|
|
433
|
+
...opts
|
|
434
|
+
} = options;
|
|
435
|
+
let server = new Server({
|
|
436
|
+
port
|
|
437
|
+
});
|
|
438
|
+
return serve ? server.serve(baseUrl, serve, opts) : server;
|
|
439
|
+
} // include some exports as static properties
|
|
440
|
+
|
|
428
441
|
Server.Error = ServerError;
|
|
429
442
|
Server.createRewriter = createRewriter;
|
|
443
|
+
Server.createServer = createServer;
|
|
430
444
|
export default Server;
|
package/dist/snapshot.js
CHANGED
|
@@ -256,6 +256,7 @@ function debugSnapshotConfig(snapshot, showInfo) {
|
|
|
256
256
|
};
|
|
257
257
|
|
|
258
258
|
debugProp(snapshot, 'url');
|
|
259
|
+
debugProp(snapshot, 'scope');
|
|
259
260
|
debugProp(snapshot, 'widths', v => `${v}px`);
|
|
260
261
|
debugProp(snapshot, 'minHeight', v => `${v}px`);
|
|
261
262
|
debugProp(snapshot, 'enableJavaScript');
|
package/dist/utils.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import EventEmitter from 'events';
|
|
2
2
|
import { sha256hash } from '@percy/client/utils';
|
|
3
|
-
export { request, getPackageJSON, hostnameMatches } from '@percy/client/utils';
|
|
3
|
+
export { request, getPackageJSON, hostnameMatches } from '@percy/client/utils';
|
|
4
|
+
export { Server, createServer } from './server.js'; // Returns the hostname portion of a URL.
|
|
4
5
|
|
|
5
6
|
export function hostname(url) {
|
|
6
7
|
return new URL(url).hostname;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@percy/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
"test:types": "tsd"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@percy/client": "1.
|
|
43
|
-
"@percy/config": "1.
|
|
44
|
-
"@percy/dom": "1.
|
|
45
|
-
"@percy/logger": "1.
|
|
42
|
+
"@percy/client": "1.4.0",
|
|
43
|
+
"@percy/config": "1.4.0",
|
|
44
|
+
"@percy/dom": "1.4.0",
|
|
45
|
+
"@percy/logger": "1.4.0",
|
|
46
46
|
"content-disposition": "^0.5.4",
|
|
47
47
|
"cross-spawn": "^7.0.3",
|
|
48
48
|
"extract-zip": "^2.0.1",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"rimraf": "^3.0.2",
|
|
54
54
|
"ws": "^8.0.0"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "341362f3cf526db57412414aa3a9743c1a014fe1"
|
|
57
57
|
}
|