@percy/core 1.32.6-beta.3 → 1.32.7-beta.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/config.js +9 -0
- package/dist/discovery.js +14 -9
- package/dist/page.js +23 -5
- package/dist/percy.js +26 -12
- package/package.json +9 -9
package/dist/config.js
CHANGED
|
@@ -717,6 +717,15 @@ export const snapshotSchema = {
|
|
|
717
717
|
thTestCaseExecutionId: {
|
|
718
718
|
$ref: '/config/snapshot#/properties/thTestCaseExecutionId'
|
|
719
719
|
},
|
|
720
|
+
// IntelliStory: injected per-snapshot by @percy/storybook so the API can
|
|
721
|
+
// do affected-story selection server-side. `storybookPath` is the
|
|
722
|
+
// project-relative path of the story's source module.
|
|
723
|
+
intelliStory: {
|
|
724
|
+
type: 'boolean'
|
|
725
|
+
},
|
|
726
|
+
storybookPath: {
|
|
727
|
+
type: 'string'
|
|
728
|
+
},
|
|
720
729
|
browsers: {
|
|
721
730
|
$ref: '/config/snapshot#/properties/browsers'
|
|
722
731
|
},
|
package/dist/discovery.js
CHANGED
|
@@ -233,12 +233,18 @@ function processSnapshotResources({
|
|
|
233
233
|
const kept = [];
|
|
234
234
|
for (let index = 0; index < resources.length; index++) {
|
|
235
235
|
const resource = resources[index];
|
|
236
|
+
// Never compress in place: these objects are shared with the resource
|
|
237
|
+
// cache, which must keep replaying the original bytes to the browser.
|
|
238
|
+
let uploaded = resource;
|
|
236
239
|
try {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
240
|
+
/* istanbul ignore else: an already-gzipped resource is very hard to mock */
|
|
241
|
+
if (!isGzipped(resource.content)) {
|
|
242
|
+
const content = Pako.gzip(resource.content);
|
|
243
|
+
uploaded = {
|
|
244
|
+
...resource,
|
|
245
|
+
content,
|
|
246
|
+
sha: sha256hash(content)
|
|
247
|
+
};
|
|
242
248
|
log.debug(`- Gzipped resource: ${resource.url}`);
|
|
243
249
|
}
|
|
244
250
|
} catch (error) {
|
|
@@ -253,9 +259,8 @@ function processSnapshotResources({
|
|
|
253
259
|
continue;
|
|
254
260
|
}
|
|
255
261
|
|
|
256
|
-
//
|
|
257
|
-
|
|
258
|
-
const size = resource.content.length;
|
|
262
|
+
// Either the gzipped copy or, when already gzipped, the resource itself.
|
|
263
|
+
const size = uploaded.content.length;
|
|
259
264
|
// Root (DOM HTML) and log resources are required for a valid snapshot;
|
|
260
265
|
// shipping an oversized one and letting the API surface a clear error
|
|
261
266
|
// is better than silently dropping it here.
|
|
@@ -271,7 +276,7 @@ function processSnapshotResources({
|
|
|
271
276
|
});
|
|
272
277
|
continue;
|
|
273
278
|
}
|
|
274
|
-
kept.push(
|
|
279
|
+
kept.push(uploaded);
|
|
275
280
|
}
|
|
276
281
|
resources = kept;
|
|
277
282
|
}
|
package/dist/page.js
CHANGED
|
@@ -20,22 +20,40 @@ export const DEFAULT_WAIT_FOR_CUSTOM_ELEMENTS_TIMEOUT = 500;
|
|
|
20
20
|
// IMPORTANT: this body is intentionally ES5 — it is evaluated in the
|
|
21
21
|
// page's realm and must work in any browser the page targets. Don't
|
|
22
22
|
// "modernize" with arrow functions, let/const, or optional chaining.
|
|
23
|
+
//
|
|
24
|
+
// serializeFunction() injects the Percy helpers object as `arguments[0]`, so
|
|
25
|
+
// the caller's first argument is `arguments[1]`.
|
|
23
26
|
export const WAIT_FOR_CUSTOM_ELEMENTS_BODY = `
|
|
24
|
-
var
|
|
27
|
+
var timeoutMs = typeof arguments[1] === 'number' && isFinite(arguments[1]) && arguments[1] > 0
|
|
28
|
+
? arguments[1]
|
|
29
|
+
: 500;
|
|
30
|
+
var deadline = Date.now() + timeoutMs;
|
|
25
31
|
return new Promise(function(resolve) {
|
|
32
|
+
var settled = false;
|
|
33
|
+
function finish() {
|
|
34
|
+
if (settled) return;
|
|
35
|
+
settled = true;
|
|
36
|
+
resolve();
|
|
37
|
+
}
|
|
38
|
+
setTimeout(finish, timeoutMs);
|
|
26
39
|
function tick() {
|
|
40
|
+
if (settled) return;
|
|
27
41
|
var undef = document.querySelectorAll(":not(:defined)");
|
|
28
|
-
if (!undef.length) return
|
|
29
|
-
if (Date.now() >= deadline) return
|
|
42
|
+
if (!undef.length) return finish();
|
|
43
|
+
if (Date.now() >= deadline) return finish();
|
|
30
44
|
var names = {};
|
|
31
45
|
for (var i = 0; i < undef.length; i++) names[undef[i].localName] = true;
|
|
32
46
|
var promises = Object.keys(names).map(function(n) {
|
|
33
|
-
|
|
47
|
+
try {
|
|
48
|
+
return window.customElements.whenDefined(n).catch(function(){});
|
|
49
|
+
} catch (e) {
|
|
50
|
+
return Promise.resolve();
|
|
51
|
+
}
|
|
34
52
|
});
|
|
35
53
|
Promise.race([
|
|
36
54
|
Promise.all(promises),
|
|
37
55
|
new Promise(function(r) { setTimeout(r, 100); })
|
|
38
|
-
]).then(tick);
|
|
56
|
+
]).then(tick, finish);
|
|
39
57
|
}
|
|
40
58
|
tick();
|
|
41
59
|
});
|
package/dist/percy.js
CHANGED
|
@@ -157,7 +157,7 @@ export class Percy {
|
|
|
157
157
|
};
|
|
158
158
|
|
|
159
159
|
// generator methods are wrapped to autorun and return promises
|
|
160
|
-
for (let m of ['start', 'stop', 'flush', 'idle', 'snapshot', 'upload', 'replaySnapshot']) {
|
|
160
|
+
for (let m of ['start', 'stop', 'flush', 'idle', 'snapshot', 'upload', 'replaySnapshot', 'startBuild']) {
|
|
161
161
|
// the original generator can be referenced with percy.yield.<method>
|
|
162
162
|
let method = (this.yield || (this.yield = {}))[m] = this[m].bind(this);
|
|
163
163
|
this[m] = (...args) => generatePromise(method(...args));
|
|
@@ -363,6 +363,20 @@ export class Percy {
|
|
|
363
363
|
this._lockHandle = null;
|
|
364
364
|
}
|
|
365
365
|
|
|
366
|
+
// Forces the snapshots queue to start, which creates the Percy build up
|
|
367
|
+
// front and populates `percy.build.id`. Normally, when uploads are delayed
|
|
368
|
+
// or deferred, the build is created lazily on the first flush. IntelliStory
|
|
369
|
+
// needs the real build id before any snapshots are taken so it can enqueue
|
|
370
|
+
// the affected-story graph against it. Safe to call more than once — the
|
|
371
|
+
// queue memoizes its start task, so the build is only created once.
|
|
372
|
+
async *startBuild() {
|
|
373
|
+
var _this$build2, _this$build3;
|
|
374
|
+
if (!this.readyState) return this.build;
|
|
375
|
+
if ((_this$build2 = this.build) !== null && _this$build2 !== void 0 && _this$build2.id || (_this$build3 = this.build) !== null && _this$build3 !== void 0 && _this$build3.error) return this.build;
|
|
376
|
+
yield _classPrivateFieldGet(_snapshots, this).start();
|
|
377
|
+
return this.build;
|
|
378
|
+
}
|
|
379
|
+
|
|
366
380
|
// Resolves once snapshot and upload queues are idle
|
|
367
381
|
async *idle() {
|
|
368
382
|
yield* _classPrivateFieldGet(_discovery, this).idle();
|
|
@@ -490,8 +504,8 @@ export class Percy {
|
|
|
490
504
|
// early if no build is associated, swallows pager rejections — telemetry
|
|
491
505
|
// loss must never fail a build.
|
|
492
506
|
async sendCacheTelemetry(message, extra) {
|
|
493
|
-
var _this$
|
|
494
|
-
if (!((_this$
|
|
507
|
+
var _this$build4;
|
|
508
|
+
if (!((_this$build4 = this.build) !== null && _this$build4 !== void 0 && _this$build4.id)) return;
|
|
495
509
|
try {
|
|
496
510
|
await this.client.sendBuildEvents(this.build.id, {
|
|
497
511
|
message,
|
|
@@ -596,10 +610,10 @@ export class Percy {
|
|
|
596
610
|
// snapshots. Once asset discovery has completed for the provided snapshots, the queued task will
|
|
597
611
|
// resolve and an upload task will be queued separately.
|
|
598
612
|
snapshot(options, snapshotPromise = {}) {
|
|
599
|
-
var _this$
|
|
613
|
+
var _this$build5;
|
|
600
614
|
if (this.readyState !== 1) {
|
|
601
615
|
throw new Error('Not running');
|
|
602
|
-
} else if ((_this$
|
|
616
|
+
} else if ((_this$build5 = this.build) !== null && _this$build5 !== void 0 && _this$build5.error) {
|
|
603
617
|
throw new Error(this.build.error);
|
|
604
618
|
} else if (Array.isArray(options)) {
|
|
605
619
|
return yieldAll(options.map(o => this.yield.snapshot(o, snapshotPromise)));
|
|
@@ -764,10 +778,10 @@ export class Percy {
|
|
|
764
778
|
// Pushes a pre-built snapshot directly to the upload queue without discovery.
|
|
765
779
|
// Used by the replay command to upload previously archived snapshots.
|
|
766
780
|
*replaySnapshot(snapshot) {
|
|
767
|
-
var _this$
|
|
781
|
+
var _this$build6;
|
|
768
782
|
if (this.readyState !== 1) {
|
|
769
783
|
throw new Error('Not running');
|
|
770
|
-
} else if ((_this$
|
|
784
|
+
} else if ((_this$build6 = this.build) !== null && _this$build6 !== void 0 && _this$build6.error) {
|
|
771
785
|
throw new Error(this.build.error);
|
|
772
786
|
}
|
|
773
787
|
snapshot.meta = {
|
|
@@ -859,7 +873,7 @@ export class Percy {
|
|
|
859
873
|
async sendBuildLogs() {
|
|
860
874
|
if (!process.env.PERCY_TOKEN) return;
|
|
861
875
|
try {
|
|
862
|
-
var _this$
|
|
876
|
+
var _this$build7, _this$build8, _this$build9, _this$build10;
|
|
863
877
|
const logsObject = {
|
|
864
878
|
// Redact secrets from CLI logs before egress to the Percy API — these
|
|
865
879
|
// can contain tokens or URLs with embedded credentials (CWE-532). The
|
|
@@ -874,10 +888,10 @@ export class Percy {
|
|
|
874
888
|
logsObject.cilogs = redactedContent;
|
|
875
889
|
}
|
|
876
890
|
const content = base64encode(Pako.gzip(JSON.stringify(logsObject)));
|
|
877
|
-
const referenceId = (_this$
|
|
891
|
+
const referenceId = (_this$build7 = this.build) !== null && _this$build7 !== void 0 && _this$build7.id ? `build_${(_this$build8 = this.build) === null || _this$build8 === void 0 ? void 0 : _this$build8.id}` : (_this$build9 = this.build) === null || _this$build9 === void 0 ? void 0 : _this$build9.id;
|
|
878
892
|
const eventObject = {
|
|
879
893
|
content: content,
|
|
880
|
-
build_id: (_this$
|
|
894
|
+
build_id: (_this$build10 = this.build) === null || _this$build10 === void 0 ? void 0 : _this$build10.id,
|
|
881
895
|
reference_id: referenceId,
|
|
882
896
|
service_name: 'cli',
|
|
883
897
|
base64encoded: true
|
|
@@ -950,9 +964,9 @@ export class Percy {
|
|
|
950
964
|
const newAllowedDomains = Array.from(processedHosts).filter(domain => !autoConfiguredHosts.has(domain));
|
|
951
965
|
const hasNewDomains = newAllowedDomains.length > 0 || newErrorHosts.size > 0;
|
|
952
966
|
try {
|
|
953
|
-
var _this$
|
|
967
|
+
var _this$build11;
|
|
954
968
|
await this.client.updateProjectDomainConfig({
|
|
955
|
-
buildId: (_this$
|
|
969
|
+
buildId: (_this$build11 = this.build) === null || _this$build11 === void 0 ? void 0 : _this$build11.id,
|
|
956
970
|
allowedDomains: Array.from(processedHosts),
|
|
957
971
|
errorDomains: Array.from(newErrorHosts)
|
|
958
972
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@percy/core",
|
|
3
|
-
"version": "1.32.
|
|
3
|
+
"version": "1.32.7-beta.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -46,12 +46,12 @@
|
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@grpc/grpc-js": "^1.14.3",
|
|
48
48
|
"@grpc/proto-loader": "^0.8.0",
|
|
49
|
-
"@percy/client": "1.32.
|
|
50
|
-
"@percy/config": "1.32.
|
|
51
|
-
"@percy/dom": "1.32.
|
|
52
|
-
"@percy/logger": "1.32.
|
|
53
|
-
"@percy/monitoring": "1.32.
|
|
54
|
-
"@percy/webdriver-utils": "1.32.
|
|
49
|
+
"@percy/client": "1.32.7-beta.0",
|
|
50
|
+
"@percy/config": "1.32.7-beta.0",
|
|
51
|
+
"@percy/dom": "1.32.7-beta.0",
|
|
52
|
+
"@percy/logger": "1.32.7-beta.0",
|
|
53
|
+
"@percy/monitoring": "1.32.7-beta.0",
|
|
54
|
+
"@percy/webdriver-utils": "1.32.7-beta.0",
|
|
55
55
|
"adm-zip": "^0.6.0",
|
|
56
56
|
"busboy": "^1.6.0",
|
|
57
57
|
"content-disposition": "^0.5.4",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"yaml": "^2.4.1"
|
|
68
68
|
},
|
|
69
69
|
"optionalDependencies": {
|
|
70
|
-
"@percy/cli-doctor": "1.32.
|
|
70
|
+
"@percy/cli-doctor": "1.32.7-beta.0"
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "f86a18de3e04d3cfa9d14ce5d186ad66c3f8e020"
|
|
73
73
|
}
|