mirror of
https://github.com/crazy-max/ghaction-upx.git
synced 2025-12-11 07:20:42 -07:00
Update node_modules
This commit is contained in:
27
node_modules/jest-worker/build/Farm.d.ts
generated
vendored
Normal file
27
node_modules/jest-worker/build/Farm.d.ts
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import { FarmOptions } from './types';
|
||||
export default class Farm {
|
||||
private _computeWorkerKey;
|
||||
private _cacheKeys;
|
||||
private _callback;
|
||||
private _last;
|
||||
private _locks;
|
||||
private _numOfWorkers;
|
||||
private _offset;
|
||||
private _queue;
|
||||
constructor(numOfWorkers: number, callback: Function, computeWorkerKey?: FarmOptions['computeWorkerKey']);
|
||||
doWork(method: string, ...args: Array<any>): Promise<unknown>;
|
||||
private _getNextTask;
|
||||
private _process;
|
||||
private _enqueue;
|
||||
private _push;
|
||||
private _lock;
|
||||
private _unlock;
|
||||
private _isLocked;
|
||||
}
|
||||
//# sourceMappingURL=Farm.d.ts.map
|
||||
1
node_modules/jest-worker/build/Farm.d.ts.map
generated
vendored
Normal file
1
node_modules/jest-worker/build/Farm.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Farm.d.ts","sourceRoot":"","sources":["../src/Farm.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAGL,WAAW,EAMZ,MAAM,SAAS,CAAC;AAEjB,MAAM,CAAC,OAAO,OAAO,IAAI;IACvB,OAAO,CAAC,iBAAiB,CAAkC;IAC3D,OAAO,CAAC,UAAU,CAAkC;IACpD,OAAO,CAAC,SAAS,CAAW;IAC5B,OAAO,CAAC,KAAK,CAAmB;IAChC,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAA0B;gBAGtC,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,QAAQ,EAClB,gBAAgB,CAAC,EAAE,WAAW,CAAC,kBAAkB,CAAC;IAepD,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IAqC7D,OAAO,CAAC,YAAY;IAYpB,OAAO,CAAC,QAAQ;IA0BhB,OAAO,CAAC,QAAQ;IAmBhB,OAAO,CAAC,KAAK;IAUb,OAAO,CAAC,KAAK;IAIb,OAAO,CAAC,OAAO;IAIf,OAAO,CAAC,SAAS;CAGlB"}
|
||||
179
node_modules/jest-worker/build/Farm.js
generated
vendored
Normal file
179
node_modules/jest-worker/build/Farm.js
generated
vendored
Normal file
@@ -0,0 +1,179 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _types = require('./types');
|
||||
|
||||
function _defineProperty(obj, key, value) {
|
||||
if (key in obj) {
|
||||
Object.defineProperty(obj, key, {
|
||||
value: value,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
} else {
|
||||
obj[key] = value;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
class Farm {
|
||||
constructor(numOfWorkers, callback, computeWorkerKey) {
|
||||
_defineProperty(this, '_computeWorkerKey', void 0);
|
||||
|
||||
_defineProperty(this, '_cacheKeys', void 0);
|
||||
|
||||
_defineProperty(this, '_callback', void 0);
|
||||
|
||||
_defineProperty(this, '_last', void 0);
|
||||
|
||||
_defineProperty(this, '_locks', void 0);
|
||||
|
||||
_defineProperty(this, '_numOfWorkers', void 0);
|
||||
|
||||
_defineProperty(this, '_offset', void 0);
|
||||
|
||||
_defineProperty(this, '_queue', void 0);
|
||||
|
||||
this._cacheKeys = Object.create(null);
|
||||
this._callback = callback;
|
||||
this._last = [];
|
||||
this._locks = [];
|
||||
this._numOfWorkers = numOfWorkers;
|
||||
this._offset = 0;
|
||||
this._queue = [];
|
||||
|
||||
if (computeWorkerKey) {
|
||||
this._computeWorkerKey = computeWorkerKey;
|
||||
}
|
||||
}
|
||||
|
||||
doWork(method, ...args) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const computeWorkerKey = this._computeWorkerKey;
|
||||
const request = [_types.CHILD_MESSAGE_CALL, false, method, args];
|
||||
let worker = null;
|
||||
let hash = null;
|
||||
|
||||
if (computeWorkerKey) {
|
||||
hash = computeWorkerKey.call(this, method, ...args);
|
||||
worker = hash == null ? null : this._cacheKeys[hash];
|
||||
}
|
||||
|
||||
const onStart = worker => {
|
||||
if (hash != null) {
|
||||
this._cacheKeys[hash] = worker;
|
||||
}
|
||||
};
|
||||
|
||||
const onEnd = (error, result) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else {
|
||||
resolve(result);
|
||||
}
|
||||
};
|
||||
|
||||
const task = {
|
||||
onEnd,
|
||||
onStart,
|
||||
request
|
||||
};
|
||||
|
||||
if (worker) {
|
||||
this._enqueue(task, worker.getWorkerId());
|
||||
} else {
|
||||
this._push(task);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
_getNextTask(workerId) {
|
||||
let queueHead = this._queue[workerId];
|
||||
|
||||
while (queueHead && queueHead.task.request[1]) {
|
||||
queueHead = queueHead.next || null;
|
||||
}
|
||||
|
||||
this._queue[workerId] = queueHead;
|
||||
return queueHead && queueHead.task;
|
||||
}
|
||||
|
||||
_process(workerId) {
|
||||
if (this._isLocked(workerId)) {
|
||||
return this;
|
||||
}
|
||||
|
||||
const task = this._getNextTask(workerId);
|
||||
|
||||
if (!task) {
|
||||
return this;
|
||||
}
|
||||
|
||||
const onEnd = (error, result) => {
|
||||
task.onEnd(error, result);
|
||||
|
||||
this._unlock(workerId);
|
||||
|
||||
this._process(workerId);
|
||||
};
|
||||
|
||||
task.request[1] = true;
|
||||
|
||||
this._lock(workerId);
|
||||
|
||||
this._callback(workerId, task.request, task.onStart, onEnd);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
_enqueue(task, workerId) {
|
||||
const item = {
|
||||
next: null,
|
||||
task
|
||||
};
|
||||
|
||||
if (task.request[1]) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (this._queue[workerId]) {
|
||||
this._last[workerId].next = item;
|
||||
} else {
|
||||
this._queue[workerId] = item;
|
||||
}
|
||||
|
||||
this._last[workerId] = item;
|
||||
|
||||
this._process(workerId);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
_push(task) {
|
||||
for (let i = 0; i < this._numOfWorkers; i++) {
|
||||
this._enqueue(task, (this._offset + i) % this._numOfWorkers);
|
||||
}
|
||||
|
||||
this._offset++;
|
||||
return this;
|
||||
}
|
||||
|
||||
_lock(workerId) {
|
||||
this._locks[workerId] = true;
|
||||
}
|
||||
|
||||
_unlock(workerId) {
|
||||
this._locks[workerId] = false;
|
||||
}
|
||||
|
||||
_isLocked(workerId) {
|
||||
return this._locks[workerId];
|
||||
}
|
||||
}
|
||||
|
||||
exports.default = Farm;
|
||||
14
node_modules/jest-worker/build/WorkerPool.d.ts
generated
vendored
Normal file
14
node_modules/jest-worker/build/WorkerPool.d.ts
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import BaseWorkerPool from './base/BaseWorkerPool';
|
||||
import { ChildMessage, OnEnd, OnStart, WorkerInterface, WorkerOptions, WorkerPoolInterface } from './types';
|
||||
declare class WorkerPool extends BaseWorkerPool implements WorkerPoolInterface {
|
||||
send(workerId: number, request: ChildMessage, onStart: OnStart, onEnd: OnEnd): void;
|
||||
createWorker(workerOptions: WorkerOptions): WorkerInterface;
|
||||
}
|
||||
export default WorkerPool;
|
||||
//# sourceMappingURL=WorkerPool.d.ts.map
|
||||
1
node_modules/jest-worker/build/WorkerPool.d.ts.map
generated
vendored
Normal file
1
node_modules/jest-worker/build/WorkerPool.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"WorkerPool.d.ts","sourceRoot":"","sources":["../src/WorkerPool.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,cAAc,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EACL,YAAY,EACZ,KAAK,EACL,OAAO,EACP,eAAe,EACf,aAAa,EACb,mBAAmB,EACpB,MAAM,SAAS,CAAC;AAWjB,cAAM,UAAW,SAAQ,cAAe,YAAW,mBAAmB;IACpE,IAAI,CACF,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,GACX,IAAI;IAIP,YAAY,CAAC,aAAa,EAAE,aAAa,GAAG,eAAe;CAU5D;AAED,eAAe,UAAU,CAAC"}
|
||||
49
node_modules/jest-worker/build/WorkerPool.js
generated
vendored
Normal file
49
node_modules/jest-worker/build/WorkerPool.js
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _BaseWorkerPool = _interopRequireDefault(require('./base/BaseWorkerPool'));
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
const canUseWorkerThreads = () => {
|
||||
try {
|
||||
require('worker_threads');
|
||||
|
||||
return true;
|
||||
} catch (_) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
class WorkerPool extends _BaseWorkerPool.default {
|
||||
send(workerId, request, onStart, onEnd) {
|
||||
this.getWorkerById(workerId).send(request, onStart, onEnd);
|
||||
}
|
||||
|
||||
createWorker(workerOptions) {
|
||||
let Worker;
|
||||
|
||||
if (this._options.enableWorkerThreads && canUseWorkerThreads()) {
|
||||
Worker = require('./workers/NodeThreadsWorker').default;
|
||||
} else {
|
||||
Worker = require('./workers/ChildProcessWorker').default;
|
||||
}
|
||||
|
||||
return new Worker(workerOptions);
|
||||
}
|
||||
}
|
||||
|
||||
var _default = WorkerPool;
|
||||
exports.default = _default;
|
||||
22
node_modules/jest-worker/build/base/BaseWorkerPool.d.ts
generated
vendored
Normal file
22
node_modules/jest-worker/build/base/BaseWorkerPool.d.ts
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
/// <reference types="node" />
|
||||
import { PoolExitResult, WorkerInterface, WorkerOptions, WorkerPoolOptions } from '../types';
|
||||
export default class BaseWorkerPool {
|
||||
private readonly _stderr;
|
||||
private readonly _stdout;
|
||||
protected readonly _options: WorkerPoolOptions;
|
||||
private readonly _workers;
|
||||
constructor(workerPath: string, options: WorkerPoolOptions);
|
||||
getStderr(): NodeJS.ReadableStream;
|
||||
getStdout(): NodeJS.ReadableStream;
|
||||
getWorkers(): Array<WorkerInterface>;
|
||||
getWorkerById(workerId: number): WorkerInterface;
|
||||
createWorker(_workerOptions: WorkerOptions): WorkerInterface;
|
||||
end(): Promise<PoolExitResult>;
|
||||
}
|
||||
//# sourceMappingURL=BaseWorkerPool.d.ts.map
|
||||
1
node_modules/jest-worker/build/base/BaseWorkerPool.d.ts.map
generated
vendored
Normal file
1
node_modules/jest-worker/build/base/BaseWorkerPool.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"BaseWorkerPool.d.ts","sourceRoot":"","sources":["../../src/base/BaseWorkerPool.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAKH,OAAO,EAEL,cAAc,EACd,eAAe,EACf,aAAa,EACb,iBAAiB,EAClB,MAAM,UAAU,CAAC;AASlB,MAAM,CAAC,OAAO,OAAO,cAAc;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAwB;IAChD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAwB;IAChD,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IAC/C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAyB;gBAEtC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB;IAyC1D,SAAS,IAAI,MAAM,CAAC,cAAc;IAIlC,SAAS,IAAI,MAAM,CAAC,cAAc;IAIlC,UAAU,IAAI,KAAK,CAAC,eAAe,CAAC;IAIpC,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,eAAe;IAIhD,YAAY,CAAC,cAAc,EAAE,aAAa,GAAG,eAAe;IAItD,GAAG,IAAI,OAAO,CAAC,cAAc,CAAC;CA6BrC"}
|
||||
207
node_modules/jest-worker/build/base/BaseWorkerPool.js
generated
vendored
Normal file
207
node_modules/jest-worker/build/base/BaseWorkerPool.js
generated
vendored
Normal file
@@ -0,0 +1,207 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function path() {
|
||||
const data = _interopRequireWildcard(require('path'));
|
||||
|
||||
path = function() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _mergeStream() {
|
||||
const data = _interopRequireDefault(require('merge-stream'));
|
||||
|
||||
_mergeStream = function() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _types() {
|
||||
const data = require('../types');
|
||||
|
||||
_types = function() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
function _getRequireWildcardCache() {
|
||||
if (typeof WeakMap !== 'function') return null;
|
||||
var cache = new WeakMap();
|
||||
_getRequireWildcardCache = function() {
|
||||
return cache;
|
||||
};
|
||||
return cache;
|
||||
}
|
||||
|
||||
function _interopRequireWildcard(obj) {
|
||||
if (obj && obj.__esModule) {
|
||||
return obj;
|
||||
}
|
||||
if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
|
||||
return {default: obj};
|
||||
}
|
||||
var cache = _getRequireWildcardCache();
|
||||
if (cache && cache.has(obj)) {
|
||||
return cache.get(obj);
|
||||
}
|
||||
var newObj = {};
|
||||
var hasPropertyDescriptor =
|
||||
Object.defineProperty && Object.getOwnPropertyDescriptor;
|
||||
for (var key in obj) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var desc = hasPropertyDescriptor
|
||||
? Object.getOwnPropertyDescriptor(obj, key)
|
||||
: null;
|
||||
if (desc && (desc.get || desc.set)) {
|
||||
Object.defineProperty(newObj, key, desc);
|
||||
} else {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
newObj.default = obj;
|
||||
if (cache) {
|
||||
cache.set(obj, newObj);
|
||||
}
|
||||
return newObj;
|
||||
}
|
||||
|
||||
function _defineProperty(obj, key, value) {
|
||||
if (key in obj) {
|
||||
Object.defineProperty(obj, key, {
|
||||
value: value,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
} else {
|
||||
obj[key] = value;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
// How long to wait for the child process to terminate
|
||||
// after CHILD_MESSAGE_END before sending force exiting.
|
||||
const FORCE_EXIT_DELAY = 500;
|
||||
/* istanbul ignore next */
|
||||
|
||||
const emptyMethod = () => {};
|
||||
|
||||
class BaseWorkerPool {
|
||||
constructor(workerPath, options) {
|
||||
_defineProperty(this, '_stderr', void 0);
|
||||
|
||||
_defineProperty(this, '_stdout', void 0);
|
||||
|
||||
_defineProperty(this, '_options', void 0);
|
||||
|
||||
_defineProperty(this, '_workers', void 0);
|
||||
|
||||
this._options = options;
|
||||
this._workers = new Array(options.numWorkers);
|
||||
|
||||
if (!path().isAbsolute(workerPath)) {
|
||||
workerPath = require.resolve(workerPath);
|
||||
}
|
||||
|
||||
const stdout = (0, _mergeStream().default)();
|
||||
const stderr = (0, _mergeStream().default)();
|
||||
const {forkOptions, maxRetries, setupArgs} = options;
|
||||
|
||||
for (let i = 0; i < options.numWorkers; i++) {
|
||||
const workerOptions = {
|
||||
forkOptions,
|
||||
maxRetries,
|
||||
setupArgs,
|
||||
workerId: i,
|
||||
workerPath
|
||||
};
|
||||
const worker = this.createWorker(workerOptions);
|
||||
const workerStdout = worker.getStdout();
|
||||
const workerStderr = worker.getStderr();
|
||||
|
||||
if (workerStdout) {
|
||||
stdout.add(workerStdout);
|
||||
}
|
||||
|
||||
if (workerStderr) {
|
||||
stderr.add(workerStderr);
|
||||
}
|
||||
|
||||
this._workers[i] = worker;
|
||||
}
|
||||
|
||||
this._stdout = stdout;
|
||||
this._stderr = stderr;
|
||||
}
|
||||
|
||||
getStderr() {
|
||||
return this._stderr;
|
||||
}
|
||||
|
||||
getStdout() {
|
||||
return this._stdout;
|
||||
}
|
||||
|
||||
getWorkers() {
|
||||
return this._workers;
|
||||
}
|
||||
|
||||
getWorkerById(workerId) {
|
||||
return this._workers[workerId];
|
||||
}
|
||||
|
||||
createWorker(_workerOptions) {
|
||||
throw Error('Missing method createWorker in WorkerPool');
|
||||
}
|
||||
|
||||
async end() {
|
||||
// We do not cache the request object here. If so, it would only be only
|
||||
// processed by one of the workers, and we want them all to close.
|
||||
const workerExitPromises = this._workers.map(async worker => {
|
||||
worker.send(
|
||||
[_types().CHILD_MESSAGE_END, false],
|
||||
emptyMethod,
|
||||
emptyMethod
|
||||
); // Schedule a force exit in case worker fails to exit gracefully so
|
||||
// await worker.waitForExit() never takes longer than FORCE_EXIT_DELAY
|
||||
|
||||
let forceExited = false;
|
||||
const forceExitTimeout = setTimeout(() => {
|
||||
worker.forceExit();
|
||||
forceExited = true;
|
||||
}, FORCE_EXIT_DELAY);
|
||||
await worker.waitForExit(); // Worker ideally exited gracefully, don't send force exit then
|
||||
|
||||
clearTimeout(forceExitTimeout);
|
||||
return forceExited;
|
||||
});
|
||||
|
||||
const workerExits = await Promise.all(workerExitPromises);
|
||||
return workerExits.reduce(
|
||||
(result, forceExited) => ({
|
||||
forceExited: result.forceExited || forceExited
|
||||
}),
|
||||
{
|
||||
forceExited: false
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
exports.default = BaseWorkerPool;
|
||||
46
node_modules/jest-worker/build/index.d.ts
generated
vendored
Normal file
46
node_modules/jest-worker/build/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
/// <reference types="node" />
|
||||
import { FarmOptions, PoolExitResult } from './types';
|
||||
/**
|
||||
* The Jest farm (publicly called "Worker") is a class that allows you to queue
|
||||
* methods across multiple child processes, in order to parallelize work. This
|
||||
* is done by providing an absolute path to a module that will be loaded on each
|
||||
* of the child processes, and bridged to the main process.
|
||||
*
|
||||
* Bridged methods are specified by using the "exposedMethods" property of the
|
||||
* "options" object. This is an array of strings, where each of them corresponds
|
||||
* to the exported name in the loaded module.
|
||||
*
|
||||
* You can also control the amount of workers by using the "numWorkers" property
|
||||
* of the "options" object, and the settings passed to fork the process through
|
||||
* the "forkOptions" property. The amount of workers defaults to the amount of
|
||||
* CPUS minus one.
|
||||
*
|
||||
* Queueing calls can be done in two ways:
|
||||
* - Standard method: calls will be redirected to the first available worker,
|
||||
* so they will get executed as soon as they can.
|
||||
*
|
||||
* - Sticky method: if a "computeWorkerKey" method is provided within the
|
||||
* config, the resulting string of this method will be used as a key.
|
||||
* Every time this key is returned, it is guaranteed that your job will be
|
||||
* processed by the same worker. This is specially useful if your workers
|
||||
* are caching results.
|
||||
*/
|
||||
export default class JestWorker {
|
||||
private _ending;
|
||||
private _farm;
|
||||
private _options;
|
||||
private _workerPool;
|
||||
constructor(workerPath: string, options?: FarmOptions);
|
||||
private _bindExposedWorkerMethods;
|
||||
private _callFunctionWithArgs;
|
||||
getStderr(): NodeJS.ReadableStream;
|
||||
getStdout(): NodeJS.ReadableStream;
|
||||
end(): Promise<PoolExitResult>;
|
||||
}
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
1
node_modules/jest-worker/build/index.d.ts.map
generated
vendored
Normal file
1
node_modules/jest-worker/build/index.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAKH,OAAO,EACL,WAAW,EACX,cAAc,EAGf,MAAM,SAAS,CAAC;AAyBjB;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,OAAO,OAAO,UAAU;IAC7B,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,KAAK,CAAO;IACpB,OAAO,CAAC,QAAQ,CAAc;IAC9B,OAAO,CAAC,WAAW,CAAsB;gBAE7B,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW;IA+BrD,OAAO,CAAC,yBAAyB;IAkBjC,OAAO,CAAC,qBAAqB;IAW7B,SAAS,IAAI,MAAM,CAAC,cAAc;IAIlC,SAAS,IAAI,MAAM,CAAC,cAAc;IAI5B,GAAG,IAAI,OAAO,CAAC,cAAc,CAAC;CAQrC"}
|
||||
199
node_modules/jest-worker/build/index.js
generated
vendored
Normal file
199
node_modules/jest-worker/build/index.js
generated
vendored
Normal file
@@ -0,0 +1,199 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _os() {
|
||||
const data = require('os');
|
||||
|
||||
_os = function() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _WorkerPool = _interopRequireDefault(require('./WorkerPool'));
|
||||
|
||||
var _Farm = _interopRequireDefault(require('./Farm'));
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
function ownKeys(object, enumerableOnly) {
|
||||
var keys = Object.keys(object);
|
||||
if (Object.getOwnPropertySymbols) {
|
||||
var symbols = Object.getOwnPropertySymbols(object);
|
||||
if (enumerableOnly)
|
||||
symbols = symbols.filter(function(sym) {
|
||||
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
||||
});
|
||||
keys.push.apply(keys, symbols);
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
||||
function _objectSpread(target) {
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var source = arguments[i] != null ? arguments[i] : {};
|
||||
if (i % 2) {
|
||||
ownKeys(Object(source), true).forEach(function(key) {
|
||||
_defineProperty(target, key, source[key]);
|
||||
});
|
||||
} else if (Object.getOwnPropertyDescriptors) {
|
||||
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
||||
} else {
|
||||
ownKeys(Object(source)).forEach(function(key) {
|
||||
Object.defineProperty(
|
||||
target,
|
||||
key,
|
||||
Object.getOwnPropertyDescriptor(source, key)
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
function _defineProperty(obj, key, value) {
|
||||
if (key in obj) {
|
||||
Object.defineProperty(obj, key, {
|
||||
value: value,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
} else {
|
||||
obj[key] = value;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
function getExposedMethods(workerPath, options) {
|
||||
let exposedMethods = options.exposedMethods; // If no methods list is given, try getting it by auto-requiring the module.
|
||||
|
||||
if (!exposedMethods) {
|
||||
const module = require(workerPath);
|
||||
|
||||
exposedMethods = Object.keys(module).filter(
|
||||
// @ts-ignore: no index
|
||||
name => typeof module[name] === 'function'
|
||||
);
|
||||
|
||||
if (typeof module === 'function') {
|
||||
exposedMethods = [...exposedMethods, 'default'];
|
||||
}
|
||||
}
|
||||
|
||||
return exposedMethods;
|
||||
}
|
||||
/**
|
||||
* The Jest farm (publicly called "Worker") is a class that allows you to queue
|
||||
* methods across multiple child processes, in order to parallelize work. This
|
||||
* is done by providing an absolute path to a module that will be loaded on each
|
||||
* of the child processes, and bridged to the main process.
|
||||
*
|
||||
* Bridged methods are specified by using the "exposedMethods" property of the
|
||||
* "options" object. This is an array of strings, where each of them corresponds
|
||||
* to the exported name in the loaded module.
|
||||
*
|
||||
* You can also control the amount of workers by using the "numWorkers" property
|
||||
* of the "options" object, and the settings passed to fork the process through
|
||||
* the "forkOptions" property. The amount of workers defaults to the amount of
|
||||
* CPUS minus one.
|
||||
*
|
||||
* Queueing calls can be done in two ways:
|
||||
* - Standard method: calls will be redirected to the first available worker,
|
||||
* so they will get executed as soon as they can.
|
||||
*
|
||||
* - Sticky method: if a "computeWorkerKey" method is provided within the
|
||||
* config, the resulting string of this method will be used as a key.
|
||||
* Every time this key is returned, it is guaranteed that your job will be
|
||||
* processed by the same worker. This is specially useful if your workers
|
||||
* are caching results.
|
||||
*/
|
||||
|
||||
class JestWorker {
|
||||
constructor(workerPath, options) {
|
||||
_defineProperty(this, '_ending', void 0);
|
||||
|
||||
_defineProperty(this, '_farm', void 0);
|
||||
|
||||
_defineProperty(this, '_options', void 0);
|
||||
|
||||
_defineProperty(this, '_workerPool', void 0);
|
||||
|
||||
this._options = _objectSpread({}, options);
|
||||
this._ending = false;
|
||||
const workerPoolOptions = {
|
||||
enableWorkerThreads: this._options.enableWorkerThreads || false,
|
||||
forkOptions: this._options.forkOptions || {},
|
||||
maxRetries: this._options.maxRetries || 3,
|
||||
numWorkers:
|
||||
this._options.numWorkers || Math.max((0, _os().cpus)().length - 1, 1),
|
||||
setupArgs: this._options.setupArgs || []
|
||||
};
|
||||
|
||||
if (this._options.WorkerPool) {
|
||||
// @ts-ignore: constructor target any?
|
||||
this._workerPool = new this._options.WorkerPool(
|
||||
workerPath,
|
||||
workerPoolOptions
|
||||
);
|
||||
} else {
|
||||
this._workerPool = new _WorkerPool.default(workerPath, workerPoolOptions);
|
||||
}
|
||||
|
||||
this._farm = new _Farm.default(
|
||||
workerPoolOptions.numWorkers,
|
||||
this._workerPool.send.bind(this._workerPool),
|
||||
this._options.computeWorkerKey
|
||||
);
|
||||
|
||||
this._bindExposedWorkerMethods(workerPath, this._options);
|
||||
}
|
||||
|
||||
_bindExposedWorkerMethods(workerPath, options) {
|
||||
getExposedMethods(workerPath, options).forEach(name => {
|
||||
if (name.startsWith('_')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.constructor.prototype.hasOwnProperty(name)) {
|
||||
throw new TypeError('Cannot define a method called ' + name);
|
||||
} // @ts-ignore: dynamic extension of the class instance is expected.
|
||||
|
||||
this[name] = this._callFunctionWithArgs.bind(this, name);
|
||||
});
|
||||
}
|
||||
|
||||
_callFunctionWithArgs(method, ...args) {
|
||||
if (this._ending) {
|
||||
throw new Error('Farm is ended, no more calls can be done to it');
|
||||
}
|
||||
|
||||
return this._farm.doWork(method, ...args);
|
||||
}
|
||||
|
||||
getStderr() {
|
||||
return this._workerPool.getStderr();
|
||||
}
|
||||
|
||||
getStdout() {
|
||||
return this._workerPool.getStdout();
|
||||
}
|
||||
|
||||
async end() {
|
||||
if (this._ending) {
|
||||
throw new Error('Farm is ended, no more calls can be done to it');
|
||||
}
|
||||
|
||||
this._ending = true;
|
||||
return this._workerPool.end();
|
||||
}
|
||||
}
|
||||
|
||||
exports.default = JestWorker;
|
||||
101
node_modules/jest-worker/build/types.d.ts
generated
vendored
Normal file
101
node_modules/jest-worker/build/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
/// <reference types="node" />
|
||||
import { EventEmitter } from 'events';
|
||||
import { ForkOptions } from 'child_process';
|
||||
export declare const CHILD_MESSAGE_INITIALIZE: 0;
|
||||
export declare const CHILD_MESSAGE_CALL: 1;
|
||||
export declare const CHILD_MESSAGE_END: 2;
|
||||
export declare const PARENT_MESSAGE_OK: 0;
|
||||
export declare const PARENT_MESSAGE_CLIENT_ERROR: 1;
|
||||
export declare const PARENT_MESSAGE_SETUP_ERROR: 2;
|
||||
export declare type PARENT_MESSAGE_ERROR = typeof PARENT_MESSAGE_CLIENT_ERROR | typeof PARENT_MESSAGE_SETUP_ERROR;
|
||||
export interface WorkerPoolInterface {
|
||||
getStderr(): NodeJS.ReadableStream;
|
||||
getStdout(): NodeJS.ReadableStream;
|
||||
getWorkers(): Array<WorkerInterface>;
|
||||
createWorker(options: WorkerOptions): WorkerInterface;
|
||||
send(workerId: number, request: ChildMessage, onStart: OnStart, onEnd: OnEnd): void;
|
||||
end(): Promise<PoolExitResult>;
|
||||
}
|
||||
export interface WorkerInterface {
|
||||
send(request: ChildMessage, onProcessStart: OnStart, onProcessEnd: OnEnd): void;
|
||||
waitForExit(): Promise<void>;
|
||||
forceExit(): void;
|
||||
getWorkerId(): number;
|
||||
getStderr(): NodeJS.ReadableStream | null;
|
||||
getStdout(): NodeJS.ReadableStream | null;
|
||||
}
|
||||
export declare type PoolExitResult = {
|
||||
forceExited: boolean;
|
||||
};
|
||||
export { ForkOptions };
|
||||
export declare type FarmOptions = {
|
||||
computeWorkerKey?: (method: string, ...args: Array<unknown>) => string | null;
|
||||
exposedMethods?: ReadonlyArray<string>;
|
||||
forkOptions?: ForkOptions;
|
||||
setupArgs?: Array<unknown>;
|
||||
maxRetries?: number;
|
||||
numWorkers?: number;
|
||||
WorkerPool?: (workerPath: string, options?: WorkerPoolOptions) => WorkerPoolInterface;
|
||||
enableWorkerThreads?: boolean;
|
||||
};
|
||||
export declare type WorkerPoolOptions = {
|
||||
setupArgs: Array<unknown>;
|
||||
forkOptions: ForkOptions;
|
||||
maxRetries: number;
|
||||
numWorkers: number;
|
||||
enableWorkerThreads: boolean;
|
||||
};
|
||||
export declare type WorkerOptions = {
|
||||
forkOptions: ForkOptions;
|
||||
setupArgs: Array<unknown>;
|
||||
maxRetries: number;
|
||||
workerId: number;
|
||||
workerPath: string;
|
||||
};
|
||||
export declare type MessagePort = typeof EventEmitter & {
|
||||
postMessage(message: unknown): void;
|
||||
};
|
||||
export declare type MessageChannel = {
|
||||
port1: MessagePort;
|
||||
port2: MessagePort;
|
||||
};
|
||||
export declare type ChildMessageInitialize = [typeof CHILD_MESSAGE_INITIALIZE, // type
|
||||
boolean, // processed
|
||||
string, // file
|
||||
// file
|
||||
Array<unknown> | undefined, // setupArgs
|
||||
// setupArgs
|
||||
MessagePort | undefined];
|
||||
export declare type ChildMessageCall = [typeof CHILD_MESSAGE_CALL, // type
|
||||
boolean, // processed
|
||||
string, // method
|
||||
Array<unknown>];
|
||||
export declare type ChildMessageEnd = [typeof CHILD_MESSAGE_END, // type
|
||||
boolean];
|
||||
export declare type ChildMessage = ChildMessageInitialize | ChildMessageCall | ChildMessageEnd;
|
||||
export declare type ParentMessageOk = [typeof PARENT_MESSAGE_OK, // type
|
||||
unknown];
|
||||
export declare type ParentMessageError = [PARENT_MESSAGE_ERROR, // type
|
||||
string, // constructor
|
||||
string, // message
|
||||
string, // stack
|
||||
unknown];
|
||||
export declare type ParentMessage = ParentMessageOk | ParentMessageError;
|
||||
export declare type OnStart = (worker: WorkerInterface) => void;
|
||||
export declare type OnEnd = (err: Error | null, result: unknown) => void;
|
||||
export declare type QueueChildMessage = {
|
||||
request: ChildMessage;
|
||||
onStart: OnStart;
|
||||
onEnd: OnEnd;
|
||||
};
|
||||
export declare type QueueItem = {
|
||||
task: QueueChildMessage;
|
||||
next: QueueItem | null;
|
||||
};
|
||||
//# sourceMappingURL=types.d.ts.map
|
||||
1
node_modules/jest-worker/build/types.d.ts.map
generated
vendored
Normal file
1
node_modules/jest-worker/build/types.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"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"}
|
||||
44
node_modules/jest-worker/build/types.js
generated
vendored
Normal file
44
node_modules/jest-worker/build/types.js
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, 'ForkOptions', {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return _child_process().ForkOptions;
|
||||
}
|
||||
});
|
||||
exports.PARENT_MESSAGE_SETUP_ERROR = exports.PARENT_MESSAGE_CLIENT_ERROR = exports.PARENT_MESSAGE_OK = exports.CHILD_MESSAGE_END = exports.CHILD_MESSAGE_CALL = exports.CHILD_MESSAGE_INITIALIZE = void 0;
|
||||
|
||||
function _child_process() {
|
||||
const data = require('child_process');
|
||||
|
||||
_child_process = function() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
// Because of the dynamic nature of a worker communication process, all messages
|
||||
// coming from any of the other processes cannot be typed. Thus, many types
|
||||
// include "unknown" as a TS type, which is (unfortunately) correct here.
|
||||
const CHILD_MESSAGE_INITIALIZE = 0;
|
||||
exports.CHILD_MESSAGE_INITIALIZE = CHILD_MESSAGE_INITIALIZE;
|
||||
const CHILD_MESSAGE_CALL = 1;
|
||||
exports.CHILD_MESSAGE_CALL = CHILD_MESSAGE_CALL;
|
||||
const CHILD_MESSAGE_END = 2;
|
||||
exports.CHILD_MESSAGE_END = CHILD_MESSAGE_END;
|
||||
const PARENT_MESSAGE_OK = 0;
|
||||
exports.PARENT_MESSAGE_OK = PARENT_MESSAGE_OK;
|
||||
const PARENT_MESSAGE_CLIENT_ERROR = 1;
|
||||
exports.PARENT_MESSAGE_CLIENT_ERROR = PARENT_MESSAGE_CLIENT_ERROR;
|
||||
const PARENT_MESSAGE_SETUP_ERROR = 2;
|
||||
exports.PARENT_MESSAGE_SETUP_ERROR = PARENT_MESSAGE_SETUP_ERROR;
|
||||
51
node_modules/jest-worker/build/workers/ChildProcessWorker.d.ts
generated
vendored
Normal file
51
node_modules/jest-worker/build/workers/ChildProcessWorker.d.ts
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
/// <reference types="node" />
|
||||
import { ChildMessage, OnEnd, OnStart, WorkerInterface, WorkerOptions } from '../types';
|
||||
/**
|
||||
* This class wraps the child process and provides a nice interface to
|
||||
* communicate with. It takes care of:
|
||||
*
|
||||
* - Re-spawning the process if it dies.
|
||||
* - Queues calls while the worker is busy.
|
||||
* - Re-sends the requests if the worker blew up.
|
||||
*
|
||||
* The reason for queueing them here (since childProcess.send also has an
|
||||
* internal queue) is because the worker could be doing asynchronous work, and
|
||||
* this would lead to the child process to read its receiving buffer and start a
|
||||
* second call. By queueing calls here, we don't send the next call to the
|
||||
* children until we receive the result of the previous one.
|
||||
*
|
||||
* As soon as a request starts to be processed by a worker, its "processed"
|
||||
* field is changed to "true", so that other workers which might encounter the
|
||||
* same call skip it.
|
||||
*/
|
||||
export default class ChildProcessWorker implements WorkerInterface {
|
||||
private _child;
|
||||
private _options;
|
||||
private _request;
|
||||
private _retries;
|
||||
private _onProcessEnd;
|
||||
private _fakeStream;
|
||||
private _stdout;
|
||||
private _stderr;
|
||||
private _exitPromise;
|
||||
private _resolveExitPromise;
|
||||
constructor(options: WorkerOptions);
|
||||
initialize(): void;
|
||||
private _shutdown;
|
||||
private _onMessage;
|
||||
private _onExit;
|
||||
send(request: ChildMessage, onProcessStart: OnStart, onProcessEnd: OnEnd): void;
|
||||
waitForExit(): Promise<void>;
|
||||
forceExit(): void;
|
||||
getWorkerId(): number;
|
||||
getStdout(): NodeJS.ReadableStream | null;
|
||||
getStderr(): NodeJS.ReadableStream | null;
|
||||
private _getFakeStream;
|
||||
}
|
||||
//# sourceMappingURL=ChildProcessWorker.d.ts.map
|
||||
1
node_modules/jest-worker/build/workers/ChildProcessWorker.d.ts.map
generated
vendored
Normal file
1
node_modules/jest-worker/build/workers/ChildProcessWorker.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ChildProcessWorker.d.ts","sourceRoot":"","sources":["../../src/workers/ChildProcessWorker.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAOH,OAAO,EAEL,YAAY,EACZ,KAAK,EACL,OAAO,EAKP,eAAe,EACf,aAAa,EACd,MAAM,UAAU,CAAC;AASlB;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,OAAO,OAAO,kBAAmB,YAAW,eAAe;IAChE,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,QAAQ,CAAgB;IAEhC,OAAO,CAAC,QAAQ,CAAsB;IACtC,OAAO,CAAC,QAAQ,CAAU;IAC1B,OAAO,CAAC,aAAa,CAAS;IAE9B,OAAO,CAAC,WAAW,CAAqB;IACxC,OAAO,CAAC,OAAO,CAAwC;IACvD,OAAO,CAAC,OAAO,CAAwC;IAEvD,OAAO,CAAC,YAAY,CAAgB;IACpC,OAAO,CAAC,mBAAmB,CAAc;gBAE7B,OAAO,EAAE,aAAa;IAgBlC,UAAU;IAiEV,OAAO,CAAC,SAAS;IAUjB,OAAO,CAAC,UAAU;IA6ClB,OAAO,CAAC,OAAO;IAgBf,IAAI,CAAC,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK;IAcxE,WAAW;IAIX,SAAS;IAST,WAAW;IAIX,SAAS,IAAI,MAAM,CAAC,cAAc,GAAG,IAAI;IAIzC,SAAS,IAAI,MAAM,CAAC,cAAc,GAAG,IAAI;IAIzC,OAAO,CAAC,cAAc;CAMvB"}
|
||||
369
node_modules/jest-worker/build/workers/ChildProcessWorker.js
generated
vendored
Normal file
369
node_modules/jest-worker/build/workers/ChildProcessWorker.js
generated
vendored
Normal file
@@ -0,0 +1,369 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _child_process() {
|
||||
const data = require('child_process');
|
||||
|
||||
_child_process = function() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _stream() {
|
||||
const data = require('stream');
|
||||
|
||||
_stream = function() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _mergeStream() {
|
||||
const data = _interopRequireDefault(require('merge-stream'));
|
||||
|
||||
_mergeStream = function() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _supportsColor() {
|
||||
const data = require('supports-color');
|
||||
|
||||
_supportsColor = function() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _types() {
|
||||
const data = require('../types');
|
||||
|
||||
_types = function() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
function ownKeys(object, enumerableOnly) {
|
||||
var keys = Object.keys(object);
|
||||
if (Object.getOwnPropertySymbols) {
|
||||
var symbols = Object.getOwnPropertySymbols(object);
|
||||
if (enumerableOnly)
|
||||
symbols = symbols.filter(function(sym) {
|
||||
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
||||
});
|
||||
keys.push.apply(keys, symbols);
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
||||
function _objectSpread(target) {
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var source = arguments[i] != null ? arguments[i] : {};
|
||||
if (i % 2) {
|
||||
ownKeys(Object(source), true).forEach(function(key) {
|
||||
_defineProperty(target, key, source[key]);
|
||||
});
|
||||
} else if (Object.getOwnPropertyDescriptors) {
|
||||
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
||||
} else {
|
||||
ownKeys(Object(source)).forEach(function(key) {
|
||||
Object.defineProperty(
|
||||
target,
|
||||
key,
|
||||
Object.getOwnPropertyDescriptor(source, key)
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
function _defineProperty(obj, key, value) {
|
||||
if (key in obj) {
|
||||
Object.defineProperty(obj, key, {
|
||||
value: value,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
} else {
|
||||
obj[key] = value;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
const SIGNAL_BASE_EXIT_CODE = 128;
|
||||
const SIGKILL_EXIT_CODE = SIGNAL_BASE_EXIT_CODE + 9;
|
||||
const SIGTERM_EXIT_CODE = SIGNAL_BASE_EXIT_CODE + 15; // How long to wait after SIGTERM before sending SIGKILL
|
||||
|
||||
const SIGKILL_DELAY = 500;
|
||||
/**
|
||||
* This class wraps the child process and provides a nice interface to
|
||||
* communicate with. It takes care of:
|
||||
*
|
||||
* - Re-spawning the process if it dies.
|
||||
* - Queues calls while the worker is busy.
|
||||
* - Re-sends the requests if the worker blew up.
|
||||
*
|
||||
* The reason for queueing them here (since childProcess.send also has an
|
||||
* internal queue) is because the worker could be doing asynchronous work, and
|
||||
* this would lead to the child process to read its receiving buffer and start a
|
||||
* second call. By queueing calls here, we don't send the next call to the
|
||||
* children until we receive the result of the previous one.
|
||||
*
|
||||
* As soon as a request starts to be processed by a worker, its "processed"
|
||||
* field is changed to "true", so that other workers which might encounter the
|
||||
* same call skip it.
|
||||
*/
|
||||
|
||||
class ChildProcessWorker {
|
||||
constructor(options) {
|
||||
_defineProperty(this, '_child', void 0);
|
||||
|
||||
_defineProperty(this, '_options', void 0);
|
||||
|
||||
_defineProperty(this, '_request', void 0);
|
||||
|
||||
_defineProperty(this, '_retries', void 0);
|
||||
|
||||
_defineProperty(this, '_onProcessEnd', void 0);
|
||||
|
||||
_defineProperty(this, '_fakeStream', void 0);
|
||||
|
||||
_defineProperty(this, '_stdout', void 0);
|
||||
|
||||
_defineProperty(this, '_stderr', void 0);
|
||||
|
||||
_defineProperty(this, '_exitPromise', void 0);
|
||||
|
||||
_defineProperty(this, '_resolveExitPromise', void 0);
|
||||
|
||||
this._options = options;
|
||||
this._request = null;
|
||||
this._fakeStream = null;
|
||||
this._stdout = null;
|
||||
this._stderr = null;
|
||||
this._exitPromise = new Promise(resolve => {
|
||||
this._resolveExitPromise = resolve;
|
||||
});
|
||||
this.initialize();
|
||||
}
|
||||
|
||||
initialize() {
|
||||
const forceColor = _supportsColor().stdout
|
||||
? {
|
||||
FORCE_COLOR: '1'
|
||||
}
|
||||
: {};
|
||||
const child = (0, _child_process().fork)(
|
||||
require.resolve('./processChild'),
|
||||
[],
|
||||
_objectSpread(
|
||||
{
|
||||
cwd: process.cwd(),
|
||||
env: _objectSpread(
|
||||
{},
|
||||
process.env,
|
||||
{
|
||||
JEST_WORKER_ID: String(this._options.workerId + 1)
|
||||
},
|
||||
forceColor
|
||||
),
|
||||
// Suppress --debug / --inspect flags while preserving others (like --harmony).
|
||||
execArgv: process.execArgv.filter(v => !/^--(debug|inspect)/.test(v)),
|
||||
silent: true
|
||||
},
|
||||
this._options.forkOptions
|
||||
)
|
||||
);
|
||||
|
||||
if (child.stdout) {
|
||||
if (!this._stdout) {
|
||||
// We need to add a permanent stream to the merged stream to prevent it
|
||||
// from ending when the subprocess stream ends
|
||||
this._stdout = (0, _mergeStream().default)(this._getFakeStream());
|
||||
}
|
||||
|
||||
this._stdout.add(child.stdout);
|
||||
}
|
||||
|
||||
if (child.stderr) {
|
||||
if (!this._stderr) {
|
||||
// We need to add a permanent stream to the merged stream to prevent it
|
||||
// from ending when the subprocess stream ends
|
||||
this._stderr = (0, _mergeStream().default)(this._getFakeStream());
|
||||
}
|
||||
|
||||
this._stderr.add(child.stderr);
|
||||
}
|
||||
|
||||
child.on('message', this._onMessage.bind(this));
|
||||
child.on('exit', this._onExit.bind(this));
|
||||
child.send([
|
||||
_types().CHILD_MESSAGE_INITIALIZE,
|
||||
false,
|
||||
this._options.workerPath,
|
||||
this._options.setupArgs
|
||||
]);
|
||||
this._child = child;
|
||||
this._retries++; // If we exceeded the amount of retries, we will emulate an error reply
|
||||
// coming from the child. This avoids code duplication related with cleaning
|
||||
// the queue, and scheduling the next call.
|
||||
|
||||
if (this._retries > this._options.maxRetries) {
|
||||
const error = new Error('Call retries were exceeded');
|
||||
|
||||
this._onMessage([
|
||||
_types().PARENT_MESSAGE_CLIENT_ERROR,
|
||||
error.name,
|
||||
error.message,
|
||||
error.stack,
|
||||
{
|
||||
type: 'WorkerError'
|
||||
}
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
_shutdown() {
|
||||
// End the temporary streams so the merged streams end too
|
||||
if (this._fakeStream) {
|
||||
this._fakeStream.end();
|
||||
|
||||
this._fakeStream = null;
|
||||
}
|
||||
|
||||
this._resolveExitPromise();
|
||||
}
|
||||
|
||||
_onMessage(response) {
|
||||
let error;
|
||||
|
||||
switch (response[0]) {
|
||||
case _types().PARENT_MESSAGE_OK:
|
||||
this._onProcessEnd(null, response[1]);
|
||||
|
||||
break;
|
||||
|
||||
case _types().PARENT_MESSAGE_CLIENT_ERROR:
|
||||
error = response[4];
|
||||
|
||||
if (error != null && typeof error === 'object') {
|
||||
const extra = error; // @ts-ignore: no index
|
||||
|
||||
const NativeCtor = global[response[1]];
|
||||
const Ctor = typeof NativeCtor === 'function' ? NativeCtor : Error;
|
||||
error = new Ctor(response[2]);
|
||||
error.type = response[1];
|
||||
error.stack = response[3];
|
||||
|
||||
for (const key in extra) {
|
||||
// @ts-ignore: adding custom properties to errors.
|
||||
error[key] = extra[key];
|
||||
}
|
||||
}
|
||||
|
||||
this._onProcessEnd(error, null);
|
||||
|
||||
break;
|
||||
|
||||
case _types().PARENT_MESSAGE_SETUP_ERROR:
|
||||
error = new Error('Error when calling setup: ' + response[2]); // @ts-ignore: adding custom properties to errors.
|
||||
|
||||
error.type = response[1];
|
||||
error.stack = response[3];
|
||||
|
||||
this._onProcessEnd(error, null);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new TypeError('Unexpected response from worker: ' + response[0]);
|
||||
}
|
||||
}
|
||||
|
||||
_onExit(exitCode) {
|
||||
if (
|
||||
exitCode !== 0 &&
|
||||
exitCode !== SIGTERM_EXIT_CODE &&
|
||||
exitCode !== SIGKILL_EXIT_CODE
|
||||
) {
|
||||
this.initialize();
|
||||
|
||||
if (this._request) {
|
||||
this._child.send(this._request);
|
||||
}
|
||||
} else {
|
||||
this._shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
send(request, onProcessStart, onProcessEnd) {
|
||||
onProcessStart(this);
|
||||
|
||||
this._onProcessEnd = (...args) => {
|
||||
// Clean the request to avoid sending past requests to workers that fail
|
||||
// while waiting for a new request (timers, unhandled rejections...)
|
||||
this._request = null;
|
||||
return onProcessEnd(...args);
|
||||
};
|
||||
|
||||
this._request = request;
|
||||
this._retries = 0;
|
||||
|
||||
this._child.send(request);
|
||||
}
|
||||
|
||||
waitForExit() {
|
||||
return this._exitPromise;
|
||||
}
|
||||
|
||||
forceExit() {
|
||||
this._child.kill('SIGTERM');
|
||||
|
||||
const sigkillTimeout = setTimeout(
|
||||
() => this._child.kill('SIGKILL'),
|
||||
SIGKILL_DELAY
|
||||
);
|
||||
|
||||
this._exitPromise.then(() => clearTimeout(sigkillTimeout));
|
||||
}
|
||||
|
||||
getWorkerId() {
|
||||
return this._options.workerId;
|
||||
}
|
||||
|
||||
getStdout() {
|
||||
return this._stdout;
|
||||
}
|
||||
|
||||
getStderr() {
|
||||
return this._stderr;
|
||||
}
|
||||
|
||||
_getFakeStream() {
|
||||
if (!this._fakeStream) {
|
||||
this._fakeStream = new (_stream().PassThrough)();
|
||||
}
|
||||
|
||||
return this._fakeStream;
|
||||
}
|
||||
}
|
||||
|
||||
exports.default = ChildProcessWorker;
|
||||
34
node_modules/jest-worker/build/workers/NodeThreadsWorker.d.ts
generated
vendored
Normal file
34
node_modules/jest-worker/build/workers/NodeThreadsWorker.d.ts
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
/// <reference types="node" />
|
||||
import { ChildMessage, OnEnd, OnStart, WorkerInterface, WorkerOptions } from '../types';
|
||||
export default class ExperimentalWorker implements WorkerInterface {
|
||||
private _worker;
|
||||
private _options;
|
||||
private _request;
|
||||
private _retries;
|
||||
private _onProcessEnd;
|
||||
private _fakeStream;
|
||||
private _stdout;
|
||||
private _stderr;
|
||||
private _exitPromise;
|
||||
private _resolveExitPromise;
|
||||
private _forceExited;
|
||||
constructor(options: WorkerOptions);
|
||||
initialize(): void;
|
||||
private _shutdown;
|
||||
private _onMessage;
|
||||
private _onExit;
|
||||
waitForExit(): Promise<void>;
|
||||
forceExit(): void;
|
||||
send(request: ChildMessage, onProcessStart: OnStart, onProcessEnd: OnEnd): void;
|
||||
getWorkerId(): number;
|
||||
getStdout(): NodeJS.ReadableStream | null;
|
||||
getStderr(): NodeJS.ReadableStream | null;
|
||||
private _getFakeStream;
|
||||
}
|
||||
//# sourceMappingURL=NodeThreadsWorker.d.ts.map
|
||||
1
node_modules/jest-worker/build/workers/NodeThreadsWorker.d.ts.map
generated
vendored
Normal file
1
node_modules/jest-worker/build/workers/NodeThreadsWorker.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"NodeThreadsWorker.d.ts","sourceRoot":"","sources":["../../src/workers/NodeThreadsWorker.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAOH,OAAO,EAEL,YAAY,EACZ,KAAK,EACL,OAAO,EAKP,eAAe,EACf,aAAa,EACd,MAAM,UAAU,CAAC;AAElB,MAAM,CAAC,OAAO,OAAO,kBAAmB,YAAW,eAAe;IAChE,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,QAAQ,CAAgB;IAEhC,OAAO,CAAC,QAAQ,CAAsB;IACtC,OAAO,CAAC,QAAQ,CAAU;IAC1B,OAAO,CAAC,aAAa,CAAS;IAE9B,OAAO,CAAC,WAAW,CAAqB;IACxC,OAAO,CAAC,OAAO,CAAwC;IACvD,OAAO,CAAC,OAAO,CAAwC;IAEvD,OAAO,CAAC,YAAY,CAAgB;IACpC,OAAO,CAAC,mBAAmB,CAAc;IACzC,OAAO,CAAC,YAAY,CAAU;gBAElB,OAAO,EAAE,aAAa;IAiBlC,UAAU;IAkEV,OAAO,CAAC,SAAS;IAUjB,OAAO,CAAC,UAAU;IA2ClB,OAAO,CAAC,OAAO;IAYf,WAAW;IAIX,SAAS;IAKT,IAAI,CAAC,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK;IAexE,WAAW;IAIX,SAAS,IAAI,MAAM,CAAC,cAAc,GAAG,IAAI;IAIzC,SAAS,IAAI,MAAM,CAAC,cAAc,GAAG,IAAI;IAIzC,OAAO,CAAC,cAAc;CAMvB"}
|
||||
379
node_modules/jest-worker/build/workers/NodeThreadsWorker.js
generated
vendored
Normal file
379
node_modules/jest-worker/build/workers/NodeThreadsWorker.js
generated
vendored
Normal file
@@ -0,0 +1,379 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function path() {
|
||||
const data = _interopRequireWildcard(require('path'));
|
||||
|
||||
path = function() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _stream() {
|
||||
const data = require('stream');
|
||||
|
||||
_stream = function() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _worker_threads() {
|
||||
const data = require('worker_threads');
|
||||
|
||||
_worker_threads = function() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _mergeStream() {
|
||||
const data = _interopRequireDefault(require('merge-stream'));
|
||||
|
||||
_mergeStream = function() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _types() {
|
||||
const data = require('../types');
|
||||
|
||||
_types = function() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
function _getRequireWildcardCache() {
|
||||
if (typeof WeakMap !== 'function') return null;
|
||||
var cache = new WeakMap();
|
||||
_getRequireWildcardCache = function() {
|
||||
return cache;
|
||||
};
|
||||
return cache;
|
||||
}
|
||||
|
||||
function _interopRequireWildcard(obj) {
|
||||
if (obj && obj.__esModule) {
|
||||
return obj;
|
||||
}
|
||||
if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
|
||||
return {default: obj};
|
||||
}
|
||||
var cache = _getRequireWildcardCache();
|
||||
if (cache && cache.has(obj)) {
|
||||
return cache.get(obj);
|
||||
}
|
||||
var newObj = {};
|
||||
var hasPropertyDescriptor =
|
||||
Object.defineProperty && Object.getOwnPropertyDescriptor;
|
||||
for (var key in obj) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var desc = hasPropertyDescriptor
|
||||
? Object.getOwnPropertyDescriptor(obj, key)
|
||||
: null;
|
||||
if (desc && (desc.get || desc.set)) {
|
||||
Object.defineProperty(newObj, key, desc);
|
||||
} else {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
newObj.default = obj;
|
||||
if (cache) {
|
||||
cache.set(obj, newObj);
|
||||
}
|
||||
return newObj;
|
||||
}
|
||||
|
||||
function ownKeys(object, enumerableOnly) {
|
||||
var keys = Object.keys(object);
|
||||
if (Object.getOwnPropertySymbols) {
|
||||
var symbols = Object.getOwnPropertySymbols(object);
|
||||
if (enumerableOnly)
|
||||
symbols = symbols.filter(function(sym) {
|
||||
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
||||
});
|
||||
keys.push.apply(keys, symbols);
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
||||
function _objectSpread(target) {
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var source = arguments[i] != null ? arguments[i] : {};
|
||||
if (i % 2) {
|
||||
ownKeys(Object(source), true).forEach(function(key) {
|
||||
_defineProperty(target, key, source[key]);
|
||||
});
|
||||
} else if (Object.getOwnPropertyDescriptors) {
|
||||
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
||||
} else {
|
||||
ownKeys(Object(source)).forEach(function(key) {
|
||||
Object.defineProperty(
|
||||
target,
|
||||
key,
|
||||
Object.getOwnPropertyDescriptor(source, key)
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
function _defineProperty(obj, key, value) {
|
||||
if (key in obj) {
|
||||
Object.defineProperty(obj, key, {
|
||||
value: value,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
} else {
|
||||
obj[key] = value;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
class ExperimentalWorker {
|
||||
constructor(options) {
|
||||
_defineProperty(this, '_worker', void 0);
|
||||
|
||||
_defineProperty(this, '_options', void 0);
|
||||
|
||||
_defineProperty(this, '_request', void 0);
|
||||
|
||||
_defineProperty(this, '_retries', void 0);
|
||||
|
||||
_defineProperty(this, '_onProcessEnd', void 0);
|
||||
|
||||
_defineProperty(this, '_fakeStream', void 0);
|
||||
|
||||
_defineProperty(this, '_stdout', void 0);
|
||||
|
||||
_defineProperty(this, '_stderr', void 0);
|
||||
|
||||
_defineProperty(this, '_exitPromise', void 0);
|
||||
|
||||
_defineProperty(this, '_resolveExitPromise', void 0);
|
||||
|
||||
_defineProperty(this, '_forceExited', void 0);
|
||||
|
||||
this._options = options;
|
||||
this._request = null;
|
||||
this._fakeStream = null;
|
||||
this._stdout = null;
|
||||
this._stderr = null;
|
||||
this._exitPromise = new Promise(resolve => {
|
||||
this._resolveExitPromise = resolve;
|
||||
});
|
||||
this._forceExited = false;
|
||||
this.initialize();
|
||||
}
|
||||
|
||||
initialize() {
|
||||
this._worker = new (_worker_threads().Worker)(
|
||||
path().resolve(__dirname, './threadChild.js'),
|
||||
{
|
||||
eval: false,
|
||||
stderr: true,
|
||||
stdout: true,
|
||||
workerData: _objectSpread(
|
||||
{
|
||||
cwd: process.cwd(),
|
||||
env: _objectSpread({}, process.env, {
|
||||
JEST_WORKER_ID: String(this._options.workerId + 1) // 0-indexed workerId, 1-indexed JEST_WORKER_ID
|
||||
}),
|
||||
// Suppress --debug / --inspect flags while preserving others (like --harmony).
|
||||
execArgv: process.execArgv.filter(
|
||||
v => !/^--(debug|inspect)/.test(v)
|
||||
),
|
||||
silent: true
|
||||
},
|
||||
this._options.forkOptions
|
||||
)
|
||||
}
|
||||
);
|
||||
|
||||
if (this._worker.stdout) {
|
||||
if (!this._stdout) {
|
||||
// We need to add a permanent stream to the merged stream to prevent it
|
||||
// from ending when the subprocess stream ends
|
||||
this._stdout = (0, _mergeStream().default)(this._getFakeStream());
|
||||
}
|
||||
|
||||
this._stdout.add(this._worker.stdout);
|
||||
}
|
||||
|
||||
if (this._worker.stderr) {
|
||||
if (!this._stderr) {
|
||||
// We need to add a permanent stream to the merged stream to prevent it
|
||||
// from ending when the subprocess stream ends
|
||||
this._stderr = (0, _mergeStream().default)(this._getFakeStream());
|
||||
}
|
||||
|
||||
this._stderr.add(this._worker.stderr);
|
||||
}
|
||||
|
||||
this._worker.on('message', this._onMessage.bind(this));
|
||||
|
||||
this._worker.on('exit', this._onExit.bind(this));
|
||||
|
||||
this._worker.postMessage([
|
||||
_types().CHILD_MESSAGE_INITIALIZE,
|
||||
false,
|
||||
this._options.workerPath,
|
||||
this._options.setupArgs
|
||||
]);
|
||||
|
||||
this._retries++; // If we exceeded the amount of retries, we will emulate an error reply
|
||||
// coming from the child. This avoids code duplication related with cleaning
|
||||
// the queue, and scheduling the next call.
|
||||
|
||||
if (this._retries > this._options.maxRetries) {
|
||||
const error = new Error('Call retries were exceeded');
|
||||
|
||||
this._onMessage([
|
||||
_types().PARENT_MESSAGE_CLIENT_ERROR,
|
||||
error.name,
|
||||
error.message,
|
||||
error.stack,
|
||||
{
|
||||
type: 'WorkerError'
|
||||
}
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
_shutdown() {
|
||||
// End the permanent stream so the merged stream end too
|
||||
if (this._fakeStream) {
|
||||
this._fakeStream.end();
|
||||
|
||||
this._fakeStream = null;
|
||||
}
|
||||
|
||||
this._resolveExitPromise();
|
||||
}
|
||||
|
||||
_onMessage(response) {
|
||||
let error;
|
||||
|
||||
switch (response[0]) {
|
||||
case _types().PARENT_MESSAGE_OK:
|
||||
this._onProcessEnd(null, response[1]);
|
||||
|
||||
break;
|
||||
|
||||
case _types().PARENT_MESSAGE_CLIENT_ERROR:
|
||||
error = response[4];
|
||||
|
||||
if (error != null && typeof error === 'object') {
|
||||
const extra = error; // @ts-ignore: no index
|
||||
|
||||
const NativeCtor = global[response[1]];
|
||||
const Ctor = typeof NativeCtor === 'function' ? NativeCtor : Error;
|
||||
error = new Ctor(response[2]);
|
||||
error.type = response[1];
|
||||
error.stack = response[3];
|
||||
|
||||
for (const key in extra) {
|
||||
// @ts-ignore: no index
|
||||
error[key] = extra[key];
|
||||
}
|
||||
}
|
||||
|
||||
this._onProcessEnd(error, null);
|
||||
|
||||
break;
|
||||
|
||||
case _types().PARENT_MESSAGE_SETUP_ERROR:
|
||||
error = new Error('Error when calling setup: ' + response[2]); // @ts-ignore: adding custom properties to errors.
|
||||
|
||||
error.type = response[1];
|
||||
error.stack = response[3];
|
||||
|
||||
this._onProcessEnd(error, null);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new TypeError('Unexpected response from worker: ' + response[0]);
|
||||
}
|
||||
}
|
||||
|
||||
_onExit(exitCode) {
|
||||
if (exitCode !== 0 && !this._forceExited) {
|
||||
this.initialize();
|
||||
|
||||
if (this._request) {
|
||||
this._worker.postMessage(this._request);
|
||||
}
|
||||
} else {
|
||||
this._shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
waitForExit() {
|
||||
return this._exitPromise;
|
||||
}
|
||||
|
||||
forceExit() {
|
||||
this._forceExited = true;
|
||||
|
||||
this._worker.terminate();
|
||||
}
|
||||
|
||||
send(request, onProcessStart, onProcessEnd) {
|
||||
onProcessStart(this);
|
||||
|
||||
this._onProcessEnd = (...args) => {
|
||||
// Clean the request to avoid sending past requests to workers that fail
|
||||
// while waiting for a new request (timers, unhandled rejections...)
|
||||
this._request = null;
|
||||
return onProcessEnd(...args);
|
||||
};
|
||||
|
||||
this._request = request;
|
||||
this._retries = 0;
|
||||
|
||||
this._worker.postMessage(request);
|
||||
}
|
||||
|
||||
getWorkerId() {
|
||||
return this._options.workerId;
|
||||
}
|
||||
|
||||
getStdout() {
|
||||
return this._stdout;
|
||||
}
|
||||
|
||||
getStderr() {
|
||||
return this._stderr;
|
||||
}
|
||||
|
||||
_getFakeStream() {
|
||||
if (!this._fakeStream) {
|
||||
this._fakeStream = new (_stream().PassThrough)();
|
||||
}
|
||||
|
||||
return this._fakeStream;
|
||||
}
|
||||
}
|
||||
|
||||
exports.default = ExperimentalWorker;
|
||||
8
node_modules/jest-worker/build/workers/processChild.d.ts
generated
vendored
Normal file
8
node_modules/jest-worker/build/workers/processChild.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
export {};
|
||||
//# sourceMappingURL=processChild.d.ts.map
|
||||
1
node_modules/jest-worker/build/workers/processChild.d.ts.map
generated
vendored
Normal file
1
node_modules/jest-worker/build/workers/processChild.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"processChild.d.ts","sourceRoot":"","sources":["../../src/workers/processChild.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
||||
194
node_modules/jest-worker/build/workers/processChild.js
generated
vendored
Normal file
194
node_modules/jest-worker/build/workers/processChild.js
generated
vendored
Normal file
@@ -0,0 +1,194 @@
|
||||
'use strict';
|
||||
|
||||
function _types() {
|
||||
const data = require('../types');
|
||||
|
||||
_types = function() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function ownKeys(object, enumerableOnly) {
|
||||
var keys = Object.keys(object);
|
||||
if (Object.getOwnPropertySymbols) {
|
||||
var symbols = Object.getOwnPropertySymbols(object);
|
||||
if (enumerableOnly)
|
||||
symbols = symbols.filter(function(sym) {
|
||||
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
||||
});
|
||||
keys.push.apply(keys, symbols);
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
||||
function _objectSpread(target) {
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var source = arguments[i] != null ? arguments[i] : {};
|
||||
if (i % 2) {
|
||||
ownKeys(Object(source), true).forEach(function(key) {
|
||||
_defineProperty(target, key, source[key]);
|
||||
});
|
||||
} else if (Object.getOwnPropertyDescriptors) {
|
||||
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
||||
} else {
|
||||
ownKeys(Object(source)).forEach(function(key) {
|
||||
Object.defineProperty(
|
||||
target,
|
||||
key,
|
||||
Object.getOwnPropertyDescriptor(source, key)
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
function _defineProperty(obj, key, value) {
|
||||
if (key in obj) {
|
||||
Object.defineProperty(obj, key, {
|
||||
value: value,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
} else {
|
||||
obj[key] = value;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
let file = null;
|
||||
let setupArgs = [];
|
||||
let initialized = false;
|
||||
/**
|
||||
* This file is a small bootstrapper for workers. It sets up the communication
|
||||
* between the worker and the parent process, interpreting parent messages and
|
||||
* sending results back.
|
||||
*
|
||||
* The file loaded will be lazily initialized the first time any of the workers
|
||||
* is called. This is done for optimal performance: if the farm is initialized,
|
||||
* but no call is made to it, child Node processes will be consuming the least
|
||||
* possible amount of memory.
|
||||
*
|
||||
* If an invalid message is detected, the child will exit (by throwing) with a
|
||||
* non-zero exit code.
|
||||
*/
|
||||
|
||||
const messageListener = request => {
|
||||
switch (request[0]) {
|
||||
case _types().CHILD_MESSAGE_INITIALIZE:
|
||||
const init = request;
|
||||
file = init[2];
|
||||
setupArgs = request[3];
|
||||
break;
|
||||
|
||||
case _types().CHILD_MESSAGE_CALL:
|
||||
const call = request;
|
||||
execMethod(call[2], call[3]);
|
||||
break;
|
||||
|
||||
case _types().CHILD_MESSAGE_END:
|
||||
end();
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new TypeError(
|
||||
'Unexpected request from parent process: ' + request[0]
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
process.on('message', messageListener);
|
||||
|
||||
function reportSuccess(result) {
|
||||
if (!process || !process.send) {
|
||||
throw new Error('Child can only be used on a forked process');
|
||||
}
|
||||
|
||||
process.send([_types().PARENT_MESSAGE_OK, result]);
|
||||
}
|
||||
|
||||
function reportClientError(error) {
|
||||
return reportError(error, _types().PARENT_MESSAGE_CLIENT_ERROR);
|
||||
}
|
||||
|
||||
function reportInitializeError(error) {
|
||||
return reportError(error, _types().PARENT_MESSAGE_SETUP_ERROR);
|
||||
}
|
||||
|
||||
function reportError(error, type) {
|
||||
if (!process || !process.send) {
|
||||
throw new Error('Child can only be used on a forked process');
|
||||
}
|
||||
|
||||
if (error == null) {
|
||||
error = new Error('"null" or "undefined" thrown');
|
||||
}
|
||||
|
||||
process.send([
|
||||
type,
|
||||
error.constructor && error.constructor.name,
|
||||
error.message,
|
||||
error.stack,
|
||||
typeof error === 'object' ? _objectSpread({}, error) : error
|
||||
]);
|
||||
}
|
||||
|
||||
function end() {
|
||||
const main = require(file);
|
||||
|
||||
if (!main.teardown) {
|
||||
exitProcess();
|
||||
return;
|
||||
}
|
||||
|
||||
execFunction(main.teardown, main, [], exitProcess, exitProcess);
|
||||
}
|
||||
|
||||
function exitProcess() {
|
||||
// Clean up open handles so the process ideally exits gracefully
|
||||
process.removeListener('message', messageListener);
|
||||
}
|
||||
|
||||
function execMethod(method, args) {
|
||||
const main = require(file);
|
||||
|
||||
let fn;
|
||||
|
||||
if (method === 'default') {
|
||||
fn = main.__esModule ? main['default'] : main;
|
||||
} else {
|
||||
fn = main[method];
|
||||
}
|
||||
|
||||
function execHelper() {
|
||||
execFunction(fn, main, args, reportSuccess, reportClientError);
|
||||
}
|
||||
|
||||
if (initialized || !main.setup) {
|
||||
execHelper();
|
||||
return;
|
||||
}
|
||||
|
||||
initialized = true;
|
||||
execFunction(main.setup, main, setupArgs, execHelper, reportInitializeError);
|
||||
}
|
||||
|
||||
function execFunction(fn, ctx, args, onResult, onError) {
|
||||
let result;
|
||||
|
||||
try {
|
||||
result = fn.apply(ctx, args);
|
||||
} catch (err) {
|
||||
onError(err);
|
||||
return;
|
||||
}
|
||||
|
||||
if (result && typeof result.then === 'function') {
|
||||
result.then(onResult, onError);
|
||||
} else {
|
||||
onResult(result);
|
||||
}
|
||||
}
|
||||
8
node_modules/jest-worker/build/workers/threadChild.d.ts
generated
vendored
Normal file
8
node_modules/jest-worker/build/workers/threadChild.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
export {};
|
||||
//# sourceMappingURL=threadChild.d.ts.map
|
||||
1
node_modules/jest-worker/build/workers/threadChild.d.ts.map
generated
vendored
Normal file
1
node_modules/jest-worker/build/workers/threadChild.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"threadChild.d.ts","sourceRoot":"","sources":["../../src/workers/threadChild.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
||||
207
node_modules/jest-worker/build/workers/threadChild.js
generated
vendored
Normal file
207
node_modules/jest-worker/build/workers/threadChild.js
generated
vendored
Normal file
@@ -0,0 +1,207 @@
|
||||
'use strict';
|
||||
|
||||
function _worker_threads() {
|
||||
const data = require('worker_threads');
|
||||
|
||||
_worker_threads = function() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _types() {
|
||||
const data = require('../types');
|
||||
|
||||
_types = function() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function ownKeys(object, enumerableOnly) {
|
||||
var keys = Object.keys(object);
|
||||
if (Object.getOwnPropertySymbols) {
|
||||
var symbols = Object.getOwnPropertySymbols(object);
|
||||
if (enumerableOnly)
|
||||
symbols = symbols.filter(function(sym) {
|
||||
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
||||
});
|
||||
keys.push.apply(keys, symbols);
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
||||
function _objectSpread(target) {
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var source = arguments[i] != null ? arguments[i] : {};
|
||||
if (i % 2) {
|
||||
ownKeys(Object(source), true).forEach(function(key) {
|
||||
_defineProperty(target, key, source[key]);
|
||||
});
|
||||
} else if (Object.getOwnPropertyDescriptors) {
|
||||
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
||||
} else {
|
||||
ownKeys(Object(source)).forEach(function(key) {
|
||||
Object.defineProperty(
|
||||
target,
|
||||
key,
|
||||
Object.getOwnPropertyDescriptor(source, key)
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
function _defineProperty(obj, key, value) {
|
||||
if (key in obj) {
|
||||
Object.defineProperty(obj, key, {
|
||||
value: value,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
} else {
|
||||
obj[key] = value;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
let file = null;
|
||||
let setupArgs = [];
|
||||
let initialized = false;
|
||||
/**
|
||||
* This file is a small bootstrapper for workers. It sets up the communication
|
||||
* between the worker and the parent process, interpreting parent messages and
|
||||
* sending results back.
|
||||
*
|
||||
* The file loaded will be lazily initialized the first time any of the workers
|
||||
* is called. This is done for optimal performance: if the farm is initialized,
|
||||
* but no call is made to it, child Node processes will be consuming the least
|
||||
* possible amount of memory.
|
||||
*
|
||||
* If an invalid message is detected, the child will exit (by throwing) with a
|
||||
* non-zero exit code.
|
||||
*/
|
||||
|
||||
const messageListener = request => {
|
||||
switch (request[0]) {
|
||||
case _types().CHILD_MESSAGE_INITIALIZE:
|
||||
const init = request;
|
||||
file = init[2];
|
||||
setupArgs = request[3];
|
||||
break;
|
||||
|
||||
case _types().CHILD_MESSAGE_CALL:
|
||||
const call = request;
|
||||
execMethod(call[2], call[3]);
|
||||
break;
|
||||
|
||||
case _types().CHILD_MESSAGE_END:
|
||||
end();
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new TypeError(
|
||||
'Unexpected request from parent process: ' + request[0]
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
_worker_threads().parentPort.on('message', messageListener);
|
||||
|
||||
function reportSuccess(result) {
|
||||
if (_worker_threads().isMainThread) {
|
||||
throw new Error('Child can only be used on a forked process');
|
||||
}
|
||||
|
||||
_worker_threads().parentPort.postMessage([
|
||||
_types().PARENT_MESSAGE_OK,
|
||||
result
|
||||
]);
|
||||
}
|
||||
|
||||
function reportClientError(error) {
|
||||
return reportError(error, _types().PARENT_MESSAGE_CLIENT_ERROR);
|
||||
}
|
||||
|
||||
function reportInitializeError(error) {
|
||||
return reportError(error, _types().PARENT_MESSAGE_SETUP_ERROR);
|
||||
}
|
||||
|
||||
function reportError(error, type) {
|
||||
if (_worker_threads().isMainThread) {
|
||||
throw new Error('Child can only be used on a forked process');
|
||||
}
|
||||
|
||||
if (error == null) {
|
||||
error = new Error('"null" or "undefined" thrown');
|
||||
}
|
||||
|
||||
_worker_threads().parentPort.postMessage([
|
||||
type,
|
||||
error.constructor && error.constructor.name,
|
||||
error.message,
|
||||
error.stack,
|
||||
typeof error === 'object' ? _objectSpread({}, error) : error
|
||||
]);
|
||||
}
|
||||
|
||||
function end() {
|
||||
const main = require(file);
|
||||
|
||||
if (!main.teardown) {
|
||||
exitProcess();
|
||||
return;
|
||||
}
|
||||
|
||||
execFunction(main.teardown, main, [], exitProcess, exitProcess);
|
||||
}
|
||||
|
||||
function exitProcess() {
|
||||
// Clean up open handles so the worker ideally exits gracefully
|
||||
_worker_threads().parentPort.removeListener('message', messageListener);
|
||||
}
|
||||
|
||||
function execMethod(method, args) {
|
||||
const main = require(file);
|
||||
|
||||
let fn;
|
||||
|
||||
if (method === 'default') {
|
||||
fn = main.__esModule ? main['default'] : main;
|
||||
} else {
|
||||
fn = main[method];
|
||||
}
|
||||
|
||||
function execHelper() {
|
||||
execFunction(fn, main, args, reportSuccess, reportClientError);
|
||||
}
|
||||
|
||||
if (initialized || !main.setup) {
|
||||
execHelper();
|
||||
return;
|
||||
}
|
||||
|
||||
initialized = true;
|
||||
execFunction(main.setup, main, setupArgs, execHelper, reportInitializeError);
|
||||
}
|
||||
|
||||
function execFunction(fn, ctx, args, onResult, onError) {
|
||||
let result;
|
||||
|
||||
try {
|
||||
result = fn.apply(ctx, args);
|
||||
} catch (err) {
|
||||
onError(err);
|
||||
return;
|
||||
}
|
||||
|
||||
if (result && typeof result.then === 'function') {
|
||||
result.then(onResult, onError);
|
||||
} else {
|
||||
onResult(result);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user