Socket
Socket
Sign inDemoInstall

@percy/core

Package Overview
Dependencies
Maintainers
1
Versions
233
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.0-beta.0 to 1.29.1-alpha.0

./dist/index.js

80

dist/percy.js

@@ -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';

@@ -32,4 +28,3 @@ import PercyConfig from '@percy/config';

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

@@ -73,14 +68,7 @@ // Static shortcut to create and start an instance in one call

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({

@@ -113,4 +101,4 @@ overrides: _options,

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));

@@ -168,6 +156,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

@@ -188,5 +176,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

@@ -209,4 +197,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();

@@ -230,4 +218,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();
}

@@ -245,9 +233,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));
}

@@ -271,4 +259,4 @@ }

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

@@ -298,4 +286,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));
}

@@ -305,4 +293,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();

@@ -370,3 +358,3 @@ // mark instance as stopped

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

@@ -391,3 +379,3 @@ dryRun: this.dryRun,

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

@@ -452,5 +440,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;

@@ -505,3 +493,3 @@ await this.suggestionsForFix(error.message);

// 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',

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

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) {

@@ -525,3 +513,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');

@@ -565,3 +553,3 @@ }

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

@@ -589,3 +577,3 @@ suggestions.forEach(item => {

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

@@ -592,0 +580,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);
let task = _assertClassBrand(_Queue_brand, this, _find).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 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 ? 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 ? 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,11 +314,11 @@ 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

@@ -358,0 +325,0 @@ let position = (queued ?? 0) + pending;

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;

{
"name": "@percy/core",
"version": "1.29.0-beta.0",
"version": "1.29.1-alpha.0",
"license": "MIT",

@@ -12,3 +12,3 @@ "repository": {

"access": "public",
"tag": "beta"
"tag": "alpha"
},

@@ -47,7 +47,7 @@ "engines": {

"dependencies": {
"@percy/client": "1.29.0-beta.0",
"@percy/config": "1.29.0-beta.0",
"@percy/dom": "1.29.0-beta.0",
"@percy/logger": "1.29.0-beta.0",
"@percy/webdriver-utils": "1.29.0-beta.0",
"@percy/client": "1.29.1-alpha.0",
"@percy/config": "1.29.1-alpha.0",
"@percy/dom": "1.29.1-alpha.0",
"@percy/logger": "1.29.1-alpha.0",
"@percy/webdriver-utils": "1.29.1-alpha.0",
"content-disposition": "^0.5.4",

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

},
"gitHead": "2d62f6ce1e9b7aa1430d186da00a2302884d92b2"
"gitHead": "5044adb5caa7507fdec629eda8f33d6ddde07997"
}
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