Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@percy/core

Package Overview
Dependencies
Maintainers
1
Versions
241
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@percy/core - npm Package Compare versions

Comparing version 1.29.4-beta.5 to 1.29.4-beta.6

6

dist/api.js

@@ -25,3 +25,3 @@ import fs from 'fs';

.route((req, res, next) => {
var _percy$testing, _percy$testing4, _percy$testing4$api, _percy$testing5, _percy$testing5$api;
var _percy$testing, _percy$testing4, _percy$testing5;
// treat all request bodies as json

@@ -52,3 +52,3 @@ if (req.body) try {

// support sabotaging requests in testing mode
if (((_percy$testing4 = percy.testing) === null || _percy$testing4 === void 0 ? void 0 : (_percy$testing4$api = _percy$testing4.api) === null || _percy$testing4$api === void 0 ? void 0 : _percy$testing4$api[req.url.pathname]) === 'error') {
if (((_percy$testing4 = percy.testing) === null || _percy$testing4 === void 0 || (_percy$testing4 = _percy$testing4.api) === null || _percy$testing4 === void 0 ? void 0 : _percy$testing4[req.url.pathname]) === 'error') {
next = () => {

@@ -58,3 +58,3 @@ var _percy$testing$build;

};
} else if (((_percy$testing5 = percy.testing) === null || _percy$testing5 === void 0 ? void 0 : (_percy$testing5$api = _percy$testing5.api) === null || _percy$testing5$api === void 0 ? void 0 : _percy$testing5$api[req.url.pathname]) === 'disconnect') {
} else if (((_percy$testing5 = percy.testing) === null || _percy$testing5 === void 0 || (_percy$testing5 = _percy$testing5.api) === null || _percy$testing5 === void 0 ? void 0 : _percy$testing5[req.url.pathname]) === 'disconnect') {
next = () => req.connection.destroy();

@@ -61,0 +61,0 @@ }

@@ -185,3 +185,3 @@ import fs from 'fs';

// close the socket connection
(_this$ws2 = this.ws) === null || _this$ws2 === void 0 ? void 0 : _this$ws2.close();
(_this$ws2 = this.ws) === null || _this$ws2 === void 0 || _this$ws2.close();

@@ -282,3 +282,3 @@ // wait for the browser to close

this.sessions.delete(data.params.sessionId);
session === null || session === void 0 ? void 0 : session._handleClose();
session === null || session === void 0 || session._handleClose();
}

@@ -288,3 +288,3 @@ if (data.sessionId) {

let session = this.sessions.get(data.sessionId);
session === null || session === void 0 ? void 0 : session._handleMessage(data);
session === null || session === void 0 || session._handleMessage(data);
} else if (data.id && this.#callbacks.has(data.id)) {

@@ -291,0 +291,0 @@ // resolve or reject a pending promise created with #send()

@@ -199,3 +199,3 @@ import logger from '@percy/logger';

} = options;
let cookies = parseCookies(snapshot === null || snapshot === void 0 ? void 0 : (_snapshot$domSnapshot = snapshot.domSnapshot) === null || _snapshot$domSnapshot === void 0 ? void 0 : _snapshot$domSnapshot.cookies);
let cookies = parseCookies(snapshot === null || snapshot === void 0 || (_snapshot$domSnapshot = snapshot.domSnapshot) === null || _snapshot$domSnapshot === void 0 ? void 0 : _snapshot$domSnapshot.cookies);

@@ -202,0 +202,0 @@ // iterate over device to trigger reqeusts and capture other dpr width

@@ -7,9 +7,5 @@ function _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }

function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _classPrivateMethodGet(s, a, r) { return _assertClassBrand(a, s), r; }
function _classPrivateFieldGet2(e, t) { var r = _classPrivateFieldGet(t, e); return _classApplyDescriptorGet(e, r); }
function _classApplyDescriptorGet(e, t) { return t.get ? t.get.call(e) : t.value; }
function _classPrivateFieldSet(e, t, r) { var s = _classPrivateFieldGet(t, e); return _classApplyDescriptorSet(e, s, r), r; }
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
function _classApplyDescriptorSet(e, t, l) { if (t.set) t.set.call(e, l);else { if (!t.writable) throw new TypeError("attempted to set read only private field"); t.value = l; } }
import PercyClient from '@percy/client';

@@ -26,2 +22,3 @@ import PercyConfig from '@percy/config';

import { WaitForJob } from './wait-for-job.js';
const MAX_SUGGESTION_CALLS = 10;

@@ -33,4 +30,3 @@ // A Percy instance will create a new build when started, handle snapshot creation, asset discovery,

var _snapshots = /*#__PURE__*/new WeakMap();
var _displaySuggestionLogs = /*#__PURE__*/new WeakSet();
var _proxyEnabled = /*#__PURE__*/new WeakSet();
var _Percy_brand = /*#__PURE__*/new WeakSet();
export class Percy {

@@ -69,2 +65,3 @@ // Static shortcut to create and start an instance in one call

projectType = null,
suggestionsCallCounter = 0,
// options such as `snapshot` and `discovery` that are valid Percy config

@@ -75,14 +72,7 @@ // options which will become accessible via the `.config` property

var _config$percy, _config$percy2;
_classPrivateMethodInitSpec(this, _proxyEnabled);
_classPrivateMethodInitSpec(this, _displaySuggestionLogs);
_classPrivateMethodInitSpec(this, _Percy_brand);
_defineProperty(this, "log", logger('core'));
_defineProperty(this, "readyState", null);
_classPrivateFieldInitSpec(this, _discovery, {
writable: true,
value: null
});
_classPrivateFieldInitSpec(this, _snapshots, {
writable: true,
value: null
});
_classPrivateFieldInitSpec(this, _discovery, null);
_classPrivateFieldInitSpec(this, _snapshots, null);
let config = PercyConfig.load({

@@ -107,2 +97,3 @@ overrides: _options,

this.labels = labels;
this.suggestionsCallCounter = suggestionsCallCounter;
this.client = new PercyClient({

@@ -117,4 +108,4 @@ token,

this.browser = new Browser(this);
_classPrivateFieldSet(this, _discovery, createDiscoveryQueue(this));
_classPrivateFieldSet(this, _snapshots, createSnapshotsQueue(this));
_classPrivateFieldSet(_discovery, this, createDiscoveryQueue(this));
_classPrivateFieldSet(_snapshots, this, createSnapshotsQueue(this));

@@ -172,6 +163,6 @@ // generator methods are wrapped to autorun and return promises

} = this.config.discovery;
_classPrivateFieldGet2(this, _discovery).set({
_classPrivateFieldGet(_discovery, this).set({
concurrency
});
_classPrivateFieldGet2(this, _snapshots).set({
_classPrivateFieldGet(_snapshots, this).set({
concurrency

@@ -196,5 +187,5 @@ });

// start the snapshots queue immediately when not delayed or deferred
if (!this.delayUploads && !this.deferUploads) yield _classPrivateFieldGet2(this, _snapshots).start();
if (!this.delayUploads && !this.deferUploads) yield _classPrivateFieldGet(_snapshots, this).start();
// do not start the discovery queue when not needed
if (!this.skipDiscovery) yield _classPrivateFieldGet2(this, _discovery).start();
if (!this.skipDiscovery) yield _classPrivateFieldGet(_discovery, this).start();
// start a local API server for SDK communication

@@ -217,4 +208,4 @@ if (this.server) yield this.server.listen();

await ((_this$server2 = this.server) === null || _this$server2 === void 0 ? void 0 : _this$server2.close());
await _classPrivateFieldGet2(this, _discovery).end();
await _classPrivateFieldGet2(this, _snapshots).end();
await _classPrivateFieldGet(_discovery, this).end();
await _classPrivateFieldGet(_snapshots, this).end();

@@ -238,4 +229,4 @@ // mark this instance as closed unless aborting

async *idle() {
yield* _classPrivateFieldGet2(this, _discovery).idle();
yield* _classPrivateFieldGet2(this, _snapshots).idle();
yield* _classPrivateFieldGet(_discovery, this).idle();
yield* _classPrivateFieldGet(_snapshots, this).idle();
}

@@ -253,9 +244,9 @@

// flush and log progress for discovery before snapshots
if (!this.skipDiscovery && _classPrivateFieldGet2(this, _discovery).size) {
if (options) yield* yieldAll(options.map(o => _classPrivateFieldGet2(this, _discovery).process(o)));else yield* _classPrivateFieldGet2(this, _discovery).flush(size => callback === null || callback === void 0 ? void 0 : callback('Processing', size));
if (!this.skipDiscovery && _classPrivateFieldGet(_discovery, this).size) {
if (options) yield* yieldAll(options.map(o => _classPrivateFieldGet(_discovery, this).process(o)));else yield* _classPrivateFieldGet(_discovery, this).flush(size => callback === null || callback === void 0 ? void 0 : callback('Processing', size));
}
// flush and log progress for snapshot uploads
if (!this.skipUploads && _classPrivateFieldGet2(this, _snapshots).size) {
if (options) yield* yieldAll(options.map(o => _classPrivateFieldGet2(this, _snapshots).process(o)));else yield* _classPrivateFieldGet2(this, _snapshots).flush(size => callback === null || callback === void 0 ? void 0 : callback('Uploading', size));
if (!this.skipUploads && _classPrivateFieldGet(_snapshots, this).size) {
if (options) yield* yieldAll(options.map(o => _classPrivateFieldGet(_snapshots, this).process(o)));else yield* _classPrivateFieldGet(_snapshots, this).flush(size => callback === null || callback === void 0 ? void 0 : callback('Uploading', size));
}

@@ -279,4 +270,4 @@ }

if (force) {
_classPrivateFieldGet2(this, _discovery).close(true);
_classPrivateFieldGet2(this, _snapshots).close(true);
_classPrivateFieldGet(_discovery, this).close(true);
_classPrivateFieldGet(_snapshots, this).close(true);
}

@@ -306,4 +297,4 @@

// if dry-running, log the total number of snapshots
if (this.dryRun && _classPrivateFieldGet2(this, _snapshots).size) {
this.log.info(info('Found', _classPrivateFieldGet2(this, _snapshots).size));
if (this.dryRun && _classPrivateFieldGet(_snapshots, this).size) {
this.log.info(info('Found', _classPrivateFieldGet(_snapshots, this).size));
}

@@ -313,4 +304,4 @@

await ((_this$server3 = this.server) === null || _this$server3 === void 0 ? void 0 : _this$server3.close());
await _classPrivateFieldGet2(this, _discovery).end();
await _classPrivateFieldGet2(this, _snapshots).end();
await _classPrivateFieldGet(_discovery, this).end();
await _classPrivateFieldGet(_snapshots, this).end();

@@ -378,3 +369,3 @@ // mark instance as stopped

// gather snapshots and discover snapshot resources
yield* discoverSnapshotResources(_classPrivateFieldGet2(this, _discovery), {
yield* discoverSnapshotResources(_classPrivateFieldGet(_discovery, this), {
skipDiscovery: this.skipDiscovery,

@@ -399,3 +390,3 @@ dryRun: this.dryRun,

// push each finished snapshot to the snapshots queue
_classPrivateFieldGet2(this, _snapshots).push(snapshot);
_classPrivateFieldGet(_snapshots, this).push(snapshot);
});

@@ -460,5 +451,5 @@ } finally {

try {
return yield* yieldTo(_classPrivateFieldGet2(this, _snapshots).push(options));
return yield* yieldTo(_classPrivateFieldGet(_snapshots, this).push(options));
} catch (error) {
_classPrivateFieldGet2(this, _snapshots).cancel(options);
_classPrivateFieldGet(_snapshots, this).cancel(options);
// Detecting and suggesting fix for errors;

@@ -477,5 +468,5 @@ await this.suggestionsForFix(error.message);

syncMode(options) {
var _this$config, _this$config$snapshot;
var _this$config;
let syncMode = false;
if ((_this$config = this.config) !== null && _this$config !== void 0 && (_this$config$snapshot = _this$config.snapshot) !== null && _this$config$snapshot !== void 0 && _this$config$snapshot.sync) syncMode = true;
if ((_this$config = this.config) !== null && _this$config !== void 0 && (_this$config = _this$config.snapshot) !== null && _this$config !== void 0 && _this$config.sync) syncMode = true;
if (options !== null && options !== void 0 && options.sync) syncMode = true;

@@ -505,7 +496,7 @@ if ((options === null || options === void 0 ? void 0 : options.sync) === false) syncMode = false;

var _item$message, _item$message2, _item$message3;
isPercyStarted || (isPercyStarted = item === null || item === void 0 ? void 0 : (_item$message = item.message) === null || _item$message === void 0 ? void 0 : _item$message.includes('Percy has started'));
containsSnapshotTaken || (containsSnapshotTaken = item === null || item === void 0 ? void 0 : (_item$message2 = item.message) === null || _item$message2 === void 0 ? void 0 : _item$message2.includes('Snapshot taken'));
isPercyStarted || (isPercyStarted = item === null || item === void 0 || (_item$message = item.message) === null || _item$message === void 0 ? void 0 : _item$message.includes('Percy has started'));
containsSnapshotTaken || (containsSnapshotTaken = item === null || item === void 0 || (_item$message2 = item.message) === null || _item$message2 === void 0 ? void 0 : _item$message2.includes('Snapshot taken'));
// This case happens when you directly upload it using cli-upload
containsSnapshotTaken || (containsSnapshotTaken = item === null || item === void 0 ? void 0 : (_item$message3 = item.message) === null || _item$message3 === void 0 ? void 0 : _item$message3.includes('Snapshot uploaded'));
containsSnapshotTaken || (containsSnapshotTaken = item === null || item === void 0 || (_item$message3 = item.message) === null || _item$message3 === void 0 ? void 0 : _item$message3.includes('Snapshot uploaded'));
return item;

@@ -515,3 +506,3 @@ });

// This is the case for No snapshot command called
_classPrivateMethodGet(this, _displaySuggestionLogs, _displaySuggestionLogs2).call(this, [{
_assertClassBrand(_Percy_brand, this, _displaySuggestionLogs).call(this, [{
failure_reason: 'Snapshot command was not called',

@@ -526,4 +517,11 @@ reason_message: 'Snapshot Command was not called. please check your CI for errors',

try {
this.suggestionsCallCounter++;
if (this.suggestionsCallCounter > MAX_SUGGESTION_CALLS) {
if (this.suggestionsCallCounter === MAX_SUGGESTION_CALLS + 1) {
this.log.debug('Rate limit exceeded for Maximum allowed suggestions per build.');
}
return;
}
const suggestionResponse = await this.client.getErrorAnalysis(errors);
_classPrivateMethodGet(this, _displaySuggestionLogs, _displaySuggestionLogs2).call(this, suggestionResponse, options);
_assertClassBrand(_Percy_brand, this, _displaySuggestionLogs).call(this, suggestionResponse, options);
} catch (e) {

@@ -535,3 +533,3 @@ // Common error code for Proxy issues

this.log.error('percy.io might not be reachable, check network connection, proxy and ensure that percy.io is whitelisted.');
if (!_classPrivateMethodGet(this, _proxyEnabled, _proxyEnabled2).call(this)) {
if (!_assertClassBrand(_Percy_brand, this, _proxyEnabled).call(this)) {
this.log.error('If inside a proxied envirnment, please configure the following environment variables: HTTP_PROXY, [ and optionally HTTPS_PROXY if you need it ]. Refer to our documentation for more details');

@@ -575,3 +573,3 @@ }

}
function _displaySuggestionLogs2(suggestions, options = {}) {
function _displaySuggestionLogs(suggestions, options = {}) {
if (!(suggestions !== null && suggestions !== void 0 && suggestions.length)) return;

@@ -593,3 +591,3 @@ suggestions.forEach(item => {

this.log.warn('Refer to the below Doc Links for the same');
referenceDocLinks === null || referenceDocLinks === void 0 ? void 0 : referenceDocLinks.forEach(_docLink => {
referenceDocLinks === null || referenceDocLinks === void 0 || referenceDocLinks.forEach(_docLink => {
this.log.warn(`* ${_docLink}`);

@@ -600,3 +598,3 @@ });

}
function _proxyEnabled2() {
function _proxyEnabled() {
return !!(getProxy({

@@ -603,0 +601,0 @@ protocol: 'https:'

@@ -7,9 +7,5 @@ function _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }

function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _classPrivateFieldSet(e, t, r) { var s = _classPrivateFieldGet2(t, e); return _classApplyDescriptorSet(e, s, r), r; }
function _classApplyDescriptorSet(e, t, l) { if (t.set) t.set.call(e, l);else { if (!t.writable) throw new TypeError("attempted to set read only private field"); t.value = l; } }
function _classPrivateMethodGet(s, a, r) { return _assertClassBrand(a, s), r; }
function _classPrivateFieldGet(e, t) { var r = _classPrivateFieldGet2(t, e); return _classApplyDescriptorGet(e, r); }
function _classPrivateFieldGet2(s, a) { return s.get(_assertClassBrand(s, a)); }
function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
function _classApplyDescriptorGet(e, t) { return t.get ? t.get.call(e) : t.value; }
import { yieldFor, generatePromise, AbortController } from './utils.js';

@@ -47,38 +43,21 @@ import logger from '@percy/logger';

var _pending = /*#__PURE__*/new WeakMap();
var _dequeue = /*#__PURE__*/new WeakSet();
var _find = /*#__PURE__*/new WeakSet();
var _Queue_brand = /*#__PURE__*/new WeakSet();
var _start = /*#__PURE__*/new WeakMap();
var _end = /*#__PURE__*/new WeakMap();
var _process = /*#__PURE__*/new WeakSet();
var _until = /*#__PURE__*/new WeakSet();
export class Queue {
// item concurrency
constructor(name) {
_classPrivateMethodInitSpec(this, _until);
_classPrivateMethodInitSpec(this, _process);
_classPrivateMethodInitSpec(this, _find);
_classPrivateMethodInitSpec(this, _dequeue);
// Maybe processes the next queued item task.
_classPrivateMethodInitSpec(this, _Queue_brand);
// item concurrency
_defineProperty(this, "concurrency", 10);
_defineProperty(this, "log", logger('core:queue'));
_classPrivateFieldInitSpec(this, _handlers, {
writable: true,
value: {}
});
_classPrivateFieldInitSpec(this, _queued, {
writable: true,
value: new Set()
});
_classPrivateFieldInitSpec(this, _pending, {
writable: true,
value: new Set()
});
_classPrivateFieldInitSpec(this, _start, {
writable: true,
value: null
});
_classPrivateFieldInitSpec(this, _end, {
writable: true,
value: null
});
// Configure queue handlers
_classPrivateFieldInitSpec(this, _handlers, {});
// internal queues
_classPrivateFieldInitSpec(this, _queued, new Set());
_classPrivateFieldInitSpec(this, _pending, new Set());
// keep track of start and end tasks
_classPrivateFieldInitSpec(this, _start, null);
_classPrivateFieldInitSpec(this, _end, null);
// represents various queue states such as ready, running, or closed
_defineProperty(this, "readyState", 0);

@@ -95,15 +74,9 @@ this.name = name;

}
// Configure queue handlers
handle(event, handler) {
_classPrivateFieldGet(this, _handlers)[event] = handler;
_classPrivateFieldGet(_handlers, this)[event] = handler;
return this;
}
// internal queues
// Queue size is total queued and pending items
get size() {
return _classPrivateFieldGet(this, _queued).size + _classPrivateFieldGet(this, _pending).size;
return _classPrivateFieldGet(_queued, this).size + _classPrivateFieldGet(_pending, this).size;
}

@@ -119,4 +92,4 @@

task.deferred = task.deferred.catch(e => {
if (!_classPrivateFieldGet(this, _handlers).error) throw e;
return _classPrivateFieldGet(this, _handlers).error(item, e);
if (!_classPrivateFieldGet(_handlers, this).error) throw e;
return _classPrivateFieldGet(_handlers, this).error(item, e);
});

@@ -139,8 +112,8 @@

}
task.item = item = _classPrivateFieldGet(this, _handlers).push ? _classPrivateFieldGet(this, _handlers).push(item, exists) : item;
task.handler = () => _classPrivateFieldGet(this, _handlers).task ? _classPrivateFieldGet(this, _handlers).task(item, ...args) : item;
task.item = item = _classPrivateFieldGet(_handlers, this).push ? _classPrivateFieldGet(_handlers, this).push(item, exists) : item;
task.handler = () => _classPrivateFieldGet(_handlers, this).task ? _classPrivateFieldGet(_handlers, this).task(item, ...args) : item;
// queue this task & maybe dequeue the next task
_classPrivateFieldGet(this, _queued).add(task);
_classPrivateMethodGet(this, _dequeue, _dequeue2).call(this);
_classPrivateFieldGet(_queued, this).add(task);
_assertClassBrand(_Queue_brand, this, _dequeue).call(this);

@@ -150,11 +123,8 @@ // return the deferred task promise

}
// Maybe processes the next queued item task.
// Cancels and aborts a specific item task.
cancel(item) {
let task = _classPrivateMethodGet(this, _find, _find2).call(this, item);
task === null || task === void 0 ? void 0 : task.ctrl.abort();
let queued = _classPrivateFieldGet(this, _queued).delete(task);
let pending = _classPrivateFieldGet(this, _pending).delete(task);
let task = _assertClassBrand(_Queue_brand, this, _find).call(this, item);
task === null || task === void 0 || task.ctrl.abort();
let queued = _classPrivateFieldGet(_queued, this).delete(task);
let pending = _classPrivateFieldGet(_pending, this).delete(task);

@@ -172,13 +142,12 @@ // reject queued tasks that are not pending

// keep track of start and end tasks
// Initialize a starting task or return an existing one.
start() {
var _classPrivateFieldGet3;
_classPrivateFieldGet(this, _start) ?? _classPrivateFieldSet(this, _start, deferred({
var _classPrivateFieldGet2;
_classPrivateFieldGet(_start, this) ?? _classPrivateFieldSet(_start, this, deferred({
readyState: 1
}));
(_classPrivateFieldGet3 = _classPrivateFieldGet(this, _start)).handler ?? (_classPrivateFieldGet3.handler = _classPrivateFieldGet(this, _end) // wait for any ending task to complete first
? () => _classPrivateFieldGet(this, _end).promise.then(_classPrivateFieldGet(this, _handlers).start) : _classPrivateFieldGet(this, _handlers).start);
return _classPrivateMethodGet(this, _process, _process2).call(this, _classPrivateFieldGet(this, _start)).deferred;
(_classPrivateFieldGet2 = _classPrivateFieldGet(_start, this)).handler ?? (_classPrivateFieldGet2.handler = _classPrivateFieldGet(_end, this)
// wait for any ending task to complete first
? () => _classPrivateFieldGet(_end, this).promise.then(_classPrivateFieldGet(_handlers, this).start) : _classPrivateFieldGet(_handlers, this).start);
return _assertClassBrand(_Queue_brand, this, _process).call(this, _classPrivateFieldGet(_start, this)).deferred;
}

@@ -188,20 +157,18 @@

end() {
var _classPrivateFieldGet4;
_classPrivateFieldGet(this, _end) ?? _classPrivateFieldSet(this, _end, deferred({
var _classPrivateFieldGet3;
_classPrivateFieldGet(_end, this) ?? _classPrivateFieldSet(_end, this, deferred({
readyState: 0
}));
(_classPrivateFieldGet4 = _classPrivateFieldGet(this, _end)).handler ?? (_classPrivateFieldGet4.handler = _classPrivateFieldGet(this, _start) // wait for any starting task to complete first
? () => _classPrivateFieldGet(this, _start).promise.then(_classPrivateFieldGet(this, _handlers).end) : _classPrivateFieldGet(this, _handlers).end);
return _classPrivateMethodGet(this, _process, _process2).call(this, _classPrivateFieldGet(this, _end)).deferred;
(_classPrivateFieldGet3 = _classPrivateFieldGet(_end, this)).handler ?? (_classPrivateFieldGet3.handler = _classPrivateFieldGet(_start, this)
// wait for any starting task to complete first
? () => _classPrivateFieldGet(_start, this).promise.then(_classPrivateFieldGet(_handlers, this).end) : _classPrivateFieldGet(_handlers, this).end);
return _assertClassBrand(_Queue_brand, this, _process).call(this, _classPrivateFieldGet(_end, this)).deferred;
}
// represents various queue states such as ready, running, or closed
// run the queue, starting it if necessary, and start dequeuing tasks
run() {
if (!_classPrivateFieldGet(this, _start)) this.start();
if (!_classPrivateFieldGet(_start, this)) this.start();
// when starting, state is updated afterwards
if (this.readyState === 0) _classPrivateFieldGet(this, _start).readyState = 2;
if (this.readyState === 0) _classPrivateFieldGet(_start, this).readyState = 2;
if (this.readyState === 1) this.readyState = 2;
while (_classPrivateMethodGet(this, _dequeue, _dequeue2).call(this)) _classPrivateMethodGet(this, _dequeue, _dequeue2).call(this);
while (_assertClassBrand(_Queue_brand, this, _dequeue).call(this)) _assertClassBrand(_Queue_brand, this, _dequeue).call(this);
return this;

@@ -218,5 +185,5 @@ }

close(abort) {
var _classPrivateFieldGet5;
var _classPrivateFieldGet4;
// when starting, state is updated afterwards
if ((_classPrivateFieldGet5 = _classPrivateFieldGet(this, _start)) !== null && _classPrivateFieldGet5 !== void 0 && _classPrivateFieldGet5.pending) _classPrivateFieldGet(this, _start).readyState = 3;
if ((_classPrivateFieldGet4 = _classPrivateFieldGet(_start, this)) !== null && _classPrivateFieldGet4 !== void 0 && _classPrivateFieldGet4.pending) _classPrivateFieldGet(_start, this).readyState = 3;
if (this.readyState < 3) this.readyState = 3;

@@ -229,5 +196,5 @@ if (abort) this.clear();

clear() {
let tasks = [..._classPrivateFieldGet(this, _queued)];
this.log.debug(`Clearing ${this.name} queue, queued state: ${_classPrivateFieldGet(this, _queued).size}, pending state: ${_classPrivateFieldGet(this, _pending).size}`);
_classPrivateFieldGet(this, _queued).clear();
let tasks = [..._classPrivateFieldGet(_queued, this)];
this.log.debug(`Clearing ${this.name} queue, queued state: ${_classPrivateFieldGet(_queued, this).size}, pending state: ${_classPrivateFieldGet(_pending, this).size}`);
_classPrivateFieldGet(_queued, this).clear();
for (let task of tasks) {

@@ -241,6 +208,6 @@ task.ctrl.abort();

process(item) {
var _classPrivateFieldGet6;
let task = _classPrivateMethodGet(this, _find, _find2).call(this, item);
if (task && !_classPrivateFieldGet(this, _start)) this.start();
(_classPrivateFieldGet6 = _classPrivateFieldGet(this, _start)) === null || _classPrivateFieldGet6 === void 0 ? void 0 : _classPrivateFieldGet6.promise.then(() => _classPrivateMethodGet(this, _process, _process2).call(this, task));
var _classPrivateFieldGet5;
let task = _assertClassBrand(_Queue_brand, this, _find).call(this, item);
if (task && !_classPrivateFieldGet(_start, this)) this.start();
(_classPrivateFieldGet5 = _classPrivateFieldGet(_start, this)) === null || _classPrivateFieldGet5 === void 0 || _classPrivateFieldGet5.promise.then(() => _assertClassBrand(_Queue_brand, this, _process).call(this, task));
return task === null || task === void 0 ? void 0 : task.deferred;

@@ -255,6 +222,6 @@ }

return yieldFor(() => {
var _classPrivateFieldGet7;
callback === null || callback === void 0 ? void 0 : callback(_classPrivateFieldGet(this, _pending).size);
let starting = ((_classPrivateFieldGet7 = _classPrivateFieldGet(this, _start)) === null || _classPrivateFieldGet7 === void 0 ? void 0 : _classPrivateFieldGet7.pending) === true;
return !starting && !_classPrivateFieldGet(this, _pending).size;
var _classPrivateFieldGet6;
callback === null || callback === void 0 || callback(_classPrivateFieldGet(_pending, this).size);
let starting = ((_classPrivateFieldGet6 = _classPrivateFieldGet(_start, this)) === null || _classPrivateFieldGet6 === void 0 ? void 0 : _classPrivateFieldGet6.pending) === true;
return !starting && !_classPrivateFieldGet(_pending, this).size;
}, {

@@ -268,9 +235,9 @@ idle: 10

flush(callback) {
this.log.debug(`Flushing ${this.name} queue, queued state: ${_classPrivateFieldGet(this, _queued).size}, pending state: ${_classPrivateFieldGet(this, _pending).size}`);
this.log.debug(`Flushing ${this.name} queue, queued state: ${_classPrivateFieldGet(_queued, this).size}, pending state: ${_classPrivateFieldGet(_pending, this).size}`);
let interrupt =
// check for existing interrupts
[..._classPrivateFieldGet(this, _pending)].find(t => t.stop) ?? [..._classPrivateFieldGet(this, _queued)].find(t => t.stop);
[..._classPrivateFieldGet(_pending, this)].find(t => t.stop) ?? [..._classPrivateFieldGet(_queued, this)].find(t => t.stop);
// get the latest queued or pending task to track
let flush = [..._classPrivateFieldGet(this, _queued)].pop() ?? [..._classPrivateFieldGet(this, _pending)].pop();
let flush = [..._classPrivateFieldGet(_queued, this)].pop() ?? [..._classPrivateFieldGet(_pending, this)].pop();
// determine if the queue should be stopped after flushing

@@ -281,3 +248,3 @@ if (flush) flush.stop = (interrupt === null || interrupt === void 0 ? void 0 : interrupt.stop) ?? this.readyState < 2;

// start the queue if not started
if (!_classPrivateFieldGet(this, _start)) this.start();
if (!_classPrivateFieldGet(_start, this)) this.start();
// run the queue if stopped

@@ -287,3 +254,3 @@ if (flush !== null && flush !== void 0 && flush.stop) this.run();

// will yield with the callback until done flushing
return _classPrivateMethodGet(this, _until, _until2).call(this, flush, callback);
return _assertClassBrand(_Queue_brand, this, _until).call(this, flush, callback);
}

@@ -293,14 +260,14 @@

}
function _dequeue2() {
if (!_classPrivateFieldGet(this, _queued).size || this.readyState < 2) return;
if (_classPrivateFieldGet(this, _pending).size >= this.concurrency) return;
let [task] = _classPrivateFieldGet(this, _queued);
return _classPrivateMethodGet(this, _process, _process2).call(this, task);
function _dequeue() {
if (!_classPrivateFieldGet(_queued, this).size || this.readyState < 2) return;
if (_classPrivateFieldGet(_pending, this).size >= this.concurrency) return;
let [task] = _classPrivateFieldGet(_queued, this);
return _assertClassBrand(_Queue_brand, this, _process).call(this, task);
}
function _find2(subject) {
let find = _classPrivateFieldGet(this, _handlers).find
function _find(subject) {
let find = _classPrivateFieldGet(_handlers, this).find
// use any configured find handler to match items
? ({
item
}) => _classPrivateFieldGet(this, _handlers).find(subject, item) : ({
}) => _classPrivateFieldGet(_handlers, this).find(subject, item) : ({
item

@@ -310,15 +277,15 @@ }) => subject === item;

// look at queued then pending items
[..._classPrivateFieldGet(this, _queued)].find(find) ?? [..._classPrivateFieldGet(this, _pending)].find(find)
[..._classPrivateFieldGet(_queued, this)].find(find) ?? [..._classPrivateFieldGet(_pending, this)].find(find)
);
}
function _process2(task) {
function _process(task) {
var _task$ctrl;
if (!task || task.promise) return task;
let queued = _classPrivateFieldGet(this, _queued).has(task);
let queued = _classPrivateFieldGet(_queued, this).has(task);
// remove queued tasks from the queue
if (queued) _classPrivateFieldGet(this, _queued).delete(task);
if (queued) _classPrivateFieldGet(_queued, this).delete(task);
// clear queued tasks when ending
if (task === _classPrivateFieldGet(this, _end)) this.clear();
if (task === _classPrivateFieldGet(_end, this)) this.clear();
// add queued tasks to pending queue
if (queued) _classPrivateFieldGet(this, _pending).add(task);
if (queued) _classPrivateFieldGet(_pending, this).add(task);
// stop the queue when necessary

@@ -332,7 +299,7 @@ if (task.stop) this.stop();

// clean up pending tasks that have not been aborted
if (queued && !task.ctrl.signal.aborted) _classPrivateFieldGet(this, _pending).delete(task);
if (queued && !task.ctrl.signal.aborted) _classPrivateFieldGet(_pending, this).delete(task);
// update queue state when necessary
if (task.readyState != null) this.readyState = task.readyState;
// clean up internal tasks after ending
if (!this.readyState) _classPrivateFieldSet(this, _start, _classPrivateFieldSet(this, _end, null));
if (!this.readyState) _classPrivateFieldSet(_start, this, _classPrivateFieldSet(_end, this, null));
// resolve or reject the deferred task promise

@@ -347,14 +314,14 @@ task[err ? 'reject' : 'resolve'](err ?? val);

}
async function* _until2(task, callback) {
async function* _until(task, callback) {
try {
yield* yieldFor(() => {
var _classPrivateFieldGet8;
if ((_classPrivateFieldGet8 = _classPrivateFieldGet(this, _start)) !== null && _classPrivateFieldGet8 !== void 0 && _classPrivateFieldGet8.pending) return false;
var _classPrivateFieldGet7;
if ((_classPrivateFieldGet7 = _classPrivateFieldGet(_start, this)) !== null && _classPrivateFieldGet7 !== void 0 && _classPrivateFieldGet7.pending) return false;
let queued,
pending = _classPrivateFieldGet(this, _pending).size;
pending = _classPrivateFieldGet(_pending, this).size;
// calculate the position within queued when not pending
if (task && task.pending == null) queued = positionOf(_classPrivateFieldGet(this, _queued), task);
if (task && task.pending == null) queued = positionOf(_classPrivateFieldGet(_queued, this), task);
// call the callback and return true when not queued or pending
let position = (queued ?? 0) + pending;
callback === null || callback === void 0 ? void 0 : callback(position);
callback === null || callback === void 0 || callback(position);
return !position;

@@ -361,0 +328,0 @@ }, {

function _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }
function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
function _classPrivateFieldGet2(e, t) { var r = _classPrivateFieldGet(t, e); return _classApplyDescriptorGet(e, r); }
function _classApplyDescriptorGet(e, t) { return t.get ? t.get.call(e) : t.value; }
function _classPrivateMethodGet(s, a, r) { return _assertClassBrand(a, s), r; }
function _classPrivateFieldSet(e, t, r) { var s = _classPrivateFieldGet(t, e); return _classApplyDescriptorSet(e, s, r), r; }
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
function _classApplyDescriptorSet(e, t, l) { if (t.set) t.set.call(e, l);else { if (!t.writable) throw new TypeError("attempted to set read only private field"); t.value = l; } }
import fs from 'fs';

@@ -106,4 +102,3 @@ import path from 'path';

var _routes = /*#__PURE__*/new WeakMap();
var _route = /*#__PURE__*/new WeakSet();
var _handleRequest = /*#__PURE__*/new WeakSet();
var _Server_brand = /*#__PURE__*/new WeakSet();
export class Server extends http.Server {

@@ -117,44 +112,36 @@ constructor({

});
_classPrivateMethodInitSpec(this, _handleRequest);
_classPrivateMethodInitSpec(this, _route);
_classPrivateFieldInitSpec(this, _sockets, {
writable: true,
value: new Set()
});
_classPrivateFieldInitSpec(this, _defaultPort, {
writable: true,
value: void 0
});
_classPrivateFieldInitSpec(this, _routes, {
writable: true,
value: [{
priority: -1,
handle: (req, res, next) => {
res.setHeader('Access-Control-Allow-Origin', '*');
if (req.method === 'OPTIONS') {
let allowHeaders = req.headers['access-control-request-headers'] || '*';
let allowMethods = [...new Set(_classPrivateFieldGet2(this, _routes).flatMap(route => (!route.match || route.match(req.url.pathname)) && route.methods || []))].join(', ');
res.setHeader('Access-Control-Allow-Headers', allowHeaders);
res.setHeader('Access-Control-Allow-Methods', allowMethods);
res.writeHead(204).end();
} else {
res.setHeader('Access-Control-Expose-Headers', '*');
return next();
}
// adds a route in the correct priority order
_classPrivateMethodInitSpec(this, _Server_brand);
_classPrivateFieldInitSpec(this, _sockets, new Set());
_classPrivateFieldInitSpec(this, _defaultPort, void 0);
// initial routes include cors and 404 handling
_classPrivateFieldInitSpec(this, _routes, [{
priority: -1,
handle: (req, res, next) => {
res.setHeader('Access-Control-Allow-Origin', '*');
if (req.method === 'OPTIONS') {
let allowHeaders = req.headers['access-control-request-headers'] || '*';
let allowMethods = [...new Set(_classPrivateFieldGet(_routes, this).flatMap(route => (!route.match || route.match(req.url.pathname)) && route.methods || []))].join(', ');
res.setHeader('Access-Control-Allow-Headers', allowHeaders);
res.setHeader('Access-Control-Allow-Methods', allowMethods);
res.writeHead(204).end();
} else {
res.setHeader('Access-Control-Expose-Headers', '*');
return next();
}
}, {
priority: 3,
handle: req => ServerError.throw(404)
}]
});
_classPrivateFieldSet(this, _defaultPort, port);
}
}, {
priority: 3,
handle: req => ServerError.throw(404)
}]);
_classPrivateFieldSet(_defaultPort, this, port);
// handle requests on end
this.on('request', (req, res) => {
req.on('end', () => _classPrivateMethodGet(this, _handleRequest, _handleRequest2).call(this, req, res));
req.on('end', () => _assertClassBrand(_Server_brand, this, _handleRequest).call(this, req, res));
});
// track open connections to terminate when the server closes
this.on('connection', socket => {
let handleClose = () => _classPrivateFieldGet2(this, _sockets).delete(socket);
_classPrivateFieldGet2(this, _sockets).add(socket.on('close', handleClose));
let handleClose = () => _classPrivateFieldGet(_sockets, this).delete(socket);
_classPrivateFieldGet(_sockets, this).add(socket.on('close', handleClose));
});

@@ -171,3 +158,3 @@ }

var _super$address;
return ((_super$address = super.address()) === null || _super$address === void 0 ? void 0 : _super$address.port) ?? _classPrivateFieldGet2(this, _defaultPort);
return ((_super$address = super.address()) === null || _super$address === void 0 ? void 0 : _super$address.port) ?? _classPrivateFieldGet(_defaultPort, this);
}

@@ -187,3 +174,3 @@

// return a promise that resolves when the server is listening
listen(port = _classPrivateFieldGet2(this, _defaultPort)) {
listen(port = _classPrivateFieldGet(_defaultPort, this)) {
return new Promise((resolve, reject) => {

@@ -199,11 +186,6 @@ let handle = err => off() && err ? reject(err) : resolve(this);

return new Promise(resolve => {
_classPrivateFieldGet2(this, _sockets).forEach(socket => socket.destroy());
_classPrivateFieldGet(_sockets, this).forEach(socket => socket.destroy());
super.close(resolve);
});
}
// initial routes include cors and 404 handling
// adds a route in the correct priority order
// set request routing and handling for pathnames and methods

@@ -214,3 +196,3 @@ route(method, pathname, handle) {

if (arguments.length === 2 && !Array.isArray(method) && method[0] === '/') [pathname, method] = [method];
return _classPrivateMethodGet(this, _route, _route2).call(this, {
return _assertClassBrand(_Server_brand, this, _route).call(this, {
priority: !pathname ? 0 : !method ? 1 : 2,

@@ -242,3 +224,3 @@ methods: method && [].concat(method).map(m => m.toUpperCase()),

});
return _classPrivateMethodGet(this, _route, _route2).call(this, {
return _assertClassBrand(_Server_brand, this, _route).call(this, {
priority: 2,

@@ -267,8 +249,8 @@ methods: ['GET'],

// create a url rewriter from provided rewrite rules
function _route2(route) {
let i = _classPrivateFieldGet2(this, _routes).findIndex(r => r.priority >= route.priority);
_classPrivateFieldGet2(this, _routes).splice(i, 0, route);
function _route(route) {
let i = _classPrivateFieldGet(_routes, this).findIndex(r => r.priority >= route.priority);
_classPrivateFieldGet(_routes, this).splice(i, 0, route);
return this;
}
async function _handleRequest2(req, res) {
async function _handleRequest(req, res) {
// support node < 15.7.0

@@ -289,3 +271,3 @@ res.req ?? (res.req = req);

return result ? handle(req, res, next) : next();
}(_classPrivateFieldGet2(this, _routes));
}(_classPrivateFieldGet(_routes, this));
} catch (error) {

@@ -292,0 +274,0 @@ var _req$headers$accept, _req$headers$content;

@@ -19,3 +19,3 @@ import EventEmitter from 'events';

this.parent = browser.sessions.get(parentId);
(_this$parent = this.parent) === null || _this$parent === void 0 ? void 0 : _this$parent.children.set(this.sessionId, this);
(_this$parent = this.parent) === null || _this$parent === void 0 || _this$parent.children.set(this.sessionId, this);
this.on('Inspector.targetCrashed', this._handleTargetCrashed);

@@ -83,3 +83,3 @@ }

this.#callbacks.clear();
(_this$parent2 = this.parent) === null || _this$parent2 === void 0 ? void 0 : _this$parent2.children.delete(this.sessionId);
(_this$parent2 = this.parent) === null || _this$parent2 === void 0 || _this$parent2.children.delete(this.sessionId);
this.browser = null;

@@ -86,0 +86,0 @@ }

@@ -479,3 +479,3 @@ import logger from '@percy/logger';

.handle('error', async (snapshot, error) => {
var _error$response, _error$response2, _error$response2$body;
var _error$response, _error$response2;
let result = {

@@ -500,3 +500,3 @@ ...snapshot,

}
let errors = (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : (_error$response2$body = _error$response2.body) === null || _error$response2$body === void 0 ? void 0 : _error$response2$body.errors;
let errors = (_error$response2 = error.response) === null || _error$response2 === void 0 || (_error$response2 = _error$response2.body) === null || _error$response2 === void 0 ? void 0 : _error$response2.errors;
let duplicate = (errors === null || errors === void 0 ? void 0 : errors.length) > 1 && errors[1].detail.includes('must be unique');

@@ -503,0 +503,0 @@ if (duplicate) {

{
"name": "@percy/core",
"version": "1.29.4-beta.5",
"version": "1.29.4-beta.6",
"license": "MIT",

@@ -46,7 +46,7 @@ "repository": {

"dependencies": {
"@percy/client": "1.29.4-beta.5",
"@percy/config": "1.29.4-beta.5",
"@percy/dom": "1.29.4-beta.5",
"@percy/logger": "1.29.4-beta.5",
"@percy/webdriver-utils": "1.29.4-beta.5",
"@percy/client": "1.29.4-beta.6",
"@percy/config": "1.29.4-beta.6",
"@percy/dom": "1.29.4-beta.6",
"@percy/logger": "1.29.4-beta.6",
"@percy/webdriver-utils": "1.29.4-beta.6",
"content-disposition": "^0.5.4",

@@ -56,3 +56,3 @@ "cross-spawn": "^7.0.3",

"fast-glob": "^3.2.11",
"micromatch": "^4.0.6",
"micromatch": "^4.0.8",
"mime-types": "^2.1.34",

@@ -65,3 +65,3 @@ "pako": "^2.1.0",

},
"gitHead": "aa585ef0d0cea47653ca7e64e6e2928f0a0ab2c9"
"gitHead": "7c33f03c17960885dbc29107add843d1851aa789"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc