@percy/core 1.3.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/server.js +15 -1
- 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/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/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
|
}
|