@percy/core 1.28.1-alpha.3 → 1.28.1-beta.1
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/config.js +0 -4
- package/dist/discovery.js +31 -41
- package/dist/network.js +1 -10
- package/dist/queue.js +1 -7
- package/dist/utils.js +0 -23
- package/package.json +8 -8
package/dist/config.js
CHANGED
package/dist/discovery.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import logger from '@percy/logger';
|
|
2
2
|
import Queue from './queue.js';
|
|
3
|
-
import { normalizeURL, hostnameMatches, createResource, createRootResource, createPercyCSSResource, createLogResource, yieldAll, snapshotLogName
|
|
3
|
+
import { normalizeURL, hostnameMatches, createResource, createRootResource, createPercyCSSResource, createLogResource, yieldAll, snapshotLogName } from './utils.js';
|
|
4
4
|
|
|
5
5
|
// Logs verbose debug logs detailing various snapshot options.
|
|
6
6
|
function debugSnapshotOptions(snapshot) {
|
|
@@ -279,8 +279,7 @@ export const RESOURCE_CACHE_KEY = Symbol('resource-cache');
|
|
|
279
279
|
// snapshot which is used to intercept and capture snapshot resource requests.
|
|
280
280
|
export function createDiscoveryQueue(percy) {
|
|
281
281
|
let {
|
|
282
|
-
concurrency
|
|
283
|
-
retry
|
|
282
|
+
concurrency
|
|
284
283
|
} = percy.config.discovery;
|
|
285
284
|
let queue = new Queue('discovery');
|
|
286
285
|
let cache;
|
|
@@ -319,48 +318,39 @@ export function createDiscoveryQueue(percy) {
|
|
|
319
318
|
/* istanbul ignore next: tested, but coverage is stripped */
|
|
320
319
|
let assetDiscoveryPageEnableJS = snapshot.cliEnableJavaScript && !snapshot.domSnapshot || (snapshot.enableJavaScript ?? !snapshot.domSnapshot);
|
|
321
320
|
percy.log.debug(`Asset discovery Browser Page enable JS: ${assetDiscoveryPageEnableJS}`);
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
cache.set(r.url, r);
|
|
343
|
-
}
|
|
321
|
+
// create a new browser page
|
|
322
|
+
let page = yield percy.browser.page({
|
|
323
|
+
enableJavaScript: assetDiscoveryPageEnableJS,
|
|
324
|
+
networkIdleTimeout: snapshot.discovery.networkIdleTimeout,
|
|
325
|
+
requestHeaders: snapshot.discovery.requestHeaders,
|
|
326
|
+
authorization: snapshot.discovery.authorization,
|
|
327
|
+
userAgent: snapshot.discovery.userAgent,
|
|
328
|
+
captureMockedServiceWorker: snapshot.discovery.captureMockedServiceWorker,
|
|
329
|
+
meta: snapshot.meta,
|
|
330
|
+
// enable network inteception
|
|
331
|
+
intercept: {
|
|
332
|
+
enableJavaScript: snapshot.enableJavaScript,
|
|
333
|
+
disableCache: snapshot.discovery.disableCache,
|
|
334
|
+
allowedHostnames: snapshot.discovery.allowedHostnames,
|
|
335
|
+
disallowedHostnames: snapshot.discovery.disallowedHostnames,
|
|
336
|
+
getResource: u => snapshot.resources.get(u) || cache.get(u),
|
|
337
|
+
saveResource: r => {
|
|
338
|
+
snapshot.resources.set(r.url, r);
|
|
339
|
+
if (!r.root) {
|
|
340
|
+
cache.set(r.url, r);
|
|
344
341
|
}
|
|
345
342
|
}
|
|
346
|
-
});
|
|
347
|
-
try {
|
|
348
|
-
yield* captureSnapshotResources(page, snapshot, {
|
|
349
|
-
captureWidths: !snapshot.domSnapshot && percy.deferUploads,
|
|
350
|
-
capture: callback
|
|
351
|
-
});
|
|
352
|
-
} finally {
|
|
353
|
-
// always close the page when done
|
|
354
|
-
await page.close();
|
|
355
343
|
}
|
|
356
|
-
}, {
|
|
357
|
-
count: retry ? 3 : 1,
|
|
358
|
-
onRetry: () => {
|
|
359
|
-
percy.log.info(`Retrying snapshot: ${snapshotLogName(snapshot.name, snapshot.meta)}`, snapshot.meta);
|
|
360
|
-
},
|
|
361
|
-
signal: snapshot._ctrl.signal,
|
|
362
|
-
throwOn: ['AbortError']
|
|
363
344
|
});
|
|
345
|
+
try {
|
|
346
|
+
yield* captureSnapshotResources(page, snapshot, {
|
|
347
|
+
captureWidths: !snapshot.domSnapshot && percy.deferUploads,
|
|
348
|
+
capture: callback
|
|
349
|
+
});
|
|
350
|
+
} finally {
|
|
351
|
+
// always close the page when done
|
|
352
|
+
await page.close();
|
|
353
|
+
}
|
|
364
354
|
}).handle('error', ({
|
|
365
355
|
name,
|
|
366
356
|
meta
|
package/dist/network.js
CHANGED
|
@@ -28,7 +28,6 @@ export class Network {
|
|
|
28
28
|
#requests = new Map();
|
|
29
29
|
#authentications = new Set();
|
|
30
30
|
#aborted = new Set();
|
|
31
|
-
#finishedUrls = new Set();
|
|
32
31
|
constructor(page, options) {
|
|
33
32
|
this.page = page;
|
|
34
33
|
this.timeout = options.networkIdleTimeout ?? 100;
|
|
@@ -79,12 +78,6 @@ export class Network {
|
|
|
79
78
|
throw new Error(`Network error: ${this.page.session.closedReason}`);
|
|
80
79
|
}
|
|
81
80
|
requests = Array.from(this.#requests.values()).filter(filter);
|
|
82
|
-
// remove requests which are finished at least once
|
|
83
|
-
// this happens when same request is made multiple times by browser in parallel and one of
|
|
84
|
-
// them gets stuck in pending state in browser [ need to debug why ]. So we dont receive
|
|
85
|
-
// loadingFinished event, causing it to show up in Active requests, but we can only store one
|
|
86
|
-
// response per url so as long as we have captured one, we dont care about other such requests
|
|
87
|
-
requests = requests.filter(req => !this.#finishedUrls.has(req.url));
|
|
88
81
|
return requests.length === 0;
|
|
89
82
|
}, {
|
|
90
83
|
timeout: Network.TIMEOUT,
|
|
@@ -127,12 +120,10 @@ export class Network {
|
|
|
127
120
|
// Called when a request should be removed from various trackers
|
|
128
121
|
_forgetRequest({
|
|
129
122
|
requestId,
|
|
130
|
-
interceptId
|
|
131
|
-
url
|
|
123
|
+
interceptId
|
|
132
124
|
}, keepPending) {
|
|
133
125
|
this.#requests.delete(requestId);
|
|
134
126
|
this.#authentications.delete(interceptId);
|
|
135
|
-
this.#finishedUrls.add(url);
|
|
136
127
|
if (!keepPending) {
|
|
137
128
|
this.#pending.delete(requestId);
|
|
138
129
|
}
|
package/dist/queue.js
CHANGED
|
@@ -122,15 +122,9 @@ export class Queue {
|
|
|
122
122
|
|
|
123
123
|
// call or set up other handlers
|
|
124
124
|
let exists = this.cancel(item);
|
|
125
|
-
task.ctrl = new AbortController();
|
|
126
|
-
// duplicate abortion controller on task, so it can can be used in further
|
|
127
|
-
// generators and can be cancelled internally
|
|
128
|
-
// TODO fix this for non object item usecase
|
|
129
|
-
if (typeof item === 'object' && !Array.isArray(item) && item !== null) {
|
|
130
|
-
item._ctrl = task.ctrl;
|
|
131
|
-
}
|
|
132
125
|
task.item = item = _classPrivateFieldGet(this, _handlers).push ? _classPrivateFieldGet(this, _handlers).push(item, exists) : item;
|
|
133
126
|
task.handler = () => _classPrivateFieldGet(this, _handlers).task ? _classPrivateFieldGet(this, _handlers).task(item, ...args) : item;
|
|
127
|
+
task.ctrl = new AbortController();
|
|
134
128
|
|
|
135
129
|
// queue this task & maybe dequeue the next task
|
|
136
130
|
_classPrivateFieldGet(this, _queued).add(task);
|
package/dist/utils.js
CHANGED
|
@@ -328,29 +328,6 @@ export function serializeFunction(fn) {
|
|
|
328
328
|
}
|
|
329
329
|
return fnbody;
|
|
330
330
|
}
|
|
331
|
-
export async function withRetries(fn, {
|
|
332
|
-
count,
|
|
333
|
-
onRetry,
|
|
334
|
-
signal,
|
|
335
|
-
throwOn
|
|
336
|
-
}) {
|
|
337
|
-
count || (count = 1); // default a single try
|
|
338
|
-
let run = 0;
|
|
339
|
-
while (true) {
|
|
340
|
-
run += 1;
|
|
341
|
-
try {
|
|
342
|
-
return await generatePromise(fn, signal);
|
|
343
|
-
} catch (e) {
|
|
344
|
-
// if this error should not be retried on, we want to skip errors
|
|
345
|
-
let throwError = throwOn === null || throwOn === void 0 ? void 0 : throwOn.includes(e.name);
|
|
346
|
-
if (!throwError && run < count) {
|
|
347
|
-
await (onRetry === null || onRetry === void 0 ? void 0 : onRetry());
|
|
348
|
-
continue;
|
|
349
|
-
}
|
|
350
|
-
throw e;
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
331
|
export function snapshotLogName(name, meta) {
|
|
355
332
|
var _meta$snapshot;
|
|
356
333
|
if (meta !== null && meta !== void 0 && (_meta$snapshot = meta.snapshot) !== null && _meta$snapshot !== void 0 && _meta$snapshot.testCase) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@percy/core",
|
|
3
|
-
"version": "1.28.1-
|
|
3
|
+
"version": "1.28.1-beta.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"publishConfig": {
|
|
11
11
|
"access": "public",
|
|
12
|
-
"tag": "
|
|
12
|
+
"tag": "beta"
|
|
13
13
|
},
|
|
14
14
|
"engines": {
|
|
15
15
|
"node": ">=14"
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
"test:types": "tsd"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@percy/client": "1.28.1-
|
|
47
|
-
"@percy/config": "1.28.1-
|
|
48
|
-
"@percy/dom": "1.28.1-
|
|
49
|
-
"@percy/logger": "1.28.1-
|
|
50
|
-
"@percy/webdriver-utils": "1.28.1-
|
|
46
|
+
"@percy/client": "1.28.1-beta.1",
|
|
47
|
+
"@percy/config": "1.28.1-beta.1",
|
|
48
|
+
"@percy/dom": "1.28.1-beta.1",
|
|
49
|
+
"@percy/logger": "1.28.1-beta.1",
|
|
50
|
+
"@percy/webdriver-utils": "1.28.1-beta.1",
|
|
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": "d423bf3f6b26eaba752470121cafb2ad03317b4d"
|
|
62
62
|
}
|