@percy/core 1.27.0-alpha.0 → 1.27.0-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/api.js CHANGED
@@ -4,9 +4,7 @@ import { createRequire } from 'module';
4
4
  import logger from '@percy/logger';
5
5
  import { normalize } from '@percy/config/utils';
6
6
  import { getPackageJSON, Server, percyAutomateRequestHandler } from './utils.js';
7
- // TODO Remove below esline disable once we publish webdriver-util
8
- import WebdriverUtils from '@percy/webdriver-utils'; // eslint-disable-line import/no-extraneous-dependencies
9
-
7
+ import WebdriverUtils from '@percy/webdriver-utils';
10
8
  // need require.resolve until import.meta.resolve can be transpiled
11
9
  export const PERCY_DOM = createRequire(import.meta.url).resolve('@percy/dom');
12
10
 
@@ -140,7 +138,7 @@ export function createPercyServer(percy, port) {
140
138
  .route('post', '/percy/flush', async (req, res) => res.json(200, {
141
139
  success: await percy.flush(req.body).then(() => true)
142
140
  })).route('post', '/percy/automateScreenshot', async (req, res) => {
143
- req = percyAutomateRequestHandler(req);
141
+ req = percyAutomateRequestHandler(req, percy.build);
144
142
  res.json(200, {
145
143
  success: await percy.upload(await new WebdriverUtils(req.body).automateScreenshot()).then(() => true)
146
144
  });
package/dist/network.js CHANGED
@@ -9,7 +9,7 @@ const ALLOWED_RESOURCES = ['Document', 'Stylesheet', 'Image', 'Media', 'Font', '
9
9
  // The Interceptor class creates common handlers for dealing with intercepting asset requests
10
10
  // for a given page using various devtools protocol events and commands.
11
11
  export class Network {
12
- static TIMEOUT = 30000;
12
+ static TIMEOUT = undefined;
13
13
  log = logger('core:discovery');
14
14
  #pending = new Map();
15
15
  #requests = new Map();
@@ -25,6 +25,7 @@ export class Network {
25
25
  page.session.browser.version.userAgent.replace('Headless', '');
26
26
  this.intercept = options.intercept;
27
27
  this.meta = options.meta;
28
+ this._initializeNetworkIdleWaitTimeout();
28
29
  }
29
30
  watch(session) {
30
31
  session.on('Network.requestWillBeSent', this._handleRequestWillBeSent);
@@ -262,6 +263,13 @@ export class Network {
262
263
  }
263
264
  this._forgetRequest(request);
264
265
  };
266
+ _initializeNetworkIdleWaitTimeout() {
267
+ if (Network.TIMEOUT) return;
268
+ Network.TIMEOUT = parseInt(process.env.PERCY_NETWORK_IDLE_WAIT_TIMEOUT) || 30000;
269
+ if (Network.TIMEOUT > 60000) {
270
+ this.log.warn('Setting PERCY_NETWORK_IDLE_WAIT_TIMEOUT over 60000ms is not recommended. ' + 'If your page needs more than 60000ms to idle due to CPU/Network load, ' + 'its recommended to increase CI resources where this cli is running.');
271
+ }
272
+ }
265
273
  }
266
274
 
267
275
  // Returns the normalized origin URL of a request
package/dist/page.js CHANGED
@@ -4,7 +4,7 @@ import Network from './network.js';
4
4
  import { PERCY_DOM } from './api.js';
5
5
  import { hostname, waitFor, waitForTimeout as sleep, serializeFunction } from './utils.js';
6
6
  export class Page {
7
- static TIMEOUT = 30000;
7
+ static TIMEOUT = undefined;
8
8
  log = logger('core:page');
9
9
  constructor(session, options) {
10
10
  this.session = session;
@@ -12,6 +12,7 @@ export class Page {
12
12
  this.enableJavaScript = options.enableJavaScript ?? true;
13
13
  this.network = new Network(this, options);
14
14
  this.meta = options.meta;
15
+ this._initializeLoadTimeout();
15
16
  session.on('Runtime.executionContextCreated', this._handleExecutionContextCreated);
16
17
  session.on('Runtime.executionContextDestroyed', this._handleExecutionContextDestroyed);
17
18
  session.on('Runtime.executionContextsCleared', this._handleExecutionContextsCleared);
@@ -241,5 +242,12 @@ export class Page {
241
242
  _handleExecutionContextsCleared = () => {
242
243
  this.contextId = null;
243
244
  };
245
+ _initializeLoadTimeout() {
246
+ if (Page.TIMEOUT) return;
247
+ Page.TIMEOUT = parseInt(process.env.PERCY_PAGE_LOAD_TIMEOUT) || 30000;
248
+ if (Page.TIMEOUT > 60000) {
249
+ this.log.warn('Setting PERCY_PAGE_LOAD_TIMEOUT over 60000ms is not recommended. ' + 'If your page needs more than 60000ms to load due to CPU/Network load, ' + 'its recommended to increase CI resources where this cli is running.');
250
+ }
251
+ }
244
252
  }
245
253
  export default Page;
package/dist/utils.js CHANGED
@@ -20,7 +20,7 @@ export function normalizeURL(url) {
20
20
  }
21
21
 
22
22
  // Returns the body for automateScreenshot in structure
23
- export function percyAutomateRequestHandler(req) {
23
+ export function percyAutomateRequestHandler(req, buildInfo) {
24
24
  if (req.body.client_info) {
25
25
  req.body.clientInfo = req.body.client_info;
26
26
  }
@@ -30,6 +30,7 @@ export function percyAutomateRequestHandler(req) {
30
30
  if (!req.body.options) {
31
31
  req.body.options = {};
32
32
  }
33
+ req.body.buildInfo = buildInfo;
33
34
  return req;
34
35
  }
35
36
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@percy/core",
3
- "version": "1.27.0-alpha.0",
3
+ "version": "1.27.0-beta.0",
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": "alpha"
12
+ "tag": "beta"
13
13
  },
14
14
  "engines": {
15
15
  "node": ">=14"
@@ -24,7 +24,10 @@
24
24
  "types": "./types/index.d.ts",
25
25
  "type": "module",
26
26
  "exports": {
27
- ".": "./dist/index.js",
27
+ ".": {
28
+ "types": "./types/index.d.ts",
29
+ "default": "./dist/index.js"
30
+ },
28
31
  "./utils": "./dist/utils.js",
29
32
  "./config": "./dist/config.js",
30
33
  "./install": "./dist/install.js",
@@ -40,10 +43,11 @@
40
43
  "test:types": "tsd"
41
44
  },
42
45
  "dependencies": {
43
- "@percy/client": "1.27.0-alpha.0",
44
- "@percy/config": "1.27.0-alpha.0",
45
- "@percy/dom": "1.27.0-alpha.0",
46
- "@percy/logger": "1.27.0-alpha.0",
46
+ "@percy/client": "1.27.0-beta.0",
47
+ "@percy/config": "1.27.0-beta.0",
48
+ "@percy/dom": "1.27.0-beta.0",
49
+ "@percy/logger": "1.27.0-beta.0",
50
+ "@percy/webdriver-utils": "1.27.0-beta.0",
47
51
  "content-disposition": "^0.5.4",
48
52
  "cross-spawn": "^7.0.3",
49
53
  "extract-zip": "^2.0.1",
@@ -54,5 +58,5 @@
54
58
  "rimraf": "^3.0.2",
55
59
  "ws": "^8.0.0"
56
60
  },
57
- "gitHead": "16f2c87641d844c6af6c3e198f6aff1c08ee0ec1"
61
+ "gitHead": "2bc16314f51dddcc1cda459e7aa4b7b2db85f00a"
58
62
  }