@percy/core 1.6.2 → 1.7.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/percy.js +12 -15
- package/dist/utils.js +5 -2
- package/package.json +6 -6
package/dist/percy.js
CHANGED
|
@@ -69,10 +69,6 @@ export class Percy {
|
|
|
69
69
|
this.#snapshots.concurrency = concurrency;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
if (this.delayUploads) {
|
|
73
|
-
this.#uploads.concurrency = 1;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
72
|
this.client = new PercyClient({
|
|
77
73
|
token,
|
|
78
74
|
clientInfo,
|
|
@@ -162,17 +158,20 @@ export class Percy {
|
|
|
162
158
|
let buildTask = this.#uploads.push('build/create', () => {
|
|
163
159
|
// pause other queued tasks until after the build is created
|
|
164
160
|
this.#uploads.stop();
|
|
161
|
+
this.build = {};
|
|
165
162
|
return this.client.createBuild().then(({
|
|
166
163
|
data: {
|
|
167
164
|
id,
|
|
168
165
|
attributes
|
|
169
166
|
}
|
|
170
167
|
}) => {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
168
|
+
let url = attributes['web-url'];
|
|
169
|
+
let number = attributes['build-number'];
|
|
170
|
+
Object.assign(this.build, {
|
|
171
|
+
id,
|
|
172
|
+
url,
|
|
173
|
+
number
|
|
174
|
+
});
|
|
176
175
|
if (!this.delayUploads) this.#uploads.run();
|
|
177
176
|
});
|
|
178
177
|
}, 0); // handle deferred build errors
|
|
@@ -246,6 +245,7 @@ export class Percy {
|
|
|
246
245
|
if (close) this.#uploads.close(); // prevent creating an empty build when deferred
|
|
247
246
|
|
|
248
247
|
if (!this.deferUploads || !this.#uploads.has('build/create') || this.#uploads.size > 1) {
|
|
248
|
+
if (this.build && !this.build.id) yield* this.#uploads.idle();
|
|
249
249
|
yield* this.#uploads.flush(s => {
|
|
250
250
|
// do not log a count when not closing or while creating a build
|
|
251
251
|
if (!close || this.#uploads.has('build/create')) return;
|
|
@@ -456,15 +456,12 @@ export class Percy {
|
|
|
456
456
|
_scheduleUpload(name, options) {
|
|
457
457
|
var _this$build4;
|
|
458
458
|
|
|
459
|
-
if ((_this$build4 = this.build) !== null && _this$build4 !== void 0 && _this$build4.error)
|
|
460
|
-
throw new Error(this.build.error);
|
|
461
|
-
} // when not dry-running, process any existing delayed uploads
|
|
462
|
-
|
|
459
|
+
if ((_this$build4 = this.build) !== null && _this$build4 !== void 0 && _this$build4.error) throw new Error(this.build.error); // maybe process any existing delayed uploads
|
|
463
460
|
|
|
464
|
-
if (!this.
|
|
461
|
+
if (!this.skipUploads && this.delayUploads && (!this.build || this.build.id)) this.#uploads.run();
|
|
465
462
|
return this.#uploads.push(`upload/${name}`, async () => {
|
|
466
463
|
// when delayed, stop the queue before other uploads are processed
|
|
467
|
-
if (this.delayUploads) this.#uploads.stop();
|
|
464
|
+
if (this.readyState < 2 && this.delayUploads) this.#uploads.stop();
|
|
468
465
|
|
|
469
466
|
try {
|
|
470
467
|
/* istanbul ignore if: useful for other internal packages */
|
package/dist/utils.js
CHANGED
|
@@ -182,11 +182,14 @@ async function scrollToBottom(options, onScroll) {
|
|
|
182
182
|
});
|
|
183
183
|
await ((_onScroll = onScroll) === null || _onScroll === void 0 ? void 0 : _onScroll(i, s));
|
|
184
184
|
}
|
|
185
|
-
} //
|
|
185
|
+
} // Used to test if a string looks like a function
|
|
186
186
|
|
|
187
187
|
|
|
188
|
+
const FUNC_REG = /^(async\s+)?(function\s*)?(\w+\s*)?\(.*?\)\s*(\{|=>)/is; // Serializes the provided function with percy helpers for use in evaluating browser scripts
|
|
189
|
+
|
|
188
190
|
export function serializeFunction(fn) {
|
|
189
|
-
|
|
191
|
+
// stringify or convert a function body into a complete function
|
|
192
|
+
let fnbody = typeof fn === 'string' && !FUNC_REG.test(fn) ? `async function eval() {\n${fn}\n}` : fn.toString(); // we might have a function shorthand if this fails
|
|
190
193
|
|
|
191
194
|
/* eslint-disable-next-line no-new, no-new-func */
|
|
192
195
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@percy/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.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.7.0",
|
|
43
|
+
"@percy/config": "1.7.0",
|
|
44
|
+
"@percy/dom": "1.7.0",
|
|
45
|
+
"@percy/logger": "1.7.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": "f1418fb1effdaad2d32c65d1a358282ab1f9ec32"
|
|
57
57
|
}
|